@insight-health/aura 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,5 @@
1
- type AuraWidgetEmitEvent<T = any> = {
2
- type: string;
3
- payload: T;
4
- };
5
- type AuraWidgetOpenParams = {
6
- partnerKey: string;
7
- subTenantId: string;
8
- user: {
9
- email: string;
10
- firstName?: string;
11
- lastName?: string;
12
- };
13
- language?: string;
14
- container?: string;
15
- widgetId?: string;
16
- widgetStyles?: Partial<Pick<CSSStyleDeclaration, 'width' | 'height' | 'borderRadius' | 'boxShadow' | 'top' | 'bottom' | 'left' | 'right'>>;
17
- onAuthenticated?: () => void;
18
- };
1
+ import { AuraRegisterTemplatePayload, AuraWidgetInitParams, AuraWidgetEmitEvent } from './types';
2
+
19
3
  /**
20
4
  * Aura service class
21
5
  * Singleton pattern - all imports reference the same instance
@@ -28,8 +12,9 @@ declare class AuraWidgetService {
28
12
  isFrameAuthenticated: boolean;
29
13
  constructor();
30
14
  private postMessage;
31
- init: (params: AuraWidgetOpenParams) => Promise<void>;
32
- setUser: (params: Pick<AuraWidgetOpenParams, "user" | "subTenantId" | "language">) => void;
15
+ init: (params: AuraWidgetInitParams) => Promise<void>;
16
+ registerTemplates: (payload: AuraRegisterTemplatePayload) => void;
17
+ setUser: (params: Pick<AuraWidgetInitParams, "user" | "subTenantId" | "language">) => void;
33
18
  show: () => void;
34
19
  hide: () => void;
35
20
  reset: () => void;
@@ -38,7 +23,7 @@ declare class AuraWidgetService {
38
23
  /**
39
24
  * Get SDK version
40
25
  */
41
- getConfig: () => AuraWidgetOpenParams | null;
26
+ getConfig: () => AuraWidgetInitParams | null;
42
27
  getVersion: () => string;
43
28
  }
44
29
  export declare const AuraWidget: AuraWidgetService;
@@ -1 +1 @@
1
- {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAMA,KAAK,mBAAmB,CAA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ACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
1
+ {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AA0BjB;;;GAGG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,cAAc,CAAsB;IAC5C,YAAY,EAAE,OAAO,CAAS;IAC9B,oBAAoB,EAAE,OAAO,CAAS;;IAatC,OAAO,CAAC,WAAW,CASjB;IAEF,IAAI,GAAI,QAAQ,oBAAoB,mBAgElC;IAEF,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF,OAAO,GACL,QAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC,UAiBvE;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,KAAK,aASH;IAEF,IAAI,GAAI,OAAO,mBAAmB,UAGhC;IAEF,EAAE,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBAEhD;IAEF;;OAEG;IACH,SAAS,oCAEP;IACF,UAAU,eAER;CACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W={insightBaseUrl:"https://anywhere.insighthealth.ai"};let f=null;function C(){return f}function v(i){f={...W,...i}}function H(i){v(i)}function d(){const i=C();if(!i)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return i}function m(){return"0.0.2"}class I{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(s=>s!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(s=>s(e))}}}const r=new I,c={log:i=>{console.log(`[Insight Health Aura Widget]: ${i}`)},warn:i=>{console.warn(`[Insight Health Aura Widget]: ${i}`)},error:i=>{console.error(`[Insight Health Aura Widget]: ${i}`)}},l={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},S={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class E{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var s;if(!((s=this.widgetFrame)!=null&&s.contentWindow)){c.warn("No widget iframe to communicate with");return}const e=d();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){const s=d(),{subTenantId:o,user:a,language:w,container:g,widgetId:F,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const p=(n==null?void 0:n.width)||"350px",b=(n==null?void 0:n.height)||"600px",y={...S,...n,...l};Object.assign(this.widgetFrame.style,y),this.widgetFrame.id=F||"aura-widget",this.widgetFrame.src=`${s.insightBaseUrl}/aura`,this.widgetFrame.__desiredWidth=p,this.widgetFrame.__desiredHeight=b,this.widgetFrame.onerror=()=>{c.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
- frame-src ${s.insightBaseUrl}
3
- `)},(g&&document.querySelector(g)||document.body).appendChild(this.widgetFrame);const x=r.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:o,user:a,language:w})}),A=r.subscribe("Auth.Complete",()=>{var u;this.isFrameAuthenticated=!0,e(),(u=t.onAuthenticated)==null||u.call(t)});this.unsubsciptions.push(x,A)}}),this.setUser=t=>{const e=this.config.partnerKey,{subTenantId:s,user:o,language:a}=t;this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,subTenantId:s,user:o,language:a}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",s={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...s})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...l})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>r.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>m(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||r.emit(t.data.type,t.data.payload)})}}let h=null;function _(){return h||(h=new E),h}const R=_();exports.AuraWidget=R;exports.configure=H;exports.getConfig=d;exports.getVersion=m;
4
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W={insightBaseUrl:"https://anywhere.insighthealth.ai"};let f=null;function C(){return f}function v(s){f={...W,...s}}function B(s){v(s)}function g(){const s=C();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function m(){return"0.0.4"}class I{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(i=>i!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(i=>i(e))}}}const a=new I,c={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},l={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},U={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class H{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){c.warn("No widget iframe to communicate with");return}const e=g();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=g(),{subTenantId:r,user:o,language:w,container:d,widgetId:p,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const b=(n==null?void 0:n.width)||"350px",F=(n==null?void 0:n.height)||"600px",y={...U,...n,...l};Object.assign(this.widgetFrame.style,y),this.widgetFrame.id=p||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=b,this.widgetFrame.__desiredHeight=F,this.widgetFrame.onerror=()=>{c.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
+ frame-src ${i.insightBaseUrl}
3
+ `)},(d&&document.querySelector(d)||document.body).appendChild(this.widgetFrame);const A=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:r,user:o,language:w})}),x=a.subscribe("Auth.Complete",()=>{var u;this.isFrameAuthenticated=!0,e(),(u=t.onAuthenticated)==null||u.call(t)});this.unsubsciptions.push(A,x)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.setUser=t=>{const e=this.config.partnerKey,{subTenantId:i,user:r,language:o}=t;this.config.subTenantId=i,this.config.user=r,this.config.language=o,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,subTenantId:i,user:r,language:o}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...l})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>a.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>m(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||a.emit(t.data.type,t.data.payload)})}}let h=null;function S(){return h||(h=new H),h}const $=S();exports.AuraWidget=$;exports.configure=B;exports.getConfig=g;exports.getVersion=m;
package/dist/index.js CHANGED
@@ -5,41 +5,41 @@ let f = null;
5
5
  function W() {
6
6
  return f;
7
7
  }
