@roomle/embedding-lib 5.28.0-alpha.1 → 5.28.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,125 +1,372 @@
1
- class S {
1
+ class H {
2
2
  _side;
3
3
  // for better debugging (who handles message? iframe or website?)
4
4
  _incomingMessageBus = null;
5
5
  _outgoingMessageBus = null;
6
6
  _execMessage = null;
7
- constructor(e, t, r, o) {
8
- this._side = e, this._incomingMessageBus = t, this._outgoingMessageBus = r, this._execMessage = o, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
7
+ constructor(t, s, r, n) {
8
+ this._side = t, this._incomingMessageBus = s, this._outgoingMessageBus = r, this._execMessage = n, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
9
9
  "message",
10
10
  this._handleMessage.bind(this)
11
11
  );
12
12
  }
13
- setOutgoingMessageBus(e) {
14
- this._outgoingMessageBus = e;
13
+ setOutgoingMessageBus(t) {
14
+ this._outgoingMessageBus = t;
15
15
  }
16
- setMessageExecution(e) {
17
- this._execMessage = e;
16
+ setMessageExecution(t) {
17
+ this._execMessage = t;
18
18
  }
19
- sendMessage(e, t = []) {
20
- return new Promise((r, o) => {
19
+ sendMessage(t, s = []) {
20
+ return new Promise((r, n) => {
21
21
  if (this._incomingMessageBus === this._outgoingMessageBus)
22
22
  return r(void 0);
23
- const i = new MessageChannel();
24
- i.port1.onmessage = (n) => {
25
- if (!n || !n.data)
26
- return i.port1.close(), i.port2.close(), o(
23
+ const o = new MessageChannel();
24
+ o.port1.onmessage = (i) => {
25
+ if (!i || !i.data)
26
+ return o.port1.close(), o.port2.close(), n(
27
27
  new Error(
28
28
  this._side + " received message but response can not be interpreted"
29
29
  )
30
30
  );
31
- let l;
31
+ let c;
32
32
  try {
33
- l = JSON.parse(n.data);
34
- } catch (u) {
35
- return i.port1.close(), i.port2.close(), this._prepareError(u), o(u);
33
+ c = JSON.parse(i.data);
34
+ } catch (l) {
35
+ return o.port1.close(), o.port2.close(), this._prepareError(l), n(l);
36
36
  }
37
- l.error ? o(l.error) : l.result !== void 0 ? r(l.result) : r(void 0), i.port1.close(), i.port2.close();
37
+ c.error ? n(c.error) : c.result !== void 0 ? r(c.result) : r(void 0), o.port1.close(), o.port2.close();
38
38
  };
39
39
  let a = "";
40
40
  try {
41
- a = JSON.stringify({ message: e, args: t });
41
+ a = JSON.stringify({ message: t, args: s });
42
42
  } catch {
43
- return o(
43
+ return n(
44
44
  new Error(
45
45
  this._side + ": can not create command because it is not JSON.stringify able"
46
46
  )
47
47
  );
48
48
  }
49
49
  if (!this._outgoingMessageBus)
50
- return o(new Error(this._side + ": outgoing bus not set yet"));
50
+ return n(new Error(this._side + ": outgoing bus not set yet"));
51
51
  this._outgoingMessageBus.postMessage(a, "*", [
52
- i.port2
52
+ o.port2
53
53
  ]);
54
54
  });
55
55
  }
56
- _handleMessage(e) {
57
- const t = e.ports && Array.isArray(e.ports) && e.ports.length > 0 ? e.ports[0] : null;
58
- if (e.data && t)
56
+ _handleMessage(t) {
57
+ const s = t.ports && Array.isArray(t.ports) && t.ports.length > 0 ? t.ports[0] : null;
58
+ if (t.data && s)
59
59
  try {
60
- const r = JSON.parse(e.data);
60
+ const r = JSON.parse(t.data);
61
61
  if (!this._execMessage)
62
- return t.postMessage(
62
+ return s.postMessage(
63
63
  JSON.stringify({
64
64
  error: this._side + " is not ready to handle messages"
65
65
  })
66
66
  );
67
67
  Array.isArray(r.args) || (r.args = [r.args]);
68
- const o = this._execMessage(r, e);
69
- if (o === void 0)
68
+ const n = this._execMessage(r, t);
69
+ if (n === void 0)
70
70
  return;
71
- o.then(
72
- (i = {}) => {
73
- let a, n;
74
- typeof i == "object" && i !== null && (a = i.error, n = i.result), a ? t.postMessage(
71
+ n.then(
72
+ (o = {}) => {
73
+ let a, i;
74
+ typeof o == "object" && o !== null && (a = o.error, i = o.result), a ? s.postMessage(
75
75
  JSON.stringify({ error: a })
76
- ) : n !== void 0 ? t.postMessage(
77
- JSON.stringify({ result: n })
78
- ) : t.postMessage(
76
+ ) : i !== void 0 ? s.postMessage(
79
77
  JSON.stringify({ result: i })
78
+ ) : s.postMessage(
79
+ JSON.stringify({ result: o })
80
80
  );
81
81
  },
82
- (i) => {
83
- t.postMessage(
82
+ (o) => {
83
+ s.postMessage(
84
84
  JSON.stringify({
85
- error: this._prepareError(i)
85
+ error: this._prepareError(o)
86
86
  })
87
87
  );
88
88
  }
89
89
  );
90
90
  } catch (r) {
91
- t.postMessage(
91
+ s.postMessage(
92
92
  JSON.stringify({
93
93
  error: this._prepareError(r)
94
94
  })
95
95
  );
96
96
  }
97
97
  }
98
- _prepareError(e) {
99
- if (typeof e == "string") {
100
- const t = this._side + ": " + e;
101
- return console.error(t), t;
98
+ _prepareError(t) {
99
+ if (typeof t == "string") {
100
+ const s = this._side + ": " + t;
101
+ return console.error(s), s;
102
102
  }
103
- return e.message = this._side + ": " + e.message, console.error(e), e.message;
103
+ return t.message = this._side + ": " + t.message, console.error(t), t.message;
104
104
  }
105
105
  }
106
- const f = ".", _ = {
106
+ /**
107
+ * @license
108
+ * Copyright 2019 Google LLC
109
+ * SPDX-License-Identifier: Apache-2.0
110
+ */
111
+ const W = Symbol("Comlink.proxy"), X = Symbol("Comlink.endpoint"), j = Symbol("Comlink.releaseProxy"), M = Symbol("Comlink.finalizer"), w = Symbol("Comlink.thrown"), G = (e) => typeof e == "object" && e !== null || typeof e == "function", Z = {
112
+ canHandle: (e) => G(e) && e[W],
113
+ serialize(e) {
114
+ const { port1: t, port2: s } = new MessageChannel();
115
+ return L(e, t), [s, [s]];
116
+ },
117
+ deserialize(e) {
118
+ return e.start(), re(e);
119
+ }
120
+ }, ee = {
121
+ canHandle: (e) => G(e) && w in e,
122
+ serialize({ value: e }) {
123
+ let t;
124
+ return e instanceof Error ? t = {
125
+ isError: !0,
126
+ value: {
127
+ message: e.message,
128
+ name: e.name,
129
+ stack: e.stack
130
+ }
131
+ } : t = { isError: !1, value: e }, [t, []];
132
+ },
133
+ deserialize(e) {
134
+ throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
135
+ }
136
+ }, z = /* @__PURE__ */ new Map([
137
+ ["proxy", Z],
138
+ ["throw", ee]
139
+ ]);
140
+ function te(e, t) {
141
+ for (const s of e)
142
+ if (t === s || s === "*" || s instanceof RegExp && s.test(t))
143
+ return !0;
144
+ return !1;
145
+ }
146
+ function L(e, t = globalThis, s = ["*"]) {
147
+ t.addEventListener("message", function r(n) {
148
+ if (!n || !n.data)
149
+ return;
150
+ if (!te(s, n.origin)) {
151
+ console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
152
+ return;
153
+ }
154
+ const { id: o, type: a, path: i } = Object.assign({ path: [] }, n.data), c = (n.data.argumentList || []).map(m);
155
+ let l;
156
+ try {
157
+ const u = i.slice(0, -1).reduce((d, h) => d[h], e), g = i.reduce((d, h) => d[h], e);
158
+ switch (a) {
159
+ case "GET":
160
+ l = g;
161
+ break;
162
+ case "SET":
163
+ u[i.slice(-1)[0]] = m(n.data.value), l = !0;
164
+ break;
165
+ case "APPLY":
166
+ l = g.apply(u, c);
167
+ break;
168
+ case "CONSTRUCT":
169
+ {
170
+ const d = new g(...c);
171
+ l = ce(d);
172
+ }
173
+ break;
174
+ case "ENDPOINT":
175
+ {
176
+ const { port1: d, port2: h } = new MessageChannel();
177
+ L(e, h), l = ae(d, [d]);
178
+ }
179
+ break;
180
+ case "RELEASE":
181
+ l = void 0;
182
+ break;
183
+ default:
184
+ return;
185
+ }
186
+ } catch (u) {
187
+ l = { value: u, [w]: 0 };
188
+ }
189
+ Promise.resolve(l).catch((u) => ({ value: u, [w]: 0 })).then((u) => {
190
+ const [g, d] = S(u);
191
+ t.postMessage(Object.assign(Object.assign({}, g), { id: o }), d), a === "RELEASE" && (t.removeEventListener("message", r), V(t), M in e && typeof e[M] == "function" && e[M]());
192
+ }).catch((u) => {
193
+ const [g, d] = S({
194
+ value: new TypeError("Unserializable return value"),
195
+ [w]: 0
196
+ });
197
+ t.postMessage(Object.assign(Object.assign({}, g), { id: o }), d);
198
+ });
199
+ }), t.start && t.start();
200
+ }
201
+ function se(e) {
202
+ return e.constructor.name === "MessagePort";
203
+ }
204
+ function V(e) {
205
+ se(e) && e.close();
206
+ }
207
+ function re(e, t) {
208
+ const s = /* @__PURE__ */ new Map();
209
+ return e.addEventListener("message", function(n) {
210
+ const { data: o } = n;
211
+ if (!o || !o.id)
212
+ return;
213
+ const a = s.get(o.id);
214
+ if (a)
215
+ try {
216
+ a(o);
217
+ } finally {
218
+ s.delete(o.id);
219
+ }
220
+ }), b(e, s, [], t);
221
+ }
222
+ function _(e) {
223
+ if (e)
224
+ throw new Error("Proxy has been released and is not useable");
225
+ }
226
+ function J(e) {
227
+ return p(e, /* @__PURE__ */ new Map(), {
228
+ type: "RELEASE"
229
+ }).then(() => {
230
+ V(e);
231
+ });
232
+ }
233
+ const y = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
234
+ const t = (y.get(e) || 0) - 1;
235
+ y.set(e, t), t === 0 && J(e);
236
+ });
237
+ function ne(e, t) {
238
+ const s = (y.get(t) || 0) + 1;
239
+ y.set(t, s), O && O.register(e, t, e);
240
+ }
241
+ function oe(e) {
242
+ O && O.unregister(e);
243
+ }
244
+ function b(e, t, s = [], r = function() {
245
+ }) {
246
+ let n = !1;
247
+ const o = new Proxy(r, {
248
+ get(a, i) {
249
+ if (_(n), i === j)
250
+ return () => {
251
+ oe(o), J(e), t.clear(), n = !0;
252
+ };
253
+ if (i === "then") {
254
+ if (s.length === 0)
255
+ return { then: () => o };
256
+ const c = p(e, t, {
257
+ type: "GET",
258
+ path: s.map((l) => l.toString())
259
+ }).then(m);
260
+ return c.then.bind(c);
261
+ }
262
+ return b(e, t, [...s, i]);
263
+ },
264
+ set(a, i, c) {
265
+ _(n);
266
+ const [l, u] = S(c);
267
+ return p(e, t, {
268
+ type: "SET",
269
+ path: [...s, i].map((g) => g.toString()),
270
+ value: l
271
+ }, u).then(m);
272
+ },
273
+ apply(a, i, c) {
274
+ _(n);
275
+ const l = s[s.length - 1];
276
+ if (l === X)
277
+ return p(e, t, {
278
+ type: "ENDPOINT"
279
+ }).then(m);
280
+ if (l === "bind")
281
+ return b(e, t, s.slice(0, -1));
282
+ const [u, g] = C(c);
283
+ return p(e, t, {
284
+ type: "APPLY",
285
+ path: s.map((d) => d.toString()),
286
+ argumentList: u
287
+ }, g).then(m);
288
+ },
289
+ construct(a, i) {
290
+ _(n);
291
+ const [c, l] = C(i);
292
+ return p(e, t, {
293
+ type: "CONSTRUCT",
294
+ path: s.map((u) => u.toString()),
295
+ argumentList: c
296
+ }, l).then(m);
297
+ }
298
+ });
299
+ return ne(o, e), o;
300
+ }
301
+ function ie(e) {
302
+ return Array.prototype.concat.apply([], e);
303
+ }
304
+ function C(e) {
305
+ const t = e.map(S);
306
+ return [t.map((s) => s[0]), ie(t.map((s) => s[1]))];
307
+ }
308
+ const $ = /* @__PURE__ */ new WeakMap();
309
+ function ae(e, t) {
310
+ return $.set(e, t), e;
311
+ }
312
+ function ce(e) {
313
+ return Object.assign(e, { [W]: !0 });
314
+ }
315
+ function S(e) {
316
+ for (const [t, s] of z)
317
+ if (s.canHandle(e)) {
318
+ const [r, n] = s.serialize(e);
319
+ return [
320
+ {
321
+ type: "HANDLER",
322
+ name: t,
323
+ value: r
324
+ },
325
+ n
326
+ ];
327
+ }
328
+ return [
329
+ {
330
+ type: "RAW",
331
+ value: e
332
+ },
333
+ $.get(e) || []
334
+ ];
335
+ }
336
+ function m(e) {
337
+ switch (e.type) {
338
+ case "HANDLER":
339
+ return z.get(e.name).deserialize(e.value);
340
+ case "RAW":
341
+ return e.value;
342
+ }
343
+ }
344
+ function p(e, t, s, r) {
345
+ return new Promise((n) => {
346
+ const o = le();
347
+ t.set(o, n), e.start && e.start(), e.postMessage(Object.assign({ id: o }, s), r);
348
+ });
349
+ }
350
+ function le() {
351
+ return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
352
+ }
353
+ const T = ".", A = {
107
354
  REQUEST_BOOT: "requestBoot",
108
355
  SETUP: "setup",
109
356
  WEBSITE_READY: "websiteReady"
110
- }, m = {
357
+ }, E = {
111
358
  GET_METHODS: "getMethods",
112
359
  RETURN_METHODS: "returnMethods",
113
360
  REGISTER_CUSTOM_VIEW: "registerCustomView",
114
361
  REGISTER_CUSTOM_VIEW_DONE: "registerCustomViewDone"
115
- }, C = async (s, e) => {
116
- if (typeof s != "string")
362
+ }, ue = async (e, t) => {
363
+ if (typeof e != "string")
117
364
  throw new Error(
118
- 'Configurator ID is not a string type: "' + typeof s + '"'
365
+ 'Configurator ID is not a string type: "' + typeof e + '"'
119
366
  );
120
- const t = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = t + "/configurators/" + s, i = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), n = () => {
367
+ const s = t.customApiUrl ? t.customApiUrl : "https://api.roomle.com/v2", r = t.overrideTenant || 9, n = s + "/configurators/" + e, o = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + o), i = () => {
121
368
  const g = {
122
- apiKey: i,
369
+ apiKey: o,
123
370
  currentTenant: r,
124
371
  locale: "en",
125
372
  language: "en",
@@ -128,60 +375,60 @@ const f = ".", _ = {
128
375
  platform: "web"
129
376
  };
130
377
  return new Headers(g);
131
- }, l = new Request(o, {
378
+ }, c = new Request(n, {
132
379
  method: "GET",
133
- headers: n(),
380
+ headers: i(),
134
381
  mode: "cors",
135
382
  cache: "default"
136
- }), u = await fetch(l), { configurator: d } = await u.json();
137
- return d;
138
- }, D = () => {
383
+ }), l = await fetch(c), { configurator: u } = await l.json();
384
+ return u;
385
+ }, ge = () => {
139
386
  try {
140
387
  return window.self !== window.top;
141
388
  } catch {
142
389
  return !0;
143
390
  }
144
- }, F = ["127.0.0.1", "localhost", "0.0.0.0"], B = () => {
145
- const s = D();
146
- let e = window.location.href;
147
- if (s) {
391
+ }, de = ["127.0.0.1", "localhost", "0.0.0.0"], fe = () => {
392
+ const e = ge();
393
+ let t = window.location.href;
394
+ if (e) {
148
395
  if (!document.referrer)
149
396
  return null;
150
- e = document.referrer;
397
+ t = document.referrer;
151
398
  }
152
- const { hostname: t } = new URL(e);
153
- return t;
154
- }, U = (s) => !!(F.includes(s) || s.endsWith("roomle.com") || s.endsWith("gitlab.io") || s.endsWith("gitlab.com")), T = [
399
+ const { hostname: s } = new URL(t);
400
+ return s;
401
+ }, he = (e) => !!(de.includes(e) || e.endsWith("roomle.com") || e.endsWith("gitlab.io") || e.endsWith("gitlab.com")), v = [
155
402
  "language",
156
403
  "browserLanguage",
157
404
  "userLanguage",
158
405
  "systemLanguage"
159
- ], W = (s = null) => {
160
- const e = window.navigator;
161
- if (s)
162
- return s.substr(0, 2);
163
- if (Array.isArray(e.languages) && e.languages.length > 0)
164
- return e.languages[0].substr(0, 2);
165
- for (let t = 0, r = T.length; t < r; t++) {
166
- const o = e[T[t]];
167
- if (o)
168
- return o.substr(0, 2);
406
+ ], me = (e = null) => {
407
+ const t = window.navigator;
408
+ if (e)
409
+ return e.substr(0, 2);
410
+ if (Array.isArray(t.languages) && t.languages.length > 0)
411
+ return t.languages[0].substr(0, 2);
412
+ for (let s = 0, r = v.length; s < r; s++) {
413
+ const n = t[v[s]];
414
+ if (n)
415
+ return n.substr(0, 2);
169
416
  }
170
417
  return "en";
171
- }, x = (s, e) => {
172
- const t = JSON.parse(JSON.stringify(s));
173
- return O(t, e);
174
- }, O = (s, e) => {
175
- for (const t in e)
418
+ }, pe = (e, t) => {
419
+ const s = JSON.parse(JSON.stringify(e));
420
+ return P(s, t);
421
+ }, P = (e, t) => {
422
+ for (const s in t)
176
423
  try {
177
- e[t].constructor === Object ? s[t] = O(s[t], e[t]) : s[t] = e[t];
424
+ t[s].constructor === Object ? e[s] = P(e[s], t[s]) : e[s] = t[s];
178
425
  } catch {
179
- s[t] = e[t];
426
+ e[s] = t[s];
180
427
  }
181
- return s;
428
+ return e;
182
429
  };
183
- var b = /* @__PURE__ */ ((s) => (s.BOTTOM_BAR = "bottom_bar", s.PARTLIST_BOUNDS = "partlist_bounds", s.INTERACTION_NOTES = "interaction_notes", s.PARAMETER_GROUPS = "parameter_groups", s))(b || {});
184
- const k = (s) => JSON.parse(JSON.stringify(s)), G = {
430
+ var Y = /* @__PURE__ */ ((e) => (e.BOTTOM_BAR = "bottom_bar", e.PARTLIST_BOUNDS = "partlist_bounds", e.INTERACTION_NOTES = "interaction_notes", e.PARAMETER_GROUPS = "parameter_groups", e))(Y || {});
431
+ const _e = (e) => JSON.parse(JSON.stringify(e)), Ee = {
185
432
  mobileLandscape: !0,
186
433
  floorMaterialRootTag: "materials_root",
187
434
  buttons: {
@@ -192,7 +439,7 @@ const k = (s) => JSON.parse(JSON.stringify(s)), G = {
192
439
  partlist_print: !0
193
440
  },
194
441
  elements: {
195
- [b.INTERACTION_NOTES]: !0
442
+ [Y.INTERACTION_NOTES]: !0
196
443
  },
197
444
  helpcenter: {
198
445
  roomdesigner: !0,
@@ -209,33 +456,33 @@ const k = (s) => JSON.parse(JSON.stringify(s)), G = {
209
456
  },
210
457
  rotationSnapDegrees: 10,
211
458
  interactionsCollapsed: !1
212
- }, J = "(idle)", V = (s) => (E(s), s?.customApiUrl && (s.customApiUrl = decodeURIComponent(s.customApiUrl)), s.shareUrl && (s.deeplink = s.shareUrl.replace(
213
- Y,
214
- q
215
- )), s), E = (s) => {
216
- if (!s)
459
+ }, we = "(idle)", ye = (e) => (I(e), e?.customApiUrl && (e.customApiUrl = decodeURIComponent(e.customApiUrl)), e.shareUrl && (e.deeplink = e.shareUrl.replace(
460
+ Me,
461
+ Te
462
+ )), e), I = (e) => {
463
+ if (!e)
217
464
  return;
218
- const e = Object.keys(s);
219
- for (const t of e) {
220
- const r = s[t];
221
- if (!Array.isArray(r) && typeof r == "object" && r !== null && E(r), Array.isArray(r))
222
- for (const o of r)
223
- E(o);
224
- (r === "true" || r === "false") && (s[t] = r === "true");
465
+ const t = Object.keys(e);
466
+ for (const s of t) {
467
+ const r = e[s];
468
+ if (!Array.isArray(r) && typeof r == "object" && r !== null && I(r), Array.isArray(r))
469
+ for (const n of r)
470
+ I(n);
471
+ (r === "true" || r === "false") && (e[s] = r === "true");
225
472
  }
226
- }, $ = (s, e) => {
227
- e.configuratorId = s.id;
228
- const t = s.settings || {};
229
- return !e.overrideTenant && s.tenant && (e.overrideTenant = s.tenant), x(t, e);
230
- }, z = () => {
231
- const s = k(G);
232
- s.locale || (s.locale = W()), s.id === J && delete s.id;
233
- const e = B();
234
- return e && U(e) && (s.configuratorId = "demoConfigurator"), s.customApiUrl = void 0, s.emails = !1, s;
235
- }, Y = "<CONF_ID>", q = "#CONFIGURATIONID#", K = (s) => {
236
- s.featureFlags || (s.featureFlags = {}), typeof s.featureFlags.realPartList != "boolean" && (s.featureFlags.realPartList = !0), typeof s.featureFlags.globalCallbacks != "boolean" && (s.featureFlags.globalCallbacks = !0), typeof s.featureFlags.mocAr != "boolean" && (s.featureFlags.mocAr = !1);
237
- }, y = () => /(android)/i.test(navigator.userAgent);
238
- class A {
473
+ }, Oe = (e, t) => {
474
+ t.configuratorId = e.id;
475
+ const s = e.settings || {};
476
+ return !t.overrideTenant && e.tenant && (t.overrideTenant = e.tenant), pe(s, t);
477
+ }, Se = () => {
478
+ const e = _e(Ee);
479
+ e.locale || (e.locale = me()), e.id === we && delete e.id;
480
+ const t = fe();
481
+ return t && he(t) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = void 0, e.emails = !1, e;
482
+ }, Me = "<CONF_ID>", Te = "#CONFIGURATIONID#", Ae = (e) => {
483
+ e.featureFlags || (e.featureFlags = {}), typeof e.featureFlags.realPartList != "boolean" && (e.featureFlags.realPartList = !0), typeof e.featureFlags.globalCallbacks != "boolean" && (e.featureFlags.globalCallbacks = !0), typeof e.featureFlags.mocAr != "boolean" && (e.featureFlags.mocAr = !1);
484
+ }, D = () => /(android)/i.test(navigator.userAgent);
485
+ class x {
239
486
  _messageHandler = null;
240
487
  isSetupDone = !1;
241
488
  viewName = "main";
@@ -259,149 +506,149 @@ class A {
259
506
  global = {
260
507
  callbacks: {}
261
508
  };
262
- setMessageHandler(e) {
263
- this._messageHandler = e;
509
+ setMessageHandler(t) {
510
+ this._messageHandler = t;
264
511
  }
265
- handleSetup(e) {
266
- const { methods: t, callbacks: r } = e;
267
- t.forEach((o) => {
268
- const i = o.split(f), a = i[0], n = i[1];
269
- this[a] || (this[a] = {}), this[a][n] = (function() {
512
+ handleSetup(t) {
513
+ const { methods: s, callbacks: r } = t;
514
+ s.forEach((n) => {
515
+ const o = n.split(T), a = o[0], i = o[1];
516
+ this[a] || (this[a] = {}), this[a][i] = (function() {
270
517
  if (!this._messageHandler) {
271
518
  console.error("MessageHandler not set");
272
519
  return;
273
520
  }
274
- return this._messageHandler.sendMessage(o, [...arguments]);
521
+ return this._messageHandler.sendMessage(n, [...arguments]);
275
522
  }).bind(this);
276
- }), r.forEach((o) => {
277
- const i = o.split(f), a = i[0], n = i[1], l = i[2];
278
- this[a] || (this[a] = {}), this[a][n] || (this[a][n] = {}), this[a][n][l] = () => {
523
+ }), r.forEach((n) => {
524
+ const o = n.split(T), a = o[0], i = o[1], c = o[2];
525
+ this[a] || (this[a] = {}), this[a][i] || (this[a][i] = {}), this[a][i][c] = () => {
279
526
  };
280
527
  }), this.isSetupDone = !0;
281
528
  }
282
- executeMessage({ message: e, args: t }) {
283
- const r = e.split(f), o = r[0], i = r[1], a = r.length === 3 ? r[2] : null;
284
- if (a && this[o][i][a]) {
285
- const n = this[o][i][a](
286
- ...t
529
+ executeMessage({ message: t, args: s }) {
530
+ const r = t.split(T), n = r[0], o = r[1], a = r.length === 3 ? r[2] : null;
531
+ if (a && this[n][o][a]) {
532
+ const i = this[n][o][a](
533
+ ...s
287
534
  );
288
- return n instanceof Promise ? n.then((l) => ({ result: l })) : n !== void 0 ? Promise.resolve({ result: n }) : Promise.resolve({ result: null });
535
+ return i instanceof Promise ? i.then((c) => ({ result: c })) : i !== void 0 ? Promise.resolve({ result: i }) : Promise.resolve({ result: null });
289
536
  }
290
- return Promise.reject('Message "' + e + '" is unkown');
537
+ return Promise.reject('Message "' + t + '" is unkown');
291
538
  }
292
- setupPlugins(e, t, r = "website") {
293
- for (const o of e)
294
- typeof o == "string" && o === "dragIn" ? this.pluginsLoaded.push(
295
- new Promise((i, a) => {
539
+ setupPlugins(t, s, r = "website") {
540
+ for (const n of t)
541
+ typeof n == "string" && n === "dragIn" ? this.pluginsLoaded.push(
542
+ new Promise((o, a) => {
296
543
  try {
297
- import("./drag-in-BEjBh6zz.mjs").then((n) => n.l).then(
298
- ({ DragIn: n }) => {
299
- const l = new n(
544
+ import("./drag-in-BEjBh6zz.mjs").then((i) => i.l).then(
545
+ ({ DragIn: i }) => {
546
+ const c = new i(
300
547
  this.ui,
301
- t,
548
+ s,
302
549
  r,
303
550
  this.viewName
304
551
  );
305
- l.init().then(() => {
306
- this.plugins.dragIn = l, i();
552
+ c.init().then(() => {
553
+ this.plugins.dragIn = c, o();
307
554
  }, a);
308
555
  }
309
556
  );
310
- } catch (n) {
311
- a(n);
557
+ } catch (i) {
558
+ a(i);
312
559
  }
313
560
  })
314
- ) : o.name && o.loader && this.pluginsLoaded.push(
315
- new Promise((i, a) => {
561
+ ) : n.name && n.loader && this.pluginsLoaded.push(
562
+ new Promise((o, a) => {
316
563
  try {
317
- o.loader().then((n) => {
318
- const l = new n(
564
+ n.loader().then((i) => {
565
+ const c = new i(
319
566
  this.ui,
320
- t,
567
+ s,
321
568
  r,
322
569
  this.viewName
323
570
  );
324
- l.init().then(() => {
325
- this.plugins[o.name] = l, i();
571
+ c.init().then(() => {
572
+ this.plugins[n.name] = c, o();
326
573
  }, a);
327
574
  });
328
- } catch (n) {
329
- a(n);
575
+ } catch (i) {
576
+ a(i);
330
577
  }
331
578
  })
332
579
  );
333
580
  }
334
581
  }
335
- const M = () => {
336
- let s, e;
337
- return { promise: new Promise((r, o) => {
338
- s = r, e = o;
339
- }), resolve: s, reject: e };
340
- }, R = (s, e, t) => {
582
+ const k = () => {
583
+ let e, t;
584
+ return { promise: new Promise((r, n) => {
585
+ e = r, t = n;
586
+ }), resolve: e, reject: t };
587
+ }, F = (e, t, s) => {
341
588
  let r = null;
342
- Object.defineProperty(s, e, {
589
+ Object.defineProperty(e, t, {
343
590
  get() {
344
- return r || t;
591
+ return r || s;
345
592
  },
346
- set(o) {
347
- o?.mute ? r = o.value : (console.warn(
593
+ set(n) {
594
+ n?.mute ? r = n.value : (console.warn(
348
595
  "You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"
349
- ), console.warn("{ mute: true, value: () => void }"), r = o);
596
+ ), console.warn("{ mute: true, value: () => void }"), r = n);
350
597
  }
351
598
  });
352
- }, L = () => window.innerHeight * 0.01 + "px", I = (s) => {
353
- s && setTimeout(
354
- () => s.style.setProperty(w, L()),
599
+ }, q = () => window.innerHeight * 0.01 + "px", U = (e) => {
600
+ e && setTimeout(
601
+ () => e.style.setProperty(N, q()),
355
602
  0
356
603
  );
357
- }, N = "rml-styles", Q = 450, w = "--rml-full-height", c = {
604
+ }, B = "rml-styles", Re = 450, N = "--rml-full-height", f = {
358
605
  CONTAINER: "rml-container",
359
606
  FILL: "rml-fill",
360
607
  POSITION: "rml-pos",
361
608
  TRANSITION: "rml-transition",
362
609
  ANDROID_HEIGHT: "rml-android-height",
363
610
  OVERFLOW_HIDDEN: "rml-overflow-hidden"
364
- }, p = /* @__PURE__ */ new Map();
365
- class X extends A {
366
- static createPlanner(e, t, r, o = []) {
611
+ }, R = /* @__PURE__ */ new Map();
612
+ class be extends x {
613
+ static createPlanner(t, s, r, n = []) {
367
614
  return this._create(
368
- e,
369
615
  t,
616
+ s,
370
617
  r,
371
- o
618
+ n
372
619
  );
373
620
  }
374
- static async connect(e, t = []) {
375
- const r = new A();
376
- r.viewName = e;
377
- const { resolve: o, promise: i } = M(), { resolve: a, promise: n } = M(), l = ({
621
+ static async connect(t, s = []) {
622
+ const r = new x();
623
+ r.viewName = t;
624
+ const { resolve: n, promise: o } = k(), { resolve: a, promise: i } = k(), c = ({
378
625
  message: g,
379
- args: h
626
+ args: d
380
627
  }) => {
381
628
  switch (g) {
382
- case m.REGISTER_CUSTOM_VIEW_DONE:
383
- o();
629
+ case E.REGISTER_CUSTOM_VIEW_DONE:
630
+ n();
384
631
  break;
385
- case m.RETURN_METHODS:
386
- r.handleSetup(h[0]), a();
632
+ case E.RETURN_METHODS:
633
+ r.handleSetup(d[0]), a();
387
634
  break;
388
635
  default:
389
636
  if (r.isSetupDone)
390
- return r.executeMessage({ message: g, args: h });
637
+ return r.executeMessage({ message: g, args: d });
391
638
  }
392
- }, u = new S(
393
- "custom-view-" + e,
639
+ }, l = new H(
640
+ "custom-view-" + t,
394
641
  window,
395
642
  window.parent,
396
- l
643
+ c
397
644
  );
398
- r.setMessageHandler(u);
399
- const d = [e];
400
- return u.sendMessage(
401
- m.REGISTER_CUSTOM_VIEW,
402
- d
403
- ), await i, u.sendMessage(m.GET_METHODS, d), await n, r.setupPlugins(
404
- t,
645
+ r.setMessageHandler(l);
646
+ const u = [t];
647
+ return l.sendMessage(
648
+ E.REGISTER_CUSTOM_VIEW,
649
+ u
650
+ ), await o, l.sendMessage(E.GET_METHODS, u), await i, r.setupPlugins(
651
+ s,
405
652
  document.body,
406
653
  "custom-view"
407
654
  ), await Promise.allSettled(r.pluginsLoaded), r;
@@ -412,12 +659,12 @@ class X extends A {
412
659
  * @param container DOM container in which the configurator should be placed
413
660
  * @param initData settings with which the configurator should be started
414
661
  */
415
- static createConfigurator(e, t, r, o = []) {
662
+ static createConfigurator(t, s, r, n = []) {
416
663
  return this._create(
417
- e,
418
664
  t,
665
+ s,
419
666
  r,
420
- o
667
+ n
421
668
  );
422
669
  }
423
670
  /**
@@ -427,12 +674,12 @@ class X extends A {
427
674
  * @param container DOM container in which the configurator should be placed
428
675
  * @param initData settings with which the configurator should be started
429
676
  */
430
- static create(e, t, r, o) {
677
+ static create(t, s, r, n) {
431
678
  return this._create(
432
- e,
433
679
  t,
680
+ s,
434
681
  r,
435
- o
682
+ n
436
683
  );
437
684
  }
438
685
  /**
@@ -441,37 +688,45 @@ class X extends A {
441
688
  * @param container DOM container in which the configurator should be placed
442
689
  * @param initData settings with which the configurator should be started
443
690
  */
444
- static createViewer(e, t, r, o = []) {
691
+ static createViewer(t, s, r, n = []) {
445
692
  return this._create(
446
- e,
447
693
  t,
694
+ s,
448
695
  r,
449
- o
696
+ n
450
697
  );
451
698
  }
452
- static async _create(e, t, r, o) {
453
- return new Promise(async (i, a) => {
699
+ static setupHi(t) {
700
+ window.addEventListener("message", (s) => {
701
+ if (s.data.type === "connect" && s.data.port) {
702
+ const r = s.data.port;
703
+ r.start?.(), L(t, r);
704
+ }
705
+ });
706
+ }
707
+ static async _create(t, s, r, n) {
708
+ return new Promise(async (o, a) => {
454
709
  try {
455
- const n = O(
456
- z(),
457
- V(r)
458
- );
459
- K(n);
460
- const l = await C(
461
- e,
462
- n
710
+ const i = P(
711
+ Se(),
712
+ ye(r)
463
713
  );
464
- r = $(l, n);
465
- const u = new this(
466
- l,
714
+ Ae(i);
715
+ const c = await ue(
467
716
  t,
468
- r,
469
- o,
470
717
  i
471
718
  );
472
- return await Promise.allSettled(u.pluginsLoaded), u;
473
- } catch (n) {
474
- return a(n);
719
+ r = Oe(c, i);
720
+ const l = new this(
721
+ c,
722
+ s,
723
+ r,
724
+ n,
725
+ o
726
+ );
727
+ return await Promise.allSettled(l.pluginsLoaded), l;
728
+ } catch (i) {
729
+ return a(i);
475
730
  }
476
731
  });
477
732
  }
@@ -480,66 +735,66 @@ class X extends A {
480
735
  _configuratorSettings;
481
736
  _initData = {};
482
737
  _iframe;
483
- constructor(e, t, r, o, i) {
484
- if (super(), !e || typeof e.id != "string")
738
+ constructor(t, s, r, n, o) {
739
+ if (super(), !t || typeof t.id != "string")
485
740
  throw new Error(
486
741
  "Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person"
487
742
  );
488
- if (p.has(t))
743
+ if (R.has(s))
489
744
  throw new Error("There is already an instance on this DOM element");
490
- if (!!!document.getElementById(N)) {
491
- const u = r.zIndex || 9999999, d = document.createElement("style");
492
- d.type = "text/css", d.id = N;
493
- const g = "transition:all ease-in-out " + Q + "ms;", h = ["-webkit-", "-o-"].reduce(
494
- (H, P) => H += P + g,
745
+ if (!!!document.getElementById(B)) {
746
+ const l = r.zIndex || 9999999, u = document.createElement("style");
747
+ u.type = "text/css", u.id = B;
748
+ const g = "transition:all ease-in-out " + Re + "ms;", d = ["-webkit-", "-o-"].reduce(
749
+ (K, Q) => K += Q + g,
495
750
  ""
496
- ) + g, v = L();
497
- d.innerHTML = `
498
- .${c.CONTAINER}{${w}:${v};}
499
- .${c.POSITION}{position:fixed;top:0;left:0;z-index:${u};opacity:0}
500
- .${c.TRANSITION}{${h}}
501
- .${c.FILL}{width:100%;height:100%;opacity:1}
502
- .${c.ANDROID_HEIGHT}{height:calc(var(${w},1vh)*100)}
503
- .${c.OVERFLOW_HIDDEN}{overflow:hidden}
504
- `, document.head.appendChild(d);
751
+ ) + g, h = q();
752
+ u.innerHTML = `
753
+ .${f.CONTAINER}{${N}:${h};}
754
+ .${f.POSITION}{position:fixed;top:0;left:0;z-index:${l};opacity:0}
755
+ .${f.TRANSITION}{${d}}
756
+ .${f.FILL}{width:100%;height:100%;opacity:1}
757
+ .${f.ANDROID_HEIGHT}{height:calc(var(${N},1vh)*100)}
758
+ .${f.OVERFLOW_HIDDEN}{overflow:hidden}
759
+ `, document.head.appendChild(u);
505
760
  }
506
761
  this._executeMessage = this._executeMessage.bind(this);
507
- const n = new S(
762
+ const i = new H(
508
763
  "website",
509
764
  window,
510
765
  null,
511
766
  this._executeMessage
512
767
  );
513
- this.setMessageHandler(n), this._onResize = this._onResize.bind(this), y() && window.addEventListener("resize", this._onResize), this._container = t, this._initData = r, this._configuratorSettings = e;
514
- const l = this._createIframe();
515
- this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = i, this._container.appendChild(l), this._iframe = l, this.setupPlugins(o, this._iframe), p.set(t, !0);
768
+ this.setMessageHandler(i), this._onResize = this._onResize.bind(this), D() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = t;
769
+ const c = this._createIframe();
770
+ this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = o, this._container.appendChild(c), this._iframe = c, this.setupPlugins(n, this._iframe), R.set(s, !0);
516
771
  }
517
772
  teardown() {
518
- this._container && p.delete(this._container);
519
- const e = this._container.querySelector("iframe");
520
- e && this._container.removeChild(e), window.removeEventListener("resize", this._onResize);
773
+ this._container && R.delete(this._container);
774
+ const t = this._container.querySelector("iframe");
775
+ t && this._container.removeChild(t), window.removeEventListener("resize", this._onResize);
521
776
  }
522
777
  _createIframe() {
523
- const e = document.createElement("iframe");
524
- let t = this._configuratorSettings?.url || "https://www.roomle.com/t/cp/";
525
- return this._initData.useLocalRoomle && (t = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (t = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (t = this._initData.overrideServerUrl), e.src = t, e.classList.add(c.CONTAINER), e.classList.add(c.FILL), e;
778
+ const t = document.createElement("iframe");
779
+ let s = this._configuratorSettings?.url || "https://www.roomle.com/t/cp/";
780
+ 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), t.src = s, t.classList.add(f.CONTAINER), t.classList.add(f.FILL), t;
526
781
  }
527
782
  _onResize() {
528
- I(this._iframe);
783
+ U(this._iframe);
529
784
  }
530
785
  _onUseFullPage() {
531
- this._iframe.classList.add(c.POSITION), document.documentElement.classList.add(c.OVERFLOW_HIDDEN), window.document.body.classList.add(c.OVERFLOW_HIDDEN), y() && (I(this._iframe), this._iframe.classList.add(c.ANDROID_HEIGHT));
786
+ this._iframe.classList.add(f.POSITION), document.documentElement.classList.add(f.OVERFLOW_HIDDEN), window.document.body.classList.add(f.OVERFLOW_HIDDEN), D() && (U(this._iframe), this._iframe.classList.add(f.ANDROID_HEIGHT));
532
787
  }
533
788
  _onBackToWebsite() {
534
- 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);
789
+ this._iframe.classList.remove(f.POSITION), this._iframe.classList.remove(f.ANDROID_HEIGHT), document.documentElement.classList.remove(f.OVERFLOW_HIDDEN), window.document.body.classList.remove(f.OVERFLOW_HIDDEN);
535
790
  }
536
- _executeMessage({ message: e, args: t }, r) {
791
+ _executeMessage({ message: t, args: s }, r) {
537
792
  if (r.source && r.source === this._iframe?.contentWindow)
538
- return e === _.REQUEST_BOOT ? this._messageHandler ? (this._messageHandler.setOutgoingMessageBus(r.source), Promise.resolve({ result: this._initData })) : (console.error("MessageHandler not set"), Promise.resolve({ error: "MessageHandler not set" })) : e === _.SETUP ? (this.handleSetup(t[0]), R(
793
+ return t === A.REQUEST_BOOT ? this._messageHandler ? (this._messageHandler.setOutgoingMessageBus(r.source), Promise.resolve({ result: this._initData })) : (console.error("MessageHandler not set"), Promise.resolve({ error: "MessageHandler not set" })) : t === A.SETUP ? (this.handleSetup(s[0]), F(
539
794
  this.ui.callbacks,
540
795
  "onUseFullPage",
541
796
  this._onUseFullPage
542
- ), R(
797
+ ), F(
543
798
  this.ui.callbacks,
544
799
  "onBackToWebsite",
545
800
  this._onBackToWebsite
@@ -548,10 +803,10 @@ class X extends A {
548
803
  console.error("MessageHandler not set");
549
804
  return;
550
805
  }
551
- this._messageHandler.sendMessage(_.WEBSITE_READY);
552
- }, 0), Promise.resolve({ result: null })) : this.executeMessage({ message: e, args: t });
806
+ this._messageHandler.sendMessage(A.WEBSITE_READY);
807
+ }, 0), Promise.resolve({ result: null })) : this.executeMessage({ message: t, args: s });
553
808
  }
554
809
  }
555
810
  export {
556
- X as default
811
+ be as default
557
812
  };