@roomle/embedding-lib 5.0.1-debug.1 → 5.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  var M = Object.defineProperty;
2
2
  var v = (t, e, s) => e in t ? M(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var u = (t, e, s) => v(t, typeof e != "symbol" ? e + "" : e, s);
3
+ var l = (t, e, s) => v(t, typeof e != "symbol" ? e + "" : e, s);
4
4
  class P {
5
5
  constructor(e, s, r, o) {
6
- u(this, "_side");
6
+ l(this, "_side");
7
7
  // for better debugging (who handles message? iframe or website?)
8
- u(this, "_incomingMessageBus");
9
- u(this, "_outgoingMessageBus", null);
10
- u(this, "_execMessage", null);
8
+ l(this, "_incomingMessageBus");
9
+ l(this, "_outgoingMessageBus", null);
10
+ l(this, "_execMessage", null);
11
11
  this._side = e, this._incomingMessageBus = s, this._outgoingMessageBus = r, this._execMessage = o, this._incomingMessageBus.addEventListener(
12
12
  "message",
13
13
  this._handleMessage.bind(this)
@@ -21,25 +21,25 @@ class P {
21
21
  }
22
22
  sendMessage(e, s = []) {
23
23
  return new Promise((r, o) => {
24
- const n = new MessageChannel();
25
- n.port1.onmessage = (a) => {
26
- if (!a || !a.data)
27
- return n.port1.close(), n.port2.close(), o(
24
+ const i = new MessageChannel();
25
+ i.port1.onmessage = (n) => {
26
+ if (!n || !n.data)
27
+ return i.port1.close(), i.port2.close(), o(
28
28
  new Error(
29
29
  this._side + " received message but response can not be interpreted"
30
30
  )
31
31
  );
32
- let l;
32
+ let c;
33
33
  try {
34
- l = JSON.parse(a.data);
35
- } catch (d) {
36
- return n.port1.close(), n.port2.close(), this._prepareError(d), o(d);
34
+ c = JSON.parse(n.data);
35
+ } catch (a) {
36
+ return i.port1.close(), i.port2.close(), this._prepareError(a), o(a);
37
37
  }
38
- l.error ? o(l.error) : l.result !== void 0 ? r(l.result) : r(void 0), n.port1.close(), n.port2.close();
38
+ c.error ? o(c.error) : c.result !== void 0 ? r(c.result) : r(void 0), i.port1.close(), i.port2.close();
39
39
  };
40
- let i = "";
40
+ let g = "";
41
41
  try {
42
- i = JSON.stringify({ message: e, args: s });
42
+ g = JSON.stringify({ message: e, args: s });
43
43
  } catch {
44
44
  return o(
45
45
  new Error(
@@ -49,8 +49,8 @@ class P {
49
49
  }
50
50
  if (!this._outgoingMessageBus)
51
51
  return o(new Error(this._side + ": outgoing bus not set yet"));
52
- this._outgoingMessageBus.postMessage(i, "*", [
53
- n.port2
52
+ this._outgoingMessageBus.postMessage(g, "*", [
53
+ i.port2
54
54
  ]);
55
55
  });
56
56
  }
@@ -70,20 +70,20 @@ class P {
70
70
  if (o === void 0)
71
71
  return;
72
72
  o.then(
73
- (n = {}) => {
74
- let i, a;
75
- typeof n == "object" && n !== null && (i = n.error, a = n.result), i ? s.postMessage(
76
- JSON.stringify({ error: i })
77
- ) : a !== void 0 ? s.postMessage(
78
- JSON.stringify({ result: a })
79
- ) : s.postMessage(
73
+ (i = {}) => {
74
+ let g, n;
75
+ typeof i == "object" && i !== null && (g = i.error, n = i.result), g ? s.postMessage(
76
+ JSON.stringify({ error: g })
77
+ ) : n !== void 0 ? s.postMessage(
80
78
  JSON.stringify({ result: n })
79
+ ) : s.postMessage(
80
+ JSON.stringify({ result: i })
81
81
  );
82
82
  },
83
- (n) => {
83
+ (i) => {
84
84
  s.postMessage(
85
85
  JSON.stringify({
86
- error: this._prepareError(n)
86
+ error: this._prepareError(i)
87
87
  })
88
88
  );
89
89
  }
@@ -108,37 +108,37 @@ const p = ".", E = {
108
108
  REQUEST_BOOT: "requestBoot",
109
109
  SETUP: "setup",
110
110
  WEBSITE_READY: "websiteReady"
111
- }, H = async (t, e) => {
111
+ }, D = async (t, e) => {
112
112
  if (typeof t != "string")
113
113
  throw new Error(
114
114
  'Configurator ID is not a string type: "' + typeof t + '"'
115
115
  );
116
- const s = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = s + "/configurators/" + t, n = "roomle_portal_v2", i = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + n), a = () => {
117
- const h = {
118
- apiKey: n,
116
+ const s = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = s + "/configurators/" + t, i = "roomle_portal_v2", g = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), n = () => {
117
+ const u = {
118
+ apiKey: i,
119
119
  currentTenant: r,
120
120
  locale: "en",
121
121
  language: "en",
122
122
  device: 1,
123
- token: i,
123
+ token: g,
124
124
  platform: "web"
125
125
  };
126
- return new Headers(h);
127
- }, l = new Request(o, {
126
+ return new Headers(u);
127
+ }, c = new Request(o, {
128
128
  method: "GET",
129
- headers: a(),
129
+ headers: n(),
130
130
  mode: "cors",
131
131
  cache: "default"
132
- }), d = await fetch(l), { configurator: m } = await d.json();
133
- return m;
134
- }, F = () => {
132
+ }), a = await fetch(c), { configurator: f } = await a.json();
133
+ return f;
134
+ }, H = () => {
135
135
  try {
136
136
  return window.self !== window.top;
137
137
  } catch {
138
138
  return !0;
139
139
  }
140
- }, D = ["127.0.0.1", "localhost", "0.0.0.0"], C = () => {
141
- const t = F();
140
+ }, F = ["127.0.0.1", "localhost", "0.0.0.0"], C = () => {
141
+ const t = H();
142
142
  let e = window.location.href;
143
143
  if (t) {
144
144
  if (!document.referrer)
@@ -147,35 +147,37 @@ const p = ".", E = {
147
147
  }
148
148
  const { hostname: s } = new URL(e);
149
149
  return s;
150
- }, B = (t) => !!(D.includes(t) || t.endsWith("roomle.com") || t.endsWith("gitlab.io") || t.endsWith("gitlab.com")), I = [
150
+ }, B = (t) => !!(F.includes(t) || t.endsWith("roomle.com") || t.endsWith("gitlab.io") || t.endsWith("gitlab.com")), A = [
151
151
  "language",
152
152
  "browserLanguage",
153
153
  "userLanguage",
154
154
  "systemLanguage"
155
- ], k = (t = null) => {
155
+ ], U = (t = null) => {
156
156
  const e = window.navigator;
157
157
  if (t)
158
158
  return t.substr(0, 2);
159
159
  if (Array.isArray(e.languages) && e.languages.length > 0)
160
160
  return e.languages[0].substr(0, 2);
161
- for (let s = 0, r = I.length; s < r; s++) {
162
- const o = e[I[s]];
161
+ for (let s = 0, r = A.length; s < r; s++) {
162
+ const o = e[A[s]];
163
163
  if (o)
164
164
  return o.substr(0, 2);
165
165
  }
166
166
  return "en";
167
- }, U = (t, e) => {
167
+ }, k = (t, e) => {
168
168
  const s = JSON.parse(JSON.stringify(t));
169
- return A(s, e);
170
- }, A = (t, e) => {
169
+ return O(s, e);
170
+ }, O = (t, e) => {
171
171
  for (const s in e)
172
172
  try {
173
- e[s].constructor === Object ? t[s] = A(t[s], e[s]) : t[s] = e[s];
173
+ e[s].constructor === Object ? t[s] = O(t[s], e[s]) : t[s] = e[s];
174
174
  } catch {
175
175
  t[s] = e[s];
176
176
  }
177
177
  return t;
178
- }, x = {
178
+ };
179
+ var x = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
180
+ const W = {
179
181
  mobileLandscape: !0,
180
182
  floorMaterialRootTag: "materials_root",
181
183
  buttons: {
@@ -195,32 +197,32 @@ const p = ".", E = {
195
197
  featureFlags: {
196
198
  mocAr: !0
197
199
  }
198
- }, W = "(idle)", G = (t) => (O(t), t != null && t.customApiUrl && (t.customApiUrl = decodeURIComponent(t.customApiUrl)), t.shareUrl && (t.deeplink = t.shareUrl.replace(
200
+ }, G = "(idle)", J = (t) => (w(t), t != null && t.customApiUrl && (t.customApiUrl = decodeURIComponent(t.customApiUrl)), t.shareUrl && (t.deeplink = t.shareUrl.replace(
199
201
  z,
200
- V
201
- )), t), O = (t) => {
202
+ Y
203
+ )), t), w = (t) => {
202
204
  if (!t)
203
205
  return;
204
206
  const e = Object.keys(t);
205
207
  for (const s of e) {
206
208
  const r = t[s];
207
- if (!Array.isArray(r) && typeof r == "object" && r !== null && O(r), Array.isArray(r))
209
+ if (!Array.isArray(r) && typeof r == "object" && r !== null && w(r), Array.isArray(r))
208
210
  for (const o of r)
209
- O(o);
211
+ w(o);
210
212
  (r === "true" || r === "false") && (t[s] = r === "true");
211
213
  }
212
- }, J = (t, e) => {
214
+ }, V = (t, e) => {
213
215
  e.configuratorId = t.id;
214
216
  const s = t.settings || {};
215
- return !e.overrideTenant && t.tenant && (e.overrideTenant = t.tenant), U(s, e);
217
+ return !e.overrideTenant && t.tenant && (e.overrideTenant = t.tenant), k(s, e);
216
218
  }, $ = () => {
217
219
  const t = {
218
- ...x
220
+ ...W
219
221
  };
220
- t.locale || (t.locale = k()), t.id === W && delete t.id;
222
+ t.locale || (t.locale = U()), t.id === G && delete t.id;
221
223
  const e = C();
222
- return e && B(e) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = "https://www.roomle.com/api/v2", t.emails = !1, t;
223
- }, z = "<CONF_ID>", V = "#CONFIGURATIONID#", b = () => /(android)/i.test(navigator.userAgent), R = (t, e, s) => {
224
+ return e && B(e) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = x.VITE_RAPI_URL, t.emails = !1, t;
225
+ }, z = "<CONF_ID>", Y = "#CONFIGURATIONID#", L = () => /(android)/i.test(navigator.userAgent), R = (t, e, s) => {
224
226
  let r = null;
225
227
  Object.defineProperty(t, e, {
226
228
  get() {
@@ -232,75 +234,108 @@ const p = ".", E = {
232
234
  ), console.warn("{ mute: true, value: () => void }"), r = o);
233
235
  }
234
236
  });
235
- }, N = () => window.innerHeight * 0.01 + "px", T = (t) => {
237
+ }, T = () => window.innerHeight * 0.01 + "px", b = (t) => {
236
238
  t && setTimeout(
237
- () => t.style.setProperty(y, N()),
239
+ () => t.style.setProperty(y, T()),
238
240
  0
239
241
  );
240
- }, L = "rml-styles", Y = 450, y = "--rml-full-height", c = {
242
+ }, S = "rml-styles", q = 450, y = "--rml-full-height", d = {
241
243
  CONTAINER: "rml-container",
242
244
  FILL: "rml-fill",
243
245
  POSITION: "rml-pos",
244
246
  TRANSITION: "rml-transition",
245
247
  ANDROID_HEIGHT: "rml-android-height",
246
248
  OVERFLOW_HIDDEN: "rml-overflow-hidden"
247
- }, w = /* @__PURE__ */ new Map();
248
- class K {
249
- constructor(e, s, r, o) {
250
- u(this, "ui", {
249
+ }, I = /* @__PURE__ */ new Map();
250
+ class Q {
251
+ constructor(e, s, r, o, i) {
252
+ l(this, "ui", {
253
+ callbacks: null
254
+ });
255
+ l(this, "extended", {
251
256
  callbacks: null
252
257
  });
253
- u(this, "extended", {
258
+ l(this, "configurator", {
254
259
  callbacks: null
255
260
  });
256
- u(this, "analytics", {
261
+ l(this, "analytics", {
257
262
  callbacks: {}
258
263
  });
259
- u(this, "global", {
264
+ l(this, "global", {
260
265
  callbacks: {}
261
266
  });
262
- u(this, "_waitForIframe");
263
- u(this, "_container");
264
- u(this, "_messageHandler");
265
- u(this, "_configuratorSettings");
266
- u(this, "_initData", {});
267
- u(this, "_iframe");
267
+ l(this, "plugins", {});
268
+ l(this, "_waitForIframe");
269
+ l(this, "_container");
270
+ l(this, "_messageHandler");
271
+ l(this, "_configuratorSettings");
272
+ l(this, "_initData", {});
273
+ l(this, "_iframe");
274
+ l(this, "pluginsLoaded", []);
268
275
  if (!e || typeof e.id != "string")
269
276
  throw new Error(
270
277
  "Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person"
271
278
  );
272
- if (w.has(s))
279
+ if (I.has(s))
273
280
  throw new Error("There is already an instance on this DOM element");
274
- if (!!!document.getElementById(L)) {
275
- const a = r.zIndex || 9999999, l = document.createElement("style");
276
- l.type = "text/css", l.id = L;
277
- const d = "transition:all ease-in-out " + Y + "ms;", m = ["-webkit-", "-o-"].reduce(
278
- (f, g) => f += g + d,
281
+ if (!!!document.getElementById(S)) {
282
+ const c = r.zIndex || 9999999, a = document.createElement("style");
283
+ a.type = "text/css", a.id = S;
284
+ const f = "transition:all ease-in-out " + q + "ms;", u = ["-webkit-", "-o-"].reduce(
285
+ (m, _) => m += _ + f,
279
286
  ""
280
- ) + d, h = N();
281
- l.innerHTML = `
282
- .${c.CONTAINER}{${y}:${h};}
283
- .${c.POSITION}{position:fixed;top:0;left:0;z-index:${a};opacity:0}
284
- .${c.TRANSITION}{${m}}
285
- .${c.FILL}{width:100%;height:100%;opacity:1}
286
- .${c.ANDROID_HEIGHT}{height:calc(var(${y},1vh)*100)}
287
- .${c.OVERFLOW_HIDDEN}{overflow:hidden}
288
- `, document.head.appendChild(l);
287
+ ) + f, h = T();
288
+ a.innerHTML = `
289
+ .${d.CONTAINER}{${y}:${h};}
290
+ .${d.POSITION}{position:fixed;top:0;left:0;z-index:${c};opacity:0}
291
+ .${d.TRANSITION}{${u}}
292
+ .${d.FILL}{width:100%;height:100%;opacity:1}
293
+ .${d.ANDROID_HEIGHT}{height:calc(var(${y},1vh)*100)}
294
+ .${d.OVERFLOW_HIDDEN}{overflow:hidden}
295
+ `, document.head.appendChild(a);
289
296
  }
290
- this._onResize = this._onResize.bind(this), b() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = e;
291
- const i = this._createIframe();
297
+ this._onResize = this._onResize.bind(this), L() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = e;
298
+ const n = this._createIframe();
292
299
  this._onUseFullPage = this._onUseFullPage.bind(this), this._executeMessage = this._executeMessage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._messageHandler = new P(
293
300
  "website",
294
301
  window,
295
302
  null,
296
303
  this._executeMessage
297
- ), this._waitForIframe = o, this._container.appendChild(i), this._iframe = i, w.set(s, !0);
304
+ ), this._waitForIframe = i, this._container.appendChild(n), this._iframe = n;
305
+ for (const c of o)
306
+ typeof c == "string" && c === "dragIn" ? this.pluginsLoaded.push(
307
+ new Promise((a, f) => {
308
+ try {
309
+ import("./drag-in-CXLxdfa-.mjs").then(
310
+ ({ DragIn: u }) => {
311
+ const h = new u(this._iframe);
312
+ h.setInstance(this.ui), this.plugins.dragIn = h, a();
313
+ }
314
+ );
315
+ } catch (u) {
316
+ f(u);
317
+ }
318
+ })
319
+ ) : c.name && c.loader && this.pluginsLoaded.push(
320
+ new Promise((a, f) => {
321
+ try {
322
+ c.loader().then((u) => {
323
+ const h = new u(this._iframe);
324
+ h.setInstance(this.ui), this.plugins[c.name] = h, a();
325
+ });
326
+ } catch (u) {
327
+ f(u);
328
+ }
329
+ })
330
+ );
331
+ I.set(s, !0);
298
332
  }
299
- static createPlanner(e, s, r) {
333
+ static createPlanner(e, s, r, o = []) {
300
334
  return this._create(
301
335
  e,
302
336
  s,
303
- r
337
+ r,
338
+ o
304
339
  );
305
340
  }
306
341
  /**
@@ -309,11 +344,12 @@ class K {
309
344
  * @param container DOM container in which the configurator should be placed
310
345
  * @param initData settings with which the configurator should be started
311
346
  */
312
- static createConfigurator(e, s, r) {
347
+ static createConfigurator(e, s, r, o = []) {
313
348
  return this._create(
314
349
  e,
315
350
  s,
316
- r
351
+ r,
352
+ o
317
353
  );
318
354
  }
319
355
  /**
@@ -323,11 +359,12 @@ class K {
323
359
  * @param container DOM container in which the configurator should be placed
324
360
  * @param initData settings with which the configurator should be started
325
361
  */
326
- static create(e, s, r) {
362
+ static create(e, s, r, o) {
327
363
  return this._create(
328
364
  e,
329
365
  s,
330
- r
366
+ r,
367
+ o
331
368
  );
332
369
  }
333
370
  /**
@@ -336,38 +373,42 @@ class K {
336
373
  * @param container DOM container in which the configurator should be placed
337
374
  * @param initData settings with which the configurator should be started
338
375
  */
339
- static createViewer(e, s, r) {
376
+ static createViewer(e, s, r, o = []) {
340
377
  return this._create(
341
378
  e,
342
379
  s,
343
- r
380
+ r,
381
+ o
344
382
  );
345
383
  }
346
- static _create(e, s, r) {
347
- return new Promise(async (o, n) => {
384
+ static async _create(e, s, r, o) {
385
+ return new Promise(async (i, g) => {
348
386
  try {
349
- const i = A(
387
+ const n = O(
350
388
  $(),
351
- G(r)
389
+ J(r)
352
390
  );
353
- i.featureFlags || (i.featureFlags = {}), typeof i.featureFlags.realPartList != "boolean" && (i.featureFlags.realPartList = !0), typeof i.featureFlags.globalCallbacks != "boolean" && (i.featureFlags.globalCallbacks = !0), typeof i.featureFlags.mocAr != "boolean" && (i.featureFlags.mocAr = !1);
354
- const a = await H(
391
+ n.featureFlags || (n.featureFlags = {}), typeof n.featureFlags.realPartList != "boolean" && (n.featureFlags.realPartList = !0), typeof n.featureFlags.globalCallbacks != "boolean" && (n.featureFlags.globalCallbacks = !0), typeof n.featureFlags.mocAr != "boolean" && (n.featureFlags.mocAr = !1);
392
+ const c = await D(
355
393
  e,
356
- i
394
+ n
357
395
  );
358
- return r = J(a, i), new this(
359
- a,
396
+ r = V(c, n);
397
+ const a = new this(
398
+ c,
360
399
  s,
361
400
  r,
362
- o
401
+ o,
402
+ i
363
403
  );
364
- } catch (i) {
365
- return n(i);
404
+ return await Promise.allSettled(a.pluginsLoaded), a;
405
+ } catch (n) {
406
+ return g(n);
366
407
  }
367
408
  });
368
409
  }
369
410
  teardown() {
370
- this._container && w.delete(this._container);
411
+ this._container && I.delete(this._container);
371
412
  const e = this._container.querySelector("iframe");
372
413
  e && this._container.removeChild(e), window.removeEventListener("resize", this._onResize);
373
414
  }
@@ -375,33 +416,33 @@ class K {
375
416
  var r;
376
417
  const e = document.createElement("iframe");
377
418
  let s = ((r = this._configuratorSettings) == null ? void 0 : r.url) || "https://www.roomle.com/t/cp/";
378
- return this._initData.useLocalRoomle && (s = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (s = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (s = this._initData.overrideServerUrl), e.src = s, e.classList.add(c.CONTAINER), e.classList.add(c.FILL), e;
419
+ return this._initData.useLocalRoomle && (s = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (s = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (s = this._initData.overrideServerUrl), e.src = s, e.classList.add(d.CONTAINER), e.classList.add(d.FILL), e;
379
420
  }
380
421
  _onResize() {
381
- T(this._iframe);
422
+ b(this._iframe);
382
423
  }
383
424
  _onUseFullPage() {
384
- this._iframe.classList.add(c.POSITION), document.documentElement.classList.add(c.OVERFLOW_HIDDEN), window.document.body.classList.add(c.OVERFLOW_HIDDEN), b() && (T(this._iframe), this._iframe.classList.add(c.ANDROID_HEIGHT));
425
+ this._iframe.classList.add(d.POSITION), document.documentElement.classList.add(d.OVERFLOW_HIDDEN), window.document.body.classList.add(d.OVERFLOW_HIDDEN), L() && (b(this._iframe), this._iframe.classList.add(d.ANDROID_HEIGHT));
385
426
  }
386
427
  _onBackToWebsite() {
387
- this._iframe.classList.remove(c.POSITION), this._iframe.classList.remove(c.ANDROID_HEIGHT), document.documentElement.classList.remove(c.OVERFLOW_HIDDEN), window.document.body.classList.remove(c.OVERFLOW_HIDDEN);
428
+ this._iframe.classList.remove(d.POSITION), this._iframe.classList.remove(d.ANDROID_HEIGHT), document.documentElement.classList.remove(d.OVERFLOW_HIDDEN), window.document.body.classList.remove(d.OVERFLOW_HIDDEN);
388
429
  }
389
430
  _executeMessage({ message: e, args: s }, r) {
390
- var l;
391
- if (!r.source || r.source !== ((l = this._iframe) == null ? void 0 : l.contentWindow))
431
+ var c;
432
+ if (!r.source || r.source !== ((c = this._iframe) == null ? void 0 : c.contentWindow))
392
433
  return;
393
434
  if (e === E.REQUEST_BOOT)
394
435
  return this._messageHandler.setOutgoingMessageBus(r.source), Promise.resolve({ result: this._initData });
395
436
  if (e === E.SETUP) {
396
- const { methods: d, callbacks: m } = s[0];
397
- return d.forEach((h) => {
398
- const f = h.split(p), g = f[0], _ = f[1];
399
- this[g] || (this[g] = {}), this[g][_] = (function() {
400
- return this._messageHandler.sendMessage(h, [...arguments]);
437
+ const { methods: a, callbacks: f } = s[0];
438
+ return a.forEach((u) => {
439
+ const h = u.split(p), m = h[0], _ = h[1];
440
+ this[m] || (this[m] = {}), this[m][_] = (function() {
441
+ return this._messageHandler.sendMessage(u, [...arguments]);
401
442
  }).bind(this);
402
- }), m.forEach((h) => {
403
- const f = h.split(p), g = f[0], _ = f[1], S = f[2];
404
- this[g] || (this[g] = {}), this[g][_] || (this[g][_] = {}), this[g][_][S] = () => {
443
+ }), f.forEach((u) => {
444
+ const h = u.split(p), m = h[0], _ = h[1], N = h[2];
445
+ this[m] || (this[m] = {}), this[m][_] || (this[m][_] = {}), this[m][_][N] = () => {
405
446
  };
406
447
  }), R(
407
448
  this.ui.callbacks,
@@ -416,16 +457,16 @@ class K {
416
457
  0
417
458
  ), Promise.resolve({ result: null });
418
459
  }
419
- const o = e.split(p), n = o[0], i = o[1], a = o.length === 3 ? o[2] : null;
420
- if (a && this[n][i][a]) {
421
- const d = this[n][i][a](
460
+ const o = e.split(p), i = o[0], g = o[1], n = o.length === 3 ? o[2] : null;
461
+ if (n && this[i][g][n]) {
462
+ const a = this[i][g][n](
422
463
  ...s
423
464
  );
424
- return d instanceof Promise ? d.then((m) => ({ result: m })) : d !== void 0 ? Promise.resolve({ result: d }) : Promise.resolve({ result: null });
465
+ return a instanceof Promise ? a.then((f) => ({ result: f })) : a !== void 0 ? Promise.resolve({ result: a }) : Promise.resolve({ result: null });
425
466
  }
426
467
  return Promise.reject('Message "' + e + '" is unkown');
427
468
  }
428
469
  }
429
470
  export {
430
- K as default
471
+ Q as default
431
472
  };
@@ -1,8 +1,8 @@
1
- var R=Object.defineProperty,A=(s,e,t)=>e in s?R(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,u=(s,e,t)=>A(s,typeof e!="symbol"?e+"":e,t);class S{constructor(e,t,r,i){u(this,"_side"),u(this,"_incomingMessageBus"),u(this,"_outgoingMessageBus",null),u(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((r,i)=>{const o=new MessageChannel;o.port1.onmessage=n=>{if(!n||!n.data)return o.port1.close(),o.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(n.data)}catch(h){return o.port1.close(),o.port2.close(),this._prepareError(h),i(h)}c.error?i(c.error):c.result!==void 0?r(c.result):r(void 0),o.port1.close(),o.port2.close()};let a="";try{a=JSON.stringify({message:e,args:t})}catch{return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(a,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const r=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);const i=this._execMessage(r,e);if(i===void 0)return;i.then((o={})=>{let a,n;typeof o=="object"&&o!==null&&(a=o.error,n=o.result),a?t.postMessage(JSON.stringify({error:a})):n!==void 0?t.postMessage(JSON.stringify({result:n})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(r){t.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const p=".",w={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},F=async(s,e)=>{if(typeof s!="string")throw new Error('Configurator ID is not a string type: "'+typeof s+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=t+"/configurators/"+s,o="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),n=()=>{const g={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(g)},c=new Request(i,{method:"GET",headers:n(),mode:"cors",cache:"default"}),h=await fetch(c),{configurator:f}=await h.json();return f},P=()=>{try{return window.self!==window.top}catch{return!0}},H=["127.0.0.1","localhost","0.0.0.0"],U=()=>{const s=P();let e=window.location.href;if(s){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},B=s=>!!(H.includes(s)||s.endsWith("roomle.com")||s.endsWith("gitlab.io")||s.endsWith("gitlab.com")),I=["language","browserLanguage","userLanguage","systemLanguage"],k=(s=null)=>{const e=window.navigator;if(s)return s.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,r=I.length;t<r;t++){const i=e[I[t]];if(i)return i.substr(0,2)}return"en"},x=(s,e)=>{const t=JSON.parse(JSON.stringify(s));return b(t,e)},b=(s,e)=>{for(const t in e)try{e[t].constructor===Object?s[t]=b(s[t],e[t]):s[t]=e[t]}catch{s[t]=e[t]}return s},W={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0}},C="(idle)",J=s=>(y(s),s!=null&&s.customApiUrl&&(s.customApiUrl=decodeURIComponent(s.customApiUrl)),s.shareUrl&&(s.deeplink=s.shareUrl.replace(j,V)),s),y=s=>{if(!s)return;const e=Object.keys(s);for(const t of e){const r=s[t];if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&y(r),Array.isArray(r))for(const i of r)y(i);(r==="true"||r==="false")&&(s[t]=r==="true")}},$=(s,e)=>{e.configuratorId=s.id;const t=s.settings||{};return!e.overrideTenant&&s.tenant&&(e.overrideTenant=s.tenant),x(t,e)},z=()=>{const s={...W};s.locale||(s.locale=k()),s.id===C&&delete s.id;const e=U();return e&&B(e)&&(s.configuratorId="demoConfigurator"),s.customApiUrl="https://www.roomle.com/api/v2",s.emails=!1,s},j="<CONF_ID>",V="#CONFIGURATIONID#",v=()=>/(android)/i.test(navigator.userAgent),T=(s,e,t)=>{let r=null;Object.defineProperty(s,e,{get(){return r||t},set(i){i!=null&&i.mute?r=i.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),r=i)}})},N=()=>window.innerHeight*.01+"px",M=s=>{s&&setTimeout(()=>s.style.setProperty(O,N()),0)},D="rml-styles",G=450,O="--rml-full-height",l={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},E=new Map;class q{constructor(e,t,r,i){if(u(this,"ui",{callbacks:null}),u(this,"extended",{callbacks:null}),u(this,"analytics",{callbacks:{}}),u(this,"global",{callbacks:{}}),u(this,"_waitForIframe"),u(this,"_container"),u(this,"_messageHandler"),u(this,"_configuratorSettings"),u(this,"_initData",{}),u(this,"_iframe"),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(E.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(D)){const a=r.zIndex||9999999,n=document.createElement("style");n.type="text/css",n.id=D;const c="transition:all ease-in-out "+G+"ms;",h=["-webkit-","-o-"].reduce((g,m)=>g+=m+c,"")+c,f=N();n.innerHTML=`
2
- .${l.CONTAINER}{${O}:${f};}
3
- .${l.POSITION}{position:fixed;top:0;left:0;z-index:${a};opacity:0}
4
- .${l.TRANSITION}{${h}}
5
- .${l.FILL}{width:100%;height:100%;opacity:1}
6
- .${l.ANDROID_HEIGHT}{height:calc(var(${O},1vh)*100)}
7
- .${l.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(n)}this._onResize=this._onResize.bind(this),v()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=r,this._configuratorSettings=e;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new S("website",window,null,this._executeMessage),this._waitForIframe=i,this._container.appendChild(o),this._iframe=o,E.set(t,!0)}static createPlanner(e,t,r){return this._create(e,t,r)}static createConfigurator(e,t,r){return this._create(e,t,r)}static create(e,t,r){return this._create(e,t,r)}static createViewer(e,t,r){return this._create(e,t,r)}static _create(e,t,r){return new Promise(async(i,o)=>{try{const a=b(z(),J(r));a.featureFlags||(a.featureFlags={}),typeof a.featureFlags.realPartList!="boolean"&&(a.featureFlags.realPartList=!0),typeof a.featureFlags.globalCallbacks!="boolean"&&(a.featureFlags.globalCallbacks=!0),typeof a.featureFlags.mocAr!="boolean"&&(a.featureFlags.mocAr=!1);const n=await F(e,a);return r=$(n,a),new this(n,t,r,i)}catch(a){return o(a)}})}teardown(){this._container&&E.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;const t=document.createElement("iframe");let r=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),t.src=r,t.classList.add(l.CONTAINER),t.classList.add(l.FILL),t}_onResize(){M(this._iframe)}_onUseFullPage(){this._iframe.classList.add(l.POSITION),document.documentElement.classList.add(l.OVERFLOW_HIDDEN),window.document.body.classList.add(l.OVERFLOW_HIDDEN),v()&&(M(this._iframe),this._iframe.classList.add(l.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(l.POSITION),this._iframe.classList.remove(l.ANDROID_HEIGHT),document.documentElement.classList.remove(l.OVERFLOW_HIDDEN),window.document.body.classList.remove(l.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var i;if(!r.source||r.source!==((i=this._iframe)==null?void 0:i.contentWindow))return;if(e===w.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===w.SETUP){const{methods:h,callbacks:f}=t[0];return h.forEach(g=>{const m=g.split(p),d=m[0],_=m[1];this[d]||(this[d]={}),this[d][_]=function(){return this._messageHandler.sendMessage(g,[...arguments])}.bind(this)}),f.forEach(g=>{const m=g.split(p),d=m[0],_=m[1],L=m[2];this[d]||(this[d]={}),this[d][_]||(this[d][_]={}),this[d][_][L]=()=>{}}),T(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),T(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(w.WEBSITE_READY),0),Promise.resolve({result:null})}const o=e.split(p),a=o[0],n=o[1],c=o.length===3?o[2]:null;if(c&&this[a][n][c]){const h=this[a][n][c](...t);return h instanceof Promise?h.then(f=>({result:f})):h!==void 0?Promise.resolve({result:h}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}export{q as default};
1
+ var R=Object.defineProperty,S=(s,e,t)=>e in s?R(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,c=(s,e,t)=>S(s,typeof e!="symbol"?e+"":e,t);class A{constructor(e,t,r,i){c(this,"_side"),c(this,"_incomingMessageBus"),c(this,"_outgoingMessageBus",null),c(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((r,i)=>{const o=new MessageChannel;o.port1.onmessage=n=>{if(!n||!n.data)return o.port1.close(),o.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let a;try{a=JSON.parse(n.data)}catch(l){return o.port1.close(),o.port2.close(),this._prepareError(l),i(l)}a.error?i(a.error):a.result!==void 0?r(a.result):r(void 0),o.port1.close(),o.port2.close()};let u="";try{u=JSON.stringify({message:e,args:t})}catch{return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(u,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const r=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);const i=this._execMessage(r,e);if(i===void 0)return;i.then((o={})=>{let u,n;typeof o=="object"&&o!==null&&(u=o.error,n=o.result),u?t.postMessage(JSON.stringify({error:u})):n!==void 0?t.postMessage(JSON.stringify({result:n})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(r){t.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const p=".",w={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},P=async(s,e)=>{if(typeof s!="string")throw new Error('Configurator ID is not a string type: "'+typeof s+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=t+"/configurators/"+s,o="roomle_portal_v2",u="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),n=()=>{const d={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:u,platform:"web"};return new Headers(d)},a=new Request(i,{method:"GET",headers:n(),mode:"cors",cache:"default"}),l=await fetch(a),{configurator:g}=await l.json();return g},F=()=>{try{return window.self!==window.top}catch{return!0}},U=["127.0.0.1","localhost","0.0.0.0"],B=()=>{const s=F();let e=window.location.href;if(s){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},H=s=>!!(U.includes(s)||s.endsWith("roomle.com")||s.endsWith("gitlab.io")||s.endsWith("gitlab.com")),E=["language","browserLanguage","userLanguage","systemLanguage"],k=(s=null)=>{const e=window.navigator;if(s)return s.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,r=E.length;t<r;t++){const i=e[E[t]];if(i)return i.substr(0,2)}return"en"},x=(s,e)=>{const t=JSON.parse(JSON.stringify(s));return y(t,e)},y=(s,e)=>{for(const t in e)try{e[t].constructor===Object?s[t]=y(s[t],e[t]):s[t]=e[t]}catch{s[t]=e[t]}return s};var W={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const C={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0}},J="(idle)",$=s=>(b(s),s!=null&&s.customApiUrl&&(s.customApiUrl=decodeURIComponent(s.customApiUrl)),s.shareUrl&&(s.deeplink=s.shareUrl.replace(j,G)),s),b=s=>{if(!s)return;const e=Object.keys(s);for(const t of e){const r=s[t];if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&b(r),Array.isArray(r))for(const i of r)b(i);(r==="true"||r==="false")&&(s[t]=r==="true")}},V=(s,e)=>{e.configuratorId=s.id;const t=s.settings||{};return!e.overrideTenant&&s.tenant&&(e.overrideTenant=s.tenant),x(t,e)},z=()=>{const s={...C};s.locale||(s.locale=k()),s.id===J&&delete s.id;const e=B();return e&&H(e)&&(s.configuratorId="demoConfigurator"),s.customApiUrl=W.VITE_RAPI_URL,s.emails=!1,s},j="<CONF_ID>",G="#CONFIGURATIONID#",v=()=>/(android)/i.test(navigator.userAgent),T=(s,e,t)=>{let r=null;Object.defineProperty(s,e,{get(){return r||t},set(i){i!=null&&i.mute?r=i.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),r=i)}})},L=()=>window.innerHeight*.01+"px",M=s=>{s&&setTimeout(()=>s.style.setProperty(I,L()),0)},N="rml-styles",q=450,I="--rml-full-height",h={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},O=new Map;class Y{constructor(e,t,r,i,o){if(c(this,"ui",{callbacks:null}),c(this,"extended",{callbacks:null}),c(this,"configurator",{callbacks:null}),c(this,"analytics",{callbacks:{}}),c(this,"global",{callbacks:{}}),c(this,"plugins",{}),c(this,"_waitForIframe"),c(this,"_container"),c(this,"_messageHandler"),c(this,"_configuratorSettings"),c(this,"_initData",{}),c(this,"_iframe"),c(this,"pluginsLoaded",[]),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(O.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(N)){const n=r.zIndex||9999999,a=document.createElement("style");a.type="text/css",a.id=N;const l="transition:all ease-in-out "+q+"ms;",g=["-webkit-","-o-"].reduce((f,m)=>f+=m+l,"")+l,d=L();a.innerHTML=`
2
+ .${h.CONTAINER}{${I}:${d};}
3
+ .${h.POSITION}{position:fixed;top:0;left:0;z-index:${n};opacity:0}
4
+ .${h.TRANSITION}{${g}}
5
+ .${h.FILL}{width:100%;height:100%;opacity:1}
6
+ .${h.ANDROID_HEIGHT}{height:calc(var(${I},1vh)*100)}
7
+ .${h.OVERFLOW_HIDDEN}{overflow:hidden}
8
+ `,document.head.appendChild(a)}this._onResize=this._onResize.bind(this),v()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=r,this._configuratorSettings=e;const u=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new A("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(u),this._iframe=u;for(const n of i)typeof n=="string"&&n==="dragIn"?this.pluginsLoaded.push(new Promise((a,l)=>{try{import("./drag-in-gOPgOymI.mjs").then(({DragIn:g})=>{const d=new g(this._iframe);d.setInstance(this.ui),this.plugins.dragIn=d,a()})}catch(g){l(g)}})):n.name&&n.loader&&this.pluginsLoaded.push(new Promise((a,l)=>{try{n.loader().then(g=>{const d=new g(this._iframe);d.setInstance(this.ui),this.plugins[n.name]=d,a()})}catch(g){l(g)}}));O.set(t,!0)}static createPlanner(e,t,r,i=[]){return this._create(e,t,r,i)}static createConfigurator(e,t,r,i=[]){return this._create(e,t,r,i)}static create(e,t,r,i){return this._create(e,t,r,i)}static createViewer(e,t,r,i=[]){return this._create(e,t,r,i)}static async _create(e,t,r,i){return new Promise(async(o,u)=>{try{const n=y(z(),$(r));n.featureFlags||(n.featureFlags={}),typeof n.featureFlags.realPartList!="boolean"&&(n.featureFlags.realPartList=!0),typeof n.featureFlags.globalCallbacks!="boolean"&&(n.featureFlags.globalCallbacks=!0),typeof n.featureFlags.mocAr!="boolean"&&(n.featureFlags.mocAr=!1);const a=await P(e,n);r=V(a,n);const l=new this(a,t,r,i,o);return await Promise.allSettled(l.pluginsLoaded),l}catch(n){return u(n)}})}teardown(){this._container&&O.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;const t=document.createElement("iframe");let r=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),t.src=r,t.classList.add(h.CONTAINER),t.classList.add(h.FILL),t}_onResize(){M(this._iframe)}_onUseFullPage(){this._iframe.classList.add(h.POSITION),document.documentElement.classList.add(h.OVERFLOW_HIDDEN),window.document.body.classList.add(h.OVERFLOW_HIDDEN),v()&&(M(this._iframe),this._iframe.classList.add(h.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(h.POSITION),this._iframe.classList.remove(h.ANDROID_HEIGHT),document.documentElement.classList.remove(h.OVERFLOW_HIDDEN),window.document.body.classList.remove(h.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var i;if(!r.source||r.source!==((i=this._iframe)==null?void 0:i.contentWindow))return;if(e===w.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===w.SETUP){const{methods:l,callbacks:g}=t[0];return l.forEach(d=>{const f=d.split(p),m=f[0],_=f[1];this[m]||(this[m]={}),this[m][_]=function(){return this._messageHandler.sendMessage(d,[...arguments])}.bind(this)}),g.forEach(d=>{const f=d.split(p),m=f[0],_=f[1],D=f[2];this[m]||(this[m]={}),this[m][_]||(this[m][_]={}),this[m][_][D]=()=>{}}),T(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),T(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(w.WEBSITE_READY),0),Promise.resolve({result:null})}const o=e.split(p),u=o[0],n=o[1],a=o.length===3?o[2]:null;if(a&&this[u][n][a]){const l=this[u][n][a](...t);return l instanceof Promise?l.then(g=>({result:g})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}export{Y as default};