@databrainhq/plugin 0.17.9-beta.55 → 0.17.9-beta.56
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 +153 -153
- package/dist/webcomponents.umd.js +1 -1
- package/package.json +1 -1
|
@@ -5054,4 +5054,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
5054
5054
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Yt(e,t){if(e){if(typeof e==`string`)return Xt(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xt(e,t):void 0}}function Xt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Zt(e,t){if(typeof e==`string`)return _(e,t);var n=e.expr,r=e.offset,i=e.suffix,a=r&&r.map((function(e){return[`[`,e.name,`${e.name?`(`:``}`,b(e.value),`${e.name?`)`:``}`,`]`].filter(y).join(``)})).join(``);return[Bt(n),a,i].filter(y).join(``)}function Qt(e){if(!e||e.length===0)return``;var t,n=[],r=function(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Yt(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
5055
5055
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}(e);try{for(r.s();!(t=r.n()).done;){var i=t.value,a=i.brackets?`[${Bt(i.index)}]`:`${i.notation}${Bt(i.index)}`;i.property&&(a=`${a}.${b(i.property)}`),n.push(a)}}catch(e){r.e(e)}finally{r.f()}return n.join(``)}function $t(e){var t=e.array_index,n=e.as,r=e.column,i=e.collate,a=e.db,o=e.isDual,l=e.notations,u=l===void 0?[]:l,d=e.options,f=e.schema,p=e.table,m=e.parentheses,h=e.suffix,g=e.order_by,b=e.subFields,x=b===void 0?[]:b,S=r===`*`?`*`:Zt(r,o),C=[a,f,p].filter(y).map((function(e){return`${typeof e==`string`?_(e):Bt(e)}`})),w=C[0];if(w){for(var T=1;T<C.length;++T)w=`${w}${u[T]||`.`}${C[T]}`;S=`${w}${u[T]||`.`}${S}`}var ee=[S=[`${S}${Qt(t)}`].concat(Jt(x)).join(`.`),Ut(i),Bt(d),s(`AS`,Bt,n)];ee.push(typeof h==`string`?v(h):Bt(h)),ee.push(v(g));var te=ee.filter(y).join(` `);return m?`(${te})`:te}function en(e){if(e){var t=e.schema,n=e.dataType,r=e.length,i=e.suffix,a=e.scale,o=e.expr,s=w({schema:t,dataType:n,length:r,suffix:i,scale:a,parentheses:r!=null});if(o&&(s+=Bt(o)),e.array){var l=yt(e);s+=[/^\[.*\]$/.test(l)?``:` `,l].join(``)}return s}}function tn(e){var t=[];if(!e)return t;var n=e.definition,r=e.keyword,i=e.match,a=e.table,o=e.on_action;return t.push(v(r)),t.push(Ze(a)),t.push(n&&`(${n.map((function(e){return Bt(e)})).join(`, `)})`),t.push(v(i)),o.map((function(e){return t.push(v(e.type),Bt(e.value))})),t.filter(y)}function nn(e){var t=[],n=e.nullable,r=e.character_set,i=e.check,a=e.comment,o=e.constraint,l=e.collate,u=e.storage,d=e.using,f=e.default_val,m=e.generated,h=e.auto_increment,g=e.unique,_=e.primary_key,S=e.column_format,C=e.reference_definition,w=e.generated_by_default,T=[v(n&&n.action),v(n&&n.value)].filter(y).join(` `);if(m||t.push(T),f){var te=f.type,ne=f.value;t.push(te.toUpperCase(),Bt(ne))}var re=p().database;return o&&t.push(v(o.keyword),b(o.constraint)),t.push(mt(i)),t.push(function(e){if(e)return[v(e.value),`(${Bt(e.expr)})`,v(e.storage_type)].filter(y).join(` `)}(m)),m&&t.push(T),t.push(ie(h),v(_),v(g),b(w),ee(a)),t.push.apply(t,Jt(x(r))),re.toLowerCase()!==`sqlite`&&t.push(Bt(l)),t.push.apply(t,Jt(x(S))),t.push.apply(t,Jt(x(u))),t.push.apply(t,Jt(tn(C))),t.push(s(`USING`,Bt,d)),t.filter(y).join(` `)}function rn(e){var t=e.order_by,n=e.column,r=e.collate,i=e.nulls,a=e.opclass,o=typeof n==`string`?{type:`column_ref`,table:e.table,column:n}:Kt(Kt({},e),{},{order_by:null});return o.collate=null,[Bt(o),Bt(r),a,v(t),v(i)].filter(y).join(` `)}function an(e){var t=[],n=$t(e.column),r=en(e.definition);return t.push(n),t.push(r),t.push(nn(e)),t.filter(y).join(` `)}function on(e){return e?Wt(e)===`object`?[`AS`,Bt(e)].join(` `):[`AS`,/^(`?)[a-z_][0-9a-z_]*(`?)$/i.test(e)?_(e):g(e)].join(` `):``}function sn(e,t){var n=e.expr,r=e.type;if(r===`cast`)return bt(e);t&&(n.isDual=t);var i=Bt(n),a=e.expr_list;if(a){var o=[i],s=a.map((function(e){return sn(e,t)})).join(`, `);return o.push([v(r),r&&`(`,s,r&&`)`].filter(y).join(``)),o.filter(y).join(` `)}return n.parentheses&&Reflect.has(n,`array_index`)&&n.type!==`cast`&&(i=`(${i})`),n.array_index&&n.type!==`column_ref`&&n.type!==`function`&&(i=`${i}${Qt(n.array_index)}`),[i,on(e.as)].filter(y).join(` `)}function cn(e){var t=Array.isArray(e)&&e[0];return!(!t||t.type!==`dual`)}function ln(e,t){if(!e||e===`*`)return e;var n=cn(t);return e.map((function(e){return sn(e,n)})).join(`, `)}Rt.var=zt,Rt.expr_list=function(e){var t=Vt(e.value),n=e.parentheses,r=e.separator;if(!n&&!r)return t;var i=r||`, `,a=t.join(i);return n?`(${a})`:a},Rt.select=function(e){var t=Lt(e._next)===`object`?Pe(e):xe(e);return e.parentheses?`(${t})`:t},Rt.unary_expr=function(e){var t=e.operator,n=e.parentheses,r=e.expr,i=`${t}${t===`-`||t===`+`||t===`~`||t===`!`?``:` `}${Bt(r)}`;return n?`(${i})`:i},Rt.map_object=function(e){var t=e.keyword,n=e.expr.map((function(e){return[b(e.key),b(e.value)].join(`, `)})).join(`, `);return[v(t),`[${n}]`].join(``)};var un=n(1),dn=n(2),fn=n(3),pn=n(4),mn=n(5),hn=n(6),gn=n(7),_n=n(8),vn=n(9),yn=n(10),bn=n(11),xn=n(12),Sn=n(13),Cn=n(14),wn={athena:un.parse,bigquery:dn.parse,db2:fn.parse,flinksql:pn.parse,hive:mn.parse,mysql:hn.parse,mariadb:gn.parse,noql:_n.parse,postgresql:vn.parse,redshift:yn.parse,snowflake:Sn.parse,sqlite:bn.parse,transactsql:xn.parse,trino:Cn.parse};function Tn(e){return(Tn=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e})(e)}function En(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if(typeof e==`string`)return Dn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Dn(e,t):void 0}}(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
5056
5056
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function Dn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function On(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,kn(r.key),r)}}function kn(e){var t=function(e,t){if(Tn(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Tn(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return Tn(t)==`symbol`?t:t+``}var An=function(){return e=function e(){(function(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)})(this,e)},(t=[{key:`astify`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:a,n=this.parse(e,t);return n&&n.ast}},{key:`sqlify`,value:function(e){return m(arguments.length>1&&arguments[1]!==void 0?arguments[1]:a),nt(e)}},{key:`exprToSQL`,value:function(e){return m(arguments.length>1&&arguments[1]!==void 0?arguments[1]:a),Bt(e)}},{key:`columnsToSQL`,value:function(e,t){if(m(arguments.length>2&&arguments[2]!==void 0?arguments[2]:a),!e||e===`*`)return[];var n=cn(t);return e.map((function(e){return sn(e,n)}))}},{key:`parse`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:a,n=t.database,r=n===void 0?`mysql`:n;m(t);var i=r.toLowerCase();if(wn[i])return wn[i](!1===t.trimQuery?e:e.trim(),t.parseOptions||a.parseOptions);throw Error(`${r} is not supported currently`)}},{key:`whiteListCheck`,value:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:a;if(t&&t.length!==0){var r=n.type,i=r===void 0?`table`:r;if(!this[`${i}List`]||typeof this[`${i}List`]!=`function`)throw Error(`${i} is not valid check mode`);var o,s=this[`${i}List`].bind(this)(e,n),l=!0,u=``,d=En(s);try{for(d.s();!(o=d.n()).done;){var f,p=o.value,m=!1,h=En(t);try{for(h.s();!(f=h.n()).done;){var g=f.value;if(RegExp(`^${g}\$`,`i`).test(p)){m=!0;break}}}catch(e){h.e(e)}finally{h.f()}if(!m){u=p,l=!1;break}}}catch(e){d.e(e)}finally{d.f()}if(!l)throw Error(`authority = '${u}' is required in ${i} whiteList to execute SQL = '${e}'`)}}},{key:`tableList`,value:function(e,t){var n=this.parse(e,t);return n&&n.tableList}},{key:`columnList`,value:function(e,t){var n=this.parse(e,t);return n&&n.columnList}}])&&On(e.prototype,t),n&&On(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}();function jn(e){return(jn=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e})(e)}(typeof self>`u`?`undefined`:jn(self))===`object`&&self&&(self.NodeSQLParser={Parser:An,util:r}),typeof global>`u`&&(typeof window>`u`?`undefined`:jn(window))===`object`&&window&&(window.global=window),(typeof global>`u`?`undefined`:jn(global))===`object`&&global&&global.window&&(global.window.NodeSQLParser={Parser:An,util:r})}]))})),QCr,$Cr,ewr,twr,nwr,rwr,iwr=h((()=>{QCr=ZCr(),ewr=()=>($Cr??=new QCr.Parser,$Cr),twr=(e,t={})=>{let n=e?.toLowerCase();return n&&[`athena`,`mssql`,`microsoft fabric`,`postgres`,`redshift`].includes(n)||t.forceTransactSqlForTrino&&n===`trino`?`transactsql`:e},nwr=(e,t,n)=>ewr().astify(e,{database:twr(t,n)}),rwr=e=>Array.isArray(e)?e[0]:e})),awr,owr=h((()=>{iwr(),awr=(e,t)=>{try{return(rwr(nwr(e,t))?.orderby||[])?.map(e=>({column:typeof e?.expr?.column==`string`?e?.expr?.column:e?.expr?.column?.expr?.value||``,type:e?.type}))}catch{return[]}}})),swr,cwr,lwr,uwr,dwr,fwr=h((()=>{YCr(),Fi(),aQt(),oq(),YK(),my(),xV(),owr(),Uy(),Cb(),swr=e=>({questionType:e.questionType,orderBy:e.orderBy,isTimeSeries:e.isTimeSeries,isCountryDimension:e.isCountryDimension,isDifferentMeasureScales:e.isDifferentMeasureScales,isProgressiveDimension:e.isProgressiveDimension,dimensions:e.dimensions,measures:e.measures,semanticTypes:Tfe(e.semanticColumns),semanticTypeConfigs:Efe(e.semanticColumns)}),cwr=e=>{if(!Vy()||!e.rows.length)return{chartType:OSe({dataLength:e.dataLength,dimensionCount:e.dimensions?.length,measureCount:e.measures?.length,isCountryDimension:e.isCountryDimension,isDifferentMeasureScales:e.isDifferentMeasureScales,isNullValue:e.isNullValue,isProgressiveDimension:e.isProgressiveDimension,isTimeSeries:e.isTimeSeries,orderBy:e.orderBy,questionType:e.questionType})};let t=Sb(e.rows,[],swr(e),{surface:`chat`});return{chartType:t.recommendation.chartType,defaults:t}},lwr=[$.singleValue,$.treeMap,$.sankey,$.horizontalStackTable,$.gauge,$.table],uwr=(e,t,n)=>{if(!t)return e;let{roles:r}=t.recommendation,i=t.settings?.sort,a=e,o=e=>!!e&&n.includes(e);if(!lwr.includes(a.chartType)){o(r.xAxis)&&a.xAxis!==r.xAxis&&(a={...a,xAxis:r.xAxis});let e=(r.yAxisList??[]).filter(o),t=Array.isArray(a.yAxisList)?a.yAxisList:[];e.length>0&&(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&(a={...a,yAxisList:e})}i&&(a={...a,customSettings:{...a.customSettings||{},sort:{by:i.by,direction:i.direction}}});let s=t.settings?.numberFormat;return s&&(a={...a,customSettings:{...a.customSettings||{},numberFormat:s}}),a},dwr=({dashboardId:e,dashboardIds:t,themeChartColors:r,token:i,workspaceId:a,companyId:o,clientId:s,embedDataAppId:l,datasourceId:u,externalDashboardId:d,onServerEvent:f,refetchDashboardData:p,saveDashLayout:m})=>{let{mutate:h}=sKt(),{mutate:g}=oKt(),_=(0,n.useRef)(null),v=()=>{_.current?.abort();let e=new AbortController;return _.current=e,e.signal},y=(0,n.useCallback)(()=>{_.current?.abort(),_.current=null,ae(!1),x(e=>({...e,isDisableButton:!1,isLoading:!1,error:``})),de(e=>({...e,isLoading:!1}))},[]);(0,n.useEffect)(()=>()=>{_.current?.abort(),_.current=null},[]);let[b,x]=(0,n.useState)(yce),[S,C]=(0,n.useState)({data:[],error:``,isLoading:!1,currentValue:``}),[w,T]=(0,n.useState)(!1),[ee,te]=(0,n.useState)(),[ne,re]=(0,n.useState)(``),[ie,ae]=(0,n.useState)(!1),[oe,se]=(0,n.useState)([]),[ce,le]=(0,n.useState)(!1),[ue,de]=(0,n.useState)({isOpen:!1,report:``,isLoading:!1}),[fe,pe]=(0,n.useState)({isOpenAppearance:!1,isOpenTypePanel:!1,chartIndex:-1}),[me,he]=(0,n.useState)([]),ge=(0,n.useMemo)(()=>b?.chats?.find(e=>e.timestamp===fe?.chartIndex),[fe?.chartIndex,b?.chats]),_e=(0,n.useMemo)(()=>[ey,ty].includes(ee?.name?.toLowerCase()||``),[ee]),ve=(0,n.useMemo)(()=>cxe(ee?.name||``),[ee]),{createExternalMetric:ye,error:be,isLoading:xe,updateExternalMetric:Se,clientSubsetData:Ce}=aq({onServerEvent:f,onSuccess:async e=>{if(T(!1),e)try{await m?.(e,ge?.chartSettings?.chartType)}catch(e){console.error(`Error saving layout:`,e)}p()},companyId:o,clientId:s,query:Xc(ge?.responseQuery||``,o||``)||``,companyIntegrationId:ee?.id||``,integrationName:ee?.name||``,metricQuery:void 0,outputColumns:void 0,selectedColumns:void 0,timeGrain:void 0,dashboardIds:t?.length?t:[e||``],groupBy:void 0,isEnableGroupBy:!1,selectedGroupBy:[],rlsFilters:[],datasetMetricSettings:{selectedTable:{label:``,value:``},selectedJoins:[],configuration:{aggregates:[],dimensions:[],filters:[],isEnableDrill:!1,orders:[],table:{alias:``,id:``,joins:[],name:``,schema:``,type:`default`},forecast:void 0,globalFilters:void 0,groupByColumnList:ge?.groupbyColumnList,isAllClient:!1,isApplyGlobalFilter:!1,isApplyMetricFilter:!1,rlsConditions:[],rlsValues:{},limit:`5000`},chatQuestion:ge?.question,timestamp:ge?.timestamp,queryTimestamp:ge?.queryTimestamp,columns:ge?.columns,summary:ge?.summary,clientColumn:{value:``,label:``},comparisonLag:0,customColumnList:[],isIncludeTime:!1,isNewDataset:!0,timeColumn:{label:``,value:``},timeGrainValue:``,timeGrainVal:{label:``,value:``},forecast:void 0,createdNewColumnOptions:[],selectedCustomColumns:[],selectedManageColumns:[],selectedNewManageColumns:[],createdFilters:[],createdSorts:[],comparisonLagSettings:Dse,selectedCustomGroups:[],selectedGroupColumns:[],metrics:[],selectedDimensions:[],newDatasetSettings:{configuration:{aggregates:[],dimensions:[],filters:[],isEnableDrill:!1,orders:[],table:{alias:``,id:``,joins:[],name:``,schema:``,type:`default`},forecast:void 0,globalFilters:void 0,groupByColumnList:ge?.groupbyColumnList,isAllClient:!1,isApplyGlobalFilter:!1,isApplyMetricFilter:!1,rlsConditions:[],rlsValues:{},limit:`5000`},metrics:[],selectedDimensions:[],selectedGroupBy:[],selectedDims:[],selectedMetrics:[],selectedAutoCompleteColumns:[],selectedMainTable:void 0,type:`NEW`,sqlColumnList:[],isSqlMode:!1,subQuery:``,isPythonMode:!1,pythonCode:void 0,isAutoCompleteMode:!1,isChatMode:!0,isDataMartQuery:!0,chatQuestion:ge?.question}},chartSettings:ge?.chartSettings,drillDownSettings:{drillType:``,isEnableCrossFilter:!1,isEnableGroupBy:!1,drilldownChartSettings:void 0}}),we=(0,n.useMemo)(()=>(Ce?.tableList)?.map(e=>({columns:e?.columns?.map(e=>e.name)||[],columnsWithDataType:e?.columns?.map(e=>({as:e.as,dataType:e.datatype,name:e.name,label:e.label,synonyms:e.synonyms})),companyId:``,id:``,recentUpdatedAt:0,schemaName:e?.tableName?.split(`.`)?.[0]||``,tableName:e?.tableName?.split(`.`)?.[1]||``,clientColumn:e?.clientColumn||``,alias:`${e?.tableName?.split(`.`)?.[0]||``}_${e?.tableName?.split(`.`)?.[1]||``}`}))||[],[Ce]),{autoCompleteDropdownOptions:Te}=iQt(!0,we,_e),Ee=(0,n.useMemo)(()=>{let{dimensions:e,measures:t,resDataColumns:n,aggregates:r}=vSe({columns:ge?.columns,data:ge?.data||[],dbName:ee?.name?.toLowerCase()||``});return{zIndex:999999,isOpen:fe?.isOpenTypePanel,onClose:()=>pe({chartIndex:0,isOpenTypePanel:!1,isOpenAppearance:!1}),enabledCharts:_Se(ge?.data||[],{dimensions:e,measures:t,aggregates:r}),onChartChange:i=>{let{singleValue:a,xAxis:o,yAxisList:s,progressData:l,comboAxisSettings:u,comboBarList:d,measure:f,pivotTableSettings:p,progressMaxData:m,progressMinData:h,sankeyValues:g,stackTableCols:_,step:v}=gSe({dimensions:e,measures:t,aggregates:r},i);x(r=>({...r,chats:r.chats?.map(r=>r.timestamp===fe.chartIndex?{...r,chartSettings:{...r?.chartSettings,chartType:i,singleValue:a,progressColumn:l,progressMaxColumn:m,progressMinColumn:h,gaugeSettings:{dimensions:e,metric:t?.[0]},xAxis:o,yAxisList:i===$.table?n:s,isGroupXAxis:!!t?.length&&e?.length>1,sankeyValues:g?.filter(e=>e)?.length?g:[],comboBarList:d?.filter(e=>e)?.length?d:[],stackTableCols:_,pivotTableSettings:p,customSettings:{...r?.chartSettings,comboAxisSettings:u},step:v,measure:f}}:r)})),pe({chartIndex:0,isOpenAppearance:!1,isOpenTypePanel:!1})},selectedChart:ge?.chartSettings?.chartType||$.line}},[fe.chartIndex,fe?.isOpenTypePanel,ee?.name,ge?.chartSettings?.chartType,ge?.columns,ge?.data]),De=(0,n.useMemo)(()=>({zIndex:999999,isOpen:fe?.isOpenAppearance,onClose:()=>pe({chartIndex:0,isOpenTypePanel:!1,isOpenAppearance:!1}),chartSettings:ge?.chartSettings,setChartSettings:e=>{if(typeof e==`function`){let t=e(ge?.chartSettings);x(e=>({...e,chats:e.chats?.map(e=>e.timestamp===fe.chartIndex?{...e,chartSettings:t}:e)}))}typeof e==`object`&&x(t=>({...t,chats:t.chats?.map(t=>t.timestamp===fe.chartIndex?{...t,chartSettings:e}:t)}))},setResetPallete:e=>{if(typeof e==`function`){let t=e(ge?.isResetPallete);x(e=>({...e,chats:e.chats?.map(e=>e.timestamp===fe.chartIndex?{...e,isResetPallete:!1,chartSettings:t?{...e.chartSettings,chartColors:r||wv}:e.chartSettings}:e)}))}typeof e==`boolean`&&x(t=>({...t,chats:t.chats?.map(t=>t.timestamp===fe.chartIndex?{...t,isResetPallete:!1,chartSettings:e?{...t.chartSettings,chartColors:r||wv}:t.chartSettings}:t)}))},setBarRadius:e=>{if(typeof e==`function`){let t=e(ge?.barRadius);x(e=>({...e,chats:e.chats?.map(e=>e.timestamp===fe.chartIndex?{...e,barRadius:t,chartSettings:{...e.chartSettings,customSettings:{...e.chartSettings.customSettings,barRadius:e.chartSettings.chartType===$.row||e.chartSettings.chartType===$.bullet||e.chartSettings.chartType===$.horizontalStack?[t?.bottomRadius,t?.topRadius,t?.topRadius,t?.bottomRadius]:[t?.topRadius,t?.topRadius,t?.bottomRadius,t?.bottomRadius]}}}:e)}))}typeof e==`object`&&x(t=>({...t,chats:t.chats?.map(t=>t.timestamp===fe.chartIndex?{...t,barRadius:e,chartSettings:{...t.chartSettings,customSettings:{...t.chartSettings.customSettings,barRadius:t.chartSettings.chartType===$.row||t.chartSettings.chartType===$.bullet||t.chartSettings.chartType===$.horizontalStack?[e?.bottomRadius,e?.topRadius,e?.topRadius,e?.bottomRadius]:[e?.topRadius,e?.topRadius,e?.bottomRadius,e?.bottomRadius]}}}:t)}))}}),[fe.chartIndex,fe?.isOpenAppearance,ge?.barRadius,ge?.chartSettings,ge?.isResetPallete,r]),Oe=({columns:e,isCountryDimension:t,isDifferentMeasureScales:n,isProgressiveDimension:i,isTimeSeries:a,query:o,resData:s,sqlMetadata:l,dimensionMetadata:u,measureMetadata:d,questionType:f,aggregateColumnMetadata:p,semanticColumns:m})=>{let{dimensions:h,measures:g,resDataColumns:_}=vSe({columns:e,data:s||[],dbName:ee?.name?.toLowerCase()||``}),v=s?.[0]?.[_?.[0]||``]===null,y=awr(o,ve),{chartType:b,defaults:x}=cwr({rows:s||[],dimensions:h,measures:g,dataLength:s?.length||0,isCountryDimension:t,isDifferentMeasureScales:n,isNullValue:v,isProgressiveDimension:i,isTimeSeries:a,orderBy:y?.[0]?.type,questionType:f,semanticColumns:m}),S={...Tv,chartColors:r||wv,numberColumns:g,isGroupXAxis:b===$.horizontalStack},C=kSe({chartSettings:S,chartType:b,dimensions:h,measures:g,columns:_,displayText:b===$.singleValue&&g?.[0]&&h?.[0]&&s?.[0]?.[h?.[0]]?s?.[0]?.[h?.[0]]:``,sqlMetadata:l,tableList:we,isRepeatedValue:ASe(s,h?.[0]||``),dimensionMetadata:u,measureMetadata:d,isMultiSeries:h?.length===2&&b===$.line,aggregateColumnMetadata:p});return uwr(C,x,_)};return(0,n.useEffect)(()=>{let e=Ce;e?.tableList?.length&&te({id:e?.companyIntegrationId,name:e?.dbName})},[Ce]),{searchState:b,setSearchState:x,onAskQuestion:()=>{let e=Date.now(),t=b?.followUp,n=b.followUp?{followUp:{isEnable:!!b.followUp,previousQuestion:ySe(b.followUp).reverse().join(` `),previousSql:b.followUp.responseQuery}}:void 0,r=ne;ae(!0),x(e=>({...e,isDisableButton:!0,error:``,isLoading:!0,currentQuestion:r})),re(``),h({signal:v(),data:{question:r,config:n,wId:a,embedDataAppId:l,dashboardId:d||``,datasourceId:u||``,isCreateMetric:!0},clientId:``,isFrontendApp:!1,token:i},{onSuccess:async n=>{let i=typeof n==`string`?JSON.parse(n):n,a=i?.error?.message||i?.error,s=i?.queryData,l=s?.message||s?.errorObj?.errorMessage,u=i?.metaData?.groupbyColumnList,d=i?.query||``;d&&=V(d,o||``);let f=Array.isArray(s)?s:[],p=jSe(i?.columns),m=i?.summary,h=i?.isCountryDimension,g=i?.isDifferentMeasureScales,_=i?.isProgressiveDimension,v=i?.isTimeSeries,y=Array.isArray(u)?u:[],b=RS(i?.sqlMetadata),S=RS(i?.measureMetadata),C=RS(i?.dimensionMetadata),w=RS(i?.aggregateColumnMetadata),T=w?.map(e=>e.aggregateColumnName);p={dimensions:p?.dimensions||[],measures:p?.measures||[],aggregates:T};let ee=i?.questionType||``;i?.reasoning,b?.map(e=>({table:e.tableName,columns:e.columns})),ae(!1),setTimeout(()=>{a||l?(x(n=>({...n,error:``,isLoading:!1,isDisableButton:!1,currentQuestion:``,errorTime:0,followUp:void 0,chats:[...n.chats,{...bce,question:r,error:a||l,timestamp:Date.now(),queryTimestamp:e,followUp:t}]})),he([])):(x(n=>({...n,error:``,isDisableButton:!1,isLoading:!1,currentQuestion:``,errorTime:0,followUp:t?{chartSettings:Oe({columns:p,resData:f,query:d,isCountryDimension:h,isDifferentMeasureScales:g,isProgressiveDimension:_,isTimeSeries:v,sqlMetadata:b,dimensionMetadata:C,measureMetadata:S,questionType:ee,aggregateColumnMetadata:w,semanticColumns:i?.semanticColumns}),data:f,question:r,responseQuery:d,groupbyColumnList:y,timestamp:Date.now(),queryTimestamp:e,barRadius:{bottomRadius:0,topRadius:0},isResetPallete:!1,error:``,followUp:t,columns:p,summary:m}:void 0,chats:[...n.chats,{chartSettings:Oe({columns:p,resData:f,query:d,isCountryDimension:h,isDifferentMeasureScales:g,isProgressiveDimension:_,isTimeSeries:v,sqlMetadata:b,dimensionMetadata:C,measureMetadata:S,questionType:ee,aggregateColumnMetadata:w,semanticColumns:i?.semanticColumns}),data:f,question:r,responseQuery:d,groupbyColumnList:y,timestamp:Date.now(),queryTimestamp:e,barRadius:{bottomRadius:0,topRadius:0},isResetPallete:!1,error:``,followUp:t,columns:p,summary:m}]})),he([]))},2e3)},onError(e){ae(!1),!li(e)&&setTimeout(()=>{x(e=>({...e,error:bse,isDisableButton:!1,isLoading:!1,errorTime:Date.now()}))},2e3)}})},autoCompleteDropdownOptions:Te,searchKeys:me,setSearchKeys:he,setSearchKeyword:re,searchKeyword:ne,showChatResults:oe,setShowChatResults:se,chartPanel:fe,setChartPanel:pe,chartTypePanelProps:Ee,chartAppearancePanelProps:De,selectedChat:ge,saveChat:ye,isSavingChat:xe,saveChatError:be,updateChat:Se,fromatQuery:e=>{try{return KCr(e,{language:ve||`mysql`})}catch{return e}},setChatReport:de,chatReport:ue,isSearchDataLoading:ie,pivotDrillState:S,setPivotDrillState:C,isModalShow:w,setModalShow:T,isLoading:ce,setLoading:le,onGenerateDataReport:e=>{e.report?de({isOpen:!0,report:e.report,isLoading:!1}):(de({isOpen:!0,report:``,isLoading:!0}),g({signal:v(),data:{data:e.data,wId:a},clientId:s,token:i,isFrontendApp:!1},{onError(e){if(li(e)){de(e=>({...e,isLoading:!1}));return}de({isOpen:!0,report:`That report could not be generated. Try again, and if it keeps failing tell whoever gave you this link.`,isLoading:!1})},onSuccess(t){let n=t?.content||``,r=t?.error?.message||``;x(t=>({...t,chats:t.chats?.map(t=>t.timestamp===e.timestamp?{...t,report:n||``}:t)})),de({isOpen:!0,report:n||r,isLoading:!1})}}))},stopSearch:y}}})),pwr=_({SearchMetricData:()=>mwr}),mwr,hwr=h((()=>{T_r(),D_r(),$_r(),fwr(),my(),R9(),mwr=({config:e,storyValues:t})=>{let{onAskQuestion:r,searchState:a,autoCompleteDropdownOptions:o,searchKeys:s,setSearchKeys:l,searchKeyword:u,setSearchKeyword:d,setSearchState:f,setChartPanel:p,setShowChatResults:m,showChatResults:h,chartTypePanelProps:g,chartAppearancePanelProps:_,saveChat:v,isSavingChat:y,saveChatError:b,updateChat:x,fromatQuery:S,chatReport:C,setChatReport:w,isSearchDataLoading:T,onGenerateDataReport:ee,chartPanel:te,pivotDrillState:ne,selectedChat:re,setPivotDrillState:ie,setModalShow:ae,isLoading:oe,setLoading:se,isModalShow:ce,stopSearch:le}=dwr(e),[ue,de]=(0,n.useState)(Tv);return(0,i.jsxs)(`div`,{className:w_r.generateMetricModal,children:[(0,i.jsx)(TJ,{isOpen:t?t.isModalShow:ce,onClose:()=>ae(!1),headerTitle:`Save To Dashboard`,children:(0,i.jsx)(nH,{onCancel:()=>ae(!1),onSubmit:v,error:b,isCreatingMetric:y})}),(0,i.jsx)(E_r,{props:{setSearchGenerateMetricModal:e.setSearchGenerateMetricModal,isBusy:T||C?.isLoading,onStop:le}}),(0,i.jsx)(Q_r,{props:{fromatQuery:S,onGenerateDataReport:ee,chatReport:C,setChatReport:w,searchDropdownProps:{onSubmitSearch:r,options:o,searchKeys:s,setSearchKeys:l,isDisabled:a.isDisableButton,searchKeyword:u,setSearchKeyword:d,position:`top`,placeholder:`Start a chat with your data...`},searchState:a,setSearchState:f,chartTypePanelProps:g,chartAppearancePanelProps:_,chartConfig:{setChartSettings:de,pivotDrillState:ne,setChartPanel:p,setShowChatResults:m,showChatResults:h,setModalShow:ae,isLoading:t?t.isLoading:oe},isSearchDataLoading:T}})]})}})),gwr,_wr,vwr=h((()=>{gwr=(0,n.lazy)(()=>Promise.resolve().then(()=>(hwr(),pwr)).then(e=>({default:e.SearchMetricData}))),_wr=e=>(0,i.jsx)(n.Suspense,{fallback:null,children:(0,i.jsx)(gwr,{...e})})})),ywr=h((()=>{vwr()})),bwr,xwr=h((()=>{m9n(),b$(),D3(),WZ(),Sa(),Zs(),Ny(),my(),GX(),bwr=({headers:e,data:t,variant:r=`primary`,noDataText:a=`No Data Available`,loadMoreText:o=`See More`,className:s=``,initialLimit:l=5,isDataLoading:u=!1,showLogo:d,isShowOptions:f,setValue:p,currentPage:m=1,isEnableScrollToTop:h,isDisableMoreOption:g,isEnableSelectAll:_,onSelectAll:v,onDeselectAll:y,isAllSelected:b,parent:x,extraValues:S,extraHeaderText:C,onTourClick:w,onRowClick:T,onRowHover:ee,onMouseOut:te,buttonContent:ne,noDataSubHeading:re,isDatasourceList:ie,stateKey:ae,onCreate:oe,isDemoDatasource:se,isOpenInNewTab:ce})=>{let[le,ue]=(0,n.useState)(l),[de,fe]=(0,n.useState)(``),[pe,me]=(0,n.useState)(``),he=e=>{if(x)switch(x){case`DASHBOARD`:case`DASHBOARD_CREATE`:return`/externalDashboard/${e.id}/?wid=${S?.workspaceId}${S?.dataMartId?`&dmId=${S?.dataMartId}`:``}${e?.createdBy?`&createdByClient=${e?.createdBy}`:``}`;case`METRIC`:return`/metric/${e?.metric?.id}/?wid=${e?.workspaceId}${S?.dataMartId?`&dmId=${S?.dataMartId}`:``}${e?.dashboardId?`&dashboardId=${e?.dashboardId}`:``}&client=${e?.metric?.clientId}&parent=homepage&isPublished=${e?.isPublished}`;case`DATASOURCE`:return`/integration/${e.integrationId}?id=${e.id}`;case`DATAAPP`:return`embedInfo/${e.id}`;case`DASHBOARD_EMBED_ACCESS`:return e?.embedType===`dashboard`?`embedAccessControl/${e?.id}?dataAppId=${e?.dataAppId}&wid=${e?.workspaceId}`:null;case`DATAMART`:return`/datamarts/edit/${e?.id}?datasourceId=${e?.datasourceId}`;case`SEMANTIC`:return`/datamarts/desc/${e?.id}`;case`LLM`:return`/settings/llms/edit/?llmId=${e?.id}`;default:return null}return null},ge=(0,n.useRef)(null);return(0,n.useEffect)(()=>{h&&m&&ge.current&&ge.current.scrollTo({top:0,behavior:`auto`})},[m]),(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(`div`,{ref:ge,className:`${m5[`container-${r}`]} ${s}`,children:[u?(0,i.jsx)(`div`,{className:`dbn:my-5 dbn:w-full dbn:flex dbn:items-center dbn:justify-end`,children:(0,i.jsx)(E3,{variant:`table`,tableRows:4})}):null,!u&&t.length===0&&!ae?(0,i.jsxs)(`div`,{className:m5.noData,children:[(0,i.jsx)(`img`,{src:WX,alt:`no-data`,width:`200px`,height:`200px`}),(0,i.jsxs)(`div`,{className:m5.heading,children:[(0,i.jsx)(xa,{variant:`heading-5`,children:a}),re?(0,i.jsx)(xa,{variant:`body-text-3`,children:re}):null,ne]})]}):null,!u&&(t.length||ae)?(0,i.jsxs)(`table`,{className:`${m5.table} ${t.length>0?``:`dbn:h-0`}`,children:[(0,i.jsx)(`thead`,{className:`${m5[`headers-${r}`]} ${t.length===0?m5[`headers-${r}-nodata`]:``} dbn:z-50`,children:(0,i.jsx)(`tr`,{children:e?.map((t,n)=>(0,i.jsxs)(`th`,{colSpan:t.colSpan,className:`${C?m5.headerCol2:m5.headerCol} ${t.columnKey?.toLowerCase()===`actions`?`dbn:w-[250px]`:``}`,children:[(0,i.jsxs)(`span`,{className:`${_&&n===0?`dbn:flex dbn:gap-2`:``}`,children:[n===0&&_?(0,i.jsx)(y$,{id:`${t?.name?.replaceAll(` `,`-`)?.toLowerCase()}-header-checkbox`,onChange:e=>{e.target.checked?v?.():y?.()},checked:b}):null,(0,i.jsx)(xa,{variant:`sec-heading-6`,color:`gray`,children:t.headerCell||t.name})]}),n===e.length-1&&C?(0,i.jsx)(xa,{variant:`body-text-3`,color:`cta`,children:C}):null]},t.name))})}),(0,i.jsx)(`tbody`,{className:m5.body,children:(g?t:t.slice(0,le))?.map((t,n)=>(0,i.jsx)(`tr`,{"data-testid":`row-${t?.name??t?.metric?.name??t?.companyRole?.name??t?.email?.split(`@`)?.[0]}`,className:`${m5[`row-${r}`]} ${x||w||ee||T?`dbn:cursor-pointer`:``}`,onClick:e=>{w&&w(t),T&&T(t)},onContextMenu:e=>{let n=he(t);n&&ce&&(e.preventDefault(),window.open(n,`_blank`))},"data-test-title":`table-rows`,onMouseOver:()=>ee?.(t),onMouseOut:()=>te?.(),children:e?.map((n,a)=>{let o=n.columnKey===`invitationToken`&&!!t[n.columnKey];return(0,i.jsx)(`td`,{colSpan:n.colSpan,className:`${m5.col} ${m5[`col-${r}`]}`,children:(0,i.jsx)(`div`,{className:m5[`col-${r}-cell`],children:a===0&&d||n.columnKey?.toLowerCase()===`type`?(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-2`,children:[(t?.type||t?.dbName)&&(0,i.jsx)(My,{name:n.columnKey?.toLowerCase()===`type`?t.type?.toString():t.dbName?.toString()?.toLowerCase(),width:20}),n.columnKey?.toLowerCase()===`name`&&(t.name===null||t.name===void 0)&&t.dbName?.toString()?.toLowerCase()===`awss3`?`Demo Datasource`:(n.columnCell?n.columnCell(t):t[n.columnKey])||`-`]}):(0,i.jsxs)(`div`,{className:`dbn:w-full dbn:flex dbn:items-center dbn:justify-between`,children:[(n.columnCell?n.columnCell(t):o?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(xa,{variant:`body-text-2`,className:`dbn:text-xs`,children:`XXXX`}),(0,i.jsx)(Xs,{"data-testid":`invitation-copy`,variant:`tertiary`,type:`button`,onClick:()=>{navigator.clipboard.writeText(t[n.columnKey]),fe(t[n.columnKey]),setTimeout(()=>fe(``),1700)},leftIcon:(0,i.jsx)(jy,{name:`copy`,size:`xs`}),className:`dbn:p-0 dbn:pl-1 dbn:text-xs dbn:gap-1`,children:de===t[n.columnKey]?`Copied`:`Copy`})]}):t[n.columnKey])||`-`,a===e.length-1&&f?(0,i.jsxs)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(jy,{name:`kebab-menu-vertical`})}),menuWidth:`120px`,position:`bottom`,children:[(0,i.jsx)(Xs,{variant:`popover`,className:`dbn:p-2 dbn:flex dbn:justify-start dbn:w-full dbn:hover:bg-gray`,onClick:()=>p?.({action:`edit`,id:t.id}),leftIcon:(0,i.jsx)(jy,{name:`pencil-simple`}),children:`Edit`}),(0,i.jsx)(Xs,{variant:`popover`,className:`dbn:p-2 dbn:flex dbn:justify-start dbn:w-full dbn:hover:bg-gray`,onClick:()=>p?.({action:`delete`,id:t.id}),leftIcon:(0,i.jsx)(jy,{name:`delete`}),children:`Delete`})]}):null]})})},`${n.name}-${a}-${n.columnKey}`)})},`row-${n}`))})]}):null,t.length>le&&!g?(0,i.jsx)(`div`,{className:m5.loadMore,children:(0,i.jsxs)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>ue(e=>e+l),children:[(0,i.jsx)(jy,{name:`arrow-down`}),(0,i.jsx)(`span`,{children:o})]})}):null]})})}})),Swr,Cwr=h((()=>{Swr=(e,t=!0)=>e.filter(e=>!t||!e.isAppFilter)})),wwr,Twr,Ewr,Dwr,Owr=h((()=>{my(),wwr=e=>{let t=new Date;if(!e)return t;try{return new Date(t.toLocaleString(`en-US`,{timeZone:e}))}catch{return t}},Twr=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)if(e[r]>=t)return n=r,n;return n},Ewr=e=>{let t=new Date,n=t.getMonth(),r=t.getFullYear();return(e?.map(e=>{switch(e?.value){case`firstDay`:return 1;case`lastDay`:return new Date(r,n+1,0).getDate();case`firstMonday`:{let e=new Date(r,n,1);return e.getDay()===0?2:(9-e.getDay())%7+1}case`15OfMonth`:return 15;default:return null}})).filter(e=>e).sort((e,t)=>e-t)},Dwr=e=>{let t=wwr(e.timezone);t.setMinutes(t.getMinutes()+1);let n=null;switch(e.frequency){case`oneTime`:n=new Date(e?.oneTimeDate?.startDate||``);break;case`Daily`:n=new Date(t),n.setDate(t.getDate());break;case`Weekly`:{let r=Object.keys(e.weekDays).filter(t=>e.weekDays[t]),i=null;r.forEach(e=>{let n=(rv.findIndex(t=>t.value===e)+7-t.getDay())%7,r=new Date(t);r.setDate(t.getDate()+n),r.toDateString()===t.toDateString()&&r.setDate(r.getDate()+7),(!i||r<i)&&(i=r)}),n=i;break}case`Monthly`:{let r=e.newDate?Ewr(e.newDate):e.date?.map(e=>parseInt(e.value,10)),i=null;r.forEach(e=>{let n=new Date(t.getFullYear(),t.getMonth(),e);n<t&&n.setMonth(t.getMonth()),(!i||n<i)&&(i=n)}),n=i;break}}if(n!==null){let r=parseInt(e.minutes||`0`,10),i=Number.isNaN(r)?0:r;switch(n.setHours(parseInt(e.hours,10),i,0,0),e.time===`PM`&&e.hours===`12`?n.setHours(12,i,0,0):e.time===`PM`?n.setHours(parseInt(e.hours,10)+12,i,0,0):e.time===`AM`&&e.hours===`12`&&n.setHours(0,i,0,0),e.frequency){case`Daily`:case`oneTime`:(n.getHours()<t.getHours()||n.getHours()===t.getHours()&&n.getMinutes()<=t.getMinutes())&&n.setDate(n.getDate()+1);break;case`Weekly`:Object.keys(e.weekDays).filter(t=>e.weekDays[t]).includes(rv[t.getDay()].value)&&(n.getHours()>t.getHours()||n.getHours()===t.getHours()&&n.getMinutes()>t.getMinutes())&&n.setDate(t.getDate());break;case`Monthly`:{let r=e.newDate?Ewr(e.newDate):e.date?.map(e=>parseInt(e.value,10)).sort((e,t)=>e-t),i=Twr(r,t.getDate());n.setDate(r[i]),n.getDate()<=t.getDate()&&(n.getHours()<t.getHours()||n.getHours()===t.getHours()&&n.getMinutes()<=t.getMinutes())&&n.setDate(r[(i+1)%r.length]),n.getMonth()===t.getMonth()&&n.getDate()<=t.getDate()&&(n.getHours()<t.getHours()||n.getHours()===t.getHours()&&n.getMinutes()<=t.getMinutes())&&(n.setMonth(n.getMonth()+1),n.setDate(r[0])),n.getMonth()===t.getMonth()&&n.getDate()<t.getDate()&&n.setMonth(n.getMonth()+1);break}}}let r=n?n.getMonth()+1:void 0;return`${n?.getDate()}/${r}/${n?.getFullYear()}, ${n?.toLocaleTimeString()}`}}));function T9(e,t,n){let r=jr(n),i=oe(n),a=[i?.details?.reason,i?.code].find(e=>typeof e==`string`&&/^[A-Z][A-Z0-9_]{0,63}$/.test(e));Gr(`schedule-report-failed`,{action:e,context:t,...r}),Oi(`schedule_report.error`,{action:e,context:t,error_code:a||`UNKNOWN`,...r})}function kwr(e,t,n){Oi(e===`create`?`schedule_report.created`:`schedule_report.updated`,{frequency:t?.frequency,chart_count:Array.isArray(t?.charts)?t.charts.length:0,recipient_count:Array.isArray(t?.emails)?t.emails.length:0,is_download_file:!!t?.isDownloadFile,download_file_format:t?.isDownloadFile?t?.downloadFileFormat:void 0,is_internal:n})}var Awr,E9,jwr,Mwr,Nwr=h((()=>{Ge(),tH(),my(),qr(),Owr(),KK(),Fi(),Dc(),Awr=(e,t)=>({...e,...t?{createdByIdentifier:t}:{}}),E9={time:`PM`,timezone:$oe()??`Asia/Kolkata`,frequency:`Daily`,minutes:`00`},jwr=e=>{let t=e?.timeConfigurations?.charts;return Array.isArray(t)&&t.length?t:e?.scheduleEmailReportCharts?.map(e=>e?.externalMetricId||e?.externalMetric?.id||e?.externalMetric?.externalMetricId)?.filter(Boolean)||[]},Mwr=({onCancel:e,getInternalToken:t,scheduleReportConfig:r,externalDashboardId:i,sharingSettingsId:a,onComplete:o,clientState:s,createdByIdentifier:l})=>{let{register:u,handleSubmit:d,watch:f,control:p,setValue:m,getValues:h,reset:g,formState:{errors:_}}=OV(),{data:v,token:y}=Ec(),b=l??v?.userIdentifier,x=(0,n.useMemo)(()=>{if(r)return r},[r]);(0,n.useEffect)(()=>{x?g({...x?.timeConfigurations,charts:jwr(x),minutes:x?.timeConfigurations?.minutes??`00`}):(m(`time`,E9.time),m(`timezone`,E9.timezone),m(`frequency`,E9.frequency),m(`minutes`,E9.minutes),m(`subject`,``),m(`downloadFileFormat`,iv?.[0]?.value))},[x]);let[S,C]=(0,n.useState)(!1),[w,T]=(0,n.useState)(``),[ee,te]=(0,n.useState)(!1),[ne,re]=(0,n.useState)(!1),ie=zGt(),ae=BGt(),oe=(e,t,n)=>{if(!e?.charts?.length&&!n)return T(`please select at least one chart to share`),C(!1),te(!1),!1;if(!e?.emails?.length)return T(`please add at least one email address`),C(!1),te(!1),!1;if(e?.frequency===`Weekly`&&!Object?.values({...e?.weekDays}).includes(!0))return T(`please select atleast one day`),C(!1),te(!1),!1;if(e?.frequency===`Monthly`&&!e?.newDate?.length)return T(`please select at least one date option`),C(!1),te(!1),!1;if(e?.frequency===`oneTime`&&!e?.oneTimeDate?.startDate)return T(`please select date for one time schedule`),C(!1),te(!1),!1;if(e?.frequency===`oneTime`){let t=e?.oneTimeDate?.startDate;if(!t)return!1;let n=typeof t==`string`?new Date(t):new Date(t.getTime());if(isNaN(n.getTime()))return T(`invalid date selected`),C(!1),te(!1),!1;let r=Number(e?.hours);if(Number.isNaN(r)||r<1||r>12)return T(`invalid hour`),C(!1),te(!1),!1;let i=Number(`${e?.minutes??`0`}`.trim()||`0`);if(Number.isNaN(i)||i<0||i>59)return T(`invalid minutes`),C(!1),te(!1),!1;let a=e?.time===`PM`&&r!==12?r+12:e?.time===`AM`&&r===12?0:r,o=new Date(n.getTime());if(o.setHours(a,i,0,0),o.getTime()<=Date.now())return T(`please select valid time for one time schedule`),C(!1),te(!1),!1}return t?s?.isRequiredClient&&!s?.clients?.length?(T(`please select at least one client`),C(!1),te(!1),!1):!0:(T(`invalid time configurations`),C(!1),te(!1),!1)},se=e=>{if(e?.frequency===`Weekly`&&!Object?.values({...e?.weekDays}).includes(!0))return T(`please select atleast one day`),C(!1),te(!1),!1;if(e?.frequency===`Monthly`&&!e?.newDate?.length)return T(`please select at least one date option`),C(!1),te(!1),!1;if(e?.frequency===`oneTime`&&!e?.oneTimeDate?.startDate)return T(`please select date for one time schedule`),C(!1),te(!1),!1;if(e?.frequency===`oneTime`){let t=e?.oneTimeDate?.startDate;if(!t)return!1;let n=typeof t==`string`?new Date(t):new Date(t.getTime());if(isNaN(n.getTime()))return T(`invalid date selected`),C(!1),te(!1),!1;let r=Number(e?.hours);if(Number.isNaN(r)||r<1||r>12)return T(`invalid hour`),C(!1),te(!1),!1;let i=Number(`${e?.minutes??`0`}`.trim()||`0`);if(Number.isNaN(i)||i<0||i>59)return T(`invalid minutes`),C(!1),te(!1),!1;let a=e?.time===`PM`&&r!==12?r+12:e?.time===`AM`&&r===12?0:r,o=new Date(n.getTime());if(o.setHours(a,i,0,0),o.getTime()<=Date.now())return T(`please select valid time for one time schedule`),C(!1),te(!1),!1}return!0},ce=async n=>{T(``),C(!0),te(!1),n.minutes=`${n?.minutes??``}`.trim()?`${n?.minutes}`.padStart(2,`0`):`00`;let{subject:r,emails:l,frequency:u,weekDays:d,date:f,hours:p,time:m,timezone:h,newDate:g,isDownloadFile:_,downloadFileFormat:S}=n,w=await t?.(x?.guestToken,!!s?.isDisableClient);if(Gr(`schedule-report-start`,{action:x?`update`:`create`,frequency:u,chartCount:n?.charts?.length??0,emailCount:Array.isArray(l)?l.length:0,subjectLength:`${r??``}`.length,hasInternalToken:!!w,isDownloadFile:!!_,downloadFileFormat:S,clientCount:s?.clients?.length??0}),!se(n)){Gr(`schedule-report-blocked`,{gate:`dates`,frequency:u});return}let ee=Dwr({date:f,frequency:u,hours:p,minutes:n?.minutes,time:m,timezone:h,weekDays:d,newDate:g,oneTimeDate:n?.oneTimeDate});if(!oe(n,ee,!!w)){Gr(`schedule-report-blocked`,{gate:`settings`,frequency:u,hasNextScheduledAt:!!ee});return}let ne=n?.charts?.map(e=>({externalMetricId:e}));x?ae?.mutate({id:x?.id,token:w||y},{onSuccess(t){t?.delete_scheduleEmailReports_by_pk?.id?ie.mutate({data:Awr({embedId:v?.embedDataAppId||null,emails:l,externalDashboardId:i||v?.externalDashboard?.id,data:ne,guestToken:w||y,nextScheduledAt:ee,sharingSettingsId:a||v?.sharingSettingsId,subject:r,isDownloadFile:_,downloadFileFormat:S,timeConfigurations:{...n,clients:s?.clients||[],isDisableClient:!!s?.isDisableClient,isSelectAll:n?.isSelectAll,isShowViewDashboardBtn:n?.isShowViewDashboardBtn},isInternal:!!w},b),token:w||y},{onSuccess(t){t?.insert_scheduleEmailReports_one?.id?(Gr(`schedule-report-success`,{action:`update`}),kwr(`update`,n,!!w),T(``),C(!1),te(!0),o?.(),e()):(T9(`update`,`save_unexpected_response`),T(`Unable to update the schedule. Please try again.`),C(!1),te(!1))},onError(e){T9(`update`,`save_failed`,e),T(`Unable to update the schedule. Please try again later.`),C(!1),te(!1)}}):(T9(`update`,`delete_unexpected_response`),T(`Unable to update the schedule. Could not remove the existing schedule.`),C(!1),te(!1))},onError(e){T9(`update`,`delete_failed`,e),T(`Unable to update the schedule. Please try again later.`),C(!1),te(!1)}}):ie.mutate({data:Awr({embedId:v?.embedDataAppId||null,emails:l,externalDashboardId:i||v?.externalDashboard?.id,data:ne,guestToken:w||y,nextScheduledAt:ee,sharingSettingsId:a||v?.sharingSettingsId,subject:r,isDownloadFile:_,downloadFileFormat:S,timeConfigurations:{...n,clients:s?.clients||[],isDisableClient:!!s?.isDisableClient,isSelectAll:n?.isSelectAll,isShowViewDashboardBtn:n?.isShowViewDashboardBtn},isInternal:!!w},b),token:w||y},{onSuccess(t){t?.insert_scheduleEmailReports_one?.id?(Gr(`schedule-report-success`,{action:`create`}),kwr(`create`,n,!!w),T(``),C(!1),te(!0),o?.(),e()):(T9(`create`,`save_unexpected_response`),T(`Unable to create the schedule. Please try again.`),C(!1),te(!1))},onError(e){T9(`create`,`save_failed`,e),T(`Unable to create the schedule. Please try again later.`),C(!1),te(!1)}})};return{register:u,handleSubmit:d,watch:f,control:p,setValue:m,getValues:h,reset:g,dashboardName:``,onSave:d(async e=>{try{await ce(e)}catch(e){let t=x?`update`:`create`;T9(t,`unhandled`,e),T(t===`update`?`Unable to update the schedule. Please try again later.`:`Unable to create the schedule. Please try again later.`),C(!1),te(!1)}}),isLoading:S,isSuccess:ee,error:w,scheduleReportConfig:x,onDelete:d(async()=>{let n=await t?.(x?.guestToken);T(``),C(!0),re(!1),te(!1),ae.mutate({id:x?.id,token:n||y},{onSuccess(t){t?.delete_scheduleEmailReports_by_pk?.id?(Gr(`schedule-report-success`,{action:`delete`}),T(``),C(!1),g(),re(!0),o?.(),e()):(T9(`delete`,`delete_unexpected_response`),T(`Unable to delete the schedule. Please try again.`),C(!1),re(!1))},onError(e){T9(`delete`,`delete_failed`,e),T(`Unable to delete the schedule. Please try again later.`),C(!1),re(!1)}})}),isDeleted:ne,errors:_}}})),Pwr,D9,Fwr=h((()=>{Pwr=`_formWrapper_rutu9_8`,D9={formWrapper:Pwr,"form-primary-text":`_form-primary-text_rutu9_12`,"week-days-container":`_week-days-container_rutu9_16`,"main-label":`_main-label_rutu9_19`,"time-element":`_time-element_rutu9_23`,"schedule-time":`_schedule-time_rutu9_26`,"time-hour-field":`_time-hour-field_rutu9_30`,"time-minute-field":`_time-minute-field_rutu9_34`,"time-separator":`_time-separator_rutu9_38`,"cancel-btn":`_cancel-btn_rutu9_42`,"delete-btn":`_delete-btn_rutu9_45`,"field-width":`_field-width_rutu9_48`,"time-dropdown-field":`_time-dropdown-field_rutu9_52`,"success-text":`_success-text_rutu9_56`}})),Iwr,Lwr,Rwr,zwr=h((()=>{tH(),R9(),ebt(),DJ(),my(),t1t(),Cwr(),Hx(),Dc(),Nwr(),Fwr(),Iwr=e=>e?.length?e.flatMap(e=>e.columns?.map(t=>({...t,_tableName:e.tableName}))||[]):[],Lwr=(e,t,n)=>Swr(e,!!t).filter(e=>lvt(e,n)),Rwr=({onCancel:e,getInternalToken:t,scheduleReportConfig:r,chartOptions:a,externalDashboardId:o,sharingSettingsId:s,onComplete:l,clientDropDown:u,clientState:d,isEmbed:f,dashboardFilters:p,workspaceId:m,datasourceId:h,encryptedClientId:g,companyTenancyType:_,clientColumnType:v})=>{let{control:y,register:b,setValue:x,watch:S,onSave:C,isLoading:w,error:T,isSuccess:ee,scheduleReportConfig:te,onDelete:ne,isDeleted:re,errors:ie}=Mwr({onCancel:e,getInternalToken:t,scheduleReportConfig:r,externalDashboardId:o,sharingSettingsId:s,onComplete:l,clientState:d}),{data:ae,token:oe}=Ec(),se=m||ae?.workspace?.id||``,ce=h||ae?.datasourceId||``,le=g||``,ue=_||ae?.companyTenancyType,de=v||ae?.clientColumnType,fe=(0,n.useMemo)(()=>d?.isDisableClient?[]:d?.clients||[],[d?.clients,d?.isDisableClient]),pe=(0,n.useMemo)(()=>fe.map(e=>e.value).filter(e=>e!=null&&e!==``),[fe]),me=fvt({tenancyLevel:ue,isDisableClient:d?.isDisableClient===!0,selectedClientCount:fe.length}),he=(0,n.useMemo)(()=>{let e=p||ae?.externalDashboard?.filters,t=fe[0]?.value;if(!e?.length||ue!==`DATABASE`||fe.length!==1||!t)return e;let n=e=>{let n=e||``,r=n.lastIndexOf(`.`),i=r>=0?n.slice(r+1):n;return i?`${t}.${i}`:n};return e.map(e=>({...e,tableName:n(e?.tableName),columns:(e?.columns||[]).map(e=>({...e,selectedTable:e?.selectedTable?n(e?.selectedTable):e?.selectedTable,applyOnTables:(e?.applyOnTables||[]).map(e=>({...e,tableName:n(e?.tableName)}))}))}))},[p,ae?.externalDashboard?.filters,ue,fe]),[ge,_e]=(0,n.useState)(!0),[ve,ye]=(0,n.useState)(!0),[be,xe]=(0,n.useState)(!0),[Se,Ce]=(0,n.useState)(!1),[we,Te]=(0,n.useState)({showDelete:!1,deleteFunction:()=>{}}),[Ee,De]=(0,n.useState)(``),Oe=(0,n.useMemo)(()=>Iwr(he),[he]),Ae=(0,n.useMemo)(()=>Lwr(Oe,f,pe),[Oe,f,pe]),je=(0,n.useMemo)(()=>Ae.map(e=>({value:e.label||e.name,label:e.label||e.name})),[Ae]),Me=S(`selectedFilterNames`)||[],Ne=S(`scheduleFilters`)||{},[Pe,Fe]=(0,n.useState)([]),[Ie,Le]=(0,n.useState)(!1),Re=(0,n.useMemo)(()=>{if(!Me.length)return[];let e=he;return e?.length?e.map(e=>({...e,columns:(e?.columns||[]).filter(e=>Me.some(t=>t.value===(e.label||e.name))).map(e=>({...e,isShowHorizontal:!0}))})).filter(e=>e.columns.length>0):[]},[Me,he]);(0,n.useEffect)(()=>{if(!Ie)return;let e={};Pe.forEach(t=>{if(!t.value||Array.isArray(t.value)&&!t.value.length||t.value===`*`)return;let n=t.label||t.column;t.as===`date`||t.as===`number`?e[n]=t.value:Array.isArray(t.value)?e[n]=t.value.map(e=>typeof e==`string`?Vx(e):e):typeof t.value==`string`?e[n]=Vx(t.value):e[n]=t.value}),x(`scheduleFilters`,e)},[Pe,Ie,x]),(0,n.useEffect)(()=>{let e=S(`scheduleFilters`);if(!Pe.length&&e&&Object.keys(e).length&&Oe.length){let t=[];for(let[n,r]of Object.entries(e)){if(r==null)continue;let e=Oe.find(e=>(e.label||e.name)===n);e&&lvt(e,pe)&&t.push({column:e.name,operator:e.as===`date`||e.as===`number`?`BETWEEN`:e.filterVariant?.value||`IN`,value:r,as:e.as,label:e.label||e.name,filterType:`horizontal`,isFilterApplied:!0,applyOnTables:e.applyOnTables,filterVariant:e.filterVariant})}t.length&&Fe(t)}Le(!0)},[Pe.length,Oe,pe,S]),(0,n.useEffect)(()=>{if(!Ie)return;let e=e=>{if(!e)return!0;let t=Oe.find(t=>(t.label||t.name)===e);return t?lvt(t,pe):!1},t=S(`selectedFilterNames`)||[],n=t.filter(t=>e(t.value));n.length!==t.length&&x(`selectedFilterNames`,n);let r=S(`scheduleFilters`)||{},i={},a=!1;Object.entries(r).forEach(([t,n])=>{e(t)?i[t]=n:a=!0}),a&&x(`scheduleFilters`,i),Fe(t=>{let n=t.filter(t=>e(t.label||t.column));return n.length===t.length?t:n})},[Oe,Ie,pe,x,S]),(0,n.useEffect)(()=>{if(!Ie||me)return;(S(`selectedFilterNames`)||[]).length&&x(`selectedFilterNames`,[]);let e=S(`scheduleFilters`)||{};Object.keys(e).length&&x(`scheduleFilters`,{}),Fe(e=>e.length?[]:e)},[me,Ie,x,S]);let ze=e=>e.map(({value:e,label:t})=>({value:e,label:t})),Be=(e,t,n)=>{let r=S(e)||n,i=t.find(e=>e.value===r)??t.find(e=>e.value===n);return{current:r,selectedOption:i?{value:i.value,label:i.label}:{value:r,label:r},hint:i?.hint}},Ve=Be(`orientation`,Dce,fy.orientation),He=Be(`density`,Oce,fy.density),Ue=Be(`tableMode`,kce,fy.tableMode),We=Be(`deliveryMode`,Ace,Tce);return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(`form`,{className:`dbn:w-full`,style:{height:`calc(100% - 44px)`},onSubmit:C,children:[(0,i.jsx)(`div`,{className:D9.formWrapper,children:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:flex-col dbn:px-5 dbn:w-full dbn:h-full dbn:gap-4`,children:[(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(`span`,{className:ge?``:`dbn:-rotate-90`,children:(0,i.jsx)(jy,{name:`caret-down-fill`})}),onClick:()=>_e(!ge),children:`General`}),ge&&(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-2 dbn:border-b dbn:border-secondary dbn:pb-5`,children:[(0,i.jsx)(SJ,{label:`Subject Line`,placeholder:`e.g. Monthly dashboard report`,register:b(`subject`,kJ),error:ie.subject?.message,isImportant:!0}),(0,i.jsx)(jJ,{control:y,type:`text`,label:`Send to`,placeholder:`Enter email addresses`,register:b(`emails`,{validate:e=>e&&e.length>0||`At least one email is required`}),error:ie.emails?.message,onChange:()=>{ie?.emails&&(ie.emails.message=``)},onChangeTags:e=>x(`emails`,e),defaultTagValue:r?.timeConfigurations?.emails||te?.timeConfigurations?.emails,width:``,regexStr:RegExp(`^(?![.])[a-zA-Z0-9._%+-]+(?<![.])@(?:(?!-)[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$`,``),tagType:`Email address`,tagError:Ee,setTagError:De,isImportant:!0})]}),(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(`span`,{className:ve?``:`dbn:-rotate-90`,children:(0,i.jsx)(jy,{name:`caret-down-fill`})}),onClick:()=>ye(!ve),children:`Report Content Settings`}),ve&&(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-2 dbn:border-b dbn:border-secondary dbn:pb-5`,children:[` `,(0,i.jsx)(KV,{control:y,name:`charts`,rules:{validate:e=>e&&e.length>0?!0:`Please select at least one chart`},render:({field:e})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(pX,{label:`Charts to Attach`,selectedOption:a.filter(t=>e.value?.some(e=>e===t.value)),options:a,onChange:t=>{x(`isSelectAll`,t?.length===a?.length),e.onChange(t?.map(e=>e.value||[]))},buttonWidth:`100%`,menuWidth:`100%`,isSearchEnabled:!0,isSelectAllEnabled:!0,useSemanticSelectAll:!1,isImportant:!0}),ie.charts?.message&&(0,i.jsx)(xa,{variant:`body-text-2`,color:`alert`,children:`${ie.charts.message}`})]})}),!u&&(d?.isDisableClient||te?.timeConfigurations?.isDisableClient||ae?.isAllClient)&&(0,i.jsx)(xa,{variant:`body-text-3`,color:`warning`,children:`Recipients see data for all clients.`}),u,t&&(0,i.jsxs)(ZZ,{className:`dbn:gap-2`,alignItems:`center`,children:[(0,i.jsx)(p$,{onChange:e=>{x(`isShowViewDashboardBtn`,e)},enabled:!!S(`isShowViewDashboardBtn`),placeholder:`Include 'View Full Dashboard' Button`,name:`enableDashboardView`}),(0,i.jsx)(uY,{text:`Adds a ‘View Full Dashboard’ button in the email, allowing recipients to access metrics in detail.`,position:`bottom`,isSingleLineTxt:!1,children:(0,i.jsx)(jy,{name:`info`})})]}),(0,i.jsxs)(ZZ,{className:`dbn:gap-2`,alignItems:`center`,children:[(0,i.jsx)(p$,{onChange:e=>{x(`isDownloadFile`,e)},enabled:!!S(`isDownloadFile`),placeholder:`Share Download file`,name:`isDownloadFile`}),(0,i.jsx)(uY,{text:`Share the files in the email, allowing recipients to download.`,position:`bottom`,isSingleLineTxt:!1,children:(0,i.jsx)(jy,{name:`info`})})]}),!!S(`isDownloadFile`)&&(0,i.jsx)(KV,{control:y,name:`downloadFileFormat`,rules:{validate:e=>e?!0:`Please select file format`},render:({field:e})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(vY,{label:`Download File Format`,selectedOption:iv.find(t=>e.value===t.value)||iv[0],options:iv,onChange:t=>{e.onChange(t?.value)},buttonWidth:`100%`,menuWidth:`100%`,isSearchEnabled:!0,isImportant:!0}),ie?.downloadFileFormat?.message&&(0,i.jsx)(xa,{variant:`body-text-2`,color:`alert`,children:`${ie?.downloadFileFormat?.message}`})]})}),je.length>0&&me&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(pX,{label:`Filters`,options:je,selectedOption:Me,onChange:e=>{x(`selectedFilterNames`,e||[]);let t={...Ne},n=(e||[]).map(e=>e.value);Object.keys(t).forEach(e=>{n.includes(e)||delete t[e]}),x(`scheduleFilters`,t)},buttonWidth:`100%`,menuWidth:`100%`,isSearchEnabled:!0}),Re.length>0&&(0,i.jsx)(kH,{appliedfilters:Pe,setAppliedFilters:Fe,filters:Re,internal:{isInternal:!0,workspaceId:se},datasourceId:ce,token:oe||``,encryptedClientId:le,clientId:fe[0]?.value??ae?.clientId,clientScopeValues:pe,isAllClient:d?.isDisableClient?!0:!fe.length&&ae?.isAllClient,isFrontendApp:!f,tenancyLevel:ue||`TABLE`,clientColumnType:de||`STRING`,theme:{width:`100%`,variant:`static`,radius:`6px`,datePickerFormat:``},layout:{clientLayout:[],adminLayout:[],isLocked:!0,onChange:()=>{}},isEditLayoutEnabled:!1,isMobileView:!0})]})]}),(0,i.jsx)(Xs,{type:`button`,variant:`popover`,leftIcon:(0,i.jsx)(`span`,{className:Se?``:`dbn:-rotate-90`,children:(0,i.jsx)(jy,{name:`caret-down-fill`})}),"data-testid":`schedule-page-setup-toggle`,onClick:()=>Ce(!Se),children:`Page Setup & Delivery`}),Se&&(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-3 dbn:border-b dbn:border-secondary dbn:pb-5`,children:[(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-1`,children:[(0,i.jsx)(vY,{label:`Orientation`,selectedOption:Ve.selectedOption,options:ze(Dce),onChange:e=>x(`orientation`,e?.value),buttonWidth:`100%`,menuWidth:`100%`}),(0,i.jsx)(xa,{variant:`small-text`,color:`gray`,children:Ve.hint})]}),(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-1`,children:[(0,i.jsx)(vY,{label:`Cards per page`,selectedOption:He.selectedOption,options:ze(Oce),onChange:e=>x(`density`,e?.value),buttonWidth:`100%`,menuWidth:`100%`}),(0,i.jsx)(xa,{variant:`small-text`,color:`gray`,children:He.hint})]}),(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-1`,children:[(0,i.jsx)(vY,{label:`Long tables`,selectedOption:Ue.selectedOption,options:ze(kce),onChange:e=>x(`tableMode`,e?.value),buttonWidth:`100%`,menuWidth:`100%`}),(0,i.jsx)(xa,{variant:`small-text`,color:`gray`,children:Ue.hint})]}),Ue.current===`paginate`&&(0,i.jsx)(SJ,{type:`number`,label:`Rows per table`,"data-testid":`schedule-row-cap`,min:1,max:5e3,register:b(`tableRowCap`,{setValueAs:e=>`${e??``}`.trim()===``?void 0:jce(Number(e))})}),(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-1`,children:[(0,i.jsx)(vY,{label:`Deliver as`,selectedOption:We.selectedOption,options:ze(Ace),onChange:e=>x(`deliveryMode`,e?.value),buttonWidth:`100%`,menuWidth:`100%`}),(0,i.jsx)(xa,{variant:`small-text`,color:`gray`,children:We.hint})]})]}),(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(`span`,{className:be?``:`dbn:-rotate-90`,children:(0,i.jsx)(jy,{name:`caret-down-fill`})}),onClick:()=>xe(!be),children:`Schedule Settings`}),be&&(0,i.jsxs)(ZZ,{direction:`col`,className:`dbn:gap-2 dbn:pb-5`,children:[` `,(0,i.jsx)(KV,{control:y,name:`frequency`,render:({field:e})=>(0,i.jsx)(vY,{label:`Frequency of emails`,options:nse,selectedOption:{value:e.value,label:e.value},onChange:t=>e.onChange(t.value),buttonWidth:`100%`,menuWidth:`100%`,isImportant:!0})}),(()=>{let e=S()?.frequency;return e===`oneTime`?(0,i.jsx)(w3,{label:`Date`,isEnableSingleDate:!0,minDate:new Date,isImportant:!0,onChange:e=>x(`oneTimeDate`,e),defaultValues:S()?.oneTimeDate?.startDate?{startDate:new Date(S()?.oneTimeDate?.startDate),endDate:new Date(S()?.oneTimeDate?.startDate),timeGrainValue:`between`}:void 0}):e===`Monthly`?(0,i.jsx)(`div`,{children:(0,i.jsx)(pX,{label:`Send on`,options:tse,selectedOption:S(`newDate`)?.length?S(`newDate`):[],onChange:e=>{x(`newDate`,e)},buttonWidth:`100%`,menuWidth:`100%`})}):e===`Daily`?null:(0,i.jsx)(`div`,{children:(0,i.jsx)(pX,{label:`Send on`,options:rv,selectedOption:rv?.filter(e=>S(`weekDays`)?.[e.value]),onChange:e=>{e?.length?rv?.forEach(t=>{x(`weekDays.${t.value}`,e?.some(e=>t.value===e?.value))}):rv?.forEach(e=>{x(`weekDays.${e.value}`,!1)})},buttonWidth:`100%`,menuWidth:`100%`})})})(),(0,i.jsxs)(`div`,{className:D9[`schedule-time`],children:[(0,i.jsxs)(xa,{variant:`input-label`,children:[`Scheduled Time`,(0,i.jsx)(`span`,{className:`dbn:text-alert`,children:`*`})]}),(0,i.jsxs)(`div`,{className:D9[`time-element`],"data-testid":`schedule-time`,children:[(0,i.jsx)(`div`,{className:D9[`time-hour-field`],children:(0,i.jsx)(SJ,{type:`number`,min:1,max:12,step:1,register:b(`hours`,kJ),defaultValue:5,error:ie.hours?.message,id:`hours`})}),(0,i.jsx)(`span`,{className:D9[`time-separator`],children:`:`}),(0,i.jsx)(`div`,{className:D9[`time-minute-field`],children:(0,i.jsx)(SJ,{type:`number`,min:0,max:59,step:1,register:b(`minutes`,{setValueAs:e=>{let t=`${e??``}`.trim();return t?t.padStart(2,`0`):`00`},validate:e=>{let t=Number(e??0);return!Number.isInteger(t)||t<0||t>59?`Minutes must be between 0 and 59`:!0}}),defaultValue:0,error:ie.minutes?.message,id:`minutes`})}),(0,i.jsx)(KV,{control:y,name:`time`,render:({field:e})=>(0,i.jsx)(`div`,{className:D9[`time-dropdown-field`],children:(0,i.jsx)(vY,{options:ese,selectedOption:{value:e.value,label:e.value},onChange:t=>e.onChange(t.value),buttonWidth:`96px`,menuWidth:`96px`,id:`am-pm`})})}),(0,i.jsx)(KV,{control:y,name:`timezone`,render:({field:e})=>(0,i.jsx)(`div`,{className:D9[`time-dropdown-field`],children:(0,i.jsx)(vY,{options:Qoe,selectedOption:{value:e.value,label:e.value},onChange:t=>e.onChange(t.value),buttonWidth:`96px`,menuWidth:`96px`,id:`timezone`})})})]})]})]}),T&&(0,i.jsx)(CV,{message:T}),ee&&(0,i.jsx)(xa,{variant:`body-text-2`,color:`success`,children:`Scheduled successfully!`}),re&&(0,i.jsx)(xa,{variant:`body-text-2`,color:`success`,children:`Deleted successfully!`})]})}),t&&(0,i.jsx)(ZZ,{direction:`row`,justify:`end`,className:`dbn:w-full dbn:border-t dbn:border-secondary dbn:py-3 dbn:h-[60px] dbn:px-5 dbn:items-center`,children:(0,i.jsxs)(ZZ,{className:`dbn:gap-2`,children:[r||te?(0,i.jsx)(Xs,{type:`button`,variant:`secondary`,onClick:()=>{Te({showDelete:!0,deleteFunction:ne})},isDisabled:w,className:`dbn:bg-gray dbn:border-secondary cta-secondary`,children:`Delete`}):(0,i.jsx)(Xs,{type:`reset`,variant:`tab`,onClick:()=>e(),isDisabled:w,className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{variant:`primary`,type:`submit`,isDisabled:w||!!Ee,className:`cta-primary`,children:r||te?`Update`:`Save`})]})}),!t&&(0,i.jsxs)(EJ,{children:[r||te?(0,i.jsx)(Xs,{type:`button`,variant:`secondary`,onClick:()=>{Te({showDelete:!0,deleteFunction:ne})},isDisabled:w,className:`cta-secondary`,children:`Delete`}):(0,i.jsx)(Xs,{type:`reset`,variant:`tab`,onClick:()=>e(),isDisabled:w,className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{variant:`primary`,type:`submit`,isDisabled:w,className:`cta-primary`,children:r||te?`Update`:`Save`})]}),(0,i.jsxs)(TJ,{customHeader:(0,i.jsxs)(`div`,{className:`dbn:w-full dbn:flex dbn:items-center dbn:justify-between`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:items-center dbn:gap-2`,children:[(0,i.jsx)(jy,{name:`delete`,color:`alert`}),`Irreversible action`]}),(0,i.jsx)(Xs,{variant:`tertiary`,type:`button`,onClick:()=>Te({showDelete:!1,deleteFunction:()=>{}}),leftIcon:(0,i.jsx)(jy,{name:`cross`,size:`sm`}),style:{padding:`0`,height:`20px`}})]}),size:`sm`,isOpen:we.showDelete,onClose:()=>Te({showDelete:!1,deleteFunction:()=>{}}),children:[(0,i.jsx)(`div`,{className:`dbn:pt-4 dbn:pb-8 dbn:pl-6`,children:(0,i.jsx)(ZZ,{justify:`start`,alignItems:`center`,className:`dbn:gap-2`,children:(0,i.jsx)(xa,{variant:`body-text-2`,children:`Are you sure you want to delete this schedule?`})})}),(0,i.jsx)(EJ,{className:`dbn:justify-between`,children:(0,i.jsxs)(`div`,{className:`dbn:ml-auto dbn:flex dbn:gap-4`,children:[(0,i.jsx)(Xs,{type:`reset`,size:`small`,variant:`tab`,onClick:()=>Te({showDelete:!1,deleteFunction:()=>{}}),className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{type:`button`,size:`small`,variant:`primary`,onClick:()=>{we.deleteFunction(),Te({showDelete:!1,deleteFunction:()=>{}})},className:`dbn:bg-alert dbn:hover:bg-discard-hover cta-primary`,children:`Delete`})]})})]})]})})}})),Bwr=_({ScheduleEmail:()=>Vwr,default:()=>Vwr}),Vwr,Hwr=h((()=>{R9(),my(),sr(),Dc(),KK(),Bc(),xwr(),qX(),zwr(),Vwr=({props:{chartOptions:e,getInternalToken:t,externalDashboardId:r,sharingSettingsId:a,onComplete:o,isShowSettings:s,setShowSettings:l,onServerEvent:u,isEmbed:d}})=>{let{token:f,data:p}=Ec(),[m,h]=(0,n.useState)(),[g,_]=(0,n.useState)(!1),[v,y]=(0,n.useState)({isShowDelete:!1,deleteRowId:``}),b=()=>y({isShowDelete:!1,deleteRowId:``}),{mutate:x}=BGt(),S=(0,n.useMemo)(()=>[{name:`REPORT TITLE`,columnKey:`name`,columnCell:e=>(0,i.jsx)(`div`,{className:`dbn:w-[120px] dbn:truncate`,title:e?.subject,children:e?.subject})},{name:`RECIPIENT`,columnKey:`isAuthenticated`,columnCell:e=>(0,i.jsxs)(`div`,{className:`dbn:w-[180px] dbn:flex dbn:gap-0.5 dbn:items-center`,children:[(0,i.jsx)(`span`,{className:`dbn:truncate dbn:bg-[#DBEAFE] dbn:rounded-md dbn:py-1 dbn:px-2 dbn:text-xs dbn:font-medium ${e?.emails?.length>1?`dbn:max-w-[150px]`:`dbn:max-w-[180px]`}`,children:e?.emails?.[0]}),e?.emails?.length>1?(0,i.jsx)(`span`,{className:`dbn:w-auto dbn:bg-[#DBEAFE] dbn:rounded-md dbn:py-1 dbn:px-2 dbn:text-xs dbn:font-medium`,children:`+${e?.emails?.length-1}`}):null]})},{name:`SCHEDULED FOR`,columnKey:`delete`,columnCell:e=>{let t=``,n=Qoe?.find(t=>t?.value===e?.timeConfigurations?.timezone)?.label;if(e?.timeConfigurations?.frequency===`Weekly`){let r=e?.timeConfigurations?.weekDays,i=Object.keys(r).filter(e=>r[e]);t=`${i?.length?`Every ${i?.join(`, `)}, `:``}${e?.timeConfigurations?.hours?`${e?.timeConfigurations?.hours}:${`${e?.timeConfigurations?.minutes??`0`}`.padStart(2,`0`)} ${e?.timeConfigurations?.time}`:``} ${n}`}return e?.timeConfigurations?.frequency===`Monthly`&&(t=`Every Month, ${e?.timeConfigurations?.hours?`${e?.timeConfigurations?.hours}:${`${e?.timeConfigurations?.minutes??`0`}`.padStart(2,`0`)} ${e?.timeConfigurations?.time}`:``} ${n}`),e?.timeConfigurations?.frequency===`Daily`&&(t=`Daily, ${e?.timeConfigurations?.hours?`${e?.timeConfigurations?.hours}:${`${e?.timeConfigurations?.minutes??`0`}`.padStart(2,`0`)} ${e?.timeConfigurations?.time}`:``} ${n}`),e?.timeConfigurations?.frequency===`oneTime`&&(t=`${new Date(e?.timeConfigurations?.oneTimeDate?.startDate).toDateString().slice(4)}, ${e?.timeConfigurations?.hours?`${e?.timeConfigurations?.hours}:${`${e?.timeConfigurations?.minutes??`0`}`.padStart(2,`0`)} ${e?.timeConfigurations?.time}`:``} ${n}`),(0,i.jsxs)(`div`,{className:`dbn:w-[180px] dbn:flex dbn:gap-2`,children:[(0,i.jsx)(`span`,{className:`dbn:w-[170px] dbn:truncate`,title:t,children:t}),(0,i.jsx)(`div`,{role:`button`,tabIndex:0,onKeyDown:()=>{},onClick:e=>e.stopPropagation(),children:(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`popover`,children:(0,i.jsx)(jy,{name:`kebab-menu-horizontal`})}),position:`bottom`,tabMenu:!0,children:(0,i.jsx)(Xs,{variant:`tertiary`,className:`dbn:text-alert dn-p-5 dbn:justify-start dbn:hover:bg-gray`,onClick:()=>y({isShowDelete:!0,deleteRowId:e.id,subject:e?.subject,emails:Array.isArray(e?.emails)?e.emails:[]}),fitContainer:!0,children:`Delete`})})})]})}}],[x,o]),{data:C,isLoading:w,refetch:T,isFetching:ee}=Lc(f||``,r||``,p?.embedDataAppId||null),te=v.emails?.length||0,ne=(0,n.useMemo)(()=>{let e=v.subject?.trim(),t=e?`"${e}"`:`this schedule`;return te?`Delete ${t}? ${te} ${te===1?`recipient`:`recipients`} stop receiving this report, and it cannot be restored.`:`Delete ${t}? It stops being sent, and it cannot be restored.`},[v.subject,te]),re=(0,n.useMemo)(()=>C?.scheduleEmailReports?.length&&C?.scheduleEmailReports||[],[C]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(oQ,{isOpen:s,onClose:()=>{u?.(Bn),l(!1)},hideHeader:!0,size:`wide`,side:`right`,hideFooter:!0,icon:(0,i.jsx)(jy,{name:`schedule`}),dataTestTitle:`schedulePanel`,children:(0,i.jsxs)(ZZ,{className:`dbn:pt-5 dbn:gap-2 dbn:w-full dbn:h-full`,direction:`col`,children:[(0,i.jsxs)(ZZ,{className:`dbn:w-full dbn:px-5`,alignItems:`center`,justify:`between`,children:[(0,i.jsxs)(ZZ,{className:`dbn:gap-1.5`,alignItems:`start`,direction:`col`,children:[(0,i.jsxs)(ZZ,{className:`dbn:gap-2`,alignItems:`center`,children:[g?(0,i.jsx)(Xs,{variant:`tab`,leftIcon:(0,i.jsx)(jy,{name:`arrow-left`}),onClick:()=>{_(!1)},className:`cta-tertiary`}):(0,i.jsx)(jy,{name:`schedule`}),(0,i.jsx)(xa,{variant:`heading-4`,children:g?`Create a Schedule`:`Report Scheduler`})]}),g?null:(0,i.jsx)(xa,{variant:`body-text-3`,color:`gray`,children:`Manage report schedules for this dashboard.`})]}),g?null:(0,i.jsxs)(ZZ,{className:`dbn:gap-4`,alignItems:`center`,children:[re.length>0?(0,i.jsx)(Xs,{variant:`secondary`,leftIcon:(0,i.jsx)(jy,{name:`plus`,size:`sm`}),onClick:()=>{h(void 0),_(!0)},size:`small`,isDisabled:w||ee,className:`cta-secondary`,children:`Schedule`}):null,(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(jy,{name:`cross`,size:`xs`}),onClick:()=>{h(void 0),_(!1),l(!1)}})]})]}),g?null:(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:p-5`,children:w||ee?(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:flex dbn:items-center dbn:justify-center`,children:(0,i.jsx)(D6,{})}):re?.length?(0,i.jsx)(`div`,{className:`dbn:max-w-full dbn:w-auto`,children:(0,i.jsx)(bwr,{data:re,headers:S,onRowClick:e=>{h(e),_(!0)}})}):(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:border dbn:border-secondary dbn:flex dbn:items-center dbn:justify-center`,children:(0,i.jsx)(KX,{message:`No schedules created yet.`,subText:`Set up a schedule to automatically send your reports.`,isNoReports:!0,children:(0,i.jsx)(Xs,{variant:`primary`,leftIcon:(0,i.jsx)(jy,{name:`plus`,size:`sm`}),onClick:()=>{h(void 0),_(!0)},size:`small`,className:`cta-primary`,children:`Schedule`})})})}),g&&(0,i.jsx)(Rwr,{onCancel:()=>{u?.(`EXIT_SCHEDULED_REPORT_MODE`),l(!1)},chartOptions:e,getInternalToken:t,scheduleReportConfig:m,externalDashboardId:r,sharingSettingsId:a,onComplete:()=>{o?.(),l(!1),_(!1),h(void 0),T()},isEmbed:d})]})}),(0,i.jsxs)(TJ,{customHeader:(0,i.jsxs)(`div`,{className:`dbn:w-full dbn:flex dbn:items-center dbn:justify-between`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:items-center dbn:gap-2`,children:[(0,i.jsx)(jy,{name:`delete`,color:`alert`}),`Irreversible action`]}),(0,i.jsx)(Xs,{variant:`tertiary`,type:`button`,onClick:b,leftIcon:(0,i.jsx)(jy,{name:`cross`,size:`sm`}),style:{padding:`0`,height:`20px`}})]}),size:`sm`,isOpen:v?.isShowDelete,onClose:b,children:[(0,i.jsx)(`div`,{className:`dbn:pt-4 dbn:pb-8 dbn:pl-6 dbn:pr-6`,children:(0,i.jsxs)(ZZ,{justify:`start`,alignItems:`start`,className:`dbn:gap-2 dbn:flex-col`,children:[(0,i.jsx)(xa,{variant:`body-text-2`,children:ne}),te>0&&te<=5?(0,i.jsx)(xa,{variant:`body-text-3`,color:`sec-text`,children:(v.emails||[]).join(`, `)}):null]})}),(0,i.jsx)(EJ,{className:`dbn:justify-between`,children:(0,i.jsxs)(`div`,{className:`dbn:ml-auto dbn:flex dbn:gap-4`,children:[(0,i.jsx)(Xs,{type:`reset`,size:`small`,variant:`tab`,onClick:b,className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{type:`button`,size:`small`,variant:`primary`,onClick:()=>{x({id:v?.deleteRowId,token:f},{onSuccess(){T(),o?.(),l(!1),b()}}),b()},className:`dbn:bg-alert dbn:hover:bg-discard-hover cta-primary`,children:`Delete`})]})})]})]})}})),Uwr=h((()=>{})),Wwr=h((()=>{})),Gwr=h((()=>{})),Kwr=h((()=>{})),qwr,Jwr,Ywr,Xwr,Zwr,Qwr,$wr,O9,eTr=h((()=>{qwr=`_manageMetricCard_g7m0a_8`,Jwr=`_borderPrimary_g7m0a_12`,Ywr=`_manageMetricContainer_g7m0a_16`,Xwr=`_cardContainer_g7m0a_20`,Zwr=`_metricName_g7m0a_24`,Qwr=`_chart_g7m0a_28`,$wr=`_manageButton_g7m0a_32`,O9={manageMetricCard:qwr,borderPrimary:Jwr,manageMetricContainer:Ywr,cardContainer:Xwr,metricName:Zwr,chart:Qwr,manageButton:$wr}})),k9,tTr=h((()=>{Ge(),eTr(),qi(),R9(),my(),lJ(),xV(),IQn(),bin(),k9=({metricItem:e,client:t,colors:r,companyTenancyType:a,isInternalApp:o,isFrontendApp:s,guestToken:l,encryptedClient:u,workspaceId:d,chartAppearance:f,datasourceId:p,language:m,translationDictionary:h,dataMartTables:g,token:_,param:v,globalFilters:y={tableName:``,filters:[]}})=>{let b=(0,n.useMemo)(()=>({...y,filters:y?.filters?.filter(t=>!t?.restrictedMetrics?.some(t=>t.value===e?.id))}),[y,e]),{dataDb:x,isQueryLoading:S,chartParams:C,drilledLevel:w,dimensions:T,dynamicOptions:ee,isSingleValueNull:te,chartSettings:ne,pivotDrillState:re,isPythonMode:ie,variables:ae,queryError:oe}=cJ({dataMartTables:g,datasourceId:p,metric:e,clientId:t,globalFilters:b,rlsFilters:v,tenancyLevel:a,isInternalApp:o,isAllClient:!1,isFrontendApp:s,guestToken:l,encryptedClientId:u,workspaceId:d,language:m,translationDictionary:h,token:_}),se=(0,n.useMemo)(()=>ne?.chartType===$.table?{...ne,yAxisList:(ne?.yAxisList?.length||0)>10?ne?.yAxisList?.slice(0,5):ne?.yAxisList}:ne,[ne]),le=(0,n.useMemo)(()=>{let t=TS({chartSettings:ne,translationDictionary:h,variables:ae,language:m});return e?.drillDownSettings?.isEnableGroupBy&&x.length&&w===T?.length&&(t={...t,chartType:`table`,yAxisList:T?.[0]?[T?.[0],...se.yAxisList||[]]:se.yAxisList}),t},[e?.drillDownSettings?.isEnableGroupBy,x.length,w,T,se,ae,m,h,ee]),ue=(0,n.useMemo)(()=>oe?ce(oe,{fallback:`This metric couldn't load.`}):void 0,[oe]),de=ue?he(ue):``;return Ki(`metric_list`,ue,{metricId:e?.metricId??e?.id}),(0,i.jsx)(`div`,{className:O9.cardContainer,children:e?.isMetric?(0,i.jsx)(`div`,{className:O9.chart,children:S?(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:py-4`,children:(0,i.jsx)(E3,{height:`full`})}):x?.length&&!te?(0,i.jsx)(Q5,{isDashboard:!0,language:m,translationDictionary:h,variables:ae,isPythonMode:ie,chartAppearance:f,pivotDrillState:re,seriesName:C?.seriesName,data:x,chartOptions:{...le,legendSettings:{...le?.legendSettings,show:!1,position:`hidden`}},colors:r||ne.chartColors,config:{hideBorder:!0}}):oe?(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:flex dbn:flex-col dbn:justify-center dbn:items-center`,children:(0,i.jsxs)(`div`,{className:` dbn:flex dbn:flex-col dbn:items-center dbn:gap-2`,children:[(0,i.jsx)(`img`,{src:yin,alt:`no data`,width:100,height:100}),(0,i.jsx)(`div`,{className:`dbn:text-center`,children:(0,i.jsx)(xa,{opacity:.7,variant:`body-text-2`,children:de})})]})}):(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:flex dbn:flex-col dbn:justify-center dbn:items-center`,children:(0,i.jsxs)(`div`,{className:` dbn:flex dbn:flex-col dbn:items-center dbn:gap-2`,children:[(0,i.jsx)(`img`,{src:FQn,alt:`no data`,width:100,height:100}),(0,i.jsx)(xa,{opacity:.7,variant:`body-text-2`,children:`No data available`})]})})}):(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-full dbn:flex dbn:flex-col dbn:justify-center dbn:items-center`,children:(0,i.jsxs)(`div`,{className:` dbn:flex dbn:flex-col dbn:items-center dbn:gap-2`,children:[(0,i.jsx)(`img`,{src:FQn,alt:`no data`,width:100,height:100}),(0,i.jsx)(xa,{opacity:.7,variant:`body-text-2`,children:`Element preview not supported here`})]})})})}})),A9,nTr,rTr,iTr,aTr,oTr,sTr,cTr,lTr=h((()=>{WK(),A9=e=>(e||``).trim().toLowerCase(),nTr=e=>{let t=A9(e),n=A9(_x(e).name);return Array.from(new Set([t,n].filter(Boolean)))},rTr=e=>{let t=e.tableName||``,n=e.schemaName?`${e.schemaName}.${t}`:t;return Array.from(new Set([...nTr(n),...nTr(t)].filter(Boolean)))},iTr=e=>{let t=e.tableName||``,n=e.schemaName?`${e.schemaName}.${t}`:t;return Array.from(new Set([n,t].map(A9).filter(Boolean)))},aTr=e=>Array.from(new Set([e.name,e.applyOnTables?.[0]?.columnName].map(A9).filter(Boolean))),oTr=e=>{let t=aTr(e),n=A9(e.labelColumnName);return[t,...n?[[n]]:[]].filter(e=>e.length)},sTr=({column:e,isSchemaAccessLoaded:t=!1,tableName:n,tenancyLevel:r,schemaList:i})=>{if(!i.length)return!t;let a=e.selectedTable||e.applyOnTables?.[0]?.tableName||n,o=A9(a),s=!!_x(a).prefix,l=nTr(a),u=i.find(t=>{if(s){if(e.isCreatedByClient&&r===`DATABASE`){let e=rTr(t);return l.some(t=>e.includes(t))}return iTr(t).includes(o)}let n=rTr(t);return l.some(e=>n.includes(e))});if(!u)return!1;let d=new Set(u.columnsWithDataType?.flatMap(e=>[e.name,e.label,e.as]).map(A9).filter(Boolean)),f=oTr(e);return!!f.length&&f.every(e=>e.some(e=>d.has(e)))},cTr=({tableList:e,clientColumnType:t})=>e?.map((e,n)=>{let r=e?.tableName||e?.name||``,i=e?.schemaName||e?.schema||``,a=e?.columns?.filter(e=>e?.isAllowDashboardFilter!==!1)?.map(n=>({as:n?.as||n?.dataType||n?.datatype||``,dataType:n?.dataType||n?.datatype||n?.as||``,name:n?.name||n?.columnName||``,label:n?.label||n?.as||n?.name||n?.columnName||``,clientColumn:e?.clientColumn||n?.clientColumn,clientColumnType:e?.clientColumnType||n?.clientColumnType||t}))||[];return{id:e?.id||`${i}.${r}.${n}`,schemaName:i,tableName:r,columns:a.map(e=>e.name),columnsWithDataType:a}})?.filter(e=>e.tableName&&e.columnsWithDataType.length)||[]})),uTr,dTr,fTr,pTr,mTr,hTr,gTr,_Tr,vTr,yTr,bTr,xTr,STr,CTr,wTr,TTr,j9,ETr=h((()=>{uTr=`_form_p3boz_8`,dTr=`_triggerButton_p3boz_18`,fTr=`_body_p3boz_22`,pTr=`_field_p3boz_31`,mTr=`_row_p3boz_35`,hTr=`_section_p3boz_42`,gTr=`_advancedSection_p3boz_47`,_Tr=`_collapsedCaret_p3boz_55`,vTr=`_options_p3boz_60`,yTr=`_presetOptions_p3boz_66`,bTr=`_presetOption_p3boz_66`,xTr=`_saveAsRow_p3boz_82`,STr=`_addPresetOption_p3boz_89`,CTr=`_footer_p3boz_104`,wTr=`_error_p3boz_113`,TTr=`_hint_p3boz_126`,j9={form:uTr,triggerButton:dTr,body:fTr,field:pTr,row:mTr,section:hTr,advancedSection:gTr,collapsedCaret:_Tr,options:vTr,presetOptions:yTr,presetOption:bTr,saveAsRow:xTr,addPresetOption:STr,footer:CTr,error:wTr,hint:TTr}})),DTr,OTr,kTr,ATr,jTr,M9,N9,P9,F9,MTr,I9,NTr,L9,PTr,FTr,ITr,LTr,RTr=h((()=>{R9(),KK(),my(),lTr(),WK(),WB(),ETr(),DTr=[`auto`,`number`,`date`],OTr=`TABLE`,kTr=Rse.filter(e=>DTr.includes(e.value)),ATr=Mv,jTr=Vse,M9=Hse,N9=Dv,P9=Ov.filter(e=>e.value!==`NONE`),F9=zse,MTr=Bse,I9={value:``,label:``},NTr=e=>e?.map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})||[],L9=e=>({label:e.schemaName?`${e.schemaName}.${e.tableName}`:e.tableName,value:e.schemaName?`${e.schemaName}.${e.tableName}`:e.tableName}),PTr=(e,t)=>{let n=t||e[0]?.selectedTable||``;return n?[{tableName:n,columns:e.map(e=>({...e,selectedTable:e.selectedTable||n}))}]:[]},FTr=({selectedColumn:e,selectedTable:t,clientColumnType:n})=>{let r=t?.columnsWithDataType?.find(e=>e.clientColumn)||void 0;return{clientColumn:e?.clientColumn||r?.clientColumn||``,clientColumnType:e?.clientColumnType||r?.clientColumnType||n||``}},ITr=e=>e?.length?e.map(e=>({...e,type:e.type||N9[0],interval:e.interval?.toString?.()||`1`,timeGrain:$ut(e.timeGrain,P9),label:e.label||``})):[{type:N9[0],interval:`1`,timeGrain:P9[0],label:``}],LTr=({dashboard:e,schemaList:t,isSchemaAccessLoaded:r=!1,token:a,clientId:o,clientColumnType:s,tenancyLevel:l,filterToEdit:u,onCancel:d,onSuccess:f})=>{let p=ZGt(),[m,h]=(0,n.useState)(``),[g,_]=(0,n.useState)(`auto`),[v,y]=(0,n.useState)(ATr[0]),[b,x]=(0,n.useState)(jTr[0]),[S,C]=(0,n.useState)(M9[0]),[w,T]=(0,n.useState)([{type:N9[0],interval:`1`,timeGrain:P9[0],label:``}]),[ee,te]=(0,n.useState)(F9[0]),[ne,re]=(0,n.useState)(I9),[ie,ae]=(0,n.useState)({min:null,max:null}),[oe,se]=(0,n.useState)(),[ce,le]=(0,n.useState)(I9),[ue,de]=(0,n.useState)(I9),[fe,pe]=(0,n.useState)(I9),[me,he]=(0,n.useState)(!0),[ge,_e]=(0,n.useState)(!1),[ve,ye]=(0,n.useState)(!1),[be,xe]=(0,n.useState)(!1),[Se,Ce]=(0,n.useState)(!1),[we,Te]=(0,n.useState)(!1),[Ee,De]=(0,n.useState)(``),Oe=(0,n.useMemo)(()=>t.map(e=>L9(e)),[t]),Ae=(0,n.useMemo)(()=>t.find(e=>L9(e).value===ce.value),[t,ce.value]),je=(0,n.useMemo)(()=>Ae?.columnsWithDataType?.map(e=>({label:e.label||e.name,value:`${e.dataType||e.as||``}--${e.name}`}))||[],[Ae]),Me=(0,n.useMemo)(()=>{let e=ue.value.split(`--`)[1];return Ae?.columnsWithDataType?.find(t=>t.name===e)},[ue.value,Ae]),Ne=(0,n.useMemo)(()=>FTr({selectedColumn:Me,selectedTable:Ae,clientColumnType:s}),[s,Me,Ae]);(0,n.useEffect)(()=>{if(!u)return;let e=t.find(e=>{let t=L9(e),n=Ve(t.value);return t.value===u.selectedTable||n===u.selectedTable||e.tableName===u.selectedTable}),n=e?.columnsWithDataType?.find(e=>e.name===u.name),r=u.labelColumnName?e?.columnsWithDataType?.find(e=>e.name===u.labelColumnName):void 0,i=u.filterType===`number`?`number`:u.filterType===`date`?`date`:`auto`;h(u.label||u.name||``),_(i),y(u.filterVariant||ATr[0]),x(u.dateVariant||jTr[0]),C(u.dateSelectionType||M9[0]),T(ITr(u.datePresetOptions)),te(u.autoSelectType||(u.filterVariant?.value===`IN`?MTr[0]:F9[0]));let a=Array.isArray(u.defaultValue)?u.defaultValue[0]:u.defaultValue;re(typeof a==`object`&&a&&`value`in a&&`label`in a?a:a?{value:a,label:a}:I9),ae(BB(u.defaultValue)),se(VB(u.defaultValue)),le(e?L9(e):I9),de(n?{label:n.label||n.name,value:`${n.dataType||n.as||``}--${n.name}`}:I9),pe(r?{label:r.label||r.name,value:`${r.dataType||r.as||``}--${r.name}`}:I9),he(!!u.isEnableClearSelection),_e(!!u.isAllowSorting),ye(!!u.isAutoSelectFilterValue),xe(!!u.isSelectAllMultiSelectOptions),Ce(!!u.isSelectAllMultiSelect),Te(!1)},[u,t]);let Pe=(0,n.useMemo)(()=>NTr(Me?.options||Me?.manualOptions),[Me]),Fe=(0,n.useMemo)(()=>w.map(e=>({value:e.label.trim(),label:e.label.trim(),presetDateOption:e})).filter(e=>e.value),[w]),Ie=v.value===`IN`?MTr:F9,Le=(e,t)=>{T(n=>n.map((n,r)=>r===e?{...n,...t}:n))},Re=()=>{T(e=>[...e,{type:N9[0],interval:`1`,timeGrain:P9[0],label:``}])},ze=e=>{T(t=>t.filter((t,n)=>n!==e))},Be=e=>{le(e),de(I9),pe(I9),re(I9),ae({min:null,max:null}),se(void 0)},Ve=e=>l!==`DATABASE`||!o?e:`${o}.${_x(e).name}`,He=()=>{if(!Ae||!Me)return;let e=Me.name,t=g===`auto`,n=g===`date`,r=t?`string`:n?`date`:g===`number`?`number`:Xut(Me.dataType,Me.as),i=rdt({filterType:g,autoVariant:v,dateVariant:b,isAutoSelectFilterValue:ve,selectedDefaultValue:ne,selectedRangeDefaultValue:ie,selectedDateDefaultValue:oe}),a=Ve(ce.value),s=Ne.clientColumn,l=Ne.clientColumnType;return odt({id:u?.id,filterType:g,selectedTable:a,dataType:Me.dataType||``,name:e,columnName:e,labelColumnToken:t?fe.value:``,as:r,isDefault:!1,isShowHorizontal:!0,label:m.trim()||Me.label||e,defaultValue:i,isCreatedByClient:!0,clientId:o,isClientScoped:!!o||!!s,clientColumn:s,clientColumnType:l,applyOnTables:adt({tableName:a,columnName:e,dataType:Me.dataType}),filterVariant:t?v:I9,isAutoSelectFilterValue:t||n&&b.value===`preset`?ve:!1,isSelectAllMultiSelectOptions:t&&v.value===`IN`?be:!1,isSelectAllMultiSelect:t&&v.value===`IN`?Se:!1,isEnableClearSelection:t&&v.value!==`like`||n&&b.value===`preset`?me:!1,isAllowSorting:t&&v.value!==`like`||n&&b.value===`preset`?ge:!1,isAppFilter:!1,dateVariant:n?b:void 0,dateSelectionType:n&&b.value===`selection`?S:void 0,datePresetOptions:n&&b.value===`preset`?w:void 0,autoSelectType:ve&&(t&&v.value!==`like`||n&&b.value===`preset`)?ee:void 0,autoSelectCount:v.value===`IN`?1:void 0})},Ue=async()=>{if(De(``),!m.trim()){De(`Please enter a filter name.`);return}let n=He();if(!e?.id||!Ae||!n){De(`Please complete all required fields.`);return}if(g===`number`){let e=Qut(ie);if(e){De(e);return}}if(!o){De(`Dashboard filters can be created only for a specific client.`);return}if(!Zut({filterType:g,dataType:Me?.dataType,fallback:Me?.as})){if(g===`number`){De(`Range filter can be created only for numeric columns.`);return}De(`Date filter can be created only for date/time columns.`);return}if(l===OTr&&(!Ne.clientColumn||!Ne.clientColumnType)){De(`Client column mapping is missing for this table.`);return}if(g===`date`&&b.value===`preset`){let e=w.findIndex(e=>{if(!e.label.trim())return!0;if(![`last`,`next`].includes(e.type?.value||``))return!1;let t=Number(e.interval);return!Number.isFinite(t)||!Number.isInteger(t)||t<1});if(e>=0){let t=w[e];De(t?.label.trim()?`"${t.label.trim()}" needs a time interval of 1 or more.`:`Preset ${e+1} needs a name in "Save As".`);return}}if(e.filters?.flatMap(e=>e.columns||[])?.some(e=>e.label===n.label&&e.id!==n.id)){De(`Filter name already exists.`);return}let i=e.filters?.flatMap(e=>(e.columns||[]).filter(i=>i.isCreatedByClient&&i.clientId===o&&i.id!==n.id&&sTr({column:i,isSchemaAccessLoaded:r,tableName:e.tableName,tenancyLevel:l,schemaList:t})).map(t=>({...t,selectedTable:t.selectedTable||e.tableName})))||[],s=PTr([...i,n],e.filters?.[0]?.tableName||n.selectedTable||``);try{await p.mutateAsync({token:a,data:{externalDashboard:e.id,filters:s}}),f()}catch(e){De(e?.message||`Unable to save dashboard filter.`)}},We=g===`auto`&&v.value!==`like`,Ge=g===`date`&&b.value===`preset`,Ke=g===`date`&&b.value===`selection`,qe=(We||Ge)&&ve,Je=(We||Ge)&&!ve,Ye=g===`number`,Xe=Ge?Fe:Pe,Ze=Je||Ye||Ke,Qe=g===`auto`&&v.value!==`like`||Ge,$e=!!m.trim(),et=p.error?.message,tt=Ee||et,nt=!$e||!Me;return(0,i.jsxs)(`div`,{className:j9.form,children:[(0,i.jsxs)(`div`,{className:j9.body,children:[nt?(0,i.jsx)(o$,{variant:`info`,text:`Please complete all required fields to configure the filter.`}):null,(0,i.jsx)(SJ,{label:`Filter Name`,placeholder:`eg: order purchased`,value:m,onChange:e=>{h(e.target.value),De(``)},isImportant:!0}),$e?null:(0,i.jsx)(`div`,{className:j9.hint,children:`Enter a filter name to choose an option type and configure the filter.`}),(0,i.jsxs)(`div`,{className:j9.row,children:[(0,i.jsx)(`div`,{className:j9.field,children:(0,i.jsx)(ZX,{label:`Option Type`,options:kTr,selectedOption:kTr.find(e=>e.value===g)||kTr[0],onChange:e=>{_(e.value),re(I9),ae({min:null,max:null}),se(void 0),Te(!1)},size:`small`,isimportant:!0,isDisabled:!$e})}),g===`auto`&&(0,i.jsx)(`div`,{className:j9.field,children:(0,i.jsx)(ZX,{label:`Filter Variant`,options:ATr,selectedOption:v,onChange:e=>{y(e),re(I9),te(e.value===`IN`?MTr[0]:F9[0])},size:`small`,isimportant:!0,isDisabled:!$e})}),g===`date`&&(0,i.jsx)(`div`,{className:j9.field,children:(0,i.jsx)(ZX,{label:`Filter Variant`,options:jTr,selectedOption:b,onChange:e=>{x(e),re(I9),se(void 0)},size:`small`,isimportant:!0,isDisabled:!$e})})]}),g===`date`&&b.value===`selection`&&(0,i.jsx)(`div`,{className:j9.field,children:(0,i.jsx)(vY,{label:`Date Selection`,selectedOption:S,options:M9,onChange:e=>{C(e),se(void 0)},buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e})}),g===`date`&&b.value===`preset`&&(0,i.jsx)(`div`,{className:j9.section,children:(0,i.jsxs)(`div`,{className:j9.presetOptions,children:[w.map((e,t)=>(0,i.jsx)(`div`,{className:j9.presetOption,children:(()=>{let n=e.type?.value===`custom`,r=[`last`,`next`].includes(e.type?.value||``);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ZX,{label:`Filter Range`,options:N9,selectedOption:e.type,onChange:n=>Le(t,{type:n,customType:n.value===`custom`?e.customType||M9[0]:e.customType}),size:`small`,isimportant:!0,isDisabled:!$e}),n?(0,i.jsxs)(`div`,{className:j9.row,children:[(0,i.jsx)(vY,{label:`Date Variant`,selectedOption:e.customType||M9[0],options:M9,onChange:e=>Le(t,{customType:e}),buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e,isImportant:!0}),(0,i.jsx)(w3,{label:e.customType?.value===`singleDate`?`Set Date`:`Set Range`,isEnableSingleDate:e.customType?.value===`singleDate`,defaultValues:e.customDate?.startDate&&e.customDate?.endDate?{startDate:e.customDate.startDate,endDate:e.customDate.endDate,timeGrainValue:e.customDate.timeGrainValue}:void 0,onChange:e=>Le(t,{customDate:e})})]}):(0,i.jsxs)(`div`,{className:j9.row,children:[r?(0,i.jsx)(SJ,{label:`Time Interval`,type:`number`,value:e.interval,onChange:e=>Le(t,{interval:e.target.value}),isDisabled:!$e,isImportant:!0}):null,(0,i.jsx)(vY,{label:`Time Grain`,selectedOption:e.timeGrain,options:P9,onChange:e=>Le(t,{timeGrain:e}),buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e,isImportant:!0})]}),(0,i.jsxs)(`div`,{className:j9.saveAsRow,children:[(0,i.jsx)(SJ,{label:`Save As`,value:e.label,onChange:e=>Le(t,{label:e.target.value}),isDisabled:!$e,isImportant:!0}),w.length>1?(0,i.jsx)(Xs,{variant:`tertiary`,onClick:()=>ze(t),isDisabled:!$e,children:(0,i.jsx)(jy,{name:`delete`})}):null]})]})})()},`date-preset-option-${t}`)),(0,i.jsx)(`div`,{className:j9.addPresetOption,children:(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(jy,{name:`plus`}),onClick:Re,isDisabled:!$e,children:`Add option`})})]})}),(0,i.jsx)(`div`,{className:j9.section,children:(0,i.jsx)(vY,{label:`Dataset`,isImportant:!0,placeholder:`Select a Table`,selectedOption:ce,options:Oe,onChange:Be,isSearchEnabled:!0,buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e})}),(0,i.jsxs)(`div`,{className:j9.row,children:[(0,i.jsx)(`div`,{className:j9.field,children:(0,i.jsx)(vY,{label:`Choose a Column`,isImportant:!0,placeholder:`Select a column`,selectedOption:ue,options:je,onChange:e=>{de(e),re(I9),ae({min:null,max:null}),se(void 0)},isSearchEnabled:!0,buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e||!Ae})}),g===`auto`?(0,i.jsx)(`div`,{className:j9.field,children:(0,i.jsx)(vY,{label:`Choose a Unique Label Column`,placeholder:`Select a label column`,selectedOption:fe,options:je,onChange:pe,isSearchEnabled:!0,isClearEnabled:!0,buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e||!Ae})}):null]}),(Qe||Ze||g===`date`)&&(0,i.jsxs)(`div`,{className:j9.advancedSection,children:[(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(`span`,{className:we?``:j9.collapsedCaret,children:(0,i.jsx)(jy,{name:`caret-down-fill`})}),onClick:()=>Te(!we),isDisabled:!$e,children:`Advanced Options`}),we?(0,i.jsxs)(`div`,{className:j9.options,children:[g===`auto`&&v.value===`IN`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p$,{name:`dashboard-filter-show-select-all`,placeholder:`Show 'Select All'`,enabled:Se,onChange:Ce,isDisabled:!$e}),(0,i.jsx)(p$,{name:`dashboard-filter-auto-select-all`,placeholder:`Auto Select All Options`,enabled:be,onChange:xe,isDisabled:!$e})]}),Qe&&(0,i.jsx)(p$,{name:`dashboard-filter-enable-clear`,placeholder:`Enable the Clear Filter Option`,enabled:me,onChange:he,isDisabled:!$e}),Qe&&(0,i.jsx)(p$,{name:`dashboard-filter-allow-sorting`,placeholder:`Allow Sorting`,enabled:ge,onChange:_e,isDisabled:!$e}),We||Ge?(0,i.jsx)(p$,{name:`dashboard-filter-auto-select-default`,placeholder:`Auto-Select the Default Value`,enabled:ve,onChange:e=>{ye(e),e&&re(I9)},isDisabled:!$e}):null,qe&&(0,i.jsx)(vY,{label:`Auto Select Type`,selectedOption:ee,options:Ie,onChange:te,buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e}),Je&&(0,i.jsx)(vY,{label:`Default Value`,placeholder:`Default Value Dropdown`,selectedOption:ne,options:Xe,onChange:re,isSearchEnabled:!0,isClearEnabled:!0,buttonWidth:`100%`,menuWidth:`100%`,isDisabled:!$e}),Ye&&(0,i.jsx)(DH,{label:`Default Value`,defaultValues:ie,onChange:e=>ae(e||{min:null,max:null}),buttonWidth:`100%`,isDisabled:!$e}),Ke&&(0,i.jsx)(w3,{label:`Default Value`,isEnableSingleDate:S.value===`singleDate`,defaultValues:oe?.startDate&&oe?.endDate?{startDate:oe.startDate,endDate:oe.endDate,timeGrainValue:oe.timeGrainValue||`between`}:void 0,onChange:se,buttonWidth:`100%`,isDisabled:!$e,isImportant:!0})]}):null]}),tt?(0,i.jsx)(`div`,{className:j9.error,children:tt}):null]}),(0,i.jsxs)(`div`,{className:j9.footer,children:[(0,i.jsx)(Xs,{variant:`secondary`,onClick:d,className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{variant:`primary`,onClick:Ue,isDisabled:!$e||p.isPending,className:`cta-primary`,children:`Save`})]})]})}})),zTr=_({CreateGlobalFilter:()=>LTr}),BTr=h((()=>{RTr()})),R9=h((()=>{Zs(),vue(),fpt(),ppt(),rc(),mpt(),Nmt(),I5t(),yY(),L5t(),B5t(),m7t(),fY(),CJ(),V7t(),uXn(),nmr(),rmr(),DJ(),WZ(),smr(),cmr(),uon(),gmr(),aXn(),Sa(),Dmr(),qHn(),m$(),Ny(),Zcr(),Flr(),rZ(),s$(),Omr(),Gor(),jmr(),Imr(),Ryt(),MHn(),O6(),c1t(),b$(),mX(),Fgn(),sQ(),Lmr(),g9n(),Zgn(),uQ(),Zmr(),hlr(),X9t(),Qmr(),$mr(),ehr(),thr(),J7t(),D3(),QZ(),nhr(),phr(),mhr(),mir(),y_r(),$cr(),b_r(),x_r(),QX(),S_r(),ywr(),Hwr(),zwr(),Uwr(),Wwr(),xlr(),Gwr(),Ier(),Kwr(),tTr(),BTr()})),VTr,HTr,UTr,z9,WTr=h((()=>{VTr=`_container_l3hvo_8`,HTr=`_label_l3hvo_12`,UTr=`_action_l3hvo_18`,z9={container:VTr,label:HTr,action:UTr}})),GTr,KTr=h((()=>{GTr=e=>{let t=Math.max(0,Math.round(e));if(t<60)return`${t} sec`;let n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n&&a.push(`${n} hr`),r&&a.push(`${r} min`),i&&a.push(`${i} sec`),a.join(` `)}})),qTr,JTr=h((()=>{Zs(),WTr(),KTr(),qTr=({refreshSeconds:e,isPaused:t,onTogglePause:n,onRefreshNow:r,isRefreshing:a=!1,className:o})=>{if(!e||e<=0)return null;let s=GTr(e);return(0,i.jsxs)(`div`,{className:`${z9.container} ${o||``}`,"aria-live":`polite`,"data-dbn-auto-refresh":t?`paused`:`running`,children:[(0,i.jsx)(`span`,{className:z9.label,children:t?`Auto-refresh paused. The cards below stay as they are.`:`This dashboard refreshes its data every ${s}.`}),(0,i.jsx)(Xs,{variant:`popover`,type:`button`,className:z9.action,onClick:n,children:t?`Resume auto-refresh`:`Pause auto-refresh`}),r?(0,i.jsx)(Xs,{variant:`popover`,type:`button`,className:z9.action,isDisabled:a,onClick:r,children:a?`Refreshing`:`Refresh now`}):null]})}})),YTr,XTr,ZTr,QTr,$Tr,eEr,tEr,nEr,rEr,B9,iEr=h((()=>{YTr=`_generateMetricModal_1hqhq_8`,XTr=`_generateMetricModalHeader_1hqhq_12`,ZTr=`_generateMetricQuery_1hqhq_16`,QTr=`_generateMetricQueryForm_1hqhq_19`,$Tr=`_generateMetricChart_1hqhq_22`,eEr=`_metricChartEmpty_1hqhq_25`,tEr=`_loaderContainer_1hqhq_29`,nEr=`_chartWrapper_1hqhq_33`,rEr=`_sqlPopUp_1hqhq_37`,B9={generateMetricModal:YTr,generateMetricModalHeader:XTr,generateMetricQuery:ZTr,generateMetricQueryForm:QTr,generateMetricChart:$Tr,metricChartEmpty:eEr,loaderContainer:tEr,chartWrapper:nEr,sqlPopUp:rEr}})),aEr,oEr,sEr,cEr,lEr,uEr,dEr,fEr,pEr=h((()=>{tH(),Uy(),my(),Cb(),xV(),lXt(),KK(),JK(),oq(),aEr=`table`,oEr=(e,t)=>e?.customSettings?.chartTypeSource??t,sEr=({generated:e,current:t,source:n,gateOn:r=!0})=>e?r?n===`human`?{chartType:t,source:n}:{chartType:e,source:`engine`}:{chartType:e,source:n}:{chartType:t,source:n},cEr=(e,{gateOn:t,source:n})=>t?{...e||{},chartTypeSource:n}:e,lEr=e=>{let t={chartType:aEr,dimensions:e.dimensions,measures:e.measures};if(!Vy()||!e.rows.length)return t;let n=Sb(e.rows,e.columnMeta,{dimensions:e.dimensions,measures:e.measures},{surface:`builder`}),{roles:r,chartType:i}=n.recommendation,a=r.xAxis&&e.dimensions.includes(r.xAxis)?[r.xAxis,...e.dimensions.filter(e=>e!==r.xAxis)]:e.dimensions,o=(r.yAxisList??[]).filter(t=>e.measures.includes(t));return{chartType:i,dimensions:a,measures:o.length?o:e.measures,defaults:n}},uEr=(e,t=[])=>{let n=new Set(t.filter(e=>e?.name).map(e=>e.name));return e.filter(e=>[`ASC`,`DESC`].includes(e?.defaultSort||``)).map(e=>{let t=Pv.includes(e?.helperFunction||``),n=nS([e])?.dimensions?.[0];return e?.helperFunction===`date format`&&e?.functionConfiguration?{method:e.defaultSort,name:e?.alias||e?.name,type:`formatted_date`,formattedColumn:n}:{method:e.defaultSort,name:e?.alias||e?.name,type:`selected_column`,formattedColumn:t&&e?n:void 0}}).filter(e=>e?.name&&!n.has(e.name))},dEr=(e=[],t=[])=>[...e,...uEr(t,e)],fEr=e=>{let{clientId:t,companyId:r,externalDashboardId:i,isLiveMode:a,metric:o,setShowMetricCreateModal:s,userProvidedDashboardId:l,clientColumnType:u,datasourceId:d,databaseName:f,onServerEvent:p,refetchDashboardData:m}=e,[h,g]=(0,n.useState)({data:[],error:``,isLoading:!1,currentValue:``}),[_,v]=(0,n.useState)(),[y,b]=(0,n.useState)(),[x,S]=(0,n.useState)(Tv),[C,w]=(0,n.useState)(!1),[T,ee]=(0,n.useState)({data:[],error:``,isLoading:!1,query:``}),[te,ne]=(0,n.useState)([]),[re,ie]=(0,n.useState)([]),[ae,oe]=(0,n.useState)({error:``,isLoading:!1}),[se,ce]=(0,n.useState)(),[le,ue]=(0,n.useState)([]),[de,fe]=(0,n.useState)(!1),[pe,me]=(0,n.useState)([]),[he,ge]=(0,n.useState)(!1),[_e,ve]=(0,n.useState)(Av),{register:ye,formState:{errors:be},handleSubmit:xe,watch:Se}=OV(),{mutate:Ce}=qGt(),we=(0,n.useRef)(null),{createExternalMetric:Te,error:Ee,updateExternalMetric:De,clientSubsetData:Oe,previewTable:Ae,token:je,dashboardOptions:Me,isLoading:Ne,workspaceId:Pe,isClientDatabaseScoped:Fe}=aq({onServerEvent:p,query:T.query,chartSettings:x,companyIntegrationId:y?.id,integrationName:y?.name,metricQuery:Se(`questionString`),datasetMetricSettings:_,outputColumns:void 0,selectedColumns:void 0,clientId:t,isEmbedded:!0,companyId:r,isLiveMode:a,dashboardIds:[i],userProvidedDashboardId:l,isEnableGroupBy:!1,groupBy:void 0,selectedGroupBy:[],metric:o,onSuccess:async t=>{if(w(!1),s(!1),t)try{await e?.saveDashLayout?.(t,x.chartType)}catch(e){console.error(`Error saving layout:`,e)}m()}}),Ie=JGt(),{mutate:Le,error:Re}=GGt(),{mutateAsync:ze}=qK(),Be=(e,t)=>{let n=t||e?.datatype||``;return n?$x(n)?Nv:xv.includes(n?.toLowerCase())||n?.toLowerCase()?.startsWith(`decimal`)||n?.toLowerCase()?.startsWith(`numeric`)?Lv:(Sv.includes(n?.toLowerCase())||n?.toLowerCase()?.includes(`char`))&&t?Fv.filter(e=>!Iv.includes(e.value)):Fv:dce},Ve=e=>rS(e,y?.name||``,le),He=e=>{if(T?.data?.length){let t=Object.keys(T?.data?.[0]||{});return e.filter(e=>t.includes(e))}return[]},Ue=({chartType:e,chartDimensions:t,chartMetrics:n,chartAggregateColumns:r,configAggregates:i,chartTypeSource:a})=>{if(e){let e=Vy();S(t=>{let n=cEr(t.customSettings,{gateOn:e,source:a??`human`});return n===t.customSettings?t:{...t,customSettings:n}})}let o=t||He(Ve(le.filter(e=>e.configType===`DIMENSION`))),s=n||He(Ve(le.filter(e=>e.configType===`AGGREGATE`))),l=r||He(Ve(le.filter(e=>e.configType===`AGGREGATE`)));if(s.length===0&&![$.table,$.singleValue].includes(e||x.chartType)){let{numberKeys:t,otherKeys:n}=Zx(T.data),r=o?.find(e=>n?.includes(e));if([$.progressBar,$.linearGauge].includes(e||``)&&S(n=>({...n,chartType:e||n.chartType,progressColumn:t?.[0]||``})),e===$.gauge)S(r=>({...r,chartType:e||r.chartType,gaugeSettings:{dimensions:n,metric:t?.[0]}}));else if(e===$.horizontalStackTable)S(r=>({...r,chartType:e||r.chartType,stackTableCols:t,yAxisList:n}));else if([$.funnel,$.funnelV2].includes(e||``))S(r=>({...r,chartType:e||r.chartType,step:n?.[0],measure:t?.[0]}));else if(e===$.sankey){let r=n?.length>1?[n?.[0],n?.[1],t?.[0]]:[n?.[0]||t?.[0],t?.[0]||n?.[0],t?.[1]];S(t=>({...t,chartType:e||t.chartType,sankeyValues:r}))}else S(n=>({...n,chartType:e||n.chartType,xAxis:r,yAxisList:t,numberColumns:t}));return}if([$.progressBar,$.linearGauge].includes(e||``)&&S(t=>({...t,chartType:e||t.chartType,progressColumn:s?.[0]||``})),e===$.singleValue)S(t=>({...t,chartType:e||t.chartType,singleValue:s?.[0]||o?.[0]}));else if(l.length&&[$.pivot,$.treeMap].includes(e||``)&&T?.data?.length)S(t=>({...t,chartType:e||t.chartType,pivotTableSettings:{...x.pivotTableSettings,columns:o,rows:l}}));else if(l.length&&[$.pivotV2].includes(e||``)&&T?.data?.length)S(t=>({...t,chartType:e||t.chartType,pivotTableSettings2:{...x.pivotTableSettings2,dimensions:o.slice(1),headers:o.slice(0,1),measures:l,aggregates:i||_e.aggregates||[]}}));else if(l.length&&[$.pivotV3].includes(e||x.chartType)&&T?.data?.length)S(n=>({...n,chartType:e||n.chartType,pivotTableSettings3:{...x.pivotTableSettings3,columns:[...o,...s],dims:t||[],aggregates:i||_e.aggregates||[]}}));else if(e===$.table){let{numberKeys:t}=Zx(T.data);S(n=>({...n,chartType:e||n.chartType,yAxisList:[...o,...s],numberColumns:t}))}else if([$.waterfall,$.waterfallV2].includes(e||``))S(t=>({...t,chartType:e||t.chartType,xAxis:o?.[0],yAxisList:[s?.[0]]}));else if(e===$.sankey){let t=o?.length>1?[o?.[0],o?.[1],s?.[0]]:[o?.[0]||s?.[0],s?.[1],s?.[2]];S(n=>({...n,chartType:e||n.chartType,sankeyValues:t}))}else[$.funnelV2,$.funnel].includes(e||``)?S(t=>({...t,chartType:e||t.chartType,step:o?.[0]||``,measure:s?.[0]})):e===$.horizontalStackTable?S(t=>({...t,chartType:e||t.chartType,stackTableCols:s||[],yAxisList:o})):S(t=>({...t,chartType:e||t.chartType,xAxis:o?.[0],yAxisList:s}))},We=[{value:`bar`,label:`Bar Chart`,icon:`bar-chart`},{value:`line`,label:`Line Chart`,icon:`line`},{value:`table`,label:`Table Chart`,icon:`table`}],Ge=(0,n.useMemo)(()=>(Oe?.tableList)?.map(e=>({columns:e?.columns?.map(e=>e.name)||[],columnsWithDataType:e?.columns?.map(e=>({as:e.as,dataType:e.datatype,name:e.name,label:e.label,synonyms:e.synonyms,defaultSort:e.defaultSort||null})),companyId:``,id:``,recentUpdatedAt:0,schemaName:e?.tableName?.split(`.`)?.[0]||``,tableName:e?.tableName?.split(`.`)?.[1]||``,clientColumn:e?.clientColumn||``,alias:`${e?.tableName?.split(`.`)?.[0]||``}_${e?.tableName?.split(`.`)?.[1]||``}`}))||[],[Oe]),Ke=(0,n.useMemo)(()=>se?.type===`custom`?se?.alias||`dbn_sql_table`:`${se?.schemaName}_${se?.tableName}`,[se]),qe=(0,n.useMemo)(()=>(se?.columnsWithDataType?.map(e=>{let t=e?.dataType,n=Be(void 0,t),r=$x(t),i=xv.includes(t?.toLowerCase())||t?.toLowerCase()?.startsWith(`decimal`)||t?.toLowerCase()?.startsWith(`numeric`),a=Sv.includes(t?.toLowerCase())||t?.toLowerCase()?.includes(`char`),o=pe.find(t=>t.column===e.name)?.values||[],s=r?cce?.map((t,n)=>({alias:Xx(t.alias(e.name),y?.name||``),configType:`FILTER`,datatype:e.dataType,dropType:`FILTER`,index:n,name:e.name,parentAlias:Ke,table:se,type:e.type===`custom`?`CUSTOM`:e.type===`python`?`PYTHON`:`DEFAULT`,helperFunction:void 0,sql:e.sql||``,draggableItemData:{column:e,table:se},synonyms:t.synonyms,filterMethod:`=`,filterType:`time`,filterValue:{timeValue:{endDate:``,startDate:``,timeFilter:t.value}},relationOperator:`AND`,label:e.label||``,defaultSort:e.defaultSort||null})):i?[{alias:e.name,configType:`FILTER`,datatype:e.dataType,dropType:`FILTER`,index:0,name:e.name,parentAlias:Ke,table:se,type:e.type===`custom`?`CUSTOM`:e.type===`python`?`PYTHON`:`DEFAULT`,helperFunction:void 0,sql:e.sql||``,draggableItemData:{column:e,table:se},synonyms:Bv?.flatMap(e=>e.synonymns),filterMethod:`=`,filterType:`default`,filterValue:{},relationOperator:`AND`,label:e.label||``,defaultSort:e.defaultSort||null}]:a?o?.map((t,n)=>({alias:Xx(`${t} ${e.name}`,y?.name||``),configType:`FILTER`,datatype:e.dataType,dropType:`FILTER`,index:n,name:e.name,parentAlias:Ke,table:se,type:e.type===`custom`?`CUSTOM`:e.type===`python`?`PYTHON`:`DEFAULT`,helperFunction:void 0,sql:e.sql||``,draggableItemData:{column:e,table:se},synonyms:[t],filterMethod:`IN`,filterType:`default`,filterValue:{stringArray:[t]},relationOperator:`AND`,label:e.label||``,defaultSort:e.defaultSort||null})):[],l=n?.map((t,n)=>{let r=t.value===`NONE`,i=`${r?e.name:`${Xx(`${t.label?.toLowerCase()} of`,y?.name||``)} ${e.name}`}`,a=zv.includes(t.value);return{alias:i,configType:e.isAggregate||a?`AGGREGATE`:`DIMENSION`,datatype:e.dataType,dropType:e.isAggregate||a?`METRIC`:`DIMENSION`,index:n,name:e.name,parentAlias:Ke,table:se,type:e.type===`custom`?`CUSTOM`:e.type===`python`?`PYTHON`:r?`DEFAULT`:`HELPER_FUNCTION`,helperFunction:t.value,sql:e.sql||``,draggableItemData:{column:e,table:se},synonyms:nce?.[t.value]||[],filterMethod:``,filterType:`default`,filterValue:{},label:e.label||``,defaultSort:e.defaultSort||null}}),u=lce?.map(t=>({alias:Xx(t.alias(e.name),y?.name||``),configType:`FILTER`,datatype:e.dataType,dropType:`FILTER`,index:0,name:e.name,parentAlias:Ke,table:se,type:e.type===`custom`?`CUSTOM`:e.type===`python`?`PYTHON`:`DEFAULT`,helperFunction:void 0,sql:e.sql||``,draggableItemData:{column:e,table:se},synonyms:t.synonymns,filterMethod:t.value,filterType:`default`,filterValue:{},relationOperator:`AND`,label:e.label||``,defaultSort:e.defaultSort||null}));return[...s,...u,...l]})||[]).flat().reverse(),[se,Ke,pe]),Je=(0,n.useMemo)(()=>!x.measure?.length&&!x.yAxisList?.filter(e=>e)?.length&&!x.singleValue,[x]),Ye=(0,n.useMemo)(()=>{let e=Qx(T.data||[],!0),t=le.some(e=>$x(e.datatype)),n=!!_?.newDatasetSettings?.configuration?.aggregates?.length&&!!_?.newDatasetSettings?.configuration?.dimensions?.length;return n&&t?[...e.filter(e=>![$.pivot,$.pivotV2,$.pivotV3].includes(e)&&e!==$.timeSeries),$.pivot,$.timeSeries,$.pivotV2,$.pivotV3]:n?[...e.filter(e=>![$.pivot,$.pivotV2,$.pivotV3].includes(e)&&e!==$.timeSeries),$.pivot,$.pivotV2,$.pivotV3]:t?[...e.filter(e=>![$.pivot,$.pivotV2,$.pivotV3].includes(e)&&e!==$.timeSeries),$.timeSeries]:e.filter(e=>![$.pivot,$.pivotV2,$.pivotV3].includes(e)&&e!==$.timeSeries)},[T.data,_?.newDatasetSettings?.configuration?.aggregates,x.xAxis]),Xe=(0,n.useMemo)(()=>T.data.length&&(x.xAxis||x.yAxisList?.length)&&(x.chartType!==$.singleValue||T.data?.[0]?.[x.singleValue||``]!==null)?`CHART`:T.error?`ERROR`:T.isLoading?`LOADING`:`INIT`,[T,x]),Ze=()=>{if(!se||!Pe)return;ee({data:[],error:``,isLoading:!0,query:``});let e=[],n=[],r=[],i=[],a=le.find(e=>e.limit&&e.configType!==`FILTER`)?.limit?.toString();le.forEach(t=>{if(t.sortType){let e={method:t.sortType,name:t.alias,type:`selected_column`};i.push(e)}if(t.configType===`FILTER`){let e=t.keyword?t.keyword?.toLowerCase().trim().split(` `)?.filter(e=>!oce.includes(e)&&e):[],n=xv.includes(t.datatype?.toLowerCase())||t?.datatype?.toLowerCase()?.startsWith(`decimal`)||t?.datatype?.toLowerCase()?.startsWith(`numeric`),i=Bv.find(t=>e.some(e=>t.synonymns.includes(e)))?.value||``,a=e.find(e=>Number(e))||0,o=t.filterType===`custom`?{alias:t.name,columnName:t.sql,dataType:`CUSTOM`,parentAlias:`NULL`,type:`custom`,method:`NONE`,value:`NULL`,relationOperator:t.relationOperator}:t.filterType===`client`?{alias:t.name,columnName:t.name,dataType:t.datatype,method:`=`,parentAlias:t.parentAlias,type:`client`,value:`client_id_variable`}:{alias:t.name,columnName:t.name,method:n?i||t.filterMethod||`=`:t.filterMethod||`=`,parentAlias:t.parentAlias,dataType:t.filterValue?.timeValue?`TIME_COLUMN`:t.datatype,type:t.filterValue?.timeValue?`time`:`default`,value:lce.find(e=>e.value===t.filterMethod)?``:n?Number(a):t.filterValue?.stringValue||t.filterValue?.stringArray||t.filterValue?.timeValue||t.filterValue?.numberArray||t.filterValue?.numberValue||``,relationOperator:t.relationOperator};r.push(o)}if(t.configType===`AGGREGATE`){let e={alias:t.alias,columnName:t.type?.toLowerCase()===`custom`?t.sql||``:t.name,dataType:t.datatype,parentAlias:t.parentAlias,type:t.type?.toLowerCase()===`custom`?`custom`:`default`,method:t.helperFunction||`SUM`};n.push(e)}else if(t.configType===`DIMENSION`){let n={alias:t.alias,columnName:t.type?.toLowerCase()===`custom`?t.sql||``:t.name,dataType:t.datatype,parentAlias:t.parentAlias,type:t.type?.toLowerCase()===`custom`?`custom`:`default`,helperFunction:t.helperFunction,timeGrain:void 0,functionConfiguration:t.functionConfiguration};e.push(n)}});let s={name:se?.clientColumn||``,datatype:se?.columnsWithDataType?.find(e=>e.name===se.clientColumn)?.dataType||``},l={alias:s.name,columnName:s.name,dataType:s.datatype,method:`=`,parentAlias:Ke,type:`client`,value:u===`NUMBER`?Number(t):t,relationOperator:`AND`},f={..._e,dimensions:e,aggregates:n,orders:dEr(i,le.filter(e=>e.configType!==`FILTER`)),table:{alias:Ke,id:se?.id,joins:[],name:se?.type===`custom`?se?.sql||``:se?.tableName,schema:se?.schemaName,type:se?.type===`custom`?`custom`:`default`},limit:a||Av.limit,filters:Fe?r.filter(e=>e.type!==`client`):s?.name?[...r,l]:r},p={...qse,newDatasetSettings:{...qse,isAutoCompleteMode:!0,selectedAutoCompleteColumns:le,selectedDims:le.filter(e=>e.configType===`DIMENSION`),selectedMetrics:le.filter(e=>e.configType===`AGGREGATE`),configuration:f,selectedMainTable:se,metrics:(f||_e).aggregates?.map(e=>({as:e.alias,value:e.columnName}))||[],selectedDimensions:(f||_e).dimensions?.map(e=>e.alias)||[]}};v?.(p),ve(f),Le({data:{cId:t,configuration:f,id:Pe,datasourceId:d,isCreateMetric:!0},token:je},{onSuccess(e){let t=e?.error,n=e?.data,r=e?.query,i=e?.metaData;if(t||Re)ee({data:[],error:t?.message||`something went wrong, please try again`,isLoading:!1,query:``});else if(n&&r){let e=Pb(Array.isArray(n)?n:[]);ee({data:e,error:``,isLoading:!1,query:r}),ne(qbe(i?.groupbyColumnList));let t=Ve(le.filter(e=>e.configType===`AGGREGATE`)),a=lEr({rows:e,dimensions:Ve(le.filter(e=>e.configType===`DIMENSION`)),measures:t,columnMeta:le.map(e=>({name:y?.name?.toLowerCase()===`redshift`?e.alias?.toLowerCase():e.alias,dataType:e.datatype}))}),s=sEr({generated:a.chartType,current:x.chartType,source:oEr(x,o?`human`:`default`),gateOn:!!a.defaults});Ue({chartType:s.chartType,chartTypeSource:s.source,chartAggregateColumns:t,chartMetrics:a.measures,chartDimensions:a.dimensions,configAggregates:f.aggregates});let l=a.defaults?.settings?.sort;l&&S(e=>({...e,customSettings:{...e.customSettings||{},sort:{by:l.by,direction:l.direction}}}))}else ee({data:[],error:ev,isLoading:!1,query:``})},onError(){ee({data:[],error:ev,isLoading:!1,query:``})}})},Qe=()=>{oe({error:``,isLoading:!0});let e={content:`Here is the table: ${JSON.stringify(se||{})}.
|
|
5057
|
-
suggest list of dimensions and measures.`,role:`user`};je&&Ie.mutate({token:je,data:{messages:[...re,e]}},{onSuccess(t){let n=t.result;oe({error:``,isLoading:!1}),ie([...re,e,n])}})},$e=xe(e=>{let t=e.questionString;ee({data:[],error:``,isLoading:!0,query:``}),S(Tv),je?Ce({data:{questionString:t},token:je},{onSuccess(e){let t=e;if(t.queryData?.length&&t.query){let e=Pb(t.queryData);ee({data:e,error:``,isLoading:!1,query:t.query}),kbe({data:e,setChartSettings:S})}else t.error?ee({data:[],error:t.error,isLoading:!1,query:t.query||``}):ee({data:[],error:ev,isLoading:!1,query:``})},onError(){ee({data:[],error:ev,isLoading:!1,query:``})}}):ee({data:[],error:``,isLoading:!1,query:``})}),et=(0,n.useCallback)(e=>S(t=>({...t,tableSettings:{...t.tableSettings,columnSizing:e}})),[]),tt=({column:e,helperFunction:t,functionConfiguration:n})=>{let r=t.value===`NONE`,i=`${r?e.name:`${Xx(`${t.label?.toLowerCase()} of`,y?.name||``)} ${e.name}`}`,a=zv.includes(t.value),o=le?.map(o=>o.alias===e.alias?{...o,helperFunction:t.value,alias:i,configType:a?`AGGREGATE`:`DIMENSION`,dropType:a?`METRIC`:`DIMENSION`,type:r?`DEFAULT`:`HELPER_FUNCTION`,functionConfiguration:n}:o);ue(o)},nt=({alias:e,column:t})=>{ue(n=>n?.map(n=>n.alias===t.alias?{...n,alias:e}:n))},rt=async()=>{me([]);let e=se?.columnsWithDataType?.filter(e=>Sv.includes(e?.dataType?.toLowerCase()||``)||e?.dataType?.toLowerCase()?.includes(`char`))||[];if(e.length&&je&&se)for(let n=0;n<e.length;n+=1){let r=e[n]?.name,i=await ze({encryptedClientId:t||``,isFrontendApp:!1,token:je||``,data:{columnName:r,wId:Pe,tableName:`${se?.schemaName}.${se?.tableName}`,datasourceId:d,databaseName:f}}),a=i?.data&&Array.isArray(i?.data)&&i?.data.length?i.data?.map(e=>e.value):[];me(e=>[...e,{column:r,values:a}])}else me([])};return(0,n.useEffect)(()=>{(x.chartType!==$.stack||x.chartType!==$.timeSeries||x?.timeSeriesSettings?.seriesType?.[0]?.type!==`stack`||x.seriesField!==`ungrouped`)&&S(e=>({...e,customSettings:{...e.customSettings,showFullStacked:!1}}))},[x?.chartType,x?.timeSeriesSettings,x.seriesField]),(0,n.useEffect)(()=>{let e=Oe?.error,t=Oe;e||!Oe?ee(t=>({...t,error:e?.message})):t?.tableList?.length&&b({id:t?.companyIntegrationId,name:t?.dbName})},[Oe]),(0,n.useEffect)(()=>{o&&(S(o.chartOptions),b(o.companyIntegration))},[o]),(0,n.useEffect)(()=>{se||Ge.length&&ce(Ge?.[0])},[Ge,se]),(0,n.useEffect)(()=>{se?rt():me([])},[se]),(0,n.useEffect)(()=>{let e=Jq(x?.customSettings?.comboAxisSettings||[]),t=e?.flatMap(e=>e?.measures),n=x?.yAxisList?.every(e=>t?.includes(e));if(x?.yAxisList?.length&&x?.yAxisList?.length!==t?.length&&!t?.length&&[$.combo,$.timeSeries,$.horizontalCombo].includes(x?.chartType||``)){let e=x?.yAxisList?.filter(e=>!x?.comboBarList?.includes(e))?.filter(e=>!t?.includes(e)),n=x?.customSettings?.comboStackAxisSymbols?.name||``,r=x?.customSettings?.comboLabelFormatter?.find(e=>e.axis===(n||`stack`))?.formatter,i=x?.comboBarList?.join(` and `),a=x?.customSettings?.comboLabelFormatter?.find(e=>e.axis===i)?.formatter;S(t=>({...t,customSettings:{...t.customSettings,comboAxisSettings:Jq([...t.customSettings?.comboAxisSettings||[],...e?.map(e=>{let t=x?.customSettings?.comboLabelFormatter?.find(t=>t.axis===e)?.formatter,n=x?.customSettings?.comboAxisSymbols?.find(t=>t.name===e);return{axis:e,measures:[e],chartTypes:[{axis:e,type:`line`}],numberFormatter:x?.customSettings?.numberFormatter,labelFormatter:t,prefix:n?.prefix||``,suffix:n?.suffix||``,isEnableLabelFormatter:!!t?.length}}),...x?.comboBarList?.length&&(x?.customSettings?.isCombineBarAxis||x?.customSettings?.isStackBar)?[{axis:x?.customSettings?.isStackBar&&n||i,measures:x?.comboBarList,chartTypes:x?.comboBarList?.map(e=>({axis:e,type:`bar`})),isEnableStackBar:x?.customSettings?.isStackBar,numberFormatter:x?.customSettings?.numberFormatter,...x?.customSettings?.isStackBar?{prefix:x?.customSettings?.comboStackAxisSymbols?.prefix||``,suffix:x?.customSettings?.comboStackAxisSymbols?.suffix||``,labelFormatter:r,isEnableLabelFormatter:!!r?.length}:{prefix:x?.customSettings?.combinedAxisPrefix||``,suffix:x?.customSettings?.combinedAxisSuffix||``,labelFormatter:a,isEnableLabelFormatter:!!a?.length}}]:[],...x?.comboBarList?.length&&!x?.customSettings?.isCombineBarAxis&&!x?.customSettings?.isStackBar?x?.comboBarList?.map(e=>{let t=x?.customSettings?.comboLabelFormatter?.find(t=>t.axis===e)?.formatter,n=x?.customSettings?.comboAxisSymbols?.find(t=>t.name===e);return{axis:e,measures:[e],chartTypes:[{axis:e,type:`bar`}],numberFormatter:x?.customSettings?.numberFormatter,labelFormatter:t,prefix:n?.prefix||``,suffix:n?.suffix||``,isEnableLabelFormatter:!!t?.length}}):[]].filter(e=>e?.measures?.length)),comboAxisSymbols:[],combinedAxisPrefix:``,combinedAxisSuffix:``,comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}))}if(t?.length&&x?.yAxisList?.length&&(x?.yAxisList?.length!==t?.length||x?.yAxisList?.length===t?.length&&!n)&&[$.combo,$.timeSeries,$.horizontalCombo].includes(x?.chartType||``)){let e=x?.yAxisList?.filter(e=>!t?.includes(e));(t?.filter(e=>!x?.yAxisList?.includes(e)))?.forEach(e=>{let t=x?.customSettings?.comboAxisSettings?.find(t=>t.measures?.includes(e)),n=t?.axis,r=(t?.measures?.length||0)>1;S(t=>({...t,customSettings:{...t.customSettings,comboAxisSettings:Jq(r?t.customSettings?.comboAxisSettings?.map(t=>t.axis===n?{...t,measures:t?.measures?.filter(t=>t!==e)}:t)?.filter(e=>e?.measures?.length)||[]:t.customSettings?.comboAxisSettings?.filter(e=>e.axis!==n&&e?.measures?.length)||[])}}))}),e?.length&&S(t=>({...t,customSettings:{...t.customSettings,comboAxisSettings:Jq([...t.customSettings?.comboAxisSettings||[],...e?.map(e=>({axis:e,measures:[e],chartTypes:[{axis:e,type:`line`}]}))].filter(e=>e?.measures?.length)||[])}}))}t?.length&&x?.yAxisList?.length&&x?.yAxisList?.length===t?.length&&n&&[$.combo,$.timeSeries,$.horizontalCombo].includes(x?.chartType||``)&&x?.customSettings?.comboAxisSettings?.length!==e?.length&&S(t=>({...t,customSettings:{...t?.customSettings,comboAxisSettings:e}}))},[x?.yAxisList,x?.customSettings?.comboAxisSettings,x?.comboBarList,x?.customSettings?.isCombineBarAxis,x?.customSettings?.isStackBar,x?.customSettings?.comboStackAxisSymbols?.name,x?.customSettings?.comboStackAxisSymbols?.prefix,x?.customSettings?.comboStackAxisSymbols?.suffix,x?.customSettings?.comboLabelFormatter,x?.customSettings?.comboAxisSymbols,x?.customSettings?.numberFormatter,x?.customSettings?.combinedAxisPrefix,x?.customSettings?.combinedAxisSuffix,x?.chartType]),(0,n.useEffect)(()=>{x?.chartType===$.horizontalCombo&&S(e=>({...e,customSettings:{...e?.customSettings,xRotation:0,customRotation:0,hideXAxisLines:!1},margins:{...e?.margins,top:5}}))},[x?.chartType]),(0,n.useEffect)(()=>{x?.yAxisList?.length&&x?.yAxisList?.length<5&&x?.chartType===$.boxplot&&S(e=>({...e,chartType:$.line})),!x?.yAxisList?.length&&x?.chartType===$.funnelV2&&S(e=>({...e,chartType:$.singleValue}))},[x?.chartType,x?.yAxisList?.length]),{isDisableSaveBtn:Je,setChartSettings:S,setShowSaveMetricModal:w,isShowSaveMetricModal:C,register:ye,errors:be,onSubmitQuery:$e,generateMetricState:T,chartTabType:Xe,chartSettings:x,chartRef:we,onColumnSizingChange:et,watch:Se,createExternalMetric:Te,saveError:Ee,updateExternalMetric:De,clientSubsetData:Oe,previewTable:Ae,token:je,dashboardOptions:Me,isCreatingMetric:Ne,tableList:Ge,selectedMainTable:se,setSelectedMainTable:ce,aiResponseState:ae,onAiQuery:Qe,autoCompleteDropdownOptions:qe,selectedColumns:le,setSelectedColumns:ue,functionOptions:Be,setChartFields:Ue,onSubmitSearch:Ze,onChangeHelperFunction:tt,onChangeAlias:nt,chartOptions:We,isShowChartType:de,setShowChartType:fe,enabledCharts:Ye.filter(e=>![$.pivotV2,$.timeSeries,$.pivotV3].includes(e)),stringColumnValues:pe,isRef:he,setRef:ge,pivotDrillState:h}}})),mEr,hEr=h((()=>{iEr(),phr(),pEr(),GX(),R9(),mEr=({clientId:e,companyId:t,externalDashboardId:n,isLiveMode:r,isShowMetricCreateModal:a,setShowMetricCreateModal:o,userProvidedDashboardId:s,workspaceId:l,chartColors:u,metric:d,metricData:f,variant:p,clientColumnType:m,datasourceId:h,tenancyType:g,onServerEvent:_,refetchDashboardData:v,saveDashLayout:y})=>{let{isDisableSaveBtn:b,setShowSaveMetricModal:x,generateMetricState:S,chartTabType:C,chartSettings:w,onColumnSizingChange:T,chartRef:ee,isCreatingMetric:te,isShowSaveMetricModal:ne,saveError:re,updateExternalMetric:ie,createExternalMetric:ae,tableList:oe,selectedMainTable:se,setSelectedMainTable:ce,selectedColumns:le,setSelectedColumns:ue,autoCompleteDropdownOptions:de,onSubmitSearch:fe,setChartFields:pe,functionOptions:me,onChangeHelperFunction:he,onChangeAlias:ge,chartOptions:_e,isShowChartType:ve,setShowChartType:ye,enabledCharts:be,setChartSettings:xe,isRef:Se,setRef:Ce,pivotDrillState:we}=fEr({clientId:e,companyId:t,isLiveMode:r,externalDashboardId:n,userProvidedDashboardId:s,chartColors:u,isShowMetricCreateModal:a,setShowMetricCreateModal:o,metric:d,metricData:f,workspaceId:l,variant:p,clientColumnType:m,datasourceId:h,databaseName:g===`MULTI_DATABASE`&&e||``,onServerEvent:_,refetchDashboardData:v,saveDashLayout:y});return(0,i.jsxs)(`div`,{className:B9.generateMetricModal,children:[(0,i.jsx)(`div`,{className:B9.generateMetricModalHeader,children:(0,i.jsx)(L9t,{heading:d?`Update Metric`:`Create Metric`,setShowMetricCreateModal:o,isDisableSaveBtn:b,setShowSaveMetricModal:x})}),(0,i.jsxs)(`div`,{className:B9.generateMetricQuery,children:[(0,i.jsxs)(`form`,{className:B9.generateMetricQueryForm,onSubmit:e=>e.preventDefault(),children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-4 dbn:items-center`,children:[(0,i.jsx)(vY,{options:oe?.map(e=>({value:e.tableName,label:e.tableName,table:e,icon:`table`})),onChange:e=>{ce(e.table),ue([])},selectedOption:{label:se?.tableName||``,value:se?.tableName||``,icon:`table`},buttonWidth:`250px`,menuWidth:`100%`}),(0,i.jsx)(`div`,{className:`dbn:w-[800px]`,children:(0,i.jsx)(fhr,{selectedOption:le,setSelectedOptions:ue,options:de,isDisabled:S.isLoading||!se,functionOptions:me,onChangeHelperFunction:he,onChangeAlias:ge})})]}),(0,i.jsx)(Xs,{variant:`popover`,type:`button`,isDisabled:S.isLoading||!le?.filter(e=>e.configType!==`FILTER`).length,onClick:()=>{Ce(!1),fe()},leftIcon:(0,i.jsx)(jy,{name:`magnifying-glass`,color:`white`}),className:`dbn:bg-primary dbn:text-white dbn:px-3 dbn:h-[47px] dbn:rounded-l-none dbn:rounded-md`,children:`Search`})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-3`,children:[_e?.map(e=>(0,i.jsx)(Xs,{variant:`popover`,className:`${w.chartType===e.value?`dbn:bg-gray`:`dbn:bg-white`} dbn:h-8 dbn:w-8 dbn:flex dbn:items-center dbn:justify-center`,leftIcon:(0,i.jsx)(uY,{text:e.value,children:(0,i.jsx)(jy,{name:e.icon,size:`xl`})}),onClick:()=>{pe({chartType:e.value})}})),(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(uY,{text:`Chart Type`,children:(0,i.jsx)(jy,{name:`bar-chart-2`,size:`xl`})}),onClick:()=>ye(!0),className:`dbn:h-8 dbn:w-8 dbn:flex dbn:items-center dbn:justify-center`})]})]}),(0,i.jsxs)(`div`,{className:B9.generateMetricChart,children:[C===`INIT`&&(0,i.jsxs)(`div`,{className:B9.metricChartEmpty,children:[(0,i.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='264'%20height='206'%20fill='none'%20viewBox='0%200%20264%20206'%3e%3cpath%20fill='%23F1F2F7'%20d='M142.93%200a102%20102%200%200%200-63.85%2022.37H50.76a6.72%206.72%200%200%200%200%2013.42h18.63a6.72%206.72%200%200%201%200%2013.42H31.14a6.72%206.72%200%200%200%200%2013.42h17.37a103%20103%200%200%200-8.15%2040.27%20104%20104%200%200%200%202.23%2021.44%20562%20562%200%200%201%2039.98-4.63l1.06.96.99-1.12c16.79-1.31%2034.4-2%2052.58-2%2038.62%200%2074.76%203.14%20105.66%208.62a103%20103%200%200%200%202.63-23.27C245.49%2046.07%20199.57%200%20142.93%200M10.83%2048.9H6.78A6.83%206.83%200%200%200%200%2055.75a6.83%206.83%200%200%200%206.78%206.84h4.05a6.83%206.83%200%200%200%206.77-6.84%206.83%206.83%200%200%200-6.77-6.85'/%3e%3cpath%20fill='%23E8EBF2'%20d='M264%20151.6c0%203.66-3%206.66-6.69%206.66H214.6a6.67%206.67%200%200%200%200%2013.34h7.94a6.67%206.67%200%200%201%200%2013.34h-18.25a102.3%20102.3%200%200%201-61.53%2020.45%20102.5%20102.5%200%200%201-100.3-80.94c12.61-1.93%2026-3.48%2039.97-4.6l1.05.95.99-1.11c16.78-1.3%2034.4-2%2052.57-2%2038.6%200%2074.74%203.13%20105.63%208.57a101%20101%200%200%201-6.3%2018.67h20.94a6.67%206.67%200%200%201%206.69%206.66'/%3e%3cpath%20fill='%23E0E2EE'%20d='M244.5%20109.9a107%20107%200%200%201-2.36%2016.27c-30.86-5.59-66.95-8.8-105.51-8.8-18.15%200-35.75.72-52.52%202.05l11.63-13.47%2018.09%2011.8L138.3%20111l42.12%206.39%2018.29-6.39%204.63%206.39%2011.05-8.2%2010.33%209.46L241%20105.63zm-162.35%209.67a566%20566%200%200%200-39.96%204.64q-.65-3.06-1.11-6.2l21.62-16.3z'/%3e%3cpath%20fill='%23E1E3EF'%20d='M242.55%20184.85a6.87%206.87%200%200%201-6.84-6.85%206.87%206.87%200%200%201%206.84-6.84%206.87%206.87%200%200%201%206.85%206.84%206.87%206.87%200%200%201-6.85%206.85'/%3e%3crect%20width='111'%20height='86'%20x='91'%20y='50'%20fill='%23fff'%20rx='10'/%3e%3cpath%20fill='%23F1F2F7'%20d='M97.13%2064.96h98.74c1.83%200%203.3-2.72%203.3-6.08s-1.47-6.08-3.3-6.08H97.13c-1.83%200-3.3%202.72-3.3%206.08s1.47%206.08%203.3%206.08'/%3e%3cpath%20fill='%23D0D4DA'%20d='M99.58%2087.73h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-5.21c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m0-13.76h36.5c.9%200%201.62-.73%201.62-1.62s-.73-1.61-1.63-1.61H99.58c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m43.44%200h6.95a1.61%201.61%200%201%200%20.01-3.23h-6.96a1.61%201.61%200%201%200%200%203.23m29.55%200h20.85c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-20.85c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m0%2010.53c-.43%200-.85.18-1.16.48a1.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.14-2.76m1.15%2014.24a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28m-1.15%2013.29c-.43%200-.85.18-1.16.48s-.47.71-.47%201.14a1.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%201%200%200-3.23m6.95%200a1.64%201.64%200%200%200-1.63%201.62%201.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%200%200%201.15-2.75c-.3-.3-.72-.48-1.15-.48m-6.95%2013.77a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.15-2.75m6.95%200a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28c-.3-.3-.72-.47-1.15-.47m8.1-13.3a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%201.15%202.76%201.61%201.61%200%200%200%201.15-2.75m-6.95-27.53a1.64%201.64%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28M104.8%20125.8h-5.22c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-5.21-24.3h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-5.21c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m5.22%2010.53h-5.22c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m33.02%200h-3.47c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.47%2017h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-3.47c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m3.47-30.76h-3.47c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-3.47-10.54h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-3.47c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m10.42%200h6.95c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-6.95c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m12.17%2010.54h-12.17c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h12.17c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-8.69%2013.76h-3.48c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h3.48c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.48%2017h6.95c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-6.95c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62'/%3e%3cpath%20fill='%23D0D4DA'%20d='M193.42%2050.1H99.58A8.55%208.55%200%200%200%2091%2058.58v68.82c0%204.69%203.85%208.5%208.58%208.5h93.84a8.55%208.55%200%200%200%208.58-8.5V58.6c0-4.69-3.85-8.5-8.58-8.5m-64.4%2068.82v-10.54h34.97v10.54zm34.97%203.22v10.54H129v-10.54zm34.75-55.06v10.54h-31.5V67.08zM164%2080.85v10.54h-35V80.85zm-38.24%2010.54h-31.5V80.85h31.5zm0%203.22v10.54h-31.5V94.61zm3.26%200H164v10.54h-35zm38.23%200h31.5v10.54h-31.5zm0-3.22V80.85h31.5v10.54zM164%2077.62H94.26V67.08h69.73zm-69.73%2030.76h31.5v10.54h-31.5zm72.98%200h31.5v10.54h-31.5zM99.58%2053.32h93.84a5.3%205.3%200%200%201%205.32%205.27v5.27H94.26v-5.27a5.3%205.3%200%200%201%205.32-5.27m-5.32%2074.1v-5.28h31.5v10.54H99.57a5.3%205.3%200%200%201-5.32-5.27m99.16%205.26h-26.18v-10.54h31.5v5.27a5.3%205.3%200%200%201-5.32%205.27'/%3e%3crect%20width='111'%20height='86'%20x='68'%20y='76'%20fill='%23fff'%20rx='10'/%3e%3cpath%20fill='%23F1F2F7'%20d='M74.13%2090.96h98.74c1.83%200%203.3-2.72%203.3-6.08s-1.47-6.08-3.3-6.08H74.13c-1.83%200-3.3%202.72-3.3%206.08s1.47%206.08%203.3%206.08'/%3e%3cpath%20fill='%23D0D4DA'%20d='M76.58%20113.73h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-5.21c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m0-13.76h36.5c.9%200%201.62-.73%201.62-1.62s-.73-1.61-1.63-1.61H76.58c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m43.44%200h6.95a1.61%201.61%200%201%200%20.01-3.23h-6.96a1.61%201.61%200%201%200%200%203.23m29.55%200h20.85c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-20.85c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m0%2010.53c-.43%200-.85.18-1.16.48a1.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.14-2.76m1.15%2014.24a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28m-1.15%2013.29c-.43%200-.85.18-1.16.48s-.47.71-.47%201.14a1.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%201%200%200-3.23m6.95%200a1.64%201.64%200%200%200-1.63%201.62%201.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%200%200%201.15-2.75c-.3-.3-.72-.48-1.15-.48m-6.95%2013.77a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.15-2.75m6.95%200a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28c-.3-.3-.72-.47-1.15-.47m8.1-13.3a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%201.15%202.76%201.61%201.61%200%200%200%201.15-2.75m-6.95-27.53a1.64%201.64%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28M81.8%20151.8h-5.22c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-5.21-24.3h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-5.21c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m5.22%2010.53h-5.22c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m33.02%200h-3.48c-.9%200-1.62.73-1.62%201.62s.73%201.61%201.63%201.61h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.47%2017h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-3.48a1.61%201.61%200%201%200%20.01%203.23m3.47-30.76h-3.48a1.61%201.61%200%201%200%20.01%203.23h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-3.47-10.54h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-3.48c-.9%200-1.62.73-1.62%201.62s.73%201.61%201.63%201.61m10.42%200h6.95c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-6.95c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m12.17%2010.54h-12.17c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h12.17c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-8.69%2013.76h-3.48c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h3.48c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.48%2017h6.95c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-6.95c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62'/%3e%3cpath%20fill='%23D0D4DA'%20d='M170.42%2076.1H76.58A8.55%208.55%200%200%200%2068%2084.58v68.82c0%204.69%203.85%208.5%208.58%208.5h93.84a8.55%208.55%200%200%200%208.58-8.5V84.6c0-4.69-3.85-8.5-8.58-8.5m-64.4%2068.82v-10.54h34.97v10.54zm34.97%203.22v10.54H106v-10.54zm34.75-55.06v10.54h-31.5V93.08zM141%20106.85v10.54h-35v-10.54zm-38.24%2010.54h-31.5v-10.54h31.5zm0%203.22v10.54h-31.5v-10.54zm3.26%200H141v10.54h-35zm38.23%200h31.5v10.54h-31.5zm0-3.22v-10.54h31.5v10.54zM141%20103.62H71.26V93.08h69.73zm-69.73%2030.76h31.5v10.54h-31.5zm72.98%200h31.5v10.54h-31.5zM76.58%2079.32h93.84a5.3%205.3%200%200%201%205.32%205.27v5.27H71.26v-5.27a5.3%205.3%200%200%201%205.32-5.27m-5.32%2074.1v-5.28h31.5v10.54H76.57a5.3%205.3%200%200%201-5.32-5.27m99.16%205.26h-26.18v-10.54h31.5v5.27a5.3%205.3%200%200%201-5.32%205.27'/%3e%3c/svg%3e`,alt:`no data`,style:{width:`300px`,height:`300px`}}),(0,i.jsx)(xa,{variant:`heading-3`,children:`No Data`}),(0,i.jsx)(`div`,{className:B9.chartButton,children:(0,i.jsx)(xa,{variant:`body-text-2`,children:`Enter Your Query to Visualize `})})]}),C===`LOADING`&&(0,i.jsx)(`div`,{className:B9.LoaderContainer,children:(0,i.jsx)(D6,{})}),C===`CHART`&&(0,i.jsx)(`div`,{className:B9.chartWrapper,children:(0,i.jsx)(Q5,{variables:{},pivotDrillState:we,chartOptions:w,data:S.data,filterValues:[],onMaximize:()=>{},colors:u,config:{ref:ee,onColumnSizingChange:T}})}),C===`ERROR`&&(0,i.jsx)(xa,{variant:`heading-3`,color:`alert`,children:S.error})]}),(0,i.jsx)(s7,{chartTypePanelProps:{isOpen:ve,onClose:()=>ye(!1),enabledCharts:be,onChartChange:e=>{pe({chartType:e})},selectedChart:w.chartType,zIndex:9999}}),(0,i.jsx)(TJ,{isOpen:ne,onClose:()=>x(!1),headerTitle:`Save To Dashboard`,children:(0,i.jsx)(nH,{onCancel:()=>x(!1),onSubmit:d?ie:ae,error:re,defaultValues:d?{name:d.name,description:d.description,isLive:d.isLive,metricId:d.isCreatedByClient?d.metricId:`update_${d.metricId}_by_${e}_${Date.now()}`}:void 0,isCreatingMetric:te})})]})}})),gEr,_Er,vEr=h((()=>{_fn(),gbe(),gEr=()=>({clientIdPlaceholder:qoe,hasDatabaseNamePlaceholder:dbe,hasTenantPredicate:ube,tenantPredicateRegex:cbe}),_Er=e=>gfn(e,gEr())})),V9,H9,yEr=h((()=>{V9=`Unpublished. Only you can see this chart.`,H9=e=>!e.createdByIdentifier||e.isPublished===!0?!1:e.isPublished===!1||!!e.externalDashboardMetrics?.[0]?.externalDashboard?.isAllowPrivateMetricsByDefault})),bEr,xEr=h((()=>{sr(),YK(),bEr=(e,t)=>{let{mutate:r,isPending:i}=iKt();return{onSaveGalleryMetrics:(0,n.useCallback)((n,i)=>{r({data:{externalMetricIds:n},token:e},{onSuccess:async e=>{e?.error||(t?.(Wn),i(),window.location.reload())}})},[e]),isLoading:i}}})),SEr,CEr,wEr,TEr=h((()=>{SEr=100,CEr=1e3,wEr=({itemCount:e,initialCount:t,incrementCount:r,resetKey:i,isActive:a=!0})=>{let[o,s]=(0,n.useState)(null),[l,u]=(0,n.useState)({resetKey:i,isActive:a,initialCount:t,count:t}),d=(0,n.useRef)(!1),f=(0,n.useRef)(void 0),[p,m]=(0,n.useState)(!1),h=l.resetKey!==i||l.isActive!==a||l.initialCount!==t;h&&u({resetKey:i,isActive:a,initialCount:t,count:t});let g=a?Math.min(h?t:l.count,e):0,_=g<e,v=(0,n.useRef)(null),y=(0,n.useCallback)((n=!1)=>{if(!a||!_||d.current)return;d.current=!0;let o=()=>{f.current=void 0,m(!1),u({resetKey:i,isActive:a,initialCount:t,count:Math.min(g+r,e)})};n?(m(!0),f.current=setTimeout(o,CEr)):o()},[_,a,e,i,g,t,r]);(0,n.useLayoutEffect)(()=>{let n=v.current,s=!n||n.container!==o||n.resetKey!==i||n.isActive!==a||n.itemCount!==e||n.initialCount!==t||n.incrementCount!==r,l=!n||n.container!==o||n.resetKey!==i||n.isActive!==a||n.initialCount!==t;s&&(clearTimeout(f.current),f.current=void 0,m(!1)),(s||n?.visibleCount!==g)&&(d.current=!1),l&&o&&a&&(o.scrollTop=0),v.current={container:o,resetKey:i,isActive:a,itemCount:e,initialCount:t,incrementCount:r,visibleCount:g}},[o,i,a,e,t,r,g]),(0,n.useEffect)(()=>()=>{clearTimeout(f.current),f.current=void 0},[]);let b=(0,n.useCallback)(()=>{!o||o.clientHeight<=0||o.clientWidth<=0||o.scrollHeight-o.scrollTop-o.clientHeight<SEr&&y(!0)},[o,y]);return(0,n.useEffect)(()=>{if(!o||!a||!_)return;let e,t=()=>{e===void 0&&(e=requestAnimationFrame(()=>{e=void 0,o.clientHeight>0&&o.clientWidth>0&&o.scrollHeight<=o.clientHeight&&y()}))};t();let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(o),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t),e!==void 0&&cancelAnimationFrame(e)}},[o,_,a,y]),{containerRef:s,handleScroll:b,visibleCount:g,hasMore:_,isLoadingMore:a&&!h&&_&&p}}})),EEr,DEr,OEr,kEr,AEr,jEr,MEr,U9,NEr=h((()=>{EEr=`_manageMetricCard_g7m0a_8`,DEr=`_borderPrimary_g7m0a_12`,OEr=`_manageMetricContainer_g7m0a_16`,kEr=`_cardContainer_g7m0a_20`,AEr=`_metricName_g7m0a_24`,jEr=`_chart_g7m0a_28`,MEr=`_manageButton_g7m0a_32`,U9={manageMetricCard:EEr,borderPrimary:DEr,manageMetricContainer:OEr,cardContainer:kEr,metricName:AEr,chart:jEr,manageButton:MEr}})),PEr,FEr,IEr,LEr=h((()=>{R9(),sr(),vEr(),yEr(),xEr(),ZK(),TEr(),hY(),tTr(),NEr(),PEr=({verdict:e,isGateOn:t})=>{if(!t||!e)return null;let n=e.status===`all-client`||e.status===`rejected`&&e.findings.every(e=>e.code===`ALL_CLIENT_UNACKNOWLEDGED`);return e.status!==`rejected`&&!n?null:(0,i.jsx)(`div`,{className:`dbn:pt-1`,"data-testid":`tenant-scope-notice-${e.metricId??``}`,"data-tenant-scope":n?`all-client`:`unscoped`,title:e.findings.map(e=>e.message).join(` `),children:(0,i.jsx)(xa,{variant:`body-text-3`,color:n?`gray-dark`:`alert-dark`,children:n?`Shows every customer’s data`:`Not limited to one customer`})})},FEr=({metric:e})=>H9(e)?(0,i.jsx)(`div`,{className:`dbn:pt-1`,"data-testid":`unpublished-notice-${e?.id}`,children:(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:V9})}):null,IEr=({props:{metricList:e,token:t,client:r,companyTenancyType:a,workspaceId:o,chartAppearance:s,colors:l,isOpenModal:u,setOpenModal:d,onServerEvent:f,datasourceId:p,language:m,translationDictionary:h,externalDashboardId:g,companyId:_}})=>{let[v,y]=(0,n.useState)([]),[b,x]=(0,n.useState)(``),[S,C]=(0,n.useState)(null),w=v.join(`|`),T=S===w;(0,n.useEffect)(()=>{if(e?.length){let t=(e?.filter(e=>e?.clientGalleryMetrics?.length))?.map(e=>e?.id);y(t)}},[e]);let{onSaveGalleryMetrics:ee,isLoading:te}=bEr(t,f),{saveLogsAsync:ne}=XK(),re=(0,n.useMemo)(()=>{let t=new Map;return(e??[]).forEach(e=>{e?.id&&t.set(e.id,_Er({metric:e,datamart:{tenancyLevel:a},acknowledgedAllClient:T}))}),t},[e,a,T]),ie=(0,n.useMemo)(()=>v.map(e=>re.get(e)).filter(e=>!!e&&e.status===`rejected`),[v,re]),ae=(0,n.useMemo)(()=>v.map(e=>re.get(e)).filter(e=>!!e&&(e.status===`all-client`||e.findings.some(e=>e.code===`ALL_CLIENT_UNACKNOWLEDGED`))),[v,re]),oe=(0,n.useMemo)(()=>ie.filter(e=>e.findings.some(e=>e.code!==`ALL_CLIENT_UNACKNOWLEDGED`)),[ie]),se=ie.length>0,ce=(e,t)=>{y(n=>{let r=t??!n.includes(e),i=n.filter(t=>t!==e);return r?[...i,e]:i})},le=(0,n.useMemo)(()=>b?e?.filter(e=>e?.clientGalleryMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(b?.toLowerCase())):e?.filter(e=>e?.clientGalleryMetrics?.length),[e,b]),ue=(0,n.useMemo)(()=>b?e?.filter(e=>!e?.clientGalleryMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(b?.toLowerCase())):e?.filter(e=>!e?.clientGalleryMetrics?.length),[e,b]),{containerRef:de,handleScroll:fe,visibleCount:pe,isLoadingMore:me}=wEr({initialCount:4,incrementCount:4,itemCount:(ue?.length||0)+(le?.length||0),resetKey:JSON.stringify([o,r,b]),isActive:u}),he=ue?.slice(0,pe),ge=le?.slice(0,Math.max(0,pe-(ue?.length||0)));return(0,i.jsxs)(TJ,{isOpen:u,onClose:()=>{f?.(Hn),d(!1)},headerTitle:`Metrics Gallery`,children:[(0,i.jsxs)(ZZ,{className:U9.manageMetricContainer,direction:`col`,children:[(0,i.jsx)(F7,{setSearchKeyword:x,className:`dbn:w-full`}),(0,i.jsxs)(ZZ,{containerRef:de,onScroll:fe,direction:`row`,className:`dbn:overflow-y-auto dbn:gap-2 dbn:flex-wrap dbn:flex-1 dbn:min-h-0 dbn:content-start dbn:pb-3`,children:[he?.map(e=>{let n=v?.includes(e?.id);return(0,i.jsxs)(`button`,{className:`${U9.manageMetricCard} ${n?`dbn-manage-metric-card ${U9.borderPrimary}`:``}`,"aria-pressed":n,onClick:()=>ce(e.id),type:`button`,"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{ce(e.id,t)}})]}),(0,i.jsx)(PEr,{verdict:re.get(e?.id),isGateOn:!0}),(0,i.jsx)(FEr,{metric:e}),(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a})})]},e?.id)}),ge?.map(e=>{let n=v?.includes(e?.id);return(0,i.jsxs)(`button`,{className:`${U9.manageMetricCard} ${n?`dbn-manage-metric-card ${U9.borderPrimary}`:``}`,"aria-pressed":n,onClick:()=>ce(e.id),type:`button`,"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{ce(e.id,t)}})]}),(0,i.jsx)(PEr,{verdict:re.get(e?.id),isGateOn:!0}),(0,i.jsx)(FEr,{metric:e}),(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a})},e.id)]},e?.id)}),me&&(0,i.jsx)(ZZ,{className:`dbn:w-full dbn:pb-6`,children:(0,i.jsx)(D6,{})})]}),oe.length?(0,i.jsx)(`div`,{"data-testid":`tenant-scope-blocked`,className:`dbn:w-full`,children:(0,i.jsx)(o$,{variant:`error`,text:oe.length===1?`1 chart cannot be shared yet.`:`${oe.length} charts cannot be shared yet.`,className:`dbn:w-full dbn:flex-col dbn:items-start dbn:gap-1`,childrenClassName:`dbn:w-full dbn:flex-col dbn:items-start dbn:px-1`,children:(0,i.jsx)(`ul`,{className:`dbn:list-none dbn:m-0 dbn:p-0`,children:oe.map(e=>(0,i.jsx)(`li`,{children:(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:`${e.metricName??`Untitled chart`}: ${e.findings[0]?.message??``}`})},e.metricId??e.metricName))})})}):null,!oe.length&&ae.length?(0,i.jsx)(`div`,{"data-testid":`tenant-scope-all-client`,className:`dbn:w-full`,children:(0,i.jsx)(o$,{variant:`warning`,text:ae.length===1?`1 selected chart shows every customer’s data, not just this one’s.`:`${ae.length} selected charts show every customer\u2019s data, not just this one\u2019s.`,className:`dbn:w-full`,children:(0,i.jsx)(y$,{id:`tenant-scope-acknowledge`,label:`Share them anyway`,containerClass:`dbn:whitespace-nowrap dbn:text-xs`,checked:T,onChange:({target:{checked:e}})=>C(e?w:null),"data-testid":`tenant-scope-acknowledge`})})}):null]}),(0,i.jsxs)(EJ,{children:[(0,i.jsx)(Xs,{variant:`tab`,onClick:()=>{f?.(Hn),d(!1)},className:`cta-secondary`,children:`Discard`}),(0,i.jsx)(Xs,{variant:`primary`,onClick:()=>{se||ee(v,async()=>await ne({clientId:r,data:{companyId:_,feature:`GALLERY`,dashboardId:g},isFrontendApp:!1,token:t}))},isDisabled:te||!e?.length||se,className:`cta-primary`,"data-testid":`gallery-save`,children:`Save`})]})]})}})),REr,zEr,BEr=h((()=>{WK(),REr=({clientId:e,tableName:t,tenancyLevel:n})=>n!==`DATABASE`||!e||!t?t||``:`${e}.${_x(t).name}`,zEr=({applyOnTables:e,clientId:t,tenancyLevel:n})=>e?.map(e=>({...e,tableName:REr({clientId:t,tableName:e.tableName,tenancyLevel:n})}))})),VEr,HEr,UEr,WEr=h((()=>{VEr=(e,t)=>Array.isArray(e)?e:e&&typeof e==`object`?Object.entries(e).map(([e,n])=>({id:e,[t]:n})):[],HEr=e=>VEr(e,`xAxisSettings`),UEr=e=>VEr(e,`yAxisSettings`)})),GEr,KEr=h((()=>{sr(),GEr=({hasToken:e,isLoading:t,error:r,isLoaded:i,onServerEvent:a})=>{(0,n.useEffect)(()=>{e?r?a?.(r):t?a?.(Nn):i&&a?.(Pn):a?.(`INVALID_TOKEN`)},[e,t,r,i,a])}})),qEr,JEr=h((()=>{qEr=(e,t)=>{if(e.current)return e.current;let n=Promise.resolve().then(t).finally(()=>{e.current===n&&(e.current=null)});return e.current=n,n}})),YEr,XEr=h((()=>{E0t(),YEr=e=>aY.sanitize(e,{ALLOWED_TAGS:[`svg`,`path`,`circle`,`rect`,`line`,`polygon`,`polyline`,`ellipse`,`g`,`defs`,`use`],ALLOWED_ATTR:[`viewBox`,`xmlns`,`fill`,`stroke`,`stroke-width`,`stroke-linecap`,`stroke-linejoin`,`d`,`cx`,`cy`,`r`,`x`,`y`,`width`,`height`,`points`,`transform`,`id`,`class`],FORBID_TAGS:[`script`,`iframe`,`object`,`embed`,`foreignObject`],FORBID_ATTR:[`on*`,`href`,`xlink:href`],ALLOW_DATA_ATTR:!1,RETURN_TRUSTED_TYPE:!1})})),ZEr,QEr,$Er,eDr=h((()=>{ZEr=`localStorageValueSet`,QEr=`dbn:embed-config`,$Er=e=>{document.dispatchEvent(new CustomEvent(ZEr,{detail:e})),document.dispatchEvent(new CustomEvent(QEr,{detail:e}))}})),tDr,nDr=h((()=>{tDr=()=>(0,i.jsx)(`h1`,{className:`sr-only`,children:`Metric builder`})})),rDr,iDr=h((()=>{$q(),q7t(),Dc(),nq(),rDr=({clientId:e,companyId:t,isLiveMode:n,externalDashboardId:r,userProvidedDashboardId:i,chartColors:a,isShowMetricCreateModal:o,setShowMetricCreateModal:s,metric:l,metricData:u,workspaceId:d,token:f,clientColumnType:p,tenancyType:m,datasourceId:h,setEditMetric:g,onServerEvent:_,refetchDashboardData:v,saveDashLayout:y,isIncrementalJoin:b,customChartSettings:x})=>{let{data:S}=Ec(),C=SKt({principal:{isAllClient:S?.isAllClient,clientId:e},tenancyLevel:m}),w={clientId:e,companyId:t,isLiveMode:n,externalDashboardId:r,userProvidedDashboardId:i,chartColors:a,isShowMetricCreateModal:o,setShowMetricCreateModal:s,metric:l,metricData:u,clientColumnType:p,datasourceId:h,setEditMetric:g,databaseName:m===`MULTI_DATABASE`&&e||``,refetchDashboardData:v,onServerEvent:_,saveDashLayout:y,customChartSettings:x},T=K7t(w),ee={isIncrementalJoin:!!b,dashboardId:i,datasetSettings:T.datasetSettings,clientSubsetData:T.clientSubsetData,clientId:e,shouldApplyClientDataScope:C,setError:T.setError,setLoading:T.setLoading,setData:T.setData,setQuery:T.setQuery,setGroupByList:T.setGroupByList,chart:T.chartSettings.chartType,setChartSettings:T.setChartSettings,chartSettings:T.chartSettings,dbName:T.dbName,data:T.data||[],limit:T.limit||`100`,setDatasetSettings:T.setDatatsetSettings,token:f,workspaceId:d,clientColumnType:p,isDatabaseTenancy:m===`DATABASE`,setDrillDownSettings:T.setDrillDownSettings,drillDownSettings:T.drillDownSettings,datasourceId:h,id:l?.id,companyId:t,onServerEvent:_,metricEncryptedQuery:l?.query,rlsConditions:T.rlsConditions,isFrontendApp:!1,encryptedClientId:``};return{config:w,metricConfig:T,datasetConfig:ee,dataset:rZt(ee)}}}));function aDr(e,t){return e&&t}function oDr({isLoading:e,hasData:t,hasSelectedFields:n,chartSettings:r}){return!e&&t&&n&&!lDr.includes(r.chartType)}function sDr(e){return!(e?.tableSettings?.isServerSidePagination&&e?.chartType===$.table)}function cDr(e){return!!e?.isMultiDimension&&!!e?.seriesField&&e.seriesField!==`ungrouped`}var lDr,uDr,dDr,fDr,pDr,mDr,hDr,gDr,_Dr=h((()=>{r$(),hlr(),Zvn(),XHn(),QHn(),my(),F8(),E6(),B8(),lDr=[$.pivotV2,$.funnelV2,...Object.values(Q_)],uDr=`relative h-7 gap-1.5 border-(--border) bg-(--muted) px-2 text-xs font-medium text-(--muted-foreground) hover:text-(--foreground)`,dDr=`size-7 border-(--border) bg-(--muted) text-(--muted-foreground) hover:text-(--foreground)`,fDr=`bg-(--accent) text-(--foreground)`,pDr=()=>(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-4 w-px shrink-0 self-center bg-(--border)`}),mDr=({field:e})=>(0,i.jsxs)(`span`,{...R8(`builder-toolbar`,`group-by-indicator`),className:`inline-flex h-7 max-w-45 shrink-0 items-center gap-1.5 rounded-(--radius-sm) border border-(--border) bg-(--muted) px-2 text-xs font-medium text-(--muted-foreground)`,children:[(0,i.jsx)(khn,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsxs)(`span`,{className:`truncate`,children:[`Grouped by `,(0,i.jsx)(`span`,{className:`text-(--foreground)`,children:e})]})]}),hDr=({testId:e,srLabel:t})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,...R8(e),className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-(--foreground)`}),(0,i.jsxs)(`span`,{className:`sr-only`,children:[` `,t]})]}),gDr=({chartSettings:e,hasData:t,hasSelectedFields:n,isLoading:r=!1,limit:a,setLimit:o,onChangeLimit:s,onOpenFilters:l,onOpenSort:u,onOpenChartType:d,onOpenChartAppearance:f,hasActiveFilters:p=!1,hasActiveSort:m=!1,onClearAll:h,showChartTypeTrigger:g=!0,filtersPanelProps:_,sortPanelProps:v,chartTypePanelProps:y,chartAppearancePanelProps:b,className:x})=>{let S=aDr(t,n),C=oDr({isLoading:r,hasData:t,hasSelectedFields:n,chartSettings:e}),w=sDr(e),T=cDr(e),ee=e=>{o(e),s(e)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{...R8(`builder-toolbar`),"data-slot":`builder-toolbar`,className:KH(`flex h-10 w-full shrink-0 items-center justify-between gap-2 rounded-t-(--radius-md) border border-b-0 border-(--border) bg-(--background) px-2`,x),children:[(0,i.jsxs)(`div`,{...R8(`builder-toolbar`,`query-actions`),className:`flex min-w-0 items-center gap-1`,children:[S?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`builder-toolbar`,`filters`),"aria-expanded":_.isOpen,onClick:l,className:KH(uDr,p&&fDr),children:[(0,i.jsx)(ZQ,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Filters`}),p?(0,i.jsx)(hDr,{testId:`builder-toolbar-filters-active-indicator`,srLabel:`(filter applied)`}):null]}):null,S?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`builder-toolbar`,`sort`),"aria-expanded":v.isOpen,onClick:u,className:KH(uDr,m&&fDr),children:[(0,i.jsx)(HQ,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Sort`}),m?(0,i.jsx)(hDr,{testId:`builder-toolbar-sort-active-indicator`,srLabel:`(sort applied)`}):null]}):null,T?(0,i.jsx)(mDr,{field:e.seriesField}):null]}),(0,i.jsxs)(`div`,{...R8(`builder-toolbar`,`output-controls`),className:`flex shrink-0 items-center gap-1`,children:[w?(0,i.jsxs)(r3n,{value:a??``,onValueChange:ee,children:[(0,i.jsxs)(a3n,{...L8(`builder-toolbar`,`limit`),size:`sm`,className:`h-7 gap-1 px-2 text-xs font-medium`,"aria-label":`Row limit`,title:`Show top N rows: sort your measure from highest to lowest, then choose a row limit. For Top 50, choose 50.`,children:[(0,i.jsx)(`span`,{className:`text-(--muted-foreground)`,children:`Row limit`}),(0,i.jsx)(i3n,{placeholder:`-`})]}),(0,i.jsx)(o3n,{children:Ase.map(e=>(0,i.jsx)(s3n,{value:e.value,children:e.label},e.value))})]}):null,g?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`builder-toolbar`,`chart-type`),"aria-expanded":y.isOpen,onClick:d,className:uDr,children:[(0,i.jsx)(GQ,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Chart type`})]}):null,C?(0,i.jsx)(B6,{type:`button`,variant:`outline`,size:`icon-sm`,...L8(`builder-toolbar`,`chart-appearance`),"aria-expanded":b.isOpen,"aria-label":`Chart appearance`,onClick:f,className:dDr,children:(0,i.jsx)(fgn,{"aria-hidden":`true`})}):null,h?(0,i.jsx)(pDr,{}):null,h?(0,i.jsxs)(B6,{type:`button`,variant:`ghost`,size:`sm`,...L8(`builder-toolbar`,`clear-all`),onClick:h,className:`h-7 px-2 text-xs font-medium`,children:[(0,i.jsx)(ohn,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Clear all`})]}):null]})]}),(0,i.jsx)(YHn,{filtersPanelProps:_}),(0,i.jsx)(ZHn,{SortPanelProps:v}),(0,i.jsx)(s7,{chartTypePanelProps:y}),(0,i.jsx)(Xvn,{ChartAppearancePanelProps:b})]})}})),vDr,yDr,bDr,xDr=h((()=>{RK(),xQ(),r$(),ein(),F8(),E6(),B8(),vDr=I8(`create-metric-header`,`save`,`reason`),yDr=`Untitled metric`,bDr=({metricName:e,isSaved:t=!1,statusLabel:r=`Draft`,title:a=`Create metric`,onBack:o,backAriaPrefix:s=`Back to`,onSave:l,saveLabel:u=`Save to dashboard`,isLoading:d=!1,chartSettings:f,dimensions:p,metrics:m,isCustomTable:h,rows:g,className:_})=>{let v=n.useMemo(()=>bQ({chartSettings:f,dimensions:p,metrics:m,isCustomTable:h}),[f,p,m,h]),y=!d&&v!==null,b=d||y,x=()=>{b||l()},S=e?.trim()?e.trim():yDr,C=n.useMemo(()=>{let e=Zrn(f,g??[],void 0);return e?bbt(e):null},[f,g]),w=(0,i.jsxs)(B6,{type:`button`,variant:`primary`,size:`md`,...L8(`create-metric-header`,`save`),onClick:x,"aria-disabled":b,"aria-busy":d,"aria-describedby":y?vDr:void 0,className:KH(`shrink-0`,b&&`cursor-not-allowed border-(--border) bg-(--muted) text-(--muted-foreground) hover:bg-(--muted)`),children:[d?(0,i.jsx)(Rhn,{className:`size-4 animate-spin`,"aria-hidden":`true`}):null,(0,i.jsx)(`span`,{children:u})]});return(0,i.jsxs)(`div`,{"data-slot":`create-metric-header`,className:KH(`flex min-h-14 w-full shrink-0 items-center justify-between gap-4 border-b border-(--border) bg-(--card) px-4 py-2`,_),children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,i.jsxs)(`button`,{type:`button`,...L8(`create-metric-header`,`back`),onClick:o,className:`-ml-1 flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-(--radius-sm) border border-transparent bg-transparent text-(--muted-foreground) hover:bg-(--muted) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:[(0,i.jsxs)(`span`,{className:`sr-only`,children:[s,` `,a]}),(0,i.jsx)(Gpn,{className:`size-4`,"aria-hidden":`true`})]}),(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-(--border)`}),(0,i.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,i.jsx)(`h2`,{...L8(`create-metric-header`,`title`),className:`truncate text-sm leading-5 font-medium text-(--foreground)`,children:S}),t?null:(0,i.jsx)(`span`,{...L8(`create-metric-header`,`status`),className:`inline-flex h-5 shrink-0 items-center rounded-(--radius-sm) border border-(--border) px-2 text-xs leading-4 font-normal text-(--muted-foreground)`,children:r})]}),C?(0,i.jsx)(`p`,{...L8(`create-metric-header`,`answer-line`),className:`truncate text-xs leading-4 font-normal text-(--muted-foreground)`,children:C}):null]})]}),y?(0,i.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,i.jsx)(v3n,{children:(0,i.jsxs)(y3n,{children:[(0,i.jsx)(b3n,{asChild:!0,children:w}),(0,i.jsx)(x3n,{side:`bottom`,align:`end`,children:v})]})}),(0,i.jsx)(`span`,{id:vDr,className:`sr-only`,children:v})]}):w]})}})),W9,SDr,CDr,wDr,TDr=h((()=>{r$(),Qdn(),W9=e=>{let t=(e||``).toLowerCase();return Kdn.includes(t)||t.startsWith(`decimal`)||t.startsWith(`numeric`)?`numeric`:qdn.includes(t)||t.includes(`char`)?`text`:Ydn.includes(t)?`array`:Jdn.includes(t)||t.includes(`timestamp`)||t.includes(`date`)?`date`:Xdn.includes(t)?`boolean`:`unknown`},SDr={numeric:bhn,text:jgn,date:WQ,boolean:Egn,array:Fhn,unknown:Lmn},CDr={numeric:`Numeric column`,text:`Text column`,date:`Date column`,boolean:`Boolean column`,array:`List column`,unknown:`Column`},wDr=({kind:e})=>{let t=SDr[e];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsx)(`span`,{className:`sr-only`,children:CDr[e]})]})}})),EDr,DDr,ODr,kDr,ADr,jDr,MDr,NDr,PDr,FDr,IDr,LDr,RDr,zDr,BDr,VDr,HDr,UDr=h((()=>{TDr(),Ge(),r$(),zdt(),fJ(),F8(),E6(),B8(),EDr=({kind:e})=>{let t=SDr[e];return(0,i.jsxs)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-(--muted-foreground)`,children:[(0,i.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsx)(`span`,{className:`sr-only`,children:CDr[e]})]})},DDr=e=>e.label||e.dataMartColumnAlias||e.name,ODr=(e,t)=>t?e.label?e.label.toLowerCase().includes(t):e.dataMartColumnAlias?e.dataMartColumnAlias.toLowerCase().includes(t):e.name?e.name.toLowerCase().includes(t):!1:!0,kDr=(e,t)=>`${e} ${t}${e===1?``:`s`}`,ADr=e=>`${e.schemaName||``}.${e.tableName}`,jDr=e=>e.columnsWithDataType??[],MDr=e=>e.columnsWithDataType?.length??e.columns?.length??0,NDr=e=>{let t=e.filter(e=>W9(e.dataType)===`numeric`);return!t.length||t.length===e.length?e:[...t,...e.filter(e=>W9(e.dataType)!==`numeric`)]},PDr=({label:e})=>(0,i.jsx)(`span`,{className:`inline-block max-w-40 truncate rounded-(--radius-sm) bg-(--popover) px-2 py-0.5 text-xs font-medium text-(--popover-foreground) shadow-(--shadow-overlay) ring-1 ring-(--border)`,children:e}),FDr=`flex h-7 w-full shrink-0 items-center gap-2 rounded-(--radius-sm) py-0 pr-2 pl-7 text-left text-mono transition-colors select-none hover:bg-(--muted) focus-visible:bg-(--muted) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,IDr=({table:e,column:t})=>{let r=n.useMemo(()=>({table:e,column:{...t,alias:t.dataMartColumnAlias||t.name}}),[e,t]),a=DDr(t),{DragNodeRef:o}=dJ({identifier:{id:t.name,type:`column`},data:r,modifiers:{highlightDrop:{onDrag:!0}},CustomDragPreview:(0,i.jsx)(PDr,{label:a})}),s=W9(t.dataType),l=z8(`data-rail-column`,t.name);return(0,i.jsxs)(`div`,{ref:o,"data-slot":`data-rail-column`,"data-testid":l[`data-testid`],className:KH(FDr,`group/data-rail-row cursor-grab text-(--foreground) active:cursor-grabbing`),title:t.description?`${a}: ${t.description}`:a,children:[(0,i.jsx)(EDr,{kind:s}),(0,i.jsx)(`span`,{className:`truncate`,children:a}),(0,i.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[t.type===`custom`?(0,i.jsx)(`span`,{className:`text-caption font-medium text-(--muted-foreground)`,children:`fx`}):null,(0,i.jsx)(_hn,{"aria-hidden":`true`,className:`size-3.5 text-(--muted-foreground) opacity-0 transition-opacity group-hover/data-rail-row:opacity-100 group-focus-visible/data-rail-row:opacity-100`})]})]})},LDr=({table:e,column:t,onSelectTable:n})=>{let r=DDr(t),a=z8(`data-rail-preview-column`,t.name);return(0,i.jsxs)(`button`,{type:`button`,"data-slot":`data-rail-preview-column`,...a,className:KH(FDr,`text-(--muted-foreground)`),title:[`${r} - select ${iV(e)} to use it`,t.description].filter(Boolean).join(`: `),onClick:()=>n(e),children:[(0,i.jsx)(EDr,{kind:W9(t.dataType)}),(0,i.jsx)(`span`,{className:`truncate`,children:r})]})},RDr=({children:e})=>(0,i.jsxs)(`div`,{className:`sticky top-0 z-10 flex shrink-0 items-center gap-2 bg-(--background) px-2 pt-2 pb-1 text-caption font-semibold tracking-widest text-(--muted-foreground) uppercase`,children:[(0,i.jsx)(`span`,{className:`truncate`,children:e}),(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-(--border)`})]}),zDr=({node:e,isSelected:t,isExpanded:n,onToggleExpand:r,onSelectTable:a})=>{let{table:o,key:s,visibleColumns:l}=e,u=iV(o),d=I8(`data-rail-table-columns`,s),f=MDr(o);return(0,i.jsxs)(`div`,{"data-slot":`data-rail-table-node`,className:`flex shrink-0 flex-col`,children:[(0,i.jsxs)(`div`,{className:KH(`flex h-8 shrink-0 items-center gap-1 rounded-(--radius-sm) pr-2 pl-1 transition-colors hover:bg-(--muted)`,t&&`bg-(--muted)`),children:[(0,i.jsx)(`button`,{type:`button`,...z8(`data-rail-table-toggle`,s),"aria-expanded":n,"aria-controls":d,"aria-label":`${n?`Collapse`:`Expand`} ${u}`,onClick:()=>r(s),className:`flex size-6 shrink-0 items-center justify-center rounded-(--radius-sm) text-(--muted-foreground) transition-colors hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,children:(0,i.jsx)(YQ,{"aria-hidden":`true`,className:KH(`size-3.5 transition-transform`,n&&`rotate-90`)})}),(0,i.jsxs)(`button`,{type:`button`,...z8(`data-rail-table`,s),"aria-current":t?`true`:void 0,title:[o.schemaName?`${o.schemaName}.${u}`:u,o.description].filter(Boolean).join(`: `),onClick:()=>a(o),onKeyDown:e=>{e.key===`ArrowRight`&&!n&&(e.preventDefault(),r(s)),e.key===`ArrowLeft`&&n&&(e.preventDefault(),r(s))},className:KH(`flex h-6 min-w-0 flex-1 items-center gap-2 rounded-(--radius-sm) px-1 text-left text-mono text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,t?`font-semibold`:`font-medium`),children:[(0,i.jsx)(e$,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-(--muted-foreground)`}),(0,i.jsx)(`span`,{className:`truncate`,children:u}),(0,i.jsx)(`span`,{className:`ml-auto shrink-0 text-caption font-normal tabular-nums text-(--muted-foreground)`,children:f})]})]}),o.description?(0,i.jsx)(`p`,{className:`px-8 pb-1 text-caption text-(--muted-foreground)`,children:o.description}):null,n?(0,i.jsx)(`div`,{id:d,role:`group`,"aria-label":`${u} columns`,className:`flex flex-col gap-px pb-1`,children:l.length===0?(0,i.jsx)(`span`,{className:KH(FDr,`text-(--muted-foreground)`),children:`No columns`}):l.map(e=>t?(0,i.jsx)(IDr,{table:o,column:e},e.name):(0,i.jsx)(LDr,{table:o,column:e,onSelectTable:a},e.name))}):null]})},BDr={connected:`bg-(--success-fg)`,syncing:`bg-(--warning-fg)`,error:`bg-(--destructive)`},VDr={connected:`Connected`,syncing:`Syncing`,error:`Connection error`},HDr=({tableList:e,selectedTable:t,onSelectTable:r,onSearchFocus:a,datasourceName:o,datasourceStatus:s,datasourceError:l,isCollapsed:u,onToggleCollapse:d,defaultCollapsed:f=!1,className:p})=>{let[m,h]=n.useState(``),[g,_]=n.useState({}),[v,y]=n.useState(f),b=u??v,x=()=>{let e=!b;u===void 0&&y(e),d?.(e)},S=t?ADr(t):``,C=m.trim().toLowerCase(),w=n.useMemo(()=>e.map(e=>{let t=NDr(jDr(e)),n=!C||iV(e).toLowerCase().includes(C)||e.tableName.toLowerCase().includes(C),r=C?t.filter(e=>ODr(e,C)):t;return{table:e,key:ADr(e),nameMatches:n,visibleColumns:r.length>0?r:t,hasColumnHit:!!C&&r.length>0}}).filter(e=>e.nameMatches||e.hasColumnHit),[e,C]),T=n.useMemo(()=>{let e=new Map;return w.forEach(t=>{let n=t.table.schemaName||``,r=e.get(n);r?r.push(t):e.set(n,[t])}),Array.from(e,([e,t])=>({schema:e,nodes:t}))},[w]),ee=T.some(e=>!!e.schema),te=e=>e.hasColumnHit||e.key===S||!!g[e.key],ne=e=>{_(t=>({...t,[e]:!t[e]}))},re=e.length,ie=e.reduce((e,t)=>e+MDr(t),0),ae=w.reduce((e,t)=>e+t.visibleColumns.length,0),oe=C?`${w.length} of ${re} tables, ${ae} of ${ie} columns`:`${kDr(re,`table`)}, ${kDr(ie,`column`)}`,se=(0,i.jsx)(`button`,{type:`button`,...L8(`data-rail-collapse`),"aria-expanded":!b,"aria-label":b?`Expand data panel`:`Collapse data panel`,title:b?`Expand data panel`:`Collapse data panel`,onClick:x,className:`flex size-6 shrink-0 items-center justify-center rounded-(--radius-sm) text-(--muted-foreground) transition-colors hover:bg-(--muted) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,children:b?(0,i.jsx)(tgn,{"aria-hidden":`true`,className:`size-4`}):(0,i.jsx)(Qhn,{"aria-hidden":`true`,className:`size-4`})});return b?(0,i.jsxs)(`div`,{"data-slot":`data-rail`,"data-collapsed":`true`,...L8(`data-rail`),className:KH(`flex h-full w-11 shrink-0 flex-col items-center gap-2 border-r border-(--border) bg-(--background) py-2`,p),children:[se,(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-6 shrink-0 bg-(--border)`}),(0,i.jsx)(`span`,{className:`text-caption font-semibold tracking-widest text-(--muted-foreground) uppercase dbn-v2-vertical-rl`,children:`Data`}),(0,i.jsxs)(`span`,{...L8(`data-rail-count`),title:oe,className:`mt-auto text-caption tabular-nums text-(--muted-foreground)`,children:[re,(0,i.jsxs)(`span`,{className:`sr-only`,children:[` `,oe]})]})]}):(0,i.jsxs)(`div`,{"data-slot":`data-rail`,"data-collapsed":`false`,...L8(`data-rail`),className:KH(`flex h-full w-67 shrink-0 flex-col border-r border-(--border) bg-(--background)`,p),children:[(0,i.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-(--border) pr-2 pl-3`,children:[(0,i.jsx)(`span`,{className:`truncate text-xs font-semibold tracking-tight text-(--foreground)`,children:`Data`}),se]}),o?(0,i.jsxs)(`div`,{...L8(`data-rail-datasource`),className:`flex h-8 shrink-0 items-center gap-2 border-b border-(--border) px-3`,title:o,children:[(0,i.jsx)(Qmn,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-(--muted-foreground)`}),(0,i.jsx)(`span`,{className:`truncate text-mono font-medium text-(--foreground)`,children:o}),s?(0,i.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center`,children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:KH(`size-1.5 rounded-full`,BDr[s])}),(0,i.jsx)(`span`,{className:`sr-only`,children:s===`error`&&l?.code?pe(l):VDr[s]})]}):null]}):null,(0,i.jsx)(`div`,{className:`shrink-0 border-b border-(--border) p-2`,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)($Q,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-(--muted-foreground)`}),(0,i.jsx)(s8,{...L8(`data-rail-search`),type:`text`,value:m,onChange:e=>h(e.target.value),onFocus:a,placeholder:`Search tables & columns`,"aria-label":`Search tables and columns`,className:`h-8 pl-7 text-xs`})]})}),(0,i.jsx)(`div`,{...L8(`data-rail-column-list`),className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-2 pb-2`,children:w.length===0?(0,i.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-1 px-4 py-8 text-center`,children:[(0,i.jsx)(`p`,{className:`text-xs font-medium text-(--foreground)`,children:e.length===0?`No tables`:`No matches`}),(0,i.jsx)(`p`,{className:`text-xs text-(--muted-foreground)`,children:e.length===0?`This datasource has no tables to build from.`:`Try a shorter search term.`})]}):(0,i.jsx)(`div`,{...L8(`data-rail-table-select`),role:`group`,"aria-label":`Tables`,className:`flex flex-col`,children:T.map(e=>(0,i.jsxs)(n.Fragment,{children:[ee&&e.schema?(0,i.jsx)(RDr,{children:e.schema}):null,e.nodes.map(e=>(0,i.jsx)(zDr,{node:e,isSelected:e.key===S,isExpanded:te(e),onToggleExpand:ne,onSelectTable:r},e.key))]},e.schema||`__no_schema__`))})}),(0,i.jsx)(`div`,{className:`flex h-8 shrink-0 items-center border-t border-(--border) px-3`,children:(0,i.jsx)(`span`,{...L8(`data-rail-count`),className:`truncate text-caption tabular-nums text-(--muted-foreground)`,children:oe})})]})}})),WDr,GDr,G9,K9,KDr=h((()=>{WDr=`item`,GDr=(...e)=>e.filter(e=>e!=null&&e!==``).map(e=>String(e).trim().replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)).filter(Boolean).join(`-`).replace(/-+/g,`-`)||WDr,G9=(...e)=>({id:GDr(...e),"data-testid":GDr(...e)}),K9=(...e)=>({"data-testid":GDr(...e)})})),qDr,JDr=h((()=>{qDr=({groups:e,onPick:t,disabled:n=!1,defaultOpen:r=!1,filterMode:a,appearance:o=`menu`,Item:s,Group:l,renderShell:u})=>{let[d,f]=x.useState(r),[p,m]=x.useState(``),h=x.useMemo(()=>{let t=p.trim().toLowerCase();return a===`native`||!t?e:e.map(e=>({...e,choices:e.choices.filter(e=>e.searchText.toLowerCase().includes(t))}))},[e,p,a]),g=e=>{n&&e||(f(e),e||m(``))},_=h.map(e=>{let n=e.choices.map(e=>(0,i.jsxs)(s,{id:e.id,"data-testid":e.id,searchText:e.searchText,onSelect:()=>{g(!1),t(e.value)},children:[(0,i.jsx)(`span`,{className:o===`command`?`inline-flex size-3.5 shrink-0 items-center justify-center self-start mt-0.5 text-(--muted-foreground)`:`flex size-3.5 shrink-0 items-center justify-center text-(--muted-foreground)`,children:e.glyph}),(0,i.jsx)(`span`,{className:o===`command`?`min-w-0 flex-1 whitespace-normal break-words`:`truncate tabular-nums`,children:e.label})]},e.key));return l?(0,i.jsx)(l,{heading:e.label,children:n},e.key):(0,i.jsx)(x.Fragment,{children:n},e.key)});return u({open:d,onOpenChange:g,search:p,onSearchChange:m,hasChoices:h.some(e=>e.choices.length>0),children:_})}})),YDr,XDr=h((()=>{r$(),cK(),KDr(),TDr(),JDr(),YDr=({columns:e,onSelectColumn:t,triggerAriaLabel:n,zoneId:r,disabled:a=!1,disabledReason:o,emptyLabel:s=`No columns available`,defaultOpen:l,className:u,components:d})=>{let{Root:f,Trigger:p,Content:m,Button:h,Input:g,Empty:_,Item:v,headerClassName:y}=d,b=a&&!!o,S=x.useMemo(()=>[{key:r,choices:e.map(e=>{let t=e.label||e.dataMartColumnAlias||e.name;return{key:`${e.parentAlias||``}-${e.name}`,value:e,label:t,searchText:t,id:G9(`field-zone`,r,`column`,e.name).id,glyph:(0,i.jsx)(wDr,{kind:W9(e.dataType)})}})}],[e,r]);return(0,i.jsx)(qDr,{groups:S,onPick:t,disabled:a,defaultOpen:l,filterMode:`substring`,Item:v,renderShell:({open:e,onOpenChange:t,search:l,onSearchChange:d,hasChoices:v,children:x})=>(0,i.jsxs)(f,{open:e,onOpenChange:t,children:[(0,i.jsx)(p,{asChild:!0,children:(0,i.jsx)(h,{type:`button`,variant:`outline`,size:`icon-xs`,"aria-disabled":a,"aria-label":b?`${n} - ${o}`:n,title:b?o:void 0,...G9(`field-zone`,r,`add`),className:KH(`shrink-0`,u),children:(0,i.jsx)(ign,{"aria-hidden":`true`})})}),(0,i.jsxs)(m,{align:`start`,size:`lg`,children:[(0,i.jsx)(`div`,{className:y,children:(0,i.jsx)(g,{value:l,onChange:e=>d(e.target.value),placeholder:`Search columns`,"aria-label":`Search columns for ${n}`,className:`h-7`,...G9(`field-zone`,r,`search`),onKeyDown:e=>e.stopPropagation()})}),v?x:(0,i.jsx)(_,{children:s})]})]})})}})),ZDr=h((()=>{xQ()})),QDr,$Dr,eOr,tOr,nOr,rOr,iOr,aOr,oOr,sOr,cOr=h((()=>{TDr(),r$(),my(),xV(),fJ(),F8(),S3n(),E6(),B8(),QDr=new Set(Cv),$Dr=new Set(zv),eOr=new Set(Rv),tOr=e=>{let t=e.helperFunction?.trim();return!t||t.toUpperCase()===`NONE`?null:t.toUpperCase()},nOr=({label:e})=>(0,i.jsx)(`span`,{className:`inline-block max-w-40 truncate rounded-(--radius-sm) bg-(--popover) px-2 py-1 text-xs font-medium text-(--popover-foreground) shadow-(--shadow-overlay) ring-1 ring-(--border)`,children:e}),rOr=`group inline-flex h-7 max-w-full shrink-0 cursor-grab items-center gap-1 rounded-(--radius-sm) border border-(--border) bg-(--muted) px-1 text-xs font-medium text-(--foreground) transition-colors hover:border-(--muted-foreground) active:cursor-grabbing focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,iOr=`cursor-grabbing border-dashed opacity-50`,aOr=`flex h-6 shrink-0 items-center justify-center rounded-(--radius-sm) text-(--muted-foreground) transition-colors hover:bg-(--accent) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,oOr=`h-6 max-w-36 min-w-0 shrink truncate rounded-(--radius-sm) px-1 text-left leading-6 text-(--foreground) transition-colors hover:bg-(--accent) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,sOr=({column:e,type:t,zoneId:r,index:a,functionOptions:o,onChangeHelperFunction:s,onChangeAlias:l,onRemove:u,isPartitionByColumnEnabled:d=!1,partitionColumnList:f=[],selectedDims:p=[],dbName:m,className:h})=>{let g=NS(e)||e.alias||e.name,_=QDr.has(e.type),v=n.useMemo(()=>[Kv,Qv].includes((m||``).toLowerCase()),[m]),y=n.useMemo(()=>{if(_)return[];let n=o(e);if(t===`DIMENSION`)return n.filter(e=>!$Dr.has(e.value));let r=[...n.filter(e=>$Dr.has(e.value)),{value:`NONE`,label:`Original Value`}];return v&&(r=r.filter(e=>!eOr.has(e.value))),r},[_,o,e,t,v]),b=tOr(e),x=y.length===1?y[0]??null:null,S=t===`DIMENSION`?e.type===`HELPER_FUNCTION`?`aggregate_dimensions`:`dimensions`:e.configType===`AGGREGATE`?`aggregate_metrics`:`metrics`,C=n.useMemo(()=>({...e.draggableItemData,column:{...e.draggableItemData.column,alias:e.alias}}),[e]),{DragNodeRef:w,isDragging:T}=dJ({identifier:{id:e.alias,type:S},data:C,modifiers:{highlightDrop:{onDrag:!0}},CustomDragPreview:(0,i.jsx)(nOr,{label:g})}),ee=W9(e.datatype),te=SDr[ee],[ne,re]=n.useState(!1),[ie,ae]=n.useState(`list`),oe=n.useRef(null),[se,ce]=n.useState(e.percentileValue??.5),[le,ue]=n.useState([]),[de,fe]=n.useState(e.functionConfiguration?.dateFormat??``),pe=e=>{re(e),e||(ae(`list`),oe.current=null)},me=(n,r)=>{if(eOr.has(n.value)){r.preventDefault(),oe.current=n,ce(e.percentileValue??.5),d&&p.length&&le.length===0&&ue(f.filter(e=>p.some(t=>t.name===e.dimension?.columnName))),ae(`percentile`);return}if(t===`DIMENSION`&&n.value===`date format`){r.preventDefault(),oe.current=n,fe(e.functionConfiguration?.dateFormat??``),ae(`dateFormat`);return}s({column:e,helperFunction:n,type:t})},he=()=>{let t=oe.current;t&&(s({column:e,helperFunction:t,type:`METRIC`,percentileValue:se,partitionByColumns:le.map(e=>{if(!e.dimension)return;let t=p.find(t=>t.name===e.dimension?.columnName);return{...e.dimension,parentAlias:t?.parentAlias||e.dimension.parentAlias}}).filter(e=>!!e)}),pe(!1))},ge=()=>{let t=oe.current;t&&(s({column:e,helperFunction:t,type:`DIMENSION`,functionConfiguration:{dateFormat:de}}),pe(!1))},_e=![`ARITHMETIC`,`CUSTOM`].includes(e.type),[ve,ye]=n.useState(!1),[be,xe]=n.useState(e.alias),[Se,Ce]=n.useState(e.cast??iy[iy.length-1]),we=n.useRef(!1),Te=n.useId(),Ee=`${Te}-rename-input`,De=`${Te}-partition`,Oe=`${Te}-percentile-value`,Ae=`${Te}-date-format-value`,je=t=>{ye(t),t&&(xe(e.alias),Ce(e.cast??iy[iy.length-1]),we.current=!1)},Me=()=>{l({alias:be||e.alias,column:e,type:t,cast:Se,isColumnCasted:we.current}),ye(!1)},Ne=[`field-chip`,r,e.alias];return(0,i.jsxs)(`div`,{ref:w,...R8(...Ne),"data-slot":`field-chip`,"data-dbn-sorting-index":a,className:KH(rOr,T&&iOr,h),children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3 shrink-0 items-center justify-center text-(--muted-foreground)`,children:(0,i.jsx)(_hn,{className:`size-3`})}),(0,i.jsxs)(`span`,{...R8(...Ne,`type`),className:`flex size-4 shrink-0 items-center justify-center text-(--muted-foreground)`,children:[(0,i.jsx)(te,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsx)(`span`,{className:`sr-only`,children:CDr[ee]})]}),_e?(0,i.jsxs)(V1n,{open:ve,onOpenChange:je,children:[(0,i.jsx)(H1n,{asChild:!0,children:(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`name`),title:g,className:oOr,children:g})}),(0,i.jsx)(c8,{align:`start`,size:`lg`,padding:`form`,children:(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Ee,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:e.label||e.dataMartColumnAlias||e.name}),(0,i.jsx)(s8,{value:be,onChange:e=>xe(e.target.value),...L8(...Ne,`rename-input`),id:Ee,className:`h-7 text-xs`})]}),e.type===`ARITHMETIC`?null:(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Te,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Cast column as`}),(0,i.jsxs)(r3n,{value:Se.value,onValueChange:e=>{let t=iy.find(t=>t.value===e);t&&(Ce(t),we.current=!0)},children:[(0,i.jsx)(a3n,{id:Te,size:`sm`,className:`h-7 w-full text-xs`,...R8(...Ne,`cast-select`),children:(0,i.jsx)(i3n,{})}),(0,i.jsx)(o3n,{children:iy.map(e=>(0,i.jsx)(s3n,{value:e.value,children:e.label},e.value))})]})]}),(0,i.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[(0,i.jsx)(B6,{type:`button`,variant:`ghost`,size:`sm`,className:`cta-secondary`,...L8(...Ne,`rename-cancel`),onClick:()=>ye(!1),children:`Cancel`}),(0,i.jsx)(B6,{type:`button`,variant:`secondary`,size:`sm`,className:`cta-primary`,...L8(...Ne,`rename-save`),onClick:Me,children:`Save`})]})]})})]}):(0,i.jsx)(`span`,{className:`h-6 max-w-36 min-w-0 shrink cursor-default truncate px-1 leading-6`,title:g,children:g}),x?(0,i.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-1 px-1 text-caption text-(--muted-foreground)`,children:[(0,i.jsx)(`span`,{className:`truncate`,children:x.label}),x.tooltip?(0,i.jsx)(v3n,{children:(0,i.jsxs)(y3n,{children:[(0,i.jsx)(b3n,{asChild:!0,children:(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`function-info`),"aria-label":`Why ${x.label.toLowerCase()} is the only option for ${g}`,className:KH(aOr,`size-6 text-(--muted-foreground) hover:text-(--foreground)`),children:(0,i.jsx)(Ehn,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,i.jsx)(x3n,{children:x.tooltip})]})}):null]}):y.length>0?(0,i.jsxs)(n8,{open:ne,onOpenChange:pe,children:[(0,i.jsx)(r8,{asChild:!0,children:(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`function`),"aria-label":b?`Change function for ${g} (currently ${b})`:`Set a function for ${g} (none set)`,title:b??`Set a function`,className:KH(aOr,`border border-(--border) bg-(--background) hover:border-(--muted-foreground)`,b?`min-w-6 max-w-24 gap-1 px-2 text-caption font-semibold tracking-wide uppercase`:`size-6`),children:b?(0,i.jsx)(`span`,{className:`min-w-0 truncate`,children:b}):(0,i.jsx)(qQ,{"aria-hidden":`true`,className:`size-3`})})}),(0,i.jsx)(i8,{align:`start`,children:ie===`list`?y.map(e=>{let t=e.value===`distinct`?e.tooltip:void 0;return(0,i.jsx)(a8,{...L8(...Ne,`function`,e.value),disabled:!!t,className:`h-auto items-start whitespace-normal`,onSelect:t?void 0:t=>me(e,t),children:(0,i.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,i.jsx)(`span`,{children:e.label}),t?(0,i.jsx)(`span`,{className:`max-w-64 whitespace-normal text-xs leading-4 text-(--muted-foreground)`,children:t}):null]})},e.value)}):ie===`percentile`?(0,i.jsxs)(`div`,{className:`flex w-56 flex-col gap-2 p-1`,children:[d?(0,i.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Partition by`}),(0,i.jsx)(`div`,{className:`flex max-h-32 flex-col gap-1 overflow-y-auto rounded-(--radius-sm) border border-(--border) p-1`,children:f.length===0?(0,i.jsx)(`p`,{className:`px-1 py-1 text-xs text-(--muted-foreground)`,children:`No dimensions available`}):f.map(e=>{let t=le.some(t=>t.value===e.value),n=`${De}-${e.value}`;return(0,i.jsxs)(`label`,{htmlFor:n,className:`flex cursor-pointer items-center gap-2 rounded-(--radius-xs) px-1 py-1 text-xs hover:bg-(--accent)`,children:[(0,i.jsx)(J$n,{checked:t,onCheckedChange:t=>ue(n=>t?[...n,e]:n.filter(t=>t.value!==e.value)),...L8(...Ne,`partition`,e.value),id:n}),(0,i.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})})]}):null,(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Oe,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Value (0-1)`}),(0,i.jsx)(s8,{type:`number`,min:0,max:1,step:.01,value:se,onChange:e=>{let t=Number(e.target.value);Number.isNaN(t)&&(t=0),t<0&&(t=0),t>1&&(t=1),ce(t)},...L8(...Ne,`percentile-value`),id:Oe,className:`h-7 text-xs`})]}),(0,i.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,i.jsx)(B6,{type:`button`,variant:`ghost`,size:`sm`,className:`cta-secondary`,...L8(...Ne,`percentile-cancel`),onClick:()=>ae(`list`),children:`Cancel`}),(0,i.jsx)(B6,{type:`button`,variant:`secondary`,size:`sm`,className:`cta-primary`,disabled:d&&le.length===0,...L8(...Ne,`percentile-save`),onClick:he,children:`Save`})]})]}):(0,i.jsxs)(`div`,{className:`flex w-56 flex-col gap-2 p-1`,children:[(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Ae,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Date format`}),(0,i.jsx)(s8,{type:`text`,value:de,onChange:e=>fe(e.target.value),placeholder:`%Y-%m-%d, yyyy-mm-dd`,...L8(...Ne,`date-format-value`),id:Ae,className:`h-7 text-xs`})]}),(0,i.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,i.jsx)(B6,{type:`button`,variant:`ghost`,size:`sm`,className:`cta-secondary`,...L8(...Ne,`date-format-cancel`),onClick:()=>ae(`list`),children:`Cancel`}),(0,i.jsx)(B6,{type:`button`,variant:`secondary`,size:`sm`,className:`cta-primary`,...L8(...Ne,`date-format-save`),onClick:ge,children:`Save`})]})]})})]}):_?(0,i.jsxs)(`span`,{...R8(...Ne,`function`,`static`),className:`flex size-6 shrink-0 cursor-default items-center justify-center rounded-(--radius-sm) border border-dashed border-(--border) text-(--muted-foreground)`,children:[(0,i.jsx)(vgn,{"aria-hidden":`true`,className:`size-3`}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Calculated field`})]}):null,(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`remove`),"aria-label":`Remove ${g}`,onClick:u,className:KH(aOr,`size-6 transition`,`pointer-fine:opacity-0 pointer-fine:group-hover:opacity-100 pointer-fine:group-focus-within:opacity-100 pointer-fine:focus-visible:opacity-100`),children:(0,i.jsx)(n$,{className:`size-3.5`,"aria-hidden":`true`})})]})}})),lOr,uOr,dOr,fOr,pOr,mOr,hOr,gOr,_Or,vOr,yOr,bOr,xOr,SOr,COr,wOr,TOr,EOr=h((()=>{XDr(),r$(),Zsn(),my(),ZDr(),hJ(),tQt(),F8(),E6(),B8(),cOr(),lOr=({children:e,onSelect:t,id:n,"data-testid":r})=>(0,i.jsx)(a8,{id:n,"data-testid":r,onSelect:t,children:e}),uOr={Root:n8,Trigger:r8,Content:i8,Button:B6,Input:s8,Empty:j1n,Item:lOr,headerClassName:w1n},dOr=e=>(0,i.jsx)(YDr,{...e,components:uOr}),fOr=`flex w-full items-start gap-2`,pOr=`flex h-9 w-24 shrink-0 items-center gap-1 text-caption font-semibold tracking-wider whitespace-nowrap uppercase text-(--muted-foreground)`,mOr=`flex max-h-28 min-h-9 w-full min-w-0 flex-1 flex-wrap items-center gap-2 overflow-y-auto rounded-(--radius) border border-dashed border-(--border) bg-(--background) px-2 py-1 transition-colors`,hOr={idle:``,armed:`border-(--muted-foreground)`,over:`border-solid border-(--primary) bg-(--accent) outline-2 -outline-offset-2 outline-(--primary)`,rejected:`border-solid border-(--muted-foreground) bg-(--muted) opacity-60`},gOr=`min-w-0 flex-1 truncate px-1 text-xs text-(--muted-foreground)`,_Or=`flex min-w-0 flex-1 items-center gap-1 px-1 text-xs text-(--muted-foreground)`,vOr=`flex h-9 w-6 shrink-0 items-center justify-center`,yOr=`Drag a numeric field to measure`,bOr=`Drag a field here to group by`,xOr={id:`dimensions`,accepts:[`column`,`dimensions`,`metrics`,`aggregate_dimensions`]},SOr={id:`metric`,accepts:[`column`,`dimensions`,`metrics`,`aggregate_metrics`]},COr=[],wOr=[],TOr=({table:e,columns:t,selectedDims:r,selectedMetrics:a,onDropColumn:o,onRemoveColumn:s,onChangeHelperFunction:l,onChangeAlias:u,functionOptions:d,dimModifiers:f,metricModifiers:p,chartSettings:m,dbName:h,partitionColumnList:g=wOr,measuresPickerDefaultOpen:_,dimensionsPickerDefaultOpen:v,arithmeticColumnOptions:y=COr,onSaveArithMetricOption:b,className:x})=>{let[S,C]=n.useState(!1),[w,T]=n.useState(),ee=a.length>0&&!!b,te=n.useMemo(()=>[Xv,qv,Gv,Zv].includes((h||``).toLowerCase()),[h]),ne=n.useCallback(e=>(t,n)=>{let i=n.active?.data,s=i?.column,l=i?.table;if(!s||!l)return;let{sorting:u}=n,d=n.active?.identifier,f=e===`DIMENSION`?[`dimensions`,`aggregate_dimensions`].includes(d?.type||``):[`metrics`,`aggregate_metrics`].includes(d?.type||``),p=()=>o({column:s,table:l,sorting:u,identifier:d,type:e});if(f){p();return}_Q({chartType:m.chartType,target:e,selectedDims:r,selectedMetrics:a,sourceType:d?.type}).canDrop&&p()},[m.chartType,o,r,a]),{setDropNodeRef:re,dragStatus:ie}=pJ({identifier:SOr,events:{onDrop:ne(`METRIC`)},modifiers:p}),{setDropNodeRef:ae,dragStatus:oe}=pJ({identifier:xOr,events:{onDrop:ne(`DIMENSION`)},modifiers:f}),{dndState:se}=uJ(),ce=!!se.active,le=se.active?.identifier?.type,ue=(e,t)=>{if(!ce)return{state:`idle`};if(e===`DIMENSION`?[`dimensions`,`aggregate_dimensions`].includes(le||``):[`metrics`,`aggregate_metrics`].includes(le||``))return{state:t?`over`:`armed`};let n=_Q({chartType:m.chartType,target:e,selectedDims:r,selectedMetrics:a,sourceType:le});return n.canDrop?{state:t?`over`:`armed`}:t?{state:`rejected`,refusal:n.warning}:{state:`idle`}},de=ue(`METRIC`,ie.isDragOver),fe=ue(`DIMENSION`,oe.isDragOver),pe=de.state===`rejected`?de.refusal:void 0,me=fe.state===`rejected`?fe.refusal:void 0,he=_Q({chartType:m.chartType,target:`DIMENSION`,selectedDims:r,selectedMetrics:a,sourceType:`column`}),ge=_Q({chartType:m.chartType,target:`METRIC`,selectedDims:r,selectedMetrics:a,sourceType:`column`}),_e=he.canDrop,ve=ge.canDrop,ye=e?`No columns available`:`Pick a table to see columns`,be=(t,n)=>{e&&o({column:n,table:e,sorting:void 0,identifier:{id:n.name,type:`column`},type:t})};return(0,i.jsxs)(`div`,{...R8(`field-zones`),className:KH(`flex w-full flex-col gap-2`,x),children:[(0,i.jsxs)(`div`,{className:fOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`measures`,`label`),className:pOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`measures`,`accepts`),className:`flex size-3 shrink-0 items-center justify-center`,children:[(0,i.jsx)(bhn,{"aria-hidden":`true`,className:`size-3`}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Accepts number columns.`})]}),`Measures`]}),(0,i.jsxs)(`div`,{ref:re,...R8(`field-zone`,`measures`),className:KH(mOr,hOr[de.state]),children:[pe?(0,i.jsxs)(`span`,{...R8(`field-zone`,`measures`,`refused`),className:_Or,children:[(0,i.jsx)(UQ,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,i.jsx)(`span`,{className:`truncate`,children:pe})]}):null,a.length===0&&!pe?(0,i.jsx)(`span`,{...R8(`field-zone`,`measures`,`empty`),className:gOr,children:yOr}):null,a.map((e,t)=>(0,i.jsx)(sOr,{column:e,type:`METRIC`,zoneId:`measures`,index:t,functionOptions:d,onChangeHelperFunction:l,onChangeAlias:u,onRemove:()=>s({column:e,type:`METRIC`}),isPartitionByColumnEnabled:te,partitionColumnList:g,selectedDims:r,dbName:h},e.uniqueId||e.alias)),(0,i.jsx)(dOr,{columns:t,onSelectColumn:e=>be(`METRIC`,e),triggerAriaLabel:`Add a measure`,zoneId:`measures`,disabled:!ve,disabledReason:ge.warning,emptyLabel:ye,defaultOpen:_,className:`ml-auto`})]}),(0,i.jsxs)(`div`,{className:vOr,children:[(0,i.jsx)(`button`,{type:`button`,...L8(`field-zone`,`measures`,`calculated-field`),"aria-label":`Add a calculated field`,"aria-disabled":!ee,title:ee?`Add a calculated field`:`Add a measure to Measures to enable calculated fields.`,onClick:()=>{ee&&(T(void 0),C(!0))},className:KH(`flex size-6 shrink-0 items-center justify-center rounded-(--radius-sm) border border-(--border) text-(--muted-foreground) transition-colors hover:bg-(--accent) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,!ee&&`cursor-not-allowed opacity-50 hover:bg-transparent`),children:(0,i.jsx)(vgn,{"aria-hidden":`true`,className:`size-3.5`})}),b?(0,i.jsx)(Xsn,{props:{isDisabled:!ee,columnOptions:y,isHovered:!1,type:`METRIC`,onSaveArithMetricOption:b,customColumn:`METRIC`,isOpenCalculatedPanel:S,setOpenCalculatedPanel:C,editColumn:w,setEditCol:T}}):null]})]}),(0,i.jsxs)(`div`,{className:fOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`dimensions`,`label`),className:pOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`dimensions`,`accepts`),className:`flex size-3 shrink-0 items-center justify-center`,children:[(0,i.jsx)(Bmn,{"aria-hidden":`true`,className:`size-3`}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Accepts any column.`})]}),`Dimensions`]}),(0,i.jsxs)(`div`,{ref:ae,...R8(`field-zone`,`dimensions`),className:KH(mOr,hOr[fe.state]),children:[me?(0,i.jsxs)(`span`,{...R8(`field-zone`,`dimensions`,`refused`),className:_Or,children:[(0,i.jsx)(UQ,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,i.jsx)(`span`,{className:`truncate`,children:me})]}):null,r.length===0&&!me?(0,i.jsx)(`span`,{...R8(`field-zone`,`dimensions`,`empty`),className:gOr,children:bOr}):null,r.map((e,t)=>(0,i.jsx)(sOr,{column:e,type:`DIMENSION`,zoneId:`dimensions`,index:t,functionOptions:d,onChangeHelperFunction:l,onChangeAlias:u,onRemove:()=>s({column:e,type:`DIMENSION`})},e.uniqueId||e.alias)),(0,i.jsx)(dOr,{columns:t,onSelectColumn:e=>be(`DIMENSION`,e),triggerAriaLabel:`Add a dimension`,zoneId:`dimensions`,disabled:!_e,disabledReason:he.warning,emptyLabel:ye,defaultOpen:v,className:`ml-auto`})]}),(0,i.jsx)(`div`,{"aria-hidden":`true`,className:vOr})]})]})}})),q9,DOr,OOr,kOr=h((()=>{r$(),t1n(),KDr(),q9=({children:e})=>(0,i.jsx)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col items-center justify-center overflow-hidden p-6`,children:e}),DOr=({onAddField:e,qaEntity:t=`preview-pane`,headline:n=`Build your first view`,hint:r=(0,i.jsx)(i.Fragment,{children:`Drag a field from the list on the left into Measures (the numbers you want) or Dimensions (how to break them down). The answer renders here as you build it.`})})=>(0,i.jsxs)(`div`,{"data-testid":`card-empty-state`,"data-slot":`create-metric-empty`,className:`flex max-w-sm flex-col items-center gap-3 text-center`,children:[(0,i.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--radius-lg) bg-(--muted)`,children:(0,i.jsx)(Mhn,{className:`size-6 text-(--muted-foreground)`,"aria-hidden":`true`})}),(0,i.jsx)(`h2`,{className:`text-sm font-medium text-(--foreground)`,children:n}),(0,i.jsx)(`p`,{...K9(t,`empty-hint`),className:`text-xs text-(--muted-foreground)`,children:r}),e?(0,i.jsxs)(H6,{type:`button`,variant:`primary`,size:`sm`,...G9(t,`empty-add-field`),onClick:e,children:[(0,i.jsx)(ign,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Add a field`})]}):null]}),OOr=({qaEntity:e=`preview-pane`})=>(0,i.jsx)(`p`,{...K9(e,`no-data-hint`),className:`mt-1 max-w-xs text-center text-xs text-(--muted-foreground)`,children:`The query ran, but nothing matched. Try relaxing a filter, raising the row limit, or grouping by a different field.`})}));function AOr(e){return Object.keys(e[0]??{}).map(t=>{let n=!1;for(let r of e){let e=r?.[t];if(e!=null&&e!==``){n=typeof e==`number`;break}}return{key:t,label:t,isNumeric:n}})}function jOr(e,t,n){let r=e==null||e===``,i=t==null||t===``;return r&&i?0:r?1:i?-1:n?e-t:String(e).localeCompare(String(t))}var MOr,NOr,POr,FOr=h((()=>{r$(),yAn(),KDr(),MOr=10,NOr=[10,25,50,75,100,250,500,1e3],POr=({rows:e,qaEntity:t})=>{let n=x.useMemo(()=>AOr(e),[e]),[r,a]=x.useState(``),o=x.useMemo(()=>{let t=r.trim().toLocaleLowerCase();return t?e.filter(e=>n.some(n=>String(e[n.key]??``).toLocaleLowerCase().includes(t))):e},[e,n,r]),[s,l]=x.useState(null),u=s&&n.some(e=>e.key===s.key)?s:null,d=x.useMemo(()=>{if(!u)return o;let e=n.find(e=>e.key===u.key),t=o.map((e,t)=>({row:e,index:t}));return t.sort((t,n)=>{let r=jOr(t.row?.[u.key],n.row?.[u.key],!!e?.isNumeric),i=t.row?.[u.key],a=n.row?.[u.key],o=i==null||i===``||a==null||a===``||u.direction===`asc`?r:-r;return o===0?t.index-n.index:o}),t.map(e=>e.row)},[o,u,n]);function f(e){l(t=>!t||t.key!==e?{key:e,direction:`asc`}:t.direction===`asc`?{key:e,direction:`desc`}:null),g(0)}let[p,m]=x.useState(MOr),[h,g]=x.useState(0),_=d.length,v=Math.max(1,Math.ceil(_/p)),y=Math.min(h,v-1),b=_===0?0:p*y+1,S=_<=p*(y+1)?_:p*(y+1),C=b<=1,w=S>=_,T=x.useMemo(()=>d.slice(p*y,p*(y+1)),[d,p,y]);function ee(e){g(Math.floor(p*y/e)),m(e)}let te=G9(t,`page-size`).id;return(0,i.jsxs)(`div`,{...K9(t,`table`),className:`dbn-v2-table flex h-full w-full flex-col overflow-hidden`,children:[(0,i.jsx)(`div`,{className:`flex shrink-0 justify-end border-b border-(--border) p-3`,children:(0,i.jsx)(vAn,{...G9(t,`search`),type:`search`,"aria-label":`Search table`,placeholder:`Search`,autoComplete:`off`,className:`max-w-64`,value:r,onChange:e=>{a(e.target.value),g(0)}})}),(0,i.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,i.jsxs)(`table`,{children:[(0,i.jsx)(`thead`,{children:(0,i.jsx)(`tr`,{children:n.map(e=>{let n=u?.key===e.key?u.direction:null;return(0,i.jsx)(`th`,{scope:`col`,"aria-sort":n===`asc`?`ascending`:n===`desc`?`descending`:`none`,className:e.isNumeric?`dbn-num`:void 0,children:(0,i.jsxs)(`button`,{type:`button`,...G9(t,`sort`,e.key),onClick:()=>f(e.key),className:`inline-flex items-center gap-1 rounded-(--radius-xs) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:[e.label,n===`asc`?(0,i.jsx)(Xpn,{"aria-hidden":`true`,className:`size-3`}):n===`desc`?(0,i.jsx)(Hpn,{"aria-hidden":`true`,className:`size-3`}):(0,i.jsx)(HQ,{"aria-hidden":`true`,className:`size-3 opacity-40`})]})},e.key)})})}),(0,i.jsxs)(`tbody`,{children:[_===0?(0,i.jsx)(`tr`,{children:(0,i.jsx)(`td`,{colSpan:Math.max(1,n.length),children:`No matching rows.`})}):null,T.map((e,t)=>(0,i.jsx)(`tr`,{children:n.map(t=>(0,i.jsx)(`td`,{className:t.isNumeric?`dbn-num`:void 0,children:String(e?.[t.key]??``)},t.key))},JSON.stringify({row:e,rowIndex:t})))]})]})}),_>0?(0,i.jsxs)(`fieldset`,{...K9(t,`pagination`),"aria-label":`Table pagination`,className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-(--border) px-3 py-1.5 text-xs text-(--muted-foreground)`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(`label`,{htmlFor:te,className:`text-(--muted-foreground)`,children:`Rows per page`}),(0,i.jsx)(`select`,{...G9(t,`page-size`),value:p,onChange:e=>ee(Number(e.target.value)),className:`h-6 cursor-pointer rounded-(--radius-sm) border border-(--border) bg-(--muted) px-1.5 text-xs text-(--foreground) transition-colors hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:cursor-not-allowed disabled:opacity-50`,children:NOr.map(e=>(0,i.jsxs)(`option`,{value:e,children:[`Show `,e]},e))})]}),(0,i.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`flex items-center gap-2`,children:[(0,i.jsxs)(`span`,{children:[b,`-`,S,` of `,_]}),(0,i.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`first`),"aria-label":`First page`,disabled:C,onClick:()=>g(0),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(jmn,{"aria-hidden":`true`,className:`size-3.5`})}),(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`prev`),"aria-label":`Previous page`,disabled:C,onClick:()=>g(Math.max(0,y-1)),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(JQ,{"aria-hidden":`true`,className:`size-3.5`})}),(0,i.jsxs)(`span`,{className:`px-1 tabular-nums`,children:[y+1,` of `,v]}),(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`next`),"aria-label":`Next page`,disabled:w,onClick:()=>g(Math.min(v-1,y+1)),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(YQ,{"aria-hidden":`true`,className:`size-3.5`})}),(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`last`),"aria-label":`Last page`,disabled:w,onClick:()=>g(v-1),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(Pmn,{"aria-hidden":`true`,className:`size-3.5`})})]})]})]}):null]})}}));function IOr(e){return!!e&&BOr.has(e)}var LOr,ROr,zOr,BOr,VOr,HOr,UOr,WOr=h((()=>{qZ(),kOr(),FOr(),xQ(),r$(),Uy(),YZ(),Ay(),Dq(),$3n(),$_(),E6(),B8(),osr(),q8(),W8(),LOr=n.lazy(async()=>({default:(await Promise.resolve().then(()=>(RK(),LK))).DbnChart})),ROr=n.lazy(async()=>({default:(await Promise.resolve().then(()=>(Gor(),Dor))).Chart})),zOr=Object.freeze({isLoading:!1,error:``,data:[],currentValue:``}),BOr=new Set([$.table,$.trendAnalyzer,$.pivot,$.pivotV2,$.pivotV3,$.horizontalStackTable]),VOr=new Set([$.horizontalStackTable,$.pivot,$.treeMap,$.sankey,$.pivotV2,$.pivotV3]),HOr=({data:e,isLoading:t,error:r,errorView:a,chartSettings:o,dimensions:s,metrics:l,isCustomTable:u,isDrillEnableGroupBy:d,drillLevel:f,onDrillLevelClick:p,onResetDrill:m,chartColors:h,chartAppearance:g,appearanceOptions:_,customMessages:v,translationDictionary:y,selectedLanguage:b,noDataImg:x,onAddField:S,colorScheme:C=`light`,onRetry:w,className:T,isActive:ee=!0})=>{let te=n.useMemo(()=>bQ({chartSettings:o,dimensions:s,metrics:l,isCustomTable:u}),[o,s,l,u]),ne=!!e&&e.length>0,re=n.useRef(null);n.useLayoutEffect(()=>{!t&&!r&&ne&&(re.current={rows:e,settings:o})},[o,e,r,ne,t]);let ie=ne?e:re.current?.rows,ae=ne?o:re.current?.settings??o,oe=!!ie&&ie.length>0,se=n.useMemo(()=>({...ae,chartColors:h??ae?.chartColors}),[ae,h]),ce=n.useMemo(()=>!oe||IOr(o.chartType)?null:qle(se,ie),[oe,o.chartType,se,ie]),le=n.useMemo(()=>JZ(g,{...KZ(se?.customSettings),tooltipSettings:se?.tooltipSettings,categoryField:ce?.type===`gaugeV2`?null:se?.xAxis,chartZoom:se?.customSettings?.chartZoom,percentageSize:se?.percentageSize,repulsion:se?.customSettings?.repulsion,isUseAsDifference:se?.waterfallSettings?.isUseAsDifference}),[g,se,ce?.type]),ue=n.useMemo(()=>IOr(o.chartType)?void 0:Eq(se),[o.chartType,se]),[de,fe]=n.useState(null),pe=q3n(de),me=s.map(e=>e.label||e.alias||e.name),he=oe&&d&&me.length>0&&!VOr.has(o.chartType),ge={customMessages:v,translationDictionary:y,selectedLanguage:b},_e=U8(`Build your first view`,`empty`,void 0,ge),ve;if(r)ve=(0,i.jsx)(q9,{children:(0,i.jsx)(`div`,{className:`contents`,"data-error-code":a?.code,children:(0,i.jsx)(G8,{error:a,message:a?void 0:r,onRetry:w,...ge})})});else if(oe){let e=ie;ve=(0,i.jsxs)(i.Fragment,{children:[he?(0,i.jsx)(UOr,{dimensionLabels:me,drillLevel:f,onDrillLevelClick:p,onResetDrill:m}):null,(0,i.jsxs)(`div`,{...R8(`preview-pane`,`chart-region`),className:`relative min-h-0 w-full flex-1`,children:[IOr(o.chartType)?(0,i.jsx)(POr,{rows:e,qaEntity:`preview-pane`}):ce?(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(q9,{children:(0,i.jsx)(H8,{})}),children:(0,i.jsx)(LOr,{type:ce.type,data:ce.data,appearance:le,applyDensity:Vy(),colorBy:ce.colorBy,valueFormatter:ue,chartColors:se.chartColors,className:`h-full w-full`})}):Qor(o.chartType)?(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(q9,{children:(0,i.jsx)(H8,{})}),children:(0,i.jsx)(`div`,{ref:fe,...R8(`preview-pane`,`legacy-chart`),className:`h-full w-full`,children:(0,i.jsx)(ROr,{chartOptions:se,data:e,chartAppearance:g,colors:se.chartColors,metricCardColor:`transparent`,chartFontSettings:pe,pivotDrillState:zOr,isMetricCard:!0})})}):(0,i.jsx)(q9,{children:(0,i.jsx)(K8,{className:`p-0`,message:`This chart type is no longer available. Pick another type in Configure.`,...ge})}),t?(0,i.jsx)(`div`,{...R8(`preview-pane`,`loading-overlay`),role:`status`,"aria-label":`Refreshing`,className:`absolute inset-0 flex items-center justify-center bg-(--background)/70`,children:(0,i.jsx)(Rhn,{className:`size-5 animate-spin text-(--muted-foreground)`,"aria-hidden":`true`})}):null]})]})}else ve=t?(0,i.jsxs)(q9,{children:[(0,i.jsx)(H8,{}),(0,i.jsx)(`p`,{...R8(`preview-pane`,`loading-hint`),className:`mt-3 text-xs text-(--muted-foreground)`,children:`Running the query...`})]}):te?(0,i.jsx)(q9,{children:(0,i.jsx)(DOr,{onAddField:S,headline:_e})}):(0,i.jsxs)(q9,{children:[(0,i.jsx)(K8,{className:`p-0`,noDataImg:x,...ge}),(0,i.jsx)(OOr,{})]});return(0,i.jsx)(`div`,{...R8(`preview-pane`),className:KH(`flex min-h-0 w-full flex-1 flex-col overflow-hidden`,T),children:ee?ve:null})},UOr=({dimensionLabels:e,drillLevel:t,onDrillLevelClick:r,onResetDrill:a})=>{let o=t>=e.length,s=``,l=o?[]:e.slice(0,t+1).map((e,t)=>(s=`${s}\u001f${e}`,{id:s,index:t,label:e}));return(0,i.jsxs)(`nav`,{...R8(`preview-pane`,`breadcrumb`),"aria-label":`Drill-down breadcrumb`,className:`flex shrink-0 items-center gap-1 border-b border-(--border) px-3 py-1.5 text-xs`,children:[(0,i.jsx)(`button`,{type:`button`,...L8(`preview-pane`,`breadcrumb`,`reset`),onClick:a,className:`rounded-(--radius-xs) px-1 py-0.5 text-(--muted-foreground) hover:text-(--foreground) hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:`All`}),l.map(({id:e,index:a,label:o})=>{let s=a===t;return(0,i.jsxs)(n.Fragment,{children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`text-(--muted-foreground)`,children:`/`}),s?(0,i.jsx)(`span`,{"aria-current":`step`,className:`font-medium text-(--foreground)`,children:o}):(0,i.jsx)(`button`,{type:`button`,...L8(`preview-pane`,`breadcrumb`,`level`,a),onClick:()=>r(a),className:`rounded-(--radius-xs) px-1 py-0.5 text-(--muted-foreground) hover:text-(--foreground) hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:o})]},e)})]})}}));function GOr(e){if(!e)return`Chart type`;for(let t of tv)for(let n of t.value)if(String(n.name).toLowerCase()===String(e).toLowerCase())return n.label;return String(e).replace(/\b\w/g,e=>e.toUpperCase())}var KOr,qOr=h((()=>{kOr(),FOr(),xQ(),r$(),my(),F8(),_3n(),E6(),B8(),q8(),W8(),WOr(),KOr=e=>{let{data:t,isLoading:r,error:a,errorView:o,chartSettings:s,dimensions:l,metrics:u,isCustomTable:d,customMessages:f,translationDictionary:p,selectedLanguage:m,noDataImg:h,onAddField:g,onRetry:_,className:v,onOpenChartType:y,isChartTypePanelOpen:b,onToggleFullscreen:x,isFullscreen:S=!1}=e,[C,w]=n.useState(`chart`),T=n.useMemo(()=>bQ({chartSettings:s,dimensions:l,metrics:u,isCustomTable:d}),[s,l,u,d]),ee=t??[],te=ee.length>0,ne={customMessages:f,translationDictionary:p,selectedLanguage:m},re=U8(`Build your first view`,`empty`,void 0,ne),ie;ie=a?(0,i.jsx)(q9,{children:(0,i.jsx)(`div`,{className:`contents`,"data-error-code":o?.code,children:(0,i.jsx)(G8,{error:o,message:o?void 0:a,onRetry:_,...ne})})}):te?(0,i.jsx)(POr,{rows:ee,qaEntity:`preview-table`}):r?(0,i.jsxs)(q9,{children:[(0,i.jsx)(H8,{}),(0,i.jsx)(`p`,{...R8(`preview-table`,`loading-hint`),className:`mt-3 text-xs text-(--muted-foreground)`,children:`Running the query...`})]}):T?(0,i.jsx)(q9,{children:(0,i.jsx)(DOr,{onAddField:g,qaEntity:`preview-table`,headline:re})}):(0,i.jsxs)(q9,{children:[(0,i.jsx)(K8,{className:`p-0`,noDataImg:h,...ne}),(0,i.jsx)(OOr,{qaEntity:`preview-table`})]});let ae=te?Object.keys(ee[0]??{}).length:0,oe;oe=a?``:r&&!te?`Running query...`:te?`${ee.length.toLocaleString()} rows`:`No results yet`;let se=te?`${ee.length.toLocaleString()} ${ee.length===1?`row`:`rows`} × ${ae} ${ae===1?`column`:`columns`}`:`No rows to display`,ce=!a&&!(C===`table`&&te);return(0,i.jsxs)(f3n,{value:C,onValueChange:e=>w(e),...R8(`preview-table`),className:KH(`-mt-2 flex min-h-0 w-full flex-1 flex-col gap-0 overflow-hidden rounded-b-(--radius-md) border border-t-0 border-(--border) bg-(--background)`,v),children:[(0,i.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-(--border) px-2`,children:[(0,i.jsxs)(m3n,{...R8(`preview-table`,`toggle`),className:`shrink-0`,"aria-label":`Preview view`,children:[(0,i.jsxs)(h3n,{value:`chart`,...L8(`preview-table`,`toggle`,`chart`),className:`px-2 text-xs data-[state=active]:border-(--border) group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none`,children:[(0,i.jsx)(GQ,{"aria-hidden":`true`,className:`size-3.5`}),`Chart`]}),(0,i.jsxs)(h3n,{value:`table`,...L8(`preview-table`,`toggle`,`table`),className:`px-2 text-xs data-[state=active]:border-(--border) group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none`,children:[(0,i.jsx)(e$,{"aria-hidden":`true`,className:`size-3.5`}),`Table`]})]}),(0,i.jsx)(`span`,{...R8(`preview-table`,`row-count`),"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-center text-caption tabular-nums text-(--muted-foreground)`,children:oe}),(0,i.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[y?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`preview-table`,`chart-type`),"aria-expanded":b,"aria-label":`Chart type: ${GOr(s?.chartType)}`,onClick:y,className:`h-7 gap-1 border-(--border) bg-(--muted) px-2 text-xs font-medium text-(--muted-foreground) hover:text-(--foreground)`,children:[(0,i.jsx)(`span`,{className:`max-w-30 truncate`,children:GOr(s?.chartType)}),(0,i.jsx)(qQ,{"aria-hidden":`true`,className:`size-3.5`})]}):null,x?(0,i.jsx)(B6,{type:`button`,variant:`outline`,size:`icon-sm`,...L8(`preview-table`,`fullscreen`),"aria-pressed":S,"aria-label":S?`Exit full screen`:`Full screen`,onClick:x,className:`size-7 border-(--border) bg-(--muted) text-(--muted-foreground) hover:text-(--foreground)`,children:S?(0,i.jsx)(Yhn,{"aria-hidden":`true`}):(0,i.jsx)(QQ,{"aria-hidden":`true`})}):null]})]}),(0,i.jsx)(g3n,{value:`chart`,forceMount:!0,hidden:C!==`chart`,className:`flex min-h-0 flex-1 flex-col p-0`,children:(0,i.jsx)(HOr,{...e,isActive:C===`chart`})}),(0,i.jsx)(g3n,{value:`table`,className:`flex min-h-0 flex-1 flex-col p-0`,children:(0,i.jsx)(`div`,{...R8(`preview-table`,`body`),className:`flex min-h-0 w-full flex-1 flex-col overflow-hidden`,children:ie})}),ce?(0,i.jsx)(`div`,{...R8(`preview-table`,`footer`),className:`flex h-7 shrink-0 items-center border-t border-(--border) px-3 text-caption tabular-nums text-(--muted-foreground)`,children:(0,i.jsx)(`span`,{className:`truncate`,children:se})}):null]})}})),JOr,YOr,XOr=h((()=>{PS(),V6(),Z6(),I1n(),E6(),JOr=`text-xs font-medium text-(--foreground)`,YOr=({open:e,onClose:t,onSubmit:r,defaultValues:a,error:o,isSaving:s=!1})=>{let[l,u]=n.useState(``),[d,f]=n.useState(``),[p,m]=n.useState(!1),h=n.useId(),g=n.useId(),_=n.useId(),v=n.useRef(!1);n.useEffect(()=>{e&&!v.current&&(u(a?.name??``),f(a?.description??``),m(!1)),v.current=e},[e,a]);let y=l.trim();return(0,i.jsx)(X6,{open:e,onOpenChange:e=>{!e&&!s&&t()},children:(0,i.jsx)(W6,{className:`sm:max-w-120`,"data-dbn-ui":`v2`,"data-testid":`create-metric-save-dialog`,children:(0,i.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),!s){if(!y){m(!0);return}r({name:y,description:d.trim(),metricId:a?.metricId||`${y}_${oS(10)}`},!1)}},children:[(0,i.jsxs)(G6,{children:[(0,i.jsx)(q6,{children:`Save to dashboard`}),(0,i.jsx)(J6,{children:a?.metricId?`Your changes are saved to this metric on the dashboard.`:`The metric is added to the top of this dashboard.`})]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,i.jsx)(`label`,{className:JOr,htmlFor:h,children:`Metric name`}),(0,i.jsx)(s8,{"aria-describedby":p?_:void 0,"aria-invalid":p&&!y,autoComplete:`off`,autoFocus:!0,disabled:s,id:h,onChange:e=>{u(e.target.value),e.target.value.trim()&&m(!1)},placeholder:`For example, Revenue by month`,value:l}),p&&!y?(0,i.jsx)(`p`,{className:`text-xs text-(--destructive)`,id:_,children:`Enter a name for the metric.`}):null]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,i.jsx)(`label`,{className:JOr,htmlFor:g,children:`Description (optional)`}),(0,i.jsx)(`textarea`,{className:KH(`min-h-20 w-full resize-y rounded-(--radius-sm) border border-(--border) bg-(--muted) px-3 py-2 text-sm text-(--foreground) outline-hidden`,`placeholder:text-(--muted-foreground) focus-visible:ring-2 focus-visible:ring-(--ring)/20 disabled:cursor-not-allowed disabled:text-(--muted-foreground)`),disabled:s,id:g,onChange:e=>f(e.target.value),placeholder:`What this metric shows`,rows:3,value:d})]}),o?(0,i.jsx)(`p`,{className:`text-xs text-(--destructive)`,role:`alert`,children:o}):null,(0,i.jsxs)(K6,{children:[(0,i.jsx)(B6,{disabled:s,onClick:t,type:`button`,variant:`ghost`,children:`Cancel`}),(0,i.jsx)(B6,{"data-testid":`create-metric-save-submit`,disabled:s,type:`submit`,variant:`primary`,children:s?`Saving`:`Save`})]})]})})})}})),ZOr=_({CreateMetricV2:()=>tkr,default:()=>tkr});function QOr(e,t){return e?t?`configure-fields`:`ready-to-save`:`select-table`}var $Or,ekr,J9,tkr,nkr=h((()=>{nDr(),xQ(),my(),sr(),_Xn(),zXn(),P$n(),xV(),zdt(),Dc(),$q(),iDr(),Fi(),E6(),_Dr(),xDr(),UDr(),EOr(),qOr(),XOr(),$Or={"data-dbn-ui":`v2`,"data-dbn-embed-v2":`create-metric`},ekr=(e,t)=>{Oi(e,t)},J9=!1,tkr=e=>{let{clientId:t,companyId:r,isLiveMode:a,externalDashboardId:o,userProvidedDashboardId:s,chartColors:l,colorPalettes:u,setShowMetricCreateModal:d,isShowMetricCreateModal:f,metric:p,metricData:m,workspaceId:h,token:g,clientColumnType:_,tenancyType:v,datasourceId:y,setEditMetric:b,shouldFitFullScreen:x,onServerEvent:S,refetchDashboardData:C,saveDashLayout:w,isIncrementalJoin:T,customChartSettings:ee,showAllChartSettings:te,showChartClickSettings:ne,allowedChartTypes:re,filters:ie}=e,ae=n.useRef(!1),oe=n.useRef(null),se=n.useCallback(e=>{if(e===!1&&ae.current){let e=oe.current==null?0:Math.round(performance.now()-oe.current);LXn(ekr,RXn.CREATE_METRIC_SAVED,{success:!0,latencyMs:e}),ae.current=!1,oe.current=null}d(e)},[d]),{metricConfig:ce,dataset:le}=rDr({clientId:t,companyId:r,isLiveMode:a,externalDashboardId:o,userProvidedDashboardId:s,chartColors:l,colorPalettes:u,isShowMetricCreateModal:f,setShowMetricCreateModal:se,metric:p,metricData:m,workspaceId:h,token:g,clientColumnType:_,tenancyType:v,datasourceId:y,setEditMetric:b,shouldFitFullScreen:x,onServerEvent:S,refetchDashboardData:C,saveDashLayout:w,isIncrementalJoin:T,customChartSettings:ee,showAllChartSettings:te,allowedChartTypes:re,filters:ie}),{isLoading:ue,chartSettings:de,setShowSaveMetricModal:fe,data:pe,error:me,setShowChartCustomProperties:he,isShowChartType:ge,setShowChartType:_e,isShowSaveMetricModal:ve,updateExternalMetric:ye,createExternalMetric:be,saveError:xe,setChartSettings:Se,isShowChartCustomProperties:Ce,setBarRadius:we,isShowSortPanel:Te,setShowSortPanel:Ee,isShowFilters:De,setShowFilters:Oe,isCreatingMetric:Ae,enabledCharts:je,setResetPallete:Me,dbName:Ne,drillDownSettings:Pe,limit:Fe,setLimit:Ie,clickBehaviourConfigs:Le,setClickBehaviourConfigs:Re}=ce,{currentSelectedTable:ze,joinTableOption:Be,setCurrentSelectedTable:Ve,configuration:He,functionOptions:Ue,companySubsetTableList:We,selectedMainTable:Ge,setSelectedMainTable:Ke,selectedDims:qe,selectedMetrics:Je,onDropColumn:Ye,dimModifiers:Xe,metricModifiers:Ze,onChangeAlias:Qe,onChangeHelperFunction:$e,onRemoveColumn:et,selectedTable:tt,createdSorts:nt,setCreatedSorts:rt,filterColumnOptions:it,onApplyFilter:at,onApplySort:ot,sortColumnOptions:st,setCreatedFilters:ct,createdFilters:lt,editorRef:ut,getFilterDropDownType:dt,setChartFields:ft,resetCharSettings:pt,onSelectPivotTable:mt,onChangeDrillDown:ht,drillFilters:gt,selectedJoinColumnOptions:_t,onChangeLimit:vt,onChangeChartType:yt,arithmeticColumnOptions:bt,onSaveArithMetricOption:xt,builderError:St}=le,Ct=n.useMemo(()=>u?u.some(e=>Py(e.colors,l))?u:[{name:`Default`,colors:l??[]},...u]:[{name:`Default`,colors:l??[]}],[l,u]),wt=n.useMemo(()=>!!He.filters.some(e=>e.type!==`client`),[He.filters]),Tt=n.useMemo(()=>bQ({chartSettings:de,dimensions:qe,metrics:Je,isCustomTable:J9}),[de,qe,Je]),Et=n.useCallback(e=>{e===$.pivotV2?(pt(e),mt(e,[])):e===$.table?ft({chartType:e,seriesName:``,isRemoveGroupBy:!0}):[$.line,$.bar,$.stack,$.row,$.horizontalStack].includes(e)&&qe.length===2&&Je.length===1?yt(e):ft({chartType:e});let t=[$.singleValue,$.gaugeV2,$.progressBarV2,$.funnelV2,$.waterfall,$.treeMap].includes(e)&&Je.length>1||[$.rose,$.pie,$.doughnut].includes(e)&&!!qe.length,n=![$.table,$.pivotV2].includes(e)&&!([$.line,$.bar,$.stack,$.row,$.horizontalStack].includes(e)&&qe.length===2&&Je.length===1)&&qe.length>1;(t||n)&&yt(e),_e(!1),S?.(ir,e.toUpperCase().replaceAll(` `,`_`))},[yt,pt,mt,ft,qe,Je,_e,S]),Dt=n.useCallback(e=>{Ke(e),S?.(er,iV(e))},[Ke,S]),Ot=n.useCallback(()=>{S?.($n)},[S]),kt=n.useCallback((e,t)=>{ae.current=!0,oe.current=performance.now(),p?ye(e,t):be(e)},[p,ye,be]);n.useEffect(()=>{if(ae.current&&xe){let e=oe.current==null?0:Math.round(performance.now()-oe.current);LXn(ekr,RXn.CREATE_METRIC_SAVED,{success:!1,latencyMs:e}),ae.current=!1,oe.current=null}},[xe]);let At=n.useCallback(()=>{let e=QOr(Ge,Tt);LXn(ekr,RXn.CREATE_METRIC_ABANDONED,{step:e}),se(!1),b?.(void 0)},[Ge,Tt,se,b]),jt=Ec(),Mt=n.useMemo(()=>N$n(jt.data),[jt.data]),Nt=jt.data?p?Mt.canEditMetric:Mt.canCreateMetric:!0;if(!f||!Nt)return null;let Pt=!!pe,Ft=!!(qe.length||Je.length),It=de.chartColors?.length?de.chartColors:l;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(`div`,{...$Or,style:{display:`contents`},children:[(0,i.jsx)(tDr,{}),(0,i.jsx)(`div`,{"data-testid":`create-metric-v2`,"data-slot":`create-metric-shell`,className:KH(x?`absolute`:`fixed`,`inset-0 z-(--dbn-zIndex-overlay,9999) flex flex-col overflow-hidden bg-(--background) text-(--foreground)`),children:(0,i.jsxs)(gXn,{children:[(0,i.jsx)(bDr,{title:p?`Update Metric`:`Create Metric`,onBack:At,onSave:()=>fe(!0),isLoading:ue,chartSettings:de,dimensions:qe,metrics:Je,isCustomTable:J9,rows:pe,metricName:p?.name,isSaved:!!p}),(0,i.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1`,children:[(0,i.jsx)(HDr,{tableList:We,selectedTable:Ge,onSelectTable:Dt,onSearchFocus:Ot}),(0,i.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col gap-2 overflow-hidden p-3`,children:[(0,i.jsx)(TOr,{table:Ge,columns:Ge?.columnsWithDataType??[],selectedDims:qe,selectedMetrics:Je,onDropColumn:Ye,onRemoveColumn:et,onChangeHelperFunction:$e,onChangeAlias:Qe,functionOptions:Ue,dimModifiers:Xe,metricModifiers:Ze,chartSettings:de,isCustomTable:J9,dbName:Ne,partitionColumnList:_t,arithmeticColumnOptions:bt,onSaveArithMetricOption:xt}),(0,i.jsx)(gDr,{chartSettings:de,hasData:Pt,hasSelectedFields:Ft,isLoading:ue,limit:Fe,setLimit:Ie,onChangeLimit:vt,onOpenFilters:()=>Oe(!0),onOpenSort:()=>Ee(!0),showChartTypeTrigger:!1,onOpenChartType:()=>_e(!0),onOpenChartAppearance:()=>he(!0),hasActiveFilters:wt,hasActiveSort:!!He.orders.length,filtersPanelProps:{token:g,tenancyType:v,globalFilters:ie,clientColumnType:_,clientId:t,joinTableOption:Be,setCurrentSelectedTable:Ve,databaseName:v===`MULTI_DATABASE`&&t||``,dbName:Ne,datasourceId:y,isOpen:De,onClose:()=>Oe(!1),filters:lt,setCreatedFilters:ct,columnOptions:it,getFilterDropDownType:dt,editorRef:ut,workspaceId:h,onApplyFilter:at,savedFilterListOptions:[],currentSelectedTable:ze},sortPanelProps:{currentSelectedTable:ze,joinTableOption:Be,setCurrentSelectedTable:Ve,isOpen:Te,onClose:()=>Ee(!1),createdSorts:nt,setCreatedSorts:rt,columnOptions:st,onApplySort:ot,selectedTable:tt,tableName:Ge?.label||Ge?.alias||Ge?.tableName||``},chartTypePanelProps:{isOpen:ge,onClose:()=>_e(!1),zIndex:9999,inline:!0,enabledCharts:je,resultData:pe,onChartChange:Et,selectedChart:de.chartType,allowedChartTypes:re},chartAppearancePanelProps:{setChartSettings:Se,chartSettings:de,colorPalettes:Ct,isOpen:Ce,onClose:()=>he(!1),setBarRadius:we,setResetPallete:Me,isDisableAction:!1,chartActionProps:{clickBehaviourConfigs:Le,setClickBehaviourConfigs:Re,chartSettings:de,setChartSettings:Se},customChartSettings:ee,showAllChartSettings:te,showChartClickSettings:ne}}),(0,i.jsx)(KOr,{className:`flex-1`,onOpenChartType:()=>_e(!0),isChartTypePanelOpen:ge,data:pe,isLoading:ue,error:me,errorView:eZt(me,St),chartSettings:de,dimensions:qe,metrics:Je,isCustomTable:J9,isDrillEnableGroupBy:Pe.isEnableGroupBy,drillLevel:gt.length||0,onDrillLevelClick:e=>ht({},void 0,void 0,e),onResetDrill:()=>ht({}),chartColors:It})]})]}),(0,i.jsx)(YOr,{open:ve,onClose:()=>fe(!1),onSubmit:kt,error:xe,defaultValues:p?{name:p.name,description:p.description,metricId:p.isCreatedByClient?p.metricId:`update_${p.metricId}_by_${t}_${Date.now()}`}:void 0,isSaving:Ae})]})})]})})}})),rkr,ikr,akr,okr=h((()=>{O6(),oUn(),T6(),E6(),rkr=n.lazy(()=>Promise.resolve().then(()=>(nkr(),ZOr))),ikr=({shouldFitFullScreen:e})=>(0,i.jsx)(`div`,{"data-dbn-ui":`v2`,"data-dbn-embed-v2":`create-metric-loading`,style:{display:`contents`},children:(0,i.jsx)(`div`,{"data-testid":`create-metric-v2-loading`,className:KH(e?`absolute`:`fixed`,`inset-0 z-(--dbn-zIndex-overlay,9999) flex items-center justify-center bg-(--background)`),children:(0,i.jsx)(D6,{})})}),akr=e=>{let{isSectionActive:t}=w6();return t(`embed_ui_v2_create_metric`)?(0,i.jsx)(n.Suspense,{fallback:e.isShowMetricCreateModal?(0,i.jsx)(ikr,{shouldFitFullScreen:e.shouldFitFullScreen}):null,children:(0,i.jsx)(rkr,{...e})}):(0,i.jsx)(aUn,{...e})}})),skr,ckr=h((()=>{YK(),sr(),skr=(e,t)=>{let{mutate:r,isPending:i}=rKt();return{onSaveManageMetrics:(0,n.useCallback)((n,i,a)=>{r({data:{externalMetricIds:n,archiveMetrics:i},token:e},{onSuccess:async e=>{e?.error||(t?.(Un),a())}})},[e]),isLoading:i}}})),lkr,ukr=h((()=>{eTr(),tTr(),R9(),yEr(),ckr(),hY(),sr(),ZK(),TEr(),lkr=({props:{metricList:e,token:t,client:r,companyTenancyType:a,workspaceId:o,chartAppearance:s,colors:l,isOpenModal:u,setOpenModal:d,onServerEvent:f,datasourceId:p,language:m,translationDictionary:h,externalDashboardId:g,companyId:_,refetchDashboardData:v,globalFilters:y,params:b}})=>{let[x,S]=(0,n.useState)([]),[C,w]=(0,n.useState)(``);(0,n.useEffect)(()=>{if(e?.length){let t=(e?.filter(e=>!e?.clientArchivedMetrics?.length))?.map(e=>e?.id);S(t)}},[e]);let{onSaveManageMetrics:T,isLoading:ee}=skr(t,f),{saveLogsAsync:te}=XK(),ne=(0,n.useMemo)(()=>C?e?.filter(e=>!e?.clientArchivedMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(C?.toLowerCase())):e?.filter(e=>!e?.clientArchivedMetrics?.length),[e,C]),re=(0,n.useMemo)(()=>C?e?.filter(e=>e?.clientArchivedMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(C?.toLowerCase())):e?.filter(e=>e?.clientArchivedMetrics?.length),[e,C]),{containerRef:ie,handleScroll:ae,visibleCount:oe,isLoadingMore:se}=wEr({initialCount:4,incrementCount:4,itemCount:(re?.length||0)+(ne?.length||0),resetKey:JSON.stringify([o,r,C]),isActive:u}),ce=re?.slice(0,oe),le=ne?.slice(0,Math.max(0,oe-(re?.length||0)));return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(TJ,{isOpen:u,onClose:()=>{f?.(Vn),d(!1)},headerTitle:`Manage Metrics`,children:[(0,i.jsxs)(ZZ,{className:O9.manageMetricContainer,direction:`col`,children:[(0,i.jsx)(F7,{setSearchKeyword:w,className:`dbn:w-full`}),(0,i.jsxs)(ZZ,{containerRef:ie,onScroll:ae,direction:`row`,className:`dbn:overflow-y-auto dbn:gap-2 dbn:flex-wrap dbn:flex-1 dbn:min-h-0 dbn:content-start dbn:pb-3`,children:[ce?.map(e=>{let n=x?.includes(e?.id);return(0,i.jsxs)(`div`,{className:`${O9.manageMetricCard} ${n?`dbn-manage-metric-card ${O9.borderPrimary}`:``}`,onClick:()=>{S(n?t=>t.filter(t=>t!==e?.id):t=>[...t?.filter(t=>t!==e?.id),e?.id])},"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{S(t?t=>[...t?.filter(t=>t!==e?.id),e?.id]:t=>t.filter(t=>t!==e?.id))}})]}),H9(e)?(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:V9}):null,(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a,globalFilters:y,param:b?.find(t=>t?.metricId===e?.metricId)})})]},e?.id)}),le?.map(e=>{let n=x?.includes(e?.id);return(0,i.jsxs)(`div`,{className:`${O9.manageMetricCard} ${n?`dbn-manage-metric-card ${O9.borderPrimary}`:``}`,onClick:()=>{S(n?t=>t.filter(t=>t!==e?.id):t=>[...t?.filter(t=>t!==e?.id),e?.id])},"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{S(t?t=>[...t?.filter(t=>t!==e?.id),e?.id]:t=>t.filter(t=>t!==e?.id))}})]}),H9(e)?(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:V9}):null,(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a,globalFilters:y,param:b?.find(t=>t?.metricId===e?.metricId)})},e.id)]},e?.id)}),se&&(0,i.jsx)(ZZ,{className:`dbn:w-full dbn:pb-6`,children:(0,i.jsx)(D6,{})})]})]}),(0,i.jsxs)(EJ,{children:[(0,i.jsx)(Xs,{variant:`tab`,onClick:()=>{f?.(Vn),d(!1)},className:`cta-secondary`,children:`Discard`}),(0,i.jsx)(Xs,{variant:`primary`,onClick:()=>{let n=e?.filter(e=>!x.includes(e?.id)&&!e?.clientArchivedMetrics?.length)?.map(e=>e?.id);T(x,n,async()=>{await te({clientId:r,data:{companyId:_,feature:`MANAGE_METRIC`,dashboardId:g},isFrontendApp:!1,token:t}),await v?.(),d(!1)})},isDisabled:ee||!e?.length,className:`cta-primary`,children:`Save`})]})]})})}})),dkr,fkr,pkr,mkr,hkr,gkr,_kr,vkr,ykr,bkr,xkr,Skr,Ckr,wkr,Tkr,Ekr,Y9,Dkr,Okr,kkr,Akr,jkr,Mkr=h((()=>{yEr(),dkr=e=>e?.elementSettings?.elementType?.value||(e?.elementSettings?.summary?.metricList?.length?`metricSummary`:`customTextBox`),fkr=e=>!e?.isMetric&&dkr(e)===`customTextBox`,pkr=e=>!e?.clientArchivedMetrics?.length,mkr=e=>e.replace(/<[^>]*>/g,` `).replace(/ /g,` `).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\s+/g,` `).trim(),hkr=e=>{let t=e.match(/^(\p{Extended_Pictographic}(?:️|\p{Extended_Pictographic}|\p{Emoji_Modifier}|[\u{1F3FB}-\u{1F3FF}])*)\s*/u);return t?{emoji:t[1],rest:e.slice(t[0].length).trim()}:{emoji:``,rest:e}},gkr=e=>(e?.name??``).trim()||mkr(e?.elementSettings?.textBox?.text??``)||`Untitled card`,_kr=(e,t)=>{let{emoji:n,rest:r}=hkr(gkr(e));return{id:String(e?.id??``),kind:t,label:r||gkr(e),emoji:n,description:mkr(e?.description??``),isUnpublished:H9(e),chartType:(e?.chartOptions?.chartType??``).toLowerCase()}},vkr=e=>e.map((e,t)=>({item:e,index:t})).sort((e,t)=>{let n=e.item?.resizeAttributes?.yAxis??0,r=t.item?.resizeAttributes?.yAxis??0;if(n!==r)return n-r;let i=e.item?.resizeAttributes?.xAxis??0,a=t.item?.resizeAttributes?.xAxis??0;return i===a?e.index-t.index:i-a}).map(e=>e.item),ykr=e=>{let t=[],n={header:null,children:[]};return vkr(e).forEach(e=>{if(e?.id){if(fkr(e)){(n.header||n.children.length)&&t.push(n),n={header:_kr(e,`section`),children:[]};return}n.children.push(_kr(e,e?.isMetric?`metric`:`element`))}}),(n.header||n.children.length)&&t.push(n),t},bkr=(e,t)=>`${e.emoji} ${e.label} ${e.description}`.toLowerCase().includes(t),xkr=(e,t)=>{let n=t.trim().toLowerCase();return n?e.map(e=>{if(e.header&&bkr(e.header,n))return{header:e.header,children:[...e.children]};let t=e.children.filter(e=>bkr(e,n));return t.length?{header:e.header,children:t}:null}).filter(e=>e!==null):e.map(e=>({...e}))},Skr=e=>e.header?[e.header.id,...e.children.map(e=>e.id)]:e.children.map(e=>e.id),Ckr=(e,t)=>{let n=Skr(e);if(!n.length)return`unchecked`;let r=n.filter(e=>t.has(e)).length;return r===0?`unchecked`:r===n.length?`checked`:`indeterminate`},wkr=(e,t)=>{let n=new Set(t),r=Skr(e),i=Ckr(e,t)!==`checked`;return r.forEach(e=>{i?n.add(e):n.delete(e)}),n},Tkr=(e,t)=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n},Ekr=e=>new Set(e.filter(e=>!!e?.id&&pkr(e)).map(e=>String(e.id))),Y9=e=>e.filter(e=>!!e?.id).map(e=>String(e.id)),Dkr=(e,t)=>({publish:Y9(e).filter(e=>t.has(e)),archive:e.filter(e=>!!e?.id&&!t.has(String(e.id))&&pkr(e)).map(e=>String(e.id))}),Okr=(e,t)=>{let n=Ekr(e);return n.size===t.size&&Y9(e).every(e=>n.has(e)===t.has(e))},kkr=e=>`${e} ${e===1?`card`:`cards`}`,Akr=[[`table`,[`table`,`pivot`]],[`map`,[`map`,`indian states`]],[`funnel`,[`funnel`,`sankey`,`waterfall`]],[`number`,[`single value`,`gauge`,`progress bar`,`linear gauge`]],[`pie`,[`pie`,`doughnut`,`rose`,`tree map`]],[`scatter`,[`scatter`,`bubble`,`radar`,`boxplot`,`network`]],[`area`,[`area`]],[`line`,[`line`,`stepped`,`time series`,`trend analyzer`]],[`bar`,[`bar`,`stack`,`row`,`histogram`,`combo`]]],jkr=(e,t)=>{if(e!==`metric`)return`element`;let n=t.trim().toLowerCase(),r=Akr.find(([,e])=>e.some(e=>n.includes(e)));return r?r[0]:`bar`}})),Nkr,Pkr,Fkr,Ikr,Lkr,Rkr=h((()=>{yEr(),jH(),r$(),V6(),Y$n(),Z6(),I1n(),E6(),B8(),Mkr(),Nkr={bar:GQ,line:dmn,area:omn,pie:mmn,table:e$,number:dhn,map:Whn,funnel:ZQ,scatter:_mn,element:Cgn},Pkr=({state:e})=>(0,i.jsx)(J$n,{"aria-hidden":`true`,tabIndex:-1,checked:e===`indeterminate`?`indeterminate`:e===`checked`,className:KH(`pointer-events-none`,e===`indeterminate`&&`[&_svg]:hidden after:h-0.5 after:w-2 after:rounded-full after:bg-current`)}),Fkr=()=>(0,i.jsx)(`div`,{className:`px-2 py-2`,children:(0,i.jsx)(AH,{label:`Loading cards`,minHeight:237,"data-testid":`manage-metrics-loading`})}),Ikr=e=>e.flatMap(e=>{let t=e.header?[{row:e.header,group:e,indented:!1}]:[],n=e.children.map(t=>({row:t,indented:!!e.header}));return[...t,...n]}),Lkr=({open:e,onOpenChange:t,items:r,onSave:a,onDismiss:o,loading:s=!1})=>{let[l,u]=n.useState(``),[d,f]=n.useState(()=>Ekr(r)),[p,m]=n.useState(0),[h,g]=n.useState(!1),[_,v]=n.useState(``),y=n.useRef(new Map),b=n.useRef(null),x=n.useRef(!1);n.useEffect(()=>{e&&!x.current&&(f(Ekr(r)),u(``),m(0),v(``)),x.current=e},[e,r]);let S=n.useMemo(()=>ykr(r),[r]),C=n.useMemo(()=>xkr(S,l),[S,l]),w=n.useMemo(()=>Ikr(C),[C]),T=n.useMemo(()=>Y9(r).length,[r]),ee=d.size,te=n.useMemo(()=>Okr(r,d),[r,d]),ne=T>0&&ee===0,re=w.length?Math.min(p,w.length-1):0,ie=n.useCallback((e,t)=>{let n=t[e];n&&y.current.get(n.row.id)?.focus()},[]),ae=e=>{f(e?new Set(Y9(r)):new Set),v(``)},oe=e=>{f(t=>e.group?wkr(e.group,t):Tkr(e.row.id,t)),v(``)},se=async()=>{if(h||te)return;let{publish:e,archive:t}=Dkr(r,d);g(!0),v(``);try{await a(e,t)}catch{v(`Could not save your changes. Try again.`)}finally{g(!1)}},ce=()=>{o?.(),t(!1)},le=(e,t)=>{if(!w.length)return;let n=t=>{e.preventDefault();let n=Math.max(0,Math.min(w.length-1,t));m(n),ie(n,w)};if(e.key===`ArrowDown`)return n(t+1);if(e.key===`ArrowUp`)return n(t-1);if(e.key===`Home`)return n(0);if(e.key===`End`)return n(w.length-1);if(e.key===` `||e.key===`Spacebar`){e.preventDefault();let n=w[t];n&&oe(n);return}e.key===`Enter`&&(e.preventDefault(),se())};return(0,i.jsx)(X6,{onOpenChange:e=>e?t(!0):ce(),open:e,children:(0,i.jsx)(W6,{className:`sm:max-w-140`,"data-dbn-embed-v2":`manage-metrics`,"data-dbn-ui":`v2`,"data-testid":`manage-metrics-dialog`,onOpenAutoFocus:e=>{e.preventDefault(),b.current?.focus()},padded:!1,children:(0,i.jsxs)(`div`,{className:`flex flex-col`,children:[(0,i.jsx)(`div`,{className:`px-4 pt-4`,children:(0,i.jsxs)(G6,{children:[(0,i.jsx)(q6,{children:`Manage Metrics`}),(0,i.jsx)(J6,{children:`Choose which cards appear on this dashboard.`})]})}),(0,i.jsxs)(`div`,{className:`relative px-4 pt-3 pb-3`,children:[(0,i.jsx)($Q,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-6 size-3.5 -translate-y-1/2 text-(--muted-foreground)`}),(0,i.jsx)(s8,{"aria-label":`Search cards`,className:`pl-8`,"data-testid":`manage-metrics-search`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&w.length&&(e.preventDefault(),m(0),ie(0,w))},placeholder:`Search cards`,ref:b,value:l})]}),(0,i.jsxs)(`div`,{className:`max-h-105 overflow-y-auto border-t border-(--border)`,children:[ne&&!s?(0,i.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-(--border) border-b bg-(--muted) px-4 py-2 text-(--muted-foreground) text-xs`,"data-testid":`manage-metrics-all-hidden`,children:[(0,i.jsx)(`span`,{children:`Every card is hidden. This dashboard will be empty.`}),(0,i.jsx)(B6,{className:`ml-auto`,onClick:()=>ae(!0),size:`xs`,type:`button`,variant:`outline`,children:`Show all`})]}):null,s?(0,i.jsx)(Fkr,{}):null,!s&&w.length?(0,i.jsx)(`div`,{"aria-label":`Dashboard cards`,"aria-multiselectable":`true`,className:`flex flex-col gap-px p-2`,"data-testid":`manage-metrics-list`,role:`listbox`,children:w.map((e,t)=>{let{row:n,group:r,indented:a}=e,o=r?Ckr(r,d):d.has(n.id)?`checked`:`unchecked`,s=o!==`unchecked`,l=r?sgn:Nkr[jkr(n.kind,n.chartType)],u=r?r.children.length:0;return(0,i.jsxs)(`div`,{"aria-label":r?`${n.label}, section`:n.label,"aria-selected":s,className:KH(`flex min-h-9 cursor-pointer items-center gap-2 rounded-(--radius-sm) px-2 py-1 outline-hidden`,`hover:bg-(--accent) focus-visible:ring-2 focus-visible:ring-(--ring)`,a&&`pl-8`,!s&&`text-(--muted-foreground)`),"data-testid":I8(`manage-metrics-row`,n.id),onClick:()=>{m(t),oe(e)},onFocus:()=>m(t),onKeyDown:e=>le(e,t),ref:e=>{y.current.set(n.id,e)},role:`option`,tabIndex:t===re?0:-1,children:[(0,i.jsx)(Pkr,{state:o}),n.emoji?(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center text-sm`,children:n.emoji}):(0,i.jsx)(l,{"aria-hidden":`true`,className:KH(`size-3.5 shrink-0`,s?`text-(--muted-foreground)`:`text-(--border)`)}),(0,i.jsxs)(`span`,{className:`min-w-0 flex flex-col`,children:[(0,i.jsx)(`span`,{className:KH(`min-w-0 truncate text-sm`,r?`font-medium`:`font-normal`,s&&`text-(--foreground)`),children:n.label}),n.isUnpublished?(0,i.jsx)(`span`,{className:`text-xs text-(--muted-foreground)`,children:V9}):null]}),r?(0,i.jsx)(`span`,{className:`shrink-0 rounded-(--radius-xs) border border-(--border) px-1.5 text-xs text-(--muted-foreground)`,children:`Section`}):null,n.description?(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-(--muted-foreground)`,children:n.description}):null,r?(0,i.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-(--muted-foreground)`,children:kkr(u)}):null]},n.id)})}):null,!s&&!w.length&&l?(0,i.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-4 py-8`,"data-testid":`manage-metrics-no-results`,children:[(0,i.jsx)(`span`,{className:`text-sm text-(--foreground)`,children:`No cards match "${l}"`}),(0,i.jsxs)(`span`,{className:`text-xs text-(--muted-foreground)`,children:[`Check the spelling, or clear the search to see all`,` ${kkr(T)}`,`.`]}),(0,i.jsx)(B6,{className:`mt-1`,onClick:()=>{u(``),b.current?.focus()},type:`button`,variant:`outline`,children:`Clear search`})]}):null,!s&&!w.length&&!l?(0,i.jsx)(`div`,{className:`px-4 py-8 text-sm text-(--muted-foreground)`,"data-testid":`manage-metrics-empty`,children:`This dashboard has no cards to manage yet.`}):null]}),_?(0,i.jsx)(`div`,{className:`border-t border-(--destructive)/40 bg-(--destructive)/10 px-4 py-2 text-xs text-(--destructive)`,"data-testid":`manage-metrics-save-error`,role:`alert`,children:_}):null,(0,i.jsxs)(K6,{className:`sm:justify-between`,children:[(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(B6,{disabled:h||!T,onClick:()=>ae(!0),type:`button`,variant:`outline`,children:`Show all`}),(0,i.jsx)(B6,{disabled:h||!T,onClick:()=>ae(!1),type:`button`,variant:`outline`,children:`Hide all`})]}),(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(B6,{disabled:h,onClick:ce,type:`button`,variant:`ghost`,children:`Cancel`}),(0,i.jsx)(B6,{"data-testid":`manage-metrics-save`,disabled:h||te,onClick:()=>void se(),type:`button`,variant:`primary`,children:h?`Saving`:`Save`})]})]})]})})})}})),zkr=_({ManageMetricsV2:()=>Bkr,default:()=>Bkr}),Bkr,Vkr=h((()=>{sr(),ZK(),ckr(),Rkr(),Bkr=({metricList:e,token:t,client:r,companyId:a,externalDashboardId:o,isOpenModal:s,setOpenModal:l,onServerEvent:u,refetchDashboardData:d})=>{let{onSaveManageMetrics:f,isLoading:p}=skr(t,u),{saveLogsAsync:m}=XK(),h=n.useRef(null),g=n.useCallback(()=>{let e=h.current;e&&!e.settled&&(h.current=null,e.reject(Error(`manage-metrics-save-failed`)))},[]),_=n.useRef(!1);n.useEffect(()=>{_.current&&!p&&g(),_.current=p},[p,g]);let v=n.useCallback((e,n)=>new Promise((i,s)=>{h.current={reject:s,settled:!1},f(e,n,async()=>{h.current&&(h.current.settled=!0),await m({clientId:r,data:{companyId:a,feature:`MANAGE_METRIC`,dashboardId:o},isFrontendApp:!1,token:t}),await d?.(),h.current=null,l(!1),i()})}),[r,a,o,f,d,m,l,t]),y=n.useCallback(()=>{u?.(Vn)},[u]);return(0,i.jsx)(Lkr,{items:e,onDismiss:y,onOpenChange:l,onSave:v,open:s})}})),Hkr,Ukr,Wkr=h((()=>{ukr(),T6(),Hkr=n.lazy(()=>Promise.resolve().then(()=>(Vkr(),zkr))),Ukr=({props:e})=>{let{isSectionActive:t}=w6();return t(`embed_ui_v2_metric_cards`)?(0,i.jsx)(n.Suspense,{fallback:null,children:(0,i.jsx)(Hkr,{client:e.client,companyId:e.companyId,externalDashboardId:e.externalDashboardId,isOpenModal:e.isOpenModal,metricList:e.metricList,onServerEvent:e.onServerEvent,refetchDashboardData:e.refetchDashboardData,setOpenModal:e.setOpenModal,token:e.token})}):(0,i.jsx)(lkr,{props:e})}})),Gkr,Kkr,qkr,Jkr,Ykr,Xkr,Zkr,Qkr,$kr,eAr,tAr,nAr,rAr,iAr,X9,aAr=h((()=>{Gkr=`_spin_qblzt_1`,Kkr=`_fadeIn_qblzt_1`,qkr=`_CustomDragPreviewContainer_qblzt_1`,Jkr=`_dark_qblzt_1`,Ykr=`_minimapHeaderProgressContainer_qblzt_19`,Xkr=`_justifyBetween_qblzt_23`,Zkr=`_justifyEnd_qblzt_27`,Qkr=`_dashboardName_qblzt_46`,$kr=`_dashboardHeaderRight_qblzt_50`,eAr=`_filter_qblzt_68`,tAr=`_filterButton_qblzt_72`,nAr=`_filterText_qblzt_76`,rAr=`_filterLength_qblzt_80`,iAr=`_pulse_qblzt_1`,X9={"dbn-dashboard":`_dbn-dashboard_qblzt_1`,"dbn-metric":`_dbn-metric_qblzt_1`,"dbn-portal":`_dbn-portal_qblzt_1`,"dbn:pointer-events-none":`_dbn:pointer-events-none_qblzt_1`,"dbn:invisible":`_dbn:invisible_qblzt_1`,"dbn:sr-only":`_dbn:sr-only_qblzt_1`,"dbn:absolute":`_dbn:absolute_qblzt_1`,"dbn:fixed":`_dbn:fixed_qblzt_1`,"dbn:relative":`_dbn:relative_qblzt_1`,"dbn:sticky":`_dbn:sticky_qblzt_1`,"dbn:inset-x-0":`_dbn:inset-x-0_qblzt_1`,"dbn:-top-1":`_dbn:-top-1_qblzt_1`,"dbn:-top-3":`_dbn:-top-3_qblzt_1`,"dbn:top-0":`_dbn:top-0_qblzt_1`,"dbn:top-1":`_dbn:top-1_qblzt_1`,"dbn:top-2":`_dbn:top-2_qblzt_1`,"dbn:-right-6":`_dbn:-right-6_qblzt_1`,"dbn:right-0":`_dbn:right-0_qblzt_1`,"dbn:right-3":`_dbn:right-3_qblzt_1`,"dbn:right-5":`_dbn:right-5_qblzt_1`,"dbn:bottom-0":`_dbn:bottom-0_qblzt_1`,"dbn:bottom-12":`_dbn:bottom-12_qblzt_1`,"dbn:bottom-20":`_dbn:bottom-20_qblzt_1`,"dbn:z-10":`_dbn:z-10_qblzt_1`,"dbn:z-20":`_dbn:z-20_qblzt_1`,"dbn:z-50":`_dbn:z-50_qblzt_1`,"dbn:z-[1]":`_dbn:z-[1]_qblzt_1`,"dbn:z-[19]":`_dbn:z-[19]_qblzt_1`,"dbn:z-[110]":`_dbn:z-[110]_qblzt_1`,"dbn:z-[9999999]":`_dbn:z-[9999999]_qblzt_1`,"dbn:z-base":`_dbn:z-base_qblzt_1`,"dbn:z-elevated":`_dbn:z-elevated_qblzt_1`,"dbn:order-1":`_dbn:order-1_qblzt_1`,"dbn:col-span-1":`_dbn:col-span-1_qblzt_1`,"dbn:col-span-2":`_dbn:col-span-2_qblzt_1`,"dbn:col-span-4":`_dbn:col-span-4_qblzt_1`,"dbn:m-0":`_dbn:m-0_qblzt_1`,"dbn:m-2":`_dbn:m-2_qblzt_1`,"dbn:m-4":`_dbn:m-4_qblzt_1`,"dbn:mx-1":`_dbn:mx-1_qblzt_1`,"dbn:mx-3":`_dbn:mx-3_qblzt_1`,"dbn:mx-auto":`_dbn:mx-auto_qblzt_1`,"dbn:my-0":`_dbn:my-0_qblzt_1`,"dbn:my-3":`_dbn:my-3_qblzt_1`,"dbn:my-5":`_dbn:my-5_qblzt_1`,"dbn:mt-0":`_dbn:mt-0_qblzt_1`,"dbn:mt-1":`_dbn:mt-1_qblzt_1`,"dbn:mt-2":`_dbn:mt-2_qblzt_1`,"dbn:mt-3":`_dbn:mt-3_qblzt_1`,"dbn:mt-4":`_dbn:mt-4_qblzt_1`,"dbn:mt-5":`_dbn:mt-5_qblzt_1`,"dbn:mt-auto":`_dbn:mt-auto_qblzt_1`,"dbn:mr-2":`_dbn:mr-2_qblzt_1`,"dbn:mr-3":`_dbn:mr-3_qblzt_1`,"dbn:mb-1":`_dbn:mb-1_qblzt_1`,"dbn:mb-2":`_dbn:mb-2_qblzt_1`,"dbn:mb-3":`_dbn:mb-3_qblzt_1`,"dbn:mb-4":`_dbn:mb-4_qblzt_1`,"dbn:mb-5":`_dbn:mb-5_qblzt_1`,"dbn:ml-5":`_dbn:ml-5_qblzt_1`,"dbn:ml-[2px]":`_dbn:ml-[2px]_qblzt_1`,"dbn:ml-auto":`_dbn:ml-auto_qblzt_1`,"dbn:block":`_dbn:block_qblzt_1`,"dbn:flex":`_dbn:flex_qblzt_1`,"dbn:grid":`_dbn:grid_qblzt_1`,"dbn:hidden":`_dbn:hidden_qblzt_1`,"dbn:inline-block":`_dbn:inline-block_qblzt_1`,"dbn:inline-flex":`_dbn:inline-flex_qblzt_1`,"dbn:aspect-square":`_dbn:aspect-square_qblzt_1`,"dbn:size-4":`_dbn:size-4_qblzt_1`,"dbn:h-0":`_dbn:h-0_qblzt_1`,"dbn:h-0.5":`_dbn:h-0.5_qblzt_1`,"dbn:h-1.5":`_dbn:h-1.5_qblzt_1`,"dbn:h-2":`_dbn:h-2_qblzt_1`,"dbn:h-2.5":`_dbn:h-2.5_qblzt_1`,"dbn:h-3":`_dbn:h-3_qblzt_1`,"dbn:h-4":`_dbn:h-4_qblzt_1`,"dbn:h-5":`_dbn:h-5_qblzt_1`,"dbn:h-6":`_dbn:h-6_qblzt_1`,"dbn:h-7":`_dbn:h-7_qblzt_1`,"dbn:h-8":`_dbn:h-8_qblzt_1`,"dbn:h-9":`_dbn:h-9_qblzt_1`,"dbn:h-10":`_dbn:h-10_qblzt_1`,"dbn:h-12":`_dbn:h-12_qblzt_1`,"dbn:h-[3px]":`_dbn:h-[3px]_qblzt_1`,"dbn:h-[10%]":`_dbn:h-[10%]_qblzt_1`,"dbn:h-[15%]":`_dbn:h-[15%]_qblzt_1`,"dbn:h-[30%]":`_dbn:h-[30%]_qblzt_1`,"dbn:h-[30px]":`_dbn:h-[30px]_qblzt_1`,"dbn:h-[40px]":`_dbn:h-[40px]_qblzt_1`,"dbn:h-[47px]":`_dbn:h-[47px]_qblzt_1`,"dbn:h-[50px]":`_dbn:h-[50px]_qblzt_1`,"dbn:h-[56px]":`_dbn:h-[56px]_qblzt_1`,"dbn:h-[60px]":`_dbn:h-[60px]_qblzt_1`,"dbn:h-[85%]":`_dbn:h-[85%]_qblzt_1`,"dbn:h-[90%]":`_dbn:h-[90%]_qblzt_1`,"dbn:h-[92%]":`_dbn:h-[92%]_qblzt_1`,"dbn:h-[95%]":`_dbn:h-[95%]_qblzt_1`,"dbn:h-[100%]":`_dbn:h-[100%]_qblzt_1`,"dbn:h-[100vh]":`_dbn:h-[100vh]_qblzt_1`,"dbn:h-[150px]":`_dbn:h-[150px]_qblzt_1`,"dbn:h-[200px]":`_dbn:h-[200px]_qblzt_1`,"dbn:h-[350px]":`_dbn:h-[350px]_qblzt_1`,"dbn:h-[400px]":`_dbn:h-[400px]_qblzt_1`,"dbn:h-[500px]":`_dbn:h-[500px]_qblzt_1`,"dbn:h-[534px]":`_dbn:h-[534px]_qblzt_1`,"dbn:h-[calc(...)]":`_dbn:h-[calc(...)]_qblzt_1`,"dbn:h-[calc(100%-80px)]":`_dbn:h-[calc(100%-80px)]_qblzt_1`,"dbn:h-[calc(100%-130px)]":`_dbn:h-[calc(100%-130px)]_qblzt_1`,"dbn:h-auto":`_dbn:h-auto_qblzt_1`,"dbn:h-fit":`_dbn:h-fit_qblzt_1`,"dbn:h-full":`_dbn:h-full_qblzt_1`,"dbn:h-min":`_dbn:h-min_qblzt_1`,"dbn:h-screen":`_dbn:h-screen_qblzt_1`,"dbn:max-h-[70%]":`_dbn:max-h-[70%]_qblzt_1`,"dbn:max-h-[85%]":`_dbn:max-h-[85%]_qblzt_1`,"dbn:max-h-[100px]":`_dbn:max-h-[100px]_qblzt_1`,"dbn:max-h-[300px]":`_dbn:max-h-[300px]_qblzt_1`,"dbn:max-h-[350px]":`_dbn:max-h-[350px]_qblzt_1`,"dbn:max-h-[400px]":`_dbn:max-h-[400px]_qblzt_1`,"dbn:max-h-fit":`_dbn:max-h-fit_qblzt_1`,"dbn:min-h-0":`_dbn:min-h-0_qblzt_1`,"dbn:min-h-11":`_dbn:min-h-11_qblzt_1`,"dbn:min-h-12":`_dbn:min-h-12_qblzt_1`,"dbn:min-h-32":`_dbn:min-h-32_qblzt_1`,"dbn:min-h-[20px]":`_dbn:min-h-[20px]_qblzt_1`,"dbn:w-1":`_dbn:w-1_qblzt_1`,"dbn:w-1.5":`_dbn:w-1.5_qblzt_1`,"dbn:w-1/2":`_dbn:w-1/2_qblzt_1`,"dbn:w-1/3":`_dbn:w-1/3_qblzt_1`,"dbn:w-1/4":`_dbn:w-1/4_qblzt_1`,"dbn:w-3":`_dbn:w-3_qblzt_1`,"dbn:w-3/4":`_dbn:w-3/4_qblzt_1`,"dbn:w-4":`_dbn:w-4_qblzt_1`,"dbn:w-5":`_dbn:w-5_qblzt_1`,"dbn:w-6":`_dbn:w-6_qblzt_1`,"dbn:w-7":`_dbn:w-7_qblzt_1`,"dbn:w-8":`_dbn:w-8_qblzt_1`,"dbn:w-9":`_dbn:w-9_qblzt_1`,"dbn:w-10":`_dbn:w-10_qblzt_1`,"dbn:w-24":`_dbn:w-24_qblzt_1`,"dbn:w-96":`_dbn:w-96_qblzt_1`,"dbn:w-800":`_dbn:w-800_qblzt_1`,"dbn:w-[1px]":`_dbn:w-[1px]_qblzt_1`,"dbn:w-[3%]":`_dbn:w-[3%]_qblzt_1`,"dbn:w-[3px]":`_dbn:w-[3px]_qblzt_1`,"dbn:w-[10%]":`_dbn:w-[10%]_qblzt_1`,"dbn:w-[15px]":`_dbn:w-[15px]_qblzt_1`,"dbn:w-[30%]":`_dbn:w-[30%]_qblzt_1`,"dbn:w-[30px]":`_dbn:w-[30px]_qblzt_1`,"dbn:w-[40%]":`_dbn:w-[40%]_qblzt_1`,"dbn:w-[49%]":`_dbn:w-[49%]_qblzt_1`,"dbn:w-[60%]":`_dbn:w-[60%]_qblzt_1`,"dbn:w-[65%]":`_dbn:w-[65%]_qblzt_1`,"dbn:w-[70%]":`_dbn:w-[70%]_qblzt_1`,"dbn:w-[80%]":`_dbn:w-[80%]_qblzt_1`,"dbn:w-[85%]":`_dbn:w-[85%]_qblzt_1`,"dbn:w-[90%]":`_dbn:w-[90%]_qblzt_1`,"dbn:w-[96%]":`_dbn:w-[96%]_qblzt_1`,"dbn:w-[97%]":`_dbn:w-[97%]_qblzt_1`,"dbn:w-[100px]":`_dbn:w-[100px]_qblzt_1`,"dbn:w-[120px]":`_dbn:w-[120px]_qblzt_1`,"dbn:w-[150px]":`_dbn:w-[150px]_qblzt_1`,"dbn:w-[170px]":`_dbn:w-[170px]_qblzt_1`,"dbn:w-[180px]":`_dbn:w-[180px]_qblzt_1`,"dbn:w-[200px]":`_dbn:w-[200px]_qblzt_1`,"dbn:w-[250px]":`_dbn:w-[250px]_qblzt_1`,"dbn:w-[300px]":`_dbn:w-[300px]_qblzt_1`,"dbn:w-[400px]":`_dbn:w-[400px]_qblzt_1`,"dbn:w-[500px]":`_dbn:w-[500px]_qblzt_1`,"dbn:w-[600px]":`_dbn:w-[600px]_qblzt_1`,"dbn:w-[750px]":`_dbn:w-[750px]_qblzt_1`,"dbn:w-[775px]":`_dbn:w-[775px]_qblzt_1`,"dbn:w-[800px]":`_dbn:w-[800px]_qblzt_1`,"dbn:w-[cal(100%-80px)]":`_dbn:w-[cal(100%-80px)]_qblzt_1`,"dbn:w-[calc(100%-36px)]":`_dbn:w-[calc(100%-36px)]_qblzt_1`,"dbn:w-[calc(100%-300px)]":`_dbn:w-[calc(100%-300px)]_qblzt_1`,"dbn:w-[inherit]":`_dbn:w-[inherit]_qblzt_1`,"dbn:w-auto":`_dbn:w-auto_qblzt_1`,"dbn:w-fit":`_dbn:w-fit_qblzt_1`,"dbn:w-full":`_dbn:w-full_qblzt_1`,"dbn:w-max":`_dbn:w-max_qblzt_1`,"dbn:w-screen":`_dbn:w-screen_qblzt_1`,"dbn:max-w-[64px]":`_dbn:max-w-[64px]_qblzt_1`,"dbn:max-w-[70%]":`_dbn:max-w-[70%]_qblzt_1`,"dbn:max-w-[84%]":`_dbn:max-w-[84%]_qblzt_1`,"dbn:max-w-[150px]":`_dbn:max-w-[150px]_qblzt_1`,"dbn:max-w-[180px]":`_dbn:max-w-[180px]_qblzt_1`,"dbn:max-w-[200px]":`_dbn:max-w-[200px]_qblzt_1`,"dbn:max-w-[250px]":`_dbn:max-w-[250px]_qblzt_1`,"dbn:max-w-[320px]":`_dbn:max-w-[320px]_qblzt_1`,"dbn:max-w-[400px]":`_dbn:max-w-[400px]_qblzt_1`,"dbn:max-w-full":`_dbn:max-w-full_qblzt_1`,"dbn:max-w-md":`_dbn:max-w-md_qblzt_1`,"dbn:min-w-0":`_dbn:min-w-0_qblzt_1`,"dbn:min-w-4":`_dbn:min-w-4_qblzt_1`,"dbn:min-w-[20px]":`_dbn:min-w-[20px]_qblzt_1`,"dbn:min-w-[200px]":`_dbn:min-w-[200px]_qblzt_1`,"dbn:flex-1":`_dbn:flex-1_qblzt_1`,"dbn:flex-shrink-0":`_dbn:flex-shrink-0_qblzt_1`,"dbn:shrink-0":`_dbn:shrink-0_qblzt_1`,"dbn:flex-grow":`_dbn:flex-grow_qblzt_1`,"dbn:grow":`_dbn:grow_qblzt_1`,"dbn:-rotate-90":`_dbn:-rotate-90_qblzt_1`,"dbn:rotate-90":`_dbn:rotate-90_qblzt_1`,"dbn:rotate-180":`_dbn:rotate-180_qblzt_1`,"dbn:animate-[spin_2s_linear_infinite]":`_dbn:animate-[spin_2s_linear_infinite]_qblzt_1`,spin:Gkr,"dbn:animate-fadeIn":`_dbn:animate-fadeIn_qblzt_1`,fadeIn:Kkr,"dbn:animate-pulse":`_dbn:animate-pulse_qblzt_1`,"dbn:animate-spin":`_dbn:animate-spin_qblzt_1`,"dbn:cursor-auto":`_dbn:cursor-auto_qblzt_1`,"dbn:cursor-grab":`_dbn:cursor-grab_qblzt_1`,"dbn:cursor-not-allowed":`_dbn:cursor-not-allowed_qblzt_1`,"dbn:cursor-pointer":`_dbn:cursor-pointer_qblzt_1`,"dbn:list-none":`_dbn:list-none_qblzt_1`,"dbn:grid-cols-2":`_dbn:grid-cols-2_qblzt_1`,"dbn:grid-cols-3":`_dbn:grid-cols-3_qblzt_1`,"dbn:grid-cols-[1fr_1fr_auto]":`_dbn:grid-cols-[1fr_1fr_auto]_qblzt_1`,"dbn:flex-col":`_dbn:flex-col_qblzt_1`,"dbn:flex-row":`_dbn:flex-row_qblzt_1`,"dbn:flex-row-reverse":`_dbn:flex-row-reverse_qblzt_1`,"dbn:flex-nowrap":`_dbn:flex-nowrap_qblzt_1`,"dbn:flex-wrap":`_dbn:flex-wrap_qblzt_1`,"dbn:flex-wrap-reverse":`_dbn:flex-wrap-reverse_qblzt_1`,"dbn:content-start":`_dbn:content-start_qblzt_1`,"dbn:items-baseline":`_dbn:items-baseline_qblzt_1`,"dbn:items-center":`_dbn:items-center_qblzt_1`,"dbn:items-end":`_dbn:items-end_qblzt_1`,"dbn:items-start":`_dbn:items-start_qblzt_1`,"dbn:items-stretch":`_dbn:items-stretch_qblzt_1`,"dbn:justify-around":`_dbn:justify-around_qblzt_1`,"dbn:justify-between":`_dbn:justify-between_qblzt_1`,"dbn:justify-center":`_dbn:justify-center_qblzt_1`,"dbn:justify-end":`_dbn:justify-end_qblzt_1`,"dbn:justify-evenly":`_dbn:justify-evenly_qblzt_1`,"dbn:justify-start":`_dbn:justify-start_qblzt_1`,"dbn:gap-0":`_dbn:gap-0_qblzt_1`,"dbn:gap-0.5":`_dbn:gap-0.5_qblzt_1`,"dbn:gap-1":`_dbn:gap-1_qblzt_1`,"dbn:gap-1.5":`_dbn:gap-1.5_qblzt_1`,"dbn:gap-2":`_dbn:gap-2_qblzt_1`,"dbn:gap-2.5":`_dbn:gap-2.5_qblzt_1`,"dbn:gap-3":`_dbn:gap-3_qblzt_1`,"dbn:gap-4":`_dbn:gap-4_qblzt_1`,"dbn:gap-5":`_dbn:gap-5_qblzt_1`,"dbn:gap-6":`_dbn:gap-6_qblzt_1`,"dbn:gap-8":`_dbn:gap-8_qblzt_1`,"dbn:gap-10":`_dbn:gap-10_qblzt_1`,"dbn:gap-[3px]":`_dbn:gap-[3px]_qblzt_1`,"dbn:gap-[6px]":`_dbn:gap-[6px]_qblzt_1`,"dbn:gap-[10px]":`_dbn:gap-[10px]_qblzt_1`,"dbn:space-x-4":`_dbn:space-x-4_qblzt_1`,"dbn:gap-y-7":`_dbn:gap-y-7_qblzt_1`,"dbn:truncate":`_dbn:truncate_qblzt_1`,"dbn:overflow-auto":`_dbn:overflow-auto_qblzt_1`,"dbn:overflow-hidden":`_dbn:overflow-hidden_qblzt_1`,"dbn:overflow-x-hidden":`_dbn:overflow-x-hidden_qblzt_1`,"dbn:overflow-y-auto":`_dbn:overflow-y-auto_qblzt_1`,"dbn:rounded":`_dbn:rounded_qblzt_1`,"dbn:rounded-2xl":`_dbn:rounded-2xl_qblzt_1`,"dbn:rounded-full":`_dbn:rounded-full_qblzt_1`,"dbn:rounded-lg":`_dbn:rounded-lg_qblzt_1`,"dbn:rounded-md":`_dbn:rounded-md_qblzt_1`,"dbn:rounded-none":`_dbn:rounded-none_qblzt_1`,"dbn:rounded-xl":`_dbn:rounded-xl_qblzt_1`,"dbn:rounded-t-3xl":`_dbn:rounded-t-3xl_qblzt_1`,"dbn:rounded-l-none":`_dbn:rounded-l-none_qblzt_1`,"dbn:rounded-r-none":`_dbn:rounded-r-none_qblzt_1`,"dbn:rounded-b-none":`_dbn:rounded-b-none_qblzt_1`,"dbn:border":`_dbn:border_qblzt_1`,"dbn:border-0":`_dbn:border-0_qblzt_1`,"dbn:border-[7px]":`_dbn:border-[7px]_qblzt_1`,"dbn:border-x-4":`_dbn:border-x-4_qblzt_1`,"dbn:border-y":`_dbn:border-y_qblzt_1`,"dbn:border-t":`_dbn:border-t_qblzt_1`,"dbn:border-r-0":`_dbn:border-r-0_qblzt_1`,"dbn:border-r-4":`_dbn:border-r-4_qblzt_1`,"dbn:border-b":`_dbn:border-b_qblzt_1`,"dbn:border-b-2":`_dbn:border-b-2_qblzt_1`,"dbn:border-l":`_dbn:border-l_qblzt_1`,"dbn:border-l-0":`_dbn:border-l-0_qblzt_1`,"dbn:border-l-4":`_dbn:border-l-4_qblzt_1`,"dbn:border-dashed":`_dbn:border-dashed_qblzt_1`,"dbn:border-none":`_dbn:border-none_qblzt_1`,"dbn:border-solid":`_dbn:border-solid_qblzt_1`,"dbn:border-[#3d3d3d]":`_dbn:border-[#3d3d3d]_qblzt_1`,"dbn:border-[rgb(0_0_0_/_0.1)]":`_dbn:border-[rgb(0_0_0_/_0.1)]_qblzt_1`,"dbn:border-alert":`_dbn:border-alert_qblzt_1`,"dbn:border-black":`_dbn:border-black_qblzt_1`,"dbn:border-primary":`_dbn:border-primary_qblzt_1`,"dbn:border-primary-title":`_dbn:border-primary-title_qblzt_1`,"dbn:border-secondary":`_dbn:border-secondary_qblzt_1`,"dbn:border-success":`_dbn:border-success_qblzt_1`,"dbn:border-t-txt-link":`_dbn:border-t-txt-link_qblzt_1`,"dbn:border-b-transparent":`_dbn:border-b-transparent_qblzt_1`,"dbn:bg-[#11A064]":`_dbn:bg-[#11A064]_qblzt_1`,"dbn:bg-[#33333366]":`_dbn:bg-[#33333366]_qblzt_1`,"dbn:bg-[#DBEAFE]":`_dbn:bg-[#DBEAFE]_qblzt_1`,"dbn:bg-[#f6f6f6]":`_dbn:bg-[#f6f6f6]_qblzt_1`,"dbn:bg-actionItem-active":`_dbn:bg-actionItem-active_qblzt_1`,"dbn:bg-alert":`_dbn:bg-alert_qblzt_1`,"dbn:bg-alert-light":`_dbn:bg-alert-light_qblzt_1`,"dbn:bg-black":`_dbn:bg-black_qblzt_1`,"dbn:bg-black/[0.1]":`_dbn:bg-black/[0.1]_qblzt_1`,"dbn:bg-blue-500":`_dbn:bg-blue-500_qblzt_1`,"dbn:bg-gray":`_dbn:bg-gray_qblzt_1`,"dbn:bg-gray-50":`_dbn:bg-gray-50_qblzt_1`,"dbn:bg-gray-500":`_dbn:bg-gray-500_qblzt_1`,"dbn:bg-green-100":`_dbn:bg-green-100_qblzt_1`,"dbn:bg-neutral-100":`_dbn:bg-neutral-100_qblzt_1`,"dbn:bg-primary":`_dbn:bg-primary_qblzt_1`,"dbn:bg-primary-title":`_dbn:bg-primary-title_qblzt_1`,"dbn:bg-purple-100":`_dbn:bg-purple-100_qblzt_1`,"dbn:bg-red-100":`_dbn:bg-red-100_qblzt_1`,"dbn:bg-secondary":`_dbn:bg-secondary_qblzt_1`,"dbn:bg-secondary-light":`_dbn:bg-secondary-light_qblzt_1`,"dbn:bg-snow":`_dbn:bg-snow_qblzt_1`,"dbn:bg-success":`_dbn:bg-success_qblzt_1`,"dbn:bg-tertiary":`_dbn:bg-tertiary_qblzt_1`,"dbn:bg-transparent":`_dbn:bg-transparent_qblzt_1`,"dbn:bg-warning":`_dbn:bg-warning_qblzt_1`,"dbn:bg-white":`_dbn:bg-white_qblzt_1`,"dbn:p-0":`_dbn:p-0_qblzt_1`,"dbn:p-1":`_dbn:p-1_qblzt_1`,"dbn:p-1.5":`_dbn:p-1.5_qblzt_1`,"dbn:p-2":`_dbn:p-2_qblzt_1`,"dbn:p-2.5":`_dbn:p-2.5_qblzt_1`,"dbn:p-3":`_dbn:p-3_qblzt_1`,"dbn:p-4":`_dbn:p-4_qblzt_1`,"dbn:p-5":`_dbn:p-5_qblzt_1`,"dbn:p-6":`_dbn:p-6_qblzt_1`,"dbn:p-8":`_dbn:p-8_qblzt_1`,"dbn:p-10":`_dbn:p-10_qblzt_1`,"dbn:px-0":`_dbn:px-0_qblzt_1`,"dbn:px-1":`_dbn:px-1_qblzt_1`,"dbn:px-1.5":`_dbn:px-1.5_qblzt_1`,"dbn:px-2":`_dbn:px-2_qblzt_1`,"dbn:px-3":`_dbn:px-3_qblzt_1`,"dbn:px-4":`_dbn:px-4_qblzt_1`,"dbn:px-5":`_dbn:px-5_qblzt_1`,"dbn:px-6":`_dbn:px-6_qblzt_1`,"dbn:px-10":`_dbn:px-10_qblzt_1`,"dbn:px-[10px]":`_dbn:px-[10px]_qblzt_1`,"dbn:py-0":`_dbn:py-0_qblzt_1`,"dbn:py-0.5":`_dbn:py-0.5_qblzt_1`,"dbn:py-1":`_dbn:py-1_qblzt_1`,"dbn:py-1.5":`_dbn:py-1.5_qblzt_1`,"dbn:py-2":`_dbn:py-2_qblzt_1`,"dbn:py-3":`_dbn:py-3_qblzt_1`,"dbn:py-4":`_dbn:py-4_qblzt_1`,"dbn:py-5":`_dbn:py-5_qblzt_1`,"dbn:py-[10px]":`_dbn:py-[10px]_qblzt_1`,"dbn:pt-0":`_dbn:pt-0_qblzt_1`,"dbn:pt-0.5":`_dbn:pt-0.5_qblzt_1`,"dbn:pt-1":`_dbn:pt-1_qblzt_1`,"dbn:pt-2":`_dbn:pt-2_qblzt_1`,"dbn:pt-3":`_dbn:pt-3_qblzt_1`,"dbn:pt-4":`_dbn:pt-4_qblzt_1`,"dbn:pt-5":`_dbn:pt-5_qblzt_1`,"dbn:pt-6":`_dbn:pt-6_qblzt_1`,"dbn:pt-[2px]":`_dbn:pt-[2px]_qblzt_1`,"dbn:pr-0":`_dbn:pr-0_qblzt_1`,"dbn:pr-3":`_dbn:pr-3_qblzt_1`,"dbn:pr-4":`_dbn:pr-4_qblzt_1`,"dbn:pr-6":`_dbn:pr-6_qblzt_1`,"dbn:pb-0":`_dbn:pb-0_qblzt_1`,"dbn:pb-1":`_dbn:pb-1_qblzt_1`,"dbn:pb-2":`_dbn:pb-2_qblzt_1`,"dbn:pb-3":`_dbn:pb-3_qblzt_1`,"dbn:pb-4":`_dbn:pb-4_qblzt_1`,"dbn:pb-5":`_dbn:pb-5_qblzt_1`,"dbn:pb-6":`_dbn:pb-6_qblzt_1`,"dbn:pb-8":`_dbn:pb-8_qblzt_1`,"dbn:pl-1":`_dbn:pl-1_qblzt_1`,"dbn:pl-2":`_dbn:pl-2_qblzt_1`,"dbn:pl-6":`_dbn:pl-6_qblzt_1`,"dbn:text-center":`_dbn:text-center_qblzt_1`,"dbn:text-left":`_dbn:text-left_qblzt_1`,"dbn:font-sans":`_dbn:font-sans_qblzt_1`,"dbn:text-base":`_dbn:text-base_qblzt_1`,"dbn:text-lg":`_dbn:text-lg_qblzt_1`,"dbn:text-sm":`_dbn:text-sm_qblzt_1`,"dbn:text-xs":`_dbn:text-xs_qblzt_1`,"dbn:text-[10px]":`_dbn:text-[10px]_qblzt_1`,"dbn:text-xxs":`_dbn:text-xxs_qblzt_1`,"dbn:leading-5":`_dbn:leading-5_qblzt_1`,"dbn:leading-6":`_dbn:leading-6_qblzt_1`,"dbn:leading-none":`_dbn:leading-none_qblzt_1`,"dbn:leading-tight":`_dbn:leading-tight_qblzt_1`,"dbn:font-bold":`_dbn:font-bold_qblzt_1`,"dbn:font-medium":`_dbn:font-medium_qblzt_1`,"dbn:font-normal":`_dbn:font-normal_qblzt_1`,"dbn:font-semibold":`_dbn:font-semibold_qblzt_1`,"dbn:tracking-wide":`_dbn:tracking-wide_qblzt_1`,"dbn:break-words":`_dbn:break-words_qblzt_1`,"dbn:whitespace-normal":`_dbn:whitespace-normal_qblzt_1`,"dbn:whitespace-nowrap":`_dbn:whitespace-nowrap_qblzt_1`,"dbn:whitespace-pre-wrap":`_dbn:whitespace-pre-wrap_qblzt_1`,"dbn:text-alert":`_dbn:text-alert_qblzt_1`,"dbn:text-inherit":`_dbn:text-inherit_qblzt_1`,"dbn:text-link-text":`_dbn:text-link-text_qblzt_1`,"dbn:text-primary":`_dbn:text-primary_qblzt_1`,"dbn:text-primary-title":`_dbn:text-primary-title_qblzt_1`,"dbn:text-purple-600":`_dbn:text-purple-600_qblzt_1`,"dbn:text-secondary":`_dbn:text-secondary_qblzt_1`,"dbn:text-text-primary-color":`_dbn:text-text-primary-color_qblzt_1`,"dbn:text-txt-light":`_dbn:text-txt-light_qblzt_1`,"dbn:text-warning-dark":`_dbn:text-warning-dark_qblzt_1`,"dbn:text-white":`_dbn:text-white_qblzt_1`,"dbn:uppercase":`_dbn:uppercase_qblzt_1`,"dbn:not-italic":`_dbn:not-italic_qblzt_1`,"dbn:tabular-nums":`_dbn:tabular-nums_qblzt_1`,"dbn:opacity-60":`_dbn:opacity-60_qblzt_1`,"dbn:opacity-70":`_dbn:opacity-70_qblzt_1`,"dbn:shadow":`_dbn:shadow_qblzt_1`,"dbn:shadow-lg":`_dbn:shadow-lg_qblzt_1`,"dbn:shadow-none":`_dbn:shadow-none_qblzt_1`,"dbn:outline-hidden":`_dbn:outline-hidden_qblzt_1`,"dbn:transition-all":`_dbn:transition-all_qblzt_1`,"dbn:transition-colors":`_dbn:transition-colors_qblzt_1`,"dbn:transition-opacity":`_dbn:transition-opacity_qblzt_1`,"dbn:transition-transform":`_dbn:transition-transform_qblzt_1`,"dbn:duration-200":`_dbn:duration-200_qblzt_1`,"dbn:duration-300":`_dbn:duration-300_qblzt_1`,"dbn:duration-500":`_dbn:duration-500_qblzt_1`,"dbn:ease-out":`_dbn:ease-out_qblzt_1`,"dbn:outline-none":`_dbn:outline-none_qblzt_1`,"dbn:group-data-[open=true]/acc:rotate-180":`_dbn:group-data-[open=true]/acc:rotate-180_qblzt_1`,"dbn:group/acc":`_dbn:group/acc_qblzt_1`,"dbn:before:absolute":`_dbn:before:absolute_qblzt_1`,"dbn:before:inset-0":`_dbn:before:inset-0_qblzt_1`,"dbn:before:content-['']":`_dbn:before:content-['']_qblzt_1`,"dbn:hover:cursor-pointer":`_dbn:hover:cursor-pointer_qblzt_1`,"dbn:hover:border-b":`_dbn:hover:border-b_qblzt_1`,"dbn:hover:border-black":`_dbn:hover:border-black_qblzt_1`,"dbn:hover:border-b-black":`_dbn:hover:border-b-black_qblzt_1`,"dbn:hover:bg-discard-hover":`_dbn:hover:bg-discard-hover_qblzt_1`,"dbn:hover:bg-gray":`_dbn:hover:bg-gray_qblzt_1`,"dbn:hover:bg-gray-3":`_dbn:hover:bg-gray-3_qblzt_1`,"dbn:hover:underline":`_dbn:hover:underline_qblzt_1`,"dbn:hover:underline-offset-4":`_dbn:hover:underline-offset-4_qblzt_1`,"dbn:focus-visible:outline":`_dbn:focus-visible:outline_qblzt_1`,"dbn:focus-visible:outline-2":`_dbn:focus-visible:outline-2_qblzt_1`,"dbn:focus-visible:outline-offset-2":`_dbn:focus-visible:outline-offset-2_qblzt_1`,"dbn:focus-visible:outline-focus":`_dbn:focus-visible:outline-focus_qblzt_1`,"dbn:motion-reduce:animate-none":`_dbn:motion-reduce:animate-none_qblzt_1`,"dbn:motion-reduce:transition-none":`_dbn:motion-reduce:transition-none_qblzt_1`,"dbn-bg-opacity-100":`_dbn-bg-opacity-100_qblzt_1`,"dbn-border-opacity-10":`_dbn-border-opacity-10_qblzt_1`,"getChartOptions-tooltip":`_getChartOptions-tooltip_qblzt_1`,CustomDragPreviewContainer:qkr,"dnd-droppable-highlight":`_dnd-droppable-highlight_qblzt_1`,"droppable-not-allowed":`_droppable-not-allowed_qblzt_1`,"sr-te-live-canvas":`_sr-te-live-canvas_qblzt_1`,dark:Jkr,"ql-size-small":`_ql-size-small_qblzt_1`,"ql-size-large":`_ql-size-large_qblzt_1`,"ql-size-huge":`_ql-size-huge_qblzt_1`,"ql-align-center":`_ql-align-center_qblzt_1`,"ql-align-right":`_ql-align-right_qblzt_1`,"ql-align-left":`_ql-align-left_qblzt_1`,"ql-align-justify":`_ql-align-justify_qblzt_1`,"ql-editor":`_ql-editor_qblzt_1`,"ql-container":`_ql-container_qblzt_1`,"ql-disabled":`_ql-disabled_qblzt_1`,"ql-tooltip":`_ql-tooltip_qblzt_1`,"ql-clipboard":`_ql-clipboard_qblzt_1`,"ql-direction-rtl":`_ql-direction-rtl_qblzt_1`,"ql-indent-1":`_ql-indent-1_qblzt_1`,"ql-indent-2":`_ql-indent-2_qblzt_1`,"ql-indent-3":`_ql-indent-3_qblzt_1`,"ql-indent-4":`_ql-indent-4_qblzt_1`,"ql-indent-5":`_ql-indent-5_qblzt_1`,"ql-indent-6":`_ql-indent-6_qblzt_1`,"ql-indent-7":`_ql-indent-7_qblzt_1`,"ql-indent-8":`_ql-indent-8_qblzt_1`,"ql-indent-9":`_ql-indent-9_qblzt_1`,"ql-video":`_ql-video_qblzt_1`,"ql-bg-black":`_ql-bg-black_qblzt_1`,"ql-bg-red":`_ql-bg-red_qblzt_1`,"ql-bg-orange":`_ql-bg-orange_qblzt_1`,"ql-bg-yellow":`_ql-bg-yellow_qblzt_1`,"ql-bg-green":`_ql-bg-green_qblzt_1`,"ql-bg-blue":`_ql-bg-blue_qblzt_1`,"ql-bg-purple":`_ql-bg-purple_qblzt_1`,"ql-color-white":`_ql-color-white_qblzt_1`,"ql-color-red":`_ql-color-red_qblzt_1`,"ql-color-orange":`_ql-color-orange_qblzt_1`,"ql-color-yellow":`_ql-color-yellow_qblzt_1`,"ql-color-green":`_ql-color-green_qblzt_1`,"ql-color-blue":`_ql-color-blue_qblzt_1`,"ql-color-purple":`_ql-color-purple_qblzt_1`,"ql-font-serif":`_ql-font-serif_qblzt_1`,"ql-font-monospace":`_ql-font-monospace_qblzt_1`,"ql-blank":`_ql-blank_qblzt_1`,"ql-snow":`_ql-snow_qblzt_1`,"ql-toolbar":`_ql-toolbar_qblzt_1`,"ql-image":`_ql-image_qblzt_1`,"ql-active":`_ql-active_qblzt_1`,"ql-picker-label":`_ql-picker-label_qblzt_1`,"ql-picker-item":`_ql-picker-item_qblzt_1`,"ql-selected":`_ql-selected_qblzt_1`,"ql-fill":`_ql-fill_qblzt_1`,"ql-stroke":`_ql-stroke_qblzt_1`,"ql-stroke-miter":`_ql-stroke-miter_qblzt_1`,"ql-hidden":`_ql-hidden_qblzt_1`,"ql-out-bottom":`_ql-out-bottom_qblzt_1`,"ql-out-top":`_ql-out-top_qblzt_1`,"ql-flip":`_ql-flip_qblzt_1`,"ql-formats":`_ql-formats_qblzt_1`,"ql-empty":`_ql-empty_qblzt_1`,"ql-even":`_ql-even_qblzt_1`,"ql-thin":`_ql-thin_qblzt_1`,"ql-transparent":`_ql-transparent_qblzt_1`,"ql-direction":`_ql-direction_qblzt_1`,"ql-syntax":`_ql-syntax_qblzt_1`,"ql-picker":`_ql-picker_qblzt_1`,"ql-picker-options":`_ql-picker-options_qblzt_1`,"ql-expanded":`_ql-expanded_qblzt_1`,"ql-color-picker":`_ql-color-picker_qblzt_1`,"ql-icon-picker":`_ql-icon-picker_qblzt_1`,"ql-header":`_ql-header_qblzt_1`,"ql-font":`_ql-font_qblzt_1`,"ql-size":`_ql-size_qblzt_1`,"ql-background":`_ql-background_qblzt_1`,"ql-color":`_ql-color_qblzt_1`,"ql-preview":`_ql-preview_qblzt_1`,"ql-action":`_ql-action_qblzt_1`,"ql-remove":`_ql-remove_qblzt_1`,"ql-editing":`_ql-editing_qblzt_1`,"dbn-preLineText":`_dbn-preLineText_qblzt_1`,"embedDashboard-container":`_embedDashboard-container_qblzt_10`,"embedDashboard-header":`_embedDashboard-header_qblzt_15`,minimapHeaderProgressContainer:Ykr,justifyBetween:Xkr,justifyEnd:Zkr,"embedDashboard-header-buttons":`_embedDashboard-header-buttons_qblzt_31`,dashboardName:Qkr,dashboardHeaderRight:$kr,"embedDashboard-wrapper":`_embedDashboard-wrapper_qblzt_54`,"embedDashboard-stickyFilters":`_embedDashboard-stickyFilters_qblzt_60`,"alt-container":`_alt-container_qblzt_64`,filter:eAr,filterButton:tAr,filterText:nAr,filterLength:rAr,"export-bottom":`_export-bottom_qblzt_84`,"export-bottom-left":`_export-bottom-left_qblzt_88`,"export-bottom-right":`_export-bottom-right_qblzt_91`,"export-center":`_export-center_qblzt_94`,"export-top":`_export-top_qblzt_98`,"export-top-left":`_export-top-left_qblzt_102`,"export-top-right":`_export-top-right_qblzt_105`,pulse:iAr}})),oAr,sAr,cAr,lAr,Z9,uAr,dAr=h((()=>{Hx(),oAr=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&`startDate`in e&&`endDate`in e,sAr=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&`min`in e&&`max`in e,cAr=e=>e==null||e===``?!1:Array.isArray(e)?e.length>0:oAr(e)?!!(e.startDate||e.endDate):!sAr(e)||e.min!==null||e.max!==null,lAr=e=>typeof e==`string`?nbe(e):e,Z9=e=>e instanceof Date?e.toISOString():typeof e==`string`?lAr(e):Array.isArray(e)?e.map(Z9):oAr(e)?{startDate:Z9(e.startDate),endDate:Z9(e.endDate)}:e,uAr=({dashboardId:e,filters:t})=>{let n=[],r={},i=new Set;return(Array.isArray(t)?t:[]).forEach(e=>{let t=e?.label?.trim();if(!t||i.has(t)||!cAr(e?.value))return;i.add(t);let a=Z9(e?.value);n.push({label:t,column:e?.column,as:e?.as,value:a}),r[t]={defaultOption:a}}),{dashboardId:e,filters:n,globalFilterOptions:r}}})),fAr,pAr=h((()=>{fAr=({isDashboardReady:e,hasLayoutAction:t,hasDownloadAction:n,hasPdfAction:r,hasManageMetricsAction:i,hasGalleryAction:a})=>e&&(t||n||r||i||a)})),mAr,hAr,gAr,_Ar,vAr,yAr=h((()=>{V2(),mAr=(0,n.lazy)(async()=>({default:(await Promise.resolve().then(()=>(m7t(),d7t))).GlobalFilters})),hAr=(0,n.lazy)(async()=>({default:(await Promise.resolve().then(()=>(BTr(),zTr))).CreateGlobalFilter})),gAr=({children:e,surface:t})=>(0,i.jsx)(B2,{surface:t,fallback:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:min-h-12 dbn:w-full dbn:items-center dbn:justify-center`,"aria-label":`Loading ${t}`,role:`status`,children:[`Loading `,t,`...`]}),children:e}),_Ar=e=>(0,i.jsx)(gAr,{surface:`dashboard filters`,children:(0,i.jsx)(mAr,{...e})}),vAr=e=>(0,i.jsx)(gAr,{surface:`filter editor`,children:(0,i.jsx)(hAr,{...e})})})),bAr,xAr,SAr=h((()=>{V2(),bAr=(0,n.lazy)(()=>Promise.resolve().then(()=>(Hwr(),Bwr))),xAr=({props:e})=>(0,i.jsx)(B2,{surface:`schedule-email`,fallback:(0,i.jsx)(`div`,{className:`dbn:flex dbn:min-h-32 dbn:items-center dbn:justify-center dbn:p-4`,"aria-label":`Loading schedule settings`,role:`status`,children:`Loading schedule settings...`}),children:(0,i.jsx)(bAr,{props:e})})})),CAr,wAr,TAr,EAr,DAr=h((()=>{Fi(),CAr=({sharingSettingsId:e,isAllowedToEmailReports:t,disableScheduleEmailReports:n,showDashboardActions:r,surface:i})=>n?{available:!1,reason:`DISABLED_BY_OPTION`}:e?t?i===`header`&&!r?{available:!1,reason:r===!1?`DASHBOARD_ACTIONS_HIDDEN`:void 0}:{available:!0}:{available:!1,reason:`EMBED_TOGGLE_OFF`}:{available:!1,reason:`SMTP_NOT_CONFIGURED`},wAr={DISABLED_BY_OPTION:`The host page sets disableScheduleEmailReports: true in the dbn-dashboard options.`,SMTP_NOT_CONFIGURED:`Set up SMTP in Settings > Embed & Distribution > Email Settings, then allow end users to schedule email reports on the embed.`,EMBED_TOGGLE_OFF:`Turn on 'Allow end users to schedule email reports' in the embed access settings, or set permissions.isAllowEmailReports in the guest token.`,DASHBOARD_ACTIONS_HIDDEN:`Pass showDashboardActions: true in the dbn-dashboard options to show the action row.`},TAr=new Set,EAr=e=>{TAr.has(e)||(TAr.add(e),console.info(`[Databrain embed] schedule report hidden: ${e}. ${wAr[e]}`),Oi(`dashboard.schedule_report_hidden`,{reason:e}))}})),Q9,$9,OAr,kAr=h((()=>{ks(),Ol(),mue(),R9(),JTr(),ETr(),hEr(),LEr(),BK(),qi(),sr(),xV(),lTr(),n7t(),WB(),vcr(),BEr(),G5t(),fXt(),bcr(),nq(),P$n(),IGt(),WEr(),Zye(),Hx(),WK(),TF(),hJ(),Dc(),KEr(),KK(),Bc(),Sq(),Pgt(),PQt(),gQt(),vJ(),b_t(),zQt(),UQt(),JEr(),AB(),XEr(),eDr(),yJ(),okr(),Wkr(),aAr(),dAr(),hl(),pAr(),SZt(),yAr(),SAr(),DAr(),Q9=e=>{let t=e?.position===`absolute`,n=e?.top?.toString()||e?.bottom?.toString()||e?.left?.toString()||e?.right?.toString();return t&&n},$9=[`#5470c6`,`#91cc75`,`#fac858`,`#ee6666`,`#73c0de`,`#3ba272`,`#fc8452`,`#9a60b4`,`#ea7ccc`],OAr=n.default.memo(({options:e,theme:t,adminThemeOption:r,customMessages:a,themeName:o,setAdminTheme:s,dashboardId:l,globalFilterOptions:u,onServerEvent:d,noDataImg:f,noDataFoundSvg:p,customContent:m,customSettingsBtn:h,chartColumns:g,language:_,translationDictionary:v,hideDashboardFilters:y,calendarType:b=`default`,componentToken:x,customChartSettings:S,chartClickFunction:C,filterStateFunction:w,configId:T})=>{let ee=new URLSearchParams(window.location.search),te=ee.get(`isDbn`),ne=T||ee.get(`configId`),re=ee.get(`embed`),[ie,ae]=(0,n.useState)(window.location.search),oe=(0,n.useRef)(_Zt(window.location.search,e?.legacyUrlState?void 0:l)),[se,ce]=(0,n.useState)({}),le=(0,n.useCallback)((e,t)=>{ce(n=>{if(!t){if(!(e in n))return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]),ue=(0,n.useMemo)(()=>({enabled:!!e?.isModifyUrl,positions:oe.current,onChange:le}),[e?.isModifyUrl,le]),{data:de,isLoading:fe,error:pe,refetch:me}=Ec(),he=(0,n.useContext)(ol),ge=window?.dbn?.isEnableProxyAuth&&de?.token?de?.token||``:x||``,_e=(ge||window?.dbn?.isEnableProxyAuth)&&!fe&&!de?.externalDashboard?.id&&pe?ml(he,pe===`TOKEN_EXPIRED`?`TOKEN_EXPIRED`:`DASHBOARD_LOAD_FAILED`):void 0,ve=Gi();(0,n.useEffect)(()=>{_e&&ve(`dashboard`,{code:_e,message:_e===`TOKEN_EXPIRED`?`The guest token has expired.`:W(he,`admin`)??`The dashboard could not be loaded.`,hint:_e===`TOKEN_EXPIRED`?`Create a new guest token for this viewer.`:void 0,retryable:![`TOKEN_EXPIRED`,`UNAUTHORIZED_ORIGIN`].includes(_e)})},[_e,he,ve]);let ye=(0,n.useRef)(null),be=(0,n.useRef)(null),xe=(0,n.useRef)(null),[Se,Ce]=(0,n.useState)(!1),[we,Te]=(0,n.useState)(1),[Ee,De]=(0,n.useState)(!1),[Oe,Ae]=(0,n.useState)(!1),[je,Me]=(0,n.useState)(!1),[Ne,Pe]=(0,n.useState)(!1),[Fe,Ie]=(0,n.useState)(!1),[Le,Re]=(0,n.useState)(0),[ze,Be]=(0,n.useState)(0),[Ve,He]=(0,n.useState)(!1),[Ue,We]=(0,n.useState)(!1),[Ge,Ke]=(0,n.useState)(!1),[qe,Je]=(0,n.useState)(!1),Ye=YGt(),Xe=XGt(),Ze=(0,n.useMemo)(()=>({isLoading:Xe.isPending,mutate:(e,t)=>Xe.mutate({id:e.id,token:ge},{onSuccess:e=>void t?.onSuccess?.(e),onError:e=>t?.onError?.(e)})}),[Xe.isPending,ge]),Qe=zc({dashboardId:l||``,token:ge,enabled:!!(de?.isAllowedToCreateDashboardFilters&&de?.isAllowedCreateDashboardView)}),{onDownloadMetrics:$e,downloadState:et,cancelDownload:tt,downloadError:nt}=lQt(),{data:rt}=xq(de?.workspace?.id||``),it=!!rt?.isEnable,[at,ot]=(0,n.useState)([]),[st,ct]=(0,n.useState)(),[lt,ut]=(0,n.useState)({show:!1}),[dt,ft]=(0,n.useState)(!1),[pt,mt]=(0,n.useState)(!1),[ht,gt]=(0,n.useState)([]),[_t,vt]=(0,n.useState)({value:``,label:`Default`}),[yt,bt]=(0,n.useState)({width:`200px`,variant:`floating`,radius:`6px`,datePickerFormat:``}),[xt,St]=(0,n.useState)({header:{fontColor:``,bgColor:``,fontWeight:``},content:{fontColor:``,lineGap:``,fontWeight:``}}),[Ct,wt]=(0,n.useState)({width:window.innerWidth,height:window.innerHeight}),[Tt,Et]=(0,n.useState)(!1),[Dt,Ot]=(0,n.useState)({isEnabled:!1,layout:[],filtersLayout:[]}),[kt,At]=(0,n.useState)(()=>{let e=new URLSearchParams(window.location.search).get(`pdfGlobalFilters`);if(e)try{let t=JSON.parse(atob(e));if(t?.filters?.length)return t}catch{}return{tableName:``,filters:[]}}),jt=(0,n.useCallback)(()=>{gt([]),At({tableName:``,filters:[]})},[]),[Mt,Nt]=(0,n.useState)(!1),[Pt,Ft]=(0,n.useState)(),[It,Lt]=(0,n.useState)(),[Rt,zt]=(0,n.useState)(``),Bt=ZGt(),Vt=QGt(),Ht=(0,n.useRef)(new URLSearchParams(window.location.search).has(`pdfGlobalFilters`)||new URLSearchParams(window.location.search).has(`pdfMetricFilters`)||new URLSearchParams(window.location.search).has(`pdfAxisSettings`)),Ut=(0,n.useMemo)(()=>{let e=new URLSearchParams(window.location.search).get(`pdfMetricFilters`);if(e)try{let t=JSON.parse(atob(e));if(t&&typeof t==`object`)return t}catch{}},[]),Wt=(0,n.useMemo)(()=>{let e=new URLSearchParams(window.location.search).get(`pdfAxisSettings`);if(e)try{let t=JSON.parse(atob(e));if(t&&typeof t==`object`)return t}catch{}},[]),[Gt,Kt]=(0,n.useState)(),qt=(0,n.useMemo)(()=>({dashboardFiltersLayout:de?.externalDashboard?.dashboardFiltersLayout??[]}),[de?.externalDashboard?.dashboardFiltersLayout]),{saveLayout:Jt,layout:Yt,isLoadingLayout:Xt,dashboardFiltersLayout:Zt,gridMargin:Qt,hasClientLayout:$t}=PKt({clientId:de?.clientId||``,externalDashboardId:de?.externalDashboard?.id,baseDocument:qt}),{data:en}=L({token:de?.token||``,name:o||``,companyId:de?.companyId||``}),tn=(0,n.useMemo)(()=>e?.renameBoard?.trim()?.split(` `)[0]?.toLowerCase()||`board`,[e?.renameBoard]),nn=(0,n.useMemo)(()=>hQt(en?.theme,r,de?.adminTheme),[r,de?.adminTheme,en]),{anchorRef:rn,colorScheme:an}=RQt(),on=(0,n.useMemo)(()=>MQt(e?.colorScheme,`options.colorScheme`),[e?.colorScheme]),sn=VQt(CQt(an??on,nn)),cn=(0,n.useMemo)(()=>AQt(DQt({explicitColorScheme:an,optionsColorScheme:on,adminThemeOptions:nn,systemPrefersDark:sn})),[nn,an,on,sn]),un=(0,n.useMemo)(()=>cn?_H(cn):void 0,[cn]),dn=(0,n.useMemo)(()=>({primary:t?.button?.primary||nn?.dashboard?.ctaColor||`#0d0d0d`,primaryText:t?.button?.primaryText||nn?.dashboard?.ctaTextColor||`#ffffff`}),[t,nn]),fn=(0,n.useMemo)(()=>t?.multiSelectFilterDropdown?.badgeTextColor||nn?.dashboard?.selectBoxTextColor||`#222c3a`,[t?.multiSelectFilterDropdown?.badgeTextColor,nn]);(0,n.useEffect)(()=>{(dn||fn)&&fc(dn,fn)},[dn,fn]);let pn=(0,n.useMemo)(()=>de?.externalDashboardMetrics?.map(e=>{let t={...e?.externalMetric?.chartOptions,mergedMetrics:void 0,mergedCards:e?.externalMetric?.chartOptions?.mergedMetrics?.firstMetric?[e?.externalMetric?.chartOptions?.mergedMetrics?.firstMetric,e?.externalMetric?.chartOptions?.mergedMetrics?.secondMetric].filter(e=>e)?.map(t=>({value:t,label:e?.data?.externalDashboardMetrics?.find(e=>e.externalMetric?.id===t)?.externalMetric?.name||``})):e?.externalMetric?.chartOptions?.mergedCards};return{...e,externalMetric:{...e.externalMetric,chartOptions:t}}})||[],[de?.externalDashboardMetrics]),mn=()=>{wt({width:window.innerWidth,height:window.innerHeight})};(0,n.useEffect)(()=>(window.addEventListener(`resize`,mn),()=>window.removeEventListener(`resize`,mn)),[]);let hn=(0,n.useMemo)(()=>(Ct.width>=800&&Je(!1),Ct.width<800),[Ct.width]);(0,n.useEffect)(()=>{$Er({ishideSidebar:!de?.isShowSideBar,config:de?.config,dashboardId:l,configId:ne??null,externalDashboardId:de?.externalDashboard?.id??null})},[de?.isShowSideBar,de?.config,de?.externalDashboard?.id,l,ne]),GEr({hasToken:!!ge||!!window?.dbn?.isEnableProxyAuth,isLoading:fe,error:pe,isLoaded:!!de?.externalDashboard?.id,onServerEvent:d});let gn=Oa(),[_n,vn]=(0,n.useState)(!1),[yn,bn]=(0,n.useState)(!1),xn=(0,n.useRef)(null),Sn=(0,n.useCallback)(()=>xn.current?xn.current:(bn(!0),qEr(xn,async()=>{try{await Promise.all([gn.invalidateQueries({queryKey:[ln]}),me?.()])}finally{bn(!1)}})),[gn,me]);(0,n.useEffect)(()=>{if(!de?.refreshTime||_n)return;let e=de.refreshTime*1e3,t=setInterval(()=>{document.visibilityState===`visible`&&Sn()},e);return()=>{clearInterval(t)}},[de?.refreshTime,_n,Sn]);let Cn=(0,n.useMemo)(()=>un?.chart?.palettes?.find(e=>e.name===un?.chart?.selected)?.colors,[un]),wn=(0,n.useMemo)(()=>un?.chart?.palettes?.filter(e=>un?.chart?.paletteOptions?.includes(e?.name)),[un]),Tn=e=>{let t=`${window.location.pathname}?${e}${window.location.hash}`;window.history.replaceState(null,``,t)};(0,n.useEffect)(()=>{e?.hideMetricCardShadow?.toString()?Et(e?.hideMetricCardShadow):nn?.cardCustomization?.disableShadowOnHover?Et(!0):Et(!1)},[nn,e?.hideMetricCardShadow]),(0,n.useEffect)(()=>{if(nn?.dashboard?.selectBoxSize)switch(nn?.dashboard?.selectBoxSize){case`small`:bt(e=>({...e,width:`130px`}));break;case`medium`:bt(e=>({...e,width:`180px`}));break;case`large`:bt(e=>({...e,width:`250px`}));break;default:bt(e=>({...e,width:`200px`}))}let e=nn?.dashboard?.selectBoxVariant;e&&bt(t=>({...t,variant:e}));let t=nn?.dashboard?.selectBoxBorderRadius;t&&bt(e=>({...e,radius:t}));let n=nn?.general?.datePickerFormat;n&&bt(e=>({...e,datePickerFormat:n}));let r=un?.dashboard?.underlyingData;r&&St({header:{fontColor:r?.header?.fontColor||`#0D0D0D`,bgColor:r?.header?.bgColor||`#f9fafb`,fontWeight:r?.header?.fontWeight||`boldfont`,fontSize:wF(r?.header?.fontSize)},content:{fontColor:r?.content?.fontColor||`#222c3a`,lineGap:r?.content?.lineGap||`medium`,fontWeight:r?.content?.fontWeight||`500`,fontSize:wF(r?.content?.fontSize)},showFullSingleValueData:r?.singleValueData||!1,paginationPosition:r?.paginationPosition||`bottom`})},[nn,un]);let En=de?.dashboardAppFilters?.filter(e=>!e?.isShowOnUrl)?.flatMap(e=>Object?.keys(e?.values)?.map(t=>({name:t,value:e.values[t]})))||[],Dn=(0,n.useMemo)(()=>de?.dashboardAppFilters?.find(e=>e?.dashboardId===l)?.values,[l,de?.dashboardAppFilters]),On=(0,n.useMemo)(()=>{let e=de?.clientId||``,t=Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)||Array.isArray(de?.clientSubsetData?.tableList),n=Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)?de?.dashboardFilterClientSubsetData?.tableList||[]:de?.clientSubsetData?.tableList||[],r=cTr({tableList:n,clientColumnType:de?.clientColumnType}),i=(e,t)=>{let r=_x(t?.selectedTable||e?.tableName||``).name,i=n.find(e=>{let t=e?.tableName||e?.name||``;return t===r||_x(t).name===r}),a=i?.columns?.find(e=>(e?.name||e?.columnName||``)===t?.name);return{clientColumn:t?.clientColumn||i?.clientColumn||a?.clientColumn,clientColumnType:t?.clientColumnType||i?.clientColumnType||a?.clientColumnType||de?.clientColumnType}};return(de?.externalDashboard?.filters?.map(n=>{let a=REr({clientId:de?.clientId,tableName:n?.tableName,tenancyLevel:de?.companyTenancyType});return{...n,tableName:a,columns:n?.columns?.filter(i=>{let a=!i?.isCreatedByClient||!i?.clientId||i?.clientId===e,o=de?.hideDashboardFilters?.includes(i?.label)||y?.includes(i?.label),s=!i?.isCreatedByClient||sTr({column:i,isSchemaAccessLoaded:t,tableName:n?.tableName,tenancyLevel:de?.companyTenancyType,schemaList:r});return a&&!o&&s})?.map(t=>{let r=i(n,t),o=Bxe(t,u);return{...t,label:t?.clientLabel||t?.label,originalLabel:t?.label,renameFilterKey:Q5t(n,t),selectedTable:t?.selectedTable||a,applyOnTables:zEr({applyOnTables:t?.applyOnTables,clientId:de?.clientId,tenancyLevel:de?.companyTenancyType}),isClientScoped:t?.isClientScoped||t?.isCreatedByClient&&!!e,clientColumn:r.clientColumn,clientColumnType:r.clientColumnType,isHidden:o?.isHide??!1,defaultValue:Vxe(t,Dn,u,o),isManualOptions:!!o?.options||!!t?.isManualOptions,manualOptions:o?.options||t?.manualOptions||[],datePresetOptions:o?.datePresetOptions?ES(o.datePresetOptions)||t?.datePresetOptions?.map(e=>b===`ind`?{...e||{},isFiscal:!0}:e)||[]:t?.datePresetOptions?.map(e=>b===`ind`?{...e||{},isFiscal:!0}:e)||[]}})||[]}})||[])?.map(e=>{let t=(e?.columns?.filter(e=>e?.isCustomFieldFilter))?.flatMap(e=>(de?.dataMartTables?.find(t=>_x(e?.selectedTable).name===t?.tableName)?.customColumnFields||[])?.map(t=>({...e,name:t?.columnName,label:t?.columnName,applyOnTables:e?.applyOnTables?.map(e=>({...e,columnName:t?.columnName,dataType:t?.datatype||``}))||[],isShowHorizontal:!0,isCustomFieldFilter:!0})));return{...e,columns:[...e?.columns?.filter(e=>!e?.isCustomFieldFilter)||[],...t||[]]}})||[]},[de?.externalDashboard?.filters,de?.companyTenancyType,de?.clientId,u,Dn,y,de?.hideDashboardFilters,de?.dataMartTables,de?.clientColumnType,de?.clientSubsetData?.tableList,de?.dashboardFilterClientSubsetData?.tableList]),kn=()=>bZt(ie,e?.legacyUrlState?void 0:l),An=(0,n.useMemo)(()=>kn(),[ie]),jn=(0,n.useMemo)(()=>!!kt?.filters?.some(e=>(e?.value!==void 0||z5t(e?.operator))&&!Ab(e?.value)&&!Bx(e?.operator,e?.value)),[kt?.filters]);(0,n.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.has(`pdfGlobalFilters`)||e.has(`pdfMetricFilters`)||e.has(`pdfAxisSettings`);!On?.length&&!t&&At(void 0)},[On]),(0,n.useEffect)(()=>{s(cn)},[cn]);let Mn=(0,n.useMemo)(()=>JSON.stringify(se),[se]);(0,n.useEffect)(()=>{let t=!e?.legacyUrlState&&Object.keys(se).length>0;if((ht.length||t)&&e?.isModifyUrl){let t=[];EX(kt?.filters||[],(On||[]).flatMap(e=>e?.columns||[])).forEach(e=>{let n=fZt(e.value,e.operator);if(n===void 0)return;let r={...e,value:n};if(Array.isArray(r.value)){if(r.value.length>1e3)return;let e=``;r.value.forEach((t,n)=>{e+=`${n===0?``:`;;`}${t.toString().includes(`'`)?Vx(t):t}`}),t.push({key:r.label,value:e})}else if(typeof r.value==`object`&&r?.value?.startDate&&r?.value?.endDate){let e=typeof r.value?.startDate==`string`?r.value?.startDate?.split(`T`)[0]:(r?.value?.startDate)?.toISOString()?.slice(0,10),n=typeof r.value?.endDate==`string`?r.value?.endDate?.split(`T`)[0]:(r?.value?.endDate)?.toISOString()?.slice(0,10);t.push({key:r.label,value:`${e};;${n}`})}else typeof r.value!=`object`&&r.value!==null&&r.value!==void 0&&r.value!==``&&t.push({key:r.label,value:r.value.toString().includes(`'`)?Vx(r.value.toString()):r.value.toString()})}),e?.legacyUrlState||Object.entries(se).forEach(([e,n])=>{t.push({key:`${mZt}${e}`,value:n})});let n=vZt({currentSearch:window.location.search,dashboardId:l,entries:t,legacyGlobals:{configId:ne||void 0,embed:re||void 0,isDbn:te||void 0},namespaced:!e?.legacyUrlState});ae(`${window.location.pathname}?${n.toString()}${window.location.hash}`),En.forEach(t=>{n.delete(t?.name),!e?.legacyUrlState&&l&&n.delete(`${tJ(l)}${t?.name}`)}),Tn(n.toString())}},[ht,ne,re,te,e?.isModifyUrl,e?.legacyUrlState,l,Mn]),(0,n.useEffect)(()=>{typeof w==`function`&&w(uAr({dashboardId:l,filters:EX(kt?.filters||[],(On||[]).flatMap(e=>e?.columns||[]))}))},[w,l,kt,On]);let Nn=(0,n.useRef)(null),Pn=(0,n.useCallback)(()=>{Nn.current&&=(clearTimeout(Nn.current),null)},[]);(0,n.useEffect)(()=>Pn,[Pn]);let Fn=(0,n.useCallback)(()=>{if(ye?.current&&pn?.length){Pn();let e=6,t=()=>{let n=ye.current;if(!n)return;let r=n.scrollHeight>n.clientHeight;if(r){Re(e-1);return}e+=2,Te(n=>{let i=Math.min(n+2,pn.length);return e=i,!r&&i<pn.length&&(Nn.current=setTimeout(t,300)),i})};Te(Math.min(6,pn.length)),Nn.current=setTimeout(t,300)}},[pn?.length,Pn]),In=(0,n.useCallback)(()=>{if(!(Ee||we>=(pn?.length||0))&&ye?.current&&pn?.length){let{scrollTop:e,scrollHeight:t,clientHeight:n}=ye.current;if(t-(e+n)<100){De(!0);let e=pn.length-we;setTimeout(()=>{De(!1),Te(t=>e<=6?pn.length:t+6)},1e3)}}},[we,pn?.length,Ee]);(0,n.useEffect)(()=>{if(pn?.length&&!fe&&!pe){if(te||e?.isShowNoDataFoundScreen||Ge||Dt?.isEnabled){Te(pn?.length);return}let t=ye?.current;return t&&pn?.length&&(!we||we<6)&&Fn(),t?.addEventListener(`scroll`,In),()=>{t?.removeEventListener(`scroll`,In)}}},[ye,pn?.length,fe,pe,we,Yt,te,e?.isShowNoDataFoundScreen,Dt?.isEnabled,Ge]),(0,n.useEffect)(()=>{Le&&ze&&we<(pn?.length||0)&&(Te(e=>e+ze),Re(0),Be(0))},[ze,Le,we,pn?.length]);let Ln=(0,n.useMemo)(()=>N$n(de,e),[de,e]),Rn=Ln.canCustomizeLayout,zn=Ln.canCreateMetric,Bn=(0,n.useMemo)(()=>CAr({sharingSettingsId:de?.sharingSettingsId,isAllowedToEmailReports:de?.isAllowedToEmailReports,disableScheduleEmailReports:e?.disableScheduleEmailReports,showDashboardActions:e?.showDashboardActions,surface:`header`}),[e?.disableScheduleEmailReports,e?.showDashboardActions,de?.sharingSettingsId,de?.isAllowedToEmailReports]),Vn=Bn.available,Hn=!!de?.externalDashboard?.id;(0,n.useEffect)(()=>{te||!Hn||fe||pe||Bn.reason&&EAr(Bn.reason)},[te,Hn,fe,pe,Bn.reason]);let Un=Ln.canManageMetrics&&!!pn?.length,Wn=Ln.canCreateDashboardView,Gn=(0,n.useMemo)(()=>de?.externalDashboard?.enableViewFilter,[de?.externalDashboard?.enableViewFilter]),Kn=(0,n.useMemo)(()=>{if(e?.dashboardSpacing?.verticalGap!==void 0||e?.dashboardSpacing?.horizontalGap!==void 0)return i7({verticalMargin:e?.dashboardSpacing?.verticalGap,horizontalMargin:e?.dashboardSpacing?.horizontalGap})},[e?.dashboardSpacing]),qn=()=>{Object.keys(Kn||{})?.length?Kt(i7(Kn)):Object.keys(Qt||{})?.length?Kt(i7(Qt)):Object.keys(de?.externalDashboard?.gridMargin||{})?.length?Kt(i7(de?.externalDashboard?.gridMargin)):Kt(i7({verticalMargin:nn?.dashboard?.verticalGap,horizontalMargin:nn?.dashboard?.horizontalGap}))};(0,n.useEffect)(()=>{qn()},[Qt,de?.externalDashboard?.gridMargin,Kn]);let Jn=(0,n.useMemo)(()=>pn?.length&&(pn?.map(e=>e.externalMetric))?.filter(e=>ycr({clientId:de?.clientId,isAllClient:de?.isAllClient,metric:e})).sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime())||[],[de?.clientId,de?.isAllClient,pn]),Yn=(0,n.useMemo)(()=>Jn?.map(e=>({value:e?.id,label:e?.name}))||[],[Jn]),Xn=(0,n.useMemo)(()=>Jn?.filter(e=>(e?.datasetMetricSettings?.metricImportMode!==`GALLERY`||e?.clientGalleryMetrics?.find(t=>t?.externalMetricId===e?.id))&&!!(de?.isAllClient||e?.isCreatedByClient&&e?.clientId===de?.clientId||!e?.isImportant))||[],[de?.clientId,de?.isAllClient,Jn]),Zn=(0,n.useMemo)(()=>{let n=!!t?.manageMetricsStyle&&Q9(t.manageMetricsStyle),r=!hn&&Ln.canManageMetrics&&!n;return fAr({isDashboardReady:Ne,hasLayoutAction:!(hn||!Ln.canCustomizeLayout),hasDownloadAction:!!(it&&(de?.isAllowToDownloadAllMetrics||e?.enableDownloadAllMetrics)),hasPdfAction:!!e?.enableDownloadAllPdf,hasRawMetrics:!!de?.externalDashboardMetrics?.length,hasManageMetricsAction:!!(r&&Xn.length),hasGalleryAction:!!(r&&de?.externalDashboardMetrics?.some(e=>e?.externalMetric?.datasetMetricSettings?.metricImportMode===`GALLERY`))})},[Ne,hn,Ln,de,e,t,it,Xn.length]),Qn=(0,n.useMemo)(()=>Jn?.filter(e=>e?.datasetMetricSettings?.metricImportMode===`GALLERY`)||[],[Jn?.length]),$n=(0,n.useMemo)(()=>Ct?.width>800&&pn?.flatMap(e=>e?.externalMetric?.chartOptions?.mergedCards?.map(e=>e.value))?.filter(e=>!!e)||[],[pn,Ct.width]);(0,n.useEffect)(()=>{ye.current&&(Ln.canCreateMetric&&de?.metricCreationMode===`DRAG_DROP`&&(ye.current.onClickCreateMetric=()=>Ce(!0)),Ln.canManageMetrics&&pn?.length&&(!t?.manageMetricsStyle||t?.manageMetricsStyle&&!Q9(t?.manageMetricsStyle))&&(ye.current.onClickManageMetrics=()=>Ae(!0)),CAr({sharingSettingsId:de?.sharingSettingsId,isAllowedToEmailReports:de?.isAllowedToEmailReports,disableScheduleEmailReports:e?.disableScheduleEmailReports,surface:`api`}).available&&(ye.current.onClickScheduleReports=()=>Ie(!0)),Ln.canCustomizeLayout&&(ye.current.onClickCustomizeLayout=()=>Ot({isEnabled:!0,layout:[]})))},[ye.current,Ln,de,e,t?.manageMetricsStyle]);let er=(0,n.useMemo)(()=>{let e=On?.filter(e=>e?.columns?.length)||[];if(!e.length)return[];let t=pn?.filter(e=>e?.externalMetric?.chartOptions?.dashboardFilters?.length)?.map(e=>e.externalMetric),n=UB(e),r=e[0];if(!t?.length)return[{...r,columns:n}];let i=n.filter(e=>t?.every(t=>!t?.chartOptions?.dashboardFilters?.some(t=>t?.value===e?.label)));return[{...r,columns:i}].filter(e=>e?.columns?.length)},[On,pn]),tr=(0,n.useMemo)(()=>{let e=Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)?de?.dashboardFilterClientSubsetData?.tableList||[]:de?.clientSubsetData?.tableList||[];return cTr({tableList:e,clientColumnType:de?.clientColumnType})},[de?.clientColumnType,de?.clientSubsetData?.tableList,de?.dashboardFilterClientSubsetData?.tableList]),nr=(0,n.useMemo)(()=>Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)||Array.isArray(de?.clientSubsetData?.tableList),[de?.clientSubsetData?.tableList,de?.dashboardFilterClientSubsetData?.tableList]),rr=(0,n.useCallback)(e=>{let t=de?.clientId||``;if(!t)return[];let n=[],r=de?.externalDashboard?.filters?.[0]?.tableName||``;return de?.externalDashboard?.filters?.forEach(r=>{let i=r?.columns?.filter(n=>n.isCreatedByClient&&n.clientId===t&&n.id!==e&&sTr({column:n,isSchemaAccessLoaded:nr,tableName:r?.tableName,tenancyLevel:de?.companyTenancyType,schemaList:tr}))||[];n.push(...i.map(e=>({...e,selectedTable:e.selectedTable||r?.tableName})))}),n.length?[{tableName:r||n[0]?.selectedTable||``,columns:n}]:[]},[tr,de?.clientId,de?.companyTenancyType,de?.externalDashboard?.filters,nr]),ir=(0,n.useCallback)(e=>{if(!de?.isAllowedToCreateDashboardFilters||!e.isCreatedByClient||e.clientId!==de?.clientId)return;let t;de?.externalDashboard?.filters?.some(n=>(t=n?.columns?.find(t=>t.id===e.id&&t.isCreatedByClient&&t.clientId===de?.clientId),t&&={...t,selectedTable:t.selectedTable||n?.tableName},!!t)),Ft(t||e),Nt(!0)},[de?.clientId,de?.externalDashboard?.filters,de?.isAllowedToCreateDashboardFilters]),ar=(0,n.useCallback)(async(e,t)=>{let n=e?.renameFilterKey||``;de?.isAllowedToRenameDashboardFilters&&de?.externalDashboard?.id&&!e?.isCreatedByClient&&n&&(await Vt.mutateAsync({token:ge||de?.token||``,data:{externalDashboard:de.externalDashboard.id,filterKey:n,alias:t}}),me?.())},[de?.externalDashboard?.id,de?.isAllowedToRenameDashboardFilters,de?.token,me,ge,Vt]),or=(0,n.useCallback)(e=>{de?.isAllowedToCreateDashboardFilters&&de?.externalDashboard?.id&&e.isCreatedByClient&&e.clientId===de?.clientId&&Lt(e)},[de?.clientId,de?.externalDashboard?.id,de?.isAllowedToCreateDashboardFilters]),sr=(0,n.useCallback)(async()=>{if(de?.isAllowedToCreateDashboardFilters&&de?.externalDashboard?.id&&It){zt(``);try{await Bt.mutateAsync({token:ge||de?.token||``,data:{externalDashboard:de.externalDashboard.id,filters:rr(It.id)}}),Lt(void 0),me?.()}catch{zt(`That filter could not be deleted. Try again, or close this and reload the dashboard.`)}}},[rr,de?.externalDashboard?.id,de?.isAllowedToCreateDashboardFilters,de?.token,It,me,ge,Bt]),cr=(0,n.useCallback)(()=>{Lt(void 0),zt(``)},[]),lr=de?.isAllowedToCreateDashboardFilters?(0,i.jsx)(Xs,{variant:`popover`,className:j9.triggerButton,id:`createFilter`,"data-testid":`create-filter`,leftIcon:(0,i.jsx)(uY,{text:`Add a Dashboard Filter`,position:`right`,isAllowPosChange:!0,children:(0,i.jsx)(jy,{name:`plus`})}),onClick:()=>{Ft(void 0),Nt(!0)}}):void 0,ur=!!de?.isAllowedToCreateDashboardFilters,dr=U5t({filters:er,canCreateDashboardFilters:ur}),fr=W5t({filters:On,canCreateDashboardFilters:ur}),pr=(0,n.useMemo)(()=>{let e=UB(On);if(!e.length)return[];let t=pn?.filter(e=>e?.externalMetric?.chartOptions?.dashboardFilters?.length)?.map(e=>e?.externalMetric);return t?.length?t?.map(t=>{let n=e.filter(e=>t?.chartOptions?.dashboardFilters?.some(t=>t?.value===e?.label));return{metricId:t.metricId,id:t.id,filters:n}}):[]},[On,pn]),mr=(0,n.useMemo)(()=>e?.hideDashboardName===!1||!e?.hideDashboardName&&de?.isShowDashboardName,[e?.hideDashboardName,de?.isShowDashboardName]);(0,n.useEffect)(()=>{let e=setTimeout(()=>{He(QQt())},1e3);return()=>clearTimeout(e)},[]);let hr=(0,n.useMemo)(()=>!!de?.dataAppId,[de?.dataAppId]),gr=async e=>{Ge&&l&&(We(!0),await Jt({cards:e,isChangedByClient:!0}),setTimeout(()=>{window.dispatchEvent(new Event(`resize`))},100),Ke(!1),setTimeout(()=>{We(!1)},1e3))},_r=async(e,t)=>{let n=typeof t==`object`?t:void 0,r=typeof t==`string`?t:void 0,i=de?.externalDashboard?.layout||[],a=Yt&&Yt.length>0?Yt:i;if(n&&$t&&(a=Yt),n){let t=PGt(a,i,Jn.map(e=>e.id===n.replacedMetricId?{...e,resizeAttributes:n.resizeAttributes}:e)),r=FGt(t,e,n);We(!0),await Jt({cards:r,isChangedByClient:!0}),setTimeout(()=>{window.dispatchEvent(new Event(`resize`))},100),setTimeout(()=>{We(!1)},1e3);return}let o=[{i:e,x:0,y:0,w:Sl(ye?.current)?fue(r):12,h:10},...a.map(e=>({...e,y:(e?.y??0)+10}))];We(!0),await Jt({cards:o,isChangedByClient:!0}),setTimeout(()=>{window.dispatchEvent(new Event(`resize`))},100),setTimeout(()=>{We(!1)},1e3)},vr=async({onError:e,onSuccess:t,viewName:n,appliedfilters:r})=>{try{de?.externalDashboard?.id&&t(await Ye.mutateAsync({data:{name:n,externalDashboard:de?.externalDashboard?.externalDashboardId,viewFilter:r,metricViewFilters:at?.map(e=>({filters:e?.filters,id:e?.id}))||[],xAxisSettings:at?.map(e=>({xAxisSettings:e?.xAxisSettings,id:e?.id}))||[],yAxisSettings:at?.map(e=>({yAxisSettings:e?.yAxisSettings,id:e?.id}))||[]},token:de?.token}))}catch(t){e(t)}},yr=(0,n.useMemo)(()=>{if(!Gn)return;let e=(Qe?.data)?.dashboardViewFilter?.find(e=>e?.id===_t?.value);if(e)return{metricViewFilters:Array.isArray(e?.metricViewFilters)&&e?.metricViewFilters||[],xAxisSettings:Array.isArray(e?.xAxisSettings)&&e?.xAxisSettings||[],yAxisSettings:Array.isArray(e?.yAxisSettings)&&e?.yAxisSettings||[]}},[Qe?.data,_t,Gn]),br=(0,n.useMemo)(()=>{let e=Gn?yr:void 0;return Wt?{metricViewFilters:e?.metricViewFilters||[],xAxisSettings:[...HEr(Wt.xAxisSettings),...e?.xAxisSettings||[]],yAxisSettings:[...UEr(Wt.yAxisSettings),...e?.yAxisSettings||[]]}:e},[Gn,yr,Wt]),xr=(0,n.useRef)({}),Sr=(0,n.useCallback)((e,t)=>{xr.current=uXt(xr.current,e,t)},[]),Cr=(0,n.useRef)({xAxisSettings:[],yAxisSettings:[]});Cr.current={xAxisSettings:at?.filter(e=>e?.xAxisSettings?.isEnable&&e?.xAxisSettings?.xaxis)?.map(e=>({xAxisSettings:e?.xAxisSettings,id:e?.id}))||[],yAxisSettings:at?.filter(e=>e?.yAxisSettings?.isEnable&&Array.isArray(e?.yAxisSettings?.yAxis)&&e?.yAxisSettings?.yAxis?.length)?.map(e=>({yAxisSettings:e?.yAxisSettings,id:e?.id}))||[]};let{isGettingPdf:wr,cancelPdf:Tr,toPDF:Er,error:Dr,isPdfExported:Or}=pQt({dashboardId:de?.externalDashboard?.externalDashboardId||``,fileName:de?.externalDashboard?.name||`dashboard`,token:de?.token,globalFilters:kt,metricFiltersRef:xr,axisSettingsRef:Cr}),kr=()=>de?hn?(0,i.jsx)(TJ,{isOpen:qe,onClose:()=>Je(!1),isMobileModal:!0,headerTitle:`Dashboard Filters`,keepMounted:!0,children:(0,i.jsx)(_Ar,{encryptedClientId:``,isMobileView:hn,selectedViewOption:_t,setSelectViewOption:vt,onSaveViewFilter:vr,datasourceId:de?.datasourceId||``,dashboardId:l||``,fetchViewFiltersOptions:Qe,deleteViewFilterMutation:Ze,token:ge,isEndUserApp:!0,isAllowedCreateDashboardView:Wn,isEnableFilterView:Gn,viewFilterLabel:tn,createViewFilterMutation:Ye,onServerEvent:d,clientColumnType:de.clientColumnType,hideDatePickerOptions:e?.hideDatePickerOptions||[],filterIconColor:t?.button?.secondaryText,filterButtonBgColor:t?.button?.secondary,tenancyLevel:de.companyTenancyType,appliedFilterPairs:An,filters:er,addGlobalFilter:lr,onApply:e=>{Ht.current||At(e)},theme:yt,internal:{isInternal:!0,workspaceId:de.workspace?.id},setSelectedFilterVal:gt,clientId:de.clientId,onEditDashboardFilter:de?.isAllowedToCreateDashboardFilters?ir:void 0,onDeleteDashboardFilter:de?.isAllowedToCreateDashboardFilters?or:void 0,isAllowRenameDashboardFilter:!!de?.isAllowedToRenameDashboardFilters,onRenameDashboardFilter:ar,isDisableClick:Ve,isEditLayoutEnabled:Dt?.isEnabled,layout:{adminLayout:de.externalDashboard.dashboardFiltersLayout,clientLayout:Zt||[],isLocked:!de.isAllowedToChangeLayout||!Dt.isEnabled,onChange:e=>Ot(t=>({...t,filtersLayout:[...e]}))}})}):(0,i.jsx)(_Ar,{encryptedClientId:``,selectedViewOption:_t,setSelectViewOption:vt,onSaveViewFilter:vr,datasourceId:de?.datasourceId||``,dashboardId:l||``,fetchViewFiltersOptions:Qe,deleteViewFilterMutation:Ze,token:ge,isEndUserApp:!0,isAllowedCreateDashboardView:Wn,isEnableFilterView:Gn,viewFilterLabel:tn,createViewFilterMutation:Ye,onServerEvent:d,clientColumnType:de.clientColumnType,hideDatePickerOptions:e?.hideDatePickerOptions||[],filterIconColor:t?.button?.secondaryText,filterButtonBgColor:t?.button?.secondary,tenancyLevel:de.companyTenancyType,appliedFilterPairs:An,filters:er,addGlobalFilter:lr,onApply:e=>{Ht.current||At(e)},theme:yt,internal:{isInternal:!0,workspaceId:de.workspace?.id},setSelectedFilterVal:gt,clientId:de.clientId,onEditDashboardFilter:de?.isAllowedToCreateDashboardFilters?ir:void 0,onDeleteDashboardFilter:de?.isAllowedToCreateDashboardFilters?or:void 0,isAllowRenameDashboardFilter:!!de?.isAllowedToRenameDashboardFilters,onRenameDashboardFilter:ar,isDisableClick:Ve,isEditLayoutEnabled:Dt?.isEnabled,layout:{adminLayout:de.externalDashboard.dashboardFiltersLayout,clientLayout:Zt||[],isLocked:!de.isAllowedToChangeLayout||!Dt.isEnabled,onChange:e=>Ot(t=>({...t,filtersLayout:[...e]}))}}):null,[Ar,jr]=(0,n.useState)(``);return(0,n.useEffect)(()=>{if(h?.iconSvg){let e=YEr(h?.iconSvg),t=new Blob([e],{type:`image/svg+xml`}),n=URL.createObjectURL(t);return jr(n),()=>{URL.revokeObjectURL(n)}}},[h?.iconSvg]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{ref:rn,"data-dbn-appearance-anchor":``,style:{display:`contents`}}),(0,i.jsxs)(`div`,{className:`dbn:relative dbn:h-full dbn:w-full`,children:[(0,i.jsxs)(`div`,{className:`${X9[`embedDashboard-container`]} dbn-dashboard ${e?.shouldFitFullScreen&&(lt?.show||Se)?`dbn:overflow-hidden`:``}`,style:{pointerEvents:Ue?`none`:void 0},ref:ye,children:[de?.externalDashboard?.id&&!fe&&!pe&&(0,i.jsxs)(i.Fragment,{children:[!mr&&!zn&&!Rn&&!Vn&&!Un&&!Zn||!e?.showDashboardActions?null:!te&&(0,i.jsxs)(`div`,{className:`${X9[`embedDashboard-header`]} ${mr?X9.justifyBetween:X9.justifyEnd}`,style:Ve?{pointerEvents:`none`}:{},children:[mr?(0,i.jsx)(`h1`,{className:X9.dashboardName,children:de.externalDashboard.name||`Dashboard`}):null,(0,i.jsx)(`div`,{className:X9[`embedDashboard-header-buttons`],children:Dt.isEnabled&&!hn?(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-4 dbn:items-center`,children:[e?.dashboardSpacing?.hide?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`tertiary`,leftIcon:(0,i.jsx)(jy,{name:`ruler`}),className:`cta-tertiary`,children:`Adjust Spacing`}),position:`bottom-end`,children:(0,i.jsxs)(`div`,{className:`dbn:p-3 dbn:flex dbn:gap-2 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-vertical`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Vertical Gap`})]}),(0,i.jsx)(SJ,{id:`vertical-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.verticalMargin,onChange:e=>Kt(t=>i7({...t,verticalMargin:Number(e.target.value)}))})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-horizontal`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Horizontal Gap`})]}),(0,i.jsx)(SJ,{id:`horizontal-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.horizontalMargin,onChange:e=>Kt(t=>i7({...t,horizontalMargin:Number(e.target.value)}))})]})]})}),(0,i.jsx)(`div`,{className:`dbn:h-6 dbn:block dbn:border-l dbn:border-secondary`})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-2`,children:[(0,i.jsx)(Xs,{type:`button`,variant:`tab`,onClick:()=>{Ot({isEnabled:!1,layout:[]}),qn(),d?.(`EXIT_CUSTOMIZE_LAYOUT_MODE`)},className:`cta-secondary`,children:`Discard`}),!e?.disableSaveLayout&&(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:async()=>{let e=Dt?.filtersLayout?.sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)?.map(e=>e.i)||[];await Jt({cards:Dt.layout,filtersLayout:e,isChangedByClient:!0,gridMargin:Gt}),d?.(`SAVE_LAYOUT`),Ot({isEnabled:!1,layout:[],filtersLayout:[]})},isDisabled:!Dt.layout.length&&!Dt.filtersLayout&&!Gt||Xt,className:`cta-primary`,children:`Save Layout`})]})]}):(0,i.jsxs)(i.Fragment,{children:[hn&&dr&&(0,i.jsxs)(`span`,{className:`dbn:relative`,children:[(0,i.jsx)(Xs,{variant:`tab`,"aria-label":`Open dashboard filters`,leftIcon:(0,i.jsx)(jy,{name:`funnel`,color:`primary`}),onClick:()=>Je(!0),"data-testid":`filters-popup-btn`,className:`cta-tertiary`}),jn?(0,i.jsx)(`span`,{className:`dbn:pointer-events-none dbn:absolute dbn:top-2 dbn:right-3 dbn:w-1 dbn:h-3`,children:(0,i.jsx)(jy,{name:`circle`,color:`primary`})}):null]}),Zn?(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`tab`,leftIcon:h?.iconSvg&&Ar?(0,i.jsx)(`img`,{src:Ar,alt:`custom settings btn`,className:`dbn:w-5 dbn:h-5 dbn:text-text-primary-color`}):(0,i.jsx)(jy,{name:`gear`}),"aria-label":h?.ariaLabel,"data-testid":`settings-btn`,className:`cta-secondary`,children:hn?``:h?.name?h?.name:`Settings`}),tabMenu:!0,position:h?.menuPosition||`bottom-start`,offset:[10,15],popoverButtonId:`settings`,containerHeight:`cta-secondary-height`,children:(0,i.jsxs)(`div`,{className:`dbn:p-2`,id:`settings-menu`,"data-testid":`settings-menu`,children:[!hn&&Ln.canCustomizeLayout&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>{Ot({isEnabled:!0,layout:[]}),d?.(`ENTER_CUSTOMIZE_LAYOUT_MODE`)},className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`custom`}),fitContainer:!0,children:`Customize Layout`})}),it&&(de?.isAllowToDownloadAllMetrics||e?.enableDownloadAllMetrics)&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:et?.isLoading?(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>tt(),className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`stop`}),fitContainer:!0,children:`Cancel download`}):(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>$e({dashboardName:de?.externalDashboard.name||`dashboard`,datasourceId:``,externalDashboardId:de?.externalDashboard?.externalDashboardId||``,globalFilters:kt,metricData:at||[],workspaceId:de?.workspace?.id||``,token:de?.token,onServerEvent:d}),className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`download`}),fitContainer:!0,isDisabled:et?.isLoading,children:`Download Metrics`})}),e?.enableDownloadAllPdf&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:wr?(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>Tr(),className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`stop`}),fitContainer:!0,children:`Cancel export`}):(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:async()=>{d?.(`START_DASHBOARD_PDF`),await Er(),d?.(`EXPORT_DASHBOARD_PDF`)},className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`download`}),fitContainer:!0,children:`Export As PDF`})}),!hn&&Ln.canManageMetrics&&!!Xn?.length&&(!t?.manageMetricsStyle||t?.manageMetricsStyle&&!Q9(t?.manageMetricsStyle))&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:(0,i.jsx)(Xs,{variant:`tertiary`,title:`manage metrics`,onClick:()=>{d?.(`ENTER_MANAGE_METRICS_MODE`),Ae(!0)},style:t?.manageMetricsStyle,className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`chart`}),fitContainer:!0,children:m?m():`Manage Metrics`})}),!hn&&Ln.canManageMetrics&&!!de.externalDashboardMetrics?.filter(e=>e?.externalMetric?.datasetMetricSettings?.metricImportMode===`GALLERY`).length&&(!t?.manageMetricsStyle||t?.manageMetricsStyle&&!Q9(t?.manageMetricsStyle))&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:(0,i.jsx)(Xs,{variant:`tertiary`,title:`manage metrics`,onClick:()=>{d?.(`ENTER_METRICS_GALLERY_MODE`),Me(!0)},style:t?.manageMetricsStyle,className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`chart`}),fitContainer:!0,children:m?m():`Gallery`})})]})}):null,!hn&&Ne&&Bn.available&&(0,i.jsx)(Xs,{"data-testid":`schedule-reports-btn`,variant:`tab`,type:`button`,onClick:()=>{d?.(`ENTER_SCHEDULED_REPORT_MODE`),Ie(!0)},title:`email-sharing`,className:`cta-secondary`,children:`Schedule Reports`}),!hn&&Ln.canCreateMetric&&de.metricCreationMode===`DRAG_DROP`&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:()=>{e?.shouldFitFullScreen&&tpt(ye.current),Ce(!0),d?.(`ENTER_CREATE_METRIC`)},leftIcon:(0,i.jsx)(jy,{name:`plus`,color:`light`}),className:`cta-primary`,containerClass:`cta-primary-height`,children:`Create Metric`})}),!hn&&Ln.canCreateMetric&&de.metricCreationMode===`POINT_CLICK`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Xs,{type:`button`,variant:`tab`,onClick:()=>ft(!0),className:`cta-tertiary`,children:(0,i.jsx)(jy,{name:`magnifying-glass`})}),(0,i.jsx)(R7,{children:dt&&(0,i.jsx)(mEr,{saveDashLayout:_r,onServerEvent:d,refetchDashboardData:me,setEditMetric:ct,metric:st?.metric,datasourceId:de?.datasourceId,clientColumnType:de.clientColumnType,tenancyType:de.companyTenancyType,token:de.token,clientId:de.clientId,companyId:de.companyId,isLiveMode:!1,externalDashboardId:de.externalDashboard.id,chartColors:e?.chartColors??Cn??$9,isShowMetricCreateModal:dt,setShowMetricCreateModal:ft,workspaceId:de.workspace?.id,userProvidedDashboardId:de.externalDashboard.externalDashboardId})})]}),!hn&&Ln.canCreateMetric&&de?.metricCreationMode===`CHAT`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:()=>mt(!0),leftIcon:(0,i.jsx)(jy,{name:`plus`,color:`light`}),className:`cta-primary`,children:`Chat with your Data`}),(0,i.jsx)(R7,{children:pt&&(0,i.jsx)(_wr,{config:{saveDashLayout:_r,onServerEvent:d,refetchDashboardData:me,externalDashboardId:de.externalDashboard.externalDashboardId,datasourceId:de?.datasourceId||``,embedDataAppId:de?.embedDataAppId||``,companyId:de.companyId,dashboardId:de.externalDashboard.id,dashboardIds:[de.externalDashboard.id],token:ge,workspaceId:de.workspace?.id,themeChartColors:e?.chartColors??Cn??$9,setSearchGenerateMetricModal:mt,clientId:de.clientId}})})]})]})}),(0,i.jsx)(`div`,{className:X9.minimapHeaderProgressContainer,ref:xe})]}),!e?.showDashboardActions&&Dt.isEnabled?(0,i.jsx)(`div`,{className:`${X9[`embedDashboard-header`]} ${X9.justifyEnd}`,children:(0,i.jsx)(`div`,{className:X9[`embedDashboard-header-buttons`],children:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-4 dbn:items-center`,children:[e?.dashboardSpacing?.hide?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`tertiary`,leftIcon:(0,i.jsx)(jy,{name:`ruler`}),children:`Adjust Spacing`}),position:`bottom-end`,children:(0,i.jsxs)(`div`,{className:`dbn:p-3 dbn:flex dbn:gap-2 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-vertical`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Vertical Gap`})]}),(0,i.jsx)(SJ,{id:`vertical-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.verticalMargin,onChange:e=>Kt(t=>i7({...t,verticalMargin:Number(e.target.value)}))})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-horizontal`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Horizontal Gap`})]}),(0,i.jsx)(SJ,{id:`horizontal-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.horizontalMargin,onChange:e=>Kt(t=>i7({...t,horizontalMargin:Number(e.target.value)}))})]})]})}),(0,i.jsx)(`div`,{className:`dbn:h-6 dbn:block dbn:border-l dbn:border-secondary`})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-2`,children:[(0,i.jsx)(Xs,{type:`button`,variant:`tab`,onClick:()=>{d?.(`EXIT_CUSTOMIZE_LAYOUT_MODE`),Ot({isEnabled:!1,layout:[]}),qn()},className:`cta-secondary`,children:`Discard`}),!e?.disableSaveLayout&&(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:async()=>{let e=Dt?.filtersLayout?.sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)?.map(e=>e.i)||[];await Jt({cards:Dt.layout,filtersLayout:e,isChangedByClient:!0,gridMargin:Gt}),d?.(`SAVE_LAYOUT`),Ot({isEnabled:!1,layout:[],filtersLayout:[]})},isDisabled:!Dt.layout.length&&!Dt.filtersLayout&&!Gt||Xt,className:`cta-primary`,children:`Save Layout`})]})]})})}):null,e?.isStickyDashboardFilters&&fr?(0,i.jsx)(`div`,{className:`${X9[`embedDashboard-stickyFilters`]} dbn-selectBox ${dr?``:`dbn:hidden`}`,children:kr()}):null,(0,i.jsxs)(`div`,{className:`${X9[`embedDashboard-wrapper`]} ${e?.isStickyDashboardFilters&&dr?`dbn:pt-0`:``}`,style:e?.dashboardPadding?{padding:e?.dashboardPadding}:{},children:[!e?.isStickyDashboardFilters&&fr?(0,i.jsx)(`div`,{className:dr?``:`dbn:hidden`,children:kr()}):null,(0,i.jsx)(qTr,{refreshSeconds:de?.refreshTime,isPaused:_n,onTogglePause:()=>vn(e=>!e),onRefreshNow:()=>void Sn(),isRefreshing:yn}),(0,i.jsx)(emr,{drillUrlState:ue,customMessages:a,onCreateMetric:!hn&&Ln.canCreateMetric?de.metricCreationMode===`DRAG_DROP`?()=>{e?.shouldFitFullScreen&&tpt(ye.current),Ce(!0),d?.(`ENTER_CREATE_METRIC`)}:de.metricCreationMode===`POINT_CLICK`?()=>ft(!0):de.metricCreationMode===`CHAT`?()=>mt(!0):void 0:void 0,refetchDashboardData:me,externalDashboardClientId:dKt({dashboard:de?.externalDashboard,principal:{clientId:de.clientId,isAllClient:de.isAllClient}}),dataMartTables:de?.dataMartTables,userIdentifier:de?.userIdentifier,viewMetricData:br,setMetricMetadata:ot,rules:de?.externalDashboard?.rules||[],disableDownloadDataNoFilters:e?.disableDownloadDataNoFilters,disableDownloadUnderlyingDataNoFilters:e?.disableDownloadUnderlyingDataNoFilters,isShowNoDataFoundScreen:e?.isShowNoDataFoundScreen,isDataApp:hr,generatingPdf:!!te,onEditMetric:e=>{let t=NGt(e.id,Yt,de?.externalDashboard?.layout||[],e.resizeAttributes,!e.isMetric);Ce(!0),ct({metric:{...e,resizeAttributes:t}}),d?.(`ENTER_EDIT_METRIC`)},calendarType:b,metricMergedFilters:pr,language:_,translationDictionary:v,saveDashLayout:gr,fullScreenModal:lt,setFullScreenModal:ut,chartFontSettings:un?.chart,chartColumns:g,isAllClient:de.isAllClient,onServerEvent:d,chartClickFunction:C,disableMetricCardBorder:e?.disableMetricCardBorder,isAllowToDownloadMetrics:de?.isAllowToDownloadMetrics,setRowMetrics:Be,metricIndex:Le,noDataImg:f,noDataFoundSvg:p,shouldFitFullScreen:e?.shouldFitFullScreen,isEnableMetricSummary:de?.isEnableMetricSummary,mergedMetrics:$n,metricCardColor:un?.dashboard?.metricCardColor||``,isShadowDisableOnHover:Tt,isDisableMetricLoader:e?.disableMetricLoader,chartAppearance:e?.chartAppearance,clientColumnType:de.clientColumnType,workspaceId:de.workspace?.id,isEditLayoutEnabled:Dt?.isEnabled,isMobileScreen:hn,gridMargin:Gt??{horizontalMargin:Number(nn?.dashboard?.horizontalGap),verticalMargin:Number(nn?.dashboard?.verticalGap)},token:ge,dataLimit:we,setDataLimit:Te,scrollContainerRef:ye,minimapRailContainerRef:be,minimapHeaderProgressContainerRef:xe,minimapTheme:{backgroundColor:un?.dashboard?.backgroundColor},isShowDashboardMinimap:e?.enableDashboardMinimap??!nn?.dashboard?.disableDashboardMinimap,isShowLoader:Ee,client:de.clientId,companyId:de.companyId,optionsIcon:e?.optionsIcon,externalDashboardId:de.externalDashboard.externalDashboardId,externalDashboardPk:de.externalDashboard.id,layout:{adminLayout:de.externalDashboard.layout,clientLayout:Yt,isLocked:!de.isAllowedToChangeLayout||!Dt.isEnabled,onChange:e=>Ot(t=>({...t,layout:[...e]}))},isAllowedToDeleteMetrics:Ln.canArchiveMetric,isAllowedToUpdateMetrics:Ln.canEditMetric,isAllowedToChangeLayout:Ln.canCustomizeLayout&&Dt.isEnabled,isAllowedToSeeUnderlyingData:Ln.canViewUnderlyingData,externalDashboardMetrics:de.externalDashboardMetrics,isMetricListLoading:fe,globalFilters:kt,onClearAllFilters:jt,breakpoint:t?.breakpoint,layoutCols:t?.metricLayoutCols,chartColors:e?.chartColors??Cn??$9,isChartColorsExplicit:!!e?.chartColors?.length||!!Cn?.length,params:Array.isArray(de.rlsSettings)?de.rlsSettings:[],companyTenancyType:de.companyTenancyType,sharingSettingsId:de.sharingSettingsId,appFilters:de.appFilters,isHideChartSettings:e?.isHideChartSettings,isHideTablePreview:e?.isHideTablePreview,enableDownloadCsv:e?.enableDownloadCsv,disableDownloadPng:e?.disableDownloadPng,enableEmailCsv:e?.enableEmailCsv,enableMultiMetricFilters:e?.enableMultiMetricFilters,disableFullscreen:e?.disableFullscreen,enableTitleClickFullscreen:e?.enableTitleClickFullscreen,enableAdhocDrill:e?.enableAdhocDrill,enableExcludeFilter:e?.enableExcludeFilter,enableCrossFilter:e?.enableCrossFilter,enableCrossFilterBeforeDrill:e?.enableCrossFilterBeforeDrill,dropdownTheme:yt,underlyingTheme:xt,hideDatePickerOptions:e?.hideDatePickerOptions,datasourceId:de.datasourceId||``,isDisableClick:Ve,setShowSettingsBtn:Pe,allowedChartTypes:e?.allowedChartTypes,onMetricFiltersChange:Sr,pdfMetricFilters:Ut},`metrics-${pn?.length}-${Yt?.length}`),(0,i.jsx)(Ukr,{props:{companyId:de?.companyId,externalDashboardId:de?.externalDashboard?.externalDashboardId,language:_,translationDictionary:v,datasourceId:de?.datasourceId||``,metricList:Xn,token:ge,client:de.clientId,companyTenancyType:de.companyTenancyType,workspaceId:de.workspace?.id,chartAppearance:e?.chartAppearance,colors:e?.chartColors??Cn??$9,isOpenModal:Oe,setOpenModal:Ae,onServerEvent:d,refetchDashboardData:me,globalFilters:kt,params:Array.isArray(de.rlsSettings)?de.rlsSettings:[]}}),(0,i.jsx)(IEr,{props:{companyId:de?.companyId,externalDashboardId:de?.externalDashboard?.externalDashboardId,language:_,translationDictionary:v,datasourceId:de?.datasourceId||``,metricList:Qn,token:ge,client:de.clientId,companyTenancyType:de.companyTenancyType,workspaceId:de.workspace?.id,chartAppearance:e?.chartAppearance,colors:e?.chartColors??Cn??$9,isOpenModal:je,setOpenModal:Me,onServerEvent:d}}),Fe?(0,i.jsx)(xAr,{props:{chartOptions:Yn,isShowSettings:!0,setShowSettings:Ie,onServerEvent:d,onComplete:()=>d?.(`SAVE_SCHEDULED_REPORT`),isEmbed:!0,externalDashboardId:de?.externalDashboard?.id}}):null,e?.shouldFitFullScreen?Se&&(0,i.jsx)(akr,{filters:er,isIncrementalJoin:de.isIncrementalJoin,onServerEvent:d,refetchDashboardData:me,saveDashLayout:_r,metric:st?.metric,setEditMetric:ct,datasourceId:de?.datasourceId,clientColumnType:de.clientColumnType,tenancyType:de.companyTenancyType,token:de.token,clientId:de.clientId,companyId:de.companyId,isLiveMode:!1,externalDashboardId:de.externalDashboard.id,chartColors:e?.chartColors??S?.chartColors?.defaultValue??Cn??$9,colorPalettes:e?.chartPaletteOptions??wn,isShowMetricCreateModal:Se,setShowMetricCreateModal:Ce,workspaceId:de.workspace?.id,userProvidedDashboardId:de.externalDashboard.externalDashboardId,shouldFitFullScreen:e?.shouldFitFullScreen,customChartSettings:S,showAllChartSettings:e?.showAllChartSettings,showChartClickSettings:e?.showChartClickSettings,allowedChartTypes:e?.allowedChartTypes}):(0,i.jsx)(R7,{children:Se&&(0,i.jsx)(akr,{filters:er,isIncrementalJoin:de?.isIncrementalJoin,onServerEvent:d,refetchDashboardData:me,saveDashLayout:_r,metric:st?.metric,setEditMetric:ct,datasourceId:de?.datasourceId,clientColumnType:de.clientColumnType,tenancyType:de.companyTenancyType,token:de.token,clientId:de.clientId,companyId:de.companyId,isLiveMode:!1,externalDashboardId:de.externalDashboard.id,chartColors:e?.chartColors??S?.chartColors?.defaultValue??Cn??$9,colorPalettes:e?.chartPaletteOptions??wn,isShowMetricCreateModal:Se,setShowMetricCreateModal:Ce,workspaceId:de.workspace?.id,userProvidedDashboardId:de.externalDashboard.externalDashboardId,customChartSettings:S,showAllChartSettings:e?.showAllChartSettings,showChartClickSettings:e?.showChartClickSettings,allowedChartTypes:e?.allowedChartTypes})})]})]}),!ge&&!window?.dbn?.isEnableProxyAuth&&!fe?(0,i.jsx)(`div`,{className:X9[`alt-container`],children:(0,i.jsx)(zK,{state:`error`,widgetName:`Dashboard`,errorMessage:a?.tokenAbsent||`This link is incomplete. Ask the person who shared it for a new link.`})}):null,fe&&!e?.disableMainLoader&&(0,i.jsx)(`div`,{className:X9[`alt-container`],children:(0,i.jsx)(D6,{})}),!!(ge||window?.dbn?.isEnableProxyAuth)&&!fe&&!de?.externalDashboard?.id&&pe&&(0,i.jsx)(`div`,{className:X9[`alt-container`],children:(0,i.jsx)(zK,{state:`error`,widgetName:`Dashboard`,errorMessage:pe===`TOKEN_EXPIRED`?a?.tokenExpiry||`Your access has expired. Ask for a new link.`:W(he)||`This dashboard could not be loaded. Check the link and try again.`,errorDetail:typeof pe==`string`?pe:void 0,onRetry:pe===`TOKEN_EXPIRED`||_e===`UNAUTHORIZED_ORIGIN`?void 0:()=>{me?.()}})})]}),(0,i.jsx)(`div`,{className:`dbn:pointer-events-none dbn:absolute dbn:bottom-0 dbn:right-0 dbn:top-0 dbn:z-[110]`,ref:be})]}),de?.isAllowedToCreateDashboardFilters?(0,i.jsx)(TJ,{isOpen:Mt,onClose:()=>{Nt(!1),Ft(void 0)},headerTitle:`Dashboard Filters`,size:`xl`,children:(0,i.jsx)(vAr,{dashboard:de?.externalDashboard?{...de.externalDashboard,filters:de.externalDashboard.filters}:void 0,schemaList:tr,isSchemaAccessLoaded:nr,token:ge||de?.token||``,clientId:de?.clientId,clientColumnType:de?.clientColumnType,tenancyLevel:de?.companyTenancyType,filterToEdit:Pt,onCancel:()=>{Nt(!1),Ft(void 0)},onSuccess:()=>{Nt(!1),Ft(void 0),me?.()}})}):null,(0,i.jsx)(TJ,{isOpen:!!de?.isAllowedToCreateDashboardFilters&&!!It,onClose:cr,headerTitle:`Delete Dashboard Filter`,size:`sm`,children:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:flex-col dbn:gap-6 dbn:px-6 dbn:pb-5`,children:[(0,i.jsx)(xa,{variant:`body-text-2`,children:`Delete the filter "${It?.label||It?.name||``}"? It leaves the filter bar, and any value selected in it stops being applied. The dashboard's own filters are not changed.`}),Rt?(0,i.jsx)(xa,{variant:`body-text-2`,color:`alert`,children:Rt}):null,(0,i.jsxs)(`div`,{className:`dbn:flex dbn:justify-end dbn:gap-3`,children:[(0,i.jsx)(Xs,{variant:`tab`,type:`button`,onClick:cr,className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{variant:`primary`,type:`button`,onClick:sr,isDisabled:Bt.isPending,className:`cta-primary`,children:`Delete`})]})]})}),Ue?(0,i.jsx)(`div`,{className:`dbn:absolute dbn:bg-gray dbn:p-4 dbn:rounded-md dbn:right-5 dbn:bottom-20 dbn:z-[9999999] dbn:border-l-4 dbn:border-black`,children:(0,i.jsx)(xa,{alignment:`center`,color:`primary`,variant:`heading-4`,children:`Please wait, adjusting layout....`})}):null,e?.exportMsgPosition!==`hidden`&&(wr||Dr||Or)?(0,i.jsx)(`div`,{className:`dbn:absolute dbn:z-[9999999] ${X9[`export-${e?.exportMsgPosition??`bottom-right`}`]}`,children:(0,i.jsx)(`div`,{className:`dbn:w-max dbn:flex dbn:items-center dbn:justify-center dbn:gap-1 dbn:p-2 dbn:rounded-md ${[`bottom-left`,`top-left`].includes(e?.exportMsgPosition??``)?`dbn:border-r-4`:[`bottom`,`top`,`center`].includes(e?.exportMsgPosition??``)?`dbn:border-x-4`:`dbn:border-l-4`} ${Dr?`dbn:bg-red-100 dbn:border-alert`:`dbn:bg-green-100 dbn:border-success`}`,children:!Dr&&(wr||Or)?(0,i.jsxs)(i.Fragment,{children:[Or?(0,i.jsx)(jy,{name:`check`,color:`success`}):null,(0,i.jsx)(xa,{alignment:`center`,color:`success`,variant:`heading-4`,children:Or?`Exported Dashboard Successfully.`:`Exporting Dashboard...`})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(jy,{name:`info-filled`,color:`alert`}),(0,i.jsx)(xa,{alignment:`center`,color:`alert`,variant:`heading-4`,children:Dr})]})})}):null,e?.exportMsgPosition!==`hidden`&&nt?(0,i.jsx)(`div`,{className:`dbn:absolute dbn:z-[9999999] ${X9[`export-${e?.exportMsgPosition??`bottom-right`}`]}`,children:(0,i.jsxs)(`div`,{role:`status`,className:`dbn:max-w-[320px] dbn:flex dbn:items-start dbn:justify-center dbn:gap-1 dbn:p-2 dbn:rounded-md dbn:bg-red-100 dbn:border-l-4 dbn:border-alert`,children:[(0,i.jsx)(jy,{name:`info-filled`,color:`alert`}),(0,i.jsx)(xa,{alignment:`center`,color:`alert`,variant:`heading-4`,children:nt})]})}):null]})})})),AAr=h((()=>{})),jAr=h((()=>{})),MAr=h((()=>{})),NAr,PAr=h((()=>{qi(),Ea(),bc(),_l(),kAr(),AAr(),jAr(),MAr(),Cht(),V_t(),U_t(),qr(),AB(),qQn(),T6(),NAr=({token:e,options:t,theme:r,dashboardId:a,isHideChartSettings:o,isHideTablePreview:s,isStickyDashboardFilters:l,enableDownloadAllMetrics:u,enableDownloadAllPdf:d,enableDownloadCsv:f,enableEmailCsv:p,enableMultiMetricFilters:m,disableFullscreen:h,enableTitleClickFullscreen:g,enableAdhocDrill:_,enableExcludeFilter:v,enableCrossFilter:y,enableChartDashboardNavigation:b,optionsIcon:x,settingsIcon:S,adminThemeOptions:C,customMessages:w,themeName:T,globalFilterOptions:ee,handleServerEvent:te,onSupportClick:ne,supportLabel:re,chartClickFunction:ie,noDataImg:ae,noDataFoundSvg:oe,manageMetricsBtnContent:se,disableDownloadPng:ce,longDescriptionConfig:le,chartColumns:ue,language:de,translationDictionary:fe,hideDashboardFilters:pe,calendarType:me=`default`,customChartSettings:he,uiVersion:ge,embedFlags:_e,dataDbnUi:ve,configId:ye,filterStateFunction:be,debug:xe})=>{let[Se,Ce]=(0,n.useState)(),{ref:we,target:Te}=Bi(xht(ve),{dashboardId:a});xr(xe);let Ee=(0,n.useRef)(void 0);Ee.current||=Or();let De=Ee.current,Oe=()=>ye||new URL(window.location.href).searchParams.get(`configId`),Ae=(0,n.useMemo)(()=>KQn(ie),[ie]);(0,n.useEffect)(()=>{let n=Date.now();return Gr(`dashboard-mounted`,{instanceId:De,dashboardId:a,hasToken:!!e,tokenLength:e?.length||0,isProxyAuth:!!window?.dbn?.isEnableProxyAuth,hasBaseUrl:!!window?.dbn?.baseUrl,themeName:T,language:de,calendarType:me,options:{disableMetricCreation:!!t?.disableMetricCreation,disableMetricUpdation:!!t?.disableMetricUpdation,disableMetricDeletion:!!t?.disableMetricDeletion,disableManageMetrics:!!t?.disableManageMetrics,disableLayoutCustomization:!!t?.disableLayoutCustomization,disableSaveLayout:!!t?.disableSaveLayout,disableScheduleEmailReports:!!t?.disableScheduleEmailReports,disableUnderlyingData:!!t?.disableUnderlyingData},enableDownloadCsv:!!f,enableDownloadAllPdf:!!d,enableMultiMetricFilters:!!m,disableFullscreen:!!h,hasGlobalFilterOptions:!!ee,hasHandleServerEvent:typeof te==`function`}),()=>{Gr(`dashboard-unmounted`,{instanceId:De,dashboardId:a,lifetimeMs:Date.now()-n})}},[De]),(0,n.useEffect)(()=>{C?.general?.name&&Ce(C)},[C]);let je=he?GS(he):{};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(B_t,{componentName:`dashboard`,adminTheme:Se,isDisableCardShadow:t?.hideMetricCardShadow,theme:r,longDescriptionConfig:le,isDisableStrokeOpt:!!t?.disableMetricCardBorder?.toString(),ctaCustomization:t?.ctaButtonCustomization,uiVersion:ge,embedFlags:_e}),(0,i.jsx)(`div`,{ref:we,style:{display:`contents`},children:(0,i.jsx)(Li,{value:Te,children:(0,i.jsxs)(yc,{theme:r,debug:xe,instanceId:De,onSupportClick:ne,supportLabel:re,children:[(0,i.jsx)(H_t,{variant:`dashboard`}),typeof a==`string`&&!a.trim()?(0,i.jsx)(Ta,{kind:`dashboard`}):(0,i.jsx)(WXn,{uiVersion:ge,resolutionInput:{explicit:_e},children:(0,i.jsx)(WQn,{isEnabled:!!b,onNavigate:Ae,children:(0,i.jsx)(gl,{token:e,dashboardId:a,configId:Oe()||``,children:(0,i.jsx)(OAr,{componentToken:e,calendarType:me,options:{...t,isHideChartSettings:o,isHideTablePreview:s,isStickyDashboardFilters:l,enableDownloadCsv:f,enableEmailCsv:p,enableDownloadAllMetrics:u,enableDownloadAllPdf:d,enableMultiMetricFilters:m,disableFullscreen:h,enableTitleClickFullscreen:g,enableAdhocDrill:_,enableExcludeFilter:v,enableCrossFilter:y,optionsIcon:x,disableLayoutCustomization:t?.disableLayoutCustomization?.toString()?t.disableLayoutCustomization:!1,disableMetricCreation:t?.disableMetricCreation?.toString()?t.disableMetricCreation:!1,disableManageMetrics:t?.disableManageMetrics?.toString()?t.disableManageMetrics:!1,disableSaveLayout:t?.disableSaveLayout?.toString()?t.disableSaveLayout:!1,disableScheduleEmailReports:t?.disableScheduleEmailReports?.toString()?t.disableScheduleEmailReports:!1,disableMainLoader:t?.disableMainLoader?.toString()?t.disableMainLoader:!1,disableMetricLoader:t?.disableMetricLoader?.toString()?t.disableMetricLoader:!1,showDashboardActions:!t?.showDashboardActions?.toString()||t.showDashboardActions,isShowNoDataFoundScreen:t?.isShowNoDataFoundScreen?.toString()?t.isShowNoDataFoundScreen:!1,isModifyUrl:t?.isModifyUrl?.toString()?t.isModifyUrl:!1,namespaceUrlState:!t?.namespaceUrlState?.toString()||t.namespaceUrlState,legacyUrlState:t?.legacyUrlState?.toString()?t.legacyUrlState:!1,disableDownloadPng:ce,disableDownloadDataNoFilters:t?.disableDownloadDataNoFilters?.toString()?t.disableDownloadDataNoFilters:!1,disableDownloadUnderlyingDataNoFilters:t?.disableDownloadUnderlyingDataNoFilters?.toString()?t.disableDownloadUnderlyingDataNoFilters:!1,showAllChartSettings:t?.showAllChartSettings?.toString()?t.showAllChartSettings:!1,showChartClickSettings:t?.showChartClickSettings?.toString()?t.showChartClickSettings:!1,enableDashboardMinimap:t?.enableDashboardMinimap?.toString()?t.enableDashboardMinimap:!1},setAdminTheme:Ce,theme:r,themeName:T,adminThemeOption:C,customMessages:w,dashboardId:a,configId:Oe()||void 0,globalFilterOptions:ee&&GS(ee),chartColumns:ue&&GS(ue),onServerEvent:te,chartClickFunction:ie,filterStateFunction:be,noDataImg:ae,noDataFoundSvg:oe,customContent:se,customSettingsBtn:S?GS(S):{},translationDictionary:fe?GS(fe):{},language:de||``,hideDashboardFilters:pe?GS(pe)||[]:pe||[],customChartSettings:{...je,customSettings:{...je?.customSettings,customUppperLimit:je?.customSettings?.customUpperLimit}}})})})})]})})})]})}})),FAr=h((()=>{PAr(),kAr()}));Tgt();var IAr=[`light`,`dark`,`system`,`theme`],LAr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),RAr=e=>e!=null&&e!==``,zAr=e=>typeof e==`string`?JSON.stringify(e):Array.isArray(e)?`an array`:typeof e,BAr=(e,t)=>{let n=[],r=(t,r)=>n.push({prop:t,message:`<${e}> "${t}" ${r}`});for(let e of[`token`,`dashboardId`,`metricId`,`themeName`]){let n=t[e];RAr(n)&&typeof n!=`string`&&r(e,`must be a string, got ${zAr(n)}.`)}let i=t.colorScheme;RAr(i)&&!IAr.includes(i)&&r(`colorScheme`,`must be one of ${IAr.join(`, `)}, got ${zAr(i)}. The value is ignored.`);for(let e of[`options`,`theme`,`customMessages`]){let n=t[e];RAr(n)&&!LAr(n)&&r(e,`must be a JSON object, got ${zAr(n)}. The value is ignored.`)}let a=t.adminThemeOptions;if(RAr(a)){if(!LAr(a))r(`adminThemeOptions`,`must be a JSON object, got ${zAr(a)}. The value is ignored.`);else for(let e of wgt(a).issues)r(`adminThemeOptions`,`field ${e.path||`(root)`} was ${e.problem===`coerced`?`converted to a valid CSS value`:`invalid and was dropped`}.`)}return n},VAr=new Set,HAr=(e,t)=>{let r=r=>((0,n.useEffect)(()=>{for(let e of BAr(t,r))VAr.has(e.message)||(VAr.add(e.message),console.error(`[databrain] ${e.message}`))},[r]),(0,n.createElement)(e,r));return r.displayName=`withPublicPropsCheck(${t})`,r};Ge(),sr(),FAr(),n2t(),qr(),AAr();var UAr=HAr(NAr,`dbn-dashboard`),WAr=HAr(t2t,`dbn-metric`);w(`viewer`);var GAr=e=>{let t=e.getAttribute(`base-url`),n=mt(t);Gr(`web-component-base-url`,{requested:t,inEffect:n})},KAr=(e,t,n)=>{if(typeof n!=`string`||!n.trim())return`${e}: no ${t.canonical} was set. Use the ${t.label} id from the Embeds page.`;if(/\s/.test(n.trim()))return`${e}: ${t.canonical} "${n}" looks like a name, not an id. Use the ${t.label} id from the Embeds page.`},qAr=(e,t,n)=>class extends e{static get observedAttributes(){let t=e.observedAttributes??[];return n?[...t,n.alias]:t}lastIdWarning;isClearingId=!1;clearId(e){this.isClearingId=!0;try{this[e.prop]=``,this.removeAttribute(e.canonical)}finally{this.isClearingId=!1}this.isConnected&&super.connectedCallback()}attributeChangedCallback(e,t,r){if(!this.isClearingId){if(e===`base-url`&&GAr(this),n&&e===n.canonical&&r===null){let e=this.getAttribute(n.alias);e?super.attributeChangedCallback?.(n.canonical,t,e):this.clearId(n);return}if(n&&e===n.alias){this.hasAttribute(n.canonical)||(r?super.attributeChangedCallback?.(n.canonical,t,r):this.clearId(n));return}super.attributeChangedCallback?.(e,t,r)}}connectedCallback(){xr(this.getAttribute(`debug`)??void 0),GAr(this),Gr(`web-component-connected`,{tag:t,attributeNames:this.getAttributeNames(),hasShadowRoot:!!this.shadowRoot}),super.connectedCallback(),n&&setTimeout(()=>this.warnOnIdProblem(n),0)}warnOnIdProblem(e){if(!this.isConnected)return;let n=this[e.prop],r=KAr(t,e,n);r&&r!==this.lastIdWarning&&(this.lastIdWarning=r,console.warn(r))}disconnectedCallback(){Gr(`web-component-disconnected`,{tag:t}),super.disconnectedCallback()}},JAr=st(UAr,{props:{token:`string`,dashboardId:`string`,debug:`string`,options:`json`,theme:`json`,isHideChartSettings:`boolean`,isHideTablePreview:`boolean`,isStickyDashboardFilters:`boolean`,enableDownloadCsv:`boolean`,enableEmailCsv:`boolean`,disableDownloadPng:`boolean`,enableDownloadAllMetrics:`boolean`,enableDownloadAllPdf:`boolean`,enableMultiMetricFilters:`boolean`,disableFullscreen:`boolean`,enableTitleClickFullscreen:`boolean`,enableAdhocDrill:`boolean`,enableExcludeFilter:`boolean`,enableCrossFilter:`boolean`,enableChartDashboardNavigation:`boolean`,configId:`string`,optionsIcon:`string`,settingsIcon:`json`,adminThemeOptions:`json`,customMessages:`json`,onSupportClick:`function`,supportLabel:`string`,themeName:`string`,enableThemeContrastWarnings:`boolean`,colorScheme:`string`,globalFilterOptions:`json`,handleServerEvent:`function`,noDataImg:`string`,noDataFoundSvg:`string`,manageMetricsBtnContent:`function`,longDescriptionConfig:`json`,chartColumns:`json`,language:`string`,translationDictionary:`json`,hideDashboardFilters:`json`,calendarType:`string`,customChartSettings:`json`,chartClickFunction:`function`,filterStateFunction:`function`,uiVersion:`string`,embedFlags:`json`,dataDbnUi:`string`,baseUrl:`string`},shadow:`open`});customElements.get(`dbn-dashboard`)||customElements.define(`dbn-dashboard`,qAr(JAr,`dbn-dashboard`,{canonical:`dashboard-id`,alias:`dashboardid`,prop:`dashboardId`,label:`dashboard`}));var YAr=st(WAr,{props:{token:`string`,metricId:`string`,debug:`string`,theme:`json`,chartRendererType:`string`,optionsIcon:`string`,chartColors:`json`,height:`number`,width:`number`,className:`string`,style:`json`,variant:`string`,onMinimize:`function`,isHideChartSettings:`boolean`,isHideTablePreview:`boolean`,metricFilterOptions:`string`,enableDownloadCsv:`boolean`,enableEmailCsv:`boolean`,disableDownloadPng:`boolean`,disableFullscreen:`boolean`,enableTitleClickFullscreen:`boolean`,enableMultiMetricFilters:`boolean`,metricFilterPosition:`string`,customMessages:`json`,onSupportClick:`function`,supportLabel:`string`,themeName:`string`,enableThemeContrastWarnings:`boolean`,colorScheme:`string`,appearanceOptions:`json`,hideDatePickerOptions:`json`,chartAppearance:`json`,hideMetricCardShadow:`boolean`,disableUnderlyingData:`boolean`,noDataImg:`string`,disableMetricCardBorder:`boolean`,longDescriptionConfig:`json`,isMergedCard:`boolean`,chartColumns:`json`,language:`string`,translationDictionary:`json`,globalFilterOptions:`json`,calendarType:`string`,isDisableCardTitle:`boolean`,disableDownloadUnderlyingDataNoFilters:`boolean`,disableDownloadDataNoFilters:`boolean`,dataDbnUi:`string`,baseUrl:`string`},shadow:`open`});customElements.get(`dbn-metric`)||customElements.define(`dbn-metric`,qAr(YAr,`dbn-metric`,{canonical:`metric-id`,alias:`metricid`,prop:`metricId`,label:`metric`})),t.applyHostBaseUrl=GAr,t.describeIdAttributeProblem=KAr}),typeof globalThis<`u`&&delete globalThis.__dbnJsxRuntime;
|
|
5057
|
+
suggest list of dimensions and measures.`,role:`user`};je&&Ie.mutate({token:je,data:{messages:[...re,e]}},{onSuccess(t){let n=t.result;oe({error:``,isLoading:!1}),ie([...re,e,n])}})},$e=xe(e=>{let t=e.questionString;ee({data:[],error:``,isLoading:!0,query:``}),S(Tv),je?Ce({data:{questionString:t},token:je},{onSuccess(e){let t=e;if(t.queryData?.length&&t.query){let e=Pb(t.queryData);ee({data:e,error:``,isLoading:!1,query:t.query}),kbe({data:e,setChartSettings:S})}else t.error?ee({data:[],error:t.error,isLoading:!1,query:t.query||``}):ee({data:[],error:ev,isLoading:!1,query:``})},onError(){ee({data:[],error:ev,isLoading:!1,query:``})}}):ee({data:[],error:``,isLoading:!1,query:``})}),et=(0,n.useCallback)(e=>S(t=>({...t,tableSettings:{...t.tableSettings,columnSizing:e}})),[]),tt=({column:e,helperFunction:t,functionConfiguration:n})=>{let r=t.value===`NONE`,i=`${r?e.name:`${Xx(`${t.label?.toLowerCase()} of`,y?.name||``)} ${e.name}`}`,a=zv.includes(t.value),o=le?.map(o=>o.alias===e.alias?{...o,helperFunction:t.value,alias:i,configType:a?`AGGREGATE`:`DIMENSION`,dropType:a?`METRIC`:`DIMENSION`,type:r?`DEFAULT`:`HELPER_FUNCTION`,functionConfiguration:n}:o);ue(o)},nt=({alias:e,column:t})=>{ue(n=>n?.map(n=>n.alias===t.alias?{...n,alias:e}:n))},rt=async()=>{me([]);let e=se?.columnsWithDataType?.filter(e=>Sv.includes(e?.dataType?.toLowerCase()||``)||e?.dataType?.toLowerCase()?.includes(`char`))||[];if(e.length&&je&&se)for(let n=0;n<e.length;n+=1){let r=e[n]?.name,i=await ze({encryptedClientId:t||``,isFrontendApp:!1,token:je||``,data:{columnName:r,wId:Pe,tableName:`${se?.schemaName}.${se?.tableName}`,datasourceId:d,databaseName:f}}),a=i?.data&&Array.isArray(i?.data)&&i?.data.length?i.data?.map(e=>e.value):[];me(e=>[...e,{column:r,values:a}])}else me([])};return(0,n.useEffect)(()=>{(x.chartType!==$.stack||x.chartType!==$.timeSeries||x?.timeSeriesSettings?.seriesType?.[0]?.type!==`stack`||x.seriesField!==`ungrouped`)&&S(e=>({...e,customSettings:{...e.customSettings,showFullStacked:!1}}))},[x?.chartType,x?.timeSeriesSettings,x.seriesField]),(0,n.useEffect)(()=>{let e=Oe?.error,t=Oe;e||!Oe?ee(t=>({...t,error:e?.message})):t?.tableList?.length&&b({id:t?.companyIntegrationId,name:t?.dbName})},[Oe]),(0,n.useEffect)(()=>{o&&(S(o.chartOptions),b(o.companyIntegration))},[o]),(0,n.useEffect)(()=>{se||Ge.length&&ce(Ge?.[0])},[Ge,se]),(0,n.useEffect)(()=>{se?rt():me([])},[se]),(0,n.useEffect)(()=>{let e=Jq(x?.customSettings?.comboAxisSettings||[]),t=e?.flatMap(e=>e?.measures),n=x?.yAxisList?.every(e=>t?.includes(e));if(x?.yAxisList?.length&&x?.yAxisList?.length!==t?.length&&!t?.length&&[$.combo,$.timeSeries,$.horizontalCombo].includes(x?.chartType||``)){let e=x?.yAxisList?.filter(e=>!x?.comboBarList?.includes(e))?.filter(e=>!t?.includes(e)),n=x?.customSettings?.comboStackAxisSymbols?.name||``,r=x?.customSettings?.comboLabelFormatter?.find(e=>e.axis===(n||`stack`))?.formatter,i=x?.comboBarList?.join(` and `),a=x?.customSettings?.comboLabelFormatter?.find(e=>e.axis===i)?.formatter;S(t=>({...t,customSettings:{...t.customSettings,comboAxisSettings:Jq([...t.customSettings?.comboAxisSettings||[],...e?.map(e=>{let t=x?.customSettings?.comboLabelFormatter?.find(t=>t.axis===e)?.formatter,n=x?.customSettings?.comboAxisSymbols?.find(t=>t.name===e);return{axis:e,measures:[e],chartTypes:[{axis:e,type:`line`}],numberFormatter:x?.customSettings?.numberFormatter,labelFormatter:t,prefix:n?.prefix||``,suffix:n?.suffix||``,isEnableLabelFormatter:!!t?.length}}),...x?.comboBarList?.length&&(x?.customSettings?.isCombineBarAxis||x?.customSettings?.isStackBar)?[{axis:x?.customSettings?.isStackBar&&n||i,measures:x?.comboBarList,chartTypes:x?.comboBarList?.map(e=>({axis:e,type:`bar`})),isEnableStackBar:x?.customSettings?.isStackBar,numberFormatter:x?.customSettings?.numberFormatter,...x?.customSettings?.isStackBar?{prefix:x?.customSettings?.comboStackAxisSymbols?.prefix||``,suffix:x?.customSettings?.comboStackAxisSymbols?.suffix||``,labelFormatter:r,isEnableLabelFormatter:!!r?.length}:{prefix:x?.customSettings?.combinedAxisPrefix||``,suffix:x?.customSettings?.combinedAxisSuffix||``,labelFormatter:a,isEnableLabelFormatter:!!a?.length}}]:[],...x?.comboBarList?.length&&!x?.customSettings?.isCombineBarAxis&&!x?.customSettings?.isStackBar?x?.comboBarList?.map(e=>{let t=x?.customSettings?.comboLabelFormatter?.find(t=>t.axis===e)?.formatter,n=x?.customSettings?.comboAxisSymbols?.find(t=>t.name===e);return{axis:e,measures:[e],chartTypes:[{axis:e,type:`bar`}],numberFormatter:x?.customSettings?.numberFormatter,labelFormatter:t,prefix:n?.prefix||``,suffix:n?.suffix||``,isEnableLabelFormatter:!!t?.length}}):[]].filter(e=>e?.measures?.length)),comboAxisSymbols:[],combinedAxisPrefix:``,combinedAxisSuffix:``,comboLabelFormatter:[],comboStackAxisSymbols:void 0,isCombineBarAxis:!1,isStackBar:!1},comboBarList:[]}))}if(t?.length&&x?.yAxisList?.length&&(x?.yAxisList?.length!==t?.length||x?.yAxisList?.length===t?.length&&!n)&&[$.combo,$.timeSeries,$.horizontalCombo].includes(x?.chartType||``)){let e=x?.yAxisList?.filter(e=>!t?.includes(e));(t?.filter(e=>!x?.yAxisList?.includes(e)))?.forEach(e=>{let t=x?.customSettings?.comboAxisSettings?.find(t=>t.measures?.includes(e)),n=t?.axis,r=(t?.measures?.length||0)>1;S(t=>({...t,customSettings:{...t.customSettings,comboAxisSettings:Jq(r?t.customSettings?.comboAxisSettings?.map(t=>t.axis===n?{...t,measures:t?.measures?.filter(t=>t!==e)}:t)?.filter(e=>e?.measures?.length)||[]:t.customSettings?.comboAxisSettings?.filter(e=>e.axis!==n&&e?.measures?.length)||[])}}))}),e?.length&&S(t=>({...t,customSettings:{...t.customSettings,comboAxisSettings:Jq([...t.customSettings?.comboAxisSettings||[],...e?.map(e=>({axis:e,measures:[e],chartTypes:[{axis:e,type:`line`}]}))].filter(e=>e?.measures?.length)||[])}}))}t?.length&&x?.yAxisList?.length&&x?.yAxisList?.length===t?.length&&n&&[$.combo,$.timeSeries,$.horizontalCombo].includes(x?.chartType||``)&&x?.customSettings?.comboAxisSettings?.length!==e?.length&&S(t=>({...t,customSettings:{...t?.customSettings,comboAxisSettings:e}}))},[x?.yAxisList,x?.customSettings?.comboAxisSettings,x?.comboBarList,x?.customSettings?.isCombineBarAxis,x?.customSettings?.isStackBar,x?.customSettings?.comboStackAxisSymbols?.name,x?.customSettings?.comboStackAxisSymbols?.prefix,x?.customSettings?.comboStackAxisSymbols?.suffix,x?.customSettings?.comboLabelFormatter,x?.customSettings?.comboAxisSymbols,x?.customSettings?.numberFormatter,x?.customSettings?.combinedAxisPrefix,x?.customSettings?.combinedAxisSuffix,x?.chartType]),(0,n.useEffect)(()=>{x?.chartType===$.horizontalCombo&&S(e=>({...e,customSettings:{...e?.customSettings,xRotation:0,customRotation:0,hideXAxisLines:!1},margins:{...e?.margins,top:5}}))},[x?.chartType]),(0,n.useEffect)(()=>{x?.yAxisList?.length&&x?.yAxisList?.length<5&&x?.chartType===$.boxplot&&S(e=>({...e,chartType:$.line})),!x?.yAxisList?.length&&x?.chartType===$.funnelV2&&S(e=>({...e,chartType:$.singleValue}))},[x?.chartType,x?.yAxisList?.length]),{isDisableSaveBtn:Je,setChartSettings:S,setShowSaveMetricModal:w,isShowSaveMetricModal:C,register:ye,errors:be,onSubmitQuery:$e,generateMetricState:T,chartTabType:Xe,chartSettings:x,chartRef:we,onColumnSizingChange:et,watch:Se,createExternalMetric:Te,saveError:Ee,updateExternalMetric:De,clientSubsetData:Oe,previewTable:Ae,token:je,dashboardOptions:Me,isCreatingMetric:Ne,tableList:Ge,selectedMainTable:se,setSelectedMainTable:ce,aiResponseState:ae,onAiQuery:Qe,autoCompleteDropdownOptions:qe,selectedColumns:le,setSelectedColumns:ue,functionOptions:Be,setChartFields:Ue,onSubmitSearch:Ze,onChangeHelperFunction:tt,onChangeAlias:nt,chartOptions:We,isShowChartType:de,setShowChartType:fe,enabledCharts:Ye.filter(e=>![$.pivotV2,$.timeSeries,$.pivotV3].includes(e)),stringColumnValues:pe,isRef:he,setRef:ge,pivotDrillState:h}}})),mEr,hEr=h((()=>{iEr(),phr(),pEr(),GX(),R9(),mEr=({clientId:e,companyId:t,externalDashboardId:n,isLiveMode:r,isShowMetricCreateModal:a,setShowMetricCreateModal:o,userProvidedDashboardId:s,workspaceId:l,chartColors:u,metric:d,metricData:f,variant:p,clientColumnType:m,datasourceId:h,tenancyType:g,onServerEvent:_,refetchDashboardData:v,saveDashLayout:y})=>{let{isDisableSaveBtn:b,setShowSaveMetricModal:x,generateMetricState:S,chartTabType:C,chartSettings:w,onColumnSizingChange:T,chartRef:ee,isCreatingMetric:te,isShowSaveMetricModal:ne,saveError:re,updateExternalMetric:ie,createExternalMetric:ae,tableList:oe,selectedMainTable:se,setSelectedMainTable:ce,selectedColumns:le,setSelectedColumns:ue,autoCompleteDropdownOptions:de,onSubmitSearch:fe,setChartFields:pe,functionOptions:me,onChangeHelperFunction:he,onChangeAlias:ge,chartOptions:_e,isShowChartType:ve,setShowChartType:ye,enabledCharts:be,setChartSettings:xe,isRef:Se,setRef:Ce,pivotDrillState:we}=fEr({clientId:e,companyId:t,isLiveMode:r,externalDashboardId:n,userProvidedDashboardId:s,chartColors:u,isShowMetricCreateModal:a,setShowMetricCreateModal:o,metric:d,metricData:f,workspaceId:l,variant:p,clientColumnType:m,datasourceId:h,databaseName:g===`MULTI_DATABASE`&&e||``,onServerEvent:_,refetchDashboardData:v,saveDashLayout:y});return(0,i.jsxs)(`div`,{className:B9.generateMetricModal,children:[(0,i.jsx)(`div`,{className:B9.generateMetricModalHeader,children:(0,i.jsx)(L9t,{heading:d?`Update Metric`:`Create Metric`,setShowMetricCreateModal:o,isDisableSaveBtn:b,setShowSaveMetricModal:x})}),(0,i.jsxs)(`div`,{className:B9.generateMetricQuery,children:[(0,i.jsxs)(`form`,{className:B9.generateMetricQueryForm,onSubmit:e=>e.preventDefault(),children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-4 dbn:items-center`,children:[(0,i.jsx)(vY,{options:oe?.map(e=>({value:e.tableName,label:e.tableName,table:e,icon:`table`})),onChange:e=>{ce(e.table),ue([])},selectedOption:{label:se?.tableName||``,value:se?.tableName||``,icon:`table`},buttonWidth:`250px`,menuWidth:`100%`}),(0,i.jsx)(`div`,{className:`dbn:w-[800px]`,children:(0,i.jsx)(fhr,{selectedOption:le,setSelectedOptions:ue,options:de,isDisabled:S.isLoading||!se,functionOptions:me,onChangeHelperFunction:he,onChangeAlias:ge})})]}),(0,i.jsx)(Xs,{variant:`popover`,type:`button`,isDisabled:S.isLoading||!le?.filter(e=>e.configType!==`FILTER`).length,onClick:()=>{Ce(!1),fe()},leftIcon:(0,i.jsx)(jy,{name:`magnifying-glass`,color:`white`}),className:`dbn:bg-primary dbn:text-white dbn:px-3 dbn:h-[47px] dbn:rounded-l-none dbn:rounded-md`,children:`Search`})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-3`,children:[_e?.map(e=>(0,i.jsx)(Xs,{variant:`popover`,className:`${w.chartType===e.value?`dbn:bg-gray`:`dbn:bg-white`} dbn:h-8 dbn:w-8 dbn:flex dbn:items-center dbn:justify-center`,leftIcon:(0,i.jsx)(uY,{text:e.value,children:(0,i.jsx)(jy,{name:e.icon,size:`xl`})}),onClick:()=>{pe({chartType:e.value})}})),(0,i.jsx)(Xs,{variant:`popover`,leftIcon:(0,i.jsx)(uY,{text:`Chart Type`,children:(0,i.jsx)(jy,{name:`bar-chart-2`,size:`xl`})}),onClick:()=>ye(!0),className:`dbn:h-8 dbn:w-8 dbn:flex dbn:items-center dbn:justify-center`})]})]}),(0,i.jsxs)(`div`,{className:B9.generateMetricChart,children:[C===`INIT`&&(0,i.jsxs)(`div`,{className:B9.metricChartEmpty,children:[(0,i.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='264'%20height='206'%20fill='none'%20viewBox='0%200%20264%20206'%3e%3cpath%20fill='%23F1F2F7'%20d='M142.93%200a102%20102%200%200%200-63.85%2022.37H50.76a6.72%206.72%200%200%200%200%2013.42h18.63a6.72%206.72%200%200%201%200%2013.42H31.14a6.72%206.72%200%200%200%200%2013.42h17.37a103%20103%200%200%200-8.15%2040.27%20104%20104%200%200%200%202.23%2021.44%20562%20562%200%200%201%2039.98-4.63l1.06.96.99-1.12c16.79-1.31%2034.4-2%2052.58-2%2038.62%200%2074.76%203.14%20105.66%208.62a103%20103%200%200%200%202.63-23.27C245.49%2046.07%20199.57%200%20142.93%200M10.83%2048.9H6.78A6.83%206.83%200%200%200%200%2055.75a6.83%206.83%200%200%200%206.78%206.84h4.05a6.83%206.83%200%200%200%206.77-6.84%206.83%206.83%200%200%200-6.77-6.85'/%3e%3cpath%20fill='%23E8EBF2'%20d='M264%20151.6c0%203.66-3%206.66-6.69%206.66H214.6a6.67%206.67%200%200%200%200%2013.34h7.94a6.67%206.67%200%200%201%200%2013.34h-18.25a102.3%20102.3%200%200%201-61.53%2020.45%20102.5%20102.5%200%200%201-100.3-80.94c12.61-1.93%2026-3.48%2039.97-4.6l1.05.95.99-1.11c16.78-1.3%2034.4-2%2052.57-2%2038.6%200%2074.74%203.13%20105.63%208.57a101%20101%200%200%201-6.3%2018.67h20.94a6.67%206.67%200%200%201%206.69%206.66'/%3e%3cpath%20fill='%23E0E2EE'%20d='M244.5%20109.9a107%20107%200%200%201-2.36%2016.27c-30.86-5.59-66.95-8.8-105.51-8.8-18.15%200-35.75.72-52.52%202.05l11.63-13.47%2018.09%2011.8L138.3%20111l42.12%206.39%2018.29-6.39%204.63%206.39%2011.05-8.2%2010.33%209.46L241%20105.63zm-162.35%209.67a566%20566%200%200%200-39.96%204.64q-.65-3.06-1.11-6.2l21.62-16.3z'/%3e%3cpath%20fill='%23E1E3EF'%20d='M242.55%20184.85a6.87%206.87%200%200%201-6.84-6.85%206.87%206.87%200%200%201%206.84-6.84%206.87%206.87%200%200%201%206.85%206.84%206.87%206.87%200%200%201-6.85%206.85'/%3e%3crect%20width='111'%20height='86'%20x='91'%20y='50'%20fill='%23fff'%20rx='10'/%3e%3cpath%20fill='%23F1F2F7'%20d='M97.13%2064.96h98.74c1.83%200%203.3-2.72%203.3-6.08s-1.47-6.08-3.3-6.08H97.13c-1.83%200-3.3%202.72-3.3%206.08s1.47%206.08%203.3%206.08'/%3e%3cpath%20fill='%23D0D4DA'%20d='M99.58%2087.73h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-5.21c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m0-13.76h36.5c.9%200%201.62-.73%201.62-1.62s-.73-1.61-1.63-1.61H99.58c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m43.44%200h6.95a1.61%201.61%200%201%200%20.01-3.23h-6.96a1.61%201.61%200%201%200%200%203.23m29.55%200h20.85c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-20.85c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m0%2010.53c-.43%200-.85.18-1.16.48a1.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.14-2.76m1.15%2014.24a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28m-1.15%2013.29c-.43%200-.85.18-1.16.48s-.47.71-.47%201.14a1.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%201%200%200-3.23m6.95%200a1.64%201.64%200%200%200-1.63%201.62%201.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%200%200%201.15-2.75c-.3-.3-.72-.48-1.15-.48m-6.95%2013.77a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.15-2.75m6.95%200a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28c-.3-.3-.72-.47-1.15-.47m8.1-13.3a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%201.15%202.76%201.61%201.61%200%200%200%201.15-2.75m-6.95-27.53a1.64%201.64%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28M104.8%20125.8h-5.22c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-5.21-24.3h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-5.21c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m5.22%2010.53h-5.22c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m33.02%200h-3.47c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.47%2017h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-3.47c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m3.47-30.76h-3.47c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-3.47-10.54h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-3.47c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m10.42%200h6.95c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-6.95c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m12.17%2010.54h-12.17c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h12.17c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-8.69%2013.76h-3.48c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h3.48c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.48%2017h6.95c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-6.95c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62'/%3e%3cpath%20fill='%23D0D4DA'%20d='M193.42%2050.1H99.58A8.55%208.55%200%200%200%2091%2058.58v68.82c0%204.69%203.85%208.5%208.58%208.5h93.84a8.55%208.55%200%200%200%208.58-8.5V58.6c0-4.69-3.85-8.5-8.58-8.5m-64.4%2068.82v-10.54h34.97v10.54zm34.97%203.22v10.54H129v-10.54zm34.75-55.06v10.54h-31.5V67.08zM164%2080.85v10.54h-35V80.85zm-38.24%2010.54h-31.5V80.85h31.5zm0%203.22v10.54h-31.5V94.61zm3.26%200H164v10.54h-35zm38.23%200h31.5v10.54h-31.5zm0-3.22V80.85h31.5v10.54zM164%2077.62H94.26V67.08h69.73zm-69.73%2030.76h31.5v10.54h-31.5zm72.98%200h31.5v10.54h-31.5zM99.58%2053.32h93.84a5.3%205.3%200%200%201%205.32%205.27v5.27H94.26v-5.27a5.3%205.3%200%200%201%205.32-5.27m-5.32%2074.1v-5.28h31.5v10.54H99.57a5.3%205.3%200%200%201-5.32-5.27m99.16%205.26h-26.18v-10.54h31.5v5.27a5.3%205.3%200%200%201-5.32%205.27'/%3e%3crect%20width='111'%20height='86'%20x='68'%20y='76'%20fill='%23fff'%20rx='10'/%3e%3cpath%20fill='%23F1F2F7'%20d='M74.13%2090.96h98.74c1.83%200%203.3-2.72%203.3-6.08s-1.47-6.08-3.3-6.08H74.13c-1.83%200-3.3%202.72-3.3%206.08s1.47%206.08%203.3%206.08'/%3e%3cpath%20fill='%23D0D4DA'%20d='M76.58%20113.73h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-5.21c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m0-13.76h36.5c.9%200%201.62-.73%201.62-1.62s-.73-1.61-1.63-1.61H76.58c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m43.44%200h6.95a1.61%201.61%200%201%200%20.01-3.23h-6.96a1.61%201.61%200%201%200%200%203.23m29.55%200h20.85c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-20.85c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m0%2010.53c-.43%200-.85.18-1.16.48a1.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.14-2.76m1.15%2014.24a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28m-1.15%2013.29c-.43%200-.85.18-1.16.48s-.47.71-.47%201.14a1.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%201%200%200-3.23m6.95%200a1.64%201.64%200%200%200-1.63%201.62%201.6%201.6%200%200%200%201.63%201.61%201.61%201.61%200%200%200%201.15-2.75c-.3-.3-.72-.48-1.15-.48m-6.95%2013.77a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.61%201.61%200%200%200-1.15-2.75m6.95%200a1.61%201.61%200%200%200-1.15%202.75%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28c-.3-.3-.72-.47-1.15-.47m8.1-13.3a1.65%201.65%200%200%200-2.3%200%201.6%201.6%200%200%200%201.15%202.76%201.61%201.61%200%200%200%201.15-2.75m-6.95-27.53a1.64%201.64%200%200%200-2.3%200%201.6%201.6%200%200%200%200%202.28%201.64%201.64%200%200%200%202.3%200%201.6%201.6%200%200%200%200-2.28M81.8%20151.8h-5.22c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-5.21-24.3h5.21c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-5.21c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62m5.22%2010.53h-5.22c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h5.21c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m33.02%200h-3.48c-.9%200-1.62.73-1.62%201.62s.73%201.61%201.63%201.61h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.47%2017h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-3.48a1.61%201.61%200%201%200%20.01%203.23m3.47-30.76h-3.48a1.61%201.61%200%201%200%20.01%203.23h3.47c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-3.47-10.54h3.47c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-3.48c-.9%200-1.62.73-1.62%201.62s.73%201.61%201.63%201.61m10.42%200h6.95c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62h-6.95c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61m12.17%2010.54h-12.17c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62h12.17c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61m-8.69%2013.76h-3.48c-.9%200-1.63.73-1.63%201.62s.73%201.61%201.63%201.61h3.48c.9%200%201.63-.72%201.63-1.61s-.73-1.62-1.63-1.62m-3.48%2017h6.95c.9%200%201.63-.73%201.63-1.62s-.73-1.61-1.63-1.61h-6.95c-.9%200-1.63.72-1.63%201.61s.73%201.62%201.63%201.62'/%3e%3cpath%20fill='%23D0D4DA'%20d='M170.42%2076.1H76.58A8.55%208.55%200%200%200%2068%2084.58v68.82c0%204.69%203.85%208.5%208.58%208.5h93.84a8.55%208.55%200%200%200%208.58-8.5V84.6c0-4.69-3.85-8.5-8.58-8.5m-64.4%2068.82v-10.54h34.97v10.54zm34.97%203.22v10.54H106v-10.54zm34.75-55.06v10.54h-31.5V93.08zM141%20106.85v10.54h-35v-10.54zm-38.24%2010.54h-31.5v-10.54h31.5zm0%203.22v10.54h-31.5v-10.54zm3.26%200H141v10.54h-35zm38.23%200h31.5v10.54h-31.5zm0-3.22v-10.54h31.5v10.54zM141%20103.62H71.26V93.08h69.73zm-69.73%2030.76h31.5v10.54h-31.5zm72.98%200h31.5v10.54h-31.5zM76.58%2079.32h93.84a5.3%205.3%200%200%201%205.32%205.27v5.27H71.26v-5.27a5.3%205.3%200%200%201%205.32-5.27m-5.32%2074.1v-5.28h31.5v10.54H76.57a5.3%205.3%200%200%201-5.32-5.27m99.16%205.26h-26.18v-10.54h31.5v5.27a5.3%205.3%200%200%201-5.32%205.27'/%3e%3c/svg%3e`,alt:`no data`,style:{width:`300px`,height:`300px`}}),(0,i.jsx)(xa,{variant:`heading-3`,children:`No Data`}),(0,i.jsx)(`div`,{className:B9.chartButton,children:(0,i.jsx)(xa,{variant:`body-text-2`,children:`Enter Your Query to Visualize `})})]}),C===`LOADING`&&(0,i.jsx)(`div`,{className:B9.LoaderContainer,children:(0,i.jsx)(D6,{})}),C===`CHART`&&(0,i.jsx)(`div`,{className:B9.chartWrapper,children:(0,i.jsx)(Q5,{variables:{},pivotDrillState:we,chartOptions:w,data:S.data,filterValues:[],onMaximize:()=>{},colors:u,config:{ref:ee,onColumnSizingChange:T}})}),C===`ERROR`&&(0,i.jsx)(xa,{variant:`heading-3`,color:`alert`,children:S.error})]}),(0,i.jsx)(s7,{chartTypePanelProps:{isOpen:ve,onClose:()=>ye(!1),enabledCharts:be,onChartChange:e=>{pe({chartType:e})},selectedChart:w.chartType,zIndex:9999}}),(0,i.jsx)(TJ,{isOpen:ne,onClose:()=>x(!1),headerTitle:`Save To Dashboard`,children:(0,i.jsx)(nH,{onCancel:()=>x(!1),onSubmit:d?ie:ae,error:re,defaultValues:d?{name:d.name,description:d.description,isLive:d.isLive,metricId:d.isCreatedByClient?d.metricId:`update_${d.metricId}_by_${e}_${Date.now()}`}:void 0,isCreatingMetric:te})})]})}})),gEr,_Er,vEr=h((()=>{_fn(),gbe(),gEr=()=>({clientIdPlaceholder:qoe,hasDatabaseNamePlaceholder:dbe,hasTenantPredicate:ube,tenantPredicateRegex:cbe}),_Er=e=>gfn(e,gEr())})),V9,H9,yEr=h((()=>{V9=`Unpublished. Only you can see this chart.`,H9=e=>!e.createdByIdentifier||e.isPublished===!0?!1:e.isPublished===!1||!!e.externalDashboardMetrics?.[0]?.externalDashboard?.isAllowPrivateMetricsByDefault})),bEr,xEr=h((()=>{sr(),YK(),bEr=(e,t)=>{let{mutate:r,isPending:i}=iKt();return{onSaveGalleryMetrics:(0,n.useCallback)((n,i)=>{r({data:{externalMetricIds:n},token:e},{onSuccess:async e=>{e?.error||(t?.(Wn),i(),window.location.reload())}})},[e]),isLoading:i}}})),SEr,CEr,wEr,TEr=h((()=>{SEr=100,CEr=1e3,wEr=({itemCount:e,initialCount:t,incrementCount:r,resetKey:i,isActive:a=!0})=>{let[o,s]=(0,n.useState)(null),[l,u]=(0,n.useState)({resetKey:i,isActive:a,initialCount:t,count:t}),d=(0,n.useRef)(!1),f=(0,n.useRef)(void 0),[p,m]=(0,n.useState)(!1),h=l.resetKey!==i||l.isActive!==a||l.initialCount!==t;h&&u({resetKey:i,isActive:a,initialCount:t,count:t});let g=a?Math.min(h?t:l.count,e):0,_=g<e,v=(0,n.useRef)(null),y=(0,n.useCallback)((n=!1)=>{if(!a||!_||d.current)return;d.current=!0;let o=()=>{f.current=void 0,m(!1),u({resetKey:i,isActive:a,initialCount:t,count:Math.min(g+r,e)})};n?(m(!0),f.current=setTimeout(o,CEr)):o()},[_,a,e,i,g,t,r]);(0,n.useLayoutEffect)(()=>{let n=v.current,s=!n||n.container!==o||n.resetKey!==i||n.isActive!==a||n.itemCount!==e||n.initialCount!==t||n.incrementCount!==r,l=!n||n.container!==o||n.resetKey!==i||n.isActive!==a||n.initialCount!==t;s&&(clearTimeout(f.current),f.current=void 0,m(!1)),(s||n?.visibleCount!==g)&&(d.current=!1),l&&o&&a&&(o.scrollTop=0),v.current={container:o,resetKey:i,isActive:a,itemCount:e,initialCount:t,incrementCount:r,visibleCount:g}},[o,i,a,e,t,r,g]),(0,n.useEffect)(()=>()=>{clearTimeout(f.current),f.current=void 0},[]);let b=(0,n.useCallback)(()=>{!o||o.clientHeight<=0||o.clientWidth<=0||o.scrollHeight-o.scrollTop-o.clientHeight<SEr&&y(!0)},[o,y]);return(0,n.useEffect)(()=>{if(!o||!a||!_)return;let e,t=()=>{e===void 0&&(e=requestAnimationFrame(()=>{e=void 0,o.clientHeight>0&&o.clientWidth>0&&o.scrollHeight<=o.clientHeight&&y()}))};t();let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(o),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t),e!==void 0&&cancelAnimationFrame(e)}},[o,_,a,y]),{containerRef:s,handleScroll:b,visibleCount:g,hasMore:_,isLoadingMore:a&&!h&&_&&p}}})),EEr,DEr,OEr,kEr,AEr,jEr,MEr,U9,NEr=h((()=>{EEr=`_manageMetricCard_g7m0a_8`,DEr=`_borderPrimary_g7m0a_12`,OEr=`_manageMetricContainer_g7m0a_16`,kEr=`_cardContainer_g7m0a_20`,AEr=`_metricName_g7m0a_24`,jEr=`_chart_g7m0a_28`,MEr=`_manageButton_g7m0a_32`,U9={manageMetricCard:EEr,borderPrimary:DEr,manageMetricContainer:OEr,cardContainer:kEr,metricName:AEr,chart:jEr,manageButton:MEr}})),PEr,FEr,IEr,LEr=h((()=>{R9(),sr(),vEr(),yEr(),xEr(),ZK(),TEr(),hY(),tTr(),NEr(),PEr=({verdict:e,isGateOn:t})=>{if(!t||!e)return null;let n=e.status===`all-client`||e.status===`rejected`&&e.findings.every(e=>e.code===`ALL_CLIENT_UNACKNOWLEDGED`);return e.status!==`rejected`&&!n?null:(0,i.jsx)(`div`,{className:`dbn:pt-1`,"data-testid":`tenant-scope-notice-${e.metricId??``}`,"data-tenant-scope":n?`all-client`:`unscoped`,title:e.findings.map(e=>e.message).join(` `),children:(0,i.jsx)(xa,{variant:`body-text-3`,color:n?`gray-dark`:`alert-dark`,children:n?`Shows every customer’s data`:`Not limited to one customer`})})},FEr=({metric:e})=>H9(e)?(0,i.jsx)(`div`,{className:`dbn:pt-1`,"data-testid":`unpublished-notice-${e?.id}`,children:(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:V9})}):null,IEr=({props:{metricList:e,token:t,client:r,companyTenancyType:a,workspaceId:o,chartAppearance:s,colors:l,isOpenModal:u,setOpenModal:d,onServerEvent:f,datasourceId:p,language:m,translationDictionary:h,externalDashboardId:g,companyId:_}})=>{let[v,y]=(0,n.useState)([]),[b,x]=(0,n.useState)(``),[S,C]=(0,n.useState)(null),w=v.join(`|`),T=S===w;(0,n.useEffect)(()=>{if(e?.length){let t=(e?.filter(e=>e?.clientGalleryMetrics?.length))?.map(e=>e?.id);y(t)}},[e]);let{onSaveGalleryMetrics:ee,isLoading:te}=bEr(t,f),{saveLogsAsync:ne}=XK(),re=(0,n.useMemo)(()=>{let t=new Map;return(e??[]).forEach(e=>{e?.id&&t.set(e.id,_Er({metric:e,datamart:{tenancyLevel:a},acknowledgedAllClient:T}))}),t},[e,a,T]),ie=(0,n.useMemo)(()=>v.map(e=>re.get(e)).filter(e=>!!e&&e.status===`rejected`),[v,re]),ae=(0,n.useMemo)(()=>v.map(e=>re.get(e)).filter(e=>!!e&&(e.status===`all-client`||e.findings.some(e=>e.code===`ALL_CLIENT_UNACKNOWLEDGED`))),[v,re]),oe=(0,n.useMemo)(()=>ie.filter(e=>e.findings.some(e=>e.code!==`ALL_CLIENT_UNACKNOWLEDGED`)),[ie]),se=ie.length>0,ce=(e,t)=>{y(n=>{let r=t??!n.includes(e),i=n.filter(t=>t!==e);return r?[...i,e]:i})},le=(0,n.useMemo)(()=>b?e?.filter(e=>e?.clientGalleryMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(b?.toLowerCase())):e?.filter(e=>e?.clientGalleryMetrics?.length),[e,b]),ue=(0,n.useMemo)(()=>b?e?.filter(e=>!e?.clientGalleryMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(b?.toLowerCase())):e?.filter(e=>!e?.clientGalleryMetrics?.length),[e,b]),{containerRef:de,handleScroll:fe,visibleCount:pe,isLoadingMore:me}=wEr({initialCount:4,incrementCount:4,itemCount:(ue?.length||0)+(le?.length||0),resetKey:JSON.stringify([o,r,b]),isActive:u}),he=ue?.slice(0,pe),ge=le?.slice(0,Math.max(0,pe-(ue?.length||0)));return(0,i.jsxs)(TJ,{isOpen:u,onClose:()=>{f?.(Hn),d(!1)},headerTitle:`Metrics Gallery`,children:[(0,i.jsxs)(ZZ,{className:U9.manageMetricContainer,direction:`col`,children:[(0,i.jsx)(F7,{setSearchKeyword:x,className:`dbn:w-full`}),(0,i.jsxs)(ZZ,{containerRef:de,onScroll:fe,direction:`row`,className:`dbn:overflow-y-auto dbn:gap-2 dbn:flex-wrap dbn:flex-1 dbn:min-h-0 dbn:content-start dbn:pb-3`,children:[he?.map(e=>{let n=v?.includes(e?.id);return(0,i.jsxs)(`button`,{className:`${U9.manageMetricCard} ${n?`dbn-manage-metric-card ${U9.borderPrimary}`:``}`,"aria-pressed":n,onClick:()=>ce(e.id),type:`button`,"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{ce(e.id,t)}})]}),(0,i.jsx)(PEr,{verdict:re.get(e?.id),isGateOn:!0}),(0,i.jsx)(FEr,{metric:e}),(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a})})]},e?.id)}),ge?.map(e=>{let n=v?.includes(e?.id);return(0,i.jsxs)(`button`,{className:`${U9.manageMetricCard} ${n?`dbn-manage-metric-card ${U9.borderPrimary}`:``}`,"aria-pressed":n,onClick:()=>ce(e.id),type:`button`,"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{ce(e.id,t)}})]}),(0,i.jsx)(PEr,{verdict:re.get(e?.id),isGateOn:!0}),(0,i.jsx)(FEr,{metric:e}),(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a})},e.id)]},e?.id)}),me&&(0,i.jsx)(ZZ,{className:`dbn:w-full dbn:pb-6`,children:(0,i.jsx)(D6,{})})]}),oe.length?(0,i.jsx)(`div`,{"data-testid":`tenant-scope-blocked`,className:`dbn:w-full`,children:(0,i.jsx)(o$,{variant:`error`,text:oe.length===1?`1 chart cannot be shared yet.`:`${oe.length} charts cannot be shared yet.`,className:`dbn:w-full dbn:flex-col dbn:items-start dbn:gap-1`,childrenClassName:`dbn:w-full dbn:flex-col dbn:items-start dbn:px-1`,children:(0,i.jsx)(`ul`,{className:`dbn:list-none dbn:m-0 dbn:p-0`,children:oe.map(e=>(0,i.jsx)(`li`,{children:(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:`${e.metricName??`Untitled chart`}: ${e.findings[0]?.message??``}`})},e.metricId??e.metricName))})})}):null,!oe.length&&ae.length?(0,i.jsx)(`div`,{"data-testid":`tenant-scope-all-client`,className:`dbn:w-full`,children:(0,i.jsx)(o$,{variant:`warning`,text:ae.length===1?`1 selected chart shows every customer’s data, not just this one’s.`:`${ae.length} selected charts show every customer\u2019s data, not just this one\u2019s.`,className:`dbn:w-full`,children:(0,i.jsx)(y$,{id:`tenant-scope-acknowledge`,label:`Share them anyway`,containerClass:`dbn:whitespace-nowrap dbn:text-xs`,checked:T,onChange:({target:{checked:e}})=>C(e?w:null),"data-testid":`tenant-scope-acknowledge`})})}):null]}),(0,i.jsxs)(EJ,{children:[(0,i.jsx)(Xs,{variant:`tab`,onClick:()=>{f?.(Hn),d(!1)},className:`cta-secondary`,children:`Discard`}),(0,i.jsx)(Xs,{variant:`primary`,onClick:()=>{se||ee(v,async()=>await ne({clientId:r,data:{companyId:_,feature:`GALLERY`,dashboardId:g},isFrontendApp:!1,token:t}))},isDisabled:te||!e?.length||se,className:`cta-primary`,"data-testid":`gallery-save`,children:`Save`})]})]})}})),REr,zEr,BEr=h((()=>{WK(),REr=({clientId:e,tableName:t,tenancyLevel:n})=>n!==`DATABASE`||!e||!t?t||``:`${e}.${_x(t).name}`,zEr=({applyOnTables:e,clientId:t,tenancyLevel:n})=>e?.map(e=>({...e,tableName:REr({clientId:t,tableName:e.tableName,tenancyLevel:n})}))})),VEr,HEr,UEr,WEr=h((()=>{VEr=(e,t)=>Array.isArray(e)?e:e&&typeof e==`object`?Object.entries(e).map(([e,n])=>({id:e,[t]:n})):[],HEr=e=>VEr(e,`xAxisSettings`),UEr=e=>VEr(e,`yAxisSettings`)})),GEr,KEr=h((()=>{sr(),GEr=({hasToken:e,isLoading:t,error:r,isLoaded:i,onServerEvent:a})=>{(0,n.useEffect)(()=>{e?r?a?.(r):t?a?.(Nn):i&&a?.(Pn):a?.(`INVALID_TOKEN`)},[e,t,r,i,a])}})),qEr,JEr=h((()=>{qEr=(e,t)=>{if(e.current)return e.current;let n=Promise.resolve().then(t).finally(()=>{e.current===n&&(e.current=null)});return e.current=n,n}})),YEr,XEr=h((()=>{E0t(),YEr=e=>aY.sanitize(e,{ALLOWED_TAGS:[`svg`,`path`,`circle`,`rect`,`line`,`polygon`,`polyline`,`ellipse`,`g`,`defs`,`use`],ALLOWED_ATTR:[`viewBox`,`xmlns`,`fill`,`stroke`,`stroke-width`,`stroke-linecap`,`stroke-linejoin`,`d`,`cx`,`cy`,`r`,`x`,`y`,`width`,`height`,`points`,`transform`,`id`,`class`],FORBID_TAGS:[`script`,`iframe`,`object`,`embed`,`foreignObject`],FORBID_ATTR:[`on*`,`href`,`xlink:href`],ALLOW_DATA_ATTR:!1,RETURN_TRUSTED_TYPE:!1})})),ZEr,QEr,$Er,eDr=h((()=>{ZEr=`localStorageValueSet`,QEr=`dbn:embed-config`,$Er=e=>{document.dispatchEvent(new CustomEvent(ZEr,{detail:e})),document.dispatchEvent(new CustomEvent(QEr,{detail:e}))}})),tDr,nDr=h((()=>{tDr=()=>(0,i.jsx)(`h1`,{className:`sr-only`,children:`Metric builder`})})),rDr,iDr=h((()=>{$q(),q7t(),Dc(),nq(),rDr=({clientId:e,companyId:t,isLiveMode:n,externalDashboardId:r,userProvidedDashboardId:i,chartColors:a,isShowMetricCreateModal:o,setShowMetricCreateModal:s,metric:l,metricData:u,workspaceId:d,token:f,clientColumnType:p,tenancyType:m,datasourceId:h,setEditMetric:g,onServerEvent:_,refetchDashboardData:v,saveDashLayout:y,isIncrementalJoin:b,customChartSettings:x})=>{let{data:S}=Ec(),C=SKt({principal:{isAllClient:S?.isAllClient,clientId:e},tenancyLevel:m}),w={clientId:e,companyId:t,isLiveMode:n,externalDashboardId:r,userProvidedDashboardId:i,chartColors:a,isShowMetricCreateModal:o,setShowMetricCreateModal:s,metric:l,metricData:u,clientColumnType:p,datasourceId:h,setEditMetric:g,databaseName:m===`MULTI_DATABASE`&&e||``,refetchDashboardData:v,onServerEvent:_,saveDashLayout:y,customChartSettings:x},T=K7t(w),ee={isIncrementalJoin:!!b,dashboardId:i,datasetSettings:T.datasetSettings,clientSubsetData:T.clientSubsetData,clientId:e,shouldApplyClientDataScope:C,setError:T.setError,setLoading:T.setLoading,setData:T.setData,setQuery:T.setQuery,setGroupByList:T.setGroupByList,chart:T.chartSettings.chartType,setChartSettings:T.setChartSettings,chartSettings:T.chartSettings,dbName:T.dbName,data:T.data||[],limit:T.limit||`100`,setDatasetSettings:T.setDatatsetSettings,token:f,workspaceId:d,clientColumnType:p,isDatabaseTenancy:m===`DATABASE`,setDrillDownSettings:T.setDrillDownSettings,drillDownSettings:T.drillDownSettings,datasourceId:h,id:l?.id,companyId:t,onServerEvent:_,metricEncryptedQuery:l?.query,rlsConditions:T.rlsConditions,isFrontendApp:!1,encryptedClientId:``};return{config:w,metricConfig:T,datasetConfig:ee,dataset:rZt(ee)}}}));function aDr(e,t){return e&&t}function oDr({isLoading:e,hasData:t,hasSelectedFields:n,chartSettings:r}){return!e&&t&&n&&!lDr.includes(r.chartType)}function sDr(e){return!(e?.tableSettings?.isServerSidePagination&&e?.chartType===$.table)}function cDr(e){return!!e?.isMultiDimension&&!!e?.seriesField&&e.seriesField!==`ungrouped`}var lDr,uDr,dDr,fDr,pDr,mDr,hDr,gDr,_Dr=h((()=>{r$(),hlr(),Zvn(),XHn(),QHn(),my(),F8(),E6(),B8(),lDr=[$.pivotV2,$.funnelV2,...Object.values(Q_)],uDr=`relative h-7 gap-1.5 border-(--border) bg-(--muted) px-2 text-xs font-medium text-(--muted-foreground) hover:text-(--foreground)`,dDr=`size-7 border-(--border) bg-(--muted) text-(--muted-foreground) hover:text-(--foreground)`,fDr=`bg-(--accent) text-(--foreground)`,pDr=()=>(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-4 w-px shrink-0 self-center bg-(--border)`}),mDr=({field:e})=>(0,i.jsxs)(`span`,{...R8(`builder-toolbar`,`group-by-indicator`),className:`inline-flex h-7 max-w-45 shrink-0 items-center gap-1.5 rounded-(--radius-sm) border border-(--border) bg-(--muted) px-2 text-xs font-medium text-(--muted-foreground)`,children:[(0,i.jsx)(khn,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsxs)(`span`,{className:`truncate`,children:[`Grouped by `,(0,i.jsx)(`span`,{className:`text-(--foreground)`,children:e})]})]}),hDr=({testId:e,srLabel:t})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,...R8(e),className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-(--foreground)`}),(0,i.jsxs)(`span`,{className:`sr-only`,children:[` `,t]})]}),gDr=({chartSettings:e,hasData:t,hasSelectedFields:n,isLoading:r=!1,limit:a,setLimit:o,onChangeLimit:s,onOpenFilters:l,onOpenSort:u,onOpenChartType:d,onOpenChartAppearance:f,hasActiveFilters:p=!1,hasActiveSort:m=!1,onClearAll:h,showChartTypeTrigger:g=!0,filtersPanelProps:_,sortPanelProps:v,chartTypePanelProps:y,chartAppearancePanelProps:b,className:x})=>{let S=aDr(t,n),C=oDr({isLoading:r,hasData:t,hasSelectedFields:n,chartSettings:e}),w=sDr(e),T=cDr(e),ee=e=>{o(e),s(e)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{...R8(`builder-toolbar`),"data-slot":`builder-toolbar`,className:KH(`flex h-10 w-full shrink-0 items-center justify-between gap-2 rounded-t-(--radius-md) border border-b-0 border-(--border) bg-(--background) px-2`,x),children:[(0,i.jsxs)(`div`,{...R8(`builder-toolbar`,`query-actions`),className:`flex min-w-0 items-center gap-1`,children:[S?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`builder-toolbar`,`filters`),"aria-expanded":_.isOpen,onClick:l,className:KH(uDr,p&&fDr),children:[(0,i.jsx)(ZQ,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Filters`}),p?(0,i.jsx)(hDr,{testId:`builder-toolbar-filters-active-indicator`,srLabel:`(filter applied)`}):null]}):null,S?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`builder-toolbar`,`sort`),"aria-expanded":v.isOpen,onClick:u,className:KH(uDr,m&&fDr),children:[(0,i.jsx)(HQ,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Sort`}),m?(0,i.jsx)(hDr,{testId:`builder-toolbar-sort-active-indicator`,srLabel:`(sort applied)`}):null]}):null,T?(0,i.jsx)(mDr,{field:e.seriesField}):null]}),(0,i.jsxs)(`div`,{...R8(`builder-toolbar`,`output-controls`),className:`flex shrink-0 items-center gap-1`,children:[w?(0,i.jsxs)(r3n,{value:a??``,onValueChange:ee,children:[(0,i.jsxs)(a3n,{...L8(`builder-toolbar`,`limit`),size:`sm`,className:`h-7 gap-1 px-2 text-xs font-medium`,"aria-label":`Row limit`,title:`Show top N rows: sort your measure from highest to lowest, then choose a row limit. For Top 50, choose 50.`,children:[(0,i.jsx)(`span`,{className:`text-(--muted-foreground)`,children:`Row limit`}),(0,i.jsx)(i3n,{placeholder:`-`})]}),(0,i.jsx)(o3n,{children:Ase.map(e=>(0,i.jsx)(s3n,{value:e.value,children:e.label},e.value))})]}):null,g?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`builder-toolbar`,`chart-type`),"aria-expanded":y.isOpen,onClick:d,className:uDr,children:[(0,i.jsx)(GQ,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Chart type`})]}):null,C?(0,i.jsx)(B6,{type:`button`,variant:`outline`,size:`icon-sm`,...L8(`builder-toolbar`,`chart-appearance`),"aria-expanded":b.isOpen,"aria-label":`Chart appearance`,onClick:f,className:dDr,children:(0,i.jsx)(fgn,{"aria-hidden":`true`})}):null,h?(0,i.jsx)(pDr,{}):null,h?(0,i.jsxs)(B6,{type:`button`,variant:`ghost`,size:`sm`,...L8(`builder-toolbar`,`clear-all`),onClick:h,className:`h-7 px-2 text-xs font-medium`,children:[(0,i.jsx)(ohn,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Clear all`})]}):null]})]}),(0,i.jsx)(YHn,{filtersPanelProps:_}),(0,i.jsx)(ZHn,{SortPanelProps:v}),(0,i.jsx)(s7,{chartTypePanelProps:y}),(0,i.jsx)(Xvn,{ChartAppearancePanelProps:b})]})}})),vDr,yDr,bDr,xDr=h((()=>{RK(),xQ(),r$(),ein(),F8(),E6(),B8(),vDr=I8(`create-metric-header`,`save`,`reason`),yDr=`Untitled metric`,bDr=({metricName:e,isSaved:t=!1,statusLabel:r=`Draft`,title:a=`Create metric`,onBack:o,backAriaPrefix:s=`Back to`,onSave:l,saveLabel:u=`Save to dashboard`,isLoading:d=!1,chartSettings:f,dimensions:p,metrics:m,isCustomTable:h,rows:g,className:_})=>{let v=n.useMemo(()=>bQ({chartSettings:f,dimensions:p,metrics:m,isCustomTable:h}),[f,p,m,h]),y=!d&&v!==null,b=d||y,x=()=>{b||l()},S=e?.trim()?e.trim():yDr,C=n.useMemo(()=>{let e=Zrn(f,g??[],void 0);return e?bbt(e):null},[f,g]),w=(0,i.jsxs)(B6,{type:`button`,variant:`primary`,size:`md`,...L8(`create-metric-header`,`save`),onClick:x,"aria-disabled":b,"aria-busy":d,"aria-describedby":y?vDr:void 0,className:KH(`shrink-0`,b&&`cursor-not-allowed border-(--border) bg-(--muted) text-(--muted-foreground) hover:bg-(--muted)`),children:[d?(0,i.jsx)(Rhn,{className:`size-4 animate-spin`,"aria-hidden":`true`}):null,(0,i.jsx)(`span`,{children:u})]});return(0,i.jsxs)(`div`,{"data-slot":`create-metric-header`,className:KH(`flex min-h-14 w-full shrink-0 items-center justify-between gap-4 border-b border-(--border) bg-(--card) px-4 py-2`,_),children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,i.jsxs)(`button`,{type:`button`,...L8(`create-metric-header`,`back`),onClick:o,className:`-ml-1 flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-(--radius-sm) border border-transparent bg-transparent text-(--muted-foreground) hover:bg-(--muted) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:[(0,i.jsxs)(`span`,{className:`sr-only`,children:[s,` `,a]}),(0,i.jsx)(Gpn,{className:`size-4`,"aria-hidden":`true`})]}),(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`h-4 w-px shrink-0 bg-(--border)`}),(0,i.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,i.jsx)(`h2`,{...L8(`create-metric-header`,`title`),className:`truncate text-sm leading-5 font-medium text-(--foreground)`,children:S}),t?null:(0,i.jsx)(`span`,{...L8(`create-metric-header`,`status`),className:`inline-flex h-5 shrink-0 items-center rounded-(--radius-sm) border border-(--border) px-2 text-xs leading-4 font-normal text-(--muted-foreground)`,children:r})]}),C?(0,i.jsx)(`p`,{...L8(`create-metric-header`,`answer-line`),className:`truncate text-xs leading-4 font-normal text-(--muted-foreground)`,children:C}):null]})]}),y?(0,i.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,i.jsx)(v3n,{children:(0,i.jsxs)(y3n,{children:[(0,i.jsx)(b3n,{asChild:!0,children:w}),(0,i.jsx)(x3n,{side:`bottom`,align:`end`,children:v})]})}),(0,i.jsx)(`span`,{id:vDr,className:`sr-only`,children:v})]}):w]})}})),W9,SDr,CDr,wDr,TDr=h((()=>{r$(),Qdn(),W9=e=>{let t=(e||``).toLowerCase();return Kdn.includes(t)||t.startsWith(`decimal`)||t.startsWith(`numeric`)?`numeric`:qdn.includes(t)||t.includes(`char`)?`text`:Ydn.includes(t)?`array`:Jdn.includes(t)||t.includes(`timestamp`)||t.includes(`date`)?`date`:Xdn.includes(t)?`boolean`:`unknown`},SDr={numeric:bhn,text:jgn,date:WQ,boolean:Egn,array:Fhn,unknown:Lmn},CDr={numeric:`Numeric column`,text:`Text column`,date:`Date column`,boolean:`Boolean column`,array:`List column`,unknown:`Column`},wDr=({kind:e})=>{let t=SDr[e];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsx)(`span`,{className:`sr-only`,children:CDr[e]})]})}})),EDr,DDr,ODr,kDr,ADr,jDr,MDr,NDr,PDr,FDr,IDr,LDr,RDr,zDr,BDr,VDr,HDr,UDr=h((()=>{TDr(),Ge(),r$(),zdt(),fJ(),F8(),E6(),B8(),EDr=({kind:e})=>{let t=SDr[e];return(0,i.jsxs)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-(--muted-foreground)`,children:[(0,i.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsx)(`span`,{className:`sr-only`,children:CDr[e]})]})},DDr=e=>e.label||e.dataMartColumnAlias||e.name,ODr=(e,t)=>t?e.label?e.label.toLowerCase().includes(t):e.dataMartColumnAlias?e.dataMartColumnAlias.toLowerCase().includes(t):e.name?e.name.toLowerCase().includes(t):!1:!0,kDr=(e,t)=>`${e} ${t}${e===1?``:`s`}`,ADr=e=>`${e.schemaName||``}.${e.tableName}`,jDr=e=>e.columnsWithDataType??[],MDr=e=>e.columnsWithDataType?.length??e.columns?.length??0,NDr=e=>{let t=e.filter(e=>W9(e.dataType)===`numeric`);return!t.length||t.length===e.length?e:[...t,...e.filter(e=>W9(e.dataType)!==`numeric`)]},PDr=({label:e})=>(0,i.jsx)(`span`,{className:`inline-block max-w-40 truncate rounded-(--radius-sm) bg-(--popover) px-2 py-0.5 text-xs font-medium text-(--popover-foreground) shadow-(--shadow-overlay) ring-1 ring-(--border)`,children:e}),FDr=`flex h-7 w-full shrink-0 items-center gap-2 rounded-(--radius-sm) py-0 pr-2 pl-7 text-left text-mono transition-colors select-none hover:bg-(--muted) focus-visible:bg-(--muted) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,IDr=({table:e,column:t})=>{let r=n.useMemo(()=>({table:e,column:{...t,alias:t.dataMartColumnAlias||t.name}}),[e,t]),a=DDr(t),{DragNodeRef:o}=dJ({identifier:{id:t.name,type:`column`},data:r,modifiers:{highlightDrop:{onDrag:!0}},CustomDragPreview:(0,i.jsx)(PDr,{label:a})}),s=W9(t.dataType),l=z8(`data-rail-column`,t.name);return(0,i.jsxs)(`div`,{ref:o,"data-slot":`data-rail-column`,"data-testid":l[`data-testid`],className:KH(FDr,`group/data-rail-row cursor-grab text-(--foreground) active:cursor-grabbing`),title:t.description?`${a}: ${t.description}`:a,children:[(0,i.jsx)(EDr,{kind:s}),(0,i.jsx)(`span`,{className:`truncate`,children:a}),(0,i.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[t.type===`custom`?(0,i.jsx)(`span`,{className:`text-caption font-medium text-(--muted-foreground)`,children:`fx`}):null,(0,i.jsx)(_hn,{"aria-hidden":`true`,className:`size-3.5 text-(--muted-foreground) opacity-0 transition-opacity group-hover/data-rail-row:opacity-100 group-focus-visible/data-rail-row:opacity-100`})]})]})},LDr=({table:e,column:t,onSelectTable:n})=>{let r=DDr(t),a=z8(`data-rail-preview-column`,t.name);return(0,i.jsxs)(`button`,{type:`button`,"data-slot":`data-rail-preview-column`,...a,className:KH(FDr,`text-(--muted-foreground)`),title:[`${r} - select ${iV(e)} to use it`,t.description].filter(Boolean).join(`: `),onClick:()=>n(e),children:[(0,i.jsx)(EDr,{kind:W9(t.dataType)}),(0,i.jsx)(`span`,{className:`truncate`,children:r})]})},RDr=({children:e})=>(0,i.jsxs)(`div`,{className:`sticky top-0 z-10 flex shrink-0 items-center gap-2 bg-(--background) px-2 pt-2 pb-1 text-caption font-semibold tracking-widest text-(--muted-foreground) uppercase`,children:[(0,i.jsx)(`span`,{className:`truncate`,children:e}),(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-(--border)`})]}),zDr=({node:e,isSelected:t,isExpanded:n,onToggleExpand:r,onSelectTable:a})=>{let{table:o,key:s,visibleColumns:l}=e,u=iV(o),d=I8(`data-rail-table-columns`,s),f=MDr(o);return(0,i.jsxs)(`div`,{"data-slot":`data-rail-table-node`,className:`flex shrink-0 flex-col`,children:[(0,i.jsxs)(`div`,{className:KH(`flex h-8 shrink-0 items-center gap-1 rounded-(--radius-sm) pr-2 pl-1 transition-colors hover:bg-(--muted)`,t&&`bg-(--muted)`),children:[(0,i.jsx)(`button`,{type:`button`,...z8(`data-rail-table-toggle`,s),"aria-expanded":n,"aria-controls":d,"aria-label":`${n?`Collapse`:`Expand`} ${u}`,onClick:()=>r(s),className:`flex size-6 shrink-0 items-center justify-center rounded-(--radius-sm) text-(--muted-foreground) transition-colors hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,children:(0,i.jsx)(YQ,{"aria-hidden":`true`,className:KH(`size-3.5 transition-transform`,n&&`rotate-90`)})}),(0,i.jsxs)(`button`,{type:`button`,...z8(`data-rail-table`,s),"aria-current":t?`true`:void 0,title:[o.schemaName?`${o.schemaName}.${u}`:u,o.description].filter(Boolean).join(`: `),onClick:()=>a(o),onKeyDown:e=>{e.key===`ArrowRight`&&!n&&(e.preventDefault(),r(s)),e.key===`ArrowLeft`&&n&&(e.preventDefault(),r(s))},className:KH(`flex h-6 min-w-0 flex-1 items-center gap-2 rounded-(--radius-sm) px-1 text-left text-mono text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,t?`font-semibold`:`font-medium`),children:[(0,i.jsx)(e$,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-(--muted-foreground)`}),(0,i.jsx)(`span`,{className:`truncate`,children:u}),(0,i.jsx)(`span`,{className:`ml-auto shrink-0 text-caption font-normal tabular-nums text-(--muted-foreground)`,children:f})]})]}),o.description?(0,i.jsx)(`p`,{className:`px-8 pb-1 text-caption text-(--muted-foreground)`,children:o.description}):null,n?(0,i.jsx)(`div`,{id:d,role:`group`,"aria-label":`${u} columns`,className:`flex flex-col gap-px pb-1`,children:l.length===0?(0,i.jsx)(`span`,{className:KH(FDr,`text-(--muted-foreground)`),children:`No columns`}):l.map(e=>t?(0,i.jsx)(IDr,{table:o,column:e},e.name):(0,i.jsx)(LDr,{table:o,column:e,onSelectTable:a},e.name))}):null]})},BDr={connected:`bg-(--success-fg)`,syncing:`bg-(--warning-fg)`,error:`bg-(--destructive)`},VDr={connected:`Connected`,syncing:`Syncing`,error:`Connection error`},HDr=({tableList:e,selectedTable:t,onSelectTable:r,onSearchFocus:a,datasourceName:o,datasourceStatus:s,datasourceError:l,isCollapsed:u,onToggleCollapse:d,defaultCollapsed:f=!1,className:p})=>{let[m,h]=n.useState(``),[g,_]=n.useState({}),[v,y]=n.useState(f),b=u??v,x=()=>{let e=!b;u===void 0&&y(e),d?.(e)},S=t?ADr(t):``,C=m.trim().toLowerCase(),w=n.useMemo(()=>e.map(e=>{let t=NDr(jDr(e)),n=!C||iV(e).toLowerCase().includes(C)||e.tableName.toLowerCase().includes(C),r=C?t.filter(e=>ODr(e,C)):t;return{table:e,key:ADr(e),nameMatches:n,visibleColumns:r.length>0?r:t,hasColumnHit:!!C&&r.length>0}}).filter(e=>e.nameMatches||e.hasColumnHit),[e,C]),T=n.useMemo(()=>{let e=new Map;return w.forEach(t=>{let n=t.table.schemaName||``,r=e.get(n);r?r.push(t):e.set(n,[t])}),Array.from(e,([e,t])=>({schema:e,nodes:t}))},[w]),ee=T.some(e=>!!e.schema),te=e=>e.hasColumnHit||e.key===S||!!g[e.key],ne=e=>{_(t=>({...t,[e]:!t[e]}))},re=e.length,ie=e.reduce((e,t)=>e+MDr(t),0),ae=w.reduce((e,t)=>e+t.visibleColumns.length,0),oe=C?`${w.length} of ${re} tables, ${ae} of ${ie} columns`:`${kDr(re,`table`)}, ${kDr(ie,`column`)}`,se=(0,i.jsx)(`button`,{type:`button`,...L8(`data-rail-collapse`),"aria-expanded":!b,"aria-label":b?`Expand data panel`:`Collapse data panel`,title:b?`Expand data panel`:`Collapse data panel`,onClick:x,className:`flex size-6 shrink-0 items-center justify-center rounded-(--radius-sm) text-(--muted-foreground) transition-colors hover:bg-(--muted) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)`,children:b?(0,i.jsx)(tgn,{"aria-hidden":`true`,className:`size-4`}):(0,i.jsx)(Qhn,{"aria-hidden":`true`,className:`size-4`})});return b?(0,i.jsxs)(`div`,{"data-slot":`data-rail`,"data-collapsed":`true`,...L8(`data-rail`),className:KH(`flex h-full w-11 shrink-0 flex-col items-center gap-2 border-r border-(--border) bg-(--background) py-2`,p),children:[se,(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-6 shrink-0 bg-(--border)`}),(0,i.jsx)(`span`,{className:`text-caption font-semibold tracking-widest text-(--muted-foreground) uppercase dbn-v2-vertical-rl`,children:`Data`}),(0,i.jsxs)(`span`,{...L8(`data-rail-count`),title:oe,className:`mt-auto text-caption tabular-nums text-(--muted-foreground)`,children:[re,(0,i.jsxs)(`span`,{className:`sr-only`,children:[` `,oe]})]})]}):(0,i.jsxs)(`div`,{"data-slot":`data-rail`,"data-collapsed":`false`,...L8(`data-rail`),className:KH(`flex h-full w-67 shrink-0 flex-col border-r border-(--border) bg-(--background)`,p),children:[(0,i.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-(--border) pr-2 pl-3`,children:[(0,i.jsx)(`span`,{className:`truncate text-xs font-semibold tracking-tight text-(--foreground)`,children:`Data`}),se]}),o?(0,i.jsxs)(`div`,{...L8(`data-rail-datasource`),className:`flex h-8 shrink-0 items-center gap-2 border-b border-(--border) px-3`,title:o,children:[(0,i.jsx)(Qmn,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-(--muted-foreground)`}),(0,i.jsx)(`span`,{className:`truncate text-mono font-medium text-(--foreground)`,children:o}),s?(0,i.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center`,children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:KH(`size-1.5 rounded-full`,BDr[s])}),(0,i.jsx)(`span`,{className:`sr-only`,children:s===`error`&&l?.code?pe(l):VDr[s]})]}):null]}):null,(0,i.jsx)(`div`,{className:`shrink-0 border-b border-(--border) p-2`,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)($Q,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-(--muted-foreground)`}),(0,i.jsx)(s8,{...L8(`data-rail-search`),type:`text`,value:m,onChange:e=>h(e.target.value),onFocus:a,placeholder:`Search tables & columns`,"aria-label":`Search tables and columns`,className:`h-8 pl-7 text-xs`})]})}),(0,i.jsx)(`div`,{...L8(`data-rail-column-list`),className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-2 pb-2`,children:w.length===0?(0,i.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-1 px-4 py-8 text-center`,children:[(0,i.jsx)(`p`,{className:`text-xs font-medium text-(--foreground)`,children:e.length===0?`No tables`:`No matches`}),(0,i.jsx)(`p`,{className:`text-xs text-(--muted-foreground)`,children:e.length===0?`This datasource has no tables to build from.`:`Try a shorter search term.`})]}):(0,i.jsx)(`div`,{...L8(`data-rail-table-select`),role:`group`,"aria-label":`Tables`,className:`flex flex-col`,children:T.map(e=>(0,i.jsxs)(n.Fragment,{children:[ee&&e.schema?(0,i.jsx)(RDr,{children:e.schema}):null,e.nodes.map(e=>(0,i.jsx)(zDr,{node:e,isSelected:e.key===S,isExpanded:te(e),onToggleExpand:ne,onSelectTable:r},e.key))]},e.schema||`__no_schema__`))})}),(0,i.jsx)(`div`,{className:`flex h-8 shrink-0 items-center border-t border-(--border) px-3`,children:(0,i.jsx)(`span`,{...L8(`data-rail-count`),className:`truncate text-caption tabular-nums text-(--muted-foreground)`,children:oe})})]})}})),WDr,GDr,G9,K9,KDr=h((()=>{WDr=`item`,GDr=(...e)=>e.filter(e=>e!=null&&e!==``).map(e=>String(e).trim().replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)).filter(Boolean).join(`-`).replace(/-+/g,`-`)||WDr,G9=(...e)=>({id:GDr(...e),"data-testid":GDr(...e)}),K9=(...e)=>({"data-testid":GDr(...e)})})),qDr,JDr=h((()=>{qDr=({groups:e,onPick:t,disabled:n=!1,defaultOpen:r=!1,filterMode:a,appearance:o=`menu`,Item:s,Group:l,renderShell:u})=>{let[d,f]=x.useState(r),[p,m]=x.useState(``),h=x.useMemo(()=>{let t=p.trim().toLowerCase();return a===`native`||!t?e:e.map(e=>({...e,choices:e.choices.filter(e=>e.searchText.toLowerCase().includes(t))}))},[e,p,a]),g=e=>{n&&e||(f(e),e||m(``))},_=h.map(e=>{let n=e.choices.map(e=>(0,i.jsxs)(s,{id:e.id,"data-testid":e.id,searchText:e.searchText,onSelect:()=>{g(!1),t(e.value)},children:[(0,i.jsx)(`span`,{className:o===`command`?`inline-flex size-3.5 shrink-0 items-center justify-center self-start mt-0.5 text-(--muted-foreground)`:`flex size-3.5 shrink-0 items-center justify-center text-(--muted-foreground)`,children:e.glyph}),(0,i.jsx)(`span`,{className:o===`command`?`min-w-0 flex-1 whitespace-normal break-words`:`truncate tabular-nums`,children:e.label})]},e.key));return l?(0,i.jsx)(l,{heading:e.label,children:n},e.key):(0,i.jsx)(x.Fragment,{children:n},e.key)});return u({open:d,onOpenChange:g,search:p,onSearchChange:m,hasChoices:h.some(e=>e.choices.length>0),children:_})}})),YDr,XDr=h((()=>{r$(),cK(),KDr(),TDr(),JDr(),YDr=({columns:e,onSelectColumn:t,triggerAriaLabel:n,zoneId:r,disabled:a=!1,disabledReason:o,emptyLabel:s=`No columns available`,defaultOpen:l,className:u,components:d})=>{let{Root:f,Trigger:p,Content:m,Button:h,Input:g,Empty:_,Item:v,headerClassName:y}=d,b=a&&!!o,S=x.useMemo(()=>[{key:r,choices:e.map(e=>{let t=e.label||e.dataMartColumnAlias||e.name;return{key:`${e.parentAlias||``}-${e.name}`,value:e,label:t,searchText:t,id:G9(`field-zone`,r,`column`,e.name).id,glyph:(0,i.jsx)(wDr,{kind:W9(e.dataType)})}})}],[e,r]);return(0,i.jsx)(qDr,{groups:S,onPick:t,disabled:a,defaultOpen:l,filterMode:`substring`,Item:v,renderShell:({open:e,onOpenChange:t,search:l,onSearchChange:d,hasChoices:v,children:x})=>(0,i.jsxs)(f,{open:e,onOpenChange:t,children:[(0,i.jsx)(p,{asChild:!0,children:(0,i.jsx)(h,{type:`button`,variant:`outline`,size:`icon-xs`,"aria-disabled":a,"aria-label":b?`${n} - ${o}`:n,title:b?o:void 0,...G9(`field-zone`,r,`add`),className:KH(`shrink-0`,u),children:(0,i.jsx)(ign,{"aria-hidden":`true`})})}),(0,i.jsxs)(m,{align:`start`,size:`lg`,children:[(0,i.jsx)(`div`,{className:y,children:(0,i.jsx)(g,{value:l,onChange:e=>d(e.target.value),placeholder:`Search columns`,"aria-label":`Search columns for ${n}`,className:`h-7`,...G9(`field-zone`,r,`search`),onKeyDown:e=>e.stopPropagation()})}),v?x:(0,i.jsx)(_,{children:s})]})]})})}})),ZDr=h((()=>{xQ()})),QDr,$Dr,eOr,tOr,nOr,rOr,iOr,aOr,oOr,sOr,cOr=h((()=>{TDr(),r$(),my(),xV(),fJ(),F8(),S3n(),E6(),B8(),QDr=new Set(Cv),$Dr=new Set(zv),eOr=new Set(Rv),tOr=e=>{let t=e.helperFunction?.trim();return!t||t.toUpperCase()===`NONE`?null:t.toUpperCase()},nOr=({label:e})=>(0,i.jsx)(`span`,{className:`inline-block max-w-40 truncate rounded-(--radius-sm) bg-(--popover) px-2 py-1 text-xs font-medium text-(--popover-foreground) shadow-(--shadow-overlay) ring-1 ring-(--border)`,children:e}),rOr=`group inline-flex h-7 max-w-full shrink-0 cursor-grab items-center gap-1 rounded-(--radius-sm) border border-(--border) bg-(--muted) px-1 text-xs font-medium text-(--foreground) transition-colors hover:border-(--muted-foreground) active:cursor-grabbing focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,iOr=`cursor-grabbing border-dashed opacity-50`,aOr=`flex h-6 shrink-0 items-center justify-center rounded-(--radius-sm) text-(--muted-foreground) transition-colors hover:bg-(--accent) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,oOr=`h-6 max-w-36 min-w-0 shrink truncate rounded-(--radius-sm) px-1 text-left leading-6 text-(--foreground) transition-colors hover:bg-(--accent) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,sOr=({column:e,type:t,zoneId:r,index:a,functionOptions:o,onChangeHelperFunction:s,onChangeAlias:l,onRemove:u,isPartitionByColumnEnabled:d=!1,partitionColumnList:f=[],selectedDims:p=[],dbName:m,className:h})=>{let g=NS(e)||e.alias||e.name,_=QDr.has(e.type),v=n.useMemo(()=>[Kv,Qv].includes((m||``).toLowerCase()),[m]),y=n.useMemo(()=>{if(_)return[];let n=o(e);if(t===`DIMENSION`)return n.filter(e=>!$Dr.has(e.value));let r=[...n.filter(e=>$Dr.has(e.value)),{value:`NONE`,label:`Original Value`}];return v&&(r=r.filter(e=>!eOr.has(e.value))),r},[_,o,e,t,v]),b=tOr(e),x=y.length===1?y[0]??null:null,S=t===`DIMENSION`?e.type===`HELPER_FUNCTION`?`aggregate_dimensions`:`dimensions`:e.configType===`AGGREGATE`?`aggregate_metrics`:`metrics`,C=n.useMemo(()=>({...e.draggableItemData,column:{...e.draggableItemData.column,alias:e.alias}}),[e]),{DragNodeRef:w,isDragging:T}=dJ({identifier:{id:e.alias,type:S},data:C,modifiers:{highlightDrop:{onDrag:!0}},CustomDragPreview:(0,i.jsx)(nOr,{label:g})}),ee=W9(e.datatype),te=SDr[ee],[ne,re]=n.useState(!1),[ie,ae]=n.useState(`list`),oe=n.useRef(null),[se,ce]=n.useState(e.percentileValue??.5),[le,ue]=n.useState([]),[de,fe]=n.useState(e.functionConfiguration?.dateFormat??``),pe=e=>{re(e),e||(ae(`list`),oe.current=null)},me=(n,r)=>{if(eOr.has(n.value)){r.preventDefault(),oe.current=n,ce(e.percentileValue??.5),d&&p.length&&le.length===0&&ue(f.filter(e=>p.some(t=>t.name===e.dimension?.columnName))),ae(`percentile`);return}if(t===`DIMENSION`&&n.value===`date format`){r.preventDefault(),oe.current=n,fe(e.functionConfiguration?.dateFormat??``),ae(`dateFormat`);return}s({column:e,helperFunction:n,type:t})},he=()=>{let t=oe.current;t&&(s({column:e,helperFunction:t,type:`METRIC`,percentileValue:se,partitionByColumns:le.map(e=>{if(!e.dimension)return;let t=p.find(t=>t.name===e.dimension?.columnName);return{...e.dimension,parentAlias:t?.parentAlias||e.dimension.parentAlias}}).filter(e=>!!e)}),pe(!1))},ge=()=>{let t=oe.current;t&&(s({column:e,helperFunction:t,type:`DIMENSION`,functionConfiguration:{dateFormat:de}}),pe(!1))},_e=![`ARITHMETIC`,`CUSTOM`].includes(e.type),[ve,ye]=n.useState(!1),[be,xe]=n.useState(e.alias),[Se,Ce]=n.useState(e.cast??iy[iy.length-1]),we=n.useRef(!1),Te=n.useId(),Ee=`${Te}-rename-input`,De=`${Te}-partition`,Oe=`${Te}-percentile-value`,Ae=`${Te}-date-format-value`,je=t=>{ye(t),t&&(xe(e.alias),Ce(e.cast??iy[iy.length-1]),we.current=!1)},Me=()=>{l({alias:be||e.alias,column:e,type:t,cast:Se,isColumnCasted:we.current}),ye(!1)},Ne=[`field-chip`,r,e.alias];return(0,i.jsxs)(`div`,{ref:w,...R8(...Ne),"data-slot":`field-chip`,"data-dbn-sorting-index":a,className:KH(rOr,T&&iOr,h),children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`flex w-3 shrink-0 items-center justify-center text-(--muted-foreground)`,children:(0,i.jsx)(_hn,{className:`size-3`})}),(0,i.jsxs)(`span`,{...R8(...Ne,`type`),className:`flex size-4 shrink-0 items-center justify-center text-(--muted-foreground)`,children:[(0,i.jsx)(te,{"aria-hidden":`true`,className:`size-3.5`}),(0,i.jsx)(`span`,{className:`sr-only`,children:CDr[ee]})]}),_e?(0,i.jsxs)(V1n,{open:ve,onOpenChange:je,children:[(0,i.jsx)(H1n,{asChild:!0,children:(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`name`),title:g,className:oOr,children:g})}),(0,i.jsx)(c8,{align:`start`,size:`lg`,padding:`form`,children:(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Ee,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:e.label||e.dataMartColumnAlias||e.name}),(0,i.jsx)(s8,{value:be,onChange:e=>xe(e.target.value),...L8(...Ne,`rename-input`),id:Ee,className:`h-7 text-xs`})]}),e.type===`ARITHMETIC`?null:(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Te,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Cast column as`}),(0,i.jsxs)(r3n,{value:Se.value,onValueChange:e=>{let t=iy.find(t=>t.value===e);t&&(Ce(t),we.current=!0)},children:[(0,i.jsx)(a3n,{id:Te,size:`sm`,className:`h-7 w-full text-xs`,...R8(...Ne,`cast-select`),children:(0,i.jsx)(i3n,{})}),(0,i.jsx)(o3n,{children:iy.map(e=>(0,i.jsx)(s3n,{value:e.value,children:e.label},e.value))})]})]}),(0,i.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[(0,i.jsx)(B6,{type:`button`,variant:`ghost`,size:`sm`,className:`cta-secondary`,...L8(...Ne,`rename-cancel`),onClick:()=>ye(!1),children:`Cancel`}),(0,i.jsx)(B6,{type:`button`,variant:`secondary`,size:`sm`,className:`cta-primary`,...L8(...Ne,`rename-save`),onClick:Me,children:`Save`})]})]})})]}):(0,i.jsx)(`span`,{className:`h-6 max-w-36 min-w-0 shrink cursor-default truncate px-1 leading-6`,title:g,children:g}),x?(0,i.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-1 px-1 text-caption text-(--muted-foreground)`,children:[(0,i.jsx)(`span`,{className:`truncate`,children:x.label}),x.tooltip?(0,i.jsx)(v3n,{children:(0,i.jsxs)(y3n,{children:[(0,i.jsx)(b3n,{asChild:!0,children:(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`function-info`),"aria-label":`Why ${x.label.toLowerCase()} is the only option for ${g}`,className:KH(aOr,`size-6 text-(--muted-foreground) hover:text-(--foreground)`),children:(0,i.jsx)(Ehn,{"aria-hidden":`true`,className:`size-3.5`})})}),(0,i.jsx)(x3n,{children:x.tooltip})]})}):null]}):y.length>0?(0,i.jsxs)(n8,{open:ne,onOpenChange:pe,children:[(0,i.jsx)(r8,{asChild:!0,children:(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`function`),"aria-label":b?`Change function for ${g} (currently ${b})`:`Set a function for ${g} (none set)`,title:b??`Set a function`,className:KH(aOr,`border border-(--border) bg-(--background) hover:border-(--muted-foreground)`,b?`min-w-6 max-w-24 gap-1 px-2 text-caption font-semibold tracking-wide uppercase`:`size-6`),children:b?(0,i.jsx)(`span`,{className:`min-w-0 truncate`,children:b}):(0,i.jsx)(qQ,{"aria-hidden":`true`,className:`size-3`})})}),(0,i.jsx)(i8,{align:`start`,children:ie===`list`?y.map(e=>{let t=e.value===`distinct`?e.tooltip:void 0;return(0,i.jsx)(a8,{...L8(...Ne,`function`,e.value),disabled:!!t,className:`h-auto items-start whitespace-normal`,onSelect:t?void 0:t=>me(e,t),children:(0,i.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,i.jsx)(`span`,{children:e.label}),t?(0,i.jsx)(`span`,{className:`max-w-64 whitespace-normal text-xs leading-4 text-(--muted-foreground)`,children:t}):null]})},e.value)}):ie===`percentile`?(0,i.jsxs)(`div`,{className:`flex w-56 flex-col gap-2 p-1`,children:[d?(0,i.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Partition by`}),(0,i.jsx)(`div`,{className:`flex max-h-32 flex-col gap-1 overflow-y-auto rounded-(--radius-sm) border border-(--border) p-1`,children:f.length===0?(0,i.jsx)(`p`,{className:`px-1 py-1 text-xs text-(--muted-foreground)`,children:`No dimensions available`}):f.map(e=>{let t=le.some(t=>t.value===e.value),n=`${De}-${e.value}`;return(0,i.jsxs)(`label`,{htmlFor:n,className:`flex cursor-pointer items-center gap-2 rounded-(--radius-xs) px-1 py-1 text-xs hover:bg-(--accent)`,children:[(0,i.jsx)(J$n,{checked:t,onCheckedChange:t=>ue(n=>t?[...n,e]:n.filter(t=>t.value!==e.value)),...L8(...Ne,`partition`,e.value),id:n}),(0,i.jsx)(`span`,{className:`truncate`,children:e.label})]},e.value)})})]}):null,(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Oe,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Value (0-1)`}),(0,i.jsx)(s8,{type:`number`,min:0,max:1,step:.01,value:se,onChange:e=>{let t=Number(e.target.value);Number.isNaN(t)&&(t=0),t<0&&(t=0),t>1&&(t=1),ce(t)},...L8(...Ne,`percentile-value`),id:Oe,className:`h-7 text-xs`})]}),(0,i.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,i.jsx)(B6,{type:`button`,variant:`ghost`,size:`sm`,className:`cta-secondary`,...L8(...Ne,`percentile-cancel`),onClick:()=>ae(`list`),children:`Cancel`}),(0,i.jsx)(B6,{type:`button`,variant:`secondary`,size:`sm`,className:`cta-primary`,disabled:d&&le.length===0,...L8(...Ne,`percentile-save`),onClick:he,children:`Save`})]})]}):(0,i.jsxs)(`div`,{className:`flex w-56 flex-col gap-2 p-1`,children:[(0,i.jsxs)(`label`,{className:`flex flex-col gap-1`,htmlFor:Ae,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-(--muted-foreground)`,children:`Date format`}),(0,i.jsx)(s8,{type:`text`,value:de,onChange:e=>fe(e.target.value),placeholder:`%Y-%m-%d, yyyy-mm-dd`,...L8(...Ne,`date-format-value`),id:Ae,className:`h-7 text-xs`})]}),(0,i.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,i.jsx)(B6,{type:`button`,variant:`ghost`,size:`sm`,className:`cta-secondary`,...L8(...Ne,`date-format-cancel`),onClick:()=>ae(`list`),children:`Cancel`}),(0,i.jsx)(B6,{type:`button`,variant:`secondary`,size:`sm`,className:`cta-primary`,...L8(...Ne,`date-format-save`),onClick:ge,children:`Save`})]})]})})]}):_?(0,i.jsxs)(`span`,{...R8(...Ne,`function`,`static`),className:`flex size-6 shrink-0 cursor-default items-center justify-center rounded-(--radius-sm) border border-dashed border-(--border) text-(--muted-foreground)`,children:[(0,i.jsx)(vgn,{"aria-hidden":`true`,className:`size-3`}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Calculated field`})]}):null,(0,i.jsx)(`button`,{type:`button`,...L8(...Ne,`remove`),"aria-label":`Remove ${g}`,onClick:u,className:KH(aOr,`size-6 transition`,`pointer-fine:opacity-0 pointer-fine:group-hover:opacity-100 pointer-fine:group-focus-within:opacity-100 pointer-fine:focus-visible:opacity-100`),children:(0,i.jsx)(n$,{className:`size-3.5`,"aria-hidden":`true`})})]})}})),lOr,uOr,dOr,fOr,pOr,mOr,hOr,gOr,_Or,vOr,yOr,bOr,xOr,SOr,COr,wOr,TOr,EOr=h((()=>{XDr(),r$(),Zsn(),my(),ZDr(),hJ(),tQt(),F8(),E6(),B8(),cOr(),lOr=({children:e,onSelect:t,id:n,"data-testid":r})=>(0,i.jsx)(a8,{id:n,"data-testid":r,onSelect:t,children:e}),uOr={Root:n8,Trigger:r8,Content:i8,Button:B6,Input:s8,Empty:j1n,Item:lOr,headerClassName:w1n},dOr=e=>(0,i.jsx)(YDr,{...e,components:uOr}),fOr=`flex w-full items-start gap-2`,pOr=`flex h-9 w-24 shrink-0 items-center gap-1 text-caption font-semibold tracking-wider whitespace-nowrap uppercase text-(--muted-foreground)`,mOr=`flex max-h-28 min-h-9 w-full min-w-0 flex-1 flex-wrap items-center gap-2 overflow-y-auto rounded-(--radius) border border-dashed border-(--border) bg-(--background) px-2 py-1 transition-colors`,hOr={idle:``,armed:`border-(--muted-foreground)`,over:`border-solid border-(--primary) bg-(--accent) outline-2 -outline-offset-2 outline-(--primary)`,rejected:`border-solid border-(--muted-foreground) bg-(--muted) opacity-60`},gOr=`min-w-0 flex-1 truncate px-1 text-xs text-(--muted-foreground)`,_Or=`flex min-w-0 flex-1 items-center gap-1 px-1 text-xs text-(--muted-foreground)`,vOr=`flex h-9 w-6 shrink-0 items-center justify-center`,yOr=`Drag a numeric field to measure`,bOr=`Drag a field here to group by`,xOr={id:`dimensions`,accepts:[`column`,`dimensions`,`metrics`,`aggregate_dimensions`]},SOr={id:`metric`,accepts:[`column`,`dimensions`,`metrics`,`aggregate_metrics`]},COr=[],wOr=[],TOr=({table:e,columns:t,selectedDims:r,selectedMetrics:a,onDropColumn:o,onRemoveColumn:s,onChangeHelperFunction:l,onChangeAlias:u,functionOptions:d,dimModifiers:f,metricModifiers:p,chartSettings:m,dbName:h,partitionColumnList:g=wOr,measuresPickerDefaultOpen:_,dimensionsPickerDefaultOpen:v,arithmeticColumnOptions:y=COr,onSaveArithMetricOption:b,className:x})=>{let[S,C]=n.useState(!1),[w,T]=n.useState(),ee=a.length>0&&!!b,te=n.useMemo(()=>[Xv,qv,Gv,Zv].includes((h||``).toLowerCase()),[h]),ne=n.useCallback(e=>(t,n)=>{let i=n.active?.data,s=i?.column,l=i?.table;if(!s||!l)return;let{sorting:u}=n,d=n.active?.identifier,f=e===`DIMENSION`?[`dimensions`,`aggregate_dimensions`].includes(d?.type||``):[`metrics`,`aggregate_metrics`].includes(d?.type||``),p=()=>o({column:s,table:l,sorting:u,identifier:d,type:e});if(f){p();return}_Q({chartType:m.chartType,target:e,selectedDims:r,selectedMetrics:a,sourceType:d?.type}).canDrop&&p()},[m.chartType,o,r,a]),{setDropNodeRef:re,dragStatus:ie}=pJ({identifier:SOr,events:{onDrop:ne(`METRIC`)},modifiers:p}),{setDropNodeRef:ae,dragStatus:oe}=pJ({identifier:xOr,events:{onDrop:ne(`DIMENSION`)},modifiers:f}),{dndState:se}=uJ(),ce=!!se.active,le=se.active?.identifier?.type,ue=(e,t)=>{if(!ce)return{state:`idle`};if(e===`DIMENSION`?[`dimensions`,`aggregate_dimensions`].includes(le||``):[`metrics`,`aggregate_metrics`].includes(le||``))return{state:t?`over`:`armed`};let n=_Q({chartType:m.chartType,target:e,selectedDims:r,selectedMetrics:a,sourceType:le});return n.canDrop?{state:t?`over`:`armed`}:t?{state:`rejected`,refusal:n.warning}:{state:`idle`}},de=ue(`METRIC`,ie.isDragOver),fe=ue(`DIMENSION`,oe.isDragOver),pe=de.state===`rejected`?de.refusal:void 0,me=fe.state===`rejected`?fe.refusal:void 0,he=_Q({chartType:m.chartType,target:`DIMENSION`,selectedDims:r,selectedMetrics:a,sourceType:`column`}),ge=_Q({chartType:m.chartType,target:`METRIC`,selectedDims:r,selectedMetrics:a,sourceType:`column`}),_e=he.canDrop,ve=ge.canDrop,ye=e?`No columns available`:`Pick a table to see columns`,be=(t,n)=>{e&&o({column:n,table:e,sorting:void 0,identifier:{id:n.name,type:`column`},type:t})};return(0,i.jsxs)(`div`,{...R8(`field-zones`),className:KH(`flex w-full flex-col gap-2`,x),children:[(0,i.jsxs)(`div`,{className:fOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`measures`,`label`),className:pOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`measures`,`accepts`),className:`flex size-3 shrink-0 items-center justify-center`,children:[(0,i.jsx)(bhn,{"aria-hidden":`true`,className:`size-3`}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Accepts number columns.`})]}),`Measures`]}),(0,i.jsxs)(`div`,{ref:re,...R8(`field-zone`,`measures`),className:KH(mOr,hOr[de.state]),children:[pe?(0,i.jsxs)(`span`,{...R8(`field-zone`,`measures`,`refused`),className:_Or,children:[(0,i.jsx)(UQ,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,i.jsx)(`span`,{className:`truncate`,children:pe})]}):null,a.length===0&&!pe?(0,i.jsx)(`span`,{...R8(`field-zone`,`measures`,`empty`),className:gOr,children:yOr}):null,a.map((e,t)=>(0,i.jsx)(sOr,{column:e,type:`METRIC`,zoneId:`measures`,index:t,functionOptions:d,onChangeHelperFunction:l,onChangeAlias:u,onRemove:()=>s({column:e,type:`METRIC`}),isPartitionByColumnEnabled:te,partitionColumnList:g,selectedDims:r,dbName:h},e.uniqueId||e.alias)),(0,i.jsx)(dOr,{columns:t,onSelectColumn:e=>be(`METRIC`,e),triggerAriaLabel:`Add a measure`,zoneId:`measures`,disabled:!ve,disabledReason:ge.warning,emptyLabel:ye,defaultOpen:_,className:`ml-auto`})]}),(0,i.jsxs)(`div`,{className:vOr,children:[(0,i.jsx)(`button`,{type:`button`,...L8(`field-zone`,`measures`,`calculated-field`),"aria-label":`Add a calculated field`,"aria-disabled":!ee,title:ee?`Add a calculated field`:`Add a measure to Measures to enable calculated fields.`,onClick:()=>{ee&&(T(void 0),C(!0))},className:KH(`flex size-6 shrink-0 items-center justify-center rounded-(--radius-sm) border border-(--border) text-(--muted-foreground) transition-colors hover:bg-(--accent) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,!ee&&`cursor-not-allowed opacity-50 hover:bg-transparent`),children:(0,i.jsx)(vgn,{"aria-hidden":`true`,className:`size-3.5`})}),b?(0,i.jsx)(Xsn,{props:{isDisabled:!ee,columnOptions:y,isHovered:!1,type:`METRIC`,onSaveArithMetricOption:b,customColumn:`METRIC`,isOpenCalculatedPanel:S,setOpenCalculatedPanel:C,editColumn:w,setEditCol:T}}):null]})]}),(0,i.jsxs)(`div`,{className:fOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`dimensions`,`label`),className:pOr,children:[(0,i.jsxs)(`span`,{...R8(`field-zone`,`dimensions`,`accepts`),className:`flex size-3 shrink-0 items-center justify-center`,children:[(0,i.jsx)(Bmn,{"aria-hidden":`true`,className:`size-3`}),(0,i.jsx)(`span`,{className:`sr-only`,children:`Accepts any column.`})]}),`Dimensions`]}),(0,i.jsxs)(`div`,{ref:ae,...R8(`field-zone`,`dimensions`),className:KH(mOr,hOr[fe.state]),children:[me?(0,i.jsxs)(`span`,{...R8(`field-zone`,`dimensions`,`refused`),className:_Or,children:[(0,i.jsx)(UQ,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,i.jsx)(`span`,{className:`truncate`,children:me})]}):null,r.length===0&&!me?(0,i.jsx)(`span`,{...R8(`field-zone`,`dimensions`,`empty`),className:gOr,children:bOr}):null,r.map((e,t)=>(0,i.jsx)(sOr,{column:e,type:`DIMENSION`,zoneId:`dimensions`,index:t,functionOptions:d,onChangeHelperFunction:l,onChangeAlias:u,onRemove:()=>s({column:e,type:`DIMENSION`})},e.uniqueId||e.alias)),(0,i.jsx)(dOr,{columns:t,onSelectColumn:e=>be(`DIMENSION`,e),triggerAriaLabel:`Add a dimension`,zoneId:`dimensions`,disabled:!_e,disabledReason:he.warning,emptyLabel:ye,defaultOpen:v,className:`ml-auto`})]}),(0,i.jsx)(`div`,{"aria-hidden":`true`,className:vOr})]})]})}})),q9,DOr,OOr,kOr=h((()=>{r$(),t1n(),KDr(),q9=({children:e})=>(0,i.jsx)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col items-center justify-center overflow-hidden p-6`,children:e}),DOr=({onAddField:e,qaEntity:t=`preview-pane`,headline:n=`Build your first view`,hint:r=(0,i.jsx)(i.Fragment,{children:`Drag a field from the list on the left into Measures (the numbers you want) or Dimensions (how to break them down). The answer renders here as you build it.`})})=>(0,i.jsxs)(`div`,{"data-testid":`card-empty-state`,"data-slot":`create-metric-empty`,className:`flex max-w-sm flex-col items-center gap-3 text-center`,children:[(0,i.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--radius-lg) bg-(--muted)`,children:(0,i.jsx)(Mhn,{className:`size-6 text-(--muted-foreground)`,"aria-hidden":`true`})}),(0,i.jsx)(`h2`,{className:`text-sm font-medium text-(--foreground)`,children:n}),(0,i.jsx)(`p`,{...K9(t,`empty-hint`),className:`text-xs text-(--muted-foreground)`,children:r}),e?(0,i.jsxs)(H6,{type:`button`,variant:`primary`,size:`sm`,...G9(t,`empty-add-field`),onClick:e,children:[(0,i.jsx)(ign,{"aria-hidden":`true`}),(0,i.jsx)(`span`,{children:`Add a field`})]}):null]}),OOr=({qaEntity:e=`preview-pane`})=>(0,i.jsx)(`p`,{...K9(e,`no-data-hint`),className:`mt-1 max-w-xs text-center text-xs text-(--muted-foreground)`,children:`The query ran, but nothing matched. Try relaxing a filter, raising the row limit, or grouping by a different field.`})}));function AOr(e){return Object.keys(e[0]??{}).map(t=>{let n=!1;for(let r of e){let e=r?.[t];if(e!=null&&e!==``){n=typeof e==`number`;break}}return{key:t,label:t,isNumeric:n}})}function jOr(e,t,n){let r=e==null||e===``,i=t==null||t===``;return r&&i?0:r?1:i?-1:n?e-t:String(e).localeCompare(String(t))}var MOr,NOr,POr,FOr=h((()=>{r$(),yAn(),KDr(),MOr=10,NOr=[10,25,50,75,100,250,500,1e3],POr=({rows:e,qaEntity:t})=>{let n=x.useMemo(()=>AOr(e),[e]),[r,a]=x.useState(``),o=x.useMemo(()=>{let t=r.trim().toLocaleLowerCase();return t?e.filter(e=>n.some(n=>String(e[n.key]??``).toLocaleLowerCase().includes(t))):e},[e,n,r]),[s,l]=x.useState(null),u=s&&n.some(e=>e.key===s.key)?s:null,d=x.useMemo(()=>{if(!u)return o;let e=n.find(e=>e.key===u.key),t=o.map((e,t)=>({row:e,index:t}));return t.sort((t,n)=>{let r=jOr(t.row?.[u.key],n.row?.[u.key],!!e?.isNumeric),i=t.row?.[u.key],a=n.row?.[u.key],o=i==null||i===``||a==null||a===``||u.direction===`asc`?r:-r;return o===0?t.index-n.index:o}),t.map(e=>e.row)},[o,u,n]);function f(e){l(t=>!t||t.key!==e?{key:e,direction:`asc`}:t.direction===`asc`?{key:e,direction:`desc`}:null),g(0)}let[p,m]=x.useState(MOr),[h,g]=x.useState(0),_=d.length,v=Math.max(1,Math.ceil(_/p)),y=Math.min(h,v-1),b=_===0?0:p*y+1,S=_<=p*(y+1)?_:p*(y+1),C=b<=1,w=S>=_,T=x.useMemo(()=>d.slice(p*y,p*(y+1)),[d,p,y]);function ee(e){g(Math.floor(p*y/e)),m(e)}let te=G9(t,`page-size`).id;return(0,i.jsxs)(`div`,{...K9(t,`table`),className:`dbn-v2-table flex h-full w-full flex-col overflow-hidden`,children:[(0,i.jsx)(`div`,{className:`flex shrink-0 justify-end border-b border-(--border) p-3`,children:(0,i.jsx)(vAn,{...G9(t,`search`),type:`search`,"aria-label":`Search table`,placeholder:`Search`,autoComplete:`off`,className:`max-w-64`,value:r,onChange:e=>{a(e.target.value),g(0)}})}),(0,i.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,i.jsxs)(`table`,{children:[(0,i.jsx)(`thead`,{children:(0,i.jsx)(`tr`,{children:n.map(e=>{let n=u?.key===e.key?u.direction:null;return(0,i.jsx)(`th`,{scope:`col`,"aria-sort":n===`asc`?`ascending`:n===`desc`?`descending`:`none`,className:e.isNumeric?`dbn-num`:void 0,children:(0,i.jsxs)(`button`,{type:`button`,...G9(t,`sort`,e.key),onClick:()=>f(e.key),className:`inline-flex items-center gap-1 rounded-(--radius-xs) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:[e.label,n===`asc`?(0,i.jsx)(Xpn,{"aria-hidden":`true`,className:`size-3`}):n===`desc`?(0,i.jsx)(Hpn,{"aria-hidden":`true`,className:`size-3`}):(0,i.jsx)(HQ,{"aria-hidden":`true`,className:`size-3 opacity-40`})]})},e.key)})})}),(0,i.jsxs)(`tbody`,{children:[_===0?(0,i.jsx)(`tr`,{children:(0,i.jsx)(`td`,{colSpan:Math.max(1,n.length),children:`No matching rows.`})}):null,T.map((e,t)=>(0,i.jsx)(`tr`,{children:n.map(t=>(0,i.jsx)(`td`,{className:t.isNumeric?`dbn-num`:void 0,children:String(e?.[t.key]??``)},t.key))},JSON.stringify({row:e,rowIndex:t})))]})]})}),_>0?(0,i.jsxs)(`fieldset`,{...K9(t,`pagination`),"aria-label":`Table pagination`,className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-(--border) px-3 py-1.5 text-xs text-(--muted-foreground)`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(`label`,{htmlFor:te,className:`text-(--muted-foreground)`,children:`Rows per page`}),(0,i.jsx)(`select`,{...G9(t,`page-size`),value:p,onChange:e=>ee(Number(e.target.value)),className:`h-6 cursor-pointer rounded-(--radius-sm) border border-(--border) bg-(--muted) px-1.5 text-xs text-(--foreground) transition-colors hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:cursor-not-allowed disabled:opacity-50`,children:NOr.map(e=>(0,i.jsxs)(`option`,{value:e,children:[`Show `,e]},e))})]}),(0,i.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`flex items-center gap-2`,children:[(0,i.jsxs)(`span`,{children:[b,`-`,S,` of `,_]}),(0,i.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`first`),"aria-label":`First page`,disabled:C,onClick:()=>g(0),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(jmn,{"aria-hidden":`true`,className:`size-3.5`})}),(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`prev`),"aria-label":`Previous page`,disabled:C,onClick:()=>g(Math.max(0,y-1)),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(JQ,{"aria-hidden":`true`,className:`size-3.5`})}),(0,i.jsxs)(`span`,{className:`px-1 tabular-nums`,children:[y+1,` of `,v]}),(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`next`),"aria-label":`Next page`,disabled:w,onClick:()=>g(Math.min(v-1,y+1)),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(YQ,{"aria-hidden":`true`,className:`size-3.5`})}),(0,i.jsx)(`button`,{type:`button`,...G9(t,`pagination`,`last`),"aria-label":`Last page`,disabled:w,onClick:()=>g(v-1),className:`inline-flex size-6 items-center justify-center rounded-(--radius-xs) text-(--muted-foreground) hover:text-(--foreground) focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40`,children:(0,i.jsx)(Pmn,{"aria-hidden":`true`,className:`size-3.5`})})]})]})]}):null]})}}));function IOr(e){return!!e&&BOr.has(e)}var LOr,ROr,zOr,BOr,VOr,HOr,UOr,WOr=h((()=>{qZ(),kOr(),FOr(),xQ(),r$(),Uy(),YZ(),Ay(),Dq(),$3n(),$_(),E6(),B8(),osr(),q8(),W8(),LOr=n.lazy(async()=>({default:(await Promise.resolve().then(()=>(RK(),LK))).DbnChart})),ROr=n.lazy(async()=>({default:(await Promise.resolve().then(()=>(Gor(),Dor))).Chart})),zOr=Object.freeze({isLoading:!1,error:``,data:[],currentValue:``}),BOr=new Set([$.table,$.trendAnalyzer,$.pivot,$.pivotV2,$.pivotV3,$.horizontalStackTable]),VOr=new Set([$.horizontalStackTable,$.pivot,$.treeMap,$.sankey,$.pivotV2,$.pivotV3]),HOr=({data:e,isLoading:t,error:r,errorView:a,chartSettings:o,dimensions:s,metrics:l,isCustomTable:u,isDrillEnableGroupBy:d,drillLevel:f,onDrillLevelClick:p,onResetDrill:m,chartColors:h,chartAppearance:g,appearanceOptions:_,customMessages:v,translationDictionary:y,selectedLanguage:b,noDataImg:x,onAddField:S,colorScheme:C=`light`,onRetry:w,className:T,isActive:ee=!0})=>{let te=n.useMemo(()=>bQ({chartSettings:o,dimensions:s,metrics:l,isCustomTable:u}),[o,s,l,u]),ne=!!e&&e.length>0,re=n.useRef(null);n.useLayoutEffect(()=>{!t&&!r&&ne&&(re.current={rows:e,settings:o})},[o,e,r,ne,t]);let ie=ne?e:re.current?.rows,ae=ne?o:re.current?.settings??o,oe=!!ie&&ie.length>0,se=n.useMemo(()=>({...ae,chartColors:h??ae?.chartColors}),[ae,h]),ce=n.useMemo(()=>!oe||IOr(o.chartType)?null:qle(se,ie),[oe,o.chartType,se,ie]),le=n.useMemo(()=>JZ(g,{...KZ(se?.customSettings),tooltipSettings:se?.tooltipSettings,categoryField:ce?.type===`gaugeV2`?null:se?.xAxis,chartZoom:se?.customSettings?.chartZoom,percentageSize:se?.percentageSize,repulsion:se?.customSettings?.repulsion,isUseAsDifference:se?.waterfallSettings?.isUseAsDifference}),[g,se,ce?.type]),ue=n.useMemo(()=>IOr(o.chartType)?void 0:Eq(se),[o.chartType,se]),[de,fe]=n.useState(null),pe=q3n(de),me=s.map(e=>e.label||e.alias||e.name),he=oe&&d&&me.length>0&&!VOr.has(o.chartType),ge={customMessages:v,translationDictionary:y,selectedLanguage:b},_e=U8(`Build your first view`,`empty`,void 0,ge),ve;if(r)ve=(0,i.jsx)(q9,{children:(0,i.jsx)(`div`,{className:`contents`,"data-error-code":a?.code,children:(0,i.jsx)(G8,{error:a,message:a?void 0:r,onRetry:w,...ge})})});else if(oe){let e=ie;ve=(0,i.jsxs)(i.Fragment,{children:[he?(0,i.jsx)(UOr,{dimensionLabels:me,drillLevel:f,onDrillLevelClick:p,onResetDrill:m}):null,(0,i.jsxs)(`div`,{...R8(`preview-pane`,`chart-region`),className:`relative min-h-0 w-full flex-1`,children:[IOr(o.chartType)?(0,i.jsx)(POr,{rows:e,qaEntity:`preview-pane`}):ce?(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(q9,{children:(0,i.jsx)(H8,{})}),children:(0,i.jsx)(LOr,{type:ce.type,data:ce.data,appearance:le,applyDensity:Vy(),colorBy:ce.colorBy,valueFormatter:ue,chartColors:se.chartColors,className:`h-full w-full`})}):Qor(o.chartType)?(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(q9,{children:(0,i.jsx)(H8,{})}),children:(0,i.jsx)(`div`,{ref:fe,...R8(`preview-pane`,`legacy-chart`),className:`h-full w-full`,children:(0,i.jsx)(ROr,{chartOptions:se,data:e,chartAppearance:g,colors:se.chartColors,metricCardColor:`transparent`,chartFontSettings:pe,pivotDrillState:zOr,isMetricCard:!0})})}):(0,i.jsx)(q9,{children:(0,i.jsx)(K8,{className:`p-0`,message:`This chart type is no longer available. Pick another type in Configure.`,...ge})}),t?(0,i.jsx)(`div`,{...R8(`preview-pane`,`loading-overlay`),role:`status`,"aria-label":`Refreshing`,className:`absolute inset-0 flex items-center justify-center bg-(--background)/70`,children:(0,i.jsx)(Rhn,{className:`size-5 animate-spin text-(--muted-foreground)`,"aria-hidden":`true`})}):null]})]})}else ve=t?(0,i.jsxs)(q9,{children:[(0,i.jsx)(H8,{}),(0,i.jsx)(`p`,{...R8(`preview-pane`,`loading-hint`),className:`mt-3 text-xs text-(--muted-foreground)`,children:`Running the query...`})]}):te?(0,i.jsx)(q9,{children:(0,i.jsx)(DOr,{onAddField:S,headline:_e})}):(0,i.jsxs)(q9,{children:[(0,i.jsx)(K8,{className:`p-0`,noDataImg:x,...ge}),(0,i.jsx)(OOr,{})]});return(0,i.jsx)(`div`,{...R8(`preview-pane`),className:KH(`flex min-h-0 w-full flex-1 flex-col overflow-hidden`,T),children:ee?ve:null})},UOr=({dimensionLabels:e,drillLevel:t,onDrillLevelClick:r,onResetDrill:a})=>{let o=t>=e.length,s=``,l=o?[]:e.slice(0,t+1).map((e,t)=>(s=`${s}\u001f${e}`,{id:s,index:t,label:e}));return(0,i.jsxs)(`nav`,{...R8(`preview-pane`,`breadcrumb`),"aria-label":`Drill-down breadcrumb`,className:`flex shrink-0 items-center gap-1 border-b border-(--border) px-3 py-1.5 text-xs`,children:[(0,i.jsx)(`button`,{type:`button`,...L8(`preview-pane`,`breadcrumb`,`reset`),onClick:a,className:`rounded-(--radius-xs) px-1 py-0.5 text-(--muted-foreground) hover:text-(--foreground) hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:`All`}),l.map(({id:e,index:a,label:o})=>{let s=a===t;return(0,i.jsxs)(n.Fragment,{children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`text-(--muted-foreground)`,children:`/`}),s?(0,i.jsx)(`span`,{"aria-current":`step`,className:`font-medium text-(--foreground)`,children:o}):(0,i.jsx)(`button`,{type:`button`,...L8(`preview-pane`,`breadcrumb`,`level`,a),onClick:()=>r(a),className:`rounded-(--radius-xs) px-1 py-0.5 text-(--muted-foreground) hover:text-(--foreground) hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)`,children:o})]},e)})]})}}));function GOr(e){if(!e)return`Chart type`;for(let t of tv)for(let n of t.value)if(String(n.name).toLowerCase()===String(e).toLowerCase())return n.label;return String(e).replace(/\b\w/g,e=>e.toUpperCase())}var KOr,qOr=h((()=>{kOr(),FOr(),xQ(),r$(),my(),F8(),_3n(),E6(),B8(),q8(),W8(),WOr(),KOr=e=>{let{data:t,isLoading:r,error:a,errorView:o,chartSettings:s,dimensions:l,metrics:u,isCustomTable:d,customMessages:f,translationDictionary:p,selectedLanguage:m,noDataImg:h,onAddField:g,onRetry:_,className:v,onOpenChartType:y,isChartTypePanelOpen:b,onToggleFullscreen:x,isFullscreen:S=!1}=e,[C,w]=n.useState(`chart`),T=n.useMemo(()=>bQ({chartSettings:s,dimensions:l,metrics:u,isCustomTable:d}),[s,l,u,d]),ee=t??[],te=ee.length>0,ne={customMessages:f,translationDictionary:p,selectedLanguage:m},re=U8(`Build your first view`,`empty`,void 0,ne),ie;ie=a?(0,i.jsx)(q9,{children:(0,i.jsx)(`div`,{className:`contents`,"data-error-code":o?.code,children:(0,i.jsx)(G8,{error:o,message:o?void 0:a,onRetry:_,...ne})})}):te?(0,i.jsx)(POr,{rows:ee,qaEntity:`preview-table`}):r?(0,i.jsxs)(q9,{children:[(0,i.jsx)(H8,{}),(0,i.jsx)(`p`,{...R8(`preview-table`,`loading-hint`),className:`mt-3 text-xs text-(--muted-foreground)`,children:`Running the query...`})]}):T?(0,i.jsx)(q9,{children:(0,i.jsx)(DOr,{onAddField:g,qaEntity:`preview-table`,headline:re})}):(0,i.jsxs)(q9,{children:[(0,i.jsx)(K8,{className:`p-0`,noDataImg:h,...ne}),(0,i.jsx)(OOr,{qaEntity:`preview-table`})]});let ae=te?Object.keys(ee[0]??{}).length:0,oe;oe=a?``:r&&!te?`Running query...`:te?`${ee.length.toLocaleString()} rows`:`No results yet`;let se=te?`${ee.length.toLocaleString()} ${ee.length===1?`row`:`rows`} × ${ae} ${ae===1?`column`:`columns`}`:`No rows to display`,ce=!a&&!(C===`table`&&te);return(0,i.jsxs)(f3n,{value:C,onValueChange:e=>w(e),...R8(`preview-table`),className:KH(`-mt-2 flex min-h-0 w-full flex-1 flex-col gap-0 overflow-hidden rounded-b-(--radius-md) border border-t-0 border-(--border) bg-(--background)`,v),children:[(0,i.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-(--border) px-2`,children:[(0,i.jsxs)(m3n,{...R8(`preview-table`,`toggle`),className:`shrink-0`,"aria-label":`Preview view`,children:[(0,i.jsxs)(h3n,{value:`chart`,...L8(`preview-table`,`toggle`,`chart`),className:`px-2 text-xs data-[state=active]:border-(--border) group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none`,children:[(0,i.jsx)(GQ,{"aria-hidden":`true`,className:`size-3.5`}),`Chart`]}),(0,i.jsxs)(h3n,{value:`table`,...L8(`preview-table`,`toggle`,`table`),className:`px-2 text-xs data-[state=active]:border-(--border) group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none`,children:[(0,i.jsx)(e$,{"aria-hidden":`true`,className:`size-3.5`}),`Table`]})]}),(0,i.jsx)(`span`,{...R8(`preview-table`,`row-count`),"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-center text-caption tabular-nums text-(--muted-foreground)`,children:oe}),(0,i.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[y?(0,i.jsxs)(B6,{type:`button`,variant:`outline`,size:`sm`,...L8(`preview-table`,`chart-type`),"aria-expanded":b,"aria-label":`Chart type: ${GOr(s?.chartType)}`,onClick:y,className:`h-7 gap-1 border-(--border) bg-(--muted) px-2 text-xs font-medium text-(--muted-foreground) hover:text-(--foreground)`,children:[(0,i.jsx)(`span`,{className:`max-w-30 truncate`,children:GOr(s?.chartType)}),(0,i.jsx)(qQ,{"aria-hidden":`true`,className:`size-3.5`})]}):null,x?(0,i.jsx)(B6,{type:`button`,variant:`outline`,size:`icon-sm`,...L8(`preview-table`,`fullscreen`),"aria-pressed":S,"aria-label":S?`Exit full screen`:`Full screen`,onClick:x,className:`size-7 border-(--border) bg-(--muted) text-(--muted-foreground) hover:text-(--foreground)`,children:S?(0,i.jsx)(Yhn,{"aria-hidden":`true`}):(0,i.jsx)(QQ,{"aria-hidden":`true`})}):null]})]}),(0,i.jsx)(g3n,{value:`chart`,forceMount:!0,hidden:C!==`chart`,className:`flex min-h-0 flex-1 flex-col p-0`,children:(0,i.jsx)(HOr,{...e,isActive:C===`chart`})}),(0,i.jsx)(g3n,{value:`table`,className:`flex min-h-0 flex-1 flex-col p-0`,children:(0,i.jsx)(`div`,{...R8(`preview-table`,`body`),className:`flex min-h-0 w-full flex-1 flex-col overflow-hidden`,children:ie})}),ce?(0,i.jsx)(`div`,{...R8(`preview-table`,`footer`),className:`flex h-7 shrink-0 items-center border-t border-(--border) px-3 text-caption tabular-nums text-(--muted-foreground)`,children:(0,i.jsx)(`span`,{className:`truncate`,children:se})}):null]})}})),JOr,YOr,XOr=h((()=>{PS(),V6(),Z6(),I1n(),E6(),JOr=`text-xs font-medium text-(--foreground)`,YOr=({open:e,onClose:t,onSubmit:r,defaultValues:a,error:o,isSaving:s=!1})=>{let[l,u]=n.useState(``),[d,f]=n.useState(``),[p,m]=n.useState(!1),h=n.useId(),g=n.useId(),_=n.useId(),v=n.useRef(!1);n.useEffect(()=>{e&&!v.current&&(u(a?.name??``),f(a?.description??``),m(!1)),v.current=e},[e,a]);let y=l.trim();return(0,i.jsx)(X6,{open:e,onOpenChange:e=>{!e&&!s&&t()},children:(0,i.jsx)(W6,{className:`sm:max-w-120`,"data-dbn-ui":`v2`,"data-testid":`create-metric-save-dialog`,children:(0,i.jsxs)(`form`,{className:`flex flex-col gap-4`,noValidate:!0,onSubmit:e=>{if(e.preventDefault(),!s){if(!y){m(!0);return}r({name:y,description:d.trim(),metricId:a?.metricId||`${y}_${oS(10)}`},!1)}},children:[(0,i.jsxs)(G6,{children:[(0,i.jsx)(q6,{children:`Save to dashboard`}),(0,i.jsx)(J6,{children:a?.metricId?`Your changes are saved to this metric on the dashboard.`:`The metric is added to the top of this dashboard.`})]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,i.jsx)(`label`,{className:JOr,htmlFor:h,children:`Metric name`}),(0,i.jsx)(s8,{"aria-describedby":p?_:void 0,"aria-invalid":p&&!y,autoComplete:`off`,autoFocus:!0,disabled:s,id:h,onChange:e=>{u(e.target.value),e.target.value.trim()&&m(!1)},placeholder:`For example, Revenue by month`,value:l}),p&&!y?(0,i.jsx)(`p`,{className:`text-xs text-(--destructive)`,id:_,children:`Enter a name for the metric.`}):null]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,i.jsx)(`label`,{className:JOr,htmlFor:g,children:`Description (optional)`}),(0,i.jsx)(`textarea`,{className:KH(`min-h-20 w-full resize-y rounded-(--radius-sm) border border-(--border) bg-(--muted) px-3 py-2 text-sm text-(--foreground) outline-hidden`,`placeholder:text-(--muted-foreground) focus-visible:ring-2 focus-visible:ring-(--ring)/20 disabled:cursor-not-allowed disabled:text-(--muted-foreground)`),disabled:s,id:g,onChange:e=>f(e.target.value),placeholder:`What this metric shows`,rows:3,value:d})]}),o?(0,i.jsx)(`p`,{className:`text-xs text-(--destructive)`,role:`alert`,children:o}):null,(0,i.jsxs)(K6,{children:[(0,i.jsx)(B6,{disabled:s,onClick:t,type:`button`,variant:`ghost`,children:`Cancel`}),(0,i.jsx)(B6,{"data-testid":`create-metric-save-submit`,disabled:s,type:`submit`,variant:`primary`,children:s?`Saving`:`Save`})]})]})})})}})),ZOr=_({CreateMetricV2:()=>tkr,default:()=>tkr});function QOr(e,t){return e?t?`configure-fields`:`ready-to-save`:`select-table`}var $Or,ekr,J9,tkr,nkr=h((()=>{nDr(),xQ(),my(),sr(),_Xn(),zXn(),P$n(),xV(),zdt(),Dc(),$q(),iDr(),Fi(),E6(),_Dr(),xDr(),UDr(),EOr(),qOr(),XOr(),$Or={"data-dbn-ui":`v2`,"data-dbn-embed-v2":`create-metric`},ekr=(e,t)=>{Oi(e,t)},J9=!1,tkr=e=>{let{clientId:t,companyId:r,isLiveMode:a,externalDashboardId:o,userProvidedDashboardId:s,chartColors:l,colorPalettes:u,setShowMetricCreateModal:d,isShowMetricCreateModal:f,metric:p,metricData:m,workspaceId:h,token:g,clientColumnType:_,tenancyType:v,datasourceId:y,setEditMetric:b,shouldFitFullScreen:x,onServerEvent:S,refetchDashboardData:C,saveDashLayout:w,isIncrementalJoin:T,customChartSettings:ee,showAllChartSettings:te,showChartClickSettings:ne,allowedChartTypes:re,filters:ie}=e,ae=n.useRef(!1),oe=n.useRef(null),se=n.useCallback(e=>{if(e===!1&&ae.current){let e=oe.current==null?0:Math.round(performance.now()-oe.current);LXn(ekr,RXn.CREATE_METRIC_SAVED,{success:!0,latencyMs:e}),ae.current=!1,oe.current=null}d(e)},[d]),{metricConfig:ce,dataset:le}=rDr({clientId:t,companyId:r,isLiveMode:a,externalDashboardId:o,userProvidedDashboardId:s,chartColors:l,colorPalettes:u,isShowMetricCreateModal:f,setShowMetricCreateModal:se,metric:p,metricData:m,workspaceId:h,token:g,clientColumnType:_,tenancyType:v,datasourceId:y,setEditMetric:b,shouldFitFullScreen:x,onServerEvent:S,refetchDashboardData:C,saveDashLayout:w,isIncrementalJoin:T,customChartSettings:ee,showAllChartSettings:te,allowedChartTypes:re,filters:ie}),{isLoading:ue,chartSettings:de,setShowSaveMetricModal:fe,data:pe,error:me,setShowChartCustomProperties:he,isShowChartType:ge,setShowChartType:_e,isShowSaveMetricModal:ve,updateExternalMetric:ye,createExternalMetric:be,saveError:xe,setChartSettings:Se,isShowChartCustomProperties:Ce,setBarRadius:we,isShowSortPanel:Te,setShowSortPanel:Ee,isShowFilters:De,setShowFilters:Oe,isCreatingMetric:Ae,enabledCharts:je,setResetPallete:Me,dbName:Ne,drillDownSettings:Pe,limit:Fe,setLimit:Ie,clickBehaviourConfigs:Le,setClickBehaviourConfigs:Re}=ce,{currentSelectedTable:ze,joinTableOption:Be,setCurrentSelectedTable:Ve,configuration:He,functionOptions:Ue,companySubsetTableList:We,selectedMainTable:Ge,setSelectedMainTable:Ke,selectedDims:qe,selectedMetrics:Je,onDropColumn:Ye,dimModifiers:Xe,metricModifiers:Ze,onChangeAlias:Qe,onChangeHelperFunction:$e,onRemoveColumn:et,selectedTable:tt,createdSorts:nt,setCreatedSorts:rt,filterColumnOptions:it,onApplyFilter:at,onApplySort:ot,sortColumnOptions:st,setCreatedFilters:ct,createdFilters:lt,editorRef:ut,getFilterDropDownType:dt,setChartFields:ft,resetCharSettings:pt,onSelectPivotTable:mt,onChangeDrillDown:ht,drillFilters:gt,selectedJoinColumnOptions:_t,onChangeLimit:vt,onChangeChartType:yt,arithmeticColumnOptions:bt,onSaveArithMetricOption:xt,builderError:St}=le,Ct=n.useMemo(()=>u?u.some(e=>Py(e.colors,l))?u:[{name:`Default`,colors:l??[]},...u]:[{name:`Default`,colors:l??[]}],[l,u]),wt=n.useMemo(()=>!!He.filters.some(e=>e.type!==`client`),[He.filters]),Tt=n.useMemo(()=>bQ({chartSettings:de,dimensions:qe,metrics:Je,isCustomTable:J9}),[de,qe,Je]),Et=n.useCallback(e=>{e===$.pivotV2?(pt(e),mt(e,[])):e===$.table?ft({chartType:e,seriesName:``,isRemoveGroupBy:!0}):[$.line,$.bar,$.stack,$.row,$.horizontalStack].includes(e)&&qe.length===2&&Je.length===1?yt(e):ft({chartType:e});let t=[$.singleValue,$.gaugeV2,$.progressBarV2,$.funnelV2,$.waterfall,$.treeMap].includes(e)&&Je.length>1||[$.rose,$.pie,$.doughnut].includes(e)&&!!qe.length,n=![$.table,$.pivotV2].includes(e)&&!([$.line,$.bar,$.stack,$.row,$.horizontalStack].includes(e)&&qe.length===2&&Je.length===1)&&qe.length>1;(t||n)&&yt(e),_e(!1),S?.(ir,e.toUpperCase().replaceAll(` `,`_`))},[yt,pt,mt,ft,qe,Je,_e,S]),Dt=n.useCallback(e=>{Ke(e),S?.(er,iV(e))},[Ke,S]),Ot=n.useCallback(()=>{S?.($n)},[S]),kt=n.useCallback((e,t)=>{ae.current=!0,oe.current=performance.now(),p?ye(e,t):be(e)},[p,ye,be]);n.useEffect(()=>{if(ae.current&&xe){let e=oe.current==null?0:Math.round(performance.now()-oe.current);LXn(ekr,RXn.CREATE_METRIC_SAVED,{success:!1,latencyMs:e}),ae.current=!1,oe.current=null}},[xe]);let At=n.useCallback(()=>{let e=QOr(Ge,Tt);LXn(ekr,RXn.CREATE_METRIC_ABANDONED,{step:e}),se(!1),b?.(void 0)},[Ge,Tt,se,b]),jt=Ec(),Mt=n.useMemo(()=>N$n(jt.data),[jt.data]),Nt=jt.data?p?Mt.canEditMetric:Mt.canCreateMetric:!0;if(!f||!Nt)return null;let Pt=!!pe,Ft=!!(qe.length||Je.length),It=de.chartColors?.length?de.chartColors:l;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(`div`,{...$Or,style:{display:`contents`},children:[(0,i.jsx)(tDr,{}),(0,i.jsx)(`div`,{"data-testid":`create-metric-v2`,"data-slot":`create-metric-shell`,className:KH(x?`absolute`:`fixed`,`inset-0 z-(--dbn-zIndex-overlay,9999) flex flex-col overflow-hidden bg-(--background) text-(--foreground)`),children:(0,i.jsxs)(gXn,{children:[(0,i.jsx)(bDr,{title:p?`Update Metric`:`Create Metric`,onBack:At,onSave:()=>fe(!0),isLoading:ue,chartSettings:de,dimensions:qe,metrics:Je,isCustomTable:J9,rows:pe,metricName:p?.name,isSaved:!!p}),(0,i.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1`,children:[(0,i.jsx)(HDr,{tableList:We,selectedTable:Ge,onSelectTable:Dt,onSearchFocus:Ot}),(0,i.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col gap-2 overflow-hidden p-3`,children:[(0,i.jsx)(TOr,{table:Ge,columns:Ge?.columnsWithDataType??[],selectedDims:qe,selectedMetrics:Je,onDropColumn:Ye,onRemoveColumn:et,onChangeHelperFunction:$e,onChangeAlias:Qe,functionOptions:Ue,dimModifiers:Xe,metricModifiers:Ze,chartSettings:de,isCustomTable:J9,dbName:Ne,partitionColumnList:_t,arithmeticColumnOptions:bt,onSaveArithMetricOption:xt}),(0,i.jsx)(gDr,{chartSettings:de,hasData:Pt,hasSelectedFields:Ft,isLoading:ue,limit:Fe,setLimit:Ie,onChangeLimit:vt,onOpenFilters:()=>Oe(!0),onOpenSort:()=>Ee(!0),showChartTypeTrigger:!1,onOpenChartType:()=>_e(!0),onOpenChartAppearance:()=>he(!0),hasActiveFilters:wt,hasActiveSort:!!He.orders.length,filtersPanelProps:{token:g,tenancyType:v,globalFilters:ie,clientColumnType:_,clientId:t,joinTableOption:Be,setCurrentSelectedTable:Ve,databaseName:v===`MULTI_DATABASE`&&t||``,dbName:Ne,datasourceId:y,isOpen:De,onClose:()=>Oe(!1),filters:lt,setCreatedFilters:ct,columnOptions:it,getFilterDropDownType:dt,editorRef:ut,workspaceId:h,onApplyFilter:at,savedFilterListOptions:[],currentSelectedTable:ze},sortPanelProps:{currentSelectedTable:ze,joinTableOption:Be,setCurrentSelectedTable:Ve,isOpen:Te,onClose:()=>Ee(!1),createdSorts:nt,setCreatedSorts:rt,columnOptions:st,onApplySort:ot,selectedTable:tt,tableName:Ge?.label||Ge?.alias||Ge?.tableName||``},chartTypePanelProps:{isOpen:ge,onClose:()=>_e(!1),zIndex:9999,inline:!0,enabledCharts:je,resultData:pe,onChartChange:Et,selectedChart:de.chartType,allowedChartTypes:re},chartAppearancePanelProps:{setChartSettings:Se,chartSettings:de,colorPalettes:Ct,isOpen:Ce,onClose:()=>he(!1),setBarRadius:we,setResetPallete:Me,isDisableAction:!1,chartActionProps:{clickBehaviourConfigs:Le,setClickBehaviourConfigs:Re,chartSettings:de,setChartSettings:Se},customChartSettings:ee,showAllChartSettings:te,showChartClickSettings:ne}}),(0,i.jsx)(KOr,{className:`flex-1`,onOpenChartType:()=>_e(!0),isChartTypePanelOpen:ge,data:pe,isLoading:ue,error:me,errorView:eZt(me,St),chartSettings:de,dimensions:qe,metrics:Je,isCustomTable:J9,isDrillEnableGroupBy:Pe.isEnableGroupBy,drillLevel:gt.length||0,onDrillLevelClick:e=>ht({},void 0,void 0,e),onResetDrill:()=>ht({}),chartColors:It})]})]}),(0,i.jsx)(YOr,{open:ve,onClose:()=>fe(!1),onSubmit:kt,error:xe,defaultValues:p?{name:p.name,description:p.description,metricId:p.isCreatedByClient?p.metricId:`update_${p.metricId}_by_${t}_${Date.now()}`}:void 0,isSaving:Ae})]})})]})})}})),rkr,ikr,akr,okr=h((()=>{O6(),oUn(),T6(),E6(),rkr=n.lazy(()=>Promise.resolve().then(()=>(nkr(),ZOr))),ikr=({shouldFitFullScreen:e})=>(0,i.jsx)(`div`,{"data-dbn-ui":`v2`,"data-dbn-embed-v2":`create-metric-loading`,style:{display:`contents`},children:(0,i.jsx)(`div`,{"data-testid":`create-metric-v2-loading`,className:KH(e?`absolute`:`fixed`,`inset-0 z-(--dbn-zIndex-overlay,9999) flex items-center justify-center bg-(--background)`),children:(0,i.jsx)(D6,{})})}),akr=e=>{let{isSectionActive:t}=w6();return t(`embed_ui_v2_create_metric`)?(0,i.jsx)(n.Suspense,{fallback:e.isShowMetricCreateModal?(0,i.jsx)(ikr,{shouldFitFullScreen:e.shouldFitFullScreen}):null,children:(0,i.jsx)(rkr,{...e})}):(0,i.jsx)(aUn,{...e})}})),skr,ckr=h((()=>{YK(),sr(),skr=(e,t)=>{let{mutate:r,isPending:i}=rKt();return{onSaveManageMetrics:(0,n.useCallback)((n,i,a)=>{r({data:{externalMetricIds:n,archiveMetrics:i},token:e},{onSuccess:async e=>{e?.error||(t?.(Un),a())}})},[e]),isLoading:i}}})),lkr,ukr=h((()=>{eTr(),tTr(),R9(),yEr(),ckr(),hY(),sr(),ZK(),TEr(),lkr=({props:{metricList:e,token:t,client:r,companyTenancyType:a,workspaceId:o,chartAppearance:s,colors:l,isOpenModal:u,setOpenModal:d,onServerEvent:f,datasourceId:p,language:m,translationDictionary:h,externalDashboardId:g,companyId:_,refetchDashboardData:v,globalFilters:y,params:b}})=>{let[x,S]=(0,n.useState)([]),[C,w]=(0,n.useState)(``);(0,n.useEffect)(()=>{if(e?.length){let t=(e?.filter(e=>!e?.clientArchivedMetrics?.length))?.map(e=>e?.id);S(t)}},[e]);let{onSaveManageMetrics:T,isLoading:ee}=skr(t,f),{saveLogsAsync:te}=XK(),ne=(0,n.useMemo)(()=>C?e?.filter(e=>!e?.clientArchivedMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(C?.toLowerCase())):e?.filter(e=>!e?.clientArchivedMetrics?.length),[e,C]),re=(0,n.useMemo)(()=>C?e?.filter(e=>e?.clientArchivedMetrics?.length)?.filter(e=>e?.name?.toLowerCase()?.includes(C?.toLowerCase())):e?.filter(e=>e?.clientArchivedMetrics?.length),[e,C]),{containerRef:ie,handleScroll:ae,visibleCount:oe,isLoadingMore:se}=wEr({initialCount:4,incrementCount:4,itemCount:(re?.length||0)+(ne?.length||0),resetKey:JSON.stringify([o,r,C]),isActive:u}),ce=re?.slice(0,oe),le=ne?.slice(0,Math.max(0,oe-(re?.length||0)));return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(TJ,{isOpen:u,onClose:()=>{f?.(Vn),d(!1)},headerTitle:`Manage Metrics`,children:[(0,i.jsxs)(ZZ,{className:O9.manageMetricContainer,direction:`col`,children:[(0,i.jsx)(F7,{setSearchKeyword:w,className:`dbn:w-full`}),(0,i.jsxs)(ZZ,{containerRef:ie,onScroll:ae,direction:`row`,className:`dbn:overflow-y-auto dbn:gap-2 dbn:flex-wrap dbn:flex-1 dbn:min-h-0 dbn:content-start dbn:pb-3`,children:[ce?.map(e=>{let n=x?.includes(e?.id);return(0,i.jsxs)(`div`,{className:`${O9.manageMetricCard} ${n?`dbn-manage-metric-card ${O9.borderPrimary}`:``}`,onClick:()=>{S(n?t=>t.filter(t=>t!==e?.id):t=>[...t?.filter(t=>t!==e?.id),e?.id])},"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{S(t?t=>[...t?.filter(t=>t!==e?.id),e?.id]:t=>t.filter(t=>t!==e?.id))}})]}),H9(e)?(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:V9}):null,(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a,globalFilters:y,param:b?.find(t=>t?.metricId===e?.metricId)})})]},e?.id)}),le?.map(e=>{let n=x?.includes(e?.id);return(0,i.jsxs)(`div`,{className:`${O9.manageMetricCard} ${n?`dbn-manage-metric-card ${O9.borderPrimary}`:``}`,onClick:()=>{S(n?t=>t.filter(t=>t!==e?.id):t=>[...t?.filter(t=>t!==e?.id),e?.id])},"data-testid":`manageCard-${e?.name?.toLowerCase().replaceAll(` `,`-`)}`,children:[(0,i.jsxs)(ZZ,{direction:`row`,className:`dbn:justify-between dbn:items-center`,children:[(0,i.jsx)(`div`,{className:`dbn:w-[90%] dbn:truncate`,children:(0,i.jsx)(xa,{variant:`heading-5`,color:`primary`,display:`inline-truncate`,children:e?.name})}),(0,i.jsx)(y$,{checked:n,onChange:({target:{checked:t}})=>{S(t?t=>[...t?.filter(t=>t!==e?.id),e?.id]:t=>t.filter(t=>t!==e?.id))}})]}),H9(e)?(0,i.jsx)(xa,{variant:`body-text-3`,color:`primary`,children:V9}):null,(0,i.jsx)(`div`,{className:`dbn:w-full dbn:h-[90%]`,id:e.id,style:{pointerEvents:`none`},children:(0,i.jsx)(k9,{token:t,language:m,translationDictionary:h,datasourceId:p,chartAppearance:s,workspaceId:o,guestToken:t,isFrontendApp:!1,metricItem:e,client:r,colors:l,companyTenancyType:a,globalFilters:y,param:b?.find(t=>t?.metricId===e?.metricId)})},e.id)]},e?.id)}),se&&(0,i.jsx)(ZZ,{className:`dbn:w-full dbn:pb-6`,children:(0,i.jsx)(D6,{})})]})]}),(0,i.jsxs)(EJ,{children:[(0,i.jsx)(Xs,{variant:`tab`,onClick:()=>{f?.(Vn),d(!1)},className:`cta-secondary`,children:`Discard`}),(0,i.jsx)(Xs,{variant:`primary`,onClick:()=>{let n=e?.filter(e=>!x.includes(e?.id)&&!e?.clientArchivedMetrics?.length)?.map(e=>e?.id);T(x,n,async()=>{await te({clientId:r,data:{companyId:_,feature:`MANAGE_METRIC`,dashboardId:g},isFrontendApp:!1,token:t}),await v?.(),d(!1)})},isDisabled:ee||!e?.length,className:`cta-primary`,children:`Save`})]})]})})}})),dkr,fkr,pkr,mkr,hkr,gkr,_kr,vkr,ykr,bkr,xkr,Skr,Ckr,wkr,Tkr,Ekr,Y9,Dkr,Okr,kkr,Akr,jkr,Mkr=h((()=>{yEr(),dkr=e=>e?.elementSettings?.elementType?.value||(e?.elementSettings?.summary?.metricList?.length?`metricSummary`:`customTextBox`),fkr=e=>!e?.isMetric&&dkr(e)===`customTextBox`,pkr=e=>!e?.clientArchivedMetrics?.length,mkr=e=>e.replace(/<[^>]*>/g,` `).replace(/ /g,` `).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\s+/g,` `).trim(),hkr=e=>{let t=e.match(/^(\p{Extended_Pictographic}(?:️|\p{Extended_Pictographic}|\p{Emoji_Modifier}|[\u{1F3FB}-\u{1F3FF}])*)\s*/u);return t?{emoji:t[1],rest:e.slice(t[0].length).trim()}:{emoji:``,rest:e}},gkr=e=>(e?.name??``).trim()||mkr(e?.elementSettings?.textBox?.text??``)||`Untitled card`,_kr=(e,t)=>{let{emoji:n,rest:r}=hkr(gkr(e));return{id:String(e?.id??``),kind:t,label:r||gkr(e),emoji:n,description:mkr(e?.description??``),isUnpublished:H9(e),chartType:(e?.chartOptions?.chartType??``).toLowerCase()}},vkr=e=>e.map((e,t)=>({item:e,index:t})).sort((e,t)=>{let n=e.item?.resizeAttributes?.yAxis??0,r=t.item?.resizeAttributes?.yAxis??0;if(n!==r)return n-r;let i=e.item?.resizeAttributes?.xAxis??0,a=t.item?.resizeAttributes?.xAxis??0;return i===a?e.index-t.index:i-a}).map(e=>e.item),ykr=e=>{let t=[],n={header:null,children:[]};return vkr(e).forEach(e=>{if(e?.id){if(fkr(e)){(n.header||n.children.length)&&t.push(n),n={header:_kr(e,`section`),children:[]};return}n.children.push(_kr(e,e?.isMetric?`metric`:`element`))}}),(n.header||n.children.length)&&t.push(n),t},bkr=(e,t)=>`${e.emoji} ${e.label} ${e.description}`.toLowerCase().includes(t),xkr=(e,t)=>{let n=t.trim().toLowerCase();return n?e.map(e=>{if(e.header&&bkr(e.header,n))return{header:e.header,children:[...e.children]};let t=e.children.filter(e=>bkr(e,n));return t.length?{header:e.header,children:t}:null}).filter(e=>e!==null):e.map(e=>({...e}))},Skr=e=>e.header?[e.header.id,...e.children.map(e=>e.id)]:e.children.map(e=>e.id),Ckr=(e,t)=>{let n=Skr(e);if(!n.length)return`unchecked`;let r=n.filter(e=>t.has(e)).length;return r===0?`unchecked`:r===n.length?`checked`:`indeterminate`},wkr=(e,t)=>{let n=new Set(t),r=Skr(e),i=Ckr(e,t)!==`checked`;return r.forEach(e=>{i?n.add(e):n.delete(e)}),n},Tkr=(e,t)=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n},Ekr=e=>new Set(e.filter(e=>!!e?.id&&pkr(e)).map(e=>String(e.id))),Y9=e=>e.filter(e=>!!e?.id).map(e=>String(e.id)),Dkr=(e,t)=>({publish:Y9(e).filter(e=>t.has(e)),archive:e.filter(e=>!!e?.id&&!t.has(String(e.id))&&pkr(e)).map(e=>String(e.id))}),Okr=(e,t)=>{let n=Ekr(e);return n.size===t.size&&Y9(e).every(e=>n.has(e)===t.has(e))},kkr=e=>`${e} ${e===1?`card`:`cards`}`,Akr=[[`table`,[`table`,`pivot`]],[`map`,[`map`,`indian states`]],[`funnel`,[`funnel`,`sankey`,`waterfall`]],[`number`,[`single value`,`gauge`,`progress bar`,`linear gauge`]],[`pie`,[`pie`,`doughnut`,`rose`,`tree map`]],[`scatter`,[`scatter`,`bubble`,`radar`,`boxplot`,`network`]],[`area`,[`area`]],[`line`,[`line`,`stepped`,`time series`,`trend analyzer`]],[`bar`,[`bar`,`stack`,`row`,`histogram`,`combo`]]],jkr=(e,t)=>{if(e!==`metric`)return`element`;let n=t.trim().toLowerCase(),r=Akr.find(([,e])=>e.some(e=>n.includes(e)));return r?r[0]:`bar`}})),Nkr,Pkr,Fkr,Ikr,Lkr,Rkr=h((()=>{yEr(),jH(),r$(),V6(),Y$n(),Z6(),I1n(),E6(),B8(),Mkr(),Nkr={bar:GQ,line:dmn,area:omn,pie:mmn,table:e$,number:dhn,map:Whn,funnel:ZQ,scatter:_mn,element:Cgn},Pkr=({state:e})=>(0,i.jsx)(J$n,{"aria-hidden":`true`,tabIndex:-1,checked:e===`indeterminate`?`indeterminate`:e===`checked`,className:KH(`pointer-events-none`,e===`indeterminate`&&`[&_svg]:hidden after:h-0.5 after:w-2 after:rounded-full after:bg-current`)}),Fkr=()=>(0,i.jsx)(`div`,{className:`px-2 py-2`,children:(0,i.jsx)(AH,{label:`Loading cards`,minHeight:237,"data-testid":`manage-metrics-loading`})}),Ikr=e=>e.flatMap(e=>{let t=e.header?[{row:e.header,group:e,indented:!1}]:[],n=e.children.map(t=>({row:t,indented:!!e.header}));return[...t,...n]}),Lkr=({open:e,onOpenChange:t,items:r,onSave:a,onDismiss:o,loading:s=!1})=>{let[l,u]=n.useState(``),[d,f]=n.useState(()=>Ekr(r)),[p,m]=n.useState(0),[h,g]=n.useState(!1),[_,v]=n.useState(``),y=n.useRef(new Map),b=n.useRef(null),x=n.useRef(!1);n.useEffect(()=>{e&&!x.current&&(f(Ekr(r)),u(``),m(0),v(``)),x.current=e},[e,r]);let S=n.useMemo(()=>ykr(r),[r]),C=n.useMemo(()=>xkr(S,l),[S,l]),w=n.useMemo(()=>Ikr(C),[C]),T=n.useMemo(()=>Y9(r).length,[r]),ee=d.size,te=n.useMemo(()=>Okr(r,d),[r,d]),ne=T>0&&ee===0,re=w.length?Math.min(p,w.length-1):0,ie=n.useCallback((e,t)=>{let n=t[e];n&&y.current.get(n.row.id)?.focus()},[]),ae=e=>{f(e?new Set(Y9(r)):new Set),v(``)},oe=e=>{f(t=>e.group?wkr(e.group,t):Tkr(e.row.id,t)),v(``)},se=async()=>{if(h||te)return;let{publish:e,archive:t}=Dkr(r,d);g(!0),v(``);try{await a(e,t)}catch{v(`Could not save your changes. Try again.`)}finally{g(!1)}},ce=()=>{o?.(),t(!1)},le=(e,t)=>{if(!w.length)return;let n=t=>{e.preventDefault();let n=Math.max(0,Math.min(w.length-1,t));m(n),ie(n,w)};if(e.key===`ArrowDown`)return n(t+1);if(e.key===`ArrowUp`)return n(t-1);if(e.key===`Home`)return n(0);if(e.key===`End`)return n(w.length-1);if(e.key===` `||e.key===`Spacebar`){e.preventDefault();let n=w[t];n&&oe(n);return}e.key===`Enter`&&(e.preventDefault(),se())};return(0,i.jsx)(X6,{onOpenChange:e=>e?t(!0):ce(),open:e,children:(0,i.jsx)(W6,{className:`sm:max-w-140`,"data-dbn-embed-v2":`manage-metrics`,"data-dbn-ui":`v2`,"data-testid":`manage-metrics-dialog`,onOpenAutoFocus:e=>{e.preventDefault(),b.current?.focus()},padded:!1,children:(0,i.jsxs)(`div`,{className:`flex flex-col`,children:[(0,i.jsx)(`div`,{className:`px-4 pt-4`,children:(0,i.jsxs)(G6,{children:[(0,i.jsx)(q6,{children:`Manage Metrics`}),(0,i.jsx)(J6,{children:`Choose which cards appear on this dashboard.`})]})}),(0,i.jsxs)(`div`,{className:`relative px-4 pt-3 pb-3`,children:[(0,i.jsx)($Q,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-6 size-3.5 -translate-y-1/2 text-(--muted-foreground)`}),(0,i.jsx)(s8,{"aria-label":`Search cards`,className:`pl-8`,"data-testid":`manage-metrics-search`,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&w.length&&(e.preventDefault(),m(0),ie(0,w))},placeholder:`Search cards`,ref:b,value:l})]}),(0,i.jsxs)(`div`,{className:`max-h-105 overflow-y-auto border-t border-(--border)`,children:[ne&&!s?(0,i.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-(--border) border-b bg-(--muted) px-4 py-2 text-(--muted-foreground) text-xs`,"data-testid":`manage-metrics-all-hidden`,children:[(0,i.jsx)(`span`,{children:`Every card is hidden. This dashboard will be empty.`}),(0,i.jsx)(B6,{className:`ml-auto`,onClick:()=>ae(!0),size:`xs`,type:`button`,variant:`outline`,children:`Show all`})]}):null,s?(0,i.jsx)(Fkr,{}):null,!s&&w.length?(0,i.jsx)(`div`,{"aria-label":`Dashboard cards`,"aria-multiselectable":`true`,className:`flex flex-col gap-px p-2`,"data-testid":`manage-metrics-list`,role:`listbox`,children:w.map((e,t)=>{let{row:n,group:r,indented:a}=e,o=r?Ckr(r,d):d.has(n.id)?`checked`:`unchecked`,s=o!==`unchecked`,l=r?sgn:Nkr[jkr(n.kind,n.chartType)],u=r?r.children.length:0;return(0,i.jsxs)(`div`,{"aria-label":r?`${n.label}, section`:n.label,"aria-selected":s,className:KH(`flex min-h-9 cursor-pointer items-center gap-2 rounded-(--radius-sm) px-2 py-1 outline-hidden`,`hover:bg-(--accent) focus-visible:ring-2 focus-visible:ring-(--ring)`,a&&`pl-8`,!s&&`text-(--muted-foreground)`),"data-testid":I8(`manage-metrics-row`,n.id),onClick:()=>{m(t),oe(e)},onFocus:()=>m(t),onKeyDown:e=>le(e,t),ref:e=>{y.current.set(n.id,e)},role:`option`,tabIndex:t===re?0:-1,children:[(0,i.jsx)(Pkr,{state:o}),n.emoji?(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center text-sm`,children:n.emoji}):(0,i.jsx)(l,{"aria-hidden":`true`,className:KH(`size-3.5 shrink-0`,s?`text-(--muted-foreground)`:`text-(--border)`)}),(0,i.jsxs)(`span`,{className:`min-w-0 flex flex-col`,children:[(0,i.jsx)(`span`,{className:KH(`min-w-0 truncate text-sm`,r?`font-medium`:`font-normal`,s&&`text-(--foreground)`),children:n.label}),n.isUnpublished?(0,i.jsx)(`span`,{className:`text-xs text-(--muted-foreground)`,children:V9}):null]}),r?(0,i.jsx)(`span`,{className:`shrink-0 rounded-(--radius-xs) border border-(--border) px-1.5 text-xs text-(--muted-foreground)`,children:`Section`}):null,n.description?(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-(--muted-foreground)`,children:n.description}):null,r?(0,i.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-(--muted-foreground)`,children:kkr(u)}):null]},n.id)})}):null,!s&&!w.length&&l?(0,i.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-4 py-8`,"data-testid":`manage-metrics-no-results`,children:[(0,i.jsx)(`span`,{className:`text-sm text-(--foreground)`,children:`No cards match "${l}"`}),(0,i.jsxs)(`span`,{className:`text-xs text-(--muted-foreground)`,children:[`Check the spelling, or clear the search to see all`,` ${kkr(T)}`,`.`]}),(0,i.jsx)(B6,{className:`mt-1`,onClick:()=>{u(``),b.current?.focus()},type:`button`,variant:`outline`,children:`Clear search`})]}):null,!s&&!w.length&&!l?(0,i.jsx)(`div`,{className:`px-4 py-8 text-sm text-(--muted-foreground)`,"data-testid":`manage-metrics-empty`,children:`This dashboard has no cards to manage yet.`}):null]}),_?(0,i.jsx)(`div`,{className:`border-t border-(--destructive)/40 bg-(--destructive)/10 px-4 py-2 text-xs text-(--destructive)`,"data-testid":`manage-metrics-save-error`,role:`alert`,children:_}):null,(0,i.jsxs)(K6,{className:`sm:justify-between`,children:[(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(B6,{disabled:h||!T,onClick:()=>ae(!0),type:`button`,variant:`outline`,children:`Show all`}),(0,i.jsx)(B6,{disabled:h||!T,onClick:()=>ae(!1),type:`button`,variant:`outline`,children:`Hide all`})]}),(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(B6,{disabled:h,onClick:ce,type:`button`,variant:`ghost`,children:`Cancel`}),(0,i.jsx)(B6,{"data-testid":`manage-metrics-save`,disabled:h||te,onClick:()=>void se(),type:`button`,variant:`primary`,children:h?`Saving`:`Save`})]})]})]})})})}})),zkr=_({ManageMetricsV2:()=>Bkr,default:()=>Bkr}),Bkr,Vkr=h((()=>{sr(),ZK(),ckr(),Rkr(),Bkr=({metricList:e,token:t,client:r,companyId:a,externalDashboardId:o,isOpenModal:s,setOpenModal:l,onServerEvent:u,refetchDashboardData:d})=>{let{onSaveManageMetrics:f,isLoading:p}=skr(t,u),{saveLogsAsync:m}=XK(),h=n.useRef(null),g=n.useCallback(()=>{let e=h.current;e&&!e.settled&&(h.current=null,e.reject(Error(`manage-metrics-save-failed`)))},[]),_=n.useRef(!1);n.useEffect(()=>{_.current&&!p&&g(),_.current=p},[p,g]);let v=n.useCallback((e,n)=>new Promise((i,s)=>{h.current={reject:s,settled:!1},f(e,n,async()=>{h.current&&(h.current.settled=!0),await m({clientId:r,data:{companyId:a,feature:`MANAGE_METRIC`,dashboardId:o},isFrontendApp:!1,token:t}),await d?.(),h.current=null,l(!1),i()})}),[r,a,o,f,d,m,l,t]),y=n.useCallback(()=>{u?.(Vn)},[u]);return(0,i.jsx)(Lkr,{items:e,onDismiss:y,onOpenChange:l,onSave:v,open:s})}})),Hkr,Ukr,Wkr=h((()=>{ukr(),T6(),Hkr=n.lazy(()=>Promise.resolve().then(()=>(Vkr(),zkr))),Ukr=({props:e})=>{let{isSectionActive:t}=w6();return t(`embed_ui_v2_metric_cards`)?(0,i.jsx)(n.Suspense,{fallback:null,children:(0,i.jsx)(Hkr,{client:e.client,companyId:e.companyId,externalDashboardId:e.externalDashboardId,isOpenModal:e.isOpenModal,metricList:e.metricList,onServerEvent:e.onServerEvent,refetchDashboardData:e.refetchDashboardData,setOpenModal:e.setOpenModal,token:e.token})}):(0,i.jsx)(lkr,{props:e})}})),Gkr,Kkr,qkr,Jkr,Ykr,Xkr,Zkr,Qkr,$kr,eAr,tAr,nAr,rAr,iAr,X9,aAr=h((()=>{Gkr=`_spin_qblzt_1`,Kkr=`_fadeIn_qblzt_1`,qkr=`_CustomDragPreviewContainer_qblzt_1`,Jkr=`_dark_qblzt_1`,Ykr=`_minimapHeaderProgressContainer_qblzt_19`,Xkr=`_justifyBetween_qblzt_23`,Zkr=`_justifyEnd_qblzt_27`,Qkr=`_dashboardName_qblzt_46`,$kr=`_dashboardHeaderRight_qblzt_50`,eAr=`_filter_qblzt_68`,tAr=`_filterButton_qblzt_72`,nAr=`_filterText_qblzt_76`,rAr=`_filterLength_qblzt_80`,iAr=`_pulse_qblzt_1`,X9={"dbn-dashboard":`_dbn-dashboard_qblzt_1`,"dbn-metric":`_dbn-metric_qblzt_1`,"dbn-portal":`_dbn-portal_qblzt_1`,"dbn:pointer-events-none":`_dbn:pointer-events-none_qblzt_1`,"dbn:invisible":`_dbn:invisible_qblzt_1`,"dbn:sr-only":`_dbn:sr-only_qblzt_1`,"dbn:absolute":`_dbn:absolute_qblzt_1`,"dbn:fixed":`_dbn:fixed_qblzt_1`,"dbn:relative":`_dbn:relative_qblzt_1`,"dbn:sticky":`_dbn:sticky_qblzt_1`,"dbn:inset-x-0":`_dbn:inset-x-0_qblzt_1`,"dbn:-top-1":`_dbn:-top-1_qblzt_1`,"dbn:-top-3":`_dbn:-top-3_qblzt_1`,"dbn:top-0":`_dbn:top-0_qblzt_1`,"dbn:top-1":`_dbn:top-1_qblzt_1`,"dbn:top-2":`_dbn:top-2_qblzt_1`,"dbn:-right-6":`_dbn:-right-6_qblzt_1`,"dbn:right-0":`_dbn:right-0_qblzt_1`,"dbn:right-3":`_dbn:right-3_qblzt_1`,"dbn:right-5":`_dbn:right-5_qblzt_1`,"dbn:bottom-0":`_dbn:bottom-0_qblzt_1`,"dbn:bottom-12":`_dbn:bottom-12_qblzt_1`,"dbn:bottom-20":`_dbn:bottom-20_qblzt_1`,"dbn:z-10":`_dbn:z-10_qblzt_1`,"dbn:z-20":`_dbn:z-20_qblzt_1`,"dbn:z-50":`_dbn:z-50_qblzt_1`,"dbn:z-[1]":`_dbn:z-[1]_qblzt_1`,"dbn:z-[19]":`_dbn:z-[19]_qblzt_1`,"dbn:z-[110]":`_dbn:z-[110]_qblzt_1`,"dbn:z-[9999999]":`_dbn:z-[9999999]_qblzt_1`,"dbn:z-base":`_dbn:z-base_qblzt_1`,"dbn:z-elevated":`_dbn:z-elevated_qblzt_1`,"dbn:order-1":`_dbn:order-1_qblzt_1`,"dbn:col-span-1":`_dbn:col-span-1_qblzt_1`,"dbn:col-span-2":`_dbn:col-span-2_qblzt_1`,"dbn:col-span-4":`_dbn:col-span-4_qblzt_1`,"dbn:m-0":`_dbn:m-0_qblzt_1`,"dbn:m-2":`_dbn:m-2_qblzt_1`,"dbn:m-4":`_dbn:m-4_qblzt_1`,"dbn:mx-1":`_dbn:mx-1_qblzt_1`,"dbn:mx-3":`_dbn:mx-3_qblzt_1`,"dbn:mx-auto":`_dbn:mx-auto_qblzt_1`,"dbn:my-0":`_dbn:my-0_qblzt_1`,"dbn:my-3":`_dbn:my-3_qblzt_1`,"dbn:my-5":`_dbn:my-5_qblzt_1`,"dbn:mt-0":`_dbn:mt-0_qblzt_1`,"dbn:mt-1":`_dbn:mt-1_qblzt_1`,"dbn:mt-2":`_dbn:mt-2_qblzt_1`,"dbn:mt-3":`_dbn:mt-3_qblzt_1`,"dbn:mt-4":`_dbn:mt-4_qblzt_1`,"dbn:mt-5":`_dbn:mt-5_qblzt_1`,"dbn:mt-auto":`_dbn:mt-auto_qblzt_1`,"dbn:mr-2":`_dbn:mr-2_qblzt_1`,"dbn:mr-3":`_dbn:mr-3_qblzt_1`,"dbn:mb-1":`_dbn:mb-1_qblzt_1`,"dbn:mb-2":`_dbn:mb-2_qblzt_1`,"dbn:mb-3":`_dbn:mb-3_qblzt_1`,"dbn:mb-4":`_dbn:mb-4_qblzt_1`,"dbn:mb-5":`_dbn:mb-5_qblzt_1`,"dbn:ml-5":`_dbn:ml-5_qblzt_1`,"dbn:ml-[2px]":`_dbn:ml-[2px]_qblzt_1`,"dbn:ml-auto":`_dbn:ml-auto_qblzt_1`,"dbn:block":`_dbn:block_qblzt_1`,"dbn:flex":`_dbn:flex_qblzt_1`,"dbn:grid":`_dbn:grid_qblzt_1`,"dbn:hidden":`_dbn:hidden_qblzt_1`,"dbn:inline-block":`_dbn:inline-block_qblzt_1`,"dbn:inline-flex":`_dbn:inline-flex_qblzt_1`,"dbn:aspect-square":`_dbn:aspect-square_qblzt_1`,"dbn:size-4":`_dbn:size-4_qblzt_1`,"dbn:h-0":`_dbn:h-0_qblzt_1`,"dbn:h-0.5":`_dbn:h-0.5_qblzt_1`,"dbn:h-1.5":`_dbn:h-1.5_qblzt_1`,"dbn:h-2":`_dbn:h-2_qblzt_1`,"dbn:h-2.5":`_dbn:h-2.5_qblzt_1`,"dbn:h-3":`_dbn:h-3_qblzt_1`,"dbn:h-4":`_dbn:h-4_qblzt_1`,"dbn:h-5":`_dbn:h-5_qblzt_1`,"dbn:h-6":`_dbn:h-6_qblzt_1`,"dbn:h-7":`_dbn:h-7_qblzt_1`,"dbn:h-8":`_dbn:h-8_qblzt_1`,"dbn:h-9":`_dbn:h-9_qblzt_1`,"dbn:h-10":`_dbn:h-10_qblzt_1`,"dbn:h-12":`_dbn:h-12_qblzt_1`,"dbn:h-[3px]":`_dbn:h-[3px]_qblzt_1`,"dbn:h-[10%]":`_dbn:h-[10%]_qblzt_1`,"dbn:h-[15%]":`_dbn:h-[15%]_qblzt_1`,"dbn:h-[30%]":`_dbn:h-[30%]_qblzt_1`,"dbn:h-[30px]":`_dbn:h-[30px]_qblzt_1`,"dbn:h-[40px]":`_dbn:h-[40px]_qblzt_1`,"dbn:h-[47px]":`_dbn:h-[47px]_qblzt_1`,"dbn:h-[50px]":`_dbn:h-[50px]_qblzt_1`,"dbn:h-[56px]":`_dbn:h-[56px]_qblzt_1`,"dbn:h-[60px]":`_dbn:h-[60px]_qblzt_1`,"dbn:h-[85%]":`_dbn:h-[85%]_qblzt_1`,"dbn:h-[90%]":`_dbn:h-[90%]_qblzt_1`,"dbn:h-[92%]":`_dbn:h-[92%]_qblzt_1`,"dbn:h-[95%]":`_dbn:h-[95%]_qblzt_1`,"dbn:h-[100%]":`_dbn:h-[100%]_qblzt_1`,"dbn:h-[100vh]":`_dbn:h-[100vh]_qblzt_1`,"dbn:h-[150px]":`_dbn:h-[150px]_qblzt_1`,"dbn:h-[200px]":`_dbn:h-[200px]_qblzt_1`,"dbn:h-[350px]":`_dbn:h-[350px]_qblzt_1`,"dbn:h-[400px]":`_dbn:h-[400px]_qblzt_1`,"dbn:h-[500px]":`_dbn:h-[500px]_qblzt_1`,"dbn:h-[534px]":`_dbn:h-[534px]_qblzt_1`,"dbn:h-[calc(...)]":`_dbn:h-[calc(...)]_qblzt_1`,"dbn:h-[calc(100%-80px)]":`_dbn:h-[calc(100%-80px)]_qblzt_1`,"dbn:h-[calc(100%-130px)]":`_dbn:h-[calc(100%-130px)]_qblzt_1`,"dbn:h-auto":`_dbn:h-auto_qblzt_1`,"dbn:h-fit":`_dbn:h-fit_qblzt_1`,"dbn:h-full":`_dbn:h-full_qblzt_1`,"dbn:h-min":`_dbn:h-min_qblzt_1`,"dbn:h-screen":`_dbn:h-screen_qblzt_1`,"dbn:max-h-[70%]":`_dbn:max-h-[70%]_qblzt_1`,"dbn:max-h-[85%]":`_dbn:max-h-[85%]_qblzt_1`,"dbn:max-h-[100px]":`_dbn:max-h-[100px]_qblzt_1`,"dbn:max-h-[300px]":`_dbn:max-h-[300px]_qblzt_1`,"dbn:max-h-[350px]":`_dbn:max-h-[350px]_qblzt_1`,"dbn:max-h-[400px]":`_dbn:max-h-[400px]_qblzt_1`,"dbn:max-h-fit":`_dbn:max-h-fit_qblzt_1`,"dbn:min-h-0":`_dbn:min-h-0_qblzt_1`,"dbn:min-h-11":`_dbn:min-h-11_qblzt_1`,"dbn:min-h-12":`_dbn:min-h-12_qblzt_1`,"dbn:min-h-32":`_dbn:min-h-32_qblzt_1`,"dbn:min-h-[20px]":`_dbn:min-h-[20px]_qblzt_1`,"dbn:w-1":`_dbn:w-1_qblzt_1`,"dbn:w-1.5":`_dbn:w-1.5_qblzt_1`,"dbn:w-1/2":`_dbn:w-1/2_qblzt_1`,"dbn:w-1/3":`_dbn:w-1/3_qblzt_1`,"dbn:w-1/4":`_dbn:w-1/4_qblzt_1`,"dbn:w-3":`_dbn:w-3_qblzt_1`,"dbn:w-3/4":`_dbn:w-3/4_qblzt_1`,"dbn:w-4":`_dbn:w-4_qblzt_1`,"dbn:w-5":`_dbn:w-5_qblzt_1`,"dbn:w-6":`_dbn:w-6_qblzt_1`,"dbn:w-7":`_dbn:w-7_qblzt_1`,"dbn:w-8":`_dbn:w-8_qblzt_1`,"dbn:w-9":`_dbn:w-9_qblzt_1`,"dbn:w-10":`_dbn:w-10_qblzt_1`,"dbn:w-24":`_dbn:w-24_qblzt_1`,"dbn:w-96":`_dbn:w-96_qblzt_1`,"dbn:w-800":`_dbn:w-800_qblzt_1`,"dbn:w-[1px]":`_dbn:w-[1px]_qblzt_1`,"dbn:w-[3%]":`_dbn:w-[3%]_qblzt_1`,"dbn:w-[3px]":`_dbn:w-[3px]_qblzt_1`,"dbn:w-[10%]":`_dbn:w-[10%]_qblzt_1`,"dbn:w-[15px]":`_dbn:w-[15px]_qblzt_1`,"dbn:w-[30%]":`_dbn:w-[30%]_qblzt_1`,"dbn:w-[30px]":`_dbn:w-[30px]_qblzt_1`,"dbn:w-[40%]":`_dbn:w-[40%]_qblzt_1`,"dbn:w-[49%]":`_dbn:w-[49%]_qblzt_1`,"dbn:w-[60%]":`_dbn:w-[60%]_qblzt_1`,"dbn:w-[65%]":`_dbn:w-[65%]_qblzt_1`,"dbn:w-[70%]":`_dbn:w-[70%]_qblzt_1`,"dbn:w-[80%]":`_dbn:w-[80%]_qblzt_1`,"dbn:w-[85%]":`_dbn:w-[85%]_qblzt_1`,"dbn:w-[90%]":`_dbn:w-[90%]_qblzt_1`,"dbn:w-[96%]":`_dbn:w-[96%]_qblzt_1`,"dbn:w-[97%]":`_dbn:w-[97%]_qblzt_1`,"dbn:w-[100px]":`_dbn:w-[100px]_qblzt_1`,"dbn:w-[120px]":`_dbn:w-[120px]_qblzt_1`,"dbn:w-[150px]":`_dbn:w-[150px]_qblzt_1`,"dbn:w-[170px]":`_dbn:w-[170px]_qblzt_1`,"dbn:w-[180px]":`_dbn:w-[180px]_qblzt_1`,"dbn:w-[200px]":`_dbn:w-[200px]_qblzt_1`,"dbn:w-[250px]":`_dbn:w-[250px]_qblzt_1`,"dbn:w-[300px]":`_dbn:w-[300px]_qblzt_1`,"dbn:w-[400px]":`_dbn:w-[400px]_qblzt_1`,"dbn:w-[500px]":`_dbn:w-[500px]_qblzt_1`,"dbn:w-[600px]":`_dbn:w-[600px]_qblzt_1`,"dbn:w-[750px]":`_dbn:w-[750px]_qblzt_1`,"dbn:w-[775px]":`_dbn:w-[775px]_qblzt_1`,"dbn:w-[800px]":`_dbn:w-[800px]_qblzt_1`,"dbn:w-[cal(100%-80px)]":`_dbn:w-[cal(100%-80px)]_qblzt_1`,"dbn:w-[calc(100%-36px)]":`_dbn:w-[calc(100%-36px)]_qblzt_1`,"dbn:w-[calc(100%-300px)]":`_dbn:w-[calc(100%-300px)]_qblzt_1`,"dbn:w-[inherit]":`_dbn:w-[inherit]_qblzt_1`,"dbn:w-auto":`_dbn:w-auto_qblzt_1`,"dbn:w-fit":`_dbn:w-fit_qblzt_1`,"dbn:w-full":`_dbn:w-full_qblzt_1`,"dbn:w-max":`_dbn:w-max_qblzt_1`,"dbn:w-screen":`_dbn:w-screen_qblzt_1`,"dbn:max-w-[64px]":`_dbn:max-w-[64px]_qblzt_1`,"dbn:max-w-[70%]":`_dbn:max-w-[70%]_qblzt_1`,"dbn:max-w-[84%]":`_dbn:max-w-[84%]_qblzt_1`,"dbn:max-w-[150px]":`_dbn:max-w-[150px]_qblzt_1`,"dbn:max-w-[180px]":`_dbn:max-w-[180px]_qblzt_1`,"dbn:max-w-[200px]":`_dbn:max-w-[200px]_qblzt_1`,"dbn:max-w-[250px]":`_dbn:max-w-[250px]_qblzt_1`,"dbn:max-w-[320px]":`_dbn:max-w-[320px]_qblzt_1`,"dbn:max-w-[400px]":`_dbn:max-w-[400px]_qblzt_1`,"dbn:max-w-full":`_dbn:max-w-full_qblzt_1`,"dbn:max-w-md":`_dbn:max-w-md_qblzt_1`,"dbn:min-w-0":`_dbn:min-w-0_qblzt_1`,"dbn:min-w-4":`_dbn:min-w-4_qblzt_1`,"dbn:min-w-[20px]":`_dbn:min-w-[20px]_qblzt_1`,"dbn:min-w-[200px]":`_dbn:min-w-[200px]_qblzt_1`,"dbn:flex-1":`_dbn:flex-1_qblzt_1`,"dbn:flex-shrink-0":`_dbn:flex-shrink-0_qblzt_1`,"dbn:shrink-0":`_dbn:shrink-0_qblzt_1`,"dbn:flex-grow":`_dbn:flex-grow_qblzt_1`,"dbn:grow":`_dbn:grow_qblzt_1`,"dbn:-rotate-90":`_dbn:-rotate-90_qblzt_1`,"dbn:rotate-90":`_dbn:rotate-90_qblzt_1`,"dbn:rotate-180":`_dbn:rotate-180_qblzt_1`,"dbn:animate-[spin_2s_linear_infinite]":`_dbn:animate-[spin_2s_linear_infinite]_qblzt_1`,spin:Gkr,"dbn:animate-fadeIn":`_dbn:animate-fadeIn_qblzt_1`,fadeIn:Kkr,"dbn:animate-pulse":`_dbn:animate-pulse_qblzt_1`,"dbn:animate-spin":`_dbn:animate-spin_qblzt_1`,"dbn:cursor-auto":`_dbn:cursor-auto_qblzt_1`,"dbn:cursor-grab":`_dbn:cursor-grab_qblzt_1`,"dbn:cursor-not-allowed":`_dbn:cursor-not-allowed_qblzt_1`,"dbn:cursor-pointer":`_dbn:cursor-pointer_qblzt_1`,"dbn:list-none":`_dbn:list-none_qblzt_1`,"dbn:grid-cols-2":`_dbn:grid-cols-2_qblzt_1`,"dbn:grid-cols-3":`_dbn:grid-cols-3_qblzt_1`,"dbn:grid-cols-[1fr_1fr_auto]":`_dbn:grid-cols-[1fr_1fr_auto]_qblzt_1`,"dbn:flex-col":`_dbn:flex-col_qblzt_1`,"dbn:flex-row":`_dbn:flex-row_qblzt_1`,"dbn:flex-row-reverse":`_dbn:flex-row-reverse_qblzt_1`,"dbn:flex-nowrap":`_dbn:flex-nowrap_qblzt_1`,"dbn:flex-wrap":`_dbn:flex-wrap_qblzt_1`,"dbn:flex-wrap-reverse":`_dbn:flex-wrap-reverse_qblzt_1`,"dbn:content-start":`_dbn:content-start_qblzt_1`,"dbn:items-baseline":`_dbn:items-baseline_qblzt_1`,"dbn:items-center":`_dbn:items-center_qblzt_1`,"dbn:items-end":`_dbn:items-end_qblzt_1`,"dbn:items-start":`_dbn:items-start_qblzt_1`,"dbn:items-stretch":`_dbn:items-stretch_qblzt_1`,"dbn:justify-around":`_dbn:justify-around_qblzt_1`,"dbn:justify-between":`_dbn:justify-between_qblzt_1`,"dbn:justify-center":`_dbn:justify-center_qblzt_1`,"dbn:justify-end":`_dbn:justify-end_qblzt_1`,"dbn:justify-evenly":`_dbn:justify-evenly_qblzt_1`,"dbn:justify-start":`_dbn:justify-start_qblzt_1`,"dbn:gap-0":`_dbn:gap-0_qblzt_1`,"dbn:gap-0.5":`_dbn:gap-0.5_qblzt_1`,"dbn:gap-1":`_dbn:gap-1_qblzt_1`,"dbn:gap-1.5":`_dbn:gap-1.5_qblzt_1`,"dbn:gap-2":`_dbn:gap-2_qblzt_1`,"dbn:gap-2.5":`_dbn:gap-2.5_qblzt_1`,"dbn:gap-3":`_dbn:gap-3_qblzt_1`,"dbn:gap-4":`_dbn:gap-4_qblzt_1`,"dbn:gap-5":`_dbn:gap-5_qblzt_1`,"dbn:gap-6":`_dbn:gap-6_qblzt_1`,"dbn:gap-8":`_dbn:gap-8_qblzt_1`,"dbn:gap-10":`_dbn:gap-10_qblzt_1`,"dbn:gap-[3px]":`_dbn:gap-[3px]_qblzt_1`,"dbn:gap-[6px]":`_dbn:gap-[6px]_qblzt_1`,"dbn:gap-[10px]":`_dbn:gap-[10px]_qblzt_1`,"dbn:space-x-4":`_dbn:space-x-4_qblzt_1`,"dbn:gap-y-7":`_dbn:gap-y-7_qblzt_1`,"dbn:truncate":`_dbn:truncate_qblzt_1`,"dbn:overflow-auto":`_dbn:overflow-auto_qblzt_1`,"dbn:overflow-hidden":`_dbn:overflow-hidden_qblzt_1`,"dbn:overflow-x-hidden":`_dbn:overflow-x-hidden_qblzt_1`,"dbn:overflow-y-auto":`_dbn:overflow-y-auto_qblzt_1`,"dbn:rounded":`_dbn:rounded_qblzt_1`,"dbn:rounded-2xl":`_dbn:rounded-2xl_qblzt_1`,"dbn:rounded-full":`_dbn:rounded-full_qblzt_1`,"dbn:rounded-lg":`_dbn:rounded-lg_qblzt_1`,"dbn:rounded-md":`_dbn:rounded-md_qblzt_1`,"dbn:rounded-none":`_dbn:rounded-none_qblzt_1`,"dbn:rounded-xl":`_dbn:rounded-xl_qblzt_1`,"dbn:rounded-t-3xl":`_dbn:rounded-t-3xl_qblzt_1`,"dbn:rounded-l-none":`_dbn:rounded-l-none_qblzt_1`,"dbn:rounded-r-none":`_dbn:rounded-r-none_qblzt_1`,"dbn:rounded-b-none":`_dbn:rounded-b-none_qblzt_1`,"dbn:border":`_dbn:border_qblzt_1`,"dbn:border-0":`_dbn:border-0_qblzt_1`,"dbn:border-[7px]":`_dbn:border-[7px]_qblzt_1`,"dbn:border-x-4":`_dbn:border-x-4_qblzt_1`,"dbn:border-y":`_dbn:border-y_qblzt_1`,"dbn:border-t":`_dbn:border-t_qblzt_1`,"dbn:border-r-0":`_dbn:border-r-0_qblzt_1`,"dbn:border-r-4":`_dbn:border-r-4_qblzt_1`,"dbn:border-b":`_dbn:border-b_qblzt_1`,"dbn:border-b-2":`_dbn:border-b-2_qblzt_1`,"dbn:border-l":`_dbn:border-l_qblzt_1`,"dbn:border-l-0":`_dbn:border-l-0_qblzt_1`,"dbn:border-l-4":`_dbn:border-l-4_qblzt_1`,"dbn:border-dashed":`_dbn:border-dashed_qblzt_1`,"dbn:border-none":`_dbn:border-none_qblzt_1`,"dbn:border-solid":`_dbn:border-solid_qblzt_1`,"dbn:border-[#3d3d3d]":`_dbn:border-[#3d3d3d]_qblzt_1`,"dbn:border-[rgb(0_0_0_/_0.1)]":`_dbn:border-[rgb(0_0_0_/_0.1)]_qblzt_1`,"dbn:border-alert":`_dbn:border-alert_qblzt_1`,"dbn:border-black":`_dbn:border-black_qblzt_1`,"dbn:border-primary":`_dbn:border-primary_qblzt_1`,"dbn:border-primary-title":`_dbn:border-primary-title_qblzt_1`,"dbn:border-secondary":`_dbn:border-secondary_qblzt_1`,"dbn:border-success":`_dbn:border-success_qblzt_1`,"dbn:border-t-txt-link":`_dbn:border-t-txt-link_qblzt_1`,"dbn:border-b-transparent":`_dbn:border-b-transparent_qblzt_1`,"dbn:bg-[#11A064]":`_dbn:bg-[#11A064]_qblzt_1`,"dbn:bg-[#33333366]":`_dbn:bg-[#33333366]_qblzt_1`,"dbn:bg-[#DBEAFE]":`_dbn:bg-[#DBEAFE]_qblzt_1`,"dbn:bg-[#f6f6f6]":`_dbn:bg-[#f6f6f6]_qblzt_1`,"dbn:bg-actionItem-active":`_dbn:bg-actionItem-active_qblzt_1`,"dbn:bg-alert":`_dbn:bg-alert_qblzt_1`,"dbn:bg-alert-light":`_dbn:bg-alert-light_qblzt_1`,"dbn:bg-black":`_dbn:bg-black_qblzt_1`,"dbn:bg-black/[0.1]":`_dbn:bg-black/[0.1]_qblzt_1`,"dbn:bg-blue-500":`_dbn:bg-blue-500_qblzt_1`,"dbn:bg-gray":`_dbn:bg-gray_qblzt_1`,"dbn:bg-gray-50":`_dbn:bg-gray-50_qblzt_1`,"dbn:bg-gray-500":`_dbn:bg-gray-500_qblzt_1`,"dbn:bg-green-100":`_dbn:bg-green-100_qblzt_1`,"dbn:bg-neutral-100":`_dbn:bg-neutral-100_qblzt_1`,"dbn:bg-primary":`_dbn:bg-primary_qblzt_1`,"dbn:bg-primary-title":`_dbn:bg-primary-title_qblzt_1`,"dbn:bg-purple-100":`_dbn:bg-purple-100_qblzt_1`,"dbn:bg-red-100":`_dbn:bg-red-100_qblzt_1`,"dbn:bg-secondary":`_dbn:bg-secondary_qblzt_1`,"dbn:bg-secondary-light":`_dbn:bg-secondary-light_qblzt_1`,"dbn:bg-snow":`_dbn:bg-snow_qblzt_1`,"dbn:bg-success":`_dbn:bg-success_qblzt_1`,"dbn:bg-tertiary":`_dbn:bg-tertiary_qblzt_1`,"dbn:bg-transparent":`_dbn:bg-transparent_qblzt_1`,"dbn:bg-warning":`_dbn:bg-warning_qblzt_1`,"dbn:bg-white":`_dbn:bg-white_qblzt_1`,"dbn:p-0":`_dbn:p-0_qblzt_1`,"dbn:p-1":`_dbn:p-1_qblzt_1`,"dbn:p-1.5":`_dbn:p-1.5_qblzt_1`,"dbn:p-2":`_dbn:p-2_qblzt_1`,"dbn:p-2.5":`_dbn:p-2.5_qblzt_1`,"dbn:p-3":`_dbn:p-3_qblzt_1`,"dbn:p-4":`_dbn:p-4_qblzt_1`,"dbn:p-5":`_dbn:p-5_qblzt_1`,"dbn:p-6":`_dbn:p-6_qblzt_1`,"dbn:p-8":`_dbn:p-8_qblzt_1`,"dbn:p-10":`_dbn:p-10_qblzt_1`,"dbn:px-0":`_dbn:px-0_qblzt_1`,"dbn:px-1":`_dbn:px-1_qblzt_1`,"dbn:px-1.5":`_dbn:px-1.5_qblzt_1`,"dbn:px-2":`_dbn:px-2_qblzt_1`,"dbn:px-3":`_dbn:px-3_qblzt_1`,"dbn:px-4":`_dbn:px-4_qblzt_1`,"dbn:px-5":`_dbn:px-5_qblzt_1`,"dbn:px-6":`_dbn:px-6_qblzt_1`,"dbn:px-10":`_dbn:px-10_qblzt_1`,"dbn:px-[10px]":`_dbn:px-[10px]_qblzt_1`,"dbn:py-0":`_dbn:py-0_qblzt_1`,"dbn:py-0.5":`_dbn:py-0.5_qblzt_1`,"dbn:py-1":`_dbn:py-1_qblzt_1`,"dbn:py-1.5":`_dbn:py-1.5_qblzt_1`,"dbn:py-2":`_dbn:py-2_qblzt_1`,"dbn:py-3":`_dbn:py-3_qblzt_1`,"dbn:py-4":`_dbn:py-4_qblzt_1`,"dbn:py-5":`_dbn:py-5_qblzt_1`,"dbn:py-[10px]":`_dbn:py-[10px]_qblzt_1`,"dbn:pt-0":`_dbn:pt-0_qblzt_1`,"dbn:pt-0.5":`_dbn:pt-0.5_qblzt_1`,"dbn:pt-1":`_dbn:pt-1_qblzt_1`,"dbn:pt-2":`_dbn:pt-2_qblzt_1`,"dbn:pt-3":`_dbn:pt-3_qblzt_1`,"dbn:pt-4":`_dbn:pt-4_qblzt_1`,"dbn:pt-5":`_dbn:pt-5_qblzt_1`,"dbn:pt-6":`_dbn:pt-6_qblzt_1`,"dbn:pt-[2px]":`_dbn:pt-[2px]_qblzt_1`,"dbn:pr-0":`_dbn:pr-0_qblzt_1`,"dbn:pr-3":`_dbn:pr-3_qblzt_1`,"dbn:pr-4":`_dbn:pr-4_qblzt_1`,"dbn:pr-6":`_dbn:pr-6_qblzt_1`,"dbn:pb-0":`_dbn:pb-0_qblzt_1`,"dbn:pb-1":`_dbn:pb-1_qblzt_1`,"dbn:pb-2":`_dbn:pb-2_qblzt_1`,"dbn:pb-3":`_dbn:pb-3_qblzt_1`,"dbn:pb-4":`_dbn:pb-4_qblzt_1`,"dbn:pb-5":`_dbn:pb-5_qblzt_1`,"dbn:pb-6":`_dbn:pb-6_qblzt_1`,"dbn:pb-8":`_dbn:pb-8_qblzt_1`,"dbn:pl-1":`_dbn:pl-1_qblzt_1`,"dbn:pl-2":`_dbn:pl-2_qblzt_1`,"dbn:pl-6":`_dbn:pl-6_qblzt_1`,"dbn:text-center":`_dbn:text-center_qblzt_1`,"dbn:text-left":`_dbn:text-left_qblzt_1`,"dbn:font-sans":`_dbn:font-sans_qblzt_1`,"dbn:text-base":`_dbn:text-base_qblzt_1`,"dbn:text-lg":`_dbn:text-lg_qblzt_1`,"dbn:text-sm":`_dbn:text-sm_qblzt_1`,"dbn:text-xs":`_dbn:text-xs_qblzt_1`,"dbn:text-[10px]":`_dbn:text-[10px]_qblzt_1`,"dbn:text-xxs":`_dbn:text-xxs_qblzt_1`,"dbn:leading-5":`_dbn:leading-5_qblzt_1`,"dbn:leading-6":`_dbn:leading-6_qblzt_1`,"dbn:leading-none":`_dbn:leading-none_qblzt_1`,"dbn:leading-tight":`_dbn:leading-tight_qblzt_1`,"dbn:font-bold":`_dbn:font-bold_qblzt_1`,"dbn:font-medium":`_dbn:font-medium_qblzt_1`,"dbn:font-normal":`_dbn:font-normal_qblzt_1`,"dbn:font-semibold":`_dbn:font-semibold_qblzt_1`,"dbn:tracking-wide":`_dbn:tracking-wide_qblzt_1`,"dbn:break-words":`_dbn:break-words_qblzt_1`,"dbn:whitespace-normal":`_dbn:whitespace-normal_qblzt_1`,"dbn:whitespace-nowrap":`_dbn:whitespace-nowrap_qblzt_1`,"dbn:whitespace-pre-wrap":`_dbn:whitespace-pre-wrap_qblzt_1`,"dbn:text-alert":`_dbn:text-alert_qblzt_1`,"dbn:text-inherit":`_dbn:text-inherit_qblzt_1`,"dbn:text-link-text":`_dbn:text-link-text_qblzt_1`,"dbn:text-primary":`_dbn:text-primary_qblzt_1`,"dbn:text-primary-title":`_dbn:text-primary-title_qblzt_1`,"dbn:text-purple-600":`_dbn:text-purple-600_qblzt_1`,"dbn:text-secondary":`_dbn:text-secondary_qblzt_1`,"dbn:text-text-primary-color":`_dbn:text-text-primary-color_qblzt_1`,"dbn:text-txt-light":`_dbn:text-txt-light_qblzt_1`,"dbn:text-warning-dark":`_dbn:text-warning-dark_qblzt_1`,"dbn:text-white":`_dbn:text-white_qblzt_1`,"dbn:uppercase":`_dbn:uppercase_qblzt_1`,"dbn:not-italic":`_dbn:not-italic_qblzt_1`,"dbn:tabular-nums":`_dbn:tabular-nums_qblzt_1`,"dbn:opacity-60":`_dbn:opacity-60_qblzt_1`,"dbn:opacity-70":`_dbn:opacity-70_qblzt_1`,"dbn:shadow":`_dbn:shadow_qblzt_1`,"dbn:shadow-lg":`_dbn:shadow-lg_qblzt_1`,"dbn:shadow-none":`_dbn:shadow-none_qblzt_1`,"dbn:outline-hidden":`_dbn:outline-hidden_qblzt_1`,"dbn:transition-all":`_dbn:transition-all_qblzt_1`,"dbn:transition-colors":`_dbn:transition-colors_qblzt_1`,"dbn:transition-opacity":`_dbn:transition-opacity_qblzt_1`,"dbn:transition-transform":`_dbn:transition-transform_qblzt_1`,"dbn:duration-200":`_dbn:duration-200_qblzt_1`,"dbn:duration-300":`_dbn:duration-300_qblzt_1`,"dbn:duration-500":`_dbn:duration-500_qblzt_1`,"dbn:ease-out":`_dbn:ease-out_qblzt_1`,"dbn:outline-none":`_dbn:outline-none_qblzt_1`,"dbn:group-data-[open=true]/acc:rotate-180":`_dbn:group-data-[open=true]/acc:rotate-180_qblzt_1`,"dbn:group/acc":`_dbn:group/acc_qblzt_1`,"dbn:before:absolute":`_dbn:before:absolute_qblzt_1`,"dbn:before:inset-0":`_dbn:before:inset-0_qblzt_1`,"dbn:before:content-['']":`_dbn:before:content-['']_qblzt_1`,"dbn:hover:cursor-pointer":`_dbn:hover:cursor-pointer_qblzt_1`,"dbn:hover:border-b":`_dbn:hover:border-b_qblzt_1`,"dbn:hover:border-black":`_dbn:hover:border-black_qblzt_1`,"dbn:hover:border-b-black":`_dbn:hover:border-b-black_qblzt_1`,"dbn:hover:bg-discard-hover":`_dbn:hover:bg-discard-hover_qblzt_1`,"dbn:hover:bg-gray":`_dbn:hover:bg-gray_qblzt_1`,"dbn:hover:bg-gray-3":`_dbn:hover:bg-gray-3_qblzt_1`,"dbn:hover:underline":`_dbn:hover:underline_qblzt_1`,"dbn:hover:underline-offset-4":`_dbn:hover:underline-offset-4_qblzt_1`,"dbn:focus-visible:outline":`_dbn:focus-visible:outline_qblzt_1`,"dbn:focus-visible:outline-2":`_dbn:focus-visible:outline-2_qblzt_1`,"dbn:focus-visible:outline-offset-2":`_dbn:focus-visible:outline-offset-2_qblzt_1`,"dbn:focus-visible:outline-focus":`_dbn:focus-visible:outline-focus_qblzt_1`,"dbn:motion-reduce:animate-none":`_dbn:motion-reduce:animate-none_qblzt_1`,"dbn:motion-reduce:transition-none":`_dbn:motion-reduce:transition-none_qblzt_1`,"dbn-bg-opacity-100":`_dbn-bg-opacity-100_qblzt_1`,"dbn-border-opacity-10":`_dbn-border-opacity-10_qblzt_1`,"getChartOptions-tooltip":`_getChartOptions-tooltip_qblzt_1`,CustomDragPreviewContainer:qkr,"dnd-droppable-highlight":`_dnd-droppable-highlight_qblzt_1`,"droppable-not-allowed":`_droppable-not-allowed_qblzt_1`,"sr-te-live-canvas":`_sr-te-live-canvas_qblzt_1`,dark:Jkr,"ql-size-small":`_ql-size-small_qblzt_1`,"ql-size-large":`_ql-size-large_qblzt_1`,"ql-size-huge":`_ql-size-huge_qblzt_1`,"ql-align-center":`_ql-align-center_qblzt_1`,"ql-align-right":`_ql-align-right_qblzt_1`,"ql-align-left":`_ql-align-left_qblzt_1`,"ql-align-justify":`_ql-align-justify_qblzt_1`,"ql-editor":`_ql-editor_qblzt_1`,"ql-container":`_ql-container_qblzt_1`,"ql-disabled":`_ql-disabled_qblzt_1`,"ql-tooltip":`_ql-tooltip_qblzt_1`,"ql-clipboard":`_ql-clipboard_qblzt_1`,"ql-direction-rtl":`_ql-direction-rtl_qblzt_1`,"ql-indent-1":`_ql-indent-1_qblzt_1`,"ql-indent-2":`_ql-indent-2_qblzt_1`,"ql-indent-3":`_ql-indent-3_qblzt_1`,"ql-indent-4":`_ql-indent-4_qblzt_1`,"ql-indent-5":`_ql-indent-5_qblzt_1`,"ql-indent-6":`_ql-indent-6_qblzt_1`,"ql-indent-7":`_ql-indent-7_qblzt_1`,"ql-indent-8":`_ql-indent-8_qblzt_1`,"ql-indent-9":`_ql-indent-9_qblzt_1`,"ql-video":`_ql-video_qblzt_1`,"ql-bg-black":`_ql-bg-black_qblzt_1`,"ql-bg-red":`_ql-bg-red_qblzt_1`,"ql-bg-orange":`_ql-bg-orange_qblzt_1`,"ql-bg-yellow":`_ql-bg-yellow_qblzt_1`,"ql-bg-green":`_ql-bg-green_qblzt_1`,"ql-bg-blue":`_ql-bg-blue_qblzt_1`,"ql-bg-purple":`_ql-bg-purple_qblzt_1`,"ql-color-white":`_ql-color-white_qblzt_1`,"ql-color-red":`_ql-color-red_qblzt_1`,"ql-color-orange":`_ql-color-orange_qblzt_1`,"ql-color-yellow":`_ql-color-yellow_qblzt_1`,"ql-color-green":`_ql-color-green_qblzt_1`,"ql-color-blue":`_ql-color-blue_qblzt_1`,"ql-color-purple":`_ql-color-purple_qblzt_1`,"ql-font-serif":`_ql-font-serif_qblzt_1`,"ql-font-monospace":`_ql-font-monospace_qblzt_1`,"ql-blank":`_ql-blank_qblzt_1`,"ql-snow":`_ql-snow_qblzt_1`,"ql-toolbar":`_ql-toolbar_qblzt_1`,"ql-image":`_ql-image_qblzt_1`,"ql-active":`_ql-active_qblzt_1`,"ql-picker-label":`_ql-picker-label_qblzt_1`,"ql-picker-item":`_ql-picker-item_qblzt_1`,"ql-selected":`_ql-selected_qblzt_1`,"ql-fill":`_ql-fill_qblzt_1`,"ql-stroke":`_ql-stroke_qblzt_1`,"ql-stroke-miter":`_ql-stroke-miter_qblzt_1`,"ql-hidden":`_ql-hidden_qblzt_1`,"ql-out-bottom":`_ql-out-bottom_qblzt_1`,"ql-out-top":`_ql-out-top_qblzt_1`,"ql-flip":`_ql-flip_qblzt_1`,"ql-formats":`_ql-formats_qblzt_1`,"ql-empty":`_ql-empty_qblzt_1`,"ql-even":`_ql-even_qblzt_1`,"ql-thin":`_ql-thin_qblzt_1`,"ql-transparent":`_ql-transparent_qblzt_1`,"ql-direction":`_ql-direction_qblzt_1`,"ql-syntax":`_ql-syntax_qblzt_1`,"ql-picker":`_ql-picker_qblzt_1`,"ql-picker-options":`_ql-picker-options_qblzt_1`,"ql-expanded":`_ql-expanded_qblzt_1`,"ql-color-picker":`_ql-color-picker_qblzt_1`,"ql-icon-picker":`_ql-icon-picker_qblzt_1`,"ql-header":`_ql-header_qblzt_1`,"ql-font":`_ql-font_qblzt_1`,"ql-size":`_ql-size_qblzt_1`,"ql-background":`_ql-background_qblzt_1`,"ql-color":`_ql-color_qblzt_1`,"ql-preview":`_ql-preview_qblzt_1`,"ql-action":`_ql-action_qblzt_1`,"ql-remove":`_ql-remove_qblzt_1`,"ql-editing":`_ql-editing_qblzt_1`,"dbn-preLineText":`_dbn-preLineText_qblzt_1`,"embedDashboard-container":`_embedDashboard-container_qblzt_10`,"embedDashboard-header":`_embedDashboard-header_qblzt_15`,minimapHeaderProgressContainer:Ykr,justifyBetween:Xkr,justifyEnd:Zkr,"embedDashboard-header-buttons":`_embedDashboard-header-buttons_qblzt_31`,dashboardName:Qkr,dashboardHeaderRight:$kr,"embedDashboard-wrapper":`_embedDashboard-wrapper_qblzt_54`,"embedDashboard-stickyFilters":`_embedDashboard-stickyFilters_qblzt_60`,"alt-container":`_alt-container_qblzt_64`,filter:eAr,filterButton:tAr,filterText:nAr,filterLength:rAr,"export-bottom":`_export-bottom_qblzt_84`,"export-bottom-left":`_export-bottom-left_qblzt_88`,"export-bottom-right":`_export-bottom-right_qblzt_91`,"export-center":`_export-center_qblzt_94`,"export-top":`_export-top_qblzt_98`,"export-top-left":`_export-top-left_qblzt_102`,"export-top-right":`_export-top-right_qblzt_105`,pulse:iAr}})),oAr,sAr,cAr,lAr,Z9,uAr,dAr=h((()=>{Hx(),oAr=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&`startDate`in e&&`endDate`in e,sAr=e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&`min`in e&&`max`in e,cAr=e=>e==null||e===``?!1:Array.isArray(e)?e.length>0:oAr(e)?!!(e.startDate||e.endDate):!sAr(e)||e.min!==null||e.max!==null,lAr=e=>typeof e==`string`?nbe(e):e,Z9=e=>e instanceof Date?e.toISOString():typeof e==`string`?lAr(e):Array.isArray(e)?e.map(Z9):oAr(e)?{startDate:Z9(e.startDate),endDate:Z9(e.endDate)}:e,uAr=({dashboardId:e,filters:t})=>{let n=[],r={},i=new Set;return(Array.isArray(t)?t:[]).forEach(e=>{let t=e?.label?.trim();if(!t||i.has(t)||!cAr(e?.value))return;i.add(t);let a=Z9(e?.value);n.push({label:t,column:e?.column,as:e?.as,value:a}),r[t]={defaultOption:a}}),{dashboardId:e,filters:n,globalFilterOptions:r}}})),fAr,pAr=h((()=>{fAr=({isDashboardReady:e,hasLayoutAction:t,hasDownloadAction:n,hasPdfAction:r,hasManageMetricsAction:i,hasGalleryAction:a})=>e&&(t||n||r||i||a)})),mAr,hAr,gAr,_Ar,vAr,yAr=h((()=>{V2(),mAr=(0,n.lazy)(async()=>({default:(await Promise.resolve().then(()=>(m7t(),d7t))).GlobalFilters})),hAr=(0,n.lazy)(async()=>({default:(await Promise.resolve().then(()=>(BTr(),zTr))).CreateGlobalFilter})),gAr=({children:e,surface:t})=>(0,i.jsx)(B2,{surface:t,fallback:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:min-h-12 dbn:w-full dbn:items-center dbn:justify-center`,"aria-label":`Loading ${t}`,role:`status`,children:[`Loading `,t,`...`]}),children:e}),_Ar=e=>(0,i.jsx)(gAr,{surface:`dashboard filters`,children:(0,i.jsx)(mAr,{...e})}),vAr=e=>(0,i.jsx)(gAr,{surface:`filter editor`,children:(0,i.jsx)(hAr,{...e})})})),bAr,xAr,SAr=h((()=>{V2(),bAr=(0,n.lazy)(()=>Promise.resolve().then(()=>(Hwr(),Bwr))),xAr=({props:e})=>(0,i.jsx)(B2,{surface:`schedule-email`,fallback:(0,i.jsx)(`div`,{className:`dbn:flex dbn:min-h-32 dbn:items-center dbn:justify-center dbn:p-4`,"aria-label":`Loading schedule settings`,role:`status`,children:`Loading schedule settings...`}),children:(0,i.jsx)(bAr,{props:e})})})),CAr,wAr,TAr,EAr,DAr=h((()=>{Fi(),CAr=({sharingSettingsId:e,isAllowedToEmailReports:t,disableScheduleEmailReports:n,showDashboardActions:r,surface:i})=>n?{available:!1,reason:`DISABLED_BY_OPTION`}:e?t?i===`header`&&!r?{available:!1,reason:r===!1?`DASHBOARD_ACTIONS_HIDDEN`:void 0}:{available:!0}:{available:!1,reason:`EMBED_TOGGLE_OFF`}:{available:!1,reason:`SMTP_NOT_CONFIGURED`},wAr={DISABLED_BY_OPTION:`The host page sets disableScheduleEmailReports: true in the dbn-dashboard options.`,SMTP_NOT_CONFIGURED:`Set up SMTP in Settings > Embed & Distribution > Email Settings, then allow end users to schedule email reports on the embed.`,EMBED_TOGGLE_OFF:`Turn on 'Allow end users to schedule email reports' in the embed access settings, or set permissions.isAllowEmailReports in the guest token.`,DASHBOARD_ACTIONS_HIDDEN:`Pass showDashboardActions: true in the dbn-dashboard options to show the action row.`},TAr=new Set,EAr=e=>{TAr.has(e)||(TAr.add(e),console.info(`[Databrain embed] schedule report hidden: ${e}. ${wAr[e]}`),Oi(`dashboard.schedule_report_hidden`,{reason:e}))}})),Q9,$9,OAr,kAr=h((()=>{ks(),Ol(),mue(),R9(),JTr(),ETr(),hEr(),LEr(),BK(),qi(),sr(),xV(),lTr(),n7t(),WB(),vcr(),BEr(),G5t(),fXt(),bcr(),nq(),P$n(),IGt(),WEr(),Zye(),Hx(),WK(),TF(),hJ(),Dc(),KEr(),KK(),Bc(),Sq(),Pgt(),PQt(),gQt(),vJ(),b_t(),zQt(),UQt(),JEr(),AB(),XEr(),eDr(),yJ(),okr(),Wkr(),aAr(),dAr(),hl(),pAr(),SZt(),yAr(),SAr(),DAr(),Q9=e=>{let t=e?.position===`absolute`,n=e?.top?.toString()||e?.bottom?.toString()||e?.left?.toString()||e?.right?.toString();return t&&n},$9=[`#5470c6`,`#91cc75`,`#fac858`,`#ee6666`,`#73c0de`,`#3ba272`,`#fc8452`,`#9a60b4`,`#ea7ccc`],OAr=n.default.memo(({options:e,theme:t,adminThemeOption:r,customMessages:a,themeName:o,setAdminTheme:s,dashboardId:l,globalFilterOptions:u,onServerEvent:d,noDataImg:f,noDataFoundSvg:p,customContent:m,customSettingsBtn:h,chartColumns:g,language:_,translationDictionary:v,hideDashboardFilters:y,calendarType:b=`default`,componentToken:x,customChartSettings:S,chartClickFunction:C,filterStateFunction:w,configId:T})=>{let ee=new URLSearchParams(window.location.search),te=ee.get(`isDbn`),ne=T||ee.get(`configId`),re=ee.get(`embed`),[ie,ae]=(0,n.useState)(window.location.search),oe=(0,n.useRef)(_Zt(window.location.search,e?.legacyUrlState?void 0:l)),[se,ce]=(0,n.useState)({}),le=(0,n.useCallback)((e,t)=>{ce(n=>{if(!t){if(!(e in n))return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]),ue=(0,n.useMemo)(()=>({enabled:!!e?.isModifyUrl,positions:oe.current,onChange:le}),[e?.isModifyUrl,le]),{data:de,isLoading:fe,error:pe,refetch:me}=Ec(),he=(0,n.useContext)(ol),ge=window?.dbn?.isEnableProxyAuth&&de?.token?de?.token||``:x||``,_e=(ge||window?.dbn?.isEnableProxyAuth)&&!fe&&!de?.externalDashboard?.id&&pe?ml(he,pe===`TOKEN_EXPIRED`?`TOKEN_EXPIRED`:`DASHBOARD_LOAD_FAILED`):void 0,ve=Gi();(0,n.useEffect)(()=>{_e&&ve(`dashboard`,{code:_e,message:_e===`TOKEN_EXPIRED`?`The guest token has expired.`:W(he,`admin`)??`The dashboard could not be loaded.`,hint:_e===`TOKEN_EXPIRED`?`Create a new guest token for this viewer.`:void 0,retryable:![`TOKEN_EXPIRED`,`UNAUTHORIZED_ORIGIN`].includes(_e)})},[_e,he,ve]);let ye=(0,n.useRef)(null),be=(0,n.useRef)(null),xe=(0,n.useRef)(null),[Se,Ce]=(0,n.useState)(!1),[we,Te]=(0,n.useState)(1),[Ee,De]=(0,n.useState)(!1),[Oe,Ae]=(0,n.useState)(!1),[je,Me]=(0,n.useState)(!1),[Ne,Pe]=(0,n.useState)(!1),[Fe,Ie]=(0,n.useState)(!1),[Le,Re]=(0,n.useState)(0),[ze,Be]=(0,n.useState)(0),[Ve,He]=(0,n.useState)(!1),[Ue,We]=(0,n.useState)(!1),[Ge,Ke]=(0,n.useState)(!1),[qe,Je]=(0,n.useState)(!1),Ye=YGt(),Xe=XGt(),Ze=(0,n.useMemo)(()=>({isLoading:Xe.isPending,mutate:(e,t)=>Xe.mutate({id:e.id,token:ge},{onSuccess:e=>void t?.onSuccess?.(e),onError:e=>t?.onError?.(e)})}),[Xe.isPending,ge]),Qe=zc({dashboardId:l||``,token:ge,enabled:!!(de?.isAllowedToCreateDashboardFilters&&de?.isAllowedCreateDashboardView)}),{onDownloadMetrics:$e,downloadState:et,cancelDownload:tt,downloadError:nt}=lQt(),{data:rt}=xq(de?.workspace?.id||``),it=!!rt?.isEnable,[at,ot]=(0,n.useState)([]),[st,ct]=(0,n.useState)(),[lt,ut]=(0,n.useState)({show:!1}),[dt,ft]=(0,n.useState)(!1),[pt,mt]=(0,n.useState)(!1),[ht,gt]=(0,n.useState)([]),[_t,vt]=(0,n.useState)({value:``,label:`Default`}),[yt,bt]=(0,n.useState)({width:`200px`,variant:`floating`,radius:`6px`,datePickerFormat:``}),[xt,St]=(0,n.useState)({header:{fontColor:``,bgColor:``,fontWeight:``},content:{fontColor:``,lineGap:``,fontWeight:``}}),[Ct,wt]=(0,n.useState)({width:window.innerWidth,height:window.innerHeight}),[Tt,Et]=(0,n.useState)(!1),[Dt,Ot]=(0,n.useState)({isEnabled:!1,layout:[],filtersLayout:[]}),[kt,At]=(0,n.useState)(()=>{let e=new URLSearchParams(window.location.search).get(`pdfGlobalFilters`);if(e)try{let t=JSON.parse(atob(e));if(t?.filters?.length)return t}catch{}return{tableName:``,filters:[]}}),jt=(0,n.useCallback)(()=>{gt([]),At({tableName:``,filters:[]})},[]),[Mt,Nt]=(0,n.useState)(!1),[Pt,Ft]=(0,n.useState)(),[It,Lt]=(0,n.useState)(),[Rt,zt]=(0,n.useState)(``),Bt=ZGt(),Vt=QGt(),Ht=(0,n.useRef)(new URLSearchParams(window.location.search).has(`pdfGlobalFilters`)||new URLSearchParams(window.location.search).has(`pdfMetricFilters`)||new URLSearchParams(window.location.search).has(`pdfAxisSettings`)),Ut=(0,n.useMemo)(()=>{let e=new URLSearchParams(window.location.search).get(`pdfMetricFilters`);if(e)try{let t=JSON.parse(atob(e));if(t&&typeof t==`object`)return t}catch{}},[]),Wt=(0,n.useMemo)(()=>{let e=new URLSearchParams(window.location.search).get(`pdfAxisSettings`);if(e)try{let t=JSON.parse(atob(e));if(t&&typeof t==`object`)return t}catch{}},[]),[Gt,Kt]=(0,n.useState)(),qt=(0,n.useMemo)(()=>({dashboardFiltersLayout:de?.externalDashboard?.dashboardFiltersLayout??[]}),[de?.externalDashboard?.dashboardFiltersLayout]),{saveLayout:Jt,layout:Yt,isLoadingLayout:Xt,dashboardFiltersLayout:Zt,gridMargin:Qt,hasClientLayout:$t}=PKt({clientId:de?.clientId||``,externalDashboardId:de?.externalDashboard?.id,baseDocument:qt}),{data:en}=L({token:de?.token||``,name:o||``,companyId:de?.companyId||``}),tn=(0,n.useMemo)(()=>e?.renameBoard?.trim()?.split(` `)[0]?.toLowerCase()||`board`,[e?.renameBoard]),nn=(0,n.useMemo)(()=>hQt(en?.theme,r,de?.adminTheme),[r,de?.adminTheme,en]),{anchorRef:rn,colorScheme:an}=RQt(),on=(0,n.useMemo)(()=>MQt(e?.colorScheme,`options.colorScheme`),[e?.colorScheme]),sn=VQt(CQt(an??on,nn)),cn=(0,n.useMemo)(()=>AQt(DQt({explicitColorScheme:an,optionsColorScheme:on,adminThemeOptions:nn,systemPrefersDark:sn})),[nn,an,on,sn]),un=(0,n.useMemo)(()=>cn?_H(cn):void 0,[cn]),dn=(0,n.useMemo)(()=>({primary:t?.button?.primary||nn?.dashboard?.ctaColor||`#0d0d0d`,primaryText:t?.button?.primaryText||nn?.dashboard?.ctaTextColor||`#ffffff`}),[t,nn]),fn=(0,n.useMemo)(()=>t?.multiSelectFilterDropdown?.badgeTextColor||nn?.dashboard?.selectBoxTextColor||`#222c3a`,[t?.multiSelectFilterDropdown?.badgeTextColor,nn]);(0,n.useEffect)(()=>{(dn||fn)&&fc(dn,fn)},[dn,fn]);let pn=(0,n.useMemo)(()=>de?.externalDashboardMetrics?.map(e=>{let t={...e?.externalMetric?.chartOptions,mergedMetrics:void 0,mergedCards:e?.externalMetric?.chartOptions?.mergedMetrics?.firstMetric?[e?.externalMetric?.chartOptions?.mergedMetrics?.firstMetric,e?.externalMetric?.chartOptions?.mergedMetrics?.secondMetric].filter(e=>e)?.map(t=>({value:t,label:e?.data?.externalDashboardMetrics?.find(e=>e.externalMetric?.id===t)?.externalMetric?.name||``})):e?.externalMetric?.chartOptions?.mergedCards};return{...e,externalMetric:{...e.externalMetric,chartOptions:t}}})||[],[de?.externalDashboardMetrics]),mn=()=>{wt({width:window.innerWidth,height:window.innerHeight})};(0,n.useEffect)(()=>(window.addEventListener(`resize`,mn),()=>window.removeEventListener(`resize`,mn)),[]);let hn=(0,n.useMemo)(()=>(Ct.width>=800&&Je(!1),Ct.width<800),[Ct.width]);(0,n.useEffect)(()=>{$Er({ishideSidebar:!de?.isShowSideBar,config:de?.config,dashboardId:l,configId:ne??null,externalDashboardId:de?.externalDashboard?.id??null})},[de?.isShowSideBar,de?.config,de?.externalDashboard?.id,l,ne]),GEr({hasToken:!!ge||!!window?.dbn?.isEnableProxyAuth,isLoading:fe,error:pe,isLoaded:!!de?.externalDashboard?.id,onServerEvent:d});let gn=Oa(),[_n,vn]=(0,n.useState)(!1),[yn,bn]=(0,n.useState)(!1),xn=(0,n.useRef)(null),Sn=(0,n.useCallback)(()=>xn.current?xn.current:(bn(!0),qEr(xn,async()=>{try{await Promise.all([gn.invalidateQueries({queryKey:[ln]}),me?.()])}finally{bn(!1)}})),[gn,me]);(0,n.useEffect)(()=>{if(!de?.refreshTime||_n)return;let e=de.refreshTime*1e3,t=setInterval(()=>{document.visibilityState===`visible`&&Sn()},e);return()=>{clearInterval(t)}},[de?.refreshTime,_n,Sn]);let Cn=(0,n.useMemo)(()=>un?.chart?.palettes?.find(e=>e.name===un?.chart?.selected)?.colors,[un]),wn=(0,n.useMemo)(()=>un?.chart?.palettes?.filter(e=>un?.chart?.paletteOptions?.includes(e?.name)),[un]),Tn=e=>{let t=`${window.location.pathname}?${e}${window.location.hash}`;window.history.replaceState(null,``,t)};(0,n.useEffect)(()=>{e?.hideMetricCardShadow?.toString()?Et(e?.hideMetricCardShadow):nn?.cardCustomization?.disableShadowOnHover?Et(!0):Et(!1)},[nn,e?.hideMetricCardShadow]),(0,n.useEffect)(()=>{if(nn?.dashboard?.selectBoxSize)switch(nn?.dashboard?.selectBoxSize){case`small`:bt(e=>({...e,width:`130px`}));break;case`medium`:bt(e=>({...e,width:`180px`}));break;case`large`:bt(e=>({...e,width:`250px`}));break;default:bt(e=>({...e,width:`200px`}))}let e=nn?.dashboard?.selectBoxVariant;e&&bt(t=>({...t,variant:e}));let t=nn?.dashboard?.selectBoxBorderRadius;t&&bt(e=>({...e,radius:t}));let n=nn?.general?.datePickerFormat;n&&bt(e=>({...e,datePickerFormat:n}));let r=un?.dashboard?.underlyingData;r&&St({header:{fontColor:r?.header?.fontColor||`#0D0D0D`,bgColor:r?.header?.bgColor||`#f9fafb`,fontWeight:r?.header?.fontWeight||`boldfont`,fontSize:wF(r?.header?.fontSize)},content:{fontColor:r?.content?.fontColor||`#222c3a`,lineGap:r?.content?.lineGap||`medium`,fontWeight:r?.content?.fontWeight||`500`,fontSize:wF(r?.content?.fontSize)},showFullSingleValueData:r?.singleValueData||!1,paginationPosition:r?.paginationPosition||`bottom`})},[nn,un]);let En=de?.dashboardAppFilters?.filter(e=>!e?.isShowOnUrl)?.flatMap(e=>Object?.keys(e?.values)?.map(t=>({name:t,value:e.values[t]})))||[],Dn=(0,n.useMemo)(()=>de?.dashboardAppFilters?.find(e=>e?.dashboardId===l)?.values,[l,de?.dashboardAppFilters]),On=(0,n.useMemo)(()=>{let e=de?.clientId||``,t=Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)||Array.isArray(de?.clientSubsetData?.tableList),n=Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)?de?.dashboardFilterClientSubsetData?.tableList||[]:de?.clientSubsetData?.tableList||[],r=cTr({tableList:n,clientColumnType:de?.clientColumnType}),i=(e,t)=>{let r=_x(t?.selectedTable||e?.tableName||``).name,i=n.find(e=>{let t=e?.tableName||e?.name||``;return t===r||_x(t).name===r}),a=i?.columns?.find(e=>(e?.name||e?.columnName||``)===t?.name);return{clientColumn:t?.clientColumn||i?.clientColumn||a?.clientColumn,clientColumnType:t?.clientColumnType||i?.clientColumnType||a?.clientColumnType||de?.clientColumnType}};return(de?.externalDashboard?.filters?.map(n=>{let a=REr({clientId:de?.clientId,tableName:n?.tableName,tenancyLevel:de?.companyTenancyType});return{...n,tableName:a,columns:n?.columns?.filter(i=>{let a=!i?.isCreatedByClient||!i?.clientId||i?.clientId===e,o=de?.hideDashboardFilters?.includes(i?.label)||y?.includes(i?.label),s=!i?.isCreatedByClient||sTr({column:i,isSchemaAccessLoaded:t,tableName:n?.tableName,tenancyLevel:de?.companyTenancyType,schemaList:r});return a&&!o&&s})?.map(t=>{let r=i(n,t),o=Bxe(t,u);return{...t,label:t?.clientLabel||t?.label,originalLabel:t?.label,renameFilterKey:Q5t(n,t),selectedTable:t?.selectedTable||a,applyOnTables:zEr({applyOnTables:t?.applyOnTables,clientId:de?.clientId,tenancyLevel:de?.companyTenancyType}),isClientScoped:t?.isClientScoped||t?.isCreatedByClient&&!!e,clientColumn:r.clientColumn,clientColumnType:r.clientColumnType,isHidden:o?.isHide??!1,defaultValue:Vxe(t,Dn,u,o),isManualOptions:!!o?.options||!!t?.isManualOptions,manualOptions:o?.options||t?.manualOptions||[],datePresetOptions:o?.datePresetOptions?ES(o.datePresetOptions)||t?.datePresetOptions?.map(e=>b===`ind`?{...e||{},isFiscal:!0}:e)||[]:t?.datePresetOptions?.map(e=>b===`ind`?{...e||{},isFiscal:!0}:e)||[]}})||[]}})||[])?.map(e=>{let t=(e?.columns?.filter(e=>e?.isCustomFieldFilter))?.flatMap(e=>(de?.dataMartTables?.find(t=>_x(e?.selectedTable).name===t?.tableName)?.customColumnFields||[])?.map(t=>({...e,name:t?.columnName,label:t?.columnName,applyOnTables:e?.applyOnTables?.map(e=>({...e,columnName:t?.columnName,dataType:t?.datatype||``}))||[],isShowHorizontal:!0,isCustomFieldFilter:!0})));return{...e,columns:[...e?.columns?.filter(e=>!e?.isCustomFieldFilter)||[],...t||[]]}})||[]},[de?.externalDashboard?.filters,de?.companyTenancyType,de?.clientId,u,Dn,y,de?.hideDashboardFilters,de?.dataMartTables,de?.clientColumnType,de?.clientSubsetData?.tableList,de?.dashboardFilterClientSubsetData?.tableList]),kn=()=>bZt(ie,e?.legacyUrlState?void 0:l),An=(0,n.useMemo)(()=>kn(),[ie]),jn=(0,n.useMemo)(()=>!!kt?.filters?.some(e=>(e?.value!==void 0||z5t(e?.operator))&&!Ab(e?.value)&&!Bx(e?.operator,e?.value)),[kt?.filters]);(0,n.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.has(`pdfGlobalFilters`)||e.has(`pdfMetricFilters`)||e.has(`pdfAxisSettings`);!On?.length&&!t&&At(void 0)},[On]),(0,n.useEffect)(()=>{s(cn)},[cn]);let Mn=(0,n.useMemo)(()=>JSON.stringify(se),[se]),Nn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let t=!e?.legacyUrlState&&Object.keys(se).length>0;if((ht.length||t||Nn.current)&&e?.isModifyUrl){let t=[];EX(ht.length&&kt?.filters||[],(On||[]).flatMap(e=>e?.columns||[])).forEach(e=>{let n=fZt(e.value,e.operator);if(n===void 0)return;let r={...e,value:n};if(Array.isArray(r.value)){if(r.value.length>1e3)return;let e=``;r.value.forEach((t,n)=>{e+=`${n===0?``:`;;`}${t.toString().includes(`'`)?Vx(t):t}`}),t.push({key:r.label,value:e})}else if(typeof r.value==`object`&&r?.value?.startDate&&r?.value?.endDate){let e=typeof r.value?.startDate==`string`?r.value?.startDate?.split(`T`)[0]:(r?.value?.startDate)?.toISOString()?.slice(0,10),n=typeof r.value?.endDate==`string`?r.value?.endDate?.split(`T`)[0]:(r?.value?.endDate)?.toISOString()?.slice(0,10);t.push({key:r.label,value:`${e};;${n}`})}else typeof r.value!=`object`&&r.value!==null&&r.value!==void 0&&r.value!==``&&t.push({key:r.label,value:r.value.toString().includes(`'`)?Vx(r.value.toString()):r.value.toString()})}),e?.legacyUrlState||Object.entries(se).forEach(([e,n])=>{t.push({key:`${mZt}${e}`,value:n})}),Nn.current=t.length>0;let n=vZt({currentSearch:window.location.search,dashboardId:l,entries:t,legacyGlobals:{configId:ne||void 0,embed:re||void 0,isDbn:te||void 0},namespaced:!e?.legacyUrlState});ae(`${window.location.pathname}?${n.toString()}${window.location.hash}`),En.forEach(t=>{n.delete(t?.name),!e?.legacyUrlState&&l&&n.delete(`${tJ(l)}${t?.name}`)}),Tn(n.toString())}},[ht,ne,re,te,e?.isModifyUrl,e?.legacyUrlState,l,Mn]),(0,n.useEffect)(()=>{typeof w==`function`&&w(uAr({dashboardId:l,filters:EX(kt?.filters||[],(On||[]).flatMap(e=>e?.columns||[]))}))},[w,l,kt,On]);let Pn=(0,n.useRef)(null),Fn=(0,n.useCallback)(()=>{Pn.current&&=(clearTimeout(Pn.current),null)},[]);(0,n.useEffect)(()=>Fn,[Fn]);let In=(0,n.useCallback)(()=>{if(ye?.current&&pn?.length){Fn();let e=6,t=()=>{let n=ye.current;if(!n)return;let r=n.scrollHeight>n.clientHeight;if(r){Re(e-1);return}e+=2,Te(n=>{let i=Math.min(n+2,pn.length);return e=i,!r&&i<pn.length&&(Pn.current=setTimeout(t,300)),i})};Te(Math.min(6,pn.length)),Pn.current=setTimeout(t,300)}},[pn?.length,Fn]),Ln=(0,n.useCallback)(()=>{if(!(Ee||we>=(pn?.length||0))&&ye?.current&&pn?.length){let{scrollTop:e,scrollHeight:t,clientHeight:n}=ye.current;if(t-(e+n)<100){De(!0);let e=pn.length-we;setTimeout(()=>{De(!1),Te(t=>e<=6?pn.length:t+6)},1e3)}}},[we,pn?.length,Ee]);(0,n.useEffect)(()=>{if(pn?.length&&!fe&&!pe){if(te||e?.isShowNoDataFoundScreen||Ge||Dt?.isEnabled){Te(pn?.length);return}let t=ye?.current;return t&&pn?.length&&(!we||we<6)&&In(),t?.addEventListener(`scroll`,Ln),()=>{t?.removeEventListener(`scroll`,Ln)}}},[ye,pn?.length,fe,pe,we,Yt,te,e?.isShowNoDataFoundScreen,Dt?.isEnabled,Ge]),(0,n.useEffect)(()=>{Le&&ze&&we<(pn?.length||0)&&(Te(e=>e+ze),Re(0),Be(0))},[ze,Le,we,pn?.length]);let Rn=(0,n.useMemo)(()=>N$n(de,e),[de,e]),zn=Rn.canCustomizeLayout,Bn=Rn.canCreateMetric,Vn=(0,n.useMemo)(()=>CAr({sharingSettingsId:de?.sharingSettingsId,isAllowedToEmailReports:de?.isAllowedToEmailReports,disableScheduleEmailReports:e?.disableScheduleEmailReports,showDashboardActions:e?.showDashboardActions,surface:`header`}),[e?.disableScheduleEmailReports,e?.showDashboardActions,de?.sharingSettingsId,de?.isAllowedToEmailReports]),Hn=Vn.available,Un=!!de?.externalDashboard?.id;(0,n.useEffect)(()=>{te||!Un||fe||pe||Vn.reason&&EAr(Vn.reason)},[te,Un,fe,pe,Vn.reason]);let Wn=Rn.canManageMetrics&&!!pn?.length,Gn=Rn.canCreateDashboardView,Kn=(0,n.useMemo)(()=>de?.externalDashboard?.enableViewFilter,[de?.externalDashboard?.enableViewFilter]),qn=(0,n.useMemo)(()=>{if(e?.dashboardSpacing?.verticalGap!==void 0||e?.dashboardSpacing?.horizontalGap!==void 0)return i7({verticalMargin:e?.dashboardSpacing?.verticalGap,horizontalMargin:e?.dashboardSpacing?.horizontalGap})},[e?.dashboardSpacing]),Jn=()=>{Object.keys(qn||{})?.length?Kt(i7(qn)):Object.keys(Qt||{})?.length?Kt(i7(Qt)):Object.keys(de?.externalDashboard?.gridMargin||{})?.length?Kt(i7(de?.externalDashboard?.gridMargin)):Kt(i7({verticalMargin:nn?.dashboard?.verticalGap,horizontalMargin:nn?.dashboard?.horizontalGap}))};(0,n.useEffect)(()=>{Jn()},[Qt,de?.externalDashboard?.gridMargin,qn]);let Yn=(0,n.useMemo)(()=>pn?.length&&(pn?.map(e=>e.externalMetric))?.filter(e=>ycr({clientId:de?.clientId,isAllClient:de?.isAllClient,metric:e})).sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime())||[],[de?.clientId,de?.isAllClient,pn]),Xn=(0,n.useMemo)(()=>Yn?.map(e=>({value:e?.id,label:e?.name}))||[],[Yn]),Zn=(0,n.useMemo)(()=>Yn?.filter(e=>(e?.datasetMetricSettings?.metricImportMode!==`GALLERY`||e?.clientGalleryMetrics?.find(t=>t?.externalMetricId===e?.id))&&!!(de?.isAllClient||e?.isCreatedByClient&&e?.clientId===de?.clientId||!e?.isImportant))||[],[de?.clientId,de?.isAllClient,Yn]),Qn=(0,n.useMemo)(()=>{let n=!!t?.manageMetricsStyle&&Q9(t.manageMetricsStyle),r=!hn&&Rn.canManageMetrics&&!n;return fAr({isDashboardReady:Ne,hasLayoutAction:!(hn||!Rn.canCustomizeLayout),hasDownloadAction:!!(it&&(de?.isAllowToDownloadAllMetrics||e?.enableDownloadAllMetrics)),hasPdfAction:!!e?.enableDownloadAllPdf,hasRawMetrics:!!de?.externalDashboardMetrics?.length,hasManageMetricsAction:!!(r&&Zn.length),hasGalleryAction:!!(r&&de?.externalDashboardMetrics?.some(e=>e?.externalMetric?.datasetMetricSettings?.metricImportMode===`GALLERY`))})},[Ne,hn,Rn,de,e,t,it,Zn.length]),$n=(0,n.useMemo)(()=>Yn?.filter(e=>e?.datasetMetricSettings?.metricImportMode===`GALLERY`)||[],[Yn?.length]),er=(0,n.useMemo)(()=>Ct?.width>800&&pn?.flatMap(e=>e?.externalMetric?.chartOptions?.mergedCards?.map(e=>e.value))?.filter(e=>!!e)||[],[pn,Ct.width]);(0,n.useEffect)(()=>{ye.current&&(Rn.canCreateMetric&&de?.metricCreationMode===`DRAG_DROP`&&(ye.current.onClickCreateMetric=()=>Ce(!0)),Rn.canManageMetrics&&pn?.length&&(!t?.manageMetricsStyle||t?.manageMetricsStyle&&!Q9(t?.manageMetricsStyle))&&(ye.current.onClickManageMetrics=()=>Ae(!0)),CAr({sharingSettingsId:de?.sharingSettingsId,isAllowedToEmailReports:de?.isAllowedToEmailReports,disableScheduleEmailReports:e?.disableScheduleEmailReports,surface:`api`}).available&&(ye.current.onClickScheduleReports=()=>Ie(!0)),Rn.canCustomizeLayout&&(ye.current.onClickCustomizeLayout=()=>Ot({isEnabled:!0,layout:[]})))},[ye.current,Rn,de,e,t?.manageMetricsStyle]);let tr=(0,n.useMemo)(()=>{let e=On?.filter(e=>e?.columns?.length)||[];if(!e.length)return[];let t=pn?.filter(e=>e?.externalMetric?.chartOptions?.dashboardFilters?.length)?.map(e=>e.externalMetric),n=UB(e),r=e[0];if(!t?.length)return[{...r,columns:n}];let i=n.filter(e=>t?.every(t=>!t?.chartOptions?.dashboardFilters?.some(t=>t?.value===e?.label)));return[{...r,columns:i}].filter(e=>e?.columns?.length)},[On,pn]),nr=(0,n.useMemo)(()=>{let e=Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)?de?.dashboardFilterClientSubsetData?.tableList||[]:de?.clientSubsetData?.tableList||[];return cTr({tableList:e,clientColumnType:de?.clientColumnType})},[de?.clientColumnType,de?.clientSubsetData?.tableList,de?.dashboardFilterClientSubsetData?.tableList]),rr=(0,n.useMemo)(()=>Array.isArray(de?.dashboardFilterClientSubsetData?.tableList)||Array.isArray(de?.clientSubsetData?.tableList),[de?.clientSubsetData?.tableList,de?.dashboardFilterClientSubsetData?.tableList]),ir=(0,n.useCallback)(e=>{let t=de?.clientId||``;if(!t)return[];let n=[],r=de?.externalDashboard?.filters?.[0]?.tableName||``;return de?.externalDashboard?.filters?.forEach(r=>{let i=r?.columns?.filter(n=>n.isCreatedByClient&&n.clientId===t&&n.id!==e&&sTr({column:n,isSchemaAccessLoaded:rr,tableName:r?.tableName,tenancyLevel:de?.companyTenancyType,schemaList:nr}))||[];n.push(...i.map(e=>({...e,selectedTable:e.selectedTable||r?.tableName})))}),n.length?[{tableName:r||n[0]?.selectedTable||``,columns:n}]:[]},[nr,de?.clientId,de?.companyTenancyType,de?.externalDashboard?.filters,rr]),ar=(0,n.useCallback)(e=>{if(!de?.isAllowedToCreateDashboardFilters||!e.isCreatedByClient||e.clientId!==de?.clientId)return;let t;de?.externalDashboard?.filters?.some(n=>(t=n?.columns?.find(t=>t.id===e.id&&t.isCreatedByClient&&t.clientId===de?.clientId),t&&={...t,selectedTable:t.selectedTable||n?.tableName},!!t)),Ft(t||e),Nt(!0)},[de?.clientId,de?.externalDashboard?.filters,de?.isAllowedToCreateDashboardFilters]),or=(0,n.useCallback)(async(e,t)=>{let n=e?.renameFilterKey||``;de?.isAllowedToRenameDashboardFilters&&de?.externalDashboard?.id&&!e?.isCreatedByClient&&n&&(await Vt.mutateAsync({token:ge||de?.token||``,data:{externalDashboard:de.externalDashboard.id,filterKey:n,alias:t}}),me?.())},[de?.externalDashboard?.id,de?.isAllowedToRenameDashboardFilters,de?.token,me,ge,Vt]),sr=(0,n.useCallback)(e=>{de?.isAllowedToCreateDashboardFilters&&de?.externalDashboard?.id&&e.isCreatedByClient&&e.clientId===de?.clientId&&Lt(e)},[de?.clientId,de?.externalDashboard?.id,de?.isAllowedToCreateDashboardFilters]),cr=(0,n.useCallback)(async()=>{if(de?.isAllowedToCreateDashboardFilters&&de?.externalDashboard?.id&&It){zt(``);try{await Bt.mutateAsync({token:ge||de?.token||``,data:{externalDashboard:de.externalDashboard.id,filters:ir(It.id)}}),Lt(void 0),me?.()}catch{zt(`That filter could not be deleted. Try again, or close this and reload the dashboard.`)}}},[ir,de?.externalDashboard?.id,de?.isAllowedToCreateDashboardFilters,de?.token,It,me,ge,Bt]),lr=(0,n.useCallback)(()=>{Lt(void 0),zt(``)},[]),ur=de?.isAllowedToCreateDashboardFilters?(0,i.jsx)(Xs,{variant:`popover`,className:j9.triggerButton,id:`createFilter`,"data-testid":`create-filter`,leftIcon:(0,i.jsx)(uY,{text:`Add a Dashboard Filter`,position:`right`,isAllowPosChange:!0,children:(0,i.jsx)(jy,{name:`plus`})}),onClick:()=>{Ft(void 0),Nt(!0)}}):void 0,dr=!!de?.isAllowedToCreateDashboardFilters,fr=U5t({filters:tr,canCreateDashboardFilters:dr}),pr=W5t({filters:On,canCreateDashboardFilters:dr}),mr=(0,n.useMemo)(()=>{let e=UB(On);if(!e.length)return[];let t=pn?.filter(e=>e?.externalMetric?.chartOptions?.dashboardFilters?.length)?.map(e=>e?.externalMetric);return t?.length?t?.map(t=>{let n=e.filter(e=>t?.chartOptions?.dashboardFilters?.some(t=>t?.value===e?.label));return{metricId:t.metricId,id:t.id,filters:n}}):[]},[On,pn]),hr=(0,n.useMemo)(()=>e?.hideDashboardName===!1||!e?.hideDashboardName&&de?.isShowDashboardName,[e?.hideDashboardName,de?.isShowDashboardName]);(0,n.useEffect)(()=>{let e=setTimeout(()=>{He(QQt())},1e3);return()=>clearTimeout(e)},[]);let gr=(0,n.useMemo)(()=>!!de?.dataAppId,[de?.dataAppId]),_r=async e=>{Ge&&l&&(We(!0),await Jt({cards:e,isChangedByClient:!0}),setTimeout(()=>{window.dispatchEvent(new Event(`resize`))},100),Ke(!1),setTimeout(()=>{We(!1)},1e3))},vr=async(e,t)=>{let n=typeof t==`object`?t:void 0,r=typeof t==`string`?t:void 0,i=de?.externalDashboard?.layout||[],a=Yt&&Yt.length>0?Yt:i;if(n&&$t&&(a=Yt),n){let t=PGt(a,i,Yn.map(e=>e.id===n.replacedMetricId?{...e,resizeAttributes:n.resizeAttributes}:e)),r=FGt(t,e,n);We(!0),await Jt({cards:r,isChangedByClient:!0}),setTimeout(()=>{window.dispatchEvent(new Event(`resize`))},100),setTimeout(()=>{We(!1)},1e3);return}let o=[{i:e,x:0,y:0,w:Sl(ye?.current)?fue(r):12,h:10},...a.map(e=>({...e,y:(e?.y??0)+10}))];We(!0),await Jt({cards:o,isChangedByClient:!0}),setTimeout(()=>{window.dispatchEvent(new Event(`resize`))},100),setTimeout(()=>{We(!1)},1e3)},yr=async({onError:e,onSuccess:t,viewName:n,appliedfilters:r})=>{try{de?.externalDashboard?.id&&t(await Ye.mutateAsync({data:{name:n,externalDashboard:de?.externalDashboard?.externalDashboardId,viewFilter:r,metricViewFilters:at?.map(e=>({filters:e?.filters,id:e?.id}))||[],xAxisSettings:at?.map(e=>({xAxisSettings:e?.xAxisSettings,id:e?.id}))||[],yAxisSettings:at?.map(e=>({yAxisSettings:e?.yAxisSettings,id:e?.id}))||[]},token:de?.token}))}catch(t){e(t)}},br=(0,n.useMemo)(()=>{if(!Kn)return;let e=(Qe?.data)?.dashboardViewFilter?.find(e=>e?.id===_t?.value);if(e)return{metricViewFilters:Array.isArray(e?.metricViewFilters)&&e?.metricViewFilters||[],xAxisSettings:Array.isArray(e?.xAxisSettings)&&e?.xAxisSettings||[],yAxisSettings:Array.isArray(e?.yAxisSettings)&&e?.yAxisSettings||[]}},[Qe?.data,_t,Kn]),xr=(0,n.useMemo)(()=>{let e=Kn?br:void 0;return Wt?{metricViewFilters:e?.metricViewFilters||[],xAxisSettings:[...HEr(Wt.xAxisSettings),...e?.xAxisSettings||[]],yAxisSettings:[...UEr(Wt.yAxisSettings),...e?.yAxisSettings||[]]}:e},[Kn,br,Wt]),Sr=(0,n.useRef)({}),Cr=(0,n.useCallback)((e,t)=>{Sr.current=uXt(Sr.current,e,t)},[]),wr=(0,n.useRef)({xAxisSettings:[],yAxisSettings:[]});wr.current={xAxisSettings:at?.filter(e=>e?.xAxisSettings?.isEnable&&e?.xAxisSettings?.xaxis)?.map(e=>({xAxisSettings:e?.xAxisSettings,id:e?.id}))||[],yAxisSettings:at?.filter(e=>e?.yAxisSettings?.isEnable&&Array.isArray(e?.yAxisSettings?.yAxis)&&e?.yAxisSettings?.yAxis?.length)?.map(e=>({yAxisSettings:e?.yAxisSettings,id:e?.id}))||[]};let{isGettingPdf:Tr,cancelPdf:Er,toPDF:Dr,error:Or,isPdfExported:kr}=pQt({dashboardId:de?.externalDashboard?.externalDashboardId||``,fileName:de?.externalDashboard?.name||`dashboard`,token:de?.token,globalFilters:kt,metricFiltersRef:Sr,axisSettingsRef:wr}),Ar=()=>de?hn?(0,i.jsx)(TJ,{isOpen:qe,onClose:()=>Je(!1),isMobileModal:!0,headerTitle:`Dashboard Filters`,keepMounted:!0,children:(0,i.jsx)(_Ar,{encryptedClientId:``,isMobileView:hn,selectedViewOption:_t,setSelectViewOption:vt,onSaveViewFilter:yr,datasourceId:de?.datasourceId||``,dashboardId:l||``,fetchViewFiltersOptions:Qe,deleteViewFilterMutation:Ze,token:ge,isEndUserApp:!0,isAllowedCreateDashboardView:Gn,isEnableFilterView:Kn,viewFilterLabel:tn,createViewFilterMutation:Ye,onServerEvent:d,clientColumnType:de.clientColumnType,hideDatePickerOptions:e?.hideDatePickerOptions||[],filterIconColor:t?.button?.secondaryText,filterButtonBgColor:t?.button?.secondary,tenancyLevel:de.companyTenancyType,appliedFilterPairs:An,filters:tr,addGlobalFilter:ur,onApply:e=>{Ht.current||At(e)},theme:yt,internal:{isInternal:!0,workspaceId:de.workspace?.id},setSelectedFilterVal:gt,clientId:de.clientId,onEditDashboardFilter:de?.isAllowedToCreateDashboardFilters?ar:void 0,onDeleteDashboardFilter:de?.isAllowedToCreateDashboardFilters?sr:void 0,isAllowRenameDashboardFilter:!!de?.isAllowedToRenameDashboardFilters,onRenameDashboardFilter:or,isDisableClick:Ve,isEditLayoutEnabled:Dt?.isEnabled,layout:{adminLayout:de.externalDashboard.dashboardFiltersLayout,clientLayout:Zt||[],isLocked:!de.isAllowedToChangeLayout||!Dt.isEnabled,onChange:e=>Ot(t=>({...t,filtersLayout:[...e]}))}})}):(0,i.jsx)(_Ar,{encryptedClientId:``,selectedViewOption:_t,setSelectViewOption:vt,onSaveViewFilter:yr,datasourceId:de?.datasourceId||``,dashboardId:l||``,fetchViewFiltersOptions:Qe,deleteViewFilterMutation:Ze,token:ge,isEndUserApp:!0,isAllowedCreateDashboardView:Gn,isEnableFilterView:Kn,viewFilterLabel:tn,createViewFilterMutation:Ye,onServerEvent:d,clientColumnType:de.clientColumnType,hideDatePickerOptions:e?.hideDatePickerOptions||[],filterIconColor:t?.button?.secondaryText,filterButtonBgColor:t?.button?.secondary,tenancyLevel:de.companyTenancyType,appliedFilterPairs:An,filters:tr,addGlobalFilter:ur,onApply:e=>{Ht.current||At(e)},theme:yt,internal:{isInternal:!0,workspaceId:de.workspace?.id},setSelectedFilterVal:gt,clientId:de.clientId,onEditDashboardFilter:de?.isAllowedToCreateDashboardFilters?ar:void 0,onDeleteDashboardFilter:de?.isAllowedToCreateDashboardFilters?sr:void 0,isAllowRenameDashboardFilter:!!de?.isAllowedToRenameDashboardFilters,onRenameDashboardFilter:or,isDisableClick:Ve,isEditLayoutEnabled:Dt?.isEnabled,layout:{adminLayout:de.externalDashboard.dashboardFiltersLayout,clientLayout:Zt||[],isLocked:!de.isAllowedToChangeLayout||!Dt.isEnabled,onChange:e=>Ot(t=>({...t,filtersLayout:[...e]}))}}):null,[jr,Mr]=(0,n.useState)(``);return(0,n.useEffect)(()=>{if(h?.iconSvg){let e=YEr(h?.iconSvg),t=new Blob([e],{type:`image/svg+xml`}),n=URL.createObjectURL(t);return Mr(n),()=>{URL.revokeObjectURL(n)}}},[h?.iconSvg]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{ref:rn,"data-dbn-appearance-anchor":``,style:{display:`contents`}}),(0,i.jsxs)(`div`,{className:`dbn:relative dbn:h-full dbn:w-full`,children:[(0,i.jsxs)(`div`,{className:`${X9[`embedDashboard-container`]} dbn-dashboard ${e?.shouldFitFullScreen&&(lt?.show||Se)?`dbn:overflow-hidden`:``}`,style:{pointerEvents:Ue?`none`:void 0},ref:ye,children:[de?.externalDashboard?.id&&!fe&&!pe&&(0,i.jsxs)(i.Fragment,{children:[!hr&&!Bn&&!zn&&!Hn&&!Wn&&!Qn||!e?.showDashboardActions?null:!te&&(0,i.jsxs)(`div`,{className:`${X9[`embedDashboard-header`]} ${hr?X9.justifyBetween:X9.justifyEnd}`,style:Ve?{pointerEvents:`none`}:{},children:[hr?(0,i.jsx)(`h1`,{className:X9.dashboardName,children:de.externalDashboard.name||`Dashboard`}):null,(0,i.jsx)(`div`,{className:X9[`embedDashboard-header-buttons`],children:Dt.isEnabled&&!hn?(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-4 dbn:items-center`,children:[e?.dashboardSpacing?.hide?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`tertiary`,leftIcon:(0,i.jsx)(jy,{name:`ruler`}),className:`cta-tertiary`,children:`Adjust Spacing`}),position:`bottom-end`,children:(0,i.jsxs)(`div`,{className:`dbn:p-3 dbn:flex dbn:gap-2 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-vertical`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Vertical Gap`})]}),(0,i.jsx)(SJ,{id:`vertical-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.verticalMargin,onChange:e=>Kt(t=>i7({...t,verticalMargin:Number(e.target.value)}))})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-horizontal`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Horizontal Gap`})]}),(0,i.jsx)(SJ,{id:`horizontal-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.horizontalMargin,onChange:e=>Kt(t=>i7({...t,horizontalMargin:Number(e.target.value)}))})]})]})}),(0,i.jsx)(`div`,{className:`dbn:h-6 dbn:block dbn:border-l dbn:border-secondary`})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-2`,children:[(0,i.jsx)(Xs,{type:`button`,variant:`tab`,onClick:()=>{Ot({isEnabled:!1,layout:[]}),Jn(),d?.(`EXIT_CUSTOMIZE_LAYOUT_MODE`)},className:`cta-secondary`,children:`Discard`}),!e?.disableSaveLayout&&(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:async()=>{let e=Dt?.filtersLayout?.sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)?.map(e=>e.i)||[];await Jt({cards:Dt.layout,filtersLayout:e,isChangedByClient:!0,gridMargin:Gt}),d?.(`SAVE_LAYOUT`),Ot({isEnabled:!1,layout:[],filtersLayout:[]})},isDisabled:!Dt.layout.length&&!Dt.filtersLayout&&!Gt||Xt,className:`cta-primary`,children:`Save Layout`})]})]}):(0,i.jsxs)(i.Fragment,{children:[hn&&fr&&(0,i.jsxs)(`span`,{className:`dbn:relative`,children:[(0,i.jsx)(Xs,{variant:`tab`,"aria-label":`Open dashboard filters`,leftIcon:(0,i.jsx)(jy,{name:`funnel`,color:`primary`}),onClick:()=>Je(!0),"data-testid":`filters-popup-btn`,className:`cta-tertiary`}),jn?(0,i.jsx)(`span`,{className:`dbn:pointer-events-none dbn:absolute dbn:top-2 dbn:right-3 dbn:w-1 dbn:h-3`,children:(0,i.jsx)(jy,{name:`circle`,color:`primary`})}):null]}),Qn?(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`tab`,leftIcon:h?.iconSvg&&jr?(0,i.jsx)(`img`,{src:jr,alt:`custom settings btn`,className:`dbn:w-5 dbn:h-5 dbn:text-text-primary-color`}):(0,i.jsx)(jy,{name:`gear`}),"aria-label":h?.ariaLabel,"data-testid":`settings-btn`,className:`cta-secondary`,children:hn?``:h?.name?h?.name:`Settings`}),tabMenu:!0,position:h?.menuPosition||`bottom-start`,offset:[10,15],popoverButtonId:`settings`,containerHeight:`cta-secondary-height`,children:(0,i.jsxs)(`div`,{className:`dbn:p-2`,id:`settings-menu`,"data-testid":`settings-menu`,children:[!hn&&Rn.canCustomizeLayout&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>{Ot({isEnabled:!0,layout:[]}),d?.(`ENTER_CUSTOMIZE_LAYOUT_MODE`)},className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`custom`}),fitContainer:!0,children:`Customize Layout`})}),it&&(de?.isAllowToDownloadAllMetrics||e?.enableDownloadAllMetrics)&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:et?.isLoading?(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>tt(),className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`stop`}),fitContainer:!0,children:`Cancel download`}):(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>$e({dashboardName:de?.externalDashboard.name||`dashboard`,datasourceId:``,externalDashboardId:de?.externalDashboard?.externalDashboardId||``,globalFilters:kt,metricData:at||[],workspaceId:de?.workspace?.id||``,token:de?.token,onServerEvent:d}),className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`download`}),fitContainer:!0,isDisabled:et?.isLoading,children:`Download Metrics`})}),e?.enableDownloadAllPdf&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:Tr?(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:()=>Er(),className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`stop`}),fitContainer:!0,children:`Cancel export`}):(0,i.jsx)(Xs,{type:`button`,variant:`tertiary`,onClick:async()=>{d?.(`START_DASHBOARD_PDF`),await Dr(),d?.(`EXPORT_DASHBOARD_PDF`)},className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`download`}),fitContainer:!0,children:`Export As PDF`})}),!hn&&Rn.canManageMetrics&&!!Zn?.length&&(!t?.manageMetricsStyle||t?.manageMetricsStyle&&!Q9(t?.manageMetricsStyle))&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:(0,i.jsx)(Xs,{variant:`tertiary`,title:`manage metrics`,onClick:()=>{d?.(`ENTER_MANAGE_METRICS_MODE`),Ae(!0)},style:t?.manageMetricsStyle,className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`chart`}),fitContainer:!0,children:m?m():`Manage Metrics`})}),!hn&&Rn.canManageMetrics&&!!de.externalDashboardMetrics?.filter(e=>e?.externalMetric?.datasetMetricSettings?.metricImportMode===`GALLERY`).length&&(!t?.manageMetricsStyle||t?.manageMetricsStyle&&!Q9(t?.manageMetricsStyle))&&(0,i.jsx)(`div`,{className:`dbn:hover:bg-gray-3 dbn:rounded-md`,children:(0,i.jsx)(Xs,{variant:`tertiary`,title:`manage metrics`,onClick:()=>{d?.(`ENTER_METRICS_GALLERY_MODE`),Me(!0)},style:t?.manageMetricsStyle,className:`dbn:justify-start`,leftIcon:(0,i.jsx)(jy,{name:`chart`}),fitContainer:!0,children:m?m():`Gallery`})})]})}):null,!hn&&Ne&&Vn.available&&(0,i.jsx)(Xs,{"data-testid":`schedule-reports-btn`,variant:`tab`,type:`button`,onClick:()=>{d?.(`ENTER_SCHEDULED_REPORT_MODE`),Ie(!0)},title:`email-sharing`,className:`cta-secondary`,children:`Schedule Reports`}),!hn&&Rn.canCreateMetric&&de.metricCreationMode===`DRAG_DROP`&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:()=>{e?.shouldFitFullScreen&&tpt(ye.current),Ce(!0),d?.(`ENTER_CREATE_METRIC`)},leftIcon:(0,i.jsx)(jy,{name:`plus`,color:`light`}),className:`cta-primary`,containerClass:`cta-primary-height`,children:`Create Metric`})}),!hn&&Rn.canCreateMetric&&de.metricCreationMode===`POINT_CLICK`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Xs,{type:`button`,variant:`tab`,onClick:()=>ft(!0),className:`cta-tertiary`,children:(0,i.jsx)(jy,{name:`magnifying-glass`})}),(0,i.jsx)(R7,{children:dt&&(0,i.jsx)(mEr,{saveDashLayout:vr,onServerEvent:d,refetchDashboardData:me,setEditMetric:ct,metric:st?.metric,datasourceId:de?.datasourceId,clientColumnType:de.clientColumnType,tenancyType:de.companyTenancyType,token:de.token,clientId:de.clientId,companyId:de.companyId,isLiveMode:!1,externalDashboardId:de.externalDashboard.id,chartColors:e?.chartColors??Cn??$9,isShowMetricCreateModal:dt,setShowMetricCreateModal:ft,workspaceId:de.workspace?.id,userProvidedDashboardId:de.externalDashboard.externalDashboardId})})]}),!hn&&Rn.canCreateMetric&&de?.metricCreationMode===`CHAT`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:()=>mt(!0),leftIcon:(0,i.jsx)(jy,{name:`plus`,color:`light`}),className:`cta-primary`,children:`Chat with your Data`}),(0,i.jsx)(R7,{children:pt&&(0,i.jsx)(_wr,{config:{saveDashLayout:vr,onServerEvent:d,refetchDashboardData:me,externalDashboardId:de.externalDashboard.externalDashboardId,datasourceId:de?.datasourceId||``,embedDataAppId:de?.embedDataAppId||``,companyId:de.companyId,dashboardId:de.externalDashboard.id,dashboardIds:[de.externalDashboard.id],token:ge,workspaceId:de.workspace?.id,themeChartColors:e?.chartColors??Cn??$9,setSearchGenerateMetricModal:mt,clientId:de.clientId}})})]})]})}),(0,i.jsx)(`div`,{className:X9.minimapHeaderProgressContainer,ref:xe})]}),!e?.showDashboardActions&&Dt.isEnabled?(0,i.jsx)(`div`,{className:`${X9[`embedDashboard-header`]} ${X9.justifyEnd}`,children:(0,i.jsx)(`div`,{className:X9[`embedDashboard-header-buttons`],children:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-4 dbn:items-center`,children:[e?.dashboardSpacing?.hide?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(UZ,{buttonContent:(0,i.jsx)(Xs,{variant:`tertiary`,leftIcon:(0,i.jsx)(jy,{name:`ruler`}),children:`Adjust Spacing`}),position:`bottom-end`,children:(0,i.jsxs)(`div`,{className:`dbn:p-3 dbn:flex dbn:gap-2 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-vertical`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Vertical Gap`})]}),(0,i.jsx)(SJ,{id:`vertical-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.verticalMargin,onChange:e=>Kt(t=>i7({...t,verticalMargin:Number(e.target.value)}))})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1 dbn:flex-col`,children:[(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-1.5 dbn:items-center`,children:[(0,i.jsx)(jy,{name:`split-horizontal`,size:`sm`}),(0,i.jsx)(xa,{variant:`heading-6`,children:`Horizontal Gap`})]}),(0,i.jsx)(SJ,{id:`horizontal-gap`,type:`number`,min:0,max:20,step:1,value:Gt?.horizontalMargin,onChange:e=>Kt(t=>i7({...t,horizontalMargin:Number(e.target.value)}))})]})]})}),(0,i.jsx)(`div`,{className:`dbn:h-6 dbn:block dbn:border-l dbn:border-secondary`})]}),(0,i.jsxs)(`div`,{className:`dbn:flex dbn:gap-2`,children:[(0,i.jsx)(Xs,{type:`button`,variant:`tab`,onClick:()=>{d?.(`EXIT_CUSTOMIZE_LAYOUT_MODE`),Ot({isEnabled:!1,layout:[]}),Jn()},className:`cta-secondary`,children:`Discard`}),!e?.disableSaveLayout&&(0,i.jsx)(Xs,{type:`button`,variant:`primary`,onClick:async()=>{let e=Dt?.filtersLayout?.sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)?.map(e=>e.i)||[];await Jt({cards:Dt.layout,filtersLayout:e,isChangedByClient:!0,gridMargin:Gt}),d?.(`SAVE_LAYOUT`),Ot({isEnabled:!1,layout:[],filtersLayout:[]})},isDisabled:!Dt.layout.length&&!Dt.filtersLayout&&!Gt||Xt,className:`cta-primary`,children:`Save Layout`})]})]})})}):null,e?.isStickyDashboardFilters&&pr?(0,i.jsx)(`div`,{className:`${X9[`embedDashboard-stickyFilters`]} dbn-selectBox ${fr?``:`dbn:hidden`}`,children:Ar()}):null,(0,i.jsxs)(`div`,{className:`${X9[`embedDashboard-wrapper`]} ${e?.isStickyDashboardFilters&&fr?`dbn:pt-0`:``}`,style:e?.dashboardPadding?{padding:e?.dashboardPadding}:{},children:[!e?.isStickyDashboardFilters&&pr?(0,i.jsx)(`div`,{className:fr?``:`dbn:hidden`,children:Ar()}):null,(0,i.jsx)(qTr,{refreshSeconds:de?.refreshTime,isPaused:_n,onTogglePause:()=>vn(e=>!e),onRefreshNow:()=>void Sn(),isRefreshing:yn}),(0,i.jsx)(emr,{drillUrlState:ue,customMessages:a,onCreateMetric:!hn&&Rn.canCreateMetric?de.metricCreationMode===`DRAG_DROP`?()=>{e?.shouldFitFullScreen&&tpt(ye.current),Ce(!0),d?.(`ENTER_CREATE_METRIC`)}:de.metricCreationMode===`POINT_CLICK`?()=>ft(!0):de.metricCreationMode===`CHAT`?()=>mt(!0):void 0:void 0,refetchDashboardData:me,externalDashboardClientId:dKt({dashboard:de?.externalDashboard,principal:{clientId:de.clientId,isAllClient:de.isAllClient}}),dataMartTables:de?.dataMartTables,userIdentifier:de?.userIdentifier,viewMetricData:xr,setMetricMetadata:ot,rules:de?.externalDashboard?.rules||[],disableDownloadDataNoFilters:e?.disableDownloadDataNoFilters,disableDownloadUnderlyingDataNoFilters:e?.disableDownloadUnderlyingDataNoFilters,isShowNoDataFoundScreen:e?.isShowNoDataFoundScreen,isDataApp:gr,generatingPdf:!!te,onEditMetric:e=>{let t=NGt(e.id,Yt,de?.externalDashboard?.layout||[],e.resizeAttributes,!e.isMetric);Ce(!0),ct({metric:{...e,resizeAttributes:t}}),d?.(`ENTER_EDIT_METRIC`)},calendarType:b,metricMergedFilters:mr,language:_,translationDictionary:v,saveDashLayout:_r,fullScreenModal:lt,setFullScreenModal:ut,chartFontSettings:un?.chart,chartColumns:g,isAllClient:de.isAllClient,onServerEvent:d,chartClickFunction:C,disableMetricCardBorder:e?.disableMetricCardBorder,isAllowToDownloadMetrics:de?.isAllowToDownloadMetrics,setRowMetrics:Be,metricIndex:Le,noDataImg:f,noDataFoundSvg:p,shouldFitFullScreen:e?.shouldFitFullScreen,isEnableMetricSummary:de?.isEnableMetricSummary,mergedMetrics:er,metricCardColor:un?.dashboard?.metricCardColor||``,isShadowDisableOnHover:Tt,isDisableMetricLoader:e?.disableMetricLoader,chartAppearance:e?.chartAppearance,clientColumnType:de.clientColumnType,workspaceId:de.workspace?.id,isEditLayoutEnabled:Dt?.isEnabled,isMobileScreen:hn,gridMargin:Gt??{horizontalMargin:Number(nn?.dashboard?.horizontalGap),verticalMargin:Number(nn?.dashboard?.verticalGap)},token:ge,dataLimit:we,setDataLimit:Te,scrollContainerRef:ye,minimapRailContainerRef:be,minimapHeaderProgressContainerRef:xe,minimapTheme:{backgroundColor:un?.dashboard?.backgroundColor},isShowDashboardMinimap:e?.enableDashboardMinimap??!nn?.dashboard?.disableDashboardMinimap,isShowLoader:Ee,client:de.clientId,companyId:de.companyId,optionsIcon:e?.optionsIcon,externalDashboardId:de.externalDashboard.externalDashboardId,externalDashboardPk:de.externalDashboard.id,layout:{adminLayout:de.externalDashboard.layout,clientLayout:Yt,isLocked:!de.isAllowedToChangeLayout||!Dt.isEnabled,onChange:e=>Ot(t=>({...t,layout:[...e]}))},isAllowedToDeleteMetrics:Rn.canArchiveMetric,isAllowedToUpdateMetrics:Rn.canEditMetric,isAllowedToChangeLayout:Rn.canCustomizeLayout&&Dt.isEnabled,isAllowedToSeeUnderlyingData:Rn.canViewUnderlyingData,externalDashboardMetrics:de.externalDashboardMetrics,isMetricListLoading:fe,globalFilters:kt,onClearAllFilters:jt,breakpoint:t?.breakpoint,layoutCols:t?.metricLayoutCols,chartColors:e?.chartColors??Cn??$9,isChartColorsExplicit:!!e?.chartColors?.length||!!Cn?.length,params:Array.isArray(de.rlsSettings)?de.rlsSettings:[],companyTenancyType:de.companyTenancyType,sharingSettingsId:de.sharingSettingsId,appFilters:de.appFilters,isHideChartSettings:e?.isHideChartSettings,isHideTablePreview:e?.isHideTablePreview,enableDownloadCsv:e?.enableDownloadCsv,disableDownloadPng:e?.disableDownloadPng,enableEmailCsv:e?.enableEmailCsv,enableMultiMetricFilters:e?.enableMultiMetricFilters,disableFullscreen:e?.disableFullscreen,enableTitleClickFullscreen:e?.enableTitleClickFullscreen,enableAdhocDrill:e?.enableAdhocDrill,enableExcludeFilter:e?.enableExcludeFilter,enableCrossFilter:e?.enableCrossFilter,enableCrossFilterBeforeDrill:e?.enableCrossFilterBeforeDrill,dropdownTheme:yt,underlyingTheme:xt,hideDatePickerOptions:e?.hideDatePickerOptions,datasourceId:de.datasourceId||``,isDisableClick:Ve,setShowSettingsBtn:Pe,allowedChartTypes:e?.allowedChartTypes,onMetricFiltersChange:Cr,pdfMetricFilters:Ut},`metrics-${pn?.length}-${Yt?.length}`),(0,i.jsx)(Ukr,{props:{companyId:de?.companyId,externalDashboardId:de?.externalDashboard?.externalDashboardId,language:_,translationDictionary:v,datasourceId:de?.datasourceId||``,metricList:Zn,token:ge,client:de.clientId,companyTenancyType:de.companyTenancyType,workspaceId:de.workspace?.id,chartAppearance:e?.chartAppearance,colors:e?.chartColors??Cn??$9,isOpenModal:Oe,setOpenModal:Ae,onServerEvent:d,refetchDashboardData:me,globalFilters:kt,params:Array.isArray(de.rlsSettings)?de.rlsSettings:[]}}),(0,i.jsx)(IEr,{props:{companyId:de?.companyId,externalDashboardId:de?.externalDashboard?.externalDashboardId,language:_,translationDictionary:v,datasourceId:de?.datasourceId||``,metricList:$n,token:ge,client:de.clientId,companyTenancyType:de.companyTenancyType,workspaceId:de.workspace?.id,chartAppearance:e?.chartAppearance,colors:e?.chartColors??Cn??$9,isOpenModal:je,setOpenModal:Me,onServerEvent:d}}),Fe?(0,i.jsx)(xAr,{props:{chartOptions:Xn,isShowSettings:!0,setShowSettings:Ie,onServerEvent:d,onComplete:()=>d?.(`SAVE_SCHEDULED_REPORT`),isEmbed:!0,externalDashboardId:de?.externalDashboard?.id}}):null,e?.shouldFitFullScreen?Se&&(0,i.jsx)(akr,{filters:tr,isIncrementalJoin:de.isIncrementalJoin,onServerEvent:d,refetchDashboardData:me,saveDashLayout:vr,metric:st?.metric,setEditMetric:ct,datasourceId:de?.datasourceId,clientColumnType:de.clientColumnType,tenancyType:de.companyTenancyType,token:de.token,clientId:de.clientId,companyId:de.companyId,isLiveMode:!1,externalDashboardId:de.externalDashboard.id,chartColors:e?.chartColors??S?.chartColors?.defaultValue??Cn??$9,colorPalettes:e?.chartPaletteOptions??wn,isShowMetricCreateModal:Se,setShowMetricCreateModal:Ce,workspaceId:de.workspace?.id,userProvidedDashboardId:de.externalDashboard.externalDashboardId,shouldFitFullScreen:e?.shouldFitFullScreen,customChartSettings:S,showAllChartSettings:e?.showAllChartSettings,showChartClickSettings:e?.showChartClickSettings,allowedChartTypes:e?.allowedChartTypes}):(0,i.jsx)(R7,{children:Se&&(0,i.jsx)(akr,{filters:tr,isIncrementalJoin:de?.isIncrementalJoin,onServerEvent:d,refetchDashboardData:me,saveDashLayout:vr,metric:st?.metric,setEditMetric:ct,datasourceId:de?.datasourceId,clientColumnType:de.clientColumnType,tenancyType:de.companyTenancyType,token:de.token,clientId:de.clientId,companyId:de.companyId,isLiveMode:!1,externalDashboardId:de.externalDashboard.id,chartColors:e?.chartColors??S?.chartColors?.defaultValue??Cn??$9,colorPalettes:e?.chartPaletteOptions??wn,isShowMetricCreateModal:Se,setShowMetricCreateModal:Ce,workspaceId:de.workspace?.id,userProvidedDashboardId:de.externalDashboard.externalDashboardId,customChartSettings:S,showAllChartSettings:e?.showAllChartSettings,showChartClickSettings:e?.showChartClickSettings,allowedChartTypes:e?.allowedChartTypes})})]})]}),!ge&&!window?.dbn?.isEnableProxyAuth&&!fe?(0,i.jsx)(`div`,{className:X9[`alt-container`],children:(0,i.jsx)(zK,{state:`error`,widgetName:`Dashboard`,errorMessage:a?.tokenAbsent||`This link is incomplete. Ask the person who shared it for a new link.`})}):null,fe&&!e?.disableMainLoader&&(0,i.jsx)(`div`,{className:X9[`alt-container`],children:(0,i.jsx)(D6,{})}),!!(ge||window?.dbn?.isEnableProxyAuth)&&!fe&&!de?.externalDashboard?.id&&pe&&(0,i.jsx)(`div`,{className:X9[`alt-container`],children:(0,i.jsx)(zK,{state:`error`,widgetName:`Dashboard`,errorMessage:pe===`TOKEN_EXPIRED`?a?.tokenExpiry||`Your access has expired. Ask for a new link.`:W(he)||`This dashboard could not be loaded. Check the link and try again.`,errorDetail:typeof pe==`string`?pe:void 0,onRetry:pe===`TOKEN_EXPIRED`||_e===`UNAUTHORIZED_ORIGIN`?void 0:()=>{me?.()}})})]}),(0,i.jsx)(`div`,{className:`dbn:pointer-events-none dbn:absolute dbn:bottom-0 dbn:right-0 dbn:top-0 dbn:z-[110]`,ref:be})]}),de?.isAllowedToCreateDashboardFilters?(0,i.jsx)(TJ,{isOpen:Mt,onClose:()=>{Nt(!1),Ft(void 0)},headerTitle:`Dashboard Filters`,size:`xl`,children:(0,i.jsx)(vAr,{dashboard:de?.externalDashboard?{...de.externalDashboard,filters:de.externalDashboard.filters}:void 0,schemaList:nr,isSchemaAccessLoaded:rr,token:ge||de?.token||``,clientId:de?.clientId,clientColumnType:de?.clientColumnType,tenancyLevel:de?.companyTenancyType,filterToEdit:Pt,onCancel:()=>{Nt(!1),Ft(void 0)},onSuccess:()=>{Nt(!1),Ft(void 0),me?.()}})}):null,(0,i.jsx)(TJ,{isOpen:!!de?.isAllowedToCreateDashboardFilters&&!!It,onClose:lr,headerTitle:`Delete Dashboard Filter`,size:`sm`,children:(0,i.jsxs)(`div`,{className:`dbn:flex dbn:flex-col dbn:gap-6 dbn:px-6 dbn:pb-5`,children:[(0,i.jsx)(xa,{variant:`body-text-2`,children:`Delete the filter "${It?.label||It?.name||``}"? It leaves the filter bar, and any value selected in it stops being applied. The dashboard's own filters are not changed.`}),Rt?(0,i.jsx)(xa,{variant:`body-text-2`,color:`alert`,children:Rt}):null,(0,i.jsxs)(`div`,{className:`dbn:flex dbn:justify-end dbn:gap-3`,children:[(0,i.jsx)(Xs,{variant:`tab`,type:`button`,onClick:lr,className:`cta-secondary`,children:`Cancel`}),(0,i.jsx)(Xs,{variant:`primary`,type:`button`,onClick:cr,isDisabled:Bt.isPending,className:`cta-primary`,children:`Delete`})]})]})}),Ue?(0,i.jsx)(`div`,{className:`dbn:absolute dbn:bg-gray dbn:p-4 dbn:rounded-md dbn:right-5 dbn:bottom-20 dbn:z-[9999999] dbn:border-l-4 dbn:border-black`,children:(0,i.jsx)(xa,{alignment:`center`,color:`primary`,variant:`heading-4`,children:`Please wait, adjusting layout....`})}):null,e?.exportMsgPosition!==`hidden`&&(Tr||Or||kr)?(0,i.jsx)(`div`,{className:`dbn:absolute dbn:z-[9999999] ${X9[`export-${e?.exportMsgPosition??`bottom-right`}`]}`,children:(0,i.jsx)(`div`,{className:`dbn:w-max dbn:flex dbn:items-center dbn:justify-center dbn:gap-1 dbn:p-2 dbn:rounded-md ${[`bottom-left`,`top-left`].includes(e?.exportMsgPosition??``)?`dbn:border-r-4`:[`bottom`,`top`,`center`].includes(e?.exportMsgPosition??``)?`dbn:border-x-4`:`dbn:border-l-4`} ${Or?`dbn:bg-red-100 dbn:border-alert`:`dbn:bg-green-100 dbn:border-success`}`,children:!Or&&(Tr||kr)?(0,i.jsxs)(i.Fragment,{children:[kr?(0,i.jsx)(jy,{name:`check`,color:`success`}):null,(0,i.jsx)(xa,{alignment:`center`,color:`success`,variant:`heading-4`,children:kr?`Exported Dashboard Successfully.`:`Exporting Dashboard...`})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(jy,{name:`info-filled`,color:`alert`}),(0,i.jsx)(xa,{alignment:`center`,color:`alert`,variant:`heading-4`,children:Or})]})})}):null,e?.exportMsgPosition!==`hidden`&&nt?(0,i.jsx)(`div`,{className:`dbn:absolute dbn:z-[9999999] ${X9[`export-${e?.exportMsgPosition??`bottom-right`}`]}`,children:(0,i.jsxs)(`div`,{role:`status`,className:`dbn:max-w-[320px] dbn:flex dbn:items-start dbn:justify-center dbn:gap-1 dbn:p-2 dbn:rounded-md dbn:bg-red-100 dbn:border-l-4 dbn:border-alert`,children:[(0,i.jsx)(jy,{name:`info-filled`,color:`alert`}),(0,i.jsx)(xa,{alignment:`center`,color:`alert`,variant:`heading-4`,children:nt})]})}):null]})})})),AAr=h((()=>{})),jAr=h((()=>{})),MAr=h((()=>{})),NAr,PAr=h((()=>{qi(),Ea(),bc(),_l(),kAr(),AAr(),jAr(),MAr(),Cht(),V_t(),U_t(),qr(),AB(),qQn(),T6(),NAr=({token:e,options:t,theme:r,dashboardId:a,isHideChartSettings:o,isHideTablePreview:s,isStickyDashboardFilters:l,enableDownloadAllMetrics:u,enableDownloadAllPdf:d,enableDownloadCsv:f,enableEmailCsv:p,enableMultiMetricFilters:m,disableFullscreen:h,enableTitleClickFullscreen:g,enableAdhocDrill:_,enableExcludeFilter:v,enableCrossFilter:y,enableChartDashboardNavigation:b,optionsIcon:x,settingsIcon:S,adminThemeOptions:C,customMessages:w,themeName:T,globalFilterOptions:ee,handleServerEvent:te,onSupportClick:ne,supportLabel:re,chartClickFunction:ie,noDataImg:ae,noDataFoundSvg:oe,manageMetricsBtnContent:se,disableDownloadPng:ce,longDescriptionConfig:le,chartColumns:ue,language:de,translationDictionary:fe,hideDashboardFilters:pe,calendarType:me=`default`,customChartSettings:he,uiVersion:ge,embedFlags:_e,dataDbnUi:ve,configId:ye,filterStateFunction:be,debug:xe})=>{let[Se,Ce]=(0,n.useState)(),{ref:we,target:Te}=Bi(xht(ve),{dashboardId:a});xr(xe);let Ee=(0,n.useRef)(void 0);Ee.current||=Or();let De=Ee.current,Oe=()=>ye||new URL(window.location.href).searchParams.get(`configId`),Ae=(0,n.useMemo)(()=>KQn(ie),[ie]);(0,n.useEffect)(()=>{let n=Date.now();return Gr(`dashboard-mounted`,{instanceId:De,dashboardId:a,hasToken:!!e,tokenLength:e?.length||0,isProxyAuth:!!window?.dbn?.isEnableProxyAuth,hasBaseUrl:!!window?.dbn?.baseUrl,themeName:T,language:de,calendarType:me,options:{disableMetricCreation:!!t?.disableMetricCreation,disableMetricUpdation:!!t?.disableMetricUpdation,disableMetricDeletion:!!t?.disableMetricDeletion,disableManageMetrics:!!t?.disableManageMetrics,disableLayoutCustomization:!!t?.disableLayoutCustomization,disableSaveLayout:!!t?.disableSaveLayout,disableScheduleEmailReports:!!t?.disableScheduleEmailReports,disableUnderlyingData:!!t?.disableUnderlyingData},enableDownloadCsv:!!f,enableDownloadAllPdf:!!d,enableMultiMetricFilters:!!m,disableFullscreen:!!h,hasGlobalFilterOptions:!!ee,hasHandleServerEvent:typeof te==`function`}),()=>{Gr(`dashboard-unmounted`,{instanceId:De,dashboardId:a,lifetimeMs:Date.now()-n})}},[De]),(0,n.useEffect)(()=>{C?.general?.name&&Ce(C)},[C]);let je=he?GS(he):{};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(B_t,{componentName:`dashboard`,adminTheme:Se,isDisableCardShadow:t?.hideMetricCardShadow,theme:r,longDescriptionConfig:le,isDisableStrokeOpt:!!t?.disableMetricCardBorder?.toString(),ctaCustomization:t?.ctaButtonCustomization,uiVersion:ge,embedFlags:_e}),(0,i.jsx)(`div`,{ref:we,style:{display:`contents`},children:(0,i.jsx)(Li,{value:Te,children:(0,i.jsxs)(yc,{theme:r,debug:xe,instanceId:De,onSupportClick:ne,supportLabel:re,children:[(0,i.jsx)(H_t,{variant:`dashboard`}),typeof a==`string`&&!a.trim()?(0,i.jsx)(Ta,{kind:`dashboard`}):(0,i.jsx)(WXn,{uiVersion:ge,resolutionInput:{explicit:_e},children:(0,i.jsx)(WQn,{isEnabled:!!b,onNavigate:Ae,children:(0,i.jsx)(gl,{token:e,dashboardId:a,configId:Oe()||``,children:(0,i.jsx)(OAr,{componentToken:e,calendarType:me,options:{...t,isHideChartSettings:o,isHideTablePreview:s,isStickyDashboardFilters:l,enableDownloadCsv:f,enableEmailCsv:p,enableDownloadAllMetrics:u,enableDownloadAllPdf:d,enableMultiMetricFilters:m,disableFullscreen:h,enableTitleClickFullscreen:g,enableAdhocDrill:_,enableExcludeFilter:v,enableCrossFilter:y,optionsIcon:x,disableLayoutCustomization:t?.disableLayoutCustomization?.toString()?t.disableLayoutCustomization:!1,disableMetricCreation:t?.disableMetricCreation?.toString()?t.disableMetricCreation:!1,disableManageMetrics:t?.disableManageMetrics?.toString()?t.disableManageMetrics:!1,disableSaveLayout:t?.disableSaveLayout?.toString()?t.disableSaveLayout:!1,disableScheduleEmailReports:t?.disableScheduleEmailReports?.toString()?t.disableScheduleEmailReports:!1,disableMainLoader:t?.disableMainLoader?.toString()?t.disableMainLoader:!1,disableMetricLoader:t?.disableMetricLoader?.toString()?t.disableMetricLoader:!1,showDashboardActions:!t?.showDashboardActions?.toString()||t.showDashboardActions,isShowNoDataFoundScreen:t?.isShowNoDataFoundScreen?.toString()?t.isShowNoDataFoundScreen:!1,isModifyUrl:t?.isModifyUrl?.toString()?t.isModifyUrl:!1,namespaceUrlState:!t?.namespaceUrlState?.toString()||t.namespaceUrlState,legacyUrlState:t?.legacyUrlState?.toString()?t.legacyUrlState:!1,disableDownloadPng:ce,disableDownloadDataNoFilters:t?.disableDownloadDataNoFilters?.toString()?t.disableDownloadDataNoFilters:!1,disableDownloadUnderlyingDataNoFilters:t?.disableDownloadUnderlyingDataNoFilters?.toString()?t.disableDownloadUnderlyingDataNoFilters:!1,showAllChartSettings:t?.showAllChartSettings?.toString()?t.showAllChartSettings:!1,showChartClickSettings:t?.showChartClickSettings?.toString()?t.showChartClickSettings:!1,enableDashboardMinimap:t?.enableDashboardMinimap?.toString()?t.enableDashboardMinimap:!1},setAdminTheme:Ce,theme:r,themeName:T,adminThemeOption:C,customMessages:w,dashboardId:a,configId:Oe()||void 0,globalFilterOptions:ee&&GS(ee),chartColumns:ue&&GS(ue),onServerEvent:te,chartClickFunction:ie,filterStateFunction:be,noDataImg:ae,noDataFoundSvg:oe,customContent:se,customSettingsBtn:S?GS(S):{},translationDictionary:fe?GS(fe):{},language:de||``,hideDashboardFilters:pe?GS(pe)||[]:pe||[],customChartSettings:{...je,customSettings:{...je?.customSettings,customUppperLimit:je?.customSettings?.customUpperLimit}}})})})})]})})})]})}})),FAr=h((()=>{PAr(),kAr()}));Tgt();var IAr=[`light`,`dark`,`system`,`theme`],LAr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),RAr=e=>e!=null&&e!==``,zAr=e=>typeof e==`string`?JSON.stringify(e):Array.isArray(e)?`an array`:typeof e,BAr=(e,t)=>{let n=[],r=(t,r)=>n.push({prop:t,message:`<${e}> "${t}" ${r}`});for(let e of[`token`,`dashboardId`,`metricId`,`themeName`]){let n=t[e];RAr(n)&&typeof n!=`string`&&r(e,`must be a string, got ${zAr(n)}.`)}let i=t.colorScheme;RAr(i)&&!IAr.includes(i)&&r(`colorScheme`,`must be one of ${IAr.join(`, `)}, got ${zAr(i)}. The value is ignored.`);for(let e of[`options`,`theme`,`customMessages`]){let n=t[e];RAr(n)&&!LAr(n)&&r(e,`must be a JSON object, got ${zAr(n)}. The value is ignored.`)}let a=t.adminThemeOptions;if(RAr(a)){if(!LAr(a))r(`adminThemeOptions`,`must be a JSON object, got ${zAr(a)}. The value is ignored.`);else for(let e of wgt(a).issues)r(`adminThemeOptions`,`field ${e.path||`(root)`} was ${e.problem===`coerced`?`converted to a valid CSS value`:`invalid and was dropped`}.`)}return n},VAr=new Set,HAr=(e,t)=>{let r=r=>((0,n.useEffect)(()=>{for(let e of BAr(t,r))VAr.has(e.message)||(VAr.add(e.message),console.error(`[databrain] ${e.message}`))},[r]),(0,n.createElement)(e,r));return r.displayName=`withPublicPropsCheck(${t})`,r};Ge(),sr(),FAr(),n2t(),qr(),AAr();var UAr=HAr(NAr,`dbn-dashboard`),WAr=HAr(t2t,`dbn-metric`);w(`viewer`);var GAr=e=>{let t=e.getAttribute(`base-url`),n=mt(t);Gr(`web-component-base-url`,{requested:t,inEffect:n})},KAr=(e,t,n)=>{if(typeof n!=`string`||!n.trim())return`${e}: no ${t.canonical} was set. Use the ${t.label} id from the Embeds page.`;if(/\s/.test(n.trim()))return`${e}: ${t.canonical} "${n}" looks like a name, not an id. Use the ${t.label} id from the Embeds page.`},qAr=(e,t,n)=>class extends e{static get observedAttributes(){let t=e.observedAttributes??[];return n?[...t,n.alias]:t}lastIdWarning;isClearingId=!1;clearId(e){this.isClearingId=!0;try{this[e.prop]=``,this.removeAttribute(e.canonical)}finally{this.isClearingId=!1}this.isConnected&&super.connectedCallback()}attributeChangedCallback(e,t,r){if(!this.isClearingId){if(e===`base-url`&&GAr(this),n&&e===n.canonical&&r===null){let e=this.getAttribute(n.alias);e?super.attributeChangedCallback?.(n.canonical,t,e):this.clearId(n);return}if(n&&e===n.alias){this.hasAttribute(n.canonical)||(r?super.attributeChangedCallback?.(n.canonical,t,r):this.clearId(n));return}super.attributeChangedCallback?.(e,t,r)}}connectedCallback(){xr(this.getAttribute(`debug`)??void 0),GAr(this),Gr(`web-component-connected`,{tag:t,attributeNames:this.getAttributeNames(),hasShadowRoot:!!this.shadowRoot}),super.connectedCallback(),n&&setTimeout(()=>this.warnOnIdProblem(n),0)}warnOnIdProblem(e){if(!this.isConnected)return;let n=this[e.prop],r=KAr(t,e,n);r&&r!==this.lastIdWarning&&(this.lastIdWarning=r,console.warn(r))}disconnectedCallback(){Gr(`web-component-disconnected`,{tag:t}),super.disconnectedCallback()}},JAr=st(UAr,{props:{token:`string`,dashboardId:`string`,debug:`string`,options:`json`,theme:`json`,isHideChartSettings:`boolean`,isHideTablePreview:`boolean`,isStickyDashboardFilters:`boolean`,enableDownloadCsv:`boolean`,enableEmailCsv:`boolean`,disableDownloadPng:`boolean`,enableDownloadAllMetrics:`boolean`,enableDownloadAllPdf:`boolean`,enableMultiMetricFilters:`boolean`,disableFullscreen:`boolean`,enableTitleClickFullscreen:`boolean`,enableAdhocDrill:`boolean`,enableExcludeFilter:`boolean`,enableCrossFilter:`boolean`,enableChartDashboardNavigation:`boolean`,configId:`string`,optionsIcon:`string`,settingsIcon:`json`,adminThemeOptions:`json`,customMessages:`json`,onSupportClick:`function`,supportLabel:`string`,themeName:`string`,enableThemeContrastWarnings:`boolean`,colorScheme:`string`,globalFilterOptions:`json`,handleServerEvent:`function`,noDataImg:`string`,noDataFoundSvg:`string`,manageMetricsBtnContent:`function`,longDescriptionConfig:`json`,chartColumns:`json`,language:`string`,translationDictionary:`json`,hideDashboardFilters:`json`,calendarType:`string`,customChartSettings:`json`,chartClickFunction:`function`,filterStateFunction:`function`,uiVersion:`string`,embedFlags:`json`,dataDbnUi:`string`,baseUrl:`string`},shadow:`open`});customElements.get(`dbn-dashboard`)||customElements.define(`dbn-dashboard`,qAr(JAr,`dbn-dashboard`,{canonical:`dashboard-id`,alias:`dashboardid`,prop:`dashboardId`,label:`dashboard`}));var YAr=st(WAr,{props:{token:`string`,metricId:`string`,debug:`string`,theme:`json`,chartRendererType:`string`,optionsIcon:`string`,chartColors:`json`,height:`number`,width:`number`,className:`string`,style:`json`,variant:`string`,onMinimize:`function`,isHideChartSettings:`boolean`,isHideTablePreview:`boolean`,metricFilterOptions:`string`,enableDownloadCsv:`boolean`,enableEmailCsv:`boolean`,disableDownloadPng:`boolean`,disableFullscreen:`boolean`,enableTitleClickFullscreen:`boolean`,enableMultiMetricFilters:`boolean`,metricFilterPosition:`string`,customMessages:`json`,onSupportClick:`function`,supportLabel:`string`,themeName:`string`,enableThemeContrastWarnings:`boolean`,colorScheme:`string`,appearanceOptions:`json`,hideDatePickerOptions:`json`,chartAppearance:`json`,hideMetricCardShadow:`boolean`,disableUnderlyingData:`boolean`,noDataImg:`string`,disableMetricCardBorder:`boolean`,longDescriptionConfig:`json`,isMergedCard:`boolean`,chartColumns:`json`,language:`string`,translationDictionary:`json`,globalFilterOptions:`json`,calendarType:`string`,isDisableCardTitle:`boolean`,disableDownloadUnderlyingDataNoFilters:`boolean`,disableDownloadDataNoFilters:`boolean`,dataDbnUi:`string`,baseUrl:`string`},shadow:`open`});customElements.get(`dbn-metric`)||customElements.define(`dbn-metric`,qAr(YAr,`dbn-metric`,{canonical:`metric-id`,alias:`metricid`,prop:`metricId`,label:`metric`})),t.applyHostBaseUrl=GAr,t.describeIdAttributeProblem=KAr}),typeof globalThis<`u`&&delete globalThis.__dbnJsxRuntime;
|