@databrainhq/plugin 0.11.15 → 0.11.16

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.
@@ -4898,13 +4898,15 @@ const Gt = (r, t, e) => async () => {
4898
4898
  const t = !!(document.querySelector("dbn-dashboard") || document.querySelector("dbn-metric"));
4899
4899
  if (!r) {
4900
4900
  if (t) {
4901
- const d = document.querySelector("dbn-dashboard");
4902
- if (d && d.shadowRoot) {
4903
- const g = document.querySelector(
4904
- "#dbn-dashboard-admin-styles"
4905
- );
4906
- g && d.shadowRoot.removeChild(g);
4907
- }
4901
+ const d = document.querySelectorAll("dbn-dashboard");
4902
+ d.length && d.forEach((g, m) => {
4903
+ if (g && g.shadowRoot) {
4904
+ const y = document.querySelector(
4905
+ `#dbn-dashboard-${m}-admin-styles`
4906
+ );
4907
+ y && g.shadowRoot.removeChild(y);
4908
+ }
4909
+ });
4908
4910
  const p = document.querySelectorAll("dbn-metric");
4909
4911
  p.length && p.forEach((g, m) => {
4910
4912
  const y = document.querySelector(
@@ -4960,18 +4962,23 @@ const Gt = (r, t, e) => async () => {
4960
4962
  .dbn-metric-card-description {
4961
4963
  color: ${r.cardDescription.color} !important;
4962
4964
  }`), t) {
4963
- const d = document.querySelector("dbn-dashboard");
4964
- if (d && d.shadowRoot) {
4965
- const g = document.querySelector(
4966
- "#dbn-dashboard-admin-styles"
4967
- );
4968
- if (g)
4969
- g.innerHTML = e;
4970
- else {
4971
- const m = document.createElement("style");
4972
- m.setAttribute("id", "dbn-dashboard-admin-styles"), m.innerHTML = e, d.shadowRoot.appendChild(m);
4965
+ const d = document.querySelectorAll("dbn-dashboard");
4966
+ d.length && d.forEach((g, m) => {
4967
+ if (g && g.shadowRoot) {
4968
+ const y = document.querySelector(
4969
+ `#dbn-dashboard-${m}-admin-styles`
4970
+ );
4971
+ if (y)
4972
+ y.innerHTML = e;
4973
+ else {
4974
+ const b = document.createElement("style");
4975
+ b.setAttribute(
4976
+ "id",
4977
+ `dbn-dashboard-${m}-admin-styles`
4978
+ ), b.innerHTML = e, g.shadowRoot.appendChild(b);
4979
+ }
4973
4980
  }
4974
- }
4981
+ });
4975
4982
  const p = document.querySelectorAll("dbn-metric");
4976
4983
  p.length && p.forEach((g, m) => {
4977
4984
  if (g.shadowRoot) {
@@ -59112,12 +59119,13 @@ const fxe = async () => {
59112
59119
  }), pW = ({ children: r, theme: t }) => (ke(() => {
59113
59120
  !t || !Object.keys(t).length || Y1e(t);
59114
59121
  }, [t]), ke(() => {
59115
- const e = document.querySelector("#dbn-styles"), n = document.querySelector("dbn-dashboard"), i = document.querySelectorAll("dbn-metric");
59116
- if (n != null && n.shadowRoot && e && !n.shadowRoot.getElementById("dbn-dashboard-style")) {
59117
- const a = document.createElement("style");
59118
- a.innerHTML = e.innerHTML, a.setAttribute("id", "dbn-dashboard-style"), n.shadowRoot.appendChild(a);
59119
- }
59120
- i.forEach((a, o) => {
59122
+ const e = document.querySelector("#dbn-styles"), n = document.querySelectorAll("dbn-dashboard"), i = document.querySelectorAll("dbn-metric");
59123
+ n.forEach((a, o) => {
59124
+ if (a != null && a.shadowRoot && e && !a.shadowRoot.getElementById(`dbn-dashboard-${o}-style`)) {
59125
+ const s = document.createElement("style");
59126
+ s.innerHTML = e.innerHTML, s.setAttribute("id", `dbn-dashboard-${o}-style`), a.shadowRoot.appendChild(s);
59127
+ }
59128
+ }), i.forEach((a, o) => {
59121
59129
  if (a.shadowRoot && e && !a.shadowRoot.getElementById(`dbn-metric-${o}-style`)) {
59122
59130
  const s = document.createElement("style");
59123
59131
  s.innerHTML = e.innerHTML, s.setAttribute("id", `dbn-metric-${o}-style`), a.shadowRoot.appendChild(s);
@@ -446,7 +446,7 @@ Check the top-level render call using <`+he+">.")}return le}}function Eo(K,le){{
446
446
  id
447
447
  }
448
448
  }
449
- `,QY=r=>Qr(["UpdateExternalMetric"],t=>Wt(YY,t)(),r),ZY=({token:r,dashboardId:t})=>{var x,M;const{data:e,isLoading:n}=fY({id:r},{enabled:!!r,refetchOnWindowFocus:!1}),i=e==null?void 0:e.guestTokens_by_pk,a=i!=null&&i.params?JSON.parse(i.params):{},o=t||((x=a.dashboard)==null?void 0:x.id),s=i==null?void 0:i.companyId,l=i==null?void 0:i.clientId,c=a==null?void 0:a.workspace,u=(M=a==null?void 0:a.dashboard)==null?void 0:M.isLive,h=a==null?void 0:a.rlsSettings,f=a==null?void 0:a.companyTenancyType,{data:d,isLoading:p}=eY({externalDashboardId:o,clientId:l},{enabled:!!o&&!!l,refetchOnWindowFocus:!1}),{data:v,isLoading:g}=rY({externalDashboardId:o},{enabled:!!o,refetchOnWindowFocus:!1}),m=d==null?void 0:d.externalDashboardMetrics,{data:y,isLoading:b}=pY({workspaceId:c==null?void 0:c.id},{enabled:!!(c!=null&&c.id),refetchOnWindowFocus:!1}),{data:w,isLoading:_}=wY({companyId:s},{enabled:!!s,refetchOnWindowFocus:!1}),[S,C,I,D]=P.useMemo(()=>{var O,R,z,F;const N=!!((O=y==null?void 0:y.companySubsetTables[0])!=null&&O.isAllowMetricCreation),E=!!((R=y==null?void 0:y.companySubsetTables[0])!=null&&R.isAllowMetricUpdation),L=!!((z=y==null?void 0:y.companySubsetTables[0])!=null&&z.isAllowMetricDeletion),k=!!((F=y==null?void 0:y.companySubsetTables[0])!=null&&F.isAllowChangeLayout);return[N,E,L,k]},[y==null?void 0:y.companySubsetTables[0]]),T=P.useMemo(()=>w!=null&&w.sharingSettings.length?w.sharingSettings[0].id:void 0,[w]);return{isLoading:n||p||g||b||_,data:{clientId:l,companyId:s,isLiveMode:u,externalDashboardMetrics:m,externalDashboard:v==null?void 0:v.externalDashboards[0],externalDashboardId:o,rlsSettings:h,companyTenancyType:f||"TABLE",isAllowedToCreateMetrics:S,isAllowedToDeleteMetrics:C,isAllowedToUpdateMetrics:I,isAllowedToChangeLayout:D,workspace:c,sharingSettingsId:T}}},UA=({onSuccess:r,companyIntegrationId:t,selectedColumns:e,query:n,metricQuery:i,integrationName:a,outputColumns:o,chartSettings:s,clientId:l,companyId:c,isLiveMode:u,timeGrain:h,dashboardIds:f,isEnableGroupBy:d,groupBy:p,selectedGroupBy:v,userProvidedDashboardId:g,metric:m,datasetMetricSettings:y})=>{const[b,w]=P.useState(""),_=xc(),{mutate:S,isLoading:C}=FG(),I=E=>{w(""),S({companyId:c,companyIntegrationId:t,description:E.description,inputFields:e,metricId:E.metricId,name:E.name,query:n,metricQuery:i,integrationName:a,outputColumns:o,createdBy:l||"external user",isLive:u||E.isLive,chartOptions:s,datasetMetricSettings:y,clientId:l||null,isCreatedByClient:!!l,timeGrain:h||null,externalDashboardIds:f.map(L=>({externalDashboardId:L})),isEnableGroupBy:d,groupBy:p??{},selectedGroupBy:v},{onSuccess:(L,k)=>{var O,R;if((O=L.insert_externalMetrics_one)!=null&&O.id){const z=(R=L.insert_externalMetrics_one)==null?void 0:R.id;_.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:g,clientId:l}],F=>{const W=F==null?void 0:F.externalDashboardMetrics;return W==null||W.push({externalDashboardId:f[0],externalMetricId:z,externalMetric:{...k,id:z}}),{...F,externalDashboardMetrics:W}})}},onError:()=>{w&&w("Metric Id already exists")}})},{mutateAsync:D,isLoading:T}=HY({onSuccess:E=>{var k;if(!E.insert_clientDeletedMetrics_one||!E.insert_externalMetrics_one)return;const L=(k=E.insert_externalMetrics_one)==null?void 0:k.id;_.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:g,clientId:l}],O=>{var z;const R=(z=O==null?void 0:O.externalDashboardMetrics)==null?void 0:z.filter(F=>F.externalMetricId!==(m==null?void 0:m.id));return R==null||R.push({externalDashboardId:f[0],externalMetricId:L,externalMetric:E.insert_externalMetrics_one}),{...O,externalDashboardMetrics:R}}),w(""),r()},onError:()=>{w("Something went wrong! Please try again later.")}}),{mutateAsync:x,isLoading:M}=QY({onSuccess:(E,L)=>{var k;(k=E.update_externalMetrics_by_pk)!=null&&k.id&&(_.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:g,clientId:l}],O=>{const R=O==null?void 0:O.externalDashboardMetrics,z=R==null?void 0:R.findIndex(F=>F.externalMetricId===(m==null?void 0:m.id));return z===-1?O:(R[z].externalMetric={...R[z].externalMetric,...L.set},{...O,externalDashboardMetrics:R})}),w(""),r())},onError:()=>{w("Something went wrong! Please try again later.")}}),N=P.useCallback(E=>{if(w(""),!(m!=null&&m.isCreatedByClient))D({externalMetricId:m==null?void 0:m.id,clientId:l,object:{companyId:c,companyIntegrationId:t||(m==null?void 0:m.companyIntegrationId),description:E.description,inputFields:e,metricId:E.metricId===(m==null?void 0:m.metricId)?`update_${E.metricId}_by_${l}_${Date.now()}`:E.metricId,name:E.name,query:n,metricQuery:i,datasetMetricSettings:y,integrationName:a,outputColumns:o,createdBy:l||"external user",clientId:l,isCreatedByClient:!!l,resizeAttributes:m==null?void 0:m.resizeAttributes,externalDashboardMetrics:{data:f.map(L=>({externalDashboardId:L}))},isLive:u||E.isLive,chartOptions:s}});else{const L={chartOptions:s,datasetMetricSettings:y};E.description&&(L.description=E.description),E.metricId&&(L.metricId=E.metricId),E.name&&(L.name=E.name),x({externalMetricId:m==null?void 0:m.id,set:L})}},[s,m,x,D,l,c,t,a,u,f,n,e,o,i,y]);return{createExternalMetric:I,updateExternalMetric:N,error:b,isLoading:C||T||M}},Nw=()=>{const{mutate:r,isLoading:t,error:e}=QG(),{mutate:n}=GG();return{generateDatasetMetric:r,isGeneratingDataset:t,generateError:e,fetchColumnValues:n}},xn="something went wrong, please try again",ye={line:"line",stepped:"stepped",bar:"bar",stack:"stack",histogram:"histogram",bubble:"bubble",scatter:"scatter",row:"row",area:"area",combo:"combo",pie:"pie",doughnut:"doughnut",waterfall:"waterfall",funnel:"funnel",gauge:"gauge",sankey:"sankey",singleValue:"single value",boxplot:"boxplot",table:"table",timeSeries:"time series",pivot:"pivot table"},GA="client_id_variable",Tf="INPUT_TABLE",If="OUTPUT_TABLE",YA="doughnut",QA="pie",qY="sankey",Al="general",Af="configuration",ZA={Snowflake:"Snowflake",Redshift:"Redshift",BigQuery:"BigQuery",Postges:"Postgres"},qA="{{DATABASE_NAME}}",XA="'client_id_variable'",JA="DATABASE",KA=[{value:"Sun",label:"Sun"},{value:"Mon",label:"Mon"},{value:"Tue",label:"Tue"},{value:"Wed",label:"Wed"},{value:"Thu",label:"Thu"},{value:"Fri",label:"Fri"},{value:"Sat",label:"Sat"}],XY=[{value:"Asia/Kolkata",label:"IST"},{value:"America/Los_Angeles",label:"PST"},{value:"Europe/London",label:"GMT"},{value:"Australia/Sydney",label:"AEST"},{value:"America/New_York",label:"EST"}],JY=[{value:"AM",label:"AM"},{value:"PM",label:"PM"}],KY=[{value:"1",label:"1"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6"},{value:"7",label:"7"},{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"13",label:"13"},{value:"14",label:"14"},{value:"15",label:"15"},{value:"16",label:"16"},{value:"17",label:"17"},{value:"18",label:"18"},{value:"19",label:"19"},{value:"20",label:"20"},{value:"21",label:"21"},{value:"22",label:"22"},{value:"23",label:"23"},{value:"24",label:"24"},{value:"25",label:"25"},{value:"26",label:"26"},{value:"27",label:"27"},{value:"28",label:"28"}],eQ=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"}],eN=[{label:"Original value",value:"original"},{label:"Adaptive formatting",value:"adaptive"},{label:"Percentage",value:"percent"},{label:",d (12345.432 => 12,345)",value:"d"},{label:".1s (12345.432 => 10k)",value:"1s"},{label:".3s (12345.432 => 12.3k)",value:"3s"},{label:",.1% (12345.432 => 1,234,543.2%)",value:"1%"},{label:",.2% (12345.432 => 1234543.20%)",value:"2%"},{label:",.3% (12345.432 => 1234543.200%)",value:"3%"},{label:".4r (12345.432 => 12350)",value:"4r"},{label:",.1f (12345.432 => 12,345.4)",value:"1f"},{label:",.2f (12345.432 => 12,345.43)",value:"2f"},{label:",.3f (12345.432 => 12,345.432)",value:"3f"},{label:"+, (12345.432 => +12,345.432)",value:"+"},{label:"$,.2f (12345.432 => $12,345.43)",value:"$"},{label:"Duration in ms (66000 => 1m 6s)",value:"ms1"},{label:"Duration in ms (1.40008 => 1ms 400μs 80ns)",value:"ms2"}],Nf=({onOutsideClick:r,wrapRef:t})=>{P.useEffect(()=>{const e=n=>{t.current&&(!t.current.contains("composedPath"in n?n.composedPath()[0]:n.target)||!t.current.contains(n.target))&&r()};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[t,r])},tN=r=>{P.useEffect(()=>{var n,i,a,o,s,l,c,u,h,f;const t=!!(document.querySelector("dbn-dashboard")||document.querySelector("dbn-metric"));if(!r){if(t){const d=document.querySelector("dbn-dashboard");if(d&&d.shadowRoot){const g=document.querySelector("#dbn-dashboard-admin-styles");g&&d.shadowRoot.removeChild(g)}const p=document.querySelectorAll("dbn-metric");p.length&&p.forEach((g,m)=>{const y=document.querySelector(`#dbn-metric-${m}-admin-styles`);y&&g.shadowRoot&&g.shadowRoot.removeChild(y)});const v=document.querySelector("#dbn-portal");if(v&&v.shadowRoot){const g=document.querySelector("#dbn-portal-admin-styles");g&&v.shadowRoot.removeChild(g)}}else{const d=document.querySelector("#dbn-admin-styles");d&&document.head.removeChild(d)}return}let e="";if((n=r.general.fontFamily)!=null&&n.trim()&&(e=`
449
+ `,QY=r=>Qr(["UpdateExternalMetric"],t=>Wt(YY,t)(),r),ZY=({token:r,dashboardId:t})=>{var x,M;const{data:e,isLoading:n}=fY({id:r},{enabled:!!r,refetchOnWindowFocus:!1}),i=e==null?void 0:e.guestTokens_by_pk,a=i!=null&&i.params?JSON.parse(i.params):{},o=t||((x=a.dashboard)==null?void 0:x.id),s=i==null?void 0:i.companyId,l=i==null?void 0:i.clientId,c=a==null?void 0:a.workspace,u=(M=a==null?void 0:a.dashboard)==null?void 0:M.isLive,h=a==null?void 0:a.rlsSettings,f=a==null?void 0:a.companyTenancyType,{data:d,isLoading:p}=eY({externalDashboardId:o,clientId:l},{enabled:!!o&&!!l,refetchOnWindowFocus:!1}),{data:v,isLoading:g}=rY({externalDashboardId:o},{enabled:!!o,refetchOnWindowFocus:!1}),m=d==null?void 0:d.externalDashboardMetrics,{data:y,isLoading:b}=pY({workspaceId:c==null?void 0:c.id},{enabled:!!(c!=null&&c.id),refetchOnWindowFocus:!1}),{data:w,isLoading:_}=wY({companyId:s},{enabled:!!s,refetchOnWindowFocus:!1}),[S,C,I,D]=P.useMemo(()=>{var O,R,z,F;const N=!!((O=y==null?void 0:y.companySubsetTables[0])!=null&&O.isAllowMetricCreation),E=!!((R=y==null?void 0:y.companySubsetTables[0])!=null&&R.isAllowMetricUpdation),L=!!((z=y==null?void 0:y.companySubsetTables[0])!=null&&z.isAllowMetricDeletion),k=!!((F=y==null?void 0:y.companySubsetTables[0])!=null&&F.isAllowChangeLayout);return[N,E,L,k]},[y==null?void 0:y.companySubsetTables[0]]),T=P.useMemo(()=>w!=null&&w.sharingSettings.length?w.sharingSettings[0].id:void 0,[w]);return{isLoading:n||p||g||b||_,data:{clientId:l,companyId:s,isLiveMode:u,externalDashboardMetrics:m,externalDashboard:v==null?void 0:v.externalDashboards[0],externalDashboardId:o,rlsSettings:h,companyTenancyType:f||"TABLE",isAllowedToCreateMetrics:S,isAllowedToDeleteMetrics:C,isAllowedToUpdateMetrics:I,isAllowedToChangeLayout:D,workspace:c,sharingSettingsId:T}}},UA=({onSuccess:r,companyIntegrationId:t,selectedColumns:e,query:n,metricQuery:i,integrationName:a,outputColumns:o,chartSettings:s,clientId:l,companyId:c,isLiveMode:u,timeGrain:h,dashboardIds:f,isEnableGroupBy:d,groupBy:p,selectedGroupBy:v,userProvidedDashboardId:g,metric:m,datasetMetricSettings:y})=>{const[b,w]=P.useState(""),_=xc(),{mutate:S,isLoading:C}=FG(),I=E=>{w(""),S({companyId:c,companyIntegrationId:t,description:E.description,inputFields:e,metricId:E.metricId,name:E.name,query:n,metricQuery:i,integrationName:a,outputColumns:o,createdBy:l||"external user",isLive:u||E.isLive,chartOptions:s,datasetMetricSettings:y,clientId:l||null,isCreatedByClient:!!l,timeGrain:h||null,externalDashboardIds:f.map(L=>({externalDashboardId:L})),isEnableGroupBy:d,groupBy:p??{},selectedGroupBy:v},{onSuccess:(L,k)=>{var O,R;if((O=L.insert_externalMetrics_one)!=null&&O.id){const z=(R=L.insert_externalMetrics_one)==null?void 0:R.id;_.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:g,clientId:l}],F=>{const W=F==null?void 0:F.externalDashboardMetrics;return W==null||W.push({externalDashboardId:f[0],externalMetricId:z,externalMetric:{...k,id:z}}),{...F,externalDashboardMetrics:W}})}},onError:()=>{w&&w("Metric Id already exists")}})},{mutateAsync:D,isLoading:T}=HY({onSuccess:E=>{var k;if(!E.insert_clientDeletedMetrics_one||!E.insert_externalMetrics_one)return;const L=(k=E.insert_externalMetrics_one)==null?void 0:k.id;_.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:g,clientId:l}],O=>{var z;const R=(z=O==null?void 0:O.externalDashboardMetrics)==null?void 0:z.filter(F=>F.externalMetricId!==(m==null?void 0:m.id));return R==null||R.push({externalDashboardId:f[0],externalMetricId:L,externalMetric:E.insert_externalMetrics_one}),{...O,externalDashboardMetrics:R}}),w(""),r()},onError:()=>{w("Something went wrong! Please try again later.")}}),{mutateAsync:x,isLoading:M}=QY({onSuccess:(E,L)=>{var k;(k=E.update_externalMetrics_by_pk)!=null&&k.id&&(_.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:g,clientId:l}],O=>{const R=O==null?void 0:O.externalDashboardMetrics,z=R==null?void 0:R.findIndex(F=>F.externalMetricId===(m==null?void 0:m.id));return z===-1?O:(R[z].externalMetric={...R[z].externalMetric,...L.set},{...O,externalDashboardMetrics:R})}),w(""),r())},onError:()=>{w("Something went wrong! Please try again later.")}}),N=P.useCallback(E=>{if(w(""),!(m!=null&&m.isCreatedByClient))D({externalMetricId:m==null?void 0:m.id,clientId:l,object:{companyId:c,companyIntegrationId:t||(m==null?void 0:m.companyIntegrationId),description:E.description,inputFields:e,metricId:E.metricId===(m==null?void 0:m.metricId)?`update_${E.metricId}_by_${l}_${Date.now()}`:E.metricId,name:E.name,query:n,metricQuery:i,datasetMetricSettings:y,integrationName:a,outputColumns:o,createdBy:l||"external user",clientId:l,isCreatedByClient:!!l,resizeAttributes:m==null?void 0:m.resizeAttributes,externalDashboardMetrics:{data:f.map(L=>({externalDashboardId:L}))},isLive:u||E.isLive,chartOptions:s}});else{const L={chartOptions:s,datasetMetricSettings:y};E.description&&(L.description=E.description),E.metricId&&(L.metricId=E.metricId),E.name&&(L.name=E.name),x({externalMetricId:m==null?void 0:m.id,set:L})}},[s,m,x,D,l,c,t,a,u,f,n,e,o,i,y]);return{createExternalMetric:I,updateExternalMetric:N,error:b,isLoading:C||T||M}},Nw=()=>{const{mutate:r,isLoading:t,error:e}=QG(),{mutate:n}=GG();return{generateDatasetMetric:r,isGeneratingDataset:t,generateError:e,fetchColumnValues:n}},xn="something went wrong, please try again",ye={line:"line",stepped:"stepped",bar:"bar",stack:"stack",histogram:"histogram",bubble:"bubble",scatter:"scatter",row:"row",area:"area",combo:"combo",pie:"pie",doughnut:"doughnut",waterfall:"waterfall",funnel:"funnel",gauge:"gauge",sankey:"sankey",singleValue:"single value",boxplot:"boxplot",table:"table",timeSeries:"time series",pivot:"pivot table"},GA="client_id_variable",Tf="INPUT_TABLE",If="OUTPUT_TABLE",YA="doughnut",QA="pie",qY="sankey",Al="general",Af="configuration",ZA={Snowflake:"Snowflake",Redshift:"Redshift",BigQuery:"BigQuery",Postges:"Postgres"},qA="{{DATABASE_NAME}}",XA="'client_id_variable'",JA="DATABASE",KA=[{value:"Sun",label:"Sun"},{value:"Mon",label:"Mon"},{value:"Tue",label:"Tue"},{value:"Wed",label:"Wed"},{value:"Thu",label:"Thu"},{value:"Fri",label:"Fri"},{value:"Sat",label:"Sat"}],XY=[{value:"Asia/Kolkata",label:"IST"},{value:"America/Los_Angeles",label:"PST"},{value:"Europe/London",label:"GMT"},{value:"Australia/Sydney",label:"AEST"},{value:"America/New_York",label:"EST"}],JY=[{value:"AM",label:"AM"},{value:"PM",label:"PM"}],KY=[{value:"1",label:"1"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6"},{value:"7",label:"7"},{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"13",label:"13"},{value:"14",label:"14"},{value:"15",label:"15"},{value:"16",label:"16"},{value:"17",label:"17"},{value:"18",label:"18"},{value:"19",label:"19"},{value:"20",label:"20"},{value:"21",label:"21"},{value:"22",label:"22"},{value:"23",label:"23"},{value:"24",label:"24"},{value:"25",label:"25"},{value:"26",label:"26"},{value:"27",label:"27"},{value:"28",label:"28"}],eQ=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"}],eN=[{label:"Original value",value:"original"},{label:"Adaptive formatting",value:"adaptive"},{label:"Percentage",value:"percent"},{label:",d (12345.432 => 12,345)",value:"d"},{label:".1s (12345.432 => 10k)",value:"1s"},{label:".3s (12345.432 => 12.3k)",value:"3s"},{label:",.1% (12345.432 => 1,234,543.2%)",value:"1%"},{label:",.2% (12345.432 => 1234543.20%)",value:"2%"},{label:",.3% (12345.432 => 1234543.200%)",value:"3%"},{label:".4r (12345.432 => 12350)",value:"4r"},{label:",.1f (12345.432 => 12,345.4)",value:"1f"},{label:",.2f (12345.432 => 12,345.43)",value:"2f"},{label:",.3f (12345.432 => 12,345.432)",value:"3f"},{label:"+, (12345.432 => +12,345.432)",value:"+"},{label:"$,.2f (12345.432 => $12,345.43)",value:"$"},{label:"Duration in ms (66000 => 1m 6s)",value:"ms1"},{label:"Duration in ms (1.40008 => 1ms 400μs 80ns)",value:"ms2"}],Nf=({onOutsideClick:r,wrapRef:t})=>{P.useEffect(()=>{const e=n=>{t.current&&(!t.current.contains("composedPath"in n?n.composedPath()[0]:n.target)||!t.current.contains(n.target))&&r()};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[t,r])},tN=r=>{P.useEffect(()=>{var n,i,a,o,s,l,c,u,h,f;const t=!!(document.querySelector("dbn-dashboard")||document.querySelector("dbn-metric"));if(!r){if(t){const d=document.querySelectorAll("dbn-dashboard");d.length&&d.forEach((g,m)=>{if(g&&g.shadowRoot){const y=document.querySelector(`#dbn-dashboard-${m}-admin-styles`);y&&g.shadowRoot.removeChild(y)}});const p=document.querySelectorAll("dbn-metric");p.length&&p.forEach((g,m)=>{const y=document.querySelector(`#dbn-metric-${m}-admin-styles`);y&&g.shadowRoot&&g.shadowRoot.removeChild(y)});const v=document.querySelector("#dbn-portal");if(v&&v.shadowRoot){const g=document.querySelector("#dbn-portal-admin-styles");g&&v.shadowRoot.removeChild(g)}}else{const d=document.querySelector("#dbn-admin-styles");d&&document.head.removeChild(d)}return}let e="";if((n=r.general.fontFamily)!=null&&n.trim()&&(e=`
450
450
  .dbn-metric {
451
451
  font-family: ${r.general.fontFamily} !important;
452
452
  }
@@ -479,7 +479,7 @@ Check the top-level render call using <`+he+">.")}return le}}function Eo(K,le){{
479
479
  }`),(f=r.cardDescription.color)!=null&&f.trim()&&(e=`${e}
480
480
  .dbn-metric-card-description {
481
481
  color: ${r.cardDescription.color} !important;
482
- }`),t){const d=document.querySelector("dbn-dashboard");if(d&&d.shadowRoot){const g=document.querySelector("#dbn-dashboard-admin-styles");if(g)g.innerHTML=e;else{const m=document.createElement("style");m.setAttribute("id","dbn-dashboard-admin-styles"),m.innerHTML=e,d.shadowRoot.appendChild(m)}}const p=document.querySelectorAll("dbn-metric");p.length&&p.forEach((g,m)=>{if(g.shadowRoot){const y=document.querySelector(`#dbn-metric-${m}-admin-styles`);if(y)y.innerHTML=e;else{const b=document.createElement("style");b.setAttribute("id",`dbn-metric-${m}-admin-styles`),b.innerHTML=e,g.shadowRoot.appendChild(b)}}});const v=document.querySelector("#dbn-portal");if(v&&v.shadowRoot){const g=document.querySelector("#dbn-portal-admin-styles");g&&v.shadowRoot.removeChild(g)}}else{const d=document.querySelector("#dbn-admin-styles")||document.createElement("style");d.setAttribute("id","dbn-admin-styles"),d.innerHTML=e,document.querySelector("#dbn-admin-styles")||document.head.appendChild(d)}},[r])},tQ=({externalDashboardId:r,clientId:t})=>{const e=xc(),{data:n,isLoading:i}=iY({clientId:t,externalDashboardId:r},{enabled:!!(t&&r),refetchOnWindowFocus:!1}),[a,o]=P.useMemo(()=>{var u,h;return[((u=n==null?void 0:n.clientDashboardLayout_by_pk)==null?void 0:u.layout)||[],!!((h=n==null?void 0:n.clientDashboardLayout_by_pk)!=null&&h.isLocked)]},[n==null?void 0:n.clientDashboardLayout_by_pk]),{mutateAsync:s,isLoading:l}=FY({onSuccess:u=>{if(!u.insert_clientDashboardLayout_one)return;const h=u.insert_clientDashboardLayout_one;e.setQueryData(["GetExternalDashboardLayout",{clientId:t,externalDashboardId:r}],f=>({...f,clientDashboardLayout_by_pk:h}))}});return{saveLayout:P.useCallback(async(u,h)=>{await s({clientId:t,externalDashboardId:r,layout:u,isLocked:!!h})},[s,t,r]),layout:a,isLayoutLocked:o,isLoadingLayout:i||l}},rQ=[{value:"=",label:"Equal to (=)"},{value:"<>",label:"Not equal to (!=)"},{value:"<",label:"Less than (<)"},{value:"<=",label:"Less or equal (<=)"},{value:">",label:"Greater than (>)"},{value:">=",label:"Greater or equal (>=)"},{value:"IN",label:"In"},{value:"NOT IN",label:"Not in"},{value:"LIKE (case sensitive)",label:"Like (case sensitive)"},{value:"REGEX",label:"Regex"},{value:"IS NOT NULL",label:"Is not null"},{value:"IS NULL",label:"Is null"}],nQ=[{value:"100",label:"100"},{value:"500",label:"500"},{value:"1000",label:"1000"},{value:"2000",label:"2000"},{value:"5000",label:"5000"}],rN=[{value:"AVG",label:"AVG"},{value:"SUM",label:"SUM"},{value:"COUNT",label:"COUNT"},{value:"COUNT_DISTINCT",label:"COUNT_DISTINCT"},{value:"MAX",label:"MAX"},{value:"MIN",label:"MIN"}],Ew=[{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"75",value:"75"},{label:"100",value:"100"},{label:"250",value:"250"},{label:"500",value:"500"},{label:"1k",value:"1000"},{label:"2k",value:"2000"},{label:"5k",value:"5000"}],iQ=["fixed","real","int","bigint","float","number","integer","int64","float64","double precision","smallint"],aQ=["varchar","text","char","text","character(36)","string"],nN=["timestamp_ltz","date","timestamp","timestamp without time zone","timestamp with time zone","datetime"],oQ=["array","text[]"],sQ=["boolean","bool"],iN=["saved","simple","custom"],Jn={chartType:"line",xAxis:"",yAxisList:[],singleValue:"",sankeyValues:[],metricFilterPosition:"top-left",step:"",measure:"",margins:{marginTop:20,marginBottom:20,marginLeft:5,marginRight:5},labelSettings:{axis:"left",show:!1,position:"hidden",truncateLabelValue:14},legendSettings:{show:!0,top:0,left:0,right:0,bottom:0,position:"horizontal",truncateLegendValue:14},customSettings:{hideSplitLines:"none",hideAxisLines:"none",barWidth:40,barRadius:0,axisLabels:"none",fontSize:14,subHeaderShow:!1,displayText:"",subHeaderFontSize:0,dateFormatter:"none",numberFormatter:"original",xRotation:50,showLabelValues:!1,comparisonTimePeriod:0,comparisonTimeColumn:"",comparisonValueShow:!1,comparisonValueFontSize:12,comparisonSuffix:"",isShowTrendLine:!1},tableSettings:{contentAlignment:"center",lineGap:"small",hideVerticalDivider:!1,enableStripedRows:!1,showRowHover:!1,showTableTitle:!1,showTableDesc:!1,enableTableSearch:!0,enableFilter:!0,enableSorting:!0,defaultRowSize:"10",isServerSidePagination:!1,conditionalFormatting:[]},pivotTableSettings:{rows:[],columns:[]},axisSettings:{axis:"left"},backGroundColor:{show:!1},timeSeriesSettings:{groupBySettings:{isDynamic:!1,options:[],value:"monthly"},seriesType:[]},isDynamicSeries:!1,isMultiDimension:!1,seriesField:"ungrouped",seriesOptions:["ungrouped"]},ng=[{value:"isEqualTo",label:"is equal to"},{value:"isNotEqualTo",label:"is not equal to"},{value:"isNull",label:"is null"},{value:"isNotNull",label:"is not null"},{value:"contains",label:"contains"},{value:"doesNotContain",label:"not contain"},{value:"startsWith",label:"starts with"},{value:"endsWith",label:"ends with"},{value:"isLessThan",label:"is less than"},{value:"isGreaterThan",label:"is greater than"},{value:"isLessThanOrEqualTo",label:"is less than equal to"},{value:"isGreaterThanOrEqualTo",label:"is greater than equal to"}],lQ=(r,t)=>{let e=r.replace(/;([^;]*)$/,"");const n=parseInt(t,10);if(e.toLowerCase().includes("limit")){const i=parseInt(e.toLowerCase().split("limit")[1].trim(),10),a=Math.min(i,n);e=e.replace(`limit ${i}`,`limit ${a}`),e=e.replace(`LIMIT ${i}`,`LIMIT ${a}`)}else e+=` limit ${n}`;return e},uQ=({limit:r,query:t,clientName:e,tenancyType:n,values:i})=>{const a=lQ(t,r),o=e?n===JA?a.replace(new RegExp(qA,"g"),e):Number(e)?a.replace(new RegExp(XA,"g"),e):a.replace(new RegExp(GA,"g"),e):a;return i?o.replace(/[^']+_variable/g,l=>`${i[l]}`):o},cQ=({clientName:r,tenancyType:t,values:e,query:n,companyId:i,workspaceId:a,metricId:o})=>{const{mutate:s}=MY();return{getUnderlyingData:({columnName:c,value:u,setData:h,setLoading:f,isSingleValueChart:d})=>{const p=uQ({query:n,limit:"5000",clientName:r,tenancyType:t,values:e});h([]),f(!0),s({columnName:d?void 0:c,companyId:i,query:p,value:d||u==null?void 0:u.replace(/'/g,"''"),workspaceId:a,metricId:o},{onSuccess(v){var m;const g=(m=v.getUnderlyingData)==null?void 0:m.data;g&&Array.isArray(g)&&g.length?(h(g),f(!1)):(h([]),f(!1))},onError(){h([]),f(!1)}})}}},aN=()=>{const{mutate:r}=cY();return{getGroupByColumnList:({query:e,databaseName:n,onSuccess:i})=>{r({databaseName:n,query:e},{onSuccess({groupbyColumnList:a}){const o=a==null?void 0:a.groupbyColumnList;Array.isArray(o)&&o.length?i(o):i([])},onError(){i([])}})}}},hQ=({range:r,count:t,time:e,from:n,to:i})=>{const a=new Date;new Date(a).setDate(a.getDate()-1);const s=a.getMonth(),l=a.getFullYear();let c,u;if(r==="This"){switch(e){case"Year":c=new Date(l,0,1),u=new Date(a);break;case"Month":c=new Date(l,s,1),u=new Date(a);break;case"Week":{const h=a.getDate()-a.getDay();c=new Date(a.setDate(h)),u=new Date(a.setDate(h+6));break}case"Day":c=new Date(a),u=new Date(a);break;default:c=new Date(0),u=new Date(a)}return{startDate:c,endDate:u}}if(r==="Last"){switch(e){case"Year":{let h,f;t===1?(h=t,f=l-1):(h=t-1,f=l),c=new Date(l-h,0,1),u=new Date(f,11,31);break}case"Month":{const h=t===1?s-1:s-t+1;c=new Date(l,h,1),u=new Date(l,s,t===1?0:31);break}case"Week":{const h=new Date(a.setDate(a.getDate()-(a.getDay()+1)%7)),f=new Date(h.getFullYear(),h.getMonth(),h.getDate()-6),d=t-1;c=new Date(f.setDate(f.getDate()-7*d)),u=new Date(h.setDate(h.getDate()-7*(d-1))),d===0&&(u=new Date(a));break}case"Day":c=new Date(a),c.setDate(a.getDate()-t),u=new Date(a);break;default:c=new Date(0),u=new Date(a)}return{startDate:c,endDate:u}}return{startDate:n||new Date(0),endDate:i||new Date(a)}},fQ=({data:r,format:t,measureColumn:e,timeColumn:n,dimensionColumn:i,startDate:a})=>r.reduce((s,l)=>{const c=Number(l[e]),u=new Date(l[n]);let h;switch(t){case"Week":{h=`Week ${Math.ceil((u.getDate()+a.getDay())/7)}`;break}case"Quarter":{const d=Math.ceil((u.getMonth()+1)/3),p=u.getFullYear();h=`Q${d} ${p}`;break}case"Month":{h=`${u.toLocaleString("default",{month:"long"})} ${u.getFullYear()}`;break}case"Day":{h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][u.getDay()];break}default:h=l[n]}const f=s.find(d=>d[i]===h);return f?f[e]+=c:s.push({[i]:h,[e]:c}),s},[]),dQ=({dimensionColumn:r,endDate:t,measureColumn:e,format:n,groupedDataList:i,time:a,count:o,range:s})=>{const l=new Date().getFullYear(),c=l-1;let u=[],h=[];if(o===1&&s==="This"&&(u=Array.from({length:12},(v,g)=>({[r]:`${new Date(2e3,g,1).toLocaleString("default",{month:"long"})} ${l}`,[e]:0})),h=[{[r]:`Q1 ${l}`,[e]:0},{[r]:`Q2 ${l}`,[e]:0},{[r]:`Q3 ${l}`,[e]:0},{[r]:`Q4 ${l}`,[e]:0}]),o===1&&s==="Last"&&(u=Array.from({length:12},(v,g)=>({[r]:`${new Date(2e3,g,1).toLocaleString("default",{month:"long"})} ${c}`,[e]:0})),h=[{[r]:`Q1 ${c}`,[e]:0},{[r]:`Q2 ${c}`,[e]:0},{[r]:`Q3 ${c}`,[e]:0},{[r]:`Q4 ${c}`,[e]:0}]),o>1&&s==="Last"){for(let v=l-o+1;v<=l;v++)for(let g=0;g<12;g++)u.push({[r]:`${new Date(v,g,1).toLocaleString("default",{month:"long"})} ${new Date(v,g,1).getFullYear()}`,[e]:0});for(let v=l-o;v<=l;v++)h.push({[r]:`Q1 ${v}`,[e]:0},{[r]:`Q2 ${v}`,[e]:0},{[r]:`Q3 ${v}`,[e]:0},{[r]:`Q4 ${v}`,[e]:0})}const f=Array.from({length:4},(v,g)=>({[r]:`Week ${g+1}`,[e]:0})),d=[{[r]:"Sunday",[e]:0},{[r]:"Monday",[e]:0},{[r]:"Tuesday",[e]:0},{[r]:"Wednesday",[e]:0},{[r]:"Thursday",[e]:0},{[r]:"Friday",[e]:0},{[r]:"Saturday",[e]:0}];let p=[];switch(`${s}${o>1?` ${o} `:" "}${a} By ${n}`){case"This Year By Month":case"Last Year By Month":case`Last ${o} Year By Month`:{p=u.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Year By Quarter":case"Last Year By Quarter":case`Last ${o} Year By Quarter`:{p=h.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Month By Week":case"Last Month By Week":{p=f.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Week By Day":case"Last Week By Day":{p=d.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Quarter By Month":{const g=(Math.ceil((t.getMonth()+1)/3)-1)*3,m=g+2;p=u.slice(g,m+1).map(b=>{const w=i.find(_=>_[r]===b[r]);return w||b});break}case"Last Quarter By Month":{const v=Math.ceil((t.getMonth()+1)/3),m=((v===1?4:v-1)-1)*3,y=m+2;p=u.slice(m,y+1).map(w=>{const _=i.find(S=>S[r]===w[r]);return _||w});break}case`Last ${o} Month By Month`:{p=Array.from({length:o},(v,g)=>{const m=new Date(t.getFullYear(),t.getMonth()-g,1);return{[r]:`${m.toLocaleString("default",{month:"long"})} ${m.getFullYear()}`,[e]:0}}).reverse().map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}default:p=i}return p},pQ=({data:r,dimensionColumn:t,measureColumn:e,timeColumn:n,option:i})=>{const{endDate:a,startDate:o}=hQ({range:i.range,count:i.count,from:i.startDate,to:i.endDate,time:i.time});if(i.time==="Week"&&i.count>1)return r.map(u=>({[t]:u[t],[e]:u[e]}));const s=fQ({data:r,dimensionColumn:t,format:i.format,measureColumn:e,startDate:o,timeColumn:n}),l=Object.values(s);return i.name==="Custom"?l:dQ({dimensionColumn:t,endDate:a,format:i.format,groupedDataList:l,measureColumn:e,time:i.time,count:i.count,range:i.range})},oN=({metric:r,globalFilters:t={tableName:"",filters:[]},rlsFilters:e,clientId:n,chartSettings:i,setChartSettings:a,tenancyLevel:o})=>{var G,$,U,Z,Y,q,V,X;const[s,l]=P.useState({limit:10,offset:0}),[c,u]=P.useState(0),[h,f]=P.useState(r.rlsConditions||[]),[d,p]=P.useState(!1),[v,g]=P.useState(),[m,y]=P.useState([]),[b,w]=P.useState(!0),[_,S]=P.useState([]),[C,I]=P.useState([]),[D,T]=P.useState(!1),[x,M]=P.useState([]),{data:N,isLoading:E}=PY({id:r.id,drillFilters:(G=r==null?void 0:r.drillDownSettings)!=null&&G.isEnableGroupBy?_:[],clientId:n,tenancyLevel:o,rlsConditions:x,globalFilters:t,filterValues:e==null?void 0:e.filterValues,limit:($=i==null?void 0:i.tableSettings)!=null&&$.isServerSidePagination&&(i==null?void 0:i.chartType)===ye.table?s.limit:void 0,offset:(U=i==null?void 0:i.tableSettings)!=null&&U.isServerSidePagination&&(i==null?void 0:i.chartType)===ye.table?s.offset:void 0},{refetchOnWindowFocus:!1}),L=P.useMemo(()=>{var Q,ie;return!!h.length&&((ie=(Q=h.find(te=>te.isAddOnMetrics&&te.datatype==="date"&&te.columnName===i.xAxis))==null?void 0:Q.options)==null?void 0:ie.every(te=>te.format))},[h,i]);P.useEffect(()=>{var Q;(Q=h==null?void 0:h.filter(ie=>ie.isAddOnMetrics))!=null&&Q.length?M(o==="DATABASE"?r.rlsConditions.filter(ie=>ie.isAddOnMetrics&&ie.datatype!=="date").map(ie=>{var te;return{...ie,tableName:`${n}.${ie.tableName.split(".").slice(1).join(".")}`,dimensionColumn:i.xAxis||"",measureColumn:((te=i.yAxisList)==null?void 0:te[0])||""}}):h.filter(ie=>ie.isAddOnMetrics).map(ie=>{var te;return{...ie,dimensionColumn:i.xAxis||"",measureColumn:((te=i.yAxisList)==null?void 0:te[0])||""}})):M([])},[h]);const k=P.useMemo(()=>{var Q,ie,te,re,ue;return(i==null?void 0:i.chartType)===ye.singleValue&&!!((Q=i==null?void 0:i.customSettings)!=null&&Q.comparisonValueShow)&&!!((ie=i==null?void 0:i.customSettings)!=null&&ie.comparisonTimeColumn)&&!!((te=i==null?void 0:i.customSettings)!=null&&te.comparisonTimeGrain)&&!!((re=i==null?void 0:i.customSettings)!=null&&re.comparisonTimePeriod)&&!!((ue=i==null?void 0:i.customSettings)!=null&&ue.comparisonTableName)&&!!(i!=null&&i.singleValue)},[i]);P.useEffect(()=>{var ie,te,re;const Q=(ie=N==null?void 0:N.externalMetricQuery)!=null&&ie.data?JSON.parse(N.externalMetricQuery.data):[];if((i==null?void 0:i.chartType)===ye.table&&u(((te=N==null?void 0:N.externalMetricQuery)==null?void 0:te.totalRecords)||0),L){const ue=h.find(_e=>_e.isAddOnMetrics&&_e.datatype==="date");if(ue){const _e=pQ({data:Q||[],dimensionColumn:ue.columnName,measureColumn:((re=i.yAxisList)==null?void 0:re[0])||"",option:ue.options.find(Ce=>Ce.name===ue.value),timeColumn:i.xAxis||ue.columnName});y(_e)}else y(Q??[])}else y(Q??[])},[(Z=N==null?void 0:N.externalMetricQuery)==null?void 0:Z.data,L,k]);const O=Q=>Q.includes("____")?Q.split("____")[1]:Q;P.useEffect(()=>{var Q;(Q=r==null?void 0:r.drillDownSettings)!=null&&Q.isEnableGroupBy&&m.length&&a(ie=>{var te,re,ue,_e,Ce,Ge,Xe,Ot;return{...ie,xAxis:O(((_e=(te=r==null?void 0:r.datasetMetricSettings)==null?void 0:te.selectedDimensions)==null?void 0:_e[_.length<((ue=(re=r==null?void 0:r.datasetMetricSettings)==null?void 0:re.selectedDimensions)==null?void 0:ue.length)?_.length:0])||"none"),yAxisList:(Ge=(Ce=r==null?void 0:r.datasetMetricSettings)==null?void 0:Ce.metrics)==null?void 0:Ge.map(de=>{var Me;return(Me=de==null?void 0:de.as)==null?void 0:Me.replace(/["`]+/g,"")}),chartType:((Ot=(Xe=r==null?void 0:r.datasetMetricSettings)==null?void 0:Xe.selectedDimensions)==null?void 0:Ot.length)===(_==null?void 0:_.length)?"table":r.chartOptions.chartType}})},[m,r.drillDownSettings,r==null?void 0:r.datasetMetricSettings,_]),P.useEffect(()=>{E&&w(!0),!m.length&&!E&&setTimeout(()=>{w(!1)},5e3)},[E,m]);const R=P.useCallback((Q,ie,te,re)=>{f(te?ue=>ue.map(_e=>_e.name===Q?{..._e,value:ie,options:_e.options.map(Ce=>Ce.name==="Custom"?{...Ce,...te}:Ce)}:_e):re?ue=>ue.map(_e=>_e.name===Q?{..._e,value:re.map(Ce=>Ce.value)}:_e):ue=>ue.map(_e=>_e.name===Q?{..._e,value:ie}:_e))},[]),z=P.useCallback(Q=>{L||(Q.event&&Q.event.event.preventDefault(),g(Q))},[h]),{getUnderlyingData:F}=cQ({clientName:n,tenancyType:o,values:e==null?void 0:e.filterValues,companyId:r==null?void 0:r.companyId,query:r==null?void 0:r.query,workspaceId:(Y=r==null?void 0:r.companyIntegration)==null?void 0:Y.workspaceId,metricId:r==null?void 0:r.id}),W=P.useMemo(()=>Array.isArray(m)&&m.length&&(v!=null&&v.name)?m.map(Q=>{const ie=Object.entries(Q).find(([,te])=>te===v.name);return ie==null?void 0:ie[0]}).filter(Q=>Q)[0]:"",[m,v==null?void 0:v.name]),B=P.useCallback(Q=>{const ie=Array.isArray(m)&&m.length&&(Q!=null&&Q.name)?m.map(te=>{const re=Object.entries(te).find(([,ue])=>ue===Q.name);return re==null?void 0:re[0]}).filter(te=>te)[0]:"";S(ie?te=>{var re;return((re=r==null?void 0:r.datasetMetricSettings)==null?void 0:re.selectedDimensions.length)>te.length?[...te,{columnName:ie,value:Q==null?void 0:Q.name}]:[]}:[])},[m,r==null?void 0:r.datasetMetricSettings,r==null?void 0:r.drillDownSettings]),{getGroupByColumnList:H}=aN();return P.useEffect(()=>{r.query&&H({query:r==null?void 0:r.query,databaseName:(r==null?void 0:r.integrationName)||"",onSuccess:Q=>I(Q)}),m!=null&&m.length&&C.length&&T(!0)},[m,C.length,r==null?void 0:r.integrationName,r.query]),{onDrillDown:B,handleChartClick:z,dataDb:m,getUnderlyingData:F,onChangeFilterValue:R,isShowChartPopup:d,setShowChartPopup:p,columnName:W,chartParams:v,isQueryLoading:E||b,setLoading:w,drilledLevel:_.length,dimensions:((V=(q=r==null?void 0:r.datasetMetricSettings)==null?void 0:q.selectedDimensions)==null?void 0:V.map(Q=>O(Q||"none")))||[],rlsConditions:h,setTableLimit:l,isEnableNextBtn:c>(s==null?void 0:s.limit)+(s==null?void 0:s.offset),isEnablePrevBtn:(s==null?void 0:s.offset)!==0,paginationInfo:{limit:s==null?void 0:s.limit,offset:s==null?void 0:s.offset,totalRecords:c},onChangePage:(Q,ie)=>{l(ie?{limit:ie,offset:0}:te=>({limit:te.limit,offset:Q?te.offset>te.limit?te.offset-te.limit:0:te.offset+te.limit}))},isExternalChart:((X=i==null?void 0:i.tableSettings)==null?void 0:X.isServerSidePagination)&&(i==null?void 0:i.chartType)===ye.table,isEnablePivotTable:D,groupByList:C,updateFilter:Q=>{f(ie=>ie.map(te=>te.name===Q.name&&te.datatype===Q.datatype&&te.tableName===Q.tableName&&te.columnName===Q.columnName?{...te,isAddOnMetrics:!te.isAddOnMetrics}:te))}}},vQ=({dashboardId:r,clientId:t,metricId:e,onSuccess:n})=>{const i=xc(),{mutateAsync:a,isLoading:o}=LY({onSuccess:l=>{l.insert_clientDeletedMetrics_one&&(i.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:r,clientId:t}],c=>{var h;const u=(h=c==null?void 0:c.externalDashboardMetrics)==null?void 0:h.filter(f=>f.externalMetricId!==e);return{...c,externalDashboardMetrics:u}}),n())}});return{handleArchiveMetric:P.useCallback(async()=>{!e||!t||await a({id:e,clientId:t})},[a,e,t]),isLoading:o}},gQ=({token:r,metricId:t})=>{const[e,n]=P.useState(!0),{data:i,isLoading:a}=jG({guestToken:r,metricId:t},{enabled:!!(r&&t)}),{externalMetric:o,sharingSettingsId:s,adminTheme:l,params:c,companyId:u,clientId:h,errorMsg:f}=P.useMemo(()=>{var g,m,y,b,w,_,S,C;return{externalMetric:(g=i==null?void 0:i.embeddedMetricData)==null?void 0:g.externalMetric,adminTheme:(m=i==null?void 0:i.embeddedMetricData)==null?void 0:m.adminTheme,sharingSettingsId:(y=i==null?void 0:i.embeddedMetricData)==null?void 0:y.sharingSettingsId,errorMsg:(w=(b=i==null?void 0:i.embeddedMetricData)==null?void 0:b.error)==null?void 0:w.message,params:(_=i==null?void 0:i.embeddedMetricData)==null?void 0:_.params,companyId:(S=i==null?void 0:i.embeddedMetricData)==null?void 0:S.companyId,clientId:(C=i==null?void 0:i.embeddedMetricData)==null?void 0:C.clientId}},[i==null?void 0:i.embeddedMetricData]),d=P.useMemo(()=>{var g;return l?(g=l.chart.palettes.find(m=>m.name===l.chart.selected))==null?void 0:g.colors:null},[l]),{rlsSettings:p,tenancyLevel:v}=P.useMemo(()=>{var m;if(!c)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const g=JSON.parse(c);return{rlsSettings:(m=g.rlsSettings)==null?void 0:m.find(y=>y.metricId===t),tenancyLevel:g.companyTenancyType||"TABLE"}},[c,t]);return tN(l),P.useEffect(()=>{a&&n(!0),(o||f)&&n(!1)},[a,o,f]),{externalMetric:o,sharingSettingsId:s,adminColors:d,companyId:u,clientId:h,rlsSettings:p,tenancyLevel:v,isLoading:e,errorMsg:f}},ur=({name:r,label:t,options:e=[],onChange:n,value:i,defaultValue:a,children:o,placeHolder:s,className:l="",containerClass:c="",isSearchEnabled:u,textSize:h,icon:f,labelVariant:d="static"})=>{const[p,v]=P.useState(""),[g,m]=P.useState(20),[y,b]=P.useState(!1),w=P.useRef(),_=i||a?e.find(I=>I.value===i||I.value===a):{label:s||"Select an option"},S={fontSize:h},C=P.useMemo(()=>p?e.filter(I=>I.label.toLowerCase().includes(p)).slice(0,g):e.slice(0,g),[p,e,g]);return Nf({wrapRef:w,onOutsideClick:()=>b(!1)}),A.jsxs("div",{ref:w,className:`${lt.listbox} ${c}`,children:[f,t?A.jsx("label",{className:`${lt["listBox-label"]} ${d==="floating"?lt["listBox-labelFloating"]:""}`,children:t}):null,A.jsxs("div",{className:`${lt.listboxButtonWrapper} ${l}`,children:[A.jsxs(Te,{className:`${lt["listBoxButton-container"]} ${d==="floating"?lt["listBoxButton-containerFloating"]:""}`,type:"button",variant:"custom",name:r,onClick:()=>b(I=>!I),children:[A.jsx("span",{className:lt.selectedOptionText,children:_==null?void 0:_.label}),A.jsx("span",{className:lt.listBoxButton,children:A.jsx(DA,{className:lt.arrowicon,"aria-hidden":"true"})})]}),A.jsx(Uv,{show:y,as:P.Fragment,leave:lt.leave,leaveFrom:lt.leaveFrom,leaveTo:lt.leaveTo,children:A.jsx("div",{className:lt["listBox-options"],children:A.jsxs(A.Fragment,{children:[u&&A.jsx(Gv,{className:lt.search,setSearchKeyword:v}),C.length===0?A.jsx("div",{className:lt.notAvailable,children:"Not Available."}):C.map(I=>A.jsxs(Te,{className:fr(i===I.value?lt.activeOption:lt.inactiveOption,lt.option),type:"button",variant:"custom",onClick:()=>{n==null||n(I.value),b(!1)},children:[A.jsx("span",{className:lt.optionLabel,style:S,children:I.label}),i===I.value?A.jsx("span",{className:lt.check,children:A.jsx(oG,{className:lt.checkIcon,"aria-hidden":"true"})}):null]},I.value)),g<=e.length&&A.jsxs(Te,{variant:"secondary",type:"button",onClick:()=>m(g+30),className:lt.loadMore,children:["Load More",A.jsx(tt,{name:"double-arrow-left-icon",className:lt.loadMoreIcon})]}),o]})})})]})]})},Lw=({control:r,name:t,...e})=>A.jsx(aw,{control:r,name:t,render:({field:{onChange:n,value:i}})=>A.jsx(ur,{...e,onChange:n,value:i})}),Sa=({options:r,defaultValue:t,value:e,onChange:n,label:i,name:a,className:o="",children:s,placeHolder:l,onClick:c,isSearchEnabled:u,containerClass:h="",labelVariant:f="static",icon:d})=>{const[p,v]=P.useState(""),[g,m]=P.useState(20),[y,b]=P.useState(!1),w=P.useRef(),_=P.useMemo(()=>p?r.filter(S=>S.label.toLowerCase().includes(p)).slice(0,g):r.slice(0,g),[p,r,g]);return Nf({wrapRef:w,onOutsideClick:()=>b(!1)}),P.useEffect(()=>{t&&t.length&&(n==null||n(t))},[]),A.jsx(A.Fragment,{children:A.jsxs("div",{ref:w,className:`${lt.listbox} ${h}`,children:[d,i?A.jsx("label",{className:`${lt["listBox-label"]} ${f==="floating"?lt["listBox-labelFloating"]:""}`,children:i}):null,A.jsxs("div",{className:lt.listboxButtonWrapper,children:[A.jsxs(Te,{className:`${lt["listBoxButton-container"]} ${o} ${f==="floating"?lt["listBoxButton-containerFloating"]:""}`,variant:"custom",type:"button",onClick:()=>b(S=>!S),name:a,children:[A.jsx("span",{className:lt.selectedOptionText,children:l||"Choose options from list"}),A.jsx("span",{className:lt.listBoxButton,children:A.jsx(DA,{className:lt.arrowicon,"aria-hidden":"true"})})]}),A.jsx(Uv,{show:y,as:P.Fragment,leave:lt.leave,leaveFrom:lt.leaveFrom,leaveTo:lt.leaveTo,children:A.jsxs("div",{className:lt["listBox-options"],children:[u&&A.jsx(Gv,{className:lt.search,setSearchKeyword:v}),_.length===0?A.jsx("div",{className:lt.notAvailable,children:"Not Available."}):_.map(S=>A.jsxs(Te,{className:fr(e!=null&&e.includes(S.value)?lt.optionSelected:"",lt.option),type:"button",variant:"custom",onClick:()=>{e!=null&&e.find(C=>C===S.value)?n==null||n(e.filter(C=>C!==S.value)):n==null||n([...e||[],S.value]),c==null||c()},children:[A.jsx("span",{className:lt.check,children:e!=null&&e.includes(S.value)?A.jsx("div",{className:lt.checkIconSelected,children:A.jsx(sG,{color:"white"})}):A.jsx("div",{className:lt.checkIconUnselected})}),A.jsx("span",{className:`${lt.optionLabel}`,children:S.label})]},S.value)),g<=r.length&&A.jsxs(Te,{variant:"secondary",type:"button",onClick:()=>m(g+30),className:lt.loadMore,children:["Load More",A.jsx(tt,{name:"double-arrow-left-icon",className:lt.loadMoreIcon})]}),s]})})]}),e!=null&&e.length?A.jsx("div",{className:lt.selectedList,children:e.map(S=>{var C;return A.jsx(we,{styleClass:"font-14c",variant:"p",className:lt.selectedListItem,children:(C=r.find(I=>I.value===S))==null?void 0:C.label},S)})}):null]})})},mQ=({control:r,name:t,...e})=>A.jsx(A.Fragment,{children:A.jsx(aw,{control:r,name:t,render:({field:{onChange:n,value:i}})=>A.jsx(Sa,{...e,name:t,value:i,onChange:n})})}),vs={label:"_label_1wy7g_1",floatingLabel:"_floatingLabel_1wy7g_7","inputField-container":"_inputField-container_1wy7g_13",checkboxLabel:"_checkboxLabel_1wy7g_19",input:"_input_1wy7g_13",floatingInput:"_floatingInput_1wy7g_31",checkboxField:"_checkboxField_1wy7g_37",inputWrapper:"_inputWrapper_1wy7g_43"},yQ={error:"_error_1csa7_1"},ig=({message:r=""})=>A.jsx(we,{variant:"p",styleClass:"custom",className:yQ.error,children:r}),Ye=({type:r="text",register:t,error:e,icon:n,label:i,isDisabled:a,labelClass:o,inputClass:s,className:l,labelVariant:c="static",id:u,...h})=>["checkbox","radio"].includes(r)?A.jsxs("div",{className:`${vs.checkboxField} ${l??""}`,children:[A.jsx("input",{...h,type:r,id:u,className:s,...t,disabled:a}),i?A.jsxs("label",{htmlFor:u,className:`${vs.checkboxLabel} ${o}`,children:[n," ",i]}):null]}):A.jsxs("div",{className:`${vs["inputField-container"]} ${l??""}`,children:[i?A.jsx("label",{htmlFor:u,className:`${vs.label} ${c==="floating"?vs.floatingLabel:""} ${o}`,children:i}):null,A.jsxs("div",{className:vs.inputWrapper,children:[A.jsx("input",{...h,id:u,type:r,className:`${vs.input} ${c==="floating"?vs.floatingInput:""} ${s}`,...t,disabled:a}),n]}),e&&A.jsx(ig,{message:e.message})]}),bQ=({data:r,chartSettings:t,setChartSettings:e,groupbyList:n})=>{var g,m;const[i,a]=P.useState(""),[o,s]=P.useState(""),[l,c]=P.useState(""),u=P.useMemo(()=>{const y=r?Object.keys(r[0]||{}).map(b=>({value:b,label:b})):[];return y.push({value:"NONE",label:"NONE"}),y},[r]),h=P.useMemo(()=>u==null?void 0:u.filter(y=>!n.includes(y.value)),[u]),f=P.useMemo(()=>u==null?void 0:u.filter(y=>n.includes(y.value)),[u]),d=P.useCallback(y=>{e(b=>({...b,yAxisList:y.filter(w=>w&&w!=="NONE"&&u.map(_=>_.value).includes(w))}))},[u]),p=P.useCallback(y=>{e(b=>({...b,pivotTableSettings:{...t.pivotTableSettings,rows:y.filter(w=>w&&w!=="NONE"&&(h==null?void 0:h.map(_=>_.value).includes(w)))}}))},[t.pivotTableSettings,u,e]),v=P.useCallback(y=>{e(b=>({...b,pivotTableSettings:{...t.pivotTableSettings,columns:y.filter(w=>w&&w!=="NONE"&&(f==null?void 0:f.map(_=>_.value).includes(w)))}}))},[t.pivotTableSettings,u,e]);return P.useEffect(()=>{i&&o&&l&&e(y=>({...y,sankeyValues:[i,o,l]}))},[i,o,l]),t.chartType===qY?A.jsxs("div",{className:di.container,children:[A.jsx(ur,{label:"Source",options:u,onChange:a,value:i}),A.jsx(ur,{label:"Target",options:u,onChange:s,value:o}),A.jsx(ur,{label:"Value",options:u,onChange:c,value:l})]}):t.chartType===ye.pivot?A.jsxs("div",{className:di.container,children:[A.jsx(Sa,{label:"Metrics",name:"metrics",options:h||[],defaultValue:h==null?void 0:h.map(y=>y.value),value:(g=t==null?void 0:t.pivotTableSettings)==null?void 0:g.rows,onChange:p}),A.jsx(Sa,{label:"Group by",name:"groupby",options:f||[],defaultValue:f==null?void 0:f.map(y=>y.value),value:(m=t==null?void 0:t.pivotTableSettings)==null?void 0:m.columns,onChange:v})]}):t.chartType===YA?A.jsx(A.Fragment,{children:!!(t.chartType===YA||QA)&&A.jsxs("div",{className:di.container,children:[A.jsx(ur,{label:"Dimension",options:u,onChange:y=>e(b=>({...b,xAxis:y})),value:t.xAxis}),A.jsx(Sa,{label:"Measure",name:"yAxisList",options:u,value:t.yAxisList,onChange:d})]})}):t.chartType===QA?A.jsx(A.Fragment,{children:A.jsxs("div",{className:di.container,children:[A.jsx(ur,{label:"Dimension",options:u,onChange:y=>e(b=>({...b,xAxis:y})),value:t.xAxis}),A.jsx(Sa,{name:"yAxisList",label:"Measure",options:u,value:t.yAxisList,onChange:d})]})}):t.chartType===ye.singleValue?A.jsx("div",{className:di.container,children:A.jsx(ur,{label:"Measure",options:u,onChange:y=>e(b=>({...b,singleValue:y})),value:t.singleValue})}):A.jsx(A.Fragment,{children:A.jsxs("div",{className:di.container,children:[![ye.gauge,ye.boxplot,ye.table].includes(t.chartType)&&A.jsx(A.Fragment,{children:t.chartType===ye.funnel?A.jsx(ur,{label:"Step",options:u,onChange:y=>e(b=>({...b,step:y})),value:t.step}):A.jsx(ur,{label:t.chartType===ye.row?"Y-axis":"X-axis",options:u,onChange:y=>e(b=>({...b,xAxis:y})),value:t.xAxis})}),[ye.funnel,ye.gauge,ye.boxplot].includes(t.chartType)?A.jsx(ur,{label:"Measure",options:u,onChange:y=>e(b=>({...b,measure:y})),value:t.measure}):A.jsxs(A.Fragment,{children:[A.jsx(Sa,{label:t.chartType===ye.row?"X-axis":t.chartType===ye.table?"Measure":"Y-axis",name:"yAxisList",options:u,value:t.yAxisList,onChange:d}),[ye.line,ye.bar,ye.timeSeries,ye.stack].includes(t.chartType)?A.jsxs(A.Fragment,{children:[A.jsx(Ye,{type:"checkbox",label:"Multi Series",className:di.checkboxTooltipWrapper,checked:t==null?void 0:t.isMultiDimension,onChange:y=>e(b=>({...b,isMultiDimension:y.target.checked,isDynamicSeries:!1}))}),A.jsx(Ye,{type:"checkbox",label:"dynamic group",className:di.checkboxTooltipWrapper,checked:t==null?void 0:t.isDynamicSeries,onChange:y=>e(b=>({...b,isDynamicSeries:y.target.checked,seriesField:"ungrouped"}))})]}):null,[ye.line,ye.bar,ye.timeSeries,ye.stack].includes(t.chartType)&&t.isMultiDimension?t.isDynamicSeries?A.jsx(Sa,{label:"Series Column",options:f,onChange:y=>e(b=>({...b,seriesField:(y==null?void 0:y[0])||"ungrouped",seriesOptions:y||[]})),value:t.seriesOptions||[]}):A.jsx(ur,{label:"Series Column",options:[{value:"ungrouped",label:"ungrouped"},...f],onChange:y=>e(b=>({...b,seriesField:y})),value:t.seriesField}):null]})]})})},wQ=[{name:"Line",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m3.5 18.5l6-6l4 4L22 6.92L20.59 5.5l-7.09 8l-4-4L2 17l1.5 1.5Z"})})},{name:"Bar",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M3 22V8h4v14H3m7 0V2h4v20h-4m7 0v-8h4v8h-4Z"})})},{name:"Combo",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M27 28V16h-8v12h-4V12H7v16H4V2H2v26a2 2 0 0 0 2 2h26v-2Zm-14 0H9V14h4Zm12 0h-4V18h4Z"}),A.jsx("path",{fill:"currentColor",d:"M22.786 14a1.988 1.988 0 0 1-1.18-.387L11.205 5.987L8.242 10L6.637 8.806l2.982-4a1.998 1.998 0 0 1 2.749-.446L22.789 12l3.604-4.86L28 8.33l-3.604 4.862a2.001 2.001 0 0 1-1.61.808Z"})]})},{name:"Scatter",icon:r=>A.jsxs("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M4 21h17v-2H5V3H3v17a1 1 0 0 0 1 1z"}),A.jsx("circle",{cx:10,cy:8,r:2,fill:"currentColor"}),A.jsx("circle",{cx:18,cy:12,r:2,fill:"currentColor"}),A.jsx("circle",{cx:11.5,cy:13.5,r:1.5,fill:"currentColor"}),A.jsx("circle",{cx:16.5,cy:6.5,r:1.5,fill:"currentColor"})]})},{name:"Row",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M4 22H2V2h2v20Zm11-1H5v-3h10v3Zm3-5H5v-3h13v3Zm3-5H5V8h16v3Zm-8-5H5V3h8v3Z"})})},{name:"Area",icon:r=>A.jsx("svg",{viewBox:"0 0 1024 1024",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-616-64h536c4.4 0 8-3.6 8-8V284c0-7.2-8.7-10.7-13.7-5.7L592 488.6l-125.4-124a8.03 8.03 0 0 0-11.3 0l-189 189.6a7.87 7.87 0 0 0-2.3 5.6V720c0 4.4 3.6 8 8 8z"})})},{name:"Pie",icon:r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M7.5 1.018a7 7 0 0 0-4.79 11.566L7.5 7.793V1.018zm1 0V7.5h6.482A7.001 7.001 0 0 0 8.5 1.018zM14.982 8.5H8.207l-4.79 4.79A7 7 0 0 0 14.982 8.5zM0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8z"})})},{name:"Waterfall",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M28 28V18h-2v10h-4V4h-2v24H10V14H8v14H4V2H2v26a2.002 2.002 0 0 0 2 2h26v-2Z"}),A.jsx("path",{fill:"currentColor",d:"M14 4h2v14h-2z"})]})},{name:"Funnel",icon:r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M1.5 1.5A.5.5 0 0 1 2 1h12a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.128.334L10 8.692V13.5a.5.5 0 0 1-.342.474l-3 1A.5.5 0 0 1 6 14.5V8.692L1.628 3.834A.5.5 0 0 1 1.5 3.5v-2zm1 .5v1.308l4.372 4.858A.5.5 0 0 1 7 8.5v5.306l2-.666V8.5a.5.5 0 0 1 .128-.334L13.5 3.308V2h-11z"})})},{name:"Bubble",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"}),A.jsx("path",{fill:"currentColor",d:"M10 16a2 2 0 1 1-2 2a2 2 0 0 1 2-2m0-2a4 4 0 1 0 4 4a4 4 0 0 0-4-4zm11-8a4 4 0 1 1-4 4a4 4 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6zm3.5 17a1.5 1.5 0 1 1-1.5 1.5a1.5 1.5 0 0 1 1.5-1.5m0-2a3.5 3.5 0 1 0 3.5 3.5a3.5 3.5 0 0 0-3.5-3.5z"})]})},{name:"Doughnut",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M12.051 21.949a10 10 0 0 1-1-19.949v4.04a5.994 5.994 0 1 0 6.91 6.909H22a10.015 10.015 0 0 1-9.95 9Zm9.95-11h-4.04a5.993 5.993 0 0 0-4.91-4.909V2a10.022 10.022 0 0 1 8.95 8.948v.001Z"})})},{name:"Stepped",icon:r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M22 10V6H10v6H4V2H2v26a2.002 2.002 0 0 0 2 2h26V10Zm-10 4V8h8v4h8v10h-6v-6H12v6H4v-8ZM4 28v-4h10v-6h6v6h8v4Z"})})},{name:"Histogram",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M3 4h1v9h3V7h5v4h4v4h4v6H3V4m13 12v4h3v-4h-3m-4-4v8h3v-8h-3M8 8v12h3V8H8m-4 6v6h3v-6H4Z"})})},{name:"Gauge",icon:r=>A.jsx("svg",{viewBox:"0 0 20 20",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M8.127 13.6c-.689 1.197-.225 2.18.732 2.732c.956.553 2.041.465 2.732-.732c.689-1.195 5.047-11.865 4.668-12.084c-.379-.219-7.442 8.888-8.132 10.084zM10 6c.438 0 .864.037 1.281.109c.438-.549.928-1.154 1.405-1.728A9.664 9.664 0 0 0 10 4C4.393 4 0 8.729 0 14.766c0 .371.016.742.049 1.103c.049.551.54.955 1.084.908c.551-.051.957-.535.908-1.086A10.462 10.462 0 0 1 2 14.766C2 9.85 5.514 6 10 6zm7.219 1.25c-.279.75-.574 1.514-.834 2.174C17.4 10.894 18 12.738 18 14.766c0 .316-.015.635-.043.943a1.001 1.001 0 0 0 1.992.182c.033-.37.051-.748.051-1.125c0-2.954-1.053-5.59-2.781-7.516z"})})},{name:"Sankey",icon:r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M30 2H2v14h6.111a7.036 7.036 0 0 1 3.13.74L15.764 19l-4.522 2.26a7.036 7.036 0 0 1-3.13.74H2v8h7.223a9.045 9.045 0 0 0 4.025-.95l8.622-4.31A7.036 7.036 0 0 1 25 24h5V14h-5a7.036 7.036 0 0 1-3.13-.74L15.348 10H30ZM8 4h16v4H8ZM4 4h2v10H4Zm0 20h2v4H4Zm16.975-1.05l-8.622 4.31a7.036 7.036 0 0 1-3.13.74H8v-4h.111a9.045 9.045 0 0 0 4.025-.95L18 20.118l1.864.932a9.045 9.045 0 0 0 4.025.95H24v.058a9.052 9.052 0 0 0-3.025.892ZM28 22h-2v-6h2ZM12.354 10.74l8.621 4.31a9.052 9.052 0 0 0 3.025.89V20h-.111a7.036 7.036 0 0 1-3.13-.74l-8.622-4.31A9.045 9.045 0 0 0 8.11 14H8v-4h1.223a7.036 7.036 0 0 1 3.13.74ZM28 8h-2V4h2Z"})})},{name:"Stack",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M22 21H2V3h2v16h2v-2h4v2h2v-3h4v3h2v-2h4v4m-4-7h4v2h-4v-2m-6-8h4v3h-4V6m4 9h-4v-5h4v5M6 10h4v2H6v-2m4 6H6v-3h4v3Z"})})},{name:"Single value",icon:r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M2.873 11.297V4.142H1.699L0 5.379v1.137l1.64-1.18h.06v5.961h1.174Zm3.213-5.09v-.063c0-.618.44-1.169 1.196-1.169c.676 0 1.174.44 1.174 1.106c0 .624-.42 1.101-.807 1.526L4.99 10.553v.744h4.78v-.99H6.643v-.069L8.41 8.252c.65-.724 1.237-1.332 1.237-2.27C9.646 4.849 8.723 4 7.308 4c-1.573 0-2.36 1.064-2.36 2.15v.057h1.138Zm6.559 1.883h.786c.823 0 1.374.481 1.379 1.179c.01.707-.55 1.216-1.421 1.21c-.77-.005-1.326-.419-1.379-.953h-1.095c.042 1.053.938 1.918 2.464 1.918c1.478 0 2.642-.839 2.62-2.144c-.02-1.143-.922-1.651-1.551-1.714v-.063c.535-.09 1.347-.66 1.326-1.678c-.026-1.053-.933-1.855-2.359-1.845c-1.5.005-2.317.88-2.348 1.898h1.116c.032-.498.498-.944 1.206-.944c.703 0 1.206.435 1.206 1.07c.005.64-.504 1.106-1.2 1.106h-.75v.96Z"})})},{name:"BoxPlot",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M22 6V4H12v2h4v2h-4v12h4v2h-4v2h10v-2h-4v-2h4V8h-4V6Zm-8 12v-3h6v3Zm6-5h-6v-3h6Z"}),A.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"})]})},{name:"Table",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M8 16h5v-5H8v5Zm0-7h12V4H8Zm7 7h5v-5h-5Zm-7 2q-.825 0-1.412-.587Q6 16.825 6 16V4q0-.825.588-1.413Q7.175 2 8 2h12q.825 0 1.413.587Q22 3.175 22 4v12q0 .825-.587 1.413Q20.825 18 20 18Zm-4 4q-.825 0-1.412-.587Q2 20.825 2 20V6h2v14h14v2Z"})})},{name:"Time series",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M21 8c-1.5 0-2.3 1.4-1.9 2.5l-3.6 3.6c-.3-.1-.7-.1-1 0l-2.6-2.6c.4-1.1-.4-2.5-1.9-2.5c-1.4 0-2.3 1.4-1.9 2.5L3.5 16c-1.1-.3-2.5.5-2.5 2c0 1.1.9 2 2 2c1.4 0 2.3-1.4 1.9-2.5l4.5-4.6c.3.1.7.1 1 0l2.6 2.6c-.3 1 .5 2.5 2 2.5s2.3-1.4 1.9-2.5l3.6-3.6c1.1.3 2.5-.5 2.5-1.9c0-1.1-.9-2-2-2m-6 1l.9-2.1L18 6l-2.1-.9L15 3l-.9 2.1L12 6l2.1.9L15 9M3.5 11L4 9l2-.5L4 8l-.5-2L3 8l-2 .5L3 9l.5 2Z"})})},{name:"Pivot Table",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M22 15h-2v3c0 1.11-.89 2-2 2h-3v2l-3-3l3-3v2h3v-3h-2l3-3l3 3m0-11v4c0 1.1-.9 2-2 2H10v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h16c1.1 0 2 .9 2 2M4 8h4V4H4v4m0 2v4h4v-4H4m4 10v-4H4v4h4m6-12V4h-4v4h4m6-4h-4v4h4V4Z"})})}],_Q=({chartType:r,onChartChange:t,isEnableTimeSeries:e,isEnablePivotTable:n})=>A.jsx("div",{className:di.chartOptions,children:wQ.map(i=>A.jsxs("div",{className:di.chartOption,children:[A.jsx(Te,{type:"button",variant:"custom",className:r===i.name.toLowerCase()?di.chartOptionBtnSelected:di.chartOptionBtn,onClick:()=>{t(i.name.toLowerCase())},isDisabled:i.name.toLowerCase()===ye.timeSeries&&!e||i.name.toLowerCase()===ye.pivot&&!n,children:i.name.toLowerCase()===ye.timeSeries&&!e||i.name.toLowerCase()===ye.pivot&&!n?A.jsx(i.icon,{style:{color:"grey",width:"20px",height:"20px"}}):A.jsx(i.icon,{style:{color:"blue",width:"20px",height:"20px"}})},i.name),A.jsx(we,{variant:"p",styleClass:"custom",className:di.chartOptionText,children:i.name})]},i.name))}),SQ=({datatype:r="unknown",className:t})=>iQ.includes(r.toLowerCase())?A.jsx(tt,{name:"number-icon",className:t}):aQ.includes(r.toLowerCase())||r.toLowerCase().includes("char")?A.jsx(tt,{name:"text-icon",className:t}):oQ.includes(r.toLowerCase())?A.jsx(tt,{name:"array-icon",className:t}):nN.includes(r.toLowerCase())?A.jsx(tt,{name:"date-icon",className:t}):sQ.includes(r.toLowerCase())?A.jsx(tt,{name:"boolean-icon",className:t}):A.jsx(tt,{name:"unknown-icon"}),sN={container:"_container_1izll_1",windowIcon:"_windowIcon_1izll_7"},xQ=r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.5,children:[A.jsx("path",{d:"M15 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10"}),A.jsx("path",{strokeLinejoin:"round",d:"M2 7h20M5 5.01l.01-.011M8 5.01l.01-.011M11 5.01l.01-.011M18 22.243l2.121-2.122m0 0L22.243 18m-2.122 2.121L18 18m2.121 2.121l2.122 2.122"})]})}),MQ=()=>A.jsxs("div",{role:"alert",className:sN.container,children:[A.jsx(xQ,{className:sN.windowIcon}),A.jsx(we,{variant:"p",styleClass:"font-20",children:"Something went wrong!"}),A.jsx(Te,{variant:"primary",size:"large",type:"button",onClick:()=>location.reload(),children:"Try again"})]}),Nl={container:"_container_dv0n1_1",field:"_field_dv0n1_9",fieldLabel:"_fieldLabel_dv0n1_17",save:"_save_dv0n1_25",cancel:"_cancel_dv0n1_33",error:"_error_dv0n1_41"},ag={container:"_container_1rie6_1",label:"_label_1rie6_9",textarea:"_textarea_1rie6_17",resizable:"_resizable_1rie6_25"},CQ=({id:r,label:t,placeholder:e,rows:n,cols:i,resizable:a=!0,register:o,error:s,defaultValue:l,value:c,onFocus:u,onBlur:h,className:f})=>A.jsxs("div",{className:`${ag.container} ${f}`,children:[A.jsx("label",{htmlFor:r,className:ag.label,children:t}),A.jsx("textarea",{id:r,name:r,rows:n,cols:i,placeholder:e,className:fr(ag.textarea,`${a?null:ag.resizable}`),defaultValue:l,...o,value:c,onFocus:u,onBlur:h}),s&&A.jsx(ig,{message:s.message})]}),DQ=({name:r,styles:t,placeholder:e,enabled:n})=>A.jsxs("label",{htmlFor:r,className:`${t.button}`,children:[Array.isArray(e)&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.label} ${n?t.labelInactive:t.labelActive}`,children:e[0]}),A.jsx("span",{className:` ${t.switch} ${n?t.enabled:t.notenabled}`}),A.jsx("span",{className:` ${t.label} ${n?t.labelActive:t.labelInactive}`,children:e[1]})]}),typeof e=="string"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.switch} ${n?t.enabled:t.notenabled}`}),A.jsx("span",{className:` ${t.label} ${n?t.labelActive:t.labelInactive}`,children:e})]}),!Array.isArray(e)&&typeof e!="string"&&A.jsx("span",{className:` ${t.switch} ${n?t.enabled:t.notenabled}`})]}),og={group:"_group_4odq6_1",button:"_button_4odq6_9",toggleWidth:"_toggleWidth_4odq6_15",checkbox:"_checkbox_4odq6_23",switch:"_switch_4odq6_31",enabled:"_enabled_4odq6_49",notenabled:"_notenabled_4odq6_65",toggle:"_toggle_4odq6_15",label:"_label_4odq6_89",labelActive:"_labelActive_4odq6_97",labelInactive:"_labelInactive_4odq6_105",toggleInactive:"_toggleInactive_4odq6_113"},TQ=({name:r,styles:t,placeholder:e,enabled:n})=>A.jsxs("label",{htmlFor:r,className:`${t.button} ${t.toggleWidth}`,children:[Array.isArray(e)&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.label} ${n&&t.toggleInactive}`,children:e[0]}),A.jsx("span",{className:` ${t.switch} ${t.toggle} ${n?t.enabled:t.notenabled}
482
+ }`),t){const d=document.querySelectorAll("dbn-dashboard");d.length&&d.forEach((g,m)=>{if(g&&g.shadowRoot){const y=document.querySelector(`#dbn-dashboard-${m}-admin-styles`);if(y)y.innerHTML=e;else{const b=document.createElement("style");b.setAttribute("id",`dbn-dashboard-${m}-admin-styles`),b.innerHTML=e,g.shadowRoot.appendChild(b)}}});const p=document.querySelectorAll("dbn-metric");p.length&&p.forEach((g,m)=>{if(g.shadowRoot){const y=document.querySelector(`#dbn-metric-${m}-admin-styles`);if(y)y.innerHTML=e;else{const b=document.createElement("style");b.setAttribute("id",`dbn-metric-${m}-admin-styles`),b.innerHTML=e,g.shadowRoot.appendChild(b)}}});const v=document.querySelector("#dbn-portal");if(v&&v.shadowRoot){const g=document.querySelector("#dbn-portal-admin-styles");g&&v.shadowRoot.removeChild(g)}}else{const d=document.querySelector("#dbn-admin-styles")||document.createElement("style");d.setAttribute("id","dbn-admin-styles"),d.innerHTML=e,document.querySelector("#dbn-admin-styles")||document.head.appendChild(d)}},[r])},tQ=({externalDashboardId:r,clientId:t})=>{const e=xc(),{data:n,isLoading:i}=iY({clientId:t,externalDashboardId:r},{enabled:!!(t&&r),refetchOnWindowFocus:!1}),[a,o]=P.useMemo(()=>{var u,h;return[((u=n==null?void 0:n.clientDashboardLayout_by_pk)==null?void 0:u.layout)||[],!!((h=n==null?void 0:n.clientDashboardLayout_by_pk)!=null&&h.isLocked)]},[n==null?void 0:n.clientDashboardLayout_by_pk]),{mutateAsync:s,isLoading:l}=FY({onSuccess:u=>{if(!u.insert_clientDashboardLayout_one)return;const h=u.insert_clientDashboardLayout_one;e.setQueryData(["GetExternalDashboardLayout",{clientId:t,externalDashboardId:r}],f=>({...f,clientDashboardLayout_by_pk:h}))}});return{saveLayout:P.useCallback(async(u,h)=>{await s({clientId:t,externalDashboardId:r,layout:u,isLocked:!!h})},[s,t,r]),layout:a,isLayoutLocked:o,isLoadingLayout:i||l}},rQ=[{value:"=",label:"Equal to (=)"},{value:"<>",label:"Not equal to (!=)"},{value:"<",label:"Less than (<)"},{value:"<=",label:"Less or equal (<=)"},{value:">",label:"Greater than (>)"},{value:">=",label:"Greater or equal (>=)"},{value:"IN",label:"In"},{value:"NOT IN",label:"Not in"},{value:"LIKE (case sensitive)",label:"Like (case sensitive)"},{value:"REGEX",label:"Regex"},{value:"IS NOT NULL",label:"Is not null"},{value:"IS NULL",label:"Is null"}],nQ=[{value:"100",label:"100"},{value:"500",label:"500"},{value:"1000",label:"1000"},{value:"2000",label:"2000"},{value:"5000",label:"5000"}],rN=[{value:"AVG",label:"AVG"},{value:"SUM",label:"SUM"},{value:"COUNT",label:"COUNT"},{value:"COUNT_DISTINCT",label:"COUNT_DISTINCT"},{value:"MAX",label:"MAX"},{value:"MIN",label:"MIN"}],Ew=[{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"75",value:"75"},{label:"100",value:"100"},{label:"250",value:"250"},{label:"500",value:"500"},{label:"1k",value:"1000"},{label:"2k",value:"2000"},{label:"5k",value:"5000"}],iQ=["fixed","real","int","bigint","float","number","integer","int64","float64","double precision","smallint"],aQ=["varchar","text","char","text","character(36)","string"],nN=["timestamp_ltz","date","timestamp","timestamp without time zone","timestamp with time zone","datetime"],oQ=["array","text[]"],sQ=["boolean","bool"],iN=["saved","simple","custom"],Jn={chartType:"line",xAxis:"",yAxisList:[],singleValue:"",sankeyValues:[],metricFilterPosition:"top-left",step:"",measure:"",margins:{marginTop:20,marginBottom:20,marginLeft:5,marginRight:5},labelSettings:{axis:"left",show:!1,position:"hidden",truncateLabelValue:14},legendSettings:{show:!0,top:0,left:0,right:0,bottom:0,position:"horizontal",truncateLegendValue:14},customSettings:{hideSplitLines:"none",hideAxisLines:"none",barWidth:40,barRadius:0,axisLabels:"none",fontSize:14,subHeaderShow:!1,displayText:"",subHeaderFontSize:0,dateFormatter:"none",numberFormatter:"original",xRotation:50,showLabelValues:!1,comparisonTimePeriod:0,comparisonTimeColumn:"",comparisonValueShow:!1,comparisonValueFontSize:12,comparisonSuffix:"",isShowTrendLine:!1},tableSettings:{contentAlignment:"center",lineGap:"small",hideVerticalDivider:!1,enableStripedRows:!1,showRowHover:!1,showTableTitle:!1,showTableDesc:!1,enableTableSearch:!0,enableFilter:!0,enableSorting:!0,defaultRowSize:"10",isServerSidePagination:!1,conditionalFormatting:[]},pivotTableSettings:{rows:[],columns:[]},axisSettings:{axis:"left"},backGroundColor:{show:!1},timeSeriesSettings:{groupBySettings:{isDynamic:!1,options:[],value:"monthly"},seriesType:[]},isDynamicSeries:!1,isMultiDimension:!1,seriesField:"ungrouped",seriesOptions:["ungrouped"]},ng=[{value:"isEqualTo",label:"is equal to"},{value:"isNotEqualTo",label:"is not equal to"},{value:"isNull",label:"is null"},{value:"isNotNull",label:"is not null"},{value:"contains",label:"contains"},{value:"doesNotContain",label:"not contain"},{value:"startsWith",label:"starts with"},{value:"endsWith",label:"ends with"},{value:"isLessThan",label:"is less than"},{value:"isGreaterThan",label:"is greater than"},{value:"isLessThanOrEqualTo",label:"is less than equal to"},{value:"isGreaterThanOrEqualTo",label:"is greater than equal to"}],lQ=(r,t)=>{let e=r.replace(/;([^;]*)$/,"");const n=parseInt(t,10);if(e.toLowerCase().includes("limit")){const i=parseInt(e.toLowerCase().split("limit")[1].trim(),10),a=Math.min(i,n);e=e.replace(`limit ${i}`,`limit ${a}`),e=e.replace(`LIMIT ${i}`,`LIMIT ${a}`)}else e+=` limit ${n}`;return e},uQ=({limit:r,query:t,clientName:e,tenancyType:n,values:i})=>{const a=lQ(t,r),o=e?n===JA?a.replace(new RegExp(qA,"g"),e):Number(e)?a.replace(new RegExp(XA,"g"),e):a.replace(new RegExp(GA,"g"),e):a;return i?o.replace(/[^']+_variable/g,l=>`${i[l]}`):o},cQ=({clientName:r,tenancyType:t,values:e,query:n,companyId:i,workspaceId:a,metricId:o})=>{const{mutate:s}=MY();return{getUnderlyingData:({columnName:c,value:u,setData:h,setLoading:f,isSingleValueChart:d})=>{const p=uQ({query:n,limit:"5000",clientName:r,tenancyType:t,values:e});h([]),f(!0),s({columnName:d?void 0:c,companyId:i,query:p,value:d||u==null?void 0:u.replace(/'/g,"''"),workspaceId:a,metricId:o},{onSuccess(v){var m;const g=(m=v.getUnderlyingData)==null?void 0:m.data;g&&Array.isArray(g)&&g.length?(h(g),f(!1)):(h([]),f(!1))},onError(){h([]),f(!1)}})}}},aN=()=>{const{mutate:r}=cY();return{getGroupByColumnList:({query:e,databaseName:n,onSuccess:i})=>{r({databaseName:n,query:e},{onSuccess({groupbyColumnList:a}){const o=a==null?void 0:a.groupbyColumnList;Array.isArray(o)&&o.length?i(o):i([])},onError(){i([])}})}}},hQ=({range:r,count:t,time:e,from:n,to:i})=>{const a=new Date;new Date(a).setDate(a.getDate()-1);const s=a.getMonth(),l=a.getFullYear();let c,u;if(r==="This"){switch(e){case"Year":c=new Date(l,0,1),u=new Date(a);break;case"Month":c=new Date(l,s,1),u=new Date(a);break;case"Week":{const h=a.getDate()-a.getDay();c=new Date(a.setDate(h)),u=new Date(a.setDate(h+6));break}case"Day":c=new Date(a),u=new Date(a);break;default:c=new Date(0),u=new Date(a)}return{startDate:c,endDate:u}}if(r==="Last"){switch(e){case"Year":{let h,f;t===1?(h=t,f=l-1):(h=t-1,f=l),c=new Date(l-h,0,1),u=new Date(f,11,31);break}case"Month":{const h=t===1?s-1:s-t+1;c=new Date(l,h,1),u=new Date(l,s,t===1?0:31);break}case"Week":{const h=new Date(a.setDate(a.getDate()-(a.getDay()+1)%7)),f=new Date(h.getFullYear(),h.getMonth(),h.getDate()-6),d=t-1;c=new Date(f.setDate(f.getDate()-7*d)),u=new Date(h.setDate(h.getDate()-7*(d-1))),d===0&&(u=new Date(a));break}case"Day":c=new Date(a),c.setDate(a.getDate()-t),u=new Date(a);break;default:c=new Date(0),u=new Date(a)}return{startDate:c,endDate:u}}return{startDate:n||new Date(0),endDate:i||new Date(a)}},fQ=({data:r,format:t,measureColumn:e,timeColumn:n,dimensionColumn:i,startDate:a})=>r.reduce((s,l)=>{const c=Number(l[e]),u=new Date(l[n]);let h;switch(t){case"Week":{h=`Week ${Math.ceil((u.getDate()+a.getDay())/7)}`;break}case"Quarter":{const d=Math.ceil((u.getMonth()+1)/3),p=u.getFullYear();h=`Q${d} ${p}`;break}case"Month":{h=`${u.toLocaleString("default",{month:"long"})} ${u.getFullYear()}`;break}case"Day":{h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][u.getDay()];break}default:h=l[n]}const f=s.find(d=>d[i]===h);return f?f[e]+=c:s.push({[i]:h,[e]:c}),s},[]),dQ=({dimensionColumn:r,endDate:t,measureColumn:e,format:n,groupedDataList:i,time:a,count:o,range:s})=>{const l=new Date().getFullYear(),c=l-1;let u=[],h=[];if(o===1&&s==="This"&&(u=Array.from({length:12},(v,g)=>({[r]:`${new Date(2e3,g,1).toLocaleString("default",{month:"long"})} ${l}`,[e]:0})),h=[{[r]:`Q1 ${l}`,[e]:0},{[r]:`Q2 ${l}`,[e]:0},{[r]:`Q3 ${l}`,[e]:0},{[r]:`Q4 ${l}`,[e]:0}]),o===1&&s==="Last"&&(u=Array.from({length:12},(v,g)=>({[r]:`${new Date(2e3,g,1).toLocaleString("default",{month:"long"})} ${c}`,[e]:0})),h=[{[r]:`Q1 ${c}`,[e]:0},{[r]:`Q2 ${c}`,[e]:0},{[r]:`Q3 ${c}`,[e]:0},{[r]:`Q4 ${c}`,[e]:0}]),o>1&&s==="Last"){for(let v=l-o+1;v<=l;v++)for(let g=0;g<12;g++)u.push({[r]:`${new Date(v,g,1).toLocaleString("default",{month:"long"})} ${new Date(v,g,1).getFullYear()}`,[e]:0});for(let v=l-o;v<=l;v++)h.push({[r]:`Q1 ${v}`,[e]:0},{[r]:`Q2 ${v}`,[e]:0},{[r]:`Q3 ${v}`,[e]:0},{[r]:`Q4 ${v}`,[e]:0})}const f=Array.from({length:4},(v,g)=>({[r]:`Week ${g+1}`,[e]:0})),d=[{[r]:"Sunday",[e]:0},{[r]:"Monday",[e]:0},{[r]:"Tuesday",[e]:0},{[r]:"Wednesday",[e]:0},{[r]:"Thursday",[e]:0},{[r]:"Friday",[e]:0},{[r]:"Saturday",[e]:0}];let p=[];switch(`${s}${o>1?` ${o} `:" "}${a} By ${n}`){case"This Year By Month":case"Last Year By Month":case`Last ${o} Year By Month`:{p=u.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Year By Quarter":case"Last Year By Quarter":case`Last ${o} Year By Quarter`:{p=h.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Month By Week":case"Last Month By Week":{p=f.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Week By Day":case"Last Week By Day":{p=d.map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}case"This Quarter By Month":{const g=(Math.ceil((t.getMonth()+1)/3)-1)*3,m=g+2;p=u.slice(g,m+1).map(b=>{const w=i.find(_=>_[r]===b[r]);return w||b});break}case"Last Quarter By Month":{const v=Math.ceil((t.getMonth()+1)/3),m=((v===1?4:v-1)-1)*3,y=m+2;p=u.slice(m,y+1).map(w=>{const _=i.find(S=>S[r]===w[r]);return _||w});break}case`Last ${o} Month By Month`:{p=Array.from({length:o},(v,g)=>{const m=new Date(t.getFullYear(),t.getMonth()-g,1);return{[r]:`${m.toLocaleString("default",{month:"long"})} ${m.getFullYear()}`,[e]:0}}).reverse().map(v=>{const g=i.find(m=>m[r]===v[r]);return g||v});break}default:p=i}return p},pQ=({data:r,dimensionColumn:t,measureColumn:e,timeColumn:n,option:i})=>{const{endDate:a,startDate:o}=hQ({range:i.range,count:i.count,from:i.startDate,to:i.endDate,time:i.time});if(i.time==="Week"&&i.count>1)return r.map(u=>({[t]:u[t],[e]:u[e]}));const s=fQ({data:r,dimensionColumn:t,format:i.format,measureColumn:e,startDate:o,timeColumn:n}),l=Object.values(s);return i.name==="Custom"?l:dQ({dimensionColumn:t,endDate:a,format:i.format,groupedDataList:l,measureColumn:e,time:i.time,count:i.count,range:i.range})},oN=({metric:r,globalFilters:t={tableName:"",filters:[]},rlsFilters:e,clientId:n,chartSettings:i,setChartSettings:a,tenancyLevel:o})=>{var G,$,U,Z,Y,q,V,X;const[s,l]=P.useState({limit:10,offset:0}),[c,u]=P.useState(0),[h,f]=P.useState(r.rlsConditions||[]),[d,p]=P.useState(!1),[v,g]=P.useState(),[m,y]=P.useState([]),[b,w]=P.useState(!0),[_,S]=P.useState([]),[C,I]=P.useState([]),[D,T]=P.useState(!1),[x,M]=P.useState([]),{data:N,isLoading:E}=PY({id:r.id,drillFilters:(G=r==null?void 0:r.drillDownSettings)!=null&&G.isEnableGroupBy?_:[],clientId:n,tenancyLevel:o,rlsConditions:x,globalFilters:t,filterValues:e==null?void 0:e.filterValues,limit:($=i==null?void 0:i.tableSettings)!=null&&$.isServerSidePagination&&(i==null?void 0:i.chartType)===ye.table?s.limit:void 0,offset:(U=i==null?void 0:i.tableSettings)!=null&&U.isServerSidePagination&&(i==null?void 0:i.chartType)===ye.table?s.offset:void 0},{refetchOnWindowFocus:!1}),L=P.useMemo(()=>{var Q,ie;return!!h.length&&((ie=(Q=h.find(te=>te.isAddOnMetrics&&te.datatype==="date"&&te.columnName===i.xAxis))==null?void 0:Q.options)==null?void 0:ie.every(te=>te.format))},[h,i]);P.useEffect(()=>{var Q;(Q=h==null?void 0:h.filter(ie=>ie.isAddOnMetrics))!=null&&Q.length?M(o==="DATABASE"?r.rlsConditions.filter(ie=>ie.isAddOnMetrics&&ie.datatype!=="date").map(ie=>{var te;return{...ie,tableName:`${n}.${ie.tableName.split(".").slice(1).join(".")}`,dimensionColumn:i.xAxis||"",measureColumn:((te=i.yAxisList)==null?void 0:te[0])||""}}):h.filter(ie=>ie.isAddOnMetrics).map(ie=>{var te;return{...ie,dimensionColumn:i.xAxis||"",measureColumn:((te=i.yAxisList)==null?void 0:te[0])||""}})):M([])},[h]);const k=P.useMemo(()=>{var Q,ie,te,re,ue;return(i==null?void 0:i.chartType)===ye.singleValue&&!!((Q=i==null?void 0:i.customSettings)!=null&&Q.comparisonValueShow)&&!!((ie=i==null?void 0:i.customSettings)!=null&&ie.comparisonTimeColumn)&&!!((te=i==null?void 0:i.customSettings)!=null&&te.comparisonTimeGrain)&&!!((re=i==null?void 0:i.customSettings)!=null&&re.comparisonTimePeriod)&&!!((ue=i==null?void 0:i.customSettings)!=null&&ue.comparisonTableName)&&!!(i!=null&&i.singleValue)},[i]);P.useEffect(()=>{var ie,te,re;const Q=(ie=N==null?void 0:N.externalMetricQuery)!=null&&ie.data?JSON.parse(N.externalMetricQuery.data):[];if((i==null?void 0:i.chartType)===ye.table&&u(((te=N==null?void 0:N.externalMetricQuery)==null?void 0:te.totalRecords)||0),L){const ue=h.find(_e=>_e.isAddOnMetrics&&_e.datatype==="date");if(ue){const _e=pQ({data:Q||[],dimensionColumn:ue.columnName,measureColumn:((re=i.yAxisList)==null?void 0:re[0])||"",option:ue.options.find(Ce=>Ce.name===ue.value),timeColumn:i.xAxis||ue.columnName});y(_e)}else y(Q??[])}else y(Q??[])},[(Z=N==null?void 0:N.externalMetricQuery)==null?void 0:Z.data,L,k]);const O=Q=>Q.includes("____")?Q.split("____")[1]:Q;P.useEffect(()=>{var Q;(Q=r==null?void 0:r.drillDownSettings)!=null&&Q.isEnableGroupBy&&m.length&&a(ie=>{var te,re,ue,_e,Ce,Ge,Xe,Ot;return{...ie,xAxis:O(((_e=(te=r==null?void 0:r.datasetMetricSettings)==null?void 0:te.selectedDimensions)==null?void 0:_e[_.length<((ue=(re=r==null?void 0:r.datasetMetricSettings)==null?void 0:re.selectedDimensions)==null?void 0:ue.length)?_.length:0])||"none"),yAxisList:(Ge=(Ce=r==null?void 0:r.datasetMetricSettings)==null?void 0:Ce.metrics)==null?void 0:Ge.map(de=>{var Me;return(Me=de==null?void 0:de.as)==null?void 0:Me.replace(/["`]+/g,"")}),chartType:((Ot=(Xe=r==null?void 0:r.datasetMetricSettings)==null?void 0:Xe.selectedDimensions)==null?void 0:Ot.length)===(_==null?void 0:_.length)?"table":r.chartOptions.chartType}})},[m,r.drillDownSettings,r==null?void 0:r.datasetMetricSettings,_]),P.useEffect(()=>{E&&w(!0),!m.length&&!E&&setTimeout(()=>{w(!1)},5e3)},[E,m]);const R=P.useCallback((Q,ie,te,re)=>{f(te?ue=>ue.map(_e=>_e.name===Q?{..._e,value:ie,options:_e.options.map(Ce=>Ce.name==="Custom"?{...Ce,...te}:Ce)}:_e):re?ue=>ue.map(_e=>_e.name===Q?{..._e,value:re.map(Ce=>Ce.value)}:_e):ue=>ue.map(_e=>_e.name===Q?{..._e,value:ie}:_e))},[]),z=P.useCallback(Q=>{L||(Q.event&&Q.event.event.preventDefault(),g(Q))},[h]),{getUnderlyingData:F}=cQ({clientName:n,tenancyType:o,values:e==null?void 0:e.filterValues,companyId:r==null?void 0:r.companyId,query:r==null?void 0:r.query,workspaceId:(Y=r==null?void 0:r.companyIntegration)==null?void 0:Y.workspaceId,metricId:r==null?void 0:r.id}),W=P.useMemo(()=>Array.isArray(m)&&m.length&&(v!=null&&v.name)?m.map(Q=>{const ie=Object.entries(Q).find(([,te])=>te===v.name);return ie==null?void 0:ie[0]}).filter(Q=>Q)[0]:"",[m,v==null?void 0:v.name]),B=P.useCallback(Q=>{const ie=Array.isArray(m)&&m.length&&(Q!=null&&Q.name)?m.map(te=>{const re=Object.entries(te).find(([,ue])=>ue===Q.name);return re==null?void 0:re[0]}).filter(te=>te)[0]:"";S(ie?te=>{var re;return((re=r==null?void 0:r.datasetMetricSettings)==null?void 0:re.selectedDimensions.length)>te.length?[...te,{columnName:ie,value:Q==null?void 0:Q.name}]:[]}:[])},[m,r==null?void 0:r.datasetMetricSettings,r==null?void 0:r.drillDownSettings]),{getGroupByColumnList:H}=aN();return P.useEffect(()=>{r.query&&H({query:r==null?void 0:r.query,databaseName:(r==null?void 0:r.integrationName)||"",onSuccess:Q=>I(Q)}),m!=null&&m.length&&C.length&&T(!0)},[m,C.length,r==null?void 0:r.integrationName,r.query]),{onDrillDown:B,handleChartClick:z,dataDb:m,getUnderlyingData:F,onChangeFilterValue:R,isShowChartPopup:d,setShowChartPopup:p,columnName:W,chartParams:v,isQueryLoading:E||b,setLoading:w,drilledLevel:_.length,dimensions:((V=(q=r==null?void 0:r.datasetMetricSettings)==null?void 0:q.selectedDimensions)==null?void 0:V.map(Q=>O(Q||"none")))||[],rlsConditions:h,setTableLimit:l,isEnableNextBtn:c>(s==null?void 0:s.limit)+(s==null?void 0:s.offset),isEnablePrevBtn:(s==null?void 0:s.offset)!==0,paginationInfo:{limit:s==null?void 0:s.limit,offset:s==null?void 0:s.offset,totalRecords:c},onChangePage:(Q,ie)=>{l(ie?{limit:ie,offset:0}:te=>({limit:te.limit,offset:Q?te.offset>te.limit?te.offset-te.limit:0:te.offset+te.limit}))},isExternalChart:((X=i==null?void 0:i.tableSettings)==null?void 0:X.isServerSidePagination)&&(i==null?void 0:i.chartType)===ye.table,isEnablePivotTable:D,groupByList:C,updateFilter:Q=>{f(ie=>ie.map(te=>te.name===Q.name&&te.datatype===Q.datatype&&te.tableName===Q.tableName&&te.columnName===Q.columnName?{...te,isAddOnMetrics:!te.isAddOnMetrics}:te))}}},vQ=({dashboardId:r,clientId:t,metricId:e,onSuccess:n})=>{const i=xc(),{mutateAsync:a,isLoading:o}=LY({onSuccess:l=>{l.insert_clientDeletedMetrics_one&&(i.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:r,clientId:t}],c=>{var h;const u=(h=c==null?void 0:c.externalDashboardMetrics)==null?void 0:h.filter(f=>f.externalMetricId!==e);return{...c,externalDashboardMetrics:u}}),n())}});return{handleArchiveMetric:P.useCallback(async()=>{!e||!t||await a({id:e,clientId:t})},[a,e,t]),isLoading:o}},gQ=({token:r,metricId:t})=>{const[e,n]=P.useState(!0),{data:i,isLoading:a}=jG({guestToken:r,metricId:t},{enabled:!!(r&&t)}),{externalMetric:o,sharingSettingsId:s,adminTheme:l,params:c,companyId:u,clientId:h,errorMsg:f}=P.useMemo(()=>{var g,m,y,b,w,_,S,C;return{externalMetric:(g=i==null?void 0:i.embeddedMetricData)==null?void 0:g.externalMetric,adminTheme:(m=i==null?void 0:i.embeddedMetricData)==null?void 0:m.adminTheme,sharingSettingsId:(y=i==null?void 0:i.embeddedMetricData)==null?void 0:y.sharingSettingsId,errorMsg:(w=(b=i==null?void 0:i.embeddedMetricData)==null?void 0:b.error)==null?void 0:w.message,params:(_=i==null?void 0:i.embeddedMetricData)==null?void 0:_.params,companyId:(S=i==null?void 0:i.embeddedMetricData)==null?void 0:S.companyId,clientId:(C=i==null?void 0:i.embeddedMetricData)==null?void 0:C.clientId}},[i==null?void 0:i.embeddedMetricData]),d=P.useMemo(()=>{var g;return l?(g=l.chart.palettes.find(m=>m.name===l.chart.selected))==null?void 0:g.colors:null},[l]),{rlsSettings:p,tenancyLevel:v}=P.useMemo(()=>{var m;if(!c)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const g=JSON.parse(c);return{rlsSettings:(m=g.rlsSettings)==null?void 0:m.find(y=>y.metricId===t),tenancyLevel:g.companyTenancyType||"TABLE"}},[c,t]);return tN(l),P.useEffect(()=>{a&&n(!0),(o||f)&&n(!1)},[a,o,f]),{externalMetric:o,sharingSettingsId:s,adminColors:d,companyId:u,clientId:h,rlsSettings:p,tenancyLevel:v,isLoading:e,errorMsg:f}},ur=({name:r,label:t,options:e=[],onChange:n,value:i,defaultValue:a,children:o,placeHolder:s,className:l="",containerClass:c="",isSearchEnabled:u,textSize:h,icon:f,labelVariant:d="static"})=>{const[p,v]=P.useState(""),[g,m]=P.useState(20),[y,b]=P.useState(!1),w=P.useRef(),_=i||a?e.find(I=>I.value===i||I.value===a):{label:s||"Select an option"},S={fontSize:h},C=P.useMemo(()=>p?e.filter(I=>I.label.toLowerCase().includes(p)).slice(0,g):e.slice(0,g),[p,e,g]);return Nf({wrapRef:w,onOutsideClick:()=>b(!1)}),A.jsxs("div",{ref:w,className:`${lt.listbox} ${c}`,children:[f,t?A.jsx("label",{className:`${lt["listBox-label"]} ${d==="floating"?lt["listBox-labelFloating"]:""}`,children:t}):null,A.jsxs("div",{className:`${lt.listboxButtonWrapper} ${l}`,children:[A.jsxs(Te,{className:`${lt["listBoxButton-container"]} ${d==="floating"?lt["listBoxButton-containerFloating"]:""}`,type:"button",variant:"custom",name:r,onClick:()=>b(I=>!I),children:[A.jsx("span",{className:lt.selectedOptionText,children:_==null?void 0:_.label}),A.jsx("span",{className:lt.listBoxButton,children:A.jsx(DA,{className:lt.arrowicon,"aria-hidden":"true"})})]}),A.jsx(Uv,{show:y,as:P.Fragment,leave:lt.leave,leaveFrom:lt.leaveFrom,leaveTo:lt.leaveTo,children:A.jsx("div",{className:lt["listBox-options"],children:A.jsxs(A.Fragment,{children:[u&&A.jsx(Gv,{className:lt.search,setSearchKeyword:v}),C.length===0?A.jsx("div",{className:lt.notAvailable,children:"Not Available."}):C.map(I=>A.jsxs(Te,{className:fr(i===I.value?lt.activeOption:lt.inactiveOption,lt.option),type:"button",variant:"custom",onClick:()=>{n==null||n(I.value),b(!1)},children:[A.jsx("span",{className:lt.optionLabel,style:S,children:I.label}),i===I.value?A.jsx("span",{className:lt.check,children:A.jsx(oG,{className:lt.checkIcon,"aria-hidden":"true"})}):null]},I.value)),g<=e.length&&A.jsxs(Te,{variant:"secondary",type:"button",onClick:()=>m(g+30),className:lt.loadMore,children:["Load More",A.jsx(tt,{name:"double-arrow-left-icon",className:lt.loadMoreIcon})]}),o]})})})]})]})},Lw=({control:r,name:t,...e})=>A.jsx(aw,{control:r,name:t,render:({field:{onChange:n,value:i}})=>A.jsx(ur,{...e,onChange:n,value:i})}),Sa=({options:r,defaultValue:t,value:e,onChange:n,label:i,name:a,className:o="",children:s,placeHolder:l,onClick:c,isSearchEnabled:u,containerClass:h="",labelVariant:f="static",icon:d})=>{const[p,v]=P.useState(""),[g,m]=P.useState(20),[y,b]=P.useState(!1),w=P.useRef(),_=P.useMemo(()=>p?r.filter(S=>S.label.toLowerCase().includes(p)).slice(0,g):r.slice(0,g),[p,r,g]);return Nf({wrapRef:w,onOutsideClick:()=>b(!1)}),P.useEffect(()=>{t&&t.length&&(n==null||n(t))},[]),A.jsx(A.Fragment,{children:A.jsxs("div",{ref:w,className:`${lt.listbox} ${h}`,children:[d,i?A.jsx("label",{className:`${lt["listBox-label"]} ${f==="floating"?lt["listBox-labelFloating"]:""}`,children:i}):null,A.jsxs("div",{className:lt.listboxButtonWrapper,children:[A.jsxs(Te,{className:`${lt["listBoxButton-container"]} ${o} ${f==="floating"?lt["listBoxButton-containerFloating"]:""}`,variant:"custom",type:"button",onClick:()=>b(S=>!S),name:a,children:[A.jsx("span",{className:lt.selectedOptionText,children:l||"Choose options from list"}),A.jsx("span",{className:lt.listBoxButton,children:A.jsx(DA,{className:lt.arrowicon,"aria-hidden":"true"})})]}),A.jsx(Uv,{show:y,as:P.Fragment,leave:lt.leave,leaveFrom:lt.leaveFrom,leaveTo:lt.leaveTo,children:A.jsxs("div",{className:lt["listBox-options"],children:[u&&A.jsx(Gv,{className:lt.search,setSearchKeyword:v}),_.length===0?A.jsx("div",{className:lt.notAvailable,children:"Not Available."}):_.map(S=>A.jsxs(Te,{className:fr(e!=null&&e.includes(S.value)?lt.optionSelected:"",lt.option),type:"button",variant:"custom",onClick:()=>{e!=null&&e.find(C=>C===S.value)?n==null||n(e.filter(C=>C!==S.value)):n==null||n([...e||[],S.value]),c==null||c()},children:[A.jsx("span",{className:lt.check,children:e!=null&&e.includes(S.value)?A.jsx("div",{className:lt.checkIconSelected,children:A.jsx(sG,{color:"white"})}):A.jsx("div",{className:lt.checkIconUnselected})}),A.jsx("span",{className:`${lt.optionLabel}`,children:S.label})]},S.value)),g<=r.length&&A.jsxs(Te,{variant:"secondary",type:"button",onClick:()=>m(g+30),className:lt.loadMore,children:["Load More",A.jsx(tt,{name:"double-arrow-left-icon",className:lt.loadMoreIcon})]}),s]})})]}),e!=null&&e.length?A.jsx("div",{className:lt.selectedList,children:e.map(S=>{var C;return A.jsx(we,{styleClass:"font-14c",variant:"p",className:lt.selectedListItem,children:(C=r.find(I=>I.value===S))==null?void 0:C.label},S)})}):null]})})},mQ=({control:r,name:t,...e})=>A.jsx(A.Fragment,{children:A.jsx(aw,{control:r,name:t,render:({field:{onChange:n,value:i}})=>A.jsx(Sa,{...e,name:t,value:i,onChange:n})})}),vs={label:"_label_1wy7g_1",floatingLabel:"_floatingLabel_1wy7g_7","inputField-container":"_inputField-container_1wy7g_13",checkboxLabel:"_checkboxLabel_1wy7g_19",input:"_input_1wy7g_13",floatingInput:"_floatingInput_1wy7g_31",checkboxField:"_checkboxField_1wy7g_37",inputWrapper:"_inputWrapper_1wy7g_43"},yQ={error:"_error_1csa7_1"},ig=({message:r=""})=>A.jsx(we,{variant:"p",styleClass:"custom",className:yQ.error,children:r}),Ye=({type:r="text",register:t,error:e,icon:n,label:i,isDisabled:a,labelClass:o,inputClass:s,className:l,labelVariant:c="static",id:u,...h})=>["checkbox","radio"].includes(r)?A.jsxs("div",{className:`${vs.checkboxField} ${l??""}`,children:[A.jsx("input",{...h,type:r,id:u,className:s,...t,disabled:a}),i?A.jsxs("label",{htmlFor:u,className:`${vs.checkboxLabel} ${o}`,children:[n," ",i]}):null]}):A.jsxs("div",{className:`${vs["inputField-container"]} ${l??""}`,children:[i?A.jsx("label",{htmlFor:u,className:`${vs.label} ${c==="floating"?vs.floatingLabel:""} ${o}`,children:i}):null,A.jsxs("div",{className:vs.inputWrapper,children:[A.jsx("input",{...h,id:u,type:r,className:`${vs.input} ${c==="floating"?vs.floatingInput:""} ${s}`,...t,disabled:a}),n]}),e&&A.jsx(ig,{message:e.message})]}),bQ=({data:r,chartSettings:t,setChartSettings:e,groupbyList:n})=>{var g,m;const[i,a]=P.useState(""),[o,s]=P.useState(""),[l,c]=P.useState(""),u=P.useMemo(()=>{const y=r?Object.keys(r[0]||{}).map(b=>({value:b,label:b})):[];return y.push({value:"NONE",label:"NONE"}),y},[r]),h=P.useMemo(()=>u==null?void 0:u.filter(y=>!n.includes(y.value)),[u]),f=P.useMemo(()=>u==null?void 0:u.filter(y=>n.includes(y.value)),[u]),d=P.useCallback(y=>{e(b=>({...b,yAxisList:y.filter(w=>w&&w!=="NONE"&&u.map(_=>_.value).includes(w))}))},[u]),p=P.useCallback(y=>{e(b=>({...b,pivotTableSettings:{...t.pivotTableSettings,rows:y.filter(w=>w&&w!=="NONE"&&(h==null?void 0:h.map(_=>_.value).includes(w)))}}))},[t.pivotTableSettings,u,e]),v=P.useCallback(y=>{e(b=>({...b,pivotTableSettings:{...t.pivotTableSettings,columns:y.filter(w=>w&&w!=="NONE"&&(f==null?void 0:f.map(_=>_.value).includes(w)))}}))},[t.pivotTableSettings,u,e]);return P.useEffect(()=>{i&&o&&l&&e(y=>({...y,sankeyValues:[i,o,l]}))},[i,o,l]),t.chartType===qY?A.jsxs("div",{className:di.container,children:[A.jsx(ur,{label:"Source",options:u,onChange:a,value:i}),A.jsx(ur,{label:"Target",options:u,onChange:s,value:o}),A.jsx(ur,{label:"Value",options:u,onChange:c,value:l})]}):t.chartType===ye.pivot?A.jsxs("div",{className:di.container,children:[A.jsx(Sa,{label:"Metrics",name:"metrics",options:h||[],defaultValue:h==null?void 0:h.map(y=>y.value),value:(g=t==null?void 0:t.pivotTableSettings)==null?void 0:g.rows,onChange:p}),A.jsx(Sa,{label:"Group by",name:"groupby",options:f||[],defaultValue:f==null?void 0:f.map(y=>y.value),value:(m=t==null?void 0:t.pivotTableSettings)==null?void 0:m.columns,onChange:v})]}):t.chartType===YA?A.jsx(A.Fragment,{children:!!(t.chartType===YA||QA)&&A.jsxs("div",{className:di.container,children:[A.jsx(ur,{label:"Dimension",options:u,onChange:y=>e(b=>({...b,xAxis:y})),value:t.xAxis}),A.jsx(Sa,{label:"Measure",name:"yAxisList",options:u,value:t.yAxisList,onChange:d})]})}):t.chartType===QA?A.jsx(A.Fragment,{children:A.jsxs("div",{className:di.container,children:[A.jsx(ur,{label:"Dimension",options:u,onChange:y=>e(b=>({...b,xAxis:y})),value:t.xAxis}),A.jsx(Sa,{name:"yAxisList",label:"Measure",options:u,value:t.yAxisList,onChange:d})]})}):t.chartType===ye.singleValue?A.jsx("div",{className:di.container,children:A.jsx(ur,{label:"Measure",options:u,onChange:y=>e(b=>({...b,singleValue:y})),value:t.singleValue})}):A.jsx(A.Fragment,{children:A.jsxs("div",{className:di.container,children:[![ye.gauge,ye.boxplot,ye.table].includes(t.chartType)&&A.jsx(A.Fragment,{children:t.chartType===ye.funnel?A.jsx(ur,{label:"Step",options:u,onChange:y=>e(b=>({...b,step:y})),value:t.step}):A.jsx(ur,{label:t.chartType===ye.row?"Y-axis":"X-axis",options:u,onChange:y=>e(b=>({...b,xAxis:y})),value:t.xAxis})}),[ye.funnel,ye.gauge,ye.boxplot].includes(t.chartType)?A.jsx(ur,{label:"Measure",options:u,onChange:y=>e(b=>({...b,measure:y})),value:t.measure}):A.jsxs(A.Fragment,{children:[A.jsx(Sa,{label:t.chartType===ye.row?"X-axis":t.chartType===ye.table?"Measure":"Y-axis",name:"yAxisList",options:u,value:t.yAxisList,onChange:d}),[ye.line,ye.bar,ye.timeSeries,ye.stack].includes(t.chartType)?A.jsxs(A.Fragment,{children:[A.jsx(Ye,{type:"checkbox",label:"Multi Series",className:di.checkboxTooltipWrapper,checked:t==null?void 0:t.isMultiDimension,onChange:y=>e(b=>({...b,isMultiDimension:y.target.checked,isDynamicSeries:!1}))}),A.jsx(Ye,{type:"checkbox",label:"dynamic group",className:di.checkboxTooltipWrapper,checked:t==null?void 0:t.isDynamicSeries,onChange:y=>e(b=>({...b,isDynamicSeries:y.target.checked,seriesField:"ungrouped"}))})]}):null,[ye.line,ye.bar,ye.timeSeries,ye.stack].includes(t.chartType)&&t.isMultiDimension?t.isDynamicSeries?A.jsx(Sa,{label:"Series Column",options:f,onChange:y=>e(b=>({...b,seriesField:(y==null?void 0:y[0])||"ungrouped",seriesOptions:y||[]})),value:t.seriesOptions||[]}):A.jsx(ur,{label:"Series Column",options:[{value:"ungrouped",label:"ungrouped"},...f],onChange:y=>e(b=>({...b,seriesField:y})),value:t.seriesField}):null]})]})})},wQ=[{name:"Line",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m3.5 18.5l6-6l4 4L22 6.92L20.59 5.5l-7.09 8l-4-4L2 17l1.5 1.5Z"})})},{name:"Bar",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M3 22V8h4v14H3m7 0V2h4v20h-4m7 0v-8h4v8h-4Z"})})},{name:"Combo",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M27 28V16h-8v12h-4V12H7v16H4V2H2v26a2 2 0 0 0 2 2h26v-2Zm-14 0H9V14h4Zm12 0h-4V18h4Z"}),A.jsx("path",{fill:"currentColor",d:"M22.786 14a1.988 1.988 0 0 1-1.18-.387L11.205 5.987L8.242 10L6.637 8.806l2.982-4a1.998 1.998 0 0 1 2.749-.446L22.789 12l3.604-4.86L28 8.33l-3.604 4.862a2.001 2.001 0 0 1-1.61.808Z"})]})},{name:"Scatter",icon:r=>A.jsxs("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M4 21h17v-2H5V3H3v17a1 1 0 0 0 1 1z"}),A.jsx("circle",{cx:10,cy:8,r:2,fill:"currentColor"}),A.jsx("circle",{cx:18,cy:12,r:2,fill:"currentColor"}),A.jsx("circle",{cx:11.5,cy:13.5,r:1.5,fill:"currentColor"}),A.jsx("circle",{cx:16.5,cy:6.5,r:1.5,fill:"currentColor"})]})},{name:"Row",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M4 22H2V2h2v20Zm11-1H5v-3h10v3Zm3-5H5v-3h13v3Zm3-5H5V8h16v3Zm-8-5H5V3h8v3Z"})})},{name:"Area",icon:r=>A.jsx("svg",{viewBox:"0 0 1024 1024",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm-616-64h536c4.4 0 8-3.6 8-8V284c0-7.2-8.7-10.7-13.7-5.7L592 488.6l-125.4-124a8.03 8.03 0 0 0-11.3 0l-189 189.6a7.87 7.87 0 0 0-2.3 5.6V720c0 4.4 3.6 8 8 8z"})})},{name:"Pie",icon:r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M7.5 1.018a7 7 0 0 0-4.79 11.566L7.5 7.793V1.018zm1 0V7.5h6.482A7.001 7.001 0 0 0 8.5 1.018zM14.982 8.5H8.207l-4.79 4.79A7 7 0 0 0 14.982 8.5zM0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8z"})})},{name:"Waterfall",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M28 28V18h-2v10h-4V4h-2v24H10V14H8v14H4V2H2v26a2.002 2.002 0 0 0 2 2h26v-2Z"}),A.jsx("path",{fill:"currentColor",d:"M14 4h2v14h-2z"})]})},{name:"Funnel",icon:r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M1.5 1.5A.5.5 0 0 1 2 1h12a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.128.334L10 8.692V13.5a.5.5 0 0 1-.342.474l-3 1A.5.5 0 0 1 6 14.5V8.692L1.628 3.834A.5.5 0 0 1 1.5 3.5v-2zm1 .5v1.308l4.372 4.858A.5.5 0 0 1 7 8.5v5.306l2-.666V8.5a.5.5 0 0 1 .128-.334L13.5 3.308V2h-11z"})})},{name:"Bubble",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"}),A.jsx("path",{fill:"currentColor",d:"M10 16a2 2 0 1 1-2 2a2 2 0 0 1 2-2m0-2a4 4 0 1 0 4 4a4 4 0 0 0-4-4zm11-8a4 4 0 1 1-4 4a4 4 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6zm3.5 17a1.5 1.5 0 1 1-1.5 1.5a1.5 1.5 0 0 1 1.5-1.5m0-2a3.5 3.5 0 1 0 3.5 3.5a3.5 3.5 0 0 0-3.5-3.5z"})]})},{name:"Doughnut",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M12.051 21.949a10 10 0 0 1-1-19.949v4.04a5.994 5.994 0 1 0 6.91 6.909H22a10.015 10.015 0 0 1-9.95 9Zm9.95-11h-4.04a5.993 5.993 0 0 0-4.91-4.909V2a10.022 10.022 0 0 1 8.95 8.948v.001Z"})})},{name:"Stepped",icon:r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M22 10V6H10v6H4V2H2v26a2.002 2.002 0 0 0 2 2h26V10Zm-10 4V8h8v4h8v10h-6v-6H12v6H4v-8ZM4 28v-4h10v-6h6v6h8v4Z"})})},{name:"Histogram",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M3 4h1v9h3V7h5v4h4v4h4v6H3V4m13 12v4h3v-4h-3m-4-4v8h3v-8h-3M8 8v12h3V8H8m-4 6v6h3v-6H4Z"})})},{name:"Gauge",icon:r=>A.jsx("svg",{viewBox:"0 0 20 20",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M8.127 13.6c-.689 1.197-.225 2.18.732 2.732c.956.553 2.041.465 2.732-.732c.689-1.195 5.047-11.865 4.668-12.084c-.379-.219-7.442 8.888-8.132 10.084zM10 6c.438 0 .864.037 1.281.109c.438-.549.928-1.154 1.405-1.728A9.664 9.664 0 0 0 10 4C4.393 4 0 8.729 0 14.766c0 .371.016.742.049 1.103c.049.551.54.955 1.084.908c.551-.051.957-.535.908-1.086A10.462 10.462 0 0 1 2 14.766C2 9.85 5.514 6 10 6zm7.219 1.25c-.279.75-.574 1.514-.834 2.174C17.4 10.894 18 12.738 18 14.766c0 .316-.015.635-.043.943a1.001 1.001 0 0 0 1.992.182c.033-.37.051-.748.051-1.125c0-2.954-1.053-5.59-2.781-7.516z"})})},{name:"Sankey",icon:r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M30 2H2v14h6.111a7.036 7.036 0 0 1 3.13.74L15.764 19l-4.522 2.26a7.036 7.036 0 0 1-3.13.74H2v8h7.223a9.045 9.045 0 0 0 4.025-.95l8.622-4.31A7.036 7.036 0 0 1 25 24h5V14h-5a7.036 7.036 0 0 1-3.13-.74L15.348 10H30ZM8 4h16v4H8ZM4 4h2v10H4Zm0 20h2v4H4Zm16.975-1.05l-8.622 4.31a7.036 7.036 0 0 1-3.13.74H8v-4h.111a9.045 9.045 0 0 0 4.025-.95L18 20.118l1.864.932a9.045 9.045 0 0 0 4.025.95H24v.058a9.052 9.052 0 0 0-3.025.892ZM28 22h-2v-6h2ZM12.354 10.74l8.621 4.31a9.052 9.052 0 0 0 3.025.89V20h-.111a7.036 7.036 0 0 1-3.13-.74l-8.622-4.31A9.045 9.045 0 0 0 8.11 14H8v-4h1.223a7.036 7.036 0 0 1 3.13.74ZM28 8h-2V4h2Z"})})},{name:"Stack",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M22 21H2V3h2v16h2v-2h4v2h2v-3h4v3h2v-2h4v4m-4-7h4v2h-4v-2m-6-8h4v3h-4V6m4 9h-4v-5h4v5M6 10h4v2H6v-2m4 6H6v-3h4v3Z"})})},{name:"Single value",icon:r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M2.873 11.297V4.142H1.699L0 5.379v1.137l1.64-1.18h.06v5.961h1.174Zm3.213-5.09v-.063c0-.618.44-1.169 1.196-1.169c.676 0 1.174.44 1.174 1.106c0 .624-.42 1.101-.807 1.526L4.99 10.553v.744h4.78v-.99H6.643v-.069L8.41 8.252c.65-.724 1.237-1.332 1.237-2.27C9.646 4.849 8.723 4 7.308 4c-1.573 0-2.36 1.064-2.36 2.15v.057h1.138Zm6.559 1.883h.786c.823 0 1.374.481 1.379 1.179c.01.707-.55 1.216-1.421 1.21c-.77-.005-1.326-.419-1.379-.953h-1.095c.042 1.053.938 1.918 2.464 1.918c1.478 0 2.642-.839 2.62-2.144c-.02-1.143-.922-1.651-1.551-1.714v-.063c.535-.09 1.347-.66 1.326-1.678c-.026-1.053-.933-1.855-2.359-1.845c-1.5.005-2.317.88-2.348 1.898h1.116c.032-.498.498-.944 1.206-.944c.703 0 1.206.435 1.206 1.07c.005.64-.504 1.106-1.2 1.106h-.75v.96Z"})})},{name:"BoxPlot",icon:r=>A.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M22 6V4H12v2h4v2h-4v12h4v2h-4v2h10v-2h-4v-2h4V8h-4V6Zm-8 12v-3h6v3Zm6-5h-6v-3h6Z"}),A.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"})]})},{name:"Table",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M8 16h5v-5H8v5Zm0-7h12V4H8Zm7 7h5v-5h-5Zm-7 2q-.825 0-1.412-.587Q6 16.825 6 16V4q0-.825.588-1.413Q7.175 2 8 2h12q.825 0 1.413.587Q22 3.175 22 4v12q0 .825-.587 1.413Q20.825 18 20 18Zm-4 4q-.825 0-1.412-.587Q2 20.825 2 20V6h2v14h14v2Z"})})},{name:"Time series",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M21 8c-1.5 0-2.3 1.4-1.9 2.5l-3.6 3.6c-.3-.1-.7-.1-1 0l-2.6-2.6c.4-1.1-.4-2.5-1.9-2.5c-1.4 0-2.3 1.4-1.9 2.5L3.5 16c-1.1-.3-2.5.5-2.5 2c0 1.1.9 2 2 2c1.4 0 2.3-1.4 1.9-2.5l4.5-4.6c.3.1.7.1 1 0l2.6 2.6c-.3 1 .5 2.5 2 2.5s2.3-1.4 1.9-2.5l3.6-3.6c1.1.3 2.5-.5 2.5-1.9c0-1.1-.9-2-2-2m-6 1l.9-2.1L18 6l-2.1-.9L15 3l-.9 2.1L12 6l2.1.9L15 9M3.5 11L4 9l2-.5L4 8l-.5-2L3 8l-2 .5L3 9l.5 2Z"})})},{name:"Pivot Table",icon:r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M22 15h-2v3c0 1.11-.89 2-2 2h-3v2l-3-3l3-3v2h3v-3h-2l3-3l3 3m0-11v4c0 1.1-.9 2-2 2H10v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h16c1.1 0 2 .9 2 2M4 8h4V4H4v4m0 2v4h4v-4H4m4 10v-4H4v4h4m6-12V4h-4v4h4m6-4h-4v4h4V4Z"})})}],_Q=({chartType:r,onChartChange:t,isEnableTimeSeries:e,isEnablePivotTable:n})=>A.jsx("div",{className:di.chartOptions,children:wQ.map(i=>A.jsxs("div",{className:di.chartOption,children:[A.jsx(Te,{type:"button",variant:"custom",className:r===i.name.toLowerCase()?di.chartOptionBtnSelected:di.chartOptionBtn,onClick:()=>{t(i.name.toLowerCase())},isDisabled:i.name.toLowerCase()===ye.timeSeries&&!e||i.name.toLowerCase()===ye.pivot&&!n,children:i.name.toLowerCase()===ye.timeSeries&&!e||i.name.toLowerCase()===ye.pivot&&!n?A.jsx(i.icon,{style:{color:"grey",width:"20px",height:"20px"}}):A.jsx(i.icon,{style:{color:"blue",width:"20px",height:"20px"}})},i.name),A.jsx(we,{variant:"p",styleClass:"custom",className:di.chartOptionText,children:i.name})]},i.name))}),SQ=({datatype:r="unknown",className:t})=>iQ.includes(r.toLowerCase())?A.jsx(tt,{name:"number-icon",className:t}):aQ.includes(r.toLowerCase())||r.toLowerCase().includes("char")?A.jsx(tt,{name:"text-icon",className:t}):oQ.includes(r.toLowerCase())?A.jsx(tt,{name:"array-icon",className:t}):nN.includes(r.toLowerCase())?A.jsx(tt,{name:"date-icon",className:t}):sQ.includes(r.toLowerCase())?A.jsx(tt,{name:"boolean-icon",className:t}):A.jsx(tt,{name:"unknown-icon"}),sN={container:"_container_1izll_1",windowIcon:"_windowIcon_1izll_7"},xQ=r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.5,children:[A.jsx("path",{d:"M15 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10"}),A.jsx("path",{strokeLinejoin:"round",d:"M2 7h20M5 5.01l.01-.011M8 5.01l.01-.011M11 5.01l.01-.011M18 22.243l2.121-2.122m0 0L22.243 18m-2.122 2.121L18 18m2.121 2.121l2.122 2.122"})]})}),MQ=()=>A.jsxs("div",{role:"alert",className:sN.container,children:[A.jsx(xQ,{className:sN.windowIcon}),A.jsx(we,{variant:"p",styleClass:"font-20",children:"Something went wrong!"}),A.jsx(Te,{variant:"primary",size:"large",type:"button",onClick:()=>location.reload(),children:"Try again"})]}),Nl={container:"_container_dv0n1_1",field:"_field_dv0n1_9",fieldLabel:"_fieldLabel_dv0n1_17",save:"_save_dv0n1_25",cancel:"_cancel_dv0n1_33",error:"_error_dv0n1_41"},ag={container:"_container_1rie6_1",label:"_label_1rie6_9",textarea:"_textarea_1rie6_17",resizable:"_resizable_1rie6_25"},CQ=({id:r,label:t,placeholder:e,rows:n,cols:i,resizable:a=!0,register:o,error:s,defaultValue:l,value:c,onFocus:u,onBlur:h,className:f})=>A.jsxs("div",{className:`${ag.container} ${f}`,children:[A.jsx("label",{htmlFor:r,className:ag.label,children:t}),A.jsx("textarea",{id:r,name:r,rows:n,cols:i,placeholder:e,className:fr(ag.textarea,`${a?null:ag.resizable}`),defaultValue:l,...o,value:c,onFocus:u,onBlur:h}),s&&A.jsx(ig,{message:s.message})]}),DQ=({name:r,styles:t,placeholder:e,enabled:n})=>A.jsxs("label",{htmlFor:r,className:`${t.button}`,children:[Array.isArray(e)&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.label} ${n?t.labelInactive:t.labelActive}`,children:e[0]}),A.jsx("span",{className:` ${t.switch} ${n?t.enabled:t.notenabled}`}),A.jsx("span",{className:` ${t.label} ${n?t.labelActive:t.labelInactive}`,children:e[1]})]}),typeof e=="string"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.switch} ${n?t.enabled:t.notenabled}`}),A.jsx("span",{className:` ${t.label} ${n?t.labelActive:t.labelInactive}`,children:e})]}),!Array.isArray(e)&&typeof e!="string"&&A.jsx("span",{className:` ${t.switch} ${n?t.enabled:t.notenabled}`})]}),og={group:"_group_4odq6_1",button:"_button_4odq6_9",toggleWidth:"_toggleWidth_4odq6_15",checkbox:"_checkbox_4odq6_23",switch:"_switch_4odq6_31",enabled:"_enabled_4odq6_49",notenabled:"_notenabled_4odq6_65",toggle:"_toggle_4odq6_15",label:"_label_4odq6_89",labelActive:"_labelActive_4odq6_97",labelInactive:"_labelInactive_4odq6_105",toggleInactive:"_toggleInactive_4odq6_113"},TQ=({name:r,styles:t,placeholder:e,enabled:n})=>A.jsxs("label",{htmlFor:r,className:`${t.button} ${t.toggleWidth}`,children:[Array.isArray(e)&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.label} ${n&&t.toggleInactive}`,children:e[0]}),A.jsx("span",{className:` ${t.switch} ${t.toggle} ${n?t.enabled:t.notenabled}
483
483
  `}),A.jsx("span",{className:` ${t.label} ${n||t.toggleInactive}`,children:e[1]})]}),typeof e=="string"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:` ${t.switch} ${t.toggle} ${n?t.enabled:t.notenabled}
484
484
  `}),A.jsx("span",{className:` ${t.label} ${n||t.labelInactive}`,children:e})]}),!Array.isArray(e)&&typeof e!="string"&&A.jsx("span",{className:` ${t.switch} ${t.toggle} ${n?t.enabled:t.notenabled}
485
485
  `})]}),IQ=({enabled:r,variant:t="switch",onChange:e,label:n,className:i="",placeholder:a,labelClassName:o,defaultEnabled:s,name:l=`toggle-${Date.now()}`})=>A.jsxs("div",{className:`${og.group} ${i}`,children:[n?A.jsx(we,{styleClass:"font-14",variant:"p",className:o,children:n}):null,A.jsx("input",{type:"checkbox",id:l,checked:s,onChange:({target:c})=>e==null?void 0:e(c.checked),className:og.checkbox}),t==="toggle"&&A.jsx(TQ,{name:l,styles:og,placeholder:a,enabled:r}),t==="switch"&&A.jsx(DQ,{name:l,styles:og,placeholder:a,enabled:r})]}),Mc={modal:"_modal_1myn6_1",popup:"_popup_1myn6_9",header:"_header_1myn6_17",headerTitle:"_headerTitle_1myn6_25",content:"_content_1myn6_33",footer:"_footer_1myn6_41"},sg=({children:r})=>{const[t,e]=P.useState();return P.useEffect(()=>{const n=document.querySelector("#dbn-portal")||document.createElement("div");if(n.setAttribute("id","dbn-portal"),document.body.querySelector("#dbn-portal")||document.body.appendChild(n),document.querySelector("dbn-dashboard")||document.querySelector("dbn-metric")){const i=document.querySelector("#dbn-styles"),a=n.shadowRoot||n.attachShadow({mode:"open"});if(i&&!a.querySelector("#dbn-portal-style")){const o=document.createElement("style");o.innerHTML=i.innerHTML,o.setAttribute("id","dbn-portal-style"),a.appendChild(o)}e(a)}else e(n)},[]),t?Oi.createPortal(r,t):null},Oo=({children:r,isOpen:t,onClose:e,headerTitle:n,customHeader:i,icon:a})=>A.jsx(sg,{children:t?A.jsx("div",{className:Mc.modal,onClick:e,children:A.jsxs("div",{className:Mc.popup,onClick:o=>{o.stopPropagation()},children:[A.jsx("section",{className:Mc.header,children:i||A.jsxs(A.Fragment,{children:[A.jsxs("span",{className:Mc.headerTitle,children:[a,n]}),A.jsx(Te,{variant:"custom",type:"button",onClick:e,children:A.jsx(tt,{name:"close-icon"})})]})}),A.jsx("section",{className:Mc.content,children:r})]})}):null}),Ef=({children:r,className:t})=>A.jsx("section",{className:`${Mc.footer} ${t}`,children:r}),lN=({onSubmit:r,defaultValues:t,onCancel:e,isEmbedded:n=!0,dashboardIds:i,onDashboardChange:a,companyId:o,error:s})=>{const{register:l,handleSubmit:c,setValue:u}=jv(),[h,f]=P.useState((t==null?void 0:t.isLive)??!1),d=c(m=>{r({...m,isLive:h})}),{data:p}=oY({companyId:o}),v=p==null?void 0:p.externalDashboards,g=n?(v==null?void 0:v.filter(m=>m.id===i[0]).map(m=>({value:m.id,label:m.name})))??[]:(v==null?void 0:v.map(m=>({value:m.id,label:m.name})))??[];return P.useEffect(()=>{t&&(u("name",t.name),u("description",t.description),u("metricId",t.metricId))},[t]),A.jsxs("form",{onSubmit:d,children:[A.jsxs("div",{className:Nl.container,children:[A.jsx(Sa,{label:"Dashboards",options:g,name:"dashboards",value:i,onChange:a}),A.jsx(Ye,{name:"name",type:"text",placeholder:"What is the name of metric?",label:"Metric Name",register:l("name",{required:!0}),defaultValue:t==null?void 0:t.name}),A.jsx(Ye,{name:"name",type:"text",placeholder:"Unique Id to identify metric",label:"Metric ID",register:l("metricId",{required:!0}),defaultValue:t==null?void 0:t.metricId}),A.jsx(CQ,{className:Nl.field,id:"desc",placeholder:"What is the name of metric?",label:"Description",rows:5,register:l("description"),defaultValue:t==null?void 0:t.description}),!n&&A.jsx(IQ,{className:Nl.field,labelClassName:Nl.fieldLabel,enabled:h,onChange:f,label:"Publish Type",placeholder:h?"LIVE MODE":"TEST MODE",defaultEnabled:t==null?void 0:t.isLive})]}),!!s&&A.jsx(we,{variant:"p",styleClass:"font-14",className:Nl.error,children:s}),A.jsxs(Ef,{children:[A.jsx(Te,{type:"reset",variant:"secondary",className:Nl.cancel,onClick:e,size:"default",children:"Cancel"}),A.jsx(Te,{type:"submit",variant:"primary",size:"small",className:Nl.save,isDisabled:!g.length||!i.length,children:"Save"})]})]})},Et={container:"_container_1u0lb_1",wrapper:"_wrapper_1u0lb_5",label:"_label_1u0lb_9",noOptions:"_noOptions_1u0lb_13",floatingLabel:"_floatingLabel_1u0lb_17",floatingLabel2:"_floatingLabel2_1u0lb_21",floating2:"_floating2_1u0lb_26",floatingText:"_floatingText_1u0lb_31",staticText:"_staticText_1u0lb_36",staticLabel:"_staticLabel_1u0lb_36",InnerText:"_InnerText_1u0lb_36",normalText:"_normalText_1u0lb_41",dropdown:"_dropdown_1u0lb_45",options:"_options_1u0lb_49",checkedOption:"_checkedOption_1u0lb_53",option:"_option_1u0lb_49",icon:"_icon_1u0lb_61",text:"_text_1u0lb_65",search:"_search_1u0lb_69",loadMore:"_loadMore_1u0lb_73",loadMoreIcon:"_loadMoreIcon_1u0lb_77",aboveList:"_aboveList_1u0lb_81"},Lf=r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m12 15.4l-6-6L7.4 8l4.6 4.6L16.6 8L18 9.4Z"})}),kw=r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m10.6 16.2l7.05-7.05l-1.4-1.4l-5.65 5.65l-2.85-2.85l-1.4 1.4ZM5 21q-.825 0-1.413-.587Q3 19.825 3 19V5q0-.825.587-1.413Q4.175 3 5 3h14q.825 0 1.413.587Q21 4.175 21 5v14q0 .825-.587 1.413Q19.825 21 19 21Z"})}),kf=r=>A.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"M5 21q-.825 0-1.413-.587Q3 19.825 3 19V5q0-.825.587-1.413Q4.175 3 5 3h14q.825 0 1.413.587Q21 4.175 21 5v14q0 .825-.587 1.413Q19.825 21 19 21Zm0-2h14V5H5v14Z"})}),Hr=({label:r,labelVariant:t="floating",selectedOption:e,onChange:n,className:i,buttonClass:a,options:o,isDisabled:s,children:l,icon:c,isSearchEnabled:u,closeControl:h,dropdownAbove:f})=>{const[d,p]=P.useState(!1),v=P.useRef(null),[g,m]=P.useState(""),[y,b]=P.useState(20),w=e.label||e.value;Nf({wrapRef:v,onOutsideClick:()=>p(!1)}),P.useEffect(()=>{h!=null&&h.close&&p(!1)},[h==null?void 0:h.close]);const _=P.useMemo(()=>g?o.filter(S=>S.label.toLowerCase().includes(g)).slice(0,y):o.slice(0,y),[g,o,y]);return A.jsxs("div",{className:fr(Et.container,i),ref:v,children:[r&&(t==="floating"||t==="static")?A.jsx(we,{variant:"span",styleClass:t==="floating"?"custom":"font-14",className:`${Et.label} ${t==="floating"?Et.floatingLabel:Et.staticLabel} ${c&&t==="floating"&&"left-8"}`,children:r}):r&&t==="floating-2"&&w?A.jsx(we,{variant:"span",styleClass:"custom",className:`${Et.label} ${Et.floatingLabel2}`,children:r}):null,A.jsxs(Te,{type:"button",variant:"custom",isDisabled:s,className:fr(Et.wrapper,a),onClick:()=>p(!d),children:[c&&t==="floating-2"&&!w?A.jsx(we,{variant:"span",styleClass:"custom",className:"mr-1",children:c}):null,c&&(t==="floating"||t==="static")?A.jsx(we,{variant:"span",styleClass:"custom",className:"mr-1",children:c}):null,A.jsx(we,{variant:"p",styleClass:"font-14",className:` grow text-left ${t==="floating"?Et.floatingText:Et.staticText}`,children:A.jsxs(we,{variant:"span",className:` ${Et.InnerText} ${t==="floating-2"&&!w&&Et.floating2}`,styleClass:"custom",children:[t==="floating"||t==="static"?w||"Select an option":null,t==="floating-2"?w||r||"Select option":null]})}),A.jsx("div",{children:A.jsx(Lf,{})})]}),d&&!s&&A.jsxs("div",{className:`${f?Et.aboveList:Et.dropdown}`,children:[u&&A.jsx(Gv,{className:Et.search,setSearchKeyword:m}),A.jsxs("div",{className:Et.options,children:[!_.length&&A.jsx("div",{className:Et.noOptions,children:"Not Available"}),_.map(S=>{const C=S.value===e.value;return A.jsx(Te,{type:"button",variant:"custom",className:C?Et.checkedOption:Et.option,onClick:()=>{n(S),p(!1)},children:S.label},S.key||S.value)}),y<=o.length&&A.jsxs(Te,{variant:"secondary",type:"button",onClick:()=>b(S=>S+20),className:Et.loadMore,children:["Load More"," ",A.jsx(tt,{name:"double-arrow-left-icon",className:Et.loadMoreIcon})]})]}),l]})]})},lg=P.memo(({label:r,labelVariant:t="floating",selectedOptions:e,onChange:n,className:i,options:a,isDisabled:o,children:s,isSearchEnabled:l,icon:c})=>{const[u,h]=P.useState(!1),f=P.useRef(null),[d,p]=P.useState(""),[v,g]=P.useState(20),m=P.useMemo(()=>d?a.filter(b=>b.label.toLowerCase().includes(d)).slice(0,v):a.slice(0,v),[d,a,v]);Nf({wrapRef:f,onOutsideClick:()=>h(!1)});const y=(b,w)=>{switch(b){case 0:return"Select options from the list";case 1:return`${w[0].value.toString().length>35?`${w[0].value.toString().substring(0,35)}...`:w[0].value}`;case 2:default:return`${w[0].value.toString().length>20?`${w[0].value.toString().substring(0,20)}...`:w[0].value}, ${w[1].value.toString().length>10?w[1].value.toString().substring(0,10):w[1].value}...`}};return A.jsxs("div",{className:fr(Et.container,i),ref:f,children:[r&&(t==="floating"||t==="static")?A.jsx(we,{variant:"span",styleClass:t==="floating"?"custom":"font-14",className:`${Et.label} ${t==="floating"?Et.floatingLabel:Et.staticLabel} ${c&&t==="floating"&&"left-8"}`,children:r}):r&&t==="floating-2"&&e.length?A.jsx(we,{variant:"span",styleClass:"custom",className:`${Et.label} ${Et.floatingLabel2}`,children:r}):null,A.jsxs(Te,{type:"button",variant:"custom",isDisabled:o,className:Et.wrapper,onClick:()=>h(!u),children:[c&&t==="floating-2"&&!e.length?A.jsx(we,{variant:"span",styleClass:"custom",className:"mr-1",children:c}):null,c&&(t==="floating"||t==="static")?A.jsx(we,{variant:"span",styleClass:"custom",className:"mr-1",children:c}):null,A.jsxs(we,{variant:"p",styleClass:"font-14",className:` grow text-left ${t==="floating"?Et.floatingText:Et.staticText} ${t==="floating-2"&&!e.length&&Et.floating2}`,children:[t==="floating"||t==="static"?y(e.length,e):null,t==="floating-2"?e.length?y(e.length,e):r||"Select option":null]}),A.jsx(Lf,{})]}),u&&!o&&A.jsxs("div",{className:Et.dropdown,children:[l&&A.jsx(Gv,{className:Et.search,setSearchKeyword:p}),A.jsxs("div",{className:Et.options,children:[!m.length&&A.jsx("div",{className:Et.noOptions,children:"Not Available"}),m.map(b=>{const w=!!e.find(_=>_.value===b.value);return A.jsxs(Te,{type:"button",variant:"custom",className:w?Et.checkedOption:Et.option,onClick:()=>{const _=w?e.filter(S=>S.value!==b.value):[...e,b];n(_)},children:[A.jsx(we,{variant:"span",styleClass:"custom",children:w?A.jsx(kw,{}):A.jsx(kf,{})}),b.label]},b.key||b.value)}),v<=a.length&&A.jsxs(Te,{variant:"secondary",type:"button",onClick:()=>g(b=>b+20),className:Et.loadMore,children:["Load More",A.jsx(tt,{name:"double-arrow-left-icon",className:Et.loadMoreIcon})]})]}),s]})]})}),uN=({companyId:r,filter:t,onChange:e,selectedOption:n,autoSelected:i=!0,integrationId:a,integrationName:o,...s})=>{const[l,c]=P.useState([]),{fetchColumnValues:u}=Nw();return P.useEffect(()=>{u({integrationId:a,integrationName:o,tableName:t.tableName,columnName:t.columnName},{onSuccess:h=>{var d;if(!((d=h.fetchColumnData)!=null&&d.data))return;const f=[];h.fetchColumnData.data.forEach(p=>{p&&f.push({label:p.label,value:p.value})}),c(f)}})},[t.tableName,t.columnName,r]),P.useEffect(()=>{l.length&&l[0]&&i&&e(l[0])},[l.length,l[0],i,t.columnName]),A.jsx(Hr,{onChange:e,selectedOption:t.defaultValue?{label:t.defaultValue,value:t.defaultValue}:n,isDisabled:!!t.defaultValue,options:l,label:t.columnName,...s})},Ow=P.memo(({filter:r,companyId:t,autoSelected:e,onChange:n,selectedOptions:i,label:a,integrationId:o,integrationName:s,...l})=>{const[c,u]=P.useState([]),{fetchColumnValues:h}=Nw();return P.useEffect(()=>{h({integrationId:o,integrationName:s,tableName:r.tableName,columnName:r.columnName},{onSuccess:f=>{var p;if(!((p=f.fetchColumnData)!=null&&p.data))return;const d=[];f.fetchColumnData.data.forEach(v=>{v&&d.push({label:v.label,value:v.value})}),u(d)}})},[r.tableName,r.columnName,t]),P.useEffect(()=>{c.length&&c[0]&&e&&n([c[0]])},[c.length,c[0],e,r.columnName]),A.jsx(lg,{onChange:n,selectedOptions:r.defaultValue?[{label:r.defaultValue,value:r.defaultValue}]:i,isDisabled:!!r.defaultValue,options:c,label:a||r.columnName,...l})}),AQ={fullscreen:"_fullscreen_1wo1t_1"};var Rw=function(r,t){return Rw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Rw(r,t)};function cN(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Rw(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Pw=function(){return Pw=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},Pw.apply(this,arguments)};/*! *****************************************************************************
@@ -605,7 +605,7 @@ echarts.use([`+M+"]);":"Unknown series "+x))}return}if(h==="tooltip"){if(b){proc
605
605
  * @copyright (c) 2099 Kent C. Dodds
606
606
  * @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
607
607
  */const oi={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};function Sye(r,t,e){var n;if(e=e||{},e.threshold=(n=e.threshold)!=null?n:oi.MATCHES,!e.accessors){const o=i5(r,t,e);return{rankedValue:r,rank:o,accessorIndex:-1,accessorThreshold:e.threshold,passed:o>=e.threshold}}const i=Dye(r,e.accessors),a={rankedValue:r,rank:oi.NO_MATCH,accessorIndex:-1,accessorThreshold:e.threshold,passed:!1};for(let o=0;o<i.length;o++){const s=i[o];let l=i5(s.itemValue,t,e);const{minRanking:c,maxRanking:u,threshold:h=e.threshold}=s.attributes;l<c&&l>=oi.MATCHES?l=c:l>u&&(l=u),l=Math.min(l,u),l>=h&&l>a.rank&&(a.rank=l,a.passed=!0,a.accessorIndex=o,a.accessorThreshold=h,a.rankedValue=s.itemValue)}return a}function i5(r,t,e){return r=a5(r,e),t=a5(t,e),t.length>r.length?oi.NO_MATCH:r===t?oi.CASE_SENSITIVE_EQUAL:(r=r.toLowerCase(),t=t.toLowerCase(),r===t?oi.EQUAL:r.startsWith(t)?oi.STARTS_WITH:r.includes(` ${t}`)?oi.WORD_STARTS_WITH:r.includes(t)?oi.CONTAINS:t.length===1?oi.NO_MATCH:xye(r).includes(t)?oi.ACRONYM:Mye(r,t))}function xye(r){let t="";return r.split(" ").forEach(n=>{n.split("-").forEach(a=>{t+=a.substr(0,1)})}),t}function Mye(r,t){let e=0,n=0;function i(l,c,u){for(let h=u,f=c.length;h<f;h++)if(c[h]===l)return e+=1,h+1;return-1}function a(l){const c=1/l,u=e/t.length;return oi.MATCHES+u*c}const o=i(t[0],r,0);if(o<0)return oi.NO_MATCH;n=o;for(let l=1,c=t.length;l<c;l++){const u=t[l];if(n=i(u,r,n),!(n>-1))return oi.NO_MATCH}const s=n-o;return a(s)}function a5(r,t){let{keepDiacritics:e}=t;return r=`${r}`,e||(r=_ye(r)),r}function Cye(r,t){let e=t;typeof t=="object"&&(e=t.accessor);const n=e(r);return n==null?[]:Array.isArray(n)?n:[String(n)]}function Dye(r,t){const e=[];for(let n=0,i=t.length;n<i;n++){const a=t[n],o=Tye(a),s=Cye(r,a);for(let l=0,c=s.length;l<c;l++)e.push({itemValue:s[l],attributes:o})}return e}const o5={maxRanking:1/0,minRanking:-1/0};function Tye(r){return typeof r=="function"?o5:{...o5,...r}}const Pt={"table-loader-container":"_table-loader-container_1tb4r_1",tableData:"_tableData_1tb4r_7",tableScroll:"_tableScroll_1tb4r_13",tableHeadCol:"_tableHeadCol_1tb4r_19",resizer:"_resizer_1tb4r_25",resizing:"_resizing_1tb4r_37",tableRow:"_tableRow_1tb4r_43",tableRowCol:"_tableRowCol_1tb4r_49",truncateText:"_truncateText_1tb4r_57",row:"_row_1tb4r_65",container:"_container_1tb4r_71",table:"_table_1tb4r_1",previewTable:"_previewTable_1tb4r_83",preview:"_preview_1tb4r_83",searchButton:"_searchButton_1tb4r_95",previewText:"_previewText_1tb4r_101",noData:"_noData_1tb4r_107",error:"_error_1tb4r_113",errorMsg:"_errorMsg_1tb4r_119",tableIcon:"_tableIcon_1tb4r_125",stripedRow:"_stripedRow_1tb4r_131",rowHover:"_rowHover_1tb4r_137",rightBorder:"_rightBorder_1tb4r_143",searchContainer:"_searchContainer_1tb4r_149",sortButton:"_sortButton_1tb4r_155",searchTab:"_searchTab_1tb4r_161",searchTabInput:"_searchTabInput_1tb4r_167",searchTabIcon:"_searchTabIcon_1tb4r_173",noDataHead:"_noDataHead_1tb4r_179",noDataBody:"_noDataBody_1tb4r_185",showSort:"_showSort_1tb4r_191",noSort:"_noSort_1tb4r_197",pagination:"_pagination_1tb4r_203",rowStyle:"_rowStyle_1tb4r_209",rowText:"_rowText_1tb4r_215",rowsDropdown:"_rowsDropdown_1tb4r_221",pageStyle:"_pageStyle_1tb4r_227",buttonContainer:"_buttonContainer_1tb4r_233",button:"_button_1tb4r_233",paginationWrapper:"_paginationWrapper_1tb4r_251",current:"_current_1tb4r_257",textTruncate:"_textTruncate_1tb4r_263"},Iye=({value:r,onChange:t,debounce:e=500,...n})=>{const[i,a]=P.useState(r);return P.useEffect(()=>{a(r)},[r]),P.useEffect(()=>{const o=setTimeout(()=>{t(i)},e);return()=>clearTimeout(o)},[e,t,i]),A.jsxs("div",{className:`${Pt.searchTab} ${n.className||""}`,children:[A.jsx("input",{...n,value:i,onChange:o=>a(o.target.value),className:Pt.searchTabInput}),i.toString().length?"":A.jsx(CA,{className:Pt.searchTabIcon,color:"#C7C7C7",width:"30px",height:"30px"})]})},Aye="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj48ZGVmcz48c3R5bGU+LmNscy0xe3N0cm9rZTojMTgyYzYwO30uY2xzLTEsLmNscy0ye2ZpbGw6bm9uZTtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7fS5jbHMtM3tmaWxsOiM1ODY1ZjY7b3BhY2l0eTouMTt9LmNscy00e2ZpbGw6I2YyZjNmNDt9LmNscy01e2ZpbGw6I2MxYzdjOTt9LmNscy02e2ZpbGw6IzE4MmM2MDt9LmNscy0ye3N0cm9rZTojNTg2NWY2O3N0cm9rZS13aWR0aDo0cHg7fTwvc3R5bGU+PC9kZWZzPjxwYXRoIGNsYXNzPSJjbHMtMyIgZD0ibTI3MS4xMSwxNzkuNzJsLS4wOSwyMC4zM3MuMTksNC4wNS4zOCw0LjUyLjc1LDEuODgsMS40MSwyLjM1LDEuMjcuOTksMi4yMSwxLjMyLDEuMTguNjEsMi42NC42MSwyMi42OC4wNSwyMi42OC4wNWwtMjkuMjItMjkuMThaIi8+PGxpbmUgY2xhc3M9ImNscy0xIiB4MT0iMjAzLjcxIiB5MT0iMjA4LjAxIiB4Mj0iMjM0LjkyIiB5Mj0iMjA4LjAxIi8+PGxpbmUgY2xhc3M9ImNscy0yIiB4MT0iMjAzLjcxIiB5MT0iMTk3LjM0IiB4Mj0iMjQ4LjA0IiB5Mj0iMTk3LjM0Ii8+PHJlY3QgY2xhc3M9ImNscy0xIiB4PSIyMDIuMyIgeT0iMjMwLjM2IiB3aWR0aD0iODkuOTUiIGhlaWdodD0iNjIuNjciIHJ4PSIzLjIxIiByeT0iMy4yMSIvPjxnPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0ibTMwMC40OSwyMDguOTl2OTkuOTljMCwzLjU1LTIuODgsNi40My02LjQzLDYuNDNoLTkzLjIzYy0zLjU1LDAtNi40My0yLjg4LTYuNDMtNi40M3YtMTIzLjA3YzAtMy41NSwyLjg4LTYuNDMsNi40My02LjQzaDcwLjI5Ii8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJtMjcxLjE1LDE3OS40OHYyMi45MWMwLDMuNTUsMi44OCw2LjQzLDYuNDMsNi40M2gyMi45MXMtMjkuMzQtMjkuNDgtMjkuMzQtMjkuMzRaIi8+PC9nPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0ibTMwNS40OSwyMTMuOTl2OTkuOTljMCwzLjU1LTIuODgsNi40My02LjQzLDYuNDNoLTkzLjIzYy0yLjk1LDAtNS40My0xLjk4LTYuMTktNC42OSIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0ibTMwNS40OSwyMTMuODJzLTIuMTMtMi4xNC01LjI0LTUuMjYiLz48cGF0aCBjbGFzcz0iY2xzLTYiIGQ9Im0xOTkuNTQsMzE1LjUzcy4yOCwxLjA0LjY2LDEuNi41NiwxLjA4LDEuMzIsMS42OSwyLjEyLDEuNDYsMi40LDEuNTEsMi43My4yNCwzLjg2LjE5LDIwLjM4LS4wOSwyMC4zOC0uMDloMjMuNjdzMTcuMDQtLjA1LDE3LjA0LS4wNWwxNy42OS4xNCwxMi43NS0uMTRzMS45OC0uMTksMi43OC0uNzEsMS42NS0xLjA0LDIuMTItMS44NCwxLjIyLTEuODQsMS4yNy0yLjM1LjE0LTE0LjQuMTQtMTQuNGwtLjE5LTExLjYyLjA5LTExLjk1di0yMi4xMnMtLjA1LTE4LjEyLS4wNS0xOC4xMnYtMjMuMzRzLTUuMDQtNS4yMi01LjA0LTUuMjJsLjA1LDI1LjYuMTQsMjguOTktLjA1LDEzLjg0LS4wNSw5Ljc0djEwLjRzMCw5Ljc5LDAsOS43OWMwLDAsLjE5LDMuMDYtLjQ3LDQuMDlzLTEuMzYsMi4zNS0yLjIxLDIuOTYtMi4wNywxLjE4LTQuNzEsMS4yMi0xNC44Ny4wNS0xNC44Ny4wNWwtMjEuNzktLjA1aC0xNi4wNWwtMjUuODguMDUtMTUuMDEuMTRaIi8+PGxpbmUgY2xhc3M9ImNscy0xIiB4MT0iMjAyLjYzIiB5MT0iMjM5LjAzIiB4Mj0iMjkyLjAxIiB5Mj0iMjM5LjAzIi8+PGxpbmUgY2xhc3M9ImNscy0xIiB4MT0iMjE5LjUiIHkxPSIyMzAuNjEiIHgyPSIyMTkuNzkiIHkyPSIyOTMuMDkiLz48bGluZSBjbGFzcz0iY2xzLTEiIHgxPSIyMzcuNzYiIHkxPSIyMzAuNTMiIHgyPSIyMzguMDUiIHkyPSIyOTMiLz48bGluZSBjbGFzcz0iY2xzLTEiIHgxPSIyNTYuMDIiIHkxPSIyMzAuNDUiIHgyPSIyNTYuMzEiIHkyPSIyOTIuOTIiLz48bGluZSBjbGFzcz0iY2xzLTEiIHgxPSIyNzQuMjgiIHkxPSIyMzAuMzYiIHgyPSIyNzQuNTciIHkyPSIyOTIuODQiLz48Zz48cmVjdCBjbGFzcz0iY2xzLTUiIHg9IjIwNi4xNyIgeT0iMjMyLjc5IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy01IiB4PSIyMjQuMjMiIHk9IjIzMi43OSIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNSIgeD0iMjQyLjY5IiB5PSIyMzIuNzkiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTUiIHg9IjI2MC42MiIgeT0iMjMyLjc5IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy01IiB4PSIyNzguODMiIHk9IjIzMi43OSIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48Zz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjIwNi4xNyIgeT0iMjQ0LjA4IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyMjQuMjMiIHk9IjI0NC4wOCIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNCIgeD0iMjQyLjY5IiB5PSIyNDQuMDgiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjI2MC42MiIgeT0iMjQ0LjA4IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyNzguODMiIHk9IjI0NC4wOCIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48Zz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjIwNi4xNyIgeT0iMjUyLjU1IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyMjQuMjMiIHk9IjI1Mi41NSIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNCIgeD0iMjQyLjY5IiB5PSIyNTIuNTUiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjI2MC42MiIgeT0iMjUyLjU1IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyNzguODMiIHk9IjI1Mi41NSIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48Zz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjIwNi4xNyIgeT0iMjYxLjAyIiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyMjQuMjMiIHk9IjI2MS4wMiIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNCIgeD0iMjQyLjY5IiB5PSIyNjEuMDIiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjI2MC42MiIgeT0iMjYxLjAyIiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyNzguODMiIHk9IjI2MS4wMiIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48Zz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjIwNi4xNyIgeT0iMjY5LjQ5IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyMjQuMjMiIHk9IjI2OS40OSIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNCIgeD0iMjQyLjY5IiB5PSIyNjkuNDkiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjI2MC42MiIgeT0iMjY5LjQ5IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyNzguODMiIHk9IjI2OS40OSIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48Zz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjIwNi4xNyIgeT0iMjc3Ljk2IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyMjQuMjMiIHk9IjI3Ny45NiIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNCIgeD0iMjQyLjY5IiB5PSIyNzcuOTYiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjI2MC42MiIgeT0iMjc3Ljk2IiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyNzguODMiIHk9IjI3Ny45NiIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48Zz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjIwNi4xNyIgeT0iMjg2LjQzIiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyMjQuMjMiIHk9IjI4Ni40MyIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjxyZWN0IGNsYXNzPSJjbHMtNCIgeD0iMjQyLjY5IiB5PSIyODYuNDMiIHdpZHRoPSI4LjQ3IiBoZWlnaHQ9IjQiLz48cmVjdCBjbGFzcz0iY2xzLTQiIHg9IjI2MC42MiIgeT0iMjg2LjQzIiB3aWR0aD0iOC40NyIgaGVpZ2h0PSI0Ii8+PHJlY3QgY2xhc3M9ImNscy00IiB4PSIyNzguODMiIHk9IjI4Ni40MyIgd2lkdGg9IjguNDciIGhlaWdodD0iNCIvPjwvZz48L3N2Zz4=",Gu=r=>A.jsxs("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...r,children:[A.jsx("path",{fill:"currentColor",d:"M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z",opacity:.5}),A.jsx("path",{fill:"currentColor",d:"M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z",children:A.jsx("animateTransform",{attributeName:"transform",dur:"1s",from:"0 12 12",repeatCount:"indefinite",to:"360 12 12",type:"rotate"})})]}),Nye=r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m16 28l-7-7l1.41-1.41L16 25.17l5.59-5.58L23 21l-7 7zm0-24l7 7l-1.41 1.41L16 6.83l-5.59 5.58L9 11l7-7z"})}),Eye=r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m16 4l7 7l-1.4 1.4L16 6.8l-5.6 5.6L9 11z"})}),Lye=r=>A.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",d:"m16 28l-7-7l1.4-1.4l5.6 5.6l5.6-5.6L23 21z"})}),kye=({rules:r,value:t})=>{const e=r.find(n=>{const{operator:i,value:a}=n;return!!(i==="isEqualTo"&&t===a||i==="isNotEqualTo"&&t!==a||i==="isNull"&&t===null||i==="isNotNull"&&t!==null||typeof t=="string"&&i==="contains"&&t.includes(a)||typeof t=="string"&&i==="doesNotContain"&&!t.includes(a)||typeof t=="string"&&i==="startsWith"&&t.startsWith(a)||typeof t=="string"&&i==="endsWith"&&t.endsWith(a)||i==="isLessThan"&&t<a||i==="isGreaterThan"&&t>a||i==="isLessThanOrEqualTo"&&t<=a||i==="isGreaterThanOrEqualTo"&&t>=a)});return e?e.styles:{}},Oye=lye(),Vh=({data:r,isLoading:t,error:e,tableSettings:n,tableName:i,className:a="",onColumnSizingChange:o,onChartReady:s,onChangePage:l,isExternalChart:c,isEnableNextBtn:u,isEnablePrevBtn:h,paginationInfo:f={limit:10,offset:0,totalRecords:10},setChartSettings:d})=>{var R,z;const{divStyle:p,headerStyle:v}=P.useMemo(()=>{const F=(n==null?void 0:n.lineGap)==="small"?"1.5rem":(n==null?void 0:n.lineGap)==="medium"?"1.9rem":"2.5rem",W=(n==null?void 0:n.lineGap)==="small"?"0.7rem":(n==null?void 0:n.lineGap)==="medium"?"0.85":"1rem";return{divStyle:{width:"100%",height:F,fontSize:W,display:"flex",alignItems:"center",justifyContent:n!=null&&n.contentAlignment?`${n.contentAlignment}`:""},headerStyle:{width:"100%",color:"#182c60",fontSize:W,height:F,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"500"}}},[n==null?void 0:n.lineGap,n==null?void 0:n.contentAlignment]),[g,m]=P.useState([]),[y,b]=P.useState({}),[w,_]=P.useState({label:((R=Jn.tableSettings)==null?void 0:R.defaultRowSize)||"10",value:((z=Jn.tableSettings)==null?void 0:z.defaultRowSize)||"10"}),[S,C]=P.useState(n==null?void 0:n.columnSizing),[I,D]=P.useState(""),T=(F,W,B,H)=>{const G=Sye(F.getValue(W),B);return H({itemRank:G}),G.passed},[x,M]=P.useState({pageIndex:0,pageSize:10});P.useEffect(()=>{o==null||o(S)},[S]),P.useEffect(()=>{var B,H;if(!(n!=null&&n.defaultRowSize))return;const F=Ew.find(G=>G.value===n.defaultRowSize),W={label:((B=Jn.tableSettings)==null?void 0:B.defaultRowSize)||"10",value:((H=Jn.tableSettings)==null?void 0:H.defaultRowSize)||"10"};_(F||W)},[n==null?void 0:n.defaultRowSize]);const N=P.useMemo(()=>{if(!r||!Array.isArray(r))return[];const{pageIndex:F,pageSize:W}=x;return r.slice(F*W,(F+1)*W)},[x,r,I]),E=P.useMemo(()=>Object.keys((r==null?void 0:r[0])||{}).map(F=>Oye.accessor(F,{header:()=>F,cell:W=>{const B=W.row.original[F];return typeof B=="object"?JSON.stringify(B):typeof B=="boolean"?B?"true":"false":B}})),[r==null?void 0:r[0]]),L=yye({data:I?Array.isArray(r)?r:[]:N,columns:E,filterFns:{fuzzy:T},state:{sorting:g,globalFilter:I,pagination:x,...S?{columnSizing:S}:{}},enableGlobalFilter:!0,onRowSelectionChange:b,onSortingChange:m,globalFilterFn:T,getCoreRowModel:uye(),getFilteredRowModel:dye(),getSortedRowModel:pye(),onGlobalFilterChange:D,onPaginationChange:M,manualPagination:!0,debugTable:!1,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:C});P.useEffect(()=>{L.setPageSize(Number(w.value))},[w,L]);const k=P.useMemo(()=>{const{pageIndex:F,pageSize:W}=L.getState().pagination,B=I?L.getRowModel().rows.length:(r==null?void 0:r.length)||0,H=B===0?0:W*F+1,G=B<=W*(F+1)?B:W*(F+1);return{from:H,to:G,total:B}},[I,r,L.getState().pagination,L.getRowModel().rows.length]);let O;if(c){const F=Uu(f.totalRecords,!0).toString().split(".");F.length>1&&[...F[1]].some(W=>parseInt(W,10)>0)?O=Uu(f.totalRecords,!0):O=Uu(f.totalRecords,!1)}return P.useEffect(()=>{L.getIsSomeColumnsVisible()&&(s==null||s())},[L.getIsSomeColumnsVisible()]),A.jsx("div",{className:`${Pt.container} ${a}`,children:A.jsxs("div",{className:Pt.previewTable,children:[n!=null&&n.enableTableSearch||n!=null&&n.showTableTitle?A.jsxs("div",{className:n.showTableTitle?Pt.preview:Pt.searchButton,children:[n.showTableTitle&&A.jsx(we,{styleClass:"font-14c",variant:"h1",className:Pt.previewText,children:i}),n.enableTableSearch&&A.jsx(Iye,{value:I,onChange:F=>D(String(F)),placeholder:"Search"})]}):null,A.jsxs("div",{className:Pt.tableData,children:[t&&!(r!=null&&r.length)&&A.jsx("div",{className:Pt["table-loader-container"],children:A.jsx(Gu,{style:{width:"50px",height:"50px",color:"blue"}})}),!!(r!=null&&r.length)&&!t&&A.jsx(WB,{style:{height:"100%"},children:A.jsxs("table",{className:Pt.table,children:[A.jsx("thead",{children:L.getHeaderGroups().map(F=>A.jsx("tr",{className:Pt.row,children:F.headers.map(W=>A.jsxs("th",{className:Pt.tableHeadCol,colSpan:W.colSpan,style:{width:W.getSize()},children:[A.jsx("button",{onMouseDown:W.getResizeHandler(),onTouchStart:W.getResizeHandler(),onDoubleClick:W.column.resetSize,className:`${Pt.resizer} ${W.column.getIsResizing()?Pt.resizing:""}`,type:"button",title:"Resize Column"}),n!=null&&n.enableSorting?A.jsxs("div",{className:W.column.getCanSort()?Pt.sortButton:"",onClick:W.column.getToggleSortingHandler(),children:[W.isPlaceholder?null:A.jsx("div",{style:v,children:O0(W.column.columnDef.header,W.getContext())}),{asc:A.jsx(Eye,{color:"#182c60"}),desc:A.jsx(Lye,{color:"#182c60"})}[W.column.getIsSorted()]??A.jsx(Nye,{color:"#182c60"})]}):A.jsx(A.Fragment,{children:W.isPlaceholder?null:A.jsx("div",{style:v,children:A.jsx(we,{variant:"p",styleClass:"custom",className:Pt.truncateText,children:O0(W.column.columnDef.header,W.getContext())})})})]},W.id))},F.id))}),A.jsx("tbody",{children:(I?L.getRowModel().rows.slice(x.pageSize*x.pageIndex,x.pageSize*(1+x.pageIndex)):L.getRowModel().rows).map((F,W)=>A.jsx("tr",{className:`${Pt.tableRow} ${n!=null&&n.showRowHover?Pt.rowHover:""} ${n!=null&&n.enableStripedRows&&Number(W)%2!==0?Pt.stripedRow:""}`,children:F.getVisibleCells().map(B=>{var H,G;return A.jsxs("td",{className:`${Pt.tableRowCol} ${n!=null&&n.hideVerticalDivider?"":Pt.rightBorder}`,title:typeof B.getValue()=="object"?JSON.stringify(B.getValue()):B.getValue(),children:[!!n&&A.jsx("div",{style:{...p,...kye({rules:((G=(H=n.conditionalFormatting)==null?void 0:H.find(({columnName:$})=>$===B.column.id))==null?void 0:G.rules)||[],value:typeof B.getValue()=="object"?JSON.stringify(B.getValue()):B.getValue()})},children:A.jsx(we,{variant:"p",styleClass:"custom",className:Pt.truncateText,children:O0(B.column.columnDef.cell,B.getContext())})}),!n&&A.jsx("div",{style:{textAlign:"center",width:"100%"},children:O0(B.column.columnDef.cell,B.getContext())})]},B.id)})},F.id))})]})}),!(r!=null&&r.length)&&!t&&!e.length&&A.jsxs("div",{className:Pt.noData,children:[A.jsx("img",{src:Aye,alt:"no-data",width:"400px",height:"400px"}),A.jsx(we,{styleClass:"font-14c",variant:"h1",className:Pt.noDataHead,children:"No data tables queried"}),A.jsx(we,{styleClass:"font-14",variant:"p",className:Pt.noDataBody,children:"Type your query and input fields beside to generate results and explore data"})]}),e&&A.jsx("div",{className:Pt.error,children:A.jsx(we,{styleClass:"primary",className:Pt.errorMsg,variant:"p",children:e})})]}),r&&!(n!=null&&n.disablePagination)&&A.jsxs("div",{className:Pt.pagination,children:[A.jsx("div",{className:Pt.rowStyle,children:A.jsx(Hr,{onChange:F=>{_(F),c&&(l==null||l(!1,parseInt(F.value,10)),d==null||d(W=>({...W,tableSettings:{...W.tableSettings,defaultRowSize:F.value}})))},selectedOption:w,options:Ew,labelVariant:"static",dropdownAbove:!0,buttonClass:Pt.rowsDropdown})}),c?A.jsxs("span",{className:Pt.pageStyle,children:[f.offset+1,"-",f.offset+r.length," of ",O]}):A.jsxs("span",{className:Pt.pageStyle,children:[k.from,"-",k.to," of ",k.total]}),A.jsxs("div",{className:Pt.buttonContainer,children:[A.jsx(Te,{variant:"custom",type:"button",className:Pt.button,onClick:()=>{c?l==null||l(!0):L.previousPage()},isDisabled:c?!h:k.from<=1,children:"Prev"}),A.jsx(Te,{variant:"custom",type:"button",className:Pt.button,onClick:()=>{c?l==null||l(!1):L.nextPage()},isDisabled:c?!u:k.to>=k.total,children:"Next"})]})]})]})})},R0=P.memo(({chartOptions:r,data:t,events:e,colors:n,config:i,className:a})=>{const o=P.useMemo(()=>nme({chartOptions:r,data:t,colors:n}),[t,r,n]),[s,l]=P.useState(!0);return P.useEffect(()=>{l(!1)},[]),r.chartType===ye.singleValue?A.jsx(Xge,{...i,value:o.value,settings:o.settings,className:a,comparisonValue:o.comparisonValue,trendLineOptions:o.trendLineOptions,events:e}):r.chartType===ye.table?A.jsx(Vh,{...i,data:o.data,error:"",isLoading:!1,tableSettings:o.tableSettings,className:a,isExternalChart:i==null?void 0:i.isExternalChart,onChangePage:i==null?void 0:i.onChangePage,isEnableNextBtn:i==null?void 0:i.isEnableNextBtn,isEnablePrevBtn:i==null?void 0:i.isEnablePrevBtn,paginationInfo:i==null?void 0:i.paginationInfo,setChartSettings:i==null?void 0:i.setChartSettings}):r.chartType===ye.pivot?A.jsx(ime,{...i,data:t,pivotTableSettings:o.pivotTableSettings}):A.jsx(DB,{style:{width:"100%",height:"100%"},...i,option:{...o,animation:s},className:a,onEvents:e,notMerge:!0})}),Rye=({isShow:r,onCancel:t,...e})=>A.jsx(Oo,{isOpen:r,onClose:t,headerTitle:"Chart Preview",children:A.jsx("div",{className:AQ.fullscreen,children:A.jsx(R0,{...e})})}),SLe={button:"_button_1ecv1_1",menu:"_menu_1ecv1_7",menuContainer:"_menuContainer_1ecv1_13",buttonText:"_buttonText_1ecv1_19",buttonIcon:"_buttonIcon_1ecv1_25",filterName:"_filterName_1ecv1_31",filterDropdown:"_filterDropdown_1ecv1_37"},Pye=r=>{const t=document.documentElement;r.colors&&Object.entries(r.colors).forEach(([e,n])=>{e&&n&&t.style.setProperty(`--databrainhq-plugin-color-${e}`,`${n}`)}),r.border&&Object.entries(r.border).forEach(([e,n])=>{e&&n&&t.style.setProperty(`--databrainhq-plugin-border-${e}`,`${n}`)}),r.shadow&&Object.entries(r.shadow).forEach(([e,n])=>{e&&n&&t.style.setProperty(`--databrainhq-plugin-shadow-${e}`,`${n}`)}),r.typography&&Object.entries(r.typography).forEach(([e,n])=>{e&&n&&t.style.setProperty(`--databrainhq-plugin-typography-${e}`,`${n}`)}),r.breakpoint&&Object.entries(r.breakpoint).forEach(([e,n])=>{e&&n&&t.style.setProperty(`--databrainhq-plugin-breakpoint-${e}`,`${n}`)})},$ye=r=>{const t="data:text/csv;charset=utf-8,";if(!r.length)return t;const e=[],n=r[0],i=Object.keys(n);e.push(`S.NO,${i.join(",").toUpperCase()}`),r.forEach((s,l)=>{const c=Object.values(s).map(u=>{if(typeof u=="number")return u;try{if(u!=null&&u.includes(","))return`"${u}"`}catch{return u}return u});e.push(`${l+1},${c.join(",")}`)});const a=e.join(`
608
- `);return encodeURI(t+a)},jye=(r,t,e)=>{const n=r.clientX-t.left+5,i=r.clientY-t.top-50,a=t.width-e.width,o=t.height-e.height,s=Math.max(0,Math.min(n,a)),l=Math.max(0,Math.min(i,o));return[s,l]},zye=(r,t,e)=>{r.style.left=`${t}px`,r.style.top=`${e}px`},ua={container:"_container_1qflp_1",popover:"_popover_1qflp_9",button:"_button_1qflp_17",buttonOpen:"_buttonOpen_1qflp_25",menu:"_menu_1qflp_33",enter:"_enter_1qflp_41",enterFrom:"_enterFrom_1qflp_49",enterTo:"_enterTo_1qflp_57",leave:"_leave_1qflp_65",leaveFrom:"_leaveFrom_1qflp_73",leaveTo:"_leaveTo_1qflp_81",center:"_center_1qflp_89",top:"_top_1qflp_97",bottom:"_bottom_1qflp_105",left:"_left_1qflp_113",right:"_right_1qflp_121","left-top-end":"_left-top-end_1qflp_129","right-top-end":"_right-top-end_1qflp_137","left-bottom-end":"_left-bottom-end_1qflp_145","right-bottom-end":"_right-bottom-end_1qflp_153","top-left":"_top-left_1qflp_161","top-right":"_top-right_1qflp_169","bottom-left":"_bottom-left_1qflp_177","bottom-right":"_bottom-right_1qflp_185","left-top":"_left-top_1qflp_129","left-bottom":"_left-bottom_1qflp_145","right-top":"_right-top_1qflp_137","right-bottom":"_right-bottom_1qflp_153"},So=({className:r="",menuClass:t="",menuContainerClass:e="",buttonClass:n="",children:i,button:a,position:o="bottom",isDisabled:s})=>{const[l,c]=P.useState(!1);return A.jsx(A.Fragment,{children:A.jsxs("div",{className:`${ua.container} ${r}`,onBlur:u=>{u.currentTarget.contains(u.relatedTarget)||c(!1)},tabIndex:-1,children:[A.jsx(Te,{className:`${n} ${l?ua.buttonOpen:""} ${ua.button}`,type:"button",variant:"custom",onClick:()=>!s&&c(u=>!u),children:a}),s?null:A.jsx("div",{className:`${ua.popover} ${ua[o]} ${e}`,children:A.jsx(Uv,{as:"div",className:`${ua.menu} ${t}`,show:l,enter:ua.enter,enterFrom:ua.enterFrom,enterTo:ua.enterTo,leave:ua.leave,leaveFrom:ua.leaveFrom,leaveTo:ua.leaveTo,children:i})})]})})},Fye=r=>["IN","NOT IN"].includes(r),Bye=r=>["IS NULL","IS NOT NULL"].includes(r),ct={container:"_container_uxvi9_1",form:"_form_uxvi9_7",filterHeader:"_filterHeader_uxvi9_23",titleContent:"_titleContent_uxvi9_29",title:"_title_uxvi9_29",buttons:"_buttons_uxvi9_41",apply:"_apply_uxvi9_47",applyIcon:"_applyIcon_uxvi9_53",reset:"_reset_uxvi9_59",filterFieldsContainer:"_filterFieldsContainer_uxvi9_67",filterFields:"_filterFields_uxvi9_67",filterContainer:"_filterContainer_uxvi9_91",AddFilter:"_AddFilter_uxvi9_97",filterDropdown:"_filterDropdown_uxvi9_103",filterDropdowns:"_filterDropdowns_uxvi9_111",noFilters:"_noFilters_uxvi9_111",gridColAndRow:"_gridColAndRow_uxvi9_127",gridCol1:"_gridCol1_uxvi9_135",gridCol2:"_gridCol2_uxvi9_143",gridCol3:"_gridCol3_uxvi9_151",filters:"_filters_uxvi9_159",filterItem:"_filterItem_uxvi9_165",filterItemOperator:"_filterItemOperator_uxvi9_171",remove:"_remove_uxvi9_177",filterCol:"_filterCol_uxvi9_183",filterText:"_filterText_uxvi9_189",smallText:"_smallText_uxvi9_195",numberFieldPopup:"_numberFieldPopup_uxvi9_203",numberField:"_numberField_uxvi9_203",numberFieldWrapper:"_numberFieldWrapper_uxvi9_219",numberFieldLabel:"_numberFieldLabel_uxvi9_227",selectedLabel:"_selectedLabel_uxvi9_235",numberFieldLabelText:"_numberFieldLabelText_uxvi9_243",numberFieldLabelSelectText:"_numberFieldLabelSelectText_uxvi9_251",numberFieldButtonClass:"_numberFieldButtonClass_uxvi9_259",numberFieldLabelMenuClass:"_numberFieldLabelMenuClass_uxvi9_267",numberFieldClearButton:"_numberFieldClearButton_uxvi9_275",numberFieldFooter:"_numberFieldFooter_uxvi9_283",checkedOption:"_checkedOption_uxvi9_291",option:"_option_uxvi9_299",addFilterMenu:"_addFilterMenu_uxvi9_307",appliedFilterTag:"_appliedFilterTag_uxvi9_315",appliedfilters:"_appliedfilters_uxvi9_323",textBold:"_textBold_uxvi9_331",filterButton:"_filterButton_uxvi9_339",filterBtnText:"_filterBtnText_uxvi9_347",filterLength:"_filterLength_uxvi9_355",addfilter:"_addfilter_uxvi9_363",alertContainer:"_alertContainer_uxvi9_371"};var Vye=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=[]),t.length!==e.length||t.some(function(n,i){return!Object.is(n,e[i])})},s5={error:null},Wye=function(r){Tl(t,r);function t(){for(var n,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return n=r.call.apply(r,[this].concat(a))||this,n.state=s5,n.resetErrorBoundary=function(){for(var s,l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];n.props.onReset==null||(s=n.props).onReset.apply(s,c),n.reset()},n}t.getDerivedStateFromError=function(i){return{error:i}};var e=t.prototype;return e.reset=function(){this.setState(s5)},e.componentDidCatch=function(i,a){var o,s;(o=(s=this.props).onError)==null||o.call(s,i,a)},e.componentDidUpdate=function(i,a){var o=this.state.error,s=this.props.resetKeys;if(o!==null&&a.error!==null&&Vye(i.resetKeys,s)){var l,c;(l=(c=this.props).onResetKeysChange)==null||l.call(c,i.resetKeys,s),this.reset()}},e.render=function(){var i=this.state.error,a=this.props,o=a.fallbackRender,s=a.FallbackComponent,l=a.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ot.isValidElement(l))return l;if(typeof o=="function")return o(c);if(s)return ot.createElement(s,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(ot.Component);const Hye=async()=>{if(!navigator.onLine)return!1;const r=new URL("https://jsonplaceholder.typicode.com/todos/1");r.searchParams.set("rand",Date.now().toString());try{return(await fetch(r.toString())).ok}catch{return!1}},Uye=r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M1 8a7 7 0 1 1 2.898 5.673c-.167-.121-.216-.406-.002-.62l1.8-1.8a3.5 3.5 0 0 0 4.572-.328l1.414-1.415a.5.5 0 0 0 0-.707l-.707-.707l1.559-1.563a.5.5 0 1 0-.708-.706l-1.559 1.562l-1.414-1.414l1.56-1.562a.5.5 0 1 0-.707-.706l-1.56 1.56l-.707-.706a.5.5 0 0 0-.707 0L5.318 5.975a3.5 3.5 0 0 0-.328 4.571l-1.8 1.8c-.58.58-.62 1.6.121 2.137A8 8 0 1 0 0 8a.5.5 0 0 0 1 0Z"})}),P0={dialog:"_dialog_1jybx_1",container:"_container_1jybx_7",pluginIcon:"_pluginIcon_1jybx_13",closeButton:"_closeButton_1jybx_19"},Gye=()=>{const[r,t]=P.useState(!1);return P.useEffect(()=>{const e=()=>{t(!0)},n=()=>{t(!1)};window.addEventListener("offline",e),window.addEventListener("online",n);const i=setInterval(()=>{Hye().then(a=>{a?n():e()})},12e3);return()=>{window.removeEventListener("offline",e),window.removeEventListener("online",n),i&&clearInterval(i)}},[]),A.jsx(A.Fragment,{children:A.jsx(sg,{children:typeof window<"u"&&(!window.navigator.onLine||r)?A.jsx("dialog",{className:P0.dialog,children:A.jsxs("div",{className:P0.container,children:[A.jsx(Te,{variant:"custom",type:"button",className:P0.closeButton,onClick:()=>t(!1),children:A.jsx(tt,{name:"close-icon"})}),A.jsx(Uye,{className:P0.pluginIcon}),A.jsx(we,{variant:"p",styleClass:"font-18",children:"No Internet Connection Detected."})]})}):null})})},Yye=new DG({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),l5=({children:r,theme:t})=>(P.useEffect(()=>{!t||!Object.keys(t).length||Pye(t)},[t]),P.useEffect(()=>{const e=document.querySelector("#dbn-styles"),n=document.querySelector("dbn-dashboard"),i=document.querySelectorAll("dbn-metric");if(n!=null&&n.shadowRoot&&e&&!n.shadowRoot.getElementById("dbn-dashboard-style")){const a=document.createElement("style");a.innerHTML=e.innerHTML,a.setAttribute("id","dbn-dashboard-style"),n.shadowRoot.appendChild(a)}i.forEach((a,o)=>{if(a.shadowRoot&&e&&!a.shadowRoot.getElementById(`dbn-metric-${o}-style`)){const s=document.createElement("style");s.innerHTML=e.innerHTML,s.setAttribute("id",`dbn-metric-${o}-style`),a.shadowRoot.appendChild(s)}})},[]),A.jsx(Wye,{FallbackComponent:MQ,children:A.jsxs(LG,{client:Yye,children:[A.jsx(Gye,{}),r]})})),u5={metric:"_metric_1pdqp_1",loader:"_loader_1pdqp_7"},Qye=P.memo(({token:r,chartColors:t,metricId:e,chartRendererType:n="canvas",variant:i="card",onMinimize:a})=>{const[o,s]=P.useState({isShow:i==="fullscreen"}),{externalMetric:l,adminColors:c,rlsSettings:u,sharingSettingsId:h,companyId:f,clientId:d,tenancyLevel:p,isLoading:v,errorMsg:g}=gQ({token:r,metricId:e});return A.jsxs(A.Fragment,{children:[v?A.jsx("div",{className:u5.loader,children:A.jsx(uTe,{})}):null,g||null,l&&!v?A.jsxs(A.Fragment,{children:[i==="card"&&A.jsx(ZH,{metricItem:l,client:d,colors:c||t,onMaximize:(m,y)=>s({isShow:!0,rlsFilters:y}),companyTenancyType:p,chartRendererType:n,param:u}),A.jsx(sg,{children:o.isShow||i==="fullscreen"?A.jsx(qH,{metric:l,clientId:d,colors:c||t,onMinimize:()=>{s({isShow:!1}),a==null||a()},companyId:f,tenancyLevel:p,rlsFilters:o.rlsFilters,sharingSettingsId:h,externalDashboardId:"",userProvidedDashboardId:""}):null})]}):null]})}),Zye=P.memo(({theme:r,width:t,height:e,style:n,className:i="",...a})=>A.jsx("div",{style:{...n,width:t?`${t}px`:void 0,height:e?`${e}px`:void 0},className:`${u5.metric} ${i} dbn-metric`,children:A.jsx(l5,{theme:r,children:A.jsx(Qye,{...a})})})),RD=({timeGrainValue:r,isTimeStamp:t,col:e,database:n})=>{if(n===ZA.Redshift||n.toUpperCase()==="POSTGRES"||n===ZA.Snowflake||n==="Bigquery"){if(r==="Today")return t?`date_trunc('day', ${e}) = date_trunc('day', CURRENT_TIMESTAMP)`:`${e} = CURRENT_DATE`;if(r==="Last 7 Days")return t?`date_trunc('day', ${e}) >= date_trunc('day', CURRENT_TIMESTAMP) - interval '6 days'`:`${e} >= CURRENT_DATE - 6`;if(r==="Last Week")return t?`extract(week from ${e}) = case when extract(week from current_date) = 1 then 4 else extract(week from current_date) - 1 end
608
+ `);return encodeURI(t+a)},jye=(r,t,e)=>{const n=r.clientX-t.left+5,i=r.clientY-t.top-50,a=t.width-e.width,o=t.height-e.height,s=Math.max(0,Math.min(n,a)),l=Math.max(0,Math.min(i,o));return[s,l]},zye=(r,t,e)=>{r.style.left=`${t}px`,r.style.top=`${e}px`},ua={container:"_container_1qflp_1",popover:"_popover_1qflp_9",button:"_button_1qflp_17",buttonOpen:"_buttonOpen_1qflp_25",menu:"_menu_1qflp_33",enter:"_enter_1qflp_41",enterFrom:"_enterFrom_1qflp_49",enterTo:"_enterTo_1qflp_57",leave:"_leave_1qflp_65",leaveFrom:"_leaveFrom_1qflp_73",leaveTo:"_leaveTo_1qflp_81",center:"_center_1qflp_89",top:"_top_1qflp_97",bottom:"_bottom_1qflp_105",left:"_left_1qflp_113",right:"_right_1qflp_121","left-top-end":"_left-top-end_1qflp_129","right-top-end":"_right-top-end_1qflp_137","left-bottom-end":"_left-bottom-end_1qflp_145","right-bottom-end":"_right-bottom-end_1qflp_153","top-left":"_top-left_1qflp_161","top-right":"_top-right_1qflp_169","bottom-left":"_bottom-left_1qflp_177","bottom-right":"_bottom-right_1qflp_185","left-top":"_left-top_1qflp_129","left-bottom":"_left-bottom_1qflp_145","right-top":"_right-top_1qflp_137","right-bottom":"_right-bottom_1qflp_153"},So=({className:r="",menuClass:t="",menuContainerClass:e="",buttonClass:n="",children:i,button:a,position:o="bottom",isDisabled:s})=>{const[l,c]=P.useState(!1);return A.jsx(A.Fragment,{children:A.jsxs("div",{className:`${ua.container} ${r}`,onBlur:u=>{u.currentTarget.contains(u.relatedTarget)||c(!1)},tabIndex:-1,children:[A.jsx(Te,{className:`${n} ${l?ua.buttonOpen:""} ${ua.button}`,type:"button",variant:"custom",onClick:()=>!s&&c(u=>!u),children:a}),s?null:A.jsx("div",{className:`${ua.popover} ${ua[o]} ${e}`,children:A.jsx(Uv,{as:"div",className:`${ua.menu} ${t}`,show:l,enter:ua.enter,enterFrom:ua.enterFrom,enterTo:ua.enterTo,leave:ua.leave,leaveFrom:ua.leaveFrom,leaveTo:ua.leaveTo,children:i})})]})})},Fye=r=>["IN","NOT IN"].includes(r),Bye=r=>["IS NULL","IS NOT NULL"].includes(r),ct={container:"_container_uxvi9_1",form:"_form_uxvi9_7",filterHeader:"_filterHeader_uxvi9_23",titleContent:"_titleContent_uxvi9_29",title:"_title_uxvi9_29",buttons:"_buttons_uxvi9_41",apply:"_apply_uxvi9_47",applyIcon:"_applyIcon_uxvi9_53",reset:"_reset_uxvi9_59",filterFieldsContainer:"_filterFieldsContainer_uxvi9_67",filterFields:"_filterFields_uxvi9_67",filterContainer:"_filterContainer_uxvi9_91",AddFilter:"_AddFilter_uxvi9_97",filterDropdown:"_filterDropdown_uxvi9_103",filterDropdowns:"_filterDropdowns_uxvi9_111",noFilters:"_noFilters_uxvi9_111",gridColAndRow:"_gridColAndRow_uxvi9_127",gridCol1:"_gridCol1_uxvi9_135",gridCol2:"_gridCol2_uxvi9_143",gridCol3:"_gridCol3_uxvi9_151",filters:"_filters_uxvi9_159",filterItem:"_filterItem_uxvi9_165",filterItemOperator:"_filterItemOperator_uxvi9_171",remove:"_remove_uxvi9_177",filterCol:"_filterCol_uxvi9_183",filterText:"_filterText_uxvi9_189",smallText:"_smallText_uxvi9_195",numberFieldPopup:"_numberFieldPopup_uxvi9_203",numberField:"_numberField_uxvi9_203",numberFieldWrapper:"_numberFieldWrapper_uxvi9_219",numberFieldLabel:"_numberFieldLabel_uxvi9_227",selectedLabel:"_selectedLabel_uxvi9_235",numberFieldLabelText:"_numberFieldLabelText_uxvi9_243",numberFieldLabelSelectText:"_numberFieldLabelSelectText_uxvi9_251",numberFieldButtonClass:"_numberFieldButtonClass_uxvi9_259",numberFieldLabelMenuClass:"_numberFieldLabelMenuClass_uxvi9_267",numberFieldClearButton:"_numberFieldClearButton_uxvi9_275",numberFieldFooter:"_numberFieldFooter_uxvi9_283",checkedOption:"_checkedOption_uxvi9_291",option:"_option_uxvi9_299",addFilterMenu:"_addFilterMenu_uxvi9_307",appliedFilterTag:"_appliedFilterTag_uxvi9_315",appliedfilters:"_appliedfilters_uxvi9_323",textBold:"_textBold_uxvi9_331",filterButton:"_filterButton_uxvi9_339",filterBtnText:"_filterBtnText_uxvi9_347",filterLength:"_filterLength_uxvi9_355",addfilter:"_addfilter_uxvi9_363",alertContainer:"_alertContainer_uxvi9_371"};var Vye=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=[]),t.length!==e.length||t.some(function(n,i){return!Object.is(n,e[i])})},s5={error:null},Wye=function(r){Tl(t,r);function t(){for(var n,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return n=r.call.apply(r,[this].concat(a))||this,n.state=s5,n.resetErrorBoundary=function(){for(var s,l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];n.props.onReset==null||(s=n.props).onReset.apply(s,c),n.reset()},n}t.getDerivedStateFromError=function(i){return{error:i}};var e=t.prototype;return e.reset=function(){this.setState(s5)},e.componentDidCatch=function(i,a){var o,s;(o=(s=this.props).onError)==null||o.call(s,i,a)},e.componentDidUpdate=function(i,a){var o=this.state.error,s=this.props.resetKeys;if(o!==null&&a.error!==null&&Vye(i.resetKeys,s)){var l,c;(l=(c=this.props).onResetKeysChange)==null||l.call(c,i.resetKeys,s),this.reset()}},e.render=function(){var i=this.state.error,a=this.props,o=a.fallbackRender,s=a.FallbackComponent,l=a.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ot.isValidElement(l))return l;if(typeof o=="function")return o(c);if(s)return ot.createElement(s,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(ot.Component);const Hye=async()=>{if(!navigator.onLine)return!1;const r=new URL("https://jsonplaceholder.typicode.com/todos/1");r.searchParams.set("rand",Date.now().toString());try{return(await fetch(r.toString())).ok}catch{return!1}},Uye=r=>A.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...r,children:A.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M1 8a7 7 0 1 1 2.898 5.673c-.167-.121-.216-.406-.002-.62l1.8-1.8a3.5 3.5 0 0 0 4.572-.328l1.414-1.415a.5.5 0 0 0 0-.707l-.707-.707l1.559-1.563a.5.5 0 1 0-.708-.706l-1.559 1.562l-1.414-1.414l1.56-1.562a.5.5 0 1 0-.707-.706l-1.56 1.56l-.707-.706a.5.5 0 0 0-.707 0L5.318 5.975a3.5 3.5 0 0 0-.328 4.571l-1.8 1.8c-.58.58-.62 1.6.121 2.137A8 8 0 1 0 0 8a.5.5 0 0 0 1 0Z"})}),P0={dialog:"_dialog_1jybx_1",container:"_container_1jybx_7",pluginIcon:"_pluginIcon_1jybx_13",closeButton:"_closeButton_1jybx_19"},Gye=()=>{const[r,t]=P.useState(!1);return P.useEffect(()=>{const e=()=>{t(!0)},n=()=>{t(!1)};window.addEventListener("offline",e),window.addEventListener("online",n);const i=setInterval(()=>{Hye().then(a=>{a?n():e()})},12e3);return()=>{window.removeEventListener("offline",e),window.removeEventListener("online",n),i&&clearInterval(i)}},[]),A.jsx(A.Fragment,{children:A.jsx(sg,{children:typeof window<"u"&&(!window.navigator.onLine||r)?A.jsx("dialog",{className:P0.dialog,children:A.jsxs("div",{className:P0.container,children:[A.jsx(Te,{variant:"custom",type:"button",className:P0.closeButton,onClick:()=>t(!1),children:A.jsx(tt,{name:"close-icon"})}),A.jsx(Uye,{className:P0.pluginIcon}),A.jsx(we,{variant:"p",styleClass:"font-18",children:"No Internet Connection Detected."})]})}):null})})},Yye=new DG({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),l5=({children:r,theme:t})=>(P.useEffect(()=>{!t||!Object.keys(t).length||Pye(t)},[t]),P.useEffect(()=>{const e=document.querySelector("#dbn-styles"),n=document.querySelectorAll("dbn-dashboard"),i=document.querySelectorAll("dbn-metric");n.forEach((a,o)=>{if(a!=null&&a.shadowRoot&&e&&!a.shadowRoot.getElementById(`dbn-dashboard-${o}-style`)){const s=document.createElement("style");s.innerHTML=e.innerHTML,s.setAttribute("id",`dbn-dashboard-${o}-style`),a.shadowRoot.appendChild(s)}}),i.forEach((a,o)=>{if(a.shadowRoot&&e&&!a.shadowRoot.getElementById(`dbn-metric-${o}-style`)){const s=document.createElement("style");s.innerHTML=e.innerHTML,s.setAttribute("id",`dbn-metric-${o}-style`),a.shadowRoot.appendChild(s)}})},[]),A.jsx(Wye,{FallbackComponent:MQ,children:A.jsxs(LG,{client:Yye,children:[A.jsx(Gye,{}),r]})})),u5={metric:"_metric_1pdqp_1",loader:"_loader_1pdqp_7"},Qye=P.memo(({token:r,chartColors:t,metricId:e,chartRendererType:n="canvas",variant:i="card",onMinimize:a})=>{const[o,s]=P.useState({isShow:i==="fullscreen"}),{externalMetric:l,adminColors:c,rlsSettings:u,sharingSettingsId:h,companyId:f,clientId:d,tenancyLevel:p,isLoading:v,errorMsg:g}=gQ({token:r,metricId:e});return A.jsxs(A.Fragment,{children:[v?A.jsx("div",{className:u5.loader,children:A.jsx(uTe,{})}):null,g||null,l&&!v?A.jsxs(A.Fragment,{children:[i==="card"&&A.jsx(ZH,{metricItem:l,client:d,colors:c||t,onMaximize:(m,y)=>s({isShow:!0,rlsFilters:y}),companyTenancyType:p,chartRendererType:n,param:u}),A.jsx(sg,{children:o.isShow||i==="fullscreen"?A.jsx(qH,{metric:l,clientId:d,colors:c||t,onMinimize:()=>{s({isShow:!1}),a==null||a()},companyId:f,tenancyLevel:p,rlsFilters:o.rlsFilters,sharingSettingsId:h,externalDashboardId:"",userProvidedDashboardId:""}):null})]}):null]})}),Zye=P.memo(({theme:r,width:t,height:e,style:n,className:i="",...a})=>A.jsx("div",{style:{...n,width:t?`${t}px`:void 0,height:e?`${e}px`:void 0},className:`${u5.metric} ${i} dbn-metric`,children:A.jsx(l5,{theme:r,children:A.jsx(Qye,{...a})})})),RD=({timeGrainValue:r,isTimeStamp:t,col:e,database:n})=>{if(n===ZA.Redshift||n.toUpperCase()==="POSTGRES"||n===ZA.Snowflake||n==="Bigquery"){if(r==="Today")return t?`date_trunc('day', ${e}) = date_trunc('day', CURRENT_TIMESTAMP)`:`${e} = CURRENT_DATE`;if(r==="Last 7 Days")return t?`date_trunc('day', ${e}) >= date_trunc('day', CURRENT_TIMESTAMP) - interval '6 days'`:`${e} >= CURRENT_DATE - 6`;if(r==="Last Week")return t?`extract(week from ${e}) = case when extract(week from current_date) = 1 then 4 else extract(week from current_date) - 1 end
609
609
  AND extract(year from ${e}) = case when extract(week from current_date) = 1 and extract(month from current_date) = 1 then extract(year from current_date) -1 else extract(year from current_date) end
610
610
  AND extract(month from ${e}) = case when extract(week from current_date) = 1 then case when extract(week from current_date) - 1 = 0 then 12 else extract(week from current_date) - 1 end else extract(month from current_date) end
611
611
  `:`extract(week from ${e}) = case when extract(week from current_date) = 1 then 4 else extract(week from current_date) - 1 end
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@databrainhq/plugin",
3
- "version": "0.11.15",
3
+ "version": "0.11.16",
4
4
  "description": "Databrain app ui plugin.",
5
5
  "author": "",
6
6
  "license": "MIT",
7
7
  "repository": "databrainhq/plugin",
8
+ "main": "src/index.ts",
8
9
  "source": "index.ts",
9
- "main": "./dist/index.umd.js",
10
10
  "module": "./dist/index.es.js",
11
11
  "types": "./dist/index.d.ts",
12
12
  "exports": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "scripts": {
26
26
  "start:repl": "vite --host 0.0.0.0",
27
- "serve": "vite --port 3005",
27
+ "start": "vite --port 3005",
28
28
  "build:css": "tailwindcss build -i src/index.css -o dist/index.css",
29
29
  "build:react": "cross-env ENTRY_NAME=react tsc && vite build",
30
30
  "build:web": "cross-env ENTRY_NAME=web vite build --config vite.config.web.ts",
@@ -118,4 +118,4 @@
118
118
  "react": "^18.2.0",
119
119
  "react-dom": "^18.2.0"
120
120
  }
121
- }
121
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './containers';
2
+ export * as utils from './utils';
3
+ export * as consts from './consts';
4
+ export * as helpers from './helpers';
5
+ export * as hooks from './hooks';
6
+ export * as types from './types';
7
+ export * as Ui from './components';