deepspotscreen-sdk 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,980 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class ae{constructor(e,t){this.tokenCache=new Map,this.baseUrl=e.replace(/\/$/,""),this.apiKey=t}async getEmbedToken(e){var i,a,o,c;const t=[e.dashboardId,e.embedType,(i=e.embedLevel)!=null?i:"",(a=e.componentId)!=null?a:"",(o=e.userId)!=null?o:""].join(":"),s=this.tokenCache.get(t);if(s&&s.expiresAt>Date.now()+6e4)return s.token;const r=await this.post("/dashboard-builder/embed-token",{dashboardId:e.dashboardId,embedType:e.embedType,embedLevel:(c=e.embedLevel)!=null?c:"dashboard",componentId:e.componentId,userId:e.userId,tenantId:e.tenantId,expiresIn:3600},{"x-deepspot-api-key":this.apiKey});return this.tokenCache.set(t,{token:r.token,expiresAt:new Date(r.expiresAt).getTime()}),r.token}async getDashboardRender(e,t,s={}){var i;const r=new URLSearchParams({embedType:"dashboard",embedLevel:(i=s.embedLevel)!=null?i:"dashboard"});return s.pageId&&r.set("pageId",s.pageId),s.tabId&&r.set("tabId",s.tabId),s.filters&&Object.entries(s.filters).forEach(([a,o])=>{o!=null&&o!==""&&r.set(`filter[${a}]`,Array.isArray(o)?o.join(","):String(o))}),this.get(`/dashboard-builder/embed/${e}/render?${r}`,{"x-embed-token":t})}async getReportRender(e,t,s,r={}){const i=new URLSearchParams({embedType:"report",embedLevel:"report",componentId:t});return r.filters&&Object.entries(r.filters).forEach(([a,o])=>{o!=null&&o!==""&&i.set(`filter[${a}]`,Array.isArray(o)?o.join(","):String(o))}),this.get(`/dashboard-builder/embed/${e}/render?${i}`,{"x-embed-token":s})}async createApiKey(e,t){return this.post("/dashboard-builder/api-keys",e,{Authorization:`Bearer ${t}`})}async listApiKeys(e){return this.get("/dashboard-builder/api-keys",{Authorization:`Bearer ${e}`})}async deleteApiKey(e,t){await this.delete(`/dashboard-builder/api-keys/${e}`,{Authorization:`Bearer ${t}`})}async getTablePage(e,t,s,r,i){return this.get(`/dashboard-builder/embed/${e}/table/${t}/data?page=${s}&pageSize=${r}`,{"x-embed-token":i})}async getFilterOptions(e,t,s){try{const r=await this.get(`/dashboard-builder/embed/${e}/filters/${t}/options`,{"x-embed-token":s});return Array.isArray(r)?r:Array.isArray(r==null?void 0:r.options)?r.options:Array.isArray(r==null?void 0:r.data)?r.data:[]}catch(r){return[]}}clearTokenCache(){this.tokenCache.clear()}async get(e,t={}){const s=await fetch(`${this.baseUrl}${e}`,{method:"GET",headers:{"Content-Type":"application/json",...t}});return this.handleResponse(s)}async post(e,t,s={}){const r=await fetch(`${this.baseUrl}${e}`,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)});return this.handleResponse(r)}async delete(e,t={}){const s=await fetch(`${this.baseUrl}${e}`,{method:"DELETE",headers:{"Content-Type":"application/json",...t}});if(!s.ok)throw new Error(`Deepspot SDK: DELETE ${e} failed (${s.status})`)}async handleResponse(e){if(!e.ok){let s=`HTTP ${e.status}`;try{const r=await e.json();s=(r==null?void 0:r.message)||(r==null?void 0:r.error)||s}catch(r){}throw new Error(`Deepspot SDK: ${s}`)}const t=await e.json();return(t==null?void 0:t.data)!==void 0?t.data:t}}class Z{constructor(e){var t,s;this.destroyed=!1,this.refreshTimer=null,this.opts=e,this.filters={...e.activeFilters},this.activePageId=(t=e.activePageId)!=null?t:"",this.activeTabId=(s=e.activeTabId)!=null?s:""}getActiveFilters(){return{...this.filters}}setFilter(e,t){this.filters[e]=t,this.scheduleRefresh()}setFilters(e){Object.assign(this.filters,e),this.scheduleRefresh()}setGlobalFilter(e,t){this.setFilter(e,t)}clearFilters(){this.filters={},this.scheduleRefresh()}goToPage(e){this.opts.embedType==="dashboard"&&(this.activePageId=e,this.opts.renderer.goToPage(e))}goToTab(e,t){this.opts.embedType==="dashboard"&&(this.activePageId=e,this.activeTabId=t,this.opts.renderer.goToTab(e,t))}async refresh(){if(!this.destroyed)try{const e=await this.fetchData();this.opts.renderer.update(e)}catch(e){console.error("Deepspot SDK: refresh failed",e)}}exportPDF(){this.opts.embedType==="dashboard"&&this.opts.renderer.exportPDF()}destroy(){this.destroyed=!0,this.refreshTimer&&clearTimeout(this.refreshTimer),this.opts.renderer.destroy(),this.opts.apiClient.clearTokenCache()}scheduleRefresh(){this.refreshTimer&&clearTimeout(this.refreshTimer),this.refreshTimer=setTimeout(()=>this.refresh(),300)}async fetchData(){const{apiClient:e,dashboardId:t,componentId:s,token:r,embedType:i,embedLevel:a}=this.opts;return i==="report"&&s?e.getReportRender(t,s,r,{filters:this.filters}):e.getDashboardRender(t,r,{embedLevel:a,pageId:this.activePageId||void 0,tabId:this.activeTabId||void 0,filters:this.filters})}}const oe=24,A=10,D=12;class Q{constructor(e,t=0){this.containerWidth=e,this.minY=t}get colWidth(){return this.containerWidth/oe}toPx(e){const t=this.colWidth,s=D/2;return{left:e.x*t+s,top:(e.y-this.minY)*A+s,width:e.w*t-D,height:e.h*A-D}}static totalHeight(e){if(!e.length)return 400;const t=Math.min(...e.map(r=>r.y));return(Math.max(...e.map(r=>r.y+r.h))-t)*A+40}applyStyles(e,t){const s=this.toPx(t);e.style.position="absolute",e.style.left=`${s.left}px`,e.style.top=`${s.top}px`,e.style.width=`${s.width}px`,e.style.height=`${s.height}px`}}let j=null;function de(){return j||(j=Promise.resolve().then(()=>require("./apexcharts.common-DGzslxI3.cjs")).then(k=>k.apexcharts_common)),j}class se{constructor(e){this.chart=null,this.container=e}async render(e,t,s,r){if(!t||t.length===0){this.renderEmpty(e.title);return}const i=this.buildOptions(e,t,s,r);if(!i){this.renderEmpty(e.title);return}this.container.innerHTML=`
2
- <div class="ds-chart-card">
3
- <div class="ds-chart-title">${e.title||""}</div>
4
- <div class="ds-chart-body" id="ds-chart-body-${e.id}"></div>
5
- </div>
6
- `;const a=this.container.querySelector(`#ds-chart-body-${e.id}`);if(a)try{this.chart&&this.chart.destroy();const{default:o}=await de();this.chart=new o(a,i),this.chart.render()}catch(o){console.error("[Deepspot SDK] ChartRenderer error:",o),a.innerHTML='<div class="ds-chart-empty">Chart render error</div>'}}async update(e,t,s){if(!this.chart||!t||t.length===0){await this.render(e,t,s);return}const{series:r,categories:i}=this.extractSeriesAndCategories(e,t);try{this.chart.updateOptions({series:r,xaxis:{categories:i},theme:{mode:s}})}catch(a){this.render(e,t,s)}}destroy(){var e;try{(e=this.chart)==null||e.destroy()}catch(t){}this.chart=null}buildOptions(e,t,s,r){const i=e.type;return i==="pie"||i==="donut"?this.buildPieOptions(e,t,s,r):i==="bar"||i==="line"||i==="area"?this.buildCartesianOptions(e,t,s,r):null}buildCartesianOptions(e,t,s,r){var h;const{series:i,categories:a,xAxisLabel:o,yAxisLabel:c,seriesColors:d}=this.extractSeriesAndCategories(e,t),f=e.properties||{},g=["#4f46e5","#10b981","#f59e0b","#ef4444","#3b82f6","#8b5cf6","#ec4899","#14b8a6"];let u;if(d.length>0&&d.length===i.length)u=d;else{const b=f.colors?Object.values(f.colors).filter(Boolean):[];u=b.length>0?b:g}const n=s==="dark";return{chart:{type:e.type==="area"?"area":e.type==="line"?"line":"bar",toolbar:{show:!1},background:"transparent",animations:{enabled:!0,speed:400},fontFamily:"inherit",height:r!=null?r:"100%"},theme:{mode:s},series:i,xaxis:{categories:a,title:{text:o},labels:{rotate:a.length>8?-45:0,style:{colors:n?"#94a3b8":"#6b7280",fontSize:"11px"}},axisBorder:{color:n?"#334155":"#e5e7eb"},axisTicks:{color:n?"#334155":"#e5e7eb"}},yaxis:{title:{text:c},labels:{style:{colors:n?"#94a3b8":"#6b7280",fontSize:"11px"}}},colors:u,legend:{show:i.length>1||((h=f.showLegend)!=null?h:!1),position:"bottom",labels:{colors:n?"#94a3b8":"#6b7280"}},grid:{borderColor:n?"#1e293b":"#f3f4f6",strokeDashArray:4,padding:{bottom:a.length>8?60:10}},tooltip:{theme:s},stroke:{curve:"smooth",width:e.type==="bar"?0:2},fill:e.type==="area"?{type:"gradient",gradient:{shadeIntensity:.5,opacityFrom:.4,opacityTo:0}}:{},dataLabels:{enabled:!1},plotOptions:{bar:{borderRadius:4,distributed:i.length===1}}}}buildPieOptions(e,t,s,r){const i=e.properties||{},a=t.length>0?Object.keys(t[0]):[],o=a[0]||"label",c=a[1]||"value",d=t.map(b=>{var l;return String((l=b[o])!=null?l:"")}),f=t.map(b=>Number(b[c])||0),g=s==="dark",u=["#4f46e5","#10b981","#f59e0b","#ef4444","#3b82f6","#8b5cf6","#ec4899","#14b8a6"],n=i.colors?Object.values(i.colors).filter(Boolean):[],h=n.length>0?n:u;return{chart:{type:e.type,toolbar:{show:!1},background:"transparent",fontFamily:"inherit",height:r!=null?r:"100%"},theme:{mode:s},series:f,labels:d,colors:h,legend:{position:"bottom",labels:{colors:g?"#94a3b8":"#6b7280"}},tooltip:{theme:s},dataLabels:{enabled:d.length<=8},plotOptions:{pie:{donut:{size:e.type==="donut"?"65%":"0%"}}}}}extractSeriesAndCategories(e,t){const s=e.properties||{},r=t.length>0?Object.keys(t[0]):[],i=s.xAxis||r[0]||"x";let a=[];if(s.selectedYAxisColumn)try{const n=typeof s.selectedYAxisColumn=="string"?JSON.parse(s.selectedYAxisColumn):s.selectedYAxisColumn;Array.isArray(n)&&(a=n.map(h=>typeof h=="string"?{column:h}:h))}catch(n){}if(!a.length&&s.yAxis){const n=s.yAxis;a=(Array.isArray(n)?n:[n]).map(b=>({column:String(b)}))}!a.length&&r.length>1&&(a=r.slice(1).map(n=>({column:n})));const o=t.map(n=>{var h;return String((h=n[i])!=null?h:"")}),c=t.length>0?Object.keys(t[0]):[],d=a.map(n=>{const h=c.includes(n.column)?n.column:null,b=h?null:c.find(p=>p.includes(n.column)||n.column.includes(p)),l=!h&&!b?c.find(p=>{var y;return p!==i&&!isNaN(Number((y=t[0])==null?void 0:y[p]))}):null,m=h||b||l||n.column;return{name:n.column,data:t.map(p=>{const y=p[m];return y!=null?Number(y):null})}}),f=a.map(n=>n.color||n.colorHex||"").filter(Boolean),g=s.xAxisLabel||i,u=s.yAxisLabel||(a.length===1?a[0].column:"");return{series:d,categories:o,xAxisLabel:g,yAxisLabel:u,seriesColors:f}}renderEmpty(e){this.container.innerHTML=`
7
- <div class="ds-chart-card">
8
- ${e?`<div class="ds-chart-title">${e}</div>`:""}
9
- <div class="ds-chart-empty">No data available</div>
10
- </div>
11
- `}}class re{constructor(){this.columns=[],this.allData=[],this.currentRows=[],this.totalRows=0,this.currentPage=1,this.currentPageSize=10,this.searchTerm="",this.isLoading=!1}render(e,t,s,r){var f;this.container=e,this.component=t,this.fetchPage=r,this.searchTerm="",this.currentPage=1,this.currentPageSize=10;const i=s&&!Array.isArray(s)&&"rows"in s;if(i){const g=s;this.currentRows=g.rows,this.allData=[],this.totalRows=g.total,this.currentPage=g.page,this.currentPageSize=g.pageSize}else this.allData=s||[],this.currentRows=[],this.totalRows=this.allData.length,this.currentPage=1;if(i&&s.rows.length===0&&s.total===0||!i&&this.allData.length===0){e.innerHTML=`
12
- <div class="ds-table-card">
13
- <div class="ds-table-header-row">
14
- <span class="ds-table-dot"></span>
15
- <div class="ds-table-title">${this.escape(t.title||"")}</div>
16
- </div>
17
- <div class="ds-chart-empty">No data available</div>
18
- </div>
19
- `;return}const a=i?s.rows[0]:this.allData[0],o=a?Object.keys(a):[],c=((f=t.properties)==null?void 0:f.columns)||[],d=c.length?c.filter(g=>o.includes(g)):[];this.columns=d.length?d:o,this.paint()}paint(){const{rows:e,startNum:t}=this.getPageRows(),s=Math.max(1,Math.ceil(this.totalRows/this.currentPageSize)),r=(this.currentPage-1)*this.currentPageSize+1,i=this.fetchPage?Math.min(r-1+(this.isLoading?this.currentPageSize:e.length),this.totalRows):Math.min(this.currentPage*this.currentPageSize,this.totalRows),a=this.columns.map(u=>`<th>${this.escape(this.formatHeader(u))}</th>`).join(""),o=e.length===0?`<tr><td colspan="${this.columns.length+1}" style="text-align:center;padding:20px;color:#9ca3af">No results found</td></tr>`:e.map((u,n)=>{const h=this.columns.map(b=>{const l=u[b];return`<td title="${this.escape(String(l!=null?l:""))}">${this.escape(this.formatValue(l))}</td>`}).join("");return`<tr><td class="ds-table-sno">${t+n}</td>${h}</tr>`}).join(""),c=this.currentPageSize,d=[10,25,50,100].map(u=>`<option value="${u}"${u===c?" selected":""}>${u}</option>`).join(""),f=this.currentPage<=1,g=this.currentPage>=s;this.container.innerHTML=`
20
- <div class="ds-table-card">
21
- <div class="ds-table-header-row">
22
- <div class="ds-table-title-wrap">
23
- <span class="ds-table-dot"></span>
24
- <span class="ds-table-title">${this.escape(this.component.title||"")}</span>
25
- </div>
26
- </div>
27
- <div class="ds-table-scroll">
28
- <table class="ds-table">
29
- <thead><tr><th class="ds-table-sno-th">S.No</th>${a}</tr></thead>
30
- <tbody>${o}</tbody>
31
- </table>
32
- </div>
33
- <div class="ds-table-footer">
34
- <div class="ds-table-info">
35
- <span>${r.toLocaleString()}–${i.toLocaleString()} of ${this.totalRows.toLocaleString()}</span>
36
- <span class="ds-table-rows-label">Rows:</span>
37
- <select class="ds-table-page-size">${d}</select>
38
- </div>
39
- <div class="ds-table-pagination">
40
- <button class="ds-table-pg-btn" data-action="first" ${f?"disabled":""}>&#171;</button>
41
- <button class="ds-table-pg-btn" data-action="prev" ${f?"disabled":""}>Previous</button>
42
- <span class="ds-table-pg-info">Page ${this.currentPage} of ${s}</span>
43
- <button class="ds-table-pg-btn" data-action="next" ${g?"disabled":""}>Next</button>
44
- <button class="ds-table-pg-btn" data-action="last" ${g?"disabled":""}>&#187;</button>
45
- </div>
46
- </div>
47
- ${this.isLoading?'<div class="ds-table-loading-overlay"><div class="ds-embed-spinner"></div></div>':""}
48
- </div>
49
- `,this.attachEvents()}attachEvents(){const e=this.container.querySelector(".ds-table-search");e==null||e.addEventListener("input",()=>{this.searchTerm=e.value,this.currentPage=1,this.fetchPage||(this.totalRows=this.filteredRows().length,this.paint())});const t=this.container.querySelector(".ds-table-page-size");t==null||t.addEventListener("change",()=>{this.currentPageSize=parseInt(t.value,10),this.currentPage=1,this.fetchPage?this.loadPage(1):(this.totalRows=this.filteredRows().length,this.paint())}),this.container.querySelectorAll("[data-action]").forEach(s=>{s.addEventListener("click",()=>{if(s.disabled)return;const r=Math.max(1,Math.ceil(this.totalRows/this.currentPageSize)),i=s.dataset.action;let a=this.currentPage;i==="first"?a=1:i==="prev"?a=Math.max(1,this.currentPage-1):i==="next"?a=Math.min(r,this.currentPage+1):i==="last"&&(a=r),(a!==this.currentPage||i==="first"||i==="last")&&(this.currentPage=a,this.fetchPage?this.loadPage(a):this.paint())})})}async loadPage(e){if(this.fetchPage){this.isLoading=!0,this.currentPage=e,this.paint();try{const t=await this.fetchPage(e,this.currentPageSize);this.currentRows=t.rows||[],this.totalRows=Number(t.total)||this.currentRows.length,this.currentPage=Number(t.page)||e}catch(t){console.error("[Deepspot SDK] TableRenderer: page fetch failed",t)}finally{this.isLoading=!1,this.paint()}}}getPageRows(){const e=(this.currentPage-1)*this.currentPageSize+1;if(this.fetchPage)return{rows:this.currentRows,startNum:e};const t=this.filteredRows(),s=(this.currentPage-1)*this.currentPageSize;return{rows:t.slice(s,s+this.currentPageSize),startNum:e}}filteredRows(){if(!this.searchTerm)return this.allData;const e=this.searchTerm.toLowerCase();return this.allData.filter(t=>this.columns.some(s=>{var r;return String((r=t[s])!=null?r:"").toLowerCase().includes(e)}))}formatHeader(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}formatValue(e){return e==null?"—":typeof e=="number"?e%1===0?e.toLocaleString():e.toFixed(2):String(e)}escape(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}class ie{render(e,t,s){var h;const r=t.properties||{};let i=null;if(s&&s.length>0){const b=s[0],l=r.metric||Object.keys(b)[0],m=b[l];if(m!==void 0)i=m;else{const p=Object.keys(b).find(y=>y.includes(l)||l.includes(y));i=b[p!=null?p:Object.keys(b)[0]]}}let a;if(i==null)try{const b=(h=r==null?void 0:r.data)==null?void 0:h.dataContent,l=b?typeof b=="string"?JSON.parse(b):b:null;a=l!=null&&l.value?String(l.value):"—"}catch(b){a="—"}else a=this.formatValue(i,r);const o=r.styleConfig||{},c=o.backgroundColor||r.backgroundColor||"",d=o.color||o.textColor||r.textColor||"",f=t.title||"",g=c?`background:${c};border:none;`:"",u=d?`color:${d};`:"",n=d?`color:${d};opacity:0.7;`:"";e.innerHTML=`
50
- <div class="ds-card"${g?` style="${g}"`:""}>
51
- <div class="ds-card-label"${n?` style="${n}"`:""}>${f}</div>
52
- <div class="ds-card-value"${u?` style="${u}"`:""}>${a}</div>
53
- </div>
54
- `}formatValue(e,t){if(e==null)return"—";const s=Number(e);if(isNaN(s))return String(e);const r=(t==null?void 0:t.prefix)||(t==null?void 0:t.currencySymbol)||"",i=(t==null?void 0:t.suffix)||"",a=s%1===0?s.toLocaleString():parseFloat(s.toFixed(2)).toLocaleString();return`${r}${a}${i}`}}class ne{constructor(e,t){this.currentValues={},this.container=e,this.onFilterChange=t}render(e,t={}){if(!e||e.length===0){this.container.style.display="none";return}this.container.style.display="",this.currentValues={...t},this.container.innerHTML=`<div class="ds-filter-bar">${e.map(s=>this.renderFilter(s,t[s.applyToField||s.filterId])).join("")}</div>`,this.attachListeners(e)}updateOptions(e,t){const s=this.container.querySelector(`select[data-filter-id="${e}"]`);if(!s)return;const r=s.value;s.innerHTML='<option value="">All</option>'+t.map(i=>`<option value="${this.escAttr(i)}">${this.escText(i)}</option>`).join(""),r&&t.includes(r)&&(s.value=r)}updateValues(e){Object.assign(this.currentValues,e),Object.entries(e).forEach(([t,s])=>{const r=this.container.querySelector(`[data-filter-id="${t}"]`);r&&s!==void 0&&(r.value=String(s))})}renderFilter(e,t){const s=`ds-filter-${e.filterId}`,r=`<label class="ds-filter-label" for="${s}">${e.label}</label>`;switch(e.type){case"dropdown":return`
55
- <div class="ds-filter-item">
56
- ${r}
57
- <select class="ds-filter-select" id="${s}" data-filter-id="${e.filterId}">
58
- <option value="">All</option>
59
- ${(e.options||[]).map(o=>`
60
- <option value="${this.escAttr(o)}" ${t===o?"selected":""}>
61
- ${this.escText(o)}
62
- </option>
63
- `).join("")}
64
- </select>
65
- </div>`;case"multi-select":return`
66
- <div class="ds-filter-item">
67
- ${r}
68
- <select class="ds-filter-select" id="${s}" data-filter-id="${e.filterId}" multiple size="1">
69
- ${(e.options||[]).map(o=>`
70
- <option value="${this.escAttr(o)}">${this.escText(o)}</option>
71
- `).join("")}
72
- </select>
73
- </div>`;case"date-range":const i=(t==null?void 0:t.from)||"",a=(t==null?void 0:t.to)||"";return`
74
- <div class="ds-filter-item">
75
- ${r}
76
- <div class="ds-date-range-inputs">
77
- <input type="date" class="ds-filter-input"
78
- data-filter-id="${e.filterId}" data-date-part="from"
79
- value="${i}" />
80
- <span>–</span>
81
- <input type="date" class="ds-filter-input"
82
- data-filter-id="${e.filterId}" data-date-part="to"
83
- value="${a}" />
84
- </div>
85
- </div>`;case"text-input":return`
86
- <div class="ds-filter-item">
87
- ${r}
88
- <input type="text" class="ds-filter-input" id="${s}"
89
- data-filter-id="${e.filterId}"
90
- value="${this.escAttr(String(t!=null?t:""))}"
91
- placeholder="Search..." />
92
- </div>`;case"number-input":return`
93
- <div class="ds-filter-item">
94
- ${r}
95
- <input type="number" class="ds-filter-input" id="${s}"
96
- data-filter-id="${e.filterId}"
97
- value="${this.escAttr(String(t!=null?t:""))}" />
98
- </div>`;default:return""}}attachListeners(e){const t={};this.container.querySelectorAll("[data-filter-id]").forEach(s=>{const r=s.dataset.filterId,i=s.dataset.datePart,a=e.find(c=>c.filterId===r),o=()=>{let c;if((a==null?void 0:a.type)==="date-range"&&i)t[r]=t[r]||{},t[r][i]=s.value,c={...t[r]};else if((a==null?void 0:a.type)==="multi-select"){const d=s;c=Array.from(d.selectedOptions).map(f=>f.value).filter(Boolean)}else c=s.value;this.currentValues[r]=c,this.onFilterChange(r,c)};s.addEventListener((a==null?void 0:a.type)==="text-input"?"input":"change",o)})}escAttr(e){return String(e!=null?e:"").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}escText(e){return String(e!=null?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}const E=class E{constructor(e,t){this.activePageId="",this.activeTabId="",this.activeFilters={},this.chartRenderers=new Map,this.tableRenderer=new re,this.cardRenderer=new ie,this.isLoadingTab=!1,this.tooltipEl=null,this.root=e,this.opts=t,this.activeFilters={...t.initialFilters}}render(e){var t,s;this.renderData=e,this.activePageId=e.activePage,this.activeTabId=e.activeTab,this.buildShell(),this.renderNavigation(),this.renderFilterBar(),this.renderGrid(),(s=(t=this.opts).onReady)==null||s.call(t)}update(e){this.renderData=e,this.activePageId=e.activePage,this.activeTabId=e.activeTab,this.isLoadingTab=!1,this.syncNavHighlight(),this.updateFilterBar(),this.renderGrid()}goToPage(e){const t=this.getTabsForPage(e)[0];t&&this.triggerTabSwitch(e,t.id)}goToTab(e,t){this.triggerTabSwitch(e,t)}destroy(){this.chartRenderers.forEach(e=>e.destroy()),this.chartRenderers.clear(),this.root.innerHTML=""}exportPDF(){var u,n;const e=this.root.querySelector("#ds-grid");if(!e)return;const t=this.root.style.height,s=this.root.style.overflow;this.root.style.height="auto",this.root.style.overflow="visible";const r=this.root.querySelector("#ds-canvas"),i=(u=r==null?void 0:r.style.height)!=null?u:"",a=(n=r==null?void 0:r.style.overflow)!=null?n:"";r&&(r.style.height="auto",r.style.overflow="visible");const o=Array.from(e.querySelectorAll(".ds-table-scroll")),c=o.map(h=>({el:h,overflow:h.style.overflow,maxHeight:h.style.maxHeight,height:h.style.height}));o.forEach(h=>{h.style.overflow="visible",h.style.maxHeight="none",h.style.height="auto"});const d=e.offsetWidth,f=parseInt(e.style.height,10)||e.offsetHeight,g=e.getBoundingClientRect().top+window.scrollY;Promise.resolve().then(()=>require("./html2canvas.esm-EoNFmhrp.cjs")).then(({default:h})=>h(e,{scale:2,useCORS:!0,allowTaint:!0,logging:!1,width:d,height:f,windowWidth:d,windowHeight:f,scrollX:0,scrollY:-g}).then(b=>{this.root.style.height=t,this.root.style.overflow=s,r&&(r.style.height=i,r.style.overflow=a),c.forEach(({el:l,overflow:m,maxHeight:p,height:y})=>{l.style.overflow=m,l.style.maxHeight=p,l.style.height=y}),Promise.resolve().then(()=>require("./jspdf.es.min-D6GjoB2T.cjs")).then(l=>l.jspdf_es_min).then(({jsPDF:l})=>{const m=b.width/2,p=b.height/2,y=new l({orientation:m>=p?"landscape":"portrait",unit:"px",format:[m,p]});y.addImage(b.toDataURL("image/png"),"PNG",0,0,m,p),y.save(`${this.renderData.dashboard.name||"dashboard"}.pdf`)})}))}exportCSV(){this.renderData.components.forEach(e=>{const t=this.renderData.data[e.id];if(!(t!=null&&t.length)||!["table","bar","line","area"].includes(e.type))return;const s=Object.keys(t[0]),r=[s.join(","),...t.map(a=>s.map(o=>{var c;return JSON.stringify((c=a[o])!=null?c:"")}).join(","))].join(`
99
- `);Object.assign(document.createElement("a"),{href:URL.createObjectURL(new Blob([r],{type:"text/csv"})),download:`${e.title||e.id}.csv`}).click()})}updateFilterValues(e){var t;Object.assign(this.activeFilters,e),(t=this.filterRenderer)==null||t.updateValues(e)}buildShell(){const e=this.opts.embedLevel,t=this.renderData.dashboard.pages,s=e==="dashboard"&&t.length>1,r=e==="page"||e==="dashboard";this.root.innerHTML=`
100
- ${this.opts.hideExport?"":'<div class="ds-toolbar" id="ds-toolbar"></div>'}
101
- ${s?'<nav class="ds-page-nav" id="ds-page-nav"></nav>':""}
102
- ${r?'<nav class="ds-page-nav" id="ds-tab-nav"></nav>':""}
103
- <div id="ds-filter-container"></div>
104
- <div class="ds-canvas" id="ds-canvas">
105
- <div class="ds-grid" id="ds-grid"></div>
106
- </div>
107
- <div id="ds-tab-loading" style="display:none;position:absolute;inset:0;
108
- background:rgba(255,255,255,0.5);align-items:center;justify-content:center;">
109
- <div class="ds-embed-spinner"></div>
110
- </div>
111
- `,this.root.style.position="relative",this.opts.hideExport||this.buildExportToolbar();const i=this.root.querySelector("#ds-filter-container");this.filterRenderer=new ne(i,(a,o)=>{var g,u,n,h,b;const c=(g=this.renderData.filters)==null?void 0:g.find(l=>l.filterId===a),d=(u=this.renderData.components)==null?void 0:u.find(l=>l.type==="inline-filter"&&l.id===a),f=(c==null?void 0:c.applyToField)||((n=d==null?void 0:d.properties)==null?void 0:n.applyToField)||a;this.activeFilters[f]=o,(b=(h=this.opts).onFilterChange)==null||b.call(h,this.activeFilters),this.opts.onTabSwitch(this.activePageId,this.activeTabId)})}buildExportToolbar(){var t,s;const e=this.root.querySelector("#ds-toolbar");e&&(e.innerHTML=`
112
- <button class="ds-toolbar-btn" id="ds-btn-pdf">⬇ PDF</button>
113
- <button class="ds-toolbar-btn" id="ds-btn-csv" style="display:none">⬇ CSV</button>
114
- `,(t=e.querySelector("#ds-btn-pdf"))==null||t.addEventListener("click",()=>this.exportPDF()),(s=e.querySelector("#ds-btn-csv"))==null||s.addEventListener("click",()=>this.exportCSV()))}renderNavigation(){this.renderPageNav(),this.renderTabNav(this.activePageId)}renderPageNav(){const e=this.root.querySelector("#ds-page-nav");e&&(e.innerHTML=this.renderData.dashboard.pages.map(t=>`
115
- <button class="ds-page-tab ${t.pageId===this.activePageId?"ds-active":""}"
116
- data-page-id="${t.pageId}">${t.title}</button>
117
- `).join(""),e.querySelectorAll(".ds-page-tab").forEach(t=>{t.addEventListener("click",()=>{var r,i;const s=t.dataset.pageId;s===this.activePageId&&!this.isLoadingTab||this.triggerTabSwitch(s,(i=(r=this.getTabsForPage(s)[0])==null?void 0:r.id)!=null?i:"")})}))}renderTabNav(e){const t=this.root.querySelector("#ds-tab-nav");t&&this.buildTabButtons(t,e)}buildTabButtons(e,t){const s=this.getTabsForPage(t);if(s.length<=1){e.style.display="none";return}e.style.display="",e.innerHTML=s.map(r=>`
118
- <button class="ds-page-tab ${r.id===this.activeTabId?"ds-active":""}"
119
- data-tab-id="${r.id}" data-page-id="${t}">${r.title}</button>
120
- `).join(""),e.querySelectorAll(".ds-page-tab").forEach(r=>{r.addEventListener("click",()=>{const i=r.dataset.tabId,a=r.dataset.pageId;i===this.activeTabId&&a===this.activePageId&&!this.isLoadingTab||this.triggerTabSwitch(a,i)})})}triggerTabSwitch(e,t){this.isLoadingTab||!e||!t||(this.isLoadingTab=!0,this.activePageId=e,this.activeTabId=t,this.syncNavHighlight(),this.showTabSpinner(),this.opts.onTabSwitch(e,t))}syncNavHighlight(){this.root.querySelectorAll("#ds-page-nav .ds-page-tab").forEach(t=>{t.classList.toggle("ds-active",t.dataset.pageId===this.activePageId)});const e=this.root.querySelector("#ds-tab-nav");e&&this.buildTabButtons(e,this.activePageId)}renderFilterBar(){if(this.opts.hideGlobalFilters)return;const e=[...this.renderData.filters||[],...this.inlineFiltersAsDefinitions()];this.filterRenderer.render(e,this.activeFilters),this.fetchFilterOptions()}updateFilterBar(){if(this.opts.hideGlobalFilters)return;const e=[...this.renderData.filters||[],...this.inlineFiltersAsDefinitions()];this.filterRenderer.render(e,this.activeFilters),this.fetchFilterOptions()}inlineFiltersAsDefinitions(){return this.opts.hideInlineFilters?[]:(this.renderData.components||[]).filter(e=>e.type==="inline-filter").map(e=>{var t,s,r,i,a,o,c,d;return{filterId:e.id,label:((t=e.properties)==null?void 0:t.filterLabel)||e.title||"",type:((s=e.properties)==null?void 0:s.filterType)||"dropdown",options:((r=e.properties)==null?void 0:r.filterOptions)||((i=e.properties)==null?void 0:i.options)||[],defaultValue:(a=e.properties)==null?void 0:a.defaultValue,targetComponents:((o=e.properties)==null?void 0:o.targetComponents)||[],filterOperator:(c=e.properties)==null?void 0:c.filterOperator,applyToField:((d=e.properties)==null?void 0:d.applyToField)||e.id}})}async fetchFilterOptions(){if(this.opts.onFetchFilterOptions)for(const e of this.renderData.filters){if(e.type!=="dropdown"&&e.type!=="multi-select"||e.options&&e.options.length>0)continue;const t=await this.opts.onFetchFilterOptions(e.filterId);t.length>0&&this.filterRenderer.updateOptions(e.filterId,t)}}renderGrid(){this.hideTabSpinner();const e=this.root.querySelector("#ds-grid");if(!e)return;if(!this.opts.hideBackground){const d=this.root.querySelector("#ds-canvas"),f=this.renderData.dashboard.pages.find(u=>u.pageId===this.activePageId),g=(f==null?void 0:f.backgroundColor)||"";d&&(d.style.background=g),this.root.style.background=g}this.chartRenderers.forEach(d=>d.destroy()),this.chartRenderers.clear();const t=(this.renderData.components||[]).filter(d=>d.type!=="inline-filter");if(!t.length){e.style.height="200px",e.innerHTML='<div class="ds-chart-empty" style="padding-top:80px;">No components on this tab.</div>';return}const s=e.clientWidth||this.root.clientWidth||800,r=t.map(d=>d.position),i=r.length?Math.min(...r.map(d=>d.y)):0,a=new Q(s,i);e.style.height=`${Q.totalHeight(r)}px`,e.innerHTML="";const o=36,c=[];t.forEach(d=>{var b,l,m;const f=document.createElement("div");if(f.className="ds-component-wrapper",f.dataset.componentId=d.id,a.applyStyles(f,d.position),!this.opts.hideBackground){const p=((l=(b=d.properties)==null?void 0:b.styleConfig)==null?void 0:l.backgroundColor)||((m=d.properties)==null?void 0:m.backgroundColor);p&&(f.style.background=p)}e.appendChild(f);const g=a.toPx(d.position),u=Math.max(50,g.height-o),n=document.createElement("div");n.style.cssText="width:100%;height:100%;",f.appendChild(n);const h=this.getComponentDescription(d);if(h){const p=this.getTooltipEl();f.addEventListener("mouseenter",()=>{p.textContent=h,p.style.display="block";const y=f.getBoundingClientRect(),S=p.offsetHeight||36;window.innerHeight-y.bottom>=S+6?p.style.top=`${y.bottom+4}px`:p.style.top=`${y.top-S-4}px`,p.style.left=`${y.left}px`,p.style.width=`${y.width}px`}),f.addEventListener("mouseleave",()=>{p.style.display="none"})}c.push(this.renderComponent(n,d,u).catch(p=>{console.error(`[Deepspot SDK] Failed to render component ${d.id} (${d.type}):`,p),n.innerHTML=`<div style="padding:8px;color:#ef4444;font-size:12px;">⚠ ${d.type} render error</div>`}))}),Promise.all(c).catch(()=>{})}async renderComponent(e,t,s){var a,o,c,d,f,g,u,n,h,b,l,m,p,y,S,C,I,L,R,P,O,H,M,N,B,K,q,G,U,W,_,Y,J,V,X;const r=this.renderData.data[t.id]||[],i=this.opts.theme;switch(t.type){case"bar":case"line":case"pie":case"donut":case"area":case"scatter":case"stacked-bar":{const w=new se(e);await w.render(t,r,i,s),this.chartRenderers.set(t.id,w);break}case"table":{const w=this.opts.onFetchTablePage?(v,T)=>this.opts.onFetchTablePage(t.id,v,T):void 0;this.tableRenderer.render(e,t,r,w);break}case"number-card":this.cardRenderer.render(e,t,r);break;case"text-heading":{if(this.opts.hideText)break;const w=((o=(a=t.properties)==null?void 0:a.data)==null?void 0:o.dataContent)||((c=t.properties)==null?void 0:c.content)||t.title||"",v=((d=t.properties)==null?void 0:d.styleConfig)||{},T=this.scToInlineStyle(v),x=this.opts.hideBackground?{}:this.parseTwColor((g=(f=t.properties)==null?void 0:f.color)!=null?g:""),$=[[x.bg?`background:${x.bg}`:"",x.text?`color:${x.text}`:""].filter(Boolean).join(";"),T].filter(Boolean).join(";");e.innerHTML=`<div class="ds-text-heading" style="${$}">${w}</div>`;break}case"text-subheading":{if(this.opts.hideText)break;const w=((n=(u=t.properties)==null?void 0:u.data)==null?void 0:n.dataContent)||((h=t.properties)==null?void 0:h.content)||t.title||"",v=((b=t.properties)==null?void 0:b.styleConfig)||{},T=this.scToInlineStyle(v),x=this.opts.hideBackground?{}:this.parseTwColor((m=(l=t.properties)==null?void 0:l.color)!=null?m:""),$=[[x.bg?`background:${x.bg}`:"",x.text?`color:${x.text}`:""].filter(Boolean).join(";"),T].filter(Boolean).join(";");e.innerHTML=`<div class="ds-text-subheading" style="${$}">${w}</div>`;break}case"text-body":{if(this.opts.hideText)break;const w=((y=(p=t.properties)==null?void 0:p.data)==null?void 0:y.dataContent)||((S=t.properties)==null?void 0:S.content)||"",v=((C=t.properties)==null?void 0:C.styleConfig)||{},T=this.scToInlineStyle(v),x=this.opts.hideBackground?{}:this.parseTwColor((L=(I=t.properties)==null?void 0:I.color)!=null?L:""),$=[[x.bg?`background:${x.bg}`:"",x.text?`color:${x.text}`:""].filter(Boolean).join(";"),T].filter(Boolean).join(";");e.innerHTML=`<div class="ds-text-body" style="${$}">${w}</div>`;break}case"text-box":{if(this.opts.hideText)break;const w=((P=(R=t.properties)==null?void 0:R.data)==null?void 0:P.dataContent)||((O=t.properties)==null?void 0:O.content)||"",v=((H=t.properties)==null?void 0:H.styleConfig)||{},T=this.scToInlineStyle(v),x=this.opts.hideBackground?{}:this.parseTwColor((N=(M=t.properties)==null?void 0:M.color)!=null?N:""),$=[[x.bg?`background:${x.bg}`:"",x.text?`color:${x.text}`:""].filter(Boolean).join(";"),T].filter(Boolean).join(";");e.innerHTML=`<div class="ds-text-box" style="${$}">${w}</div>`;break}case"text":{if(this.opts.hideText)break;const w=((K=(B=t.properties)==null?void 0:B.data)==null?void 0:K.dataContent)||((q=t.properties)==null?void 0:q.content)||"",v=((G=t.properties)==null?void 0:G.styleConfig)||{},T=this.scToInlineStyle(v),x=this.opts.hideBackground?{}:this.parseTwColor((W=(U=t.properties)==null?void 0:U.color)!=null?W:""),$=[[x.bg?`background:${x.bg}`:"",x.text?`color:${x.text}`:""].filter(Boolean).join(";"),T].filter(Boolean).join(";");e.innerHTML=`<div class="ds-text-body" style="${$}">${w}</div>`;break}case"header":{if(this.opts.hideHeader)break;const w=((Y=(_=t.properties)==null?void 0:_.data)==null?void 0:Y.dataContent)||((J=t.properties)==null?void 0:J.content)||t.title||"",v=((V=t.properties)==null?void 0:V.styleConfig)||{},T=!this.opts.hideBackground&&v.backgroundColor?`background:${v.backgroundColor};`:"",x=v.color?`color:${v.color};`:v.textColor?`color:${v.textColor};`:"";e.innerHTML=`
121
- <div class="ds-header-component" style="${T}${x}">
122
- <div class="ds-header-content">${w}</div>
123
- </div>`;break}case"section":{const w=((X=t.properties)==null?void 0:X.styleConfig)||{},v=!this.opts.hideBackground&&w.backgroundColor?`background:${w.backgroundColor};`:"";e.innerHTML=`
124
- <div class="ds-section-wrapper" style="${v}">
125
- ${t.title?`<div class="ds-section-title">${t.title}</div>`:""}
126
- </div>`;break}}}showTabSpinner(){const e=this.root.querySelector("#ds-tab-loading"),t=this.root.querySelector("#ds-grid");e&&(e.style.display="flex"),t&&(t.style.opacity="0.35")}hideTabSpinner(){const e=this.root.querySelector("#ds-tab-loading"),t=this.root.querySelector("#ds-grid");e&&(e.style.display="none"),t&&(t.style.opacity="1")}scToInlineStyle(e){const t=new Set(["backgroundColor"]),s=r=>r.replace(/([A-Z])/g,"-$1").toLowerCase();return Object.entries(e).filter(([r,i])=>!t.has(r)&&i!=null&&i!=="").map(([r,i])=>`${s(r)}:${i}`).join(";")}parseTwColor(e){if(!e)return{};const t={};for(const s of e.split(/\s+/)){if(!s)continue;if(s==="bg-white"){t.bg="#ffffff";continue}if(s==="bg-black"){t.bg="#000000";continue}if(s==="bg-transparent"){t.bg="transparent";continue}if(s==="text-white"){t.text="#ffffff";continue}if(s==="text-black"){t.text="#000000";continue}const r=/^(bg|text)-([a-z]+)-(\d+)$/.exec(s);if(!r)continue;const i=E.TW_PALETTE[r[2]],a=i==null?void 0:i[Number(r[3])];a&&(r[1]==="bg"&&(t.bg=a),r[1]==="text"&&(t.text=a))}return t}getTooltipEl(){if(!this.tooltipEl){const e=document.createElement("div");e.className="ds-global-tooltip",e.style.display="none",document.body.appendChild(e),this.tooltipEl=e}return this.tooltipEl}getComponentDescription(e){var t,s,r,i;if((t=e.properties)!=null&&t.description)return String(e.properties.description);try{const a=(r=(s=e.properties)==null?void 0:s.data)==null?void 0:r.dataContent;if(a){const o=typeof a=="string"?JSON.parse(a):a;return(o==null?void 0:o.description)||((i=o==null?void 0:o.config)==null?void 0:i.description)||""}}catch(a){}return""}getTabsForPage(e){var t,s;return(s=(t=this.renderData.dashboard.pages.find(r=>r.pageId===e))==null?void 0:t.tabs)!=null?s:[]}};E.TW_PALETTE={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337"}};let z=E;class le{constructor(e,t){this.chartRenderer=null,this.tableRenderer=new re,this.cardRenderer=new ie,this.root=e,this.theme=t}render(e,t){const s=e.components[0];if(!s){this.root.innerHTML=`<div class="ds-embed-error">
127
- <div class="ds-embed-error-icon">⚠</div>
128
- <div>Component not found.</div>
129
- </div>`;return}const r=e.data[s.id]||[];this.renderComponent(s,r),t==null||t()}update(e){const t=e.components[0];if(!t)return;const s=e.data[t.id]||[];switch(t.type){case"bar":case"line":case"pie":case"donut":case"area":this.chartRenderer?this.chartRenderer.update(t,s,this.theme):this.renderComponent(t,s);break;case"table":this.tableRenderer.render(this.root,t,s);break;case"number-card":this.cardRenderer.render(this.root,t,s);break}}destroy(){var e;(e=this.chartRenderer)==null||e.destroy(),this.chartRenderer=null,this.root.innerHTML=""}renderComponent(e,t){var s;switch(e.type){case"bar":case"line":case"pie":case"donut":case"area":(s=this.chartRenderer)==null||s.destroy(),this.chartRenderer=new se(this.root),this.chartRenderer.render(e,t,this.theme);break;case"table":this.tableRenderer.render(this.root,e,t);break;case"number-card":this.cardRenderer.render(this.root,e,t);break;default:this.root.innerHTML=`<div class="ds-chart-empty">Unsupported component type: ${e.type}</div>`}}}let ee=!1;function ce(){if(!(ee||typeof document=="undefined")){ee=!0;try{const k=`/* ─────────────────────────────────────────────────────────────────────────────
130
- Deepspot SDK — Base Embed Styles
131
- Injected once into the host page's <head> by the SDK.
132
- All selectors are scoped under .ds-embed-* to avoid leaking into host styles.
133
- ───────────────────────────────────────────────────────────────────────────── */
134
-
135
- /* ── Reset inside SDK containers ──────────────────────────────────────────── */
136
- .ds-embed-root *,
137
- .ds-embed-root *::before,
138
- .ds-embed-root *::after {
139
- box-sizing: border-box;
140
- margin: 0;
141
- padding: 0;
142
- }
143
-
144
- /* ── Root container ────────────────────────────────────────────────────────── */
145
- .ds-embed-root {
146
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
147
- Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
148
- font-size: 14px;
149
- line-height: 1.5;
150
- width: 100%;
151
- height: 100%;
152
- overflow: auto;
153
- position: relative;
154
- /* Default white background — overridden by page backgroundColor from publish page */
155
- background: #ffffff;
156
- color: #111827;
157
- }
158
-
159
- .ds-embed-root.ds-theme-light {
160
- /* No forced background — let component styleConfig backgrounds show through */
161
- color: #111827;
162
- }
163
-
164
- .ds-embed-root.ds-theme-dark {
165
- /* No forced background — let component styleConfig backgrounds show through */
166
- color: #f1f5f9;
167
- }
168
-
169
- /* ── Loading state ─────────────────────────────────────────────────────────── */
170
- .ds-embed-loading {
171
- display: flex;
172
- flex-direction: column;
173
- align-items: center;
174
- justify-content: center;
175
- height: 100%;
176
- min-height: 200px;
177
- gap: 12px;
178
- color: #6b7280;
179
- }
180
-
181
- .ds-embed-spinner {
182
- width: 36px;
183
- height: 36px;
184
- border: 3px solid #e5e7eb;
185
- border-top-color: #6366f1;
186
- border-radius: 50%;
187
- animation: ds-spin 0.8s linear infinite;
188
- }
189
-
190
- @keyframes ds-spin {
191
- to { transform: rotate(360deg); }
192
- }
193
-
194
- .ds-embed-loading-text {
195
- font-size: 13px;
196
- }
197
-
198
- /* ── Error state ───────────────────────────────────────────────────────────── */
199
- .ds-embed-error {
200
- display: flex;
201
- flex-direction: column;
202
- align-items: center;
203
- justify-content: center;
204
- height: 100%;
205
- min-height: 200px;
206
- gap: 8px;
207
- padding: 24px;
208
- text-align: center;
209
- color: #ef4444;
210
- }
211
-
212
- .ds-embed-error-icon {
213
- font-size: 32px;
214
- }
215
-
216
- .ds-embed-error-message {
217
- font-size: 13px;
218
- color: #6b7280;
219
- }
220
-
221
- /* ── Filter bar ────────────────────────────────────────────────────────────── */
222
- .ds-filter-bar {
223
- display: flex;
224
- flex-wrap: wrap;
225
- align-items: center;
226
- gap: 10px;
227
- padding: 10px 16px;
228
- border-bottom: 1px solid #e5e7eb;
229
- background: inherit;
230
- }
231
-
232
- .ds-theme-dark .ds-filter-bar {
233
- border-bottom-color: #1e293b;
234
- }
235
-
236
- .ds-filter-item {
237
- display: flex;
238
- flex-direction: column;
239
- gap: 4px;
240
- }
241
-
242
- .ds-filter-label {
243
- font-size: 11px;
244
- font-weight: 600;
245
- text-transform: uppercase;
246
- letter-spacing: 0.05em;
247
- color: #6b7280;
248
- }
249
-
250
- .ds-filter-select,
251
- .ds-filter-input {
252
- height: 32px;
253
- padding: 0 10px;
254
- border: 1px solid #d1d5db;
255
- border-radius: 6px;
256
- font-size: 13px;
257
- background: #ffffff;
258
- color: #111827;
259
- cursor: pointer;
260
- min-width: 130px;
261
- }
262
-
263
- .ds-theme-dark .ds-filter-select,
264
- .ds-theme-dark .ds-filter-input {
265
- background: #1e293b;
266
- border-color: #334155;
267
- color: #f1f5f9;
268
- }
269
-
270
- .ds-filter-select:focus,
271
- .ds-filter-input:focus {
272
- outline: none;
273
- border-color: #6366f1;
274
- box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
275
- }
276
-
277
- .ds-date-range-inputs {
278
- display: flex;
279
- gap: 6px;
280
- align-items: center;
281
- }
282
-
283
- .ds-date-range-inputs input[type="date"] {
284
- height: 32px;
285
- padding: 0 8px;
286
- border: 1px solid #d1d5db;
287
- border-radius: 6px;
288
- font-size: 13px;
289
- background: #ffffff;
290
- color: #111827;
291
- }
292
-
293
- .ds-theme-dark .ds-date-range-inputs input[type="date"] {
294
- background: #1e293b;
295
- border-color: #334155;
296
- color: #f1f5f9;
297
- }
298
-
299
- /* ── Page / Tab navigation ─────────────────────────────────────────────────── */
300
- .ds-page-nav {
301
- display: flex;
302
- gap: 4px;
303
- padding: 8px 16px 0;
304
- border-bottom: 1px solid #e5e7eb;
305
- overflow-x: auto;
306
- }
307
-
308
- .ds-theme-dark .ds-page-nav {
309
- border-bottom-color: #1e293b;
310
- }
311
-
312
- .ds-page-tab {
313
- padding: 6px 16px;
314
- font-size: 13px;
315
- font-weight: 500;
316
- border: none;
317
- border-bottom: 2px solid transparent;
318
- background: transparent;
319
- color: #6b7280;
320
- cursor: pointer;
321
- white-space: nowrap;
322
- transition: color 0.15s, border-color 0.15s;
323
- }
324
-
325
- .ds-page-tab:hover {
326
- color: #111827;
327
- }
328
-
329
- .ds-theme-dark .ds-page-tab:hover {
330
- color: #f1f5f9;
331
- }
332
-
333
- .ds-page-tab.ds-active {
334
- color: #6366f1;
335
- border-bottom-color: #6366f1;
336
- }
337
-
338
- /* ── Grid canvas ───────────────────────────────────────────────────────────── */
339
- .ds-canvas {
340
- position: relative;
341
- width: 100%;
342
- /* No horizontal padding — grid.clientWidth must equal container width so
343
- GridLayout.colWidth = containerWidth/24 matches the dashboard builder.
344
- 16px on each side was shrinking the grid by 32px and misaligning positions. */
345
- padding: 8px 0 16px;
346
- overflow-x: hidden;
347
- }
348
-
349
- .ds-grid {
350
- position: relative;
351
- width: 100%;
352
- /* Clip absolutely-positioned children to the grid boundary so rounding
353
- errors or miscalculated widths don't create a horizontal scrollbar. */
354
- overflow: hidden;
355
- }
356
-
357
- .ds-component-wrapper {
358
- position: absolute;
359
- /* overflow intentionally not set — individual card components handle their own clipping,
360
- and tooltip bubbles must be able to overflow the wrapper boundary */
361
- }
362
-
363
- /* ── Description tooltip — fixed on body, positioned via JS, never clips content ── */
364
- .ds-global-tooltip {
365
- position: fixed;
366
- z-index: 9999;
367
- background: rgba(15, 23, 42, 0.92);
368
- color: #f1f5f9;
369
- font-size: 12px;
370
- line-height: 1.6;
371
- padding: 8px 14px;
372
- border-radius: 8px;
373
- white-space: normal;
374
- pointer-events: none;
375
- backdrop-filter: blur(4px);
376
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
377
- max-width: 600px;
378
- }
379
-
380
- /* ── Chart component ───────────────────────────────────────────────────────── */
381
- .ds-chart-card {
382
- width: 100%;
383
- height: 100%;
384
- background: #ffffff;
385
- border: 1px solid #e5e7eb;
386
- border-radius: 10px;
387
- overflow: hidden;
388
- display: flex;
389
- flex-direction: column;
390
- }
391
-
392
- .ds-theme-dark .ds-chart-card {
393
- background: #1e293b;
394
- border-color: #334155;
395
- }
396
-
397
- .ds-chart-title {
398
- padding: 10px 14px 4px;
399
- font-size: 13px;
400
- font-weight: 600;
401
- color: #374151;
402
- flex-shrink: 0;
403
- }
404
-
405
- .ds-theme-dark .ds-chart-title {
406
- color: #e2e8f0;
407
- }
408
-
409
- .ds-chart-body {
410
- flex: 1;
411
- min-height: 0;
412
- }
413
-
414
- .ds-chart-empty {
415
- display: flex;
416
- align-items: center;
417
- justify-content: center;
418
- height: 100%;
419
- color: #9ca3af;
420
- font-size: 13px;
421
- }
422
-
423
- /* ── Table component ───────────────────────────────────────────────────────── */
424
- .ds-table-card {
425
- width: 100%;
426
- height: 100%;
427
- background: #ffffff;
428
- border: 1px solid #e5e7eb;
429
- border-radius: 10px;
430
- overflow: hidden;
431
- display: flex;
432
- flex-direction: column;
433
- position: relative;
434
- }
435
-
436
- .ds-theme-dark .ds-table-card {
437
- background: #1e293b;
438
- border-color: #334155;
439
- }
440
-
441
- /* ── Table header: dot + title on left, search on right ──────────────────────*/
442
- .ds-table-header-row {
443
- display: flex;
444
- align-items: center;
445
- justify-content: space-between;
446
- padding: 10px 14px 8px;
447
- flex-shrink: 0;
448
- gap: 8px;
449
- border-bottom: 1px solid #f3f4f6;
450
- }
451
-
452
- .ds-theme-dark .ds-table-header-row {
453
- border-bottom-color: #334155;
454
- }
455
-
456
- .ds-table-title-wrap {
457
- display: flex;
458
- align-items: center;
459
- gap: 6px;
460
- min-width: 0;
461
- }
462
-
463
- .ds-table-dot {
464
- width: 8px;
465
- height: 8px;
466
- border-radius: 50%;
467
- background: #6366f1;
468
- flex-shrink: 0;
469
- }
470
-
471
- .ds-table-title {
472
- font-size: 13px;
473
- font-weight: 600;
474
- color: #374151;
475
- white-space: nowrap;
476
- overflow: hidden;
477
- text-overflow: ellipsis;
478
- }
479
-
480
- .ds-theme-dark .ds-table-title {
481
- color: #e2e8f0;
482
- }
483
-
484
- /* ── Search ──────────────────────────────────────────────────────────────────*/
485
- .ds-table-search-wrap {
486
- position: relative;
487
- flex-shrink: 0;
488
- }
489
-
490
- .ds-table-search-icon {
491
- position: absolute;
492
- left: 8px;
493
- top: 50%;
494
- transform: translateY(-50%);
495
- width: 14px;
496
- height: 14px;
497
- color: #9ca3af;
498
- pointer-events: none;
499
- }
500
-
501
- .ds-table-search {
502
- height: 30px;
503
- padding: 0 10px 0 28px;
504
- border: 1px solid #e5e7eb;
505
- border-radius: 6px;
506
- font-size: 12px;
507
- background: #f9fafb;
508
- color: #374151;
509
- width: 180px;
510
- outline: none;
511
- transition: border-color 0.15s, box-shadow 0.15s;
512
- }
513
-
514
- .ds-table-search:focus {
515
- border-color: #6366f1;
516
- box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
517
- background: #fff;
518
- }
519
-
520
- .ds-theme-dark .ds-table-search {
521
- background: #0f172a;
522
- border-color: #334155;
523
- color: #e2e8f0;
524
- }
525
-
526
- .ds-theme-dark .ds-table-search:focus {
527
- background: #1e293b;
528
- }
529
-
530
- /* ── Scroll area ─────────────────────────────────────────────────────────────*/
531
- .ds-table-scroll {
532
- flex: 1;
533
- overflow: auto;
534
- min-height: 0;
535
- }
536
-
537
- .ds-table {
538
- width: 100%;
539
- border-collapse: collapse;
540
- font-size: 12px;
541
- }
542
-
543
- .ds-table-sno-th {
544
- width: 48px;
545
- text-align: center !important;
546
- }
547
-
548
- .ds-table-sno {
549
- text-align: center;
550
- color: #9ca3af;
551
- font-size: 11px;
552
- }
553
-
554
- .ds-theme-dark .ds-table-sno {
555
- color: #64748b;
556
- }
557
-
558
- .ds-table th {
559
- position: sticky;
560
- top: 0;
561
- padding: 8px 12px;
562
- text-align: left;
563
- font-weight: 600;
564
- font-size: 11px;
565
- text-transform: uppercase;
566
- letter-spacing: 0.05em;
567
- background: #f9fafb;
568
- color: #6b7280;
569
- border-bottom: 1px solid #e5e7eb;
570
- white-space: nowrap;
571
- }
572
-
573
- .ds-theme-dark .ds-table th {
574
- background: #0f172a;
575
- color: #94a3b8;
576
- border-bottom-color: #334155;
577
- }
578
-
579
- .ds-table td {
580
- padding: 8px 12px;
581
- border-bottom: 1px solid #f3f4f6;
582
- color: #374151;
583
- max-width: 200px;
584
- overflow: hidden;
585
- text-overflow: ellipsis;
586
- white-space: nowrap;
587
- }
588
-
589
- .ds-theme-dark .ds-table td {
590
- color: #cbd5e1;
591
- border-bottom-color: #1e293b;
592
- }
593
-
594
- .ds-table tr:hover td {
595
- background: #f9fafb;
596
- }
597
-
598
- .ds-theme-dark .ds-table tr:hover td {
599
- background: #0f172a;
600
- }
601
-
602
- /* ── Footer: info + pagination ───────────────────────────────────────────────*/
603
- .ds-table-footer {
604
- display: flex;
605
- align-items: center;
606
- justify-content: space-between;
607
- padding: 8px 14px;
608
- border-top: 1px solid #f3f4f6;
609
- flex-shrink: 0;
610
- gap: 8px;
611
- flex-wrap: wrap;
612
- }
613
-
614
- .ds-theme-dark .ds-table-footer {
615
- border-top-color: #334155;
616
- }
617
-
618
- .ds-table-info {
619
- display: flex;
620
- align-items: center;
621
- gap: 8px;
622
- font-size: 12px;
623
- color: #6b7280;
624
- }
625
-
626
- .ds-theme-dark .ds-table-info {
627
- color: #94a3b8;
628
- }
629
-
630
- .ds-table-rows-label {
631
- margin-left: 4px;
632
- }
633
-
634
- .ds-table-page-size {
635
- height: 28px;
636
- padding: 0 6px;
637
- border: 1px solid #e5e7eb;
638
- border-radius: 5px;
639
- font-size: 12px;
640
- background: #fff;
641
- color: #374151;
642
- cursor: pointer;
643
- outline: none;
644
- }
645
-
646
- .ds-theme-dark .ds-table-page-size {
647
- background: #0f172a;
648
- border-color: #334155;
649
- color: #e2e8f0;
650
- }
651
-
652
- .ds-table-pagination {
653
- display: flex;
654
- align-items: center;
655
- gap: 6px;
656
- }
657
-
658
- .ds-table-pg-btn {
659
- height: 28px;
660
- padding: 0 10px;
661
- border: 1px solid #e5e7eb;
662
- border-radius: 5px;
663
- font-size: 12px;
664
- font-weight: 500;
665
- background: #fff;
666
- color: #374151;
667
- cursor: pointer;
668
- transition: background 0.12s, border-color 0.12s;
669
- white-space: nowrap;
670
- }
671
-
672
- .ds-table-pg-btn:hover:not(:disabled) {
673
- background: #f3f4f6;
674
- border-color: #d1d5db;
675
- }
676
-
677
- .ds-table-pg-btn:disabled {
678
- opacity: 0.4;
679
- cursor: not-allowed;
680
- }
681
-
682
- .ds-theme-dark .ds-table-pg-btn {
683
- background: #1e293b;
684
- border-color: #334155;
685
- color: #e2e8f0;
686
- }
687
-
688
- .ds-theme-dark .ds-table-pg-btn:hover:not(:disabled) {
689
- background: #0f172a;
690
- }
691
-
692
- .ds-table-pg-info {
693
- font-size: 12px;
694
- color: #6b7280;
695
- white-space: nowrap;
696
- }
697
-
698
- .ds-theme-dark .ds-table-pg-info {
699
- color: #94a3b8;
700
- }
701
-
702
- /* ── Loading overlay while fetching a page ───────────────────────────────────*/
703
- .ds-table-loading-overlay {
704
- position: absolute;
705
- inset: 0;
706
- background: rgba(255,255,255,0.6);
707
- display: flex;
708
- align-items: center;
709
- justify-content: center;
710
- border-radius: 10px;
711
- z-index: 10;
712
- }
713
-
714
- .ds-theme-dark .ds-table-loading-overlay {
715
- background: rgba(30,41,59,0.7);
716
- }
717
-
718
- /* ── KPI Number Card ───────────────────────────────────────────────────────── */
719
- .ds-card {
720
- width: 100%;
721
- height: 100%;
722
- border: 1px solid #e5e7eb;
723
- border-radius: 10px;
724
- display: flex;
725
- flex-direction: column;
726
- align-items: center;
727
- justify-content: center;
728
- padding: 16px;
729
- text-align: center;
730
- background: #ffffff;
731
- }
732
-
733
- .ds-theme-dark .ds-card {
734
- background: #1e293b;
735
- border-color: #334155;
736
- }
737
-
738
- .ds-card-label {
739
- font-size: 12px;
740
- font-weight: 500;
741
- color: #6b7280;
742
- margin-bottom: 6px;
743
- text-transform: uppercase;
744
- letter-spacing: 0.05em;
745
- }
746
-
747
- .ds-card-value {
748
- font-size: 32px;
749
- font-weight: 700;
750
- color: #111827;
751
- line-height: 1.1;
752
- }
753
-
754
- .ds-theme-dark .ds-card-value {
755
- color: #f1f5f9;
756
- }
757
-
758
- /* ── v2: Text / content components ────────────────────────────────────────── */
759
-
760
- .ds-text-heading {
761
- width: 100%;
762
- height: 100%;
763
- display: flex;
764
- flex-direction: column;
765
- justify-content: center;
766
- padding: 8px 12px;
767
- font-size: 20px;
768
- font-weight: 700;
769
- color: #111827;
770
- line-height: 1.3;
771
- overflow: hidden;
772
- }
773
-
774
- .ds-theme-dark .ds-text-heading {
775
- color: #f1f5f9;
776
- }
777
-
778
- .ds-text-subheading {
779
- width: 100%;
780
- height: 100%;
781
- display: flex;
782
- flex-direction: column;
783
- justify-content: center;
784
- padding: 6px 12px;
785
- font-size: 15px;
786
- font-weight: 600;
787
- color: #374151;
788
- line-height: 1.4;
789
- overflow: hidden;
790
- }
791
-
792
- .ds-theme-dark .ds-text-subheading {
793
- color: #cbd5e1;
794
- }
795
-
796
- .ds-text-body {
797
- width: 100%;
798
- height: 100%;
799
- padding: 8px 12px;
800
- font-size: 14px;
801
- color: #374151;
802
- line-height: 1.6;
803
- overflow: auto;
804
- }
805
-
806
- .ds-theme-dark .ds-text-body {
807
- color: #94a3b8;
808
- }
809
-
810
- .ds-text-box {
811
- width: 100%;
812
- height: 100%;
813
- padding: 10px 14px;
814
- font-size: 13px;
815
- color: #374151;
816
- line-height: 1.6;
817
- border: 1px solid #e5e7eb;
818
- border-radius: 8px;
819
- background: #f9fafb;
820
- overflow: auto;
821
- }
822
-
823
- .ds-theme-dark .ds-text-box {
824
- color: #cbd5e1;
825
- border-color: #334155;
826
- background: #1e293b;
827
- }
828
-
829
- /* ── v2: Header component ──────────────────────────────────────────────────── */
830
-
831
- .ds-header-component {
832
- width: 100%;
833
- height: 100%;
834
- display: flex;
835
- align-items: center;
836
- padding: 12px 20px;
837
- background: #f3f4f6;
838
- border-bottom: 1px solid #e5e7eb;
839
- overflow: hidden;
840
- }
841
-
842
- .ds-theme-dark .ds-header-component {
843
- background: #1e293b;
844
- border-bottom-color: #334155;
845
- }
846
-
847
- .ds-header-content {
848
- font-size: 18px;
849
- font-weight: 700;
850
- color: #111827;
851
- white-space: nowrap;
852
- overflow: hidden;
853
- text-overflow: ellipsis;
854
- }
855
-
856
- .ds-theme-dark .ds-header-content {
857
- color: #f1f5f9;
858
- }
859
-
860
- /* ── v2: Section container ─────────────────────────────────────────────────── */
861
-
862
- .ds-section-wrapper {
863
- width: 100%;
864
- height: 100%;
865
- border: 1px solid #e5e7eb;
866
- border-radius: 10px;
867
- background: #f9fafb;
868
- overflow: hidden;
869
- }
870
-
871
- .ds-theme-dark .ds-section-wrapper {
872
- border-color: #334155;
873
- background: #1e293b;
874
- }
875
-
876
- .ds-section-title {
877
- padding: 8px 14px;
878
- font-size: 12px;
879
- font-weight: 600;
880
- text-transform: uppercase;
881
- letter-spacing: 0.05em;
882
- color: #6b7280;
883
- border-bottom: 1px solid #e5e7eb;
884
- }
885
-
886
- .ds-theme-dark .ds-section-title {
887
- color: #94a3b8;
888
- border-bottom-color: #334155;
889
- }
890
-
891
- /* ── v2: Inline filter (selection-filter placed in-grid) ───────────────────── */
892
-
893
- .ds-inline-filter {
894
- width: 100%;
895
- height: 100%;
896
- display: flex;
897
- flex-direction: column;
898
- justify-content: center;
899
- gap: 4px;
900
- padding: 6px 10px;
901
- }
902
-
903
- .ds-inline-filter-select,
904
- .ds-inline-filter-input {
905
- width: 100%;
906
- height: 34px;
907
- padding: 0 10px;
908
- border: 1px solid #d1d5db;
909
- border-radius: 6px;
910
- font-size: 13px;
911
- background: #ffffff;
912
- color: #111827;
913
- cursor: pointer;
914
- outline: none;
915
- transition: border-color 0.15s, box-shadow 0.15s;
916
- }
917
-
918
- .ds-inline-filter-select:focus,
919
- .ds-inline-filter-input:focus {
920
- border-color: #6366f1;
921
- box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
922
- }
923
-
924
- .ds-theme-dark .ds-inline-filter-select,
925
- .ds-theme-dark .ds-inline-filter-input {
926
- background: #1e293b;
927
- border-color: #334155;
928
- color: #f1f5f9;
929
- }
930
-
931
- /* ── Export toolbar ────────────────────────────────────────────────────────── */
932
- .ds-toolbar {
933
- display: flex;
934
- justify-content: flex-end;
935
- padding: 8px 16px 0;
936
- gap: 8px;
937
- }
938
-
939
- .ds-toolbar-btn {
940
- height: 30px;
941
- padding: 0 12px;
942
- border: 1px solid #d1d5db;
943
- border-radius: 6px;
944
- font-size: 12px;
945
- font-weight: 500;
946
- background: #ffffff;
947
- color: #374151;
948
- cursor: pointer;
949
- display: flex;
950
- align-items: center;
951
- gap: 5px;
952
- transition: background 0.15s, border-color 0.15s;
953
- }
954
-
955
- .ds-toolbar-btn:hover {
956
- background: #f9fafb;
957
- border-color: #9ca3af;
958
- }
959
-
960
- .ds-theme-dark .ds-toolbar-btn {
961
- background: #1e293b;
962
- border-color: #334155;
963
- color: #e2e8f0;
964
- }
965
-
966
- .ds-theme-dark .ds-toolbar-btn:hover {
967
- background: #0f172a;
968
- }
969
- `,e=document.createElement("style");e.id="deepspot-sdk-styles",e.textContent=k,document.head.appendChild(e)}catch(k){}}}function te(k){if(typeof k=="string"){const e=document.querySelector(k);if(!e)throw new Error(`Deepspot SDK: container "${k}" not found in DOM`);return e}return k}class he{constructor(e){if(!e.apiKey)throw new Error("Deepspot SDK: apiKey is required");if(!e.baseUrl)throw new Error("Deepspot SDK: baseUrl is required");this.apiClient=new ae(e.baseUrl,e.apiKey),ce()}async embedDashboard(e){var a,o,c,d,f,g,u,n,h,b;const t=te(e.container),s=(a=e.embedLevel)!=null?a:"dashboard",r=(o=e.theme)!=null?o:"light";t.style.height=e.height||"600px",t.style.display="block";const i=this.createRoot(t,r);this.showLoading(i);try{const l=await this.apiClient.getEmbedToken({dashboardId:e.dashboardId,embedType:"dashboard",embedLevel:s,userId:e.userId,tenantId:e.tenantId}),m=await this.apiClient.getDashboardRender(e.dashboardId,l,{embedLevel:s,pageId:e.pageId,tabId:e.tabId,filters:e.filters||{}});let p;const y=new z(i,{embedLevel:s,theme:r,hideFilters:(c=e.hideGlobalFilters)!=null?c:!1,hideExport:(d=e.hideExport)!=null?d:!1,hideGlobalFilters:(f=e.hideGlobalFilters)!=null?f:!1,hideInlineFilters:(g=e.hideInlineFilters)!=null?g:!1,hideText:(u=e.hideText)!=null?u:!1,hideHeader:(n=e.hideHeader)!=null?n:!1,hideBackground:(h=e.hideBackground)!=null?h:!1,initialFilters:e.filters||{},onFilterChange:e.onFilterChange,onReady:e.onReady,onFetchFilterOptions:S=>this.apiClient.getFilterOptions(e.dashboardId,S,l),onFetchTablePage:(S,C,I)=>this.apiClient.getTablePage(e.dashboardId,S,C,I,l),onTabSwitch:async(S,C)=>{var I,L,R;(I=e.onTabSwitch)==null||I.call(e,S,C);try{const P=await this.apiClient.getDashboardRender(e.dashboardId,l,{embedLevel:s,pageId:S,tabId:C,filters:(R=(L=p==null?void 0:p.getActiveFilters())!=null?L:e.filters)!=null?R:{}});y.update(P)}catch(P){console.error("Deepspot SDK: tab fetch failed",P)}}});return y.render(m),p=new Z({dashboardId:e.dashboardId,token:l,embedType:"dashboard",embedLevel:s,activePageId:m.activePage,activeTabId:m.activeTab,activeFilters:e.filters||{},apiClient:this.apiClient,renderer:y,onFilterChange:e.onFilterChange}),p}catch(l){throw this.showError(i,(l==null?void 0:l.message)||"Failed to load dashboard"),(b=e.onError)==null||b.call(e,(l==null?void 0:l.message)||"Failed to load dashboard"),l}}async embedReport(e){var r;const t=te(e.container);t.style.height=e.height||"400px",t.style.display="block";const s=this.createRoot(t,e.theme||"light");this.showLoading(s);try{const i=await this.apiClient.getEmbedToken({dashboardId:e.dashboardId,embedType:"report",componentId:e.componentId,userId:e.userId,tenantId:e.tenantId}),a=await this.apiClient.getReportRender(e.dashboardId,e.componentId,i,{filters:e.filters||{}}),o=new le(s,e.theme||"light");return o.render(a,e.onReady),new Z({dashboardId:e.dashboardId,componentId:e.componentId,token:i,embedType:"report",activeFilters:e.filters||{},apiClient:this.apiClient,renderer:o})}catch(i){throw this.showError(s,(i==null?void 0:i.message)||"Failed to load report"),(r=e.onError)==null||r.call(e,(i==null?void 0:i.message)||"Failed to load report"),i}}createRoot(e,t){e.innerHTML="";const s=document.createElement("div");return s.className=`ds-embed-root ds-theme-${t}`,s.style.width="100%",s.style.height="100%",e.appendChild(s),s}showLoading(e){e.innerHTML=`
970
- <div class="ds-embed-loading">
971
- <div class="ds-embed-spinner"></div>
972
- <div class="ds-embed-loading-text">Loading…</div>
973
- </div>
974
- `}showError(e,t){e.innerHTML=`
975
- <div class="ds-embed-error">
976
- <div class="ds-embed-error-icon">⚠</div>
977
- <div>${t}</div>
978
- <div class="ds-embed-error-message">Check your SDK configuration.</div>
979
- </div>
980
- `}}exports.DeepspotSDK=he;