@aquera/data-visualizer-sdk 0.0.19 → 0.0.21

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.
@@ -1,2 +1,2 @@
1
- import{$ as Ot,$a as Ht,B as bt,D as yt,Da as Rt,Ea as Nt,F as ce,G as Ct,J as vt,Ja as Ae,Ka as ye,L as xt,M as wt,Ma as zt,N as Pt,Na as Fe,O as Mt,Oa as Vt,P as Dt,Q as kt,R as St,Ra as T,S as ge,V as pe,Va as Ge,Wa as Wt,X as Le,_a as qt,a as je,aa as Tt,ab as Lt,b as Ze,bb as Ee,c as lt,ca as ke,d as Me,da as Se,fa as Oe,fb as $e,g as De,gb as Gt,i as q,ib as $t,j as K,k as dt,l as ct,m as gt,n as pt,na as Te,oa as At,p as ht,pa as Ft,q as mt,qa as be,r as ie,s as ut,sa as Et,t as ft,ta as It,v as de,w as _t}from"./chunk-A6TQPIGW.js";import{Ab as M,Bb as ot,Eb as _,Ga as tt,Gb as d,Ha as nt,Jb as ae,Kb as j,La as c,Lb as Z,N as B,Ob as R,Pb as at,Qb as te,R as Ke,S as v,Sb as w,Tb as W,Ub as He,X as u,Xa as we,Y as f,Z as Qe,_ as Je,ab as z,ac as se,ba as Xe,bc as ne,cc as le,d as Ye,da as me,ea as xe,fb as L,gc as fe,ha as et,ia as m,kb as it,la as X,lb as ee,lc as S,mb as b,nb as y,ob as U,oc as _e,p as A,pa as re,pb as rt,pc as Y,qb as F,rb as E,rc as st,sb as C,tb as s,ub as l,vb as h,wb as oe,xb as Pe,yb as ue,zb as V}from"./chunk-U4S2XPPP.js";import{a as P,b as H}from"./chunk-ZW5NV4UO.js";function Qt(){return{dashboardsTitle:"Dashboards",loadingDashboards:"Loading dashboards\u2026",noDashboardsTitle:"No dashboards yet",noDashboardsSub:"Generate one from your data, or create it in the builder.",generateDashboardButton:"Generate dashboard",refreshButton:"Refresh",exportButton:"Export",editButton:"Edit",renamePlaceholder:"Dashboard name",askAqueraButton:"Ask Aquera",errors:{loadFailedFallback:"Could not load dashboards",saveFailedFallback:"Could not save the dashboard",refreshFailedFallback:"Could not refresh the dashboard",exportFailedFallback:"Could not export the dashboard"}}}function Jt(){return{mcpGateway:de.MCP_GATEWAY_ENABLED??!1,aiPrompt:!0,autoGenerate:!0,export:!0,rename:!0,refresh:!0,executiveSummary:!0,edit:!0}}function Bt(){return{baseUrl:de.baseUrl??"",mcpUrl:de.MCP_URL??null,tokenizedOrigins:[de.baseUrl].filter(r=>!!r),headers:{},customerId:null,productId:null,productName:null,authMode:"inherit",authToken:null,getToken:null,resolvedToken:null,onUnauthorized:null,ssoEnabled:de.SSO_ENABLED??!1,features:Jt(),ui:{theme:"light",density:"comfortable",header:!0,locale:"en"},copy:Qt(),hrefs:{askAquera:"/ask-aquera",builder:"/manage-dashboards"},initialDashboardId:null}}var Ut=mt("dashboards",Bt);function D(){return Ut.read()}function jt(r){let t=Bt(),e=H(P(P({},t),ie(r)),{features:P(P({},t.features),ie(r.features??{})),ui:P(P({},t.ui),ie(r.ui??{})),hrefs:P(P({},t.hrefs),ie(r.hrefs??{})),copy:H(P(P({},t.copy),ie(r.copy??{})),{errors:P(P({},t.copy.errors),ie(r.copy?.errors??{}))}),headers:P(P({},t.headers),r.headers??{})});return r.tokenizedOrigins||(e.tokenizedOrigins=[e.baseUrl,e.mcpUrl].filter(n=>!!n)),Ut.write(e)}var G=class r{requests$=new Ye;requests=this.requests$.asObservable();toAskAquera(){this.requests$.next({to:D().hrefs.askAquera})}toAskAqueraDashboard(t,e){this.requests$.next({to:`${D().hrefs.askAquera}/dashboard/${t}`,queryParams:e})}toBuilder(t){this.requests$.next({to:`${D().hrefs.builder}/${t}`})}static \u0275fac=function(e){return new(e||r)};static \u0275prov=B({token:r,factory:r.\u0275fac})};var k={get baseUrl(){return D().baseUrl},get MCP_URL(){return D().mcpUrl??""},get MCP_GATEWAY_ENABLED(){return D().features.mcpGateway},get SSO_ENABLED(){return D().ssoEnabled}};function Zt(){return D().customerId??""}function O(){return D().productId??""}var he=class r{constructor(t){this.http=t}http;tokenStore=v(ce);publishRepo=v(T);lastSentCustomerId=null;lastSentProductId=null;get customerId(){return this.tokenStore.tenantId()??""}mcpGatewayUrl(){return`${k.baseUrl}/dviz-mcp`}async callMcpTool(t,e={}){let n=this.customerId,i=O(),o={};n!==this.lastSentCustomerId&&(o.customerId=n),i!==this.lastSentProductId&&(o.productId=i);let a;try{a=await A(this.http.post(this.mcpGatewayUrl(),{jsonrpc:"2.0",id:Date.now(),method:"tools/call",params:{name:t,arguments:e}},{headers:{Accept:"application/json, text/event-stream"},params:o})),this.lastSentCustomerId=n,this.lastSentProductId=i}catch(p){throw p instanceof q?new Error(p.error?.error?.message||p.error?.message||p.message):p}if(a.error)throw new Error(a.error.message);let g=a.result;if(g?.isError)throw new Error(g.structuredContent?.error?.message??g.content?.[0]?.text??`${t} failed`);return g?.structuredContent??{}}async loadDashboards(){return(await this.publishRepo.listDashboards({published:"true",limit:100})).filter(e=>e.isPublished===!0||e.version==="published").map(e=>({id:e.id,name:e.name??"Untitled",description:e.description,createdAt:e.createdAt??new Date().toISOString(),updatedAt:e.updatedAt,isAutoGenerated:e.isAutoGenerated===!0,category:e.category??null}))}async renameDashboard(t,e){if(!k.MCP_GATEWAY_ENABLED){try{await A(this.http.put(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}?published=true`,{name:e}))}catch(n){throw n instanceof q?new Error(n.error?.error||n.message):n}return}await this.callMcpTool("updateDashboard",{dashboardId:t,name:e,published:!0})}async fetchDashboard(t){let e,n=!1;if(k.MCP_GATEWAY_ENABLED){let i=await this.callMcpTool("getDashboard",{dashboardId:t,published:"true"});e=i?.dashboard??{},n=i?.canRefresh===!0}else{let i=await A(this.http.get(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}?published=true`));e=i?.data??i,n=i?.canRefresh===!0}return{id:e.id,name:e.name??"Untitled",widgets:await this.mapAndHydrateWidgets(e.widgets),connectionId:e.connectionId,isPipeline:e.isPipeline,adapterType:e.adapterType,category:e.category??null,canRefresh:n}}async refreshDashboard(t){if(!k.MCP_GATEWAY_ENABLED){let n=await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}/refresh`,{})),i=n?.data??n;return{widgets:await this.mapAndHydrateWidgets(i?.widgets)}}let e=await this.callMcpTool("refreshDashboard",{dashboardId:t});return{widgets:await this.mapAndHydrateWidgets(e?.refresh?.widgets)}}async previewWidgetTemplateDetailPanel(t){return(await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/widget-templates/${t}/detail-panel`,{}))).data}async previewWidgetDetailPanelDefinition(t){return(await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/widget-templates/preview-detail-panel`,{detailPanel:t}))).data}async mapAndHydrateWidgets(t){let e=(t??[]).map(n=>({id:n.id,title:n.title,type:n.widgetType??"chart",layout:n.layout??{x:0,y:0,w:12,h:4},nileConfig:{chart:n.chart??n.config?.chart??{},aq:n.config?.aq??{},_meta:n.config?._meta},drilldownBy:Array.isArray(n.drilldownBy)?n.drilldownBy:void 0,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null}));return await Promise.all(e.map(n=>ye(n.nileConfig))),e}static \u0275fac=function(e){return new(e||r)(Ke(K))};static \u0275prov=B({token:r,factory:r.\u0275fac,providedIn:"root"})};var $=class r{http=v(K);tokenStore=v(ce);get customerId(){return this.tokenStore.tenantId()??""}async fetchGridPage(t,e,n,i,o,a,g,p){let x=`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/data-grid/${t}?pageIndex=${e}&pageSize=${n}`,N=(i??[]).filter(J=>J&&J.value!=null&&String(J.value).trim()!=="");return N.length&&(x+=`&filters=${encodeURIComponent(JSON.stringify(N))}`),o&&Object.keys(o).length&&(x+=`&dashboardFilters=${encodeURIComponent(JSON.stringify(o))}`),g&&g.length&&(x+=`&resolvedFilters=${encodeURIComponent(JSON.stringify(g))}`),a&&(x+=`&dashboardId=${encodeURIComponent(a)}`),p&&(x+=`&conversationId=${encodeURIComponent(p)}`),A(this.http.get(x))}async generateWidget(t,e){let n=vt()?{prompt:t}:{prompt:t,dataSourceId:e},i;try{i=await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/widget/generate`,n))}catch(g){if(g instanceof q){let p=g.error?.error||g.message;throw new Error(p)}throw g}if(i?.success===!1)throw new Error(i.error||"Request failed");let o=i?.data??i;if(!o?.config)throw new Error("Invalid response from widget generate API");let a=o;return await ye(a.config),a}async filterSuggest(t,e,n,i){let o=n.filter(p=>!!p.id).map(p=>({widgetId:p.id})),a;try{a=await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}/filter/suggest?status=${i??"draft"}`,{query:e,refreshCache:!1,widgets:o}))}catch(p){throw p instanceof q?new Error(p.error?.error||p.message):p}if(a?.success===!1)throw new Error(a.error||"Request failed");let g=a?.data??a??{};return{nextToken:g.nextToken,completions:Array.isArray(g.completions)?g.completions:[],suggestions:Array.isArray(g.suggestions)?g.suggestions:[]}}async applyFilters(t,e,n,i,o,a){let g=await new Promise((qe,ve)=>{let Ue=this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${n}/filter/apply?status=${i??"draft"}`,Vt(t,e,a)).subscribe({next:I=>qe(I),error:I=>{I instanceof q?ve(new Error(I.error?.error||I.message)):ve(I)}});if(o){if(o.aborted){Ue.unsubscribe();let I=new Error("Aborted");I.name="AbortError",ve(I);return}o.addEventListener("abort",()=>{Ue.unsubscribe();let I=new Error("Aborted");I.name="AbortError",ve(I)},{once:!0})}});if(g?.success===!1)throw new Error(g.error||"Request failed");let p=g?.data??g,x=Array.isArray(p)?p:p?.widgets;if(!Array.isArray(x))throw new Error("Invalid response from apply-filters API");let N=!Array.isArray(p)&&Array.isArray(p?.resolvedFilters)?p.resolvedFilters:[],J=!Array.isArray(p)&&Array.isArray(p?.filterGroups)?p.filterGroups:[];return await Promise.all(x.map(qe=>ye(qe.config))),{widgets:x,resolvedFilters:N,filterGroups:J}}static \u0275fac=function(e){return new(e||r)};static \u0275prov=B({token:r,factory:r.\u0275fac,providedIn:"root"})};var en=["grid"];function tn(r,t){if(r&1&&w(0),r&2){let e=d(2);He(" ",e.widgetDetailPanelTitle," ")}}function nn(r,t){r&1&&h(0,"nile-skeleton-loader",6)}function rn(r,t){if(r&1&&h(0,"shared-dashboard-grid",8),r&2){let e=d(2);C("widgets",e.widgetDetailPanelWidgets)("widgetsLoading",e.widgetDetailPanelLoading)("editMode",!1)("selectable",!1)("canSetAlert",!1)("canAddToStory",!1)("canForecast",!1)}}function on(r,t){r&1&&(s(0,"div",9)(1,"div",10),h(2,"nile-skeleton-loader",11)(3,"nile-skeleton-loader",11)(4,"nile-skeleton-loader",11),l(),h(5,"nile-skeleton-loader",12),l())}function an(r,t){if(r&1){let e=M();s(0,"div",2)(1,"div",4)(2,"nile-breadcrumb",5),_("nile-click",function(){u(e);let i=d();return f(i.closeWidgetDetailPanel())}),s(3,"nile-breadcrumb-item"),w(4),l(),s(5,"nile-breadcrumb-item"),b(6,tn,1,1)(7,nn,1,0,"nile-skeleton-loader",6),l()()(),s(8,"div",7),b(9,rn,1,7,"shared-dashboard-grid",8)(10,on,6,0,"div",9),l()()}if(r&2){let e=d();c(4),He(" ",e.dashboardName," "),c(2),y(e.widgetDetailPanelTitle?6:7),c(3),y(e.widgetDetailPanelWidgets.length?9:e.widgetDetailPanelLoading?10:-1)}}var Ce=class r{widgets=[];dashboardId=null;applyingFilters=!1;widgetDetailPanelOpen=!1;widgetDetailPanelLoading=!1;widgetDetailPanelTitle=null;widgetDetailPanelWidgets=[];dashboardName=null;widgetDetailPanelSkeletonSlots=[];widgetDetailPanelSkeletonHeight(){return this.widgetDetailPanelSkeletonSlots.length?Math.max(...this.widgetDetailPanelSkeletonSlots.map(t=>(t.y+t.h)*72)):0}async onKpiWidgetClicked(t){if(this.widgetDetailPanelLoading)return;let e=t.config?._meta,n=e?.templateId??null,i=e?.detailPanel??null;if(!(!n&&!i)){this.beginCardMorph(t.id),this.runViewTransition(()=>{this.widgetDetailPanelOpen=!0,this.widgetDetailPanelLoading=!0,this.widgetDetailPanelTitle=i?.title??t.title??null,this.widgetDetailPanelSkeletonSlots=(i?.widgets??[]).map(o=>o.layout).filter(o=>!!o),this.widgetDetailPanelWidgets=this.detailPanelPlaceholders(i),this.cdr.markForCheck()});try{let o=i?await this.dashboardsService.previewWidgetDetailPanelDefinition(i):await this.dashboardsService.previewWidgetTemplateDetailPanel(String(n));if(!o.widgets.length){this.widgetDetailPanelOpen=!1;return}this.widgetDetailPanelTitle=o.title??t.title??null;let a=o.widgets.map((g,p)=>H(P({},g),{id:`detail-panel-${p}`}));this.widgetDetailPanelWidgets=a.every(g=>g.layout)?a:Le(a)}catch{this.widgetDetailPanelOpen=!1}finally{this.widgetDetailPanelLoading=!1,this.cdr.markForCheck()}}}detailPanelPlaceholders(t){let e=t?.widgets??[];if(!e.length)return[];let n=e.map((i,o)=>H(P({},i),{id:`detail-panel-${o}`}));return n.every(i=>i.layout)?n:Le(n)}closeWidgetDetailPanel(){this.runViewTransition(()=>{this.widgetDetailPanelOpen=!1,this.widgetDetailPanelTitle=null,this.widgetDetailPanelWidgets=[],this.widgetDetailPanelSkeletonSlots=[],this.cdr.markForCheck()},"back")}currentTimeRange=null;lastMonitoredTotal=null;isRefreshingData=!1;activeDashboardFilters=null;activeResolvedFilters=null;activeFilterGroups=[];applySummary=null;alertDrawerOpen=!1;alertWidget=null;alertFilterPredicates=null;alertFilterHasOr=!1;alertAuthoringMode="widget";alertSource=null;gridRef;http=v(K);zone=v(xe);navigator=v(G);openAiService=v($);dashboardsService=v(he);forecastService=v(Tt);cdr=v(st);appRef=v(it);hostEl=v(re);static MORPH_NAME="dv-detail-morph";morphSourceEl=null;beginCardMorph(t){if(!t||typeof CSS>"u"||!CSS.escape)return!1;let e=this.hostEl.nativeElement.querySelector(`.widget-card[data-widget-id="${CSS.escape(String(t))}"]`);if(!e)return!1;let n=e.getBoundingClientRect();return n.height>0&&n.bottom>0&&n.top<window.innerHeight?(e.style.viewTransitionName=r.MORPH_NAME,this.morphSourceEl=e,this.hostEl.nativeElement.classList.add("dv-morphing"),!0):!1}endCardMorph(){this.morphSourceEl&&(this.morphSourceEl.style.removeProperty("view-transition-name"),this.morphSourceEl=null),this.hostEl.nativeElement.classList.remove("dv-morphing")}runViewTransition(t,e="forward"){let n=document,i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(typeof n.startViewTransition!="function"||i){t(),this.endCardMorph();return}let o=document.documentElement;e==="back"&&(o.dataset.vtDirection="back");let a=()=>{delete o.dataset.vtDirection,this.endCardMorph()};n.startViewTransition(()=>{t(),this.appRef.tick()})?.finished?.then(a,a)??a()}sessionMap=new Map;primedFilterWidgets=new Set;filterSuggestCache=new Map;filterSuggestInflight=new Set;applyFiltersSeq=0;applyFiltersAbort;viewInited=!1;openInBuilder(){!this.dashboardId||!D().features.edit||this.navigator.toBuilder(this.dashboardId)}set config(t){let e=t?.id??null,n=e!==this.dashboardId;if(n&&(this.primedFilterWidgets.clear(),this.filterSuggestCache.clear(),this.filterSuggestInflight.clear(),this.activeDashboardFilters=null,this.activeResolvedFilters=null,this.activeFilterGroups=[],this.applySummary=null,this.currentTimeRange=null,this.lastMonitoredTotal=null),!t){this.widgets=[],this.dashboardId=null,this.alertSource=null,this.dashboardName=null;return}this.dashboardId=e,this.dashboardName=t.name??null,this.alertSource={connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType},this.widgets=(t.widgets??[]).map(o=>({id:o.id,title:o.title??"",widgetType:o.type??"chart",layout:o.layout,config:o.nileConfig,drilldownBy:o.drilldownBy,dataSourceId:o.dataSourceId,queryMeta:o.queryMeta,category:o.category??null})),this.forecastable=t.forecastable??{};let i=this.collectInitialFilters(this.widgets);i?this.applyInitialFilters(i):n&&t.canRefresh&&this.refreshLoadedDashboardData(e),this.viewInited&&queueMicrotask(()=>this.primeFilterWidgets())}async refreshLoadedDashboardData(t){this.isRefreshingData=!0;try{let{widgets:e}=await this.dashboardsService.refreshDashboard(t);this.dashboardId===t&&!this.activeDashboardFilters&&(this.widgets=e.map(n=>({id:n.id,title:n.title??"",widgetType:n.type??"chart",layout:n.layout,config:n.nileConfig,drilldownBy:n.drilldownBy,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null})))}catch(e){console.error("Failed to refresh dashboard data:",e)}finally{this.isRefreshingData=!1,this.cdr.markForCheck()}}collectInitialFilters(t){let e={};for(let n of t){let i=n.config?.chart;if(i?.type==="filter")for(let o of i.controls??[]){if(!o.id)continue;let a=o.value;a!=null&&(typeof a=="string"&&a.trim()===""||(e[o.id]=a))}}return Object.keys(e).length>0?e:null}async applyInitialFilters(t){let e=this.widgets.filter(o=>!pe(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let{widgets:o,resolvedFilters:a,filterGroups:g}=await this.openAiService.applyFilters(e,t,this.dashboardId,"published",n.signal,{timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;this.widgets=ge(this.widgets,o),this.activeDashboardFilters=t,this.activeResolvedFilters=a,this.activeFilterGroups=g,this.applySummary=Fe(o,this.buildActiveFilters(t))}catch(o){if(o?.name==="AbortError")return;console.error("Apply initial filters failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}ngAfterViewInit(){this.viewInited=!0,queueMicrotask(()=>this.primeFilterWidgets())}alertTargetWidget(){let t=this.widgets.filter(n=>!pe(n)),e=t.filter(n=>!!n.config?.chart?.gridId);return e.length===1?e[0]:t.find(n=>!!n.queryMeta?.sql)??null}onWidgetPatchedByGrid(t){this.widgets=this.widgets.map(e=>e.id===t.id?t:e),this.cdr.markForCheck()}forecastable={};forecastBusy=new Set;forecastingWidgetId=null;async onForecast(t){let e=this.dashboardId,n=String(t.widget.id);if(!(!e||this.forecastBusy.has(n))){this.forecastBusy.add(n),this.forecastingWidgetId=n,this.cdr.markForCheck();try{let i=t.enable?await this.forecastService.addToWidget(e,n,t.settings??{}):await this.forecastService.removeFromWidget(e,n);if(t.enable&&i?.guardrails&&i.guardrails.passed===!1)return;i?.widget&&this.applyForecastedWidget(i.widget),be({variant:"success",title:t.enable?t.settings?"Forecast updated":"Forecast added":"Forecast removed",content:t.enable?"The projection is shown with its confidence range.":"The chart is back to its measured history."})}catch{}finally{this.forecastBusy.delete(n),this.forecastingWidgetId=null,this.cdr.markForCheck()}}}applyForecastedWidget(t){this.widgets=this.widgets.map(e=>String(e.id)===String(t.id)?H(P({},e),{config:t.config?.chart??t.nileConfig??e.config,queryMeta:t.queryMeta??e.queryMeta}):e)}onSetAlert(t){if(pe(t)){let e=this.alertTargetWidget();if(!e)return;this.alertWidget=e,this.alertFilterPredicates=this.activeResolvedFilters,this.alertFilterHasOr=this.activeFilterGroups.length>1,this.alertAuthoringMode="filter"}else this.alertWidget=t,this.alertFilterPredicates=null,this.alertFilterHasOr=!1,this.alertAuthoringMode="widget";this.alertDrawerOpen=!0,this.cdr.markForCheck()}onAlertClosed(){this.alertDrawerOpen=!1,this.cdr.markForCheck()}onAlertSaved(){this.alertDrawerOpen=!1,this.cdr.markForCheck()}onFilterChange(t){let e=t.widgetId,n=t.controlId;!e||!n||this.dashboardId&&this.fetchSuggestionsOnce(e,n,this.dashboardId)}fetchSuggestionsOnce(t,e,n){let i=this.filterSuggestCache.get(t);if(i){this.gridRef?.patchFilterSuggestions(t,e,i);return}this.filterSuggestInflight.has(t)||(this.filterSuggestInflight.add(t),(async()=>{try{let o=await this.openAiService.filterSuggest(n,"",this.widgets,"published");this.applyFilterSuggestions(t,e,o)}catch(o){console.warn("Filter suggest failed:",o)}finally{this.filterSuggestInflight.delete(t)}})())}async onFilterSubmit(t){if(this.isEmptyFilters(t.filters)){await this.reloadDashboard();return}let e=this.widgets.filter(o=>!pe(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let{widgets:o,resolvedFilters:a,filterGroups:g}=await this.openAiService.applyFilters(e,t.filters,this.dashboardId,"published",n.signal,{mode:t.mode,prompt:t.prompt,timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;this.widgets=ge(this.widgets,o),this.activeDashboardFilters=t.filters,this.lastMonitoredTotal=null,this.activeResolvedFilters=a,this.activeFilterGroups=g,this.applySummary=Fe(o,this.buildActiveFilters(t.filters))}catch(o){if(o?.name==="AbortError")return;console.error("Apply filters failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}async applyTimeRange(t){this.currentTimeRange=t;let e=this.widgets.filter(o=>!pe(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let o=this.activeDashboardFilters??{},{widgets:a,resolvedFilters:g,filterGroups:p}=await this.openAiService.applyFilters(e,o,this.dashboardId,"published",n.signal,{resolvedFilters:this.activeResolvedFilters??[],timeRange:t??void 0});if(i!==this.applyFiltersSeq)return;this.widgets=ge(this.widgets,a),this.activeResolvedFilters=g,this.activeFilterGroups=p,this.applySummary=Fe(a,this.buildActiveFilters(o)),t&&this.checkForNewSinceLastCheck(t)}catch(o){if(o?.name==="AbortError")return;console.error("Apply time range failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}checkForNewSinceLastCheck(t){if(!(Math.abs(Date.now()-new Date(t.to).getTime())<6e4))return;let n=this.kpiTotal(this.widgets);n!=null&&(this.lastMonitoredTotal=n)}kpiTotal(t){let e=0,n=!1;for(let i of t){let o=i.config?.chart;if(o?.type!=="kpi")continue;let a=Number(o.value);Number.isFinite(a)&&(e+=a,n=!0)}return n?e:null}buildActiveFilters(t){return Nt(t,e=>this.filterFieldLabel(e))}filterFieldLabel(t){for(let e of this.filterSuggestCache.values()){let n=e.find(i=>i.type==="attribute"&&i.id===t);if(n)return n.label}return t}isEmptyFilters(t){if(!t)return!0;for(let e of Object.values(t))if(e!=null&&!(typeof e=="string"&&e.trim()==="")&&!(typeof e=="object"&&Object.keys(e).length===0))return!1;return!0}async reloadDashboard(){if(!this.dashboardId)return;this.applyFiltersAbort?.abort();let t=++this.applyFiltersSeq;this.applyingFilters=!0,this.activeDashboardFilters=null,this.lastMonitoredTotal=null,this.activeResolvedFilters=null,this.activeFilterGroups=[],this.applySummary=null;try{let e=await this.dashboardsService.fetchDashboard(this.dashboardId);if(t!==this.applyFiltersSeq)return;this.widgets=(e.widgets??[]).map(n=>({id:n.id,title:n.title??"",widgetType:n.type??"chart",layout:n.layout,config:zt(n.nileConfig),drilldownBy:n.drilldownBy,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null}))}catch(e){console.error("Reload dashboard failed:",e)}finally{t===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}this.currentTimeRange&&t===this.applyFiltersSeq&&await this.applyTimeRange(this.currentTimeRange)}primeFilterWidgets(){if(this.dashboardId)for(let t of this.widgets){if(this.primedFilterWidgets.has(t.id))continue;let e=t.config?.chart;if(e?.type!=="filter")continue;let n=e.controls?.find(i=>i.variant==="prompt"||i.variant==="expression"||i.variant==="hybrid")??e.controls?.find(i=>i.id);n?.id&&(this.primedFilterWidgets.add(t.id),this.fetchSuggestionsOnce(t.id,n.id,this.dashboardId))}}applyFilterSuggestions(t,e,n){let i=Array.isArray(n.suggestions)?n.suggestions:[];if(!i.length){n.nextToken&&i.push({id:n.nextToken.value,label:n.nextToken.label,type:"attribute"});for(let o of n.completions)i.push({label:o,type:"suggestion"})}i.length!==0&&(this.filterSuggestCache.set(t,i),this.gridRef?.patchFilterSuggestions(t,e,i))}async onAiSend(t){if(!this.dashboardId)return;let e=this.sessionMap.get(t.widgetId)??t.sessionId;this.sessionMap.set(t.widgetId,e);try{let n=Zt(),i=await A(this.http.post(`${k.baseUrl}/api/customers/${n}/products/${O()}/workforce/dashboards/${this.dashboardId}/widgets/${t.widgetId}/chat`,{message:t.message,sessionId:e})),o=i?.reply?.content;o&&(this.sessionMap.set(t.widgetId,i.sessionId??e),this.zone.run(()=>{t.chartEl?.addAiResponse?.(o)}))}catch(n){console.error("Chat request failed:",n),this.zone.run(()=>{t.chartEl?.addAiResponse?.("Sorry, I couldn't process your request. Please try again.")})}}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["app-dashboard-viewer"]],viewQuery:function(e,n){if(e&1&&ae(en,5),e&2){let i;j(i=Z())&&(n.gridRef=i.first)}},inputs:{config:"config"},features:[se([{provide:Mt,useFactory:t=>t.fetchGridPage.bind(t),deps:[$]},{provide:kt,useFactory:t=>t.fetchFilterValues.bind(t),deps:[T]},Oe(T),ke(T),Se(T),Te(T)])],decls:4,vars:21,consts:[["grid",""],[3,"forecast","aiSend","openAiBuilder","filterSubmit","filterChange","widgetChartTypeChanged","widgetFiltersChanged","widgetColorChanged","setAlert","widgetClick","widgets","editMode","dashboardId","persistToPublished","widgetsLoading","dashboardFilters","resolvedFilters","applySummary","canSetAlert","canAddToStory","canForecast","forecastable","forecastingWidgetId"],[1,"aq-detail-overlay"],[3,"closed","saved","open","widget","dashboardId","source","filterPredicates","filterHasOr","authoringMode"],[1,"aq-detail-overlay__crumbs"],[3,"nile-click"],["variant","text","width","160","height","16"],[1,"aq-detail-overlay__body"],[3,"widgets","widgetsLoading","editMode","selectable","canSetAlert","canAddToStory","canForecast"],[1,"aq-detail-skeleton"],[1,"aq-detail-skeleton__row"],["variant","rectangular","width","100%","height","96","border-radius","12px"],["variant","rectangular","width","100%","height","280","border-radius","12px"]],template:function(e,n){e&1&&(s(0,"shared-dashboard-grid",1,0),_("forecast",function(o){return n.onForecast(o)})("aiSend",function(o){return n.onAiSend(o)})("openAiBuilder",function(){return n.openInBuilder()})("filterSubmit",function(o){return n.onFilterSubmit(o)})("filterChange",function(o){return n.onFilterChange(o)})("widgetChartTypeChanged",function(o){return n.onWidgetPatchedByGrid(o)})("widgetFiltersChanged",function(o){return n.onWidgetPatchedByGrid(o)})("widgetColorChanged",function(o){return n.onWidgetPatchedByGrid(o)})("setAlert",function(o){return n.onSetAlert(o)})("widgetClick",function(o){return n.onKpiWidgetClicked(o)}),l(),b(2,an,11,3,"div",2),s(3,"app-alert-drawer",3),_("closed",function(){return n.onAlertClosed()})("saved",function(){return n.onAlertSaved()}),l()),e&2&&(C("widgets",n.widgets)("editMode",!1)("dashboardId",n.dashboardId)("persistToPublished",!0)("widgetsLoading",n.applyingFilters||n.isRefreshingData)("dashboardFilters",n.activeDashboardFilters)("resolvedFilters",n.activeResolvedFilters)("applySummary",n.applySummary)("canSetAlert",!0)("canAddToStory",!1)("canForecast",!0)("forecastable",n.forecastable)("forecastingWidgetId",n.forecastingWidgetId),c(2),y(n.widgetDetailPanelOpen?2:-1),c(),C("open",n.alertDrawerOpen)("widget",n.alertWidget)("dashboardId",n.dashboardId)("source",n.alertSource)("filterPredicates",n.alertFilterPredicates)("filterHasOr",n.alertFilterHasOr)("authoringMode",n.alertAuthoringMode))},dependencies:[De,Ae,Ee],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;position:relative;height:100%;view-transition-name:dv-viewer-pane}.aq-detail-overlay[_ngcontent-%COMP%]{position:absolute;inset:0;z-index:50;display:flex;flex-direction:column;background:#fff;view-transition-name:dv-detail-morph}.dv-morphing[_nghost-%COMP%]{view-transition-name:none}.aq-detail-overlay__crumbs[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;box-sizing:border-box;min-height:56px;padding:10px 20px;border-bottom:1px solid #eaecf0;flex-shrink:0}.aq-detail-overlay__crumbs[_ngcontent-%COMP%] nile-breadcrumb[_ngcontent-%COMP%]{display:inline-flex;align-items:center}.aq-detail-overlay__body[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:auto;padding:20px;background:var(--nile-color-bg-subtle, #fbfbfd)}.aq-detail-skeleton[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px}.aq-detail-skeleton__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.aq-detail-skeleton-grid[_ngcontent-%COMP%]{position:relative;width:100%}.aq-detail-skeleton-slot[_ngcontent-%COMP%]{position:absolute}.dv-skel-card[_ngcontent-%COMP%]{height:100%;display:flex;flex-direction:column;box-sizing:border-box;background:var(--ng-colors-bg-primary, #fff);border-radius:var(--ng-radius-xl, 12px);box-shadow:var(--ng-shadow-sm);overflow:hidden}.dv-skel-card__head[_ngcontent-%COMP%]{padding:13px 14px;border-bottom:1px solid #eef1f6;flex-shrink:0}.dv-skel-card__body[_ngcontent-%COMP%]{flex:1;min-height:0;padding:12px 14px}.dv-skel-card__body[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%], .dv-skel-card__body[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%]::part(base){height:100%}']})};var Re=class r{http=v(K);tokenStore=v(ce);get customerId(){return this.tokenStore.tenantId()??""}async chat(t,e,n,i){let o=await new Promise((a,g)=>{let p=this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${e}/chat`,{message:t,sessionId:n}).subscribe({next:x=>a(x),error:x=>{x instanceof q?g(new Error(x.error?.error||x.message)):g(x)}});if(i){if(i.aborted){p.unsubscribe();let x=new Error("Aborted");x.name="AbortError",g(x);return}i.addEventListener("abort",()=>{p.unsubscribe();let x=new Error("Aborted");x.name="AbortError",g(x)},{once:!0})}});if(!o?.success)throw new Error("Chat request failed");return o}async getSuggestions(t){if(!t)return[];let e;try{e=await A(this.http.get(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}/chat/suggestions`))}catch(n){throw n instanceof q?new Error(n.error?.error||n.message):n}if(Array.isArray(e))return e;if(e.success===!1)throw new Error("Suggestions request failed");return e.suggestions??e.data??[]}static \u0275fac=function(e){return new(e||r)};static \u0275prov=B({token:r,factory:r.\u0275fac,providedIn:"root"})};var ln=["sliderGrid"],dn=r=>({"recommend-window":r}),cn=()=>({variant:"welcome"}),gn=()=>[1,2,3,4],pn=r=>({"mic-listening":r}),hn=r=>({disabled:r}),Yt=(r,t)=>t.title;function mn(r,t){r&1&&V(0)}function un(r,t){r&1&&(s(0,"div",18),h(1,"nile-skeleton-loader",19),l())}function fn(r,t){r&1&&(s(0,"div",17),F(1,un,2,0,"div",18,U),l()),r&2&&(c(),E(ne(0,gn)))}function _n(r,t){if(r&1){let e=M();s(0,"button",23),_("click",function(){let i=u(e).$implicit,o=d(5);return f(o.runPrompt(i.title))}),s(1,"div",24),h(2,"nile-icon",25),l(),s(3,"span",26),w(4),l()()}if(r&2){let e=t.$implicit;c(4),W(e.title)}}function bn(r,t){if(r&1){let e=M();s(0,"div",17),F(1,_n,5,1,"button",20,Yt),l(),s(3,"button",21),_("click",function(){u(e);let i=d(4);return f(i.openPromptGallery())}),h(4,"nile-glyph",22),s(5,"span"),w(6,"View prompt gallery"),l()()}if(r&2){let e=d(4);c(),E(e.topRecommended())}}function yn(r,t){if(r&1&&(s(0,"div",9)(1,"div",12),h(2,"nile-icon",13),l(),s(3,"h2",14),w(4,"What would you like to ask?"),l(),s(5,"p",15),w(6,"Ask anything about your dashboard."),l(),L(7,mn,1,0,"ng-container",16),b(8,fn,3,1,"div",17)(9,bn,7,0),l()),r&2){let e=d(3),n=R(3);c(7),C("ngTemplateOutlet",n)("ngTemplateOutletContext",ne(3,cn)),c(),y(e.loadingSuggestions()?8:e.recommended().length>0?9:-1)}}function Cn(r,t){r&1&&(s(0,"div",10),h(1,"nile-icon",27),s(2,"div",28),w(3,"Generating your answer..."),l()()),r&2&&(c(),C("name","loader")("size","20"))}function vn(r,t){if(r&1&&(s(0,"div",29)(1,"div",30)(2,"span"),w(3),l()()()),r&2){let e=d().$implicit;c(3),W(e.content)}}function xn(r,t){if(r&1&&(s(0,"div")(1,"div",31),h(2,"nile-glyph",32),l(),s(3,"div",33),h(4,"div",34),l()()),r&2){let e=d().$implicit;c(4),C("innerHTML",e.content,nt)}}function wn(r,t){if(r&1&&(b(0,vn,4,1,"div",29),b(1,xn,5,1,"div")),r&2){let e=t.$implicit;y(e.role==="user"?0:-1),c(),y(e.role==="assistant"?1:-1)}}function Pn(r,t){r&1&&V(0)}function Mn(r,t){if(r&1&&L(0,Pn,1,0,"ng-container",35),r&2){d(3);let e=R(3);C("ngTemplateOutlet",e)}}function Dn(r,t){if(r&1){let e=M();s(0,"button",23),_("click",function(){let i=u(e).$implicit,o=d(4);return f(o.onGalleryPromptClick(i.title))}),s(1,"div",24),h(2,"nile-icon",25),l(),s(3,"span",26),w(4),l()()}if(r&2){let e=t.$implicit;c(4),W(e.title)}}function kn(r,t){if(r&1){let e=M();s(0,"div",11)(1,"div",36)(2,"span",37),w(3,"Prompt gallery"),l(),s(4,"button",38),_("click",function(){u(e);let i=d(3);return f(i.closePromptGallery())}),h(5,"nile-glyph",39),l()(),s(6,"div",40)(7,"p",41),w(8,"Pick a suggestion to get started."),l(),s(9,"div",42),F(10,Dn,5,1,"button",20,Yt),l()()()}if(r&2){let e=d(3);c(10),E(e.recommended())}}function Sn(r,t){if(r&1){let e=M();s(0,"div",6)(1,"nile-glyph",7),_("click",function(){u(e);let i=d(2);return f(i.closePanel.emit())}),l()(),s(2,"div",8),b(3,yn,10,4,"div",9),b(4,Cn,4,2,"div",10),F(5,wn,2,2,null,null,U),l(),b(7,Mn,1,1,"ng-container"),b(8,kn,12,0,"div",11)}if(r&2){let e,n,i,o,a=d(2);c(2),C("ngClass",le(5,dn,!(!((e=a.chatsDetails())==null||e.message==null)&&e.message.length))),c(),y(!((n=a.chatsDetails())==null||n.message==null)&&n.message.length?-1:3),c(),y(a.isGenerating()?4:-1),c(),E((i=a.chatsDetails())==null?null:i.message),c(2),y(!((o=a.chatsDetails())==null||o.message==null)&&o.message.length?7:-1),c(),y(a.showPromptGallery()?8:-1)}}function On(r,t){if(r&1){let e=M();s(0,"div",43),_("pointerdown",function(i){u(e);let o=d(2);return f(o.onResizeStart(i))})("pointermove",function(i){u(e);let o=d(2);return f(o.onResizeMove(i))})("pointerup",function(i){u(e);let o=d(2);return f(o.onResizeEnd(i))})("pointercancel",function(i){u(e);let o=d(2);return f(o.onResizeEnd(i))}),l(),s(1,"div",44)(2,"div",45)(3,"shared-dashboard-grid",46,1),_("filterSubmit",function(i){u(e);let o=d(2);return f(o.onSliderFilterSubmit(i))})("filterChange",function(i){u(e);let o=d(2);return f(o.onSliderFilterChange(i))})("widgetChartTypeChanged",function(i){u(e);let o=d(2);return f(o.onSliderWidgetPatched(i))})("widgetFiltersChanged",function(i){u(e);let o=d(2);return f(o.onSliderWidgetPatched(i))})("setAlert",function(i){u(e);let o=d(2);return f(o.onSetAlert(i))}),l(),s(5,"app-alert-drawer",47),_("closed",function(){u(e);let i=d(2);return f(i.onAlertClosed())})("saved",function(){u(e);let i=d(2);return f(i.onAlertClosed())}),l()()()}if(r&2){let e=d(2);c(3),C("widgets",e.sliderWidgets())("editMode",!1)("outerMargin",!1)("dashboardId",e.dashboardId())("dashboardFilters",e.activeDashboardFilters())("resolvedFilters",e.activeResolvedFilters())("persistToPublished",!0)("canSetAlert",!0)("canAddToStory",!1),c(2),C("open",e.alertDrawerOpen())("widget",e.alertWidget())("dashboardId",e.dashboardId())("source",e.alertSource())}}function Tn(r,t){if(r&1&&(s(0,"div",4)(1,"div",5),b(2,Sn,9,7),l(),b(3,On,6,13),l()),r&2){let e=d();te("chat-layout--resizing",e.isResizing()),c(),at("flex",e.chatColumnWidthPct()!==null?"0 0 "+e.chatColumnWidthPct()+"%":null),te("chat-column--split",!!e.dashboardConfig()&&!e.chatOnly()),c(),y(e.loadingChat()?-1:2),c(),y(e.dashboardConfig()&&!e.chatOnly()?3:-1)}}function An(r,t){if(r&1){let e=M();s(0,"div",48)(1,"label",49)(2,"input",50),_("input",function(i){u(e);let o=d();return f(o.queryString.set(i.target.value))})("keyup.enter",function(){u(e);let i=d();return f(i.postMessage())}),l(),s(3,"div",51)(4,"div",52)(5,"nile-glyph",53),_("click",function(){u(e);let i=d();return f(i.toggleMic())}),l(),s(6,"nile-glyph",54),_("click",function(){u(e);let i=d();return f(i.isGenerating()?i.cancelGenerate():i.postMessage())}),l()()()()()}if(r&2){let e=t.variant,n=d();te("input-query-container--welcome",e==="welcome"),c(2),C("value",n.queryString()),c(3),C("name",n.isMicListening()?"ng-mic":"ng-mic-off")("ngClass",le(8,pn,n.isMicListening())),c(),C("name",n.isGenerating()?"ng-circle-stop":"ng-send")("size",n.isGenerating()?"18":"16")("ngClass",le(10,hn,!n.isGenerating()&&!n.queryString()))}}var Ne=class r{constructor(t,e,n){this.chatService=t;this.openAiService=e;this.sanitizer=n;X(()=>{let o=this.dashboardId();o&&this.loadSuggestions(o)});let i=null;X(()=>{let o=this.dashboardConfig(),a=o?.id??null;a!==i&&(this.primedFilterWidgets.clear(),i=a);let g=(o?.widgets??[]).map(p=>({id:p.id,title:p.title??"",widgetType:p.type??"chart",layout:p.layout,config:p.nileConfig,drilldownBy:p.drilldownBy,queryMeta:p.queryMeta,dataSourceId:p.dataSourceId}));this.sliderWidgets.set(g),queueMicrotask(()=>this.primeFilterWidgets())})}chatService;openAiService;sanitizer;closePanel=new me;dashboardId=Y("");dashboardName=Y("");dashboardConfig=Y(null);chatOnly=Y(!1);initialPrompt=Y("");allChats=m([]);chatsDetails=m(null);isGenerating=m(!1);queryString=m("");searchTerm=m("");selectedChatContextId=m("");loadingChat=m(!1);loadingAllChat=m(!1);isDeleting=m(!1);isMicListening=m(!1);recognition=null;micBaseText="";silenceTimer=null;micSilenceMs=5e3;recommended=m([]);topRecommended=S(()=>this.recommended().slice(0,4));loadingSuggestions=m(!1);showPromptGallery=m(!1);chatColumnWidthPct=m(null);isResizing=m(!1);resizeRect=null;resizePointerId=null;resizeRafPending=!1;sliderWidgets=m([]);activeDashboardFilters=m(null);activeResolvedFilters=m(null);alertDrawerOpen=m(!1);alertWidget=m(null);onSetAlert(t){this.alertWidget.set(t),this.alertDrawerOpen.set(!0)}onSliderWidgetPatched(t){this.sliderWidgets.update(e=>e.map(n=>n.id===t.id?t:n))}onAlertClosed(){this.alertDrawerOpen.set(!1)}alertSource=S(()=>{let t=this.dashboardConfig();return t?{connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType}:null});sliderGridRef;applyingFilters=m(!1);filterSuggestTimers=new Map;filterSuggestSeq=new Map;primedFilterWidgets=new Set;applyFiltersSeq=0;applyFiltersAbort;generateAbort;formattedChats=S(()=>this.buildFormattedChats(this.allChats()));filteredFormattedChats=S(()=>{let t=this.formattedChats(),e=this.searchTerm().toLowerCase().trim();if(!e)return t;let n=i=>i.filter(o=>o.displayName.toLowerCase().includes(e));return{today:n(t.today),yesterday:n(t.yesterday),older:n(t.older)}});ngOnInit(){this.createNewChat();let t=this.initialPrompt();t&&(this.queryString.set(t),this.postMessage())}async loadSuggestions(t){this.loadingSuggestions.set(!0);try{let e=await this.chatService.getSuggestions(t);this.recommended.set(e.map(n=>({title:n})))}catch(e){console.error("Failed to load chat suggestions:",e),this.recommended.set([])}finally{this.loadingSuggestions.set(!1)}}runPrompt(t){this.queryString.set(t),this.postMessage()}openPromptGallery(){this.showPromptGallery.set(!0)}closePromptGallery(){this.showPromptGallery.set(!1)}onGalleryPromptClick(t){this.closePromptGallery(),this.runPrompt(t)}isFilterWidget(t){return t?.config?.chart?.type==="filter"}onSliderFilterChange(t){let e=t.widgetId,n=t.controlId;if(!e||!n)return;let i=this.dashboardId();if(!i)return;let o=this.filterSuggestTimers.get(e);o&&clearTimeout(o);let a=(t.query??"").trim();if(!a)return;let g=(this.filterSuggestSeq.get(e)??0)+1;this.filterSuggestSeq.set(e,g);let p=setTimeout(async()=>{try{let x=this.sliderWidgets(),N=await this.openAiService.filterSuggest(i,a,x,"published");if(this.filterSuggestSeq.get(e)!==g)return;this.applyFilterSuggestions(e,n,N)}catch(x){console.warn("Filter suggest failed:",x)}},400);this.filterSuggestTimers.set(e,p)}async onSliderFilterSubmit(t){let e=this.sliderWidgets(),n=e.filter(a=>!this.isFilterWidget(a));if(n.length===0)return;this.applyFiltersAbort?.abort();let i=new AbortController;this.applyFiltersAbort=i;let o=++this.applyFiltersSeq;this.applyingFilters.set(!0);try{let{widgets:a,resolvedFilters:g}=await this.openAiService.applyFilters(n,t.filters,this.dashboardId(),"published",i.signal,{mode:t.mode,prompt:t.prompt});if(o!==this.applyFiltersSeq)return;this.sliderWidgets.set(ge(e,a)),this.activeDashboardFilters.set(t.filters),this.activeResolvedFilters.set(g)}catch(a){if(a?.name==="AbortError"||o!==this.applyFiltersSeq)return;let g=a instanceof Error?a.message:"Failed to apply filters.";this.pushSystemMessage("error",`Apply filters failed: ${g}`)}finally{o===this.applyFiltersSeq&&this.applyingFilters.set(!1)}}primeFilterWidgets(){let t=this.dashboardId();if(!t)return;let e=this.sliderWidgets();for(let n of e){if(this.primedFilterWidgets.has(n.id))continue;let i=n.config?.chart;if(i?.type!=="filter")continue;let o=i.controls?.find(g=>g.variant==="expression"||g.variant==="hybrid");if(!o?.id)continue;this.primedFilterWidgets.add(n.id);let a=o.id;(async()=>{try{let g=await this.openAiService.filterSuggest(t,"",e,"published");this.applyFilterSuggestions(n.id,a,g)}catch(g){this.primedFilterWidgets.delete(n.id),console.warn("Filter suggest prime failed:",g)}})()}}applyFilterSuggestions(t,e,n){let i=Array.isArray(n.suggestions)?n.suggestions:[];if(!i.length){n.nextToken&&i.push({id:n.nextToken.value,label:n.nextToken.label,type:"attribute"});for(let o of n.completions)i.push({label:o,type:"suggestion"})}i.length!==0&&this.sliderGridRef?.patchFilterSuggestions(t,e,i)}onResizeStart(t){t.preventDefault();let e=t.currentTarget,n=e.parentElement;n&&(this.resizeRect=n.getBoundingClientRect(),e.setPointerCapture(t.pointerId),this.resizePointerId=t.pointerId,this.isResizing.set(!0))}onResizeMove(t){if(!this.isResizing()||!this.resizeRect)return;let n=(t.clientX-this.resizeRect.left)/this.resizeRect.width*100,i=Math.min(75,Math.max(20,n));this.chatColumnWidthPct.set(i),this.scheduleGridReflow()}onResizeEnd(t){let e=t.currentTarget;this.resizePointerId!==null&&e.hasPointerCapture?.(this.resizePointerId)&&e.releasePointerCapture(this.resizePointerId),this.isResizing.set(!1),this.resizeRect=null,this.resizePointerId=null,this.scheduleGridReflow()}scheduleGridReflow(){this.resizeRafPending||(this.resizeRafPending=!0,requestAnimationFrame(()=>{this.resizeRafPending=!1,window.dispatchEvent(new Event("resize"))}))}createNewChat(){let t={id:crypto.randomUUID(),displayName:"New Chat",createdOn:new Date().toISOString(),sessionId:crypto.randomUUID(),message:[]};this.allChats.update(e=>[t,...e]),this.getChatDetails(t.id)}getChatDetails(t){this.selectedChatContextId.set(t);let e=this.allChats().find(n=>n.id===t);e&&this.chatsDetails.set(e),this.loadingChat.set(!1)}deleteChat(t){if(this.isDeleting.set(!0),this.allChats.update(e=>e.filter(n=>n.id!==t)),this.isDeleting.set(!1),this.chatsDetails()?.id===t){let e=this.allChats();e.length?this.getChatDetails(e[0].id):this.createNewChat()}}onSearchChat(t){this.searchTerm.set(t)}async postMessage(){let t=this.queryString().trim();if(!t||this.isGenerating())return;this.chatsDetails()||this.createNewChat();let e=this.chatsDetails();e.message.unshift({role:"user",content:t}),e.displayName==="New Chat"&&(e.displayName=t.length>20?t.substring(0,20):t,this.allChats.update(i=>[...i])),this.chatsDetails.set(P({},e)),this.queryString.set(""),this.isGenerating.set(!0);let n=new AbortController;this.generateAbort=n;try{let i=await this.chatService.chat(t,this.dashboardId(),e.sessionId,n.signal);e.sessionId=i.sessionId,e.message.unshift({role:"assistant",content:this.sanitizeHtml(i.reply.content)})}catch(i){if(i instanceof Error&&i.name==="AbortError")e.message=e.message.filter((o,a)=>!(a===0&&o.role==="user"));else{let o=i instanceof Error?i.message:"Failed to get response.";this.pushSystemMessage("error",`Chat failed: ${o}`)}}finally{this.generateAbort===n&&(this.generateAbort=void 0),this.chatsDetails.set(P({},e)),this.isGenerating.set(!1)}}cancelGenerate(){this.generateAbort?.abort()}toggleMic(){this.isMicListening()?(this.clearSilenceTimer(),this.recognition?.stop()):this.startListening()}startListening(){let t=window,e=t.SpeechRecognition??t.webkitSpeechRecognition;e&&(this.micBaseText=this.queryString(),this.recognition=new e,this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang="en-US",this.recognition.onresult=n=>{let i="";for(let a=0;a<n.results.length;a++)i+=n.results[a][0].transcript;let o=this.micBaseText&&!this.micBaseText.endsWith(" ")?" ":"";this.queryString.set(this.micBaseText+o+i),this.resetSilenceTimer()},this.recognition.onend=()=>{this.clearSilenceTimer(),this.isMicListening.set(!1),this.recognition=null},this.recognition.start(),this.isMicListening.set(!0),this.resetSilenceTimer())}resetSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{this.silenceTimer=null,this.recognition?.stop(),this.queryString().trim()&&this.postMessage()},this.micSilenceMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}pushSystemMessage(t,e){let n=this.chatsDetails();if(!n){t==="success"&&this.showToast("Done",e);return}let i=String(e).trim().replace(/[.!?]+$/,"").replace(/[<>&]/g,a=>a==="<"?"&lt;":a===">"?"&gt;":"&amp;"),o=t==="error"?`ERROR: ${i}!`:i;n.message.unshift({role:"assistant",content:this.sanitizeHtml(`<p class="chat-system chat-system--${t}">${o}</p>`)}),this.chatsDetails.set(P({},n))}showToast(t,e){let n=document.createElement("nile-toast");n.variant="success",n.title=t,n.content=e,n.duration=5e3,n.closable=!0,n.toast(),Ft()}sanitizeHtml(t){return this.sanitizer.sanitize(tt.HTML,t)??""}buildFormattedChats(t){let e=[...t].sort((i,o)=>new Date(o.createdOn).getTime()-new Date(i.createdOn).getTime()),n={today:[],yesterday:[],older:[]};return e.forEach(i=>{this.isToday(i.createdOn)?n.today.push(i):this.isYesterday(i.createdOn)?n.yesterday.push(i):n.older.push(i)}),n}isToday(t){let e=new Date(t),n=new Date;return e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()}isYesterday(t){let e=new Date(t),n=new Date;return n.setDate(n.getDate()-1),e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()}static \u0275fac=function(e){return new(e||r)(we(Re),we($),we(gt))};static \u0275cmp=z({type:r,selectors:[["db-ai-prompt-panel"]],viewQuery:function(e,n){if(e&1&&ae(ln,5),e&2){let i;j(i=Z())&&(n.sliderGridRef=i.first)}},inputs:{dashboardId:[1,"dashboardId"],dashboardName:[1,"dashboardName"],dashboardConfig:[1,"dashboardConfig"],chatOnly:[1,"chatOnly"],initialPrompt:[1,"initialPrompt"]},outputs:{closePanel:"closePanel"},features:[se([])],decls:4,vars:1,consts:[["promptInput",""],["sliderGrid",""],[1,"qna-panel"],[1,"chat-layout",3,"chat-layout--resizing"],[1,"chat-layout"],[1,"chat-column"],[1,"chat-header"],["name","close","size","16",1,"close-panel-icon",3,"click"],[1,"chat-message-container",3,"ngClass"],[1,"welcome-section"],[1,"generating-loader"],[1,"contained-panel","prompt-gallery-panel"],[1,"ai-badge","ai-badge--md","welcome-icon-wrap"],["color","#2970ff","name","smartcode","size","20"],[1,"welcome-title"],[1,"welcome-subtitle"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"recommended"],[1,"recommended-box","skeleton-box"],[2,"width","100%","height","64px","border-radius","12px"],["type","button",1,"recommended-box"],["type","button",1,"browse-more",3,"click"],["name","ng-lightbulb-05","method","stroke","size","14"],["type","button",1,"recommended-box",3,"click"],[1,"ai-badge","ai-badge--sm","rec-icon-wrap"],["color","#2970ff","name","ng-lightbulb-05","size","16","method","stroke"],[1,"rec-title"],[3,"name","size"],[1,"generating-text"],[1,"user-row"],[1,"user"],[1,"ai-badge","ai-badge--sm","assistant-icon"],["name","ng-stars-02","method","stroke","size","16","color","#2970ff"],[1,"assistant"],[1,"assistant-body",3,"innerHTML"],[4,"ngTemplateOutlet"],[1,"contained-panel__header"],[1,"contained-panel__title"],["type","button","aria-label","Close",1,"contained-panel__close",3,"click"],["name","close","size","16"],[1,"contained-panel__body"],[1,"prompt-gallery-subtitle"],[1,"prompt-gallery"],["role","separator","aria-orientation","vertical","aria-label","Resize chat column",1,"chat-layout__resizer",3,"pointerdown","pointermove","pointerup","pointercancel"],[1,"dashboard-slider"],[1,"dashboard-slider__body"],[3,"filterSubmit","filterChange","widgetChartTypeChanged","widgetFiltersChanged","setAlert","widgets","editMode","outerMargin","dashboardId","dashboardFilters","resolvedFilters","persistToPublished","canSetAlert","canAddToStory"],[3,"closed","saved","open","widget","dashboardId","source"],[1,"input-query-container"],[1,"chat-input-pill"],["type","text","placeholder","Enter your query",1,"input-query",3,"input","keyup.enter","value"],[1,"pill-toolbar"],[1,"pill-toolbar__right"],["method","stroke",1,"mic-icon",3,"click","name","ngClass"],["method","stroke",1,"send-icon",3,"click","name","size","ngClass"]],template:function(e,n){e&1&&(s(0,"div",2),b(1,Tn,4,8,"div",3),l(),L(2,An,7,12,"ng-template",null,0,fe)),e&2&&(c(),y(n.loadingAllChat()?-1:1))},dependencies:[De,lt,Me,Rt,Ae,Ee],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:0}.qna-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--ng-colors-bg-secondary, #f9fafb);font-family:var(--ng-font-family-body)}.chat-layout[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:row;overflow:hidden;min-height:0;container-type:inline-size}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%]{cursor:col-resize;-webkit-user-select:none;user-select:none}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%] .chat-column[_ngcontent-%COMP%]{transition:none!important}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%] .chat-layout__resizer[_ngcontent-%COMP%]:after{opacity:1}.chat-layout__resizer[_ngcontent-%COMP%]{flex:0 0 1px;align-self:stretch;cursor:col-resize;touch-action:none;-webkit-user-select:none;user-select:none;position:relative;background:transparent}.chat-layout__resizer[_ngcontent-%COMP%]:before{content:"";position:absolute;top:0;bottom:0;left:50%;transform:translate(-50%);width:1px;background:var(--ng-colors-border-secondary, #e9eaeb);transition:background .15s}.chat-layout__resizer[_ngcontent-%COMP%]:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:4px;height:36px;border-radius:999px;background:#2970ff;opacity:0;transition:opacity .15s;pointer-events:none}.chat-layout__resizer[_ngcontent-%COMP%]:hover:before{background:#2970ff;opacity:0;transition:opacity .15s;pointer-events:none}.chat-layout__resizer[_ngcontent-%COMP%]:hover:after{opacity:1}.dashboard-slider[_ngcontent-%COMP%]{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden;min-width:0;min-height:0;background:var(--ng-colors-bg-secondary, #f9fafb);animation:_ngcontent-%COMP%_slider-in .25s ease-out}.dashboard-slider__header[_ngcontent-%COMP%]{height:56px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box}.dashboard-slider__title[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27)}.dashboard-slider__body[_ngcontent-%COMP%]{flex:1;min-height:0;min-width:0;overflow:auto;padding:8px}.dashboard-slider__body[_ngcontent-%COMP%] > shared-dashboard-grid[_ngcontent-%COMP%]{display:block;min-width:calc(66.6667cqw - 32px)}@keyframes _ngcontent-%COMP%_slider-in{0%{transform:translate(24px);opacity:0}to{transform:translate(0);opacity:1}}.chat-column[_ngcontent-%COMP%]{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden;min-width:0;position:relative;background:#fff;container-type:inline-size;transition:flex-basis .3s ease,flex .3s ease}.chat-column.chat-column--split[_ngcontent-%COMP%]{flex:0 0 33.333%}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%]{padding:16px 16px 8px;flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:flex-end}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%] .close-panel-icon[_ngcontent-%COMP%]{cursor:pointer;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%] .close-panel-icon[_ngcontent-%COMP%]:hover{color:var(--ng-colors-text-primary-900, #181d27)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%]{flex:1;overflow:auto;padding:20px 24px;display:flex;flex-direction:column-reverse}.chat-column[_ngcontent-%COMP%] .chat-message-container.recommend-window[_ngcontent-%COMP%]{justify-content:center;align-items:center;padding:32px 40px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user-row[_ngcontent-%COMP%]{display:flex;flex-direction:row-reverse;justify-content:flex-start;align-items:flex-start;gap:8px;margin-bottom:20px;margin-top:8px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user[_ngcontent-%COMP%]{flex:0 1 auto;min-width:0}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{background:#eff4ff;color:var(--ng-colors-text-primary-900, #181d27);padding:9px 14px;border-radius:14px 14px 2px;font-size:14px;display:inline-block;max-width:100%;text-align:left}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user-icon[_ngcontent-%COMP%]{flex-shrink:0;width:28px;height:28px;border-radius:50%;background:#eff4ff;color:#2970ff;display:inline-flex;align-items:center;justify-content:center}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .assistant-icon[_ngcontent-%COMP%]{margin-bottom:6px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .assistant[_ngcontent-%COMP%]{padding:14px 16px;background:var(--ng-colors-bg-secondary, #f9fafb);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:2px 14px 14px;margin-bottom:14px;font-size:14px;line-height:1.65;color:var(--ng-colors-text-primary-900, #181d27)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .generating-loader[_ngcontent-%COMP%]{padding:10px 14px;height:40px;display:flex;gap:8px;align-items:center;background:var(--ng-colors-bg-secondary, #f9fafb);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:8px;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862);width:fit-content}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;gap:12px;width:100%;max-width:820px;text-align:center}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-icon-wrap[_ngcontent-%COMP%]{margin-bottom:4px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-title[_ngcontent-%COMP%]{margin:0;font-size:22px;font-weight:700;color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.02em}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-subtitle[_ngcontent-%COMP%]{margin:0 0 8px;font-size:14px;color:var(--ng-colors-text-tertiary-600, #535862);max-width:440px;line-height:1.6}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .browse-more[_ngcontent-%COMP%]{margin-top:4px;align-self:flex-end;display:inline-flex;align-items:center;gap:6px;padding:6px 4px;background:transparent;border:0;cursor:pointer;font-size:12px;font-weight:500;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .browse-more[_ngcontent-%COMP%]:hover{color:#2970ff}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;width:100%}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px;font:inherit;color:inherit;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:14px;padding:18px;cursor:pointer;transition:border-color .18s,box-shadow .18s,transform .15s;background:#fff;text-align:left}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]:hover{border-color:#2970ff;box-shadow:0 6px 24px #2970ff1a;transform:translateY(-2px)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%] .rec-title[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);text-transform:capitalize;line-height:1.4}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%]{padding:14px 24px 18px;display:flex;justify-content:center;flex-shrink:0;background:#fff}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .chat-input-pill[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;width:100%;max-width:760px;padding:14px 16px 12px;background:#fff;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:24px;box-shadow:0 1px 2px #1018280a,0 8px 24px #1018280f;cursor:text;transition:border-color .15s,box-shadow .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .chat-input-pill[_ngcontent-%COMP%]:focus-within{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff1f}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .input-query[_ngcontent-%COMP%]{width:100%;min-width:0;border:0;outline:0;background:transparent;padding:6px 2px;font:inherit;font-size:15px;color:var(--ng-colors-text-primary-900, #181d27);text-overflow:ellipsis}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .input-query[_ngcontent-%COMP%]::placeholder{color:var(--ng-colors-text-tertiary-600, #717680);overflow:hidden;text-overflow:ellipsis}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .pill-toolbar[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:flex-end;gap:8px}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .pill-toolbar__right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon[_ngcontent-%COMP%]{cursor:pointer;flex-shrink:0;transition:opacity .15s,transform .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon[_ngcontent-%COMP%]:hover{transform:translate(2px)}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon.disabled[_ngcontent-%COMP%]{opacity:.2;pointer-events:none}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon[_ngcontent-%COMP%]{cursor:pointer;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon[_ngcontent-%COMP%]:hover{color:#2970ff}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon.mic-listening[_ngcontent-%COMP%]{color:#e53e3e;animation:_ngcontent-%COMP%_mic-pulse 1.2s ease-in-out infinite}.chat-column[_ngcontent-%COMP%] .input-query-container.input-query-container--welcome[_ngcontent-%COMP%]{border-top:0;background:transparent;padding:4px 0 12px;width:100%;max-width:680px}@keyframes _ngcontent-%COMP%_mic-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(1.3)}}.dashboard-slider__body[_ngcontent-%COMP%]{padding:unset}.contained-panel[_ngcontent-%COMP%]{position:absolute;inset:0;display:flex;flex-direction:column;background:#fff;border-left:1px solid var(--ng-colors-border-secondary, #e9eaeb);box-shadow:-8px 0 24px #10182814;z-index:var(--z-floating);animation:_ngcontent-%COMP%_contained-slide .25s ease-out}.contained-panel__header[_ngcontent-%COMP%]{height:56px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:space-between;gap:8px;box-sizing:border-box}.contained-panel__close[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:4px;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;transition:color .15s;flex-shrink:0}.contained-panel__close[_ngcontent-%COMP%]:hover{color:var(--ng-colors-text-primary-900, #181d27)}.contained-panel__title[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.contained-panel__body[_ngcontent-%COMP%]{flex:1;min-height:0;overflow:auto;padding:16px 20px 20px}.prompt-gallery-subtitle[_ngcontent-%COMP%]{margin:0 0 24px;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862)}.prompt-gallery[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr;gap:12px;padding:6px 6px 8px}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;gap:10px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;padding:12px 16px;cursor:pointer;background:#fff;text-align:left;font:inherit;color:inherit;transition:border-color .18s,box-shadow .18s,transform .15s}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]:hover{border-color:#2970ff;box-shadow:0 6px 24px #2970ff1a;transform:translateY(-2px)}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%] .rec-title[_ngcontent-%COMP%]{font-size:13px;font-weight:500;color:var(--ng-colors-text-secondary-700, #414651);line-height:1.45}@keyframes _ngcontent-%COMP%_contained-slide{0%{transform:translate(8px);opacity:0}to{transform:translate(0);opacity:1}}.chat-system[_ngcontent-%COMP%]{margin:4px 0;font-size:13px;line-height:1.4;color:var(--ng-colors-text-tertiary-600, #535862)}.chat-system--error[_ngcontent-%COMP%]{color:var(--ng-colors-fg-error-primary, #d92d20);font-weight:500}']})};var Fn=r=>[r];function En(r,t){if(r&1&&ue(0,"nile-progress-bar",4),r&2){let e=d();ot("value",e.percent())}}var ze=class r{streamId;done=new me;failed=new me;streamService=v(Lt);totalCharts=m(0);widgetPhases=m([]);phaseLabel=m("Connecting to your data\u2026");dashboardNumber=m(0);barKey=m(0);pendingNewDashboard=!0;readyCount=S(()=>this.widgetPhases().filter(t=>t==="building"||t==="saving").length);percent=S(()=>{let t=this.totalCharts();if(!t)return 0;let e=this.widgetPhases(),n=0;for(let i=0;i<t;i++){let o=e[i];n+=o==="building"||o==="saving"?1:o==="querying"?.66:o==="analyzing"?.33:0}return Math.round(Math.min(1,n/t)*100)});countLabel=S(()=>{let t=this.totalCharts(),e=this.dashboardNumber();return!t||!e?"":`Dashboard ${e} \xB7 ${this.readyCount()} of ${t} charts`});finished=!1;dispose=null;ngOnInit(){if(!this.streamId){this.failed.emit();return}this.dispose=this.streamService.stream(this.streamId,t=>this.onEvent(t))}ngOnDestroy(){this.teardown()}onEvent(t){switch(t.kind){case"progress":{this.pendingNewDashboard&&(this.dashboardNumber.update(e=>e+1),this.pendingNewDashboard=!1),this.totalCharts.set(t.totalWidgets),this.widgetPhases.update(e=>{let n=[...e];return n[t.widgetIndex]=Ht(n[t.widgetIndex],t.phase),n}),this.phaseLabel.set(t.label);break}case"dashboard-start":{this.resetForNextDashboard(t.dashboardName?`Setting up ${t.dashboardName}\u2026`:"Preparing the next dashboard\u2026");break}case"saved":{this.resetForNextDashboard("Preparing the next dashboard\u2026");break}case"complete":{t.dashboardIds.length>0?this.finish(()=>this.done.emit(t.dashboardIds)):this.finish(()=>this.failed.emit());break}case"error":{t.dashboardIds.length>0?this.finish(()=>this.done.emit(t.dashboardIds)):this.finish(()=>this.failed.emit());break}}}resetForNextDashboard(t){this.barKey.update(e=>e+1),this.pendingNewDashboard=!0,this.totalCharts.set(0),this.widgetPhases.set([]),this.phaseLabel.set(t)}finish(t){this.finished||(this.finished=!0,this.teardown(),t())}teardown(){this.dispose?.(),this.dispose=null}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["app-dashboard-generating"]],inputs:{streamId:"streamId"},outputs:{done:"done",failed:"failed"},decls:13,vars:4,consts:[["role","status","aria-live","polite",1,"genbar"],["variant","informative","size","medium","pulse","",1,"genbar__light"],[1,"genbar__title"],["aria-hidden","true",1,"genbar__divider"],[1,"genbar__bar",3,"value"],[1,"genbar__count"],[1,"genbar__live"],["aria-hidden","true",1,"genbar__spinner"],[1,"genbar__status"]],template:function(e,n){e&1&&(oe(0,"div",0),ue(1,"nile-status-light",1),oe(2,"span",2),w(3,"Generating your dashboards"),Pe(),ue(4,"span",3),F(5,En,1,1,"nile-progress-bar",4,rt),oe(7,"span",5),w(8),Pe(),oe(9,"div",6),ue(10,"nile-spinner",7),oe(11,"span",8),w(12),Pe()()()),e&2&&(c(5),E(le(2,Fn,n.barKey())),c(3),W(n.countLabel()),c(4),W(n.phaseLabel()))},styles:["[_nghost-%COMP%]{display:block;width:100%}.genbar[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-md, 12px);width:100%;min-width:0;padding-inline-start:var(--ng-spacing-lg, 16px)}.genbar__light[_ngcontent-%COMP%]{flex:none}.genbar__title[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-semibold, 600);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-primary-900, #181d27);white-space:nowrap}.genbar__divider[_ngcontent-%COMP%]{width:1px;height:20px;background:var(--ng-colors-border-secondary, #e9eaeb);flex:none}.genbar__bar[_ngcontent-%COMP%]{width:160px;flex:none}.genbar__count[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap}.genbar__live[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;margin-left:auto;flex:none;min-width:0}.genbar__spinner[_ngcontent-%COMP%]{font-size:14px;--indicator-color: #2970ff;--track-color: rgba(41, 112, 255, .2);flex:none}.genbar__status[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:260px}@media(max-width:760px){.genbar__divider[_ngcontent-%COMP%], .genbar__bar[_ngcontent-%COMP%], .genbar__count[_ngcontent-%COMP%]{display:none}}"]})};var In=["tabsScroller"],Kt=()=>({subtitle:"Explore your dashboards or ask your data a question"}),Rn=()=>({subtitle:"Setting up your initial dashboards \u2014 crafting a starter set from your data."}),Nn=(r,t)=>t.id;function zn(r,t){if(r&1&&(s(0,"header",8),V(1,16),l()),r&2){d(2);let e=R(5);c(),C("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Kt))}}function Vn(r,t){if(r&1&&h(0,"nile-skeleton-loader",11),r&2){let e=t.$implicit;ee("width",e)}}function Wn(r,t){r&1&&h(0,"nile-skeleton-loader",14)}function qn(r,t){r&1&&V(0)}function Hn(r,t){if(r&1&&(s(0,"div",5)(1,"div",7),b(2,zn,2,3,"header",8),s(3,"div",9)(4,"div",10),F(5,Vn,1,1,"nile-skeleton-loader",11,U),l(),h(7,"span",12)(8,"nile-skeleton-loader",13),F(9,Wn,1,0,"nile-skeleton-loader",14,U),l(),L(11,qn,1,0,"ng-container",15),l()()),r&2){let e=d(),n=R(7);c(2),y(e.showHeader()?2:-1),c(3),E(e.skeletonTabWidths),c(4),E(e.skeletonActionBtns),c(2),C("ngTemplateOutlet",n)}}function Ln(r,t){if(r&1&&(s(0,"header",8),V(1,16),l()),r&2){d(2);let e=R(5);c(),C("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Rn))}}function Gn(r,t){if(r&1){let e=M();s(0,"app-dashboard-generating",18),_("done",function(i){u(e);let o=d(2);return f(o.onGenerationDone(i))})("failed",function(){u(e);let i=d(2);return f(i.onGenerationFailed())}),l()}if(r&2){let e=d(2);C("streamId",e.generationStreamId())}}function $n(r,t){r&1&&V(0)}function Bn(r,t){if(r&1&&(s(0,"div",6)(1,"div",7),b(2,Ln,2,3,"header",8),s(3,"div",9),b(4,Gn,1,1,"app-dashboard-generating",17),l()(),L(5,$n,1,0,"ng-container",15),l()),r&2){let e=d(),n=R(7);c(2),y(e.showHeader()?2:-1),c(2),y(e.features().autoGenerate?4:-1),c(),C("ngTemplateOutlet",n)}}function Un(r,t){if(r&1&&(s(0,"header",8),V(1,16),l()),r&2){d(2);let e=R(5);c(),C("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Kt))}}function jn(r,t){r&1&&h(0,"nile-glyph",47)}function Zn(r,t){if(r&1){let e=M();s(0,"span",49),_("click",function(i){return i.stopPropagation()}),s(1,"input",50,3),_("input",function(){u(e);let i=R(2),o=d(4);return f(o.onRenameInputChange(i.value))})("keydown",function(i){u(e);let o=d().$implicit,a=d(3);return f(a.onRenameInputKeydown(i,o))})("click",function(i){return i.stopPropagation()}),l(),s(3,"button",51),_("click",function(i){u(e);let o=d().$implicit,a=d(3);return f(a.commitRenameDashboard(o,i))}),h(4,"nile-glyph",52),l()()}if(r&2){let e=d().$implicit,n=d(3);c(),C("value",n.renamingValue())("disabled",n.isRenamingDashboard()),ee("data-dashboard-id",e.id),c(2),C("disabled",n.isRenamingDashboard())}}function Yn(r,t){if(r&1){let e=M();s(0,"button",55),_("click",function(i){u(e);let o=d(2).$implicit,a=d(3);return f(a.startRenameDashboard(o,i))}),h(1,"nile-glyph",56),l()}}function Kn(r,t){if(r&1&&(s(0,"span",53),w(1),l(),b(2,Yn,2,0,"button",54)),r&2){let e=d().$implicit,n=d(3);c(),W(e.name),c(),y(n.features().rename&&!e.isAutoGenerated?2:-1)}}function Qn(r,t){if(r&1){let e=M();s(0,"nile-nav-tab",46),_("click",function(){let i=u(e).$implicit,o=d(3);return f(o.setActiveTab(i.id))}),b(1,jn,1,0,"nile-glyph",47),b(2,Zn,5,4,"span",48)(3,Kn,3,2),l()}if(r&2){let e=t.$implicit,n=d(3);ee("panel",e.id),c(),y(e.isAutoGenerated?1:-1),c(),y(n.renamingDashboardId()===e.id?2:3)}}function Jn(r,t){if(r&1){let e=M();s(0,"app-time-range-picker",57),_("apply",function(i){u(e);let o=d(3);return f(o.onTimeRangeApply(i))}),l()}if(r&2){let e=d(3);C("resetKey",e.activeTabId())}}function Xn(r,t){r&1&&h(0,"span",37)}function ei(r,t){if(r&1){let e=M();s(0,"nile-lite-tooltip",42)(1,"button",58),_("click",function(){u(e);let i=d(3);return f(i.refreshActiveDashboard())}),h(2,"nile-glyph",59),l()()}if(r&2){let e=d(3);c(),C("disabled",!e.activeTabId()||e.refreshingDashboard()),c(),te("home-refresh-glyph--spinning",e.refreshingDashboard())}}function ti(r,t){if(r&1){let e=M();s(0,"nile-lite-tooltip",44)(1,"button",60),_("click",function(){u(e);let i=d(3);return f(i.selectHomeMenuItem("executiveSummary"))}),h(2,"nile-glyph",61),l()()}}function ni(r,t){if(r&1){let e=M();s(0,"nile-dropdown",62),_("nile-hide",function(){u(e);let i=d(3);return f(i.downloadMenuOpen.set(!1))}),s(1,"nile-lite-tooltip",63)(2,"button",64),_("click",function(){u(e);let i=d(3);return f(i.downloadMenuOpen.set(!i.downloadMenuOpen()))}),h(3,"nile-glyph",65),l()(),s(4,"nile-menu")(5,"nile-menu-item",66),_("click",function(){u(e);let i=d(3);return i.downloadMenuOpen.set(!1),f(i.selectHomeMenuItem("exportPdf"))}),h(6,"nile-glyph",67),w(7," Download as PDF "),l(),s(8,"nile-menu-item",66),_("click",function(){u(e);let i=d(3);return i.downloadMenuOpen.set(!1),f(i.selectHomeMenuItem("exportPng"))}),h(9,"nile-glyph",68),w(10," Download as PNG "),l()()()}if(r&2){let e=d(3);C("open",e.downloadMenuOpen())}}function ii(r,t){if(r&1){let e=M();s(0,"div",23)(1,"button",24),_("click",function(){u(e);let i=d(2);return f(i.scrollTabs(-1))}),h(2,"nile-glyph",25),l(),s(3,"div",26,2),_("scroll",function(){u(e);let i=d(2);return f(i.onTabsScroll())}),s(5,"nile-nav-tab-group",27),h(6,"nile-nav-tab",28),F(7,Qn,4,3,"nile-nav-tab",29,Nn),l()(),s(9,"button",30),_("click",function(){u(e);let i=d(2);return f(i.scrollTabs(1))}),h(10,"nile-glyph",31),l(),h(11,"span",12),b(12,Jn,1,1,"app-time-range-picker",32),s(13,"nile-dropdown",33),_("nile-hide",function(){u(e);let i=d(2);return f(i.categoryFilterOpen.set(!1))}),s(14,"nile-lite-tooltip",34)(15,"button",35),_("click",function(){u(e);let i=d(2);return f(i.categoryFilterOpen.set(!i.categoryFilterOpen()))}),h(16,"nile-glyph",36),b(17,Xn,1,0,"span",37),l()(),s(18,"shared-category-filter-row",38),_("mousedown",function(i){return i.stopPropagation()})("selectionChange",function(i){u(e);let o=d(2);return f(o.onCategoryFilterChange(i))}),l()(),s(19,"nile-lite-tooltip",39)(20,"button",40),_("click",function(){u(e);let i=d(2);return f(i.goToCreateDashboard())}),h(21,"nile-glyph",41),l()(),b(22,ei,3,3,"nile-lite-tooltip",42),s(23,"div",43),b(24,ti,3,0,"nile-lite-tooltip",44),b(25,ni,11,1,"nile-dropdown",45),l()()}if(r&2){let e=d(2);te("is-scrollable",e.canScrollLeft()||e.canScrollRight()),c(),C("disabled",!e.canScrollLeft()),c(4),ee("value",e.activeTabId()||"__sentinel__"),c(2),E(e.visibleDashboards()),c(2),C("disabled",!e.canScrollRight()),c(3),y(e.activeTabId()?12:-1),c(),C("open",e.categoryFilterOpen()),c(4),y(e.selectedCategory()?17:-1),c(),C("selected",e.selectedCategory()),c(2),C("disabled",e.creatingDashboard()),c(2),y(e.features().refresh?22:-1),c(2),y(e.features().executiveSummary?24:-1),c(),y(e.features().export?25:-1)}}function ri(r,t){if(r&1&&(s(0,"nile-nav-tab-panel",69),h(1,"app-dashboard-viewer",71),l()),r&2){let e=d(3);ee("name",e.activeTabId()),c(),C("config",e.loadedDashboards().get(e.activeTabId()))}}function oi(r,t){r&1&&V(0)}function ai(r,t){if(r&1&&(s(0,"div",70),L(1,oi,1,0,"ng-container",15),l()),r&2){d(3);let e=R(7);c(),C("ngTemplateOutlet",e)}}function si(r,t){if(r&1&&b(0,ri,2,2,"nile-nav-tab-panel",69)(1,ai,2,1,"div",70),r&2){let e=d(2);y(e.loadedDashboards().has(e.activeTabId())?0:e.isTabLoading()||e.refreshingDashboard()?1:-1)}}function li(r,t){if(r&1){let e=M();s(0,"div",20)(1,"h2",72),w(2,"No dashboards in this category"),l(),s(3,"p",73),w(4,"Try a different category, or clear the filter to see everything."),l(),s(5,"nile-button",74),_("click",function(){u(e);let i=d(2);return f(i.onCategoryFilterChange(null))}),w(6," Clear filter "),l()()}}function di(r,t){if(r&1){let e=M();s(0,"div",20)(1,"div",75),Qe(),s(2,"svg",76),h(3,"rect",77)(4,"rect",78)(5,"rect",79),s(6,"rect",80),h(7,"animate",81)(8,"animate",82),l(),s(9,"rect",83),h(10,"animate",84)(11,"animate",85),l(),s(12,"rect",86),h(13,"animate",87)(14,"animate",88),l(),s(15,"rect",89),h(16,"animate",90)(17,"animate",91),l(),s(18,"rect",92),h(19,"animate",93)(20,"animate",94),l(),h(21,"rect",95)(22,"rect",96)(23,"circle",97),s(24,"circle",98),h(25,"animate",99),l(),h(26,"rect",100)(27,"rect",101),s(28,"path",102),h(29,"animate",103),l(),s(30,"circle",104),h(31,"animate",105),l()()(),Je(),s(32,"h2",72),w(33,"Build your dashboard"),l(),s(34,"p",73),w(35," Tap the below button to generate dashboard. "),l(),s(36,"nile-button",106),_("click",function(){u(e);let i=d(2);return f(i.goToCreateDashboard())}),h(37,"nile-glyph",107),w(38," Create dashboard "),l()()}if(r&2){let e=d(2);c(36),ee("disabled",e.creatingDashboard()?"":null)}}function ci(r,t){if(r&1){let e=M();s(0,"db-ai-prompt-panel",108),_("closePanel",function(){u(e);let i=d(2);return f(i.showAiPanel.set(!1))}),l()}if(r&2){let e=d(2);C("dashboardId",e.activeTabId())("dashboardName",e.activeDashboardName())("dashboardConfig",e.loadedDashboards().get(e.activeTabId())??null)("chatOnly",e.aiChatOnly())("initialPrompt",e.aiInitialPrompt())}}function gi(r,t){if(r&1){let e=M();s(0,"div",6)(1,"div",7),b(2,Un,2,3,"header",8),b(3,ii,26,13,"div",19),b(4,si,2,1)(5,li,7,0,"div",20)(6,di,39,1,"div",20),s(7,"nile-drawer",21),_("nile-request-close",function(){u(e);let i=d();return f(i.showAiPanel.set(!1))}),b(8,ci,1,5,"db-ai-prompt-panel",22),l()()()}if(r&2){let e=d();c(2),y(e.showHeader()?2:-1),c(),y(e.allDashboards().length>0?3:-1),c(),y(e.activeTabId()?4:e.allDashboards().length>0?5:e.allDashboards().length===0?6:-1),c(3),C("open",e.showAiPanel()),c(),y(e.features().aiPrompt&&e.showAiPanel()?8:-1)}}function pi(r,t){if(r&1&&(s(0,"div",109)(1,"h1",110),w(2,"Dashboards"),l(),s(3,"p",111),w(4),l()()),r&2){let e=t.subtitle;c(4),W(e)}}function hi(r,t){r&1&&(s(0,"div",114)(1,"div",117),h(2,"nile-skeleton-loader",118)(3,"nile-skeleton-loader",119),l(),h(4,"nile-skeleton-loader",120),s(5,"div",121),h(6,"nile-skeleton-loader",122)(7,"nile-skeleton-loader",123),l(),h(8,"nile-skeleton-loader",124),l())}function mi(r,t){r&1&&(s(0,"div",116)(1,"div",125)(2,"div",126),h(3,"nile-skeleton-loader",127)(4,"nile-skeleton-loader",128),l(),h(5,"nile-skeleton-loader",129),l(),h(6,"nile-skeleton-loader",130),l())}function ui(r,t){if(r&1&&(s(0,"div",112)(1,"div",113),F(2,hi,9,0,"div",114,U),l(),s(4,"div",115),F(5,mi,7,0,"div",116,U),l()()),r&2){let e=d();c(2),E(e.skeletonKpis),c(3),E(e.skeletonWidgets)}}var Be=4,Ve=class r{MAX_TABS=Be;tabsScrollerEl;dashboardViewerRef;timeRangePickerRef;onTimeRangeApply(t){this.dashboardViewerRef?.applyTimeRange(t)}tabsScrollLeft=m(0);tabsClientWidth=m(0);tabsScrollWidth=m(0);canScrollLeft=S(()=>this.tabsScrollLeft()>0);canScrollRight=S(()=>this.tabsScrollLeft()+this.tabsClientWidth()<this.tabsScrollWidth()-1);onTabsScroll(){this.updateTabsScrollState()}updateTabsScrollState(){let t=this.tabsScrollerEl?.nativeElement;t&&(this.tabsScrollLeft.set(t.scrollLeft),this.tabsClientWidth.set(t.clientWidth),this.tabsScrollWidth.set(t.scrollWidth))}scrollTabs(t){let e=this.tabsScrollerEl?.nativeElement;e&&e.scrollBy({left:t*e.clientWidth*.8,behavior:"smooth"})}scrollActiveTabIntoView(){let t=this.tabsScrollerEl?.nativeElement;if(!t)return;let e=this.activeTabId();if(!e)return;let n=window.CSS&&CSS.escape?CSS.escape(e):e.replace(/"/g,'\\"'),i=t.querySelector(`nile-nav-tab[panel="${n}"]`);if(!i)return;let o=i.getBoundingClientRect(),a=t.getBoundingClientRect(),g=16;o.right>a.right?t.scrollBy({left:o.right-a.right+g,behavior:"smooth"}):o.left<a.left&&t.scrollBy({left:o.left-a.left-g,behavior:"smooth"})}onWindowResize=()=>this.ngZone.run(()=>this.updateTabsScrollState());showAiPanel=m(!1);aiChatOnly=m(!1);aiInitialPrompt=m("");allDashboards=m([]);selectedCategory=m(null);dashboardCategories=Gt;categoryFilterOpen=m(!1);visibleDashboards=S(()=>{let t=this.selectedCategory(),e=this.allDashboards();return t?e.filter(n=>n.category?.includes(t)):e});activeTabs=m([]);activeTabId=m("");loadedDashboards=m(new Map);isLoading=m(!0);isTabLoading=m(!1);skeletonTabWidths=[72,220,140];skeletonKpis=Array.from({length:4});skeletonWidgets=Array.from({length:4});skeletonActionBtns=Array.from({length:4});showMore=S(()=>this.allDashboards().length>0);activeDashboardName=S(()=>this.allDashboards().find(t=>t.id===this.activeTabId())?.name??"");activeConfig=S(()=>this.loadedDashboards().get(this.activeTabId())??null);isExporting=m(!1);showExportDropdown=m(!1);downloadMenuOpen=m(!1);creatingDashboard=m(!1);generationStreamId=m("");isGenerating=S(()=>this.generationStreamId()!=="");generationSettled=!1;showHeader(){return D().ui.header}features(){return D().features}copy(){return D().copy}service=v(he);ngZone=v(xe);el=v(re);navigator=v(G);routeProgress=v(It);autoDashboard=v(qt);goToCreateDashboard(){this.creatingDashboard()||(this.creatingDashboard.set(!0),this.navigator.toAskAquera())}constructor(){X(()=>{this.activeTabId(),this.allDashboards(),queueMicrotask(()=>this.scrollActiveTabIntoView())})}ngAfterViewChecked(){this.updateTabsScrollState()}onExportTriggerClick(){this.showExportDropdown.set(!this.showExportDropdown())}selectHomeMenuItem(t){if(t==="askAi")this.aiChatOnly.set(!0),this.aiInitialPrompt.set(""),this.showAiPanel.set(!0);else if(t==="executiveSummary"){let e=this.activeTabId();e&&this.navigator.toAskAqueraDashboard(e,{summary:1})}else t==="exportPdf"?this.exportDashboardPdf():t==="exportPng"&&this.exportDashboardPng()}getDashboardTarget(){let t=this.activeTabId();return this.el.nativeElement.querySelector(`nile-nav-tab-panel[name="${t}"] app-dashboard-viewer gridster`)}async exportDashboardPdf(){if(this.isExporting())return;let t=this.getDashboardTarget();if(t){this.showExportDropdown.set(!1),this.isExporting.set(!0),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=t.scrollWidth,n=t.scrollHeight,i=await Ge(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),o=this.activeDashboardName()||"Dashboard",a=90,g=new Wt({orientation:e>n?"landscape":"portrait",unit:"px",format:[e,n+a]});g.setFillColor(245,245,248),g.rect(0,0,e,a,"F"),g.setFont("helvetica","bold"),g.setFontSize(28),g.setTextColor(50,50,60),g.text(o,e/2,a/2+7,{align:"center"}),g.addImage(i,"JPEG",0,a,e,n),g.save(`${o}.pdf`)}finally{this.isExporting.set(!1)}}}async exportDashboardPng(){if(this.isExporting())return;let t=this.getDashboardTarget();if(t){this.showExportDropdown.set(!1),this.isExporting.set(!0),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=t.scrollWidth,n=t.scrollHeight,i=await Ge(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),o=this.activeDashboardName()||"Dashboard",a=90,g=document.createElement("canvas");g.width=e,g.height=n+a;let p=g.getContext("2d");p.fillStyle="#f5f5f8",p.fillRect(0,0,e,a),p.fillStyle="#32323c",p.font="bold 28px helvetica",p.textAlign="center",p.textBaseline="middle",p.fillText(o,e/2,a/2+7);let x=new Image;x.src=i,await new Promise(J=>{x.onload=()=>J()}),p.drawImage(x,0,a,e,n);let N=document.createElement("a");N.href=g.toDataURL("image/png"),N.download=`${o}.png`,N.click()}finally{this.isExporting.set(!1)}}}toggleAiPanel(){this.showAiPanel.update(t=>!t)}onToggleAiPanel=()=>this.ngZone.run(()=>this.showAiPanel.update(t=>!t));ngOnInit(){this.loadList(),window.addEventListener("dv:toggle-ai-panel",this.onToggleAiPanel),window.addEventListener("resize",this.onWindowResize)}ngOnDestroy(){window.removeEventListener("dv:toggle-ai-panel",this.onToggleAiPanel),window.removeEventListener("resize",this.onWindowResize)}async loadList(){this.isLoading.set(!0);try{let t=await this.routeProgress.track(this.service.loadDashboards());this.ngZone.run(()=>{this.allDashboards.set(t);let e=t.slice(0,Be);this.activeTabs.set(e),e.length>0&&!this.activeTabId()&&(this.activeTabId.set(e[0].id),this.loadTab(e[0].id))}),t.length===0&&await this.checkAutoDashboard()}catch(t){console.error("Failed to load dashboards list:",t)}finally{this.ngZone.run(()=>this.isLoading.set(!1))}}async checkAutoDashboard(){if(!(this.generationSettled||this.isGenerating()))try{let t=await this.autoDashboard.trigger();t?.success&&!t.skipped&&t.streamId&&this.ngZone.run(()=>{this.generationStreamId.set(t.streamId)})}catch{}}onGenerationDone(t){this.generationSettled=!0,this.generationStreamId.set("");let e=t.length;this.loadList().then(()=>{this.showReadyToast(e>1?`${e} dashboards are ready`:"Your dashboard is ready")})}onGenerationFailed(){this.generationSettled=!0,this.generationStreamId.set("")}showReadyToast(t){be({variant:"success",title:"All set",content:t})}async loadTab(t){if(!this.loadedDashboards().has(t)){this.isTabLoading.set(!0);try{let e=await this.routeProgress.track(this.service.fetchDashboard(t));this.ngZone.run(()=>{let n=new Map(this.loadedDashboards());n.set(t,e),this.loadedDashboards.set(n)})}catch(e){console.error(`Failed to load dashboard ${t}:`,e)}finally{this.ngZone.run(()=>this.isTabLoading.set(!1))}}}refreshingDashboard=m(!1);async refreshActiveDashboard(){let t=this.activeTabId();if(!t||this.refreshingDashboard())return;let e=this.loadedDashboards().get(t);this.refreshingDashboard.set(!0),this.ngZone.run(()=>{let n=new Map(this.loadedDashboards());n.delete(t),this.loadedDashboards.set(n)});try{let n=await this.routeProgress.track(this.service.fetchDashboard(t));this.ngZone.run(()=>{let i=new Map(this.loadedDashboards());i.set(t,n),this.loadedDashboards.set(i)})}catch(n){console.error(`Failed to refresh dashboard ${t}:`,n),e&&this.ngZone.run(()=>{let i=new Map(this.loadedDashboards());i.set(t,e),this.loadedDashboards.set(i)})}finally{this.ngZone.run(()=>{this.refreshingDashboard.set(!1),queueMicrotask(()=>this.timeRangePickerRef?.reapply())})}}onTabChange(t){let e=t.detail.value;e!==this.activeTabId()&&this.setActiveTab(e)}onCategoryFilterChange(t){this.selectedCategory.set(t),this.categoryFilterOpen.set(!1);let e=this.visibleDashboards();e.some(n=>n.id===this.activeTabId())||(e.length>0?this.setActiveTab(e[0].id):this.activeTabId.set(""))}setActiveTab(t){this.showAiPanel.set(!1),this.activeTabId.set(t),this.loadTab(t)}isInActiveTabs(t){return this.activeTabs().some(e=>e.id===t)}canAdd(){return this.activeTabs().length<Be}isLastActiveDashboard(t){return this.activeTabs().length===1&&this.isInActiveTabs(t)}renamingDashboardId=m(null);renamingValue=m("");isRenamingDashboard=m(!1);startRenameDashboard(t,e){e.stopPropagation(),!t.isAutoGenerated&&(this.renamingDashboardId.set(t.id),this.renamingValue.set(t.name),queueMicrotask(()=>{let n=this.el.nativeElement.querySelector(`.tab-rename-input[data-dashboard-id="${t.id}"]`);n?.focus(),n?.select()}))}onRenameInputChange(t){this.renamingValue.set(t)}onRenameInputKeydown(t,e){t.key==="Enter"?(t.preventDefault(),this.commitRenameDashboard(e)):t.key==="Escape"&&(t.preventDefault(),this.cancelRenameDashboard(t))}cancelRenameDashboard(t){t?.stopPropagation(),this.renamingDashboardId.set(null),this.renamingValue.set("")}async commitRenameDashboard(t,e){e?.stopPropagation();let n=this.renamingValue().trim();if(!n||n===t.name){this.cancelRenameDashboard();return}this.isRenamingDashboard.set(!0);try{await this.service.renameDashboard(t.id,n),this.ngZone.run(()=>{let i=o=>o.map(a=>a.id===t.id?H(P({},a),{name:n}):a);this.allDashboards.update(i),this.activeTabs.update(i),this.renamingDashboardId.set(null),this.renamingValue.set("")}),be({variant:"success",title:"Renamed",content:"Dashboard renamed."})}catch{}finally{this.ngZone.run(()=>this.isRenamingDashboard.set(!1))}}onDashboardToggle(t,e){if(e){if(!this.canAdd())return;this.activeTabs.update(n=>[...n,t]),this.setActiveTab(t.id)}else{let n=this.activeTabId()===t.id;if(this.activeTabs.update(i=>i.filter(o=>o.id!==t.id)),n){let i=this.activeTabs();i.length>0?this.setActiveTab(i[0].id):this.activeTabId.set("")}}}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["dvz-dashboards-page"]],viewQuery:function(e,n){if(e&1&&ae(In,5)(Ce,5)($e,5),e&2){let i;j(i=Z())&&(n.tabsScrollerEl=i.first),j(i=Z())&&(n.dashboardViewerRef=i.first),j(i=Z())&&(n.timeRangePickerRef=i.first)}},decls:8,vars:3,consts:[["pageTitleBlock",""],["dashboardSkeleton",""],["tabsScroller",""],["renameInput",""],[1,"home-page"],["aria-hidden","true",1,"tabs-wrapper","home-skeleton"],[1,"tabs-wrapper"],[1,"tabs-bar"],[1,"home-nav"],[1,"tabs-bar__nav","home-skeleton__tabs-row"],[1,"home-skeleton__tab-pills"],["variant","rounded","height","28",1,"home-skeleton__tab"],["aria-hidden","true",1,"home-menu-divider"],["variant","rounded","width","32","height","28","border-radius","8px"],["variant","circular","width","28","height","28"],[4,"ngTemplateOutlet"],[3,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"streamId"],[3,"done","failed","streamId"],[1,"tabs-bar__nav",3,"is-scrollable"],[1,"home-empty-state"],["contained","","no-header","","placement","end","label","Ask",1,"home-ai-drawer",3,"nile-request-close","open"],[3,"dashboardId","dashboardName","dashboardConfig","chatOnly","initialPrompt"],[1,"tabs-bar__nav"],["type","button","aria-label","Scroll tabs left",1,"tabs-scroll-btn","tabs-scroll-btn--left",3,"click","disabled"],["name","ng-chevron-left","method","stroke","size","16"],[1,"tabs-scroller",3,"scroll"],["variant","filled",1,"dashboard-tab-group"],["slot","nav","panel","__sentinel__",1,"tab-sentinel"],["slot","nav"],["type","button","aria-label","Scroll tabs right",1,"tabs-scroll-btn","tabs-scroll-btn--right",3,"click","disabled"],["name","ng-chevron-right","method","stroke","size","16"],[3,"resetKey"],["hoist","","placement","bottom-end",1,"home-category-filter",3,"nile-hide","open"],["slot","trigger","content","Filter by category"],["type","button","aria-label","Filter by category",1,"home-action-btn",3,"click"],["name","ng-filter-lines","method","stroke","size","18"],["aria-hidden","true",1,"home-category-filter__dot"],["variant","menu",1,"home-category-filter__panel",3,"mousedown","selectionChange","selected"],["content","Create dashboard"],["type","button","aria-label","Create dashboard",1,"home-action-btn",3,"click","disabled"],["name","ng-plus","method","stroke","size","18"],["content","Refresh dashboard"],[1,"home-actions"],["content","Executive Summary"],["placement","bottom-end",1,"home-download",3,"open"],["slot","nav",3,"click"],["name","ng-stars-02","method","stroke","size","14","color","#7a5af8","aria-label","Auto-generated dashboard",1,"tab-auto-badge"],[1,"tab-rename"],[1,"tab-rename",3,"click"],["type","text",1,"tab-rename-input",3,"input","keydown","click","value","disabled"],["type","button","aria-label","Save dashboard name",1,"tab-rename-save",3,"click","disabled"],["name","ng-check","method","stroke","size","14","color","#2970ff"],[1,"tab-label"],["type","button","aria-label","Rename dashboard",1,"tab-edit-btn"],["type","button","aria-label","Rename dashboard",1,"tab-edit-btn",3,"click"],["name","ng-edit-02","method","stroke","size","12"],[3,"apply","resetKey"],["type","button","aria-label","Refresh dashboard",1,"home-action-btn",3,"click","disabled"],["name","ng-refresh-ccw","method","stroke","size","18",1,"home-refresh-glyph"],["type","button","aria-label","Executive Summary",1,"home-action-btn",3,"click"],["name","ng-file-02","method","stroke","size","18"],["placement","bottom-end",1,"home-download",3,"nile-hide","open"],["slot","trigger","content","Download"],["type","button","aria-label","Download",1,"home-action-btn",3,"click"],["name","ng-download-01","method","stroke","size","18"],[3,"click"],["slot","prefix","name","ng-file-06","method","stroke","size","14"],["slot","prefix","name","ng-image-03","method","stroke","size","14"],["active","",1,"viewer-scroll-container"],["aria-hidden","true",1,"home-skeleton"],[3,"config"],[1,"home-empty-state__title"],[1,"home-empty-state__desc"],["variant","tertiary",3,"click"],[1,"home-empty-state__graphic"],["viewBox","0 0 380 140","aria-hidden","true","preserveAspectRatio","xMidYMid meet"],["x","40","y","20","width","300","height","100","rx","8","fill","#fff","stroke","#80AED3","stroke-width","1.5","stroke-dasharray","4 4"],["x","56","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","64","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["x","64","y","80","width","6","height","20","rx","1","fill","#005EA6","opacity","0.7"],["attributeName","height","values","20;14;20","dur","2s","repeatCount","indefinite"],["attributeName","y","values","80;86;80","dur","2s","repeatCount","indefinite"],["x","76","y","74","width","6","height","26","rx","1","fill","#005EA6"],["attributeName","height","values","26;18;26","dur","2s","begin","0.2s","repeatCount","indefinite"],["attributeName","y","values","74;82;74","dur","2s","begin","0.2s","repeatCount","indefinite"],["x","88","y","68","width","6","height","32","rx","1","fill","#005EA6","opacity","0.85"],["attributeName","height","values","32;24;32","dur","2s","begin","0.4s","repeatCount","indefinite"],["attributeName","y","values","68;76;68","dur","2s","begin","0.4s","repeatCount","indefinite"],["x","100","y","78","width","6","height","22","rx","1","fill","#005EA6","opacity","0.6"],["attributeName","height","values","22;16;22","dur","2s","begin","0.6s","repeatCount","indefinite"],["attributeName","y","values","78;84;78","dur","2s","begin","0.6s","repeatCount","indefinite"],["x","112","y","66","width","6","height","34","rx","1","fill","#005EA6","opacity","0.85"],["attributeName","height","values","34;26;34","dur","2s","begin","0.8s","repeatCount","indefinite"],["attributeName","y","values","66;74;66","dur","2s","begin","0.8s","repeatCount","indefinite"],["x","148","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","156","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["cx","190","cy","78","r","14","fill","none","stroke","#E6EFF6","stroke-width","5"],["cx","190","cy","78","r","14","fill","none","stroke","#005EA6","stroke-width","5","stroke-linecap","round","stroke-dasharray","88","stroke-dashoffset","88","transform","rotate(-90 190 78)"],["attributeName","stroke-dashoffset","values","88;22;22;88","keyTimes","0;0.5;0.85;1","dur","2.6s","repeatCount","indefinite"],["x","240","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","248","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["d","M 250 92 L 264 80 L 278 86 L 292 72 L 306 78 L 320 64","fill","none","stroke","#005EA6","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round","stroke-dasharray","200","stroke-dashoffset","200"],["attributeName","stroke-dashoffset","values","200;0;0;200","keyTimes","0;0.5;0.85;1","dur","2.6s","repeatCount","indefinite"],["cx","320","cy","64","r","2.5","fill","#005EA6"],["attributeName","opacity","values","0;0;1;1;0","keyTimes","0;0.45;0.55;0.85;1","dur","2.6s","repeatCount","indefinite"],["variant","primary","aria-label","Create dashboard",1,"home-empty-state__cta",3,"click"],["slot","prefix","name","ng-plus","size","16"],[3,"closePanel","dashboardId","dashboardName","dashboardConfig","chatOnly","initialPrompt"],[1,"home-nav__title-block"],[1,"home-nav__title"],[1,"home-nav__sub"],[1,"home-skeleton__panel"],[1,"home-skeleton__kpis"],[1,"home-skeleton__kpi"],[1,"home-skeleton__widgets"],[1,"home-skeleton__widget"],[1,"home-skeleton__kpi-head"],["variant","text","width","56%","height","14"],["variant","rounded","width","32","height","32","border-radius","8px"],["variant","text","width","48%","height","30"],[1,"home-skeleton__kpi-row"],["variant","rounded","width","72","height","20","border-radius","999px"],["variant","text","width","38%","height","11"],["variant","rounded","width","100%","height","44","border-radius","8px",1,"home-skeleton__kpi-spark"],[1,"home-skeleton__widget-head"],[1,"home-skeleton__widget-titles"],["variant","text","width","42%","height","16"],["variant","text","width","64%","height","11"],["variant","circular","width","20","height","20"],["variant","rounded","width","100%","height","100%","border-radius","10px",1,"home-skeleton__widget-chart"]],template:function(e,n){e&1&&(s(0,"div",4),b(1,Hn,12,2,"div",5),b(2,Bn,6,3,"div",6),b(3,gi,9,5,"div",6),l(),L(4,pi,5,1,"ng-template",null,0,fe)(6,ui,7,0,"ng-template",null,1,fe)),e&2&&(c(),y(n.isLoading()?1:-1),c(),y(!n.isLoading()&&n.isGenerating()?2:-1),c(),y(!n.isLoading()&&!n.isGenerating()?3:-1))},dependencies:[Me,Ce,Ne,ze,$e,$t],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:0}.home-page[_ngcontent-%COMP%]{height:100%;min-height:0;display:flex;flex-direction:column;background:var(--ng-colors-bg-active);overflow:visible;position:relative}.loading-state[_ngcontent-%COMP%], .empty-state[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:200px;color:var(--ng-colors-text-tertiary-600)}.home-empty-state[_ngcontent-%COMP%]{margin:24px;padding:56px 32px;display:flex;flex-direction:column;align-items:center;text-align:center;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px}.home-empty-state__graphic[_ngcontent-%COMP%]{width:380px;max-width:100%;height:140px;margin-bottom:24px;display:block}.home-empty-state__graphic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.home-empty-state__title[_ngcontent-%COMP%]{margin:0 0 8px;font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.01em}.home-empty-state__desc[_ngcontent-%COMP%]{margin:0;max-width:480px;font-size:14px;line-height:1.5;color:var(--ng-colors-text-tertiary-600, #535862)}.home-empty-state__cta[_ngcontent-%COMP%]{margin-top:24px}.toolbar[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:flex-end;height:64px;padding:0 38px;background:var(--ng-componentcolors-alpha-white-100);border-bottom:1px solid var(--ng-componentcolors-alpha-black-10);position:fixed;top:var(--nav-height, 56px);left:0;right:0;z-index:var(--z-header)}.toolbar__right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-3, 12px)}.tabs-wrapper[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;min-height:0}.tabs-bar[_ngcontent-%COMP%]{position:relative;min-height:0;display:flex;flex-direction:column}.tabs-bar[_ngcontent-%COMP%] .home-nav[_ngcontent-%COMP%]{position:sticky;top:0;z-index:var(--z-sticky-row);display:flex;align-items:center;justify-content:space-between;gap:16px;height:76px;margin:0;padding:0 22px;background:var(--ng-componentcolors-alpha-white-100, #ffffff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0}.tabs-bar[_ngcontent-%COMP%] .home-nav__title-block[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;min-width:0}.tabs-bar[_ngcontent-%COMP%] .home-nav__title[_ngcontent-%COMP%]{margin:0;font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);line-height:1.2;letter-spacing:-.01em}.tabs-bar[_ngcontent-%COMP%] .home-nav__sub[_ngcontent-%COMP%]{margin:0;font-size:13px;font-weight:400;color:var(--ng-colors-text-tertiary-600, #535862);line-height:1.3}.tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav[_ngcontent-%COMP%]{position:sticky;top:76px;height:56px;display:flex;align-items:center;gap:4px;z-index:var(--z-sticky-row);min-width:0;margin:0;padding:22px;background:var(--ng-componentcolors-alpha-white-100, #ffffff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.tabs-bar[_ngcontent-%COMP%] .home-menu-divider[_ngcontent-%COMP%]{width:1px;height:20px;background:var(--ng-colors-border-secondary, #e9eaeb);margin:0 6px 0 8px;flex-shrink:0}.tabs-bar[_ngcontent-%COMP%] .tabs-scroller[_ngcontent-%COMP%]{flex:1;min-width:0;overflow-x:auto;overflow-y:hidden;position:relative;scrollbar-width:none}.tabs-bar[_ngcontent-%COMP%] .tabs-scroller[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.tabs-bar[_ngcontent-%COMP%] .dashboard-tab-group[_ngcontent-%COMP%]{display:block;width:max-content;min-width:100%}.tabs-bar[_ngcontent-%COMP%] .tab-sentinel[_ngcontent-%COMP%]{display:none!important}.tabs-bar[_ngcontent-%COMP%] .tab-auto-badge[_ngcontent-%COMP%]{display:inline-flex;vertical-align:text-bottom;margin-right:4px;flex:0 0 auto}.tabs-bar[_ngcontent-%COMP%] .tab-label[_ngcontent-%COMP%]{white-space:nowrap}.tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-left:4px;padding:0;border:0;background:transparent;border-radius:4px;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;opacity:0;pointer-events:none;flex:0 0 auto;transition:background .15s,opacity .15s,color .15s}.tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:hover, .tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:focus-visible{background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.tabs-bar[_ngcontent-%COMP%] nile-nav-tab[_ngcontent-%COMP%]:hover .tab-edit-btn[_ngcontent-%COMP%], .tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:focus-visible{opacity:1;pointer-events:auto}.tabs-bar[_ngcontent-%COMP%] .tab-rename[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:4px}.tabs-bar[_ngcontent-%COMP%] .tab-rename-input[_ngcontent-%COMP%]{width:140px;height:24px;padding:0 6px;font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);background:#fff;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:6px;outline:none}.tabs-bar[_ngcontent-%COMP%] .tab-rename-input[_ngcontent-%COMP%]:focus{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff29}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;background:transparent;border-radius:4px;cursor:pointer;flex:0 0 auto}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-quaternary, #f2f4f7)}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]:disabled{cursor:default;opacity:.5}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;border-radius:6px;flex-shrink:0;opacity:0;pointer-events:none;transition:opacity .15s,background .15s,color .15s}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:hover, .tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:focus, .tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:focus-visible{outline:0;background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[disabled][_ngcontent-%COMP%]{cursor:default;color:var(--ng-colors-text-disabled, #a4a7ae);background:transparent}.tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav.is-scrollable[_ngcontent-%COMP%]:hover .tabs-scroll-btn[_ngcontent-%COMP%], .tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav.is-scrollable[_ngcontent-%COMP%]:focus-within .tabs-scroll-btn[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.more-menu[_ngcontent-%COMP%]{width:260px;max-height:320px;overflow-y:auto;padding:var(--ng-spacing-xs) 0}.more-menu-item[_ngcontent-%COMP%]{padding:var(--ng-spacing-xs) var(--ng-spacing-md);display:flex;align-items:center;cursor:pointer}.more-menu-item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.more-menu-item[_ngcontent-%COMP%] nile-checkbox[_ngcontent-%COMP%]{width:100%}nile-tab-panel[_ngcontent-%COMP%], nile-nav-tab-panel[_ngcontent-%COMP%]{display:block;height:100%}.panel-loading[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:200px}.home-skeleton__tabs-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px}.home-skeleton__tab-pills[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;flex-shrink:0}.home-skeleton__tab[_ngcontent-%COMP%]{flex:0 0 auto}.home-skeleton__panel[_ngcontent-%COMP%]{flex:1;min-height:0;padding:18px 24px 32px;display:flex;flex-direction:column;gap:16px;overflow:auto}.home-skeleton__kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}@media(max-width:1100px){.home-skeleton__kpis[_ngcontent-%COMP%]{grid-template-columns:repeat(2,1fr)}}.home-skeleton__kpi[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px;padding:18px 20px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;background:#fff}.home-skeleton__kpi-head[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:12px}.home-skeleton__kpi-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;margin-top:4px}.home-skeleton__kpi-spark[_ngcontent-%COMP%]{margin-top:6px}.home-skeleton__widgets[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}@media(max-width:900px){.home-skeleton__widgets[_ngcontent-%COMP%]{grid-template-columns:1fr}}.home-skeleton__widget[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:18px;padding:20px 22px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;background:#fff;min-height:320px}.home-skeleton__widget-head[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.home-skeleton__widget-titles[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}.home-skeleton__widget-chart[_ngcontent-%COMP%]{display:block;flex:1;min-height:0}.viewer-scroll-container[_ngcontent-%COMP%]{display:block;flex:1;min-height:0;overflow:auto}.viewer-scroll-container[_ngcontent-%COMP%]::part(base){padding:unset;min-height:100%}[_nghost-%COMP%] .viewer-scroll-container:has(.aq-detail-overlay){overflow:hidden}app-dashboard-viewer[_ngcontent-%COMP%], nile-dashboard-viewer[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.export-menu[_ngcontent-%COMP%] nile-menu-item[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-medium, 500)}.home-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:2px;flex-shrink:0}.home-action-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;border-radius:6px;flex-shrink:0}.home-action-btn[_ngcontent-%COMP%]:hover, .home-action-btn[_ngcontent-%COMP%]:focus, .home-action-btn[_ngcontent-%COMP%]:focus-visible{outline:0;background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.home-category-filter[_ngcontent-%COMP%] .home-action-btn[_ngcontent-%COMP%]{position:relative}.home-category-filter__dot[_ngcontent-%COMP%]{position:absolute;top:3px;right:3px;width:6px;height:6px;border-radius:50%;background:var(--ng-colors-fg-brand-primary-600)}.home-category-filter[_ngcontent-%COMP%]::part(panel){background:transparent;box-shadow:none;border-radius:0}.home-category-filter__panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1px;min-width:200px;max-height:320px;overflow-y:auto}.home-refresh-glyph[_ngcontent-%COMP%]{display:inline-flex;transform-origin:50% 50%}.home-refresh-glyph--spinning[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_home-refresh-spin .9s linear infinite}@keyframes _ngcontent-%COMP%_home-refresh-spin{to{transform:rotate(360deg)}}.home-ai-drawer[_ngcontent-%COMP%]::part(base){z-index:var(--z-drawer, 900)}.home-ai-drawer[_ngcontent-%COMP%]::part(panel){width:100%;max-width:100%}.home-ai-drawer[_ngcontent-%COMP%]::part(body){padding:0;overflow:hidden}.home-ai-drawer[_ngcontent-%COMP%] db-ai-prompt-panel[_ngcontent-%COMP%]{display:block;height:100%;min-height:0}.home-category-filter__heading[_ngcontent-%COMP%]{display:block;padding:6px 10px 4px;font-size:10.5px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600)}.home-category-filter__item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:7px 10px;border:0;border-radius:7px;background:transparent;font:inherit;font-size:13px;color:var(--ng-colors-text-secondary-700);text-align:left;white-space:nowrap;cursor:pointer}.home-category-filter__item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.home-category-filter__item.is-active[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600);font-weight:600;background:var(--ng-colors-bg-secondary)}.home-category-filter__label[_ngcontent-%COMP%]{min-width:0;overflow:hidden;text-overflow:ellipsis}']})};function fi(r,t){r&1&&h(0,"dvz-dashboards-page")}var We=class r{config=Y(void 0);ready=_e({alias:"dvz-ready"});error=_e({alias:"dvz-error"});unauthorized=_e({alias:"dvz-unauthorized"});navigate=_e({alias:"dvz-navigate"});host=v(re);navigator=v(G);destroyRef=v(Xe);stopAdopting=null;stopTokenRefresh=null;stopUi=null;configured=!1;constructor(){X(()=>{let t=this.config();t&&this.apply(t)}),this.navigator.requests.pipe(Et(this.destroyRef)).subscribe(t=>this.navigate.emit(t)),queueMicrotask(()=>{let t=this.host.nativeElement.shadowRoot;t&&(this.stopAdopting=je(t))})}async apply(t){let e=t.auth;Ct(t.api.baseUrl),_t(t.api,e);let n=jt({baseUrl:t.api.baseUrl,mcpUrl:t.api.mcpUrl,tokenizedOrigins:t.api.tokenizedOrigins,headers:t.api.headers,customerId:t.tenant.customerId??null,productId:t.tenant.productId,productName:t.tenant.productName??null,authMode:e.mode,authToken:e.mode==="token"?e.token:null,getToken:e.mode==="callback"?e.getToken:null,onUnauthorized:()=>this.unauthorized.emit(),features:t.features,ui:t.ui,copy:t.copy,hrefs:t.hrefs,initialDashboardId:t.initial?.dashboardId??null});this.stopUi?.(),this.stopUi=Ze(this.host.nativeElement,t.ui),xt({productId:t.tenant.productId,name:t.tenant.productName}),yt(()=>this.unauthorized.emit());let i=n;if(await ut(i),this.stopTokenRefresh??=ft(i),!this.configured){this.configured=!0;let o=D();this.ready.emit({customerId:o.customerId??"",productId:o.productId??""})}}ngOnDestroy(){this.stopAdopting?.(),this.stopTokenRefresh?.(),this.stopUi?.()}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["dvz-dashboards-root"]],inputs:{config:[1,"config"]},outputs:{ready:"dvz-ready",error:"dvz-error",unauthorized:"dvz-unauthorized",navigate:"dvz-navigate"},features:[se([G])],decls:1,vars:1,template:function(e,n){e&1&&b(0,fi,1,0,"dvz-dashboards-page"),e&2&&y(n.config()?0:-1)},dependencies:[Ve],styles:[`:host{display:block;height:100%;min-height:0}
1
+ import{$ as Ot,$a as qt,B as bt,D as yt,Ea as Rt,F as ce,Fa as Nt,G as Ct,J as vt,Ka as Ae,L as xt,La as ye,M as wt,N as Pt,Na as zt,O as Mt,Oa as Fe,P as Dt,Pa as Vt,Q as kt,R as St,S as ge,Sa as T,V as pe,Wa as Ge,X as Le,Xa as Wt,a as je,aa as Tt,ab as Ht,b as Ze,bb as Lt,c as lt,ca as ke,cb as Ee,d as Me,da as Se,fa as Oe,g as De,gb as $e,hb as Gt,i as q,j as K,jb as $t,k as dt,l as ct,m as gt,n as pt,na as Te,oa as At,p as ht,pa as Ft,q as mt,qa as be,r as ie,s as ut,t as ft,ta as Et,ua as It,v as de,w as _t}from"./chunk-WDWFGOLW.js";import{Ab as M,Bb as ot,Eb as _,Ga as tt,Gb as d,Ha as nt,Jb as ae,Kb as j,La as c,Lb as Z,N as B,Ob as R,Pb as at,Qb as te,R as Ke,S as v,Sb as w,Tb as W,Ub as He,X as u,Xa as we,Y as f,Z as Qe,_ as Je,ab as z,ac as se,ba as Xe,bc as ne,cc as le,d as Ye,da as me,ea as xe,fb as L,gc as fe,ha as et,ia as m,kb as it,la as X,lb as ee,lc as S,mb as b,nb as y,ob as U,oc as _e,p as A,pa as re,pb as rt,pc as Y,qb as F,rb as E,rc as st,sb as C,tb as s,ub as l,vb as h,wb as oe,xb as Pe,yb as ue,zb as V}from"./chunk-U4S2XPPP.js";import{a as P,b as H}from"./chunk-ZW5NV4UO.js";function Qt(){return{dashboardsTitle:"Dashboards",loadingDashboards:"Loading dashboards\u2026",noDashboardsTitle:"No dashboards yet",noDashboardsSub:"Generate one from your data, or create it in the builder.",generateDashboardButton:"Generate dashboard",refreshButton:"Refresh",exportButton:"Export",editButton:"Edit",renamePlaceholder:"Dashboard name",askAqueraButton:"Ask Aquera",errors:{loadFailedFallback:"Could not load dashboards",saveFailedFallback:"Could not save the dashboard",refreshFailedFallback:"Could not refresh the dashboard",exportFailedFallback:"Could not export the dashboard"}}}function Jt(){return{mcpGateway:de.MCP_GATEWAY_ENABLED??!1,aiPrompt:!0,autoGenerate:!0,export:!0,rename:!0,refresh:!0,executiveSummary:!0,edit:!0}}function Bt(){return{baseUrl:de.baseUrl??"",mcpUrl:de.MCP_URL??null,tokenizedOrigins:[de.baseUrl].filter(r=>!!r),headers:{},customerId:null,productId:null,productName:null,authMode:"inherit",authToken:null,getToken:null,resolvedToken:null,onUnauthorized:null,ssoEnabled:de.SSO_ENABLED??!1,features:Jt(),ui:{theme:"light",density:"comfortable",header:!0,locale:"en"},copy:Qt(),hrefs:{askAquera:"/ask-aquera",builder:"/manage-dashboards"},initialDashboardId:null}}var Ut=mt("dashboards",Bt);function D(){return Ut.read()}function jt(r){let t=Bt(),e=H(P(P({},t),ie(r)),{features:P(P({},t.features),ie(r.features??{})),ui:P(P({},t.ui),ie(r.ui??{})),hrefs:P(P({},t.hrefs),ie(r.hrefs??{})),copy:H(P(P({},t.copy),ie(r.copy??{})),{errors:P(P({},t.copy.errors),ie(r.copy?.errors??{}))}),headers:P(P({},t.headers),r.headers??{})});return r.tokenizedOrigins||(e.tokenizedOrigins=[e.baseUrl,e.mcpUrl].filter(n=>!!n)),Ut.write(e)}var G=class r{requests$=new Ye;requests=this.requests$.asObservable();toAskAquera(){this.requests$.next({to:D().hrefs.askAquera})}toAskAqueraDashboard(t,e){this.requests$.next({to:`${D().hrefs.askAquera}/dashboard/${t}`,queryParams:e})}toBuilder(t){this.requests$.next({to:`${D().hrefs.builder}/${t}`})}static \u0275fac=function(e){return new(e||r)};static \u0275prov=B({token:r,factory:r.\u0275fac})};var k={get baseUrl(){return D().baseUrl},get MCP_URL(){return D().mcpUrl??""},get MCP_GATEWAY_ENABLED(){return D().features.mcpGateway},get SSO_ENABLED(){return D().ssoEnabled}};function Zt(){return D().customerId??""}function O(){return D().productId??""}var he=class r{constructor(t){this.http=t}http;tokenStore=v(ce);publishRepo=v(T);lastSentCustomerId=null;lastSentProductId=null;get customerId(){return this.tokenStore.tenantId()??""}mcpGatewayUrl(){return`${k.baseUrl}/dviz-mcp`}async callMcpTool(t,e={}){let n=this.customerId,i=O(),o={};n!==this.lastSentCustomerId&&(o.customerId=n),i!==this.lastSentProductId&&(o.productId=i);let a;try{a=await A(this.http.post(this.mcpGatewayUrl(),{jsonrpc:"2.0",id:Date.now(),method:"tools/call",params:{name:t,arguments:e}},{headers:{Accept:"application/json, text/event-stream"},params:o})),this.lastSentCustomerId=n,this.lastSentProductId=i}catch(p){throw p instanceof q?new Error(p.error?.error?.message||p.error?.message||p.message):p}if(a.error)throw new Error(a.error.message);let g=a.result;if(g?.isError)throw new Error(g.structuredContent?.error?.message??g.content?.[0]?.text??`${t} failed`);return g?.structuredContent??{}}async loadDashboards(){return(await this.publishRepo.listDashboards({published:"true",limit:100})).filter(e=>e.isPublished===!0||e.version==="published").map(e=>({id:e.id,name:e.name??"Untitled",description:e.description,createdAt:e.createdAt??new Date().toISOString(),updatedAt:e.updatedAt,isAutoGenerated:e.isAutoGenerated===!0,category:e.category??null}))}async renameDashboard(t,e){if(!k.MCP_GATEWAY_ENABLED){try{await A(this.http.put(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}?published=true`,{name:e}))}catch(n){throw n instanceof q?new Error(n.error?.error||n.message):n}return}await this.callMcpTool("updateDashboard",{dashboardId:t,name:e,published:!0})}async fetchDashboard(t){let e,n=!1;if(k.MCP_GATEWAY_ENABLED){let i=await this.callMcpTool("getDashboard",{dashboardId:t,published:"true"});e=i?.dashboard??{},n=i?.canRefresh===!0}else{let i=await A(this.http.get(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}?published=true`));e=i?.data??i,n=i?.canRefresh===!0}return{id:e.id,name:e.name??"Untitled",widgets:await this.mapAndHydrateWidgets(e.widgets),connectionId:e.connectionId,isPipeline:e.isPipeline,adapterType:e.adapterType,category:e.category??null,canRefresh:n}}async refreshDashboard(t){if(!k.MCP_GATEWAY_ENABLED){let n=await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}/refresh`,{})),i=n?.data??n;return{widgets:await this.mapAndHydrateWidgets(i?.widgets)}}let e=await this.callMcpTool("refreshDashboard",{dashboardId:t});return{widgets:await this.mapAndHydrateWidgets(e?.refresh?.widgets)}}async previewWidgetTemplateDetailPanel(t){return(await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/widget-templates/${t}/detail-panel`,{}))).data}async previewWidgetDetailPanelDefinition(t){return(await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/widget-templates/preview-detail-panel`,{detailPanel:t}))).data}async mapAndHydrateWidgets(t){let e=(t??[]).map(n=>({id:n.id,title:n.title,type:n.widgetType??"chart",layout:n.layout??{x:0,y:0,w:12,h:4},nileConfig:{chart:n.chart??n.config?.chart??{},aq:n.config?.aq??{},_meta:n.config?._meta},drilldownBy:Array.isArray(n.drilldownBy)?n.drilldownBy:void 0,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null}));return await Promise.all(e.map(n=>ye(n.nileConfig))),e}static \u0275fac=function(e){return new(e||r)(Ke(K))};static \u0275prov=B({token:r,factory:r.\u0275fac,providedIn:"root"})};var $=class r{http=v(K);tokenStore=v(ce);get customerId(){return this.tokenStore.tenantId()??""}async fetchGridPage(t,e,n,i,o,a,g,p){let x=`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/data-grid/${t}?pageIndex=${e}&pageSize=${n}`,N=(i??[]).filter(J=>J&&J.value!=null&&String(J.value).trim()!=="");return N.length&&(x+=`&filters=${encodeURIComponent(JSON.stringify(N))}`),o&&Object.keys(o).length&&(x+=`&dashboardFilters=${encodeURIComponent(JSON.stringify(o))}`),g&&g.length&&(x+=`&resolvedFilters=${encodeURIComponent(JSON.stringify(g))}`),a&&(x+=`&dashboardId=${encodeURIComponent(a)}`),p&&(x+=`&conversationId=${encodeURIComponent(p)}`),A(this.http.get(x))}async generateWidget(t,e){let n=vt()?{prompt:t}:{prompt:t,dataSourceId:e},i;try{i=await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/widget/generate`,n))}catch(g){if(g instanceof q){let p=g.error?.error||g.message;throw new Error(p)}throw g}if(i?.success===!1)throw new Error(i.error||"Request failed");let o=i?.data??i;if(!o?.config)throw new Error("Invalid response from widget generate API");let a=o;return await ye(a.config),a}async filterSuggest(t,e,n,i){let o=n.filter(p=>!!p.id).map(p=>({widgetId:p.id})),a;try{a=await A(this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}/filter/suggest?status=${i??"draft"}`,{query:e,refreshCache:!1,widgets:o}))}catch(p){throw p instanceof q?new Error(p.error?.error||p.message):p}if(a?.success===!1)throw new Error(a.error||"Request failed");let g=a?.data??a??{};return{nextToken:g.nextToken,completions:Array.isArray(g.completions)?g.completions:[],suggestions:Array.isArray(g.suggestions)?g.suggestions:[]}}async applyFilters(t,e,n,i,o,a){let g=await new Promise((qe,ve)=>{let Ue=this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${n}/filter/apply?status=${i??"draft"}`,Vt(t,e,a)).subscribe({next:I=>qe(I),error:I=>{I instanceof q?ve(new Error(I.error?.error||I.message)):ve(I)}});if(o){if(o.aborted){Ue.unsubscribe();let I=new Error("Aborted");I.name="AbortError",ve(I);return}o.addEventListener("abort",()=>{Ue.unsubscribe();let I=new Error("Aborted");I.name="AbortError",ve(I)},{once:!0})}});if(g?.success===!1)throw new Error(g.error||"Request failed");let p=g?.data??g,x=Array.isArray(p)?p:p?.widgets;if(!Array.isArray(x))throw new Error("Invalid response from apply-filters API");let N=!Array.isArray(p)&&Array.isArray(p?.resolvedFilters)?p.resolvedFilters:[],J=!Array.isArray(p)&&Array.isArray(p?.filterGroups)?p.filterGroups:[];return await Promise.all(x.map(qe=>ye(qe.config))),{widgets:x,resolvedFilters:N,filterGroups:J}}static \u0275fac=function(e){return new(e||r)};static \u0275prov=B({token:r,factory:r.\u0275fac,providedIn:"root"})};var en=["grid"];function tn(r,t){if(r&1&&w(0),r&2){let e=d(2);He(" ",e.widgetDetailPanelTitle," ")}}function nn(r,t){r&1&&h(0,"nile-skeleton-loader",6)}function rn(r,t){if(r&1&&h(0,"shared-dashboard-grid",8),r&2){let e=d(2);C("widgets",e.widgetDetailPanelWidgets)("widgetsLoading",e.widgetDetailPanelLoading)("editMode",!1)("selectable",!1)("canSetAlert",!1)("canAddToStory",!1)("canForecast",!1)}}function on(r,t){r&1&&(s(0,"div",9)(1,"div",10),h(2,"nile-skeleton-loader",11)(3,"nile-skeleton-loader",11)(4,"nile-skeleton-loader",11),l(),h(5,"nile-skeleton-loader",12),l())}function an(r,t){if(r&1){let e=M();s(0,"div",2)(1,"div",4)(2,"nile-breadcrumb",5),_("nile-click",function(){u(e);let i=d();return f(i.closeWidgetDetailPanel())}),s(3,"nile-breadcrumb-item"),w(4),l(),s(5,"nile-breadcrumb-item"),b(6,tn,1,1)(7,nn,1,0,"nile-skeleton-loader",6),l()()(),s(8,"div",7),b(9,rn,1,7,"shared-dashboard-grid",8)(10,on,6,0,"div",9),l()()}if(r&2){let e=d();c(4),He(" ",e.dashboardName," "),c(2),y(e.widgetDetailPanelTitle?6:7),c(3),y(e.widgetDetailPanelWidgets.length?9:e.widgetDetailPanelLoading?10:-1)}}var Ce=class r{widgets=[];dashboardId=null;applyingFilters=!1;widgetDetailPanelOpen=!1;widgetDetailPanelLoading=!1;widgetDetailPanelTitle=null;widgetDetailPanelWidgets=[];dashboardName=null;widgetDetailPanelSkeletonSlots=[];widgetDetailPanelSkeletonHeight(){return this.widgetDetailPanelSkeletonSlots.length?Math.max(...this.widgetDetailPanelSkeletonSlots.map(t=>(t.y+t.h)*72)):0}async onKpiWidgetClicked(t){if(this.widgetDetailPanelLoading)return;let e=t.config?._meta,n=e?.templateId??null,i=e?.detailPanel??null;if(!(!n&&!i)){this.beginCardMorph(t.id),this.runViewTransition(()=>{this.widgetDetailPanelOpen=!0,this.widgetDetailPanelLoading=!0,this.widgetDetailPanelTitle=i?.title??t.title??null,this.widgetDetailPanelSkeletonSlots=(i?.widgets??[]).map(o=>o.layout).filter(o=>!!o),this.widgetDetailPanelWidgets=this.detailPanelPlaceholders(i),this.cdr.markForCheck()});try{let o=i?await this.dashboardsService.previewWidgetDetailPanelDefinition(i):await this.dashboardsService.previewWidgetTemplateDetailPanel(String(n));if(!o.widgets.length){this.widgetDetailPanelOpen=!1;return}this.widgetDetailPanelTitle=o.title??t.title??null;let a=o.widgets.map((g,p)=>H(P({},g),{id:`detail-panel-${p}`}));this.widgetDetailPanelWidgets=a.every(g=>g.layout)?a:Le(a)}catch{this.widgetDetailPanelOpen=!1}finally{this.widgetDetailPanelLoading=!1,this.cdr.markForCheck()}}}detailPanelPlaceholders(t){let e=t?.widgets??[];if(!e.length)return[];let n=e.map((i,o)=>H(P({},i),{id:`detail-panel-${o}`}));return n.every(i=>i.layout)?n:Le(n)}closeWidgetDetailPanel(){this.runViewTransition(()=>{this.widgetDetailPanelOpen=!1,this.widgetDetailPanelTitle=null,this.widgetDetailPanelWidgets=[],this.widgetDetailPanelSkeletonSlots=[],this.cdr.markForCheck()},"back")}currentTimeRange=null;lastMonitoredTotal=null;isRefreshingData=!1;activeDashboardFilters=null;activeResolvedFilters=null;activeFilterGroups=[];applySummary=null;alertDrawerOpen=!1;alertWidget=null;alertFilterPredicates=null;alertFilterHasOr=!1;alertAuthoringMode="widget";alertSource=null;gridRef;http=v(K);zone=v(xe);navigator=v(G);openAiService=v($);dashboardsService=v(he);forecastService=v(Tt);cdr=v(st);appRef=v(it);hostEl=v(re);static MORPH_NAME="dv-detail-morph";morphSourceEl=null;beginCardMorph(t){if(!t||typeof CSS>"u"||!CSS.escape)return!1;let e=this.hostEl.nativeElement.querySelector(`.widget-card[data-widget-id="${CSS.escape(String(t))}"]`);if(!e)return!1;let n=e.getBoundingClientRect();return n.height>0&&n.bottom>0&&n.top<window.innerHeight?(e.style.viewTransitionName=r.MORPH_NAME,this.morphSourceEl=e,this.hostEl.nativeElement.classList.add("dv-morphing"),!0):!1}endCardMorph(){this.morphSourceEl&&(this.morphSourceEl.style.removeProperty("view-transition-name"),this.morphSourceEl=null),this.hostEl.nativeElement.classList.remove("dv-morphing")}runViewTransition(t,e="forward"){let n=document,i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(typeof n.startViewTransition!="function"||i){t(),this.endCardMorph();return}let o=document.documentElement;e==="back"&&(o.dataset.vtDirection="back");let a=()=>{delete o.dataset.vtDirection,this.endCardMorph()};n.startViewTransition(()=>{t(),this.appRef.tick()})?.finished?.then(a,a)??a()}sessionMap=new Map;primedFilterWidgets=new Set;filterSuggestCache=new Map;filterSuggestInflight=new Set;applyFiltersSeq=0;applyFiltersAbort;viewInited=!1;openInBuilder(){!this.dashboardId||!D().features.edit||this.navigator.toBuilder(this.dashboardId)}set config(t){let e=t?.id??null,n=e!==this.dashboardId;if(n&&(this.primedFilterWidgets.clear(),this.filterSuggestCache.clear(),this.filterSuggestInflight.clear(),this.activeDashboardFilters=null,this.activeResolvedFilters=null,this.activeFilterGroups=[],this.applySummary=null,this.currentTimeRange=null,this.lastMonitoredTotal=null),!t){this.widgets=[],this.dashboardId=null,this.alertSource=null,this.dashboardName=null;return}this.dashboardId=e,this.dashboardName=t.name??null,this.alertSource={connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType},this.widgets=(t.widgets??[]).map(o=>({id:o.id,title:o.title??"",widgetType:o.type??"chart",layout:o.layout,config:o.nileConfig,drilldownBy:o.drilldownBy,dataSourceId:o.dataSourceId,queryMeta:o.queryMeta,category:o.category??null})),this.forecastable=t.forecastable??{};let i=this.collectInitialFilters(this.widgets);i?this.applyInitialFilters(i):n&&t.canRefresh&&this.refreshLoadedDashboardData(e),this.viewInited&&queueMicrotask(()=>this.primeFilterWidgets())}async refreshLoadedDashboardData(t){this.isRefreshingData=!0;try{let{widgets:e}=await this.dashboardsService.refreshDashboard(t);this.dashboardId===t&&!this.activeDashboardFilters&&(this.widgets=e.map(n=>({id:n.id,title:n.title??"",widgetType:n.type??"chart",layout:n.layout,config:n.nileConfig,drilldownBy:n.drilldownBy,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null})))}catch(e){console.error("Failed to refresh dashboard data:",e)}finally{this.isRefreshingData=!1,this.cdr.markForCheck()}}collectInitialFilters(t){let e={};for(let n of t){let i=n.config?.chart;if(i?.type==="filter")for(let o of i.controls??[]){if(!o.id)continue;let a=o.value;a!=null&&(typeof a=="string"&&a.trim()===""||(e[o.id]=a))}}return Object.keys(e).length>0?e:null}async applyInitialFilters(t){let e=this.widgets.filter(o=>!pe(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let{widgets:o,resolvedFilters:a,filterGroups:g}=await this.openAiService.applyFilters(e,t,this.dashboardId,"published",n.signal,{timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;this.widgets=ge(this.widgets,o),this.activeDashboardFilters=t,this.activeResolvedFilters=a,this.activeFilterGroups=g,this.applySummary=Fe(o,this.buildActiveFilters(t))}catch(o){if(o?.name==="AbortError")return;console.error("Apply initial filters failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}ngAfterViewInit(){this.viewInited=!0,queueMicrotask(()=>this.primeFilterWidgets())}alertTargetWidget(){let t=this.widgets.filter(n=>!pe(n)),e=t.filter(n=>!!n.config?.chart?.gridId);return e.length===1?e[0]:t.find(n=>!!n.queryMeta?.sql)??null}onWidgetPatchedByGrid(t){this.widgets=this.widgets.map(e=>e.id===t.id?t:e),this.cdr.markForCheck()}forecastable={};forecastBusy=new Set;forecastingWidgetId=null;async onForecast(t){let e=this.dashboardId,n=String(t.widget.id);if(!(!e||this.forecastBusy.has(n))){this.forecastBusy.add(n),this.forecastingWidgetId=n,this.cdr.markForCheck();try{let i=t.enable?await this.forecastService.addToWidget(e,n,t.settings??{}):await this.forecastService.removeFromWidget(e,n);if(t.enable&&i?.guardrails&&i.guardrails.passed===!1)return;i?.widget&&this.applyForecastedWidget(i.widget),be({variant:"success",title:t.enable?t.settings?"Forecast updated":"Forecast added":"Forecast removed",content:t.enable?"The projection is shown with its confidence range.":"The chart is back to its measured history."})}catch{}finally{this.forecastBusy.delete(n),this.forecastingWidgetId=null,this.cdr.markForCheck()}}}applyForecastedWidget(t){this.widgets=this.widgets.map(e=>String(e.id)===String(t.id)?H(P({},e),{config:t.config?.chart??t.nileConfig??e.config,queryMeta:t.queryMeta??e.queryMeta}):e)}onSetAlert(t){if(pe(t)){let e=this.alertTargetWidget();if(!e)return;this.alertWidget=e,this.alertFilterPredicates=this.activeResolvedFilters,this.alertFilterHasOr=this.activeFilterGroups.length>1,this.alertAuthoringMode="filter"}else this.alertWidget=t,this.alertFilterPredicates=null,this.alertFilterHasOr=!1,this.alertAuthoringMode="widget";this.alertDrawerOpen=!0,this.cdr.markForCheck()}onAlertClosed(){this.alertDrawerOpen=!1,this.cdr.markForCheck()}onAlertSaved(){this.alertDrawerOpen=!1,this.cdr.markForCheck()}onFilterChange(t){let e=t.widgetId,n=t.controlId;!e||!n||this.dashboardId&&this.fetchSuggestionsOnce(e,n,this.dashboardId)}fetchSuggestionsOnce(t,e,n){let i=this.filterSuggestCache.get(t);if(i){this.gridRef?.patchFilterSuggestions(t,e,i);return}this.filterSuggestInflight.has(t)||(this.filterSuggestInflight.add(t),(async()=>{try{let o=await this.openAiService.filterSuggest(n,"",this.widgets,"published");this.applyFilterSuggestions(t,e,o)}catch(o){console.warn("Filter suggest failed:",o)}finally{this.filterSuggestInflight.delete(t)}})())}async onFilterSubmit(t){if(this.isEmptyFilters(t.filters)){await this.reloadDashboard();return}let e=this.widgets.filter(o=>!pe(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let{widgets:o,resolvedFilters:a,filterGroups:g}=await this.openAiService.applyFilters(e,t.filters,this.dashboardId,"published",n.signal,{mode:t.mode,prompt:t.prompt,timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;this.widgets=ge(this.widgets,o),this.activeDashboardFilters=t.filters,this.lastMonitoredTotal=null,this.activeResolvedFilters=a,this.activeFilterGroups=g,this.applySummary=Fe(o,this.buildActiveFilters(t.filters))}catch(o){if(o?.name==="AbortError")return;console.error("Apply filters failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}async applyTimeRange(t){this.currentTimeRange=t;let e=this.widgets.filter(o=>!pe(o));if(e.length===0||!this.dashboardId)return;this.applyFiltersAbort?.abort();let n=new AbortController;this.applyFiltersAbort=n;let i=++this.applyFiltersSeq;this.applyingFilters=!0;try{let o=this.activeDashboardFilters??{},{widgets:a,resolvedFilters:g,filterGroups:p}=await this.openAiService.applyFilters(e,o,this.dashboardId,"published",n.signal,{resolvedFilters:this.activeResolvedFilters??[],timeRange:t??void 0});if(i!==this.applyFiltersSeq)return;this.widgets=ge(this.widgets,a),this.activeResolvedFilters=g,this.activeFilterGroups=p,this.applySummary=Fe(a,this.buildActiveFilters(o)),t&&this.checkForNewSinceLastCheck(t)}catch(o){if(o?.name==="AbortError")return;console.error("Apply time range failed:",o)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}checkForNewSinceLastCheck(t){if(!(Math.abs(Date.now()-new Date(t.to).getTime())<6e4))return;let n=this.kpiTotal(this.widgets);n!=null&&(this.lastMonitoredTotal=n)}kpiTotal(t){let e=0,n=!1;for(let i of t){let o=i.config?.chart;if(o?.type!=="kpi")continue;let a=Number(o.value);Number.isFinite(a)&&(e+=a,n=!0)}return n?e:null}buildActiveFilters(t){return Nt(t,e=>this.filterFieldLabel(e))}filterFieldLabel(t){for(let e of this.filterSuggestCache.values()){let n=e.find(i=>i.type==="attribute"&&i.id===t);if(n)return n.label}return t}isEmptyFilters(t){if(!t)return!0;for(let e of Object.values(t))if(e!=null&&!(typeof e=="string"&&e.trim()==="")&&!(typeof e=="object"&&Object.keys(e).length===0))return!1;return!0}async reloadDashboard(){if(!this.dashboardId)return;this.applyFiltersAbort?.abort();let t=++this.applyFiltersSeq;this.applyingFilters=!0,this.activeDashboardFilters=null,this.lastMonitoredTotal=null,this.activeResolvedFilters=null,this.activeFilterGroups=[],this.applySummary=null;try{let e=await this.dashboardsService.fetchDashboard(this.dashboardId);if(t!==this.applyFiltersSeq)return;this.widgets=(e.widgets??[]).map(n=>({id:n.id,title:n.title??"",widgetType:n.type??"chart",layout:n.layout,config:zt(n.nileConfig),drilldownBy:n.drilldownBy,dataSourceId:n.dataSourceId,queryMeta:n.queryMeta,category:n.category??null}))}catch(e){console.error("Reload dashboard failed:",e)}finally{t===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}this.currentTimeRange&&t===this.applyFiltersSeq&&await this.applyTimeRange(this.currentTimeRange)}primeFilterWidgets(){if(this.dashboardId)for(let t of this.widgets){if(this.primedFilterWidgets.has(t.id))continue;let e=t.config?.chart;if(e?.type!=="filter")continue;let n=e.controls?.find(i=>i.variant==="prompt"||i.variant==="expression"||i.variant==="hybrid")??e.controls?.find(i=>i.id);n?.id&&(this.primedFilterWidgets.add(t.id),this.fetchSuggestionsOnce(t.id,n.id,this.dashboardId))}}applyFilterSuggestions(t,e,n){let i=Array.isArray(n.suggestions)?n.suggestions:[];if(!i.length){n.nextToken&&i.push({id:n.nextToken.value,label:n.nextToken.label,type:"attribute"});for(let o of n.completions)i.push({label:o,type:"suggestion"})}i.length!==0&&(this.filterSuggestCache.set(t,i),this.gridRef?.patchFilterSuggestions(t,e,i))}async onAiSend(t){if(!this.dashboardId)return;let e=this.sessionMap.get(t.widgetId)??t.sessionId;this.sessionMap.set(t.widgetId,e);try{let n=Zt(),i=await A(this.http.post(`${k.baseUrl}/api/customers/${n}/products/${O()}/workforce/dashboards/${this.dashboardId}/widgets/${t.widgetId}/chat`,{message:t.message,sessionId:e})),o=i?.reply?.content;o&&(this.sessionMap.set(t.widgetId,i.sessionId??e),this.zone.run(()=>{t.chartEl?.addAiResponse?.(o)}))}catch(n){console.error("Chat request failed:",n),this.zone.run(()=>{t.chartEl?.addAiResponse?.("Sorry, I couldn't process your request. Please try again.")})}}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["app-dashboard-viewer"]],viewQuery:function(e,n){if(e&1&&ae(en,5),e&2){let i;j(i=Z())&&(n.gridRef=i.first)}},inputs:{config:"config"},features:[se([{provide:Mt,useFactory:t=>t.fetchGridPage.bind(t),deps:[$]},{provide:kt,useFactory:t=>t.fetchFilterValues.bind(t),deps:[T]},Oe(T),ke(T),Se(T),Te(T)])],decls:4,vars:21,consts:[["grid",""],[3,"forecast","aiSend","openAiBuilder","filterSubmit","filterChange","widgetChartTypeChanged","widgetFiltersChanged","widgetColorChanged","setAlert","widgetClick","widgets","editMode","dashboardId","persistToPublished","widgetsLoading","dashboardFilters","resolvedFilters","applySummary","canSetAlert","canAddToStory","canForecast","forecastable","forecastingWidgetId"],[1,"aq-detail-overlay"],[3,"closed","saved","open","widget","dashboardId","source","filterPredicates","filterHasOr","authoringMode"],[1,"aq-detail-overlay__crumbs"],[3,"nile-click"],["variant","text","width","160","height","16"],[1,"aq-detail-overlay__body"],[3,"widgets","widgetsLoading","editMode","selectable","canSetAlert","canAddToStory","canForecast"],[1,"aq-detail-skeleton"],[1,"aq-detail-skeleton__row"],["variant","rectangular","width","100%","height","96","border-radius","12px"],["variant","rectangular","width","100%","height","280","border-radius","12px"]],template:function(e,n){e&1&&(s(0,"shared-dashboard-grid",1,0),_("forecast",function(o){return n.onForecast(o)})("aiSend",function(o){return n.onAiSend(o)})("openAiBuilder",function(){return n.openInBuilder()})("filterSubmit",function(o){return n.onFilterSubmit(o)})("filterChange",function(o){return n.onFilterChange(o)})("widgetChartTypeChanged",function(o){return n.onWidgetPatchedByGrid(o)})("widgetFiltersChanged",function(o){return n.onWidgetPatchedByGrid(o)})("widgetColorChanged",function(o){return n.onWidgetPatchedByGrid(o)})("setAlert",function(o){return n.onSetAlert(o)})("widgetClick",function(o){return n.onKpiWidgetClicked(o)}),l(),b(2,an,11,3,"div",2),s(3,"app-alert-drawer",3),_("closed",function(){return n.onAlertClosed()})("saved",function(){return n.onAlertSaved()}),l()),e&2&&(C("widgets",n.widgets)("editMode",!1)("dashboardId",n.dashboardId)("persistToPublished",!0)("widgetsLoading",n.applyingFilters||n.isRefreshingData)("dashboardFilters",n.activeDashboardFilters)("resolvedFilters",n.activeResolvedFilters)("applySummary",n.applySummary)("canSetAlert",!0)("canAddToStory",!1)("canForecast",!0)("forecastable",n.forecastable)("forecastingWidgetId",n.forecastingWidgetId),c(2),y(n.widgetDetailPanelOpen?2:-1),c(),C("open",n.alertDrawerOpen)("widget",n.alertWidget)("dashboardId",n.dashboardId)("source",n.alertSource)("filterPredicates",n.alertFilterPredicates)("filterHasOr",n.alertFilterHasOr)("authoringMode",n.alertAuthoringMode))},dependencies:[De,Ae,Ee],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;position:relative;height:100%;view-transition-name:dv-viewer-pane}.aq-detail-overlay[_ngcontent-%COMP%]{position:absolute;inset:0;z-index:50;display:flex;flex-direction:column;background:#fff;view-transition-name:dv-detail-morph}.dv-morphing[_nghost-%COMP%]{view-transition-name:none}.aq-detail-overlay__crumbs[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;box-sizing:border-box;min-height:56px;padding:10px 20px;border-bottom:1px solid #eaecf0;flex-shrink:0}.aq-detail-overlay__crumbs[_ngcontent-%COMP%] nile-breadcrumb[_ngcontent-%COMP%]{display:inline-flex;align-items:center}.aq-detail-overlay__body[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:auto;padding:20px;background:var(--nile-color-bg-subtle, #fbfbfd)}.aq-detail-skeleton[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px}.aq-detail-skeleton__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.aq-detail-skeleton-grid[_ngcontent-%COMP%]{position:relative;width:100%}.aq-detail-skeleton-slot[_ngcontent-%COMP%]{position:absolute}.dv-skel-card[_ngcontent-%COMP%]{height:100%;display:flex;flex-direction:column;box-sizing:border-box;background:var(--ng-colors-bg-primary, #fff);border-radius:var(--ng-radius-xl, 12px);box-shadow:var(--ng-shadow-sm);overflow:hidden}.dv-skel-card__head[_ngcontent-%COMP%]{padding:13px 14px;border-bottom:1px solid #eef1f6;flex-shrink:0}.dv-skel-card__body[_ngcontent-%COMP%]{flex:1;min-height:0;padding:12px 14px}.dv-skel-card__body[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%], .dv-skel-card__body[_ngcontent-%COMP%] nile-skeleton-loader[_ngcontent-%COMP%]::part(base){height:100%}']})};var Re=class r{http=v(K);tokenStore=v(ce);get customerId(){return this.tokenStore.tenantId()??""}async chat(t,e,n,i){let o=await new Promise((a,g)=>{let p=this.http.post(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${e}/chat`,{message:t,sessionId:n}).subscribe({next:x=>a(x),error:x=>{x instanceof q?g(new Error(x.error?.error||x.message)):g(x)}});if(i){if(i.aborted){p.unsubscribe();let x=new Error("Aborted");x.name="AbortError",g(x);return}i.addEventListener("abort",()=>{p.unsubscribe();let x=new Error("Aborted");x.name="AbortError",g(x)},{once:!0})}});if(!o?.success)throw new Error("Chat request failed");return o}async getSuggestions(t){if(!t)return[];let e;try{e=await A(this.http.get(`${k.baseUrl}/api/customers/${this.customerId}/products/${O()}/workforce/dashboards/${t}/chat/suggestions`))}catch(n){throw n instanceof q?new Error(n.error?.error||n.message):n}if(Array.isArray(e))return e;if(e.success===!1)throw new Error("Suggestions request failed");return e.suggestions??e.data??[]}static \u0275fac=function(e){return new(e||r)};static \u0275prov=B({token:r,factory:r.\u0275fac,providedIn:"root"})};var ln=["sliderGrid"],dn=r=>({"recommend-window":r}),cn=()=>({variant:"welcome"}),gn=()=>[1,2,3,4],pn=r=>({"mic-listening":r}),hn=r=>({disabled:r}),Yt=(r,t)=>t.title;function mn(r,t){r&1&&V(0)}function un(r,t){r&1&&(s(0,"div",18),h(1,"nile-skeleton-loader",19),l())}function fn(r,t){r&1&&(s(0,"div",17),F(1,un,2,0,"div",18,U),l()),r&2&&(c(),E(ne(0,gn)))}function _n(r,t){if(r&1){let e=M();s(0,"button",23),_("click",function(){let i=u(e).$implicit,o=d(5);return f(o.runPrompt(i.title))}),s(1,"div",24),h(2,"nile-icon",25),l(),s(3,"span",26),w(4),l()()}if(r&2){let e=t.$implicit;c(4),W(e.title)}}function bn(r,t){if(r&1){let e=M();s(0,"div",17),F(1,_n,5,1,"button",20,Yt),l(),s(3,"button",21),_("click",function(){u(e);let i=d(4);return f(i.openPromptGallery())}),h(4,"nile-glyph",22),s(5,"span"),w(6,"View prompt gallery"),l()()}if(r&2){let e=d(4);c(),E(e.topRecommended())}}function yn(r,t){if(r&1&&(s(0,"div",9)(1,"div",12),h(2,"nile-icon",13),l(),s(3,"h2",14),w(4,"What would you like to ask?"),l(),s(5,"p",15),w(6,"Ask anything about your dashboard."),l(),L(7,mn,1,0,"ng-container",16),b(8,fn,3,1,"div",17)(9,bn,7,0),l()),r&2){let e=d(3),n=R(3);c(7),C("ngTemplateOutlet",n)("ngTemplateOutletContext",ne(3,cn)),c(),y(e.loadingSuggestions()?8:e.recommended().length>0?9:-1)}}function Cn(r,t){r&1&&(s(0,"div",10),h(1,"nile-icon",27),s(2,"div",28),w(3,"Generating your answer..."),l()()),r&2&&(c(),C("name","loader")("size","20"))}function vn(r,t){if(r&1&&(s(0,"div",29)(1,"div",30)(2,"span"),w(3),l()()()),r&2){let e=d().$implicit;c(3),W(e.content)}}function xn(r,t){if(r&1&&(s(0,"div")(1,"div",31),h(2,"nile-glyph",32),l(),s(3,"div",33),h(4,"div",34),l()()),r&2){let e=d().$implicit;c(4),C("innerHTML",e.content,nt)}}function wn(r,t){if(r&1&&(b(0,vn,4,1,"div",29),b(1,xn,5,1,"div")),r&2){let e=t.$implicit;y(e.role==="user"?0:-1),c(),y(e.role==="assistant"?1:-1)}}function Pn(r,t){r&1&&V(0)}function Mn(r,t){if(r&1&&L(0,Pn,1,0,"ng-container",35),r&2){d(3);let e=R(3);C("ngTemplateOutlet",e)}}function Dn(r,t){if(r&1){let e=M();s(0,"button",23),_("click",function(){let i=u(e).$implicit,o=d(4);return f(o.onGalleryPromptClick(i.title))}),s(1,"div",24),h(2,"nile-icon",25),l(),s(3,"span",26),w(4),l()()}if(r&2){let e=t.$implicit;c(4),W(e.title)}}function kn(r,t){if(r&1){let e=M();s(0,"div",11)(1,"div",36)(2,"span",37),w(3,"Prompt gallery"),l(),s(4,"button",38),_("click",function(){u(e);let i=d(3);return f(i.closePromptGallery())}),h(5,"nile-glyph",39),l()(),s(6,"div",40)(7,"p",41),w(8,"Pick a suggestion to get started."),l(),s(9,"div",42),F(10,Dn,5,1,"button",20,Yt),l()()()}if(r&2){let e=d(3);c(10),E(e.recommended())}}function Sn(r,t){if(r&1){let e=M();s(0,"div",6)(1,"nile-glyph",7),_("click",function(){u(e);let i=d(2);return f(i.closePanel.emit())}),l()(),s(2,"div",8),b(3,yn,10,4,"div",9),b(4,Cn,4,2,"div",10),F(5,wn,2,2,null,null,U),l(),b(7,Mn,1,1,"ng-container"),b(8,kn,12,0,"div",11)}if(r&2){let e,n,i,o,a=d(2);c(2),C("ngClass",le(5,dn,!(!((e=a.chatsDetails())==null||e.message==null)&&e.message.length))),c(),y(!((n=a.chatsDetails())==null||n.message==null)&&n.message.length?-1:3),c(),y(a.isGenerating()?4:-1),c(),E((i=a.chatsDetails())==null?null:i.message),c(2),y(!((o=a.chatsDetails())==null||o.message==null)&&o.message.length?7:-1),c(),y(a.showPromptGallery()?8:-1)}}function On(r,t){if(r&1){let e=M();s(0,"div",43),_("pointerdown",function(i){u(e);let o=d(2);return f(o.onResizeStart(i))})("pointermove",function(i){u(e);let o=d(2);return f(o.onResizeMove(i))})("pointerup",function(i){u(e);let o=d(2);return f(o.onResizeEnd(i))})("pointercancel",function(i){u(e);let o=d(2);return f(o.onResizeEnd(i))}),l(),s(1,"div",44)(2,"div",45)(3,"shared-dashboard-grid",46,1),_("filterSubmit",function(i){u(e);let o=d(2);return f(o.onSliderFilterSubmit(i))})("filterChange",function(i){u(e);let o=d(2);return f(o.onSliderFilterChange(i))})("widgetChartTypeChanged",function(i){u(e);let o=d(2);return f(o.onSliderWidgetPatched(i))})("widgetFiltersChanged",function(i){u(e);let o=d(2);return f(o.onSliderWidgetPatched(i))})("setAlert",function(i){u(e);let o=d(2);return f(o.onSetAlert(i))}),l(),s(5,"app-alert-drawer",47),_("closed",function(){u(e);let i=d(2);return f(i.onAlertClosed())})("saved",function(){u(e);let i=d(2);return f(i.onAlertClosed())}),l()()()}if(r&2){let e=d(2);c(3),C("widgets",e.sliderWidgets())("editMode",!1)("outerMargin",!1)("dashboardId",e.dashboardId())("dashboardFilters",e.activeDashboardFilters())("resolvedFilters",e.activeResolvedFilters())("persistToPublished",!0)("canSetAlert",!0)("canAddToStory",!1),c(2),C("open",e.alertDrawerOpen())("widget",e.alertWidget())("dashboardId",e.dashboardId())("source",e.alertSource())}}function Tn(r,t){if(r&1&&(s(0,"div",4)(1,"div",5),b(2,Sn,9,7),l(),b(3,On,6,13),l()),r&2){let e=d();te("chat-layout--resizing",e.isResizing()),c(),at("flex",e.chatColumnWidthPct()!==null?"0 0 "+e.chatColumnWidthPct()+"%":null),te("chat-column--split",!!e.dashboardConfig()&&!e.chatOnly()),c(),y(e.loadingChat()?-1:2),c(),y(e.dashboardConfig()&&!e.chatOnly()?3:-1)}}function An(r,t){if(r&1){let e=M();s(0,"div",48)(1,"label",49)(2,"input",50),_("input",function(i){u(e);let o=d();return f(o.queryString.set(i.target.value))})("keyup.enter",function(){u(e);let i=d();return f(i.postMessage())}),l(),s(3,"div",51)(4,"div",52)(5,"nile-glyph",53),_("click",function(){u(e);let i=d();return f(i.toggleMic())}),l(),s(6,"nile-glyph",54),_("click",function(){u(e);let i=d();return f(i.isGenerating()?i.cancelGenerate():i.postMessage())}),l()()()()()}if(r&2){let e=t.variant,n=d();te("input-query-container--welcome",e==="welcome"),c(2),C("value",n.queryString()),c(3),C("name",n.isMicListening()?"ng-mic":"ng-mic-off")("ngClass",le(8,pn,n.isMicListening())),c(),C("name",n.isGenerating()?"ng-circle-stop":"ng-send")("size",n.isGenerating()?"18":"16")("ngClass",le(10,hn,!n.isGenerating()&&!n.queryString()))}}var Ne=class r{constructor(t,e,n){this.chatService=t;this.openAiService=e;this.sanitizer=n;X(()=>{let o=this.dashboardId();o&&this.loadSuggestions(o)});let i=null;X(()=>{let o=this.dashboardConfig(),a=o?.id??null;a!==i&&(this.primedFilterWidgets.clear(),i=a);let g=(o?.widgets??[]).map(p=>({id:p.id,title:p.title??"",widgetType:p.type??"chart",layout:p.layout,config:p.nileConfig,drilldownBy:p.drilldownBy,queryMeta:p.queryMeta,dataSourceId:p.dataSourceId}));this.sliderWidgets.set(g),queueMicrotask(()=>this.primeFilterWidgets())})}chatService;openAiService;sanitizer;closePanel=new me;dashboardId=Y("");dashboardName=Y("");dashboardConfig=Y(null);chatOnly=Y(!1);initialPrompt=Y("");allChats=m([]);chatsDetails=m(null);isGenerating=m(!1);queryString=m("");searchTerm=m("");selectedChatContextId=m("");loadingChat=m(!1);loadingAllChat=m(!1);isDeleting=m(!1);isMicListening=m(!1);recognition=null;micBaseText="";silenceTimer=null;micSilenceMs=5e3;recommended=m([]);topRecommended=S(()=>this.recommended().slice(0,4));loadingSuggestions=m(!1);showPromptGallery=m(!1);chatColumnWidthPct=m(null);isResizing=m(!1);resizeRect=null;resizePointerId=null;resizeRafPending=!1;sliderWidgets=m([]);activeDashboardFilters=m(null);activeResolvedFilters=m(null);alertDrawerOpen=m(!1);alertWidget=m(null);onSetAlert(t){this.alertWidget.set(t),this.alertDrawerOpen.set(!0)}onSliderWidgetPatched(t){this.sliderWidgets.update(e=>e.map(n=>n.id===t.id?t:n))}onAlertClosed(){this.alertDrawerOpen.set(!1)}alertSource=S(()=>{let t=this.dashboardConfig();return t?{connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType}:null});sliderGridRef;applyingFilters=m(!1);filterSuggestTimers=new Map;filterSuggestSeq=new Map;primedFilterWidgets=new Set;applyFiltersSeq=0;applyFiltersAbort;generateAbort;formattedChats=S(()=>this.buildFormattedChats(this.allChats()));filteredFormattedChats=S(()=>{let t=this.formattedChats(),e=this.searchTerm().toLowerCase().trim();if(!e)return t;let n=i=>i.filter(o=>o.displayName.toLowerCase().includes(e));return{today:n(t.today),yesterday:n(t.yesterday),older:n(t.older)}});ngOnInit(){this.createNewChat();let t=this.initialPrompt();t&&(this.queryString.set(t),this.postMessage())}async loadSuggestions(t){this.loadingSuggestions.set(!0);try{let e=await this.chatService.getSuggestions(t);this.recommended.set(e.map(n=>({title:n})))}catch(e){console.error("Failed to load chat suggestions:",e),this.recommended.set([])}finally{this.loadingSuggestions.set(!1)}}runPrompt(t){this.queryString.set(t),this.postMessage()}openPromptGallery(){this.showPromptGallery.set(!0)}closePromptGallery(){this.showPromptGallery.set(!1)}onGalleryPromptClick(t){this.closePromptGallery(),this.runPrompt(t)}isFilterWidget(t){return t?.config?.chart?.type==="filter"}onSliderFilterChange(t){let e=t.widgetId,n=t.controlId;if(!e||!n)return;let i=this.dashboardId();if(!i)return;let o=this.filterSuggestTimers.get(e);o&&clearTimeout(o);let a=(t.query??"").trim();if(!a)return;let g=(this.filterSuggestSeq.get(e)??0)+1;this.filterSuggestSeq.set(e,g);let p=setTimeout(async()=>{try{let x=this.sliderWidgets(),N=await this.openAiService.filterSuggest(i,a,x,"published");if(this.filterSuggestSeq.get(e)!==g)return;this.applyFilterSuggestions(e,n,N)}catch(x){console.warn("Filter suggest failed:",x)}},400);this.filterSuggestTimers.set(e,p)}async onSliderFilterSubmit(t){let e=this.sliderWidgets(),n=e.filter(a=>!this.isFilterWidget(a));if(n.length===0)return;this.applyFiltersAbort?.abort();let i=new AbortController;this.applyFiltersAbort=i;let o=++this.applyFiltersSeq;this.applyingFilters.set(!0);try{let{widgets:a,resolvedFilters:g}=await this.openAiService.applyFilters(n,t.filters,this.dashboardId(),"published",i.signal,{mode:t.mode,prompt:t.prompt});if(o!==this.applyFiltersSeq)return;this.sliderWidgets.set(ge(e,a)),this.activeDashboardFilters.set(t.filters),this.activeResolvedFilters.set(g)}catch(a){if(a?.name==="AbortError"||o!==this.applyFiltersSeq)return;let g=a instanceof Error?a.message:"Failed to apply filters.";this.pushSystemMessage("error",`Apply filters failed: ${g}`)}finally{o===this.applyFiltersSeq&&this.applyingFilters.set(!1)}}primeFilterWidgets(){let t=this.dashboardId();if(!t)return;let e=this.sliderWidgets();for(let n of e){if(this.primedFilterWidgets.has(n.id))continue;let i=n.config?.chart;if(i?.type!=="filter")continue;let o=i.controls?.find(g=>g.variant==="expression"||g.variant==="hybrid");if(!o?.id)continue;this.primedFilterWidgets.add(n.id);let a=o.id;(async()=>{try{let g=await this.openAiService.filterSuggest(t,"",e,"published");this.applyFilterSuggestions(n.id,a,g)}catch(g){this.primedFilterWidgets.delete(n.id),console.warn("Filter suggest prime failed:",g)}})()}}applyFilterSuggestions(t,e,n){let i=Array.isArray(n.suggestions)?n.suggestions:[];if(!i.length){n.nextToken&&i.push({id:n.nextToken.value,label:n.nextToken.label,type:"attribute"});for(let o of n.completions)i.push({label:o,type:"suggestion"})}i.length!==0&&this.sliderGridRef?.patchFilterSuggestions(t,e,i)}onResizeStart(t){t.preventDefault();let e=t.currentTarget,n=e.parentElement;n&&(this.resizeRect=n.getBoundingClientRect(),e.setPointerCapture(t.pointerId),this.resizePointerId=t.pointerId,this.isResizing.set(!0))}onResizeMove(t){if(!this.isResizing()||!this.resizeRect)return;let n=(t.clientX-this.resizeRect.left)/this.resizeRect.width*100,i=Math.min(75,Math.max(20,n));this.chatColumnWidthPct.set(i),this.scheduleGridReflow()}onResizeEnd(t){let e=t.currentTarget;this.resizePointerId!==null&&e.hasPointerCapture?.(this.resizePointerId)&&e.releasePointerCapture(this.resizePointerId),this.isResizing.set(!1),this.resizeRect=null,this.resizePointerId=null,this.scheduleGridReflow()}scheduleGridReflow(){this.resizeRafPending||(this.resizeRafPending=!0,requestAnimationFrame(()=>{this.resizeRafPending=!1,window.dispatchEvent(new Event("resize"))}))}createNewChat(){let t={id:crypto.randomUUID(),displayName:"New Chat",createdOn:new Date().toISOString(),sessionId:crypto.randomUUID(),message:[]};this.allChats.update(e=>[t,...e]),this.getChatDetails(t.id)}getChatDetails(t){this.selectedChatContextId.set(t);let e=this.allChats().find(n=>n.id===t);e&&this.chatsDetails.set(e),this.loadingChat.set(!1)}deleteChat(t){if(this.isDeleting.set(!0),this.allChats.update(e=>e.filter(n=>n.id!==t)),this.isDeleting.set(!1),this.chatsDetails()?.id===t){let e=this.allChats();e.length?this.getChatDetails(e[0].id):this.createNewChat()}}onSearchChat(t){this.searchTerm.set(t)}async postMessage(){let t=this.queryString().trim();if(!t||this.isGenerating())return;this.chatsDetails()||this.createNewChat();let e=this.chatsDetails();e.message.unshift({role:"user",content:t}),e.displayName==="New Chat"&&(e.displayName=t.length>20?t.substring(0,20):t,this.allChats.update(i=>[...i])),this.chatsDetails.set(P({},e)),this.queryString.set(""),this.isGenerating.set(!0);let n=new AbortController;this.generateAbort=n;try{let i=await this.chatService.chat(t,this.dashboardId(),e.sessionId,n.signal);e.sessionId=i.sessionId,e.message.unshift({role:"assistant",content:this.sanitizeHtml(i.reply.content)})}catch(i){if(i instanceof Error&&i.name==="AbortError")e.message=e.message.filter((o,a)=>!(a===0&&o.role==="user"));else{let o=i instanceof Error?i.message:"Failed to get response.";this.pushSystemMessage("error",`Chat failed: ${o}`)}}finally{this.generateAbort===n&&(this.generateAbort=void 0),this.chatsDetails.set(P({},e)),this.isGenerating.set(!1)}}cancelGenerate(){this.generateAbort?.abort()}toggleMic(){this.isMicListening()?(this.clearSilenceTimer(),this.recognition?.stop()):this.startListening()}startListening(){let t=window,e=t.SpeechRecognition??t.webkitSpeechRecognition;e&&(this.micBaseText=this.queryString(),this.recognition=new e,this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang="en-US",this.recognition.onresult=n=>{let i="";for(let a=0;a<n.results.length;a++)i+=n.results[a][0].transcript;let o=this.micBaseText&&!this.micBaseText.endsWith(" ")?" ":"";this.queryString.set(this.micBaseText+o+i),this.resetSilenceTimer()},this.recognition.onend=()=>{this.clearSilenceTimer(),this.isMicListening.set(!1),this.recognition=null},this.recognition.start(),this.isMicListening.set(!0),this.resetSilenceTimer())}resetSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{this.silenceTimer=null,this.recognition?.stop(),this.queryString().trim()&&this.postMessage()},this.micSilenceMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}pushSystemMessage(t,e){let n=this.chatsDetails();if(!n){t==="success"&&this.showToast("Done",e);return}let i=String(e).trim().replace(/[.!?]+$/,"").replace(/[<>&]/g,a=>a==="<"?"&lt;":a===">"?"&gt;":"&amp;"),o=t==="error"?`ERROR: ${i}!`:i;n.message.unshift({role:"assistant",content:this.sanitizeHtml(`<p class="chat-system chat-system--${t}">${o}</p>`)}),this.chatsDetails.set(P({},n))}showToast(t,e){let n=document.createElement("nile-toast");n.variant="success",n.title=t,n.content=e,n.duration=5e3,n.closable=!0,n.toast(),Ft()}sanitizeHtml(t){return this.sanitizer.sanitize(tt.HTML,t)??""}buildFormattedChats(t){let e=[...t].sort((i,o)=>new Date(o.createdOn).getTime()-new Date(i.createdOn).getTime()),n={today:[],yesterday:[],older:[]};return e.forEach(i=>{this.isToday(i.createdOn)?n.today.push(i):this.isYesterday(i.createdOn)?n.yesterday.push(i):n.older.push(i)}),n}isToday(t){let e=new Date(t),n=new Date;return e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()}isYesterday(t){let e=new Date(t),n=new Date;return n.setDate(n.getDate()-1),e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()}static \u0275fac=function(e){return new(e||r)(we(Re),we($),we(gt))};static \u0275cmp=z({type:r,selectors:[["db-ai-prompt-panel"]],viewQuery:function(e,n){if(e&1&&ae(ln,5),e&2){let i;j(i=Z())&&(n.sliderGridRef=i.first)}},inputs:{dashboardId:[1,"dashboardId"],dashboardName:[1,"dashboardName"],dashboardConfig:[1,"dashboardConfig"],chatOnly:[1,"chatOnly"],initialPrompt:[1,"initialPrompt"]},outputs:{closePanel:"closePanel"},features:[se([])],decls:4,vars:1,consts:[["promptInput",""],["sliderGrid",""],[1,"qna-panel"],[1,"chat-layout",3,"chat-layout--resizing"],[1,"chat-layout"],[1,"chat-column"],[1,"chat-header"],["name","close","size","16",1,"close-panel-icon",3,"click"],[1,"chat-message-container",3,"ngClass"],[1,"welcome-section"],[1,"generating-loader"],[1,"contained-panel","prompt-gallery-panel"],[1,"ai-badge","ai-badge--md","welcome-icon-wrap"],["color","#2970ff","name","smartcode","size","20"],[1,"welcome-title"],[1,"welcome-subtitle"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"recommended"],[1,"recommended-box","skeleton-box"],[2,"width","100%","height","64px","border-radius","12px"],["type","button",1,"recommended-box"],["type","button",1,"browse-more",3,"click"],["name","ng-lightbulb-05","method","stroke","size","14"],["type","button",1,"recommended-box",3,"click"],[1,"ai-badge","ai-badge--sm","rec-icon-wrap"],["color","#2970ff","name","ng-lightbulb-05","size","16","method","stroke"],[1,"rec-title"],[3,"name","size"],[1,"generating-text"],[1,"user-row"],[1,"user"],[1,"ai-badge","ai-badge--sm","assistant-icon"],["name","ng-stars-02","method","stroke","size","16","color","#2970ff"],[1,"assistant"],[1,"assistant-body",3,"innerHTML"],[4,"ngTemplateOutlet"],[1,"contained-panel__header"],[1,"contained-panel__title"],["type","button","aria-label","Close",1,"contained-panel__close",3,"click"],["name","close","size","16"],[1,"contained-panel__body"],[1,"prompt-gallery-subtitle"],[1,"prompt-gallery"],["role","separator","aria-orientation","vertical","aria-label","Resize chat column",1,"chat-layout__resizer",3,"pointerdown","pointermove","pointerup","pointercancel"],[1,"dashboard-slider"],[1,"dashboard-slider__body"],[3,"filterSubmit","filterChange","widgetChartTypeChanged","widgetFiltersChanged","setAlert","widgets","editMode","outerMargin","dashboardId","dashboardFilters","resolvedFilters","persistToPublished","canSetAlert","canAddToStory"],[3,"closed","saved","open","widget","dashboardId","source"],[1,"input-query-container"],[1,"chat-input-pill"],["type","text","placeholder","Enter your query",1,"input-query",3,"input","keyup.enter","value"],[1,"pill-toolbar"],[1,"pill-toolbar__right"],["method","stroke",1,"mic-icon",3,"click","name","ngClass"],["method","stroke",1,"send-icon",3,"click","name","size","ngClass"]],template:function(e,n){e&1&&(s(0,"div",2),b(1,Tn,4,8,"div",3),l(),L(2,An,7,12,"ng-template",null,0,fe)),e&2&&(c(),y(n.loadingAllChat()?-1:1))},dependencies:[De,lt,Me,Rt,Ae,Ee],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:0}.qna-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;background:var(--ng-colors-bg-secondary, #f9fafb);font-family:var(--ng-font-family-body)}.chat-layout[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:row;overflow:hidden;min-height:0;container-type:inline-size}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%]{cursor:col-resize;-webkit-user-select:none;user-select:none}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%] .chat-column[_ngcontent-%COMP%]{transition:none!important}.chat-layout.chat-layout--resizing[_ngcontent-%COMP%] .chat-layout__resizer[_ngcontent-%COMP%]:after{opacity:1}.chat-layout__resizer[_ngcontent-%COMP%]{flex:0 0 1px;align-self:stretch;cursor:col-resize;touch-action:none;-webkit-user-select:none;user-select:none;position:relative;background:transparent}.chat-layout__resizer[_ngcontent-%COMP%]:before{content:"";position:absolute;top:0;bottom:0;left:50%;transform:translate(-50%);width:1px;background:var(--ng-colors-border-secondary, #e9eaeb);transition:background .15s}.chat-layout__resizer[_ngcontent-%COMP%]:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:4px;height:36px;border-radius:999px;background:#2970ff;opacity:0;transition:opacity .15s;pointer-events:none}.chat-layout__resizer[_ngcontent-%COMP%]:hover:before{background:#2970ff;opacity:0;transition:opacity .15s;pointer-events:none}.chat-layout__resizer[_ngcontent-%COMP%]:hover:after{opacity:1}.dashboard-slider[_ngcontent-%COMP%]{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden;min-width:0;min-height:0;background:var(--ng-colors-bg-secondary, #f9fafb);animation:_ngcontent-%COMP%_slider-in .25s ease-out}.dashboard-slider__header[_ngcontent-%COMP%]{height:56px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box}.dashboard-slider__title[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27)}.dashboard-slider__body[_ngcontent-%COMP%]{flex:1;min-height:0;min-width:0;overflow:auto;padding:8px}.dashboard-slider__body[_ngcontent-%COMP%] > shared-dashboard-grid[_ngcontent-%COMP%]{display:block;min-width:calc(66.6667cqw - 32px)}@keyframes _ngcontent-%COMP%_slider-in{0%{transform:translate(24px);opacity:0}to{transform:translate(0);opacity:1}}.chat-column[_ngcontent-%COMP%]{flex:1 1 auto;display:flex;flex-direction:column;overflow:hidden;min-width:0;position:relative;background:#fff;container-type:inline-size;transition:flex-basis .3s ease,flex .3s ease}.chat-column.chat-column--split[_ngcontent-%COMP%]{flex:0 0 33.333%}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%]{padding:16px 16px 8px;flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:flex-end}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%] .close-panel-icon[_ngcontent-%COMP%]{cursor:pointer;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .chat-header[_ngcontent-%COMP%] .close-panel-icon[_ngcontent-%COMP%]:hover{color:var(--ng-colors-text-primary-900, #181d27)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%]{flex:1;overflow:auto;padding:20px 24px;display:flex;flex-direction:column-reverse}.chat-column[_ngcontent-%COMP%] .chat-message-container.recommend-window[_ngcontent-%COMP%]{justify-content:center;align-items:center;padding:32px 40px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user-row[_ngcontent-%COMP%]{display:flex;flex-direction:row-reverse;justify-content:flex-start;align-items:flex-start;gap:8px;margin-bottom:20px;margin-top:8px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user[_ngcontent-%COMP%]{flex:0 1 auto;min-width:0}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{background:#eff4ff;color:var(--ng-colors-text-primary-900, #181d27);padding:9px 14px;border-radius:14px 14px 2px;font-size:14px;display:inline-block;max-width:100%;text-align:left}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .user-icon[_ngcontent-%COMP%]{flex-shrink:0;width:28px;height:28px;border-radius:50%;background:#eff4ff;color:#2970ff;display:inline-flex;align-items:center;justify-content:center}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .assistant-icon[_ngcontent-%COMP%]{margin-bottom:6px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .assistant[_ngcontent-%COMP%]{padding:14px 16px;background:var(--ng-colors-bg-secondary, #f9fafb);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:2px 14px 14px;margin-bottom:14px;font-size:14px;line-height:1.65;color:var(--ng-colors-text-primary-900, #181d27)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .generating-loader[_ngcontent-%COMP%]{padding:10px 14px;height:40px;display:flex;gap:8px;align-items:center;background:var(--ng-colors-bg-secondary, #f9fafb);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:8px;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862);width:fit-content}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;gap:12px;width:100%;max-width:820px;text-align:center}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-icon-wrap[_ngcontent-%COMP%]{margin-bottom:4px}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-title[_ngcontent-%COMP%]{margin:0;font-size:22px;font-weight:700;color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.02em}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .welcome-section[_ngcontent-%COMP%] .welcome-subtitle[_ngcontent-%COMP%]{margin:0 0 8px;font-size:14px;color:var(--ng-colors-text-tertiary-600, #535862);max-width:440px;line-height:1.6}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .browse-more[_ngcontent-%COMP%]{margin-top:4px;align-self:flex-end;display:inline-flex;align-items:center;gap:6px;padding:6px 4px;background:transparent;border:0;cursor:pointer;font-size:12px;font-weight:500;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .browse-more[_ngcontent-%COMP%]:hover{color:#2970ff}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;width:100%}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px;font:inherit;color:inherit;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:14px;padding:18px;cursor:pointer;transition:border-color .18s,box-shadow .18s,transform .15s;background:#fff;text-align:left}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]:hover{border-color:#2970ff;box-shadow:0 6px 24px #2970ff1a;transform:translateY(-2px)}.chat-column[_ngcontent-%COMP%] .chat-message-container[_ngcontent-%COMP%] .recommended[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%] .rec-title[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);text-transform:capitalize;line-height:1.4}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%]{padding:14px 24px 18px;display:flex;justify-content:center;flex-shrink:0;background:#fff}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .chat-input-pill[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px;width:100%;max-width:760px;padding:14px 16px 12px;background:#fff;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:24px;box-shadow:0 1px 2px #1018280a,0 8px 24px #1018280f;cursor:text;transition:border-color .15s,box-shadow .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .chat-input-pill[_ngcontent-%COMP%]:focus-within{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff1f}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .input-query[_ngcontent-%COMP%]{width:100%;min-width:0;border:0;outline:0;background:transparent;padding:6px 2px;font:inherit;font-size:15px;color:var(--ng-colors-text-primary-900, #181d27);text-overflow:ellipsis}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .input-query[_ngcontent-%COMP%]::placeholder{color:var(--ng-colors-text-tertiary-600, #717680);overflow:hidden;text-overflow:ellipsis}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .pill-toolbar[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:flex-end;gap:8px}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .pill-toolbar__right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon[_ngcontent-%COMP%]{cursor:pointer;flex-shrink:0;transition:opacity .15s,transform .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon[_ngcontent-%COMP%]:hover{transform:translate(2px)}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .send-icon.disabled[_ngcontent-%COMP%]{opacity:.2;pointer-events:none}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon[_ngcontent-%COMP%]{cursor:pointer;color:var(--ng-colors-text-tertiary-600, #535862);transition:color .15s}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon[_ngcontent-%COMP%]:hover{color:#2970ff}.chat-column[_ngcontent-%COMP%] .input-query-container[_ngcontent-%COMP%] .mic-icon.mic-listening[_ngcontent-%COMP%]{color:#e53e3e;animation:_ngcontent-%COMP%_mic-pulse 1.2s ease-in-out infinite}.chat-column[_ngcontent-%COMP%] .input-query-container.input-query-container--welcome[_ngcontent-%COMP%]{border-top:0;background:transparent;padding:4px 0 12px;width:100%;max-width:680px}@keyframes _ngcontent-%COMP%_mic-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(1.3)}}.dashboard-slider__body[_ngcontent-%COMP%]{padding:unset}.contained-panel[_ngcontent-%COMP%]{position:absolute;inset:0;display:flex;flex-direction:column;background:#fff;border-left:1px solid var(--ng-colors-border-secondary, #e9eaeb);box-shadow:-8px 0 24px #10182814;z-index:var(--z-floating);animation:_ngcontent-%COMP%_contained-slide .25s ease-out}.contained-panel__header[_ngcontent-%COMP%]{height:56px;padding:0 16px;border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0;background:#fff;display:flex;align-items:center;justify-content:space-between;gap:8px;box-sizing:border-box}.contained-panel__close[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:4px;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;transition:color .15s;flex-shrink:0}.contained-panel__close[_ngcontent-%COMP%]:hover{color:var(--ng-colors-text-primary-900, #181d27)}.contained-panel__title[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.contained-panel__body[_ngcontent-%COMP%]{flex:1;min-height:0;overflow:auto;padding:16px 20px 20px}.prompt-gallery-subtitle[_ngcontent-%COMP%]{margin:0 0 24px;font-size:13px;color:var(--ng-colors-text-tertiary-600, #535862)}.prompt-gallery[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr;gap:12px;padding:6px 6px 8px}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;gap:10px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;padding:12px 16px;cursor:pointer;background:#fff;text-align:left;font:inherit;color:inherit;transition:border-color .18s,box-shadow .18s,transform .15s}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%]:hover{border-color:#2970ff;box-shadow:0 6px 24px #2970ff1a;transform:translateY(-2px)}.prompt-gallery[_ngcontent-%COMP%] .recommended-box[_ngcontent-%COMP%] .rec-title[_ngcontent-%COMP%]{font-size:13px;font-weight:500;color:var(--ng-colors-text-secondary-700, #414651);line-height:1.45}@keyframes _ngcontent-%COMP%_contained-slide{0%{transform:translate(8px);opacity:0}to{transform:translate(0);opacity:1}}.chat-system[_ngcontent-%COMP%]{margin:4px 0;font-size:13px;line-height:1.4;color:var(--ng-colors-text-tertiary-600, #535862)}.chat-system--error[_ngcontent-%COMP%]{color:var(--ng-colors-fg-error-primary, #d92d20);font-weight:500}']})};var Fn=r=>[r];function En(r,t){if(r&1&&ue(0,"nile-progress-bar",4),r&2){let e=d();ot("value",e.percent())}}var ze=class r{streamId;done=new me;failed=new me;streamService=v(Lt);totalCharts=m(0);widgetPhases=m([]);phaseLabel=m("Connecting to your data\u2026");dashboardNumber=m(0);barKey=m(0);pendingNewDashboard=!0;readyCount=S(()=>this.widgetPhases().filter(t=>t==="building"||t==="saving").length);percent=S(()=>{let t=this.totalCharts();if(!t)return 0;let e=this.widgetPhases(),n=0;for(let i=0;i<t;i++){let o=e[i];n+=o==="building"||o==="saving"?1:o==="querying"?.66:o==="analyzing"?.33:0}return Math.round(Math.min(1,n/t)*100)});countLabel=S(()=>{let t=this.totalCharts(),e=this.dashboardNumber();return!t||!e?"":`Dashboard ${e} \xB7 ${this.readyCount()} of ${t} charts`});finished=!1;dispose=null;ngOnInit(){if(!this.streamId){this.failed.emit();return}this.dispose=this.streamService.stream(this.streamId,t=>this.onEvent(t))}ngOnDestroy(){this.teardown()}onEvent(t){switch(t.kind){case"progress":{this.pendingNewDashboard&&(this.dashboardNumber.update(e=>e+1),this.pendingNewDashboard=!1),this.totalCharts.set(t.totalWidgets),this.widgetPhases.update(e=>{let n=[...e];return n[t.widgetIndex]=Ht(n[t.widgetIndex],t.phase),n}),this.phaseLabel.set(t.label);break}case"dashboard-start":{this.resetForNextDashboard(t.dashboardName?`Setting up ${t.dashboardName}\u2026`:"Preparing the next dashboard\u2026");break}case"saved":{this.resetForNextDashboard("Preparing the next dashboard\u2026");break}case"complete":{t.dashboardIds.length>0?this.finish(()=>this.done.emit(t.dashboardIds)):this.finish(()=>this.failed.emit());break}case"error":{t.dashboardIds.length>0?this.finish(()=>this.done.emit(t.dashboardIds)):this.finish(()=>this.failed.emit());break}}}resetForNextDashboard(t){this.barKey.update(e=>e+1),this.pendingNewDashboard=!0,this.totalCharts.set(0),this.widgetPhases.set([]),this.phaseLabel.set(t)}finish(t){this.finished||(this.finished=!0,this.teardown(),t())}teardown(){this.dispose?.(),this.dispose=null}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["app-dashboard-generating"]],inputs:{streamId:"streamId"},outputs:{done:"done",failed:"failed"},decls:13,vars:4,consts:[["role","status","aria-live","polite",1,"genbar"],["variant","informative","size","medium","pulse","",1,"genbar__light"],[1,"genbar__title"],["aria-hidden","true",1,"genbar__divider"],[1,"genbar__bar",3,"value"],[1,"genbar__count"],[1,"genbar__live"],["aria-hidden","true",1,"genbar__spinner"],[1,"genbar__status"]],template:function(e,n){e&1&&(oe(0,"div",0),ue(1,"nile-status-light",1),oe(2,"span",2),w(3,"Generating your dashboards"),Pe(),ue(4,"span",3),F(5,En,1,1,"nile-progress-bar",4,rt),oe(7,"span",5),w(8),Pe(),oe(9,"div",6),ue(10,"nile-spinner",7),oe(11,"span",8),w(12),Pe()()()),e&2&&(c(5),E(le(2,Fn,n.barKey())),c(3),W(n.countLabel()),c(4),W(n.phaseLabel()))},styles:["[_nghost-%COMP%]{display:block;width:100%}.genbar[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-md, 12px);width:100%;min-width:0;padding-inline-start:var(--ng-spacing-lg, 16px)}.genbar__light[_ngcontent-%COMP%]{flex:none}.genbar__title[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-semibold, 600);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-primary-900, #181d27);white-space:nowrap}.genbar__divider[_ngcontent-%COMP%]{width:1px;height:20px;background:var(--ng-colors-border-secondary, #e9eaeb);flex:none}.genbar__bar[_ngcontent-%COMP%]{width:160px;flex:none}.genbar__count[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap}.genbar__live[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;margin-left:auto;flex:none;min-width:0}.genbar__spinner[_ngcontent-%COMP%]{font-size:14px;--indicator-color: #2970ff;--track-color: rgba(41, 112, 255, .2);flex:none}.genbar__status[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);line-height:var(--ng-line-height-text-sm, 1.4);color:var(--ng-colors-text-tertiary-600, #535862);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:260px}@media(max-width:760px){.genbar__divider[_ngcontent-%COMP%], .genbar__bar[_ngcontent-%COMP%], .genbar__count[_ngcontent-%COMP%]{display:none}}"]})};var In=["tabsScroller"],Kt=()=>({subtitle:"Explore your dashboards or ask your data a question"}),Rn=()=>({subtitle:"Setting up your initial dashboards \u2014 crafting a starter set from your data."}),Nn=(r,t)=>t.id;function zn(r,t){if(r&1&&(s(0,"header",8),V(1,16),l()),r&2){d(2);let e=R(5);c(),C("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Kt))}}function Vn(r,t){if(r&1&&h(0,"nile-skeleton-loader",11),r&2){let e=t.$implicit;ee("width",e)}}function Wn(r,t){r&1&&h(0,"nile-skeleton-loader",14)}function qn(r,t){r&1&&V(0)}function Hn(r,t){if(r&1&&(s(0,"div",5)(1,"div",7),b(2,zn,2,3,"header",8),s(3,"div",9)(4,"div",10),F(5,Vn,1,1,"nile-skeleton-loader",11,U),l(),h(7,"span",12)(8,"nile-skeleton-loader",13),F(9,Wn,1,0,"nile-skeleton-loader",14,U),l(),L(11,qn,1,0,"ng-container",15),l()()),r&2){let e=d(),n=R(7);c(2),y(e.showHeader()?2:-1),c(3),E(e.skeletonTabWidths),c(4),E(e.skeletonActionBtns),c(2),C("ngTemplateOutlet",n)}}function Ln(r,t){if(r&1&&(s(0,"header",8),V(1,16),l()),r&2){d(2);let e=R(5);c(),C("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Rn))}}function Gn(r,t){if(r&1){let e=M();s(0,"app-dashboard-generating",18),_("done",function(i){u(e);let o=d(2);return f(o.onGenerationDone(i))})("failed",function(){u(e);let i=d(2);return f(i.onGenerationFailed())}),l()}if(r&2){let e=d(2);C("streamId",e.generationStreamId())}}function $n(r,t){r&1&&V(0)}function Bn(r,t){if(r&1&&(s(0,"div",6)(1,"div",7),b(2,Ln,2,3,"header",8),s(3,"div",9),b(4,Gn,1,1,"app-dashboard-generating",17),l()(),L(5,$n,1,0,"ng-container",15),l()),r&2){let e=d(),n=R(7);c(2),y(e.showHeader()?2:-1),c(2),y(e.features().autoGenerate?4:-1),c(),C("ngTemplateOutlet",n)}}function Un(r,t){if(r&1&&(s(0,"header",8),V(1,16),l()),r&2){d(2);let e=R(5);c(),C("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Kt))}}function jn(r,t){r&1&&h(0,"nile-glyph",47)}function Zn(r,t){if(r&1){let e=M();s(0,"span",49),_("click",function(i){return i.stopPropagation()}),s(1,"input",50,3),_("input",function(){u(e);let i=R(2),o=d(4);return f(o.onRenameInputChange(i.value))})("keydown",function(i){u(e);let o=d().$implicit,a=d(3);return f(a.onRenameInputKeydown(i,o))})("click",function(i){return i.stopPropagation()}),l(),s(3,"button",51),_("click",function(i){u(e);let o=d().$implicit,a=d(3);return f(a.commitRenameDashboard(o,i))}),h(4,"nile-glyph",52),l()()}if(r&2){let e=d().$implicit,n=d(3);c(),C("value",n.renamingValue())("disabled",n.isRenamingDashboard()),ee("data-dashboard-id",e.id),c(2),C("disabled",n.isRenamingDashboard())}}function Yn(r,t){if(r&1){let e=M();s(0,"button",55),_("click",function(i){u(e);let o=d(2).$implicit,a=d(3);return f(a.startRenameDashboard(o,i))}),h(1,"nile-glyph",56),l()}}function Kn(r,t){if(r&1&&(s(0,"span",53),w(1),l(),b(2,Yn,2,0,"button",54)),r&2){let e=d().$implicit,n=d(3);c(),W(e.name),c(),y(n.features().rename&&!e.isAutoGenerated?2:-1)}}function Qn(r,t){if(r&1){let e=M();s(0,"nile-nav-tab",46),_("click",function(){let i=u(e).$implicit,o=d(3);return f(o.setActiveTab(i.id))}),b(1,jn,1,0,"nile-glyph",47),b(2,Zn,5,4,"span",48)(3,Kn,3,2),l()}if(r&2){let e=t.$implicit,n=d(3);ee("panel",e.id),c(),y(e.isAutoGenerated?1:-1),c(),y(n.renamingDashboardId()===e.id?2:3)}}function Jn(r,t){if(r&1){let e=M();s(0,"app-time-range-picker",57),_("apply",function(i){u(e);let o=d(3);return f(o.onTimeRangeApply(i))}),l()}if(r&2){let e=d(3);C("resetKey",e.activeTabId())}}function Xn(r,t){r&1&&h(0,"span",37)}function ei(r,t){if(r&1){let e=M();s(0,"nile-lite-tooltip",42)(1,"button",58),_("click",function(){u(e);let i=d(3);return f(i.refreshActiveDashboard())}),h(2,"nile-glyph",59),l()()}if(r&2){let e=d(3);c(),C("disabled",!e.activeTabId()||e.refreshingDashboard()),c(),te("home-refresh-glyph--spinning",e.refreshingDashboard())}}function ti(r,t){if(r&1){let e=M();s(0,"nile-lite-tooltip",44)(1,"button",60),_("click",function(){u(e);let i=d(3);return f(i.selectHomeMenuItem("executiveSummary"))}),h(2,"nile-glyph",61),l()()}}function ni(r,t){if(r&1){let e=M();s(0,"nile-dropdown",62),_("nile-hide",function(){u(e);let i=d(3);return f(i.downloadMenuOpen.set(!1))}),s(1,"nile-lite-tooltip",63)(2,"button",64),_("click",function(){u(e);let i=d(3);return f(i.downloadMenuOpen.set(!i.downloadMenuOpen()))}),h(3,"nile-glyph",65),l()(),s(4,"nile-menu")(5,"nile-menu-item",66),_("click",function(){u(e);let i=d(3);return i.downloadMenuOpen.set(!1),f(i.selectHomeMenuItem("exportPdf"))}),h(6,"nile-glyph",67),w(7," Download as PDF "),l(),s(8,"nile-menu-item",66),_("click",function(){u(e);let i=d(3);return i.downloadMenuOpen.set(!1),f(i.selectHomeMenuItem("exportPng"))}),h(9,"nile-glyph",68),w(10," Download as PNG "),l()()()}if(r&2){let e=d(3);C("open",e.downloadMenuOpen())}}function ii(r,t){if(r&1){let e=M();s(0,"div",23)(1,"button",24),_("click",function(){u(e);let i=d(2);return f(i.scrollTabs(-1))}),h(2,"nile-glyph",25),l(),s(3,"div",26,2),_("scroll",function(){u(e);let i=d(2);return f(i.onTabsScroll())}),s(5,"nile-nav-tab-group",27),h(6,"nile-nav-tab",28),F(7,Qn,4,3,"nile-nav-tab",29,Nn),l()(),s(9,"button",30),_("click",function(){u(e);let i=d(2);return f(i.scrollTabs(1))}),h(10,"nile-glyph",31),l(),h(11,"span",12),b(12,Jn,1,1,"app-time-range-picker",32),s(13,"nile-dropdown",33),_("nile-hide",function(){u(e);let i=d(2);return f(i.categoryFilterOpen.set(!1))}),s(14,"nile-lite-tooltip",34)(15,"button",35),_("click",function(){u(e);let i=d(2);return f(i.categoryFilterOpen.set(!i.categoryFilterOpen()))}),h(16,"nile-glyph",36),b(17,Xn,1,0,"span",37),l()(),s(18,"shared-category-filter-row",38),_("mousedown",function(i){return i.stopPropagation()})("selectionChange",function(i){u(e);let o=d(2);return f(o.onCategoryFilterChange(i))}),l()(),s(19,"nile-lite-tooltip",39)(20,"button",40),_("click",function(){u(e);let i=d(2);return f(i.goToCreateDashboard())}),h(21,"nile-glyph",41),l()(),b(22,ei,3,3,"nile-lite-tooltip",42),s(23,"div",43),b(24,ti,3,0,"nile-lite-tooltip",44),b(25,ni,11,1,"nile-dropdown",45),l()()}if(r&2){let e=d(2);te("is-scrollable",e.canScrollLeft()||e.canScrollRight()),c(),C("disabled",!e.canScrollLeft()),c(4),ee("value",e.activeTabId()||"__sentinel__"),c(2),E(e.visibleDashboards()),c(2),C("disabled",!e.canScrollRight()),c(3),y(e.activeTabId()?12:-1),c(),C("open",e.categoryFilterOpen()),c(4),y(e.selectedCategory()?17:-1),c(),C("selected",e.selectedCategory()),c(2),C("disabled",e.creatingDashboard()),c(2),y(e.features().refresh?22:-1),c(2),y(e.features().executiveSummary?24:-1),c(),y(e.features().export?25:-1)}}function ri(r,t){if(r&1&&(s(0,"nile-nav-tab-panel",69),h(1,"app-dashboard-viewer",71),l()),r&2){let e=d(3);ee("name",e.activeTabId()),c(),C("config",e.loadedDashboards().get(e.activeTabId()))}}function oi(r,t){r&1&&V(0)}function ai(r,t){if(r&1&&(s(0,"div",70),L(1,oi,1,0,"ng-container",15),l()),r&2){d(3);let e=R(7);c(),C("ngTemplateOutlet",e)}}function si(r,t){if(r&1&&b(0,ri,2,2,"nile-nav-tab-panel",69)(1,ai,2,1,"div",70),r&2){let e=d(2);y(e.loadedDashboards().has(e.activeTabId())?0:e.isTabLoading()||e.refreshingDashboard()?1:-1)}}function li(r,t){if(r&1){let e=M();s(0,"div",20)(1,"h2",72),w(2,"No dashboards in this category"),l(),s(3,"p",73),w(4,"Try a different category, or clear the filter to see everything."),l(),s(5,"nile-button",74),_("click",function(){u(e);let i=d(2);return f(i.onCategoryFilterChange(null))}),w(6," Clear filter "),l()()}}function di(r,t){if(r&1){let e=M();s(0,"div",20)(1,"div",75),Qe(),s(2,"svg",76),h(3,"rect",77)(4,"rect",78)(5,"rect",79),s(6,"rect",80),h(7,"animate",81)(8,"animate",82),l(),s(9,"rect",83),h(10,"animate",84)(11,"animate",85),l(),s(12,"rect",86),h(13,"animate",87)(14,"animate",88),l(),s(15,"rect",89),h(16,"animate",90)(17,"animate",91),l(),s(18,"rect",92),h(19,"animate",93)(20,"animate",94),l(),h(21,"rect",95)(22,"rect",96)(23,"circle",97),s(24,"circle",98),h(25,"animate",99),l(),h(26,"rect",100)(27,"rect",101),s(28,"path",102),h(29,"animate",103),l(),s(30,"circle",104),h(31,"animate",105),l()()(),Je(),s(32,"h2",72),w(33,"Build your dashboard"),l(),s(34,"p",73),w(35," Tap the below button to generate dashboard. "),l(),s(36,"nile-button",106),_("click",function(){u(e);let i=d(2);return f(i.goToCreateDashboard())}),h(37,"nile-glyph",107),w(38," Create dashboard "),l()()}if(r&2){let e=d(2);c(36),ee("disabled",e.creatingDashboard()?"":null)}}function ci(r,t){if(r&1){let e=M();s(0,"db-ai-prompt-panel",108),_("closePanel",function(){u(e);let i=d(2);return f(i.showAiPanel.set(!1))}),l()}if(r&2){let e=d(2);C("dashboardId",e.activeTabId())("dashboardName",e.activeDashboardName())("dashboardConfig",e.loadedDashboards().get(e.activeTabId())??null)("chatOnly",e.aiChatOnly())("initialPrompt",e.aiInitialPrompt())}}function gi(r,t){if(r&1){let e=M();s(0,"div",6)(1,"div",7),b(2,Un,2,3,"header",8),b(3,ii,26,13,"div",19),b(4,si,2,1)(5,li,7,0,"div",20)(6,di,39,1,"div",20),s(7,"nile-drawer",21),_("nile-request-close",function(){u(e);let i=d();return f(i.showAiPanel.set(!1))}),b(8,ci,1,5,"db-ai-prompt-panel",22),l()()()}if(r&2){let e=d();c(2),y(e.showHeader()?2:-1),c(),y(e.allDashboards().length>0?3:-1),c(),y(e.activeTabId()?4:e.allDashboards().length>0?5:e.allDashboards().length===0?6:-1),c(3),C("open",e.showAiPanel()),c(),y(e.features().aiPrompt&&e.showAiPanel()?8:-1)}}function pi(r,t){if(r&1&&(s(0,"div",109)(1,"h1",110),w(2,"Dashboards"),l(),s(3,"p",111),w(4),l()()),r&2){let e=t.subtitle;c(4),W(e)}}function hi(r,t){r&1&&(s(0,"div",114)(1,"div",117),h(2,"nile-skeleton-loader",118)(3,"nile-skeleton-loader",119),l(),h(4,"nile-skeleton-loader",120),s(5,"div",121),h(6,"nile-skeleton-loader",122)(7,"nile-skeleton-loader",123),l(),h(8,"nile-skeleton-loader",124),l())}function mi(r,t){r&1&&(s(0,"div",116)(1,"div",125)(2,"div",126),h(3,"nile-skeleton-loader",127)(4,"nile-skeleton-loader",128),l(),h(5,"nile-skeleton-loader",129),l(),h(6,"nile-skeleton-loader",130),l())}function ui(r,t){if(r&1&&(s(0,"div",112)(1,"div",113),F(2,hi,9,0,"div",114,U),l(),s(4,"div",115),F(5,mi,7,0,"div",116,U),l()()),r&2){let e=d();c(2),E(e.skeletonKpis),c(3),E(e.skeletonWidgets)}}var Be=4,Ve=class r{MAX_TABS=Be;tabsScrollerEl;dashboardViewerRef;timeRangePickerRef;onTimeRangeApply(t){this.dashboardViewerRef?.applyTimeRange(t)}tabsScrollLeft=m(0);tabsClientWidth=m(0);tabsScrollWidth=m(0);canScrollLeft=S(()=>this.tabsScrollLeft()>0);canScrollRight=S(()=>this.tabsScrollLeft()+this.tabsClientWidth()<this.tabsScrollWidth()-1);onTabsScroll(){this.updateTabsScrollState()}updateTabsScrollState(){let t=this.tabsScrollerEl?.nativeElement;t&&(this.tabsScrollLeft.set(t.scrollLeft),this.tabsClientWidth.set(t.clientWidth),this.tabsScrollWidth.set(t.scrollWidth))}scrollTabs(t){let e=this.tabsScrollerEl?.nativeElement;e&&e.scrollBy({left:t*e.clientWidth*.8,behavior:"smooth"})}scrollActiveTabIntoView(){let t=this.tabsScrollerEl?.nativeElement;if(!t)return;let e=this.activeTabId();if(!e)return;let n=window.CSS&&CSS.escape?CSS.escape(e):e.replace(/"/g,'\\"'),i=t.querySelector(`nile-nav-tab[panel="${n}"]`);if(!i)return;let o=i.getBoundingClientRect(),a=t.getBoundingClientRect(),g=16;o.right>a.right?t.scrollBy({left:o.right-a.right+g,behavior:"smooth"}):o.left<a.left&&t.scrollBy({left:o.left-a.left-g,behavior:"smooth"})}onWindowResize=()=>this.ngZone.run(()=>this.updateTabsScrollState());showAiPanel=m(!1);aiChatOnly=m(!1);aiInitialPrompt=m("");allDashboards=m([]);selectedCategory=m(null);dashboardCategories=Gt;categoryFilterOpen=m(!1);visibleDashboards=S(()=>{let t=this.selectedCategory(),e=this.allDashboards();return t?e.filter(n=>n.category?.includes(t)):e});activeTabs=m([]);activeTabId=m("");loadedDashboards=m(new Map);isLoading=m(!0);isTabLoading=m(!1);skeletonTabWidths=[72,220,140];skeletonKpis=Array.from({length:4});skeletonWidgets=Array.from({length:4});skeletonActionBtns=Array.from({length:4});showMore=S(()=>this.allDashboards().length>0);activeDashboardName=S(()=>this.allDashboards().find(t=>t.id===this.activeTabId())?.name??"");activeConfig=S(()=>this.loadedDashboards().get(this.activeTabId())??null);isExporting=m(!1);showExportDropdown=m(!1);downloadMenuOpen=m(!1);creatingDashboard=m(!1);generationStreamId=m("");isGenerating=S(()=>this.generationStreamId()!=="");generationSettled=!1;showHeader(){return D().ui.header}features(){return D().features}copy(){return D().copy}service=v(he);ngZone=v(xe);el=v(re);navigator=v(G);routeProgress=v(It);autoDashboard=v(qt);goToCreateDashboard(){this.creatingDashboard()||(this.creatingDashboard.set(!0),this.navigator.toAskAquera())}constructor(){X(()=>{this.activeTabId(),this.allDashboards(),queueMicrotask(()=>this.scrollActiveTabIntoView())})}ngAfterViewChecked(){this.updateTabsScrollState()}onExportTriggerClick(){this.showExportDropdown.set(!this.showExportDropdown())}selectHomeMenuItem(t){if(t==="askAi")this.aiChatOnly.set(!0),this.aiInitialPrompt.set(""),this.showAiPanel.set(!0);else if(t==="executiveSummary"){let e=this.activeTabId();e&&this.navigator.toAskAqueraDashboard(e,{summary:1})}else t==="exportPdf"?this.exportDashboardPdf():t==="exportPng"&&this.exportDashboardPng()}getDashboardTarget(){let t=this.activeTabId();return this.el.nativeElement.querySelector(`nile-nav-tab-panel[name="${t}"] app-dashboard-viewer gridster`)}async exportDashboardPdf(){if(this.isExporting())return;let t=this.getDashboardTarget();if(t){this.showExportDropdown.set(!1),this.isExporting.set(!0),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=t.scrollWidth,n=t.scrollHeight,i=await Ge(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),o=this.activeDashboardName()||"Dashboard",a=90,g=new Wt({orientation:e>n?"landscape":"portrait",unit:"px",format:[e,n+a]});g.setFillColor(245,245,248),g.rect(0,0,e,a,"F"),g.setFont("helvetica","bold"),g.setFontSize(28),g.setTextColor(50,50,60),g.text(o,e/2,a/2+7,{align:"center"}),g.addImage(i,"JPEG",0,a,e,n),g.save(`${o}.pdf`)}finally{this.isExporting.set(!1)}}}async exportDashboardPng(){if(this.isExporting())return;let t=this.getDashboardTarget();if(t){this.showExportDropdown.set(!1),this.isExporting.set(!0),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)));try{let e=t.scrollWidth,n=t.scrollHeight,i=await Ge(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),o=this.activeDashboardName()||"Dashboard",a=90,g=document.createElement("canvas");g.width=e,g.height=n+a;let p=g.getContext("2d");p.fillStyle="#f5f5f8",p.fillRect(0,0,e,a),p.fillStyle="#32323c",p.font="bold 28px helvetica",p.textAlign="center",p.textBaseline="middle",p.fillText(o,e/2,a/2+7);let x=new Image;x.src=i,await new Promise(J=>{x.onload=()=>J()}),p.drawImage(x,0,a,e,n);let N=document.createElement("a");N.href=g.toDataURL("image/png"),N.download=`${o}.png`,N.click()}finally{this.isExporting.set(!1)}}}toggleAiPanel(){this.showAiPanel.update(t=>!t)}onToggleAiPanel=()=>this.ngZone.run(()=>this.showAiPanel.update(t=>!t));ngOnInit(){this.loadList(),window.addEventListener("dv:toggle-ai-panel",this.onToggleAiPanel),window.addEventListener("resize",this.onWindowResize)}ngOnDestroy(){window.removeEventListener("dv:toggle-ai-panel",this.onToggleAiPanel),window.removeEventListener("resize",this.onWindowResize)}async loadList(){this.isLoading.set(!0);try{let t=await this.routeProgress.track(this.service.loadDashboards());this.ngZone.run(()=>{this.allDashboards.set(t);let e=t.slice(0,Be);this.activeTabs.set(e),e.length>0&&!this.activeTabId()&&(this.activeTabId.set(e[0].id),this.loadTab(e[0].id))}),t.length===0&&await this.checkAutoDashboard()}catch(t){console.error("Failed to load dashboards list:",t)}finally{this.ngZone.run(()=>this.isLoading.set(!1))}}async checkAutoDashboard(){if(!(this.generationSettled||this.isGenerating()))try{let t=await this.autoDashboard.trigger();t?.success&&!t.skipped&&t.streamId&&this.ngZone.run(()=>{this.generationStreamId.set(t.streamId)})}catch{}}onGenerationDone(t){this.generationSettled=!0,this.generationStreamId.set("");let e=t.length;this.loadList().then(()=>{this.showReadyToast(e>1?`${e} dashboards are ready`:"Your dashboard is ready")})}onGenerationFailed(){this.generationSettled=!0,this.generationStreamId.set("")}showReadyToast(t){be({variant:"success",title:"All set",content:t})}async loadTab(t){if(!this.loadedDashboards().has(t)){this.isTabLoading.set(!0);try{let e=await this.routeProgress.track(this.service.fetchDashboard(t));this.ngZone.run(()=>{let n=new Map(this.loadedDashboards());n.set(t,e),this.loadedDashboards.set(n)})}catch(e){console.error(`Failed to load dashboard ${t}:`,e)}finally{this.ngZone.run(()=>this.isTabLoading.set(!1))}}}refreshingDashboard=m(!1);async refreshActiveDashboard(){let t=this.activeTabId();if(!t||this.refreshingDashboard())return;let e=this.loadedDashboards().get(t);this.refreshingDashboard.set(!0),this.ngZone.run(()=>{let n=new Map(this.loadedDashboards());n.delete(t),this.loadedDashboards.set(n)});try{let n=await this.routeProgress.track(this.service.fetchDashboard(t));this.ngZone.run(()=>{let i=new Map(this.loadedDashboards());i.set(t,n),this.loadedDashboards.set(i)})}catch(n){console.error(`Failed to refresh dashboard ${t}:`,n),e&&this.ngZone.run(()=>{let i=new Map(this.loadedDashboards());i.set(t,e),this.loadedDashboards.set(i)})}finally{this.ngZone.run(()=>{this.refreshingDashboard.set(!1),queueMicrotask(()=>this.timeRangePickerRef?.reapply())})}}onTabChange(t){let e=t.detail.value;e!==this.activeTabId()&&this.setActiveTab(e)}onCategoryFilterChange(t){this.selectedCategory.set(t),this.categoryFilterOpen.set(!1);let e=this.visibleDashboards();e.some(n=>n.id===this.activeTabId())||(e.length>0?this.setActiveTab(e[0].id):this.activeTabId.set(""))}setActiveTab(t){this.showAiPanel.set(!1),this.activeTabId.set(t),this.loadTab(t)}isInActiveTabs(t){return this.activeTabs().some(e=>e.id===t)}canAdd(){return this.activeTabs().length<Be}isLastActiveDashboard(t){return this.activeTabs().length===1&&this.isInActiveTabs(t)}renamingDashboardId=m(null);renamingValue=m("");isRenamingDashboard=m(!1);startRenameDashboard(t,e){e.stopPropagation(),!t.isAutoGenerated&&(this.renamingDashboardId.set(t.id),this.renamingValue.set(t.name),queueMicrotask(()=>{let n=this.el.nativeElement.querySelector(`.tab-rename-input[data-dashboard-id="${t.id}"]`);n?.focus(),n?.select()}))}onRenameInputChange(t){this.renamingValue.set(t)}onRenameInputKeydown(t,e){t.key==="Enter"?(t.preventDefault(),this.commitRenameDashboard(e)):t.key==="Escape"&&(t.preventDefault(),this.cancelRenameDashboard(t))}cancelRenameDashboard(t){t?.stopPropagation(),this.renamingDashboardId.set(null),this.renamingValue.set("")}async commitRenameDashboard(t,e){e?.stopPropagation();let n=this.renamingValue().trim();if(!n||n===t.name){this.cancelRenameDashboard();return}this.isRenamingDashboard.set(!0);try{await this.service.renameDashboard(t.id,n),this.ngZone.run(()=>{let i=o=>o.map(a=>a.id===t.id?H(P({},a),{name:n}):a);this.allDashboards.update(i),this.activeTabs.update(i),this.renamingDashboardId.set(null),this.renamingValue.set("")}),be({variant:"success",title:"Renamed",content:"Dashboard renamed."})}catch{}finally{this.ngZone.run(()=>this.isRenamingDashboard.set(!1))}}onDashboardToggle(t,e){if(e){if(!this.canAdd())return;this.activeTabs.update(n=>[...n,t]),this.setActiveTab(t.id)}else{let n=this.activeTabId()===t.id;if(this.activeTabs.update(i=>i.filter(o=>o.id!==t.id)),n){let i=this.activeTabs();i.length>0?this.setActiveTab(i[0].id):this.activeTabId.set("")}}}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["dvz-dashboards-page"]],viewQuery:function(e,n){if(e&1&&ae(In,5)(Ce,5)($e,5),e&2){let i;j(i=Z())&&(n.tabsScrollerEl=i.first),j(i=Z())&&(n.dashboardViewerRef=i.first),j(i=Z())&&(n.timeRangePickerRef=i.first)}},decls:8,vars:3,consts:[["pageTitleBlock",""],["dashboardSkeleton",""],["tabsScroller",""],["renameInput",""],[1,"home-page"],["aria-hidden","true",1,"tabs-wrapper","home-skeleton"],[1,"tabs-wrapper"],[1,"tabs-bar"],[1,"home-nav"],[1,"tabs-bar__nav","home-skeleton__tabs-row"],[1,"home-skeleton__tab-pills"],["variant","rounded","height","28",1,"home-skeleton__tab"],["aria-hidden","true",1,"home-menu-divider"],["variant","rounded","width","32","height","28","border-radius","8px"],["variant","circular","width","28","height","28"],[4,"ngTemplateOutlet"],[3,"ngTemplateOutlet","ngTemplateOutletContext"],[3,"streamId"],[3,"done","failed","streamId"],[1,"tabs-bar__nav",3,"is-scrollable"],[1,"home-empty-state"],["contained","","no-header","","placement","end","label","Ask",1,"home-ai-drawer",3,"nile-request-close","open"],[3,"dashboardId","dashboardName","dashboardConfig","chatOnly","initialPrompt"],[1,"tabs-bar__nav"],["type","button","aria-label","Scroll tabs left",1,"tabs-scroll-btn","tabs-scroll-btn--left",3,"click","disabled"],["name","ng-chevron-left","method","stroke","size","16"],[1,"tabs-scroller",3,"scroll"],["variant","filled",1,"dashboard-tab-group"],["slot","nav","panel","__sentinel__",1,"tab-sentinel"],["slot","nav"],["type","button","aria-label","Scroll tabs right",1,"tabs-scroll-btn","tabs-scroll-btn--right",3,"click","disabled"],["name","ng-chevron-right","method","stroke","size","16"],[3,"resetKey"],["hoist","","placement","bottom-end",1,"home-category-filter",3,"nile-hide","open"],["slot","trigger","content","Filter by category"],["type","button","aria-label","Filter by category",1,"home-action-btn",3,"click"],["name","ng-filter-lines","method","stroke","size","18"],["aria-hidden","true",1,"home-category-filter__dot"],["variant","menu",1,"home-category-filter__panel",3,"mousedown","selectionChange","selected"],["content","Create dashboard"],["type","button","aria-label","Create dashboard",1,"home-action-btn",3,"click","disabled"],["name","ng-plus","method","stroke","size","18"],["content","Refresh dashboard"],[1,"home-actions"],["content","Executive Summary"],["placement","bottom-end",1,"home-download",3,"open"],["slot","nav",3,"click"],["name","ng-stars-02","method","stroke","size","14","color","#7a5af8","aria-label","Auto-generated dashboard",1,"tab-auto-badge"],[1,"tab-rename"],[1,"tab-rename",3,"click"],["type","text",1,"tab-rename-input",3,"input","keydown","click","value","disabled"],["type","button","aria-label","Save dashboard name",1,"tab-rename-save",3,"click","disabled"],["name","ng-check","method","stroke","size","14","color","#2970ff"],[1,"tab-label"],["type","button","aria-label","Rename dashboard",1,"tab-edit-btn"],["type","button","aria-label","Rename dashboard",1,"tab-edit-btn",3,"click"],["name","ng-edit-02","method","stroke","size","12"],[3,"apply","resetKey"],["type","button","aria-label","Refresh dashboard",1,"home-action-btn",3,"click","disabled"],["name","ng-refresh-ccw","method","stroke","size","18",1,"home-refresh-glyph"],["type","button","aria-label","Executive Summary",1,"home-action-btn",3,"click"],["name","ng-file-02","method","stroke","size","18"],["placement","bottom-end",1,"home-download",3,"nile-hide","open"],["slot","trigger","content","Download"],["type","button","aria-label","Download",1,"home-action-btn",3,"click"],["name","ng-download-01","method","stroke","size","18"],[3,"click"],["slot","prefix","name","ng-file-06","method","stroke","size","14"],["slot","prefix","name","ng-image-03","method","stroke","size","14"],["active","",1,"viewer-scroll-container"],["aria-hidden","true",1,"home-skeleton"],[3,"config"],[1,"home-empty-state__title"],[1,"home-empty-state__desc"],["variant","tertiary",3,"click"],[1,"home-empty-state__graphic"],["viewBox","0 0 380 140","aria-hidden","true","preserveAspectRatio","xMidYMid meet"],["x","40","y","20","width","300","height","100","rx","8","fill","#fff","stroke","#80AED3","stroke-width","1.5","stroke-dasharray","4 4"],["x","56","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","64","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["x","64","y","80","width","6","height","20","rx","1","fill","#005EA6","opacity","0.7"],["attributeName","height","values","20;14;20","dur","2s","repeatCount","indefinite"],["attributeName","y","values","80;86;80","dur","2s","repeatCount","indefinite"],["x","76","y","74","width","6","height","26","rx","1","fill","#005EA6"],["attributeName","height","values","26;18;26","dur","2s","begin","0.2s","repeatCount","indefinite"],["attributeName","y","values","74;82;74","dur","2s","begin","0.2s","repeatCount","indefinite"],["x","88","y","68","width","6","height","32","rx","1","fill","#005EA6","opacity","0.85"],["attributeName","height","values","32;24;32","dur","2s","begin","0.4s","repeatCount","indefinite"],["attributeName","y","values","68;76;68","dur","2s","begin","0.4s","repeatCount","indefinite"],["x","100","y","78","width","6","height","22","rx","1","fill","#005EA6","opacity","0.6"],["attributeName","height","values","22;16;22","dur","2s","begin","0.6s","repeatCount","indefinite"],["attributeName","y","values","78;84;78","dur","2s","begin","0.6s","repeatCount","indefinite"],["x","112","y","66","width","6","height","34","rx","1","fill","#005EA6","opacity","0.85"],["attributeName","height","values","34;26;34","dur","2s","begin","0.8s","repeatCount","indefinite"],["attributeName","y","values","66;74;66","dur","2s","begin","0.8s","repeatCount","indefinite"],["x","148","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","156","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["cx","190","cy","78","r","14","fill","none","stroke","#E6EFF6","stroke-width","5"],["cx","190","cy","78","r","14","fill","none","stroke","#005EA6","stroke-width","5","stroke-linecap","round","stroke-dasharray","88","stroke-dashoffset","88","transform","rotate(-90 190 78)"],["attributeName","stroke-dashoffset","values","88;22;22;88","keyTimes","0;0.5;0.85;1","dur","2.6s","repeatCount","indefinite"],["x","240","y","36","width","84","height","68","rx","6","fill","#F7FAFC","stroke","#E6E9EB"],["x","248","y","44","width","40","height","3","rx","1.5","fill","#80AED3"],["d","M 250 92 L 264 80 L 278 86 L 292 72 L 306 78 L 320 64","fill","none","stroke","#005EA6","stroke-width","1.5","stroke-linecap","round","stroke-linejoin","round","stroke-dasharray","200","stroke-dashoffset","200"],["attributeName","stroke-dashoffset","values","200;0;0;200","keyTimes","0;0.5;0.85;1","dur","2.6s","repeatCount","indefinite"],["cx","320","cy","64","r","2.5","fill","#005EA6"],["attributeName","opacity","values","0;0;1;1;0","keyTimes","0;0.45;0.55;0.85;1","dur","2.6s","repeatCount","indefinite"],["variant","primary","aria-label","Create dashboard",1,"home-empty-state__cta",3,"click"],["slot","prefix","name","ng-plus","size","16"],[3,"closePanel","dashboardId","dashboardName","dashboardConfig","chatOnly","initialPrompt"],[1,"home-nav__title-block"],[1,"home-nav__title"],[1,"home-nav__sub"],[1,"home-skeleton__panel"],[1,"home-skeleton__kpis"],[1,"home-skeleton__kpi"],[1,"home-skeleton__widgets"],[1,"home-skeleton__widget"],[1,"home-skeleton__kpi-head"],["variant","text","width","56%","height","14"],["variant","rounded","width","32","height","32","border-radius","8px"],["variant","text","width","48%","height","30"],[1,"home-skeleton__kpi-row"],["variant","rounded","width","72","height","20","border-radius","999px"],["variant","text","width","38%","height","11"],["variant","rounded","width","100%","height","44","border-radius","8px",1,"home-skeleton__kpi-spark"],[1,"home-skeleton__widget-head"],[1,"home-skeleton__widget-titles"],["variant","text","width","42%","height","16"],["variant","text","width","64%","height","11"],["variant","circular","width","20","height","20"],["variant","rounded","width","100%","height","100%","border-radius","10px",1,"home-skeleton__widget-chart"]],template:function(e,n){e&1&&(s(0,"div",4),b(1,Hn,12,2,"div",5),b(2,Bn,6,3,"div",6),b(3,gi,9,5,"div",6),l(),L(4,pi,5,1,"ng-template",null,0,fe)(6,ui,7,0,"ng-template",null,1,fe)),e&2&&(c(),y(n.isLoading()?1:-1),c(),y(!n.isLoading()&&n.isGenerating()?2:-1),c(),y(!n.isLoading()&&!n.isGenerating()?3:-1))},dependencies:[Me,Ce,Ne,ze,$e,$t],styles:['@charset "UTF-8";[_nghost-%COMP%]{display:block;height:100%;min-height:0}.home-page[_ngcontent-%COMP%]{height:100%;min-height:0;display:flex;flex-direction:column;background:var(--ng-colors-bg-active);overflow:visible;position:relative}.loading-state[_ngcontent-%COMP%], .empty-state[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:200px;color:var(--ng-colors-text-tertiary-600)}.home-empty-state[_ngcontent-%COMP%]{margin:24px;padding:56px 32px;display:flex;flex-direction:column;align-items:center;text-align:center;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px}.home-empty-state__graphic[_ngcontent-%COMP%]{width:380px;max-width:100%;height:140px;margin-bottom:24px;display:block}.home-empty-state__graphic[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.home-empty-state__title[_ngcontent-%COMP%]{margin:0 0 8px;font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);letter-spacing:-.01em}.home-empty-state__desc[_ngcontent-%COMP%]{margin:0;max-width:480px;font-size:14px;line-height:1.5;color:var(--ng-colors-text-tertiary-600, #535862)}.home-empty-state__cta[_ngcontent-%COMP%]{margin-top:24px}.toolbar[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:flex-end;height:64px;padding:0 38px;background:var(--ng-componentcolors-alpha-white-100);border-bottom:1px solid var(--ng-componentcolors-alpha-black-10);position:fixed;top:var(--nav-height, 56px);left:0;right:0;z-index:var(--z-header)}.toolbar__right[_ngcontent-%COMP%]{display:flex;align-items:center;gap:var(--ng-spacing-3, 12px)}.tabs-wrapper[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;min-height:0}.tabs-bar[_ngcontent-%COMP%]{position:relative;min-height:0;display:flex;flex-direction:column}.tabs-bar[_ngcontent-%COMP%] .home-nav[_ngcontent-%COMP%]{position:sticky;top:0;z-index:var(--z-sticky-row);display:flex;align-items:center;justify-content:space-between;gap:16px;height:76px;margin:0;padding:0 22px;background:var(--ng-componentcolors-alpha-white-100, #ffffff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb);flex-shrink:0}.tabs-bar[_ngcontent-%COMP%] .home-nav__title-block[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2px;min-width:0}.tabs-bar[_ngcontent-%COMP%] .home-nav__title[_ngcontent-%COMP%]{margin:0;font-size:16px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);line-height:1.2;letter-spacing:-.01em}.tabs-bar[_ngcontent-%COMP%] .home-nav__sub[_ngcontent-%COMP%]{margin:0;font-size:13px;font-weight:400;color:var(--ng-colors-text-tertiary-600, #535862);line-height:1.3}.tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav[_ngcontent-%COMP%]{position:sticky;top:76px;height:56px;display:flex;align-items:center;gap:4px;z-index:var(--z-sticky-row);min-width:0;margin:0;padding:22px;background:var(--ng-componentcolors-alpha-white-100, #ffffff);border-bottom:1px solid var(--ng-colors-border-secondary, #e9eaeb)}.tabs-bar[_ngcontent-%COMP%] .home-menu-divider[_ngcontent-%COMP%]{width:1px;height:20px;background:var(--ng-colors-border-secondary, #e9eaeb);margin:0 6px 0 8px;flex-shrink:0}.tabs-bar[_ngcontent-%COMP%] .tabs-scroller[_ngcontent-%COMP%]{flex:1;min-width:0;overflow-x:auto;overflow-y:hidden;position:relative;scrollbar-width:none}.tabs-bar[_ngcontent-%COMP%] .tabs-scroller[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.tabs-bar[_ngcontent-%COMP%] .dashboard-tab-group[_ngcontent-%COMP%]{display:block;width:max-content;min-width:100%}.tabs-bar[_ngcontent-%COMP%] .tab-sentinel[_ngcontent-%COMP%]{display:none!important}.tabs-bar[_ngcontent-%COMP%] .tab-auto-badge[_ngcontent-%COMP%]{display:inline-flex;vertical-align:text-bottom;margin-right:4px;flex:0 0 auto}.tabs-bar[_ngcontent-%COMP%] .tab-label[_ngcontent-%COMP%]{white-space:nowrap}.tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-left:4px;padding:0;border:0;background:transparent;border-radius:4px;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;opacity:0;pointer-events:none;flex:0 0 auto;transition:background .15s,opacity .15s,color .15s}.tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:hover, .tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:focus-visible{background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.tabs-bar[_ngcontent-%COMP%] nile-nav-tab[_ngcontent-%COMP%]:hover .tab-edit-btn[_ngcontent-%COMP%], .tabs-bar[_ngcontent-%COMP%] .tab-edit-btn[_ngcontent-%COMP%]:focus-visible{opacity:1;pointer-events:auto}.tabs-bar[_ngcontent-%COMP%] .tab-rename[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:4px}.tabs-bar[_ngcontent-%COMP%] .tab-rename-input[_ngcontent-%COMP%]{width:140px;height:24px;padding:0 6px;font-size:13px;font-weight:600;color:var(--ng-colors-text-primary-900, #181d27);background:#fff;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:6px;outline:none}.tabs-bar[_ngcontent-%COMP%] .tab-rename-input[_ngcontent-%COMP%]:focus{border-color:#2970ff;box-shadow:0 0 0 3px #2970ff29}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;background:transparent;border-radius:4px;cursor:pointer;flex:0 0 auto}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--ng-colors-bg-quaternary, #f2f4f7)}.tabs-bar[_ngcontent-%COMP%] .tab-rename-save[_ngcontent-%COMP%]:disabled{cursor:default;opacity:.5}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;border-radius:6px;flex-shrink:0;opacity:0;pointer-events:none;transition:opacity .15s,background .15s,color .15s}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:hover, .tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:focus, .tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[_ngcontent-%COMP%]:focus-visible{outline:0;background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.tabs-bar[_ngcontent-%COMP%] .tabs-scroll-btn[disabled][_ngcontent-%COMP%]{cursor:default;color:var(--ng-colors-text-disabled, #a4a7ae);background:transparent}.tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav.is-scrollable[_ngcontent-%COMP%]:hover .tabs-scroll-btn[_ngcontent-%COMP%], .tabs-bar[_ngcontent-%COMP%] .tabs-bar__nav.is-scrollable[_ngcontent-%COMP%]:focus-within .tabs-scroll-btn[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.more-menu[_ngcontent-%COMP%]{width:260px;max-height:320px;overflow-y:auto;padding:var(--ng-spacing-xs) 0}.more-menu-item[_ngcontent-%COMP%]{padding:var(--ng-spacing-xs) var(--ng-spacing-md);display:flex;align-items:center;cursor:pointer}.more-menu-item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.more-menu-item[_ngcontent-%COMP%] nile-checkbox[_ngcontent-%COMP%]{width:100%}nile-tab-panel[_ngcontent-%COMP%], nile-nav-tab-panel[_ngcontent-%COMP%]{display:block;height:100%}.panel-loading[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;height:200px}.home-skeleton__tabs-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px}.home-skeleton__tab-pills[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;flex-shrink:0}.home-skeleton__tab[_ngcontent-%COMP%]{flex:0 0 auto}.home-skeleton__panel[_ngcontent-%COMP%]{flex:1;min-height:0;padding:18px 24px 32px;display:flex;flex-direction:column;gap:16px;overflow:auto}.home-skeleton__kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}@media(max-width:1100px){.home-skeleton__kpis[_ngcontent-%COMP%]{grid-template-columns:repeat(2,1fr)}}.home-skeleton__kpi[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px;padding:18px 20px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;background:#fff}.home-skeleton__kpi-head[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:12px}.home-skeleton__kpi-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px;margin-top:4px}.home-skeleton__kpi-spark[_ngcontent-%COMP%]{margin-top:6px}.home-skeleton__widgets[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}@media(max-width:900px){.home-skeleton__widgets[_ngcontent-%COMP%]{grid-template-columns:1fr}}.home-skeleton__widget[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:18px;padding:20px 22px;border:1px solid var(--ng-colors-border-secondary, #e9eaeb);border-radius:12px;background:#fff;min-height:320px}.home-skeleton__widget-head[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.home-skeleton__widget-titles[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}.home-skeleton__widget-chart[_ngcontent-%COMP%]{display:block;flex:1;min-height:0}.viewer-scroll-container[_ngcontent-%COMP%]{display:block;flex:1;min-height:0;overflow:auto}.viewer-scroll-container[_ngcontent-%COMP%]::part(base){padding:unset;min-height:100%}[_nghost-%COMP%] .viewer-scroll-container:has(.aq-detail-overlay){overflow:hidden}app-dashboard-viewer[_ngcontent-%COMP%], nile-dashboard-viewer[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.export-menu[_ngcontent-%COMP%] nile-menu-item[_ngcontent-%COMP%]{font-size:var(--ng-font-size-text-sm, 14px);font-weight:var(--ng-font-weight-medium, 500)}.home-actions[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:2px;flex-shrink:0}.home-action-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;outline:0;background:transparent;color:var(--ng-colors-text-tertiary-600, #535862);cursor:pointer;border-radius:6px;flex-shrink:0}.home-action-btn[_ngcontent-%COMP%]:hover, .home-action-btn[_ngcontent-%COMP%]:focus, .home-action-btn[_ngcontent-%COMP%]:focus-visible{outline:0;background:var(--ng-colors-bg-active, #e9eaeb);color:var(--ng-colors-text-primary-900, #181d27)}.home-category-filter[_ngcontent-%COMP%] .home-action-btn[_ngcontent-%COMP%]{position:relative}.home-category-filter__dot[_ngcontent-%COMP%]{position:absolute;top:3px;right:3px;width:6px;height:6px;border-radius:50%;background:var(--ng-colors-fg-brand-primary-600)}.home-category-filter[_ngcontent-%COMP%]::part(panel){background:transparent;box-shadow:none;border-radius:0}.home-category-filter__panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1px;min-width:200px;max-height:320px;overflow-y:auto}.home-refresh-glyph[_ngcontent-%COMP%]{display:inline-flex;transform-origin:50% 50%}.home-refresh-glyph--spinning[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_home-refresh-spin .9s linear infinite}@keyframes _ngcontent-%COMP%_home-refresh-spin{to{transform:rotate(360deg)}}.home-ai-drawer[_ngcontent-%COMP%]::part(base){z-index:var(--z-drawer, 900)}.home-ai-drawer[_ngcontent-%COMP%]::part(panel){width:100%;max-width:100%}.home-ai-drawer[_ngcontent-%COMP%]::part(body){padding:0;overflow:hidden}.home-ai-drawer[_ngcontent-%COMP%] db-ai-prompt-panel[_ngcontent-%COMP%]{display:block;height:100%;min-height:0}.home-category-filter__heading[_ngcontent-%COMP%]{display:block;padding:6px 10px 4px;font-size:10.5px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--ng-colors-text-tertiary-600)}.home-category-filter__item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:7px 10px;border:0;border-radius:7px;background:transparent;font:inherit;font-size:13px;color:var(--ng-colors-text-secondary-700);text-align:left;white-space:nowrap;cursor:pointer}.home-category-filter__item[_ngcontent-%COMP%]:hover{background:var(--ng-colors-bg-secondary)}.home-category-filter__item.is-active[_ngcontent-%COMP%]{color:var(--ng-colors-fg-brand-primary-600);font-weight:600;background:var(--ng-colors-bg-secondary)}.home-category-filter__label[_ngcontent-%COMP%]{min-width:0;overflow:hidden;text-overflow:ellipsis}']})};function fi(r,t){r&1&&h(0,"dvz-dashboards-page")}var We=class r{config=Y(void 0);ready=_e({alias:"dvz-ready"});error=_e({alias:"dvz-error"});unauthorized=_e({alias:"dvz-unauthorized"});navigate=_e({alias:"dvz-navigate"});host=v(re);navigator=v(G);destroyRef=v(Xe);stopAdopting=null;stopTokenRefresh=null;stopUi=null;configured=!1;constructor(){X(()=>{let t=this.config();t&&this.apply(t)}),this.navigator.requests.pipe(Et(this.destroyRef)).subscribe(t=>this.navigate.emit(t)),queueMicrotask(()=>{let t=this.host.nativeElement.shadowRoot;t&&(this.stopAdopting=je(t))})}async apply(t){let e=t.auth;Ct(t.api.baseUrl),_t(t.api,e);let n=jt({baseUrl:t.api.baseUrl,mcpUrl:t.api.mcpUrl,tokenizedOrigins:t.api.tokenizedOrigins,headers:t.api.headers,customerId:t.tenant.customerId??null,productId:t.tenant.productId,productName:t.tenant.productName??null,authMode:e.mode,authToken:e.mode==="token"?e.token:null,getToken:e.mode==="callback"?e.getToken:null,onUnauthorized:()=>this.unauthorized.emit(),features:t.features,ui:t.ui,copy:t.copy,hrefs:t.hrefs,initialDashboardId:t.initial?.dashboardId??null});this.stopUi?.(),this.stopUi=Ze(this.host.nativeElement,t.ui),xt({productId:t.tenant.productId,name:t.tenant.productName}),yt(()=>this.unauthorized.emit());let i=n;if(await ut(i),this.stopTokenRefresh??=ft(i),!this.configured){this.configured=!0;let o=D();this.ready.emit({customerId:o.customerId??"",productId:o.productId??""})}}ngOnDestroy(){this.stopAdopting?.(),this.stopTokenRefresh?.(),this.stopUi?.()}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=z({type:r,selectors:[["dvz-dashboards-root"]],inputs:{config:[1,"config"]},outputs:{ready:"dvz-ready",error:"dvz-error",unauthorized:"dvz-unauthorized",navigate:"dvz-navigate"},features:[se([G])],decls:1,vars:1,template:function(e,n){e&1&&b(0,fi,1,0,"dvz-dashboards-page"),e&2&&y(n.config()?0:-1)},dependencies:[Ve],styles:[`:host{display:block;height:100%;min-height:0}
2
2
  `],encapsulation:3,changeDetection:0})};ht();var _i="dvz-dashboards";function bi(r={}){return pt(We,_i,[et(),bt(),dt(ct([wt])),{provide:Pt,useFactory:()=>D().baseUrl},Dt($),St(T),Ot(T),Oe(T),ke(T),Se(T),Te(T),At(T)],r)}bi();export{_i as a,bi as b};