@databrainhq/plugin 0.12.7 → 0.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/webcomponents.es.js
CHANGED
|
@@ -25446,10 +25446,13 @@ const wf = "/dashboard", lg = "/metric", hye = "dashboardData", pye = `${wf}/emb
|
|
|
25446
25446
|
return;
|
|
25447
25447
|
const h = d;
|
|
25448
25448
|
e.setQueryData(
|
|
25449
|
-
[
|
|
25449
|
+
[
|
|
25450
|
+
xK,
|
|
25451
|
+
{ dashboardId: n, clientId: t }
|
|
25452
|
+
],
|
|
25450
25453
|
(v) => ({
|
|
25451
25454
|
...v,
|
|
25452
|
-
|
|
25455
|
+
...h
|
|
25453
25456
|
})
|
|
25454
25457
|
);
|
|
25455
25458
|
}
|
|
@@ -272,7 +272,7 @@ Check the top-level render call using <`+At+">.")}return dt}}function Nn(Ce,dt){
|
|
|
272
272
|
}`),(d=n.cardDescription.color)!=null&&d.trim()&&(e=`${e}
|
|
273
273
|
.dbn-metric-card-description {
|
|
274
274
|
color: ${n.cardDescription.color} !important;
|
|
275
|
-
}`),t){const h=document.querySelectorAll("dbn-dashboard");h.length&&h.forEach((y,b)=>{if(y&&y.shadowRoot){const S=document.querySelector(`#dbn-dashboard-${b}-admin-styles`);if(S)S.innerHTML=e;else{const _=document.createElement("style");_.setAttribute("id",`dbn-dashboard-${b}-admin-styles`),_.innerHTML=e,y.shadowRoot.appendChild(_)}}});const v=document.querySelectorAll("dbn-metric");v.length&&v.forEach((y,b)=>{if(y.shadowRoot){const S=document.querySelector(`#dbn-metric-${b}-admin-styles`);if(S)S.innerHTML=e;else{const _=document.createElement("style");_.setAttribute("id",`dbn-metric-${b}-admin-styles`),_.innerHTML=e,y.shadowRoot.appendChild(_)}}});const g=document.querySelector("#dbn-portal");if(g&&g.shadowRoot){const y=document.querySelector("#dbn-portal-admin-styles");y&&g.shadowRoot.removeChild(y)}}else{const h=document.querySelector("#dbn-admin-styles")||document.createElement("style");h.setAttribute("id","dbn-admin-styles"),h.innerHTML=e,document.querySelector("#dbn-admin-styles")||document.head.appendChild(h)}},[n])},nde=({token:n,dashboardId:t})=>v0([ufe,{dashboardId:t}],()=>{const e=t?`${Mc}?dashboardId=${t}`:Mc;return wo(e,{method:"GET",token:n})},{enabled:!!n}),rde=(n,t)=>v0([jW,{dashboardId:n,clientId:t}],()=>wo(`${dfe}?id=${n}&clientId=${t}`,{method:"GET"}),{enabled:!!n&&!!t}),ide=n=>v0(pfe,()=>wo(hfe,{method:"GET",token:n}),{enabled:!!n}),ade=(n,t)=>v0([ffe,{id:t}],()=>wo(`${cfe}?metricId=${t}`,{method:"GET",token:n}),{enabled:!!n}),ode=({externalDashboardId:n,clientId:t})=>{const e=$T(),{data:r,isLoading:i}=rde(n,t),[a,o]=oe.useMemo(()=>{const c=r;return[(c==null?void 0:c.layout)||[],!!(c!=null&&c.isLocked)]},[r]),{mutateAsync:s,isLoading:l}=Wfe();return{saveLayout:oe.useCallback(async(c,f)=>{await s({clientId:t,externalDashboardId:n,layout:c,isLocked:!!f},{onSuccess:d=>{if(!d)return;const h=d;e.setQueryData([jW,{externalDashboardId:n,clientId:t}],v=>({...v,clientDashboardLayout_by_pk:h}))}})},[s,t,n]),layout:a,isLayoutLocked:o,isLoadingLayout:i||l}},wu="something went wrong, please try again",nt={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"},Cc={month:"monthly",quarter:"quarterly",daily:"daily",weekly:"weekly",yearly:"yearly"},VW="client_id_variable",n1="INPUT_TABLE",r1="OUTPUT_TABLE",HW="doughnut",WW="pie",sde="sankey",_g="general",i1="configuration",UW={Snowflake:"Snowflake",Redshift:"Redshift",BigQuery:"BigQuery",Postges:"Postgres"},GW="{{DATABASE_NAME}}",YW="'client_id_variable'",QW="DATABASE",ZW=[{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"}],lde=[{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"}],ude=[{value:"AM",label:"AM"},{value:"PM",label:"PM"}],cde=[{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"}],fde=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"}],XW=[{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"}],dde=[{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"}],hde=[{value:"100",label:"100"},{value:"200",label:"200"},{value:"300",label:"300"},{value:"400",label:"400"},{value:"500",label:"500"},{value:"1000",label:"1000"}],qW=[{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"}],a1=[{label:"Show 10",value:"10"},{label:"Show 25",value:"25"},{label:"Show 50",value:"50"},{label:"Show 75",value:"75"},{label:"Show 100",value:"100"},{label:"Show 250",value:"250"},{label:"Show 500",value:"500"},{label:"Show 1k",value:"1000"}],pde=["fixed","real","int","bigint","float","number","integer","int64","float64","double precision","smallint"],vde=["varchar","text","char","text","character(36)","string"],JW=["timestamp_ltz","date","timestamp","timestamp without time zone","timestamp with time zone","datetime"],gde=["array","text[]"],mde=["boolean","bool"],KW=["saved","simple","custom"],Vl={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,0,0,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:[],badgeColumns:[],badgeColors:{},badgeTextColors:{},badgeSeparator:",",listColumns:[],listSeparator:","},pivotTableSettings:{rows:[],columns:[]},gaugeSettings:{metric:"",dimensions:[]},axisSettings:{axis:"left"},backGroundColor:{show:!1},timeSeriesSettings:{groupBySettings:{isDynamic:!1,options:[],value:"monthly",fillXAxis:!1},seriesType:[]},isDynamicSeries:!1,isMultiDimension:!1,seriesField:"ungrouped",seriesOptions:["ungrouped"],ungroupedAlias:"",dynamicXAxis:{isEnabled:!1,options:[],selectedOption:{value:"",label:""}}},zT=[{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"}],yde=(n,t)=>{let e=n.replace(/;([^;]*)$/,"");const r=parseInt(t,10);if(e.toLowerCase().includes("limit")){const i=parseInt(e.toLowerCase().split("limit")[1].trim(),10),a=Math.min(i,r);e=e.replace(`limit ${i}`,`limit ${a}`),e=e.replace(`LIMIT ${i}`,`LIMIT ${a}`)}else e+=` limit ${r}`;return e},bde=({limit:n,query:t,clientName:e,tenancyType:r,values:i})=>{const a=yde(t,n),o=e?r===QW?a.replace(new RegExp(GW,"g"),e):Number(e)?a.replace(new RegExp(YW,"g"),e):a.replace(new RegExp(VW,"g"),e):a;return i?o.replace(/[^']+_variable/g,l=>`${i[l]}`):o},wde=({clientName:n,tenancyType:t,values:e,query:r,companyId:i,workspaceId:a,metricId:o})=>{const{mutate:s}=Kfe();return{getUnderlyingData:({columnName:u,value:c,setData:f,setLoading:d,isSingleValueChart:h})=>{const v=bde({query:r,limit:"5000",clientName:n,tenancyType:t,values:e});f([]),d(!0),s({columnName:h?void 0:u,companyId:i,query:v,value:h||c==null?void 0:c.replace(/'/g,"''"),workspaceId:a,metricId:o},{onSuccess(g){const y=g==null?void 0:g.data;y&&Array.isArray(y)&&y.length?(f(y),d(!1)):(f([]),d(!1))},onError(){f([]),d(!1)}})}}},Sde=({range:n,count:t,time:e,from:r,to:i})=>{const a=new Date;new Date(a).setDate(a.getDate()-1);const s=a.getMonth(),l=a.getFullYear();let u,c;if(n==="This"){switch(e){case"Year":u=new Date(l,0,1),c=new Date(a);break;case"Month":u=new Date(l,s,1),c=new Date(a);break;case"Week":{const f=a.getDate()-a.getDay();u=new Date(a.setDate(f)),c=new Date(a.setDate(f+6));break}case"Day":u=new Date(a),c=new Date(a);break;default:u=new Date(0),c=new Date(a)}return{startDate:u,endDate:c}}if(n==="Last"){switch(e){case"Year":{let f,d;t===1?(f=t,d=l-1):(f=t-1,d=l),u=new Date(l-f,0,1),c=new Date(d,11,31);break}case"Month":{const f=t===1?s-1:s-t+1;u=new Date(l,f,1),c=new Date(l,s,t===1?0:31);break}case"Week":{const f=new Date(a.setDate(a.getDate()-(a.getDay()+1)%7)),d=new Date(f.getFullYear(),f.getMonth(),f.getDate()-6),h=t-1;u=new Date(d.setDate(d.getDate()-7*h)),c=new Date(f.setDate(f.getDate()-7*(h-1))),h===0&&(c=new Date(a));break}case"Day":u=new Date(a),u.setDate(a.getDate()-t),c=new Date(a);break;default:u=new Date(0),c=new Date(a)}return{startDate:u,endDate:c}}return{startDate:r||new Date(0),endDate:i||new Date(a)}},_de=({data:n,format:t,measureColumn:e,timeColumn:r,dimensionColumn:i,startDate:a})=>n.reduce((s,l)=>{const u=Number(l[e]),c=new Date(l[r]);let f;switch(t){case"Week":{f=`Week ${Math.ceil((c.getDate()+a.getDay())/7)}`;break}case"Quarter":{const h=Math.ceil((c.getMonth()+1)/3),v=c.getFullYear();f=`Q${h} ${v}`;break}case"Month":{f=`${c.toLocaleString("default",{month:"long"})} ${c.getFullYear()}`;break}case"Day":{f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][c.getDay()];break}default:f=l[r]}const d=s.find(h=>h[i]===f);return d?d[e]+=u:s.push({[i]:f,[e]:u}),s},[]),xde=({dimensionColumn:n,endDate:t,measureColumn:e,format:r,groupedDataList:i,time:a,count:o,range:s})=>{const l=new Date().getFullYear(),u=l-1;let c=[],f=[];if(o===1&&s==="This"&&(c=Array.from({length:12},(g,y)=>({[n]:`${new Date(2e3,y,1).toLocaleString("default",{month:"long"})} ${l}`,[e]:0})),f=[{[n]:`Q1 ${l}`,[e]:0},{[n]:`Q2 ${l}`,[e]:0},{[n]:`Q3 ${l}`,[e]:0},{[n]:`Q4 ${l}`,[e]:0}]),o===1&&s==="Last"&&(c=Array.from({length:12},(g,y)=>({[n]:`${new Date(2e3,y,1).toLocaleString("default",{month:"long"})} ${u}`,[e]:0})),f=[{[n]:`Q1 ${u}`,[e]:0},{[n]:`Q2 ${u}`,[e]:0},{[n]:`Q3 ${u}`,[e]:0},{[n]:`Q4 ${u}`,[e]:0}]),o>1&&s==="Last"){for(let g=l-o+1;g<=l;g++)for(let y=0;y<12;y++)c.push({[n]:`${new Date(g,y,1).toLocaleString("default",{month:"long"})} ${new Date(g,y,1).getFullYear()}`,[e]:0});for(let g=l-o;g<=l;g++)f.push({[n]:`Q1 ${g}`,[e]:0},{[n]:`Q2 ${g}`,[e]:0},{[n]:`Q3 ${g}`,[e]:0},{[n]:`Q4 ${g}`,[e]:0})}const d=Array.from({length:4},(g,y)=>({[n]:`Week ${y+1}`,[e]:0})),h=[{[n]:"Sunday",[e]:0},{[n]:"Monday",[e]:0},{[n]:"Tuesday",[e]:0},{[n]:"Wednesday",[e]:0},{[n]:"Thursday",[e]:0},{[n]:"Friday",[e]:0},{[n]:"Saturday",[e]:0}];let v=[];switch(`${s}${o>1?` ${o} `:" "}${a} By ${r}`){case"This Year By Month":case"Last Year By Month":case`Last ${o} Year By Month`:{v=c.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Year By Quarter":case"Last Year By Quarter":case`Last ${o} Year By Quarter`:{v=f.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Month By Week":case"Last Month By Week":{v=d.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Week By Day":case"Last Week By Day":{v=h.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Quarter By Month":{const y=(Math.ceil((t.getMonth()+1)/3)-1)*3,b=y+2;v=c.slice(y,b+1).map(_=>{const D=i.find(T=>T[n]===_[n]);return D||_});break}case"Last Quarter By Month":{const g=Math.ceil((t.getMonth()+1)/3),b=((g===1?4:g-1)-1)*3,S=b+2;v=c.slice(b,S+1).map(D=>{const T=i.find(C=>C[n]===D[n]);return T||D});break}case`Last ${o} Month By Month`:{v=Array.from({length:o},(g,y)=>{const b=new Date(t.getFullYear(),t.getMonth()-y,1);return{[n]:`${b.toLocaleString("default",{month:"long"})} ${b.getFullYear()}`,[e]:0}}).reverse().map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}default:v=i}return v},Mde=({data:n,dimensionColumn:t,measureColumn:e,timeColumn:r,option:i})=>{const{endDate:a,startDate:o}=Sde({range:i.range,count:i.count,from:i.startDate,to:i.endDate,time:i.time});if(i.time==="Week"&&i.count>1)return n.map(c=>({[t]:c[t],[e]:c[e]}));const s=_de({data:n,dimensionColumn:t,format:i.format,measureColumn:e,startDate:o,timeColumn:r}),l=Object.values(s);return i.name==="Custom"?l:xde({dimensionColumn:t,endDate:a,format:i.format,groupedDataList:l,measureColumn:e,time:i.time,count:i.count,range:i.range})},Cde=n=>v0([Lfe,n],()=>wo(Nfe,{method:"POST",data:n}),{enabled:!!(n!=null&&n.id)}),Tde=n=>v0([Rfe,n],()=>wo(`${kfe}?id=${n}`,{method:"GET"}),{enabled:!!n}),eU=({metric:n,globalFilters:t={tableName:"",filters:[]},rlsFilters:e,clientId:r,chartSettings:i,setChartSettings:a,tenancyLevel:o,isInternalApp:s,appFilters:l})=>{var ue,pe,fe,ve,me,Se,K;const[u,c]=oe.useState({limit:10,offset:0}),[f,d]=oe.useState(0),[h,v]=oe.useState(n.rlsConditions||[]),[g,y]=oe.useState(!1),[b,S]=oe.useState(),[_,D]=oe.useState([]),[T,C]=oe.useState(!0),[E,k]=oe.useState([]),[R,L]=oe.useState([]),[I,z]=oe.useState(!1),[j,O]=oe.useState([]),{data:F,isLoading:V}=Cde({id:n.id,drillFilters:(ue=n==null?void 0:n.drillDownSettings)!=null&&ue.isEnableGroupBy?E:[],clientId:r,tenancyLevel:o,rlsConditions:j,globalFilters:t,filterValues:e==null?void 0:e.filterValues,limit:(pe=i==null?void 0:i.tableSettings)!=null&&pe.isServerSidePagination&&(i==null?void 0:i.chartType)===nt.table?Math.min(u.limit,1e3):void 0,offset:(fe=i==null?void 0:i.tableSettings)!=null&&fe.isServerSidePagination&&(i==null?void 0:i.chartType)===nt.table?u.offset:void 0}),W=oe.useMemo(()=>{var he,be;return!!h.length&&((be=(he=h.find(_e=>_e.isAddOnMetrics&&_e.datatype==="date"&&_e.columnName===i.xAxis))==null?void 0:he.options)==null?void 0:be.every(_e=>_e.format))},[h,i]),Y=he=>he.includes("____")?he.split("____")[1]:he,Z=oe.useMemo(()=>{var he,be,_e,ce;return Y(((ce=(he=n==null?void 0:n.datasetMetricSettings)==null?void 0:he.selectedDimensions)==null?void 0:ce[E.length<((_e=(be=n==null?void 0:n.datasetMetricSettings)==null?void 0:be.selectedDimensions)==null?void 0:_e.length)?E.length:0])||"")},[n==null?void 0:n.datasetMetricSettings,E]);oe.useEffect(()=>{var he;(he=h==null?void 0:h.filter(be=>be.isAddOnMetrics))!=null&&he.length?O(o==="DATABASE"?n.rlsConditions.filter(be=>be.isAddOnMetrics&&be.datatype!=="date").map(be=>{var _e;return{...be,tableName:`${r}.${be.tableName.split(".").slice(1).join(".")}`,dimensionColumn:i.xAxis||"",measureColumn:((_e=i.yAxisList)==null?void 0:_e[0])||""}}):h.filter(be=>be.isAddOnMetrics).map(be=>{var _e,ce,we,Ae,Be,qe;return s?{...be,dimensionColumn:i.xAxis||"",measureColumn:((_e=i.yAxisList)==null?void 0:_e[0])||""}:{...be,dimensionColumn:i.xAxis||"",measureColumn:((ce=i.yAxisList)==null?void 0:ce[0])||"",value:be.isAppFilter?be.datatype==="date"?(we=be==null?void 0:be.options)==null?void 0:we.find(je=>{var Ye;return je.name===((Ye=l==null?void 0:l.values)==null?void 0:Ye[be.name])}):be.datatype==="string"&&typeof((Ae=l==null?void 0:l.values)==null?void 0:Ae[be.name])=="string"?[(Be=l==null?void 0:l.values)==null?void 0:Be[be.name]]:(qe=l==null?void 0:l.values)==null?void 0:qe[be.name]:be.value}})):O([])},[h,l]);const G=oe.useMemo(()=>{var he,be,_e,ce,we;return(i==null?void 0:i.chartType)===nt.singleValue&&!!((he=i==null?void 0:i.customSettings)!=null&&he.comparisonValueShow)&&!!((be=i==null?void 0:i.customSettings)!=null&&be.comparisonTimeColumn)&&!!((_e=i==null?void 0:i.customSettings)!=null&&_e.comparisonTimeGrain)&&!!((ce=i==null?void 0:i.customSettings)!=null&&ce.comparisonTimePeriod)&&!!((we=i==null?void 0:i.customSettings)!=null&&we.comparisonTableName)&&!!(i!=null&&i.singleValue)},[i]);oe.useEffect(()=>{var ce;const he=F,be=he!=null&&he.data&&typeof he.data=="string"?JSON.parse(he.data):[];if((i==null?void 0:i.chartType)===nt.table&&d((he==null?void 0:he.totalRecords)||0),W){const we=h.find(Ae=>Ae.isAddOnMetrics&&Ae.datatype==="date");if(we){const Ae=Mde({data:be||[],dimensionColumn:we.columnName,measureColumn:((ce=i.yAxisList)==null?void 0:ce[0])||"",option:we.options.find(Be=>Be.name===we.value),timeColumn:i.xAxis||we.columnName});D(Ae)}else D(be??[])}else D(be??[]);const _e=he==null?void 0:he.metaData;L((_e==null?void 0:_e.groupbyColumnList)||[])},[F,W,G]),oe.useEffect(()=>{var he,be,_e,ce,we,Ae,Be,qe;if((he=n==null?void 0:n.drillDownSettings)!=null&&he.isEnableGroupBy&&_.length){const je=(ce=(_e=(be=n==null?void 0:n.drillDownSettings)==null?void 0:be.drilldownChartSettings)==null?void 0:_e.find(Ye=>Ye.name===Z))==null?void 0:ce.chartSettings;je&&((Ae=(we=n==null?void 0:n.datasetMetricSettings)==null?void 0:we.selectedDimensions)!=null&&Ae.length)&&((qe=(Be=n==null?void 0:n.datasetMetricSettings)==null?void 0:Be.selectedDimensions)==null?void 0:qe.length)>(E==null?void 0:E.length)?a(je):a(Ye=>{var De,it,Ke,_t,Tt,sn,mn,Qt;return{...Ye,xAxis:Y(((_t=(De=n==null?void 0:n.datasetMetricSettings)==null?void 0:De.selectedDimensions)==null?void 0:_t[E.length<((Ke=(it=n==null?void 0:n.datasetMetricSettings)==null?void 0:it.selectedDimensions)==null?void 0:Ke.length)?E.length:0])||"none"),yAxisList:(sn=(Tt=n==null?void 0:n.datasetMetricSettings)==null?void 0:Tt.metrics)==null?void 0:sn.map(lt=>{var mt;return(mt=lt==null?void 0:lt.as)==null?void 0:mt.replace(/["`]+/g,"")}),chartType:((Qt=(mn=n==null?void 0:n.datasetMetricSettings)==null?void 0:mn.selectedDimensions)==null?void 0:Qt.length)===(E==null?void 0:E.length)?"table":n.chartOptions.chartType}})}},[_,n.drillDownSettings,n==null?void 0:n.datasetMetricSettings,E]),oe.useEffect(()=>{V&&C(!0),!_.length&&!V&&setTimeout(()=>{C(!1)},5e3)},[V,_]);const J=oe.useCallback((he,be,_e,ce)=>{v(_e?we=>we.map(Ae=>Ae.name===he?{...Ae,value:be,options:Ae.options.map(Be=>Be.name==="Custom"?{...Be,..._e}:Be)}:Ae):ce?we=>we.map(Ae=>Ae.name===he?{...Ae,value:ce.map(Be=>Be.value)}:Ae):we=>we.map(Ae=>Ae.name===he?{...Ae,value:be}:Ae))},[]),ne=oe.useCallback(he=>{W||(he.event&&he.event.event.preventDefault(),S(he))},[h]),{getUnderlyingData:ee}=wde({clientName:r,tenancyType:o,values:e==null?void 0:e.filterValues,companyId:n==null?void 0:n.companyId,query:n==null?void 0:n.query,workspaceId:(ve=n==null?void 0:n.companyIntegration)==null?void 0:ve.workspaceId,metricId:n==null?void 0:n.id}),re=oe.useMemo(()=>Array.isArray(_)&&_.length&&(b!=null&&b.name)?_.map(he=>{const be=Object.entries(he).find(([,_e])=>_e===b.name);return be==null?void 0:be[0]}).filter(he=>he)[0]:"",[_,b==null?void 0:b.name]),se=oe.useCallback(he=>{const be=Array.isArray(_)&&_.length&&(he!=null&&he.name)?_.map(_e=>{const ce=Object.entries(_e).find(([,we])=>we===he.name);return ce==null?void 0:ce[0]}).filter(_e=>_e)[0]:"";k(be?_e=>{var ce;return((ce=n==null?void 0:n.datasetMetricSettings)==null?void 0:ce.selectedDimensions.length)>_e.length?[..._e,{columnName:be,value:he==null?void 0:he.name}]:[]}:[])},[_,n==null?void 0:n.datasetMetricSettings,n==null?void 0:n.drillDownSettings]);return oe.useEffect(()=>{_!=null&&_.length&&R.length?z(!0):z(!1)},[_,R.length,n==null?void 0:n.integrationName,n.query]),{onDrillDown:se,handleChartClick:ne,dataDb:_,getUnderlyingData:ee,onChangeFilterValue:J,isShowChartPopup:g,setShowChartPopup:y,columnName:re,chartParams:b,isQueryLoading:V||T,setLoading:C,drilledLevel:E.length,dimensions:((Se=(me=n==null?void 0:n.datasetMetricSettings)==null?void 0:me.selectedDimensions)==null?void 0:Se.map(he=>Y(he||"none")))||[],rlsConditions:h,setTableLimit:c,isEnableNextBtn:f>(u==null?void 0:u.limit)+(u==null?void 0:u.offset),isEnablePrevBtn:(u==null?void 0:u.offset)!==0,paginationInfo:{limit:u==null?void 0:u.limit,offset:u==null?void 0:u.offset,totalRecords:f},onChangePage:(he,be)=>{c(be?{limit:be,offset:0}:_e=>({limit:_e.limit,offset:he?_e.offset>_e.limit?_e.offset-_e.limit:0:_e.offset+_e.limit}))},isExternalChart:((K=i==null?void 0:i.tableSettings)==null?void 0:K.isServerSidePagination)&&(i==null?void 0:i.chartType)===nt.table,isEnablePivotTable:I,groupByList:R,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:he=>{v(be=>be.map(_e=>_e.name===he.name&&_e.datatype===he.datatype&&_e.tableName===he.tableName&&_e.columnName===he.columnName?{..._e,isAddOnMetrics:!_e.isAddOnMetrics}:_e))}}},Dde=({dashboardId:n,clientId:t,metricId:e,onSuccess:r})=>{const i=$T(),{mutateAsync:a,isLoading:o}=tde();return{handleArchiveMetric:oe.useCallback(async()=>{!e||!t||await a({id:e,clientId:t},{onSuccess:l=>{l!=null&&l.insert_clientDeletedMetrics_one&&(i.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:n,clientId:t}],u=>{var f;const c=(f=u==null?void 0:u.externalDashboardMetrics)==null?void 0:f.filter(d=>d.externalMetricId!==e);return{...u,externalDashboardMetrics:c}}),r())}})},[a,e,t]),isLoading:o}},Ede=({token:n,metricId:t})=>{const[e,r]=oe.useState(!0),{data:i,isLoading:a}=ade(n,t);console.log(i);const{externalMetric:o,sharingSettingsId:s,adminTheme:l,params:u,companyId:c,clientId:f,errorMsg:d}=oe.useMemo(()=>{var b,S,_,D,T,C,E,k;const y=i;return{externalMetric:(b=y==null?void 0:y.embeddedMetricData)==null?void 0:b.externalMetric,adminTheme:(S=y==null?void 0:y.embeddedMetricData)==null?void 0:S.adminTheme,sharingSettingsId:(_=y==null?void 0:y.embeddedMetricData)==null?void 0:_.sharingSettingsId,errorMsg:(T=(D=y==null?void 0:y.embeddedMetricData)==null?void 0:D.error)==null?void 0:T.message,params:(C=y==null?void 0:y.embeddedMetricData)==null?void 0:C.params,companyId:(E=y==null?void 0:y.embeddedMetricData)==null?void 0:E.companyId,clientId:(k=y==null?void 0:y.embeddedMetricData)==null?void 0:k.clientId}},[i]),h=oe.useMemo(()=>{var y;return l?(y=l.chart.palettes.find(b=>b.name===l.chart.selected))==null?void 0:y.colors:null},[l]),{rlsSettings:v,tenancyLevel:g}=oe.useMemo(()=>{var b;if(!u)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const y=JSON.parse(u);return{rlsSettings:(b=y.rlsSettings)==null?void 0:b.find(S=>S.metricId===t),tenancyLevel:y.companyTenancyType||"TABLE"}},[u,t]);return BW(l),oe.useEffect(()=>{a&&r(!0),(o||d)&&r(!1)},[a,o,d]),{externalMetric:o,sharingSettingsId:s,adminColors:h,companyId:c,clientId:f,rlsSettings:v,tenancyLevel:g,isLoading:e,errorMsg:d}},Ti=({name:n,label:t,options:e=[],onChange:r,value:i,defaultValue:a,children:o,placeHolder:s,className:l="",containerClass:u="",isSearchEnabled:c,textSize:f,icon:d,labelVariant:h="static"})=>{const[v,g]=oe.useState(""),[y,b]=oe.useState(20),[S,_]=oe.useState(!1),D=oe.useRef(),T=i||a?e.find(k=>k.value===i||k.value===a):{label:s||"Select an option"},C={fontSize:f},E=oe.useMemo(()=>v?e.filter(k=>k.label.toLowerCase().includes(v)).slice(0,y):e.slice(0,y),[v,e,y]);return t1({wrapRef:D,onOutsideClick:()=>_(!1)}),P.jsxs("div",{ref:D,className:`${Vn.listbox} ${u}`,children:[d,t?P.jsx("label",{className:`${Vn["listBox-label"]} ${h==="floating"?Vn["listBox-labelFloating"]:""}`,children:t}):null,P.jsxs("div",{className:`${Vn.listboxButtonWrapper} ${l}`,children:[P.jsxs(It,{className:`${Vn["listBoxButton-container"]} ${h==="floating"?Vn["listBoxButton-containerFloating"]:""}`,type:"button",variant:"custom",name:n,onClick:()=>_(k=>!k),children:[P.jsx("span",{className:Vn.selectedOptionText,children:T==null?void 0:T.label}),P.jsx("span",{className:Vn.listBoxButton,children:P.jsx(bW,{className:Vn.arrowicon,"aria-hidden":"true"})})]}),P.jsx(MT,{show:S,as:oe.Fragment,leave:Vn.leave,leaveFrom:Vn.leaveFrom,leaveTo:Vn.leaveTo,children:P.jsx("div",{className:Vn["listBox-options"],children:P.jsxs(P.Fragment,{children:[c&&P.jsx(CT,{className:Vn.search,setSearchKeyword:g}),E.length===0?P.jsx("div",{className:Vn.notAvailable,children:"Not Available."}):E.map(k=>P.jsxs(It,{className:Gi(i===k.value?Vn.activeOption:Vn.inactiveOption,Vn.option),type:"button",variant:"custom",onClick:()=>{r==null||r(k.value),_(!1)},children:[P.jsx("span",{className:Vn.optionLabel,style:C,children:k.label}),i===k.value?P.jsx("span",{className:Vn.check,children:P.jsx(Lce,{className:Vn.checkIcon,"aria-hidden":"true"})}):null]},k.value)),y<=e.length&&P.jsxs(It,{variant:"secondary",type:"button",onClick:()=>b(y+30),className:Vn.loadMore,children:["Load More",P.jsx(pn,{name:"double-arrow-left-icon",className:Vn.loadMoreIcon})]}),o]})})})]})]})},YR=({control:n,name:t,...e})=>P.jsx(xR,{control:n,name:t,render:({field:{onChange:r,value:i}})=>P.jsx(Ti,{...e,onChange:r,value:i})}),Os=({options:n,defaultValue:t,value:e,onChange:r,label:i,name:a,className:o="",children:s,placeHolder:l,onClick:u,isSearchEnabled:c,containerClass:f="",labelVariant:d="static",icon:h})=>{const[v,g]=oe.useState(""),[y,b]=oe.useState(20),[S,_]=oe.useState(!1),D=oe.useRef(),T=oe.useMemo(()=>v?n.filter(C=>C.label.toLowerCase().includes(v)).slice(0,y):n.slice(0,y),[v,n,y]);return t1({wrapRef:D,onOutsideClick:()=>_(!1)}),oe.useEffect(()=>{t&&t.length&&(r==null||r(t))},[]),P.jsx(P.Fragment,{children:P.jsxs("div",{ref:D,className:`${Vn.listbox} ${f}`,children:[h,i?P.jsx("label",{className:`${Vn["listBox-label"]} ${d==="floating"?Vn["listBox-labelFloating"]:""}`,children:i}):null,P.jsxs("div",{className:Vn.listboxButtonWrapper,children:[P.jsxs(It,{className:`${Vn["listBoxButton-container"]} ${o} ${d==="floating"?Vn["listBoxButton-containerFloating"]:""}`,variant:"custom",type:"button",onClick:()=>_(C=>!C),name:a,children:[P.jsx("span",{className:Vn.selectedOptionText,children:l||"Choose options from list"}),P.jsx("span",{className:Vn.listBoxButton,children:P.jsx(bW,{className:Vn.arrowicon,"aria-hidden":"true"})})]}),P.jsx(MT,{show:S,as:oe.Fragment,leave:Vn.leave,leaveFrom:Vn.leaveFrom,leaveTo:Vn.leaveTo,children:P.jsxs("div",{className:Vn["listBox-options"],children:[c&&P.jsx(CT,{className:Vn.search,setSearchKeyword:g}),T.length===0?P.jsx("div",{className:Vn.notAvailable,children:"Not Available."}):T.map(C=>P.jsxs(It,{className:Gi(e!=null&&e.includes(C.value)?Vn.optionSelected:"",Vn.option),type:"button",variant:"custom",onClick:()=>{e!=null&&e.find(E=>E===C.value)?r==null||r(e.filter(E=>E!==C.value)):r==null||r([...e||[],C.value]),u==null||u()},children:[P.jsx("span",{className:Vn.check,children:e!=null&&e.includes(C.value)?P.jsx("div",{className:Vn.checkIconSelected,children:P.jsx(kce,{color:"white"})}):P.jsx("div",{className:Vn.checkIconUnselected})}),P.jsx("span",{className:`${Vn.optionLabel}`,children:C.label})]},C.value)),y<=n.length&&P.jsxs(It,{variant:"secondary",type:"button",onClick:()=>b(y+30),className:Vn.loadMore,children:["Load More",P.jsx(pn,{name:"double-arrow-left-icon",className:Vn.loadMoreIcon})]}),s]})})]}),e!=null&&e.length?P.jsx("div",{className:Vn.selectedList,children:e.map(C=>{var E;return P.jsx(wt,{styleClass:"font-14c",variant:"p",className:Vn.selectedListItem,children:(E=n.find(k=>k.value===C))==null?void 0:E.label},C)})}):null]})})},Ade=({control:n,name:t,...e})=>P.jsx(P.Fragment,{children:P.jsx(xR,{control:n,name:t,render:({field:{onChange:r,value:i}})=>P.jsx(Os,{...e,name:t,value:i,onChange:r})})}),yp={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"},Ide={error:"_error_1csa7_1"},jT=({message:n=""})=>P.jsx(wt,{variant:"p",styleClass:"custom",className:Ide.error,children:n}),fn=({type:n="text",register:t,error:e,icon:r,label:i,isDisabled:a,labelClass:o,inputClass:s,className:l,labelVariant:u="static",id:c,elementRef:f,...d})=>["checkbox","radio"].includes(n)?P.jsxs("div",{className:`${yp.checkboxField} ${l??""}`,children:[P.jsx("input",{...d,ref:f,type:n,id:c,className:s,...t,disabled:a}),i?P.jsxs("label",{htmlFor:c,className:`${yp.checkboxLabel} ${o}`,children:[r," ",i]}):null]}):P.jsxs("div",{className:`${yp["inputField-container"]} ${l??""}`,children:[i?P.jsx("label",{htmlFor:c,className:`${yp.label} ${u==="floating"?yp.floatingLabel:""} ${o}`,children:i}):null,P.jsxs("div",{className:yp.inputWrapper,children:[P.jsx("input",{...d,ref:f,id:c,type:n,className:`${yp.input} ${u==="floating"?yp.floatingInput:""} ${s}`,...t,disabled:a}),r]}),e&&P.jsx(jT,{message:e.message})]}),Nde=({data:n,chartSettings:t,setChartSettings:e,groupbyList:r})=>{var b,S,_,D,T,C,E,k,R,L;const[i,a]=oe.useState(""),[o,s]=oe.useState(""),[l,u]=oe.useState("");oe.useEffect(()=>{if(!t.sankeyValues||i||o||l)return;const[I,z,j]=t.sankeyValues;a(I),s(z),u(j)},[t.sankeyValues]);const c=oe.useMemo(()=>{const I=n?Object.keys(n[0]||{}).map(z=>({value:z,label:z})):[];return I.push({value:"NONE",label:"NONE"}),I},[n]),f=oe.useMemo(()=>c==null?void 0:c.filter(I=>!r.includes(I.value)),[c]),d=oe.useMemo(()=>c==null?void 0:c.filter(I=>r.includes(I.value)),[c]),h=oe.useCallback(I=>{e(z=>({...z,yAxisList:I.filter(j=>j&&j!=="NONE"&&c.map(O=>O.value).includes(j))}))},[c]),v=oe.useCallback(I=>{e(z=>({...z,pivotTableSettings:{...t.pivotTableSettings,rows:I.filter(j=>j&&j!=="NONE"&&(f==null?void 0:f.map(O=>O.value).includes(j)))}}))},[t.pivotTableSettings,c,e]),g=oe.useCallback(I=>{e(z=>({...z,pivotTableSettings:{...t.pivotTableSettings,columns:I.filter(j=>j&&j!=="NONE"&&(d==null?void 0:d.map(O=>O.value).includes(j)))}}))},[t.pivotTableSettings,c,e]),y=oe.useCallback(I=>{e(z=>({...z,gaugeSettings:{...t.gaugeSettings,dimensions:I.filter(j=>j&&j!=="NONE"&&(d==null?void 0:d.map(O=>O.value).includes(j)))}}))},[t.gaugeSettings,c,e]);return oe.useEffect(()=>{i&&o&&l&&e(I=>({...I,sankeyValues:[i,o,l]}))},[i,o,l]),t.chartType===sde?P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Source",options:c,onChange:I=>{I===o&&s(""),a(I)},value:i,isSearchEnabled:!0}),P.jsx(Ti,{label:"Target",options:c.filter(I=>I.value!==i),onChange:s,value:o,isSearchEnabled:!0}),P.jsx(Ti,{label:"Value",options:c.filter(I=>I.value!==i&&I.value!==o),onChange:u,value:l,isSearchEnabled:!0})]}):t.chartType===nt.pivot?P.jsxs("div",{className:os.container,children:[P.jsx(Os,{label:"Metrics",name:"metrics",options:f||[],defaultValue:f==null?void 0:f.map(I=>I.value),value:(b=t==null?void 0:t.pivotTableSettings)==null?void 0:b.rows,onChange:v,isSearchEnabled:!0}),P.jsx(Os,{label:"Group by",name:"groupby",options:d||[],defaultValue:d==null?void 0:d.map(I=>I.value),value:(S=t==null?void 0:t.pivotTableSettings)==null?void 0:S.columns,onChange:g,isSearchEnabled:!0})]}):t.chartType===nt.gauge?P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Metric",options:f||[],onChange:I=>e(z=>({...z,gaugeSettings:{...t.gaugeSettings,metric:I}})),value:(_=t==null?void 0:t.gaugeSettings)==null?void 0:_.metric,isSearchEnabled:!0}),P.jsx(Os,{label:"Dimensions",name:"dimensions",options:d||[],defaultValue:d==null?void 0:d.map(I=>I.value),value:(D=t==null?void 0:t.gaugeSettings)==null?void 0:D.dimensions,onChange:y,isSearchEnabled:!0})]}):t.chartType===HW?P.jsx(P.Fragment,{children:!!(t.chartType===HW||WW)&&P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Dimension",options:c,onChange:I=>e(z=>({...z,xAxis:I})),value:t.xAxis,isSearchEnabled:!0}),P.jsx(Os,{label:"Measure",name:"yAxisList",options:c,value:t.yAxisList,onChange:h,isSearchEnabled:!0})]})}):t.chartType===WW?P.jsx(P.Fragment,{children:P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Dimension",options:c,onChange:I=>e(z=>({...z,xAxis:I})),value:t.xAxis,isSearchEnabled:!0}),P.jsx(Os,{name:"yAxisList",label:"Measure",options:c,value:t.yAxisList,onChange:h,isSearchEnabled:!0})]})}):t.chartType===nt.singleValue?P.jsx("div",{className:os.container,children:P.jsx(Ti,{label:"Measure",options:c,onChange:I=>e(z=>({...z,singleValue:I})),value:t.singleValue,isSearchEnabled:!0})}):P.jsx(P.Fragment,{children:P.jsxs("div",{className:os.container,children:[![nt.gauge,nt.boxplot,nt.table].includes(t.chartType)&&P.jsx(P.Fragment,{children:t.chartType===nt.funnel?P.jsx(Ti,{label:"Step",options:c,onChange:I=>e(z=>({...z,step:I})),value:t.step,isSearchEnabled:!0}):P.jsx(Ti,{label:t.chartType===nt.row?"Y-axis":"X-axis",options:c,onChange:I=>e(z=>({...z,xAxis:I})),value:t.xAxis,isSearchEnabled:!0})}),[nt.funnel,nt.gauge,nt.boxplot].includes(t.chartType)?P.jsx(Ti,{label:"Measure",options:c,onChange:I=>e(z=>({...z,measure:I})),value:t.measure,isSearchEnabled:!0}):P.jsxs(P.Fragment,{children:[P.jsx(Os,{label:t.chartType===nt.row?"X-axis":t.chartType===nt.table?"Measure":"Y-axis",name:"yAxisList",options:c,value:t.yAxisList,onChange:h,isSearchEnabled:!0}),[nt.line,nt.bar,nt.area,nt.combo,nt.scatter,nt.bubble,nt.stack,nt.waterfall].includes(t.chartType)?P.jsxs(P.Fragment,{children:[" ",P.jsx(fn,{type:"checkbox",label:"Switch X-axis",className:os.checkboxTooltipWrapper,checked:(T=t==null?void 0:t.dynamicXAxis)==null?void 0:T.isEnabled,onChange:I=>e(z=>({...z,dynamicXAxis:{isEnabled:I.target.checked,options:[],selectedOption:{value:"",label:""}}}))}),((C=t.dynamicXAxis)==null?void 0:C.isEnabled)&&P.jsx(Os,{label:"X-axis options",options:c,onChange:I=>e(z=>{var j;return{...z,dynamicXAxis:{isEnabled:!!((j=z.dynamicXAxis)!=null&&j.isEnabled),options:(I==null?void 0:I.map(O=>({label:O,value:O})))||[],selectedOption:{value:(I==null?void 0:I[0])||"",label:(I==null?void 0:I[0])||""}},xAxis:I==null?void 0:I[0]}}),value:((R=(k=(E=t.dynamicXAxis)==null?void 0:E.options)==null?void 0:k.filter(I=>{var z;return(z=c.map(j=>j.value))==null?void 0:z.includes(I.value)}))==null?void 0:R.map(I=>I.value))||[],isSearchEnabled:!0})]}):null,[nt.line,nt.bar,nt.timeSeries,nt.stack].includes(t.chartType)?P.jsxs(P.Fragment,{children:[P.jsx(fn,{type:"checkbox",label:"Multi Series",className:os.checkboxTooltipWrapper,checked:t==null?void 0:t.isMultiDimension,onChange:I=>e(z=>({...z,isMultiDimension:I.target.checked,isDynamicSeries:!1}))}),(t==null?void 0:t.isMultiDimension)&&P.jsx(fn,{type:"checkbox",label:"dynamic group",className:os.checkboxTooltipWrapper,checked:t==null?void 0:t.isDynamicSeries,onChange:I=>e(z=>({...z,isDynamicSeries:I.target.checked,seriesField:"ungrouped"}))}),t.isDynamicSeries&&P.jsx(fn,{type:"text",label:"Alias for Ungrouped",placeholder:"add alias for ungrouped",className:os.checkboxTooltipWrapper,onChange:I=>e(z=>({...z,ungroupedAlias:I.target.value})),value:t.ungroupedAlias})]}):null,[nt.line,nt.bar,nt.timeSeries,nt.stack].includes(t.chartType)&&t.isMultiDimension?t.isDynamicSeries?P.jsx(Os,{label:"Series Column",options:d,onChange:I=>e(z=>({...z,seriesField:(I==null?void 0:I[0])||"ungrouped",seriesOptions:(I==null?void 0:I.filter(j=>j!=="ungrouped"))||[]})),value:((L=t.seriesOptions)==null?void 0:L.filter(I=>{var z;return(z=d.map(j=>j.value))==null?void 0:z.includes(I)}))||[],isSearchEnabled:!0}):P.jsx(Ti,{label:"Series Column",options:[{value:"ungrouped",label:"ungrouped"},...d],onChange:I=>e(z=>({...z,seriesField:I})),value:t.seriesField,isSearchEnabled:!0}):null]})]})})},Lde=[{name:"Line",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M3 22V8h4v14H3m7 0V2h4v20h-4m7 0v-8h4v8h-4Z"})})},{name:"Combo",icon:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M27 28V16h-8v12h-4V12H7v16H4V2H2v26a2 2 0 0 0 2 2h26v-2Zm-14 0H9V14h4Zm12 0h-4V18h4Z"}),P.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:n=>P.jsxs("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M4 21h17v-2H5V3H3v17a1 1 0 0 0 1 1z"}),P.jsx("circle",{cx:10,cy:8,r:2,fill:"currentColor"}),P.jsx("circle",{cx:18,cy:12,r:2,fill:"currentColor"}),P.jsx("circle",{cx:11.5,cy:13.5,r:1.5,fill:"currentColor"}),P.jsx("circle",{cx:16.5,cy:6.5,r:1.5,fill:"currentColor"})]})},{name:"Row",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M4 22H2V2h2v20Zm11-1H5v-3h10v3Zm3-5H5v-3h13v3Zm3-5H5V8h16v3Zm-8-5H5V3h8v3Z"})})},{name:"Area",icon:n=>P.jsx("svg",{viewBox:"0 0 1024 1024",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M28 28V18h-2v10h-4V4h-2v24H10V14H8v14H4V2H2v26a2.002 2.002 0 0 0 2 2h26v-2Z"}),P.jsx("path",{fill:"currentColor",d:"M14 4h2v14h-2z"})]})},{name:"Funnel",icon:n=>P.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"}),P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M3 4h1v9h3V7h5v4h4v4h4v6H3V4m13 12v4h3v-4h-3m-4-4v8h3v-8h-3M8 8v12h3V8H8m-4 6v6h3v-6H4Z"})})},{name:"Gauge",icon:n=>P.jsx("svg",{viewBox:"0 0 20 20",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M22 6V4H12v2h4v2h-4v12h4v2h-4v2h10v-2h-4v-2h4V8h-4V6Zm-8 12v-3h6v3Zm6-5h-6v-3h6Z"}),P.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"})]})},{name:"Table",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M8 16h5v-5H8v5Zm0-7h12V4H8v5Zm7 7h5v-5h-5v5Zm-7 2q-.825 0-1.413-.588T6 16V4q0-.825.588-1.413T8 2h12q.825 0 1.413.588T22 4v12q0 .825-.588 1.413T20 18H8Zm-4 4q-.825 0-1.413-.588T2 20V6h2v14h14v2H4Z"})})},{name:"Time series",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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"})})}],kde=({chartType:n,onChartChange:t,isEnableTimeSeries:e,isEnablePivotTable:r,hasNumberKeys:i,isEnableGauge:a,enableCharts:o})=>P.jsx("div",{className:os.chartOptions,children:Lde.map(s=>P.jsxs("div",{className:os.chartOption,children:[P.jsx(It,{type:"button",variant:"custom",className:n===s.name.toLowerCase()?os.chartOptionBtnSelected:os.chartOptionBtn,onClick:()=>{t(s.name.toLowerCase())},isDisabled:s.name.toLowerCase()===nt.timeSeries&&!e||s.name.toLowerCase()===nt.pivot&&!r||!o.includes(s.name.toLowerCase()),children:P.jsx(s.icon,{style:{color:s.name.toLowerCase()===nt.timeSeries&&!e||s.name.toLowerCase()===nt.pivot&&!r||!o.includes(s.name.toLowerCase())?"grey":"blue",width:"20px",height:"20px"}})},s.name),P.jsx(wt,{variant:"p",styleClass:"custom",className:os.chartOptionText,children:s.name})]},s.name))}),Rde=({datatype:n="unknown",className:t})=>pde.includes(n.toLowerCase())?P.jsx(pn,{name:"number-icon",className:t}):vde.includes(n.toLowerCase())||n.toLowerCase().includes("char")?P.jsx(pn,{name:"text-icon",className:t}):gde.includes(n.toLowerCase())?P.jsx(pn,{name:"array-icon",className:t}):JW.includes(n.toLowerCase())?P.jsx(pn,{name:"date-icon",className:t}):mde.includes(n.toLowerCase())?P.jsx(pn,{name:"boolean-icon",className:t}):P.jsx(pn,{name:"unknown-icon"}),tU={container:"_container_1izll_1",windowIcon:"_windowIcon_1izll_7"},Ode=n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.5,children:[P.jsx("path",{d:"M15 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10"}),P.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"})]})}),Pde=()=>P.jsxs("div",{role:"alert",className:tU.container,children:[P.jsx(Ode,{className:tU.windowIcon}),P.jsx(wt,{variant:"p",styleClass:"font-20",children:"Something went wrong!"}),P.jsx(It,{variant:"primary",size:"large",type:"button",onClick:()=>location.reload(),children:"Try again"})]}),xg={container:"_container_dv0n1_1",field:"_field_dv0n1_9",fieldLabel:"_fieldLabel_dv0n1_17",save:"_save_dv0n1_25",cancel:"_cancel_dv0n1_33",error:"_error_dv0n1_41"},FT={container:"_container_1rie6_1",label:"_label_1rie6_9",textarea:"_textarea_1rie6_17",resizable:"_resizable_1rie6_25"},$de=({id:n,label:t,placeholder:e,rows:r,cols:i,resizable:a=!0,register:o,error:s,defaultValue:l,value:u,onFocus:c,onBlur:f,className:d})=>P.jsxs("div",{className:`${FT.container} ${d}`,children:[P.jsx("label",{htmlFor:n,className:FT.label,children:t}),P.jsx("textarea",{id:n,name:n,rows:r,cols:i,placeholder:e,className:Gi(FT.textarea,`${a?null:FT.resizable}`),defaultValue:l,...o,value:u,onFocus:c,onBlur:f}),s&&P.jsx(jT,{message:s.message})]}),zde=({name:n,styles:t,placeholder:e,enabled:r})=>P.jsxs("label",{htmlFor:n,className:`${t.button}`,children:[Array.isArray(e)&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.label} ${r?t.labelInactive:t.labelActive}`,children:e[0]}),P.jsx("span",{className:` ${t.switch} ${r?t.enabled:t.notenabled}`}),P.jsx("span",{className:` ${t.label} ${r?t.labelActive:t.labelInactive}`,children:e[1]})]}),typeof e=="string"&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.switch} ${r?t.enabled:t.notenabled}`}),P.jsx("span",{className:` ${t.label} ${r?t.labelActive:t.labelInactive}`,children:e})]}),!Array.isArray(e)&&typeof e!="string"&&P.jsx("span",{className:` ${t.switch} ${r?t.enabled:t.notenabled}`})]}),BT={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"},jde=({name:n,styles:t,placeholder:e,enabled:r})=>P.jsxs("label",{htmlFor:n,className:`${t.button} ${t.toggleWidth}`,children:[Array.isArray(e)&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.label} ${r&&t.toggleInactive}`,children:e[0]}),P.jsx("span",{className:` ${t.switch} ${t.toggle} ${r?t.enabled:t.notenabled}
|
|
275
|
+
}`),t){const h=document.querySelectorAll("dbn-dashboard");h.length&&h.forEach((y,b)=>{if(y&&y.shadowRoot){const S=document.querySelector(`#dbn-dashboard-${b}-admin-styles`);if(S)S.innerHTML=e;else{const _=document.createElement("style");_.setAttribute("id",`dbn-dashboard-${b}-admin-styles`),_.innerHTML=e,y.shadowRoot.appendChild(_)}}});const v=document.querySelectorAll("dbn-metric");v.length&&v.forEach((y,b)=>{if(y.shadowRoot){const S=document.querySelector(`#dbn-metric-${b}-admin-styles`);if(S)S.innerHTML=e;else{const _=document.createElement("style");_.setAttribute("id",`dbn-metric-${b}-admin-styles`),_.innerHTML=e,y.shadowRoot.appendChild(_)}}});const g=document.querySelector("#dbn-portal");if(g&&g.shadowRoot){const y=document.querySelector("#dbn-portal-admin-styles");y&&g.shadowRoot.removeChild(y)}}else{const h=document.querySelector("#dbn-admin-styles")||document.createElement("style");h.setAttribute("id","dbn-admin-styles"),h.innerHTML=e,document.querySelector("#dbn-admin-styles")||document.head.appendChild(h)}},[n])},nde=({token:n,dashboardId:t})=>v0([ufe,{dashboardId:t}],()=>{const e=t?`${Mc}?dashboardId=${t}`:Mc;return wo(e,{method:"GET",token:n})},{enabled:!!n}),rde=(n,t)=>v0([jW,{dashboardId:n,clientId:t}],()=>wo(`${dfe}?id=${n}&clientId=${t}`,{method:"GET"}),{enabled:!!n&&!!t}),ide=n=>v0(pfe,()=>wo(hfe,{method:"GET",token:n}),{enabled:!!n}),ade=(n,t)=>v0([ffe,{id:t}],()=>wo(`${cfe}?metricId=${t}`,{method:"GET",token:n}),{enabled:!!n}),ode=({externalDashboardId:n,clientId:t})=>{const e=$T(),{data:r,isLoading:i}=rde(n,t),[a,o]=oe.useMemo(()=>{const c=r;return[(c==null?void 0:c.layout)||[],!!(c!=null&&c.isLocked)]},[r]),{mutateAsync:s,isLoading:l}=Wfe();return{saveLayout:oe.useCallback(async(c,f)=>{await s({clientId:t,externalDashboardId:n,layout:c,isLocked:!!f},{onSuccess:d=>{if(!d)return;const h=d;e.setQueryData([jW,{dashboardId:n,clientId:t}],v=>({...v,...h}))}})},[s,t,n]),layout:a,isLayoutLocked:o,isLoadingLayout:i||l}},wu="something went wrong, please try again",nt={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"},Cc={month:"monthly",quarter:"quarterly",daily:"daily",weekly:"weekly",yearly:"yearly"},VW="client_id_variable",n1="INPUT_TABLE",r1="OUTPUT_TABLE",HW="doughnut",WW="pie",sde="sankey",_g="general",i1="configuration",UW={Snowflake:"Snowflake",Redshift:"Redshift",BigQuery:"BigQuery",Postges:"Postgres"},GW="{{DATABASE_NAME}}",YW="'client_id_variable'",QW="DATABASE",ZW=[{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"}],lde=[{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"}],ude=[{value:"AM",label:"AM"},{value:"PM",label:"PM"}],cde=[{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"}],fde=[{value:"Daily",label:"Daily"},{value:"Weekly",label:"Weekly"},{value:"Monthly",label:"Monthly"}],XW=[{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"}],dde=[{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"}],hde=[{value:"100",label:"100"},{value:"200",label:"200"},{value:"300",label:"300"},{value:"400",label:"400"},{value:"500",label:"500"},{value:"1000",label:"1000"}],qW=[{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"}],a1=[{label:"Show 10",value:"10"},{label:"Show 25",value:"25"},{label:"Show 50",value:"50"},{label:"Show 75",value:"75"},{label:"Show 100",value:"100"},{label:"Show 250",value:"250"},{label:"Show 500",value:"500"},{label:"Show 1k",value:"1000"}],pde=["fixed","real","int","bigint","float","number","integer","int64","float64","double precision","smallint"],vde=["varchar","text","char","text","character(36)","string"],JW=["timestamp_ltz","date","timestamp","timestamp without time zone","timestamp with time zone","datetime"],gde=["array","text[]"],mde=["boolean","bool"],KW=["saved","simple","custom"],Vl={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,0,0,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:[],badgeColumns:[],badgeColors:{},badgeTextColors:{},badgeSeparator:",",listColumns:[],listSeparator:","},pivotTableSettings:{rows:[],columns:[]},gaugeSettings:{metric:"",dimensions:[]},axisSettings:{axis:"left"},backGroundColor:{show:!1},timeSeriesSettings:{groupBySettings:{isDynamic:!1,options:[],value:"monthly",fillXAxis:!1},seriesType:[]},isDynamicSeries:!1,isMultiDimension:!1,seriesField:"ungrouped",seriesOptions:["ungrouped"],ungroupedAlias:"",dynamicXAxis:{isEnabled:!1,options:[],selectedOption:{value:"",label:""}}},zT=[{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"}],yde=(n,t)=>{let e=n.replace(/;([^;]*)$/,"");const r=parseInt(t,10);if(e.toLowerCase().includes("limit")){const i=parseInt(e.toLowerCase().split("limit")[1].trim(),10),a=Math.min(i,r);e=e.replace(`limit ${i}`,`limit ${a}`),e=e.replace(`LIMIT ${i}`,`LIMIT ${a}`)}else e+=` limit ${r}`;return e},bde=({limit:n,query:t,clientName:e,tenancyType:r,values:i})=>{const a=yde(t,n),o=e?r===QW?a.replace(new RegExp(GW,"g"),e):Number(e)?a.replace(new RegExp(YW,"g"),e):a.replace(new RegExp(VW,"g"),e):a;return i?o.replace(/[^']+_variable/g,l=>`${i[l]}`):o},wde=({clientName:n,tenancyType:t,values:e,query:r,companyId:i,workspaceId:a,metricId:o})=>{const{mutate:s}=Kfe();return{getUnderlyingData:({columnName:u,value:c,setData:f,setLoading:d,isSingleValueChart:h})=>{const v=bde({query:r,limit:"5000",clientName:n,tenancyType:t,values:e});f([]),d(!0),s({columnName:h?void 0:u,companyId:i,query:v,value:h||c==null?void 0:c.replace(/'/g,"''"),workspaceId:a,metricId:o},{onSuccess(g){const y=g==null?void 0:g.data;y&&Array.isArray(y)&&y.length?(f(y),d(!1)):(f([]),d(!1))},onError(){f([]),d(!1)}})}}},Sde=({range:n,count:t,time:e,from:r,to:i})=>{const a=new Date;new Date(a).setDate(a.getDate()-1);const s=a.getMonth(),l=a.getFullYear();let u,c;if(n==="This"){switch(e){case"Year":u=new Date(l,0,1),c=new Date(a);break;case"Month":u=new Date(l,s,1),c=new Date(a);break;case"Week":{const f=a.getDate()-a.getDay();u=new Date(a.setDate(f)),c=new Date(a.setDate(f+6));break}case"Day":u=new Date(a),c=new Date(a);break;default:u=new Date(0),c=new Date(a)}return{startDate:u,endDate:c}}if(n==="Last"){switch(e){case"Year":{let f,d;t===1?(f=t,d=l-1):(f=t-1,d=l),u=new Date(l-f,0,1),c=new Date(d,11,31);break}case"Month":{const f=t===1?s-1:s-t+1;u=new Date(l,f,1),c=new Date(l,s,t===1?0:31);break}case"Week":{const f=new Date(a.setDate(a.getDate()-(a.getDay()+1)%7)),d=new Date(f.getFullYear(),f.getMonth(),f.getDate()-6),h=t-1;u=new Date(d.setDate(d.getDate()-7*h)),c=new Date(f.setDate(f.getDate()-7*(h-1))),h===0&&(c=new Date(a));break}case"Day":u=new Date(a),u.setDate(a.getDate()-t),c=new Date(a);break;default:u=new Date(0),c=new Date(a)}return{startDate:u,endDate:c}}return{startDate:r||new Date(0),endDate:i||new Date(a)}},_de=({data:n,format:t,measureColumn:e,timeColumn:r,dimensionColumn:i,startDate:a})=>n.reduce((s,l)=>{const u=Number(l[e]),c=new Date(l[r]);let f;switch(t){case"Week":{f=`Week ${Math.ceil((c.getDate()+a.getDay())/7)}`;break}case"Quarter":{const h=Math.ceil((c.getMonth()+1)/3),v=c.getFullYear();f=`Q${h} ${v}`;break}case"Month":{f=`${c.toLocaleString("default",{month:"long"})} ${c.getFullYear()}`;break}case"Day":{f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][c.getDay()];break}default:f=l[r]}const d=s.find(h=>h[i]===f);return d?d[e]+=u:s.push({[i]:f,[e]:u}),s},[]),xde=({dimensionColumn:n,endDate:t,measureColumn:e,format:r,groupedDataList:i,time:a,count:o,range:s})=>{const l=new Date().getFullYear(),u=l-1;let c=[],f=[];if(o===1&&s==="This"&&(c=Array.from({length:12},(g,y)=>({[n]:`${new Date(2e3,y,1).toLocaleString("default",{month:"long"})} ${l}`,[e]:0})),f=[{[n]:`Q1 ${l}`,[e]:0},{[n]:`Q2 ${l}`,[e]:0},{[n]:`Q3 ${l}`,[e]:0},{[n]:`Q4 ${l}`,[e]:0}]),o===1&&s==="Last"&&(c=Array.from({length:12},(g,y)=>({[n]:`${new Date(2e3,y,1).toLocaleString("default",{month:"long"})} ${u}`,[e]:0})),f=[{[n]:`Q1 ${u}`,[e]:0},{[n]:`Q2 ${u}`,[e]:0},{[n]:`Q3 ${u}`,[e]:0},{[n]:`Q4 ${u}`,[e]:0}]),o>1&&s==="Last"){for(let g=l-o+1;g<=l;g++)for(let y=0;y<12;y++)c.push({[n]:`${new Date(g,y,1).toLocaleString("default",{month:"long"})} ${new Date(g,y,1).getFullYear()}`,[e]:0});for(let g=l-o;g<=l;g++)f.push({[n]:`Q1 ${g}`,[e]:0},{[n]:`Q2 ${g}`,[e]:0},{[n]:`Q3 ${g}`,[e]:0},{[n]:`Q4 ${g}`,[e]:0})}const d=Array.from({length:4},(g,y)=>({[n]:`Week ${y+1}`,[e]:0})),h=[{[n]:"Sunday",[e]:0},{[n]:"Monday",[e]:0},{[n]:"Tuesday",[e]:0},{[n]:"Wednesday",[e]:0},{[n]:"Thursday",[e]:0},{[n]:"Friday",[e]:0},{[n]:"Saturday",[e]:0}];let v=[];switch(`${s}${o>1?` ${o} `:" "}${a} By ${r}`){case"This Year By Month":case"Last Year By Month":case`Last ${o} Year By Month`:{v=c.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Year By Quarter":case"Last Year By Quarter":case`Last ${o} Year By Quarter`:{v=f.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Month By Week":case"Last Month By Week":{v=d.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Week By Day":case"Last Week By Day":{v=h.map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}case"This Quarter By Month":{const y=(Math.ceil((t.getMonth()+1)/3)-1)*3,b=y+2;v=c.slice(y,b+1).map(_=>{const D=i.find(T=>T[n]===_[n]);return D||_});break}case"Last Quarter By Month":{const g=Math.ceil((t.getMonth()+1)/3),b=((g===1?4:g-1)-1)*3,S=b+2;v=c.slice(b,S+1).map(D=>{const T=i.find(C=>C[n]===D[n]);return T||D});break}case`Last ${o} Month By Month`:{v=Array.from({length:o},(g,y)=>{const b=new Date(t.getFullYear(),t.getMonth()-y,1);return{[n]:`${b.toLocaleString("default",{month:"long"})} ${b.getFullYear()}`,[e]:0}}).reverse().map(g=>{const y=i.find(b=>b[n]===g[n]);return y||g});break}default:v=i}return v},Mde=({data:n,dimensionColumn:t,measureColumn:e,timeColumn:r,option:i})=>{const{endDate:a,startDate:o}=Sde({range:i.range,count:i.count,from:i.startDate,to:i.endDate,time:i.time});if(i.time==="Week"&&i.count>1)return n.map(c=>({[t]:c[t],[e]:c[e]}));const s=_de({data:n,dimensionColumn:t,format:i.format,measureColumn:e,startDate:o,timeColumn:r}),l=Object.values(s);return i.name==="Custom"?l:xde({dimensionColumn:t,endDate:a,format:i.format,groupedDataList:l,measureColumn:e,time:i.time,count:i.count,range:i.range})},Cde=n=>v0([Lfe,n],()=>wo(Nfe,{method:"POST",data:n}),{enabled:!!(n!=null&&n.id)}),Tde=n=>v0([Rfe,n],()=>wo(`${kfe}?id=${n}`,{method:"GET"}),{enabled:!!n}),eU=({metric:n,globalFilters:t={tableName:"",filters:[]},rlsFilters:e,clientId:r,chartSettings:i,setChartSettings:a,tenancyLevel:o,isInternalApp:s,appFilters:l})=>{var ue,pe,fe,ve,me,Se,K;const[u,c]=oe.useState({limit:10,offset:0}),[f,d]=oe.useState(0),[h,v]=oe.useState(n.rlsConditions||[]),[g,y]=oe.useState(!1),[b,S]=oe.useState(),[_,D]=oe.useState([]),[T,C]=oe.useState(!0),[E,k]=oe.useState([]),[R,L]=oe.useState([]),[I,z]=oe.useState(!1),[j,O]=oe.useState([]),{data:F,isLoading:V}=Cde({id:n.id,drillFilters:(ue=n==null?void 0:n.drillDownSettings)!=null&&ue.isEnableGroupBy?E:[],clientId:r,tenancyLevel:o,rlsConditions:j,globalFilters:t,filterValues:e==null?void 0:e.filterValues,limit:(pe=i==null?void 0:i.tableSettings)!=null&&pe.isServerSidePagination&&(i==null?void 0:i.chartType)===nt.table?Math.min(u.limit,1e3):void 0,offset:(fe=i==null?void 0:i.tableSettings)!=null&&fe.isServerSidePagination&&(i==null?void 0:i.chartType)===nt.table?u.offset:void 0}),W=oe.useMemo(()=>{var he,be;return!!h.length&&((be=(he=h.find(_e=>_e.isAddOnMetrics&&_e.datatype==="date"&&_e.columnName===i.xAxis))==null?void 0:he.options)==null?void 0:be.every(_e=>_e.format))},[h,i]),Y=he=>he.includes("____")?he.split("____")[1]:he,Z=oe.useMemo(()=>{var he,be,_e,ce;return Y(((ce=(he=n==null?void 0:n.datasetMetricSettings)==null?void 0:he.selectedDimensions)==null?void 0:ce[E.length<((_e=(be=n==null?void 0:n.datasetMetricSettings)==null?void 0:be.selectedDimensions)==null?void 0:_e.length)?E.length:0])||"")},[n==null?void 0:n.datasetMetricSettings,E]);oe.useEffect(()=>{var he;(he=h==null?void 0:h.filter(be=>be.isAddOnMetrics))!=null&&he.length?O(o==="DATABASE"?n.rlsConditions.filter(be=>be.isAddOnMetrics&&be.datatype!=="date").map(be=>{var _e;return{...be,tableName:`${r}.${be.tableName.split(".").slice(1).join(".")}`,dimensionColumn:i.xAxis||"",measureColumn:((_e=i.yAxisList)==null?void 0:_e[0])||""}}):h.filter(be=>be.isAddOnMetrics).map(be=>{var _e,ce,we,Ae,Be,qe;return s?{...be,dimensionColumn:i.xAxis||"",measureColumn:((_e=i.yAxisList)==null?void 0:_e[0])||""}:{...be,dimensionColumn:i.xAxis||"",measureColumn:((ce=i.yAxisList)==null?void 0:ce[0])||"",value:be.isAppFilter?be.datatype==="date"?(we=be==null?void 0:be.options)==null?void 0:we.find(je=>{var Ye;return je.name===((Ye=l==null?void 0:l.values)==null?void 0:Ye[be.name])}):be.datatype==="string"&&typeof((Ae=l==null?void 0:l.values)==null?void 0:Ae[be.name])=="string"?[(Be=l==null?void 0:l.values)==null?void 0:Be[be.name]]:(qe=l==null?void 0:l.values)==null?void 0:qe[be.name]:be.value}})):O([])},[h,l]);const G=oe.useMemo(()=>{var he,be,_e,ce,we;return(i==null?void 0:i.chartType)===nt.singleValue&&!!((he=i==null?void 0:i.customSettings)!=null&&he.comparisonValueShow)&&!!((be=i==null?void 0:i.customSettings)!=null&&be.comparisonTimeColumn)&&!!((_e=i==null?void 0:i.customSettings)!=null&&_e.comparisonTimeGrain)&&!!((ce=i==null?void 0:i.customSettings)!=null&&ce.comparisonTimePeriod)&&!!((we=i==null?void 0:i.customSettings)!=null&&we.comparisonTableName)&&!!(i!=null&&i.singleValue)},[i]);oe.useEffect(()=>{var ce;const he=F,be=he!=null&&he.data&&typeof he.data=="string"?JSON.parse(he.data):[];if((i==null?void 0:i.chartType)===nt.table&&d((he==null?void 0:he.totalRecords)||0),W){const we=h.find(Ae=>Ae.isAddOnMetrics&&Ae.datatype==="date");if(we){const Ae=Mde({data:be||[],dimensionColumn:we.columnName,measureColumn:((ce=i.yAxisList)==null?void 0:ce[0])||"",option:we.options.find(Be=>Be.name===we.value),timeColumn:i.xAxis||we.columnName});D(Ae)}else D(be??[])}else D(be??[]);const _e=he==null?void 0:he.metaData;L((_e==null?void 0:_e.groupbyColumnList)||[])},[F,W,G]),oe.useEffect(()=>{var he,be,_e,ce,we,Ae,Be,qe;if((he=n==null?void 0:n.drillDownSettings)!=null&&he.isEnableGroupBy&&_.length){const je=(ce=(_e=(be=n==null?void 0:n.drillDownSettings)==null?void 0:be.drilldownChartSettings)==null?void 0:_e.find(Ye=>Ye.name===Z))==null?void 0:ce.chartSettings;je&&((Ae=(we=n==null?void 0:n.datasetMetricSettings)==null?void 0:we.selectedDimensions)!=null&&Ae.length)&&((qe=(Be=n==null?void 0:n.datasetMetricSettings)==null?void 0:Be.selectedDimensions)==null?void 0:qe.length)>(E==null?void 0:E.length)?a(je):a(Ye=>{var De,it,Ke,_t,Tt,sn,mn,Qt;return{...Ye,xAxis:Y(((_t=(De=n==null?void 0:n.datasetMetricSettings)==null?void 0:De.selectedDimensions)==null?void 0:_t[E.length<((Ke=(it=n==null?void 0:n.datasetMetricSettings)==null?void 0:it.selectedDimensions)==null?void 0:Ke.length)?E.length:0])||"none"),yAxisList:(sn=(Tt=n==null?void 0:n.datasetMetricSettings)==null?void 0:Tt.metrics)==null?void 0:sn.map(lt=>{var mt;return(mt=lt==null?void 0:lt.as)==null?void 0:mt.replace(/["`]+/g,"")}),chartType:((Qt=(mn=n==null?void 0:n.datasetMetricSettings)==null?void 0:mn.selectedDimensions)==null?void 0:Qt.length)===(E==null?void 0:E.length)?"table":n.chartOptions.chartType}})}},[_,n.drillDownSettings,n==null?void 0:n.datasetMetricSettings,E]),oe.useEffect(()=>{V&&C(!0),!_.length&&!V&&setTimeout(()=>{C(!1)},5e3)},[V,_]);const J=oe.useCallback((he,be,_e,ce)=>{v(_e?we=>we.map(Ae=>Ae.name===he?{...Ae,value:be,options:Ae.options.map(Be=>Be.name==="Custom"?{...Be,..._e}:Be)}:Ae):ce?we=>we.map(Ae=>Ae.name===he?{...Ae,value:ce.map(Be=>Be.value)}:Ae):we=>we.map(Ae=>Ae.name===he?{...Ae,value:be}:Ae))},[]),ne=oe.useCallback(he=>{W||(he.event&&he.event.event.preventDefault(),S(he))},[h]),{getUnderlyingData:ee}=wde({clientName:r,tenancyType:o,values:e==null?void 0:e.filterValues,companyId:n==null?void 0:n.companyId,query:n==null?void 0:n.query,workspaceId:(ve=n==null?void 0:n.companyIntegration)==null?void 0:ve.workspaceId,metricId:n==null?void 0:n.id}),re=oe.useMemo(()=>Array.isArray(_)&&_.length&&(b!=null&&b.name)?_.map(he=>{const be=Object.entries(he).find(([,_e])=>_e===b.name);return be==null?void 0:be[0]}).filter(he=>he)[0]:"",[_,b==null?void 0:b.name]),se=oe.useCallback(he=>{const be=Array.isArray(_)&&_.length&&(he!=null&&he.name)?_.map(_e=>{const ce=Object.entries(_e).find(([,we])=>we===he.name);return ce==null?void 0:ce[0]}).filter(_e=>_e)[0]:"";k(be?_e=>{var ce;return((ce=n==null?void 0:n.datasetMetricSettings)==null?void 0:ce.selectedDimensions.length)>_e.length?[..._e,{columnName:be,value:he==null?void 0:he.name}]:[]}:[])},[_,n==null?void 0:n.datasetMetricSettings,n==null?void 0:n.drillDownSettings]);return oe.useEffect(()=>{_!=null&&_.length&&R.length?z(!0):z(!1)},[_,R.length,n==null?void 0:n.integrationName,n.query]),{onDrillDown:se,handleChartClick:ne,dataDb:_,getUnderlyingData:ee,onChangeFilterValue:J,isShowChartPopup:g,setShowChartPopup:y,columnName:re,chartParams:b,isQueryLoading:V||T,setLoading:C,drilledLevel:E.length,dimensions:((Se=(me=n==null?void 0:n.datasetMetricSettings)==null?void 0:me.selectedDimensions)==null?void 0:Se.map(he=>Y(he||"none")))||[],rlsConditions:h,setTableLimit:c,isEnableNextBtn:f>(u==null?void 0:u.limit)+(u==null?void 0:u.offset),isEnablePrevBtn:(u==null?void 0:u.offset)!==0,paginationInfo:{limit:u==null?void 0:u.limit,offset:u==null?void 0:u.offset,totalRecords:f},onChangePage:(he,be)=>{c(be?{limit:be,offset:0}:_e=>({limit:_e.limit,offset:he?_e.offset>_e.limit?_e.offset-_e.limit:0:_e.offset+_e.limit}))},isExternalChart:((K=i==null?void 0:i.tableSettings)==null?void 0:K.isServerSidePagination)&&(i==null?void 0:i.chartType)===nt.table,isEnablePivotTable:I,groupByList:R,hasNumberKeys:!0,isEnableGauge:!0,updateFilter:he=>{v(be=>be.map(_e=>_e.name===he.name&&_e.datatype===he.datatype&&_e.tableName===he.tableName&&_e.columnName===he.columnName?{..._e,isAddOnMetrics:!_e.isAddOnMetrics}:_e))}}},Dde=({dashboardId:n,clientId:t,metricId:e,onSuccess:r})=>{const i=$T(),{mutateAsync:a,isLoading:o}=tde();return{handleArchiveMetric:oe.useCallback(async()=>{!e||!t||await a({id:e,clientId:t},{onSuccess:l=>{l!=null&&l.insert_clientDeletedMetrics_one&&(i.setQueryData(["EmbeddedDashboardMetrics",{externalDashboardId:n,clientId:t}],u=>{var f;const c=(f=u==null?void 0:u.externalDashboardMetrics)==null?void 0:f.filter(d=>d.externalMetricId!==e);return{...u,externalDashboardMetrics:c}}),r())}})},[a,e,t]),isLoading:o}},Ede=({token:n,metricId:t})=>{const[e,r]=oe.useState(!0),{data:i,isLoading:a}=ade(n,t);console.log(i);const{externalMetric:o,sharingSettingsId:s,adminTheme:l,params:u,companyId:c,clientId:f,errorMsg:d}=oe.useMemo(()=>{var b,S,_,D,T,C,E,k;const y=i;return{externalMetric:(b=y==null?void 0:y.embeddedMetricData)==null?void 0:b.externalMetric,adminTheme:(S=y==null?void 0:y.embeddedMetricData)==null?void 0:S.adminTheme,sharingSettingsId:(_=y==null?void 0:y.embeddedMetricData)==null?void 0:_.sharingSettingsId,errorMsg:(T=(D=y==null?void 0:y.embeddedMetricData)==null?void 0:D.error)==null?void 0:T.message,params:(C=y==null?void 0:y.embeddedMetricData)==null?void 0:C.params,companyId:(E=y==null?void 0:y.embeddedMetricData)==null?void 0:E.companyId,clientId:(k=y==null?void 0:y.embeddedMetricData)==null?void 0:k.clientId}},[i]),h=oe.useMemo(()=>{var y;return l?(y=l.chart.palettes.find(b=>b.name===l.chart.selected))==null?void 0:y.colors:null},[l]),{rlsSettings:v,tenancyLevel:g}=oe.useMemo(()=>{var b;if(!u)return{rlsSettings:void 0,tenancyLevel:"TABLE"};const y=JSON.parse(u);return{rlsSettings:(b=y.rlsSettings)==null?void 0:b.find(S=>S.metricId===t),tenancyLevel:y.companyTenancyType||"TABLE"}},[u,t]);return BW(l),oe.useEffect(()=>{a&&r(!0),(o||d)&&r(!1)},[a,o,d]),{externalMetric:o,sharingSettingsId:s,adminColors:h,companyId:c,clientId:f,rlsSettings:v,tenancyLevel:g,isLoading:e,errorMsg:d}},Ti=({name:n,label:t,options:e=[],onChange:r,value:i,defaultValue:a,children:o,placeHolder:s,className:l="",containerClass:u="",isSearchEnabled:c,textSize:f,icon:d,labelVariant:h="static"})=>{const[v,g]=oe.useState(""),[y,b]=oe.useState(20),[S,_]=oe.useState(!1),D=oe.useRef(),T=i||a?e.find(k=>k.value===i||k.value===a):{label:s||"Select an option"},C={fontSize:f},E=oe.useMemo(()=>v?e.filter(k=>k.label.toLowerCase().includes(v)).slice(0,y):e.slice(0,y),[v,e,y]);return t1({wrapRef:D,onOutsideClick:()=>_(!1)}),P.jsxs("div",{ref:D,className:`${Vn.listbox} ${u}`,children:[d,t?P.jsx("label",{className:`${Vn["listBox-label"]} ${h==="floating"?Vn["listBox-labelFloating"]:""}`,children:t}):null,P.jsxs("div",{className:`${Vn.listboxButtonWrapper} ${l}`,children:[P.jsxs(It,{className:`${Vn["listBoxButton-container"]} ${h==="floating"?Vn["listBoxButton-containerFloating"]:""}`,type:"button",variant:"custom",name:n,onClick:()=>_(k=>!k),children:[P.jsx("span",{className:Vn.selectedOptionText,children:T==null?void 0:T.label}),P.jsx("span",{className:Vn.listBoxButton,children:P.jsx(bW,{className:Vn.arrowicon,"aria-hidden":"true"})})]}),P.jsx(MT,{show:S,as:oe.Fragment,leave:Vn.leave,leaveFrom:Vn.leaveFrom,leaveTo:Vn.leaveTo,children:P.jsx("div",{className:Vn["listBox-options"],children:P.jsxs(P.Fragment,{children:[c&&P.jsx(CT,{className:Vn.search,setSearchKeyword:g}),E.length===0?P.jsx("div",{className:Vn.notAvailable,children:"Not Available."}):E.map(k=>P.jsxs(It,{className:Gi(i===k.value?Vn.activeOption:Vn.inactiveOption,Vn.option),type:"button",variant:"custom",onClick:()=>{r==null||r(k.value),_(!1)},children:[P.jsx("span",{className:Vn.optionLabel,style:C,children:k.label}),i===k.value?P.jsx("span",{className:Vn.check,children:P.jsx(Lce,{className:Vn.checkIcon,"aria-hidden":"true"})}):null]},k.value)),y<=e.length&&P.jsxs(It,{variant:"secondary",type:"button",onClick:()=>b(y+30),className:Vn.loadMore,children:["Load More",P.jsx(pn,{name:"double-arrow-left-icon",className:Vn.loadMoreIcon})]}),o]})})})]})]})},YR=({control:n,name:t,...e})=>P.jsx(xR,{control:n,name:t,render:({field:{onChange:r,value:i}})=>P.jsx(Ti,{...e,onChange:r,value:i})}),Os=({options:n,defaultValue:t,value:e,onChange:r,label:i,name:a,className:o="",children:s,placeHolder:l,onClick:u,isSearchEnabled:c,containerClass:f="",labelVariant:d="static",icon:h})=>{const[v,g]=oe.useState(""),[y,b]=oe.useState(20),[S,_]=oe.useState(!1),D=oe.useRef(),T=oe.useMemo(()=>v?n.filter(C=>C.label.toLowerCase().includes(v)).slice(0,y):n.slice(0,y),[v,n,y]);return t1({wrapRef:D,onOutsideClick:()=>_(!1)}),oe.useEffect(()=>{t&&t.length&&(r==null||r(t))},[]),P.jsx(P.Fragment,{children:P.jsxs("div",{ref:D,className:`${Vn.listbox} ${f}`,children:[h,i?P.jsx("label",{className:`${Vn["listBox-label"]} ${d==="floating"?Vn["listBox-labelFloating"]:""}`,children:i}):null,P.jsxs("div",{className:Vn.listboxButtonWrapper,children:[P.jsxs(It,{className:`${Vn["listBoxButton-container"]} ${o} ${d==="floating"?Vn["listBoxButton-containerFloating"]:""}`,variant:"custom",type:"button",onClick:()=>_(C=>!C),name:a,children:[P.jsx("span",{className:Vn.selectedOptionText,children:l||"Choose options from list"}),P.jsx("span",{className:Vn.listBoxButton,children:P.jsx(bW,{className:Vn.arrowicon,"aria-hidden":"true"})})]}),P.jsx(MT,{show:S,as:oe.Fragment,leave:Vn.leave,leaveFrom:Vn.leaveFrom,leaveTo:Vn.leaveTo,children:P.jsxs("div",{className:Vn["listBox-options"],children:[c&&P.jsx(CT,{className:Vn.search,setSearchKeyword:g}),T.length===0?P.jsx("div",{className:Vn.notAvailable,children:"Not Available."}):T.map(C=>P.jsxs(It,{className:Gi(e!=null&&e.includes(C.value)?Vn.optionSelected:"",Vn.option),type:"button",variant:"custom",onClick:()=>{e!=null&&e.find(E=>E===C.value)?r==null||r(e.filter(E=>E!==C.value)):r==null||r([...e||[],C.value]),u==null||u()},children:[P.jsx("span",{className:Vn.check,children:e!=null&&e.includes(C.value)?P.jsx("div",{className:Vn.checkIconSelected,children:P.jsx(kce,{color:"white"})}):P.jsx("div",{className:Vn.checkIconUnselected})}),P.jsx("span",{className:`${Vn.optionLabel}`,children:C.label})]},C.value)),y<=n.length&&P.jsxs(It,{variant:"secondary",type:"button",onClick:()=>b(y+30),className:Vn.loadMore,children:["Load More",P.jsx(pn,{name:"double-arrow-left-icon",className:Vn.loadMoreIcon})]}),s]})})]}),e!=null&&e.length?P.jsx("div",{className:Vn.selectedList,children:e.map(C=>{var E;return P.jsx(wt,{styleClass:"font-14c",variant:"p",className:Vn.selectedListItem,children:(E=n.find(k=>k.value===C))==null?void 0:E.label},C)})}):null]})})},Ade=({control:n,name:t,...e})=>P.jsx(P.Fragment,{children:P.jsx(xR,{control:n,name:t,render:({field:{onChange:r,value:i}})=>P.jsx(Os,{...e,name:t,value:i,onChange:r})})}),yp={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"},Ide={error:"_error_1csa7_1"},jT=({message:n=""})=>P.jsx(wt,{variant:"p",styleClass:"custom",className:Ide.error,children:n}),fn=({type:n="text",register:t,error:e,icon:r,label:i,isDisabled:a,labelClass:o,inputClass:s,className:l,labelVariant:u="static",id:c,elementRef:f,...d})=>["checkbox","radio"].includes(n)?P.jsxs("div",{className:`${yp.checkboxField} ${l??""}`,children:[P.jsx("input",{...d,ref:f,type:n,id:c,className:s,...t,disabled:a}),i?P.jsxs("label",{htmlFor:c,className:`${yp.checkboxLabel} ${o}`,children:[r," ",i]}):null]}):P.jsxs("div",{className:`${yp["inputField-container"]} ${l??""}`,children:[i?P.jsx("label",{htmlFor:c,className:`${yp.label} ${u==="floating"?yp.floatingLabel:""} ${o}`,children:i}):null,P.jsxs("div",{className:yp.inputWrapper,children:[P.jsx("input",{...d,ref:f,id:c,type:n,className:`${yp.input} ${u==="floating"?yp.floatingInput:""} ${s}`,...t,disabled:a}),r]}),e&&P.jsx(jT,{message:e.message})]}),Nde=({data:n,chartSettings:t,setChartSettings:e,groupbyList:r})=>{var b,S,_,D,T,C,E,k,R,L;const[i,a]=oe.useState(""),[o,s]=oe.useState(""),[l,u]=oe.useState("");oe.useEffect(()=>{if(!t.sankeyValues||i||o||l)return;const[I,z,j]=t.sankeyValues;a(I),s(z),u(j)},[t.sankeyValues]);const c=oe.useMemo(()=>{const I=n?Object.keys(n[0]||{}).map(z=>({value:z,label:z})):[];return I.push({value:"NONE",label:"NONE"}),I},[n]),f=oe.useMemo(()=>c==null?void 0:c.filter(I=>!r.includes(I.value)),[c]),d=oe.useMemo(()=>c==null?void 0:c.filter(I=>r.includes(I.value)),[c]),h=oe.useCallback(I=>{e(z=>({...z,yAxisList:I.filter(j=>j&&j!=="NONE"&&c.map(O=>O.value).includes(j))}))},[c]),v=oe.useCallback(I=>{e(z=>({...z,pivotTableSettings:{...t.pivotTableSettings,rows:I.filter(j=>j&&j!=="NONE"&&(f==null?void 0:f.map(O=>O.value).includes(j)))}}))},[t.pivotTableSettings,c,e]),g=oe.useCallback(I=>{e(z=>({...z,pivotTableSettings:{...t.pivotTableSettings,columns:I.filter(j=>j&&j!=="NONE"&&(d==null?void 0:d.map(O=>O.value).includes(j)))}}))},[t.pivotTableSettings,c,e]),y=oe.useCallback(I=>{e(z=>({...z,gaugeSettings:{...t.gaugeSettings,dimensions:I.filter(j=>j&&j!=="NONE"&&(d==null?void 0:d.map(O=>O.value).includes(j)))}}))},[t.gaugeSettings,c,e]);return oe.useEffect(()=>{i&&o&&l&&e(I=>({...I,sankeyValues:[i,o,l]}))},[i,o,l]),t.chartType===sde?P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Source",options:c,onChange:I=>{I===o&&s(""),a(I)},value:i,isSearchEnabled:!0}),P.jsx(Ti,{label:"Target",options:c.filter(I=>I.value!==i),onChange:s,value:o,isSearchEnabled:!0}),P.jsx(Ti,{label:"Value",options:c.filter(I=>I.value!==i&&I.value!==o),onChange:u,value:l,isSearchEnabled:!0})]}):t.chartType===nt.pivot?P.jsxs("div",{className:os.container,children:[P.jsx(Os,{label:"Metrics",name:"metrics",options:f||[],defaultValue:f==null?void 0:f.map(I=>I.value),value:(b=t==null?void 0:t.pivotTableSettings)==null?void 0:b.rows,onChange:v,isSearchEnabled:!0}),P.jsx(Os,{label:"Group by",name:"groupby",options:d||[],defaultValue:d==null?void 0:d.map(I=>I.value),value:(S=t==null?void 0:t.pivotTableSettings)==null?void 0:S.columns,onChange:g,isSearchEnabled:!0})]}):t.chartType===nt.gauge?P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Metric",options:f||[],onChange:I=>e(z=>({...z,gaugeSettings:{...t.gaugeSettings,metric:I}})),value:(_=t==null?void 0:t.gaugeSettings)==null?void 0:_.metric,isSearchEnabled:!0}),P.jsx(Os,{label:"Dimensions",name:"dimensions",options:d||[],defaultValue:d==null?void 0:d.map(I=>I.value),value:(D=t==null?void 0:t.gaugeSettings)==null?void 0:D.dimensions,onChange:y,isSearchEnabled:!0})]}):t.chartType===HW?P.jsx(P.Fragment,{children:!!(t.chartType===HW||WW)&&P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Dimension",options:c,onChange:I=>e(z=>({...z,xAxis:I})),value:t.xAxis,isSearchEnabled:!0}),P.jsx(Os,{label:"Measure",name:"yAxisList",options:c,value:t.yAxisList,onChange:h,isSearchEnabled:!0})]})}):t.chartType===WW?P.jsx(P.Fragment,{children:P.jsxs("div",{className:os.container,children:[P.jsx(Ti,{label:"Dimension",options:c,onChange:I=>e(z=>({...z,xAxis:I})),value:t.xAxis,isSearchEnabled:!0}),P.jsx(Os,{name:"yAxisList",label:"Measure",options:c,value:t.yAxisList,onChange:h,isSearchEnabled:!0})]})}):t.chartType===nt.singleValue?P.jsx("div",{className:os.container,children:P.jsx(Ti,{label:"Measure",options:c,onChange:I=>e(z=>({...z,singleValue:I})),value:t.singleValue,isSearchEnabled:!0})}):P.jsx(P.Fragment,{children:P.jsxs("div",{className:os.container,children:[![nt.gauge,nt.boxplot,nt.table].includes(t.chartType)&&P.jsx(P.Fragment,{children:t.chartType===nt.funnel?P.jsx(Ti,{label:"Step",options:c,onChange:I=>e(z=>({...z,step:I})),value:t.step,isSearchEnabled:!0}):P.jsx(Ti,{label:t.chartType===nt.row?"Y-axis":"X-axis",options:c,onChange:I=>e(z=>({...z,xAxis:I})),value:t.xAxis,isSearchEnabled:!0})}),[nt.funnel,nt.gauge,nt.boxplot].includes(t.chartType)?P.jsx(Ti,{label:"Measure",options:c,onChange:I=>e(z=>({...z,measure:I})),value:t.measure,isSearchEnabled:!0}):P.jsxs(P.Fragment,{children:[P.jsx(Os,{label:t.chartType===nt.row?"X-axis":t.chartType===nt.table?"Measure":"Y-axis",name:"yAxisList",options:c,value:t.yAxisList,onChange:h,isSearchEnabled:!0}),[nt.line,nt.bar,nt.area,nt.combo,nt.scatter,nt.bubble,nt.stack,nt.waterfall].includes(t.chartType)?P.jsxs(P.Fragment,{children:[" ",P.jsx(fn,{type:"checkbox",label:"Switch X-axis",className:os.checkboxTooltipWrapper,checked:(T=t==null?void 0:t.dynamicXAxis)==null?void 0:T.isEnabled,onChange:I=>e(z=>({...z,dynamicXAxis:{isEnabled:I.target.checked,options:[],selectedOption:{value:"",label:""}}}))}),((C=t.dynamicXAxis)==null?void 0:C.isEnabled)&&P.jsx(Os,{label:"X-axis options",options:c,onChange:I=>e(z=>{var j;return{...z,dynamicXAxis:{isEnabled:!!((j=z.dynamicXAxis)!=null&&j.isEnabled),options:(I==null?void 0:I.map(O=>({label:O,value:O})))||[],selectedOption:{value:(I==null?void 0:I[0])||"",label:(I==null?void 0:I[0])||""}},xAxis:I==null?void 0:I[0]}}),value:((R=(k=(E=t.dynamicXAxis)==null?void 0:E.options)==null?void 0:k.filter(I=>{var z;return(z=c.map(j=>j.value))==null?void 0:z.includes(I.value)}))==null?void 0:R.map(I=>I.value))||[],isSearchEnabled:!0})]}):null,[nt.line,nt.bar,nt.timeSeries,nt.stack].includes(t.chartType)?P.jsxs(P.Fragment,{children:[P.jsx(fn,{type:"checkbox",label:"Multi Series",className:os.checkboxTooltipWrapper,checked:t==null?void 0:t.isMultiDimension,onChange:I=>e(z=>({...z,isMultiDimension:I.target.checked,isDynamicSeries:!1}))}),(t==null?void 0:t.isMultiDimension)&&P.jsx(fn,{type:"checkbox",label:"dynamic group",className:os.checkboxTooltipWrapper,checked:t==null?void 0:t.isDynamicSeries,onChange:I=>e(z=>({...z,isDynamicSeries:I.target.checked,seriesField:"ungrouped"}))}),t.isDynamicSeries&&P.jsx(fn,{type:"text",label:"Alias for Ungrouped",placeholder:"add alias for ungrouped",className:os.checkboxTooltipWrapper,onChange:I=>e(z=>({...z,ungroupedAlias:I.target.value})),value:t.ungroupedAlias})]}):null,[nt.line,nt.bar,nt.timeSeries,nt.stack].includes(t.chartType)&&t.isMultiDimension?t.isDynamicSeries?P.jsx(Os,{label:"Series Column",options:d,onChange:I=>e(z=>({...z,seriesField:(I==null?void 0:I[0])||"ungrouped",seriesOptions:(I==null?void 0:I.filter(j=>j!=="ungrouped"))||[]})),value:((L=t.seriesOptions)==null?void 0:L.filter(I=>{var z;return(z=d.map(j=>j.value))==null?void 0:z.includes(I)}))||[],isSearchEnabled:!0}):P.jsx(Ti,{label:"Series Column",options:[{value:"ungrouped",label:"ungrouped"},...d],onChange:I=>e(z=>({...z,seriesField:I})),value:t.seriesField,isSearchEnabled:!0}):null]})]})})},Lde=[{name:"Line",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M3 22V8h4v14H3m7 0V2h4v20h-4m7 0v-8h4v8h-4Z"})})},{name:"Combo",icon:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M27 28V16h-8v12h-4V12H7v16H4V2H2v26a2 2 0 0 0 2 2h26v-2Zm-14 0H9V14h4Zm12 0h-4V18h4Z"}),P.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:n=>P.jsxs("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M4 21h17v-2H5V3H3v17a1 1 0 0 0 1 1z"}),P.jsx("circle",{cx:10,cy:8,r:2,fill:"currentColor"}),P.jsx("circle",{cx:18,cy:12,r:2,fill:"currentColor"}),P.jsx("circle",{cx:11.5,cy:13.5,r:1.5,fill:"currentColor"}),P.jsx("circle",{cx:16.5,cy:6.5,r:1.5,fill:"currentColor"})]})},{name:"Row",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M4 22H2V2h2v20Zm11-1H5v-3h10v3Zm3-5H5v-3h13v3Zm3-5H5V8h16v3Zm-8-5H5V3h8v3Z"})})},{name:"Area",icon:n=>P.jsx("svg",{viewBox:"0 0 1024 1024",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M28 28V18h-2v10h-4V4h-2v24H10V14H8v14H4V2H2v26a2.002 2.002 0 0 0 2 2h26v-2Z"}),P.jsx("path",{fill:"currentColor",d:"M14 4h2v14h-2z"})]})},{name:"Funnel",icon:n=>P.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"}),P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M3 4h1v9h3V7h5v4h4v4h4v6H3V4m13 12v4h3v-4h-3m-4-4v8h3v-8h-3M8 8v12h3V8H8m-4 6v6h3v-6H4Z"})})},{name:"Gauge",icon:n=>P.jsx("svg",{viewBox:"0 0 20 20",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 16 16",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsxs("svg",{viewBox:"0 0 32 32",width:"1.2em",height:"1.2em",...n,children:[P.jsx("path",{fill:"currentColor",d:"M22 6V4H12v2h4v2h-4v12h4v2h-4v2h10v-2h-4v-2h4V8h-4V6Zm-8 12v-3h6v3Zm6-5h-6v-3h6Z"}),P.jsx("path",{fill:"currentColor",d:"M30 30H4a2 2 0 0 1-2-2V2h2v26h26Z"})]})},{name:"Table",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M8 16h5v-5H8v5Zm0-7h12V4H8v5Zm7 7h5v-5h-5v5Zm-7 2q-.825 0-1.413-.588T6 16V4q0-.825.588-1.413T8 2h12q.825 0 1.413.588T22 4v12q0 .825-.588 1.413T20 18H8Zm-4 4q-.825 0-1.413-.588T2 20V6h2v14h14v2H4Z"})})},{name:"Time series",icon:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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:n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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"})})}],kde=({chartType:n,onChartChange:t,isEnableTimeSeries:e,isEnablePivotTable:r,hasNumberKeys:i,isEnableGauge:a,enableCharts:o})=>P.jsx("div",{className:os.chartOptions,children:Lde.map(s=>P.jsxs("div",{className:os.chartOption,children:[P.jsx(It,{type:"button",variant:"custom",className:n===s.name.toLowerCase()?os.chartOptionBtnSelected:os.chartOptionBtn,onClick:()=>{t(s.name.toLowerCase())},isDisabled:s.name.toLowerCase()===nt.timeSeries&&!e||s.name.toLowerCase()===nt.pivot&&!r||!o.includes(s.name.toLowerCase()),children:P.jsx(s.icon,{style:{color:s.name.toLowerCase()===nt.timeSeries&&!e||s.name.toLowerCase()===nt.pivot&&!r||!o.includes(s.name.toLowerCase())?"grey":"blue",width:"20px",height:"20px"}})},s.name),P.jsx(wt,{variant:"p",styleClass:"custom",className:os.chartOptionText,children:s.name})]},s.name))}),Rde=({datatype:n="unknown",className:t})=>pde.includes(n.toLowerCase())?P.jsx(pn,{name:"number-icon",className:t}):vde.includes(n.toLowerCase())||n.toLowerCase().includes("char")?P.jsx(pn,{name:"text-icon",className:t}):gde.includes(n.toLowerCase())?P.jsx(pn,{name:"array-icon",className:t}):JW.includes(n.toLowerCase())?P.jsx(pn,{name:"date-icon",className:t}):mde.includes(n.toLowerCase())?P.jsx(pn,{name:"boolean-icon",className:t}):P.jsx(pn,{name:"unknown-icon"}),tU={container:"_container_1izll_1",windowIcon:"_windowIcon_1izll_7"},Ode=n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.5,children:[P.jsx("path",{d:"M15 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10"}),P.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"})]})}),Pde=()=>P.jsxs("div",{role:"alert",className:tU.container,children:[P.jsx(Ode,{className:tU.windowIcon}),P.jsx(wt,{variant:"p",styleClass:"font-20",children:"Something went wrong!"}),P.jsx(It,{variant:"primary",size:"large",type:"button",onClick:()=>location.reload(),children:"Try again"})]}),xg={container:"_container_dv0n1_1",field:"_field_dv0n1_9",fieldLabel:"_fieldLabel_dv0n1_17",save:"_save_dv0n1_25",cancel:"_cancel_dv0n1_33",error:"_error_dv0n1_41"},FT={container:"_container_1rie6_1",label:"_label_1rie6_9",textarea:"_textarea_1rie6_17",resizable:"_resizable_1rie6_25"},$de=({id:n,label:t,placeholder:e,rows:r,cols:i,resizable:a=!0,register:o,error:s,defaultValue:l,value:u,onFocus:c,onBlur:f,className:d})=>P.jsxs("div",{className:`${FT.container} ${d}`,children:[P.jsx("label",{htmlFor:n,className:FT.label,children:t}),P.jsx("textarea",{id:n,name:n,rows:r,cols:i,placeholder:e,className:Gi(FT.textarea,`${a?null:FT.resizable}`),defaultValue:l,...o,value:u,onFocus:c,onBlur:f}),s&&P.jsx(jT,{message:s.message})]}),zde=({name:n,styles:t,placeholder:e,enabled:r})=>P.jsxs("label",{htmlFor:n,className:`${t.button}`,children:[Array.isArray(e)&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.label} ${r?t.labelInactive:t.labelActive}`,children:e[0]}),P.jsx("span",{className:` ${t.switch} ${r?t.enabled:t.notenabled}`}),P.jsx("span",{className:` ${t.label} ${r?t.labelActive:t.labelInactive}`,children:e[1]})]}),typeof e=="string"&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.switch} ${r?t.enabled:t.notenabled}`}),P.jsx("span",{className:` ${t.label} ${r?t.labelActive:t.labelInactive}`,children:e})]}),!Array.isArray(e)&&typeof e!="string"&&P.jsx("span",{className:` ${t.switch} ${r?t.enabled:t.notenabled}`})]}),BT={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"},jde=({name:n,styles:t,placeholder:e,enabled:r})=>P.jsxs("label",{htmlFor:n,className:`${t.button} ${t.toggleWidth}`,children:[Array.isArray(e)&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.label} ${r&&t.toggleInactive}`,children:e[0]}),P.jsx("span",{className:` ${t.switch} ${t.toggle} ${r?t.enabled:t.notenabled}
|
|
276
276
|
`}),P.jsx("span",{className:` ${t.label} ${r||t.toggleInactive}`,children:e[1]})]}),typeof e=="string"&&P.jsxs(P.Fragment,{children:[P.jsx("span",{className:` ${t.switch} ${t.toggle} ${r?t.enabled:t.notenabled}
|
|
277
277
|
`}),P.jsx("span",{className:` ${t.label} ${r||t.labelInactive}`,children:e})]}),!Array.isArray(e)&&typeof e!="string"&&P.jsx("span",{className:` ${t.switch} ${t.toggle} ${r?t.enabled:t.notenabled}
|
|
278
278
|
`})]}),Fde=({enabled:n,variant:t="switch",onChange:e,label:r,className:i="",placeholder:a,labelClassName:o,defaultEnabled:s,name:l=`toggle-${Date.now()}`})=>P.jsxs("div",{className:`${BT.group} ${i}`,children:[r?P.jsx(wt,{styleClass:"font-14",variant:"p",className:o,children:r}):null,P.jsx("input",{type:"checkbox",id:l,checked:s,onChange:({target:u})=>e==null?void 0:e(u.checked),className:BT.checkbox}),t==="toggle"&&P.jsx(jde,{name:l,styles:BT,placeholder:a,enabled:n}),t==="switch"&&P.jsx(zde,{name:l,styles:BT,placeholder:a,enabled:n})]}),g0={modal:"_modal_1myn6_1",popup:"_popup_1myn6_9",header:"_header_1myn6_17",headerTitle:"_headerTitle_1myn6_25",content:"_content_1myn6_33",footer:"_footer_1myn6_41"},VT=({children:n})=>{const[t,e]=oe.useState();return oe.useEffect(()=>{const r=document.querySelector("#dbn-portal")||document.createElement("div");if(r.setAttribute("id","dbn-portal"),document.body.querySelector("#dbn-portal")||document.body.appendChild(r),document.querySelector("dbn-dashboard")||document.querySelector("dbn-metric")){const i=document.querySelector("#dbn-styles"),a=r.shadowRoot||r.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(r)},[]),t?oT.createPortal(n,t):null},Yd=({children:n,isOpen:t,onClose:e,headerTitle:r,customHeader:i,icon:a})=>P.jsx(VT,{children:t?P.jsx("div",{className:g0.modal,onClick:e,children:P.jsxs("div",{className:g0.popup,onClick:o=>{o.stopPropagation()},children:[P.jsx("section",{className:g0.header,children:i||P.jsxs(P.Fragment,{children:[P.jsxs("span",{className:g0.headerTitle,children:[a,r]}),P.jsx(It,{variant:"custom",type:"button",onClick:e,children:P.jsx(pn,{name:"close-icon"})})]})}),P.jsx("section",{className:g0.content,children:n})]})}):null}),o1=({children:n,className:t})=>P.jsx("section",{className:`${g0.footer} ${t}`,children:n}),nU=({onSubmit:n,defaultValues:t,onCancel:e,isEmbedded:r=!0,dashboardIds:i,onDashboardChange:a,error:o,options:s})=>{const{register:l,handleSubmit:u,setValue:c}=mT(),[f,d]=oe.useState((t==null?void 0:t.isLive)??!1),h=u(v=>{n({...v,isLive:f})});return oe.useEffect(()=>{t&&(c("name",t.name),c("description",t.description),c("metricId",t.metricId))},[t]),P.jsxs("form",{onSubmit:h,children:[P.jsxs("div",{className:xg.container,children:[P.jsx(Os,{label:"Dashboards",options:s,name:"dashboards",value:i,onChange:a}),P.jsx(fn,{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}),P.jsx(fn,{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}),P.jsx($de,{className:xg.field,id:"desc",placeholder:"What is the name of metric?",label:"Description",rows:5,register:l("description"),defaultValue:t==null?void 0:t.description}),!r&&P.jsx(Fde,{className:xg.field,labelClassName:xg.fieldLabel,enabled:f,onChange:d,label:"Publish Type",placeholder:f?"LIVE MODE":"TEST MODE",defaultEnabled:t==null?void 0:t.isLive})]}),!!o&&P.jsx(wt,{variant:"p",styleClass:"font-14",className:xg.error,children:o}),P.jsxs(o1,{children:[P.jsx(It,{type:"reset",variant:"secondary",className:xg.cancel,onClick:e,size:"default",children:"Cancel"}),P.jsx(It,{type:"submit",variant:"primary",size:"small",className:xg.save,isDisabled:!s.length||!i.length,children:"Save"})]})]})},_r={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"},s1=n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"m12 15.4l-6-6L7.4 8l4.6 4.6L16.6 8L18 9.4l-6 6Z"})}),QR=n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.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.4l4.25 4.25ZM5 21q-.825 0-1.413-.588T3 19V5q0-.825.588-1.413T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.588 1.413T19 21H5Z"})}),l1=n=>P.jsx("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...n,children:P.jsx("path",{fill:"currentColor",d:"M5 21q-.825 0-1.413-.588T3 19V5q0-.825.588-1.413T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.588 1.413T19 21H5Zm0-2h14V5H5v14Z"})}),ra=({label:n,labelVariant:t="floating",selectedOption:e,onChange:r,className:i,buttonClass:a,options:o,isDisabled:s,children:l,icon:u,isSearchEnabled:c,closeControl:f,dropdownAbove:d})=>{const[h,v]=oe.useState(!1),g=oe.useRef(null),[y,b]=oe.useState(""),[S,_]=oe.useState(20),D=e.label||e.value;t1({wrapRef:g,onOutsideClick:()=>v(!1)}),oe.useEffect(()=>{f!=null&&f.close&&v(!1)},[f==null?void 0:f.close]);const T=oe.useMemo(()=>y?o.filter(C=>C.label.toLowerCase().includes(y)).slice(0,S):o==null?void 0:o.slice(0,S),[y,o,S]);return P.jsxs("div",{className:Gi(_r.container,i),ref:g,children:[n&&(t==="floating"||t==="static")?P.jsx(wt,{variant:"span",styleClass:t==="floating"?"custom":"font-14",className:`${_r.label} ${t==="floating"?_r.floatingLabel:_r.staticLabel} ${u&&t==="floating"&&"left-8"}`,children:n}):n&&t==="floating-2"&&D?P.jsx(wt,{variant:"span",styleClass:"custom",className:`${_r.label} ${_r.floatingLabel2}`,children:n}):null,P.jsxs(It,{type:"button",variant:"custom",isDisabled:s,className:Gi(_r.wrapper,a),onClick:()=>v(!h),children:[u&&t==="floating-2"&&!D?P.jsx(wt,{variant:"span",styleClass:"custom",className:"mr-1",children:u}):null,u&&(t==="floating"||t==="static")?P.jsx(wt,{variant:"span",styleClass:"custom",className:"mr-1",children:u}):null,P.jsx(wt,{variant:"p",styleClass:"font-14",className:` grow text-left ${t==="floating"?_r.floatingText:_r.staticText}`,children:P.jsxs(wt,{variant:"span",className:` ${_r.InnerText} ${t==="floating-2"&&!D&&_r.floating2}`,styleClass:"custom",children:[t==="floating"||t==="static"?D||"Select an option":null,t==="floating-2"?D||n||"Select option":null]})}),P.jsx("div",{children:P.jsx(s1,{})})]}),h&&!s&&P.jsxs("div",{className:`${d?_r.aboveList:_r.dropdown}`,children:[c&&P.jsx(CT,{className:_r.search,setSearchKeyword:b}),P.jsxs("div",{className:_r.options,children:[!(T!=null&&T.length)&&P.jsx("div",{className:_r.noOptions,children:"Not Available"}),T==null?void 0:T.map(C=>{const E=C.value===e.value;return P.jsx(It,{type:"button",variant:"custom",className:E?_r.checkedOption:_r.option,onClick:()=>{var k;r(C),((k=C.labelType)==null?void 0:k.toLowerCase())!=="custom"&&v(!1)},children:C.label},C.key||C.value)}),S<=(o==null?void 0:o.length)&&P.jsxs(It,{variant:"secondary",type:"button",onClick:()=>_(C=>C+20),className:_r.loadMore,children:["Load More"," ",P.jsx(pn,{name:"double-arrow-left-icon",className:_r.loadMoreIcon})]})]}),l]})]})},m0=Ne.memo(({label:n,labelVariant:t="floating",selectedOptions:e,onChange:r,className:i,options:a,isDisabled:o,children:s,isSearchEnabled:l,icon:u})=>{const[c,f]=oe.useState(!1),d=oe.useRef(null),[h,v]=oe.useState(""),[g,y]=oe.useState(20),b=oe.useMemo(()=>h?a.filter(_=>_.label.toLowerCase().includes(h)).slice(0,g):a==null?void 0:a.slice(0,g),[h,a,g]);t1({wrapRef:d,onOutsideClick:()=>f(!1)});const S=(_,D)=>{switch(_){case 0:return"Select options from the list";case 1:return`${D[0].value.toString().length>35?`${D[0].value.toString().substring(0,35)}...`:D[0].value}`;case 2:default:return`${D[0].value.toString().length>20?`${D[0].value.toString().substring(0,20)}...`:D[0].value}, ${D[1].value.toString().length>10?D[1].value.toString().substring(0,10):D[1].value}...`}};return P.jsxs("div",{className:Gi(_r.container,i),ref:d,children:[n&&(t==="floating"||t==="static")?P.jsx(wt,{variant:"span",styleClass:t==="floating"?"custom":"font-14",className:`${_r.label} ${t==="floating"?_r.floatingLabel:_r.staticLabel} ${u&&t==="floating"&&"left-8"}`,children:n}):n&&t==="floating-2"&&e.length?P.jsx(wt,{variant:"span",styleClass:"custom",className:`${_r.label} ${_r.floatingLabel2}`,children:n}):null,P.jsxs(It,{type:"button",variant:"custom",isDisabled:o,className:_r.wrapper,onClick:()=>f(!c),children:[u&&t==="floating-2"&&!e.length?P.jsx(wt,{variant:"span",styleClass:"custom",className:"mr-1",children:u}):null,u&&(t==="floating"||t==="static")?P.jsx(wt,{variant:"span",styleClass:"custom",className:"mr-1",children:u}):null,P.jsxs(wt,{variant:"p",styleClass:"font-14",className:` grow text-left ${t==="floating"?_r.floatingText:_r.staticText} ${t==="floating-2"&&!e.length&&_r.floating2}`,children:[t==="floating"||t==="static"?S(e.length,e):null,t==="floating-2"?e.length?S(e.length,e):n||"Select option":null]}),P.jsx(s1,{})]}),c&&!o&&P.jsxs("div",{className:_r.dropdown,children:[l&&P.jsx(CT,{className:_r.search,setSearchKeyword:v}),P.jsxs("div",{className:_r.options,children:[!(b!=null&&b.length)&&P.jsx("div",{className:_r.noOptions,children:"Not Available"}),b==null?void 0:b.map(_=>{const D=!!e.find(T=>T.value===_.value);return P.jsxs(It,{type:"button",variant:"custom",className:D?_r.checkedOption:_r.option,onClick:()=>{const T=D?e.filter(C=>C.value!==_.value):[...e.filter(C=>a.find(E=>C.value===E.value)),_];r(T)},children:[P.jsx(wt,{variant:"span",styleClass:"custom",children:D?P.jsx(QR,{}):P.jsx(l1,{})}),_.label]},_.key||_.value)}),g<=(a==null?void 0:a.length)&&P.jsxs(It,{variant:"secondary",type:"button",onClick:()=>y(_=>_+20),className:_r.loadMore,children:["Load More",P.jsx(pn,{name:"double-arrow-left-icon",className:_r.loadMoreIcon})]})]}),s]})]})}),rU=({filter:n,onChange:t,selectedOption:e,autoSelected:r=!0,workspaceId:i,filterClause:a,...o})=>{const[s,l]=oe.useState([]),{fetchColumnValues:u}=GR();return oe.useEffect(()=>{u({wId:i,tableName:n.tableName,columnName:n.columnName,filter:a!=null&&a.columnName&&(a!=null&&a.value)?a:void 0},{onSuccess:c=>{if(!(c!=null&&c.data)||!Array.isArray(c.data))return;const f=[];c.data.forEach(d=>{d&&f.push({label:d.label,value:d.value})}),l(f)}})},[n.tableName,n.columnName,a]),oe.useEffect(()=>{s.length&&s[0]&&r&&t(s[0])},[s.length,s[0],r,n.columnName]),P.jsx(ra,{onChange:t,selectedOption:n.defaultValue?{label:n.defaultValue,value:n.defaultValue}:e,isDisabled:!!n.defaultValue,options:s,label:n.columnName,...o})},ZR=Ne.memo(({filter:n,autoSelected:t,onChange:e,selectedOptions:r,label:i,workspaceId:a,filterClause:o,...s})=>{const[l,u]=oe.useState([]),{fetchColumnValues:c}=GR();return oe.useEffect(()=>{c({wId:a,tableName:n.tableName,columnName:n.columnName,filter:o!=null&&o.columnName&&(o!=null&&o.value)?o:void 0},{onSuccess:f=>{if(!(f!=null&&f.data)||!Array.isArray(f.data))return;const d=[];f.data.forEach(h=>{h&&d.push({label:h.label,value:h.value})}),u(d)}})},[n.tableName,n.columnName,o]),oe.useEffect(()=>{l.length&&l[0]&&t&&e([l[0]])},[l.length,l[0],t,n.columnName]),P.jsx(m0,{onChange:e,selectedOptions:n.defaultValue?[{label:n.defaultValue,value:n.defaultValue}]:r,isDisabled:!!n.defaultValue,options:l,label:i||n.columnName,...s})}),Bde={fullscreen:"_fullscreen_1wo1t_1"};var XR=function(n,t){return XR=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},XR(n,t)};function iU(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");XR(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var qR=function(){return qR=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},qR.apply(this,arguments)};/*! *****************************************************************************
|