@soyio/soyio-widget 1.0.13 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -69
- package/dist/index.d.ts +14 -32
- package/dist/index.js +28 -27
- package/dist/index.umd.cjs +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,68 +26,33 @@ yarn add @soyio/soyio-widget
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
Integrate the widget into your frontend framework using the script below. Ensure to replace placeholders (e.g., \<
|
|
29
|
+
Integrate the widget into your frontend framework using the script below. Ensure to replace placeholders (e.g., \<request>, \<company id>) with actual values relevant to your implementation.
|
|
30
30
|
|
|
31
|
-
### 1.
|
|
31
|
+
### 1. Disclosure Request
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Start validation attempt
|
|
36
|
-
</button>
|
|
33
|
+
A **`disclosure_request`** is a process that a user goes through where they are verified, and then they share the necessary data as required by each company.
|
|
34
|
+
This verification can happen in one of the following two ways:
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
import { SoyioWidget } from "@soyio/soyio-widget";
|
|
36
|
+
1. **Validation**: Through document validation and facial video. This occurs when a user has never been verified before with Soyio.
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
const widgetConfig = {
|
|
43
|
-
flow: "register",
|
|
44
|
-
configProps: {
|
|
45
|
-
companyId: "<company id>",
|
|
46
|
-
userReference: "<user identifier of company>",
|
|
47
|
-
userEmail: "<user email>",
|
|
48
|
-
flowTemplateId: "<flow template id>",
|
|
49
|
-
forceError: "<error type>",
|
|
50
|
-
customColor: "<custom color>",
|
|
51
|
-
},
|
|
52
|
-
onEvent: (data) => console.log(data),
|
|
53
|
-
isSandbox: true,
|
|
54
|
-
};
|
|
38
|
+
2. **Authentication**: Through an access key (passkey) or facial video. This can occur when a user has already been validated previously with Soyio.
|
|
55
39
|
|
|
56
|
-
|
|
57
|
-
function initWidget() {
|
|
58
|
-
new SoyioWidget(widgetConfig);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Add event listener to the button to create the widget on click
|
|
62
|
-
document.getElementById('start-validation-attempt')
|
|
63
|
-
.addEventListener('click', initWidget);
|
|
64
|
-
</script>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Optional props:
|
|
68
|
-
|
|
69
|
-
- `userReference`
|
|
70
|
-
- `userEmail`
|
|
71
|
-
- `forceError`
|
|
72
|
-
- `customColor`.
|
|
73
|
-
|
|
74
|
-
### 2. Auth attempt
|
|
40
|
+
To instantiate this process in the code, it should be done in the following manner:
|
|
75
41
|
|
|
76
42
|
```html
|
|
77
|
-
<button id="start-
|
|
78
|
-
Start auth attempt
|
|
79
|
-
</button>
|
|
43
|
+
<button id="start-disclosure-request">Start disclosure request</button>
|
|
80
44
|
|
|
81
45
|
<script>
|
|
82
46
|
import { SoyioWidget } from "@soyio/soyio-widget";
|
|
83
47
|
|
|
84
48
|
// Widget configuration
|
|
85
49
|
const widgetConfig = {
|
|
86
|
-
|
|
50
|
+
request: "disclosure",
|
|
87
51
|
configProps: {
|
|
88
52
|
companyId: "<company id>",
|
|
89
53
|
userReference: "<user identifier of company>",
|
|
90
|
-
|
|
54
|
+
userEmail: "<user email>",
|
|
55
|
+
templateId: "<template id>",
|
|
91
56
|
forceError: "<error type>",
|
|
92
57
|
customColor: "<custom color>",
|
|
93
58
|
},
|
|
@@ -101,30 +66,32 @@ Optional props:
|
|
|
101
66
|
}
|
|
102
67
|
|
|
103
68
|
// Add event listener to the button to create the widget on click
|
|
104
|
-
document
|
|
105
|
-
|
|
69
|
+
document
|
|
70
|
+
.getElementById("start-disclosure-request")
|
|
71
|
+
.addEventListener("click", initWidget);
|
|
106
72
|
</script>
|
|
107
73
|
```
|
|
108
74
|
|
|
109
75
|
Optional props:
|
|
110
76
|
|
|
111
77
|
- `userReference`
|
|
78
|
+
- `userEmail`
|
|
112
79
|
- `forceError`
|
|
113
80
|
- `customColor`.
|
|
114
81
|
|
|
115
|
-
###
|
|
82
|
+
### 2. Signature attempt
|
|
83
|
+
|
|
84
|
+
The **`signature_attempt`** is a process where, using a previously created `signature_attempt_id`, a request is initiated in which a user can digitally sign a document. To sign the document, the user must be authenticated. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
|
|
116
85
|
|
|
117
86
|
```html
|
|
118
|
-
<button id="start-
|
|
119
|
-
Start signature attempt
|
|
120
|
-
</button>
|
|
87
|
+
<button id="start-signature-attempt">Start signature attempt</button>
|
|
121
88
|
|
|
122
89
|
<script>
|
|
123
90
|
import { SoyioWidget } from "@soyio/soyio-widget";
|
|
124
91
|
|
|
125
92
|
// Widget configuration
|
|
126
93
|
const widgetConfig = {
|
|
127
|
-
|
|
94
|
+
request: "signature",
|
|
128
95
|
configProps: {
|
|
129
96
|
signatureAttemptId: "<signature attempt id>",
|
|
130
97
|
forceError: "<error type>",
|
|
@@ -140,8 +107,9 @@ Optional props:
|
|
|
140
107
|
}
|
|
141
108
|
|
|
142
109
|
// Add event listener to the button to create the widget on click
|
|
143
|
-
document
|
|
144
|
-
|
|
110
|
+
document
|
|
111
|
+
.getElementById("start-signature-attempt")
|
|
112
|
+
.addEventListener("click", initWidget);
|
|
145
113
|
</script>
|
|
146
114
|
```
|
|
147
115
|
|
|
@@ -155,37 +123,32 @@ Optional props:
|
|
|
155
123
|
- **`companyId`**: The unique identifier for the company, must start with `'com_'`.
|
|
156
124
|
- **`userReference`**: A reference identifier provided by the company for the user engaging with the widget. This identifier is used in events (`onEvent` and `webhooks`) to inform the company which user the events are associated with.
|
|
157
125
|
- **`userEmail`**: The user's email address. If not provided, Soyio will prompt the user to enter their email.
|
|
158
|
-
- **`
|
|
126
|
+
- **`templateId`**: Identifier of template. Specifies the order and quantity of documents requested from the user, as well as the mandatory data that the user is asked to share with the company. It must start with `'dtpl_'`.
|
|
159
127
|
- **`signatureAttemptId`**: Identifier of signature attempt obtained when creating the `SignatureAttempt`. It must start with `'sa_'`.
|
|
160
128
|
- **`identityId`**: This identifier must start with `'id_'` and signifies the user's identity.
|
|
161
129
|
- **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
|
|
162
130
|
- **`forceError`**: Triggers specific errors for testing or debugging. Used to simulate failure scenarios. Only works in `sandbox` mode.
|
|
163
131
|
- **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
|
|
164
|
-
- **`customColor`**: A hex code string that specifies the base color of the interface
|
|
132
|
+
- **`customColor`**: A hex code string that specifies the base color of the interface.
|
|
165
133
|
|
|
166
134
|
### Events
|
|
167
135
|
|
|
168
|
-
The `onEvent` callback is designed to handle various events that occur during widget interaction. Specifically, it receives detailed information upon the successful completion of user
|
|
169
|
-
|
|
170
|
-
- **`IDENTITY_REGISTERED`**: This event is dispatched when a user successfully completes the validation attempt. The event object contains:
|
|
171
|
-
|
|
172
|
-
- `eventName`: The name of the event, in this case, `'IDENTITY_REGISTERED'`.
|
|
173
|
-
- `identityId`: The unique identifier for the newly registered identity.
|
|
174
|
-
- `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
|
|
136
|
+
The `onEvent` callback is designed to handle various events that occur during widget interaction. Specifically, it receives detailed information upon the successful completion of user request. Here are the events it handles:
|
|
175
137
|
|
|
176
|
-
- **`
|
|
138
|
+
- **`DISCLOSURE_REQUEST_SUCCESSFUL`**: This event occurs when a user successfully completes a `disclosure_request`. The identity verification could have been a `validation` or `authentication`.
|
|
177
139
|
|
|
178
|
-
- `eventName`: The name of the event, in this case, `'
|
|
179
|
-
- `
|
|
140
|
+
- `eventName`: The name of the event, in this case, `'DISCLOSURE_REQUEST_SUCCESSFUL'`.
|
|
141
|
+
- `verificationMethod`: Takes the values of `authentication` or `validation`.
|
|
142
|
+
- `identityId`: The unique identifier for the verified identity.
|
|
180
143
|
- `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
|
|
181
144
|
|
|
182
145
|
- **`IDENTITY_SIGNATURE`**: This event occurs when a user successfully completes a signature attempt. The event object includes:
|
|
183
146
|
|
|
184
147
|
- `eventName`: The name of the event, in this case, `'IDENTITY_SIGNATURE'`.
|
|
185
|
-
- `identityId`: The unique identifier for the authenticated identity.
|
|
186
148
|
- `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
|
|
187
149
|
|
|
188
150
|
- **`DENIED_CAMERA_PERMISSION`**: Event triggered when user denies camera permissions. It closes the widget.
|
|
151
|
+
- **`UNEXPECTED_ERROR`**: Event triggered when user exits because of an unexpected error.
|
|
189
152
|
|
|
190
153
|
- **`REJECTED_SIGNATURE`**: Event triggered when user clicks the "reject" button in the signature attempt. The event object includes:
|
|
191
154
|
|
|
@@ -207,7 +170,7 @@ The `forceError` parameter can simulate the following error conditions:
|
|
|
207
170
|
- `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
|
|
208
171
|
- `'unknown_error'`: Generates a generic error, representing an unspecified problem.
|
|
209
172
|
- `'expiration_error'`: Occurs when there is an issue with the identity provider that prevents the validation of one or both documents provided by the user, due to unspecified problems in the validation process.
|
|
210
|
-
- `'camera_permission_error'`: Happens when the user does not grant the necessary permissions to access the camera, preventing the completion of the
|
|
173
|
+
- `'camera_permission_error'`: Happens when the user does not grant the necessary permissions to access the camera, preventing the completion of the disclosure or signature request.
|
|
211
174
|
|
|
212
175
|
#### Typescript
|
|
213
176
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
declare type AttemptConfig =
|
|
1
|
+
declare type AttemptConfig = DisclosureRequestConfig | SignatureAttemptConfig;
|
|
2
2
|
|
|
3
|
-
declare type
|
|
4
|
-
|
|
5
|
-
configProps:
|
|
3
|
+
declare type DisclosureRequestConfig = {
|
|
4
|
+
request: 'disclosure';
|
|
5
|
+
configProps: DisclosureRequestProps;
|
|
6
6
|
onEvent: (data: EventData) => void;
|
|
7
7
|
isSandbox?: boolean;
|
|
8
8
|
developmentUrl?: string;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
declare type
|
|
11
|
+
declare type DisclosureRequestProps = {
|
|
12
12
|
companyId: string;
|
|
13
|
-
|
|
13
|
+
templateId: string;
|
|
14
14
|
userReference?: string;
|
|
15
|
+
userEmail?: string;
|
|
15
16
|
forceError?: ForceErrors;
|
|
16
17
|
customColor?: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
declare type EventData = {
|
|
20
|
-
eventName: '
|
|
21
|
+
eventName: 'IDENTITY_VALIDATED' | 'IDENTITY_AUTHENTICATED' | 'IDENTITY_SIGNATURE' | 'DENIED_CAMERA_PERMISSION' | 'REJECTED_SIGNATURE' | 'DISCLOSURE_REQUEST_SUCCESSFUL' | 'UNEXPECTED_ERROR';
|
|
21
22
|
identityId: string;
|
|
22
23
|
userReference?: string;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
declare type Flow = 'authenticate' | 'register' | 'signature';
|
|
26
|
-
|
|
27
26
|
declare type ForceErrors = 'facial_validation_error' | 'document_validation_error' | 'unknown_error' | 'expiration_error' | 'camera_permission_error';
|
|
28
27
|
|
|
28
|
+
declare type Request_2 = 'disclosure' | 'signature';
|
|
29
|
+
|
|
29
30
|
declare type SignatureAttemptConfig = {
|
|
30
|
-
|
|
31
|
+
request: 'signature';
|
|
31
32
|
configProps: SignatureAttemptProps;
|
|
32
33
|
onEvent: (data: EventData) => void;
|
|
33
34
|
isSandbox?: boolean;
|
|
@@ -43,13 +44,11 @@ declare type SignatureAttemptProps = {
|
|
|
43
44
|
declare namespace SoyioTypes {
|
|
44
45
|
export {
|
|
45
46
|
ForceErrors,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ValidationAttemptProps,
|
|
47
|
+
Request_2 as Request,
|
|
48
|
+
DisclosureRequestProps,
|
|
49
49
|
SignatureAttemptProps,
|
|
50
50
|
EventData,
|
|
51
|
-
|
|
52
|
-
AuthAttemptConfig,
|
|
51
|
+
DisclosureRequestConfig,
|
|
53
52
|
SignatureAttemptConfig,
|
|
54
53
|
AttemptConfig
|
|
55
54
|
}
|
|
@@ -64,21 +63,4 @@ declare class SoyioWidget {
|
|
|
64
63
|
export { SoyioWidget }
|
|
65
64
|
export default SoyioWidget;
|
|
66
65
|
|
|
67
|
-
declare type ValidationAttemptConfig = {
|
|
68
|
-
flow: 'register';
|
|
69
|
-
configProps: ValidationAttemptProps;
|
|
70
|
-
onEvent: (data: EventData) => void;
|
|
71
|
-
isSandbox?: boolean;
|
|
72
|
-
developmentUrl?: string;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
declare type ValidationAttemptProps = {
|
|
76
|
-
companyId: string;
|
|
77
|
-
flowTemplateId: string;
|
|
78
|
-
userReference?: string;
|
|
79
|
-
userEmail?: string;
|
|
80
|
-
forceError?: ForceErrors;
|
|
81
|
-
customColor?: string;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
66
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (t, e, n) => (
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var _ = (t, e, n) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var u = (t, e, n) => (_(t, typeof e != "symbol" ? e + "" : e, n), n), T = (t, e, n) => {
|
|
4
4
|
if (!e.has(t))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
@@ -9,19 +9,20 @@ var a = (t, e, n) => {
|
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
e instanceof WeakSet ? e.add(t) : e.set(t, n);
|
|
11
11
|
};
|
|
12
|
-
var f = (t, e, n) => (
|
|
13
|
-
const
|
|
14
|
-
"
|
|
12
|
+
var f = (t, e, n) => (T(t, e, "access private method"), n);
|
|
13
|
+
const v = "WIDGET_EVENT", b = "https://app.soyio.id/widget", y = "https://sandbox.soyio.id/widget", N = [
|
|
14
|
+
"DISCLOSURE_REQUEST_SUCCESSFUL",
|
|
15
15
|
"IDENTITY_REGISTERED",
|
|
16
16
|
"IDENTITY_SIGNATURE",
|
|
17
|
+
"UNEXPECTED_ERROR",
|
|
17
18
|
"DENIED_CAMERA_PERMISSION",
|
|
18
19
|
"REJECTED_SIGNATURE"
|
|
19
|
-
],
|
|
20
|
-
function
|
|
21
|
-
const e = t.isSandbox ?? !1, n = t.developmentUrl || (e ?
|
|
22
|
-
return `${n}/${t.
|
|
20
|
+
], R = "WIDGET_CLOSED";
|
|
21
|
+
function U(t) {
|
|
22
|
+
const e = t.isSandbox ?? !1, n = t.developmentUrl || (e ? y : b), o = Object.entries(t.configProps).filter(([, c]) => c).map(([c, d]) => `${c}=${encodeURIComponent(d)}`).join("&");
|
|
23
|
+
return `${n}/${t.request}?sdk=web&${o}`;
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
+
const g = !!(typeof window < "u" && window.document && window.document.createElement), D = 500;
|
|
25
26
|
let i = null, l = null;
|
|
26
27
|
function r() {
|
|
27
28
|
i && !i.closed && i.focus();
|
|
@@ -29,39 +30,39 @@ function r() {
|
|
|
29
30
|
function E() {
|
|
30
31
|
document.body.style.filter = "", document.body.removeEventListener("click", r);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function C() {
|
|
33
34
|
l = setInterval(() => {
|
|
34
35
|
(!i || i.closed) && (l && clearInterval(l), E());
|
|
35
|
-
},
|
|
36
|
+
}, D);
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
const e =
|
|
39
|
-
document.body.style.filter = "blur(5px)", document.body.addEventListener("click", (
|
|
40
|
-
r(),
|
|
41
|
-
}), i = window.open(e, "Soyio", `scrollbars=yes, width=${n}, height=${o}, top=${h}, left=${m}`), r(),
|
|
38
|
+
function O(t) {
|
|
39
|
+
const e = U(t), n = 510, o = 720, c = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width, d = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height, m = c / 2 - n / 2, h = d / 2 - o / 2;
|
|
40
|
+
document.body.style.filter = "blur(5px)", document.body.addEventListener("click", (S) => {
|
|
41
|
+
r(), S.preventDefault();
|
|
42
|
+
}), i = window.open(e, "Soyio", `scrollbars=yes, width=${n}, height=${o}, top=${h}, left=${m}`), r(), C();
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function P() {
|
|
44
45
|
i && (i.close(), i = null), E();
|
|
45
46
|
}
|
|
46
47
|
let w = !1;
|
|
47
48
|
async function L(t) {
|
|
48
49
|
const { onEvent: e } = t, n = await import("./index-yZw-yxuV.js").then((o) => o.i);
|
|
49
|
-
w || (n.on(
|
|
50
|
-
e(o.data),
|
|
50
|
+
w || (n.on(v, (o) => {
|
|
51
|
+
e(o.data), N.includes(o.data.eventName) ? P() : o.data.eventName === R && E();
|
|
51
52
|
}), w = !0);
|
|
52
53
|
}
|
|
53
54
|
function W(t) {
|
|
54
55
|
L(t);
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
+
const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
57
58
|
__proto__: null
|
|
58
59
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
59
60
|
var s, p;
|
|
60
|
-
class
|
|
61
|
+
class x {
|
|
61
62
|
constructor(e) {
|
|
62
63
|
a(this, s);
|
|
63
64
|
u(this, "onEvent");
|
|
64
|
-
this.onEvent = e.onEvent,
|
|
65
|
+
this.onEvent = e.onEvent, g && (O(e), W({
|
|
65
66
|
onEvent: f(this, s, p).bind(this)
|
|
66
67
|
}));
|
|
67
68
|
}
|
|
@@ -70,7 +71,7 @@ s = new WeakSet(), p = function(e) {
|
|
|
70
71
|
this.onEvent(e);
|
|
71
72
|
};
|
|
72
73
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
G as SoyioTypes,
|
|
75
|
+
x as SoyioWidget,
|
|
76
|
+
x as default
|
|
76
77
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
(function(A
|
|
2
|
-
`;function Z(n){return n===void 0&&(n=window),n.location.protocol}function Y(n){if(n===void 0&&(n=window),n.mockDomain){var t=n.mockDomain.split("//")[0];if(t)return t}return Z(n)}function hn(n){return n===void 0&&(n=window),Y(n)==="about:"}function K(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Bn(n){if(n===void 0&&(n=window),n&&!K(n))try{return n.opener}catch{}}function vn(n){try{return!0}catch{}return!1}function wn(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=K(n);return r&&vn()?wn(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return e+"//"+o}function M(n){n===void 0&&(n=window);var t=wn(n);return t&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:t}function X(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(hn(t)&&vn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),Y(r)==="mock:"}(t)&&vn())return!0}catch{}try{if(wn(t)===wn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||hn(n)&&vn()||M(window)===M(n))return!0}catch{}return!1}function mn(n){if(!X(n))throw new Error("Expected window to be same domain");return n}function Gn(n,t){if(!n||!t)return!1;var e=K(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 Jn(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 Ue=[],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!==W}if(t&&X(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}(Ue,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 Zn(n){return n===void 0&&(n=window),Bn(n=n||window)||K(n)||void 0}function en(n,t){if(typeof n=="string"){if(typeof t=="string")return n==="*"||t===n;if(w(t)||Array.isArray(t))return!1}return w(n)?w(t)?n.toString()===t.toString():!Array.isArray(t)&&!!t.match(n):!!Array.isArray(n)&&(Array.isArray(t)?JSON.stringify(n)===JSON.stringify(t):!w(t)&&n.some(function(e){return en(e,t)}))}function pn(n){try{if(n===window)return!0}catch(t){if(t&&t.message===W)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(t){if(t&&t.message===W)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.self===n)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.parent===n)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.top===n)return!0}catch(t){if(t&&t.message===W)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 kn(n){if(X(n))return mn(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 Ge(n){if(function(e){return e===void 0&&(e=window),!!K(e)}(n)){var t=kn(n);if(t&&t.parentElement){t.parentElement.removeChild(t);return}}try{n.close()}catch{}}function _(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 Vn=[],tn=[],Pn=0,rn;function $n(){if(!Pn&&rn){var n=rn;rn=null,n.resolve()}}function On(){Pn+=1}function on(){Pn-=1,$n()}var b=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;On();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(_(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(_(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(Vn.indexOf(i)===-1){Vn.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,On();for(var i=function(h,g){return h.then(function(m){g.resolve(m)},function(m){g.reject(m)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,l=s.promise,d=void 0;if(e)try{d=c?c(this.value):this.value}catch(h){l.reject(h);continue}else if(r){if(!u){l.reject(this.error);continue}try{d=u(this.error)}catch(h){l.reject(h);continue}}if(d instanceof n&&(d.resolved||d.rejected)){var f=d;f.resolved?l.resolve(f.value):l.reject(f.error),f.errorHandled=!0}else _(d)?d instanceof n&&(d.resolved||d.rejected)?d.resolved?l.resolve(d.value):l.reject(d.error):i(d,l):l.resolve(d)}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:_(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,l,d){return l.then(function(f){i[u]=f,(o-=1)==0&&r.resolve(i)},function(f){d.reject(f)})},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(!_(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];_(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;On();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)||_(e)},n.flush=function(){return function(e){var r=rn=rn||new e;return $n(),r}(n)},n}();function gn(n,t){for(var e=0;e<n.length;e++)try{if(n[e]===t)return e}catch{}return-1}var In=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(pn(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!pn(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=gn(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=gn(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=gn(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(),gn(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 qn(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 k(){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 yn;function Kn(n){try{return JSON.stringify([].slice.call(n),function(t,e){return typeof e=="function"?"memoize["+function(r){if(yn=yn||new In,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=yn.get(r);return o||(o=typeof r+":"+k(),yn.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 Je(){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,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];s<Xn&&(i=null,a=null,s=an,an+=1);var f;f=r?(a=a||new In).getOrSet(this,Je):i=i||{};var h;try{h=Kn(l)}catch{return n.apply(this,arguments)}var g=f[h];if(g&&o&&Date.now()-g.time<o&&(delete f[h],g=null),g)return g.value;var m=Date.now(),p=n.apply(this,arguments);return f[h]={time:m,value:p},p};return c.reset=function(){i=null,a=null},Yn(c,(t.name||qn(n))+"::memoized")}un.clear=function(){Xn=an};function Ze(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]=b.try(function(){return n.apply(o,r)}).finally(function(){delete t[c]})),t[c]}return e.reset=function(){t={}},Yn(e,qn(n)+"::promiseMemoized")}function Q(){}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 _n(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
|
|
1
|
+
(function(D,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(D=typeof globalThis<"u"?globalThis:D||self,A(D["soyio-widget"]={}))})(this,function(D){"use strict";var st=Object.defineProperty;var dt=(D,A,F)=>A in D?st(D,A,{enumerable:!0,configurable:!0,writable:!0,value:F}):D[A]=F;var ye=(D,A,F)=>(dt(D,typeof A!="symbol"?A+"":A,F),F),ft=(D,A,F)=>{if(!A.has(D))throw TypeError("Cannot "+F)};var Ee=(D,A,F)=>{if(A.has(D))throw TypeError("Cannot add the same private member more than once");A instanceof WeakSet?A.add(D):A.set(D,F)};var We=(D,A,F)=>(ft(D,A,"access private method"),F);var ln,Se;function A(S,T){for(var C=0;C<T.length;C++){const y=T[C];if(typeof y!="string"&&!Array.isArray(y)){for(const v in y)if(v!=="default"&&!(v in S)){const w=Object.getOwnPropertyDescriptor(y,v);w&&Object.defineProperty(S,v,w.get?w:{enumerable:!0,get:()=>y[v]})}}}return Object.freeze(Object.defineProperty(S,Symbol.toStringTag,{value:"Module"}))}const F="WIDGET_EVENT",be="https://app.soyio.id/widget",xe="https://sandbox.soyio.id/widget",Pe=["DISCLOSURE_REQUEST_SUCCESSFUL","IDENTITY_REGISTERED","IDENTITY_SIGNATURE","UNEXPECTED_ERROR","DENIED_CAMERA_PERMISSION","REJECTED_SIGNATURE"],Oe="WIDGET_CLOSED";function Ie(S){const T=S.isSandbox??!1,C=S.developmentUrl||(T?xe:be),y=Object.entries(S.configProps).filter(([,v])=>v).map(([v,w])=>`${v}=${encodeURIComponent(w)}`).join("&");return`${C}/${S.request}?sdk=web&${y}`}const De=!!(typeof window<"u"&&window.document&&window.document.createElement),Ae=500;let q=null,Sn=null;function bn(){q&&!q.closed&&q.focus()}function xn(){document.body.style.filter="",document.body.removeEventListener("click",bn)}function Re(){Sn=setInterval(()=>{(!q||q.closed)&&(Sn&&clearInterval(Sn),xn())},Ae)}function Ne(S){const T=Ie(S),C=510,y=720,v=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,w=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height,W=v/2-C/2,Z=w/2-y/2;document.body.style.filter="blur(5px)",document.body.addEventListener("click",Y=>{bn(),Y.preventDefault()}),q=window.open(T,"Soyio",`scrollbars=yes, width=${C}, height=${y}, top=${Z}, left=${W}`),bn(),Re()}function je(){q&&(q.close(),q=null),xn()}let Mn=!1;async function ze(S){const{onEvent:T}=S,C=await Promise.resolve().then(()=>Ue);Mn||(C.on(F,y=>{T(y.data),Pe.includes(y.data.eventName)?je():y.data.eventName===Oe&&xn()}),Mn=!0)}function Ce(S){ze(S)}const Te=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));class Ln{constructor(T){Ee(this,ln);ye(this,"onEvent");this.onEvent=T.onEvent,De&&(Ne(T),Ce({onEvent:We(this,ln,Se).bind(this)}))}}ln=new WeakSet,Se=function(T){this.onEvent(T)};var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Le(S){return S&&S.__esModule&&Object.prototype.hasOwnProperty.call(S,"default")?S.default:S}var Fn={exports:{}},Un={exports:{}};(function(S,T){(function(C,y){S.exports=y()})(typeof self<"u"?self:Me,function(){return function(C){var y={};function v(w){if(y[w])return y[w].exports;var W=y[w]={i:w,l:!1,exports:{}};return C[w].call(W.exports,W,W.exports,v),W.l=!0,W.exports}return v.m=C,v.c=y,v.d=function(w,W,Z){v.o(w,W)||Object.defineProperty(w,W,{enumerable:!0,get:Z})},v.r=function(w){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(w,"__esModule",{value:!0})},v.t=function(w,W){if(1&W&&(w=v(w)),8&W||4&W&&typeof w=="object"&&w&&w.__esModule)return w;var Z=Object.create(null);if(v.r(Z),Object.defineProperty(Z,"default",{enumerable:!0,value:w}),2&W&&typeof w!="string")for(var Y in w)v.d(Z,Y,(function(hn){return w[hn]}).bind(null,Y));return Z},v.n=function(w){var W=w&&w.__esModule?function(){return w.default}:function(){return w};return v.d(W,"a",W),W},v.o=function(w,W){return{}.hasOwnProperty.call(w,W)},v.p="",v(v.s=0)}([function(C,y,v){v.r(y),v.d(y,"Promise",function(){return b}),v.d(y,"TYPES",function(){return ut}),v.d(y,"ProxyWindow",function(){return B}),v.d(y,"setup",function(){return ge}),v.d(y,"destroy",function(){return at}),v.d(y,"serializeMessage",function(){return tt}),v.d(y,"deserializeMessage",function(){return rt}),v.d(y,"createProxyWindow",function(){return ot}),v.d(y,"toProxyWindow",function(){return it}),v.d(y,"on",function(){return V}),v.d(y,"once",function(){return et}),v.d(y,"send",function(){return $}),v.d(y,"markWindowKnown",function(){return ae}),v.d(y,"cleanUpWindow",function(){return ct}),v.d(y,"bridge",function(){});function w(n){return{}.toString.call(n)==="[object RegExp]"}var W=`Call was rejected by callee.\r
|
|
2
|
+
`;function Z(n){return n===void 0&&(n=window),n.location.protocol}function Y(n){if(n===void 0&&(n=window),n.mockDomain){var t=n.mockDomain.split("//")[0];if(t)return t}return Z(n)}function hn(n){return n===void 0&&(n=window),Y(n)==="about:"}function K(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Bn(n){if(n===void 0&&(n=window),n&&!K(n))try{return n.opener}catch{}}function vn(n){try{return!0}catch{}return!1}function wn(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=K(n);return r&&vn()?wn(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return e+"//"+o}function M(n){n===void 0&&(n=window);var t=wn(n);return t&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:t}function X(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(hn(t)&&vn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),Y(r)==="mock:"}(t)&&vn())return!0}catch{}try{if(wn(t)===wn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||hn(n)&&vn()||M(window)===M(n))return!0}catch{}return!1}function mn(n){if(!X(n))throw new Error("Expected window to be same domain");return n}function Gn(n,t){if(!n||!t)return!1;var e=K(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 Jn(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 He=[],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!==W}if(t&&X(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}(He,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 Zn(n){return n===void 0&&(n=window),Bn(n=n||window)||K(n)||void 0}function en(n,t){if(typeof n=="string"){if(typeof t=="string")return n==="*"||t===n;if(w(t)||Array.isArray(t))return!1}return w(n)?w(t)?n.toString()===t.toString():!Array.isArray(t)&&!!t.match(n):!!Array.isArray(n)&&(Array.isArray(t)?JSON.stringify(n)===JSON.stringify(t):!w(t)&&n.some(function(e){return en(e,t)}))}function pn(n){try{if(n===window)return!0}catch(t){if(t&&t.message===W)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(t){if(t&&t.message===W)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.self===n)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.parent===n)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.top===n)return!0}catch(t){if(t&&t.message===W)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 kn(n){if(X(n))return mn(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 Ge(n){if(function(e){return e===void 0&&(e=window),!!K(e)}(n)){var t=kn(n);if(t&&t.parentElement){t.parentElement.removeChild(t);return}}try{n.close()}catch{}}function _(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 qn=[],tn=[],Pn=0,rn;function Vn(){if(!Pn&&rn){var n=rn;rn=null,n.resolve()}}function On(){Pn+=1}function on(){Pn-=1,Vn()}var b=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;On();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(_(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(_(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(qn.indexOf(i)===-1){qn.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,On();for(var i=function(h,g){return h.then(function(m){g.resolve(m)},function(m){g.reject(m)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,l=s.promise,d=void 0;if(e)try{d=c?c(this.value):this.value}catch(h){l.reject(h);continue}else if(r){if(!u){l.reject(this.error);continue}try{d=u(this.error)}catch(h){l.reject(h);continue}}if(d instanceof n&&(d.resolved||d.rejected)){var f=d;f.resolved?l.resolve(f.value):l.reject(f.error),f.errorHandled=!0}else _(d)?d instanceof n&&(d.resolved||d.rejected)?d.resolved?l.resolve(d.value):l.reject(d.error):i(d,l):l.resolve(d)}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:_(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,l,d){return l.then(function(f){i[u]=f,(o-=1)==0&&r.resolve(i)},function(f){d.reject(f)})},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(!_(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];_(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;On();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)||_(e)},n.flush=function(){return function(e){var r=rn=rn||new e;return Vn(),r}(n)},n}();function gn(n,t){for(var e=0;e<n.length;e++)try{if(n[e]===t)return e}catch{}return-1}var In=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(pn(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!pn(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=gn(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=gn(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=gn(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(),gn(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 k(){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 yn;function Kn(n){try{return JSON.stringify([].slice.call(n),function(t,e){return typeof e=="function"?"memoize["+function(r){if(yn=yn||new In,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=yn.get(r);return o||(o=typeof r+":"+k(),yn.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 Je(){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,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];s<Xn&&(i=null,a=null,s=an,an+=1);var f;f=r?(a=a||new In).getOrSet(this,Je):i=i||{};var h;try{h=Kn(l)}catch{return n.apply(this,arguments)}var g=f[h];if(g&&o&&Date.now()-g.time<o&&(delete f[h],g=null),g)return g.value;var m=Date.now(),p=n.apply(this,arguments);return f[h]={time:m,value:p},p};return c.reset=function(){i=null,a=null},Yn(c,(t.name||$n(n))+"::memoized")}un.clear=function(){Xn=an};function Ze(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]=b.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 Q(){}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 _n(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 Dn(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 ne(){return!!document.body&&document.readyState==="complete"}function ee(){return!!document.body&&document.readyState==="interactive"}un(function(){return new b(function(n){if(ne()||ee())return n();var t=setInterval(function(){if(ne()||ee())return clearInterval(t),n()},10)})});var En=typeof document<"u"?document.currentScript:null,ke=un(function(){if(En||(En=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 En;throw new Error("Can not determine current script")}),qe=k();un(function(){var n;try{n=ke()}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=k();return n.setAttribute("data-uid-auto",t),t});function dn(n){n===void 0&&(n=window);var t="__post_robot_10_0_46__";return n!==window?n[t]:n[t]=n[t]||{}}var te=function(){return{}};function j(n,t){return n===void 0&&(n="store"),t===void 0&&(t=te),sn(dn(),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 Ve=function(){};function Wn(){var n=dn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new Ve,n.WINDOW_WILDCARD}function L(n,t){return n===void 0&&(n="store"),t===void 0&&(t=te),j("windowStore").getOrSet(n,function(){var e=new In,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 re(){return j("instance").getOrSet("instanceID",k)}function oe(n,t){var e=t.domain,r=L("helloPromises"),o=r.get(n);o&&o.resolve({domain:e});var i=b.resolve({domain:e});return r.set(n,i),i}function An(n,t){return(0,t.send)(n,"postrobot_hello",{instanceID:re()},{domain:"*",timeout:-1}).then(function(e){var r=e.origin,o=e.data.instanceID;return oe(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function ie(n,t){var e=t.send;return L("windowInstanceIDPromises").getOrSet(n,function(){return An(n,{send:e}).then(function(r){return r.instanceID})})}function ae(n){L("knownWindows").set(n,!0)}function Rn(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function ue(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 nn(n,t){return{__type__:n,__val__:t}}var U,$e=((U={}).function=function(){},U.error=function(n){return nn("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},U.promise=function(){},U.regex=function(n){return nn("regex",n.source)},U.date=function(n){return nn("date",n.toJSON())},U.array=function(n){return n},U.object=function(n){return n},U.string=function(n){return n},U.number=function(n){return n},U.boolean=function(n){return n},U.null=function(n){return n},U[void 0]=function(n){return nn("undefined",n)},U),Ye={},H,Ke=((H={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},H.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},
|
|
5
|
+
`+o.stack,o},H.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},H.regex=function(n){return new RegExp(n)},H.date=function(n){return new Date(n)},H.array=function(n){return n},H.object=function(n){return n},H.string=function(n){return n},H.number=function(n){return n},H.boolean=function(n){return n},H.null=function(n){return n},H[void 0]=function(){},H),Xe={};new b(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=j("idToProxyWindow"),t=0,e=n.keys();t<e.length;t++){var r=e[t];n.get(r).shouldClean()&&n.del(r)}}function ce(n,t){var e=t.send,r=t.id,o=r===void 0?k():r,i=n.then(function(c){if(X(c))return mn(c).name}),a=n.then(function(c){if(G(c))throw new Error("Window is closed, can not determine type");return Bn(c)?"popup":"iframe"});i.catch(Q),a.catch(Q);var s=function(){return n.then(function(c){if(!G(c))return X(c)?mn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:Ze(function(){return n.then(function(c){return ie(c,{send:e})})}),close:function(){return n.then(Ge)},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(l){var d=window.location.protocol+"//"+window.location.host,f=u.method,h=f===void 0?"get":f,g=u.body;if(c.indexOf("/")===0)c=""+d+c;else if(!c.match(/^https?:\/\//)&&c.indexOf(d)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(c));if(h==="post")return s().then(function(m){if(!m)throw new Error("Can not post to window without target name");(function(p){var x=p.url,N=p.target,O=p.body,P=p.method,z=P===void 0?"post":P,E=document.createElement("form");if(E.setAttribute("target",N),E.setAttribute("method",z),E.setAttribute("action",x),E.style.display="none",O)for(var I=0,J=Object.keys(O);I<J.length;I++){var R,fn=J[I],Tn=document.createElement("input");Tn.setAttribute("name",fn),Tn.setAttribute("value",(R=O[fn])==null?void 0:R.toString()),E.appendChild(Tn)}Qn().appendChild(E),E.submit(),Qn().removeChild(E)})({url:c,target:m,method:h,body:g})});if(h!=="get")throw new Error("Unsupported method: "+h);if(X(l))try{if(l.location&&typeof l.location.replace=="function"){l.location.replace(c);return}}catch{}l.location=c})},setName:function(c){return n.then(function(u){var l=X(u),d=kn(u);if(!l)throw new Error("Can not set name for cross-domain window: "+c);mn(u).name=c,d&&d.setAttribute("name",c),i=b.resolve(c)})}}}var B=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 b,this.serializedWindow=i||ce(this.actualWindowPromise,{send:r}),j("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=b.hash({isPopup:r,name:o}).then(function(s){var c=s.name;s.isPopup&&c&&window.open("",c,"noopener")}),a=this.serializedWindow.focus();return b.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=ce(this.actualWindowPromise,{send:o,id:this.getID()}),L("winToProxyWindow").set(e,this)},t.awaitWindow=function(){return this.actualWindowPromise},t.matchWindow=function(e,r){var o=this,i=r.send;return b.try(function(){return o.actualWindow?e===o.actualWindow:b.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:ie(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(),j("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:o})},n.isProxyWindow=function(e){return!!(e&&!pn(e)&&e.isProxyWindow)},n.toProxyWindow=function(e,r){var o=r.send;if(Nn(),n.isProxyWindow(e))return e;var i=e;return L("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function jn(n,t,e,r,o){var i=L("methodStore"),a=j("proxyWindowMethods");B.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 se(n,t){var e=L("methodStore"),r=j("proxyWindowMethods");return e.getOrSet(n,function(){return{}})[t]||r.get(t)}function de(n,t,e,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,j("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(l){var d=l.source,f=l.origin,h=l.data,g=h.id,m=h.name,p=se(d,g);if(!p)throw new Error("Could not find method '"+m+"' with id: "+h.id+" in "+M(window));var x=p.source,N=p.domain,O=p.val;return b.try(function(){if(!en(N,f))throw new Error("Method '"+h.name+"' domain "+JSON.stringify(Dn(p.domain)?p.domain.source:p.domain)+" does not match origin "+f+" in "+M(window));if(B.isProxyWindow(x))return x.matchWindow(d,{send:s}).then(function(P){if(!P)throw new Error("Method call '"+h.name+"' failed - proxy window does not match source in "+M(window))})}).then(function(){return O.apply({source:d,origin:f},h.args)},function(P){return b.try(function(){if(O.onError)return O.onError(P)}).then(function(){throw P.stack&&(P.stack="Remote call to "+m+"("+function(z){return z===void 0&&(z=[]),(E=z,[].slice.call(E)).map(function(I){return typeof I=="string"?"'"+I+"'":I===void 0?"undefined":I===null?"null":typeof I=="boolean"?I.toString():Array.isArray(I)?"[ ... ]":typeof I=="object"?"{ ... }":typeof I=="function"?"() => { ... }":"<"+typeof I+">"}).join(", ");var E}(h.args)+`) failed
|
|
6
6
|
|
|
7
|
-
`+P.stack),P})}).then(function(P){return{result:P,id:g,name:m}})})});var i,a,s,c=e.__id__||k();n=B.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+"::")),B.isProxyWindow(n)?(jn(c,e,u,n,t),n.awaitWindow().then(function(l){jn(c,e,u,l,t)})):jn(c,e,u,n,t),nn("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=Ye);var u=JSON.stringify(s,function(l){var d=this[l];if(
|
|
7
|
+
`+P.stack),P})}).then(function(P){return{result:P,id:g,name:m}})})});var i,a,s,c=e.__id__||k();n=B.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+"::")),B.isProxyWindow(n)?(jn(c,e,u,n,t),n.awaitWindow().then(function(l){jn(c,e,u,l,t)})):jn(c,e,u,n,t),nn("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=Ye);var u=JSON.stringify(s,function(l){var d=this[l];if(Rn(this))return d;var f=ue(d);if(!f)return d;var h=c[f]||$e[f];return h?h(d,l):d});return u===void 0?"undefined":u}(e,((o={}).promise=function(s,c){return function(u,l,d,f,h){return nn("cross_domain_zalgo_promise",{then:de(u,l,function(g,m){return d.then(g,m)},f,{on:h.on,send:h.send})})}(n,t,s,c,{on:i,send:a})},o.function=function(s,c){return de(n,t,s,c,{on:i,send:a})},o.object=function(s){return pn(s)||B.isProxyWindow(s)?nn("cross_domain_window",B.serialize(s,{send:a})):s},o))}function le(n,t,e,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=Xe),a!=="undefined")return JSON.parse(a,function(c,u){if(Rn(this))return u;var l,d;if(Rn(u)?(l=u.__type__,d=u.__val__):(l=ue(u),d=u),!l)return d;var f=s[l]||Ke[l];return f?f(d,c):d})}(e,((o={}).cross_domain_zalgo_promise=function(a){return function(s,c,u){return new b(u.then)}(0,0,a)},o.cross_domain_function=function(a){return function(s,c,u,l){var d=u.id,f=u.name,h=l.send,g=function(p){p===void 0&&(p={});function x(){var N=arguments;return B.toProxyWindow(s,{send:h}).awaitWindow().then(function(O){var P=se(O,d);if(P&&P.val!==x)return P.val.apply({source:window,origin:M()},N);var z=[].slice.call(N);return p.fireAndForget?h(O,"postrobot_method",{id:d,name:f,args:z},{domain:c,fireAndForget:!0}):h(O,"postrobot_method",{id:d,name:f,args:z},{domain:c,fireAndForget:!1}).then(function(E){return E.data.result})}).catch(function(O){throw O})}return x.__name__=f,x.__origin__=c,x.__source__=s,x.__id__=d,x.origin=c,x},m=g();return m.fireAndForget=g({fireAndForget:!0}),m}(n,t,a,{send:i})},o.cross_domain_window=function(a){return B.deserialize(a,{send:i})},o))}var zn={};zn.postrobot_post_message=function(n,t,e){e.indexOf("file:")===0&&(e="*"),n.postMessage(t,e)};function Cn(n,t,e,r){var o=r.on,i=r.send;return b.try(function(){var a=L().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(e),a.flush=a.flush||b.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(zn),l=[],d=0;d<u.length;d++){var f=u[d];try{zn[f](n,s,t)}catch(h){l.push(h)}}if(l.length===u.length)throw new Error(`All post-robot messaging strategies failed:
|
|
8
8
|
|
|
9
9
|
`+l.map(function(h,g){return g+". "+cn(h)}).join(`
|
|
10
10
|
|
|
11
|
-
`))}),a.flush.then(function(){delete a.flush})}).then(Q)}function he(n){return j("responseListeners").get(n)}function ve(n){j("responseListeners").del(n)}function we(n){return j("erroredResponseListeners").has(n)}function me(n){var t=n.name,e=n.win,r=n.domain,o=L("requestListeners");if(e==="*"&&(e=null),r==="*"&&(r=null),!t)throw new Error("Name required to get request listener");for(var i=0,a=[e,Wn()];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 l=0,d=u.__domain_regex__;l<d.length;l++){var f=d[l],h=f.listener;if(en(f.regex,r))return h}}if(u["*"])return u["*"]}}}}}function _e(n,t,e,r){var o=r.on,i=r.send,a=me({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,l,d){return b.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return
|
|
11
|
+
`))}),a.flush.then(function(){delete a.flush})}).then(Q)}function he(n){return j("responseListeners").get(n)}function ve(n){j("responseListeners").del(n)}function we(n){return j("erroredResponseListeners").has(n)}function me(n){var t=n.name,e=n.win,r=n.domain,o=L("requestListeners");if(e==="*"&&(e=null),r==="*"&&(r=null),!t)throw new Error("Name required to get request listener");for(var i=0,a=[e,Wn()];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 l=0,d=u.__domain_regex__;l<d.length;l++){var f=d[l],h=f.listener;if(en(f.regex,r))return h}}if(u["*"])return u["*"]}}}}}function _e(n,t,e,r){var o=r.on,i=r.send,a=me({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,l,d){return b.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return Cn(n,t,{id:k(),origin:M(window),type:"postrobot_message_response",hash:e.hash,name:e.name,ack:u,data:l,error:d},{on:o,send:i})}catch(f){throw new Error("Send response message failed for "+s+" in "+M()+`
|
|
12
12
|
|
|
13
|
-
`+cn(f))}})}return b.all([b.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return
|
|
13
|
+
`+cn(f))}})}return b.all([b.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return Cn(n,t,{id:k(),origin:M(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 "+M()+`
|
|
14
14
|
|
|
15
|
-
`+cn(u))}}),b.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(Q).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function Qe(n,t,e){if(!we(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(!en(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 nt(n,t,e){if(!we(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(!en(r.domain,t))throw new Error("Response origin "+t+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":w(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");ve(e.hash),e.ack==="error"?r.promise.reject(e.error):e.ack==="success"&&r.promise.resolve({source:n,origin:t,data:e.data})}}function pe(n,t){var e=t.on,r=t.send,o=j("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(l,d,f,h){var g=h.on,m=h.send,p;try{p=le(d,f,l,{on:g,send:m})}catch{return}if(p&&typeof p=="object"&&p!==null){var x=p.__post_robot_10_0_46__;if(Array.isArray(x))return x}}(n.data,i,a,{on:e,send:r});if(s){ae(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"?_e(i,a,u,{on:e,send:r}):u.type==="postrobot_message_response"?nt(i,a,u):u.type==="postrobot_message_ack"&&Qe(i,a,u)}catch(l){setTimeout(function(){throw l},0)}}}}function
|
|
15
|
+
`+cn(u))}}),b.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(Q).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function Qe(n,t,e){if(!we(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(!en(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 nt(n,t,e){if(!we(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(!en(r.domain,t))throw new Error("Response origin "+t+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":w(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");ve(e.hash),e.ack==="error"?r.promise.reject(e.error):e.ack==="success"&&r.promise.resolve({source:n,origin:t,data:e.data})}}function pe(n,t){var e=t.on,r=t.send,o=j("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(l,d,f,h){var g=h.on,m=h.send,p;try{p=le(d,f,l,{on:g,send:m})}catch{return}if(p&&typeof p=="object"&&p!==null){var x=p.__post_robot_10_0_46__;if(Array.isArray(x))return x}}(n.data,i,a,{on:e,send:r});if(s){ae(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"?_e(i,a,u,{on:e,send:r}):u.type==="postrobot_message_response"?nt(i,a,u):u.type==="postrobot_message_ack"&&Qe(i,a,u)}catch(l){setTimeout(function(){throw l},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,l=L("requestListeners");if(!s||typeof s!="string")throw new Error("Name required to add request listener");if(c&&c!=="*"&&B.isProxyWindow(c)){var d=c.awaitWindow().then(function(R){return o({name:s,win:R,domain:u},a)});return{cancel:function(){d.then(function(R){return R.cancel()},Q)}}}var f=c;if(Array.isArray(f)){for(var h=[],g=0,m=f;g<m.length;g++)h.push(o({name:s,domain:u,win:m[g]},a));return{cancel:function(){for(var R=0;R<h.length;R++)h[R].cancel()}}}if(Array.isArray(u)){for(var p=[],x=0,N=u;x<N.length;x++)p.push(o({name:s,win:f,domain:N[x]},a));return{cancel:function(){for(var R=0;R<p.length;R++)p[R].cancel()}}}var O=me({name:s,win:f,domain:u});f&&f!=="*"||(f=Wn());var P=(u=u||"*").toString();if(O)throw f&&u?new Error("Request listener already exists for "+s+" on domain "+u.toString()+" for "+(f===Wn()?"wildcard":"specified")+" window"):f?new Error("Request listener already exists for "+s+" for "+(f===Wn()?"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 z=l.getOrSet(f,function(){return{}}),E=sn(z,s,function(){return{}}),I,J;return Dn(u)?(I=sn(E,"__domain_regex__",function(){return[]})).push(J={regex:u,listener:a}):E[P]=a,{cancel:function(){delete E[P],J&&(I.splice(I.indexOf(J,1)),I.length||delete E.__domain_regex__),Object.keys(E).length||delete z[s],f&&!Object.keys(z).length&&l.del(f)}}}({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 et(n,t,e){typeof(t=t||{})=="function"&&(e=t,t={});var r=new b,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 B.toProxyWindow(t,{send:n}).awaitWindow().then(function(u){return b.try(function(){if(function(l,d,f){if(!l)throw new Error("Expected name");if(f&&typeof f!="string"&&!Array.isArray(f)&&!Dn(f))throw new TypeError("Can not send "+l+". Expected domain "+JSON.stringify(f)+" to be a string, array, or regex");if(G(d))throw new Error("Can not send "+l+". Target window is closed")}(e,u,i),function(l,d){var f=Zn(d);if(f)return f===l;if(d===l||function(m){m===void 0&&(m=window);try{if(m.top)return m.top}catch{}if(K(m)===m)return m;try{if(Gn(window,m)&&window.top)return window.top}catch{}try{if(Gn(m,window)&&window.top)return window.top}catch{}for(var p=0,x=function O(P){for(var z=[],E=0,I=Jn(P);E<I.length;E++){var J=I[E];z.push(J);for(var R=0,fn=O(J);R<fn.length;R++)z.push(fn[R])}return z}(m);p<x.length;p++){var N=x[p];try{if(N.top)return N.top}catch{}if(K(N)===N)return N}}(d)===d)return!1;for(var h=0,g=Jn(l);h<g.length;h++)if(g[h]===d)return!0;return!1}(window,u))return function(l,d,f){d===void 0&&(d=5e3),f===void 0&&(f="Window");var h=function(g){return L("helloPromises").getOrSet(g,function(){return new b})}(l);return d!==-1&&(h=h.timeout(d,new Error(f+" did not load after "+d+"ms"))),h}(u,s)}).then(function(l){return function(d,f,h,g){var m=g.send;return b.try(function(){return typeof f=="string"?f:b.try(function(){return h||An(d,{send:m}).then(function(p){return p.domain})}).then(function(p){if(!en(f,f))throw new Error("Domain "+_n(f)+" does not match "+_n(f));return p})})}(u,i,(l===void 0?{}:l).domain,{send:n})}).then(function(l){var d=l,f=e==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":e,h=new b,g=e+"_"+k();if(!c){var m={name:e,win:u,domain:d,promise:h};(function(E,I){j("responseListeners").set(E,I)})(g,m);var p=L("requestPromises").getOrSet(u,function(){return[]});p.push(h),h.catch(function(){(function(E){j("erroredResponseListeners").set(E,!0)})(g),ve(g)});var x=function(E){return L("knownWindows").get(E,!1)}(u)?1e4:2e3,N=a,O=x,P=N,z=function(E,I){var J;return function R(){J=setTimeout(function(){(function(){if(G(u))return h.reject(new Error("Window closed for "+e+" before "+(m.ack?"response":"ack")));if(m.cancelled)return h.reject(new Error("Response listener was cancelled for "+e));O=Math.max(O-500,0),P!==-1&&(P=Math.max(P-500,0)),m.ack||O!==0?P===0&&h.reject(new Error("No response for postMessage "+f+" in "+M()+" in "+N+"ms")):h.reject(new Error("No ack for postMessage "+f+" in "+M()+" in "+x+"ms"))})(),R()},500)}(),{cancel:function(){clearTimeout(J)}}}();h.finally(function(){z.cancel(),p.splice(p.indexOf(h,1))}).catch(Q)}return Cn(u,d,{id:k(),origin:M(window),type:"postrobot_message_request",hash:g,name:e,data:r,fireAndForget:c},{on:V,send:n}).then(function(){return c?h.resolve():h},function(E){throw new Error("Send request message failed for "+f+" in "+M()+`
|
|
16
16
|
|
|
17
|
-
`+cn(E))})})})};function tt(n,t,e){return fe(n,t,e,{on
|
|
17
|
+
`+cn(E))})})})};function tt(n,t,e){return fe(n,t,e,{on:V,send:$})}function rt(n,t,e){return le(n,t,e,{on:V,send:$})}function ot(n){return new B({send:$,win:n})}function it(n){return B.toProxyWindow(n,{send:$})}function ge(){dn().initialized||(dn().initialized=!0,t=(n={on:V,send:$}).on,e=n.send,(r=dn()).receiveMessage=r.receiveMessage||function(o){return pe(o,{on:t,send:e})},function(o){var i=o.on,a=o.send;j().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 l=u.on,d=u.send;b.try(function(){var f=c.source||c.sourceElement,h=c.origin||c.originalEvent&&c.originalEvent.origin,g=c.data;if(h==="null"&&(h="file://"),f){if(!h)throw new Error("Post message did not have origin domain");pe({source:f,origin:h,data:g},{on:l,send:d})}})})(s,{on:i,send:a})})})}({on:V,send:$}),function(o){var i=o.on,a=o.send;j("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return oe(u.source,{domain:u.origin}),{instanceID:re()}}),c=Zn();return c&&An(c,{send:a}).catch(function(u){}),s})}({on:V,send:$}));var n,t,e,r}function at(){(function(){for(var t=j("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=j().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var ut=!0;function ct(n){for(var t=0,e=L("requestPromises").get(n,[]);t<e.length;t++)e[t].reject(new Error("Window "+(G(n)?"closed":"cleaned up")+" before response")).catch(Q)}ge()}])})})(Un);var Fe=Un.exports;(function(S){S.exports=Fe,S.exports.default=S.exports})(Fn);var Hn=Fn.exports;const Ue=A({__proto__:null,default:Le(Hn)},[Hn]);D.SoyioTypes=Te,D.SoyioWidget=Ln,D.default=Ln,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|