@soyio/soyio-widget 0.0.23 → 0.0.25

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/dist/index.js CHANGED
@@ -1,42 +1,42 @@
1
1
  var Hr = Object.defineProperty;
2
- var Gr = (w, E, D) => E in w ? Hr(w, E, { enumerable: !0, configurable: !0, writable: !0, value: D }) : w[E] = D;
3
- var k = (w, E, D) => (Gr(w, typeof E != "symbol" ? E + "" : E, D), D), Jr = (w, E, D) => {
4
- if (!E.has(w))
2
+ var Gr = (w, y, D) => y in w ? Hr(w, y, { enumerable: !0, configurable: !0, writable: !0, value: D }) : w[y] = D;
3
+ var K = (w, y, D) => (Gr(w, typeof y != "symbol" ? y + "" : y, D), D), Jr = (w, y, D) => {
4
+ if (!y.has(w))
5
5
  throw TypeError("Cannot " + D);
6
6
  };
7
- var Tn = (w, E, D) => {
8
- if (E.has(w))
7
+ var Tn = (w, y, D) => {
8
+ if (y.has(w))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- E instanceof WeakSet ? E.add(w) : E.set(w, D);
10
+ y instanceof WeakSet ? y.add(w) : y.set(w, D);
11
11
  };
12
- var jn = (w, E, D) => (Jr(w, E, "access private method"), D);
13
- const qr = "soyio-widget-iframe-container", Wn = "soyio-widget-iframe", Zr = "https://app.soyio.id/widget", Vr = "https://sandbox.soyio.id/widget", Yr = ["IDENTITY_AUTHENTICATED", "IDENTITY_REGISTERED"];
14
- function $r(w, E, D, W) {
15
- const y = W || (D ? Vr : Zr), v = `platform=web&companyId=${encodeURIComponent(E.companyId)}`;
12
+ var jn = (w, y, D) => (Jr(w, y, "access private method"), D);
13
+ const qr = "soyio-widget-iframe-container", Wn = "soyio-widget-iframe", Zr = "https://app.soyio.id/widget", Vr = "https://sandbox.soyio.id/widget", $r = ["IDENTITY_AUTHENTICATED", "IDENTITY_REGISTERED"];
14
+ function Yr(w, y, D, W) {
15
+ const E = W || (D ? Vr : Zr), v = `platform=web&companyId=${encodeURIComponent(y.companyId)}`, S = y.userEmail ? `&userEmail=${y.userEmail}` : "";
16
16
  switch (w) {
17
17
  case "authenticate":
18
- return `${y}/authenticate?${v}&identityId=${E.identityId}`;
18
+ return `${E}/authenticate?${v}&identityId=${y.identityId}`;
19
19
  case "register":
20
- return `${y}/register?${v}&flowTemplateId=${E.flowTemplateId}`;
20
+ return `${E}/register?${v}&flowTemplateId=${y.flowTemplateId}${S}`;
21
21
  default:
22
22
  return "INVALID_PARAMS";
23
23
  }
24
24
  }
25
- function Xr() {
25
+ function kr() {
26
26
  return !!document.getElementById(Wn);
27
27
  }
28
- function Kr() {
28
+ function Xr() {
29
29
  return document.getElementById(qr);
30
30
  }
31
- function kr(w, E, D, W) {
32
- const y = Kr();
33
- if (!y)
31
+ function Kr(w, y, D, W) {
32
+ const E = Xr();
33
+ if (!E)
34
34
  throw new Error("Iframe container does not exist");
35
35
  const v = document.createElement("iframe");
36
- return v.src = $r(w, E, D, W), v.id = Wn, v.style.zIndex = String(Number.MAX_SAFE_INTEGER), v.style.width = "100%", v.style.height = "100%", v.allow = "autoplay; camera", y.appendChild(v), v;
36
+ return v.src = Yr(w, y, D, W), v.id = Wn, v.style.zIndex = String(Number.MAX_SAFE_INTEGER), v.style.width = "100%", v.style.height = "100%", v.allow = "autoplay", v.allow = "camera", v.allow = "publickey-credentials-create", v.allow = "publickey-credentials-get", E.appendChild(v), v;
37
37
  }
38
- function Qr(w, E, D, W) {
39
- return Xr() ? document.getElementById(Wn) : kr(w, E, D, W);
38
+ function Qr(w, y, D, W) {
39
+ return kr() ? document.getElementById(Wn) : Kr(w, y, D, W);
40
40
  }
41
41
  function lr() {
42
42
  const w = document.getElementById(Wn);
@@ -47,13 +47,13 @@ function nt(w) {
47
47
  return w && w.__esModule && Object.prototype.hasOwnProperty.call(w, "default") ? w.default : w;
48
48
  }
49
49
  var vr = { exports: {} }, wr = { exports: {} };
50
- (function(w, E) {
50
+ (function(w, y) {
51
51
  (function(D, W) {
52
52
  w.exports = W();
53
53
  })(typeof self < "u" ? self : _r, function() {
54
54
  return function(D) {
55
55
  var W = {};
56
- function y(v) {
56
+ function E(v) {
57
57
  if (W[v])
58
58
  return W[v].exports;
59
59
  var S = W[v] = {
@@ -61,72 +61,72 @@ var vr = { exports: {} }, wr = { exports: {} };
61
61
  l: !1,
62
62
  exports: {}
63
63
  };
64
- return D[v].call(S.exports, S, S.exports, y), S.l = !0, S.exports;
64
+ return D[v].call(S.exports, S, S.exports, E), S.l = !0, S.exports;
65
65
  }
66
- return y.m = D, y.c = W, y.d = function(v, S, G) {
67
- y.o(v, S) || Object.defineProperty(v, S, {
66
+ return E.m = D, E.c = W, E.d = function(v, S, G) {
67
+ E.o(v, S) || Object.defineProperty(v, S, {
68
68
  enumerable: !0,
69
69
  get: G
70
70
  });
71
- }, y.r = function(v) {
71
+ }, E.r = function(v) {
72
72
  typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(v, Symbol.toStringTag, {
73
73
  value: "Module"
74
74
  }), Object.defineProperty(v, "__esModule", {
75
75
  value: !0
76
76
  });
77
- }, y.t = function(v, S) {
78
- if (1 & S && (v = y(v)), 8 & S || 4 & S && typeof v == "object" && v && v.__esModule)
77
+ }, E.t = function(v, S) {
78
+ if (1 & S && (v = E(v)), 8 & S || 4 & S && typeof v == "object" && v && v.__esModule)
79
79
  return v;
80
80
  var G = /* @__PURE__ */ Object.create(null);
81
- if (y.r(G), Object.defineProperty(G, "default", {
81
+ if (E.r(G), Object.defineProperty(G, "default", {
82
82
  enumerable: !0,
83
83
  value: v
84
84
  }), 2 & S && typeof v != "string")
85
85
  for (var Q in v)
86
- y.d(G, Q, (function(sn) {
86
+ E.d(G, Q, (function(sn) {
87
87
  return v[sn];
88
88
  }).bind(null, Q));
89
89
  return G;
90
- }, y.n = function(v) {
90
+ }, E.n = function(v) {
91
91
  var S = v && v.__esModule ? function() {
92
92
  return v.default;
93
93
  } : function() {
94
94
  return v;
95
95
  };
96
- return y.d(S, "a", S), S;
97
- }, y.o = function(v, S) {
96
+ return E.d(S, "a", S), S;
97
+ }, E.o = function(v, S) {
98
98
  return {}.hasOwnProperty.call(v, S);
99
- }, y.p = "", y(y.s = 0);
100
- }([function(D, W, y) {
101
- y.r(W), y.d(W, "Promise", function() {
99
+ }, E.p = "", E(E.s = 0);
100
+ }([function(D, W, E) {
101
+ E.r(W), E.d(W, "Promise", function() {
102
102
  return I;
103
- }), y.d(W, "TYPES", function() {
103
+ }), E.d(W, "TYPES", function() {
104
104
  return Br;
105
- }), y.d(W, "ProxyWindow", function() {
105
+ }), E.d(W, "ProxyWindow", function() {
106
106
  return F;
107
- }), y.d(W, "setup", function() {
107
+ }), E.d(W, "setup", function() {
108
108
  return hr;
109
- }), y.d(W, "destroy", function() {
109
+ }), E.d(W, "destroy", function() {
110
110
  return Fr;
111
- }), y.d(W, "serializeMessage", function() {
111
+ }), E.d(W, "serializeMessage", function() {
112
112
  return jr;
113
- }), y.d(W, "deserializeMessage", function() {
113
+ }), E.d(W, "deserializeMessage", function() {
114
114
  return Cr;
115
- }), y.d(W, "createProxyWindow", function() {
115
+ }), E.d(W, "createProxyWindow", function() {
116
116
  return Mr;
117
- }), y.d(W, "toProxyWindow", function() {
117
+ }), E.d(W, "toProxyWindow", function() {
118
118
  return Lr;
119
- }), y.d(W, "on", function() {
119
+ }), E.d(W, "on", function() {
120
120
  return J;
121
- }), y.d(W, "once", function() {
121
+ }), E.d(W, "once", function() {
122
122
  return Tr;
123
- }), y.d(W, "send", function() {
123
+ }), E.d(W, "send", function() {
124
124
  return q;
125
- }), y.d(W, "markWindowKnown", function() {
125
+ }), E.d(W, "markWindowKnown", function() {
126
126
  return nr;
127
- }), y.d(W, "cleanUpWindow", function() {
127
+ }), E.d(W, "cleanUpWindow", function() {
128
128
  return Ur;
129
- }), y.d(W, "bridge", function() {
129
+ }), E.d(W, "bridge", function() {
130
130
  });
131
131
  function v(n) {
132
132
  return {}.toString.call(n) === "[object RegExp]";
@@ -353,7 +353,7 @@ var vr = { exports: {} }, wr = { exports: {} };
353
353
  function Fn(n) {
354
354
  return n === void 0 && (n = window), Cn(n = n || window) || Z(n) || void 0;
355
355
  }
356
- function K(n, t) {
356
+ function X(n, t) {
357
357
  if (typeof n == "string") {
358
358
  if (typeof t == "string")
359
359
  return n === "*" || t === n;
@@ -361,7 +361,7 @@ var vr = { exports: {} }, wr = { exports: {} };
361
361
  return !1;
362
362
  }
363
363
  return v(n) ? v(t) ? n.toString() === t.toString() : !Array.isArray(t) && !!t.match(n) : !!Array.isArray(n) && (Array.isArray(t) ? JSON.stringify(n) === JSON.stringify(t) : !v(t) && n.some(function(r) {
364
- return K(r, t);
364
+ return X(r, t);
365
365
  }));
366
366
  }
367
367
  function ln(n) {
@@ -444,7 +444,7 @@ var vr = { exports: {} }, wr = { exports: {} };
444
444
  } catch {
445
445
  }
446
446
  }
447
- function Y(n) {
447
+ function $(n) {
448
448
  try {
449
449
  if (!n)
450
450
  return !1;
@@ -501,14 +501,14 @@ var vr = { exports: {} }, wr = { exports: {} };
501
501
  return t.resolve = function(r) {
502
502
  if (this.resolved || this.rejected)
503
503
  return this;
504
- if (Y(r))
504
+ if ($(r))
505
505
  throw new Error("Can not resolve promise with another promise");
506
506
  return this.resolved = !0, this.value = r, this.dispatch(), this;
507
507
  }, t.reject = function(r) {
508
508
  var e = this;
509
509
  if (this.resolved || this.rejected)
510
510
  return this;
511
- if (Y(r))
511
+ if ($(r))
512
512
  throw new Error("Can not reject promise with another promise");
513
513
  if (!r) {
514
514
  var o = r && typeof r.toString == "function" ? r.toString() : {}.toString.call(r);
@@ -562,7 +562,7 @@ var vr = { exports: {} }, wr = { exports: {} };
562
562
  var d = f;
563
563
  d.resolved ? h.resolve(d.value) : h.reject(d.error), d.errorHandled = !0;
564
564
  } else
565
- Y(f) ? f instanceof n && (f.resolved || f.rejected) ? f.resolved ? h.resolve(f.value) : h.reject(f.error) : i(f, h) : h.resolve(f);
565
+ $(f) ? f instanceof n && (f.resolved || f.rejected) ? f.resolved ? h.resolve(f.value) : h.reject(f.error) : i(f, h) : h.resolve(f);
566
566
  }
567
567
  o.length = 0, this.dispatching = !1, rn();
568
568
  }
@@ -608,7 +608,7 @@ var vr = { exports: {} }, wr = { exports: {} };
608
608
  }, t.lazy = function() {
609
609
  return this.errorHandled = !0, this;
610
610
  }, n.resolve = function(r) {
611
- return r instanceof n ? r : Y(r) ? new n(function(e, o) {
611
+ return r instanceof n ? r : $(r) ? new n(function(e, o) {
612
612
  return r.then(e, o);
613
613
  }) : new n().resolve(r);
614
614
  }, n.reject = function(r) {
@@ -632,7 +632,7 @@ var vr = { exports: {} }, wr = { exports: {} };
632
632
  i[s] = c.value, o -= 1;
633
633
  continue;
634
634
  }
635
- } else if (!Y(c)) {
635
+ } else if (!$(c)) {
636
636
  i[s] = c, o -= 1;
637
637
  continue;
638
638
  }
@@ -643,7 +643,7 @@ var vr = { exports: {} }, wr = { exports: {} };
643
643
  var e = {}, o = [], i = function(s) {
644
644
  if (r.hasOwnProperty(s)) {
645
645
  var c = r[s];
646
- Y(c) ? o.push(c.then(function(u) {
646
+ $(c) ? o.push(c.then(function(u) {
647
647
  e[s] = u;
648
648
  })) : e[s] = c;
649
649
  }
@@ -679,7 +679,7 @@ var vr = { exports: {} }, wr = { exports: {} };
679
679
  setTimeout(e, r);
680
680
  });
681
681
  }, n.isPromise = function(r) {
682
- return !!(r && r instanceof n) || Y(r);
682
+ return !!(r && r instanceof n) || $(r);
683
683
  }, n.flush = function() {
684
684
  return function(r) {
685
685
  var e = nn = nn || new r();
@@ -908,7 +908,7 @@ var vr = { exports: {} }, wr = { exports: {} };
908
908
  t = {};
909
909
  }, Jn(r, Gn(n) + "::promiseMemoized");
910
910
  }
911
- function $() {
911
+ function Y() {
912
912
  }
913
913
  function on(n, t) {
914
914
  if (t === void 0 && (t = 1), t >= 3)
@@ -953,24 +953,24 @@ var vr = { exports: {} }, wr = { exports: {} };
953
953
  var e = r();
954
954
  return n[t] = e, e;
955
955
  }
956
- function Yn() {
956
+ function $n() {
957
957
  var n = document.body;
958
958
  if (!n)
959
959
  throw new Error("Body element not found");
960
960
  return n;
961
961
  }
962
- function $n() {
962
+ function Yn() {
963
963
  return !!document.body && document.readyState === "complete";
964
964
  }
965
- function Xn() {
965
+ function kn() {
966
966
  return !!document.body && document.readyState === "interactive";
967
967
  }
968
968
  en(function() {
969
969
  return new I(function(n) {
970
- if ($n() || Xn())
970
+ if (Yn() || kn())
971
971
  return n();
972
972
  var t = setInterval(function() {
973
- if ($n() || Xn())
973
+ if (Yn() || kn())
974
974
  return clearInterval(t), n();
975
975
  }, 10);
976
976
  });
@@ -1029,11 +1029,11 @@ var vr = { exports: {} }, wr = { exports: {} };
1029
1029
  var t = "__post_robot_10_0_46__";
1030
1030
  return n !== window ? n[t] : n[t] = n[t] || {};
1031
1031
  }
1032
- var Kn = function() {
1032
+ var Xn = function() {
1033
1033
  return {};
1034
1034
  };
1035
1035
  function z(n, t) {
1036
- return n === void 0 && (n = "store"), t === void 0 && (t = Kn), an(un(), n, function() {
1036
+ return n === void 0 && (n = "store"), t === void 0 && (t = Xn), an(un(), n, function() {
1037
1037
  var r = t();
1038
1038
  return {
1039
1039
  has: function(e) {
@@ -1067,7 +1067,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1067
1067
  return n.WINDOW_WILDCARD = n.WINDOW_WILDCARD || new br(), n.WINDOW_WILDCARD;
1068
1068
  }
1069
1069
  function C(n, t) {
1070
- return n === void 0 && (n = "store"), t === void 0 && (t = Kn), z("windowStore").getOrSet(n, function() {
1070
+ return n === void 0 && (n = "store"), t === void 0 && (t = Xn), z("windowStore").getOrSet(n, function() {
1071
1071
  var r = new In(), e = function(o) {
1072
1072
  return r.getOrSet(o, t);
1073
1073
  };
@@ -1091,7 +1091,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1091
1091
  };
1092
1092
  });
1093
1093
  }
1094
- function kn() {
1094
+ function Kn() {
1095
1095
  return z("instance").getOrSet("instanceID", H);
1096
1096
  }
1097
1097
  function Qn(n, t) {
@@ -1106,7 +1106,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1106
1106
  }
1107
1107
  function Pn(n, t) {
1108
1108
  return (0, t.send)(n, "postrobot_hello", {
1109
- instanceID: kn()
1109
+ instanceID: Kn()
1110
1110
  }, {
1111
1111
  domain: "*",
1112
1112
  timeout: -1
@@ -1140,7 +1140,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1140
1140
  function rr(n) {
1141
1141
  return n === void 0 ? "undefined" : n === null ? "null" : Array.isArray(n) ? "array" : typeof n == "function" ? "function" : typeof n == "object" ? n instanceof Error ? "error" : typeof n.then == "function" ? "promise" : {}.toString.call(n) === "[object RegExp]" ? "regex" : {}.toString.call(n) === "[object Date]" ? "date" : "object" : typeof n == "string" ? "string" : typeof n == "number" ? "number" : typeof n == "boolean" ? "boolean" : void 0;
1142
1142
  }
1143
- function X(n, t) {
1143
+ function k(n, t) {
1144
1144
  return {
1145
1145
  __type__: n,
1146
1146
  __val__: t
@@ -1148,7 +1148,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1148
1148
  }
1149
1149
  var M, Pr = ((M = {}).function = function() {
1150
1150
  }, M.error = function(n) {
1151
- return X("error", {
1151
+ return k("error", {
1152
1152
  message: n.message,
1153
1153
  stack: n.stack,
1154
1154
  code: n.code,
@@ -1156,9 +1156,9 @@ var vr = { exports: {} }, wr = { exports: {} };
1156
1156
  });
1157
1157
  }, M.promise = function() {
1158
1158
  }, M.regex = function(n) {
1159
- return X("regex", n.source);
1159
+ return k("regex", n.source);
1160
1160
  }, M.date = function(n) {
1161
- return X("date", n.toJSON());
1161
+ return k("date", n.toJSON());
1162
1162
  }, M.array = function(n) {
1163
1163
  return n;
1164
1164
  }, M.object = function(n) {
@@ -1172,7 +1172,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1172
1172
  }, M.null = function(n) {
1173
1173
  return n;
1174
1174
  }, M[void 0] = function(n) {
1175
- return X("undefined", n);
1175
+ return k("undefined", n);
1176
1176
  }, M), Or = {}, L, Ar = ((L = {}).function = function() {
1177
1177
  throw new Error("Function serialization is not implemented; nothing to deserialize");
1178
1178
  }, L.error = function(n) {
@@ -1223,7 +1223,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1223
1223
  throw new Error("Window is closed, can not determine type");
1224
1224
  return Cn(c) ? "popup" : "iframe";
1225
1225
  });
1226
- i.catch($), a.catch($);
1226
+ i.catch(Y), a.catch(Y);
1227
1227
  var s = function() {
1228
1228
  return n.then(function(c) {
1229
1229
  if (!B(c))
@@ -1274,7 +1274,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1274
1274
  var N, cn = U[A], zn = document.createElement("input");
1275
1275
  zn.setAttribute("name", cn), zn.setAttribute("value", (N = O[cn]) == null ? void 0 : N.toString()), x.appendChild(zn);
1276
1276
  }
1277
- Yn().appendChild(x), x.submit(), Yn().removeChild(x);
1277
+ $n().appendChild(x), x.submit(), $n().removeChild(x);
1278
1278
  })({
1279
1279
  url: c,
1280
1280
  target: m,
@@ -1447,7 +1447,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1447
1447
  throw new Error("Could not find method '" + m + "' with id: " + l.id + " in " + j(window));
1448
1448
  var b = p.source, R = p.domain, O = p.val;
1449
1449
  return I.try(function() {
1450
- if (!K(R, d))
1450
+ if (!X(R, d))
1451
1451
  throw new Error("Method '" + l.name + "' domain " + JSON.stringify(bn(p.domain) ? p.domain.source : p.domain) + " does not match origin " + d + " in " + j(window));
1452
1452
  if (F.isProxyWindow(b))
1453
1453
  return b.matchWindow(f, {
@@ -1489,7 +1489,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1489
1489
  var u = r.__name__ || r.name || e;
1490
1490
  return typeof u == "string" && typeof u.indexOf == "function" && u.indexOf("anonymous::") === 0 && (u = u.replace("anonymous::", e + "::")), F.isProxyWindow(n) ? (Dn(c, r, u, n, t), n.awaitWindow().then(function(h) {
1491
1491
  Dn(c, r, u, h, t);
1492
- })) : Dn(c, r, u, n, t), X("cross_domain_function", {
1492
+ })) : Dn(c, r, u, n, t), k("cross_domain_function", {
1493
1493
  id: c,
1494
1494
  name: u
1495
1495
  });
@@ -1511,7 +1511,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1511
1511
  return u === void 0 ? "undefined" : u;
1512
1512
  }(r, ((o = {}).promise = function(s, c) {
1513
1513
  return function(u, h, f, d, l) {
1514
- return X("cross_domain_zalgo_promise", {
1514
+ return k("cross_domain_zalgo_promise", {
1515
1515
  then: or(u, h, function(g, m) {
1516
1516
  return f.then(g, m);
1517
1517
  }, d, {
@@ -1529,7 +1529,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1529
1529
  send: a
1530
1530
  });
1531
1531
  }, o.object = function(s) {
1532
- return ln(s) || F.isProxyWindow(s) ? X("cross_domain_window", F.serialize(s, {
1532
+ return ln(s) || F.isProxyWindow(s) ? k("cross_domain_window", F.serialize(s, {
1533
1533
  send: a
1534
1534
  })) : s;
1535
1535
  }, o));
@@ -1639,7 +1639,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1639
1639
  }), a.flush.then(function() {
1640
1640
  delete a.flush;
1641
1641
  });
1642
- }).then($);
1642
+ }).then(Y);
1643
1643
  }
1644
1644
  function ur(n) {
1645
1645
  return z("responseListeners").get(n);
@@ -1667,7 +1667,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1667
1667
  if (u.__domain_regex__)
1668
1668
  for (var h = 0, f = u.__domain_regex__; h < f.length; h++) {
1669
1669
  var d = f[h], l = d.listener;
1670
- if (K(d.regex, e))
1670
+ if (X(d.regex, e))
1671
1671
  return l;
1672
1672
  }
1673
1673
  }
@@ -1738,7 +1738,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1738
1738
  return c("success", u);
1739
1739
  }, function(u) {
1740
1740
  return c("error", null, u);
1741
- })]).then($).catch(function(u) {
1741
+ })]).then(Y).catch(function(u) {
1742
1742
  if (a && a.handleError)
1743
1743
  return a.handleError(u);
1744
1744
  throw u;
@@ -1750,7 +1750,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1750
1750
  if (!e)
1751
1751
  throw new Error("No handler found for post message ack for message: " + r.name + " from " + t + " in " + window.location.protocol + "//" + window.location.host + window.location.pathname);
1752
1752
  try {
1753
- if (!K(e.domain, t))
1753
+ if (!X(e.domain, t))
1754
1754
  throw new Error("Ack origin " + t + " does not match domain " + e.domain.toString());
1755
1755
  if (n !== e.win)
1756
1756
  throw new Error("Ack source does not match registered window");
@@ -1765,7 +1765,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1765
1765
  var e = ur(r.hash);
1766
1766
  if (!e)
1767
1767
  throw new Error("No handler found for post message response for message: " + r.name + " from " + t + " in " + window.location.protocol + "//" + window.location.host + window.location.pathname);
1768
- if (!K(e.domain, t))
1768
+ if (!X(e.domain, t))
1769
1769
  throw new Error("Response origin " + t + " does not match domain " + (o = e.domain, Array.isArray(o) ? "(" + o.join(" | ") + ")" : v(o) ? "RegExp(" + o.toString() + ")" : o.toString()));
1770
1770
  var o;
1771
1771
  if (n !== e.win)
@@ -1845,7 +1845,7 @@ var vr = { exports: {} }, wr = { exports: {} };
1845
1845
  cancel: function() {
1846
1846
  f.then(function(N) {
1847
1847
  return N.cancel();
1848
- }, $);
1848
+ }, Y);
1849
1849
  }
1850
1850
  };
1851
1851
  }
@@ -2009,7 +2009,7 @@ var vr = { exports: {} }, wr = { exports: {} };
2009
2009
  return p.domain;
2010
2010
  });
2011
2011
  }).then(function(p) {
2012
- if (!K(d, d))
2012
+ if (!X(d, d))
2013
2013
  throw new Error("Domain " + Vn(d) + " does not match " + Vn(d));
2014
2014
  return p;
2015
2015
  });
@@ -2059,7 +2059,7 @@ var vr = { exports: {} }, wr = { exports: {} };
2059
2059
  }();
2060
2060
  l.finally(function() {
2061
2061
  T.cancel(), p.splice(p.indexOf(l, 1));
2062
- }).catch($);
2062
+ }).catch(Y);
2063
2063
  }
2064
2064
  return Rn(u, f, {
2065
2065
  id: H(),
@@ -2159,7 +2159,7 @@ var vr = { exports: {} }, wr = { exports: {} };
2159
2159
  return Qn(u.source, {
2160
2160
  domain: u.origin
2161
2161
  }), {
2162
- instanceID: kn()
2162
+ instanceID: Kn()
2163
2163
  };
2164
2164
  }), c = Fn();
2165
2165
  return c && Pn(c, {
@@ -2186,7 +2186,7 @@ var vr = { exports: {} }, wr = { exports: {} };
2186
2186
  var Br = !0;
2187
2187
  function Ur(n) {
2188
2188
  for (var t = 0, r = C("requestPromises").get(n, []); t < r.length; t++)
2189
- r[t].reject(new Error("Window " + (B(n) ? "closed" : "cleaned up") + " before response")).catch($);
2189
+ r[t].reject(new Error("Window " + (B(n) ? "closed" : "cleaned up") + " before response")).catch(Y);
2190
2190
  }
2191
2191
  hr();
2192
2192
  }]);
@@ -2199,11 +2199,11 @@ var rt = wr.exports;
2199
2199
  var tt = vr.exports;
2200
2200
  const gn = /* @__PURE__ */ nt(tt), et = "WIDGET_MOUNTED", ot = "WIDGET_EVENT";
2201
2201
  function it(w) {
2202
- const { configure: E, onEvent: D } = w;
2202
+ const { configure: y, onEvent: D } = w;
2203
2203
  gn.on(et, () => {
2204
- E();
2204
+ y();
2205
2205
  }), gn.on(ot, (W) => {
2206
- D(W.data), Yr.includes(W.data.eventName) && lr();
2206
+ D(W.data), $r.includes(W.data.eventName) && lr();
2207
2207
  });
2208
2208
  }
2209
2209
  function at(w) {
@@ -2212,25 +2212,25 @@ function at(w) {
2212
2212
  function ut(w) {
2213
2213
  gn.send(w.contentWindow, "ready");
2214
2214
  }
2215
- function ct(w, E) {
2216
- gn.send(w.contentWindow, "config", E);
2215
+ function ct(w, y) {
2216
+ gn.send(w.contentWindow, "config", y);
2217
2217
  }
2218
2218
  var yn, mr, En, pr;
2219
2219
  class ft {
2220
2220
  // eslint-disable-next-line max-params
2221
- constructor(E) {
2221
+ constructor(y) {
2222
2222
  Tn(this, yn);
2223
2223
  Tn(this, En);
2224
- k(this, "iframe");
2225
- k(this, "flow");
2226
- k(this, "configProps");
2227
- k(this, "onEvent");
2228
- k(this, "isSandbox");
2229
- this.flow = E.flow, this.configProps = E.configProps, this.onEvent = E.onEvent, this.isSandbox = E.isSandbox ?? !1, this.validateProps(), this.iframe = Qr(
2224
+ K(this, "iframe");
2225
+ K(this, "flow");
2226
+ K(this, "configProps");
2227
+ K(this, "onEvent");
2228
+ K(this, "isSandbox");
2229
+ this.flow = y.flow, this.configProps = y.configProps, this.onEvent = y.onEvent, this.isSandbox = y.isSandbox ?? !1, this.validateProps(), this.iframe = Qr(
2230
2230
  this.flow,
2231
2231
  this.configProps,
2232
2232
  this.isSandbox,
2233
- E.developmentUrl
2233
+ y.developmentUrl
2234
2234
  ), at({
2235
2235
  configure: jn(this, yn, mr).bind(this),
2236
2236
  onEvent: jn(this, En, pr).bind(this)
@@ -2256,8 +2256,8 @@ class ft {
2256
2256
  }
2257
2257
  yn = new WeakSet(), mr = function() {
2258
2258
  ut(this.iframe), ct(this.iframe, this.configProps);
2259
- }, En = new WeakSet(), pr = function(E) {
2260
- this.onEvent(E);
2259
+ }, En = new WeakSet(), pr = function(y) {
2260
+ this.onEvent(y);
2261
2261
  };
2262
2262
  export {
2263
2263
  ft as default
@@ -1,17 +1,17 @@
1
- (function(R,P){typeof exports=="object"&&typeof module<"u"?module.exports=P():typeof define=="function"&&define.amd?define(P):(R=typeof globalThis<"u"?globalThis:R||self,R["soyio-widget"]=P())})(this,function(){"use strict";var ue=Object.defineProperty;var ce=(R,P,L)=>P in R?ue(R,P,{enumerable:!0,configurable:!0,writable:!0,value:L}):R[P]=L;var nn=(R,P,L)=>(ce(R,typeof P!="symbol"?P+"":P,L),L),se=(R,P,L)=>{if(!P.has(R))throw TypeError("Cannot "+L)};var Cn=(R,P,L)=>{if(P.has(R))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(R):P.set(R,L)};var Mn=(R,P,L)=>(se(R,P,"access private method"),L);var ln,gt,vn,yt;const R="soyio-widget-iframe-container",P="soyio-widget-iframe",L="https://app.soyio.id/widget",Et="https://sandbox.soyio.id/widget",Wt=["IDENTITY_AUTHENTICATED","IDENTITY_REGISTERED"];function xt(W,D,H,y){const g=y||(H?Et:L),v=`platform=web&companyId=${encodeURIComponent(D.companyId)}`;switch(W){case"authenticate":return`${g}/authenticate?${v}&identityId=${D.identityId}`;case"register":return`${g}/register?${v}&flowTemplateId=${D.flowTemplateId}`;default:return"INVALID_PARAMS"}}function St(){return!!document.getElementById(P)}function It(){return document.getElementById(R)}function bt(W,D,H,y){const g=It();if(!g)throw new Error("Iframe container does not exist");const v=document.createElement("iframe");return v.src=xt(W,D,H,y),v.id=P,v.style.zIndex=String(Number.MAX_SAFE_INTEGER),v.style.width="100%",v.style.height="100%",v.allow="autoplay; camera",g.appendChild(v),v}function Pt(W,D,H,y){return St()?document.getElementById(P):bt(W,D,H,y)}function Ln(){const W=document.getElementById(P);W&&W.remove()}var Ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function At(W){return W&&W.__esModule&&Object.prototype.hasOwnProperty.call(W,"default")?W.default:W}var Fn={exports:{}},Bn={exports:{}};(function(W,D){(function(H,y){W.exports=y()})(typeof self<"u"?self:Ot,function(){return function(H){var y={};function g(v){if(y[v])return y[v].exports;var x=y[v]={i:v,l:!1,exports:{}};return H[v].call(x.exports,x,x.exports,g),x.l=!0,x.exports}return g.m=H,g.c=y,g.d=function(v,x,Z){g.o(v,x)||Object.defineProperty(v,x,{enumerable:!0,get:Z})},g.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},g.t=function(v,x){if(1&x&&(v=g(v)),8&x||4&x&&typeof v=="object"&&v&&v.__esModule)return v;var Z=Object.create(null);if(g.r(Z),Object.defineProperty(Z,"default",{enumerable:!0,value:v}),2&x&&typeof v!="string")for(var tn in v)g.d(Z,tn,(function(wn){return v[wn]}).bind(null,tn));return Z},g.n=function(v){var x=v&&v.__esModule?function(){return v.default}:function(){return v};return g.d(x,"a",x),x},g.o=function(v,x){return{}.hasOwnProperty.call(v,x)},g.p="",g(g.s=0)}([function(H,y,g){g.r(y),g.d(y,"Promise",function(){return S}),g.d(y,"TYPES",function(){return ie}),g.d(y,"ProxyWindow",function(){return U}),g.d(y,"setup",function(){return pt}),g.d(y,"destroy",function(){return oe}),g.d(y,"serializeMessage",function(){return ne}),g.d(y,"deserializeMessage",function(){return te}),g.d(y,"createProxyWindow",function(){return ee}),g.d(y,"toProxyWindow",function(){return re}),g.d(y,"on",function(){return V}),g.d(y,"once",function(){return _t}),g.d(y,"send",function(){return Y}),g.d(y,"markWindowKnown",function(){return it}),g.d(y,"cleanUpWindow",function(){return ae}),g.d(y,"bridge",function(){});function v(n){return{}.toString.call(n)==="[object RegExp]"}var x=`Call was rejected by callee.\r
2
- `;function Z(n){return n===void 0&&(n=window),n.location.protocol}function tn(n){if(n===void 0&&(n=window),n.mockDomain){var e=n.mockDomain.split("//")[0];if(e)return e}return Z(n)}function wn(n){return n===void 0&&(n=window),tn(n)==="about:"}function $(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Un(n){if(n===void 0&&(n=window),n&&!$(n))try{return n.opener}catch{}}function mn(n){try{return!0}catch{}return!1}function pn(n){n===void 0&&(n=window);var e=n.location;if(!e)throw new Error("Can not read window location");var t=Z(n);if(!t)throw new Error("Can not read window protocol");if(t==="file:")return"file://";if(t==="about:"){var r=$(n);return r&&mn()?pn(r):"about://"}var o=e.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function C(n){n===void 0&&(n=window);var e=pn(n);return e&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:e}function X(n){if(!function(e){try{if(e===window)return!0}catch{}try{var t=Object.getOwnPropertyDescriptor(e,"location");if(t&&t.enumerable===!1)return!1}catch{}try{if(wn(e)&&mn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),tn(r)==="mock:"}(e)&&mn())return!0}catch{}try{if(pn(e)===pn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||wn(n)&&mn()||C(window)===C(n))return!0}catch{}return!1}function gn(n){if(!X(n))throw new Error("Expected window to be same domain");return n}function Hn(n,e){if(!n||!e)return!1;var t=$(e);return t?t===n:function(r){var o=[];try{for(;r.parent!==r;)o.push(r.parent),r=r.parent}catch{}return o}(e).indexOf(n)!==-1}function Gn(n){var e=[],t;try{t=n.frames}catch{t=n}var r;try{r=t.length}catch{}if(r===0)return e;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=t[o]}catch{continue}e.push(i)}return e}for(var a=0;a<100;a++){var s=void 0;try{s=t[a]}catch{return e}if(!s)return e;e.push(s)}return e}var Ft=[],Bt=[];function G(n,e){e===void 0&&(e=!0);try{if(n===window)return!1}catch{return!0}try{if(!n)return!0}catch{return!0}try{if(n.closed)return!0}catch(o){return!o||o.message!==x}if(e&&X(n))try{if(n.mockclosed)return!0}catch{}try{if(!n.parent||!n.top)return!0}catch{}var t=function(o,i){for(var a=0;a<o.length;a++)try{if(o[a]===i)return a}catch{}return-1}(Ft,n);if(t!==-1){var r=Bt[t];if(r&&function(o){if(!o.contentWindow||!o.parentNode)return!0;var i=o.ownerDocument;if(i&&i.documentElement&&!i.documentElement.contains(o)){for(var a=o;a.parentNode&&a.parentNode!==a;)a=a.parentNode;if(!a.host||!i.documentElement.contains(a.host))return!0}return!1}(r))return!0}return!1}function Jn(n){return n===void 0&&(n=window),Un(n=n||window)||$(n)||void 0}function _(n,e){if(typeof n=="string"){if(typeof e=="string")return n==="*"||e===n;if(v(e)||Array.isArray(e))return!1}return v(n)?v(e)?n.toString()===e.toString():!Array.isArray(e)&&!!e.match(n):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!v(e)&&n.some(function(t){return _(t,e)}))}function yn(n){try{if(n===window)return!0}catch(e){if(e&&e.message===x)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(e){if(e&&e.message===x)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(e){if(e&&e.message===x)return!0}try{if(n&&n.self===n)return!0}catch(e){if(e&&e.message===x)return!0}try{if(n&&n.parent===n)return!0}catch(e){if(e&&e.message===x)return!0}try{if(n&&n.top===n)return!0}catch(e){if(e&&e.message===x)return!0}try{if(n&&n.__cross_domain_utils_window_check__==="__unlikely_value__")return!1}catch{return!0}try{if("postMessage"in n&&"self"in n&&"location"in n)return!0}catch{}return!1}function qn(n){if(X(n))return gn(n).frameElement;for(var e=0,t=document.querySelectorAll("iframe");e<t.length;e++){var r=t[e];if(r&&r.contentWindow&&r.contentWindow===n)return r}}function Ut(n){if(function(t){return t===void 0&&(t=window),!!$(t)}(n)){var e=qn(n);if(e&&e.parentElement){e.parentElement.removeChild(e);return}}try{n.close()}catch{}}function K(n){try{if(!n)return!1;if(typeof Promise<"u"&&n instanceof Promise)return!0;if(typeof window<"u"&&typeof window.Window=="function"&&n instanceof window.Window||typeof window<"u"&&typeof window.constructor=="function"&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var t=e.call(n);if(t==="[object Window]"||t==="[object global]"||t==="[object DOMWindow]")return!1}if(typeof n.then=="function")return!0}catch{return!1}return!1}var Zn=[],en=[],In=0,rn;function Vn(){if(!In&&rn){var n=rn;rn=null,n.resolve()}}function bn(){In+=1}function on(){In-=1,Vn()}var S=function(){function n(t){var r=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],t){var o,i,a=!1,s=!1,c=!1;bn();try{t(function(u){c?r.resolve(u):(a=!0,o=u)},function(u){c?r.reject(u):(s=!0,i=u)})}catch(u){on(),this.reject(u);return}on(),c=!0,a?this.resolve(o):s&&this.reject(i)}}var e=n.prototype;return e.resolve=function(t){if(this.resolved||this.rejected)return this;if(K(t))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=t,this.dispatch(),this},e.reject=function(t){var r=this;if(this.resolved||this.rejected)return this;if(K(t))throw new Error("Can not reject promise with another promise");if(!t){var o=t&&typeof t.toString=="function"?t.toString():{}.toString.call(t);t=new Error("Expected reject to be called with Error, got "+o)}return this.rejected=!0,this.error=t,this.errorHandled||setTimeout(function(){r.errorHandled||function(i,a){if(Zn.indexOf(i)===-1){Zn.push(i),setTimeout(function(){throw i},1);for(var s=0;s<en.length;s++)en[s](i,a)}}(t,r)},1),this.dispatch(),this},e.asyncReject=function(t){return this.errorHandled=!0,this.reject(t),this},e.dispatch=function(){var t=this.resolved,r=this.rejected,o=this.handlers;if(!this.dispatching&&(t||r)){this.dispatching=!0,bn();for(var i=function(l,p){return l.then(function(w){p.resolve(w)},function(w){p.reject(w)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,h=s.promise,f=void 0;if(t)try{f=c?c(this.value):this.value}catch(l){h.reject(l);continue}else if(r){if(!u){h.reject(this.error);continue}try{f=u(this.error)}catch(l){h.reject(l);continue}}if(f instanceof n&&(f.resolved||f.rejected)){var d=f;d.resolved?h.resolve(d.value):h.reject(d.error),d.errorHandled=!0}else K(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?h.resolve(f.value):h.reject(f.error):i(f,h):h.resolve(f)}o.length=0,this.dispatching=!1,on()}},e.then=function(t,r){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.then expected a function for success handler");if(r&&typeof r!="function"&&!r.call)throw new Error("Promise.then expected a function for error handler");var o=new n;return this.handlers.push({promise:o,onSuccess:t,onError:r}),this.errorHandled=!0,this.dispatch(),o},e.catch=function(t){return this.then(void 0,t)},e.finally=function(t){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return n.try(t).then(function(){return r})},function(r){return n.try(t).then(function(){throw r})})},e.timeout=function(t,r){var o=this;if(this.resolved||this.rejected)return this;var i=setTimeout(function(){o.resolved||o.rejected||o.reject(r||new Error("Promise timed out after "+t+"ms"))},t);return this.then(function(a){return clearTimeout(i),a})},e.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(t){return t instanceof n?t:K(t)?new n(function(r,o){return t.then(r,o)}):new n().resolve(t)},n.reject=function(t){return new n().reject(t)},n.asyncReject=function(t){return new n().asyncReject(t)},n.all=function(t){var r=new n,o=t.length,i=[].slice();if(!o)return r.resolve(i),r;for(var a=function(u,h,f){return h.then(function(d){i[u]=d,(o-=1)==0&&r.resolve(i)},function(d){f.reject(d)})},s=0;s<t.length;s++){var c=t[s];if(c instanceof n){if(c.resolved){i[s]=c.value,o-=1;continue}}else if(!K(c)){i[s]=c,o-=1;continue}a(s,n.resolve(c),r)}return o===0&&r.resolve(i),r},n.hash=function(t){var r={},o=[],i=function(s){if(t.hasOwnProperty(s)){var c=t[s];K(c)?o.push(c.then(function(u){r[s]=u})):r[s]=c}};for(var a in t)i(a);return n.all(o).then(function(){return r})},n.map=function(t,r){return n.all(t.map(r))},n.onPossiblyUnhandledException=function(t){return function(r){return en.push(r),{cancel:function(){en.splice(en.indexOf(r),1)}}}(t)},n.try=function(t,r,o){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.try expected a function");var i;bn();try{i=t.apply(r,o||[])}catch(a){return on(),n.reject(a)}return on(),n.resolve(i)},n.delay=function(t){return new n(function(r){setTimeout(r,t)})},n.isPromise=function(t){return!!(t&&t instanceof n)||K(t)},n.flush=function(){return function(t){var r=rn=rn||new t;return Vn(),r}(n)},n}();function En(n,e){for(var t=0;t<n.length;t++)try{if(n[t]===e)return t}catch{}return-1}var Pn=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if(typeof WeakMap>"u"||Object.freeze===void 0)return!1;try{var t=new WeakMap,r={};return Object.freeze(r),t.set(r,"__testvalue__"),t.get(r)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var t=this.weakmap,r=this.keys,o=0;o<r.length;o++){var i=r[o];if(yn(i)&&G(i)){if(t)try{t.delete(i)}catch{}r.splice(o,1),this.values.splice(o,1),o-=1}}},e.isSafeToReadWrite=function(t){return!yn(t)},e.set=function(t,r){if(!t)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.set(t,r)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var i=this.name,a=t[i];a&&a[0]===t?a[1]=r:Object.defineProperty(t,i,{value:[t,r],writable:!0});return}catch{}this._cleanupClosedWindows();var s=this.keys,c=this.values,u=En(s,t);u===-1?(s.push(t),c.push(r)):c[u]=r},e.get=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(t))return r.get(t)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];return o&&o[0]===t?o[1]:void 0}catch{}this._cleanupClosedWindows();var i=En(this.keys,t);if(i!==-1)return this.values[i]},e.delete=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(t)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];o&&o[0]===t&&(o[0]=o[1]=void 0)}catch{}this._cleanupClosedWindows();var i=this.keys,a=En(i,t);a!==-1&&(i.splice(a,1),this.values.splice(a,1))},e.has=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(t))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];return!(!o||o[0]!==t)}catch{}return this._cleanupClosedWindows(),En(this.keys,t)!==-1},e.getOrSet=function(t,r){if(this.has(t))return this.get(t);var o=r();return this.set(t,o),o},n}();function Yn(n){return n.name||n.__name__||n.displayName||"anonymous"}function $n(n,e){try{delete n.name,n.name=e}catch{}return n.__name__=n.displayName=e,n}function q(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(e){if(typeof btoa=="function")return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(t,r){return String.fromCharCode(parseInt(r,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}(new Date().toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var Wn;function Xn(n){try{return JSON.stringify([].slice.call(n),function(e,t){return typeof t=="function"?"memoize["+function(r){if(Wn=Wn||new Pn,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=Wn.get(r);return o||(o=typeof r+":"+q(),Wn.set(r,o)),o}(t)+"]":typeof window<"u"&&t instanceof window.Element||t!==null&&typeof t=="object"&&t.nodeType===1&&typeof t.style=="object"&&typeof t.ownerDocument=="object"?{}:t})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function Ht(){return{}}var an=0,Kn=0;function un(n,e){e===void 0&&(e={});var t=e.thisNamespace,r=t!==void 0&&t,o=e.time,i,a,s=an;an+=1;var c=function(){for(var u=arguments.length,h=new Array(u),f=0;f<u;f++)h[f]=arguments[f];s<Kn&&(i=null,a=null,s=an,an+=1);var d;d=r?(a=a||new Pn).getOrSet(this,Ht):i=i||{};var l;try{l=Xn(h)}catch{return n.apply(this,arguments)}var p=d[l];if(p&&o&&Date.now()-p.time<o&&(delete d[l],p=null),p)return p.value;var w=Date.now(),m=n.apply(this,arguments);return d[l]={time:w,value:m},m};return c.reset=function(){i=null,a=null},$n(c,(e.name||Yn(n))+"::memoized")}un.clear=function(){Kn=an};function Gt(n){var e={};function t(){for(var r=arguments,o=this,i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var c=Xn(a);return e.hasOwnProperty(c)||(e[c]=S.try(function(){return n.apply(o,r)}).finally(function(){delete e[c]})),e[c]}return t.reset=function(){e={}},$n(t,Yn(n)+"::promiseMemoized")}function k(){}function cn(n,e){if(e===void 0&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if(typeof n=="string")return n;if(n instanceof Error){var t=n&&n.stack,r=n&&n.message;if(t&&r)return t.indexOf(r)!==-1?t:r+`
3
- `+t;if(t)return t;if(r)return r}return n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}catch(o){return"Error while stringifying error: "+cn(o,e+1)}}function kn(n){return typeof n=="string"?n:n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}un(function(n){if(Object.values)return Object.values(n);var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(n[t]);return e});function On(n){return{}.toString.call(n)==="[object RegExp]"}function sn(n,e,t){if(n.hasOwnProperty(e))return n[e];var r=t();return n[e]=r,r}function Qn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function _n(){return!!document.body&&document.readyState==="complete"}function nt(){return!!document.body&&document.readyState==="interactive"}un(function(){return new S(function(n){if(_n()||nt())return n();var e=setInterval(function(){if(_n()||nt())return clearInterval(e),n()},10)})});var xn=typeof document<"u"?document.currentScript:null,Jt=un(function(){if(xn||(xn=function(){try{var n=function(){try{throw new Error("_")}catch(a){return a.stack||""}}(),e=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),t=e&&e[1];if(!t)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===t)return i}}catch{}}()))return xn;throw new Error("Can not determine current script")}),qt=q();un(function(){var n;try{n=Jt()}catch{return qt}var e=n.getAttribute("data-uid");if(e&&typeof e=="string"||(e=n.getAttribute("data-uid-auto"))&&typeof e=="string")return e;if(n.src){var t=function(r){for(var o="",i=0;i<r.length;i++){var a=r[i].charCodeAt(0)*i;r[i+1]&&(a+=r[i+1].charCodeAt(0)*(i-1)),o+=String.fromCharCode(97+Math.abs(a)%26)}return o}(JSON.stringify({src:n.src,dataset:n.dataset}));e="uid_"+t.slice(t.length-30)}else e=q();return n.setAttribute("data-uid-auto",e),e});function fn(n){n===void 0&&(n=window);var e="__post_robot_10_0_46__";return n!==window?n[e]:n[e]=n[e]||{}}var tt=function(){return{}};function z(n,e){return n===void 0&&(n="store"),e===void 0&&(e=tt),sn(fn(),n,function(){var t=e();return{has:function(r){return t.hasOwnProperty(r)},get:function(r,o){return t.hasOwnProperty(r)?t[r]:o},set:function(r,o){return t[r]=o,o},del:function(r){delete t[r]},getOrSet:function(r,o){return sn(t,r,o)},reset:function(){t=e()},keys:function(){return Object.keys(t)}}})}var Zt=function(){};function Sn(){var n=fn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new Zt,n.WINDOW_WILDCARD}function M(n,e){return n===void 0&&(n="store"),e===void 0&&(e=tt),z("windowStore").getOrSet(n,function(){var t=new Pn,r=function(o){return t.getOrSet(o,e)};return{has:function(o){return r(o).hasOwnProperty(n)},get:function(o,i){var a=r(o);return a.hasOwnProperty(n)?a[n]:i},set:function(o,i){return r(o)[n]=i,i},del:function(o){delete r(o)[n]},getOrSet:function(o,i){return sn(r(o),n,i)}}})}function et(){return z("instance").getOrSet("instanceID",q)}function rt(n,e){var t=e.domain,r=M("helloPromises"),o=r.get(n);o&&o.resolve({domain:t});var i=S.resolve({domain:t});return r.set(n,i),i}function An(n,e){return(0,e.send)(n,"postrobot_hello",{instanceID:et()},{domain:"*",timeout:-1}).then(function(t){var r=t.origin,o=t.data.instanceID;return rt(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function ot(n,e){var t=e.send;return M("windowInstanceIDPromises").getOrSet(n,function(){return An(n,{send:t}).then(function(r){return r.instanceID})})}function it(n){M("knownWindows").set(n,!0)}function Dn(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function at(n){return n===void 0?"undefined":n===null?"null":Array.isArray(n)?"array":typeof n=="function"?"function":typeof n=="object"?n instanceof Error?"error":typeof n.then=="function"?"promise":{}.toString.call(n)==="[object RegExp]"?"regex":{}.toString.call(n)==="[object Date]"?"date":"object":typeof n=="string"?"string":typeof n=="number"?"number":typeof n=="boolean"?"boolean":void 0}function Q(n,e){return{__type__:n,__val__:e}}var F,Vt=((F={}).function=function(){},F.error=function(n){return Q("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},F.promise=function(){},F.regex=function(n){return Q("regex",n.source)},F.date=function(n){return Q("date",n.toJSON())},F.array=function(n){return n},F.object=function(n){return n},F.string=function(n){return n},F.number=function(n){return n},F.boolean=function(n){return n},F.null=function(n){return n},F[void 0]=function(n){return Q("undefined",n)},F),Yt={},B,$t=((B={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},B.error=function(n){var e=n.stack,t=n.code,r=n.data,o=new Error(n.message);return o.code=t,r&&(o.data=r),o.stack=e+`
1
+ (function(R,P){typeof exports=="object"&&typeof module<"u"?module.exports=P():typeof define=="function"&&define.amd?define(P):(R=typeof globalThis<"u"?globalThis:R||self,R["soyio-widget"]=P())})(this,function(){"use strict";var ut=Object.defineProperty;var ct=(R,P,L)=>P in R?ut(R,P,{enumerable:!0,configurable:!0,writable:!0,value:L}):R[P]=L;var nn=(R,P,L)=>(ct(R,typeof P!="symbol"?P+"":P,L),L),st=(R,P,L)=>{if(!P.has(R))throw TypeError("Cannot "+L)};var Cn=(R,P,L)=>{if(P.has(R))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(R):P.set(R,L)};var Mn=(R,P,L)=>(st(R,P,"access private method"),L);var ln,ge,vn,ye;const R="soyio-widget-iframe-container",P="soyio-widget-iframe",L="https://app.soyio.id/widget",Ee="https://sandbox.soyio.id/widget",We=["IDENTITY_AUTHENTICATED","IDENTITY_REGISTERED"];function xe(W,D,H,y){const g=y||(H?Ee:L),v=`platform=web&companyId=${encodeURIComponent(D.companyId)}`,x=D.userEmail?`&userEmail=${D.userEmail}`:"";switch(W){case"authenticate":return`${g}/authenticate?${v}&identityId=${D.identityId}`;case"register":return`${g}/register?${v}&flowTemplateId=${D.flowTemplateId}${x}`;default:return"INVALID_PARAMS"}}function Se(){return!!document.getElementById(P)}function Ie(){return document.getElementById(R)}function be(W,D,H,y){const g=Ie();if(!g)throw new Error("Iframe container does not exist");const v=document.createElement("iframe");return v.src=xe(W,D,H,y),v.id=P,v.style.zIndex=String(Number.MAX_SAFE_INTEGER),v.style.width="100%",v.style.height="100%",v.allow="autoplay",v.allow="camera",v.allow="publickey-credentials-create",v.allow="publickey-credentials-get",g.appendChild(v),v}function Pe(W,D,H,y){return Se()?document.getElementById(P):be(W,D,H,y)}function Ln(){const W=document.getElementById(P);W&&W.remove()}var Oe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ae(W){return W&&W.__esModule&&Object.prototype.hasOwnProperty.call(W,"default")?W.default:W}var Fn={exports:{}},Bn={exports:{}};(function(W,D){(function(H,y){W.exports=y()})(typeof self<"u"?self:Oe,function(){return function(H){var y={};function g(v){if(y[v])return y[v].exports;var x=y[v]={i:v,l:!1,exports:{}};return H[v].call(x.exports,x,x.exports,g),x.l=!0,x.exports}return g.m=H,g.c=y,g.d=function(v,x,Z){g.o(v,x)||Object.defineProperty(v,x,{enumerable:!0,get:Z})},g.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},g.t=function(v,x){if(1&x&&(v=g(v)),8&x||4&x&&typeof v=="object"&&v&&v.__esModule)return v;var Z=Object.create(null);if(g.r(Z),Object.defineProperty(Z,"default",{enumerable:!0,value:v}),2&x&&typeof v!="string")for(var en in v)g.d(Z,en,(function(wn){return v[wn]}).bind(null,en));return Z},g.n=function(v){var x=v&&v.__esModule?function(){return v.default}:function(){return v};return g.d(x,"a",x),x},g.o=function(v,x){return{}.hasOwnProperty.call(v,x)},g.p="",g(g.s=0)}([function(H,y,g){g.r(y),g.d(y,"Promise",function(){return S}),g.d(y,"TYPES",function(){return it}),g.d(y,"ProxyWindow",function(){return U}),g.d(y,"setup",function(){return pe}),g.d(y,"destroy",function(){return ot}),g.d(y,"serializeMessage",function(){return nt}),g.d(y,"deserializeMessage",function(){return et}),g.d(y,"createProxyWindow",function(){return tt}),g.d(y,"toProxyWindow",function(){return rt}),g.d(y,"on",function(){return V}),g.d(y,"once",function(){return _e}),g.d(y,"send",function(){return $}),g.d(y,"markWindowKnown",function(){return ie}),g.d(y,"cleanUpWindow",function(){return at}),g.d(y,"bridge",function(){});function v(n){return{}.toString.call(n)==="[object RegExp]"}var x=`Call was rejected by callee.\r
2
+ `;function Z(n){return n===void 0&&(n=window),n.location.protocol}function en(n){if(n===void 0&&(n=window),n.mockDomain){var t=n.mockDomain.split("//")[0];if(t)return t}return Z(n)}function wn(n){return n===void 0&&(n=window),en(n)==="about:"}function Y(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Un(n){if(n===void 0&&(n=window),n&&!Y(n))try{return n.opener}catch{}}function mn(n){try{return!0}catch{}return!1}function pn(n){n===void 0&&(n=window);var t=n.location;if(!t)throw new Error("Can not read window location");var e=Z(n);if(!e)throw new Error("Can not read window protocol");if(e==="file:")return"file://";if(e==="about:"){var r=Y(n);return r&&mn()?pn(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return e+"//"+o}function C(n){n===void 0&&(n=window);var t=pn(n);return t&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:t}function k(n){if(!function(t){try{if(t===window)return!0}catch{}try{var e=Object.getOwnPropertyDescriptor(t,"location");if(e&&e.enumerable===!1)return!1}catch{}try{if(wn(t)&&mn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),en(r)==="mock:"}(t)&&mn())return!0}catch{}try{if(pn(t)===pn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||wn(n)&&mn()||C(window)===C(n))return!0}catch{}return!1}function gn(n){if(!k(n))throw new Error("Expected window to be same domain");return n}function Hn(n,t){if(!n||!t)return!1;var e=Y(t);return e?e===n:function(r){var o=[];try{for(;r.parent!==r;)o.push(r.parent),r=r.parent}catch{}return o}(t).indexOf(n)!==-1}function Gn(n){var t=[],e;try{e=n.frames}catch{e=n}var r;try{r=e.length}catch{}if(r===0)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch{continue}t.push(i)}return t}for(var a=0;a<100;a++){var s=void 0;try{s=e[a]}catch{return t}if(!s)return t;t.push(s)}return t}var Fe=[],Be=[];function G(n,t){t===void 0&&(t=!0);try{if(n===window)return!1}catch{return!0}try{if(!n)return!0}catch{return!0}try{if(n.closed)return!0}catch(o){return!o||o.message!==x}if(t&&k(n))try{if(n.mockclosed)return!0}catch{}try{if(!n.parent||!n.top)return!0}catch{}var e=function(o,i){for(var a=0;a<o.length;a++)try{if(o[a]===i)return a}catch{}return-1}(Fe,n);if(e!==-1){var r=Be[e];if(r&&function(o){if(!o.contentWindow||!o.parentNode)return!0;var i=o.ownerDocument;if(i&&i.documentElement&&!i.documentElement.contains(o)){for(var a=o;a.parentNode&&a.parentNode!==a;)a=a.parentNode;if(!a.host||!i.documentElement.contains(a.host))return!0}return!1}(r))return!0}return!1}function Jn(n){return n===void 0&&(n=window),Un(n=n||window)||Y(n)||void 0}function _(n,t){if(typeof n=="string"){if(typeof t=="string")return n==="*"||t===n;if(v(t)||Array.isArray(t))return!1}return v(n)?v(t)?n.toString()===t.toString():!Array.isArray(t)&&!!t.match(n):!!Array.isArray(n)&&(Array.isArray(t)?JSON.stringify(n)===JSON.stringify(t):!v(t)&&n.some(function(e){return _(e,t)}))}function yn(n){try{if(n===window)return!0}catch(t){if(t&&t.message===x)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(t){if(t&&t.message===x)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(t){if(t&&t.message===x)return!0}try{if(n&&n.self===n)return!0}catch(t){if(t&&t.message===x)return!0}try{if(n&&n.parent===n)return!0}catch(t){if(t&&t.message===x)return!0}try{if(n&&n.top===n)return!0}catch(t){if(t&&t.message===x)return!0}try{if(n&&n.__cross_domain_utils_window_check__==="__unlikely_value__")return!1}catch{return!0}try{if("postMessage"in n&&"self"in n&&"location"in n)return!0}catch{}return!1}function qn(n){if(k(n))return gn(n).frameElement;for(var t=0,e=document.querySelectorAll("iframe");t<e.length;t++){var r=e[t];if(r&&r.contentWindow&&r.contentWindow===n)return r}}function Ue(n){if(function(e){return e===void 0&&(e=window),!!Y(e)}(n)){var t=qn(n);if(t&&t.parentElement){t.parentElement.removeChild(t);return}}try{n.close()}catch{}}function X(n){try{if(!n)return!1;if(typeof Promise<"u"&&n instanceof Promise)return!0;if(typeof window<"u"&&typeof window.Window=="function"&&n instanceof window.Window||typeof window<"u"&&typeof window.constructor=="function"&&n instanceof window.constructor)return!1;var t={}.toString;if(t){var e=t.call(n);if(e==="[object Window]"||e==="[object global]"||e==="[object DOMWindow]")return!1}if(typeof n.then=="function")return!0}catch{return!1}return!1}var Zn=[],tn=[],In=0,rn;function Vn(){if(!In&&rn){var n=rn;rn=null,n.resolve()}}function bn(){In+=1}function on(){In-=1,Vn()}var S=function(){function n(e){var r=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],e){var o,i,a=!1,s=!1,c=!1;bn();try{e(function(u){c?r.resolve(u):(a=!0,o=u)},function(u){c?r.reject(u):(s=!0,i=u)})}catch(u){on(),this.reject(u);return}on(),c=!0,a?this.resolve(o):s&&this.reject(i)}}var t=n.prototype;return t.resolve=function(e){if(this.resolved||this.rejected)return this;if(X(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},t.reject=function(e){var r=this;if(this.resolved||this.rejected)return this;if(X(e))throw new Error("Can not reject promise with another promise");if(!e){var o=e&&typeof e.toString=="function"?e.toString():{}.toString.call(e);e=new Error("Expected reject to be called with Error, got "+o)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){r.errorHandled||function(i,a){if(Zn.indexOf(i)===-1){Zn.push(i),setTimeout(function(){throw i},1);for(var s=0;s<tn.length;s++)tn[s](i,a)}}(e,r)},1),this.dispatch(),this},t.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},t.dispatch=function(){var e=this.resolved,r=this.rejected,o=this.handlers;if(!this.dispatching&&(e||r)){this.dispatching=!0,bn();for(var i=function(l,p){return l.then(function(w){p.resolve(w)},function(w){p.reject(w)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,h=s.promise,f=void 0;if(e)try{f=c?c(this.value):this.value}catch(l){h.reject(l);continue}else if(r){if(!u){h.reject(this.error);continue}try{f=u(this.error)}catch(l){h.reject(l);continue}}if(f instanceof n&&(f.resolved||f.rejected)){var d=f;d.resolved?h.resolve(d.value):h.reject(d.error),d.errorHandled=!0}else X(f)?f instanceof n&&(f.resolved||f.rejected)?f.resolved?h.resolve(f.value):h.reject(f.error):i(f,h):h.resolve(f)}o.length=0,this.dispatching=!1,on()}},t.then=function(e,r){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.then expected a function for success handler");if(r&&typeof r!="function"&&!r.call)throw new Error("Promise.then expected a function for error handler");var o=new n;return this.handlers.push({promise:o,onSuccess:e,onError:r}),this.errorHandled=!0,this.dispatch(),o},t.catch=function(e){return this.then(void 0,e)},t.finally=function(e){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return n.try(e).then(function(){return r})},function(r){return n.try(e).then(function(){throw r})})},t.timeout=function(e,r){var o=this;if(this.resolved||this.rejected)return this;var i=setTimeout(function(){o.resolved||o.rejected||o.reject(r||new Error("Promise timed out after "+e+"ms"))},e);return this.then(function(a){return clearTimeout(i),a})},t.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},t.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(e){return e instanceof n?e:X(e)?new n(function(r,o){return e.then(r,o)}):new n().resolve(e)},n.reject=function(e){return new n().reject(e)},n.asyncReject=function(e){return new n().asyncReject(e)},n.all=function(e){var r=new n,o=e.length,i=[].slice();if(!o)return r.resolve(i),r;for(var a=function(u,h,f){return h.then(function(d){i[u]=d,(o-=1)==0&&r.resolve(i)},function(d){f.reject(d)})},s=0;s<e.length;s++){var c=e[s];if(c instanceof n){if(c.resolved){i[s]=c.value,o-=1;continue}}else if(!X(c)){i[s]=c,o-=1;continue}a(s,n.resolve(c),r)}return o===0&&r.resolve(i),r},n.hash=function(e){var r={},o=[],i=function(s){if(e.hasOwnProperty(s)){var c=e[s];X(c)?o.push(c.then(function(u){r[s]=u})):r[s]=c}};for(var a in e)i(a);return n.all(o).then(function(){return r})},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(e){return function(r){return tn.push(r),{cancel:function(){tn.splice(tn.indexOf(r),1)}}}(e)},n.try=function(e,r,o){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.try expected a function");var i;bn();try{i=e.apply(r,o||[])}catch(a){return on(),n.reject(a)}return on(),n.resolve(i)},n.delay=function(e){return new n(function(r){setTimeout(r,e)})},n.isPromise=function(e){return!!(e&&e instanceof n)||X(e)},n.flush=function(){return function(e){var r=rn=rn||new e;return Vn(),r}(n)},n}();function En(n,t){for(var e=0;e<n.length;e++)try{if(n[e]===t)return e}catch{}return-1}var Pn=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if(typeof WeakMap>"u"||Object.freeze===void 0)return!1;try{var e=new WeakMap,r={};return Object.freeze(r),e.set(r,"__testvalue__"),e.get(r)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var t=n.prototype;return t._cleanupClosedWindows=function(){for(var e=this.weakmap,r=this.keys,o=0;o<r.length;o++){var i=r[o];if(yn(i)&&G(i)){if(e)try{e.delete(i)}catch{}r.splice(o,1),this.values.splice(o,1),o-=1}}},t.isSafeToReadWrite=function(e){return!yn(e)},t.set=function(e,r){if(!e)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.set(e,r)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var i=this.name,a=e[i];a&&a[0]===e?a[1]=r:Object.defineProperty(e,i,{value:[e,r],writable:!0});return}catch{}this._cleanupClosedWindows();var s=this.keys,c=this.values,u=En(s,e);u===-1?(s.push(e),c.push(r)):c[u]=r},t.get=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(e))return r.get(e)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];return o&&o[0]===e?o[1]:void 0}catch{}this._cleanupClosedWindows();var i=En(this.keys,e);if(i!==-1)return this.values[i]},t.delete=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(e)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];o&&o[0]===e&&(o[0]=o[1]=void 0)}catch{}this._cleanupClosedWindows();var i=this.keys,a=En(i,e);a!==-1&&(i.splice(a,1),this.values.splice(a,1))},t.has=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(e))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];return!(!o||o[0]!==e)}catch{}return this._cleanupClosedWindows(),En(this.keys,e)!==-1},t.getOrSet=function(e,r){if(this.has(e))return this.get(e);var o=r();return this.set(e,o),o},n}();function $n(n){return n.name||n.__name__||n.displayName||"anonymous"}function Yn(n,t){try{delete n.name,n.name=t}catch{}return n.__name__=n.displayName=t,n}function q(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(t){if(typeof btoa=="function")return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,r){return String.fromCharCode(parseInt(r,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(t,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}(new Date().toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var Wn;function kn(n){try{return JSON.stringify([].slice.call(n),function(t,e){return typeof e=="function"?"memoize["+function(r){if(Wn=Wn||new Pn,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=Wn.get(r);return o||(o=typeof r+":"+q(),Wn.set(r,o)),o}(e)+"]":typeof window<"u"&&e instanceof window.Element||e!==null&&typeof e=="object"&&e.nodeType===1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"?{}:e})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function He(){return{}}var an=0,Xn=0;function un(n,t){t===void 0&&(t={});var e=t.thisNamespace,r=e!==void 0&&e,o=t.time,i,a,s=an;an+=1;var c=function(){for(var u=arguments.length,h=new Array(u),f=0;f<u;f++)h[f]=arguments[f];s<Xn&&(i=null,a=null,s=an,an+=1);var d;d=r?(a=a||new Pn).getOrSet(this,He):i=i||{};var l;try{l=kn(h)}catch{return n.apply(this,arguments)}var p=d[l];if(p&&o&&Date.now()-p.time<o&&(delete d[l],p=null),p)return p.value;var w=Date.now(),m=n.apply(this,arguments);return d[l]={time:w,value:m},m};return c.reset=function(){i=null,a=null},Yn(c,(t.name||$n(n))+"::memoized")}un.clear=function(){Xn=an};function Ge(n){var t={};function e(){for(var r=arguments,o=this,i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var c=kn(a);return t.hasOwnProperty(c)||(t[c]=S.try(function(){return n.apply(o,r)}).finally(function(){delete t[c]})),t[c]}return e.reset=function(){t={}},Yn(e,$n(n)+"::promiseMemoized")}function K(){}function cn(n,t){if(t===void 0&&(t=1),t>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if(typeof n=="string")return n;if(n instanceof Error){var e=n&&n.stack,r=n&&n.message;if(e&&r)return e.indexOf(r)!==-1?e:r+`
3
+ `+e;if(e)return e;if(r)return r}return n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}catch(o){return"Error while stringifying error: "+cn(o,t+1)}}function Kn(n){return typeof n=="string"?n:n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}un(function(n){if(Object.values)return Object.values(n);var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(n[e]);return t});function On(n){return{}.toString.call(n)==="[object RegExp]"}function sn(n,t,e){if(n.hasOwnProperty(t))return n[t];var r=e();return n[t]=r,r}function Qn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function _n(){return!!document.body&&document.readyState==="complete"}function ne(){return!!document.body&&document.readyState==="interactive"}un(function(){return new S(function(n){if(_n()||ne())return n();var t=setInterval(function(){if(_n()||ne())return clearInterval(t),n()},10)})});var xn=typeof document<"u"?document.currentScript:null,Je=un(function(){if(xn||(xn=function(){try{var n=function(){try{throw new Error("_")}catch(a){return a.stack||""}}(),t=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),e=t&&t[1];if(!e)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===e)return i}}catch{}}()))return xn;throw new Error("Can not determine current script")}),qe=q();un(function(){var n;try{n=Je()}catch{return qe}var t=n.getAttribute("data-uid");if(t&&typeof t=="string"||(t=n.getAttribute("data-uid-auto"))&&typeof t=="string")return t;if(n.src){var e=function(r){for(var o="",i=0;i<r.length;i++){var a=r[i].charCodeAt(0)*i;r[i+1]&&(a+=r[i+1].charCodeAt(0)*(i-1)),o+=String.fromCharCode(97+Math.abs(a)%26)}return o}(JSON.stringify({src:n.src,dataset:n.dataset}));t="uid_"+e.slice(e.length-30)}else t=q();return n.setAttribute("data-uid-auto",t),t});function fn(n){n===void 0&&(n=window);var t="__post_robot_10_0_46__";return n!==window?n[t]:n[t]=n[t]||{}}var ee=function(){return{}};function z(n,t){return n===void 0&&(n="store"),t===void 0&&(t=ee),sn(fn(),n,function(){var e=t();return{has:function(r){return e.hasOwnProperty(r)},get:function(r,o){return e.hasOwnProperty(r)?e[r]:o},set:function(r,o){return e[r]=o,o},del:function(r){delete e[r]},getOrSet:function(r,o){return sn(e,r,o)},reset:function(){e=t()},keys:function(){return Object.keys(e)}}})}var Ze=function(){};function Sn(){var n=fn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new Ze,n.WINDOW_WILDCARD}function M(n,t){return n===void 0&&(n="store"),t===void 0&&(t=ee),z("windowStore").getOrSet(n,function(){var e=new Pn,r=function(o){return e.getOrSet(o,t)};return{has:function(o){return r(o).hasOwnProperty(n)},get:function(o,i){var a=r(o);return a.hasOwnProperty(n)?a[n]:i},set:function(o,i){return r(o)[n]=i,i},del:function(o){delete r(o)[n]},getOrSet:function(o,i){return sn(r(o),n,i)}}})}function te(){return z("instance").getOrSet("instanceID",q)}function re(n,t){var e=t.domain,r=M("helloPromises"),o=r.get(n);o&&o.resolve({domain:e});var i=S.resolve({domain:e});return r.set(n,i),i}function An(n,t){return(0,t.send)(n,"postrobot_hello",{instanceID:te()},{domain:"*",timeout:-1}).then(function(e){var r=e.origin,o=e.data.instanceID;return re(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function oe(n,t){var e=t.send;return M("windowInstanceIDPromises").getOrSet(n,function(){return An(n,{send:e}).then(function(r){return r.instanceID})})}function ie(n){M("knownWindows").set(n,!0)}function Dn(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function ae(n){return n===void 0?"undefined":n===null?"null":Array.isArray(n)?"array":typeof n=="function"?"function":typeof n=="object"?n instanceof Error?"error":typeof n.then=="function"?"promise":{}.toString.call(n)==="[object RegExp]"?"regex":{}.toString.call(n)==="[object Date]"?"date":"object":typeof n=="string"?"string":typeof n=="number"?"number":typeof n=="boolean"?"boolean":void 0}function Q(n,t){return{__type__:n,__val__:t}}var F,Ve=((F={}).function=function(){},F.error=function(n){return Q("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},F.promise=function(){},F.regex=function(n){return Q("regex",n.source)},F.date=function(n){return Q("date",n.toJSON())},F.array=function(n){return n},F.object=function(n){return n},F.string=function(n){return n},F.number=function(n){return n},F.boolean=function(n){return n},F.null=function(n){return n},F[void 0]=function(n){return Q("undefined",n)},F),$e={},B,Ye=((B={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},B.error=function(n){var t=n.stack,e=n.code,r=n.data,o=new Error(n.message);return o.code=e,r&&(o.data=r),o.stack=t+`
4
4
 
5
- `+o.stack,o},B.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},B.regex=function(n){return new RegExp(n)},B.date=function(n){return new Date(n)},B.array=function(n){return n},B.object=function(n){return n},B.string=function(n){return n},B.number=function(n){return n},B.boolean=function(n){return n},B.null=function(n){return n},B[void 0]=function(){},B),Xt={};new S(function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval(function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)},10)});function Nn(){for(var n=z("idToProxyWindow"),e=0,t=n.keys();e<t.length;e++){var r=t[e];n.get(r).shouldClean()&&n.del(r)}}function ut(n,e){var t=e.send,r=e.id,o=r===void 0?q():r,i=n.then(function(c){if(X(c))return gn(c).name}),a=n.then(function(c){if(G(c))throw new Error("Window is closed, can not determine type");return Un(c)?"popup":"iframe"});i.catch(k),a.catch(k);var s=function(){return n.then(function(c){if(!G(c))return X(c)?gn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:Gt(function(){return n.then(function(c){return ot(c,{send:t})})}),close:function(){return n.then(Ut)},getName:s,focus:function(){return n.then(function(c){c.focus()})},isClosed:function(){return n.then(function(c){return G(c)})},setLocation:function(c,u){return u===void 0&&(u={}),n.then(function(h){var f=window.location.protocol+"//"+window.location.host,d=u.method,l=d===void 0?"get":d,p=u.body;if(c.indexOf("/")===0)c=""+f+c;else if(!c.match(/^https?:\/\//)&&c.indexOf(f)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(c));if(l==="post")return s().then(function(w){if(!w)throw new Error("Can not post to window without target name");(function(m){var I=m.url,T=m.target,O=m.body,b=m.method,j=b===void 0?"post":b,E=document.createElement("form");if(E.setAttribute("target",T),E.setAttribute("method",j),E.setAttribute("action",I),E.style.display="none",O)for(var A=0,J=Object.keys(O);A<J.length;A++){var N,dn=J[A],jn=document.createElement("input");jn.setAttribute("name",dn),jn.setAttribute("value",(N=O[dn])==null?void 0:N.toString()),E.appendChild(jn)}Qn().appendChild(E),E.submit(),Qn().removeChild(E)})({url:c,target:w,method:l,body:p})});if(l!=="get")throw new Error("Unsupported method: "+l);if(X(h))try{if(h.location&&typeof h.location.replace=="function"){h.location.replace(c);return}}catch{}h.location=c})},setName:function(c){return n.then(function(u){var h=X(u),f=qn(u);if(!h)throw new Error("Can not set name for cross-domain window: "+c);gn(u).name=c,f&&f.setAttribute("name",c),i=S.resolve(c)})}}}var U=function(){function n(t){var r=t.send,o=t.win,i=t.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new S,this.serializedWindow=i||ut(this.actualWindowPromise,{send:r}),z("idToProxyWindow").set(this.getID(),this),o&&this.setWindow(o,{send:r})}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType().then(function(t){return t==="popup"})},e.setLocation=function(t,r){var o=this;return this.serializedWindow.setLocation(t,r).then(function(){return o})},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(t){var r=this;return this.serializedWindow.setName(t).then(function(){return r})},e.close=function(){var t=this;return this.serializedWindow.close().then(function(){return t})},e.focus=function(){var t=this,r=this.isPopup(),o=this.getName(),i=S.hash({isPopup:r,name:o}).then(function(s){var c=s.name;s.isPopup&&c&&window.open("",c,"noopener")}),a=this.serializedWindow.focus();return S.all([i,a]).then(function(){return t})},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(t,r){var o=r.send;this.actualWindow=t,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=ut(this.actualWindowPromise,{send:o,id:this.getID()}),M("winToProxyWindow").set(t,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(t,r){var o=this,i=r.send;return S.try(function(){return o.actualWindow?t===o.actualWindow:S.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:ot(t,{send:i})}).then(function(a){var s=a.proxyInstanceID===a.knownWindowInstanceID;return s&&o.setWindow(t,{send:i}),s})})},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return!!(this.actualWindow&&G(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(t){return n.isProxyWindow(t)?t.unwrap():t},n.serialize=function(t,r){var o=r.send;return Nn(),n.toProxyWindow(t,{send:o}).serialize()},n.deserialize=function(t,r){var o=r.send;return Nn(),z("idToProxyWindow").get(t.id)||new n({serializedWindow:t,send:o})},n.isProxyWindow=function(t){return!!(t&&!yn(t)&&t.isProxyWindow)},n.toProxyWindow=function(t,r){var o=r.send;if(Nn(),n.isProxyWindow(t))return t;var i=t;return M("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function Rn(n,e,t,r,o){var i=M("methodStore"),a=z("proxyWindowMethods");U.isProxyWindow(r)?a.set(n,{val:e,name:t,domain:o,source:r}):(a.del(n),i.getOrSet(r,function(){return{}})[n]={domain:o,name:t,val:e,source:r})}function ct(n,e){var t=M("methodStore"),r=z("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[e]||r.get(e)}function st(n,e,t,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,z("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(h){var f=h.source,d=h.origin,l=h.data,p=l.id,w=l.name,m=ct(f,p);if(!m)throw new Error("Could not find method '"+w+"' with id: "+l.id+" in "+C(window));var I=m.source,T=m.domain,O=m.val;return S.try(function(){if(!_(T,d))throw new Error("Method '"+l.name+"' domain "+JSON.stringify(On(m.domain)?m.domain.source:m.domain)+" does not match origin "+d+" in "+C(window));if(U.isProxyWindow(I))return I.matchWindow(f,{send:s}).then(function(b){if(!b)throw new Error("Method call '"+l.name+"' failed - proxy window does not match source in "+C(window))})}).then(function(){return O.apply({source:f,origin:d},l.args)},function(b){return S.try(function(){if(O.onError)return O.onError(b)}).then(function(){throw b.stack&&(b.stack="Remote call to "+w+"("+function(j){return j===void 0&&(j=[]),(E=j,[].slice.call(E)).map(function(A){return typeof A=="string"?"'"+A+"'":A===void 0?"undefined":A===null?"null":typeof A=="boolean"?A.toString():Array.isArray(A)?"[ ... ]":typeof A=="object"?"{ ... }":typeof A=="function"?"() => { ... }":"<"+typeof A+">"}).join(", ");var E}(l.args)+`) failed
5
+ `+o.stack,o},B.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},B.regex=function(n){return new RegExp(n)},B.date=function(n){return new Date(n)},B.array=function(n){return n},B.object=function(n){return n},B.string=function(n){return n},B.number=function(n){return n},B.boolean=function(n){return n},B.null=function(n){return n},B[void 0]=function(){},B),ke={};new S(function(n){if(window.document&&window.document.body)return n(window.document.body);var t=setInterval(function(){if(window.document&&window.document.body)return clearInterval(t),n(window.document.body)},10)});function Nn(){for(var n=z("idToProxyWindow"),t=0,e=n.keys();t<e.length;t++){var r=e[t];n.get(r).shouldClean()&&n.del(r)}}function ue(n,t){var e=t.send,r=t.id,o=r===void 0?q():r,i=n.then(function(c){if(k(c))return gn(c).name}),a=n.then(function(c){if(G(c))throw new Error("Window is closed, can not determine type");return Un(c)?"popup":"iframe"});i.catch(K),a.catch(K);var s=function(){return n.then(function(c){if(!G(c))return k(c)?gn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:Ge(function(){return n.then(function(c){return oe(c,{send:e})})}),close:function(){return n.then(Ue)},getName:s,focus:function(){return n.then(function(c){c.focus()})},isClosed:function(){return n.then(function(c){return G(c)})},setLocation:function(c,u){return u===void 0&&(u={}),n.then(function(h){var f=window.location.protocol+"//"+window.location.host,d=u.method,l=d===void 0?"get":d,p=u.body;if(c.indexOf("/")===0)c=""+f+c;else if(!c.match(/^https?:\/\//)&&c.indexOf(f)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(c));if(l==="post")return s().then(function(w){if(!w)throw new Error("Can not post to window without target name");(function(m){var I=m.url,T=m.target,O=m.body,b=m.method,j=b===void 0?"post":b,E=document.createElement("form");if(E.setAttribute("target",T),E.setAttribute("method",j),E.setAttribute("action",I),E.style.display="none",O)for(var A=0,J=Object.keys(O);A<J.length;A++){var N,dn=J[A],jn=document.createElement("input");jn.setAttribute("name",dn),jn.setAttribute("value",(N=O[dn])==null?void 0:N.toString()),E.appendChild(jn)}Qn().appendChild(E),E.submit(),Qn().removeChild(E)})({url:c,target:w,method:l,body:p})});if(l!=="get")throw new Error("Unsupported method: "+l);if(k(h))try{if(h.location&&typeof h.location.replace=="function"){h.location.replace(c);return}}catch{}h.location=c})},setName:function(c){return n.then(function(u){var h=k(u),f=qn(u);if(!h)throw new Error("Can not set name for cross-domain window: "+c);gn(u).name=c,f&&f.setAttribute("name",c),i=S.resolve(c)})}}}var U=function(){function n(e){var r=e.send,o=e.win,i=e.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new S,this.serializedWindow=i||ue(this.actualWindowPromise,{send:r}),z("idToProxyWindow").set(this.getID(),this),o&&this.setWindow(o,{send:r})}var t=n.prototype;return t.getID=function(){return this.serializedWindow.id},t.getType=function(){return this.serializedWindow.getType()},t.isPopup=function(){return this.getType().then(function(e){return e==="popup"})},t.setLocation=function(e,r){var o=this;return this.serializedWindow.setLocation(e,r).then(function(){return o})},t.getName=function(){return this.serializedWindow.getName()},t.setName=function(e){var r=this;return this.serializedWindow.setName(e).then(function(){return r})},t.close=function(){var e=this;return this.serializedWindow.close().then(function(){return e})},t.focus=function(){var e=this,r=this.isPopup(),o=this.getName(),i=S.hash({isPopup:r,name:o}).then(function(s){var c=s.name;s.isPopup&&c&&window.open("",c,"noopener")}),a=this.serializedWindow.focus();return S.all([i,a]).then(function(){return e})},t.isClosed=function(){return this.serializedWindow.isClosed()},t.getWindow=function(){return this.actualWindow},t.setWindow=function(e,r){var o=r.send;this.actualWindow=e,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=ue(this.actualWindowPromise,{send:o,id:this.getID()}),M("winToProxyWindow").set(e,this)},t.awaitWindow=function(){return this.actualWindowPromise},t.matchWindow=function(e,r){var o=this,i=r.send;return S.try(function(){return o.actualWindow?e===o.actualWindow:S.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:oe(e,{send:i})}).then(function(a){var s=a.proxyInstanceID===a.knownWindowInstanceID;return s&&o.setWindow(e,{send:i}),s})})},t.unwrap=function(){return this.actualWindow||this},t.getInstanceID=function(){return this.serializedWindow.getInstanceID()},t.shouldClean=function(){return!!(this.actualWindow&&G(this.actualWindow))},t.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var o=r.send;return Nn(),n.toProxyWindow(e,{send:o}).serialize()},n.deserialize=function(e,r){var o=r.send;return Nn(),z("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:o})},n.isProxyWindow=function(e){return!!(e&&!yn(e)&&e.isProxyWindow)},n.toProxyWindow=function(e,r){var o=r.send;if(Nn(),n.isProxyWindow(e))return e;var i=e;return M("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function Rn(n,t,e,r,o){var i=M("methodStore"),a=z("proxyWindowMethods");U.isProxyWindow(r)?a.set(n,{val:t,name:e,domain:o,source:r}):(a.del(n),i.getOrSet(r,function(){return{}})[n]={domain:o,name:e,val:t,source:r})}function ce(n,t){var e=M("methodStore"),r=z("proxyWindowMethods");return e.getOrSet(n,function(){return{}})[t]||r.get(t)}function se(n,t,e,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,z("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(h){var f=h.source,d=h.origin,l=h.data,p=l.id,w=l.name,m=ce(f,p);if(!m)throw new Error("Could not find method '"+w+"' with id: "+l.id+" in "+C(window));var I=m.source,T=m.domain,O=m.val;return S.try(function(){if(!_(T,d))throw new Error("Method '"+l.name+"' domain "+JSON.stringify(On(m.domain)?m.domain.source:m.domain)+" does not match origin "+d+" in "+C(window));if(U.isProxyWindow(I))return I.matchWindow(f,{send:s}).then(function(b){if(!b)throw new Error("Method call '"+l.name+"' failed - proxy window does not match source in "+C(window))})}).then(function(){return O.apply({source:f,origin:d},l.args)},function(b){return S.try(function(){if(O.onError)return O.onError(b)}).then(function(){throw b.stack&&(b.stack="Remote call to "+w+"("+function(j){return j===void 0&&(j=[]),(E=j,[].slice.call(E)).map(function(A){return typeof A=="string"?"'"+A+"'":A===void 0?"undefined":A===null?"null":typeof A=="boolean"?A.toString():Array.isArray(A)?"[ ... ]":typeof A=="object"?"{ ... }":typeof A=="function"?"() => { ... }":"<"+typeof A+">"}).join(", ");var E}(l.args)+`) failed
6
6
 
7
- `+b.stack),b})}).then(function(b){return{result:b,id:p,name:w}})})});var i,a,s,c=t.__id__||q();n=U.unwrap(n);var u=t.__name__||t.name||r;return typeof u=="string"&&typeof u.indexOf=="function"&&u.indexOf("anonymous::")===0&&(u=u.replace("anonymous::",r+"::")),U.isProxyWindow(n)?(Rn(c,t,u,n,e),n.awaitWindow().then(function(h){Rn(c,t,u,h,e)})):Rn(c,t,u,n,e),Q("cross_domain_function",{id:c,name:u})}function ft(n,e,t,r){var o,i=r.on,a=r.send;return function(s,c){c===void 0&&(c=Yt);var u=JSON.stringify(s,function(h){var f=this[h];if(Dn(this))return f;var d=at(f);if(!d)return f;var l=c[d]||Vt[d];return l?l(f,h):f});return u===void 0?"undefined":u}(t,((o={}).promise=function(s,c){return function(u,h,f,d,l){return Q("cross_domain_zalgo_promise",{then:st(u,h,function(p,w){return f.then(p,w)},d,{on:l.on,send:l.send})})}(n,e,s,c,{on:i,send:a})},o.function=function(s,c){return st(n,e,s,c,{on:i,send:a})},o.object=function(s){return yn(s)||U.isProxyWindow(s)?Q("cross_domain_window",U.serialize(s,{send:a})):s},o))}function dt(n,e,t,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=Xt),a!=="undefined")return JSON.parse(a,function(c,u){if(Dn(this))return u;var h,f;if(Dn(u)?(h=u.__type__,f=u.__val__):(h=at(u),f=u),!h)return f;var d=s[h]||$t[h];return d?d(f,c):f})}(t,((o={}).cross_domain_zalgo_promise=function(a){return function(s,c,u){return new S(u.then)}(0,0,a)},o.cross_domain_function=function(a){return function(s,c,u,h){var f=u.id,d=u.name,l=h.send,p=function(m){m===void 0&&(m={});function I(){var T=arguments;return U.toProxyWindow(s,{send:l}).awaitWindow().then(function(O){var b=ct(O,f);if(b&&b.val!==I)return b.val.apply({source:window,origin:C()},T);var j=[].slice.call(T);return m.fireAndForget?l(O,"postrobot_method",{id:f,name:d,args:j},{domain:c,fireAndForget:!0}):l(O,"postrobot_method",{id:f,name:d,args:j},{domain:c,fireAndForget:!1}).then(function(E){return E.data.result})}).catch(function(O){throw O})}return I.__name__=d,I.__origin__=c,I.__source__=s,I.__id__=f,I.origin=c,I},w=p();return w.fireAndForget=p({fireAndForget:!0}),w}(n,e,a,{send:i})},o.cross_domain_window=function(a){return U.deserialize(a,{send:i})},o))}var Tn={};Tn.postrobot_post_message=function(n,e,t){t.indexOf("file:")===0&&(t="*"),n.postMessage(e,t)};function zn(n,e,t,r){var o=r.on,i=r.send;return S.try(function(){var a=M().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(t),a.flush=a.flush||S.flush().then(function(){if(G(n))throw new Error("Window is closed");var s=ft(n,e,((c={}).__post_robot_10_0_46__=a.buffer||[],c),{on:o,send:i}),c;delete a.buffer;for(var u=Object.keys(Tn),h=[],f=0;f<u.length;f++){var d=u[f];try{Tn[d](n,s,e)}catch(l){h.push(l)}}if(h.length===u.length)throw new Error(`All post-robot messaging strategies failed:
7
+ `+b.stack),b})}).then(function(b){return{result:b,id:p,name:w}})})});var i,a,s,c=e.__id__||q();n=U.unwrap(n);var u=e.__name__||e.name||r;return typeof u=="string"&&typeof u.indexOf=="function"&&u.indexOf("anonymous::")===0&&(u=u.replace("anonymous::",r+"::")),U.isProxyWindow(n)?(Rn(c,e,u,n,t),n.awaitWindow().then(function(h){Rn(c,e,u,h,t)})):Rn(c,e,u,n,t),Q("cross_domain_function",{id:c,name:u})}function fe(n,t,e,r){var o,i=r.on,a=r.send;return function(s,c){c===void 0&&(c=$e);var u=JSON.stringify(s,function(h){var f=this[h];if(Dn(this))return f;var d=ae(f);if(!d)return f;var l=c[d]||Ve[d];return l?l(f,h):f});return u===void 0?"undefined":u}(e,((o={}).promise=function(s,c){return function(u,h,f,d,l){return Q("cross_domain_zalgo_promise",{then:se(u,h,function(p,w){return f.then(p,w)},d,{on:l.on,send:l.send})})}(n,t,s,c,{on:i,send:a})},o.function=function(s,c){return se(n,t,s,c,{on:i,send:a})},o.object=function(s){return yn(s)||U.isProxyWindow(s)?Q("cross_domain_window",U.serialize(s,{send:a})):s},o))}function de(n,t,e,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=ke),a!=="undefined")return JSON.parse(a,function(c,u){if(Dn(this))return u;var h,f;if(Dn(u)?(h=u.__type__,f=u.__val__):(h=ae(u),f=u),!h)return f;var d=s[h]||Ye[h];return d?d(f,c):f})}(e,((o={}).cross_domain_zalgo_promise=function(a){return function(s,c,u){return new S(u.then)}(0,0,a)},o.cross_domain_function=function(a){return function(s,c,u,h){var f=u.id,d=u.name,l=h.send,p=function(m){m===void 0&&(m={});function I(){var T=arguments;return U.toProxyWindow(s,{send:l}).awaitWindow().then(function(O){var b=ce(O,f);if(b&&b.val!==I)return b.val.apply({source:window,origin:C()},T);var j=[].slice.call(T);return m.fireAndForget?l(O,"postrobot_method",{id:f,name:d,args:j},{domain:c,fireAndForget:!0}):l(O,"postrobot_method",{id:f,name:d,args:j},{domain:c,fireAndForget:!1}).then(function(E){return E.data.result})}).catch(function(O){throw O})}return I.__name__=d,I.__origin__=c,I.__source__=s,I.__id__=f,I.origin=c,I},w=p();return w.fireAndForget=p({fireAndForget:!0}),w}(n,t,a,{send:i})},o.cross_domain_window=function(a){return U.deserialize(a,{send:i})},o))}var Tn={};Tn.postrobot_post_message=function(n,t,e){e.indexOf("file:")===0&&(e="*"),n.postMessage(t,e)};function zn(n,t,e,r){var o=r.on,i=r.send;return S.try(function(){var a=M().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(e),a.flush=a.flush||S.flush().then(function(){if(G(n))throw new Error("Window is closed");var s=fe(n,t,((c={}).__post_robot_10_0_46__=a.buffer||[],c),{on:o,send:i}),c;delete a.buffer;for(var u=Object.keys(Tn),h=[],f=0;f<u.length;f++){var d=u[f];try{Tn[d](n,s,t)}catch(l){h.push(l)}}if(h.length===u.length)throw new Error(`All post-robot messaging strategies failed:
8
8
 
9
9
  `+h.map(function(l,p){return p+". "+cn(l)}).join(`
10
10
 
11
- `))}),a.flush.then(function(){delete a.flush})}).then(k)}function ht(n){return z("responseListeners").get(n)}function lt(n){z("responseListeners").del(n)}function vt(n){return z("erroredResponseListeners").has(n)}function wt(n){var e=n.name,t=n.win,r=n.domain,o=M("requestListeners");if(t==="*"&&(t=null),r==="*"&&(r=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[t,Sn()];i<a.length;i++){var s=a[i];if(s){var c=o.get(s);if(c){var u=c[e];if(u){if(r&&typeof r=="string"){if(u[r])return u[r];if(u.__domain_regex__)for(var h=0,f=u.__domain_regex__;h<f.length;h++){var d=f[h],l=d.listener;if(_(d.regex,r))return l}}if(u["*"])return u["*"]}}}}}function Kt(n,e,t,r){var o=r.on,i=r.send,a=wt({name:t.name,win:n,domain:e}),s=t.name==="postrobot_method"&&t.data&&typeof t.data.name=="string"?t.data.name+"()":t.name;function c(u,h,f){return S.flush().then(function(){if(!t.fireAndForget&&!G(n))try{return zn(n,e,{id:q(),origin:C(window),type:"postrobot_message_response",hash:t.hash,name:t.name,ack:u,data:h,error:f},{on:o,send:i})}catch(d){throw new Error("Send response message failed for "+s+" in "+C()+`
11
+ `))}),a.flush.then(function(){delete a.flush})}).then(K)}function he(n){return z("responseListeners").get(n)}function le(n){z("responseListeners").del(n)}function ve(n){return z("erroredResponseListeners").has(n)}function we(n){var t=n.name,e=n.win,r=n.domain,o=M("requestListeners");if(e==="*"&&(e=null),r==="*"&&(r=null),!t)throw new Error("Name required to get request listener");for(var i=0,a=[e,Sn()];i<a.length;i++){var s=a[i];if(s){var c=o.get(s);if(c){var u=c[t];if(u){if(r&&typeof r=="string"){if(u[r])return u[r];if(u.__domain_regex__)for(var h=0,f=u.__domain_regex__;h<f.length;h++){var d=f[h],l=d.listener;if(_(d.regex,r))return l}}if(u["*"])return u["*"]}}}}}function Xe(n,t,e,r){var o=r.on,i=r.send,a=we({name:e.name,win:n,domain:t}),s=e.name==="postrobot_method"&&e.data&&typeof e.data.name=="string"?e.data.name+"()":e.name;function c(u,h,f){return S.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return zn(n,t,{id:q(),origin:C(window),type:"postrobot_message_response",hash:e.hash,name:e.name,ack:u,data:h,error:f},{on:o,send:i})}catch(d){throw new Error("Send response message failed for "+s+" in "+C()+`
12
12
 
13
- `+cn(d))}})}return S.all([S.flush().then(function(){if(!t.fireAndForget&&!G(n))try{return zn(n,e,{id:q(),origin:C(window),type:"postrobot_message_ack",hash:t.hash,name:t.name},{on:o,send:i})}catch(u){throw new Error("Send ack message failed for "+s+" in "+C()+`
13
+ `+cn(d))}})}return S.all([S.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return zn(n,t,{id:q(),origin:C(window),type:"postrobot_message_ack",hash:e.hash,name:e.name},{on:o,send:i})}catch(u){throw new Error("Send ack message failed for "+s+" in "+C()+`
14
14
 
15
- `+cn(u))}}),S.try(function(){if(!a)throw new Error("No handler found for post message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return a.handler({source:n,origin:e,data:t.data})}).then(function(u){return c("success",u)},function(u){return c("error",null,u)})]).then(k).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function kt(n,e,t){if(!vt(t.hash)){var r=ht(t.hash);if(!r)throw new Error("No handler found for post message ack for message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!_(r.domain,e))throw new Error("Ack origin "+e+" does not match domain "+r.domain.toString());if(n!==r.win)throw new Error("Ack source does not match registered window")}catch(o){r.promise.reject(o)}r.ack=!0}}function Qt(n,e,t){if(!vt(t.hash)){var r=ht(t.hash);if(!r)throw new Error("No handler found for post message response for message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(r.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":v(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");lt(t.hash),t.ack==="error"?r.promise.reject(t.error):t.ack==="success"&&r.promise.resolve({source:n,origin:e,data:t.data})}}function mt(n,e){var t=e.on,r=e.send,o=z("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(h,f,d,l){var p=l.on,w=l.send,m;try{m=dt(f,d,h,{on:p,send:w})}catch{return}if(m&&typeof m=="object"&&m!==null){var I=m.__post_robot_10_0_46__;if(Array.isArray(I))return I}}(n.data,i,a,{on:t,send:r});if(s){it(i);for(var c=0;c<s.length;c++){var u=s[c];if(o.has(u.id)||(o.set(u.id,!0),G(i)&&!u.fireAndForget))return;u.origin.indexOf("file:")===0&&(a="file://");try{u.type==="postrobot_message_request"?Kt(i,a,u,{on:t,send:r}):u.type==="postrobot_message_response"?Qt(i,a,u):u.type==="postrobot_message_ack"&&kt(i,a,u)}catch(h){setTimeout(function(){throw h},0)}}}}function V(n,e,t){if(!n)throw new Error("Expected name");if(typeof(e=e||{})=="function"&&(t=e,e={}),!t)throw new Error("Expected handler");var r=function o(i,a){var s=i.name,c=i.win,u=i.domain,h=M("requestListeners");if(!s||typeof s!="string")throw new Error("Name required to add request listener");if(c&&c!=="*"&&U.isProxyWindow(c)){var f=c.awaitWindow().then(function(N){return o({name:s,win:N,domain:u},a)});return{cancel:function(){f.then(function(N){return N.cancel()},k)}}}var d=c;if(Array.isArray(d)){for(var l=[],p=0,w=d;p<w.length;p++)l.push(o({name:s,domain:u,win:w[p]},a));return{cancel:function(){for(var N=0;N<l.length;N++)l[N].cancel()}}}if(Array.isArray(u)){for(var m=[],I=0,T=u;I<T.length;I++)m.push(o({name:s,win:d,domain:T[I]},a));return{cancel:function(){for(var N=0;N<m.length;N++)m[N].cancel()}}}var O=wt({name:s,win:d,domain:u});d&&d!=="*"||(d=Sn());var b=(u=u||"*").toString();if(O)throw d&&u?new Error("Request listener already exists for "+s+" on domain "+u.toString()+" for "+(d===Sn()?"wildcard":"specified")+" window"):d?new Error("Request listener already exists for "+s+" for "+(d===Sn()?"wildcard":"specified")+" window"):u?new Error("Request listener already exists for "+s+" on domain "+u.toString()):new Error("Request listener already exists for "+s);var j=h.getOrSet(d,function(){return{}}),E=sn(j,s,function(){return{}}),A,J;return On(u)?(A=sn(E,"__domain_regex__",function(){return[]})).push(J={regex:u,listener:a}):E[b]=a,{cancel:function(){delete E[b],J&&(A.splice(A.indexOf(J,1)),A.length||delete E.__domain_regex__),Object.keys(E).length||delete j[s],d&&!Object.keys(j).length&&h.del(d)}}}({name:n,win:e.window,domain:e.domain||"*"},{handler:t||e.handler,handleError:e.errorHandler||function(o){throw o}});return{cancel:function(){r.cancel()}}}function _t(n,e,t){typeof(e=e||{})=="function"&&(t=e,e={});var r=new S,o;return e.errorHandler=function(i){o.cancel(),r.reject(i)},o=V(n,e,function(i){if(o.cancel(),r.resolve(i),t)return t(i)}),r.cancel=o.cancel,r}var Y=function n(e,t,r,o){var i=(o=o||{}).domain||"*",a=o.timeout||-1,s=o.timeout||5e3,c=o.fireAndForget||!1;return U.toProxyWindow(e,{send:n}).awaitWindow().then(function(u){return S.try(function(){if(function(h,f,d){if(!h)throw new Error("Expected name");if(d&&typeof d!="string"&&!Array.isArray(d)&&!On(d))throw new TypeError("Can not send "+h+". Expected domain "+JSON.stringify(d)+" to be a string, array, or regex");if(G(f))throw new Error("Can not send "+h+". Target window is closed")}(t,u,i),function(h,f){var d=Jn(f);if(d)return d===h;if(f===h||function(w){w===void 0&&(w=window);try{if(w.top)return w.top}catch{}if($(w)===w)return w;try{if(Hn(window,w)&&window.top)return window.top}catch{}try{if(Hn(w,window)&&window.top)return window.top}catch{}for(var m=0,I=function O(b){for(var j=[],E=0,A=Gn(b);E<A.length;E++){var J=A[E];j.push(J);for(var N=0,dn=O(J);N<dn.length;N++)j.push(dn[N])}return j}(w);m<I.length;m++){var T=I[m];try{if(T.top)return T.top}catch{}if($(T)===T)return T}}(f)===f)return!1;for(var l=0,p=Gn(h);l<p.length;l++)if(p[l]===f)return!0;return!1}(window,u))return function(h,f,d){f===void 0&&(f=5e3),d===void 0&&(d="Window");var l=function(p){return M("helloPromises").getOrSet(p,function(){return new S})}(h);return f!==-1&&(l=l.timeout(f,new Error(d+" did not load after "+f+"ms"))),l}(u,s)}).then(function(h){return function(f,d,l,p){var w=p.send;return S.try(function(){return typeof d=="string"?d:S.try(function(){return l||An(f,{send:w}).then(function(m){return m.domain})}).then(function(m){if(!_(d,d))throw new Error("Domain "+kn(d)+" does not match "+kn(d));return m})})}(u,i,(h===void 0?{}:h).domain,{send:n})}).then(function(h){var f=h,d=t==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":t,l=new S,p=t+"_"+q();if(!c){var w={name:t,win:u,domain:f,promise:l};(function(E,A){z("responseListeners").set(E,A)})(p,w);var m=M("requestPromises").getOrSet(u,function(){return[]});m.push(l),l.catch(function(){(function(E){z("erroredResponseListeners").set(E,!0)})(p),lt(p)});var I=function(E){return M("knownWindows").get(E,!1)}(u)?1e4:2e3,T=a,O=I,b=T,j=function(E,A){var J;return function N(){J=setTimeout(function(){(function(){if(G(u))return l.reject(new Error("Window closed for "+t+" before "+(w.ack?"response":"ack")));if(w.cancelled)return l.reject(new Error("Response listener was cancelled for "+t));O=Math.max(O-500,0),b!==-1&&(b=Math.max(b-500,0)),w.ack||O!==0?b===0&&l.reject(new Error("No response for postMessage "+d+" in "+C()+" in "+T+"ms")):l.reject(new Error("No ack for postMessage "+d+" in "+C()+" in "+I+"ms"))})(),N()},500)}(),{cancel:function(){clearTimeout(J)}}}();l.finally(function(){j.cancel(),m.splice(m.indexOf(l,1))}).catch(k)}return zn(u,f,{id:q(),origin:C(window),type:"postrobot_message_request",hash:p,name:t,data:r,fireAndForget:c},{on:V,send:n}).then(function(){return c?l.resolve():l},function(E){throw new Error("Send request message failed for "+d+" in "+C()+`
15
+ `+cn(u))}}),S.try(function(){if(!a)throw new Error("No handler found for post message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return a.handler({source:n,origin:t,data:e.data})}).then(function(u){return c("success",u)},function(u){return c("error",null,u)})]).then(K).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function Ke(n,t,e){if(!ve(e.hash)){var r=he(e.hash);if(!r)throw new Error("No handler found for post message ack for message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!_(r.domain,t))throw new Error("Ack origin "+t+" does not match domain "+r.domain.toString());if(n!==r.win)throw new Error("Ack source does not match registered window")}catch(o){r.promise.reject(o)}r.ack=!0}}function Qe(n,t,e){if(!ve(e.hash)){var r=he(e.hash);if(!r)throw new Error("No handler found for post message response for message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(r.domain,t))throw new Error("Response origin "+t+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":v(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");le(e.hash),e.ack==="error"?r.promise.reject(e.error):e.ack==="success"&&r.promise.resolve({source:n,origin:t,data:e.data})}}function me(n,t){var e=t.on,r=t.send,o=z("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(h,f,d,l){var p=l.on,w=l.send,m;try{m=de(f,d,h,{on:p,send:w})}catch{return}if(m&&typeof m=="object"&&m!==null){var I=m.__post_robot_10_0_46__;if(Array.isArray(I))return I}}(n.data,i,a,{on:e,send:r});if(s){ie(i);for(var c=0;c<s.length;c++){var u=s[c];if(o.has(u.id)||(o.set(u.id,!0),G(i)&&!u.fireAndForget))return;u.origin.indexOf("file:")===0&&(a="file://");try{u.type==="postrobot_message_request"?Xe(i,a,u,{on:e,send:r}):u.type==="postrobot_message_response"?Qe(i,a,u):u.type==="postrobot_message_ack"&&Ke(i,a,u)}catch(h){setTimeout(function(){throw h},0)}}}}function V(n,t,e){if(!n)throw new Error("Expected name");if(typeof(t=t||{})=="function"&&(e=t,t={}),!e)throw new Error("Expected handler");var r=function o(i,a){var s=i.name,c=i.win,u=i.domain,h=M("requestListeners");if(!s||typeof s!="string")throw new Error("Name required to add request listener");if(c&&c!=="*"&&U.isProxyWindow(c)){var f=c.awaitWindow().then(function(N){return o({name:s,win:N,domain:u},a)});return{cancel:function(){f.then(function(N){return N.cancel()},K)}}}var d=c;if(Array.isArray(d)){for(var l=[],p=0,w=d;p<w.length;p++)l.push(o({name:s,domain:u,win:w[p]},a));return{cancel:function(){for(var N=0;N<l.length;N++)l[N].cancel()}}}if(Array.isArray(u)){for(var m=[],I=0,T=u;I<T.length;I++)m.push(o({name:s,win:d,domain:T[I]},a));return{cancel:function(){for(var N=0;N<m.length;N++)m[N].cancel()}}}var O=we({name:s,win:d,domain:u});d&&d!=="*"||(d=Sn());var b=(u=u||"*").toString();if(O)throw d&&u?new Error("Request listener already exists for "+s+" on domain "+u.toString()+" for "+(d===Sn()?"wildcard":"specified")+" window"):d?new Error("Request listener already exists for "+s+" for "+(d===Sn()?"wildcard":"specified")+" window"):u?new Error("Request listener already exists for "+s+" on domain "+u.toString()):new Error("Request listener already exists for "+s);var j=h.getOrSet(d,function(){return{}}),E=sn(j,s,function(){return{}}),A,J;return On(u)?(A=sn(E,"__domain_regex__",function(){return[]})).push(J={regex:u,listener:a}):E[b]=a,{cancel:function(){delete E[b],J&&(A.splice(A.indexOf(J,1)),A.length||delete E.__domain_regex__),Object.keys(E).length||delete j[s],d&&!Object.keys(j).length&&h.del(d)}}}({name:n,win:t.window,domain:t.domain||"*"},{handler:e||t.handler,handleError:t.errorHandler||function(o){throw o}});return{cancel:function(){r.cancel()}}}function _e(n,t,e){typeof(t=t||{})=="function"&&(e=t,t={});var r=new S,o;return t.errorHandler=function(i){o.cancel(),r.reject(i)},o=V(n,t,function(i){if(o.cancel(),r.resolve(i),e)return e(i)}),r.cancel=o.cancel,r}var $=function n(t,e,r,o){var i=(o=o||{}).domain||"*",a=o.timeout||-1,s=o.timeout||5e3,c=o.fireAndForget||!1;return U.toProxyWindow(t,{send:n}).awaitWindow().then(function(u){return S.try(function(){if(function(h,f,d){if(!h)throw new Error("Expected name");if(d&&typeof d!="string"&&!Array.isArray(d)&&!On(d))throw new TypeError("Can not send "+h+". Expected domain "+JSON.stringify(d)+" to be a string, array, or regex");if(G(f))throw new Error("Can not send "+h+". Target window is closed")}(e,u,i),function(h,f){var d=Jn(f);if(d)return d===h;if(f===h||function(w){w===void 0&&(w=window);try{if(w.top)return w.top}catch{}if(Y(w)===w)return w;try{if(Hn(window,w)&&window.top)return window.top}catch{}try{if(Hn(w,window)&&window.top)return window.top}catch{}for(var m=0,I=function O(b){for(var j=[],E=0,A=Gn(b);E<A.length;E++){var J=A[E];j.push(J);for(var N=0,dn=O(J);N<dn.length;N++)j.push(dn[N])}return j}(w);m<I.length;m++){var T=I[m];try{if(T.top)return T.top}catch{}if(Y(T)===T)return T}}(f)===f)return!1;for(var l=0,p=Gn(h);l<p.length;l++)if(p[l]===f)return!0;return!1}(window,u))return function(h,f,d){f===void 0&&(f=5e3),d===void 0&&(d="Window");var l=function(p){return M("helloPromises").getOrSet(p,function(){return new S})}(h);return f!==-1&&(l=l.timeout(f,new Error(d+" did not load after "+f+"ms"))),l}(u,s)}).then(function(h){return function(f,d,l,p){var w=p.send;return S.try(function(){return typeof d=="string"?d:S.try(function(){return l||An(f,{send:w}).then(function(m){return m.domain})}).then(function(m){if(!_(d,d))throw new Error("Domain "+Kn(d)+" does not match "+Kn(d));return m})})}(u,i,(h===void 0?{}:h).domain,{send:n})}).then(function(h){var f=h,d=e==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":e,l=new S,p=e+"_"+q();if(!c){var w={name:e,win:u,domain:f,promise:l};(function(E,A){z("responseListeners").set(E,A)})(p,w);var m=M("requestPromises").getOrSet(u,function(){return[]});m.push(l),l.catch(function(){(function(E){z("erroredResponseListeners").set(E,!0)})(p),le(p)});var I=function(E){return M("knownWindows").get(E,!1)}(u)?1e4:2e3,T=a,O=I,b=T,j=function(E,A){var J;return function N(){J=setTimeout(function(){(function(){if(G(u))return l.reject(new Error("Window closed for "+e+" before "+(w.ack?"response":"ack")));if(w.cancelled)return l.reject(new Error("Response listener was cancelled for "+e));O=Math.max(O-500,0),b!==-1&&(b=Math.max(b-500,0)),w.ack||O!==0?b===0&&l.reject(new Error("No response for postMessage "+d+" in "+C()+" in "+T+"ms")):l.reject(new Error("No ack for postMessage "+d+" in "+C()+" in "+I+"ms"))})(),N()},500)}(),{cancel:function(){clearTimeout(J)}}}();l.finally(function(){j.cancel(),m.splice(m.indexOf(l,1))}).catch(K)}return zn(u,f,{id:q(),origin:C(window),type:"postrobot_message_request",hash:p,name:e,data:r,fireAndForget:c},{on:V,send:n}).then(function(){return c?l.resolve():l},function(E){throw new Error("Send request message failed for "+d+" in "+C()+`
16
16
 
17
- `+cn(E))})})})};function ne(n,e,t){return ft(n,e,t,{on:V,send:Y})}function te(n,e,t){return dt(n,e,t,{on:V,send:Y})}function ee(n){return new U({send:Y,win:n})}function re(n){return U.toProxyWindow(n,{send:Y})}function pt(){fn().initialized||(fn().initialized=!0,e=(n={on:V,send:Y}).on,t=n.send,(r=fn()).receiveMessage=r.receiveMessage||function(o){return mt(o,{on:e,send:t})},function(o){var i=o.on,a=o.send;z().getOrSet("postMessageListener",function(){return function(s,c,u){return s.addEventListener("message",u),{cancel:function(){s.removeEventListener("message",u)}}}(window,0,function(s){(function(c,u){var h=u.on,f=u.send;S.try(function(){var d=c.source||c.sourceElement,l=c.origin||c.originalEvent&&c.originalEvent.origin,p=c.data;if(l==="null"&&(l="file://"),d){if(!l)throw new Error("Post message did not have origin domain");mt({source:d,origin:l,data:p},{on:h,send:f})}})})(s,{on:i,send:a})})})}({on:V,send:Y}),function(o){var i=o.on,a=o.send;z("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return rt(u.source,{domain:u.origin}),{instanceID:et()}}),c=Jn();return c&&An(c,{send:a}).catch(function(u){}),s})}({on:V,send:Y}));var n,e,t,r}function oe(){(function(){for(var e=z("responseListeners"),t=0,r=e.keys();t<r.length;t++){var o=r[t],i=e.get(o);i&&(i.cancelled=!0),e.del(o)}})(),(n=z().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var ie=!0;function ae(n){for(var e=0,t=M("requestPromises").get(n,[]);e<t.length;e++)t[e].reject(new Error("Window "+(G(n)?"closed":"cleaned up")+" before response")).catch(k)}pt()}])})})(Bn);var Dt=Bn.exports;(function(W){W.exports=Dt,W.exports.default=W.exports})(Fn);var Nt=Fn.exports;const hn=At(Nt),Rt="WIDGET_MOUNTED",Tt="WIDGET_EVENT";function zt(W){const{configure:D,onEvent:H}=W;hn.on(Rt,()=>{D()}),hn.on(Tt,y=>{H(y.data),Wt.includes(y.data.eventName)&&Ln()})}function jt(W){zt(W)}function Ct(W){hn.send(W.contentWindow,"ready")}function Mt(W,D){hn.send(W.contentWindow,"config",D)}class Lt{constructor(D){Cn(this,ln);Cn(this,vn);nn(this,"iframe");nn(this,"flow");nn(this,"configProps");nn(this,"onEvent");nn(this,"isSandbox");this.flow=D.flow,this.configProps=D.configProps,this.onEvent=D.onEvent,this.isSandbox=D.isSandbox??!1,this.validateProps(),this.iframe=Pt(this.flow,this.configProps,this.isSandbox,D.developmentUrl),jt({configure:Mn(this,ln,gt).bind(this),onEvent:Mn(this,vn,yt).bind(this)})}validateProps(){if(this.flow==="authenticate"){if(!this.configProps.identityId)throw new Error("identityId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}else if(this.flow==="register"){if(!this.configProps.flowTemplateId)throw new Error("flowTemplateId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}}close(){Ln()}}return ln=new WeakSet,gt=function(){Ct(this.iframe),Mt(this.iframe,this.configProps)},vn=new WeakSet,yt=function(D){this.onEvent(D)},Lt});
17
+ `+cn(E))})})})};function nt(n,t,e){return fe(n,t,e,{on:V,send:$})}function et(n,t,e){return de(n,t,e,{on:V,send:$})}function tt(n){return new U({send:$,win:n})}function rt(n){return U.toProxyWindow(n,{send:$})}function pe(){fn().initialized||(fn().initialized=!0,t=(n={on:V,send:$}).on,e=n.send,(r=fn()).receiveMessage=r.receiveMessage||function(o){return me(o,{on:t,send:e})},function(o){var i=o.on,a=o.send;z().getOrSet("postMessageListener",function(){return function(s,c,u){return s.addEventListener("message",u),{cancel:function(){s.removeEventListener("message",u)}}}(window,0,function(s){(function(c,u){var h=u.on,f=u.send;S.try(function(){var d=c.source||c.sourceElement,l=c.origin||c.originalEvent&&c.originalEvent.origin,p=c.data;if(l==="null"&&(l="file://"),d){if(!l)throw new Error("Post message did not have origin domain");me({source:d,origin:l,data:p},{on:h,send:f})}})})(s,{on:i,send:a})})})}({on:V,send:$}),function(o){var i=o.on,a=o.send;z("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return re(u.source,{domain:u.origin}),{instanceID:te()}}),c=Jn();return c&&An(c,{send:a}).catch(function(u){}),s})}({on:V,send:$}));var n,t,e,r}function ot(){(function(){for(var t=z("responseListeners"),e=0,r=t.keys();e<r.length;e++){var o=r[e],i=t.get(o);i&&(i.cancelled=!0),t.del(o)}})(),(n=z().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var it=!0;function at(n){for(var t=0,e=M("requestPromises").get(n,[]);t<e.length;t++)e[t].reject(new Error("Window "+(G(n)?"closed":"cleaned up")+" before response")).catch(K)}pe()}])})})(Bn);var De=Bn.exports;(function(W){W.exports=De,W.exports.default=W.exports})(Fn);var Ne=Fn.exports;const hn=Ae(Ne),Re="WIDGET_MOUNTED",Te="WIDGET_EVENT";function ze(W){const{configure:D,onEvent:H}=W;hn.on(Re,()=>{D()}),hn.on(Te,y=>{H(y.data),We.includes(y.data.eventName)&&Ln()})}function je(W){ze(W)}function Ce(W){hn.send(W.contentWindow,"ready")}function Me(W,D){hn.send(W.contentWindow,"config",D)}class Le{constructor(D){Cn(this,ln);Cn(this,vn);nn(this,"iframe");nn(this,"flow");nn(this,"configProps");nn(this,"onEvent");nn(this,"isSandbox");this.flow=D.flow,this.configProps=D.configProps,this.onEvent=D.onEvent,this.isSandbox=D.isSandbox??!1,this.validateProps(),this.iframe=Pe(this.flow,this.configProps,this.isSandbox,D.developmentUrl),je({configure:Mn(this,ln,ge).bind(this),onEvent:Mn(this,vn,ye).bind(this)})}validateProps(){if(this.flow==="authenticate"){if(!this.configProps.identityId)throw new Error("identityId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}else if(this.flow==="register"){if(!this.configProps.flowTemplateId)throw new Error("flowTemplateId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}}close(){Ln()}}return ln=new WeakSet,ge=function(){Ce(this.iframe),Me(this.iframe,this.configProps)},vn=new WeakSet,ye=function(D){this.onEvent(D)},Le});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-widget",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",