@svgrid/enterprise 1.0.1

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/src/revoked.ts ADDED
@@ -0,0 +1,49 @@
1
+ // Revoked license keys. A key in this set throws on use even if it has the
2
+ // valid SVPRO- prefix. Use this to invalidate keys that have been leaked,
3
+ // shared outside their seat count, or issued for trials that have expired.
4
+ //
5
+ // =============================================================================
6
+ // MAINTAINER NOTE - DO NOT COMMIT REAL REVOKED KEYS TO THIS FILE
7
+ // =============================================================================
8
+ //
9
+ // The public repo ships this file with an empty Set. The real revoked list
10
+ // is maintained privately by the maintainer. Pick one of two override
11
+ // patterns:
12
+ //
13
+ // A) skip-worktree (recommended for a single maintainer's clone)
14
+ //
15
+ // One-time setup on the maintainer's machine:
16
+ //
17
+ // git update-index --skip-worktree \
18
+ // packages/enterprise/src/revoked.ts
19
+ //
20
+ // Then edit this file with real keys; git will not track the changes
21
+ // and they will never be pushed. To re-track later:
22
+ //
23
+ // git update-index --no-skip-worktree \
24
+ // packages/enterprise/src/revoked.ts
25
+ //
26
+ // B) gitignored sibling file (revoked.local.ts)
27
+ //
28
+ // Create packages/enterprise/src/revoked.local.ts (covered by the
29
+ // package's .gitignore). Export a `REVOKED_LOCAL` Set from it. To
30
+ // have it merged in, replace the export below with:
31
+ //
32
+ // // @ts-ignore -- optional, gitignored file
33
+ // import { REVOKED_LOCAL } from './revoked.local'
34
+ // export const REVOKED_KEYS: ReadonlySet<string> = new Set<string>([
35
+ // ...REVOKED_LOCAL,
36
+ // ])
37
+ //
38
+ // Note: this only works if the file actually exists at type-check
39
+ // time. For a fresh public clone with no revoked.local.ts, fall back
40
+ // to the empty default.
41
+ //
42
+ // For npm publication the right long-term answer is a build step that
43
+ // inlines the list from an env var or private file. Not wired up yet.
44
+ // =============================================================================
45
+
46
+ export const REVOKED_KEYS: ReadonlySet<string> = new Set<string>([
47
+ // 'SVPRO-EVAL-acme-202506-3F7K9P', // example - expired ACME trial
48
+ // 'SVPRO-LEAKED-globex-202612-X8N4P', // example - key leaked on GitHub
49
+ ])
@@ -0,0 +1,105 @@
1
+ // Minimal globalThis.Smart shim so the vendored smart.export.js IIFE can
2
+ // register Smart.Utilities.DataExporter without dragging in the rest of the
3
+ // Smart UI runtime. DataExporter calls into Smart.Utilities.{Assign, Core.toDash}
4
+ // at registration; the other namespaces (DateTime, NumberRenderer, Draw,
5
+ // BigNumber, Complex) are guarded by `if (!Smart.Utilities.X) return e;` paths
6
+ // inside the exporter and degrade gracefully when missing.
7
+ //
8
+ // We export a function instead of relying on import-side-effects so callers
9
+ // can deterministically install the shim before the smart.export.js module
10
+ // runs its IIFE.
11
+
12
+ type SmartGlobal = {
13
+ Utilities: {
14
+ Assign(name: string, cls: unknown): void
15
+ Core: {
16
+ toDash(input: string): string
17
+ }
18
+ DataExporter?: new (
19
+ options: Record<string, unknown>,
20
+ groupBy?: ReadonlyArray<string>,
21
+ filterBy?: Record<string, unknown>,
22
+ conditionalFormatting?: unknown,
23
+ ) => SmartDataExporterInstance
24
+ [key: string]: unknown
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Shape of the image object Smart's xlsx writer expects from
30
+ * `addImageToCell(...).image`. `base64` may be a full data URL; the
31
+ * exporter strips the prefix.
32
+ */
33
+ export type SmartImageDescriptor = {
34
+ id: string
35
+ base64: string
36
+ imageType: string
37
+ width: number
38
+ height: number
39
+ }
40
+
41
+ export type SmartDataExporterInstance = {
42
+ /**
43
+ * Smart looks for these on the INSTANCE (not the constructor opts) at
44
+ * exportData() time. The wrapper sets them after `new DataExporter(...)`.
45
+ */
46
+ headerContent?: Array<{
47
+ cells: Record<string, unknown>
48
+ style?: Record<string, unknown>
49
+ }>
50
+ footerContent?: Array<{
51
+ cells: Record<string, unknown>
52
+ style?: Record<string, unknown>
53
+ }>
54
+ addImageToCell?: (
55
+ rowIndex: number,
56
+ dataField: string,
57
+ value: unknown,
58
+ rawValue: unknown,
59
+ row: Record<string, unknown>,
60
+ arrIndex: number,
61
+ ) => { image: SmartImageDescriptor; value?: unknown } | null
62
+ spreadsheets?: ReadonlyArray<{
63
+ label: string
64
+ dataSource: ReadonlyArray<Record<string, unknown>>
65
+ columns: ReadonlyArray<{ dataField: string; label: string }>
66
+ dataFields: ReadonlyArray<string>
67
+ style?: unknown
68
+ }>
69
+ exportData(
70
+ data: ReadonlyArray<Record<string, unknown>>,
71
+ format: string,
72
+ filename?: string,
73
+ callback?: (result: unknown) => void,
74
+ ): unknown
75
+ }
76
+
77
+ declare global {
78
+ interface Window {
79
+ Smart?: SmartGlobal
80
+ }
81
+ }
82
+
83
+ let installed = false
84
+
85
+ export function installSmartShim(): void {
86
+ if (installed) return
87
+ if (typeof window === 'undefined') {
88
+ throw new Error('@svgrid/enterprise: installSmartShim() requires a browser environment')
89
+ }
90
+ const existing = window.Smart
91
+ const shim: SmartGlobal = existing ?? ({ Utilities: {} as SmartGlobal['Utilities'] })
92
+ shim.Utilities = shim.Utilities ?? ({} as SmartGlobal['Utilities'])
93
+ if (typeof shim.Utilities.Assign !== 'function') {
94
+ shim.Utilities.Assign = (name: string, cls: unknown) => {
95
+ ;(shim.Utilities as Record<string, unknown>)[name] = cls
96
+ }
97
+ }
98
+ if (!shim.Utilities.Core || typeof shim.Utilities.Core.toDash !== 'function') {
99
+ shim.Utilities.Core = {
100
+ toDash: (s: string) => s.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()),
101
+ }
102
+ }
103
+ window.Smart = shim
104
+ installed = true
105
+ }
@@ -0,0 +1,5 @@
1
+ // The vendored smart.export.js is a pure IIFE that registers
2
+ // Smart.Utilities.DataExporter on the global Smart namespace. It has no
3
+ // ESM exports of its own. This sibling .d.ts marks it as a module so
4
+ // TypeScript allows `import './smart.export.js'` as a side-effect import.
5
+ export {}
@@ -0,0 +1,7 @@
1
+ /* Smart UI v26.0.8 (2026-05-15)
2
+ Copyright (c) 2011-2026 jQWidgets.
3
+ License: https://htmlelements.com/license/ */
4
+ /* Vendored into @svgrid/enterprise. Do not edit - the Smart namespace shim
5
+ in smart-shim.ts is the only modification surface. */
6
+
7
+ (()=>{var e="\r\n";function t(e,t,a){if(!t&&""!==t&&0!==t)return"";let o=t;return"boolean"==typeof t&&a&&(o=a(t)),` ${e}="${o}"`}var a=class{static createHeader(e={}){const t=["version"];e.version||(e.version="1.0"),e.encoding&&t.push("encoding"),e.standalone&&t.push("standalone");return`<?xml ${t.map((t=>`${t}="${e[t]}"`)).join(" ")} ?>`}static createXml(a,o){let r="";a.properties&&(a.properties.prefixedAttributes&&a.properties.prefixedAttributes.forEach((e=>{Object.keys(e.map).forEach((a=>{r+=t(e.prefix+a,e.map[a],o)}))})),a.properties.rawMap&&Object.keys(a.properties.rawMap).forEach((e=>{r+=t(e,a.properties.rawMap[e],o)})));let n="<"+a.name+r;return a.children||null!=a.textNode?null!=a.textNode?n+">"+a.textNode+"</"+a.name+">"+e:(n+=">\r\n",a.children&&a.children.forEach((e=>{n+=this.createXml(e,o)})),n+"</"+a.name+">"+e):n+"/>"+e}};Smart.Utilities.Assign("DataExporter",class{constructor(e,t,a,o){const r=this;e||(e={}),r.style=e.style,r.header=e.header,r.exportHeader=void 0===e.exportHeader||e.exportHeader,r.hierarchical=e.hierarchical,r.expandChar=e.expandChar||"+",r.collapseChar=e.collapseChar||"-",r.pageOrientation=e.pageOrientation,r.allowNull=e.allowNull||!1,r.spreadsheets=e.spreadsheets||null,r.protectSheet=e.protectSheet||null,r._media=[],!r.hierarchical&&t&&t.length>0?r.groupBy=t:r.mergedCells=e.mergedCells,!r.groupBy&&a&&Object.keys(a).length>0&&(r.filterBy=a),o&&(r.conditionalFormatting=o),r.timeBetween1900And1970=new Date(1970,0,1,0,0,0).getTime()-new Date(1900,0,1,0,0,0).getTime()}downloadFile(e,t,a){let o;if(!a)return e;if(o=e instanceof Blob?e:new Blob([e],{type:t}),window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(o,a);else{const e=document.createElement("a"),t=URL.createObjectURL(o);e.href=t,e.download=a,e.style.position="absolute",e.style.visibility="hidden",document.body.appendChild(e),e.click(),setTimeout((function(){document.body.removeChild(e),window.URL.revokeObjectURL(t)}),100)}}exportData(e,t,a,o){const r=this;if(r.actualHierarchy=r.hierarchical,t=t.toLowerCase(),r.exportHeader&&(r.header?(0===(e=e.slice(0)).length&&(r.actualHierarchy=!1),r.processComplexHeader(r.header,e,t)):1===e.length&&(r.actualHierarchy=!1)),0===e.length)return void console.warn("No data to export.");if("xlsx"===t){r.xlsxStartIndex=r.complexHeader?r.complexHeader.length:+r.exportHeader;const e=r.headerContent?r.headerContent.length:0;r.xlsxStartIndex=r.xlsxStartIndex+e}r.actualHierarchy&&(e=r.processHierarchicalData(e,t)),r.getDatafields(e),a&&a.slice(a.length-t.length-1,a.length)!=="."+t&&(a+="."+t);let n=null;switch(t){case"csv":n=r.exportToCSVAndTSV(e,{delimiter:", ",MIME:"text/csv;charset=utf-8;",toRemove:2},a);break;case"html":n=r.exportToHTML(e,a);break;case"jpeg":case"png":r.exportToImage(e,a,t,o);break;case"json":n=r.exportToJSON(e,a);break;case"pdf":n=r.exportToPDF(e,a);break;case"tsv":n=r.exportToCSVAndTSV(e,{delimiter:"\t",MIME:"text/tab-separated-values",toRemove:1},a);break;case"xlsx":n=r.exportToXLSX(e,a,o);break;case"xml":n=r.exportToXML(e,a);break;case"md":n=r.exportToMD(e,a)}return o&&n&&o(n),delete r.complexHeader,n}exportToCSVAndTSV(e,t,a){const o=this,r=o.datafields;let n="";for(let a=0;a<e.length;a++){const l=e[a];let s="";for(let e=0;e<r.length;e++)o.actualHierarchy&&0===e?s+=('""'+t.delimiter).repeat(l._level-1)+'"'+l[r[e]]+'"'+t.delimiter+('""'+t.delimiter).repeat(o.maxLevel-l._level):s+='"'+l[r[e]]+'"'+t.delimiter;s=s.slice(0,s.length-t.toRemove)+"\n",n+=s}if(!a)return n;const l=""+n;return this.downloadFile(l,t.MIME,a)}exportToHTML(e,t){const a=this,o=a.datafields,r=a.style;let n="",l=0,s="";if(e=a.processGroupingInformation(e),a.data=e,a.exportHeader&&(n=a.getHTMLHeader(o,e),l=1),arguments[2]){s=`<script type="text/javascript" src="${Array.from(document.getElementsByTagName("script")).find((e=>-1!==e.src.indexOf("html2canvas"))).src}"><\/script>`}let i=`<!DOCTYPE html>\n<html>\n<head>\n <meta charset="UTF-8">\n <style type="text/css">\n${a.getRowStyle()}${a.getColumnStyle()}\n </style>${s}${a.toggleableFunctionality()}\n</head>\n<body>\n <table${a.getTableStyle()}>${n}\n <tbody>\n`;const c={},p={},m=[];a.getMergedCellsInfo(c,p);e:for(let n=l;n<e.length;n++){const s=e[n],d=n-l;let f=a.getAlternationIndex(d," rowN"),h="",g="",u="",x=0;if(a.actualHierarchy)s._collapsed&&(h=" collapsed"),g=` level="${s._level}"`;else if(a.groupBy)for(let e=0;e<a.groupBy.length;e++){const t=a.groupBy[e],o=s[t],r=a.groups[t][o];if(u+=o,-1===m.indexOf(u)){i+=` <tr class="row">\n <td class="column group" style="padding-left: ${25*x}px;" colspan="${a.datafields.length}">${r}</td>\n </tr>`,m.push(u),n--;continue e}x++}let y=` <tr class="row row${d}${f}${h}"${g}`;t||(y+=' style="page-break-inside: avoid;"'),y+=">\n";for(let e=0;e<o.length;e++){const t=e+","+d;let n=1,l=1;if(c[t])n=c[t].colspan,l=c[t].rowspan;else if(p[t])continue;const i=o[e];let m=s[i],f="";if(a.actualHierarchy&&0===e){let e="";s._expanded?e=a.collapseChar:!1===s._expanded&&(e=a.expandChar),f=`<div class="toggle-element" style="margin-left: ${25*(s._level-1)+5}px;" expanded>${e}</div>`}m=a.getFormattedValue(m,i),"string"==typeof m&&(m.indexOf("base64")>=0||m.indexOf(".png")>=0||m.indexOf(".jpeg")>=0)&&(m=`<img height="30" src="${m}"/>`);let h="";if(r&&r.columns&&r.columns[i]&&r.columns[i][d]){const e=r.columns[i][d];h+=`border-color: ${e.border}; background-color: ${e.background}; color: ${e.color};"`}0===e&&x>1&&(h+=`padding-left: ${25*(x-1)}px;"`),h&&(h=` style="${h}"`),y+=` <td class="column column${i}"${h} colspan="${n}" rowspan="${l}">${f+m}</td>\n`}i+=y+" </tr>\n"}return i+=" </tbody>\n </table>\n</body>\n</html>",arguments[2]?i:this.downloadFile(i,"text/html",t)}exportToImage(e,t,a,o){try{html2canvas}catch(e){throw new Error("smart-grid: Missing reference to 'html2canvas.min.js'.")}let r=null;const n=this.exportToHTML(e,t,!0),l=document.createElement("iframe");return l.style.position="absolute",l.style.top=0,l.style.left=0,l.style.border="none",l.style.width="100%",l.style.height="100%",l.style.opacity=0,l.style.pointerEvents="none",document.body.appendChild(l),l.contentDocument.write(n),function e(){l.contentDocument.body&&l.contentDocument.body.firstElementChild?l.contentWindow.html2canvas(l.contentDocument.body.firstElementChild).then((e=>{const n=new Smart.Utilities.Draw(document.createElement("div"));r=e.toDataURL("image/png"),o?o(r):(document.body.appendChild(e),n.exportImage(void 0,e,a,t)),l.remove(),e.remove()})):requestAnimationFrame(e)}(),r}getMergedCellsInfo(e,t,a){const o=this;if(!o.mergedCells)return;const r=a&&0!==a[o.datafields.length-1];o.mergedCellsPDF=o.mergedCells.slice(0);for(let n=0;n<o.mergedCellsPDF.length;n++){const l=o.mergedCellsPDF[n];let s=l.colspan,i=l.rowspan;if(i<2&&s<2)continue;const c=l.cell[1];let p=l.cell[0];if(r&&s>1){const e=a[p],t=a[p+s-1],r=[];if(t>e){let n=e,l=p,m=0;e:for(let o=e;o<=t;o++){let e=l,t=0;for(;a[l]===n;)if(l++,m++,t++,m===s){r.push({start:e,span:t});break e}r.push({start:e,span:t}),n=a[l]}s=r[0].span;for(let e=1;e<r.length;e++)o.mergedCellsPDF.push({cell:[r[e].start,c],colspan:r[e].span,rowspan:i,originalCell:p})}}for(let a=p;a<p+s;a++)for(let o=c;o<c+i;o++){const r=a+","+o;a!==p||o!==c?t[r]=!0:e[r]={colspan:s,rowspan:i,originalCell:l.originalCell}}}}getAlternationIndex(e,t){if(!this.style)return"";const a=this.style.rows;return a&&a.alternationCount&&((void 0===a.alternationStart||e>=a.alternationStart)&&(void 0===a.alternationEnd||e<=a.alternationEnd)||a.alternationStart===a.alternationEnd)?t+e%a.alternationCount:""}getFormattedValue(e,t){const a=this,o=a.style;if(null===e)return a.allowNull?"null":"";if(t&&o&&o.columns&&o.columns[t]&&o.columns[t].format){if("number"==typeof e)return a.formatNumber(e,o.columns[t].format);if(e instanceof Date)return a.formatDate(e,o.columns[t].format)}else if(e instanceof Date)return a.formatDate(e,"d");return e}exportToJSON(e,t){return this.downloadFile(JSON.stringify(e,this.datafields.concat("rows")),"application/json",t)}exportToMD(e,t){const a=this.datafields;let o="";for(let t=0,r=e.length;t<r;t+=1)for(let r=0,n=a.length;r<n;r+=1){const n=e[t][a[r]];"string"==typeof n&&(o+=n)}return this.downloadFile(o,"application/text",t)}exportToPDF(e,t){try{pdfMake}catch(e){throw new Error("Missing reference to 'pdfmake.min.js'.")}let a,o=this,r=o.datafields,n=+o.exportHeader,l=[],s={},i={},c={},p=n?o.complexHeader?o.complexHeader.length:1:0,m={pageOrientation:o.pageOrientation||"portrait"},d=[],f=[];function h(){let e=[];for(let t=0;t<a.length;t++)e.push([]);return e}e=o.processGroupingInformation(e),o.data=e;let g=[];if(o.headerContent){const e=o.headerContent,t=[];for(let a=0;a<e.length;a++){const r=e[a].cells;let n={};for(let e=0;e<o.datafields.length;e++){const t=o.datafields[e];r[t]?n[t]=r[t]:n[t]=null}t.push(n)}g=t}if(o.footerContent){const t=o.footerContent,a=[];for(let e=0;e<t.length;e++){const r=t[e].cells;let n={};for(let e=0;e<o.datafields.length;e++){const t=o.datafields[e];r[t]?n[t]=r[t]:n[t]=null}a.push(n)}e=[...e,...a]}o.headerRows=p,o.getPDFStyle();const u=o.styleInfo;a=u?o.wrapPDFColumns(m,c):[{body:d,datafields:r}],n&&(d=o.getPDFHeader(r,a,c));let x=[];if(g.length>0)for(let e=0;e<g.length;e++){const t=g[e];let l=0;const p=h(),m=e-n;let d=o.getAlternationIndex(m,"");for(let e=0;e<r.length;e++){const a=r[e],n={style:["row","row"+m,"cell","cell"+a]},f=c[e]||0;if(void 0!==d&&n.style.splice(1,0,"rowN"+d),o.mergedCellsPDF){const t=e+","+m,a=s[t];if(a){if(n.colSpan=a.colspan,n.rowSpan=a.rowspan,void 0!==a.originalCell){n.text="",n.style[n.style.length-1]="cell"+r[a.originalCell],p[f].push(n);continue}}else if(i[t]){p[f].push({});continue}}const h=o.getFormattedValue(t[a],a);"string"==typeof h&&(h.indexOf("base64")>=0||h.indexOf(".png")>=0||h.indexOf(".jpeg")>=0)?(n.image=h,n.width=100):h&&Array.isArray(h)&&h[0]&&h[0].indexOf("base64")>=0?(n.image=h[0],n.width=100,u&&u.widths[e]&&(n.width=parseInt(u.widths[e],10)-10)):n.text=h.toString(),o.getUniqueStylePDF(n,a,m),o.setIndentation(n,{j:e,currentRecord:t,value:h,outlineLevel:l}),p[f].push(n)}for(let e=0;e<a.length;e++)x.push(p[e])}o.getMergedCellsInfo(s,i,c);e:for(let t=n;t<e.length;t++){const p=e[t];let m="",d=0;if(o.groupBy)for(let e=0;e<o.groupBy.length;e++){const r=o.groupBy[e],n=p[r],s=o.groups[r][n];if(m+=n,-1===l.indexOf(m)){o.createGroupHeaderRow(a,{text:s,style:["row","cell","group"],marginLeft:7.5*d}),l.push(m),t--;continue e}d++}const f=h(),g=t-n;let x=o.getAlternationIndex(g,"");for(let e=0;e<r.length;e++){const t=r[e],a={style:["row","row"+g,"cell","cell"+t]},n=c[e]||0;if(void 0!==x&&a.style.splice(1,0,"rowN"+x),o.mergedCellsPDF){const t=e+","+g,o=s[t];if(o){if(a.colSpan=o.colspan,a.rowSpan=o.rowspan,void 0!==o.originalCell){a.text="",a.style[a.style.length-1]="cell"+r[o.originalCell],f[n].push(a);continue}}else if(i[t]){f[n].push({});continue}}const l=o.getFormattedValue(p[t],t);"string"==typeof l&&(l.indexOf("base64")>=0||l.indexOf(".png")>=0||l.indexOf(".jpeg")>=0)?(a.image=l,a.width=100):l&&Array.isArray(l)&&l[0]&&l[0].indexOf("base64")>=0?(a.image=l[0],a.width=100,u&&u.widths[e]&&(a.width=parseInt(u.widths[e],10)-10)):a.text=l.toString(),o.getUniqueStylePDF(a,t,g),o.setIndentation(a,{j:e,currentRecord:p,value:l,outlineLevel:d}),f[n].push(a)}for(let e=0;e<a.length;e++)a[e].body.push(f[e])}if(u){for(let e=0;e<a.length;e++){const t=a[e].body;for(let a=p-1;a>=0;a--)t.unshift(d[e][a]);if(x.length>0)for(let e=x.length-1;e>=0;e--)t.unshift(x[e]);f.push({table:{headerRows:p,widths:a[e].widths,heights:function(e){return u.heights[e]?u.heights[e]:u.defaultHeight?u.defaultHeight:void 0},body:t},pageBreak:"after"})}delete f[a.length-1].pageBreak,m.styles=u.styles}else{const e=a[0].body;for(let t=p-1;t>=0;t--)e.unshift(d[0][t]);if(x.length>0)for(let t=x.length-1;t>=0;t--)e.unshift(x[t]);f=[{table:{headerRows:p,body:e}}],m.styles={header:{bold:!0},group:{bold:!0}}}if(m.content=f,!t){const e=pdfMake.createPdf(m);return delete o.mergedCellsPDF,delete o.styleInfo,e}pdfMake.createPdf(m).download(t),delete o.mergedCellsPDF,delete o.styleInfo}getPDFStyle(){const e=this,t=e.style;if(!t)return"";const a=e.data[0],o=t.header,r=t.columns,n=t.rows,l={heights:[],widths:Array(e.datafields.length).fill("*"),styles:{header:{},row:{},cell:{},group:{fillColor:"#FFFFFF",color:"#000000",bold:!0}}};function s(t,o){if(t)for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r))if(void 0===a[r])if("height"===r&&"header"===o)for(let a=0;a<e.headerRows;a++)l.heights[a]=parseInt(t[r],10)/e.headerRows/1.4;else e.storePDFStyle({prop:r,value:t[r],toUpdate:o});else for(let a in t[r]){if(!isNaN(a)||!Object.prototype.hasOwnProperty.call(t[r],a))continue;const n=t[r][a],s=e.datafields.indexOf(r);"width"===a&&"*"===l.widths[s]?l.widths[s]=n:e.storePDFStyle({prop:a,value:n,toUpdate:o+r})}}if(e.styleInfo=l,s(o,"header"),s(r,"cell"),n){for(let t in n){if(!Object.prototype.hasOwnProperty.call(n,t)||-1!==t.indexOf("alt"))continue;const a=n[t];if(isNaN(t))"height"===t?l.defaultHeight=parseFloat(a)/1.4:e.storePDFStyle({prop:t,value:a,toUpdate:"row"});else for(let o in a)Object.prototype.hasOwnProperty.call(a,o)&&("height"===o?l.heights[parseFloat(t)+e.headerRows]=parseFloat(a[o])/1.4:e.storePDFStyle({prop:o,value:a[o],toUpdate:"row"+t}))}if(n.alternationCount)for(let e=0;e<n.alternationCount;e++){const t={};n[`alternationIndex${e}Color`]&&(t.color=n[`alternationIndex${e}Color`]),n[`alternationIndex${e}BackgroundColor`]&&(t.fillColor=n[`alternationIndex${e}BackgroundColor`]),l.styles["rowN"+e]=t}}}storePDFStyle(e){const t=this;let a=t.styleInfo.styles[e.toUpdate];a||(a={},t.styleInfo.styles[e.toUpdate]=a);let o=e.value;switch(e.prop){case"backgroundColor":a.fillColor=o;break;case"color":a.color=o;break;case"fontSize":a.fontSize=parseFloat(o);break;case"fontStyle":"italic"===o&&(a.italics=!0);break;case"fontWeight":"bold"===o&&(a.bold=!0);break;case"textAlign":a.alignment=o}}wrapPDFColumns(e,t){const a=this,o=this.styleInfo,r="portrait"===e.pageOrientation?655:1155,n=[];let l=0;for(let e=0;e<o.widths.length;e++){let s,i=o.widths[e];if("*"===i?s=r/6:"string"==typeof i&&-1!==i.indexOf("%")?(s=Math.min(r,Math.floor(parseFloat(i)/100*r)),s===r&&(i="*")):(i=parseFloat(i),i>=r?(s=r,i="*"):(s=i,i/=1.4)),void 0===n[l]){const o=[];n[l]={body:o,width:s,widths:[i],datafields:[a.datafields[e]]},t[e]=l;continue}const c=n[l];c.width+s>r?(l++,e--):(t[e]=l,c.width+=s,c.widths.push(i),c.datafields.push(a.datafields[e]))}return n}getPDFHeader(e,t,a){const o=this,r=[],n=o.headerRows,l=[],s=[];let i,c,p=[];o.complexHeader?(i=o.complexHeader,c=o.complexDataFieldsHeader):(i=[Object.values(o.data[0])],c=i);for(let e=0;e<n;e++){const t=i[e],o=c[e];for(let r=0;r<t.length;r++){let n=a[r]||0;l[n]||(l[n]=[],s[n]=[]),l[n][e]||(l[n][e]=[],s[n][e]=[]),l[n][e].push(t[r]),s[n][e].push(o[r])}}function m(e,t,a,o){for(let r=0;r<n;r++){const l=e[r],s=t[r],i=[];for(let e=0;e<l.length;e++){const a=s[e];let c=1,p=1;if(s[e-1]&&s[e-1]===a||t[r-1]&&t[r-1][e]===a){i.push({});continue}let m=e+1;for(;s[m]&&s[m]===s[m-1];)c++,m++;for(m=r+1;t[m]&&t[m][e]===a;)p++,m++;const d=r===n-1||p+r===n?o.datafields[e]:null,f={text:l[e],colSpan:c,rowSpan:p};d?f.style=["header","header"+d]:(f.alignment="center",f.style="header"),i.push(f)}a.push(i)}}for(let e=0;e<t.length;e++)p=[],m(l[e],s[e],p,t[e]),r.push(p);return r}createGroupHeaderRow(e,t){for(let a=0;a<e.length;a++){const o=Object.assign({},t),r=e[a].datafields.length,n=[o];o.colSpan=r,n.length=r,n.fill({},1,r-1),e[a].body.push(n)}}getUniqueStylePDF(e,t,a){const o=this.style;if(!o||!o.columns||!o.columns[t])return;const r=o.columns[t][a];r&&(e.fillColor=function(e){const t=/rgba\((\d+),(\d+),(\d+)\,(\d*.\d+|\d+)\)/gi.exec(e.replace(/\s/g,""));if(null===t)return e;const a=parseFloat(t[1]).toString(16).toUpperCase(),o=parseFloat(t[2]).toString(16).toUpperCase(),r=parseFloat(t[3]).toString(16).toUpperCase();return"#"+"0".repeat(2-a.length)+a+"0".repeat(2-o.length)+o+"0".repeat(2-r.length)+r}(r.background),e.color=r.color.toLowerCase())}setIndentation(e,t){if(0!==t.j)return;const a=this;if(a.actualHierarchy){const o=t.currentRecord;void 0!==o._expanded?(e.marginLeft=25*(o._level-1),e.text=a.collapseChar+" "+t.value):e.marginLeft=25*(o._level-1)+6}else t.outlineLevel>1&&(e.marginLeft=7.5*(t.outlineLevel-1))}addBodyImageToMap(e,t,a,o){const{row:r,column:n}=e.position||{},l=e;o&&(null===t||null===a||r&&n||(e.position||(e.position={}),e.position=Object.assign({},e.position,{row:t,column:o.indexOf(a)+1})),l.totalWidth=l.width,l.totalHeight=l.height),this.buildImageMap({imageToAdd:l,idx:1});let s=this.worksheetImageIds.get(1);s||(s=new Map,this.worksheetImageIds.set(1,s));const i=this.worksheetImages.get(1);i?i.push(l):this.worksheetImages.set(1,[l]),s.get(e.id)||s.set(e.id,{index:s.size,type:e.imageType})}buildImageMap(e){const{imageToAdd:t,idx:a}=e,o=this.images.get(t.id);if(o){const e=o.find((e=>e.sheetId===a));e?e.image.push(t):o.push({sheetId:a,image:[t]})}else this.images.set(t.id,[{sheetId:a,image:[t]}]),this.workbookImageIds.set(t.id,{type:t.imageType,index:this.workbookImageIds.size})}createXmlPart(e,t){const o=a.createHeader({encoding:"UTF-8",standalone:"yes"}),r=a.createXml(e);return t?r:`${o}${r}`}generateWorksheetImages(e,t,a){const o=this;this.images=new Map,this.worksheetImages=new Map,this.worksheetHeaderFooterImages=new Map,this.workbookImageIds=new Map,this.worksheetImageIds=new Map;let r=0,n=0,l=0;if(o.addImageToCell){for(let e=1+(o.headerContent?o.headerContent.length:0);e<a.length;e++){const t=a[e];for(let a=0;a<o.datafields.length;a++){const r=o.datafields[a];let n=t[r];if(n&&Array.isArray(n)){for(let a=0;a<n.length;a++){const s=o.addImageToCell(e+l++,r,n[a],n,t,a);s&&(t[r]="",this.addBodyImageToMap(s.image,1+e,r,o.datafields))}continue}const s=o.addImageToCell(e+l++,r,n,n,t,0);s&&(t[r]="",s.value&&s.value!==n&&(t[r]=s.value),this.addBodyImageToMap(s.image,1+e,r,o.datafields))}}if(o.headerContent)for(let e=0;e<o.headerContent.length;e++){const t=a[e];for(let a=0;a<o.datafields.length;a++){const r=o.datafields[a],n=t[r],l=o.addImageToCell(e+1,r,n,n,t,0);l&&(t[r]="",this.addBodyImageToMap(l.image,1+e,r,o.datafields))}}this.images.forEach((t=>{const a=t[0].image[0],{base64:o,imageType:r}=a,l="jpg"===r?"jpeg":r,s=(e,t)=>{e||(e="");const a=atob(e),o=new Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);const r=new Uint8Array(o);return new Blob([r],{type:t})};let i;i=o&&Array.isArray(o)?s(o[0].split(",")[1],"image/"+l):s(o.split(",")[1],"image/"+l),e.file(`xl/media/image${++n}.${l}`,i,!0)}))}let s=0;var i=e=>Math.ceil(9525*e),c=(e,t,a,o)=>({name:"xdr:pic",children:[f(e,t+1),p(e,a+1),m(e,o)]}),p=(e,t)=>{let a;if(e.transparency){const t=Math.min(Math.max(e.transparency,0),100);a=[{name:"a:alphaModFix",properties:{rawMap:{amt:1e5-Math.round(1e3*t)}}}]}if(e.recolor)switch(a||(a=[]),e.recolor.toLocaleLowerCase()){case"grayscale":a.push({name:"a:grayscl"});break;case"sepia":a.push(getDuoTone({color:"black"},{color:"D9C3A5",tint:50,saturation:180}));break;case"washout":a.push({name:"a:lum",properties:{rawMap:{bright:"70000",contrast:"-70000"}}})}return{name:"xdr:blipFill",children:[{name:"a:blip",properties:{rawMap:{cstate:"print","r:embed":`rId${t}`,"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships"}},children:a},{name:"a:stretch",children:[{name:"a:fillRect"}]}]}},m=(e,t)=>{const a={name:"a:xfrm",children:[{name:"a:off",properties:{rawMap:{x:0,y:0}}},{name:"a:ext",properties:{rawMap:{cx:t.width,cy:t.height}}}]};if(e.rotation){const t=e.rotation;a.properties={rawMap:{rot:6e4*Math.min(Math.max(t,0),360)}}}return{name:"xdr:spPr",children:[a,{name:"a:prstGeom",properties:{rawMap:{prst:"rect"}},children:[{name:"a:avLst"}]}]}},d=e=>{const t=[{name:"a:ext",properties:{rawMap:{uri:"{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"}},children:[{name:"a16:creationId",properties:{rawMap:{id:"{822E6D20-D7BC-2841-A643-D49A6EF008A2}","xmlns:a16":"http://schemas.microsoft.com/office/drawing/2014/main"}}}]}];switch(e.recolor&&e.recolor.toLowerCase()){case"grayscale":case"sepia":case"washout":t.push({name:"a:ext",properties:{rawMap:{uri:"{C183D7F6-B498-43B3-948B-1728B52AA6E4}"}},children:[{name:"adec:decorative",properties:{rawMap:{val:"0","xmlns:adec":"http://schemas.microsoft.com/office/drawing/2017/decorative"}}}]})}return{name:"a:extLst",children:t}},f=(e,t)=>({name:"xdr:nvPicPr",children:[{name:"xdr:cNvPr",properties:{rawMap:{id:t,name:e.id,descr:null!=e.altText?e.altText:void 0}},children:[d(e)]},{name:"xdr:cNvPicPr",properties:{rawMap:{preferRelativeResize:"0"}},children:[{name:"a:picLocks"}]}]}),h=(e,t)=>({name:`xdr:${e}`,children:[{name:"xdr:col",textNode:t.col.toString()},{name:"xdr:colOff",textNode:t.offsetX.toString()},{name:"xdr:row",textNode:t.row.toString()},{name:"xdr:rowOff",textNode:t.offsetY.toString()}]}),g={getTemplate(e){const{sheetIndex:t}=e,a=o.worksheetImages.get(t),r=o.worksheetImageIds.get(t);return{name:"xdr:wsDr",properties:{rawMap:{"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"}},children:a.map(((e,t)=>{const a=(e=>{e.fitCell=!!e.fitCell||!e.width||!e.height;const{position:t={},fitCell:a,width:o=0,height:r=0,totalHeight:n,totalWidth:l}=e,{offsetX:s=0,offsetY:c=0,row:p=1,rowSpan:m=1,column:d=1,colSpan:f=1}=t;return{from:{row:p-1,col:d-1,offsetX:i(s),offsetY:i(c)},to:{row:p-1+(a?1:m-1),col:d-1+(a?1:f-1),offsetX:i(o+s),offsetY:i(r+c)},height:i(n||r),width:i(l||o)}})(e);return{name:"xdr:twoCellAnchor",properties:{rawMap:{editAs:"absolute"}},children:[h("from",a.from),h("to",a.to),c(e,t,r.get(e.id).index,a),{name:"xdr:clientData"}]}}))}}};const u=e=>this.createXmlPart(g.getTemplate({sheetIndex:e}));var x={getTemplate(e){const{Id:t,Type:a,Target:o}=e;return{name:"Relationship",properties:{rawMap:{Id:t,Type:a,Target:o}}}}},y={getTemplate:e=>({name:"Relationships",properties:{rawMap:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"}},children:e.map((e=>x.getTemplate(e)))})},b=y;const w=e=>{const t=this.worksheetImageIds.get(e)||[],a=[];for(const[e,o]of t)a.push({Id:`rId${o.index+1}`,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",Target:`../media/image${this.workbookImageIds.get(e).index+1}.${o.type}`});return this.createXmlPart(y.getTemplate(a))};var C=(t,a)=>{const o=`xl/drawings/drawing${a+1}.xml`,r=`xl/drawings/_rels/drawing${a+1}.xml.rels`;e.file(r,w(t)),e.file(o,u(t))};for(let e=1;e<a.length;e++){this.worksheetImages.has(e)&&(C(e,s),r=s,s++)}var v=this.exportAsTable?1:0;e.file("xl/worksheets/_rels/sheet1.xml.rels",(({drawingIndex:e,tableIndex:t}={})=>{if(void 0===e&&void 0===t)return"";const a=[];null!==e&&n>0&&a.push({Id:`rId${a.length+1}`,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",Target:`../drawings/drawing${e+1}.xml`}),null!==t&&a.push({Id:`rId${a.length+1}`,Type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",Target:"../tables/table1.xml"});const o=b.getTemplate(a);return this.createXmlPart(o)})({tableIndex:v,drawingIndex:r}))}exportToXLSX(e,t,a){try{JSZip}catch(e){throw new Error("Missing reference to 'jszip.min.js'.")}const o=this;let r=o.style;if(e=o.processGroupingInformation(e,!0),o.data=e,o.getColumnsArray(),o.complexHeaderMergedCells=[],o.complexHeaderMergeInfo)for(let e in o.complexHeaderMergeInfo)if(Object.prototype.hasOwnProperty.call(o.complexHeaderMergeInfo,e)){const t=o.complexHeaderMergeInfo[e];if(t.from[0]===t.to[0]&&t.from[1]===t.to[1])continue;o.complexHeaderMergedCells.push({from:o.columnsArray[t.from[1]]+(t.from[0]+1),to:o.columnsArray[t.to[1]]+(t.to[0]+1)})}o.getConditionalFormatting(),r||(r=o.generateDefaultStyle(e));const n=new JSZip,l=n.folder("_rels"),s=n.folder("docProps"),i=n.folder("xl");if(o.headerContent){const t=o.headerContent,a=[];for(let e=0;e<t.length;e++){const r=t[e].cells;let n={};for(let e=0;e<o.datafields.length;e++){const t=o.datafields[e];r[t]?n[t]=r[t]:n[t]=null}a.push(n)}e=[...a,...e]}if(o.footerContent){const t=o.footerContent,a=[];for(let e=0;e<t.length;e++){const r=t[e].cells;let n={};for(let e=0;e<o.datafields.length;e++){const t=o.datafields[e];r[t]?n[t]=r[t]:n[t]=null}a.push(n)}e=[...e,...a]}this.generateWorksheetImages(n,i,e);const c=o.generateSharedStrings(e),p=c.collection,m=c.xml,d=o.generateStyles(r),f=o.groupBy?o.generateSheet1WithGrouping(e,p):o.generateSheet1(e,p,o.datafields,o.columnsArray),h=o.generateAuxiliaryFiles();let g=!1;const u=this.worksheetImages.get(1);u&&u.length&&(g=!0);const x=i.folder("_rels"),y=i.folder("theme"),b=i.folder("worksheets");if(g){i.folder("media"),i.folder("drawings"),i.folder("drawings/_rels")}if(l.file(".rels",h._relsRels),s.file("app.xml",h.docPropsAppXml),s.file("core.xml",h.docPropsCoreXml),x.file("workbook.xml.rels",h.xl_relsWorkbookXmlRels),y.file("theme1.xml",h.xlThemeTheme1Xml),b.file("sheet1.xml",f),i.file("sharedStrings.xml",m),i.file("styles.xml",d),i.file("workbook.xml",h.xlWorkbookXml),n.file("[Content_Types].xml",h.Content_TypesXml),this.spreadsheets){let e=2;for(let t=0;t<this.spreadsheets.length;t++){const a=this.spreadsheets[t],r=a.dataFields;let n=[...a.dataSource],l=[];for(let e=0;e<a.columns.length;e++){const t=a.columns[e];"string"==typeof t?l[t]=t:l[t.dataField]=t.label}n.splice(0,0,l);const s=o.generateSheet1(n,p,r,o.getColumnsArrayFromDataFields(r),e);b.file("sheet"+e+++".xml",s)}}if(this.exportAsTable){const t=Object.values(o.data[0]),a=o.groupBy&&o.groupBy.length?o.groupDimensionEnd:o.columnsArray[o.columnsArray.length-1]+(e.length-1);let r=`<table xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" mc:Ignorable="xr xr3" id="1" name="Table1" displayName="Table1" ref="A${this.xlsxStartIndex}:${a}" totalsRowShown="0">\n<autoFilter ref="A${this.xlsxStartIndex}:${a}">`;for(let e=0;e<t.length;e++)r+=`<filterColumn colId="${e}" hiddenButton="0"/>\n`;r+="</autoFilter>";let n=`\n<tableColumns count="${t.length}">`;for(let e=0;e<t.length;e++){n+=`<tableColumn id="${e+1}" name="${t[e]}" dataCellStyle="Normal"/>\n`}n+="\n</tableColumns>",r+=n,r+='\n <tableStyleInfo name="TableStyleLight1" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/>\n</table>';i.folder("tables").file("table1.xml",r)}n.generateAsync({type:"blob",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}).then((function(e){return!t&&a&&a(e),o.downloadFile(e,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",t)})),delete o.conditionalFormattingXLSX,delete o.complexHeaderMergeInfo,delete o.defaultRowHeight,delete o.rowHeight}processGroupingInformation(e,t){const a=this;if(!a.groupBy)return e;let o;if(e=e.slice(0),a.exportHeader&&(t&&a.complexHeader?(o=e.slice(0,a.complexHeader.length),e.splice(0,a.complexHeader.length)):(o=[e[0]],e.splice(0,1))),e.length>1){const t=function(e,t){let a;switch(t||typeof e){case"string":a=(new Intl.Collator).compare;break;case"number":a=function(e,t){return e-t};break;case"boolean":case"bool":a=function(e,t){return e===t?0:!1===e?-1:1};break;case"date":case"time":case"dateTime":e instanceof Date?a=function(e,t){return e.getTime()-t.getTime()}:(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)&&(a=function(e,t){return e.compare(t)});break;case"object":if(e instanceof Date)a=function(e,t){return e.getTime()-t.getTime()};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)a=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;a=function(t,a){return e.compareComplexNumbers(t,a)}}}return a};(function(e,a,o,r){if(!e||!Array.isArray(e)||0===e.length||!a||Array.isArray(a)&&0===a.length)return;"string"==typeof a&&(a=[a]);const n=[],l=[];void 0===o&&(o=[]);for(let r=0;r<a.length;r++)void 0===o[r]||"asc"===o[r]||"ascending"===o[r]?n[r]=1:n[r]=-1,l[r]=t(e[0][a[r]]);r?r(e,a,o,l):e.sort((function(e,t){for(let o=0;o<a.length;o++){const r=l[o](e[a[o]],t[a[o]]);if(0===r){if(a[o+1])continue;return void 0!==e._index?(e._index-t._index)*n[o]:0}return r*n[o]}}))})(e,a.groupBy)}return o&&(e=o.concat(e)),a.getGroupLabels(e),e}exportToXML(e,t){const a=this.datafields.slice(0);let o='<?xml version="1.0" encoding="UTF-8" ?>\n<table>\n';return-1===a.indexOf("rows")&&a.push("rows"),o+=function e(t,o){let r="";for(let n=0;n<t.length;n++){const l=t[n];r+=o+"<row>\n";for(let t=0;t<a.length;t++){const n=a[t];if("rows"!==n)r+=o+` <${n}>${l[n]}</${n}>\n`;else{if(!l.rows)continue;r+=`${o} <rows>\n${e(l.rows,o+" ")}${o} </rows>\n`}}r+=o+"</row>\n"}return r}(e," ")+"</table>",t?this.downloadFile(o,"application/xml",t):o}formatDate(e,t){if(!Smart.Utilities.DateTime)return e;try{return new Smart.Utilities.DateTime(e).toString(t)}catch(t){return e}}formatNumber(e,t){if(!Smart.Utilities.NumberRenderer)return e;const a=(new Smart.Utilities.NumberRenderer).formatNumber(e,t);return void 0===a?e:a}generateAuxiliaryFiles(){const e=(new Date).toISOString(),t=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:creator>Smart HTML Elements</dc:creator><cp:lastModifiedBy>Smart HTML Elements</cp:lastModifiedBy><dcterms:created xsi:type="dcterms:W3CDTF">${e}</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">${e}</dcterms:modified></cp:coreProperties>`;let a='<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>',o=1;if(this.spreadsheets)for(let e=0;e<this.spreadsheets.length;e++){const t=2+e;o++,a+=`<Relationship Id="rId${t}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${t}.xml"/>`}const r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${a}<Relationship Id="rId${++o}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/><Relationship Id="rId${++o}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId${++o}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/></Relationships>`;let n='<sheet name="Sheet1" sheetId="1" r:id="rId1"/>';if(this.spreadsheets)for(let e=0;e<this.spreadsheets.length;e++){const t=2+e;n+=`<sheet name="${this.spreadsheets[e].label}" sheetId="${t}" r:id="rId${t}"/>`}const l=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15 xr xr6 xr10 xr2" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6" xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"><fileVersion appName="xl" lastEdited="7" lowestEdited="7" rupBuild="20325"/><workbookPr defaultThemeVersion="166925"/><mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"><mc:Choice Requires="x15"><x15ac:absPath url="C:UsersjqwidgetsDesktop" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/></mc:Choice></mc:AlternateContent><xr:revisionPtr revIDLastSave="0" documentId="13_ncr:1_{0DEDCB6D-5403-4CD8-AAA5-59B6D238A8B6}" xr6:coauthVersionLast="34" xr6:coauthVersionMax="34" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}"/><bookViews><workbookView xWindow="0" yWindow="0" windowWidth="19200" windowHeight="6950" xr2:uid="{0CB664E6-3800-4A88-B158-B46A682E7484}"/></bookViews><sheets>${n}</sheets><calcPr calcId="179021"/><extLst><ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:workbookPr chartTrackingRefBase="1"/></ext></extLst></workbook>`,s=this.worksheetImages.get(1);let i="";s&&s.length&&(i='<Override PartName="/xl/drawings/drawing1.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml"/>');let c="";this.exportAsTable&&(c='<Override PartName="/xl/tables/table1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"/>');let p='<Override PartName = "/xl/worksheets/sheet1.xml" ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />';if(this.spreadsheets)for(let e=0;e<this.spreadsheets.length;e++)p+=`<Override PartName = "/xl/worksheets/sheet${e+2}.xml" ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />`;return{_relsRels:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',docPropsAppXml:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size="2" baseType="variant"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>1</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector size="1" baseType="lpstr"><vt:lpstr>Sheet1</vt:lpstr></vt:vector></TitlesOfParts><Company></Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>16.0300</AppVersion></Properties>',docPropsCoreXml:t,xl_relsWorkbookXmlRels:r,xlThemeTheme1Xml:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="44546A"/></a:dk2><a:lt2><a:srgbClr val="E7E6E6"/></a:lt2><a:accent1><a:srgbClr val="4472C4"/></a:accent1><a:accent2><a:srgbClr val="ED7D31"/></a:accent2><a:accent3><a:srgbClr val="A5A5A5"/></a:accent3><a:accent4><a:srgbClr val="FFC000"/></a:accent4><a:accent5><a:srgbClr val="5B9BD5"/></a:accent5><a:accent6><a:srgbClr val="70AD47"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Calibri Light" panose="020F0302020204030204"/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Calibri" panose="020F0502020204030204"/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}" vid="{4A3C46E8-61CC-4603-A589-7422A47A8E4A}"/></a:ext></a:extLst></a:theme>',xlWorkbookXml:l,Content_TypesXml:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="bin" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings"/><Default Extension="jpeg" ContentType="image/jpeg"/><Default Extension="png" ContentType="image/png"/><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>${p}<Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>${c}${i}<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>`}}generateDefaultStyle(e){const t=this,a={},o=t.datafields,r=t.complexHeader?e[t.complexHeader.length]:e[+t.exportHeader];if(!r)return a;for(let e=0;e<o.length;e++){r[o[e]]instanceof Date&&(a.columns||(a.columns=[]),a.columns[o[e]]={format:"d"})}return a}generateGroupRow(e){const t=e.rowNumber,a="A"+t,o=` <row r="${t}" outlineLevel="${e.outlineLevel}" spans="1:${e.numberOfColumns}"${this.getCustomRowHeight(t-1)} x14ac:dyDescent="0.45">\n <c r="${a}" t="s" s="0">\n <v>${e.sharedStringIndex}</v>\n </c>\n </row>\n`;return e.mergedCells.push({from:a,to:this.columnsArray[e.numberOfColumns-1]+t}),o}generateSharedStrings(e){const t=this,a=t.datafields,o=[];let r="",n=0,l=0;function s(e){n++,-1===o.indexOf(e)&&(l++,o.push(e),e=(e=(e=(e=(e=e.replace(/&(?!amp;)/g,"&amp;")).replace(/'/g,"&apos;")).replace(/"/g,"&quot;")).replace(/>/g,"&gt;")).replace(/</g,"&lt;"),r+=`<si><t>${e}</t></si>`)}const i=(e,a)=>{for(let o=0;o<e.length;o++){const r=e[o];for(let e=0;e<a.length;e++){let o=r[a[e]];null!==o||t.allowNull||(o=""),"string"==typeof o&&s(o)}}};if(i(e,a),t.spreadsheets)for(let e=0;e<t.spreadsheets.length;e++){const a=t.spreadsheets[e],o=a.dataFields;let r=[...a.dataSource],n=[];for(let e=0;e<a.columns.length;e++){const t=a.columns[e];"string"==typeof t?n[t]=t:n[t.dataField]=t.label}r.splice(0,0,n),i(r,o)}if(t.groupLabels)for(let e=0;e<t.groupLabels.length;e++)s(t.groupLabels[e]);return r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="${n}" uniqueCount="${l}">${r}</sst>`,{collection:o,xml:r}}generateSheet1(e,t,a,o,r){const n=this,l=o.length,s=e.length,i=o[l-1]+s,c=n.getFilters(),p=[].concat(n.complexHeaderMergedCells);let m=0;const d=n.freezeHeader?`<sheetView rightToLeft="0" workbookViewId="0">\n <pane state="frozen" topLeftCell="A${n.xlsxStartIndex+1}" ySplit="${n.xlsxStartIndex}"/>\n </sheetView>`:"";let f=n.getCustomColumnWidths(o);if(r>1){let e="<cols>";for(let t=0;t<o.length;t++)e+='<col min="1" max="1" width="25" hidden="0" bestFit="0" customWidth="1"/>';e+="</cols>",f=e}let h=n.protectSheet?'<sheetProtection sheet="1"/>':"";if(n.protectSheet&&n.protectSheet.password){h=`<sheetProtection sheet="1" password="${function(e){const t=e.length;if(!t)return"";const a=new Array(t+1);a[0]=t;for(let o=1;o<=t;o++)a[o]=255&e.charCodeAt(o-1);let o=0;for(let e=a.length-1;e>=0;e--){o=((0==(16384&o)?0:1)|o<<1&32767)^a[e]}return(52811^o).toString(16).toUpperCase().padStart(4,"0")}(n.protectSheet.password)}"/>`}let g=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{7F25248B-C640-4C64-AD47-C0EA0E5D90D0}">\n <sheetPr filterMode="${""!==c}" />\n <dimension ref="A1:${i}" />\n <sheetViews>\n <sheetView ${r<=1?'tabSelected="1"':""} workbookViewId="0" />\n ${n.freezeColumnsCount>0?`\n<sheetView rightToLeft="0" workbookViewId="0">\n<pane state="frozen" topLeftCell="B1" xSplit="${n.freezeColumnsCount}"/>\n</sheetView>\n`:""}\n ${d}\n </sheetViews>\n <sheetFormatPr defaultRowHeight="14.5" x14ac:dyDescent="0.35" />${f}\n <sheetData>\n`;function u(e,t){return o[e]+t}for(let o=0;o<=e.length;o++){const r=e[o],s=o+1;let i="";if(n.actualHierarchy){const t=e[o-1];t&&t._collapsed&&(!r||t._level>r._level)&&(i=' collapsed="true"')}if(o===e.length){i&&(g+=` <row r="${s}" outlineLevel="${Math.max(e[o-1]._level-2,0)}" hidden="false" collapsed="true" />\n`);break}let c=` <row r="${s}"${n.getOutlineLevel(r)} hidden="${r._hidden||r._collapsed||!1}"${i} spans="1:${l}"${n.getCustomRowHeight(s-1)} customHeight="1" x14ac:dyDescent="0.45">\n`;for(let e=0;e<a.length;e++){const o=n.getXLSXCellStyle(u(e,s));c+=n.getActualCellData(r[a[e]],{r:u(e,s),s:o},t,s,a[e])}c+=" </row>\n",g+=c}if(n.headerContent)for(let e=0;e<n.headerContent.length;e++){const t=n.headerContent[e];t.style&&t.style.mergeAcross&&p.push({from:"A"+(e+1),to:o[l-1]+(e+1)})}if(n.footerContent)for(let t=0;t<n.footerContent.length;t++){const a=n.footerContent[t];a.style&&a.style.mergeAcross&&p.push({from:"A"+(e.length-t),to:o[l-1]+(e.length-t)})}return g+=` </sheetData>${n.conditionalFormattingXLSX.conditions}${c}${n.getMergedCells(p)}\n ${h}\n <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />\n <pageSetup paperSize="9" orientation="portrait" r:id="rId1" />\n ${(e=>{let t="";const a=this.worksheetImages.get(e);return a&&a.length&&(t+=`<drawing r:id="rId${++m}"/>`),t})(1)}\n ${(()=>{if(!n.exportAsTable)return"";return`<tableParts count="1">\n <tablePart r:id="rId${++m}"/>\n </tableParts>`})()}\n</worksheet>`,g}generateSheet1WithGrouping(e,t){const a=this,o=a.columnsArray.length,r=e.length,n=a.columnsArray[o-1]+r,l=a.datafields,s=[].concat(a.complexHeaderMergedCells);let i=0;let c=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{7F25248B-C640-4C64-AD47-C0EA0E5D90D0}">\n <dimension ref="A1:${n}" />\n <sheetViews>\n <sheetView tabSelected="1" workbookViewId="0" />\n ${a.freezeHeader?`<sheetView rightToLeft="0" workbookViewId="0">\n <pane state="frozen" topLeftCell="A${a.xlsxStartIndex+1}" ySplit="${a.xlsxStartIndex}"/>\n </sheetView>`:""}\n </sheetViews>\n <sheetFormatPr defaultRowHeight="14.5" x14ac:dyDescent="0.35" />${a.getCustomColumnWidths()}\n <sheetData>\n`,p=0,m=[];function d(e,t){return a.columnsArray[e]+t}e:for(let r=0;r<e.length;r++){const n=e[r],i=r+1+p;let f=0,h="";if(!a.exportHeader||!a.complexHeader&&0!==r||a.complexHeader&&r>=a.complexHeader.length){let e="";for(let l=0;l<a.groupBy.length;l++){const d=a.groupBy[l],h=n[d],g=a.groups[d][h];if(e+=h,-1===m.indexOf(e)){let n=t.indexOf(g);c+=a.generateGroupRow({rowNumber:i,outlineLevel:f,numberOfColumns:o,sharedStringIndex:n,mergedCells:s}),m.push(e),r--,p++;continue e}f++}h=` outlineLevel="${f}"`}let g=` <row r="${i}"${h} spans="1:${o}"${a.getCustomRowHeight(i-1)} customHeight="1" x14ac:dyDescent="0.45">\n`;for(let e=0;e<l.length;e++){const o=a.getXLSXCellStyle(d(e,r+1));g+=a.getActualCellData(n[l[e]],{r:d(e,i),s:o},t,i,l[e])}g+=" </row>\n",c+=g}return c+=` </sheetData>${a.exportAsTable?"":a.getMergedCells(s)}\n <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />\n <pageSetup paperSize="9" orientation="portrait" r:id="rId1" />\n ${(e=>{let t="";const a=this.worksheetImages.get(e);return a&&a.length&&(t+=`<drawing r:id="rId${++i}"/>`),t})(1)}\n ${(()=>{if(!a.exportAsTable)return"";return`<tableParts count="1">\n <tablePart r:id="rId${++i}"/>\n </tableParts>`})()}\n</worksheet>`,a.groupDimensionEnd=a.columnsArray[o-1]+(r+p),a.groupRowsCount=r+p,c}isFormula(e){return null!==e&&(this.autoConvertFormulas&&e.toString().startsWith("="))}getActualCellData(e,t,a){const o=t.r,r=t.s||' s="0"';if(null!==e||this.allowNull||(e=""),e&&this.isFormula(e))return` <c r="${o}" t="s"${r}>\n <f>${e.slice(1)}</f>\n </c>\n`;if("string"==typeof e)return` <c r="${o}" t="s"${r}>\n <v>${a.indexOf(e)}</v>\n </c>\n`;if("boolean"==typeof e)return` <c r="${o}" t="b"${r}>\n <v>${+e}</v>\n </c>\n`;if(e instanceof Date){return` <c r="${o}"${r}>\n <v>${2+Math.round(this.timeBetween1900And1970/864e5)+(e.getTime()-60*e.getTimezoneOffset()*1e3)/864e5}</v>\n </c>\n`}return` <c r="${o}"${r}>\n <v>${e}</v>\n </c>\n`}getColumnsArray(){const e=this.datafields.length,t=[];function a(e){return e<26?"":String.fromCharCode(64+Math.floor(e/26))}for(let o=0;o<e;o++)t.push(a(o)+String.fromCharCode(65+(o<26?o:o%26)));this.columnsArray=t}getColumnsArrayFromDataFields(e){const t=e.length,a=[];function o(e){return e<26?"":String.fromCharCode(64+Math.floor(e/26))}for(let e=0;e<t;e++)a.push(o(e)+String.fromCharCode(65+(e<26?e:e%26)));return a}getColumnStyle(){const e=this,t=e.style;if(!t)return" .header { border: 1px solid black; padding: 5px; }\n .column { border: 1px solid black; padding: 5px; }\n .group { background-color: #FFFFFF; color: #000000; font-weight: bold; }";let a;a=t.removeDefault?{header:"",column:"",group:""}:{header:"border: 1px solid black; padding: 5px; ",column:"overflow: hidden; border: 1px solid black; padding: 5px; ",group:"background-color: #FFFFFF; color: #000000; font-weight: bold; "};const o=e.data[0];let r="";const n=t.header||{};for(let t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const r=n[t];if(o[t]){a["header"+t]||(a["header"+t]="");for(let e in r)if(Object.prototype.hasOwnProperty.call(r,e)){const o=Smart.Utilities.Core.toDash(e)+": "+r[e]+"; ";a["header"+t]+=o,"width"===e&&(a["column"+t]||(a["column"+t]=""),a["column"+t]+=o)}}else"height"===t&&e.complexHeader?a.header+="height: "+parseInt(n[t],10)/e.complexHeader.length+"px; ":a.header+=Smart.Utilities.Core.toDash(t)+": "+n[t]+"; "}const l=t.columns||{};for(let e in l){if(!Object.prototype.hasOwnProperty.call(l,e))continue;const t=l[e];if(o[e]){a["column"+e]||(a["column"+e]="");for(let o in t)isNaN(o)&&Object.prototype.hasOwnProperty.call(t,o)&&"format"!==o&&(a["column"+e]+=Smart.Utilities.Core.toDash(o)+": "+t[o]+"; ")}else a.column+=Smart.Utilities.Core.toDash(e)+": "+t+"; "}for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(r+=` .${e} { ${a[e]}}\n`);return t.custom&&(r+=`${t.custom}\n`),r}getCustomColumnWidths(e){const t=this;if(e!==t.columnsArray)return"";if(!t.style||!t.columnWidth||0===t.columnWidth.length)return"";let a="\n <cols>\n";for(let e=0;e<t.columnWidth.length;e++){let o=t.columnWidth[e];void 0!==o&&(o=Math.round(parseFloat(o))/7,a+=` <col min="${e+1}" max="${e+1}" width="${o}" customWidth="1" />\n`)}return a+=" </cols>",a}getCustomFilter(e,t){let a,o="equal";switch(e instanceof Date&&(e=(e.getTime()+this.timeBetween1900And1970)/864e5+2),t=t.toUpperCase()){case"EMPTY":a="";break;case"NOT_EMPTY":a="",o="notEqual";break;case"CONTAINS":case"CONTAINS_CASE_SENSITIVE":a=`*${e}*`;break;case"DOES_NOT_CONTAIN":case"DOES_NOT_CONTAIN_CASE_SENSITIVE":a=`*${e}*`,o="notEqual";break;case"STARTS_WITH":case"STARTS_WITH_CASE_SENSITIVE":a=`${e}*`;break;case"ENDS_WITH":case"ENDS_WITH_CASE_SENSITIVE":a=`*${e}`;break;case"EQUAL":case"EQUAL_CASE_SENSITIVE":a=e;break;case"NULL":a=null;break;case"NOT_NULL":a=null,o="notEqual";break;case"NOT_EQUAL":a=e,o="notEqual";break;case"LESS_THAN":a=e,o="lessThan";break;case"LESS_THAN_OR_EQUAL":a=e,o="lessThanOrEqual";break;case"GREATER_THAN":a=e,o="greaterThan";break;case"GREATER_THAN_OR_EQUAL":a=e,o="greaterThanOrEqual"}return` <customFilter val="${a}" operator="${o}"/>\n`}getCustomRowHeight(e){const t=this;return t.style&&(t.rowHeight[e]||t.defaultRowHeight)||""}getDatafields(e){const t=e[0],a=[];for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&"_"!==e.charAt(0)&&a.push(e);this.datafields=a}getFilters(){const e=this,t=e.filterBy;if(!t)return"";let a="";for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const r=e.datafields.indexOf(o);if(-1===r)continue;const n=t[o],l=n.filters;a+=` <filterColumn colId="${r}">\n <customFilters and="${!n.operator}">\n`;for(let t=0;t<l.length;t++)a+=e.getCustomFilter(l[t].value,l[t].condition);a+=" </customFilters>\n </filterColumn>"}return a?(a=`\n <autoFilter ref="A1:${e.columnsArray[e.columnsArray.length-1]+e.data.length}">\n${a}\n </autoFilter>`,a):""}getGroupLabels(e){const t=this,a=void 0!==t.xlsxStartIndex?t.xlsxStartIndex:+t.exportHeader,o={},r=[];for(let n=a;n<e.length;n++){const l=e[n];for(let n=0;n<t.groupBy.length;n++){const s=t.groupBy[n],i=l[s];let c=o[s];void 0===c&&(o[s]={},c=o[s]),void 0===c[i]&&(c[i]=(t.exportHeader?e[a-1][s]:s)+": "+i,r.push(c[i]))}}t.groups=o,t.groupLabels=r}getHTMLHeader(e,t){const a=this;let o="\n <thead>\n";if(!a.complexHeader){o+=" <tr>\n";for(let a=0;a<e.length;a++){const r=e[a];o+=` <th class="header header${r}">${t[0][r]}</th>\n`}return o+=" </tr>\n </thead>",o}for(let t=0;t<a.complexDataFieldsHeader.length;t++){const r=a.complexDataFieldsHeader[t];o+=" <tr>\n";for(let n=0;n<r.length;n++){const l=r[n];let s=1,i=1;if(r[n-1]&&r[n-1]===l||a.complexDataFieldsHeader[t-1]&&a.complexDataFieldsHeader[t-1][n]===l)continue;let c=n+1;for(;r[c]&&r[c]===r[c-1];)s++,c++;for(c=t+1;a.complexDataFieldsHeader[c]&&a.complexDataFieldsHeader[c][n]===l;)i++,c++;o+=` <th class="header${t===a.complexHeader.length-1||i+t===a.complexHeader.length?" header"+e[n]:""}" colspan="${s}" rowspan="${i}">${a.complexHeader[t][n]}</th>\n`}o+=" </tr>\n"}return o+=" </thead>",o}getConditionalFormatting(){const e=this,t=e.conditionalFormatting;if(!t)return void(e.conditionalFormattingXLSX={conditions:"",styles:""});const a=[];let o="",r="";for(let n=t.length-1;n>=0;n--){const l=t[n],s=e.columnsArray[e.datafields.indexOf(l.column)],i=s+(e.xlsxStartIndex+1),c=i+":"+s+e.data.length,p=l.background+l.color,m=e.getConditionalAttributes(l,i);let d=a.indexOf(p);if(-1===d){r+=` <dxf>\n <font>\n <b val="0"/>\n <i val="0"/>\n <color rgb="${"White"===l.color?"FFFFFFFF":"FF000000"}"/>\n <sz val="10"/>\n </font>\n <fill>\n <patternFill>\n <bgColor rgb="${e.toARGB(l.background)}"/>\n </patternFill>\n </fill>\n </dxf>\n`,d=a.length,a.push(p)}o+=` <conditionalFormatting sqref="${c}">\n <cfRule dxfId="${d}" text="${m.text}" rank="${m.rank}" percent="${m.percent}" bottom="${m.bottom}" equalAverage="${m.equalAverage}" aboveAverage="${m.aboveAverage}"${m.operator}${m.timePeriod} priority="${n+2}" type="${m.type}">\n${m.formula} </cfRule>\n </conditionalFormatting>\n`}r=` <dxfs count="${a.length}">\n${r} </dxfs>`,e.conditionalFormattingXLSX={conditions:o,styles:r}}getConditionalAttributes(e,t){let a=e.condition,o=e.comparator,r="",n=0,l=0,s=0,i=0,c="",p="",m="",d="";switch(a){case"equal":c="equal",m="cellIs",d=` <formula>${o}</formula>\n`;break;case"lessThan":c="lessThan",m="cellIs",d=` <formula>${o}</formula>\n`;break;case"greaterThan":c="greaterThan",m="cellIs",d=` <formula>${o}</formula>\n`;break;case"notEqual":c="notEqual",m="cellIs",d=` <formula>${o}</formula>\n`;break;case"between":c="between",m="cellIs",d=` <formula>${e.min}</formula>\n <formula>${e.max}</formula>\n`;break;case"duplicate":m="duplicateValues",d=" <formula>0</formula>\n";break;case"topNItems":n=o,m="top10";break;case"bottomNItems":n=o,s=1,m="top10";break;case"topNPercent":n=o,l=1,m="top10";break;case"bottomNPercent":n=o,l=1,s=1,m="top10";break;case"aboveAverage":i=1,m="aboveAverage",d=" <formula>0</formula>\n";break;case"belowAverage":m="aboveAverage",d=" <formula>0</formula>\n";break;case"contains":r=o,c="containsText",m="containsText",d=` <formula>NOT(ISERROR(SEARCH("${o}",${t})))</formula>\n`;break;case"doesNotContain":r=o,c="notContains",m="notContainsText",d=` <formula>ISERROR(SEARCH("${o}",${t}))</formula>\n`;break;case"dateOccur":p=` timePeriod="${o}"`,m="timePeriod"}return c&&(c=` operator="${c}" `),{text:r,rank:n,percent:l,bottom:s,equalAverage:0,aboveAverage:i,operator:c,timePeriod:p,type:m,formula:d}}getMergedCells(e){const t=this;let a="";for(let t=0;t<e.length;t++)e[t].from!==e[t].to&&(a+=`\n <mergeCell ref="${e[t].from}:${e[t].to}" />\n`);if(t.mergedCells)for(let e=0;e<t.mergedCells.length;e++){const o=t.mergedCells[e];if(o.rowspan<2&&o.colspan<2)continue;a+=`\n <mergeCell ref="${t.columnsArray[o.cell[0]]+(o.cell[1]+t.xlsxStartIndex+1)}:${t.columnsArray[o.cell[0]+o.colspan-1]+(o.cell[1]+t.xlsxStartIndex+o.rowspan)}" />\n`}return a&&(a=`\n <mergeCells count="${e.length}">${a} </mergeCells>`),a}getNumFmtIndex(e,t){let a=t.collection.indexOf(e);return-1===a?(a=t.collection.length+100,t.collection.push(e),t.xml+=`<numFmt numFmtId="${a}" formatCode="${e}"/>`):a+=100,a}getOutlineLevel(e){return this.actualHierarchy&&1!==e._level?` outlineLevel="${e._level-1}"`:""}getRowStyle(){const e=this.style;if(!e)return"";const t=e.rows;if(!t)return"";const a={row:""};let o="";for(let e in t){if(!Object.prototype.hasOwnProperty.call(t,e)||"alternationCount"===e||"alternationStart"===e||"alternationEnd"===e)continue;const o=t[e];if(-1===e.indexOf("alt"))if(isNaN(e))a.row+=Smart.Utilities.Core.toDash(e)+": "+t[e]+"; ";else{a["row"+e]||(a["row"+e]="");for(let t in o)Object.prototype.hasOwnProperty.call(o,t)&&(a["row"+e]+=Smart.Utilities.Core.toDash(t)+": "+o[t]+"; ")}else{const t=e.slice(16,17),r=e.slice(17);a["rowN"+t]||(a["rowN"+t]=""),a["rowN"+t]+="Color"===r?"color : "+o+"; ":"BorderColor"===r?"border-color : "+o+"; ":"background-color : "+o+"; "}}let r=Object.keys(a);r.sort((function(e,t){if("row"===e)return-1;if("row"===t)return 1;const a=!isNaN(e.slice(3)),o=!isNaN(t.slice(3));return a&&!o?1:!a&&o?-1:+(e<t)}));for(let e=0;e<r.length;e++)o+=` .${r[e]} { ${a[r[e]]}}\n`;return o}getTableStyle(){const e=this.style;if(!e)return' style="table-layout: fixed; border: 1px solid black; border-collapse: collapse;"';let t="table-layout: fixed; ";for(let a in e)Object.prototype.hasOwnProperty.call(e,a)&&-1===["header","columns","rows","removeDefault","custom"].indexOf(a)&&(t+=Smart.Utilities.Core.toDash(a)+": "+e[a]+"; ");return t&&(t=' style="'+t+'"'),t}getXLSXCellStyle(e){const t=this;return void 0!==t.cellStyleMapping[e]?` s="${t.cellStyleMapping[e]}"`:""}getXLSXFormat(e,t){if("number"==typeof t){let t="$";if(e&&"string"==typeof e&&e.indexOf("c")>=0&&e.indexOf("x")>=0&&(t=e.substring(0,e.indexOf("x")),e=e.substring(1+e.indexOf("x"))),!/^([a-zA-Z]\d*)$/g.test(e))return e;let a=parseFloat(e.slice(1))||0,o=a>0?"."+"0".repeat(a):"";switch(e=e.slice(0,1)){case"C":case"c":return"$"!==t?"#,0"+o+" "+t:t+"#,0"+o;case"D":case"d":return a?"#,0"+o:"0";case"E":case"e":return"0"+o+e+"000";case"F":case"f":return"0"+o;case"N":case"n":return"#,0"+o;case"P":case"p":return"#,0"+o+" %";default:return}}else if(t instanceof Date){switch(e){case"d":return"m/d/yyyy";case"D":return"nnnnmmmm dd, yyyy";case"t":return"h:m AM/PM";case"T":return"h:mm:ss AM/PM";case"f":return"nnnnmmmm dd, yyyy h:m AM/PM";case"F":return"nnnnmmmm dd, yyyy h:mm:ss AM/PM";case"M":return"mmmm d";case"Y":return"yyyy mmmm";case"FP":case"PP":return"yyyy-mm-dd hh:mm:ss";case"FT":case"PT":return"hh:mm:ss"}return e=(e=(e=(e=e.replace(/f|u|n|p|e|a|x|o/gi,"")).replace(/tt/gi,"AM/PM")).replace(/:{2,}|:\s|:$|\.$/g,"")).trim()}}processColumnStyle(e){const t=this,a=e.header,o=e.columns,r=t.data[0],n=t.xlsxStartIndex;if(t.columnWidth=[],n&&a)for(let e=0;e<t.columnsArray.length;e++){const o=t.columnsArray[e],l=o+n,s=a[t.datafields[e]];for(let e in a)if(Object.prototype.hasOwnProperty.call(a,e)&&void 0===r[e])if(t.complexHeader)for(let r=0;r<t.complexHeader.length;r++)"height"!==e?t.storeCellStyle(o+(r+1),e,a[e]):t.rowHeight[r]=` ht="${parseFloat(a.height)/t.complexHeader.length/2}"`;else{if("height"===e){t.rowHeight[n-1]=` ht="${parseFloat(a.height)/2}"`;continue}t.storeCellStyle(l,e,a[e])}if(s)for(let a in s)if(Object.prototype.hasOwnProperty.call(s,a)){if("width"===a){t.columnWidth[e]=s.width;continue}t.storeCellStyle(l,a,s[a])}}else if(a)for(let e=0;e<t.columnsArray.length;e++){const o=a[t.datafields[e]];o&&void 0!==o.width&&(t.columnWidth[e]=o.width)}if(!o)return"";for(let e=n;e<t.data.length;e++)for(let a=0;a<t.columnsArray.length;a++){const n=t.columnsArray[a]+(e+1),l=t.datafields[a],s=o[l];for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&void 0===r[e]&&t.storeCellStyle(n,e,o[e]);if(s){for(let a in s)isNaN(a)&&Object.prototype.hasOwnProperty.call(s,a)&&t.storeCellStyle(n,a,s[a],t.data[e][l]);if(s[e]){const a=s[e];for(let o in a)isNaN(o)&&Object.prototype.hasOwnProperty.call(a,o)&&a[o]&&t.storeCellStyle(n,o,a[o],t.data[e][l])}}}if(t.headerContent&&t.headerContent.length)for(let e=0;e<t.headerContent.length;e++){const a=(e,a,o)=>{for(let r=0;r<t.columnsArray.length;r++){const n=t.columnsArray[r]+e;t.storeCellStyle(n,a,o)}},o=e+1;if(t.headerContent[e].style){const r=t.headerContent[e].style,n=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"),l=e=>isNaN(e)?"00":n[(e-e%16)/16]+n[e%16],s=e=>e.startsWith("#")?e.toUpperCase():(e=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))?"#"+l(e[1])+l(e[2])+l(e[3]).toUpperCase():null;for(let e in r){let n=r[e];"height"!==e?("color"!==e&&"backgroundColor"!==e||(n=s(n)),a(o,e,n)):t.rowHeight[o-1]=` ht="${parseFloat(n)}"`}}}if(t.footerContent&&t.footerContent.length)for(let e=0;e<t.footerContent.length;e++){const a=(e,a,o)=>{for(let r=0;r<t.columnsArray.length;r++){const n=t.columnsArray[r]+e;t.storeCellStyle(n,a,o)}};let o=t.headerContent&&t.headerContent.length?t.headerContent.length:0;const r=1+t.data.length+e+o;if(t.footerContent[e].style){const o=t.footerContent[e].style,n=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"),l=e=>isNaN(e)?"00":n[(e-e%16)/16]+n[e%16],s=e=>e.startsWith("#")?e.toUpperCase():(e=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))?"#"+l(e[1])+l(e[2])+l(e[3]).toUpperCase():null;for(let e in o){let n=o[e];"height"!==e?("color"!==e&&"backgroundColor"!==e||(n=s(n)),a(r,e,n)):t.rowHeight[r-1]=` ht="${parseFloat(n)}"`}}}}processComplexHeader(e,t,a){const o=this,r={},n=-1!==["html","jpeg","pdf","png","xlsx"].indexOf(a)&&e.columngroups,l=[],s={},i={},c=[],p=[];let m=0;function d(t){for(let a=0;a<e.columngroups.length;a++){const o=e.columngroups[a];if(o.name===t)return o}}function f(e,t){const a=[];for(;e;){if(a.unshift(e[t]),!e.parentGroup)return a;e=d(e.parentGroup)}}if(n){for(let t=0;t<e.columngroups.length;t++){const a=e.columngroups[t],o=f(a,"label");s[a.name]=o,i[a.name]=f(a,"name"),m=Math.max(m,o.length)}m++;for(let e=0;e<m;e++)c[e]=[],p[e]=[]}for(let t=0;t<e.columns.length;t++){const a=e.columns[t];if(r[a.dataField]=a.label,!n)continue;if(l[t]=a.dataField,c[m-1][t]=a.label,p[m-1][t]=a.dataField,!a.columnGroup)continue;const o=s[a.columnGroup],d=i[a.columnGroup];if(o)for(let e=0;e<o.length;e++)c[e][t]=o[e],p[e][t]=d[e]}if(c.length>1){const e=Object.keys(r).length;for(let o=0;o<m-1;o++){const r={};for(let t=0;t<e;t++){if(void 0===c[o][t]){let e=o+1;for(;void 0===c[e][t];)e++;c[o][t]=c[e][t],p[o][t]=p[e][t]}r[l[t]]=c[o][t]}"xlsx"===a&&t.splice(o,0,r)}if(o.complexHeader=c,o.complexDataFieldsHeader=p,"xlsx"!==a)t.unshift(r);else{t.splice(m-1,0,r);const a={};for(let t=0;t<m;t++)for(let o=0;o<e;o++){const e=p[t][o];if(a[e]){const r=a[e].to;if(t-r[0]>1||o-r[1]>1){a[e+Math.random().toString(36)]=a[e],a[e]={from:[t,o],to:[t,o]};continue}a[e].to=[t,o]}else a[e]={from:[t,o]},a[e].to=a[e].from}o.complexHeaderMergeInfo=a}}else t.unshift(r)}processHierarchicalData(e,t){const a=this,o="xlsx"!==t?+a.exportHeader:a.xlsxStartIndex,r={},n=[];let l=0,s=!1;if(void 0===e[o]._keyDataField)return a.processNestedData(e,t,o);for(let t=o;t<e.length;t++){const a=Object.assign({},e[t]);let o=a._parentDataField;void 0===o&&(o=null),void 0===r[o]?r[o]=[a]:r[o].push(a)}if(o)for(let a=0;a<o;a++)n.push(Object.assign({},e[a])),-1===["json","pdf","xml"].indexOf(t)&&(n[a]._level=1);return"json"!==t&&"xml"!==t?function e(t,a,o){const i=r[t];if(l=Math.max(l,a),void 0!==i)for(let t=0;t<i.length;t++){const l=i[t],c=l._keyDataField;l._collapsed=o,l._level=a,n.push(l),r[c]&&(s=!0,l._expanded=void 0===l._expanded||l._expanded,e(c,a+1,o||!l._expanded))}}(null,1,!1):function e(a,o,n){const i=r[a];if(l=Math.max(l,o),void 0!==i)for(let a=0;a<i.length;a++){const l=i[a],c=l._keyDataField;let p;if("json"===t){p={};for(let e in l)Object.prototype.hasOwnProperty.call(l,e)&&"_"!==e.charAt(0)&&(p[e]=l[e])}else p=Object.assign({},l);n.push(p),r[c]&&(s=!0,p.rows=[],e(c,o+1,p.rows))}}(null,1,n),s||(a.actualHierarchy=!1),a.maxLevel=l,n}processNestedData(e,t,a){const o=this,r=[];let n=0,l=!1;if(a)for(let o=0;o<a;o++)r.push(Object.assign({},e[o])),-1===["json","pdf","xml"].indexOf(t)&&(r[o]._level=1);return"json"!==t&&"xml"!==t?function e(t,a,o,s){n=Math.max(n,o);for(let n=t;n<a.length;n++){const t=Object.assign({},a[n]);t._collapsed=s,t._level=o,r.push(t),t.children&&t.children.length>0&&(l=!0,t._expanded=void 0===t._expanded||t._expanded,e(0,t.children,o+1,s||!t._expanded)),delete t.children}}(a,e,1,!1):function e(t,a,o,s){n=Math.max(n,s);for(let n=t;n<a.length;n++){const t=Object.assign({},a[n]);1===s?r[n]=t:o[n]=t,t.children&&t.children.length>0&&(l=!0,t.rows=[],e(0,t.children,t.rows,s+1)),delete t.children}}(a,e,void 0,1),l||(o.actualHierarchy=!1),o.maxLevel=n,r}processRowStyle(e){const t=this,a=e.rows;if(t.rowHeight=[],!a)return;const o=t.xlsxStartIndex;function r(e,a,r){for(let n=0;n<t.columnsArray.length;n++){const l=t.columnsArray[n]+(e+1+o);t.storeCellStyle(l,a,r)}}a.height&&(a.height||(a.height=15),t.defaultRowHeight=` ht="${parseFloat(a.height)/2}"`);for(let e=o;e<t.data.length;e++){const l=e-o;for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&-1===e.indexOf("alt")&&isNaN(e)&&"height"!==e&&r(l,e,a[e]);if(a.alternationCount&&((void 0===a.alternationStart||l>=a.alternationStart)&&(void 0===a.alternationEnd||l<=a.alternationEnd)||a.alternationStart===a.alternationEnd)){const e=(l-(a.alternationStart||0))%a.alternationCount;a[`alternationIndex${e}Color`]&&r(l,"color",a[`alternationIndex${e}Color`]),a[`alternationIndex${e}BorderColor`]&&r(l,"borderColor",a[`alternationIndex${e}BorderColor`]),a[`alternationIndex${e}BackgroundColor`]&&r(l,"backgroundColor",a[`alternationIndex${e}BackgroundColor`])}if(t.setRowHeight){const a=t.setRowHeight(l);if(a){t.rowHeight[e]=` ht="${parseFloat(a)}"`;continue}}if(a[l])for(let s in a[l])if(Object.prototype.hasOwnProperty.call(a[l],s)){if("height"===s){t.rowHeight[e]=` ht="${parseFloat(a[l].height)/2}"`;continue}if(t.data[e]&&t.data[e][s]){function n(e,a,r,n){const l=t.datafields?t.datafields.indexOf(n):-1;if(l>=0){const n=t.columnsArray[l]+(e+1+o);t.storeCellStyle(n,a,r)}}for(let e in a[l][s])n(l,e,a[l][s][e],s);continue}r(l,s,a[l][s])}}}storeCellStyle(e,t,a){const o=this.styleMap[e];switch(t){case"backgroundColor":o.fills.fgColor=a;break;case"color":o.fonts.color=a;break;case"fontFamily":o.fonts.name=a.replace(/"/g,"'");break;case"fontSize":o.fonts.sz=Math.round(parseFloat(a)/(96/72));break;case"fontStyle":"italic"===a?o.fonts.i=!0:delete o.fonts.i;break;case"fontWeight":"bold"===a?o.fonts.b=!0:delete o.fonts.b;break;case"numFmt":o.numFmt=a;break;case"textAlign":o.alignment.horizontal=a;break;case"textDecoration":"underline"===a?o.fonts.u=!0:delete o.fonts.u;break;case"verticalAlign":"middle"===a&&(a="center"),o.alignment.vertical=a}}toARGB(e){e||(e="#FFFFFF"),e=e.replace(/\s/g,"");const t=/rgb\((\d+),(\d+),(\d+)\)/gi.exec(e);if(null!==t){const e=parseFloat(t[1]).toString(16).toUpperCase(),a=parseFloat(t[2]).toString(16).toUpperCase(),o=parseFloat(t[3]).toString(16).toUpperCase();return"FF"+"0".repeat(2-e.length)+e+"0".repeat(2-a.length)+a+"0".repeat(2-o.length)+o}const a=/rgba\((\d+),(\d+),(\d+)\,(\d*.\d+|\d+)\)/gi.exec(e);if(null!==a){const e=Math.round(255*parseFloat(a[4])).toString(16).toUpperCase(),t=parseFloat(a[1]).toString(16).toUpperCase(),o=parseFloat(a[2]).toString(16).toUpperCase(),r=parseFloat(a[3]).toString(16).toUpperCase();return"0".repeat(2-e.length)+e+"0".repeat(2-t.length)+t+"0".repeat(2-o.length)+o+"0".repeat(2-r.length)+r}const o=/^#(.)(.)(.)$/gi.exec(e);if(null!==o){const e=o[1].toUpperCase(),t=o[2].toUpperCase(),a=o[3].toUpperCase();return"FF"+e+e+t+t+a+a}return"FF"+e.toUpperCase().slice(1)}toggleableFunctionality(){const e=this;return e.actualHierarchy?`\n <style type="text/css">\n .toggle-element {\n width: 5px;\n height: 1px;\n padding-right: 5px;\n float: left;\n text-align: right;\n cursor: pointer;\n user-select: none;\n }\n\n .collapsed {\n display: none;\n }\n </style>\n <script type="text/javascript">\n window.onload = function () {\n var expandChar = '${e.expandChar}',\n collapseChar = '${e.collapseChar}',\n toggleElements = document.getElementsByClassName('toggle-element');\n\n function getParent(child) {\n var prevSibling = child.previousElementSibling;\n\n while (prevSibling) {\n if (child.getAttribute('level') > prevSibling.getAttribute('level')) {\n return prevSibling;\n }\n\n prevSibling = prevSibling.previousElementSibling;\n }\n\n }\n\n function getFirstCollapsedAncestor(child) {\n var parent = getParent(child);\n\n while (parent) {\n if (parent.firstElementChild.firstElementChild.innerHTML === expandChar) {\n return parent;\n }\n\n parent = getParent(parent);\n }\n }\n\n for (var i = 0; i < toggleElements.length; i++) {\n toggleElements[i].addEventListener('click', function (event) {\n var expanded = this.innerHTML === collapseChar,\n row = this.parentElement.parentElement,\n sibling = row.nextElementSibling;\n\n if (expanded) {\n this.innerHTML = expandChar;\n }\n else {\n this.innerHTML = collapseChar;\n }\n\n while (sibling && row.getAttribute('level') < sibling.getAttribute('level')) {\n if (expanded) {\n sibling.style.display = 'none';\n }\n else {\n var firstCollapsedAncestor = getFirstCollapsedAncestor(sibling);\n\n if (!firstCollapsedAncestor || firstCollapsedAncestor === row) {\n sibling.classList.remove('collapsed');\n sibling.style.display = null;\n }\n\n }\n\n sibling = sibling.nextElementSibling;\n }\n });\n }\n }\n <\/script>`:""}generateStyles(e){const t=this;if(t.cellStyleMapping={},0===Object.keys(e).length&&!t.complexHeader)return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2 xr" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision"><fonts count="1" x14ac:knownFonts="1"><font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><charset val="204"/><scheme val="minor"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>${t.conditionalFormattingXLSX.styles||'<dxfs count="0"/>'}<tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/><extLst><ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/></ext><ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/></ext></extLst></styleSheet>`;t.styleMap={};let a=t.headerContent?t.headerContent.length:0;a+=t.footerContent?t.footerContent.length:0;let o=t.data.length+a;t.groupBy&&t.groupBy.length&&(o+=50);for(let e=0;e<o;e++)for(let a=0;a<t.columnsArray.length;a++)t.styleMap[t.columnsArray[a]+(e+1)]={numFmts:{},fonts:{},fills:{},borders:{},alignment:{}};if(e&&e.columns)for(let a=0;a<t.columnsArray.length;a++){const o=t.datafields[a];if(!e.columns[o]||!e.columns[o].format)continue;const r=t.getXLSXFormat(e.columns[o].format,t.data[1][o]),n=t.getXLSXFormat(e.columns[o].format,t.data[t.data.length-1][o]);if(n)e.columns[o].numFmt=n;else if(r)e.columns[o].numFmt=r;else if(e.columns[o].format&&(o.toLowerCase().indexOf("date")>=0||e.columns[o].format.indexOf("d/")>=0)){let t=e.columns[o].format;switch(t){case"d":t="m/d/yyyy";break;case"D":t="nnnnmmmm dd, yyyy";break;case"t":t="h:m AM/PM";break;case"T":t="h:mm:ss AM/PM";break;case"f":t="nnnnmmmm dd, yyyy h:m AM/PM";break;case"F":t="nnnnmmmm dd, yyyy h:mm:ss AM/PM";break;case"M":t="mmmm d";break;case"Y":t="yyyy mmmm";break;case"FP":case"PP":t="yyyy-mm-dd hh:mm:ss";break;case"FT":case"PT":t="hh:mm:ss"}t=t.replace(/f|u|n|p|e|a|x|o/gi,""),t=t.replace(/tt/gi,"AM/PM"),t=t.replace(/:{2,}|:\s|:$|\.$/g,""),t=t.trim(),e.columns[o].numFmt=t}}t.processRowStyle(e),t.processColumnStyle(e);const r={};for(let e=0;e<t.complexHeaderMergedCells.length;e++){const a=t.complexHeaderMergedCells[e];parseFloat(a.to[1])!==t.complexHeader.length?(t.styleMap[a.from].alignment.horizontal="center",t.styleMap[a.from].alignment.vertical="center"):r[a.to]=a.from}const n={xml:'<font><sz val="11" /><color theme="1" /><name val="Calibri" /><family val="2" /><charset val="204" /><scheme val="minor" /></font>',collection:["default"]},l={xml:'<fill><patternFill patternType="none" /></fill><fill><patternFill patternType="gray125" /></fill>',collection:["default","gray125"]},s={xml:"",collection:[]},i={xml:'<xf fontId="0" fillId="0" borderId="1"/>',collection:["default"]};for(let e=0;e<o;e++)for(let a=0;a<t.columnsArray.length;a++){const o=t.columnsArray[a]+(e+1),c=t.styleMap[o];let p="",m="",d="",f=[],h=[],g=[],u=[];for(let e in c.fonts)if(Object.prototype.hasOwnProperty.call(c.fonts,e)){const a=c.fonts[e];switch(e){case"color":f[0]=a,p+=a?`<color rgb="${t.toARGB(a)}" />`:`<color rgb="${t.toARGB("#333333")}" />`;break;case"name":f[1]=a,p+=`<name val="${a}" />`;break;case"sz":f[2]=a,p+=`<sz val="${a}" />`;break;case"i":f[3]=a,p+="<i />";break;case"b":f[4]=a,p+="<b />";break;case"u":f[5]=a,p+="<u />"}}for(let e in c.fills)if(Object.prototype.hasOwnProperty.call(c.fills,e)){const a=c.fills[e];switch(e){case"fgColor":h[0]=a,m+=`<fgColor rgb="${t.toARGB(a)}" />`}}for(let e in c.alignment)if(Object.prototype.hasOwnProperty.call(c.alignment,e)){const t=c.alignment[e];switch(e){case"horizontal":g[0]=t,d+=`horizontal="${t}" `;break;case"vertical":g[1]=t,d+=`vertical="${t}" `}}if(f=f.toString(),h=h.toString(),""!==p){let e=n.collection.indexOf(f);-1===e&&(e=n.collection.length,n.xml+="<font>"+p+"</font>",n.collection.push(f)),u[0]=e}if(""!==m){let e=l.collection.indexOf(h);-1===e&&(e=l.collection.length,l.xml+='<fill><patternFill patternType="solid">'+m+"</patternFill></fill>",l.collection.push(h)),u[1]=e}g.length>0&&(u[2]=d),void 0!==c.numFmt&&(u[3]=t.getNumFmtIndex(c.numFmt,s));const x=u.toString();if(""!==x){let e=i.collection.indexOf(x);if(-1===e){let t="<xf ";e=i.collection.length,void 0!==u[0]&&(t+=`fontId="${u[0]}" `),void 0!==u[1]&&(t+=`fillId="${u[1]}" `),void 0!==u[3]&&(t+=`numFmtId="${u[3]}" `),void 0!==u[2]?t+=`applyAlignment="1" borderId="1"><alignment ${d}/></xf>`:t+=' borderId="1"/>',i.xml+=t,i.collection.push(x)}t.cellStyleMapping[r[o]||o]=e}}return s.collection.length&&(s.xml=`<numFmts count="${s.collection.length}">${s.xml}</numFmts>`),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2 xr" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision">${s.xml}<fonts count="${n.collection.length}" x14ac:knownFonts="1">${n.xml}</fonts><fills count="${l.collection.length}">${l.xml}</fills><borders count="2"><border><left/><right/><top/><bottom/></border><border><left style="hair"/><right style="hair"/><top style="hair"/><bottom style="hair"/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${i.collection.length}">${i.xml}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>${t.conditionalFormattingXLSX.styles}<dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/><extLst><ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/></ext><ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/></ext></extLst></styleSheet>`}})})();
Binary file
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Tests for the moment-of-intent PLG upgrade prompt. Unlike the passive
3
+ * watermark, this card is triggered when a Pro feature is actually invoked
4
+ * unlicensed, names that feature, links to a free trial, and shows at most
5
+ * once per session.
6
+ */
7
+
8
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
9
+ import { showUpgradePrompt, dismissUpgradePrompt } from './upgrade-prompt'
10
+
11
+ const CARD_ATTR = 'data-@svgrid/enterprise-upgrade'
12
+
13
+ function card(): HTMLElement | null {
14
+ return document.querySelector(`[${CARD_ATTR}]`)
15
+ }
16
+
17
+ describe('upgrade prompt (moment-of-intent PLG nudge)', () => {
18
+ beforeEach(() => {
19
+ dismissUpgradePrompt()
20
+ document.body.innerHTML = ''
21
+ })
22
+
23
+ afterEach(() => {
24
+ dismissUpgradePrompt()
25
+ })
26
+
27
+ it('renders a card naming the feature, with a trial CTA', () => {
28
+ showUpgradePrompt('Export')
29
+ const el = card()
30
+ expect(el).not.toBeNull()
31
+ expect(el!.textContent).toContain('Export')
32
+ expect(el!.textContent).toContain('Unlock SvGrid Pro')
33
+
34
+ const trial = el!.querySelector('a[data-act="trial"]') as HTMLAnchorElement
35
+ expect(trial).not.toBeNull()
36
+ expect(trial.href).toContain('svgrid.com/pricing')
37
+ expect(trial.href).toContain('ref=in-app')
38
+ expect(trial.target).toBe('_blank')
39
+ })
40
+
41
+ it('shows at most once per session', () => {
42
+ showUpgradePrompt('Export')
43
+ expect(card()).not.toBeNull()
44
+ // A second feature call must not stack a second card.
45
+ showUpgradePrompt('Import')
46
+ expect(document.querySelectorAll(`[${CARD_ATTR}]`).length).toBe(1)
47
+ })
48
+
49
+ it('removes the card on close and does not re-show for the session', () => {
50
+ vi.useFakeTimers()
51
+ try {
52
+ showUpgradePrompt('Print')
53
+ const closeBtn = card()!.querySelector('[data-act="x"]') as HTMLButtonElement
54
+ closeBtn.click()
55
+ // close animates out, then removes the node after the fade.
56
+ vi.advanceTimersByTime(300)
57
+ expect(card()).toBeNull()
58
+ // A later feature call must not bring it back this session (the flag
59
+ // stays set; only dismissUpgradePrompt() re-arms it).
60
+ showUpgradePrompt('AI assistant')
61
+ expect(card()).toBeNull()
62
+ } finally {
63
+ vi.useRealTimers()
64
+ }
65
+ })
66
+
67
+ it('falls back to a generic message when no feature is named', () => {
68
+ showUpgradePrompt()
69
+ expect(card()!.textContent).toContain('Pro')
70
+ })
71
+ })
@@ -0,0 +1,148 @@
1
+ // Product-led-growth (PLG) upgrade nudge, shown at the *moment of intent*: the
2
+ // instant a developer actually calls a Pro feature (export / import / print /
3
+ // AI) without a license key set. Unlike the passive corner watermark
4
+ // (watermark.ts), this is a one-click contextual card that names the feature
5
+ // they just used and links straight to a free trial.
6
+ //
7
+ // Rules of the road:
8
+ // - Soft, never blocking. The feature already ran; this only nudges.
9
+ // - Shows once per session (SPA lifetime). Once shown - whether the user
10
+ // acts on it or closes it - it stays quiet for the rest of the session.
11
+ // Calling setLicenseKey() silences it before it ever appears.
12
+ // - Storage-free: no cookies, no localStorage, no sessionStorage. State is
13
+ // a single in-memory flag, so the library keeps its "zero web storage"
14
+ // promise (see docs/help/security.md). A hard reload may show it once
15
+ // more - by design; that's still a moment-of-intent nudge.
16
+ // - SSR-safe: every DOM access is guarded. On the server it's a no-op.
17
+ // - Zero dependencies, inline styles - no CSS file to import, nothing to
18
+ // bundle, works in any host app regardless of its styling.
19
+
20
+ const CARD_ATTR = 'data-@svgrid/enterprise-upgrade'
21
+ const PRICING_URL = 'https://www.svgrid.com/pricing'
22
+ // ?ref=in-app lets us measure how many trials start from this exact prompt
23
+ // vs. the pricing page itself - the whole point of a moment-of-intent CTA.
24
+ const TRIAL_URL = 'https://www.svgrid.com/pricing?ref=in-app&utm_source=@svgrid/enterprise&utm_medium=upgrade-prompt'
25
+
26
+ let shownThisSession = false
27
+
28
+ /** Human-readable labels for the Pro surfaces that gate behind a license. */
29
+ export type ProFeatureLabel =
30
+ | 'Export'
31
+ | 'Import'
32
+ | 'Print'
33
+ | 'AI assistant'
34
+ | 'Pivot'
35
+
36
+ /**
37
+ * Show the contextual upgrade prompt for `feature`. No-ops if one has already
38
+ * been shown this session, a card is already up, or we're on the server. Safe
39
+ * to call on every Pro feature invocation - it self-throttles.
40
+ */
41
+ export function showUpgradePrompt(feature?: ProFeatureLabel | string): void {
42
+ if (shownThisSession) return
43
+ if (typeof document === 'undefined' || typeof window === 'undefined') return
44
+ if (document.querySelector(`[${CARD_ATTR}]`)) return
45
+ shownThisSession = true
46
+
47
+ const card = buildCard(feature)
48
+ document.body.appendChild(card)
49
+ // Animate in on the next frame so the transition actually runs.
50
+ requestAnimationFrame(() => {
51
+ card.style.opacity = '1'
52
+ card.style.transform = 'translateY(0)'
53
+ })
54
+ }
55
+
56
+ /**
57
+ * Remove the card if present and re-arm the once-per-session flag so a later
58
+ * `showUpgradePrompt()` can show again. Mainly for hosts that want to control
59
+ * the nudge themselves (and for tests).
60
+ */
61
+ export function dismissUpgradePrompt(): void {
62
+ shownThisSession = false
63
+ if (typeof document === 'undefined') return
64
+ document.querySelectorAll(`[${CARD_ATTR}]`).forEach((el) => el.remove())
65
+ }
66
+
67
+ // User closed or clicked through the card. Remove it, but leave
68
+ // `shownThisSession` set so it does not reappear for the rest of the session.
69
+ function close(card: HTMLElement): void {
70
+ card.style.opacity = '0'
71
+ card.style.transform = 'translateY(8px)'
72
+ window.setTimeout(() => card.remove(), 220)
73
+ }
74
+
75
+ function buildCard(feature?: ProFeatureLabel | string): HTMLElement {
76
+ const card = document.createElement('div')
77
+ card.setAttribute(CARD_ATTR, '1')
78
+ card.setAttribute('role', 'dialog')
79
+ card.setAttribute('aria-label', 'Unlock SvGrid Pro')
80
+ Object.assign(card.style, {
81
+ position: 'fixed',
82
+ bottom: '16px',
83
+ right: '16px',
84
+ zIndex: '2147483646', // one below the watermark so they never collide
85
+ width: '320px',
86
+ maxWidth: 'calc(100vw - 32px)',
87
+ boxSizing: 'border-box',
88
+ padding: '16px 16px 14px',
89
+ background: '#0f172a',
90
+ color: '#e2e8f0',
91
+ borderRadius: '12px',
92
+ border: '1px solid rgba(99,102,241,0.4)',
93
+ boxShadow: '0 12px 40px rgba(0,0,0,0.45)',
94
+ fontFamily: '-apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
95
+ fontSize: '13px',
96
+ lineHeight: '1.45',
97
+ opacity: '0',
98
+ transform: 'translateY(8px)',
99
+ transition: 'opacity 220ms ease, transform 220ms ease',
100
+ } as Partial<CSSStyleDeclaration> as CSSStyleDeclaration)
101
+
102
+ const featureName = feature ? String(feature) : 'This'
103
+ const featurePhrase = feature
104
+ ? `<strong style="color:#fff">${escapeHtml(featureName)}</strong> is a Pro feature.`
105
+ : `You just used a <strong style="color:#fff">Pro</strong> feature.`
106
+
107
+ card.innerHTML = `
108
+ <button type="button" data-act="x" aria-label="Dismiss"
109
+ style="position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;
110
+ align-items:center;justify-content:center;background:transparent;border:0;
111
+ color:#94a3b8;font-size:18px;line-height:1;cursor:pointer;border-radius:6px;">&times;</button>
112
+ <div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
113
+ <span style="display:inline-block;background:#4f46e5;color:#fff;font-size:10px;
114
+ font-weight:700;letter-spacing:0.06em;padding:2px 7px;border-radius:999px;">PRO</span>
115
+ <span style="font-weight:700;color:#fff;">Unlock SvGrid Pro</span>
116
+ </div>
117
+ <p style="margin:0 0 12px;color:#cbd5e1;">
118
+ ${featurePhrase} It runs in evaluation with a watermark - start a free trial
119
+ to remove it and ship to production.
120
+ </p>
121
+ <div style="display:flex;gap:8px;align-items:center;">
122
+ <a data-act="trial" href="${TRIAL_URL}" target="_blank" rel="noopener noreferrer"
123
+ style="flex:1;text-align:center;background:#6366f1;color:#fff;font-weight:600;
124
+ text-decoration:none;padding:8px 12px;border-radius:8px;">Start free trial</a>
125
+ <a data-act="pricing" href="${PRICING_URL}" target="_blank" rel="noopener noreferrer"
126
+ style="color:#a5b4fc;text-decoration:none;padding:8px 6px;font-weight:600;">Pricing</a>
127
+ </div>
128
+ <p style="margin:10px 0 0;font-size:11px;color:#64748b;">
129
+ Already licensed? Call <code style="color:#94a3b8;">setLicenseKey()</code> at startup to hide this.
130
+ </p>
131
+ `
132
+
133
+ card.querySelector('[data-act="x"]')?.addEventListener('click', () => close(card))
134
+ // Clicking through to a trial / pricing also counts as "handled" - close the
135
+ // card, but let the link open in its new tab first.
136
+ card.querySelector('[data-act="trial"]')?.addEventListener('click', () => close(card))
137
+ card.querySelector('[data-act="pricing"]')?.addEventListener('click', () => close(card))
138
+
139
+ return card
140
+ }
141
+
142
+ function escapeHtml(s: string): string {
143
+ return s
144
+ .replace(/&/g, '&amp;')
145
+ .replace(/</g, '&lt;')
146
+ .replace(/>/g, '&gt;')
147
+ .replace(/"/g, '&quot;')
148
+ }