8
- function C(i) {
9
- f = { ...A, ...i };
8
+ function C(s) {
9
+ f = { ...A, ...s };
10
10
  }
11
- function R(i) {
12
- C(i);
11
+ function $(s) {
12
+ C(s);
13
13
  }
14
14
  function u() {
15
- const i = W();
16
- if (!i)
15
+ const s = W();
16
+ if (!s)
17
17
  throw new Error(
18
18
  "Aura SDK not configured. Call configure() first to set global configuration."
19
19
  );
20
- return i;
20
+ return s;
21
21
  }
22
- function v() {
23
- return "0.0.2";
22
+ function B() {
23
+ return "0.0.4";
24
24
  }
25
- class H {
25
+ class I {
26
26
  constructor() {
27
27
  this.events = {}, this.subscribe = (t, e) => (this.events[t] || (this.events[t] = []), this.events[t].push(e), () => {
28
- this.events[t] = this.events[t].filter((s) => s !== e);
28
+ this.events[t] = this.events[t].filter((i) => i !== e);
29
29
  }), this.emit = (t, e) => {
30
- this.events[t] && this.events[t].forEach((s) => s(e));
30
+ this.events[t] && this.events[t].forEach((i) => i(e));
31
31
  };
32
32
  }
33
33
  }
34
- const r = new H(), c = {
35
- log: (i) => {
36
- console.log(`[Insight Health Aura Widget]: ${i}`);
34
+ const a = new I(), c = {
35
+ log: (s) => {
36
+ console.log(`[Insight Health Aura Widget]: ${s}`);
37
37
  },
38
- warn: (i) => {
39
- console.warn(`[Insight Health Aura Widget]: ${i}`);
38
+ warn: (s) => {
39
+ console.warn(`[Insight Health Aura Widget]: ${s}`);
40
40
  },
41
- error: (i) => {
42
- console.error(`[Insight Health Aura Widget]: ${i}`);
41
+ error: (s) => {
42
+ console.error(`[Insight Health Aura Widget]: ${s}`);
43
43
  }
44
44
  }, l = {
45
45
  opacity: "0",
@@ -48,7 +48,7 @@ const r = new H(), c = {
48
48
  height: "0",
49
49
  maxWidth: "0",
50
50
  maxHeight: "0"
51
- }, I = {
51
+ }, U = {
52
52
  border: "none",
53
53
  borderRadius: "10px",
54
54
  boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
@@ -60,11 +60,11 @@ const r = new H(), c = {
60
60
  transition: "opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",
61
61
  zIndex: "9999"
62
62
  };
63
- class E {
63
+ class v {
64
64
  constructor() {
65
65
  this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (t) => {
66
- var s;
67
- if (!((s = this.widgetFrame) != null && s.contentWindow)) {
66
+ var i;
67
+ if (!((i = this.widgetFrame) != null && i.contentWindow)) {
68
68
  c.warn("No widget iframe to communicate with");
69
69
  return;
70
70
  }
@@ -74,30 +74,34 @@ class E {
74
74
  });
75
75
  }, this.init = (t) => new Promise((e) => {
76
76
  if (!this.widgetFrame) {
77
- const s = u(), {
78
- subTenantId: o,
79
- user: a,
77
+ this.reset();
78
+ const i = u(), {
79
+ subTenantId: r,
80
+ user: o,
80
81
  language: m,
81
82
  container: d,
82
83
  widgetId: w,
83
84
  widgetStyles: n
84
85
  } = t;
85
86
  this.config = t, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
86
- const F = (n == null ? void 0 : n.width) || "350px", p = (n == null ? void 0 : n.height) || "600px", b = {
87
- ...I,
87
+ const p = (n == null ? void 0 : n.width) || "350px", F = (n == null ? void 0 : n.height) || "600px", b = {
88
+ ...U,
88
89
  ...n,
89
90
  ...l
90
91
  };
91
- Object.assign(this.widgetFrame.style, b), this.widgetFrame.id = w || "aura-widget", this.widgetFrame.src = `${s.insightBaseUrl}/aura`, this.widgetFrame.__desiredWidth = F, this.widgetFrame.__desiredHeight = p, this.widgetFrame.onerror = () => {
92
+ Object.assign(this.widgetFrame.style, b), this.widgetFrame.id = w || "aura-widget", this.widgetFrame.setAttribute(
93
+ "allow",
94
+ `microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`
95
+ ), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = p, this.widgetFrame.__desiredHeight = F, this.widgetFrame.onerror = () => {
92
96
  c.error(
93
97
  `Failed to load iframe. Please ensure your Content Security Policy includes:
94
- frame-src ${s.insightBaseUrl}
98
+ frame-src ${i.insightBaseUrl}
95
99
  `
96
100
  );
97
101
  }, (d && document.querySelector(d) || document.body).appendChild(this.widgetFrame);
98
- const y = r.subscribe("Auth.Ready", () => {
99
- this.isFrameReady = !0, this.setUser({ subTenantId: o, user: a, language: m });
100
- }), x = r.subscribe(
102
+ const y = a.subscribe("Auth.Ready", () => {
103
+ this.isFrameReady = !0, this.setUser({ subTenantId: r, user: o, language: m });
104
+ }), x = a.subscribe(
101
105
  "Auth.Complete",
102
106
  () => {
103
107
  var g;
@@ -106,20 +110,25 @@ class E {
106
110
  );
107
111
  this.unsubsciptions.push(y, x);
108
112
  }
109
- }), this.setUser = (t) => {
110
- const e = this.config.partnerKey, { subTenantId: s, user: o, language: a } = t;
111
- this.isFrameAuthenticated = !1, this.postMessage({
113
+ }), this.registerTemplates = (t) => {
114
+ this.postMessage({
115
+ type: "Template.Register",
116
+ payload: t
117
+ });
118
+ }, this.setUser = (t) => {
119
+ const e = this.config.partnerKey, { subTenantId: i, user: r, language: o } = t;
120
+ this.config.subTenantId = i, this.config.user = r, this.config.language = o, this.isFrameAuthenticated = !1, this.postMessage({
112
121
  type: "Auth.Login",
113
122
  payload: {
114
123
  partnerKey: e,
115
- subTenantId: s,
116
- user: o,
117
- language: a
124
+ subTenantId: i,
125
+ user: r,
126
+ language: o
118
127
  }
119
128
  });
120
129
  }, this.show = () => {
121
130
  if (this.widgetFrame) {
122
- const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px", s = {
131
+ const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px", i = {
123
132
  opacity: "1",
124
133
  pointerEvents: "auto",
125
134
  width: t,
@@ -127,7 +136,7 @@ class E {
127
136
  maxWidth: t,
128
137
  maxHeight: e
129
138
  };
130
- Object.assign(this.widgetFrame.style, { ...s });
139
+ Object.assign(this.widgetFrame.style, { ...i });
131
140
  }
132
141
  }, this.hide = () => {
133
142
  this.widgetFrame && Object.assign(this.widgetFrame.style, { ...l });
@@ -135,24 +144,23 @@ class E {
135
144
  this.widgetFrame && this.widgetFrame.remove(), this.widgetFrame = null, this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.unsubsciptions.forEach((t) => t == null ? void 0 : t()), this.unsubsciptions = [];
136
145
  }, this.emit = (t) => {
137
146
  this.postMessage(t), this.show();
138
- }, this.on = (t, e) => r.subscribe(t, e), this.getConfig = () => this.config, this.getVersion = () => v(), window.addEventListener(
147
+ }, this.on = (t, e) => a.subscribe(t, e), this.getConfig = () => this.config, this.getVersion = () => B(), window.addEventListener(
139
148
  "message",
140
149
  (t) => {
141
150
  var e;
142
- t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || r.emit(t.data.type, t.data.payload);
151
+ t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || a.emit(t.data.type, t.data.payload);
143
152
  }
144
153
  );
145
154
  }
146
155
  }
147
156
  let h = null;
148
- function _() {
149
- return h || (h = new E()), h;
157
+ function H() {
158
+ return h || (h = new v()), h;
150
159
  }
151
- const S = _();
160
+ const E = H();
152
161
  export {
153
- S as AuraWidget,
154
- R as configure,
162
+ E as AuraWidget,
163
+ $ as configure,
155
164
  u as getConfig,
156
- v as getVersion
165
+ B as getVersion
157
166
  };
158
- //# sourceMappingURL=index.js.map
package/dist/index.umd.js CHANGED
@@ -1,4 +1,3 @@
1
- (function(n,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(n=typeof globalThis<"u"?globalThis:n||self,r(n.InsightAura={}))})(this,function(n){"use strict";const r={insightBaseUrl:"https://anywhere.insighthealth.ai"};let c=null;function F(){return c}function b(i){c={...r,...i}}function y(i){b(i)}function h(){const i=F();if(!i)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return i}function l(){return"0.0.2"}class A{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(s=>s!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(s=>s(e))}}}const a=new A,f={log:i=>{console.log(`[Insight Health Aura Widget]: ${i}`)},warn:i=>{console.warn(`[Insight Health Aura Widget]: ${i}`)},error:i=>{console.error(`[Insight Health Aura Widget]: ${i}`)}},m={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},x={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class W{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var s;if(!((s=this.widgetFrame)!=null&&s.contentWindow)){f.warn("No widget iframe to communicate with");return}const e=h();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){const s=h(),{subTenantId:g,user:u,language:I,container:w,widgetId:H,widgetStyles:o}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const S=(o==null?void 0:o.width)||"350px",E=(o==null?void 0:o.height)||"600px",_={...x,...o,...m};Object.assign(this.widgetFrame.style,_),this.widgetFrame.id=H||"aura-widget",this.widgetFrame.src=`${s.insightBaseUrl}/aura`,this.widgetFrame.__desiredWidth=S,this.widgetFrame.__desiredHeight=E,this.widgetFrame.onerror=()=>{f.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
- frame-src ${s.insightBaseUrl}
3
- `)},(w&&document.querySelector(w)||document.body).appendChild(this.widgetFrame);const R=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:g,user:u,language:I})}),B=a.subscribe("Auth.Complete",()=>{var p;this.isFrameAuthenticated=!0,e(),(p=t.onAuthenticated)==null||p.call(t)});this.unsubsciptions.push(R,B)}}),this.setUser=t=>{const e=this.config.partnerKey,{subTenantId:s,user:g,language:u}=t;this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,subTenantId:s,user:g,language:u}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",s={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...s})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...m})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>a.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>l(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||a.emit(t.data.type,t.data.payload)})}}let d=null;function C(){return d||(d=new W),d}const v=C();n.AuraWidget=v,n.configure=y,n.getConfig=h,n.getVersion=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
4
- //# sourceMappingURL=index.umd.js.map
1
+ (function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.InsightAura={}))})(this,function(n){"use strict";const o={insightBaseUrl:"https://anywhere.insighthealth.ai"};let c=null;function b(){return c}function F(s){c={...o,...s}}function y(s){F(s)}function g(){const s=b();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function l(){return"0.0.4"}class A{constructor(){this.events={},this.subscribe=(e,t)=>(this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(i=>i!==t)}),this.emit=(e,t)=>{this.events[e]&&this.events[e].forEach(i=>i(t))}}}const a=new A,f={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},m={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},x={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class W{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=e=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){f.warn("No widget iframe to communicate with");return}const t=g();this.widgetFrame.contentWindow.postMessage(e,{targetOrigin:t.insightBaseUrl})},this.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset();const i=g(),{subTenantId:h,user:d,language:v,container:w,widgetId:B,widgetStyles:r}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const U=(r==null?void 0:r.width)||"350px",H=(r==null?void 0:r.height)||"600px",S={...x,...r,...m};Object.assign(this.widgetFrame.style,S),this.widgetFrame.id=B||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=U,this.widgetFrame.__desiredHeight=H,this.widgetFrame.onerror=()=>{f.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
+ frame-src ${i.insightBaseUrl}
3
+ `)},(w&&document.querySelector(w)||document.body).appendChild(this.widgetFrame);const $=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:h,user:d,language:v})}),E=a.subscribe("Auth.Complete",()=>{var p;this.isFrameAuthenticated=!0,t(),(p=e.onAuthenticated)==null||p.call(e)});this.unsubsciptions.push($,E)}}),this.registerTemplates=e=>{this.postMessage({type:"Template.Register",payload:e})},this.setUser=e=>{const t=this.config.partnerKey,{subTenantId:i,user:h,language:d}=e;this.config.subTenantId=i,this.config.user=h,this.config.language=d,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,subTenantId:i,user:h,language:d}})},this.show=()=>{if(this.widgetFrame){const e=this.widgetFrame.__desiredWidth||"350px",t=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:e,height:t,maxWidth:e,maxHeight:t};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...m})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(e=>e==null?void 0:e()),this.unsubsciptions=[]},this.emit=e=>{this.postMessage(e),this.show()},this.on=(e,t)=>a.subscribe(e,t),this.getConfig=()=>this.config,this.getVersion=()=>l(),window.addEventListener("message",e=>{var t;e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data||a.emit(e.data.type,e.data.payload)})}}let u=null;function C(){return u||(u=new W),u}const I=C();n.AuraWidget=I,n.configure=y,n.getConfig=g,n.getVersion=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,35 @@
1
+ export type AuraWidgetEmitEvent<T = any> = {
2
+ type: string;
3
+ payload: T;
4
+ };
5
+ export type AuraWidgetInitParams = {
6
+ partnerKey: string;
7
+ subTenantId: string;
8
+ user: {
9
+ email: string;
10
+ firstName?: string;
11
+ lastName?: string;
12
+ };
13
+ language?: string;
14
+ container?: string;
15
+ widgetId?: string;
16
+ widgetStyles?: Partial<Pick<CSSStyleDeclaration, 'width' | 'height' | 'borderRadius' | 'boxShadow' | 'top' | 'bottom' | 'left' | 'right'>>;
17
+ onAuthenticated?: () => void;
18
+ };
19
+ export type AuraWidgetMessageEvent<T = any> = {
20
+ type: string;
21
+ payload: T;
22
+ };
23
+ export type AuraTemplate = {
24
+ id: string;
25
+ name: string;
26
+ body: {
27
+ sections: Record<string, any>[];
28
+ };
29
+ description: string;
30
+ encounterPhase: 'pre-chart' | 'in-visit';
31
+ };
32
+ export type AuraRegisterTemplatePayload = {
33
+ templates: AuraTemplate[];
34
+ };
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,GAAG,IAAI;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CACpB,IAAI,CACF,mBAAmB,EACjB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,WAAW,GACX,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,CACV,CACF,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,GAAG,IAAI;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;KACjC,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,WAAW,GAAG,UAAU,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insight-health/aura",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Aura SDK package for Insight Health AI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/globalConfig.ts","../src/root.ts","../src/utils/eventBus.ts","../src/utils/logger.ts","../src/auraWidget.ts"],"sourcesContent":["/**\n * Global storage for Aura SDK configuration\n */\n\n/**\n * Root-level global configuration\n * Shared across all services/interfaces\n */\nexport interface GlobalConfig {\n insightBaseUrl?: string;\n // Add other global config options here\n}\n\nconst defaultConfig: Partial<GlobalConfig> = {\n insightBaseUrl: 'https://anywhere.insighthealth.ai',\n};\n\nlet globalConfig: GlobalConfig | null = null;\n\n/**\n * Get the global configuration\n */\nexport function getGlobalConfig(): GlobalConfig | null {\n return globalConfig;\n}\n\n/**\n * Set the global configuration\n */\nexport function setGlobalConfig(config: GlobalConfig): void {\n globalConfig = { ...defaultConfig, ...config };\n}\n\n/**\n * Clear the global configuration\n */\nexport function clearGlobalConfig(): void {\n globalConfig = null;\n}\n\n/**\n * Check if global configuration is set\n */\nexport function hasGlobalConfig(): boolean {\n return globalConfig !== null;\n}\n","/// <reference types=\"vite/client\" />\n\nimport { getGlobalConfig, GlobalConfig, setGlobalConfig } from './globalConfig';\n\n/**\n * Configure the Aura SDK globally (root-level)\n * Sets base configuration like baseUrl, apiKey, etc.\n * This configuration is shared across all services\n */\nexport function configure(config: GlobalConfig): void {\n setGlobalConfig(config);\n}\n\nexport function getConfig(): GlobalConfig {\n const globalConfig = getGlobalConfig();\n if (!globalConfig) {\n throw new Error(\n 'Aura SDK not configured. Call configure() first to set global configuration.'\n );\n }\n return globalConfig;\n}\n\nexport function getVersion(): string {\n return import.meta.env.PACKAGE_VERSION;\n}\n","class EventBus {\n private events: Record<string, ((data: any) => void)[]> = {};\n\n subscribe = (event: string, callback: (data: any) => void) => {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n\n return () => {\n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n };\n };\n\n emit = (event: string, data: any) => {\n if (!this.events[event]) {\n return;\n }\n this.events[event].forEach((callback) => callback(data));\n };\n}\n\nexport const eventBus = new EventBus();\n","export const logger = {\n log: (message: string) => {\n console.log(`[Insight Health Aura Widget]: ${message}`);\n },\n warn: (message: string) => {\n console.warn(`[Insight Health Aura Widget]: ${message}`);\n },\n error: (message: string) => {\n console.error(`[Insight Health Aura Widget]: ${message}`);\n },\n};\n","/**\n * Aura SDK for Insight Health AI\n */\nimport { getVersion, getConfig } from './root';\nimport { eventBus, logger } from './utils';\n\ntype AuraWidgetEmitEvent<T = any> = {\n type: string;\n payload: T;\n};\n\ntype AuraWidgetOpenParams = {\n partnerKey: string;\n subTenantId: string;\n user: {\n email: string;\n firstName?: string;\n lastName?: string;\n };\n language?: string;\n container?: string;\n widgetId?: string;\n widgetStyles?: Partial<\n Pick<\n CSSStyleDeclaration,\n | 'width'\n | 'height'\n | 'borderRadius'\n | 'boxShadow'\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n >\n >;\n onAuthenticated?: () => void;\n};\n\ntype AuraWidgetMessageEvent<T = any> = {\n type: string;\n payload: T;\n};\n\nconst hiddenStyles: Partial<CSSStyleDeclaration> = {\n opacity: '0',\n pointerEvents: 'none',\n width: '0',\n height: '0',\n maxWidth: '0',\n maxHeight: '0',\n};\n\nconst defaultStyles: Partial<CSSStyleDeclaration> = {\n border: 'none',\n borderRadius: '10px',\n boxShadow: '0 0 10px 0 rgba(0, 0, 0, 0.1)',\n overflow: 'hidden',\n background: '#fff',\n position: 'fixed',\n bottom: '20px',\n right: '20px',\n transition:\n 'opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out',\n zIndex: '9999',\n};\n\n/**\n * Aura service class\n * Singleton pattern - all imports reference the same instance\n */\nclass AuraWidgetService {\n private config: AuraWidgetOpenParams | null = null;\n private widgetFrame: HTMLIFrameElement | null = null;\n private unsubsciptions: (() => void)[] = [];\n isFrameReady: boolean = false;\n isFrameAuthenticated: boolean = false;\n constructor() {\n window.addEventListener(\n 'message',\n (event: MessageEvent<AuraWidgetMessageEvent>) => {\n if (event.source !== this.widgetFrame?.contentWindow || !event.data) {\n return;\n }\n eventBus.emit(event.data.type, event.data.payload);\n }\n );\n }\n\n private postMessage = (event: AuraWidgetEmitEvent) => {\n if (!this.widgetFrame?.contentWindow) {\n logger.warn('No widget iframe to communicate with');\n return;\n }\n const globalConfig = getConfig();\n this.widgetFrame.contentWindow.postMessage(event, {\n targetOrigin: globalConfig.insightBaseUrl,\n });\n };\n\n init = (params: AuraWidgetOpenParams) => {\n return new Promise<void>((resolve) => {\n if (!this.widgetFrame) {\n const globalConfig = getConfig();\n const {\n subTenantId,\n user,\n language,\n container,\n widgetId,\n widgetStyles,\n } = params;\n this.config = params;\n this.isFrameReady = false;\n this.widgetFrame = document.createElement('iframe');\n // Store the desired dimensions from styles or use defaults\n const desiredWidth = widgetStyles?.width || '350px';\n const desiredHeight = widgetStyles?.height || '600px';\n const initialStyles = {\n ...defaultStyles,\n ...widgetStyles,\n ...hiddenStyles,\n };\n Object.assign(this.widgetFrame.style, initialStyles);\n this.widgetFrame.id = widgetId || `aura-widget`;\n this.widgetFrame.src = `${globalConfig.insightBaseUrl}/aura`;\n // Store desired dimensions for show/hide\n (this.widgetFrame as any).__desiredWidth = desiredWidth;\n (this.widgetFrame as any).__desiredHeight = desiredHeight;\n\n // Add error handler for CSP violations\n this.widgetFrame.onerror = () => {\n logger.error(\n `Failed to load iframe. Please ensure your Content Security Policy includes:\\n` +\n ` frame-src ${globalConfig.insightBaseUrl}\\n`\n );\n };\n\n (\n (container && document.querySelector(container)) ||\n document.body\n ).appendChild(this.widgetFrame);\n\n const unsubscribeAuthReady = eventBus.subscribe('Auth.Ready', () => {\n this.isFrameReady = true;\n this.setUser({ subTenantId, user, language });\n });\n\n const unsubscribeAuthComplete = eventBus.subscribe(\n 'Auth.Complete',\n () => {\n this.isFrameAuthenticated = true;\n resolve();\n params.onAuthenticated?.();\n }\n );\n this.unsubsciptions.push(unsubscribeAuthReady, unsubscribeAuthComplete);\n }\n });\n };\n\n setUser = (\n params: Pick<AuraWidgetOpenParams, 'user' | 'subTenantId' | 'language'>\n ) => {\n const partnerKey = this.config!.partnerKey;\n const { subTenantId, user, language } = params;\n this.isFrameAuthenticated = false;\n this.postMessage({\n type: 'Auth.Login',\n payload: {\n partnerKey,\n subTenantId,\n user,\n language,\n },\n });\n };\n\n show = () => {\n if (this.widgetFrame) {\n const desiredWidth = (this.widgetFrame as any).__desiredWidth || '350px';\n const desiredHeight =\n (this.widgetFrame as any).__desiredHeight || '600px';\n const showStyles = {\n opacity: '1',\n pointerEvents: 'auto',\n width: desiredWidth,\n height: desiredHeight,\n maxWidth: desiredWidth,\n maxHeight: desiredHeight,\n };\n Object.assign(this.widgetFrame.style, { ...showStyles });\n }\n };\n\n hide = () => {\n if (this.widgetFrame) {\n Object.assign(this.widgetFrame.style, { ...hiddenStyles });\n }\n };\n\n reset = () => {\n if (this.widgetFrame) {\n this.widgetFrame.remove();\n }\n this.widgetFrame = null;\n this.isFrameReady = false;\n this.isFrameAuthenticated = false;\n this.unsubsciptions.forEach((unsubscribe) => unsubscribe?.());\n this.unsubsciptions = [];\n };\n\n emit = (event: AuraWidgetEmitEvent) => {\n this.postMessage(event);\n this.show();\n };\n\n on = (event: string, callback: (data: any) => void) => {\n return eventBus.subscribe(event, callback);\n };\n\n /**\n * Get SDK version\n */\n getConfig = () => {\n return this.config;\n };\n getVersion = () => {\n return getVersion();\n };\n}\n\n// Singleton instance\nlet auraWidgetServiceInstance: AuraWidgetService | null = null;\n\n/**\n * Get the singleton Aura instance\n * All imports will reference the same instance\n */\nfunction getInstance(): AuraWidgetService {\n if (!auraWidgetServiceInstance) {\n auraWidgetServiceInstance = new AuraWidgetService();\n }\n return auraWidgetServiceInstance;\n}\n\nexport const AuraWidget = getInstance();\n"],"names":["defaultConfig","globalConfig","getGlobalConfig","setGlobalConfig","config","configure","getConfig","getVersion","EventBus","event","callback","cb","data","eventBus","logger","message","hiddenStyles","defaultStyles","AuraWidgetService","_a","params","resolve","subTenantId","user","language","container","widgetId","widgetStyles","desiredWidth","desiredHeight","initialStyles","unsubscribeAuthReady","unsubscribeAuthComplete","partnerKey","showStyles","unsubscribe","auraWidgetServiceInstance","getInstance","AuraWidget"],"mappings":"gFAaA,MAAMA,EAAuC,CAC3C,eAAgB,mCAClB,EAEA,IAAIC,EAAoC,KAKjC,SAASC,GAAuC,CACrD,OAAOD,CACT,CAKO,SAASE,EAAgBC,EAA4B,CAC1DH,EAAe,CAAE,GAAGD,EAAe,GAAGI,CAAA,CACxC,CCtBO,SAASC,EAAUD,EAA4B,CACpDD,EAAgBC,CAAM,CACxB,CAEO,SAASE,GAA0B,CACxC,MAAML,EAAeC,EAAA,EACrB,GAAI,CAACD,EACH,MAAM,IAAI,MACR,8EAAA,EAGJ,OAAOA,CACT,CAEO,SAASM,GAAqB,CACnC,MAAO,OACT,CCzBA,MAAMC,CAAS,CAAf,aAAA,CACE,KAAQ,OAAkD,CAAA,EAE1D,KAAA,UAAY,CAACC,EAAeC,KACrB,KAAK,OAAOD,CAAK,IACpB,KAAK,OAAOA,CAAK,EAAI,CAAA,GAEvB,KAAK,OAAOA,CAAK,EAAE,KAAKC,CAAQ,EAEzB,IAAM,CACX,KAAK,OAAOD,CAAK,EAAI,KAAK,OAAOA,CAAK,EAAE,OAAQE,GAAO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mB,QACzCK,EAAa,CACjB,QAAS,IACT,cAAe,OACf,MAAON,EACP,OAAQC,EACR,SAAUD,EACV,UAAWC,CAAA,EAEb,OAAO,OAAO,KAAK,YAAY,MAAO,CAAE,GAAGK,EAAY,CACzD,CACF,EAEA,KAAA,KAAO,IAAM,CACP,KAAK,aACP,OAAO,OAAO,KAAK,YAAY,MAAO,CAAE,GAAGlB,EAAc,CAE7D,EAEA,KAAA,MAAQ,IAAM,CACR,KAAK,aACP,KAAK,YAAY,OAAA,EAEnB,KAAK,YAAc,KACnB,KAAK,aAAe,GACpB,KAAK,qBAAuB,GAC5B,KAAK,eAAe,QAASmB,GAAgBA,GAAA,YAAAA,GAAe,EAC5D,KAAK,eAAiB,CAAA,CACxB,EAEA,KAAA,KAAQ1B,GAA+B,CACrC,KAAK,YAAYA,CAAK,EACtB,KAAK,KAAA,CACP,EAEA,KAAA,GAAK,CAACA,EAAeC,IACZG,EAAS,UAAUJ,EAAOC,CAAQ,EAM3C,KAAA,UAAY,IACH,KAAK,OAEd,KAAA,WAAa,IACJH,EAAA,EAtJP,OAAO,iBACL,UACCE,GAAgD,OAC3CA,EAAM,WAAWU,EAAA,KAAK,cAAL,YAAAA,EAAkB,gBAAiB,CAACV,EAAM,MAG/DI,EAAS,KAAKJ,EAAM,KAAK,KAAMA,EAAM,KAAK,OAAO,CACnD,CAAA,CAEJ,CA+IF,CAGA,IAAI2B,EAAsD,KAM1D,SAASC,GAAiC,CACxC,OAAKD,IACHA,EAA4B,IAAIlB,GAE3BkB,CACT,CAEO,MAAME,EAAaD,EAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/globalConfig.ts","../src/root.ts","../src/utils/eventBus.ts","../src/utils/logger.ts","../src/auraWidget.ts"],"sourcesContent":["/**\n * Global storage for Aura SDK configuration\n */\n\n/**\n * Root-level global configuration\n * Shared across all services/interfaces\n */\nexport interface GlobalConfig {\n insightBaseUrl?: string;\n // Add other global config options here\n}\n\nconst defaultConfig: Partial<GlobalConfig> = {\n insightBaseUrl: 'https://anywhere.insighthealth.ai',\n};\n\nlet globalConfig: GlobalConfig | null = null;\n\n/**\n * Get the global configuration\n */\nexport function getGlobalConfig(): GlobalConfig | null {\n return globalConfig;\n}\n\n/**\n * Set the global configuration\n */\nexport function setGlobalConfig(config: GlobalConfig): void {\n globalConfig = { ...defaultConfig, ...config };\n}\n\n/**\n * Clear the global configuration\n */\nexport function clearGlobalConfig(): void {\n globalConfig = null;\n}\n\n/**\n * Check if global configuration is set\n */\nexport function hasGlobalConfig(): boolean {\n return globalConfig !== null;\n}\n","/// <reference types=\"vite/client\" />\n\nimport { getGlobalConfig, GlobalConfig, setGlobalConfig } from './globalConfig';\n\n/**\n * Configure the Aura SDK globally (root-level)\n * Sets base configuration like baseUrl, apiKey, etc.\n * This configuration is shared across all services\n */\nexport function configure(config: GlobalConfig): void {\n setGlobalConfig(config);\n}\n\nexport function getConfig(): GlobalConfig {\n const globalConfig = getGlobalConfig();\n if (!globalConfig) {\n throw new Error(\n 'Aura SDK not configured. Call configure() first to set global configuration.'\n );\n }\n return globalConfig;\n}\n\nexport function getVersion(): string {\n return import.meta.env.PACKAGE_VERSION;\n}\n","class EventBus {\n private events: Record<string, ((data: any) => void)[]> = {};\n\n subscribe = (event: string, callback: (data: any) => void) => {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n\n return () => {\n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n };\n };\n\n emit = (event: string, data: any) => {\n if (!this.events[event]) {\n return;\n }\n this.events[event].forEach((callback) => callback(data));\n };\n}\n\nexport const eventBus = new EventBus();\n","export const logger = {\n log: (message: string) => {\n console.log(`[Insight Health Aura Widget]: ${message}`);\n },\n warn: (message: string) => {\n console.warn(`[Insight Health Aura Widget]: ${message}`);\n },\n error: (message: string) => {\n console.error(`[Insight Health Aura Widget]: ${message}`);\n },\n};\n","/**\n * Aura SDK for Insight Health AI\n */\nimport { getVersion, getConfig } from './root';\nimport { eventBus, logger } from './utils';\n\ntype AuraWidgetEmitEvent<T = any> = {\n type: string;\n payload: T;\n};\n\ntype AuraWidgetOpenParams = {\n partnerKey: string;\n subTenantId: string;\n user: {\n email: string;\n firstName?: string;\n lastName?: string;\n };\n language?: string;\n container?: string;\n widgetId?: string;\n widgetStyles?: Partial<\n Pick<\n CSSStyleDeclaration,\n | 'width'\n | 'height'\n | 'borderRadius'\n | 'boxShadow'\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n >\n >;\n onAuthenticated?: () => void;\n};\n\ntype AuraWidgetMessageEvent<T = any> = {\n type: string;\n payload: T;\n};\n\nconst hiddenStyles: Partial<CSSStyleDeclaration> = {\n opacity: '0',\n pointerEvents: 'none',\n width: '0',\n height: '0',\n maxWidth: '0',\n maxHeight: '0',\n};\n\nconst defaultStyles: Partial<CSSStyleDeclaration> = {\n border: 'none',\n borderRadius: '10px',\n boxShadow: '0 0 10px 0 rgba(0, 0, 0, 0.1)',\n overflow: 'hidden',\n background: '#fff',\n position: 'fixed',\n bottom: '20px',\n right: '20px',\n transition:\n 'opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out',\n zIndex: '9999',\n};\n\n/**\n * Aura service class\n * Singleton pattern - all imports reference the same instance\n */\nclass AuraWidgetService {\n private config: AuraWidgetOpenParams | null = null;\n private widgetFrame: HTMLIFrameElement | null = null;\n private unsubsciptions: (() => void)[] = [];\n isFrameReady: boolean = false;\n isFrameAuthenticated: boolean = false;\n constructor() {\n window.addEventListener(\n 'message',\n (event: MessageEvent<AuraWidgetMessageEvent>) => {\n if (event.source !== this.widgetFrame?.contentWindow || !event.data) {\n return;\n }\n eventBus.emit(event.data.type, event.data.payload);\n }\n );\n }\n\n private postMessage = (event: AuraWidgetEmitEvent) => {\n if (!this.widgetFrame?.contentWindow) {\n logger.warn('No widget iframe to communicate with');\n return;\n }\n const globalConfig = getConfig();\n this.widgetFrame.contentWindow.postMessage(event, {\n targetOrigin: globalConfig.insightBaseUrl,\n });\n };\n\n init = (params: AuraWidgetOpenParams) => {\n return new Promise<void>((resolve) => {\n if (!this.widgetFrame) {\n const globalConfig = getConfig();\n const {\n subTenantId,\n user,\n language,\n container,\n widgetId,\n widgetStyles,\n } = params;\n this.config = params;\n this.isFrameReady = false;\n this.widgetFrame = document.createElement('iframe');\n // Store the desired dimensions from styles or use defaults\n const desiredWidth = widgetStyles?.width || '350px';\n const desiredHeight = widgetStyles?.height || '600px';\n const initialStyles = {\n ...defaultStyles,\n ...widgetStyles,\n ...hiddenStyles,\n };\n Object.assign(this.widgetFrame.style, initialStyles);\n this.widgetFrame.id = widgetId || `aura-widget`;\n this.widgetFrame.src = `${globalConfig.insightBaseUrl}/aura`;\n // Store desired dimensions for show/hide\n (this.widgetFrame as any).__desiredWidth = desiredWidth;\n (this.widgetFrame as any).__desiredHeight = desiredHeight;\n\n // Add error handler for CSP violations\n this.widgetFrame.onerror = () => {\n logger.error(\n `Failed to load iframe. Please ensure your Content Security Policy includes:\\n` +\n ` frame-src ${globalConfig.insightBaseUrl}\\n`\n );\n };\n\n (\n (container && document.querySelector(container)) ||\n document.body\n ).appendChild(this.widgetFrame);\n\n const unsubscribeAuthReady = eventBus.subscribe('Auth.Ready', () => {\n this.isFrameReady = true;\n this.setUser({ subTenantId, user, language });\n });\n\n const unsubscribeAuthComplete = eventBus.subscribe(\n 'Auth.Complete',\n () => {\n this.isFrameAuthenticated = true;\n resolve();\n params.onAuthenticated?.();\n }\n );\n this.unsubsciptions.push(unsubscribeAuthReady, unsubscribeAuthComplete);\n }\n });\n };\n\n setUser = (\n params: Pick<AuraWidgetOpenParams, 'user' | 'subTenantId' | 'language'>\n ) => {\n const partnerKey = this.config!.partnerKey;\n const { subTenantId, user, language } = params;\n this.isFrameAuthenticated = false;\n this.postMessage({\n type: 'Auth.Login',\n payload: {\n partnerKey,\n subTenantId,\n user,\n language,\n },\n });\n };\n\n show = () => {\n if (this.widgetFrame) {\n const desiredWidth = (this.widgetFrame as any).__desiredWidth || '350px';\n const desiredHeight =\n (this.widgetFrame as any).__desiredHeight || '600px';\n const showStyles = {\n opacity: '1',\n pointerEvents: 'auto',\n width: desiredWidth,\n height: desiredHeight,\n maxWidth: desiredWidth,\n maxHeight: desiredHeight,\n };\n Object.assign(this.widgetFrame.style, { ...showStyles });\n }\n };\n\n hide = () => {\n if (this.widgetFrame) {\n Object.assign(this.widgetFrame.style, { ...hiddenStyles });\n }\n };\n\n reset = () => {\n if (this.widgetFrame) {\n this.widgetFrame.remove();\n }\n this.widgetFrame = null;\n this.isFrameReady = false;\n this.isFrameAuthenticated = false;\n this.unsubsciptions.forEach((unsubscribe) => unsubscribe?.());\n this.unsubsciptions = [];\n };\n\n emit = (event: AuraWidgetEmitEvent) => {\n this.postMessage(event);\n this.show();\n };\n\n on = (event: string, callback: (data: any) => void) => {\n return eventBus.subscribe(event, callback);\n };\n\n /**\n * Get SDK version\n */\n getConfig = () => {\n return this.config;\n };\n getVersion = () => {\n return getVersion();\n };\n}\n\n// Singleton instance\nlet auraWidgetServiceInstance: AuraWidgetService | null = null;\n\n/**\n * Get the singleton Aura instance\n * All imports will reference the same instance\n */\nfunction getInstance(): AuraWidgetService {\n if (!auraWidgetServiceInstance) {\n auraWidgetServiceInstance = new AuraWidgetService();\n }\n return auraWidgetServiceInstance;\n}\n\nexport const AuraWidget = getInstance();\n"],"names":["defaultConfig","globalConfig","getGlobalConfig","setGlobalConfig","config","configure","getConfig","getVersion","EventBus","event","callback","cb","data","eventBus","logger","message","hiddenStyles","defaultStyles","AuraWidgetService","_a","params","resolve","subTenantId","user","language","container","widgetId","widgetStyles","desiredWidth","desiredHeight","initialStyles","unsubscribeAuthReady","unsubscribeAuthComplete","partnerKey","showStyles","unsubscribe","auraWidgetServiceInstance","getInstance","AuraWidget"],"mappings":"AAaA,MAAMA,IAAuC;AAAA,EAC3C,gBAAgB;AAClB;AAEA,IAAIC,IAAoC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AA;AAEb,eAAO,OAAO,KAAK,YAAY,OAAO,EAAE,GAAGK,GAAY;AAAA,MACzD;AAAA,IACF,GAEA,KAAA,OAAO,MAAM;AACX,MAAI,KAAK,eACP,OAAO,OAAO,KAAK,YAAY,OAAO,EAAE,GAAGlB,GAAc;AAAA,IAE7D,GAEA,KAAA,QAAQ,MAAM;AACZ,MAAI,KAAK,eACP,KAAK,YAAY,OAAA,GAEnB,KAAK,cAAc,MACnB,KAAK,eAAe,IACpB,KAAK,uBAAuB,IAC5B,KAAK,eAAe,QAAQ,CAACmB,MAAgBA,KAAA,gBAAAA,GAAe,GAC5D,KAAK,iBAAiB,CAAA;AAAA,IACxB,GAEA,KAAA,OAAO,CAAC1B,MAA+B;AACrC,WAAK,YAAYA,CAAK,GACtB,KAAK,KAAA;AAAA,IACP,GAEA,KAAA,KAAK,CAACA,GAAeC,MACZG,EAAS,UAAUJ,GAAOC,CAAQ,GAM3C,KAAA,YAAY,MACH,KAAK,QAEd,KAAA,aAAa,MACJH,EAAA,GAtJP,OAAO;AAAA,MACL;AAAA,MACA,CAACE,MAAgD;AJlEvD,YAAAU;AImEQ,QAAIV,EAAM,aAAWU,IAAA,KAAK,gBAAL,gBAAAA,EAAkB,kBAAiB,CAACV,EAAM,QAG/DI,EAAS,KAAKJ,EAAM,KAAK,MAAMA,EAAM,KAAK,OAAO;AAAA,MACnD;AAAA,IAAA;AAAA,EAEJ;AA+IF;AAGA,IAAI2B,IAAsD;AAM1D,SAASC,IAAiC;AACxC,SAAKD,MACHA,IAA4B,IAAIlB,EAAA,IAE3BkB;AACT;AAEO,MAAME,IAAaD,EAAA;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/globalConfig.ts","../src/root.ts","../src/utils/eventBus.ts","../src/utils/logger.ts","../src/auraWidget.ts"],"sourcesContent":["/**\n * Global storage for Aura SDK configuration\n */\n\n/**\n * Root-level global configuration\n * Shared across all services/interfaces\n */\nexport interface GlobalConfig {\n insightBaseUrl?: string;\n // Add other global config options here\n}\n\nconst defaultConfig: Partial<GlobalConfig> = {\n insightBaseUrl: 'https://anywhere.insighthealth.ai',\n};\n\nlet globalConfig: GlobalConfig | null = null;\n\n/**\n * Get the global configuration\n */\nexport function getGlobalConfig(): GlobalConfig | null {\n return globalConfig;\n}\n\n/**\n * Set the global configuration\n */\nexport function setGlobalConfig(config: GlobalConfig): void {\n globalConfig = { ...defaultConfig, ...config };\n}\n\n/**\n * Clear the global configuration\n */\nexport function clearGlobalConfig(): void {\n globalConfig = null;\n}\n\n/**\n * Check if global configuration is set\n */\nexport function hasGlobalConfig(): boolean {\n return globalConfig !== null;\n}\n","/// <reference types=\"vite/client\" />\n\nimport { getGlobalConfig, GlobalConfig, setGlobalConfig } from './globalConfig';\n\n/**\n * Configure the Aura SDK globally (root-level)\n * Sets base configuration like baseUrl, apiKey, etc.\n * This configuration is shared across all services\n */\nexport function configure(config: GlobalConfig): void {\n setGlobalConfig(config);\n}\n\nexport function getConfig(): GlobalConfig {\n const globalConfig = getGlobalConfig();\n if (!globalConfig) {\n throw new Error(\n 'Aura SDK not configured. Call configure() first to set global configuration.'\n );\n }\n return globalConfig;\n}\n\nexport function getVersion(): string {\n return import.meta.env.PACKAGE_VERSION;\n}\n","class EventBus {\n private events: Record<string, ((data: any) => void)[]> = {};\n\n subscribe = (event: string, callback: (data: any) => void) => {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n\n return () => {\n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n };\n };\n\n emit = (event: string, data: any) => {\n if (!this.events[event]) {\n return;\n }\n this.events[event].forEach((callback) => callback(data));\n };\n}\n\nexport const eventBus = new EventBus();\n","export const logger = {\n log: (message: string) => {\n console.log(`[Insight Health Aura Widget]: ${message}`);\n },\n warn: (message: string) => {\n console.warn(`[Insight Health Aura Widget]: ${message}`);\n },\n error: (message: string) => {\n console.error(`[Insight Health Aura Widget]: ${message}`);\n },\n};\n","/**\n * Aura SDK for Insight Health AI\n */\nimport { getVersion, getConfig } from './root';\nimport { eventBus, logger } from './utils';\n\ntype AuraWidgetEmitEvent<T = any> = {\n type: string;\n payload: T;\n};\n\ntype AuraWidgetOpenParams = {\n partnerKey: string;\n subTenantId: string;\n user: {\n email: string;\n firstName?: string;\n lastName?: string;\n };\n language?: string;\n container?: string;\n widgetId?: string;\n widgetStyles?: Partial<\n Pick<\n CSSStyleDeclaration,\n | 'width'\n | 'height'\n | 'borderRadius'\n | 'boxShadow'\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n >\n >;\n onAuthenticated?: () => void;\n};\n\ntype AuraWidgetMessageEvent<T = any> = {\n type: string;\n payload: T;\n};\n\nconst hiddenStyles: Partial<CSSStyleDeclaration> = {\n opacity: '0',\n pointerEvents: 'none',\n width: '0',\n height: '0',\n maxWidth: '0',\n maxHeight: '0',\n};\n\nconst defaultStyles: Partial<CSSStyleDeclaration> = {\n border: 'none',\n borderRadius: '10px',\n boxShadow: '0 0 10px 0 rgba(0, 0, 0, 0.1)',\n overflow: 'hidden',\n background: '#fff',\n position: 'fixed',\n bottom: '20px',\n right: '20px',\n transition:\n 'opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out',\n zIndex: '9999',\n};\n\n/**\n * Aura service class\n * Singleton pattern - all imports reference the same instance\n */\nclass AuraWidgetService {\n private config: AuraWidgetOpenParams | null = null;\n private widgetFrame: HTMLIFrameElement | null = null;\n private unsubsciptions: (() => void)[] = [];\n isFrameReady: boolean = false;\n isFrameAuthenticated: boolean = false;\n constructor() {\n window.addEventListener(\n 'message',\n (event: MessageEvent<AuraWidgetMessageEvent>) => {\n if (event.source !== this.widgetFrame?.contentWindow || !event.data) {\n return;\n }\n eventBus.emit(event.data.type, event.data.payload);\n }\n );\n }\n\n private postMessage = (event: AuraWidgetEmitEvent) => {\n if (!this.widgetFrame?.contentWindow) {\n logger.warn('No widget iframe to communicate with');\n return;\n }\n const globalConfig = getConfig();\n this.widgetFrame.contentWindow.postMessage(event, {\n targetOrigin: globalConfig.insightBaseUrl,\n });\n };\n\n init = (params: AuraWidgetOpenParams) => {\n return new Promise<void>((resolve) => {\n if (!this.widgetFrame) {\n const globalConfig = getConfig();\n const {\n subTenantId,\n user,\n language,\n container,\n widgetId,\n widgetStyles,\n } = params;\n this.config = params;\n this.isFrameReady = false;\n this.widgetFrame = document.createElement('iframe');\n // Store the desired dimensions from styles or use defaults\n const desiredWidth = widgetStyles?.width || '350px';\n const desiredHeight = widgetStyles?.height || '600px';\n const initialStyles = {\n ...defaultStyles,\n ...widgetStyles,\n ...hiddenStyles,\n };\n Object.assign(this.widgetFrame.style, initialStyles);\n this.widgetFrame.id = widgetId || `aura-widget`;\n this.widgetFrame.src = `${globalConfig.insightBaseUrl}/aura`;\n // Store desired dimensions for show/hide\n (this.widgetFrame as any).__desiredWidth = desiredWidth;\n (this.widgetFrame as any).__desiredHeight = desiredHeight;\n\n // Add error handler for CSP violations\n this.widgetFrame.onerror = () => {\n logger.error(\n `Failed to load iframe. Please ensure your Content Security Policy includes:\\n` +\n ` frame-src ${globalConfig.insightBaseUrl}\\n`\n );\n };\n\n (\n (container && document.querySelector(container)) ||\n document.body\n ).appendChild(this.widgetFrame);\n\n const unsubscribeAuthReady = eventBus.subscribe('Auth.Ready', () => {\n this.isFrameReady = true;\n this.setUser({ subTenantId, user, language });\n });\n\n const unsubscribeAuthComplete = eventBus.subscribe(\n 'Auth.Complete',\n () => {\n this.isFrameAuthenticated = true;\n resolve();\n params.onAuthenticated?.();\n }\n );\n this.unsubsciptions.push(unsubscribeAuthReady, unsubscribeAuthComplete);\n }\n });\n };\n\n setUser = (\n params: Pick<AuraWidgetOpenParams, 'user' | 'subTenantId' | 'language'>\n ) => {\n const partnerKey = this.config!.partnerKey;\n const { subTenantId, user, language } = params;\n this.isFrameAuthenticated = false;\n this.postMessage({\n type: 'Auth.Login',\n payload: {\n partnerKey,\n subTenantId,\n user,\n language,\n },\n });\n };\n\n show = () => {\n if (this.widgetFrame) {\n const desiredWidth = (this.widgetFrame as any).__desiredWidth || '350px';\n const desiredHeight =\n (this.widgetFrame as any).__desiredHeight || '600px';\n const showStyles = {\n opacity: '1',\n pointerEvents: 'auto',\n width: desiredWidth,\n height: desiredHeight,\n maxWidth: desiredWidth,\n maxHeight: desiredHeight,\n };\n Object.assign(this.widgetFrame.style, { ...showStyles });\n }\n };\n\n hide = () => {\n if (this.widgetFrame) {\n Object.assign(this.widgetFrame.style, { ...hiddenStyles });\n }\n };\n\n reset = () => {\n if (this.widgetFrame) {\n this.widgetFrame.remove();\n }\n this.widgetFrame = null;\n this.isFrameReady = false;\n this.isFrameAuthenticated = false;\n this.unsubsciptions.forEach((unsubscribe) => unsubscribe?.());\n this.unsubsciptions = [];\n };\n\n emit = (event: AuraWidgetEmitEvent) => {\n this.postMessage(event);\n this.show();\n };\n\n on = (event: string, callback: (data: any) => void) => {\n return eventBus.subscribe(event, callback);\n };\n\n /**\n * Get SDK version\n */\n getConfig = () => {\n return this.config;\n };\n getVersion = () => {\n return getVersion();\n };\n}\n\n// Singleton instance\nlet auraWidgetServiceInstance: AuraWidgetService | null = null;\n\n/**\n * Get the singleton Aura instance\n * All imports will reference the same instance\n */\nfunction getInstance(): AuraWidgetService {\n if (!auraWidgetServiceInstance) {\n auraWidgetServiceInstance = new AuraWidgetService();\n }\n return auraWidgetServiceInstance;\n}\n\nexport const AuraWidget = getInstance();\n"],"names":["defaultConfig","globalConfig","getGlobalConfig","setGlobalConfig","config","configure","getConfig","getVersion","EventBus","event","callback","cb","data","eventBus","logger","message","hiddenStyles","defaultStyles","AuraWidgetService","_a","params","resolve","subTenantId","user","language","container","widgetId","widgetStyles","desiredWidth","desiredHeight","initialStyles","unsubscribeAuthReady","unsubscribeAuthComplete","partnerKey","showStyles","unsubscribe","auraWidgetServiceInstance","getInstance","AuraWidget"],"mappings":"mOAaA,MAAMA,EAAuC,CAC3C,eAAgB,mCAClB,EAEA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