@roomle/embedding-lib 5.7.1 → 5.8.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,6 +1,14 @@
1
- ## [5.7.1](https://github.com/roomle-dev/roomle-ui/compare/embedding-lib-v5.7.0...embedding-lib-v5.7.1) (2024-11-28)
1
+ ## [5.8.0-alpha.2](https://github.com/roomle-dev/roomle-ui/compare/embedding-lib-v5.8.0-alpha.1...embedding-lib-v5.8.0-alpha.2) (2024-11-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * Make behaviour of tooltips more flexible ([5b08e7a](https://github.com/roomle-dev/roomle-ui/commit/5b08e7a08ceeeb8c089ca52344b399c085a74b7d))
7
+ * **SDK:** upgrade to version 2.90.0-alpha.2 ([#1370](https://github.com/roomle-dev/roomle-ui/issues/1370)) ([25e00ba](https://github.com/roomle-dev/roomle-ui/commit/25e00ba29c6f9c7378be9491bc5268af96f8cc54))
2
8
 
3
9
 
4
10
  ### Bug Fixes
5
11
 
6
- * **hot-fix:** make api=false possible again ([2950f92](https://github.com/roomle-dev/roomle-ui/commit/2950f92e88361fc9bdffb09da8c20c67c5a7b553))
12
+ * add some space on the top to the interaction notes in case of planner inside edit mode ([611bfa9](https://github.com/roomle-dev/roomle-ui/commit/611bfa931ef9d122b1c62ea0c55e14f1a290a3d6))
13
+ * Drawer-toggle rotates wrong when second level drawer is active ([3a8f66c](https://github.com/roomle-dev/roomle-ui/commit/3a8f66cc469cbed9978b6507ddc3eb51374bdd20))
14
+ * make hide interaction note flag hidden by default ([4abae62](https://github.com/roomle-dev/roomle-ui/commit/4abae623c2e0d7f33fd3763c2ce89e8b498b7566))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomle/embedding-lib",
3
- "version": "5.7.1",
3
+ "version": "5.8.0-alpha.2",
4
4
  "description": "This is a small library which can be used to communicate with the Roomle Configurator",
5
5
  "type": "module",
6
6
  "main": "./roomle-embedding-lib.umd.js",
@@ -29,7 +29,7 @@
29
29
  "npm": "8.3.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@roomle/web-sdk": "2.89.0"
32
+ "@roomle/web-sdk": "2.90.0-alpha.2"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
@@ -1,32 +1,32 @@
1
- var C = Object.defineProperty;
2
- var F = (s, t, e) => t in s ? C(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var c = (s, t, e) => F(s, typeof t != "symbol" ? t + "" : t, e);
4
- class y {
5
- constructor(t, e, o, r) {
1
+ var F = Object.defineProperty;
2
+ var B = (t, s, e) => s in t ? F(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
3
+ var c = (t, s, e) => B(t, typeof s != "symbol" ? s + "" : s, e);
4
+ class T {
5
+ constructor(s, e, n, r) {
6
6
  c(this, "_side");
7
7
  // for better debugging (who handles message? iframe or website?)
8
8
  c(this, "_incomingMessageBus", null);
9
9
  c(this, "_outgoingMessageBus", null);
10
10
  c(this, "_execMessage", null);
11
- this._side = t, this._incomingMessageBus = e, this._outgoingMessageBus = o, this._execMessage = r, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
11
+ this._side = s, this._incomingMessageBus = e, this._outgoingMessageBus = n, this._execMessage = r, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
12
12
  "message",
13
13
  this._handleMessage.bind(this)
14
14
  );
15
15
  }
16
- setOutgoingMessageBus(t) {
17
- this._outgoingMessageBus = t;
16
+ setOutgoingMessageBus(s) {
17
+ this._outgoingMessageBus = s;
18
18
  }
19
- setMessageExecution(t) {
20
- this._execMessage = t;
19
+ setMessageExecution(s) {
20
+ this._execMessage = s;
21
21
  }
22
- sendMessage(t, e = []) {
23
- return new Promise((o, r) => {
22
+ sendMessage(s, e = []) {
23
+ return new Promise((n, r) => {
24
24
  if (this._incomingMessageBus === this._outgoingMessageBus)
25
- return o(void 0);
26
- const n = new MessageChannel();
27
- n.port1.onmessage = (i) => {
25
+ return n(void 0);
26
+ const o = new MessageChannel();
27
+ o.port1.onmessage = (i) => {
28
28
  if (!i || !i.data)
29
- return n.port1.close(), n.port2.close(), r(
29
+ return o.port1.close(), o.port2.close(), r(
30
30
  new Error(
31
31
  this._side + " received message but response can not be interpreted"
32
32
  )
@@ -35,13 +35,13 @@ class y {
35
35
  try {
36
36
  l = JSON.parse(i.data);
37
37
  } catch (d) {
38
- return n.port1.close(), n.port2.close(), this._prepareError(d), r(d);
38
+ return o.port1.close(), o.port2.close(), this._prepareError(d), r(d);
39
39
  }
40
- l.error ? r(l.error) : l.result !== void 0 ? o(l.result) : o(void 0), n.port1.close(), n.port2.close();
40
+ l.error ? r(l.error) : l.result !== void 0 ? n(l.result) : n(void 0), o.port1.close(), o.port2.close();
41
41
  };
42
42
  let a = "";
43
43
  try {
44
- a = JSON.stringify({ message: t, args: e });
44
+ a = JSON.stringify({ message: s, args: e });
45
45
  } catch {
46
46
  return r(
47
47
  new Error(
@@ -52,58 +52,58 @@ class y {
52
52
  if (!this._outgoingMessageBus)
53
53
  return r(new Error(this._side + ": outgoing bus not set yet"));
54
54
  this._outgoingMessageBus.postMessage(a, "*", [
55
- n.port2
55
+ o.port2
56
56
  ]);
57
57
  });
58
58
  }
59
- _handleMessage(t) {
60
- const e = t.ports && Array.isArray(t.ports) && t.ports.length > 0 ? t.ports[0] : null;
61
- if (t.data && e)
59
+ _handleMessage(s) {
60
+ const e = s.ports && Array.isArray(s.ports) && s.ports.length > 0 ? s.ports[0] : null;
61
+ if (s.data && e)
62
62
  try {
63
- const o = JSON.parse(t.data);
63
+ const n = JSON.parse(s.data);
64
64
  if (!this._execMessage)
65
65
  return e.postMessage(
66
66
  JSON.stringify({
67
67
  error: this._side + " is not ready to handle messages"
68
68
  })
69
69
  );
70
- Array.isArray(o.args) || (o.args = [o.args]);
71
- const r = this._execMessage(o, t);
70
+ Array.isArray(n.args) || (n.args = [n.args]);
71
+ const r = this._execMessage(n, s);
72
72
  if (r === void 0)
73
73
  return;
74
74
  r.then(
75
- (n = {}) => {
75
+ (o = {}) => {
76
76
  let a, i;
77
- typeof n == "object" && n !== null && (a = n.error, i = n.result), a ? e.postMessage(
77
+ typeof o == "object" && o !== null && (a = o.error, i = o.result), a ? e.postMessage(
78
78
  JSON.stringify({ error: a })
79
79
  ) : i !== void 0 ? e.postMessage(
80
80
  JSON.stringify({ result: i })
81
81
  ) : e.postMessage(
82
- JSON.stringify({ result: n })
82
+ JSON.stringify({ result: o })
83
83
  );
84
84
  },
85
- (n) => {
85
+ (o) => {
86
86
  e.postMessage(
87
87
  JSON.stringify({
88
- error: this._prepareError(n)
88
+ error: this._prepareError(o)
89
89
  })
90
90
  );
91
91
  }
92
92
  );
93
- } catch (o) {
93
+ } catch (n) {
94
94
  e.postMessage(
95
95
  JSON.stringify({
96
- error: this._prepareError(o)
96
+ error: this._prepareError(n)
97
97
  })
98
98
  );
99
99
  }
100
100
  }
101
- _prepareError(t) {
102
- if (typeof t == "string") {
103
- const e = this._side + ": " + t;
101
+ _prepareError(s) {
102
+ if (typeof s == "string") {
103
+ const e = this._side + ": " + s;
104
104
  return console.error(e), e;
105
105
  }
106
- return t.message = this._side + ": " + t.message, console.error(t), t.message;
106
+ return s.message = this._side + ": " + s.message, console.error(s), s.message;
107
107
  }
108
108
  }
109
109
  const p = ".", E = {
@@ -115,15 +115,15 @@ const p = ".", E = {
115
115
  RETURN_METHODS: "returnMethods",
116
116
  REGISTER_CUSTOM_VIEW: "registerCustomView",
117
117
  REGISTER_CUSTOM_VIEW_DONE: "registerCustomViewDone"
118
- }, U = async (s, t) => {
119
- if (typeof s != "string")
118
+ }, U = async (t, s) => {
119
+ if (typeof t != "string")
120
120
  throw new Error(
121
- 'Configurator ID is not a string type: "' + typeof s + '"'
121
+ 'Configurator ID is not a string type: "' + typeof t + '"'
122
122
  );
123
- const e = t.customApiUrl ? t.customApiUrl : "https://api.roomle.com/v2", o = t.overrideTenant || 9, r = e + "/configurators/" + s, n = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + n), i = () => {
123
+ const e = s.customApiUrl ? s.customApiUrl : "https://api.roomle.com/v2", n = s.overrideTenant || 9, r = e + "/configurators/" + t, o = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + o), i = () => {
124
124
  const h = {
125
- apiKey: n,
126
- currentTenant: o,
125
+ apiKey: o,
126
+ currentTenant: n,
127
127
  locale: "en",
128
128
  language: "en",
129
129
  device: 1,
@@ -138,53 +138,53 @@ const p = ".", E = {
138
138
  cache: "default"
139
139
  }), d = await fetch(l), { configurator: g } = await d.json();
140
140
  return g;
141
- }, B = () => {
141
+ }, k = () => {
142
142
  try {
143
143
  return window.self !== window.top;
144
144
  } catch {
145
145
  return !0;
146
146
  }
147
147
  }, W = ["127.0.0.1", "localhost", "0.0.0.0"], x = () => {
148
- const s = B();
149
- let t = window.location.href;
150
- if (s) {
148
+ const t = k();
149
+ let s = window.location.href;
150
+ if (t) {
151
151
  if (!document.referrer)
152
152
  return null;
153
- t = document.referrer;
153
+ s = document.referrer;
154
154
  }
155
- const { hostname: e } = new URL(t);
155
+ const { hostname: e } = new URL(s);
156
156
  return e;
157
- }, k = (s) => !!(W.includes(s) || s.endsWith("roomle.com") || s.endsWith("gitlab.io") || s.endsWith("gitlab.com")), I = [
157
+ }, G = (t) => !!(W.includes(t) || t.endsWith("roomle.com") || t.endsWith("gitlab.io") || t.endsWith("gitlab.com")), R = [
158
158
  "language",
159
159
  "browserLanguage",
160
160
  "userLanguage",
161
161
  "systemLanguage"
162
- ], G = (s = null) => {
163
- const t = window.navigator;
164
- if (s)
165
- return s.substr(0, 2);
166
- if (Array.isArray(t.languages) && t.languages.length > 0)
167
- return t.languages[0].substr(0, 2);
168
- for (let e = 0, o = I.length; e < o; e++) {
169
- const r = t[I[e]];
162
+ ], V = (t = null) => {
163
+ const s = window.navigator;
164
+ if (t)
165
+ return t.substr(0, 2);
166
+ if (Array.isArray(s.languages) && s.languages.length > 0)
167
+ return s.languages[0].substr(0, 2);
168
+ for (let e = 0, n = R.length; e < n; e++) {
169
+ const r = s[R[e]];
170
170
  if (r)
171
171
  return r.substr(0, 2);
172
172
  }
173
173
  return "en";
174
- }, V = (s, t) => {
175
- const e = JSON.parse(JSON.stringify(s));
176
- return M(e, t);
177
- }, M = (s, t) => {
178
- for (const e in t)
174
+ }, J = (t, s) => {
175
+ const e = JSON.parse(JSON.stringify(t));
176
+ return S(e, s);
177
+ }, S = (t, s) => {
178
+ for (const e in s)
179
179
  try {
180
- t[e].constructor === Object ? s[e] = M(s[e], t[e]) : s[e] = t[e];
180
+ s[e].constructor === Object ? t[e] = S(t[e], s[e]) : t[e] = s[e];
181
181
  } catch {
182
- s[e] = t[e];
182
+ t[e] = s[e];
183
183
  }
184
- return s;
184
+ return t;
185
185
  };
186
- var J = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
187
- const $ = {
186
+ var v = /* @__PURE__ */ ((t) => (t.BOTTOM_BAR = "bottom_bar", t.PARTLIST_BOUNDS = "partlist_bounds", t.INTERACTION_NOTES = "interaction_notes", t))(v || {}), $ = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
187
+ const z = {
188
188
  mobileLandscape: !0,
189
189
  floorMaterialRootTag: "materials_root",
190
190
  buttons: {
@@ -194,6 +194,9 @@ const $ = {
194
194
  load_product: !0,
195
195
  partlist_print: !0
196
196
  },
197
+ elements: {
198
+ [v.INTERACTION_NOTES]: !1
199
+ },
197
200
  helpcenter: {
198
201
  roomdesigner: !0,
199
202
  configurator: !1,
@@ -206,35 +209,33 @@ const $ = {
206
209
  wallAutoHeight: !1
207
210
  },
208
211
  rotationSnapDegrees: 10
209
- }, z = "(idle)", Y = (s) => (O(s), s != null && s.customApiUrl && (s.customApiUrl = decodeURIComponent(s.customApiUrl)), s.shareUrl && (s.deeplink = s.shareUrl.replace(
210
- Q,
211
- X
212
- )), s), O = (s) => {
213
- if (!s)
212
+ }, Y = "(idle)", q = (t) => (O(t), t != null && t.customApiUrl && (t.customApiUrl = decodeURIComponent(t.customApiUrl)), t.shareUrl && (t.deeplink = t.shareUrl.replace(
213
+ X,
214
+ Z
215
+ )), t), O = (t) => {
216
+ if (!t)
214
217
  return;
215
- const t = Object.keys(s);
216
- for (const e of t) {
217
- const o = s[e];
218
- if (!Array.isArray(o) && typeof o == "object" && o !== null && O(o), Array.isArray(o))
219
- for (const r of o)
218
+ const s = Object.keys(t);
219
+ for (const e of s) {
220
+ const n = t[e];
221
+ if (!Array.isArray(n) && typeof n == "object" && n !== null && O(n), Array.isArray(n))
222
+ for (const r of n)
220
223
  O(r);
221
- (o === "true" || o === "false") && (s[e] = o === "true");
224
+ (n === "true" || n === "false") && (t[e] = n === "true");
222
225
  }
223
- }, q = (s, t) => {
224
- t.configuratorId = s.id;
225
- const e = s.settings || {};
226
- return !t.overrideTenant && s.tenant && (t.overrideTenant = s.tenant), V(e, t);
227
- }, K = () => {
228
- const s = {
229
- ...$
226
+ }, K = (t, s) => {
227
+ s.configuratorId = t.id;
228
+ const e = t.settings || {};
229
+ return !s.overrideTenant && t.tenant && (s.overrideTenant = t.tenant), J(e, s);
230
+ }, Q = () => {
231
+ const t = {
232
+ ...z
230
233
  };
231
- s.locale || (s.locale = G()), s.id === z && delete s.id;
232
- const t = x();
233
- return t && k(t) && (s.configuratorId = "demoConfigurator"), s.customApiUrl = J.VITE_RAPI_URL, s.emails = !1, s;
234
- }, Q = "<CONF_ID>", X = "#CONFIGURATIONID#", Z = (s) => {
235
- 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);
236
- }, R = () => /(android)/i.test(navigator.userAgent);
237
- class A {
234
+ t.locale || (t.locale = V()), t.id === Y && delete t.id;
235
+ const s = x();
236
+ return s && G(s) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = $.VITE_RAPI_URL, t.emails = !1, t;
237
+ }, X = "<CONF_ID>", Z = "#CONFIGURATIONID#", M = () => /(android)/i.test(navigator.userAgent);
238
+ class y {
238
239
  constructor() {
239
240
  c(this, "_messageHandler", null);
240
241
  c(this, "isSetupDone", !1);
@@ -257,13 +258,13 @@ class A {
257
258
  callbacks: {}
258
259
  });
259
260
  }
260
- setMessageHandler(t) {
261
- this._messageHandler = t;
261
+ setMessageHandler(s) {
262
+ this._messageHandler = s;
262
263
  }
263
- handleSetup(t) {
264
- const { methods: e, callbacks: o } = t;
264
+ handleSetup(s) {
265
+ const { methods: e, callbacks: n } = s;
265
266
  e.forEach((r) => {
266
- const n = r.split(p), a = n[0], i = n[1];
267
+ const o = r.split(p), a = o[0], i = o[1];
267
268
  this[a] || (this[a] = {}), this[a][i] = (function() {
268
269
  if (!this._messageHandler) {
269
270
  console.error("MessageHandler not set");
@@ -271,37 +272,37 @@ class A {
271
272
  }
272
273
  return this._messageHandler.sendMessage(r, [...arguments]);
273
274
  }).bind(this);
274
- }), o.forEach((r) => {
275
- const n = r.split(p), a = n[0], i = n[1], l = n[2];
275
+ }), n.forEach((r) => {
276
+ const o = r.split(p), a = o[0], i = o[1], l = o[2];
276
277
  this[a] || (this[a] = {}), this[a][i] || (this[a][i] = {}), this[a][i][l] = () => {
277
278
  };
278
279
  }), this.isSetupDone = !0;
279
280
  }
280
- executeMessage({ message: t, args: e }) {
281
- const o = t.split(p), r = o[0], n = o[1], a = o.length === 3 ? o[2] : null;
282
- if (a && this[r][n][a]) {
283
- const i = this[r][n][a](
281
+ executeMessage({ message: s, args: e }) {
282
+ const n = s.split(p), r = n[0], o = n[1], a = n.length === 3 ? n[2] : null;
283
+ if (a && this[r][o][a]) {
284
+ const i = this[r][o][a](
284
285
  ...e
285
286
  );
286
287
  return i instanceof Promise ? i.then((l) => ({ result: l })) : i !== void 0 ? Promise.resolve({ result: i }) : Promise.resolve({ result: null });
287
288
  }
288
- return Promise.reject('Message "' + t + '" is unkown');
289
+ return Promise.reject('Message "' + s + '" is unkown');
289
290
  }
290
- setupPlugins(t, e, o = "website") {
291
- for (const r of t)
291
+ setupPlugins(s, e, n = "website") {
292
+ for (const r of s)
292
293
  typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(
293
- new Promise((n, a) => {
294
+ new Promise((o, a) => {
294
295
  try {
295
296
  import("./drag-in-Do47zdKL.mjs").then((i) => i.l).then(
296
297
  ({ DragIn: i }) => {
297
298
  const l = new i(
298
299
  this.ui,
299
300
  e,
300
- o,
301
+ n,
301
302
  this.viewName
302
303
  );
303
304
  l.init().then(() => {
304
- this.plugins.dragIn = l, n();
305
+ this.plugins.dragIn = l, o();
305
306
  }, a);
306
307
  }
307
308
  );
@@ -310,17 +311,17 @@ class A {
310
311
  }
311
312
  })
312
313
  ) : r.name && r.loader && this.pluginsLoaded.push(
313
- new Promise((n, a) => {
314
+ new Promise((o, a) => {
314
315
  try {
315
316
  r.loader().then((i) => {
316
317
  const l = new i(
317
318
  this.ui,
318
319
  e,
319
- o,
320
+ n,
320
321
  this.viewName
321
322
  );
322
323
  l.init().then(() => {
323
- this.plugins[r.name] = l, n();
324
+ this.plugins[r.name] = l, o();
324
325
  }, a);
325
326
  });
326
327
  } catch (i) {
@@ -330,29 +331,29 @@ class A {
330
331
  );
331
332
  }
332
333
  }
333
- const T = () => {
334
- let s, t;
335
- return { promise: new Promise((o, r) => {
336
- s = o, t = r;
337
- }), resolve: s, reject: t };
338
- }, N = (s, t, e) => {
339
- let o = null;
340
- Object.defineProperty(s, t, {
334
+ const A = () => {
335
+ let t, s;
336
+ return { promise: new Promise((n, r) => {
337
+ t = n, s = r;
338
+ }), resolve: t, reject: s };
339
+ }, N = (t, s, e) => {
340
+ let n = null;
341
+ Object.defineProperty(t, s, {
341
342
  get() {
342
- return o || e;
343
+ return n || e;
343
344
  },
344
345
  set(r) {
345
- r != null && r.mute ? o = r.value : (console.warn(
346
+ r != null && r.mute ? n = r.value : (console.warn(
346
347
  "You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"
347
- ), console.warn("{ mute: true, value: () => void }"), o = r);
348
+ ), console.warn("{ mute: true, value: () => void }"), n = r);
348
349
  }
349
350
  });
350
- }, b = () => window.innerHeight * 0.01 + "px", L = (s) => {
351
- s && setTimeout(
352
- () => s.style.setProperty(S, b()),
351
+ }, H = () => window.innerHeight * 0.01 + "px", b = (t) => {
352
+ t && setTimeout(
353
+ () => t.style.setProperty(I, H()),
353
354
  0
354
355
  );
355
- }, v = "rml-styles", j = 450, S = "--rml-full-height", u = {
356
+ }, L = "rml-styles", j = 450, I = "--rml-full-height", u = {
356
357
  CONTAINER: "rml-container",
357
358
  FILL: "rml-fill",
358
359
  POSITION: "rml-pos",
@@ -360,8 +361,8 @@ const T = () => {
360
361
  ANDROID_HEIGHT: "rml-android-height",
361
362
  OVERFLOW_HIDDEN: "rml-overflow-hidden"
362
363
  }, w = /* @__PURE__ */ new Map();
363
- class se extends A {
364
- constructor(e, o, r, n, a) {
364
+ class se extends y {
365
+ constructor(e, n, r, o, a) {
365
366
  super();
366
367
  c(this, "_waitForIframe");
367
368
  c(this, "_container");
@@ -372,62 +373,62 @@ class se extends A {
372
373
  throw new Error(
373
374
  "Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person"
374
375
  );
375
- if (w.has(o))
376
+ if (w.has(n))
376
377
  throw new Error("There is already an instance on this DOM element");
377
- if (!!!document.getElementById(v)) {
378
+ if (!!!document.getElementById(L)) {
378
379
  const g = r.zIndex || 9999999, h = document.createElement("style");
379
- h.type = "text/css", h.id = v;
380
- const m = "transition:all ease-in-out " + j + "ms;", f = ["-webkit-", "-o-"].reduce(
381
- (P, D) => P += D + m,
380
+ h.type = "text/css", h.id = L;
381
+ const f = "transition:all ease-in-out " + j + "ms;", m = ["-webkit-", "-o-"].reduce(
382
+ (D, C) => D += C + f,
382
383
  ""
383
- ) + m, H = b();
384
+ ) + f, P = H();
384
385
  h.innerHTML = `
385
- .${u.CONTAINER}{${S}:${H};}
386
+ .${u.CONTAINER}{${I}:${P};}
386
387
  .${u.POSITION}{position:fixed;top:0;left:0;z-index:${g};opacity:0}
387
- .${u.TRANSITION}{${f}}
388
+ .${u.TRANSITION}{${m}}
388
389
  .${u.FILL}{width:100%;height:100%;opacity:1}
389
- .${u.ANDROID_HEIGHT}{height:calc(var(${S},1vh)*100)}
390
+ .${u.ANDROID_HEIGHT}{height:calc(var(${I},1vh)*100)}
390
391
  .${u.OVERFLOW_HIDDEN}{overflow:hidden}
391
392
  `, document.head.appendChild(h);
392
393
  }
393
394
  this._executeMessage = this._executeMessage.bind(this);
394
- const l = new y(
395
+ const l = new T(
395
396
  "website",
396
397
  window,
397
398
  null,
398
399
  this._executeMessage
399
400
  );
400
- this.setMessageHandler(l), this._onResize = this._onResize.bind(this), R() && window.addEventListener("resize", this._onResize), this._container = o, this._initData = r, this._configuratorSettings = e;
401
+ this.setMessageHandler(l), this._onResize = this._onResize.bind(this), M() && window.addEventListener("resize", this._onResize), this._container = n, this._initData = r, this._configuratorSettings = e;
401
402
  const d = this._createIframe();
402
- this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = a, this._container.appendChild(d), this._iframe = d, this.setupPlugins(n, this._iframe), w.set(o, !0);
403
+ this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = a, this._container.appendChild(d), this._iframe = d, this.setupPlugins(o, this._iframe), w.set(n, !0);
403
404
  }
404
- static createPlanner(e, o, r, n = []) {
405
+ static createPlanner(e, n, r, o = []) {
405
406
  return this._create(
406
407
  e,
407
- o,
408
+ n,
408
409
  r,
409
- n
410
+ o
410
411
  );
411
412
  }
412
- static async connect(e, o = []) {
413
- const r = new A();
413
+ static async connect(e, n = []) {
414
+ const r = new y();
414
415
  r.viewName = e;
415
- const { resolve: n, promise: a } = T(), { resolve: i, promise: l } = T(), d = ({
416
- message: m,
417
- args: f
416
+ const { resolve: o, promise: a } = A(), { resolve: i, promise: l } = A(), d = ({
417
+ message: f,
418
+ args: m
418
419
  }) => {
419
- switch (m) {
420
+ switch (f) {
420
421
  case _.REGISTER_CUSTOM_VIEW_DONE:
421
- n();
422
+ o();
422
423
  break;
423
424
  case _.RETURN_METHODS:
424
- r.handleSetup(f[0]), i();
425
+ r.handleSetup(m[0]), i();
425
426
  break;
426
427
  default:
427
428
  if (r.isSetupDone)
428
- return r.executeMessage({ message: m, args: f });
429
+ return r.executeMessage({ message: f, args: m });
429
430
  }
430
- }, g = new y(
431
+ }, g = new T(
431
432
  "custom-view-" + e,
432
433
  window,
433
434
  window.parent,
@@ -439,7 +440,7 @@ class se extends A {
439
440
  _.REGISTER_CUSTOM_VIEW,
440
441
  h
441
442
  ), await a, g.sendMessage(_.GET_METHODS, h), await l, r.setupPlugins(
442
- o,
443
+ n,
443
444
  document.body,
444
445
  "custom-view"
445
446
  ), await Promise.allSettled(r.pluginsLoaded), r;
@@ -450,12 +451,12 @@ class se extends A {
450
451
  * @param container DOM container in which the configurator should be placed
451
452
  * @param initData settings with which the configurator should be started
452
453
  */
453
- static createConfigurator(e, o, r, n = []) {
454
+ static createConfigurator(e, n, r, o = []) {
454
455
  return this._create(
455
456
  e,
456
- o,
457
+ n,
457
458
  r,
458
- n
459
+ o
459
460
  );
460
461
  }
461
462
  /**
@@ -465,12 +466,12 @@ class se extends A {
465
466
  * @param container DOM container in which the configurator should be placed
466
467
  * @param initData settings with which the configurator should be started
467
468
  */
468
- static create(e, o, r, n) {
469
+ static create(e, n, r, o) {
469
470
  return this._create(
470
471
  e,
471
- o,
472
+ n,
472
473
  r,
473
- n
474
+ o
474
475
  );
475
476
  }
476
477
  /**
@@ -479,32 +480,32 @@ class se extends A {
479
480
  * @param container DOM container in which the configurator should be placed
480
481
  * @param initData settings with which the configurator should be started
481
482
  */
482
- static createViewer(e, o, r, n = []) {
483
+ static createViewer(e, n, r, o = []) {
483
484
  return this._create(
484
485
  e,
485
- o,
486
+ n,
486
487
  r,
487
- n
488
+ o
488
489
  );
489
490
  }
490
- static async _create(e, o, r, n) {
491
+ static async _create(e, n, r, o) {
491
492
  return new Promise(async (a, i) => {
492
493
  try {
493
- const l = M(
494
- K(),
495
- Y(r)
494
+ const l = S(
495
+ Q(),
496
+ q(r)
496
497
  );
497
- Z(l);
498
+ l.featureFlags || (l.featureFlags = {}), typeof l.featureFlags.realPartList != "boolean" && (l.featureFlags.realPartList = !0), typeof l.featureFlags.globalCallbacks != "boolean" && (l.featureFlags.globalCallbacks = !0), typeof l.featureFlags.mocAr != "boolean" && (l.featureFlags.mocAr = !1);
498
499
  const d = await U(
499
500
  e,
500
501
  l
501
502
  );
502
- r = q(d, l);
503
+ r = K(d, l);
503
504
  const g = new this(
504
505
  d,
505
- o,
506
- r,
507
506
  n,
507
+ r,
508
+ o,
508
509
  a
509
510
  );
510
511
  return await Promise.allSettled(g.pluginsLoaded), g;
@@ -521,22 +522,22 @@ class se extends A {
521
522
  _createIframe() {
522
523
  var r;
523
524
  const e = document.createElement("iframe");
524
- let o = ((r = this._configuratorSettings) == null ? void 0 : r.url) || "https://www.roomle.com/t/cp/";
525
- return this._initData.useLocalRoomle && (o = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (o = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (o = this._initData.overrideServerUrl), e.src = o, e.classList.add(u.CONTAINER), e.classList.add(u.FILL), e;
525
+ let n = ((r = this._configuratorSettings) == null ? void 0 : r.url) || "https://www.roomle.com/t/cp/";
526
+ return this._initData.useLocalRoomle && (n = location.href.replace("embedding.html", "")), location.href.includes("roomle.gitlab.io") && (n = location.href.replace("embedding.html", "index.html")), this._initData.overrideServerUrl && (n = this._initData.overrideServerUrl), e.src = n, e.classList.add(u.CONTAINER), e.classList.add(u.FILL), e;
526
527
  }
527
528
  _onResize() {
528
- L(this._iframe);
529
+ b(this._iframe);
529
530
  }
530
531
  _onUseFullPage() {
531
- this._iframe.classList.add(u.POSITION), document.documentElement.classList.add(u.OVERFLOW_HIDDEN), window.document.body.classList.add(u.OVERFLOW_HIDDEN), R() && (L(this._iframe), this._iframe.classList.add(u.ANDROID_HEIGHT));
532
+ this._iframe.classList.add(u.POSITION), document.documentElement.classList.add(u.OVERFLOW_HIDDEN), window.document.body.classList.add(u.OVERFLOW_HIDDEN), M() && (b(this._iframe), this._iframe.classList.add(u.ANDROID_HEIGHT));
532
533
  }
533
534
  _onBackToWebsite() {
534
535
  this._iframe.classList.remove(u.POSITION), this._iframe.classList.remove(u.ANDROID_HEIGHT), document.documentElement.classList.remove(u.OVERFLOW_HIDDEN), window.document.body.classList.remove(u.OVERFLOW_HIDDEN);
535
536
  }
536
- _executeMessage({ message: e, args: o }, r) {
537
- var n;
538
- if (r.source && r.source === ((n = this._iframe) == null ? void 0 : n.contentWindow))
539
- return e === 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 === E.SETUP ? (this.handleSetup(o[0]), N(
537
+ _executeMessage({ message: e, args: n }, r) {
538
+ var o;
539
+ if (r.source && r.source === ((o = this._iframe) == null ? void 0 : o.contentWindow))
540
+ return e === 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 === E.SETUP ? (this.handleSetup(n[0]), N(
540
541
  this.ui.callbacks,
541
542
  "onUseFullPage",
542
543
  this._onUseFullPage
@@ -550,7 +551,7 @@ class se extends A {
550
551
  return;
551
552
  }
552
553
  this._messageHandler.sendMessage(E.WEBSITE_READY);
553
- }, 0), Promise.resolve({ result: null })) : this.executeMessage({ message: e, args: o });
554
+ }, 0), Promise.resolve({ result: null })) : this.executeMessage({ message: e, args: n });
554
555
  }
555
556
  }
556
557
  export {
@@ -1,8 +1,8 @@
1
- var H=Object.defineProperty,A=(s,e,t)=>e in s?H(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,c=(s,e,t)=>A(s,typeof e!="symbol"?e+"":e,t);class O{constructor(e,t,r,i){c(this,"_side"),c(this,"_incomingMessageBus",null),c(this,"_outgoingMessageBus",null),c(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus&&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)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return r(void 0);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 l;try{l=JSON.parse(n.data)}catch(u){return o.port1.close(),o.port2.close(),this._prepareError(u),i(u)}l.error?i(l.error):l.result!==void 0?r(l.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=".",f={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},U=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 d={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(d)},l=new Request(i,{method:"GET",headers:n(),mode:"cors",cache:"default"}),u=await fetch(l),{configurator:h}=await u.json();return h},F=()=>{try{return window.self!==window.top}catch{return!0}},B=["127.0.0.1","localhost","0.0.0.0"],k=()=>{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},x=s=>!!(B.includes(s)||s.endsWith("roomle.com")||s.endsWith("gitlab.io")||s.endsWith("gitlab.com")),I=["language","browserLanguage","userLanguage","systemLanguage"],C=(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"},W=(s,e)=>{const t=JSON.parse(JSON.stringify(s));return w(t,e)},w=(s,e)=>{for(const t in e)try{e[t].constructor===Object?s[t]=w(s[t],e[t]):s[t]=e[t]}catch{s[t]=e[t]}return s};var V={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const G={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,wallAutoHeight:!1},rotationSnapDegrees:10},J="(idle)",$=s=>(E(s),s!=null&&s.customApiUrl&&(s.customApiUrl=decodeURIComponent(s.customApiUrl)),s.shareUrl&&(s.deeplink=s.shareUrl.replace(q,Y)),s),E=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&&E(r),Array.isArray(r))for(const i of r)E(i);(r==="true"||r==="false")&&(s[t]=r==="true")}},j=(s,e)=>{e.configuratorId=s.id;const t=s.settings||{};return!e.overrideTenant&&s.tenant&&(e.overrideTenant=s.tenant),W(t,e)},z=()=>{const s={...G};s.locale||(s.locale=C()),s.id===J&&delete s.id;const e=k();return e&&x(e)&&(s.configuratorId="demoConfigurator"),s.customApiUrl=V.VITE_RAPI_URL,s.emails=!1,s},q="<CONF_ID>",Y="#CONFIGURATIONID#",Q=s=>{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)},M=()=>/(android)/i.test(navigator.userAgent);class v{constructor(){c(this,"_messageHandler",null),c(this,"isSetupDone",!1),c(this,"viewName","main"),c(this,"plugins",{}),c(this,"pluginsLoaded",[]),c(this,"ui",{callbacks:null}),c(this,"extended",{callbacks:null}),c(this,"configurator",{callbacks:null}),c(this,"analytics",{callbacks:{}}),c(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:r}=e;t.forEach(i=>{const o=i.split(p),a=o[0],n=o[1];this[a]||(this[a]={}),this[a][n]=function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(i,[...arguments])}.bind(this)}),r.forEach(i=>{const o=i.split(p),a=o[0],n=o[1],l=o[2];this[a]||(this[a]={}),this[a][n]||(this[a][n]={}),this[a][n][l]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const r=e.split(p),i=r[0],o=r[1],a=r.length===3?r[2]:null;if(a&&this[i][o][a]){const n=this[i][o][a](...t);return n instanceof Promise?n.then(l=>({result:l})):n!==void 0?Promise.resolve({result:n}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,r="website"){for(const i of e)typeof i=="string"&&i==="dragIn"?this.pluginsLoaded.push(new Promise((o,a)=>{try{import("./drag-in-CYmR1HFI.mjs").then(n=>n.l).then(({DragIn:n})=>{const l=new n(this.ui,t,r,this.viewName);l.init().then(()=>{this.plugins.dragIn=l,o()},a)})}catch(n){a(n)}})):i.name&&i.loader&&this.pluginsLoaded.push(new Promise((o,a)=>{try{i.loader().then(n=>{const l=new n(this.ui,t,r,this.viewName);l.init().then(()=>{this.plugins[i.name]=l,o()},a)})}catch(n){a(n)}}))}}const T=()=>{let s,e;return{promise:new Promise((t,r)=>{s=t,e=r}),resolve:s,reject:e}},S=(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)}})},R=()=>window.innerHeight*.01+"px",D=s=>{s&&setTimeout(()=>s.style.setProperty(b,R()),0)},N="rml-styles",K=450,b="--rml-full-height",g={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},y=new Map;class X extends v{constructor(e,t,r,i,o){if(super(),c(this,"_waitForIframe"),c(this,"_container"),c(this,"_configuratorSettings"),c(this,"_initData",{}),c(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(y.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(N)){const l=r.zIndex||9999999,u=document.createElement("style");u.type="text/css",u.id=N;const h="transition:all ease-in-out "+K+"ms;",d=["-webkit-","-o-"].reduce((L,P)=>L+=P+h,"")+h,m=R();u.innerHTML=`
2
- .${g.CONTAINER}{${b}:${m};}
1
+ var H=Object.defineProperty,U=(r,e,t)=>e in r?H(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c=(r,e,t)=>U(r,typeof e!="symbol"?e+"":e,t);class I{constructor(e,t,s,i){c(this,"_side"),c(this,"_incomingMessageBus",null),c(this,"_outgoingMessageBus",null),c(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=i,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,i)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);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 l;try{l=JSON.parse(n.data)}catch(u){return o.port1.close(),o.port2.close(),this._prepareError(u),i(u)}l.error?i(l.error):l.result!==void 0?s(l.result):s(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 s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const i=this._execMessage(s,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(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_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=".",f={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},B=async(r,e)=>{if(typeof r!="string")throw new Error('Configurator ID is not a string type: "'+typeof r+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,i=t+"/configurators/"+r,o="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),n=()=>{const d={apiKey:o,currentTenant:s,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(d)},l=new Request(i,{method:"GET",headers:n(),mode:"cors",cache:"default"}),u=await fetch(l),{configurator:h}=await u.json();return h},F=()=>{try{return window.self!==window.top}catch{return!0}},C=["127.0.0.1","localhost","0.0.0.0"],k=()=>{const r=F();let e=window.location.href;if(r){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},x=r=>!!(C.includes(r)||r.endsWith("roomle.com")||r.endsWith("gitlab.io")||r.endsWith("gitlab.com")),y=["language","browserLanguage","userLanguage","systemLanguage"],W=(r=null)=>{const e=window.navigator;if(r)return r.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=y.length;t<s;t++){const i=e[y[t]];if(i)return i.substr(0,2)}return"en"},V=(r,e)=>{const t=JSON.parse(JSON.stringify(r));return w(t,e)},w=(r,e)=>{for(const t in e)try{e[t].constructor===Object?r[t]=w(r[t],e[t]):r[t]=e[t]}catch{r[t]=e[t]}return r};var T=(r=>(r.BOTTOM_BAR="bottom_bar",r.PARTLIST_BOUNDS="partlist_bounds",r.INTERACTION_NOTES="interaction_notes",r))(T||{}),G={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const J={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[T.INTERACTION_NOTES]:!1},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1},rotationSnapDegrees:10},$="(idle)",j=r=>(E(r),r!=null&&r.customApiUrl&&(r.customApiUrl=decodeURIComponent(r.customApiUrl)),r.shareUrl&&(r.deeplink=r.shareUrl.replace(Y,Q)),r),E=r=>{if(!r)return;const e=Object.keys(r);for(const t of e){const s=r[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&E(s),Array.isArray(s))for(const i of s)E(i);(s==="true"||s==="false")&&(r[t]=s==="true")}},z=(r,e)=>{e.configuratorId=r.id;const t=r.settings||{};return!e.overrideTenant&&r.tenant&&(e.overrideTenant=r.tenant),V(t,e)},q=()=>{const r={...J};r.locale||(r.locale=W()),r.id===$&&delete r.id;const e=k();return e&&x(e)&&(r.configuratorId="demoConfigurator"),r.customApiUrl=G.VITE_RAPI_URL,r.emails=!1,r},Y="<CONF_ID>",Q="#CONFIGURATIONID#",M=()=>/(android)/i.test(navigator.userAgent);class v{constructor(){c(this,"_messageHandler",null),c(this,"isSetupDone",!1),c(this,"viewName","main"),c(this,"plugins",{}),c(this,"pluginsLoaded",[]),c(this,"ui",{callbacks:null}),c(this,"extended",{callbacks:null}),c(this,"configurator",{callbacks:null}),c(this,"analytics",{callbacks:{}}),c(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(i=>{const o=i.split(p),a=o[0],n=o[1];this[a]||(this[a]={}),this[a][n]=function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(i,[...arguments])}.bind(this)}),s.forEach(i=>{const o=i.split(p),a=o[0],n=o[1],l=o[2];this[a]||(this[a]={}),this[a][n]||(this[a][n]={}),this[a][n][l]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(p),i=s[0],o=s[1],a=s.length===3?s[2]:null;if(a&&this[i][o][a]){const n=this[i][o][a](...t);return n instanceof Promise?n.then(l=>({result:l})):n!==void 0?Promise.resolve({result:n}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const i of e)typeof i=="string"&&i==="dragIn"?this.pluginsLoaded.push(new Promise((o,a)=>{try{import("./drag-in-CYmR1HFI.mjs").then(n=>n.l).then(({DragIn:n})=>{const l=new n(this.ui,t,s,this.viewName);l.init().then(()=>{this.plugins.dragIn=l,o()},a)})}catch(n){a(n)}})):i.name&&i.loader&&this.pluginsLoaded.push(new Promise((o,a)=>{try{i.loader().then(n=>{const l=new n(this.ui,t,s,this.viewName);l.init().then(()=>{this.plugins[i.name]=l,o()},a)})}catch(n){a(n)}}))}}const S=()=>{let r,e;return{promise:new Promise((t,s)=>{r=t,e=s}),resolve:r,reject:e}},N=(r,e,t)=>{let s=null;Object.defineProperty(r,e,{get(){return s||t},set(i){i!=null&&i.mute?s=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 }"),s=i)}})},R=()=>window.innerHeight*.01+"px",D=r=>{r&&setTimeout(()=>r.style.setProperty(O,R()),0)},L="rml-styles",K=450,O="--rml-full-height",g={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},b=new Map;class X extends v{constructor(e,t,s,i,o){if(super(),c(this,"_waitForIframe"),c(this,"_container"),c(this,"_configuratorSettings"),c(this,"_initData",{}),c(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(b.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(L)){const l=s.zIndex||9999999,u=document.createElement("style");u.type="text/css",u.id=L;const h="transition:all ease-in-out "+K+"ms;",d=["-webkit-","-o-"].reduce((P,A)=>P+=A+h,"")+h,m=R();u.innerHTML=`
2
+ .${g.CONTAINER}{${O}:${m};}
3
3
  .${g.POSITION}{position:fixed;top:0;left:0;z-index:${l};opacity:0}
4
4
  .${g.TRANSITION}{${d}}
5
5
  .${g.FILL}{width:100%;height:100%;opacity:1}
6
- .${g.ANDROID_HEIGHT}{height:calc(var(${b},1vh)*100)}
6
+ .${g.ANDROID_HEIGHT}{height:calc(var(${O},1vh)*100)}
7
7
  .${g.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(u)}this._executeMessage=this._executeMessage.bind(this);const a=new O("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),M()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=r,this._configuratorSettings=e;const n=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=o,this._container.appendChild(n),this._iframe=n,this.setupPlugins(i,this._iframe),y.set(t,!0)}static createPlanner(e,t,r,i=[]){return this._create(e,t,r,i)}static async connect(e,t=[]){const r=new v;r.viewName=e;const{resolve:i,promise:o}=T(),{resolve:a,promise:n}=T(),l=({message:d,args:m})=>{switch(d){case _.REGISTER_CUSTOM_VIEW_DONE:i();break;case _.RETURN_METHODS:r.handleSetup(m[0]),a();break;default:if(r.isSetupDone)return r.executeMessage({message:d,args:m})}},u=new O("custom-view-"+e,window,window.parent,l);r.setMessageHandler(u);const h=[e];return u.sendMessage(_.REGISTER_CUSTOM_VIEW,h),await o,u.sendMessage(_.GET_METHODS,h),await n,r.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(r.pluginsLoaded),r}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,a)=>{try{const n=w(z(),$(r));Q(n);const l=await U(e,n);r=j(l,n);const u=new this(l,t,r,i,o);return await Promise.allSettled(u.pluginsLoaded),u}catch(n){return a(n)}})}teardown(){this._container&&y.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(g.CONTAINER),t.classList.add(g.FILL),t}_onResize(){D(this._iframe)}_onUseFullPage(){this._iframe.classList.add(g.POSITION),document.documentElement.classList.add(g.OVERFLOW_HIDDEN),window.document.body.classList.add(g.OVERFLOW_HIDDEN),M()&&(D(this._iframe),this._iframe.classList.add(g.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(g.POSITION),this._iframe.classList.remove(g.ANDROID_HEIGHT),document.documentElement.classList.remove(g.OVERFLOW_HIDDEN),window.document.body.classList.remove(g.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var i;if(r.source&&r.source===((i=this._iframe)==null?void 0:i.contentWindow))return e===f.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===f.SETUP?(this.handleSetup(t[0]),S(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),S(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(f.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{X as default};
8
+ `,document.head.appendChild(u)}this._executeMessage=this._executeMessage.bind(this);const a=new I("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),M()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const n=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=o,this._container.appendChild(n),this._iframe=n,this.setupPlugins(i,this._iframe),b.set(t,!0)}static createPlanner(e,t,s,i=[]){return this._create(e,t,s,i)}static async connect(e,t=[]){const s=new v;s.viewName=e;const{resolve:i,promise:o}=S(),{resolve:a,promise:n}=S(),l=({message:d,args:m})=>{switch(d){case _.REGISTER_CUSTOM_VIEW_DONE:i();break;case _.RETURN_METHODS:s.handleSetup(m[0]),a();break;default:if(s.isSetupDone)return s.executeMessage({message:d,args:m})}},u=new I("custom-view-"+e,window,window.parent,l);s.setMessageHandler(u);const h=[e];return u.sendMessage(_.REGISTER_CUSTOM_VIEW,h),await o,u.sendMessage(_.GET_METHODS,h),await n,s.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(e,t,s,i=[]){return this._create(e,t,s,i)}static create(e,t,s,i){return this._create(e,t,s,i)}static createViewer(e,t,s,i=[]){return this._create(e,t,s,i)}static async _create(e,t,s,i){return new Promise(async(o,a)=>{try{const n=w(q(),j(s));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 l=await B(e,n);s=z(l,n);const u=new this(l,t,s,i,o);return await Promise.allSettled(u.pluginsLoaded),u}catch(n){return a(n)}})}teardown(){this._container&&b.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 s=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";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(g.CONTAINER),t.classList.add(g.FILL),t}_onResize(){D(this._iframe)}_onUseFullPage(){this._iframe.classList.add(g.POSITION),document.documentElement.classList.add(g.OVERFLOW_HIDDEN),window.document.body.classList.add(g.OVERFLOW_HIDDEN),M()&&(D(this._iframe),this._iframe.classList.add(g.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(g.POSITION),this._iframe.classList.remove(g.ANDROID_HEIGHT),document.documentElement.classList.remove(g.OVERFLOW_HIDDEN),window.document.body.classList.remove(g.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},s){var i;if(s.source&&s.source===((i=this._iframe)==null?void 0:i.contentWindow))return e===f.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):e===f.SETUP?(this.handleSetup(t[0]),N(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),N(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(f.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{X as default};
@@ -1,17 +1,17 @@
1
- (function(_,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(_=typeof globalThis<"u"?globalThis:_||self,_["roomle-embedding-lib"]=_["roomle-embedding-lib"]||{},_["roomle-embedding-lib"].umd=_["roomle-embedding-lib"].umd||{},_["roomle-embedding-lib"].umd.js=p())})(this,function(){"use strict";var Zt=Object.defineProperty;var te=(_,p,E)=>p in _?Zt(_,p,{enumerable:!0,configurable:!0,writable:!0,value:E}):_[p]=E;var c=(_,p,E)=>te(_,typeof p!="symbol"?p+"":p,E);class _{constructor(e,t,s,r){c(this,"_side");c(this,"_incomingMessageBus",null);c(this,"_outgoingMessageBus",null);c(this,"_execMessage",null);this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=a=>{if(!a||!a.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let l;try{l=JSON.parse(a.data)}catch(d){return i.port1.close(),i.port2.close(),this._prepareError(d),r(d)}l.error?r(l.error):l.result!==void 0?s(l.result):s(void 0),i.port1.close(),i.port2.close()};let o="";try{o=JSON.stringify({message:e,args:t})}catch{return r(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return r(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(o,"*",[i.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 s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const r=this._execMessage(s,e);if(r===void 0)return;r.then((i={})=>{let o,a;typeof i=="object"&&i!==null&&(o=i.error,a=i.result),o?t.postMessage(JSON.stringify({error:o})):a!==void 0?t.postMessage(JSON.stringify({result:a})):t.postMessage(JSON.stringify({result:i}))},i=>{t.postMessage(JSON.stringify({error:this._prepareError(i)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_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=".",E={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},w={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},ft=async(n,e)=>{if(typeof n!="string")throw new Error('Configurator ID is not a string type: "'+typeof n+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,r=t+"/configurators/"+n,i="roomle_portal_v2",o="03-"+window.btoa(new Date().toISOString()+";anonymous;"+i),a=()=>{const u={apiKey:i,currentTenant:s,locale:"en",language:"en",device:1,token:o,platform:"web"};return new Headers(u)},l=new Request(r,{method:"GET",headers:a(),mode:"cors",cache:"default"}),d=await fetch(l),{configurator:h}=await d.json();return h},pt=()=>{try{return window.self!==window.top}catch{return!0}},yt=["127.0.0.1","localhost","0.0.0.0"],Et=()=>{const n=pt();let e=window.location.href;if(n){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},Dt=n=>!!(yt.includes(n)||n.endsWith("roomle.com")||n.endsWith("gitlab.io")||n.endsWith("gitlab.com")),k=["language","browserLanguage","userLanguage","systemLanguage"],St=(n=null)=>{const e=window.navigator;if(n)return n.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=k.length;t<s;t++){const r=e[k[t]];if(r)return r.substr(0,2)}return"en"},Tt=(n,e)=>{const t=JSON.parse(JSON.stringify(n));return L(t,e)},L=(n,e)=>{for(const t in e)try{e[t].constructor===Object?n[t]=L(n[t],e[t]):n[t]=e[t]}catch{n[t]=e[t]}return n};var It={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const wt={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,wallAutoHeight:!1},rotationSnapDegrees:10},At="(idle)",bt=n=>(C(n),n!=null&&n.customApiUrl&&(n.customApiUrl=decodeURIComponent(n.customApiUrl)),n.shareUrl&&(n.deeplink=n.shareUrl.replace(Mt,Rt)),n),C=n=>{if(!n)return;const e=Object.keys(n);for(const t of e){const s=n[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&C(s),Array.isArray(s))for(const r of s)C(r);(s==="true"||s==="false")&&(n[t]=s==="true")}},Ot=(n,e)=>{e.configuratorId=n.id;const t=n.settings||{};return!e.overrideTenant&&n.tenant&&(e.overrideTenant=n.tenant),Tt(t,e)},vt=()=>{const n={...wt};n.locale||(n.locale=St()),n.id===At&&delete n.id;const e=Et();return e&&Dt(e)&&(n.configuratorId="demoConfigurator"),n.customApiUrl=It.VITE_RAPI_URL,n.emails=!1,n},Mt="<CONF_ID>",Rt="#CONFIGURATIONID#",Lt=n=>{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)},z=()=>/(android)/i.test(navigator.userAgent);class V{constructor(){c(this,"_messageHandler",null);c(this,"isSetupDone",!1);c(this,"viewName","main");c(this,"plugins",{});c(this,"pluginsLoaded",[]);c(this,"ui",{callbacks:null});c(this,"extended",{callbacks:null});c(this,"configurator",{callbacks:null});c(this,"analytics",{callbacks:{}});c(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(r=>{const i=r.split(p),o=i[0],a=i[1];this[o]||(this[o]={}),this[o][a]=(function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(r,[...arguments])}).bind(this)}),s.forEach(r=>{const i=r.split(p),o=i[0],a=i[1],l=i[2];this[o]||(this[o]={}),this[o][a]||(this[o][a]={}),this[o][a][l]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(p),r=s[0],i=s[1],o=s.length===3?s[2]:null;if(o&&this[r][i][o]){const a=this[r][i][o](...t);return a instanceof Promise?a.then(l=>({result:l})):a!==void 0?Promise.resolve({result:a}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)typeof r=="string"&&r==="dragIn"?this.pluginsLoaded.push(new Promise((i,o)=>{try{Promise.resolve().then(()=>Ft).then(({DragIn:a})=>{const l=new a(this.ui,t,s,this.viewName);l.init().then(()=>{this.plugins.dragIn=l,i()},o)})}catch(a){o(a)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((i,o)=>{try{r.loader().then(a=>{const l=new a(this.ui,t,s,this.viewName);l.init().then(()=>{this.plugins[r.name]=l,i()},o)})}catch(a){o(a)}}))}}const q=()=>{let n,e;return{promise:new Promise((s,r)=>{n=s,e=r}),resolve:n,reject:e}},K=(n,e,t)=>{let s=null;Object.defineProperty(n,e,{get(){return s||t},set(r){r!=null&&r.mute?s=r.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 }"),s=r)}})},J=()=>window.innerHeight*.01+"px",j=n=>{n&&setTimeout(()=>n.style.setProperty(N,J()),0)},Q="rml-styles",Ct=450,N="--rml-full-height",m={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},x=new Map;class Nt extends V{constructor(t,s,r,i,o){super();c(this,"_waitForIframe");c(this,"_container");c(this,"_configuratorSettings");c(this,"_initData",{});c(this,"_iframe");if(!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(x.has(s))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(Q)){const h=r.zIndex||9999999,u=document.createElement("style");u.type="text/css",u.id=Q;const g="transition:all ease-in-out "+Ct+"ms;",f=["-webkit-","-o-"].reduce((D,y)=>D+=y+g,"")+g,T=J();u.innerHTML=`
2
- .${m.CONTAINER}{${N}:${T};}
1
+ (function(_,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(_=typeof globalThis<"u"?globalThis:_||self,_["roomle-embedding-lib"]=_["roomle-embedding-lib"]||{},_["roomle-embedding-lib"].umd=_["roomle-embedding-lib"].umd||{},_["roomle-embedding-lib"].umd.js=p())})(this,function(){"use strict";var Zt=Object.defineProperty;var te=(_,p,D)=>p in _?Zt(_,p,{enumerable:!0,configurable:!0,writable:!0,value:D}):_[p]=D;var l=(_,p,D)=>te(_,typeof p!="symbol"?p+"":p,D);class _{constructor(e,t,s,r){l(this,"_side");l(this,"_incomingMessageBus",null);l(this,"_outgoingMessageBus",null);l(this,"_execMessage",null);this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=c=>{if(!c||!c.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let a;try{a=JSON.parse(c.data)}catch(d){return i.port1.close(),i.port2.close(),this._prepareError(d),r(d)}a.error?r(a.error):a.result!==void 0?s(a.result):s(void 0),i.port1.close(),i.port2.close()};let o="";try{o=JSON.stringify({message:e,args:t})}catch{return r(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return r(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(o,"*",[i.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 s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const r=this._execMessage(s,e);if(r===void 0)return;r.then((i={})=>{let o,c;typeof i=="object"&&i!==null&&(o=i.error,c=i.result),o?t.postMessage(JSON.stringify({error:o})):c!==void 0?t.postMessage(JSON.stringify({result:c})):t.postMessage(JSON.stringify({result:i}))},i=>{t.postMessage(JSON.stringify({error:this._prepareError(i)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_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=".",D={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},w={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},pt=async(n,e)=>{if(typeof n!="string")throw new Error('Configurator ID is not a string type: "'+typeof n+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,r=t+"/configurators/"+n,i="roomle_portal_v2",o="03-"+window.btoa(new Date().toISOString()+";anonymous;"+i),c=()=>{const u={apiKey:i,currentTenant:s,locale:"en",language:"en",device:1,token:o,platform:"web"};return new Headers(u)},a=new Request(r,{method:"GET",headers:c(),mode:"cors",cache:"default"}),d=await fetch(a),{configurator:h}=await d.json();return h},yt=()=>{try{return window.self!==window.top}catch{return!0}},Dt=["127.0.0.1","localhost","0.0.0.0"],Et=()=>{const n=yt();let e=window.location.href;if(n){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},Tt=n=>!!(Dt.includes(n)||n.endsWith("roomle.com")||n.endsWith("gitlab.io")||n.endsWith("gitlab.com")),$=["language","browserLanguage","userLanguage","systemLanguage"],St=(n=null)=>{const e=window.navigator;if(n)return n.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=$.length;t<s;t++){const r=e[$[t]];if(r)return r.substr(0,2)}return"en"},It=(n,e)=>{const t=JSON.parse(JSON.stringify(n));return L(t,e)},L=(n,e)=>{for(const t in e)try{e[t].constructor===Object?n[t]=L(n[t],e[t]):n[t]=e[t]}catch{n[t]=e[t]}return n};var z=(n=>(n.BOTTOM_BAR="bottom_bar",n.PARTLIST_BOUNDS="partlist_bounds",n.INTERACTION_NOTES="interaction_notes",n))(z||{}),wt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const bt={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[z.INTERACTION_NOTES]:!1},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1},rotationSnapDegrees:10},At="(idle)",Ot=n=>(C(n),n!=null&&n.customApiUrl&&(n.customApiUrl=decodeURIComponent(n.customApiUrl)),n.shareUrl&&(n.deeplink=n.shareUrl.replace(Mt,Lt)),n),C=n=>{if(!n)return;const e=Object.keys(n);for(const t of e){const s=n[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&C(s),Array.isArray(s))for(const r of s)C(r);(s==="true"||s==="false")&&(n[t]=s==="true")}},vt=(n,e)=>{e.configuratorId=n.id;const t=n.settings||{};return!e.overrideTenant&&n.tenant&&(e.overrideTenant=n.tenant),It(t,e)},Rt=()=>{const n={...bt};n.locale||(n.locale=St()),n.id===At&&delete n.id;const e=Et();return e&&Tt(e)&&(n.configuratorId="demoConfigurator"),n.customApiUrl=wt.VITE_RAPI_URL,n.emails=!1,n},Mt="<CONF_ID>",Lt="#CONFIGURATIONID#",V=()=>/(android)/i.test(navigator.userAgent);class q{constructor(){l(this,"_messageHandler",null);l(this,"isSetupDone",!1);l(this,"viewName","main");l(this,"plugins",{});l(this,"pluginsLoaded",[]);l(this,"ui",{callbacks:null});l(this,"extended",{callbacks:null});l(this,"configurator",{callbacks:null});l(this,"analytics",{callbacks:{}});l(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(r=>{const i=r.split(p),o=i[0],c=i[1];this[o]||(this[o]={}),this[o][c]=(function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(r,[...arguments])}).bind(this)}),s.forEach(r=>{const i=r.split(p),o=i[0],c=i[1],a=i[2];this[o]||(this[o]={}),this[o][c]||(this[o][c]={}),this[o][c][a]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(p),r=s[0],i=s[1],o=s.length===3?s[2]:null;if(o&&this[r][i][o]){const c=this[r][i][o](...t);return c instanceof Promise?c.then(a=>({result:a})):c!==void 0?Promise.resolve({result:c}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)typeof r=="string"&&r==="dragIn"?this.pluginsLoaded.push(new Promise((i,o)=>{try{Promise.resolve().then(()=>Ft).then(({DragIn:c})=>{const a=new c(this.ui,t,s,this.viewName);a.init().then(()=>{this.plugins.dragIn=a,i()},o)})}catch(c){o(c)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((i,o)=>{try{r.loader().then(c=>{const a=new c(this.ui,t,s,this.viewName);a.init().then(()=>{this.plugins[r.name]=a,i()},o)})}catch(c){o(c)}}))}}const K=()=>{let n,e;return{promise:new Promise((s,r)=>{n=s,e=r}),resolve:n,reject:e}},J=(n,e,t)=>{let s=null;Object.defineProperty(n,e,{get(){return s||t},set(r){r!=null&&r.mute?s=r.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 }"),s=r)}})},j=()=>window.innerHeight*.01+"px",Q=n=>{n&&setTimeout(()=>n.style.setProperty(N,j()),0)},Z="rml-styles",Ct=450,N="--rml-full-height",m={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},x=new Map;class Nt extends q{constructor(t,s,r,i,o){super();l(this,"_waitForIframe");l(this,"_container");l(this,"_configuratorSettings");l(this,"_initData",{});l(this,"_iframe");if(!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(x.has(s))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(Z)){const h=r.zIndex||9999999,u=document.createElement("style");u.type="text/css",u.id=Z;const g="transition:all ease-in-out "+Ct+"ms;",f=["-webkit-","-o-"].reduce((E,y)=>E+=y+g,"")+g,S=j();u.innerHTML=`
2
+ .${m.CONTAINER}{${N}:${S};}
3
3
  .${m.POSITION}{position:fixed;top:0;left:0;z-index:${h};opacity:0}
4
4
  .${m.TRANSITION}{${f}}
5
5
  .${m.FILL}{width:100%;height:100%;opacity:1}
6
6
  .${m.ANDROID_HEIGHT}{height:calc(var(${N},1vh)*100)}
7
7
  .${m.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(u)}this._executeMessage=this._executeMessage.bind(this);const l=new _("website",window,null,this._executeMessage);this.setMessageHandler(l),this._onResize=this._onResize.bind(this),z()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=t;const d=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=o,this._container.appendChild(d),this._iframe=d,this.setupPlugins(i,this._iframe),x.set(s,!0)}static createPlanner(t,s,r,i=[]){return this._create(t,s,r,i)}static async connect(t,s=[]){const r=new V;r.viewName=t;const{resolve:i,promise:o}=q(),{resolve:a,promise:l}=q(),d=({message:g,args:f})=>{switch(g){case w.REGISTER_CUSTOM_VIEW_DONE:i();break;case w.RETURN_METHODS:r.handleSetup(f[0]),a();break;default:if(r.isSetupDone)return r.executeMessage({message:g,args:f})}},h=new _("custom-view-"+t,window,window.parent,d);r.setMessageHandler(h);const u=[t];return h.sendMessage(w.REGISTER_CUSTOM_VIEW,u),await o,h.sendMessage(w.GET_METHODS,u),await l,r.setupPlugins(s,document.body,"custom-view"),await Promise.allSettled(r.pluginsLoaded),r}static createConfigurator(t,s,r,i=[]){return this._create(t,s,r,i)}static create(t,s,r,i){return this._create(t,s,r,i)}static createViewer(t,s,r,i=[]){return this._create(t,s,r,i)}static async _create(t,s,r,i){return new Promise(async(o,a)=>{try{const l=L(vt(),bt(r));Lt(l);const d=await ft(t,l);r=Ot(d,l);const h=new this(d,s,r,i,o);return await Promise.allSettled(h.pluginsLoaded),h}catch(l){return a(l)}})}teardown(){this._container&&x.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var r;const t=document.createElement("iframe");let s=((r=this._configuratorSettings)==null?void 0:r.url)||"https://www.roomle.com/t/cp/";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(m.CONTAINER),t.classList.add(m.FILL),t}_onResize(){j(this._iframe)}_onUseFullPage(){this._iframe.classList.add(m.POSITION),document.documentElement.classList.add(m.OVERFLOW_HIDDEN),window.document.body.classList.add(m.OVERFLOW_HIDDEN),z()&&(j(this._iframe),this._iframe.classList.add(m.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(m.POSITION),this._iframe.classList.remove(m.ANDROID_HEIGHT),document.documentElement.classList.remove(m.OVERFLOW_HIDDEN),window.document.body.classList.remove(m.OVERFLOW_HIDDEN)}_executeMessage({message:t,args:s},r){var i;if(r.source&&r.source===((i=this._iframe)==null?void 0:i.contentWindow))return t===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"})):t===E.SETUP?(this.handleSetup(s[0]),K(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),K(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(E.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:s})}}class xt{constructor(e,t,s,r){c(this,"_mainDomElement");c(this,"_instance");c(this,"_mode","website");c(this,"_viewName","main");this._instance=e,this._mainDomElement=t,this._mode=s,this._viewName=r}async init(){return Promise.resolve()}}const A="rml-drag-in-styles",b="rml-drag-in-drag-element",O="rml-drag-in-overlay",v="rml-drag-in-drag-ghost",Z="rml-drag-in-fade-in",tt="rml-drag-in-fade-out",G={DISPLAY_NONE:"rml-display-none"},et=.5,st="250ms",rt="forwards",nt=`@keyframes ${Z} {from{opacity: 0;}to {opacity: ${et};}}`,it=`@keyframes ${tt} {from{opacity: ${et};}to {opacity: 0;}}`,ot=`${Z} ${st} ${rt}`,at=`${tt} ${st} ${rt}`,M="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",F=112,P=112;class Gt extends xt{constructor(t,s,r,i){super(t,s,r,i);c(this,"options",{});c(this,"_customDragSignal",new AbortController);this._mainDomElement=s,this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!!!document.getElementById(A)){const s=document.createElement("style");s.type="text/css",s.id=A,s.innerHTML=`
8
+ `,document.head.appendChild(u)}this._executeMessage=this._executeMessage.bind(this);const a=new _("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),V()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=t;const d=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=o,this._container.appendChild(d),this._iframe=d,this.setupPlugins(i,this._iframe),x.set(s,!0)}static createPlanner(t,s,r,i=[]){return this._create(t,s,r,i)}static async connect(t,s=[]){const r=new q;r.viewName=t;const{resolve:i,promise:o}=K(),{resolve:c,promise:a}=K(),d=({message:g,args:f})=>{switch(g){case w.REGISTER_CUSTOM_VIEW_DONE:i();break;case w.RETURN_METHODS:r.handleSetup(f[0]),c();break;default:if(r.isSetupDone)return r.executeMessage({message:g,args:f})}},h=new _("custom-view-"+t,window,window.parent,d);r.setMessageHandler(h);const u=[t];return h.sendMessage(w.REGISTER_CUSTOM_VIEW,u),await o,h.sendMessage(w.GET_METHODS,u),await a,r.setupPlugins(s,document.body,"custom-view"),await Promise.allSettled(r.pluginsLoaded),r}static createConfigurator(t,s,r,i=[]){return this._create(t,s,r,i)}static create(t,s,r,i){return this._create(t,s,r,i)}static createViewer(t,s,r,i=[]){return this._create(t,s,r,i)}static async _create(t,s,r,i){return new Promise(async(o,c)=>{try{const a=L(Rt(),Ot(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 d=await pt(t,a);r=vt(d,a);const h=new this(d,s,r,i,o);return await Promise.allSettled(h.pluginsLoaded),h}catch(a){return c(a)}})}teardown(){this._container&&x.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var r;const t=document.createElement("iframe");let s=((r=this._configuratorSettings)==null?void 0:r.url)||"https://www.roomle.com/t/cp/";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(m.CONTAINER),t.classList.add(m.FILL),t}_onResize(){Q(this._iframe)}_onUseFullPage(){this._iframe.classList.add(m.POSITION),document.documentElement.classList.add(m.OVERFLOW_HIDDEN),window.document.body.classList.add(m.OVERFLOW_HIDDEN),V()&&(Q(this._iframe),this._iframe.classList.add(m.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(m.POSITION),this._iframe.classList.remove(m.ANDROID_HEIGHT),document.documentElement.classList.remove(m.OVERFLOW_HIDDEN),window.document.body.classList.remove(m.OVERFLOW_HIDDEN)}_executeMessage({message:t,args:s},r){var i;if(r.source&&r.source===((i=this._iframe)==null?void 0:i.contentWindow))return t===D.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===D.SETUP?(this.handleSetup(s[0]),J(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),J(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(D.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:s})}}class xt{constructor(e,t,s,r){l(this,"_mainDomElement");l(this,"_instance");l(this,"_mode","website");l(this,"_viewName","main");this._instance=e,this._mainDomElement=t,this._mode=s,this._viewName=r}async init(){return Promise.resolve()}}const b="rml-drag-in-styles",A="rml-drag-in-drag-element",O="rml-drag-in-overlay",v="rml-drag-in-drag-ghost",tt="rml-drag-in-fade-in",et="rml-drag-in-fade-out",G={DISPLAY_NONE:"rml-display-none"},st=.5,rt="250ms",nt="forwards",it=`@keyframes ${tt} {from{opacity: 0;}to {opacity: ${st};}}`,ot=`@keyframes ${et} {from{opacity: ${st};}to {opacity: 0;}}`,at=`${tt} ${rt} ${nt}`,ct=`${et} ${rt} ${nt}`,R="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",F=112,P=112;class Gt extends xt{constructor(t,s,r,i){super(t,s,r,i);l(this,"options",{});l(this,"_customDragSignal",new AbortController);this._mainDomElement=s,this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!!!document.getElementById(b)){const s=document.createElement("style");s.type="text/css",s.id=b,s.innerHTML=`
9
9
  .${G.DISPLAY_NONE}{display:none}
10
10
  .${O}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
11
11
  .${v}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
12
- ${nt}
13
12
  ${it}
14
- `,document.head.appendChild(s)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let s=t.querySelector("."+v);s||(s=document.createElement("div"),s.classList.add(v),s.innerText=" ",t.appendChild(s))}async init(){if(await super.init(),this._mode==="website")try{const{DragInFromWebsiteStrategy:t}=await Promise.resolve().then(()=>kt);this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw console.error('Could not load Dragin strategy "FromWebsite"'),t}else if(this._mode==="custom-view")try{const{DragInFromCustomViewStrategy:t}=await Promise.resolve().then(()=>Qt);this._strategy=new t(this._instance,this.options,this._viewName)}catch(t){throw console.error('Could not load Dragin strategy "FromCustomView"'),t}else throw new Error("Unsupported mode")}get isDragging(){return this._strategy.isDragging}dragStart(t,s,r="rml_id"){this._strategy.dragStart(t,s,r)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,s,r="rml_id"){this._strategy.touchStart(t,s,r)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:s,customDragUpdate:r,beforeUpdateGhost:i}){i&&this._strategy.beforeUpdateGhost(i);const o=this._customDragSignal.signal,a=h=>{h.target.getAttribute("data-rml-draggable")==="true"&&t(h)},l=h=>{this._strategy.releaseInput(h),this._strategy.isDragging&&s(h)},d=h=>{r(h)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(h=>{h.draggable=!1}),document.addEventListener("mousedown",a,{signal:o}),document.addEventListener("mouseup",l,{signal:o}),document.addEventListener("mousemove",d,{signal:o}),document.addEventListener("mouseleave",l,{signal:o}),document.addEventListener("touchstart",a,{signal:o}),document.addEventListener("touchend",l,{signal:o}),document.addEventListener("touchmove",d,{signal:o})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Ft=Object.freeze(Object.defineProperty({__proto__:null,DragIn:Gt},Symbol.toStringTag,{value:"Module"}));class Pt{constructor(e=16){c(this,"_computedStyleCache",new Map);c(this,"_maxLifetime",16);c(this,"_cacheCleanInterval",null);this._maxLifetime=e}get(e){const t=this._computedStyleCache.get(e),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const r=getComputedStyle(e);return this._computedStyleCache.set(e,{style:r,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_cleanUpCache(){const e=Date.now();for(const[t,{updated:s}]of this._computedStyleCache.entries())e-s>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const S=n=>window.TouchEvent&&n instanceof window.TouchEvent;let H;const R=n=>(H||(H=new Pt),H.get(n)),ct=(n,e,t)=>{const s=parseFloat(n),r=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const o=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*o}if(e==="rem"){const o=parseFloat(R(document.documentElement).fontSize);return s*o}if(e==="em"){const o=parseFloat(R(t).fontSize);return s*o}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const o={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*o[e]}const i={cm:37.7952755906,mm:3.77952755906,in:96};return e in i?s*i[e]*r:(console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"),0)},lt=(n,e,t={x:0,y:0})=>{const s=n.getBoundingClientRect(),i=R(n).transform;let o=0,a=0;if(i!=="none"){const g=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,f=i.match(g);f&&(o=ct(f[1],f[2],n),a=ct(f[3],f[4],n))}const{clientX:l,clientY:d}=I(e,t),h=l-s.left-o+n.scrollLeft,u=d-s.top-a+n.scrollTop;return{x:h,y:u}},I=(n,e=null)=>{const{clientX:t,clientY:s}=S(n)?Ht(n):n,r=t>0?t:e?e.x:t,i=s>0?s:e?e.y:s;return{clientX:r,clientY:i}},Ht=n=>{if(n.touches.length){let{clientX:t,clientY:s}=n.touches[0];if(n.touches.length>1){const r=n.touches[1],i=r.clientX,o=r.clientY;t=(t+i)/2,s=(s+o)/2}return{clientX:t,clientY:s}}const e=n.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},U=500,B=10,Ut=100,ht=15,Y=(n,e=0)=>S(n)?{clientX:n.touches[e].clientX,clientY:n.touches[e].clientY}:{clientX:n.clientX,clientY:n.clientY},dt=n=>n&&S(n)?n.touches.length>0:!0;class ut{constructor(e,{onTouchDragStart:t},s={}){c(this,"_touchDragTimeOut");c(this,"_onTouchDragStart");c(this,"_payload",null);c(this,"_delay",U);c(this,"_firstTouch",null);c(this,"_lastTouch",null);c(this,"_epsilon",B);this._payload=e,this._onTouchDragStart=t,this._delay=typeof s.delay=="number"?s.delay:U,this._epsilon=typeof s.epsilon=="number"?s.epsilon:B}onStart(e){dt(e)&&(this._touchDragTimeOut||(this._firstTouch=Y(e,S(e)?e.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=Y(e)),this._checkXDistance(e)()},this._delay)))}onEnd(){this._resetTouches()}onMove(e){dt(e)&&(this._lastTouch=Y(e))}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(e){return()=>{if(!this._firstTouch||!this._lastTouch)return;let t=!1;t=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<this._epsilon,t&&(this._onTouchDragStart(this._payload,e),this._resetTouches())}}}const gt=(n,e,t=0,s=0)=>{const r=e.x+e.width+t,i=e.x-t,o=e.y+e.height+s,a=e.y-s,{x:l,y:d}=n;return l>=i&&l<=r&&d>=a&&d<=o},_t=(n,e,t,s=0,r=0)=>{if(!(!t||!t.hiddenIn&&!t.visibleIn))return t.visibleIn?gt({x:n,y:e},t.visibleIn,s,r):t.hiddenIn?!gt({x:n,y:e},t.hiddenIn,-s,-r):!1},Bt=()=>{if(!!!document.getElementById(A)){const e=document.createElement("style");e.type="text/css",e.id=A,e.innerHTML=`
15
- ${nt}
13
+ ${ot}
14
+ `,document.head.appendChild(s)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let s=t.querySelector("."+v);s||(s=document.createElement("div"),s.classList.add(v),s.innerText=" ",t.appendChild(s))}async init(){if(await super.init(),this._mode==="website")try{const{DragInFromWebsiteStrategy:t}=await Promise.resolve().then(()=>$t);this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw console.error('Could not load Dragin strategy "FromWebsite"'),t}else if(this._mode==="custom-view")try{const{DragInFromCustomViewStrategy:t}=await Promise.resolve().then(()=>Qt);this._strategy=new t(this._instance,this.options,this._viewName)}catch(t){throw console.error('Could not load Dragin strategy "FromCustomView"'),t}else throw new Error("Unsupported mode")}get isDragging(){return this._strategy.isDragging}dragStart(t,s,r="rml_id"){this._strategy.dragStart(t,s,r)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,s,r="rml_id"){this._strategy.touchStart(t,s,r)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:s,customDragUpdate:r,beforeUpdateGhost:i}){i&&this._strategy.beforeUpdateGhost(i);const o=this._customDragSignal.signal,c=h=>{h.target.getAttribute("data-rml-draggable")==="true"&&t(h)},a=h=>{this._strategy.releaseInput(h),this._strategy.isDragging&&s(h)},d=h=>{r(h)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(h=>{h.draggable=!1}),document.addEventListener("mousedown",c,{signal:o}),document.addEventListener("mouseup",a,{signal:o}),document.addEventListener("mousemove",d,{signal:o}),document.addEventListener("mouseleave",a,{signal:o}),document.addEventListener("touchstart",c,{signal:o}),document.addEventListener("touchend",a,{signal:o}),document.addEventListener("touchmove",d,{signal:o})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Ft=Object.freeze(Object.defineProperty({__proto__:null,DragIn:Gt},Symbol.toStringTag,{value:"Module"}));class Pt{constructor(e=16){l(this,"_computedStyleCache",new Map);l(this,"_maxLifetime",16);l(this,"_cacheCleanInterval",null);this._maxLifetime=e}get(e){const t=this._computedStyleCache.get(e),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const r=getComputedStyle(e);return this._computedStyleCache.set(e,{style:r,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_cleanUpCache(){const e=Date.now();for(const[t,{updated:s}]of this._computedStyleCache.entries())e-s>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const T=n=>window.TouchEvent&&n instanceof window.TouchEvent;let H;const M=n=>(H||(H=new Pt),H.get(n)),lt=(n,e,t)=>{const s=parseFloat(n),r=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const o=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*o}if(e==="rem"){const o=parseFloat(M(document.documentElement).fontSize);return s*o}if(e==="em"){const o=parseFloat(M(t).fontSize);return s*o}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const o={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*o[e]}const i={cm:37.7952755906,mm:3.77952755906,in:96};return e in i?s*i[e]*r:(console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"),0)},ht=(n,e,t={x:0,y:0})=>{const s=n.getBoundingClientRect(),i=M(n).transform;let o=0,c=0;if(i!=="none"){const g=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,f=i.match(g);f&&(o=lt(f[1],f[2],n),c=lt(f[3],f[4],n))}const{clientX:a,clientY:d}=I(e,t),h=a-s.left-o+n.scrollLeft,u=d-s.top-c+n.scrollTop;return{x:h,y:u}},I=(n,e=null)=>{const{clientX:t,clientY:s}=T(n)?Ht(n):n,r=t>0?t:e?e.x:t,i=s>0?s:e?e.y:s;return{clientX:r,clientY:i}},Ht=n=>{if(n.touches.length){let{clientX:t,clientY:s}=n.touches[0];if(n.touches.length>1){const r=n.touches[1],i=r.clientX,o=r.clientY;t=(t+i)/2,s=(s+o)/2}return{clientX:t,clientY:s}}const e=n.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},U=500,B=10,Ut=100,dt=15,Y=(n,e=0)=>T(n)?{clientX:n.touches[e].clientX,clientY:n.touches[e].clientY}:{clientX:n.clientX,clientY:n.clientY},ut=n=>n&&T(n)?n.touches.length>0:!0;class gt{constructor(e,{onTouchDragStart:t},s={}){l(this,"_touchDragTimeOut");l(this,"_onTouchDragStart");l(this,"_payload",null);l(this,"_delay",U);l(this,"_firstTouch",null);l(this,"_lastTouch",null);l(this,"_epsilon",B);this._payload=e,this._onTouchDragStart=t,this._delay=typeof s.delay=="number"?s.delay:U,this._epsilon=typeof s.epsilon=="number"?s.epsilon:B}onStart(e){ut(e)&&(this._touchDragTimeOut||(this._firstTouch=Y(e,T(e)?e.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=Y(e)),this._checkXDistance(e)()},this._delay)))}onEnd(){this._resetTouches()}onMove(e){ut(e)&&(this._lastTouch=Y(e))}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(e){return()=>{if(!this._firstTouch||!this._lastTouch)return;let t=!1;t=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<this._epsilon,t&&(this._onTouchDragStart(this._payload,e),this._resetTouches())}}}const _t=(n,e,t=0,s=0)=>{const r=e.x+e.width+t,i=e.x-t,o=e.y+e.height+s,c=e.y-s,{x:a,y:d}=n;return a>=i&&a<=r&&d>=c&&d<=o},mt=(n,e,t,s=0,r=0)=>{if(!(!t||!t.hiddenIn&&!t.visibleIn))return t.visibleIn?_t({x:n,y:e},t.visibleIn,s,r):t.hiddenIn?!_t({x:n,y:e},t.hiddenIn,-s,-r):!1},Bt=()=>{if(!!!document.getElementById(b)){const e=document.createElement("style");e.type="text/css",e.id=b,e.innerHTML=`
16
15
  ${it}
17
- `,document.head.appendChild(e)}},Yt=({x:n,y:e},t)=>{var r,i,o,a,l,d;let s=document.getElementById(b);if(!s){if(s=document.createElement("div"),(r=t.ghost)!=null&&r.element)s.appendChild(t.ghost.element);else{const h=document.createElement("img");h.src=((i=t.ghost)==null?void 0:i.url)||M,h.width=((o=t.ghost)==null?void 0:o.width)||F,h.height=((a=t.ghost)==null?void 0:a.height)||P,s.appendChild(h)}s.id=b,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.willChange="transform",s.style.transform="translate3d(0, 0, 0)",s.style.zIndex="9999",s.style.opacity="0.5",_t(n,e,t.ghost||{},(l=t.settings)==null?void 0:l.dragInOverlapX,(d=t.settings)==null?void 0:d.dragInOverlapY)||(s.style.display="none"),s.style.pointerEvents="none",document.body.appendChild(s)}},Xt=({x:n,y:e},t)=>{var l,d,h,u;const s=document.getElementById(b);if(!s)return;let r=(l=t.ghost)==null?void 0:l.width,i=(d=t.ghost)==null?void 0:d.height;typeof r>"u"&&(r=s.getBoundingClientRect().width||F),typeof i>"u"&&(i=s.getBoundingClientRect().height||P);const o=n-r/2,a=e-i/2;s.style.transform=`translate3d(${o}px, ${a}px, 0)`,t.ghost&&(_t(n,e,t.ghost,(h=t.settings)==null?void 0:h.dragInOverlapX,(u=t.settings)==null?void 0:u.dragInOverlapY)?s.style.animation!=ot&&(s.style.animation=ot):s.style.animation!=at&&(s.style.animation=at))};class Wt{constructor(e=null){c(this,"_dragGhostAnimationFrameId",null);c(this,"_dragGhostRemoveAnimationFrameId",null);c(this,"_dragGhostElement",null);this._dragGhostElement=e}updateDragGhost(e,t,s){var r;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((r=s.ghost)!=null&&r.external)&&s.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{Bt();const i={x:e,y:t};!s.ghost&&this._dragGhostElement&&(s.ghost={}),s.ghost&&!s.ghost.element&&this._dragGhostElement&&(s.ghost.element=this._dragGhostElement),Yt(i,s),Xt(i,s),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const e=document.getElementById(b);e&&document.body.removeChild(e),this._dragGhostRemoveAnimationFrameId=null}))}}class $t{constructor(e,t,s){c(this,"_options",{});c(this,"_instance");c(this,"_mainDomElement");c(this,"_currentDrag",{});c(this,"_currentTouch",null);c(this,"_firefoxDragPosition",{x:0,y:0});c(this,"_onBeforeUpdateDrag",()=>({}));c(this,"isDragging",!1);c(this,"_firefoxFallback",e=>{if(!this._currentDrag.event)return;const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});this._instance=e,this._mainDomElement=t,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}dragStart(e,t,s="rml_id"){const r=this._mainDomElement.parentNode;if(R(r).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let o=r.querySelector("."+O);o||(o=document.createElement("div"),o.classList.add(O),r.appendChild(o)),o.classList.remove(G.DISPLAY_NONE),t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const l=r.querySelector("."+v);this._currentDrag.event=t;const d=t.target,h=d.cloneNode(),u=d.getBoundingClientRect();h.style.width=`${u.width}px`,h.style.height=`${u.height}px`,this._currentDrag.ghost=new Wt(h),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:g,clientY:f}=I(t,this._firefoxDragPosition);this._currentDrag.offset.x=g-u.left,this._currentDrag.offset.y=f-u.top,t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(l,0,0);const{x:T,y:D}=lt(r,this._currentDrag.event||t,this._firefoxDragPosition),y=Math.max(1,T),$=Math.max(1,D);this.isDragging=!0,this._instance.dragInObject(e,y,$,s)}dragUpdate(e){var D;const t=this._mainDomElement.parentNode,{x:s,y:r}=lt(t,e,this._firefoxDragPosition);if(s===0&&r===0)return;const i=Math.max(1,s),o=Math.max(1,r);if(i===1&&o===1)return;let a=i,l=o;if(S(e)){const y=((D=this._options.settings)==null?void 0:D.fingerSize)||0;a=Math.max(2,i+y),l=Math.max(2,o-y)}const{x:d,y:h,options:u}=this._onBeforeUpdateDrag(a,l,{}),g=u||{settings:{},ghost:{}};g.ghost||(g.ghost={}),g.ghost.visibleIn&&g.ghost.hiddenIn||(g.ghost.hiddenIn=this._mainDomElement.getBoundingClientRect());const f=typeof d=="number"?d:a,T=typeof h=="number"?h:l;if(this._currentDrag.ghost){const{clientX:y,clientY:$}=I(e,this._firefoxDragPosition);this._currentDrag.ghost.updateDragGhost(y,$,g)}this._instance.updateDrag(f,T,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const e=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+O);t&&t.classList.add(G.DISPLAY_NONE)}touchStart(e,t,s="rml_id"){var o,a,l,d;t.preventDefault();const r=(h,u)=>{this.dragStart(e,u,s)},i={};typeof((a=(o=this._options)==null?void 0:o.settings)==null?void 0:a.touchDragDelay)=="number"&&(i.delay=this._options.settings.touchDragDelay),(d=(l=this._options)==null?void 0:l.settings)!=null&&d.touchDragEpsilon&&(i.epsilon=this._options.settings.touchDragEpsilon),this._currentTouch=new ut(void 0,{onTouchDragStart:r},i),this._currentTouch.onStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(e){}}const kt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromWebsiteStrategy:$t},Symbol.toStringTag,{value:"Module"})),zt=n=>`[data-rml-custom-view="${n}"]`,X=n=>{n.preventDefault(),n.stopPropagation()},Vt=(n,e,t,s)=>{const r=t-n,i=s-e;return Math.sqrt(r*r+i*i)};class qt{constructor({onCustomDragStart:e},t={}){c(this,"_startX",0);c(this,"_startY",0);c(this,"_lastX",0);c(this,"_lastY",0);c(this,"_epsilon");c(this,"_isWaiting",!1);c(this,"_onCustomDragStart");this._epsilon=typeof t.epsilon=="number"?t.epsilon:ht,this._onCustomDragStart=e}onMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._isWaiting&&Vt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(e),this._isWaiting=!1)}onStart(e){this._startX=e.clientX,this._startY=e.clientY,this.onMove(e),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const W="data-rml-old-draggable",Kt=void 0,mt=(n,e)=>{const t=S(n),s={delay:t?U:Ut,epsilon:t?B:ht};if(!e)return s;if(!t&&!(n instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:r,epsilonKey:i}=t?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof e[r]=="number"&&(s.delay=e.touchDragDelay),typeof e[i]=="number"&&(s.epsilon=e.touchDragEpsilon),s},Jt=n=>{let e="",t=F,s=P;if(!n)return{url:M,width:t,height:s};const r=n;if(r instanceof HTMLElement){const i=r.getBoundingClientRect(),o=r.getAttribute("data-rml-ghost-url"),a=r.getAttribute("data-rml-ghost-width"),l=r.getAttribute("data-rml-ghost-height");o?e=o:!o&&r instanceof HTMLImageElement&&r.src&&(e=r.src),e?(t=i.width,s=i.height):e=M,t=a?parseInt(a,10):t,s=l?parseInt(l,10):s}return{url:e||M,width:t,height:s}};class jt{constructor(e,t,s){c(this,"_options",{});c(this,"_instance");c(this,"_viewName");c(this,"_currentCustomDrag",null);c(this,"_currentBb",null);c(this,"_startTarget",null);c(this,"_onBeforeUpdateDrag",()=>({}));c(this,"isDragging",!1);this._instance=e,this._options=t||{},this._viewName=s}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}async _dragStart(e,t,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(W,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",X),this._startTarget.addEventListener("dragstart",X)),this._currentBb=await this._instance.getBoundingClientRect(zt(this._viewName));const{clientX:r,clientY:i}=I(t),o=this._currentBb.x+r,a=this._currentBb.y+i;this.isDragging=!0,this._instance.dragInObject(e,o,a,s)}_dragUpdate(e){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(e),!this._currentBb||!this.isDragging)return;const{clientX:t,clientY:s}=I(e),{url:r,width:i,height:o}=Jt(this._startTarget),a=this._currentBb.x+t,l=this._currentBb.y+s,d=this._options||{},h={ghost:{visibleIn:{x:this._currentBb.x-(d.dragInOverlapX||0),y:this._currentBb.y+(d.dragInOverlapY||0),width:this._currentBb.width+(d.dragInOverlapX||0),height:this._currentBb.height+(d.dragInOverlapY||0)},url:r,width:i,height:o},mode:"custom-view"},{x:u,y:g,options:f}=this._onBeforeUpdateDrag(a,l,h),T=typeof u=="number"?u:a,D=typeof g=="number"?g:l,y=f||h;this._instance.updateDrag(T,D,y)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(e,t,s){this._instance.disableEvents(),this._startTarget=t.target;const r=(i,o)=>{this._dragStart(e,o,s)};this._currentCustomDrag=S(t)?new ut(Kt,{onTouchDragStart:r},mt(t,this._options)):new qt({onCustomDragStart:i=>this._dragStart(e,i,s)},mt(t,this._options)),this._currentCustomDrag.onStart(t)}dragEnd(){this._dragEnd()}dragUpdate(e){this._dragUpdate(e)}touchStart(e,t,s="rml_id"){this.dragStart(e,t,s)}touchMove(e){this.dragUpdate(e)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(W)==="true",this._startTarget.removeAttribute(W),this._startTarget.removeEventListener("dragstart",X))}releaseInput(e){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}const Qt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromCustomViewStrategy:jt},Symbol.toStringTag,{value:"Module"}));return Nt});
16
+ ${ot}
17
+ `,document.head.appendChild(e)}},Yt=({x:n,y:e},t)=>{var r,i,o,c,a,d;let s=document.getElementById(A);if(!s){if(s=document.createElement("div"),(r=t.ghost)!=null&&r.element)s.appendChild(t.ghost.element);else{const h=document.createElement("img");h.src=((i=t.ghost)==null?void 0:i.url)||R,h.width=((o=t.ghost)==null?void 0:o.width)||F,h.height=((c=t.ghost)==null?void 0:c.height)||P,s.appendChild(h)}s.id=A,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.willChange="transform",s.style.transform="translate3d(0, 0, 0)",s.style.zIndex="9999",s.style.opacity="0.5",mt(n,e,t.ghost||{},(a=t.settings)==null?void 0:a.dragInOverlapX,(d=t.settings)==null?void 0:d.dragInOverlapY)||(s.style.display="none"),s.style.pointerEvents="none",document.body.appendChild(s)}},Xt=({x:n,y:e},t)=>{var a,d,h,u;const s=document.getElementById(A);if(!s)return;let r=(a=t.ghost)==null?void 0:a.width,i=(d=t.ghost)==null?void 0:d.height;typeof r>"u"&&(r=s.getBoundingClientRect().width||F),typeof i>"u"&&(i=s.getBoundingClientRect().height||P);const o=n-r/2,c=e-i/2;s.style.transform=`translate3d(${o}px, ${c}px, 0)`,t.ghost&&(mt(n,e,t.ghost,(h=t.settings)==null?void 0:h.dragInOverlapX,(u=t.settings)==null?void 0:u.dragInOverlapY)?s.style.animation!=at&&(s.style.animation=at):s.style.animation!=ct&&(s.style.animation=ct))};class Wt{constructor(e=null){l(this,"_dragGhostAnimationFrameId",null);l(this,"_dragGhostRemoveAnimationFrameId",null);l(this,"_dragGhostElement",null);this._dragGhostElement=e}updateDragGhost(e,t,s){var r;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((r=s.ghost)!=null&&r.external)&&s.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{Bt();const i={x:e,y:t};!s.ghost&&this._dragGhostElement&&(s.ghost={}),s.ghost&&!s.ghost.element&&this._dragGhostElement&&(s.ghost.element=this._dragGhostElement),Yt(i,s),Xt(i,s),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const e=document.getElementById(A);e&&document.body.removeChild(e),this._dragGhostRemoveAnimationFrameId=null}))}}class kt{constructor(e,t,s){l(this,"_options",{});l(this,"_instance");l(this,"_mainDomElement");l(this,"_currentDrag",{});l(this,"_currentTouch",null);l(this,"_firefoxDragPosition",{x:0,y:0});l(this,"_onBeforeUpdateDrag",()=>({}));l(this,"isDragging",!1);l(this,"_firefoxFallback",e=>{if(!this._currentDrag.event)return;const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});this._instance=e,this._mainDomElement=t,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}dragStart(e,t,s="rml_id"){const r=this._mainDomElement.parentNode;if(M(r).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let o=r.querySelector("."+O);o||(o=document.createElement("div"),o.classList.add(O),r.appendChild(o)),o.classList.remove(G.DISPLAY_NONE),t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const a=r.querySelector("."+v);this._currentDrag.event=t;const d=t.target,h=d.cloneNode(),u=d.getBoundingClientRect();h.style.width=`${u.width}px`,h.style.height=`${u.height}px`,this._currentDrag.ghost=new Wt(h),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:g,clientY:f}=I(t,this._firefoxDragPosition);this._currentDrag.offset.x=g-u.left,this._currentDrag.offset.y=f-u.top,t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(a,0,0);const{x:S,y:E}=ht(r,this._currentDrag.event||t,this._firefoxDragPosition),y=Math.max(1,S),k=Math.max(1,E);this.isDragging=!0,this._instance.dragInObject(e,y,k,s)}dragUpdate(e){var E;const t=this._mainDomElement.parentNode,{x:s,y:r}=ht(t,e,this._firefoxDragPosition);if(s===0&&r===0)return;const i=Math.max(1,s),o=Math.max(1,r);if(i===1&&o===1)return;let c=i,a=o;if(T(e)){const y=((E=this._options.settings)==null?void 0:E.fingerSize)||0;c=Math.max(2,i+y),a=Math.max(2,o-y)}const{x:d,y:h,options:u}=this._onBeforeUpdateDrag(c,a,{}),g=u||{settings:{},ghost:{}};g.ghost||(g.ghost={}),g.ghost.visibleIn&&g.ghost.hiddenIn||(g.ghost.hiddenIn=this._mainDomElement.getBoundingClientRect());const f=typeof d=="number"?d:c,S=typeof h=="number"?h:a;if(this._currentDrag.ghost){const{clientX:y,clientY:k}=I(e,this._firefoxDragPosition);this._currentDrag.ghost.updateDragGhost(y,k,g)}this._instance.updateDrag(f,S,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const e=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+O);t&&t.classList.add(G.DISPLAY_NONE)}touchStart(e,t,s="rml_id"){var o,c,a,d;t.preventDefault();const r=(h,u)=>{this.dragStart(e,u,s)},i={};typeof((c=(o=this._options)==null?void 0:o.settings)==null?void 0:c.touchDragDelay)=="number"&&(i.delay=this._options.settings.touchDragDelay),(d=(a=this._options)==null?void 0:a.settings)!=null&&d.touchDragEpsilon&&(i.epsilon=this._options.settings.touchDragEpsilon),this._currentTouch=new gt(void 0,{onTouchDragStart:r},i),this._currentTouch.onStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(e){}}const $t=Object.freeze(Object.defineProperty({__proto__:null,DragInFromWebsiteStrategy:kt},Symbol.toStringTag,{value:"Module"})),zt=n=>`[data-rml-custom-view="${n}"]`,X=n=>{n.preventDefault(),n.stopPropagation()},Vt=(n,e,t,s)=>{const r=t-n,i=s-e;return Math.sqrt(r*r+i*i)};class qt{constructor({onCustomDragStart:e},t={}){l(this,"_startX",0);l(this,"_startY",0);l(this,"_lastX",0);l(this,"_lastY",0);l(this,"_epsilon");l(this,"_isWaiting",!1);l(this,"_onCustomDragStart");this._epsilon=typeof t.epsilon=="number"?t.epsilon:dt,this._onCustomDragStart=e}onMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._isWaiting&&Vt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(e),this._isWaiting=!1)}onStart(e){this._startX=e.clientX,this._startY=e.clientY,this.onMove(e),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const W="data-rml-old-draggable",Kt=void 0,ft=(n,e)=>{const t=T(n),s={delay:t?U:Ut,epsilon:t?B:dt};if(!e)return s;if(!t&&!(n instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:r,epsilonKey:i}=t?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof e[r]=="number"&&(s.delay=e.touchDragDelay),typeof e[i]=="number"&&(s.epsilon=e.touchDragEpsilon),s},Jt=n=>{let e="",t=F,s=P;if(!n)return{url:R,width:t,height:s};const r=n;if(r instanceof HTMLElement){const i=r.getBoundingClientRect(),o=r.getAttribute("data-rml-ghost-url"),c=r.getAttribute("data-rml-ghost-width"),a=r.getAttribute("data-rml-ghost-height");o?e=o:!o&&r instanceof HTMLImageElement&&r.src&&(e=r.src),e?(t=i.width,s=i.height):e=R,t=c?parseInt(c,10):t,s=a?parseInt(a,10):s}return{url:e||R,width:t,height:s}};class jt{constructor(e,t,s){l(this,"_options",{});l(this,"_instance");l(this,"_viewName");l(this,"_currentCustomDrag",null);l(this,"_currentBb",null);l(this,"_startTarget",null);l(this,"_onBeforeUpdateDrag",()=>({}));l(this,"isDragging",!1);this._instance=e,this._options=t||{},this._viewName=s}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}async _dragStart(e,t,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(W,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",X),this._startTarget.addEventListener("dragstart",X)),this._currentBb=await this._instance.getBoundingClientRect(zt(this._viewName));const{clientX:r,clientY:i}=I(t),o=this._currentBb.x+r,c=this._currentBb.y+i;this.isDragging=!0,this._instance.dragInObject(e,o,c,s)}_dragUpdate(e){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(e),!this._currentBb||!this.isDragging)return;const{clientX:t,clientY:s}=I(e),{url:r,width:i,height:o}=Jt(this._startTarget),c=this._currentBb.x+t,a=this._currentBb.y+s,d=this._options||{},h={ghost:{visibleIn:{x:this._currentBb.x-(d.dragInOverlapX||0),y:this._currentBb.y+(d.dragInOverlapY||0),width:this._currentBb.width+(d.dragInOverlapX||0),height:this._currentBb.height+(d.dragInOverlapY||0)},url:r,width:i,height:o},mode:"custom-view"},{x:u,y:g,options:f}=this._onBeforeUpdateDrag(c,a,h),S=typeof u=="number"?u:c,E=typeof g=="number"?g:a,y=f||h;this._instance.updateDrag(S,E,y)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(e,t,s){this._instance.disableEvents(),this._startTarget=t.target;const r=(i,o)=>{this._dragStart(e,o,s)};this._currentCustomDrag=T(t)?new gt(Kt,{onTouchDragStart:r},ft(t,this._options)):new qt({onCustomDragStart:i=>this._dragStart(e,i,s)},ft(t,this._options)),this._currentCustomDrag.onStart(t)}dragEnd(){this._dragEnd()}dragUpdate(e){this._dragUpdate(e)}touchStart(e,t,s="rml_id"){this.dragStart(e,t,s)}touchMove(e){this.dragUpdate(e)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(W)==="true",this._startTarget.removeAttribute(W),this._startTarget.removeEventListener("dragstart",X))}releaseInput(e){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}const Qt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromCustomViewStrategy:jt},Symbol.toStringTag,{value:"Module"}));return Nt});
@@ -1,17 +1,17 @@
1
- (function(p,D){typeof exports=="object"&&typeof module<"u"?module.exports=D():typeof define=="function"&&define.amd?define(D):(p=typeof globalThis<"u"?globalThis:p||self,p["roomle-embedding-lib"]=p["roomle-embedding-lib"]||{},p["roomle-embedding-lib"].umd=p["roomle-embedding-lib"].umd||{},p["roomle-embedding-lib"].umd.min=p["roomle-embedding-lib"].umd.min||{},p["roomle-embedding-lib"].umd.min.js=D())})(this,function(){"use strict";var p=Object.defineProperty,D=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,h=(i,t,e)=>D(i,typeof t!="symbol"?t+"":t,e);class ${constructor(t,e,s,r){h(this,"_side"),h(this,"_incomingMessageBus",null),h(this,"_outgoingMessageBus",null),h(this,"_execMessage",null),this._side=t,this._incomingMessageBus=e,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(t){this._outgoingMessageBus=t}setMessageExecution(t){this._execMessage=t}sendMessage(t,e=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const n=new MessageChannel;n.port1.onmessage=a=>{if(!a||!a.data)return n.port1.close(),n.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(a.data)}catch(l){return n.port1.close(),n.port2.close(),this._prepareError(l),r(l)}c.error?r(c.error):c.result!==void 0?s(c.result):s(void 0),n.port1.close(),n.port2.close()};let o="";try{o=JSON.stringify({message:t,args:e})}catch{return r(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return r(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(o,"*",[n.port2])})}_handleMessage(t){const e=t.ports&&Array.isArray(t.ports)&&t.ports.length>0?t.ports[0]:null;if(t.data&&e)try{const s=JSON.parse(t.data);if(!this._execMessage)return e.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const r=this._execMessage(s,t);if(r===void 0)return;r.then((n={})=>{let o,a;typeof n=="object"&&n!==null&&(o=n.error,a=n.result),o?e.postMessage(JSON.stringify({error:o})):a!==void 0?e.postMessage(JSON.stringify({result:a})):e.postMessage(JSON.stringify({result:n}))},n=>{e.postMessage(JSON.stringify({error:this._prepareError(n)}))})}catch(s){e.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(t){if(typeof t=="string"){const e=this._side+": "+t;return console.error(e),e}return t.message=this._side+": "+t.message,console.error(t),t.message}}const C=".",L={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},E={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},ft=async(i,t)=>{if(typeof i!="string")throw new Error('Configurator ID is not a string type: "'+typeof i+'"');const e=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",s=t.overrideTenant||9,r=e+"/configurators/"+i,n="roomle_portal_v2",o="03-"+window.btoa(new Date().toISOString()+";anonymous;"+n),a=()=>{const u={apiKey:n,currentTenant:s,locale:"en",language:"en",device:1,token:o,platform:"web"};return new Headers(u)},c=new Request(r,{method:"GET",headers:a(),mode:"cors",cache:"default"}),l=await fetch(c),{configurator:d}=await l.json();return d},yt=()=>{try{return window.self!==window.top}catch{return!0}},vt=["127.0.0.1","localhost","0.0.0.0"],Dt=()=>{const i=yt();let t=window.location.href;if(i){if(!document.referrer)return null;t=document.referrer}const{hostname:e}=new URL(t);return e},wt=i=>!!(vt.includes(i)||i.endsWith("roomle.com")||i.endsWith("gitlab.io")||i.endsWith("gitlab.com")),j=["language","browserLanguage","userLanguage","systemLanguage"],bt=(i=null)=>{const t=window.navigator;if(i)return i.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,s=j.length;e<s;e++){const r=t[j[e]];if(r)return r.substr(0,2)}return"en"},Et=(i,t)=>{const e=JSON.parse(JSON.stringify(i));return A(e,t)},A=(i,t)=>{for(const e in t)try{t[e].constructor===Object?i[e]=A(i[e],t[e]):i[e]=t[e]}catch{i[e]=t[e]}return i};var Tt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const It={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,wallAutoHeight:!1},rotationSnapDegrees:10},St="(idle)",Ot=i=>(N(i),i!=null&&i.customApiUrl&&(i.customApiUrl=decodeURIComponent(i.customApiUrl)),i.shareUrl&&(i.deeplink=i.shareUrl.replace(Ct,Lt)),i),N=i=>{if(!i)return;const t=Object.keys(i);for(const e of t){const s=i[e];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&N(s),Array.isArray(s))for(const r of s)N(r);(s==="true"||s==="false")&&(i[e]=s==="true")}},xt=(i,t)=>{t.configuratorId=i.id;const e=i.settings||{};return!t.overrideTenant&&i.tenant&&(t.overrideTenant=i.tenant),Et(e,t)},Mt=()=>{const i={...It};i.locale||(i.locale=bt()),i.id===St&&delete i.id;const t=Dt();return t&&wt(t)&&(i.configuratorId="demoConfigurator"),i.customApiUrl=Tt.VITE_RAPI_URL,i.emails=!1,i},Ct="<CONF_ID>",Lt="#CONFIGURATIONID#",At=i=>{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)},z=()=>/(android)/i.test(navigator.userAgent);class V{constructor(){h(this,"_messageHandler",null),h(this,"isSetupDone",!1),h(this,"viewName","main"),h(this,"plugins",{}),h(this,"pluginsLoaded",[]),h(this,"ui",{callbacks:null}),h(this,"extended",{callbacks:null}),h(this,"configurator",{callbacks:null}),h(this,"analytics",{callbacks:{}}),h(this,"global",{callbacks:{}})}setMessageHandler(t){this._messageHandler=t}handleSetup(t){const{methods:e,callbacks:s}=t;e.forEach(r=>{const n=r.split(C),o=n[0],a=n[1];this[o]||(this[o]={}),this[o][a]=function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(r,[...arguments])}.bind(this)}),s.forEach(r=>{const n=r.split(C),o=n[0],a=n[1],c=n[2];this[o]||(this[o]={}),this[o][a]||(this[o][a]={}),this[o][a][c]=()=>{}}),this.isSetupDone=!0}executeMessage({message:t,args:e}){const s=t.split(C),r=s[0],n=s[1],o=s.length===3?s[2]:null;if(o&&this[r][n][o]){const a=this[r][n][o](...e);return a instanceof Promise?a.then(c=>({result:c})):a!==void 0?Promise.resolve({result:a}):Promise.resolve({result:null})}return Promise.reject('Message "'+t+'" is unkown')}setupPlugins(t,e,s="website"){for(const r of t)typeof r=="string"&&r==="dragIn"?this.pluginsLoaded.push(new Promise((n,o)=>{try{Promise.resolve().then(()=>Ut).then(({DragIn:a})=>{const c=new a(this.ui,e,s,this.viewName);c.init().then(()=>{this.plugins.dragIn=c,n()},o)})}catch(a){o(a)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((n,o)=>{try{r.loader().then(a=>{const c=new a(this.ui,e,s,this.viewName);c.init().then(()=>{this.plugins[r.name]=c,n()},o)})}catch(a){o(a)}}))}}const q=()=>{let i,t;return{promise:new Promise((e,s)=>{i=e,t=s}),resolve:i,reject:t}},J=(i,t,e)=>{let s=null;Object.defineProperty(i,t,{get(){return s||e},set(r){r!=null&&r.mute?s=r.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 }"),s=r)}})},K=()=>window.innerHeight*.01+"px",Q=i=>{i&&setTimeout(()=>i.style.setProperty(R,K()),0)},Z="rml-styles",Nt=450,R="--rml-full-height",m={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},P=new Map;class Rt extends V{constructor(t,e,s,r,n){if(super(),h(this,"_waitForIframe"),h(this,"_container"),h(this,"_configuratorSettings"),h(this,"_initData",{}),h(this,"_iframe"),!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(P.has(e))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(Z)){const c=s.zIndex||9999999,l=document.createElement("style");l.type="text/css",l.id=Z;const d="transition:all ease-in-out "+Nt+"ms;",u=["-webkit-","-o-"].reduce((_,y)=>_+=y+d,"")+d,g=K();l.innerHTML=`
1
+ (function(p,D){typeof exports=="object"&&typeof module<"u"?module.exports=D():typeof define=="function"&&define.amd?define(D):(p=typeof globalThis<"u"?globalThis:p||self,p["roomle-embedding-lib"]=p["roomle-embedding-lib"]||{},p["roomle-embedding-lib"].umd=p["roomle-embedding-lib"].umd||{},p["roomle-embedding-lib"].umd.min=p["roomle-embedding-lib"].umd.min||{},p["roomle-embedding-lib"].umd.min.js=D())})(this,function(){"use strict";var p=Object.defineProperty,D=(i,t,e)=>t in i?p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,h=(i,t,e)=>D(i,typeof t!="symbol"?t+"":t,e);class ${constructor(t,e,s,r){h(this,"_side"),h(this,"_incomingMessageBus",null),h(this,"_outgoingMessageBus",null),h(this,"_execMessage",null),this._side=t,this._incomingMessageBus=e,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(t){this._outgoingMessageBus=t}setMessageExecution(t){this._execMessage=t}sendMessage(t,e=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const n=new MessageChannel;n.port1.onmessage=o=>{if(!o||!o.data)return n.port1.close(),n.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(o.data)}catch(l){return n.port1.close(),n.port2.close(),this._prepareError(l),r(l)}c.error?r(c.error):c.result!==void 0?s(c.result):s(void 0),n.port1.close(),n.port2.close()};let a="";try{a=JSON.stringify({message:t,args:e})}catch{return r(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return r(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(a,"*",[n.port2])})}_handleMessage(t){const e=t.ports&&Array.isArray(t.ports)&&t.ports.length>0?t.ports[0]:null;if(t.data&&e)try{const s=JSON.parse(t.data);if(!this._execMessage)return e.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const r=this._execMessage(s,t);if(r===void 0)return;r.then((n={})=>{let a,o;typeof n=="object"&&n!==null&&(a=n.error,o=n.result),a?e.postMessage(JSON.stringify({error:a})):o!==void 0?e.postMessage(JSON.stringify({result:o})):e.postMessage(JSON.stringify({result:n}))},n=>{e.postMessage(JSON.stringify({error:this._prepareError(n)}))})}catch(s){e.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(t){if(typeof t=="string"){const e=this._side+": "+t;return console.error(e),e}return t.message=this._side+": "+t.message,console.error(t),t.message}}const C=".",N={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},E={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},yt=async(i,t)=>{if(typeof i!="string")throw new Error('Configurator ID is not a string type: "'+typeof i+'"');const e=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",s=t.overrideTenant||9,r=e+"/configurators/"+i,n="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+n),o=()=>{const u={apiKey:n,currentTenant:s,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(u)},c=new Request(r,{method:"GET",headers:o(),mode:"cors",cache:"default"}),l=await fetch(c),{configurator:d}=await l.json();return d},vt=()=>{try{return window.self!==window.top}catch{return!0}},Dt=["127.0.0.1","localhost","0.0.0.0"],bt=()=>{const i=vt();let t=window.location.href;if(i){if(!document.referrer)return null;t=document.referrer}const{hostname:e}=new URL(t);return e},wt=i=>!!(Dt.includes(i)||i.endsWith("roomle.com")||i.endsWith("gitlab.io")||i.endsWith("gitlab.com")),j=["language","browserLanguage","userLanguage","systemLanguage"],Et=(i=null)=>{const t=window.navigator;if(i)return i.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,s=j.length;e<s;e++){const r=t[j[e]];if(r)return r.substr(0,2)}return"en"},Tt=(i,t)=>{const e=JSON.parse(JSON.stringify(i));return A(e,t)},A=(i,t)=>{for(const e in t)try{t[e].constructor===Object?i[e]=A(i[e],t[e]):i[e]=t[e]}catch{i[e]=t[e]}return i};var z=(i=>(i.BOTTOM_BAR="bottom_bar",i.PARTLIST_BOUNDS="partlist_bounds",i.INTERACTION_NOTES="interaction_notes",i))(z||{}),It={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const St={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[z.INTERACTION_NOTES]:!1},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1},rotationSnapDegrees:10},Ot="(idle)",xt=i=>(L(i),i!=null&&i.customApiUrl&&(i.customApiUrl=decodeURIComponent(i.customApiUrl)),i.shareUrl&&(i.deeplink=i.shareUrl.replace(Nt,At)),i),L=i=>{if(!i)return;const t=Object.keys(i);for(const e of t){const s=i[e];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&L(s),Array.isArray(s))for(const r of s)L(r);(s==="true"||s==="false")&&(i[e]=s==="true")}},Mt=(i,t)=>{t.configuratorId=i.id;const e=i.settings||{};return!t.overrideTenant&&i.tenant&&(t.overrideTenant=i.tenant),Tt(e,t)},Ct=()=>{const i={...St};i.locale||(i.locale=Et()),i.id===Ot&&delete i.id;const t=bt();return t&&wt(t)&&(i.configuratorId="demoConfigurator"),i.customApiUrl=It.VITE_RAPI_URL,i.emails=!1,i},Nt="<CONF_ID>",At="#CONFIGURATIONID#",V=()=>/(android)/i.test(navigator.userAgent);class q{constructor(){h(this,"_messageHandler",null),h(this,"isSetupDone",!1),h(this,"viewName","main"),h(this,"plugins",{}),h(this,"pluginsLoaded",[]),h(this,"ui",{callbacks:null}),h(this,"extended",{callbacks:null}),h(this,"configurator",{callbacks:null}),h(this,"analytics",{callbacks:{}}),h(this,"global",{callbacks:{}})}setMessageHandler(t){this._messageHandler=t}handleSetup(t){const{methods:e,callbacks:s}=t;e.forEach(r=>{const n=r.split(C),a=n[0],o=n[1];this[a]||(this[a]={}),this[a][o]=function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(r,[...arguments])}.bind(this)}),s.forEach(r=>{const n=r.split(C),a=n[0],o=n[1],c=n[2];this[a]||(this[a]={}),this[a][o]||(this[a][o]={}),this[a][o][c]=()=>{}}),this.isSetupDone=!0}executeMessage({message:t,args:e}){const s=t.split(C),r=s[0],n=s[1],a=s.length===3?s[2]:null;if(a&&this[r][n][a]){const o=this[r][n][a](...e);return o instanceof Promise?o.then(c=>({result:c})):o!==void 0?Promise.resolve({result:o}):Promise.resolve({result:null})}return Promise.reject('Message "'+t+'" is unkown')}setupPlugins(t,e,s="website"){for(const r of t)typeof r=="string"&&r==="dragIn"?this.pluginsLoaded.push(new Promise((n,a)=>{try{Promise.resolve().then(()=>Bt).then(({DragIn:o})=>{const c=new o(this.ui,e,s,this.viewName);c.init().then(()=>{this.plugins.dragIn=c,n()},a)})}catch(o){a(o)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((n,a)=>{try{r.loader().then(o=>{const c=new o(this.ui,e,s,this.viewName);c.init().then(()=>{this.plugins[r.name]=c,n()},a)})}catch(o){a(o)}}))}}const J=()=>{let i,t;return{promise:new Promise((e,s)=>{i=e,t=s}),resolve:i,reject:t}},K=(i,t,e)=>{let s=null;Object.defineProperty(i,t,{get(){return s||e},set(r){r!=null&&r.mute?s=r.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 }"),s=r)}})},Q=()=>window.innerHeight*.01+"px",Z=i=>{i&&setTimeout(()=>i.style.setProperty(R,Q()),0)},tt="rml-styles",Lt=450,R="--rml-full-height",m={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},P=new Map;class Rt extends q{constructor(t,e,s,r,n){if(super(),h(this,"_waitForIframe"),h(this,"_container"),h(this,"_configuratorSettings"),h(this,"_initData",{}),h(this,"_iframe"),!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(P.has(e))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(tt)){const c=s.zIndex||9999999,l=document.createElement("style");l.type="text/css",l.id=tt;const d="transition:all ease-in-out "+Lt+"ms;",u=["-webkit-","-o-"].reduce((_,y)=>_+=y+d,"")+d,g=Q();l.innerHTML=`
2
2
  .${m.CONTAINER}{${R}:${g};}
3
3
  .${m.POSITION}{position:fixed;top:0;left:0;z-index:${c};opacity:0}
4
4
  .${m.TRANSITION}{${u}}
5
5
  .${m.FILL}{width:100%;height:100%;opacity:1}
6
6
  .${m.ANDROID_HEIGHT}{height:calc(var(${R},1vh)*100)}
7
7
  .${m.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(l)}this._executeMessage=this._executeMessage.bind(this);const o=new $("website",window,null,this._executeMessage);this.setMessageHandler(o),this._onResize=this._onResize.bind(this),z()&&window.addEventListener("resize",this._onResize),this._container=e,this._initData=s,this._configuratorSettings=t;const a=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=n,this._container.appendChild(a),this._iframe=a,this.setupPlugins(r,this._iframe),P.set(e,!0)}static createPlanner(t,e,s,r=[]){return this._create(t,e,s,r)}static async connect(t,e=[]){const s=new V;s.viewName=t;const{resolve:r,promise:n}=q(),{resolve:o,promise:a}=q(),c=({message:u,args:g})=>{switch(u){case E.REGISTER_CUSTOM_VIEW_DONE:r();break;case E.RETURN_METHODS:s.handleSetup(g[0]),o();break;default:if(s.isSetupDone)return s.executeMessage({message:u,args:g})}},l=new $("custom-view-"+t,window,window.parent,c);s.setMessageHandler(l);const d=[t];return l.sendMessage(E.REGISTER_CUSTOM_VIEW,d),await n,l.sendMessage(E.GET_METHODS,d),await a,s.setupPlugins(e,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(t,e,s,r=[]){return this._create(t,e,s,r)}static create(t,e,s,r){return this._create(t,e,s,r)}static createViewer(t,e,s,r=[]){return this._create(t,e,s,r)}static async _create(t,e,s,r){return new Promise(async(n,o)=>{try{const a=A(Mt(),Ot(s));At(a);const c=await ft(t,a);s=xt(c,a);const l=new this(c,e,s,r,n);return await Promise.allSettled(l.pluginsLoaded),l}catch(a){return o(a)}})}teardown(){this._container&&P.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var t;const e=document.createElement("iframe");let s=((t=this._configuratorSettings)==null?void 0:t.url)||"https://www.roomle.com/t/cp/";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(m.CONTAINER),e.classList.add(m.FILL),e}_onResize(){Q(this._iframe)}_onUseFullPage(){this._iframe.classList.add(m.POSITION),document.documentElement.classList.add(m.OVERFLOW_HIDDEN),window.document.body.classList.add(m.OVERFLOW_HIDDEN),z()&&(Q(this._iframe),this._iframe.classList.add(m.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(m.POSITION),this._iframe.classList.remove(m.ANDROID_HEIGHT),document.documentElement.classList.remove(m.OVERFLOW_HIDDEN),window.document.body.classList.remove(m.OVERFLOW_HIDDEN)}_executeMessage({message:t,args:e},s){var r;if(s.source&&s.source===((r=this._iframe)==null?void 0:r.contentWindow))return t===L.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):t===L.SETUP?(this.handleSetup(e[0]),J(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),J(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(L.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:e})}}class Pt{constructor(t,e,s,r){h(this,"_mainDomElement"),h(this,"_instance"),h(this,"_mode","website"),h(this,"_viewName","main"),this._instance=t,this._mainDomElement=e,this._mode=s,this._viewName=r}async init(){return Promise.resolve()}}const T="rml-drag-in-styles",I="rml-drag-in-drag-element",S="rml-drag-in-overlay",O="rml-drag-in-drag-ghost",tt="rml-drag-in-fade-in",et="rml-drag-in-fade-out",F={DISPLAY_NONE:"rml-display-none"},st=.5,it="250ms",rt="forwards",nt=`@keyframes ${tt} {from{opacity: 0;}to {opacity: ${st};}}`,ot=`@keyframes ${et} {from{opacity: ${st};}to {opacity: 0;}}`,at=`${tt} ${it} ${rt}`,lt=`${et} ${it} ${rt}`,x="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",U=112,B=112;class Ft extends Pt{constructor(t,e,s,r){super(t,e,s,r),h(this,"options",{}),h(this,"_customDragSignal",new AbortController),this._mainDomElement=e,this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!document.getElementById(T)){const t=document.createElement("style");t.type="text/css",t.id=T,t.innerHTML=`
8
+ `,document.head.appendChild(l)}this._executeMessage=this._executeMessage.bind(this);const a=new $("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),V()&&window.addEventListener("resize",this._onResize),this._container=e,this._initData=s,this._configuratorSettings=t;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=n,this._container.appendChild(o),this._iframe=o,this.setupPlugins(r,this._iframe),P.set(e,!0)}static createPlanner(t,e,s,r=[]){return this._create(t,e,s,r)}static async connect(t,e=[]){const s=new q;s.viewName=t;const{resolve:r,promise:n}=J(),{resolve:a,promise:o}=J(),c=({message:u,args:g})=>{switch(u){case E.REGISTER_CUSTOM_VIEW_DONE:r();break;case E.RETURN_METHODS:s.handleSetup(g[0]),a();break;default:if(s.isSetupDone)return s.executeMessage({message:u,args:g})}},l=new $("custom-view-"+t,window,window.parent,c);s.setMessageHandler(l);const d=[t];return l.sendMessage(E.REGISTER_CUSTOM_VIEW,d),await n,l.sendMessage(E.GET_METHODS,d),await o,s.setupPlugins(e,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(t,e,s,r=[]){return this._create(t,e,s,r)}static create(t,e,s,r){return this._create(t,e,s,r)}static createViewer(t,e,s,r=[]){return this._create(t,e,s,r)}static async _create(t,e,s,r){return new Promise(async(n,a)=>{try{const o=A(Ct(),xt(s));o.featureFlags||(o.featureFlags={}),typeof o.featureFlags.realPartList!="boolean"&&(o.featureFlags.realPartList=!0),typeof o.featureFlags.globalCallbacks!="boolean"&&(o.featureFlags.globalCallbacks=!0),typeof o.featureFlags.mocAr!="boolean"&&(o.featureFlags.mocAr=!1);const c=await yt(t,o);s=Mt(c,o);const l=new this(c,e,s,r,n);return await Promise.allSettled(l.pluginsLoaded),l}catch(o){return a(o)}})}teardown(){this._container&&P.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var t;const e=document.createElement("iframe");let s=((t=this._configuratorSettings)==null?void 0:t.url)||"https://www.roomle.com/t/cp/";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(m.CONTAINER),e.classList.add(m.FILL),e}_onResize(){Z(this._iframe)}_onUseFullPage(){this._iframe.classList.add(m.POSITION),document.documentElement.classList.add(m.OVERFLOW_HIDDEN),window.document.body.classList.add(m.OVERFLOW_HIDDEN),V()&&(Z(this._iframe),this._iframe.classList.add(m.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(m.POSITION),this._iframe.classList.remove(m.ANDROID_HEIGHT),document.documentElement.classList.remove(m.OVERFLOW_HIDDEN),window.document.body.classList.remove(m.OVERFLOW_HIDDEN)}_executeMessage({message:t,args:e},s){var r;if(s.source&&s.source===((r=this._iframe)==null?void 0:r.contentWindow))return t===N.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):t===N.SETUP?(this.handleSetup(e[0]),K(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),K(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(N.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:e})}}class Pt{constructor(t,e,s,r){h(this,"_mainDomElement"),h(this,"_instance"),h(this,"_mode","website"),h(this,"_viewName","main"),this._instance=t,this._mainDomElement=e,this._mode=s,this._viewName=r}async init(){return Promise.resolve()}}const T="rml-drag-in-styles",I="rml-drag-in-drag-element",S="rml-drag-in-overlay",O="rml-drag-in-drag-ghost",et="rml-drag-in-fade-in",st="rml-drag-in-fade-out",F={DISPLAY_NONE:"rml-display-none"},it=.5,rt="250ms",nt="forwards",ot=`@keyframes ${et} {from{opacity: 0;}to {opacity: ${it};}}`,at=`@keyframes ${st} {from{opacity: ${it};}to {opacity: 0;}}`,lt=`${et} ${rt} ${nt}`,ht=`${st} ${rt} ${nt}`,x="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",B=112,U=112;class Ft extends Pt{constructor(t,e,s,r){super(t,e,s,r),h(this,"options",{}),h(this,"_customDragSignal",new AbortController),this._mainDomElement=e,this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!document.getElementById(T)){const t=document.createElement("style");t.type="text/css",t.id=T,t.innerHTML=`
9
9
  .${F.DISPLAY_NONE}{display:none}
10
10
  .${S}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
11
11
  .${O}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
12
- ${nt}
13
12
  ${ot}
14
- `,document.head.appendChild(t)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let e=t.querySelector("."+O);e||(e=document.createElement("div"),e.classList.add(O),e.innerText=" ",t.appendChild(e))}async init(){if(await super.init(),this._mode==="website")try{const{DragInFromWebsiteStrategy:t}=await Promise.resolve().then(()=>jt);this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw console.error('Could not load Dragin strategy "FromWebsite"'),t}else if(this._mode==="custom-view")try{const{DragInFromCustomViewStrategy:t}=await Promise.resolve().then(()=>Zt);this._strategy=new t(this._instance,this.options,this._viewName)}catch(t){throw console.error('Could not load Dragin strategy "FromCustomView"'),t}else throw new Error("Unsupported mode")}get isDragging(){return this._strategy.isDragging}dragStart(t,e,s="rml_id"){this._strategy.dragStart(t,e,s)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,e,s="rml_id"){this._strategy.touchStart(t,e,s)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:e,customDragUpdate:s,beforeUpdateGhost:r}){r&&this._strategy.beforeUpdateGhost(r);const n=this._customDragSignal.signal,o=l=>{l.target.getAttribute("data-rml-draggable")==="true"&&t(l)},a=l=>{this._strategy.releaseInput(l),this._strategy.isDragging&&e(l)},c=l=>{s(l)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(l=>{l.draggable=!1}),document.addEventListener("mousedown",o,{signal:n}),document.addEventListener("mouseup",a,{signal:n}),document.addEventListener("mousemove",c,{signal:n}),document.addEventListener("mouseleave",a,{signal:n}),document.addEventListener("touchstart",o,{signal:n}),document.addEventListener("touchend",a,{signal:n}),document.addEventListener("touchmove",c,{signal:n})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Ut=Object.freeze(Object.defineProperty({__proto__:null,DragIn:Ft},Symbol.toStringTag,{value:"Module"}));class Bt{constructor(t=16){h(this,"_computedStyleCache",new Map),h(this,"_maxLifetime",16),h(this,"_cacheCleanInterval",null),this._maxLifetime=t}get(t){const e=this._computedStyleCache.get(t),s=Date.now();if(e&&s-e.updated<this._maxLifetime)return e.style;const r=getComputedStyle(t);return this._computedStyleCache.set(t,{style:r,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_cleanUpCache(){const t=Date.now();for(const[e,{updated:s}]of this._computedStyleCache.entries())t-s>=this._maxLifetime&&this._computedStyleCache.delete(e);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const f=i=>window.TouchEvent&&i instanceof window.TouchEvent;let H;const M=i=>(H||(H=new Bt),H.get(i)),ht=(i,t,e)=>{const s=parseFloat(i),r=window.devicePixelRatio||1;if(t==="px")return s;if(t==="%"){const o=e===document.documentElement?window.innerWidth:e.offsetWidth;return s/100*o}if(t==="rem"){const o=parseFloat(M(document.documentElement).fontSize);return s*o}if(t==="em"){const o=parseFloat(M(e).fontSize);return s*o}if(t==="vh"||t==="vw"||t==="vmin"||t==="vmax"){const o={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*o[t]}const n={cm:37.7952755906,mm:3.77952755906,in:96};return t in n?s*n[t]*r:(console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"),0)},ct=(i,t,e={x:0,y:0})=>{const s=i.getBoundingClientRect(),r=M(i).transform;let n=0,o=0;if(r!=="none"){const u=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,g=r.match(u);g&&(n=ht(g[1],g[2],i),o=ht(g[3],g[4],i))}const{clientX:a,clientY:c}=w(t,e),l=a-s.left-n+i.scrollLeft,d=c-s.top-o+i.scrollTop;return{x:l,y:d}},w=(i,t=null)=>{const{clientX:e,clientY:s}=f(i)?Ht(i):i,r=e>0?e:t?t.x:e,n=s>0?s:t?t.y:s;return{clientX:r,clientY:n}},Ht=i=>{if(i.touches.length){let{clientX:e,clientY:s}=i.touches[0];if(i.touches.length>1){const r=i.touches[1],n=r.clientX,o=r.clientY;e=(e+n)/2,s=(s+o)/2}return{clientX:e,clientY:s}}const t=i.changedTouches[0];return{clientX:t.clientX,clientY:t.clientY}},G=500,Y=10,Gt=100,dt=15,X=(i,t=0)=>f(i)?{clientX:i.touches[t].clientX,clientY:i.touches[t].clientY}:{clientX:i.clientX,clientY:i.clientY},ut=i=>i&&f(i)?i.touches.length>0:!0;class gt{constructor(t,{onTouchDragStart:e},s={}){h(this,"_touchDragTimeOut"),h(this,"_onTouchDragStart"),h(this,"_payload",null),h(this,"_delay",G),h(this,"_firstTouch",null),h(this,"_lastTouch",null),h(this,"_epsilon",Y),this._payload=t,this._onTouchDragStart=e,this._delay=typeof s.delay=="number"?s.delay:G,this._epsilon=typeof s.epsilon=="number"?s.epsilon:Y}onStart(t){ut(t)&&(this._touchDragTimeOut||(this._firstTouch=X(t,f(t)?t.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=X(t)),this._checkXDistance(t)()},this._delay)))}onEnd(){this._resetTouches()}onMove(t){ut(t)&&(this._lastTouch=X(t))}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(t){return()=>{if(!this._firstTouch||!this._lastTouch)return;let e=!1;e=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<this._epsilon,e&&(this._onTouchDragStart(this._payload,t),this._resetTouches())}}}const mt=(i,t,e=0,s=0)=>{const r=t.x+t.width+e,n=t.x-e,o=t.y+t.height+s,a=t.y-s,{x:c,y:l}=i;return c>=n&&c<=r&&l>=a&&l<=o},_t=(i,t,e,s=0,r=0)=>{if(!(!e||!e.hiddenIn&&!e.visibleIn))return e.visibleIn?mt({x:i,y:t},e.visibleIn,s,r):e.hiddenIn?!mt({x:i,y:t},e.hiddenIn,-s,-r):!1},Yt=()=>{if(!document.getElementById(T)){const i=document.createElement("style");i.type="text/css",i.id=T,i.innerHTML=`
15
- ${nt}
13
+ ${at}
14
+ `,document.head.appendChild(t)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let e=t.querySelector("."+O);e||(e=document.createElement("div"),e.classList.add(O),e.innerText=" ",t.appendChild(e))}async init(){if(await super.init(),this._mode==="website")try{const{DragInFromWebsiteStrategy:t}=await Promise.resolve().then(()=>jt);this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw console.error('Could not load Dragin strategy "FromWebsite"'),t}else if(this._mode==="custom-view")try{const{DragInFromCustomViewStrategy:t}=await Promise.resolve().then(()=>Zt);this._strategy=new t(this._instance,this.options,this._viewName)}catch(t){throw console.error('Could not load Dragin strategy "FromCustomView"'),t}else throw new Error("Unsupported mode")}get isDragging(){return this._strategy.isDragging}dragStart(t,e,s="rml_id"){this._strategy.dragStart(t,e,s)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,e,s="rml_id"){this._strategy.touchStart(t,e,s)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:e,customDragUpdate:s,beforeUpdateGhost:r}){r&&this._strategy.beforeUpdateGhost(r);const n=this._customDragSignal.signal,a=l=>{l.target.getAttribute("data-rml-draggable")==="true"&&t(l)},o=l=>{this._strategy.releaseInput(l),this._strategy.isDragging&&e(l)},c=l=>{s(l)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(l=>{l.draggable=!1}),document.addEventListener("mousedown",a,{signal:n}),document.addEventListener("mouseup",o,{signal:n}),document.addEventListener("mousemove",c,{signal:n}),document.addEventListener("mouseleave",o,{signal:n}),document.addEventListener("touchstart",a,{signal:n}),document.addEventListener("touchend",o,{signal:n}),document.addEventListener("touchmove",c,{signal:n})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Bt=Object.freeze(Object.defineProperty({__proto__:null,DragIn:Ft},Symbol.toStringTag,{value:"Module"}));class Ut{constructor(t=16){h(this,"_computedStyleCache",new Map),h(this,"_maxLifetime",16),h(this,"_cacheCleanInterval",null),this._maxLifetime=t}get(t){const e=this._computedStyleCache.get(t),s=Date.now();if(e&&s-e.updated<this._maxLifetime)return e.style;const r=getComputedStyle(t);return this._computedStyleCache.set(t,{style:r,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_cleanUpCache(){const t=Date.now();for(const[e,{updated:s}]of this._computedStyleCache.entries())t-s>=this._maxLifetime&&this._computedStyleCache.delete(e);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const f=i=>window.TouchEvent&&i instanceof window.TouchEvent;let H;const M=i=>(H||(H=new Ut),H.get(i)),ct=(i,t,e)=>{const s=parseFloat(i),r=window.devicePixelRatio||1;if(t==="px")return s;if(t==="%"){const a=e===document.documentElement?window.innerWidth:e.offsetWidth;return s/100*a}if(t==="rem"){const a=parseFloat(M(document.documentElement).fontSize);return s*a}if(t==="em"){const a=parseFloat(M(e).fontSize);return s*a}if(t==="vh"||t==="vw"||t==="vmin"||t==="vmax"){const a={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*a[t]}const n={cm:37.7952755906,mm:3.77952755906,in:96};return t in n?s*n[t]*r:(console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"),0)},dt=(i,t,e={x:0,y:0})=>{const s=i.getBoundingClientRect(),r=M(i).transform;let n=0,a=0;if(r!=="none"){const u=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,g=r.match(u);g&&(n=ct(g[1],g[2],i),a=ct(g[3],g[4],i))}const{clientX:o,clientY:c}=b(t,e),l=o-s.left-n+i.scrollLeft,d=c-s.top-a+i.scrollTop;return{x:l,y:d}},b=(i,t=null)=>{const{clientX:e,clientY:s}=f(i)?Ht(i):i,r=e>0?e:t?t.x:e,n=s>0?s:t?t.y:s;return{clientX:r,clientY:n}},Ht=i=>{if(i.touches.length){let{clientX:e,clientY:s}=i.touches[0];if(i.touches.length>1){const r=i.touches[1],n=r.clientX,a=r.clientY;e=(e+n)/2,s=(s+a)/2}return{clientX:e,clientY:s}}const t=i.changedTouches[0];return{clientX:t.clientX,clientY:t.clientY}},G=500,Y=10,Gt=100,ut=15,k=(i,t=0)=>f(i)?{clientX:i.touches[t].clientX,clientY:i.touches[t].clientY}:{clientX:i.clientX,clientY:i.clientY},gt=i=>i&&f(i)?i.touches.length>0:!0;class mt{constructor(t,{onTouchDragStart:e},s={}){h(this,"_touchDragTimeOut"),h(this,"_onTouchDragStart"),h(this,"_payload",null),h(this,"_delay",G),h(this,"_firstTouch",null),h(this,"_lastTouch",null),h(this,"_epsilon",Y),this._payload=t,this._onTouchDragStart=e,this._delay=typeof s.delay=="number"?s.delay:G,this._epsilon=typeof s.epsilon=="number"?s.epsilon:Y}onStart(t){gt(t)&&(this._touchDragTimeOut||(this._firstTouch=k(t,f(t)?t.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=k(t)),this._checkXDistance(t)()},this._delay)))}onEnd(){this._resetTouches()}onMove(t){gt(t)&&(this._lastTouch=k(t))}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(t){return()=>{if(!this._firstTouch||!this._lastTouch)return;let e=!1;e=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<this._epsilon,e&&(this._onTouchDragStart(this._payload,t),this._resetTouches())}}}const _t=(i,t,e=0,s=0)=>{const r=t.x+t.width+e,n=t.x-e,a=t.y+t.height+s,o=t.y-s,{x:c,y:l}=i;return c>=n&&c<=r&&l>=o&&l<=a},pt=(i,t,e,s=0,r=0)=>{if(!(!e||!e.hiddenIn&&!e.visibleIn))return e.visibleIn?_t({x:i,y:t},e.visibleIn,s,r):e.hiddenIn?!_t({x:i,y:t},e.hiddenIn,-s,-r):!1},Yt=()=>{if(!document.getElementById(T)){const i=document.createElement("style");i.type="text/css",i.id=T,i.innerHTML=`
16
15
  ${ot}
17
- `,document.head.appendChild(i)}},Xt=({x:i,y:t},e)=>{var s,r,n,o,a,c;let l=document.getElementById(I);if(!l){if(l=document.createElement("div"),(s=e.ghost)!=null&&s.element)l.appendChild(e.ghost.element);else{const d=document.createElement("img");d.src=((r=e.ghost)==null?void 0:r.url)||x,d.width=((n=e.ghost)==null?void 0:n.width)||U,d.height=((o=e.ghost)==null?void 0:o.height)||B,l.appendChild(d)}l.id=I,l.style.position="fixed",l.style.top="0",l.style.left="0",l.style.willChange="transform",l.style.transform="translate3d(0, 0, 0)",l.style.zIndex="9999",l.style.opacity="0.5",_t(i,t,e.ghost||{},(a=e.settings)==null?void 0:a.dragInOverlapX,(c=e.settings)==null?void 0:c.dragInOverlapY)||(l.style.display="none"),l.style.pointerEvents="none",document.body.appendChild(l)}},kt=({x:i,y:t},e)=>{var s,r,n,o;const a=document.getElementById(I);if(!a)return;let c=(s=e.ghost)==null?void 0:s.width,l=(r=e.ghost)==null?void 0:r.height;typeof c>"u"&&(c=a.getBoundingClientRect().width||U),typeof l>"u"&&(l=a.getBoundingClientRect().height||B);const d=i-c/2,u=t-l/2;a.style.transform=`translate3d(${d}px, ${u}px, 0)`,e.ghost&&(_t(i,t,e.ghost,(n=e.settings)==null?void 0:n.dragInOverlapX,(o=e.settings)==null?void 0:o.dragInOverlapY)?a.style.animation!=at&&(a.style.animation=at):a.style.animation!=lt&&(a.style.animation=lt))};class Wt{constructor(t=null){h(this,"_dragGhostAnimationFrameId",null),h(this,"_dragGhostRemoveAnimationFrameId",null),h(this,"_dragGhostElement",null),this._dragGhostElement=t}updateDragGhost(t,e,s){var r;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((r=s.ghost)!=null&&r.external)&&s.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{Yt();const n={x:t,y:e};!s.ghost&&this._dragGhostElement&&(s.ghost={}),s.ghost&&!s.ghost.element&&this._dragGhostElement&&(s.ghost.element=this._dragGhostElement),Xt(n,s),kt(n,s),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const t=document.getElementById(I);t&&document.body.removeChild(t),this._dragGhostRemoveAnimationFrameId=null}))}}class $t{constructor(t,e,s){h(this,"_options",{}),h(this,"_instance"),h(this,"_mainDomElement"),h(this,"_currentDrag",{}),h(this,"_currentTouch",null),h(this,"_firefoxDragPosition",{x:0,y:0}),h(this,"_onBeforeUpdateDrag",()=>({})),h(this,"isDragging",!1),h(this,"_firefoxFallback",r=>{if(!this._currentDrag.event)return;const n=r||window.event;this._firefoxDragPosition.x=n.pageX||0,this._firefoxDragPosition.y=n.pageY||0}),this._instance=t,this._mainDomElement=e,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}dragStart(t,e,s="rml_id"){const r=this._mainDomElement.parentNode;if(M(r).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let n=r.querySelector("."+S);n||(n=document.createElement("div"),n.classList.add(S),r.appendChild(n)),n.classList.remove(F.DISPLAY_NONE),e.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const o=r.querySelector("."+O);this._currentDrag.event=e;const a=e.target,c=a.cloneNode(),l=a.getBoundingClientRect();c.style.width=`${l.width}px`,c.style.height=`${l.height}px`,this._currentDrag.ghost=new Wt(c),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:d,clientY:u}=w(e,this._firefoxDragPosition);this._currentDrag.offset.x=d-l.left,this._currentDrag.offset.y=u-l.top,e instanceof DragEvent&&e.dataTransfer&&e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(o,0,0);const{x:g,y:_}=ct(r,this._currentDrag.event||e,this._firefoxDragPosition),y=Math.max(1,g),b=Math.max(1,_);this.isDragging=!0,this._instance.dragInObject(t,y,b,s)}dragUpdate(t){var e;const s=this._mainDomElement.parentNode,{x:r,y:n}=ct(s,t,this._firefoxDragPosition);if(r===0&&n===0)return;const o=Math.max(1,r),a=Math.max(1,n);if(o===1&&a===1)return;let c=o,l=a;if(f(t)){const v=((e=this._options.settings)==null?void 0:e.fingerSize)||0;c=Math.max(2,o+v),l=Math.max(2,a-v)}const{x:d,y:u,options:g}=this._onBeforeUpdateDrag(c,l,{}),_=g||{settings:{},ghost:{}};_.ghost||(_.ghost={}),_.ghost.visibleIn&&_.ghost.hiddenIn||(_.ghost.hiddenIn=this._mainDomElement.getBoundingClientRect());const y=typeof d=="number"?d:c,b=typeof u=="number"?u:l;if(this._currentDrag.ghost){const{clientX:v,clientY:te}=w(t,this._firefoxDragPosition);this._currentDrag.ghost.updateDragGhost(v,te,_)}this._instance.updateDrag(y,b,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const t=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const e=t.querySelector("."+S);e&&e.classList.add(F.DISPLAY_NONE)}touchStart(t,e,s="rml_id"){var r,n,o,a;e.preventDefault();const c=(d,u)=>{this.dragStart(t,u,s)},l={};typeof((n=(r=this._options)==null?void 0:r.settings)==null?void 0:n.touchDragDelay)=="number"&&(l.delay=this._options.settings.touchDragDelay),(a=(o=this._options)==null?void 0:o.settings)!=null&&a.touchDragEpsilon&&(l.epsilon=this._options.settings.touchDragEpsilon),this._currentTouch=new gt(void 0,{onTouchDragStart:c},l),this._currentTouch.onStart(e)}touchMove(t){this._currentTouch&&this._currentTouch.onMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(t){}}const jt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromWebsiteStrategy:$t},Symbol.toStringTag,{value:"Module"})),zt=i=>`[data-rml-custom-view="${i}"]`,k=i=>{i.preventDefault(),i.stopPropagation()},Vt=(i,t,e,s)=>{const r=e-i,n=s-t;return Math.sqrt(r*r+n*n)};class qt{constructor({onCustomDragStart:t},e={}){h(this,"_startX",0),h(this,"_startY",0),h(this,"_lastX",0),h(this,"_lastY",0),h(this,"_epsilon"),h(this,"_isWaiting",!1),h(this,"_onCustomDragStart"),this._epsilon=typeof e.epsilon=="number"?e.epsilon:dt,this._onCustomDragStart=t}onMove(t){this._lastX=t.clientX,this._lastY=t.clientY,this._isWaiting&&Vt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(t),this._isWaiting=!1)}onStart(t){this._startX=t.clientX,this._startY=t.clientY,this.onMove(t),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const W="data-rml-old-draggable",Jt=void 0,pt=(i,t)=>{const e=f(i),s={delay:e?G:Gt,epsilon:e?Y:dt};if(!t)return s;if(!e&&!(i instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:r,epsilonKey:n}=e?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof t[r]=="number"&&(s.delay=t.touchDragDelay),typeof t[n]=="number"&&(s.epsilon=t.touchDragEpsilon),s},Kt=i=>{let t="",e=U,s=B;if(!i)return{url:x,width:e,height:s};const r=i;if(r instanceof HTMLElement){const n=r.getBoundingClientRect(),o=r.getAttribute("data-rml-ghost-url"),a=r.getAttribute("data-rml-ghost-width"),c=r.getAttribute("data-rml-ghost-height");o?t=o:!o&&r instanceof HTMLImageElement&&r.src&&(t=r.src),t?(e=n.width,s=n.height):t=x,e=a?parseInt(a,10):e,s=c?parseInt(c,10):s}return{url:t||x,width:e,height:s}};class Qt{constructor(t,e,s){h(this,"_options",{}),h(this,"_instance"),h(this,"_viewName"),h(this,"_currentCustomDrag",null),h(this,"_currentBb",null),h(this,"_startTarget",null),h(this,"_onBeforeUpdateDrag",()=>({})),h(this,"isDragging",!1),this._instance=t,this._options=e||{},this._viewName=s}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}async _dragStart(t,e,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(W,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",k),this._startTarget.addEventListener("dragstart",k)),this._currentBb=await this._instance.getBoundingClientRect(zt(this._viewName));const{clientX:r,clientY:n}=w(e),o=this._currentBb.x+r,a=this._currentBb.y+n;this.isDragging=!0,this._instance.dragInObject(t,o,a,s)}_dragUpdate(t){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(t),!this._currentBb||!this.isDragging)return;const{clientX:e,clientY:s}=w(t),{url:r,width:n,height:o}=Kt(this._startTarget),a=this._currentBb.x+e,c=this._currentBb.y+s,l=this._options||{},d={ghost:{visibleIn:{x:this._currentBb.x-(l.dragInOverlapX||0),y:this._currentBb.y+(l.dragInOverlapY||0),width:this._currentBb.width+(l.dragInOverlapX||0),height:this._currentBb.height+(l.dragInOverlapY||0)},url:r,width:n,height:o},mode:"custom-view"},{x:u,y:g,options:_}=this._onBeforeUpdateDrag(a,c,d),y=typeof u=="number"?u:a,b=typeof g=="number"?g:c,v=_||d;this._instance.updateDrag(y,b,v)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(t,e,s){this._instance.disableEvents(),this._startTarget=e.target;const r=(n,o)=>{this._dragStart(t,o,s)};this._currentCustomDrag=f(e)?new gt(Jt,{onTouchDragStart:r},pt(e,this._options)):new qt({onCustomDragStart:n=>this._dragStart(t,n,s)},pt(e,this._options)),this._currentCustomDrag.onStart(e)}dragEnd(){this._dragEnd()}dragUpdate(t){this._dragUpdate(t)}touchStart(t,e,s="rml_id"){this.dragStart(t,e,s)}touchMove(t){this.dragUpdate(t)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(W)==="true",this._startTarget.removeAttribute(W),this._startTarget.removeEventListener("dragstart",k))}releaseInput(t){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}const Zt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromCustomViewStrategy:Qt},Symbol.toStringTag,{value:"Module"}));return Rt});
16
+ ${at}
17
+ `,document.head.appendChild(i)}},kt=({x:i,y:t},e)=>{var s,r,n,a,o,c;let l=document.getElementById(I);if(!l){if(l=document.createElement("div"),(s=e.ghost)!=null&&s.element)l.appendChild(e.ghost.element);else{const d=document.createElement("img");d.src=((r=e.ghost)==null?void 0:r.url)||x,d.width=((n=e.ghost)==null?void 0:n.width)||B,d.height=((a=e.ghost)==null?void 0:a.height)||U,l.appendChild(d)}l.id=I,l.style.position="fixed",l.style.top="0",l.style.left="0",l.style.willChange="transform",l.style.transform="translate3d(0, 0, 0)",l.style.zIndex="9999",l.style.opacity="0.5",pt(i,t,e.ghost||{},(o=e.settings)==null?void 0:o.dragInOverlapX,(c=e.settings)==null?void 0:c.dragInOverlapY)||(l.style.display="none"),l.style.pointerEvents="none",document.body.appendChild(l)}},Xt=({x:i,y:t},e)=>{var s,r,n,a;const o=document.getElementById(I);if(!o)return;let c=(s=e.ghost)==null?void 0:s.width,l=(r=e.ghost)==null?void 0:r.height;typeof c>"u"&&(c=o.getBoundingClientRect().width||B),typeof l>"u"&&(l=o.getBoundingClientRect().height||U);const d=i-c/2,u=t-l/2;o.style.transform=`translate3d(${d}px, ${u}px, 0)`,e.ghost&&(pt(i,t,e.ghost,(n=e.settings)==null?void 0:n.dragInOverlapX,(a=e.settings)==null?void 0:a.dragInOverlapY)?o.style.animation!=lt&&(o.style.animation=lt):o.style.animation!=ht&&(o.style.animation=ht))};class Wt{constructor(t=null){h(this,"_dragGhostAnimationFrameId",null),h(this,"_dragGhostRemoveAnimationFrameId",null),h(this,"_dragGhostElement",null),this._dragGhostElement=t}updateDragGhost(t,e,s){var r;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((r=s.ghost)!=null&&r.external)&&s.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{Yt();const n={x:t,y:e};!s.ghost&&this._dragGhostElement&&(s.ghost={}),s.ghost&&!s.ghost.element&&this._dragGhostElement&&(s.ghost.element=this._dragGhostElement),kt(n,s),Xt(n,s),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const t=document.getElementById(I);t&&document.body.removeChild(t),this._dragGhostRemoveAnimationFrameId=null}))}}class $t{constructor(t,e,s){h(this,"_options",{}),h(this,"_instance"),h(this,"_mainDomElement"),h(this,"_currentDrag",{}),h(this,"_currentTouch",null),h(this,"_firefoxDragPosition",{x:0,y:0}),h(this,"_onBeforeUpdateDrag",()=>({})),h(this,"isDragging",!1),h(this,"_firefoxFallback",r=>{if(!this._currentDrag.event)return;const n=r||window.event;this._firefoxDragPosition.x=n.pageX||0,this._firefoxDragPosition.y=n.pageY||0}),this._instance=t,this._mainDomElement=e,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}dragStart(t,e,s="rml_id"){const r=this._mainDomElement.parentNode;if(M(r).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let n=r.querySelector("."+S);n||(n=document.createElement("div"),n.classList.add(S),r.appendChild(n)),n.classList.remove(F.DISPLAY_NONE),e.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const a=r.querySelector("."+O);this._currentDrag.event=e;const o=e.target,c=o.cloneNode(),l=o.getBoundingClientRect();c.style.width=`${l.width}px`,c.style.height=`${l.height}px`,this._currentDrag.ghost=new Wt(c),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:d,clientY:u}=b(e,this._firefoxDragPosition);this._currentDrag.offset.x=d-l.left,this._currentDrag.offset.y=u-l.top,e instanceof DragEvent&&e.dataTransfer&&e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(a,0,0);const{x:g,y:_}=dt(r,this._currentDrag.event||e,this._firefoxDragPosition),y=Math.max(1,g),w=Math.max(1,_);this.isDragging=!0,this._instance.dragInObject(t,y,w,s)}dragUpdate(t){var e;const s=this._mainDomElement.parentNode,{x:r,y:n}=dt(s,t,this._firefoxDragPosition);if(r===0&&n===0)return;const a=Math.max(1,r),o=Math.max(1,n);if(a===1&&o===1)return;let c=a,l=o;if(f(t)){const v=((e=this._options.settings)==null?void 0:e.fingerSize)||0;c=Math.max(2,a+v),l=Math.max(2,o-v)}const{x:d,y:u,options:g}=this._onBeforeUpdateDrag(c,l,{}),_=g||{settings:{},ghost:{}};_.ghost||(_.ghost={}),_.ghost.visibleIn&&_.ghost.hiddenIn||(_.ghost.hiddenIn=this._mainDomElement.getBoundingClientRect());const y=typeof d=="number"?d:c,w=typeof u=="number"?u:l;if(this._currentDrag.ghost){const{clientX:v,clientY:te}=b(t,this._firefoxDragPosition);this._currentDrag.ghost.updateDragGhost(v,te,_)}this._instance.updateDrag(y,w,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const t=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const e=t.querySelector("."+S);e&&e.classList.add(F.DISPLAY_NONE)}touchStart(t,e,s="rml_id"){var r,n,a,o;e.preventDefault();const c=(d,u)=>{this.dragStart(t,u,s)},l={};typeof((n=(r=this._options)==null?void 0:r.settings)==null?void 0:n.touchDragDelay)=="number"&&(l.delay=this._options.settings.touchDragDelay),(o=(a=this._options)==null?void 0:a.settings)!=null&&o.touchDragEpsilon&&(l.epsilon=this._options.settings.touchDragEpsilon),this._currentTouch=new mt(void 0,{onTouchDragStart:c},l),this._currentTouch.onStart(e)}touchMove(t){this._currentTouch&&this._currentTouch.onMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(t){}}const jt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromWebsiteStrategy:$t},Symbol.toStringTag,{value:"Module"})),zt=i=>`[data-rml-custom-view="${i}"]`,X=i=>{i.preventDefault(),i.stopPropagation()},Vt=(i,t,e,s)=>{const r=e-i,n=s-t;return Math.sqrt(r*r+n*n)};class qt{constructor({onCustomDragStart:t},e={}){h(this,"_startX",0),h(this,"_startY",0),h(this,"_lastX",0),h(this,"_lastY",0),h(this,"_epsilon"),h(this,"_isWaiting",!1),h(this,"_onCustomDragStart"),this._epsilon=typeof e.epsilon=="number"?e.epsilon:ut,this._onCustomDragStart=t}onMove(t){this._lastX=t.clientX,this._lastY=t.clientY,this._isWaiting&&Vt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(t),this._isWaiting=!1)}onStart(t){this._startX=t.clientX,this._startY=t.clientY,this.onMove(t),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const W="data-rml-old-draggable",Jt=void 0,ft=(i,t)=>{const e=f(i),s={delay:e?G:Gt,epsilon:e?Y:ut};if(!t)return s;if(!e&&!(i instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:r,epsilonKey:n}=e?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof t[r]=="number"&&(s.delay=t.touchDragDelay),typeof t[n]=="number"&&(s.epsilon=t.touchDragEpsilon),s},Kt=i=>{let t="",e=B,s=U;if(!i)return{url:x,width:e,height:s};const r=i;if(r instanceof HTMLElement){const n=r.getBoundingClientRect(),a=r.getAttribute("data-rml-ghost-url"),o=r.getAttribute("data-rml-ghost-width"),c=r.getAttribute("data-rml-ghost-height");a?t=a:!a&&r instanceof HTMLImageElement&&r.src&&(t=r.src),t?(e=n.width,s=n.height):t=x,e=o?parseInt(o,10):e,s=c?parseInt(c,10):s}return{url:t||x,width:e,height:s}};class Qt{constructor(t,e,s){h(this,"_options",{}),h(this,"_instance"),h(this,"_viewName"),h(this,"_currentCustomDrag",null),h(this,"_currentBb",null),h(this,"_startTarget",null),h(this,"_onBeforeUpdateDrag",()=>({})),h(this,"isDragging",!1),this._instance=t,this._options=e||{},this._viewName=s}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}async _dragStart(t,e,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(W,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",X),this._startTarget.addEventListener("dragstart",X)),this._currentBb=await this._instance.getBoundingClientRect(zt(this._viewName));const{clientX:r,clientY:n}=b(e),a=this._currentBb.x+r,o=this._currentBb.y+n;this.isDragging=!0,this._instance.dragInObject(t,a,o,s)}_dragUpdate(t){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(t),!this._currentBb||!this.isDragging)return;const{clientX:e,clientY:s}=b(t),{url:r,width:n,height:a}=Kt(this._startTarget),o=this._currentBb.x+e,c=this._currentBb.y+s,l=this._options||{},d={ghost:{visibleIn:{x:this._currentBb.x-(l.dragInOverlapX||0),y:this._currentBb.y+(l.dragInOverlapY||0),width:this._currentBb.width+(l.dragInOverlapX||0),height:this._currentBb.height+(l.dragInOverlapY||0)},url:r,width:n,height:a},mode:"custom-view"},{x:u,y:g,options:_}=this._onBeforeUpdateDrag(o,c,d),y=typeof u=="number"?u:o,w=typeof g=="number"?g:c,v=_||d;this._instance.updateDrag(y,w,v)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(t,e,s){this._instance.disableEvents(),this._startTarget=e.target;const r=(n,a)=>{this._dragStart(t,a,s)};this._currentCustomDrag=f(e)?new mt(Jt,{onTouchDragStart:r},ft(e,this._options)):new qt({onCustomDragStart:n=>this._dragStart(t,n,s)},ft(e,this._options)),this._currentCustomDrag.onStart(e)}dragEnd(){this._dragEnd()}dragUpdate(t){this._dragUpdate(t)}touchStart(t,e,s="rml_id"){this.dragStart(t,e,s)}touchMove(t){this.dragUpdate(t)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(W)==="true",this._startTarget.removeAttribute(W),this._startTarget.removeEventListener("dragstart",X))}releaseInput(t){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}const Zt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromCustomViewStrategy:Qt},Symbol.toStringTag,{value:"Module"}));return Rt});