@aquera/data-visualizer-sdk 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ask-aquera/src/ask-aquera-config.d.ts +10 -0
- package/chunk-3ANFJNEW.js +18 -0
- package/{chunk-KRLLBWXX.js → chunk-AFTJULGE.js} +688 -688
- package/chunk-I4PGOKUA.js +2 -0
- package/{chunk-5OHN7YS2.js → chunk-J4NO6UPD.js} +1 -1
- package/{chunk-FYNF5FCN.js → chunk-V77IQCJY.js} +1 -1
- package/main.js +1 -1
- package/package.json +1 -1
- package/chunk-BJIGX7YA.js +0 -2
- package/chunk-T2W7AVC3.js +0 -18
package/chunk-BJIGX7YA.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as fe,A as ce,B as yt,D as Ct,Da as A,E as vt,F as xt,Fa as Le,G as wt,Ga as Nt,H as Pt,I as Mt,J as Dt,Ja as qt,K as kt,Ka as Wt,L as St,La as Ht,M as Ot,Ma as Fe,N as De,O as ke,Pa as Ge,Q as Se,Qa as Lt,Y as Oe,Z as Tt,_ as At,a as Ue,b as je,ba as Ft,c as st,ca as Et,d as Pe,f as Me,g as L,h as J,i as lt,j as dt,k as ct,ka as It,l as gt,la as Rt,n as pt,o as ht,p as ie,q as mt,qa as Te,r as ut,ra as be,s as de,sa as zt,t as _t,ta as Ae,ua as Vt,wa as ge,y as ft,ya as He,z as bt}from"./chunk-KRLLBWXX.js";import{$b as se,Ab as D,Bb as ot,Eb as b,Ga as et,Gb as d,Ha as tt,Jb as ae,Kb as Y,La as c,Lb as K,N as j,Ob as N,Pb as rt,Qb as $,R as Ye,S as w,Sb as P,Tb as q,Ub as We,X as u,Xa as xe,Y as _,Z as Ke,_ as Qe,ab as W,ac as ne,ba as Je,bc as le,d as Ze,da as he,ea as ve,fb as G,fc as ue,ha as Xe,ia as f,kb as nt,kc as O,la as ee,lb as te,mb as y,nb as C,nc as _e,ob as Z,oc as Q,p as F,pa as oe,pb as it,qb as I,qc as at,rb as R,sb as v,tb as a,ub as l,vb as h,wb as re,xb as we,yb as me,zb as H}from"./chunk-Z5FDX7CX.js";import{a as x,b as E}from"./chunk-ZW5NV4UO.js";function Kt(){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 Qt(){return{mcpGateway:de.MCP_GATEWAY_ENABLED??!1,aiPrompt:!0,autoGenerate:!0,export:!0,rename:!0,refresh:!0,executiveSummary:!0,edit:!0}}function Gt(){return{baseUrl:de.baseUrl??"",mcpUrl:de.MCP_URL??null,tokenizedOrigins:[de.baseUrl].filter(o=>!!o),headers:{},customerId:null,productId:null,productName:null,authMode:"inherit",authToken:null,getToken:null,resolvedToken:null,onUnauthorized:null,ssoEnabled:de.SSO_ENABLED??!1,features:Qt(),ui:{theme:"light",density:"comfortable",header:!0,locale:"en"},copy:Kt(),hrefs:{askAquera:"/ask-aquera",builder:"/manage-dashboards"},initialDashboardId:null}}var $t=ht("dashboards",Gt);function k(){return $t.read()}function Bt(o){let t=Gt(),e=E(x(x({},t),ie(o)),{features:x(x({},t.features),ie(o.features??{})),ui:x(x({},t.ui),ie(o.ui??{})),hrefs:x(x({},t.hrefs),ie(o.hrefs??{})),copy:E(x(x({},t.copy),ie(o.copy??{})),{errors:x(x({},t.copy.errors),ie(o.copy?.errors??{}))}),headers:x(x({},t.headers),o.headers??{})});return o.tokenizedOrigins||(e.tokenizedOrigins=[e.baseUrl,e.mcpUrl].filter(n=>!!n)),$t.write(e)}var B=class o{requests$=new Ze;requests=this.requests$.asObservable();toAskAquera(){this.requests$.next({to:k().hrefs.askAquera})}toAskAqueraDashboard(t,e){this.requests$.next({to:`${k().hrefs.askAquera}/dashboard/${t}`,queryParams:e})}toBuilder(t){this.requests$.next({to:`${k().hrefs.builder}/${t}`})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=j({token:o,factory:o.\u0275fac})};var S={get baseUrl(){return k().baseUrl},get MCP_URL(){return k().mcpUrl??""},get MCP_GATEWAY_ENABLED(){return k().features.mcpGateway},get SSO_ENABLED(){return k().ssoEnabled}};function Ut(){return k().customerId??""}function T(){return k().productId??""}var pe=class o{constructor(t){this.http=t}http;tokenStore=w(ce);publishRepo=w(A);lastSentCustomerId=null;lastSentProductId=null;get customerId(){return this.tokenStore.tenantId()??""}mcpGatewayUrl(){return`${S.baseUrl}/dviz-mcp`}async callMcpTool(t,e={}){let n=this.customerId,i=T(),r={};n!==this.lastSentCustomerId&&(r.customerId=n),i!==this.lastSentProductId&&(r.productId=i);let s;try{s=await F(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:r})),this.lastSentCustomerId=n,this.lastSentProductId=i}catch(p){throw p instanceof L?new Error(p.error?.error?.message||p.error?.message||p.message):p}if(s.error)throw new Error(s.error.message);let g=s.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(!S.MCP_GATEWAY_ENABLED){try{await F(this.http.put(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}?published=true`,{name:e}))}catch(n){throw n instanceof L?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(S.MCP_GATEWAY_ENABLED){let i=await this.callMcpTool("getDashboard",{dashboardId:t,published:"true"});e=i?.dashboard??{},n=i?.canRefresh===!0}else{let i=await F(this.http.get(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/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(!S.MCP_GATEWAY_ENABLED){let n=await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/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 F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/widget-templates/${t}/detail-panel`,{}))).data}async previewWidgetDetailPanelDefinition(t){return(await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/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=>be(n.nileConfig))),e}static \u0275fac=function(e){return new(e||o)(Ye(J))};static \u0275prov=j({token:o,factory:o.\u0275fac,providedIn:"root"})};var U=class o{http=w(J);tokenStore=w(ce);get customerId(){return this.tokenStore.tenantId()??""}async fetchGridPage(t,e,n,i,r,s,g,p){let m=`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/data-grid/${t}?pageIndex=${e}&pageSize=${n}`,M=(i??[]).filter(V=>V&&V.value!=null&&String(V.value).trim()!=="");return M.length&&(m+=`&filters=${encodeURIComponent(JSON.stringify(M))}`),r&&Object.keys(r).length&&(m+=`&dashboardFilters=${encodeURIComponent(JSON.stringify(r))}`),g&&g.length&&(m+=`&resolvedFilters=${encodeURIComponent(JSON.stringify(g))}`),s&&(m+=`&dashboardId=${encodeURIComponent(s)}`),p&&(m+=`&conversationId=${encodeURIComponent(p)}`),F(this.http.get(m))}async generateWidget(t,e){let n=Ct()?{prompt:t}:{prompt:t,dataSourceId:e},i;try{i=await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/widget/generate`,n))}catch(g){if(g instanceof L){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 r=i?.data??i;if(!r?.config)throw new Error("Invalid response from widget generate API");let s=r;return await be(s.config),s}async filterSuggest(t,e,n,i){let r=n.filter(p=>!!p.id).map(p=>({widgetId:p.id})),s;try{s=await F(this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}/filter/suggest?status=${i??"draft"}`,{query:e,refreshCache:!1,widgets:r}))}catch(p){throw p instanceof L?new Error(p.error?.error||p.message):p}if(s?.success===!1)throw new Error(s.error||"Request failed");let g=s?.data??s??{};return{nextToken:g.nextToken,completions:Array.isArray(g.completions)?g.completions:[],suggestions:Array.isArray(g.suggestions)?g.suggestions:[]}}async applyFilters(t,e,n,i,r,s){let g=await new Promise((qe,Ce)=>{let Be=this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${n}/filter/apply?status=${i??"draft"}`,Vt(t,e,s)).subscribe({next:z=>qe(z),error:z=>{z instanceof L?Ce(new Error(z.error?.error||z.message)):Ce(z)}});if(r){if(r.aborted){Be.unsubscribe();let z=new Error("Aborted");z.name="AbortError",Ce(z);return}r.addEventListener("abort",()=>{Be.unsubscribe();let z=new Error("Aborted");z.name="AbortError",Ce(z)},{once:!0})}});if(g?.success===!1)throw new Error(g.error||"Request failed");let p=g?.data??g,m=Array.isArray(p)?p:p?.widgets;if(!Array.isArray(m))throw new Error("Invalid response from apply-filters API");let M=!Array.isArray(p)&&Array.isArray(p?.resolvedFilters)?p.resolvedFilters:[],V=!Array.isArray(p)&&Array.isArray(p?.filterGroups)?p.filterGroups:[];return await Promise.all(m.map(qe=>be(qe.config))),{widgets:m,resolvedFilters:M,filterGroups:V}}static \u0275fac=function(e){return new(e||o)};static \u0275prov=j({token:o,factory:o.\u0275fac,providedIn:"root"})};var Xt=["grid"];function en(o,t){if(o&1&&P(0),o&2){let e=d(2);We(" ",e.widgetDetailPanelTitle," ")}}function tn(o,t){o&1&&h(0,"nile-skeleton-loader",6)}function nn(o,t){if(o&1&&h(0,"shared-dashboard-grid",8),o&2){let e=d(2);v("widgets",e.widgetDetailPanelWidgets)("widgetsLoading",e.widgetDetailPanelLoading)("editMode",!1)("selectable",!1)("canSetAlert",!1)("canAddToStory",!1)("canForecast",!1)}}function on(o,t){o&1&&(a(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 rn(o,t){if(o&1){let e=D();a(0,"div",2)(1,"div",4)(2,"nile-breadcrumb",5),b("nile-click",function(){u(e);let i=d();return _(i.closeWidgetDetailPanel())}),a(3,"nile-breadcrumb-item"),P(4),l(),a(5,"nile-breadcrumb-item"),y(6,en,1,1)(7,tn,1,0,"nile-skeleton-loader",6),l()()(),a(8,"div",7),y(9,nn,1,7,"shared-dashboard-grid",8)(10,on,6,0,"div",9),l()()}if(o&2){let e=d();c(4),We(" ",e.dashboardName," "),c(2),C(e.widgetDetailPanelTitle?6:7),c(3),C(e.widgetDetailPanelWidgets.length?9:e.widgetDetailPanelLoading?10:-1)}}var ye=class o{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(r=>r.layout).filter(r=>!!r),this.widgetDetailPanelWidgets=this.detailPanelPlaceholders(i),this.cdr.markForCheck()});try{let r=i?await this.dashboardsService.previewWidgetDetailPanelDefinition(i):await this.dashboardsService.previewWidgetTemplateDetailPanel(String(n));if(!r.widgets.length){this.widgetDetailPanelOpen=!1;return}this.widgetDetailPanelTitle=r.title??t.title??null;let s=r.widgets.map((g,p)=>E(x({},g),{id:`detail-panel-${p}`}));this.widgetDetailPanelWidgets=s.every(g=>g.layout)?s:He(s)}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,r)=>E(x({},i),{id:`detail-panel-${r}`}));return n.every(i=>i.layout)?n:He(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=w(J);zone=w(ve);navigator=w(B);openAiService=w(U);dashboardsService=w(pe);forecastService=w(Ot);cdr=w(at);appRef=w(nt);hostEl=w(oe);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=o.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 r=document.documentElement;e==="back"&&(r.dataset.vtDirection="back");let s=()=>{delete r.dataset.vtDirection,this.endCardMorph()};n.startViewTransition(()=>{t(),this.appRef.tick()})?.finished?.then(s,s)??s()}sessionMap=new Map;primedFilterWidgets=new Set;filterSuggestCache=new Map;filterSuggestInflight=new Set;applyFiltersSeq=0;applyFiltersAbort;viewInited=!1;openInBuilder(){!this.dashboardId||!k().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(r=>({id:r.id,title:r.title??"",widgetType:r.type??"chart",layout:r.layout,config:r.nileConfig,drilldownBy:r.drilldownBy,dataSourceId:r.dataSourceId,queryMeta:r.queryMeta,category:r.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 r of i.controls??[]){if(!r.id)continue;let s=r.value;s!=null&&(typeof s=="string"&&s.trim()===""||(e[r.id]=s))}}return Object.keys(e).length>0?e:null}async applyInitialFilters(t){let e=this.widgets.filter(r=>!ge(r));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:r,resolvedFilters:s,filterGroups:g}=await this.openAiService.applyFilters(e,t,this.dashboardId,"published",n.signal,{timeRange:this.currentTimeRange??void 0});if(i!==this.applyFiltersSeq)return;let p=new Map(r.map(m=>[m.id,m]));this.widgets=this.widgets.map(m=>{let M=p.get(m.id);return M?E(x(x({},m),M),{config:M.config??m.config}):m}),this.activeDashboardFilters=t,this.activeResolvedFilters=s,this.activeFilterGroups=g,this.applySummary=Ae(r,this.buildActiveFilters(t))}catch(r){if(r?.name==="AbortError")return;console.error("Apply initial filters failed:",r)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}ngAfterViewInit(){this.viewInited=!0,queueMicrotask(()=>this.primeFilterWidgets())}alertTargetWidget(){let t=this.widgets.filter(n=>!ge(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),fe({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)?E(x({},e),{config:t.config?.chart??t.nileConfig??e.config,queryMeta:t.queryMeta??e.queryMeta}):e)}onSetAlert(t){if(ge(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 r=await this.openAiService.filterSuggest(n,"",this.widgets,"published");this.applyFilterSuggestions(t,e,r)}catch(r){console.warn("Filter suggest failed:",r)}finally{this.filterSuggestInflight.delete(t)}})())}async onFilterSubmit(t){if(this.isEmptyFilters(t.filters)){await this.reloadDashboard();return}let e=this.widgets.filter(r=>!ge(r));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:r,resolvedFilters:s,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;let p=new Map(r.map(m=>[m.id,m]));this.widgets=this.widgets.map(m=>{let M=p.get(m.id);return M?E(x(x({},m),M),{config:M.config??m.config}):m}),this.activeDashboardFilters=t.filters,this.lastMonitoredTotal=null,this.activeResolvedFilters=s,this.activeFilterGroups=g,this.applySummary=Ae(r,this.buildActiveFilters(t.filters))}catch(r){if(r?.name==="AbortError")return;console.error("Apply filters failed:",r)}finally{i===this.applyFiltersSeq&&(this.applyingFilters=!1),this.cdr.markForCheck()}}async applyTimeRange(t){this.currentTimeRange=t;let e=this.widgets.filter(r=>!ge(r));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 r=this.activeDashboardFilters??{},{widgets:s,resolvedFilters:g,filterGroups:p}=await this.openAiService.applyFilters(e,r,this.dashboardId,"published",n.signal,{resolvedFilters:this.activeResolvedFilters??[],timeRange:t});if(i!==this.applyFiltersSeq)return;let m=new Map(s.map(M=>[M.id,M]));this.widgets=this.widgets.map(M=>{let V=m.get(M.id);return V?E(x(x({},M),V),{config:V.config??M.config}):M}),this.activeResolvedFilters=g,this.activeFilterGroups=p,this.applySummary=Ae(s,this.buildActiveFilters(r)),this.checkForNewSinceLastCheck(t)}catch(r){if(r?.name==="AbortError")return;console.error("Apply time range failed:",r)}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 r=i.config?.chart;if(r?.type!=="kpi")continue;let s=Number(r.value);Number.isFinite(s)&&(e+=s,n=!0)}return n?e:null}buildActiveFilters(t){return Rt(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 r of n.completions)i.push({label:r,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=Ut(),i=await F(this.http.post(`${S.baseUrl}/api/customers/${n}/products/${T()}/workforce/dashboards/${this.dashboardId}/widgets/${t.widgetId}/chat`,{message:t.message,sessionId:e})),r=i?.reply?.content;r&&(this.sessionMap.set(t.widgetId,i.sessionId??e),this.zone.run(()=>{t.chartEl?.addAiResponse?.(r)}))}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||o)};static \u0275cmp=W({type:o,selectors:[["app-dashboard-viewer"]],viewQuery:function(e,n){if(e&1&&ae(Xt,5),e&2){let i;Y(i=K())&&(n.gridRef=i.first)}},inputs:{config:"config"},features:[se([{provide:Pt,useFactory:t=>t.fetchGridPage.bind(t),deps:[U]},{provide:Dt,useFactory:t=>t.fetchFilterValues.bind(t),deps:[A]},Se(A),De(A),ke(A),Oe(A)])],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&&(a(0,"shared-dashboard-grid",1,0),b("forecast",function(r){return n.onForecast(r)})("aiSend",function(r){return n.onAiSend(r)})("openAiBuilder",function(){return n.openInBuilder()})("filterSubmit",function(r){return n.onFilterSubmit(r)})("filterChange",function(r){return n.onFilterChange(r)})("widgetChartTypeChanged",function(r){return n.onWidgetPatchedByGrid(r)})("widgetFiltersChanged",function(r){return n.onWidgetPatchedByGrid(r)})("widgetColorChanged",function(r){return n.onWidgetPatchedByGrid(r)})("setAlert",function(r){return n.onSetAlert(r)})("widgetClick",function(r){return n.onKpiWidgetClicked(r)}),l(),y(2,rn,11,3,"div",2),a(3,"app-alert-drawer",3),b("closed",function(){return n.onAlertClosed()})("saved",function(){return n.onAlertSaved()}),l()),e&2&&(v("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),C(n.widgetDetailPanelOpen?2:-1),c(),v("open",n.alertDrawerOpen)("widget",n.alertWidget)("dashboardId",n.dashboardId)("source",n.alertSource)("filterPredicates",n.alertFilterPredicates)("filterHasOr",n.alertFilterHasOr)("authoringMode",n.alertAuthoringMode))},dependencies:[Me,Te,Fe],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 Ie=class o{http=w(J);tokenStore=w(ce);get customerId(){return this.tokenStore.tenantId()??""}async chat(t,e,n,i){let r=await new Promise((s,g)=>{let p=this.http.post(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${e}/chat`,{message:t,sessionId:n}).subscribe({next:m=>s(m),error:m=>{m instanceof L?g(new Error(m.error?.error||m.message)):g(m)}});if(i){if(i.aborted){p.unsubscribe();let m=new Error("Aborted");m.name="AbortError",g(m);return}i.addEventListener("abort",()=>{p.unsubscribe();let m=new Error("Aborted");m.name="AbortError",g(m)},{once:!0})}});if(!r?.success)throw new Error("Chat request failed");return r}async getSuggestions(t){if(!t)return[];let e;try{e=await F(this.http.get(`${S.baseUrl}/api/customers/${this.customerId}/products/${T()}/workforce/dashboards/${t}/chat/suggestions`))}catch(n){throw n instanceof L?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||o)};static \u0275prov=j({token:o,factory:o.\u0275fac,providedIn:"root"})};var sn=["sliderGrid"],ln=o=>({"recommend-window":o}),dn=()=>({variant:"welcome"}),cn=()=>[1,2,3,4],gn=o=>({"mic-listening":o}),pn=o=>({disabled:o}),jt=(o,t)=>t.title;function hn(o,t){o&1&&H(0)}function mn(o,t){o&1&&(a(0,"div",18),h(1,"nile-skeleton-loader",19),l())}function un(o,t){o&1&&(a(0,"div",17),I(1,mn,2,0,"div",18,Z),l()),o&2&&(c(),R(ne(0,cn)))}function _n(o,t){if(o&1){let e=D();a(0,"button",23),b("click",function(){let i=u(e).$implicit,r=d(5);return _(r.runPrompt(i.title))}),a(1,"div",24),h(2,"nile-icon",25),l(),a(3,"span",26),P(4),l()()}if(o&2){let e=t.$implicit;c(4),q(e.title)}}function fn(o,t){if(o&1){let e=D();a(0,"div",17),I(1,_n,5,1,"button",20,jt),l(),a(3,"button",21),b("click",function(){u(e);let i=d(4);return _(i.openPromptGallery())}),h(4,"nile-glyph",22),a(5,"span"),P(6,"View prompt gallery"),l()()}if(o&2){let e=d(4);c(),R(e.topRecommended())}}function bn(o,t){if(o&1&&(a(0,"div",9)(1,"div",12),h(2,"nile-icon",13),l(),a(3,"h2",14),P(4,"What would you like to ask?"),l(),a(5,"p",15),P(6,"Ask anything about your dashboard."),l(),G(7,hn,1,0,"ng-container",16),y(8,un,3,1,"div",17)(9,fn,7,0),l()),o&2){let e=d(3),n=N(3);c(7),v("ngTemplateOutlet",n)("ngTemplateOutletContext",ne(3,dn)),c(),C(e.loadingSuggestions()?8:e.recommended().length>0?9:-1)}}function yn(o,t){o&1&&(a(0,"div",10),h(1,"nile-icon",27),a(2,"div",28),P(3,"Generating your answer..."),l()()),o&2&&(c(),v("name","loader")("size","20"))}function Cn(o,t){if(o&1&&(a(0,"div",29)(1,"div",30)(2,"span"),P(3),l()()()),o&2){let e=d().$implicit;c(3),q(e.content)}}function vn(o,t){if(o&1&&(a(0,"div")(1,"div",31),h(2,"nile-glyph",32),l(),a(3,"div",33),h(4,"div",34),l()()),o&2){let e=d().$implicit;c(4),v("innerHTML",e.content,tt)}}function xn(o,t){if(o&1&&(y(0,Cn,4,1,"div",29),y(1,vn,5,1,"div")),o&2){let e=t.$implicit;C(e.role==="user"?0:-1),c(),C(e.role==="assistant"?1:-1)}}function wn(o,t){o&1&&H(0)}function Pn(o,t){if(o&1&&G(0,wn,1,0,"ng-container",35),o&2){d(3);let e=N(3);v("ngTemplateOutlet",e)}}function Mn(o,t){if(o&1){let e=D();a(0,"button",23),b("click",function(){let i=u(e).$implicit,r=d(4);return _(r.onGalleryPromptClick(i.title))}),a(1,"div",24),h(2,"nile-icon",25),l(),a(3,"span",26),P(4),l()()}if(o&2){let e=t.$implicit;c(4),q(e.title)}}function Dn(o,t){if(o&1){let e=D();a(0,"div",11)(1,"div",36)(2,"span",37),P(3,"Prompt gallery"),l(),a(4,"button",38),b("click",function(){u(e);let i=d(3);return _(i.closePromptGallery())}),h(5,"nile-glyph",39),l()(),a(6,"div",40)(7,"p",41),P(8,"Pick a suggestion to get started."),l(),a(9,"div",42),I(10,Mn,5,1,"button",20,jt),l()()()}if(o&2){let e=d(3);c(10),R(e.recommended())}}function kn(o,t){if(o&1){let e=D();a(0,"div",6)(1,"nile-glyph",7),b("click",function(){u(e);let i=d(2);return _(i.closePanel.emit())}),l()(),a(2,"div",8),y(3,bn,10,4,"div",9),y(4,yn,4,2,"div",10),I(5,xn,2,2,null,null,Z),l(),y(7,Pn,1,1,"ng-container"),y(8,Dn,12,0,"div",11)}if(o&2){let e,n,i,r,s=d(2);c(2),v("ngClass",le(5,ln,!(!((e=s.chatsDetails())==null||e.message==null)&&e.message.length))),c(),C(!((n=s.chatsDetails())==null||n.message==null)&&n.message.length?-1:3),c(),C(s.isGenerating()?4:-1),c(),R((i=s.chatsDetails())==null?null:i.message),c(2),C(!((r=s.chatsDetails())==null||r.message==null)&&r.message.length?7:-1),c(),C(s.showPromptGallery()?8:-1)}}function Sn(o,t){if(o&1){let e=D();a(0,"div",43),b("pointerdown",function(i){u(e);let r=d(2);return _(r.onResizeStart(i))})("pointermove",function(i){u(e);let r=d(2);return _(r.onResizeMove(i))})("pointerup",function(i){u(e);let r=d(2);return _(r.onResizeEnd(i))})("pointercancel",function(i){u(e);let r=d(2);return _(r.onResizeEnd(i))}),l(),a(1,"div",44)(2,"div",45)(3,"shared-dashboard-grid",46,1),b("filterSubmit",function(i){u(e);let r=d(2);return _(r.onSliderFilterSubmit(i))})("filterChange",function(i){u(e);let r=d(2);return _(r.onSliderFilterChange(i))})("widgetChartTypeChanged",function(i){u(e);let r=d(2);return _(r.onSliderWidgetPatched(i))})("widgetFiltersChanged",function(i){u(e);let r=d(2);return _(r.onSliderWidgetPatched(i))})("setAlert",function(i){u(e);let r=d(2);return _(r.onSetAlert(i))}),l(),a(5,"app-alert-drawer",47),b("closed",function(){u(e);let i=d(2);return _(i.onAlertClosed())})("saved",function(){u(e);let i=d(2);return _(i.onAlertClosed())}),l()()()}if(o&2){let e=d(2);c(3),v("widgets",e.sliderWidgets())("editMode",!1)("outerMargin",!1)("dashboardId",e.dashboardId())("persistToPublished",!0)("canSetAlert",!0)("canAddToStory",!1),c(2),v("open",e.alertDrawerOpen())("widget",e.alertWidget())("dashboardId",e.dashboardId())("source",e.alertSource())}}function On(o,t){if(o&1&&(a(0,"div",4)(1,"div",5),y(2,kn,9,7),l(),y(3,Sn,6,11),l()),o&2){let e=d();$("chat-layout--resizing",e.isResizing()),c(),rt("flex",e.chatColumnWidthPct()!==null?"0 0 "+e.chatColumnWidthPct()+"%":null),$("chat-column--split",!!e.dashboardConfig()&&!e.chatOnly()),c(),C(e.loadingChat()?-1:2),c(),C(e.dashboardConfig()&&!e.chatOnly()?3:-1)}}function Tn(o,t){if(o&1){let e=D();a(0,"div",48)(1,"label",49)(2,"input",50),b("input",function(i){u(e);let r=d();return _(r.queryString.set(i.target.value))})("keyup.enter",function(){u(e);let i=d();return _(i.postMessage())}),l(),a(3,"div",51)(4,"div",52)(5,"nile-glyph",53),b("click",function(){u(e);let i=d();return _(i.toggleMic())}),l(),a(6,"nile-glyph",54),b("click",function(){u(e);let i=d();return _(i.isGenerating()?i.cancelGenerate():i.postMessage())}),l()()()()()}if(o&2){let e=t.variant,n=d();$("input-query-container--welcome",e==="welcome"),c(2),v("value",n.queryString()),c(3),v("name",n.isMicListening()?"ng-mic":"ng-mic-off")("ngClass",le(8,gn,n.isMicListening())),c(),v("name",n.isGenerating()?"ng-circle-stop":"ng-send")("size",n.isGenerating()?"18":"16")("ngClass",le(10,pn,!n.isGenerating()&&!n.queryString()))}}var Re=class o{constructor(t,e,n){this.chatService=t;this.openAiService=e;this.sanitizer=n;ee(()=>{let r=this.dashboardId();r&&this.loadSuggestions(r)});let i=null;ee(()=>{let r=this.dashboardConfig(),s=r?.id??null;s!==i&&(this.primedFilterWidgets.clear(),i=s);let g=(r?.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 he;dashboardId=Q("");dashboardName=Q("");dashboardConfig=Q(null);chatOnly=Q(!1);initialPrompt=Q("");allChats=f([]);chatsDetails=f(null);isGenerating=f(!1);queryString=f("");searchTerm=f("");selectedChatContextId=f("");loadingChat=f(!1);loadingAllChat=f(!1);isDeleting=f(!1);isMicListening=f(!1);recognition=null;micBaseText="";silenceTimer=null;micSilenceMs=5e3;recommended=f([]);topRecommended=O(()=>this.recommended().slice(0,4));loadingSuggestions=f(!1);showPromptGallery=f(!1);chatColumnWidthPct=f(null);isResizing=f(!1);resizeRect=null;resizePointerId=null;resizeRafPending=!1;sliderWidgets=f([]);alertDrawerOpen=f(!1);alertWidget=f(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=O(()=>{let t=this.dashboardConfig();return t?{connectionId:t.connectionId,isPipeline:t.isPipeline,adapterType:t.adapterType}:null});sliderGridRef;applyingFilters=f(!1);filterSuggestTimers=new Map;filterSuggestSeq=new Map;primedFilterWidgets=new Set;applyFiltersSeq=0;applyFiltersAbort;generateAbort;formattedChats=O(()=>this.buildFormattedChats(this.allChats()));filteredFormattedChats=O(()=>{let t=this.formattedChats(),e=this.searchTerm().toLowerCase().trim();if(!e)return t;let n=i=>i.filter(r=>r.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 r=this.filterSuggestTimers.get(e);r&&clearTimeout(r);let s=(t.query??"").trim();if(!s)return;let g=(this.filterSuggestSeq.get(e)??0)+1;this.filterSuggestSeq.set(e,g);let p=setTimeout(async()=>{try{let m=this.sliderWidgets(),M=await this.openAiService.filterSuggest(i,s,m,"published");if(this.filterSuggestSeq.get(e)!==g)return;this.applyFilterSuggestions(e,n,M)}catch(m){console.warn("Filter suggest failed:",m)}},400);this.filterSuggestTimers.set(e,p)}async onSliderFilterSubmit(t){let e=this.sliderWidgets(),n=e.filter(s=>!this.isFilterWidget(s));if(n.length===0)return;this.applyFiltersAbort?.abort();let i=new AbortController;this.applyFiltersAbort=i;let r=++this.applyFiltersSeq;this.applyingFilters.set(!0);try{let{widgets:s}=await this.openAiService.applyFilters(n,t.filters,this.dashboardId(),"published",i.signal,{mode:t.mode,prompt:t.prompt});if(r!==this.applyFiltersSeq)return;let g=new Map(s.map(p=>[p.id,p]));this.sliderWidgets.set(e.map(p=>{let m=g.get(p.id);return m?E(x(x({},p),m),{config:m.config??p.config}):p}))}catch(s){if(s?.name==="AbortError"||r!==this.applyFiltersSeq)return;let g=s instanceof Error?s.message:"Failed to apply filters.";this.pushSystemMessage("error",`Apply filters failed: ${g}`)}finally{r===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 r=i.controls?.find(g=>g.variant==="expression"||g.variant==="hybrid");if(!r?.id)continue;this.primedFilterWidgets.add(n.id);let s=r.id;(async()=>{try{let g=await this.openAiService.filterSuggest(t,"",e,"published");this.applyFilterSuggestions(n.id,s,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 r of n.completions)i.push({label:r,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(x({},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((r,s)=>!(s===0&&r.role==="user"));else{let r=i instanceof Error?i.message:"Failed to get response.";this.pushSystemMessage("error",`Chat failed: ${r}`)}}finally{this.generateAbort===n&&(this.generateAbort=void 0),this.chatsDetails.set(x({},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 s=0;s<n.results.length;s++)i+=n.results[s][0].transcript;let r=this.micBaseText&&!this.micBaseText.endsWith(" ")?" ":"";this.queryString.set(this.micBaseText+r+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,s=>s==="<"?"<":s===">"?">":"&"),r=t==="error"?`ERROR: ${i}!`:i;n.message.unshift({role:"assistant",content:this.sanitizeHtml(`<p class="chat-system chat-system--${t}">${r}</p>`)}),this.chatsDetails.set(x({},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(),At()}sanitizeHtml(t){return this.sanitizer.sanitize(et.HTML,t)??""}buildFormattedChats(t){let e=[...t].sort((i,r)=>new Date(r.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||o)(xe(Ie),xe(U),xe(ct))};static \u0275cmp=W({type:o,selectors:[["db-ai-prompt-panel"]],viewQuery:function(e,n){if(e&1&&ae(sn,5),e&2){let i;Y(i=K())&&(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","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&&(a(0,"div",2),y(1,On,4,8,"div",3),l(),G(2,Tn,7,12,"ng-template",null,0,ue)),e&2&&(c(),C(n.loadingAllChat()?-1:1))},dependencies:[Me,st,Pe,It,Te,Fe],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 An=o=>[o];function Fn(o,t){if(o&1&&me(0,"nile-progress-bar",4),o&2){let e=d();ot("value",e.percent())}}var ze=class o{streamId;done=new he;failed=new he;streamService=w(Ht);totalCharts=f(0);widgetPhases=f([]);phaseLabel=f("Connecting to your data\u2026");dashboardNumber=f(0);barKey=f(0);pendingNewDashboard=!0;readyCount=O(()=>this.widgetPhases().filter(t=>t==="building"||t==="saving").length);percent=O(()=>{let t=this.totalCharts();if(!t)return 0;let e=this.widgetPhases(),n=0;for(let i=0;i<t;i++){let r=e[i];n+=r==="building"||r==="saving"?1:r==="querying"?.66:r==="analyzing"?.33:0}return Math.round(Math.min(1,n/t)*100)});countLabel=O(()=>{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]=Wt(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||o)};static \u0275cmp=W({type:o,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&&(re(0,"div",0),me(1,"nile-status-light",1),re(2,"span",2),P(3,"Generating your dashboards"),we(),me(4,"span",3),I(5,Fn,1,1,"nile-progress-bar",4,it),re(7,"span",5),P(8),we(),re(9,"div",6),me(10,"nile-spinner",7),re(11,"span",8),P(12),we()()()),e&2&&(c(5),R(le(2,An,n.barKey())),c(3),q(n.countLabel()),c(4),q(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 En=["tabsScroller"],Yt=()=>({subtitle:"Explore your dashboards or ask your data a question"}),In=()=>({subtitle:"Setting up your initial dashboards \u2014 crafting a starter set from your data."}),Zt=(o,t)=>t.id;function Rn(o,t){if(o&1&&(a(0,"header",8),H(1,16),l()),o&2){d(2);let e=N(5);c(),v("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Yt))}}function zn(o,t){if(o&1&&h(0,"nile-skeleton-loader",11),o&2){let e=t.$implicit;te("width",e)}}function Vn(o,t){o&1&&h(0,"nile-skeleton-loader",14)}function Nn(o,t){o&1&&H(0)}function qn(o,t){if(o&1&&(a(0,"div",5)(1,"div",7),y(2,Rn,2,3,"header",8),a(3,"div",9)(4,"div",10),I(5,zn,1,1,"nile-skeleton-loader",11,Z),l(),h(7,"span",12)(8,"nile-skeleton-loader",13),I(9,Vn,1,0,"nile-skeleton-loader",14,Z),l(),G(11,Nn,1,0,"ng-container",15),l()()),o&2){let e=d(),n=N(7);c(2),C(e.showHeader()?2:-1),c(3),R(e.skeletonTabWidths),c(4),R(e.skeletonActionBtns),c(2),v("ngTemplateOutlet",n)}}function Wn(o,t){if(o&1&&(a(0,"header",8),H(1,16),l()),o&2){d(2);let e=N(5);c(),v("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,In))}}function Hn(o,t){if(o&1){let e=D();a(0,"app-dashboard-generating",18),b("done",function(i){u(e);let r=d(2);return _(r.onGenerationDone(i))})("failed",function(){u(e);let i=d(2);return _(i.onGenerationFailed())}),l()}if(o&2){let e=d(2);v("streamId",e.generationStreamId())}}function Ln(o,t){o&1&&H(0)}function Gn(o,t){if(o&1&&(a(0,"div",6)(1,"div",7),y(2,Wn,2,3,"header",8),a(3,"div",9),y(4,Hn,1,1,"app-dashboard-generating",17),l()(),G(5,Ln,1,0,"ng-container",15),l()),o&2){let e=d(),n=N(7);c(2),C(e.showHeader()?2:-1),c(2),C(e.features().autoGenerate?4:-1),c(),v("ngTemplateOutlet",n)}}function $n(o,t){if(o&1&&(a(0,"header",8),H(1,16),l()),o&2){d(2);let e=N(5);c(),v("ngTemplateOutlet",e)("ngTemplateOutletContext",ne(2,Yt))}}function Bn(o,t){o&1&&h(0,"nile-glyph",52)}function Un(o,t){if(o&1){let e=D();a(0,"span",54),b("click",function(i){return i.stopPropagation()}),a(1,"input",55,3),b("input",function(){u(e);let i=N(2),r=d(4);return _(r.onRenameInputChange(i.value))})("keydown",function(i){u(e);let r=d().$implicit,s=d(3);return _(s.onRenameInputKeydown(i,r))})("click",function(i){return i.stopPropagation()}),l(),a(3,"button",56),b("click",function(i){u(e);let r=d().$implicit,s=d(3);return _(s.commitRenameDashboard(r,i))}),h(4,"nile-glyph",57),l()()}if(o&2){let e=d().$implicit,n=d(3);c(),v("value",n.renamingValue())("disabled",n.isRenamingDashboard()),te("data-dashboard-id",e.id),c(2),v("disabled",n.isRenamingDashboard())}}function jn(o,t){if(o&1){let e=D();a(0,"button",60),b("click",function(i){u(e);let r=d(2).$implicit,s=d(3);return _(s.startRenameDashboard(r,i))}),h(1,"nile-glyph",61),l()}}function Zn(o,t){if(o&1&&(a(0,"span",58),P(1),l(),y(2,jn,2,0,"button",59)),o&2){let e=d().$implicit,n=d(3);c(),q(e.name),c(),C(n.features().rename&&!e.isAutoGenerated?2:-1)}}function Yn(o,t){if(o&1){let e=D();a(0,"nile-nav-tab",51),b("click",function(){let i=u(e).$implicit,r=d(3);return _(r.setActiveTab(i.id))}),y(1,Bn,1,0,"nile-glyph",52),y(2,Un,5,4,"span",53)(3,Zn,3,2),l()}if(o&2){let e=t.$implicit,n=d(3);te("panel",e.id),c(),C(e.isAutoGenerated?1:-1),c(),C(n.renamingDashboardId()===e.id?2:3)}}function Kn(o,t){if(o&1){let e=D();a(0,"app-time-range-picker",62),b("apply",function(i){u(e);let r=d(3);return _(r.onTimeRangeApply(i))}),l()}if(o&2){let e=d(3);v("resetKey",e.activeTabId())}}function Qn(o,t){o&1&&h(0,"span",37)}function Jn(o,t){o&1&&h(0,"nile-glyph",42)}function Xn(o,t){o&1&&h(0,"nile-glyph",42)}function ei(o,t){if(o&1){let e=D();a(0,"button",40),b("click",function(){let i=u(e).$implicit,r=d(3);return _(r.onCategoryFilterChange(i.id))}),a(1,"span",41),P(2),l(),y(3,Xn,1,0,"nile-glyph",42),l()}if(o&2){let e=t.$implicit,n=d(3);$("is-active",n.selectedCategory()===e.id),c(2),q(e.label),c(),C(n.selectedCategory()===e.id?3:-1)}}function ti(o,t){if(o&1){let e=D();a(0,"nile-lite-tooltip",47)(1,"button",63),b("click",function(){u(e);let i=d(3);return _(i.refreshActiveDashboard())}),h(2,"nile-glyph",64),l()()}if(o&2){let e=d(3);c(),v("disabled",!e.activeTabId()||e.refreshingDashboard()),c(),$("home-refresh-glyph--spinning",e.refreshingDashboard())}}function ni(o,t){if(o&1){let e=D();a(0,"nile-lite-tooltip",49)(1,"button",65),b("click",function(){u(e);let i=d(3);return _(i.selectHomeMenuItem("executiveSummary"))}),h(2,"nile-glyph",66),l()()}}function ii(o,t){if(o&1){let e=D();a(0,"nile-dropdown",67),b("nile-hide",function(){u(e);let i=d(3);return _(i.downloadMenuOpen.set(!1))}),a(1,"nile-lite-tooltip",68)(2,"button",69),b("click",function(){u(e);let i=d(3);return _(i.downloadMenuOpen.set(!i.downloadMenuOpen()))}),h(3,"nile-glyph",70),l()(),a(4,"nile-menu")(5,"nile-menu-item",71),b("click",function(){u(e);let i=d(3);return i.downloadMenuOpen.set(!1),_(i.selectHomeMenuItem("exportPdf"))}),h(6,"nile-glyph",72),P(7," Download as PDF "),l(),a(8,"nile-menu-item",71),b("click",function(){u(e);let i=d(3);return i.downloadMenuOpen.set(!1),_(i.selectHomeMenuItem("exportPng"))}),h(9,"nile-glyph",73),P(10," Download as PNG "),l()()()}if(o&2){let e=d(3);v("open",e.downloadMenuOpen())}}function oi(o,t){if(o&1){let e=D();a(0,"div",23)(1,"button",24),b("click",function(){u(e);let i=d(2);return _(i.scrollTabs(-1))}),h(2,"nile-glyph",25),l(),a(3,"div",26,2),b("scroll",function(){u(e);let i=d(2);return _(i.onTabsScroll())}),a(5,"nile-nav-tab-group",27),h(6,"nile-nav-tab",28),I(7,Yn,4,3,"nile-nav-tab",29,Zt),l()(),a(9,"button",30),b("click",function(){u(e);let i=d(2);return _(i.scrollTabs(1))}),h(10,"nile-glyph",31),l(),h(11,"span",12),y(12,Kn,1,1,"app-time-range-picker",32),a(13,"nile-dropdown",33),b("nile-hide",function(){u(e);let i=d(2);return _(i.categoryFilterOpen.set(!1))}),a(14,"nile-lite-tooltip",34)(15,"button",35),b("click",function(){u(e);let i=d(2);return _(i.categoryFilterOpen.set(!i.categoryFilterOpen()))}),h(16,"nile-glyph",36),y(17,Qn,1,0,"span",37),l()(),a(18,"div",38),b("mousedown",function(i){return i.stopPropagation()}),a(19,"span",39),P(20,"Filter by category"),l(),a(21,"button",40),b("click",function(){u(e);let i=d(2);return _(i.onCategoryFilterChange(null))}),a(22,"span",41),P(23,"All categories"),l(),y(24,Jn,1,0,"nile-glyph",42),l(),I(25,ei,4,4,"button",43,Zt),l()(),a(27,"nile-lite-tooltip",44)(28,"button",45),b("click",function(){u(e);let i=d(2);return _(i.goToCreateDashboard())}),h(29,"nile-glyph",46),l()(),y(30,ti,3,3,"nile-lite-tooltip",47),a(31,"div",48),y(32,ni,3,0,"nile-lite-tooltip",49),y(33,ii,11,1,"nile-dropdown",50),l()()}if(o&2){let e=d(2);$("is-scrollable",e.canScrollLeft()||e.canScrollRight()),c(),v("disabled",!e.canScrollLeft()),c(4),te("value",e.activeTabId()||"__sentinel__"),c(2),R(e.visibleDashboards()),c(2),v("disabled",!e.canScrollRight()),c(3),C(e.activeTabId()?12:-1),c(),v("open",e.categoryFilterOpen()),c(4),C(e.selectedCategory()?17:-1),c(4),$("is-active",!e.selectedCategory()),c(3),C(e.selectedCategory()?-1:24),c(),R(e.dashboardCategories),c(3),v("disabled",e.creatingDashboard()),c(2),C(e.features().refresh?30:-1),c(2),C(e.features().executiveSummary?32:-1),c(),C(e.features().export?33:-1)}}function ri(o,t){if(o&1&&(a(0,"nile-nav-tab-panel",74),h(1,"app-dashboard-viewer",76),l()),o&2){let e=d(3);te("name",e.activeTabId()),c(),v("config",e.loadedDashboards().get(e.activeTabId()))}}function ai(o,t){o&1&&H(0)}function si(o,t){if(o&1&&(a(0,"div",75),G(1,ai,1,0,"ng-container",15),l()),o&2){d(3);let e=N(7);c(),v("ngTemplateOutlet",e)}}function li(o,t){if(o&1&&y(0,ri,2,2,"nile-nav-tab-panel",74)(1,si,2,1,"div",75),o&2){let e=d(2);C(e.loadedDashboards().has(e.activeTabId())?0:e.isTabLoading()||e.refreshingDashboard()?1:-1)}}function di(o,t){if(o&1){let e=D();a(0,"div",20)(1,"h2",77),P(2,"No dashboards in this category"),l(),a(3,"p",78),P(4,"Try a different category, or clear the filter to see everything."),l(),a(5,"nile-button",79),b("click",function(){u(e);let i=d(2);return _(i.onCategoryFilterChange(null))}),P(6," Clear filter "),l()()}}function ci(o,t){if(o&1){let e=D();a(0,"div",20)(1,"div",80),Ke(),a(2,"svg",81),h(3,"rect",82)(4,"rect",83)(5,"rect",84),a(6,"rect",85),h(7,"animate",86)(8,"animate",87),l(),a(9,"rect",88),h(10,"animate",89)(11,"animate",90),l(),a(12,"rect",91),h(13,"animate",92)(14,"animate",93),l(),a(15,"rect",94),h(16,"animate",95)(17,"animate",96),l(),a(18,"rect",97),h(19,"animate",98)(20,"animate",99),l(),h(21,"rect",100)(22,"rect",101)(23,"circle",102),a(24,"circle",103),h(25,"animate",104),l(),h(26,"rect",105)(27,"rect",106),a(28,"path",107),h(29,"animate",108),l(),a(30,"circle",109),h(31,"animate",110),l()()(),Qe(),a(32,"h2",77),P(33,"Build your dashboard"),l(),a(34,"p",78),P(35," Tap the below button to generate dashboard. "),l(),a(36,"nile-button",111),b("click",function(){u(e);let i=d(2);return _(i.goToCreateDashboard())}),h(37,"nile-glyph",112),P(38," Create dashboard "),l()()}if(o&2){let e=d(2);c(36),te("disabled",e.creatingDashboard()?"":null)}}function gi(o,t){if(o&1){let e=D();a(0,"db-ai-prompt-panel",113),b("closePanel",function(){u(e);let i=d(2);return _(i.showAiPanel.set(!1))}),l()}if(o&2){let e=d(2);v("dashboardId",e.activeTabId())("dashboardName",e.activeDashboardName())("dashboardConfig",e.loadedDashboards().get(e.activeTabId())??null)("chatOnly",e.aiChatOnly())("initialPrompt",e.aiInitialPrompt())}}function pi(o,t){if(o&1){let e=D();a(0,"div",6)(1,"div",7),y(2,$n,2,3,"header",8),y(3,oi,34,15,"div",19),y(4,li,2,1)(5,di,7,0,"div",20)(6,ci,39,1,"div",20),a(7,"nile-drawer",21),b("nile-request-close",function(){u(e);let i=d();return _(i.showAiPanel.set(!1))}),y(8,gi,1,5,"db-ai-prompt-panel",22),l()()()}if(o&2){let e=d();c(2),C(e.showHeader()?2:-1),c(),C(e.allDashboards().length>0?3:-1),c(),C(e.activeTabId()?4:e.allDashboards().length>0?5:e.allDashboards().length===0?6:-1),c(3),v("open",e.showAiPanel()),c(),C(e.features().aiPrompt&&e.showAiPanel()?8:-1)}}function hi(o,t){if(o&1&&(a(0,"div",114)(1,"h1",115),P(2,"Dashboards"),l(),a(3,"p",116),P(4),l()()),o&2){let e=t.subtitle;c(4),q(e)}}function mi(o,t){o&1&&(a(0,"div",119)(1,"div",122),h(2,"nile-skeleton-loader",123)(3,"nile-skeleton-loader",124),l(),h(4,"nile-skeleton-loader",125),a(5,"div",126),h(6,"nile-skeleton-loader",127)(7,"nile-skeleton-loader",128),l(),h(8,"nile-skeleton-loader",129),l())}function ui(o,t){o&1&&(a(0,"div",121)(1,"div",130)(2,"div",131),h(3,"nile-skeleton-loader",132)(4,"nile-skeleton-loader",133),l(),h(5,"nile-skeleton-loader",134),l(),h(6,"nile-skeleton-loader",135),l())}function _i(o,t){if(o&1&&(a(0,"div",117)(1,"div",118),I(2,mi,9,0,"div",119,Z),l(),a(4,"div",120),I(5,ui,7,0,"div",121,Z),l()()),o&2){let e=d();c(2),R(e.skeletonKpis),c(3),R(e.skeletonWidgets)}}var $e=4,Ve=class o{MAX_TABS=$e;tabsScrollerEl;dashboardViewerRef;timeRangePickerRef;onTimeRangeApply(t){this.dashboardViewerRef?.applyTimeRange(t)}tabsScrollLeft=f(0);tabsClientWidth=f(0);tabsScrollWidth=f(0);canScrollLeft=O(()=>this.tabsScrollLeft()>0);canScrollRight=O(()=>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 r=i.getBoundingClientRect(),s=t.getBoundingClientRect(),g=16;r.right>s.right?t.scrollBy({left:r.right-s.right+g,behavior:"smooth"}):r.left<s.left&&t.scrollBy({left:r.left-s.left-g,behavior:"smooth"})}onWindowResize=()=>this.ngZone.run(()=>this.updateTabsScrollState());showAiPanel=f(!1);aiChatOnly=f(!1);aiInitialPrompt=f("");allDashboards=f([]);selectedCategory=f(null);dashboardCategories=Lt;categoryFilterOpen=f(!1);visibleDashboards=O(()=>{let t=this.selectedCategory(),e=this.allDashboards();return t?e.filter(n=>n.category?.includes(t)):e});activeTabs=f([]);activeTabId=f("");loadedDashboards=f(new Map);isLoading=f(!0);isTabLoading=f(!1);skeletonTabWidths=[72,220,140];skeletonKpis=Array.from({length:4});skeletonWidgets=Array.from({length:4});skeletonActionBtns=Array.from({length:4});showMore=O(()=>this.allDashboards().length>0);activeDashboardName=O(()=>this.allDashboards().find(t=>t.id===this.activeTabId())?.name??"");activeConfig=O(()=>this.loadedDashboards().get(this.activeTabId())??null);isExporting=f(!1);showExportDropdown=f(!1);downloadMenuOpen=f(!1);creatingDashboard=f(!1);generationStreamId=f("");isGenerating=O(()=>this.generationStreamId()!=="");generationSettled=!1;showHeader(){return k().ui.header}features(){return k().features}copy(){return k().copy}service=w(pe);ngZone=w(ve);el=w(oe);navigator=w(B);routeProgress=w(Et);autoDashboard=w(qt);goToCreateDashboard(){this.creatingDashboard()||(this.creatingDashboard.set(!0),this.navigator.toAskAquera())}constructor(){ee(()=>{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 Le(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),r=this.activeDashboardName()||"Dashboard",s=90,g=new Nt({orientation:e>n?"landscape":"portrait",unit:"px",format:[e,n+s]});g.setFillColor(245,245,248),g.rect(0,0,e,s,"F"),g.setFont("helvetica","bold"),g.setFontSize(28),g.setTextColor(50,50,60),g.text(r,e/2,s/2+7,{align:"center"}),g.addImage(i,"JPEG",0,s,e,n),g.save(`${r}.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 Le(t,{quality:1,width:e,height:n,cacheBust:!0,backgroundColor:"#ffffff",style:{height:`${n}px`,maxHeight:"none",overflow:"visible"}}),r=this.activeDashboardName()||"Dashboard",s=90,g=document.createElement("canvas");g.width=e,g.height=n+s;let p=g.getContext("2d");p.fillStyle="#f5f5f8",p.fillRect(0,0,e,s),p.fillStyle="#32323c",p.font="bold 28px helvetica",p.textAlign="center",p.textBaseline="middle",p.fillText(r,e/2,s/2+7);let m=new Image;m.src=i,await new Promise(V=>{m.onload=()=>V()}),p.drawImage(m,0,s,e,n);let M=document.createElement("a");M.href=g.toDataURL("image/png"),M.download=`${r}.png`,M.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,$e);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){fe({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=f(!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<$e}isLastActiveDashboard(t){return this.activeTabs().length===1&&this.isInActiveTabs(t)}renamingDashboardId=f(null);renamingValue=f("");isRenamingDashboard=f(!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=r=>r.map(s=>s.id===t.id?E(x({},s),{name:n}):s);this.allDashboards.update(i),this.activeTabs.update(i),this.renamingDashboardId.set(null),this.renamingValue.set("")}),fe({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(r=>r.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||o)};static \u0275cmp=W({type:o,selectors:[["dvz-dashboards-page"]],viewQuery:function(e,n){if(e&1&&ae(En,5)(ye,5)(Ge,5),e&2){let i;Y(i=K())&&(n.tabsScrollerEl=i.first),Y(i=K())&&(n.dashboardViewerRef=i.first),Y(i=K())&&(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"],[1,"home-category-filter__panel",3,"mousedown"],[1,"home-category-filter__heading"],["type","button",1,"home-category-filter__item",3,"click"],[1,"home-category-filter__label"],["name","ng-check","size","14"],["type","button",1,"home-category-filter__item",3,"is-active"],["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&&(a(0,"div",4),y(1,qn,12,2,"div",5),y(2,Gn,6,3,"div",6),y(3,pi,9,5,"div",6),l(),G(4,hi,5,1,"ng-template",null,0,ue)(6,_i,7,0,"ng-template",null,1,ue)),e&2&&(c(),C(n.isLoading()?1:-1),c(),C(!n.isLoading()&&n.isGenerating()?2:-1),c(),C(!n.isLoading()&&!n.isGenerating()?3:-1))},dependencies:[Pe,ye,Re,ze,Ge],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;padding:6px;background:var(--ng-colors-bg-primary);border:1px solid var(--ng-colors-border-primary);border-radius:var(--ng-radius-lg);box-shadow:var(--ng-shadow-lg)}.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(o,t){o&1&&h(0,"dvz-dashboards-page")}var Ne=class o{config=Q(void 0);ready=_e({alias:"dvz-ready"});error=_e({alias:"dvz-error"});unauthorized=_e({alias:"dvz-unauthorized"});navigate=_e({alias:"dvz-navigate"});host=w(oe);navigator=w(B);destroyRef=w(Je);stopAdopting=null;stopTokenRefresh=null;stopUi=null;configured=!1;constructor(){ee(()=>{let t=this.config();t&&this.apply(t)}),this.navigator.requests.pipe(Ft(this.destroyRef)).subscribe(t=>this.navigate.emit(t)),queueMicrotask(()=>{let t=this.host.nativeElement.shadowRoot;t&&(this.stopAdopting=Ue(t))})}async apply(t){let e=t.auth,n=Bt({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=je(this.host.nativeElement,t.ui),yt(t.api.baseUrl),_t(t.api,e),vt({productId:t.tenant.productId,name:t.tenant.productName}),bt(()=>this.unauthorized.emit());let i=n;if(await mt(i),this.stopTokenRefresh??=ut(i),!this.configured){this.configured=!0;let r=k();this.ready.emit({customerId:r.customerId??"",productId:r.productId??""})}}ngOnDestroy(){this.stopAdopting?.(),this.stopTokenRefresh?.(),this.stopUi?.()}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=W({type:o,selectors:[["dvz-dashboards-root"]],inputs:{config:[1,"config"]},outputs:{ready:"dvz-ready",error:"dvz-error",unauthorized:"dvz-unauthorized",navigate:"dvz-navigate"},features:[se([B])],decls:1,vars:1,template:function(e,n){e&1&&y(0,fi,1,0,"dvz-dashboards-page"),e&2&&C(n.config()?0:-1)},dependencies:[Ve],styles:[`:host{display:block;height:100%;min-height:0}
|
|
2
|
-
`],encapsulation:3,changeDetection:0})};pt();var bi="dvz-dashboards";function yi(o={}){return gt(Ne,bi,[Xe(),ft(),lt(dt([xt])),{provide:wt,useFactory:()=>k().baseUrl},Mt(U),kt(A),St(A),Se(A),De(A),ke(A),Oe(A),Tt(A)],o)}yi();export{bi as a,yi as b};
|