@everymatrix/user-action-controller 1.22.2 → 1.22.10
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/cjs/loader.cjs.js +1 -1
- package/dist/cjs/player-legislation-wrapper_3.cjs.entry.js +73 -40
- package/dist/cjs/user-action-controller.cjs.js +1 -1
- package/dist/collection/components/user-action-controller/user-action-controller.js +99 -41
- package/dist/components/user-action-controller.js +77 -42
- package/dist/esm/loader.js +1 -1
- package/dist/esm/player-legislation-wrapper_3.entry.js +73 -40
- package/dist/esm/user-action-controller.js +1 -1
- package/dist/types/components/user-action-controller/user-action-controller.d.ts +6 -0
- package/dist/types/components.d.ts +8 -0
- package/dist/user-action-controller/p-ecc1c1e4.entry.js +1 -0
- package/dist/user-action-controller/user-action-controller.esm.js +1 -1
- package/package.json +1 -1
- package/dist/user-action-controller/p-9b3c5ed7.entry.js +0 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["player-legislation-wrapper_3.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["player-legislation-wrapper_3.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"gmVersion":[1,"gm-version"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"hasToSetConsents":[32]},[[0,"hasToSetConsents","hasToSetConsentsHandler"],[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -132,6 +132,10 @@ const UserActionController = class {
|
|
|
132
132
|
* Event name to be sent when the button is clicked
|
|
133
133
|
*/
|
|
134
134
|
this.postMessageEvent = 'closeButtonClicked';
|
|
135
|
+
/**
|
|
136
|
+
* Select GM version
|
|
137
|
+
*/
|
|
138
|
+
this.gmVersion = '';
|
|
135
139
|
/**
|
|
136
140
|
* Client custom styling via inline style
|
|
137
141
|
*/
|
|
@@ -177,14 +181,30 @@ const UserActionController = class {
|
|
|
177
181
|
};
|
|
178
182
|
}
|
|
179
183
|
determineMandatoryActions() {
|
|
180
|
-
let url
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
let url;
|
|
185
|
+
let requestOptions;
|
|
186
|
+
url = this.gmVersion === 'gmcore' ? new URL(`${this.endpoint}v1/player/consentRequirements`) : new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consents`);
|
|
187
|
+
requestOptions = {
|
|
188
|
+
method: 'GET',
|
|
189
|
+
headers: {
|
|
190
|
+
'X-SessionId': `${this.userSession}`,
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
if (url && requestOptions) {
|
|
194
|
+
return fetch(url.href, requestOptions)
|
|
195
|
+
.then(res => res.json())
|
|
196
|
+
.then(data => {
|
|
197
|
+
const selectGmVersion = this.gmVersion === 'gmcore' ? data.consents || [] : data.items || [];
|
|
198
|
+
selectGmVersion.forEach(action => action.mustAccept && this.mandatoryActions.push(action.tagCode));
|
|
199
|
+
})
|
|
200
|
+
.catch(error => {
|
|
201
|
+
console.error('Error fetching data:', error);
|
|
186
202
|
});
|
|
187
|
-
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// Handle the case where 'url' is not defined
|
|
206
|
+
return Promise.reject('Unsupported endpoint');
|
|
207
|
+
}
|
|
188
208
|
}
|
|
189
209
|
handleQueryResponse() {
|
|
190
210
|
if (this.receivedQueryResponses === this.expectedQueryResponses) {
|
|
@@ -192,43 +212,53 @@ const UserActionController = class {
|
|
|
192
212
|
}
|
|
193
213
|
}
|
|
194
214
|
updateUserConsents() {
|
|
195
|
-
|
|
196
|
-
let
|
|
215
|
+
let url;
|
|
216
|
+
let requestOptions;
|
|
217
|
+
url = (this.gmVersion === 'gmcore')
|
|
218
|
+
? new URL(`${this.endpoint}v1/player/${this.userId}/consent`)
|
|
219
|
+
: new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consent`);
|
|
220
|
+
const body = {
|
|
197
221
|
items: this.userActions
|
|
198
222
|
};
|
|
199
|
-
|
|
223
|
+
requestOptions = {
|
|
200
224
|
method: 'POST',
|
|
201
|
-
headers:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
headers: (this.gmVersion === 'gmcore')
|
|
226
|
+
? {
|
|
227
|
+
'Content-Type': 'application/json',
|
|
228
|
+
'Accept': 'application/json',
|
|
229
|
+
'X-SessionId': `${this.userSession}`,
|
|
230
|
+
}
|
|
231
|
+
: {
|
|
232
|
+
'X-SessionId': `${this.userSession}`,
|
|
233
|
+
},
|
|
206
234
|
body: JSON.stringify(body)
|
|
207
235
|
};
|
|
208
|
-
|
|
209
|
-
.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
236
|
+
if (url && requestOptions) {
|
|
237
|
+
fetch(url.href, requestOptions)
|
|
238
|
+
.then(res => res.json())
|
|
239
|
+
.then(() => {
|
|
240
|
+
window.postMessage({
|
|
241
|
+
type: 'WidgetNotification',
|
|
242
|
+
data: {
|
|
243
|
+
type: 'success',
|
|
244
|
+
message: 'Consent update successful!'
|
|
245
|
+
}
|
|
246
|
+
}, window.location.href);
|
|
247
|
+
})
|
|
248
|
+
.catch((err) => {
|
|
249
|
+
window.postMessage({
|
|
250
|
+
type: 'WidgetNotification',
|
|
251
|
+
data: {
|
|
252
|
+
type: 'error',
|
|
253
|
+
message: 'Server might not be responding',
|
|
254
|
+
err
|
|
255
|
+
}
|
|
256
|
+
}, window.location.href);
|
|
257
|
+
})
|
|
258
|
+
.finally(() => {
|
|
259
|
+
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
232
262
|
}
|
|
233
263
|
handleApplyClick() {
|
|
234
264
|
this.queryFired = true;
|
|
@@ -239,6 +269,9 @@ const UserActionController = class {
|
|
|
239
269
|
}
|
|
240
270
|
this.closeButtonEvent.emit();
|
|
241
271
|
}
|
|
272
|
+
hasToSetConsentsHandler(_) {
|
|
273
|
+
this.hasToSetConsents = true;
|
|
274
|
+
}
|
|
242
275
|
userLegislationConsentHandler(event) {
|
|
243
276
|
// Increase / Decrease the amount of mandatory actions taken
|
|
244
277
|
if (this.mandatoryActions.includes(event.detail.type)) {
|
|
@@ -269,7 +302,7 @@ const UserActionController = class {
|
|
|
269
302
|
// end custom styling area
|
|
270
303
|
}
|
|
271
304
|
render() {
|
|
272
|
-
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
305
|
+
const activeUAList = this.hasToSetConsents ? ['termsandconditions'] : this.activeUserActions.replace(/ /g, '').split(',');
|
|
273
306
|
this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
|
|
274
307
|
this.expectedQueryResponses = activeUAList.length;
|
|
275
308
|
return (index.h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, index.h("div", { class: "UserActionController" }, this.showCloseButton &&
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["player-legislation-wrapper_3.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
18
|
+
return index.bootstrapLazy([["player-legislation-wrapper_3.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"gmVersion":[1,"gm-version"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"hasToSetConsents":[32]},[[0,"hasToSetConsents","hasToSetConsentsHandler"],[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -7,6 +7,10 @@ export class UserActionController {
|
|
|
7
7
|
* Event name to be sent when the button is clicked
|
|
8
8
|
*/
|
|
9
9
|
this.postMessageEvent = 'closeButtonClicked';
|
|
10
|
+
/**
|
|
11
|
+
* Select GM version
|
|
12
|
+
*/
|
|
13
|
+
this.gmVersion = '';
|
|
10
14
|
/**
|
|
11
15
|
* Client custom styling via inline style
|
|
12
16
|
*/
|
|
@@ -52,14 +56,30 @@ export class UserActionController {
|
|
|
52
56
|
};
|
|
53
57
|
}
|
|
54
58
|
determineMandatoryActions() {
|
|
55
|
-
let url
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
let url;
|
|
60
|
+
let requestOptions;
|
|
61
|
+
url = this.gmVersion === 'gmcore' ? new URL(`${this.endpoint}v1/player/consentRequirements`) : new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consents`);
|
|
62
|
+
requestOptions = {
|
|
63
|
+
method: 'GET',
|
|
64
|
+
headers: {
|
|
65
|
+
'X-SessionId': `${this.userSession}`,
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
if (url && requestOptions) {
|
|
69
|
+
return fetch(url.href, requestOptions)
|
|
70
|
+
.then(res => res.json())
|
|
71
|
+
.then(data => {
|
|
72
|
+
const selectGmVersion = this.gmVersion === 'gmcore' ? data.consents || [] : data.items || [];
|
|
73
|
+
selectGmVersion.forEach(action => action.mustAccept && this.mandatoryActions.push(action.tagCode));
|
|
74
|
+
})
|
|
75
|
+
.catch(error => {
|
|
76
|
+
console.error('Error fetching data:', error);
|
|
61
77
|
});
|
|
62
|
-
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Handle the case where 'url' is not defined
|
|
81
|
+
return Promise.reject('Unsupported endpoint');
|
|
82
|
+
}
|
|
63
83
|
}
|
|
64
84
|
handleQueryResponse() {
|
|
65
85
|
if (this.receivedQueryResponses === this.expectedQueryResponses) {
|
|
@@ -67,43 +87,53 @@ export class UserActionController {
|
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
updateUserConsents() {
|
|
70
|
-
|
|
71
|
-
let
|
|
90
|
+
let url;
|
|
91
|
+
let requestOptions;
|
|
92
|
+
url = (this.gmVersion === 'gmcore')
|
|
93
|
+
? new URL(`${this.endpoint}v1/player/${this.userId}/consent`)
|
|
94
|
+
: new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consent`);
|
|
95
|
+
const body = {
|
|
72
96
|
items: this.userActions
|
|
73
97
|
};
|
|
74
|
-
|
|
98
|
+
requestOptions = {
|
|
75
99
|
method: 'POST',
|
|
76
|
-
headers:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
headers: (this.gmVersion === 'gmcore')
|
|
101
|
+
? {
|
|
102
|
+
'Content-Type': 'application/json',
|
|
103
|
+
'Accept': 'application/json',
|
|
104
|
+
'X-SessionId': `${this.userSession}`,
|
|
105
|
+
}
|
|
106
|
+
: {
|
|
107
|
+
'X-SessionId': `${this.userSession}`,
|
|
108
|
+
},
|
|
81
109
|
body: JSON.stringify(body)
|
|
82
110
|
};
|
|
83
|
-
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
if (url && requestOptions) {
|
|
112
|
+
fetch(url.href, requestOptions)
|
|
113
|
+
.then(res => res.json())
|
|
114
|
+
.then(() => {
|
|
115
|
+
window.postMessage({
|
|
116
|
+
type: 'WidgetNotification',
|
|
117
|
+
data: {
|
|
118
|
+
type: 'success',
|
|
119
|
+
message: 'Consent update successful!'
|
|
120
|
+
}
|
|
121
|
+
}, window.location.href);
|
|
122
|
+
})
|
|
123
|
+
.catch((err) => {
|
|
124
|
+
window.postMessage({
|
|
125
|
+
type: 'WidgetNotification',
|
|
126
|
+
data: {
|
|
127
|
+
type: 'error',
|
|
128
|
+
message: 'Server might not be responding',
|
|
129
|
+
err
|
|
130
|
+
}
|
|
131
|
+
}, window.location.href);
|
|
132
|
+
})
|
|
133
|
+
.finally(() => {
|
|
134
|
+
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
107
137
|
}
|
|
108
138
|
handleApplyClick() {
|
|
109
139
|
this.queryFired = true;
|
|
@@ -114,6 +144,9 @@ export class UserActionController {
|
|
|
114
144
|
}
|
|
115
145
|
this.closeButtonEvent.emit();
|
|
116
146
|
}
|
|
147
|
+
hasToSetConsentsHandler(_) {
|
|
148
|
+
this.hasToSetConsents = true;
|
|
149
|
+
}
|
|
117
150
|
userLegislationConsentHandler(event) {
|
|
118
151
|
// Increase / Decrease the amount of mandatory actions taken
|
|
119
152
|
if (this.mandatoryActions.includes(event.detail.type)) {
|
|
@@ -144,7 +177,7 @@ export class UserActionController {
|
|
|
144
177
|
// end custom styling area
|
|
145
178
|
}
|
|
146
179
|
render() {
|
|
147
|
-
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
180
|
+
const activeUAList = this.hasToSetConsents ? ['termsandconditions'] : this.activeUserActions.replace(/ /g, '').split(',');
|
|
148
181
|
this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
|
|
149
182
|
this.expectedQueryResponses = activeUAList.length;
|
|
150
183
|
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el },
|
|
@@ -338,6 +371,24 @@ export class UserActionController {
|
|
|
338
371
|
"reflect": false,
|
|
339
372
|
"defaultValue": "'closeButtonClicked'"
|
|
340
373
|
},
|
|
374
|
+
"gmVersion": {
|
|
375
|
+
"type": "string",
|
|
376
|
+
"mutable": false,
|
|
377
|
+
"complexType": {
|
|
378
|
+
"original": "string",
|
|
379
|
+
"resolved": "string",
|
|
380
|
+
"references": {}
|
|
381
|
+
},
|
|
382
|
+
"required": false,
|
|
383
|
+
"optional": false,
|
|
384
|
+
"docs": {
|
|
385
|
+
"tags": [],
|
|
386
|
+
"text": "Select GM version"
|
|
387
|
+
},
|
|
388
|
+
"attribute": "gm-version",
|
|
389
|
+
"reflect": false,
|
|
390
|
+
"defaultValue": "''"
|
|
391
|
+
},
|
|
341
392
|
"clientStyling": {
|
|
342
393
|
"type": "string",
|
|
343
394
|
"mutable": true,
|
|
@@ -379,7 +430,8 @@ export class UserActionController {
|
|
|
379
430
|
"queryFired": {},
|
|
380
431
|
"readyActionsCount": {},
|
|
381
432
|
"receivedQueryResponses": {},
|
|
382
|
-
"limitStylingAppends": {}
|
|
433
|
+
"limitStylingAppends": {},
|
|
434
|
+
"hasToSetConsents": {}
|
|
383
435
|
}; }
|
|
384
436
|
static get events() { return [{
|
|
385
437
|
"method": "closeButtonEvent",
|
|
@@ -402,6 +454,12 @@ export class UserActionController {
|
|
|
402
454
|
"methodName": "handleQueryResponse"
|
|
403
455
|
}]; }
|
|
404
456
|
static get listeners() { return [{
|
|
457
|
+
"name": "hasToSetConsents",
|
|
458
|
+
"method": "hasToSetConsentsHandler",
|
|
459
|
+
"target": undefined,
|
|
460
|
+
"capture": false,
|
|
461
|
+
"passive": false
|
|
462
|
+
}, {
|
|
405
463
|
"name": "userLegislationConsent",
|
|
406
464
|
"method": "userLegislationConsentHandler",
|
|
407
465
|
"target": undefined,
|
|
@@ -14,6 +14,10 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
14
14
|
* Event name to be sent when the button is clicked
|
|
15
15
|
*/
|
|
16
16
|
this.postMessageEvent = 'closeButtonClicked';
|
|
17
|
+
/**
|
|
18
|
+
* Select GM version
|
|
19
|
+
*/
|
|
20
|
+
this.gmVersion = '';
|
|
17
21
|
/**
|
|
18
22
|
* Client custom styling via inline style
|
|
19
23
|
*/
|
|
@@ -59,14 +63,30 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
59
63
|
};
|
|
60
64
|
}
|
|
61
65
|
determineMandatoryActions() {
|
|
62
|
-
let url
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
let url;
|
|
67
|
+
let requestOptions;
|
|
68
|
+
url = this.gmVersion === 'gmcore' ? new URL(`${this.endpoint}v1/player/consentRequirements`) : new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consents`);
|
|
69
|
+
requestOptions = {
|
|
70
|
+
method: 'GET',
|
|
71
|
+
headers: {
|
|
72
|
+
'X-SessionId': `${this.userSession}`,
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
if (url && requestOptions) {
|
|
76
|
+
return fetch(url.href, requestOptions)
|
|
77
|
+
.then(res => res.json())
|
|
78
|
+
.then(data => {
|
|
79
|
+
const selectGmVersion = this.gmVersion === 'gmcore' ? data.consents || [] : data.items || [];
|
|
80
|
+
selectGmVersion.forEach(action => action.mustAccept && this.mandatoryActions.push(action.tagCode));
|
|
81
|
+
})
|
|
82
|
+
.catch(error => {
|
|
83
|
+
console.error('Error fetching data:', error);
|
|
68
84
|
});
|
|
69
|
-
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Handle the case where 'url' is not defined
|
|
88
|
+
return Promise.reject('Unsupported endpoint');
|
|
89
|
+
}
|
|
70
90
|
}
|
|
71
91
|
handleQueryResponse() {
|
|
72
92
|
if (this.receivedQueryResponses === this.expectedQueryResponses) {
|
|
@@ -74,43 +94,53 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
74
94
|
}
|
|
75
95
|
}
|
|
76
96
|
updateUserConsents() {
|
|
77
|
-
|
|
78
|
-
let
|
|
97
|
+
let url;
|
|
98
|
+
let requestOptions;
|
|
99
|
+
url = (this.gmVersion === 'gmcore')
|
|
100
|
+
? new URL(`${this.endpoint}v1/player/${this.userId}/consent`)
|
|
101
|
+
: new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consent`);
|
|
102
|
+
const body = {
|
|
79
103
|
items: this.userActions
|
|
80
104
|
};
|
|
81
|
-
|
|
105
|
+
requestOptions = {
|
|
82
106
|
method: 'POST',
|
|
83
|
-
headers:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
headers: (this.gmVersion === 'gmcore')
|
|
108
|
+
? {
|
|
109
|
+
'Content-Type': 'application/json',
|
|
110
|
+
'Accept': 'application/json',
|
|
111
|
+
'X-SessionId': `${this.userSession}`,
|
|
112
|
+
}
|
|
113
|
+
: {
|
|
114
|
+
'X-SessionId': `${this.userSession}`,
|
|
115
|
+
},
|
|
88
116
|
body: JSON.stringify(body)
|
|
89
117
|
};
|
|
90
|
-
|
|
91
|
-
.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
if (url && requestOptions) {
|
|
119
|
+
fetch(url.href, requestOptions)
|
|
120
|
+
.then(res => res.json())
|
|
121
|
+
.then(() => {
|
|
122
|
+
window.postMessage({
|
|
123
|
+
type: 'WidgetNotification',
|
|
124
|
+
data: {
|
|
125
|
+
type: 'success',
|
|
126
|
+
message: 'Consent update successful!'
|
|
127
|
+
}
|
|
128
|
+
}, window.location.href);
|
|
129
|
+
})
|
|
130
|
+
.catch((err) => {
|
|
131
|
+
window.postMessage({
|
|
132
|
+
type: 'WidgetNotification',
|
|
133
|
+
data: {
|
|
134
|
+
type: 'error',
|
|
135
|
+
message: 'Server might not be responding',
|
|
136
|
+
err
|
|
137
|
+
}
|
|
138
|
+
}, window.location.href);
|
|
139
|
+
})
|
|
140
|
+
.finally(() => {
|
|
141
|
+
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
114
144
|
}
|
|
115
145
|
handleApplyClick() {
|
|
116
146
|
this.queryFired = true;
|
|
@@ -121,6 +151,9 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
121
151
|
}
|
|
122
152
|
this.closeButtonEvent.emit();
|
|
123
153
|
}
|
|
154
|
+
hasToSetConsentsHandler(_) {
|
|
155
|
+
this.hasToSetConsents = true;
|
|
156
|
+
}
|
|
124
157
|
userLegislationConsentHandler(event) {
|
|
125
158
|
// Increase / Decrease the amount of mandatory actions taken
|
|
126
159
|
if (this.mandatoryActions.includes(event.detail.type)) {
|
|
@@ -151,7 +184,7 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
151
184
|
// end custom styling area
|
|
152
185
|
}
|
|
153
186
|
render() {
|
|
154
|
-
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
187
|
+
const activeUAList = this.hasToSetConsents ? ['termsandconditions'] : this.activeUserActions.replace(/ /g, '').split(',');
|
|
155
188
|
this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
|
|
156
189
|
this.expectedQueryResponses = activeUAList.length;
|
|
157
190
|
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, h("div", { class: "UserActionController" }, this.showCloseButton &&
|
|
@@ -173,13 +206,15 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
173
206
|
"showCloseButton": [516, "show-close-button"],
|
|
174
207
|
"usePostmessage": [516, "use-postmessage"],
|
|
175
208
|
"postMessageEvent": [1, "post-message-event"],
|
|
209
|
+
"gmVersion": [1, "gm-version"],
|
|
176
210
|
"clientStyling": [1537, "client-styling"],
|
|
177
211
|
"clientStylingUrl": [513, "client-styling-url"],
|
|
178
212
|
"queryFired": [32],
|
|
179
213
|
"readyActionsCount": [32],
|
|
180
214
|
"receivedQueryResponses": [32],
|
|
181
|
-
"limitStylingAppends": [32]
|
|
182
|
-
|
|
215
|
+
"limitStylingAppends": [32],
|
|
216
|
+
"hasToSetConsents": [32]
|
|
217
|
+
}, [[0, "hasToSetConsents", "hasToSetConsentsHandler"], [0, "userLegislationConsent", "userLegislationConsentHandler"]]]);
|
|
183
218
|
function defineCustomElement$1() {
|
|
184
219
|
if (typeof customElements === "undefined") {
|
|
185
220
|
return;
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["player-legislation-wrapper_3",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
13
|
+
return bootstrapLazy([["player-legislation-wrapper_3",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"gmVersion":[1,"gm-version"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"hasToSetConsents":[32]},[[0,"hasToSetConsents","hasToSetConsentsHandler"],[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -128,6 +128,10 @@ const UserActionController = class {
|
|
|
128
128
|
* Event name to be sent when the button is clicked
|
|
129
129
|
*/
|
|
130
130
|
this.postMessageEvent = 'closeButtonClicked';
|
|
131
|
+
/**
|
|
132
|
+
* Select GM version
|
|
133
|
+
*/
|
|
134
|
+
this.gmVersion = '';
|
|
131
135
|
/**
|
|
132
136
|
* Client custom styling via inline style
|
|
133
137
|
*/
|
|
@@ -173,14 +177,30 @@ const UserActionController = class {
|
|
|
173
177
|
};
|
|
174
178
|
}
|
|
175
179
|
determineMandatoryActions() {
|
|
176
|
-
let url
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
let url;
|
|
181
|
+
let requestOptions;
|
|
182
|
+
url = this.gmVersion === 'gmcore' ? new URL(`${this.endpoint}v1/player/consentRequirements`) : new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consents`);
|
|
183
|
+
requestOptions = {
|
|
184
|
+
method: 'GET',
|
|
185
|
+
headers: {
|
|
186
|
+
'X-SessionId': `${this.userSession}`,
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
if (url && requestOptions) {
|
|
190
|
+
return fetch(url.href, requestOptions)
|
|
191
|
+
.then(res => res.json())
|
|
192
|
+
.then(data => {
|
|
193
|
+
const selectGmVersion = this.gmVersion === 'gmcore' ? data.consents || [] : data.items || [];
|
|
194
|
+
selectGmVersion.forEach(action => action.mustAccept && this.mandatoryActions.push(action.tagCode));
|
|
195
|
+
})
|
|
196
|
+
.catch(error => {
|
|
197
|
+
console.error('Error fetching data:', error);
|
|
182
198
|
});
|
|
183
|
-
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
// Handle the case where 'url' is not defined
|
|
202
|
+
return Promise.reject('Unsupported endpoint');
|
|
203
|
+
}
|
|
184
204
|
}
|
|
185
205
|
handleQueryResponse() {
|
|
186
206
|
if (this.receivedQueryResponses === this.expectedQueryResponses) {
|
|
@@ -188,43 +208,53 @@ const UserActionController = class {
|
|
|
188
208
|
}
|
|
189
209
|
}
|
|
190
210
|
updateUserConsents() {
|
|
191
|
-
|
|
192
|
-
let
|
|
211
|
+
let url;
|
|
212
|
+
let requestOptions;
|
|
213
|
+
url = (this.gmVersion === 'gmcore')
|
|
214
|
+
? new URL(`${this.endpoint}v1/player/${this.userId}/consent`)
|
|
215
|
+
: new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consent`);
|
|
216
|
+
const body = {
|
|
193
217
|
items: this.userActions
|
|
194
218
|
};
|
|
195
|
-
|
|
219
|
+
requestOptions = {
|
|
196
220
|
method: 'POST',
|
|
197
|
-
headers:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
221
|
+
headers: (this.gmVersion === 'gmcore')
|
|
222
|
+
? {
|
|
223
|
+
'Content-Type': 'application/json',
|
|
224
|
+
'Accept': 'application/json',
|
|
225
|
+
'X-SessionId': `${this.userSession}`,
|
|
226
|
+
}
|
|
227
|
+
: {
|
|
228
|
+
'X-SessionId': `${this.userSession}`,
|
|
229
|
+
},
|
|
202
230
|
body: JSON.stringify(body)
|
|
203
231
|
};
|
|
204
|
-
|
|
205
|
-
.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
232
|
+
if (url && requestOptions) {
|
|
233
|
+
fetch(url.href, requestOptions)
|
|
234
|
+
.then(res => res.json())
|
|
235
|
+
.then(() => {
|
|
236
|
+
window.postMessage({
|
|
237
|
+
type: 'WidgetNotification',
|
|
238
|
+
data: {
|
|
239
|
+
type: 'success',
|
|
240
|
+
message: 'Consent update successful!'
|
|
241
|
+
}
|
|
242
|
+
}, window.location.href);
|
|
243
|
+
})
|
|
244
|
+
.catch((err) => {
|
|
245
|
+
window.postMessage({
|
|
246
|
+
type: 'WidgetNotification',
|
|
247
|
+
data: {
|
|
248
|
+
type: 'error',
|
|
249
|
+
message: 'Server might not be responding',
|
|
250
|
+
err
|
|
251
|
+
}
|
|
252
|
+
}, window.location.href);
|
|
253
|
+
})
|
|
254
|
+
.finally(() => {
|
|
255
|
+
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
228
258
|
}
|
|
229
259
|
handleApplyClick() {
|
|
230
260
|
this.queryFired = true;
|
|
@@ -235,6 +265,9 @@ const UserActionController = class {
|
|
|
235
265
|
}
|
|
236
266
|
this.closeButtonEvent.emit();
|
|
237
267
|
}
|
|
268
|
+
hasToSetConsentsHandler(_) {
|
|
269
|
+
this.hasToSetConsents = true;
|
|
270
|
+
}
|
|
238
271
|
userLegislationConsentHandler(event) {
|
|
239
272
|
// Increase / Decrease the amount of mandatory actions taken
|
|
240
273
|
if (this.mandatoryActions.includes(event.detail.type)) {
|
|
@@ -265,7 +298,7 @@ const UserActionController = class {
|
|
|
265
298
|
// end custom styling area
|
|
266
299
|
}
|
|
267
300
|
render() {
|
|
268
|
-
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
301
|
+
const activeUAList = this.hasToSetConsents ? ['termsandconditions'] : this.activeUserActions.replace(/ /g, '').split(',');
|
|
269
302
|
this.requiredActionsCount = activeUAList.filter(action => this.mandatoryActions.includes(action)).length;
|
|
270
303
|
this.expectedQueryResponses = activeUAList.length;
|
|
271
304
|
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, h("div", { class: "UserActionController" }, this.showCloseButton &&
|
|
@@ -13,5 +13,5 @@ const patchBrowser = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
patchBrowser().then(options => {
|
|
16
|
-
return bootstrapLazy([["player-legislation-wrapper_3",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
16
|
+
return bootstrapLazy([["player-legislation-wrapper_3",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"activeUserActions":[513,"active-user-actions"],"showCloseButton":[516,"show-close-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"gmVersion":[1,"gm-version"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"hasToSetConsents":[32]},[[0,"hasToSetConsents","hasToSetConsentsHandler"],[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{"activeUserActions":[513,"active-user-actions"],"clientStyling":[1,"client-styling"],"limitStylingAppends":[32]}],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
17
17
|
});
|
|
@@ -46,6 +46,10 @@ export declare class UserActionController {
|
|
|
46
46
|
* Event name to be sent when the button is clicked
|
|
47
47
|
*/
|
|
48
48
|
postMessageEvent: string;
|
|
49
|
+
/**
|
|
50
|
+
* Select GM version
|
|
51
|
+
*/
|
|
52
|
+
gmVersion: string;
|
|
49
53
|
/**
|
|
50
54
|
* Client custom styling via inline style
|
|
51
55
|
*/
|
|
@@ -66,6 +70,7 @@ export declare class UserActionController {
|
|
|
66
70
|
readyActionsCount: number;
|
|
67
71
|
receivedQueryResponses: number;
|
|
68
72
|
private limitStylingAppends;
|
|
73
|
+
hasToSetConsents: boolean;
|
|
69
74
|
private mandatoryActions;
|
|
70
75
|
private requiredActionsCount;
|
|
71
76
|
private expectedQueryResponses;
|
|
@@ -76,6 +81,7 @@ export declare class UserActionController {
|
|
|
76
81
|
updateUserConsents(): void;
|
|
77
82
|
handleApplyClick(): void;
|
|
78
83
|
handleClose(): void;
|
|
84
|
+
hasToSetConsentsHandler(_: CustomEvent): void;
|
|
79
85
|
userLegislationConsentHandler(event: CustomEvent<LegislationConsentEvent>): void;
|
|
80
86
|
componentWillLoad(): Promise<void>;
|
|
81
87
|
componentDidRender(): void;
|
|
@@ -23,6 +23,10 @@ export namespace Components {
|
|
|
23
23
|
* the endpoint required for the update call
|
|
24
24
|
*/
|
|
25
25
|
"endpoint": string;
|
|
26
|
+
/**
|
|
27
|
+
* Select GM version
|
|
28
|
+
*/
|
|
29
|
+
"gmVersion": string;
|
|
26
30
|
/**
|
|
27
31
|
* whether or not to include the submit button (in case we want to compose a different )
|
|
28
32
|
*/
|
|
@@ -86,6 +90,10 @@ declare namespace LocalJSX {
|
|
|
86
90
|
* the endpoint required for the update call
|
|
87
91
|
*/
|
|
88
92
|
"endpoint": string;
|
|
93
|
+
/**
|
|
94
|
+
* Select GM version
|
|
95
|
+
*/
|
|
96
|
+
"gmVersion"?: string;
|
|
89
97
|
/**
|
|
90
98
|
* whether or not to include the submit button (in case we want to compose a different )
|
|
91
99
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,h as s,c as e}from"./p-ba444709.js";const i=class{constructor(s){t(this,s),this.clientStyling="",this.limitStylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}render(){const t=this.activeUserActions.replace(/ /g,"").split(",");return s("div",{class:"PlayerLegislationWrapper",ref:t=>this.stylingContainer=t},t.map((t=>s("slot",{name:t}))))}};i.style=":host{display:block}";const n=class{constructor(s){t(this,s),this.userLegislationConsent=e(this,"userLegislationConsent",7),this.queried=!1,this.consentType="",this.mandatory=!1,this.consentTitle="",this.tcLink="#",this.privacyLink="#",this.clientStyling="",this.textContent="",this.limitStylingAppends=!1,this.stringVariants={termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}determineTextContent(){return"termsandconditions"===this.consentType?s("span",null,this.stringVariants.termsandconditions1,s("a",{href:this.tcLink},this.stringVariants.tc),this.stringVariants.termsandconditions2,s("a",{href:this.privacyLink},this.stringVariants.privacy),this.stringVariants.termsandconditions3):s("span",null,this.stringVariants[this.consentType])}userLegislationConsentHandler(){this.userLegislationConsent.emit({type:this.consentType,value:this.checkboxInput.checked})}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}render(){return this.queried&&this.userLegislationConsentHandler(),this.textContent=this.determineTextContent(),s("div",{ref:t=>this.stylingContainer=t},s("p",{class:"ConsentTitle"},this.consentTitle),s("label",{class:"userConsent",htmlFor:"userConsent"},s("input",{ref:t=>this.checkboxInput=t,id:"userConsent",type:"checkbox",onInput:()=>this.userLegislationConsentHandler()}),this.textContent,this.mandatory&&s("span",{class:"MandatoryItem"},"*")))}};n.style=":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";const o=class{constructor(s){t(this,s),this.closeButtonEvent=e(this,"closeButtonClicked",7),this.postMessageEvent="closeButtonClicked",this.gmVersion="",this.clientStyling="",this.clientStylingUrl="",this.consentTitles={termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},this.queryFired=!1,this.readyActionsCount=0,this.receivedQueryResponses=0,this.limitStylingAppends=!1,this.mandatoryActions=["termsandconditions"],this.requiredActionsCount=0,this.expectedQueryResponses=0,this.userActions=[],this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),s=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{this.clientStyling=t,s.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(s)}),1)})).catch((t=>{console.log("error ",t)}))}}determineMandatoryActions(){let t,s;return t="gmcore"===this.gmVersion?new URL(`${this.endpoint}v1/player/consentRequirements`):new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consents`),s={method:"GET",headers:{"X-SessionId":`${this.userSession}`}},t&&s?fetch(t.href,s).then((t=>t.json())).then((t=>{("gmcore"===this.gmVersion?t.consents||[]:t.items||[]).forEach((t=>t.mustAccept&&this.mandatoryActions.push(t.tagCode)))})).catch((t=>{console.error("Error fetching data:",t)})):Promise.reject("Unsupported endpoint")}handleQueryResponse(){this.receivedQueryResponses===this.expectedQueryResponses&&this.updateUserConsents()}updateUserConsents(){let t,s;t="gmcore"===this.gmVersion?new URL(`${this.endpoint}v1/player/${this.userId}/consent`):new URL(`${this.endpoint}v1/player/${this.userId}/legislation/consent`),s={method:"POST",headers:"gmcore"===this.gmVersion?{"Content-Type":"application/json",Accept:"application/json","X-SessionId":`${this.userSession}`}:{"X-SessionId":`${this.userSession}`},body:JSON.stringify({items:this.userActions})},t&&s&&fetch(t.href,s).then((t=>t.json())).then((()=>{window.postMessage({type:"WidgetNotification",data:{type:"success",message:"Consent update successful!"}},window.location.href)})).catch((t=>{window.postMessage({type:"WidgetNotification",data:{type:"error",message:"Server might not be responding",err:t}},window.location.href)})).finally((()=>{window.postMessage({type:"UserActionsCompleted"},window.location.href)}))}handleApplyClick(){this.queryFired=!0}handleClose(){this.usePostmessage&&window.postMessage({type:this.postMessageEvent}),this.closeButtonEvent.emit()}hasToSetConsentsHandler(t){this.hasToSetConsents=!0}userLegislationConsentHandler(t){this.mandatoryActions.includes(t.detail.type)&&(t.detail.value?this.readyActionsCount++:this.readyActionsCount--),this.queryFired&&(this.userActions.push({tagCode:t.detail.type,status:t.detail.value?"Accepted":"Denied"}),this.receivedQueryResponses++)}componentWillLoad(){return this.determineMandatoryActions()}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}render(){const t=this.hasToSetConsents?["termsandconditions"]:this.activeUserActions.replace(/ /g,"").split(",");return this.requiredActionsCount=t.filter((t=>this.mandatoryActions.includes(t))).length,this.expectedQueryResponses=t.length,s("div",{class:"QueryReferenceContainer",ref:t=>this.stylingContainer=t},s("div",{class:"UserActionController"},this.showCloseButton&&s("div",{class:"CloseButton",onClick:()=>this.handleClose()},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",fill:"currentColor",viewBox:"0 0 16 16"},s("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"}))),s("h2",{class:"UserConsentNotice"},this.userNoticeText),s("player-legislation-wrapper",{"active-user-actions":this.activeUserActions,"client-styling":this.clientStyling},t.map((t=>s("player-user-consents",{slot:t,consentType:t,consentTitle:this.consentTitles[t],queried:this.queryFired,mandatory:this.mandatoryActions.includes(t),"client-styling":this.clientStyling})))),this.includeSubmitButton&&s("button",{class:"ConsentSubmitButton",disabled:this.readyActionsCount!==this.requiredActionsCount,onClick:()=>this.handleApplyClick()},this.submitButtonText)))}static get watchers(){return{receivedQueryResponses:["handleQueryResponse"]}}};o.style=":host{display:block}.QueryReferenceContainer{height:100%;width:100%}.UserConsentNotice{font-size:1.2rem;font-weight:200;text-align:center}.CloseButton{width:25px;height:25px;align-self:flex-end}.UserActionController{font-family:Arial, Helvetica, sans-serif;font-weight:100;height:100%;width:100%;padding:1rem 1.5rem 2rem;background-color:#fff;display:flex;flex-direction:column;justify-content:space-between;border-radius:5%}.ConsentSubmitButton{font-size:1rem;padding:0.4rem 1.4rem;background:#fff;border:2px solid #000;color:#000;border-radius:5px;align-self:flex-end}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc}@media screen and (max-width: 320px){.QueryReferenceContainer{font-size:0.8rem;color:blue}}";export{i as player_legislation_wrapper,n as player_user_consents,o as user_action_controller}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as t}from"./p-ba444709.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((e=>t([["p-
|
|
1
|
+
import{p as e,b as t}from"./p-ba444709.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((e=>t([["p-ecc1c1e4",[[1,"user-action-controller",{endpoint:[513],userSession:[513,"user-session"],userId:[513,"user-id"],includeSubmitButton:[516,"include-submit-button"],submitButtonText:[513,"submit-button-text"],userNoticeText:[513,"user-notice-text"],activeUserActions:[513,"active-user-actions"],showCloseButton:[516,"show-close-button"],usePostmessage:[516,"use-postmessage"],postMessageEvent:[1,"post-message-event"],gmVersion:[1,"gm-version"],clientStyling:[1537,"client-styling"],clientStylingUrl:[513,"client-styling-url"],queryFired:[32],readyActionsCount:[32],receivedQueryResponses:[32],limitStylingAppends:[32],hasToSetConsents:[32]},[[0,"hasToSetConsents","hasToSetConsentsHandler"],[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-legislation-wrapper",{activeUserActions:[513,"active-user-actions"],clientStyling:[1,"client-styling"],limitStylingAppends:[32]}],[1,"player-user-consents",{queried:[516],consentType:[513,"consent-type"],mandatory:[516],consentTitle:[513,"consent-title"],tcLink:[513,"tc-link"],privacyLink:[513,"privacy-link"],clientStyling:[1,"client-styling"],textContent:[32],limitStylingAppends:[32]}]]]],e)));
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as s,c as e}from"./p-ba444709.js";const i=class{constructor(s){t(this,s),this.clientStyling="",this.limitStylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}render(){const t=this.activeUserActions.replace(/ /g,"").split(",");return s("div",{class:"PlayerLegislationWrapper",ref:t=>this.stylingContainer=t},t.map((t=>s("slot",{name:t}))))}};i.style=":host{display:block}";const n=class{constructor(s){t(this,s),this.userLegislationConsent=e(this,"userLegislationConsent",7),this.queried=!1,this.consentType="",this.mandatory=!1,this.consentTitle="",this.tcLink="#",this.privacyLink="#",this.clientStyling="",this.textContent="",this.limitStylingAppends=!1,this.stringVariants={termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}determineTextContent(){return"termsandconditions"===this.consentType?s("span",null,this.stringVariants.termsandconditions1,s("a",{href:this.tcLink},this.stringVariants.tc),this.stringVariants.termsandconditions2,s("a",{href:this.privacyLink},this.stringVariants.privacy),this.stringVariants.termsandconditions3):s("span",null,this.stringVariants[this.consentType])}userLegislationConsentHandler(){this.userLegislationConsent.emit({type:this.consentType,value:this.checkboxInput.checked})}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}render(){return this.queried&&this.userLegislationConsentHandler(),this.textContent=this.determineTextContent(),s("div",{ref:t=>this.stylingContainer=t},s("p",{class:"ConsentTitle"},this.consentTitle),s("label",{class:"userConsent",htmlFor:"userConsent"},s("input",{ref:t=>this.checkboxInput=t,id:"userConsent",type:"checkbox",onInput:()=>this.userLegislationConsentHandler()}),this.textContent,this.mandatory&&s("span",{class:"MandatoryItem"},"*")))}};n.style=":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";const o=class{constructor(s){t(this,s),this.closeButtonEvent=e(this,"closeButtonClicked",7),this.postMessageEvent="closeButtonClicked",this.clientStyling="",this.clientStylingUrl="",this.consentTitles={termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},this.queryFired=!1,this.readyActionsCount=0,this.receivedQueryResponses=0,this.limitStylingAppends=!1,this.mandatoryActions=["termsandconditions"],this.requiredActionsCount=0,this.expectedQueryResponses=0,this.userActions=[],this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),s=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{this.clientStyling=t,s.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(s)}),1)})).catch((t=>{console.log("error ",t)}))}}determineMandatoryActions(){let t=new URL(`${this.endpoint}/v1/player/consentRequirements`);return fetch(t.href).then((t=>t.json())).then((t=>{t.items.forEach((t=>{t.mustAccept&&this.mandatoryActions.push(t.tagCode)}))}))}handleQueryResponse(){this.receivedQueryResponses===this.expectedQueryResponses&&this.updateUserConsents()}updateUserConsents(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);let s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-SessionId":`${this.userSession}`},body:JSON.stringify({items:this.userActions})};fetch(t.href,s).then((t=>t.json())).then((()=>{window.postMessage({type:"WidgetNotification",data:{type:"success",message:"Consent update successfull!"}},window.location.href)})).catch((t=>{window.postMessage({type:"WidgetNotification",data:{type:"error",message:"Server might not be responding",err:t}},window.location.href)})).finally((()=>{window.postMessage({type:"UserActionsCompleted"},window.location.href)}))}handleApplyClick(){this.queryFired=!0}handleClose(){this.usePostmessage&&window.postMessage({type:this.postMessageEvent}),this.closeButtonEvent.emit()}userLegislationConsentHandler(t){this.mandatoryActions.includes(t.detail.type)&&(t.detail.value?this.readyActionsCount++:this.readyActionsCount--),this.queryFired&&(this.userActions.push({tagCode:t.detail.type,status:t.detail.value?"Accepted":"Denied"}),this.receivedQueryResponses++)}componentWillLoad(){return this.determineMandatoryActions()}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}render(){const t=this.activeUserActions.replace(/ /g,"").split(",");return this.requiredActionsCount=t.filter((t=>this.mandatoryActions.includes(t))).length,this.expectedQueryResponses=t.length,s("div",{class:"QueryReferenceContainer",ref:t=>this.stylingContainer=t},s("div",{class:"UserActionController"},this.showCloseButton&&s("div",{class:"CloseButton",onClick:()=>this.handleClose()},s("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",fill:"currentColor",viewBox:"0 0 16 16"},s("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"}))),s("h2",{class:"UserConsentNotice"},this.userNoticeText),s("player-legislation-wrapper",{"active-user-actions":this.activeUserActions,"client-styling":this.clientStyling},t.map((t=>s("player-user-consents",{slot:t,consentType:t,consentTitle:this.consentTitles[t],queried:this.queryFired,mandatory:this.mandatoryActions.includes(t),"client-styling":this.clientStyling})))),this.includeSubmitButton&&s("button",{class:"ConsentSubmitButton",disabled:this.readyActionsCount!==this.requiredActionsCount,onClick:()=>this.handleApplyClick()},this.submitButtonText)))}static get watchers(){return{receivedQueryResponses:["handleQueryResponse"]}}};o.style=":host{display:block}.QueryReferenceContainer{height:100%;width:100%}.UserConsentNotice{font-size:1.2rem;font-weight:200;text-align:center}.CloseButton{width:25px;height:25px;align-self:flex-end}.UserActionController{font-family:Arial, Helvetica, sans-serif;font-weight:100;height:100%;width:100%;padding:1rem 1.5rem 2rem;background-color:#fff;display:flex;flex-direction:column;justify-content:space-between;border-radius:5%}.ConsentSubmitButton{font-size:1rem;padding:0.4rem 1.4rem;background:#fff;border:2px solid #000;color:#000;border-radius:5px;align-self:flex-end}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc}@media screen and (max-width: 320px){.QueryReferenceContainer{font-size:0.8rem;color:blue}}";export{i as player_legislation_wrapper,n as player_user_consents,o as user_action_controller}
|