@roomle/embedding-lib 6.5.0-alpha.2 → 6.5.0-alpha.3

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.
@@ -0,0 +1,134 @@
1
+ import { g as C, e as E, a as b, i as v } from "./utils-Dav4kGNW.mjs";
2
+ import { R as u, a as x, b as B } from "./embedding-plugins-DqMSzAJe.mjs";
3
+ import { E as L } from "./drag-ghost-DHrf_Evu.mjs";
4
+ class Y {
5
+ _options = {};
6
+ _instance;
7
+ _mainDomElement;
8
+ _currentDrag = {};
9
+ _firefoxDragPosition = { x: 0, y: 0 };
10
+ _onBeforeUpdateDrag = () => ({});
11
+ isDragging = !1;
12
+ _hasEnteredIframe = !1;
13
+ _pendingDragIn = null;
14
+ _canvasBb = null;
15
+ _overlayBb = null;
16
+ _interactionContainerBb = null;
17
+ _currentTouch = null;
18
+ _firefoxFallback = (e) => {
19
+ if (!this._currentDrag.event)
20
+ return;
21
+ e.preventDefault();
22
+ const t = e || window.event;
23
+ this._firefoxDragPosition.x = t.pageX || 0, this._firefoxDragPosition.y = t.pageY || 0;
24
+ };
25
+ constructor(e, t, s) {
26
+ this._instance = e, this._mainDomElement = t, this._options = s || {}, this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback), this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
27
+ this._instance.cancelDragIn();
28
+ });
29
+ }
30
+ beforeUpdateGhost(e) {
31
+ this._onBeforeUpdateDrag = e;
32
+ }
33
+ async dragStart(e, t, s = "rml_id") {
34
+ const o = this._mainDomElement.parentNode;
35
+ if (C(o).position !== "relative") {
36
+ console.warn(
37
+ "Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly"
38
+ );
39
+ return;
40
+ }
41
+ this._mainDomElement.style.pointerEvents = "none";
42
+ let i = o.querySelector(
43
+ "." + u
44
+ );
45
+ i || (i = document.createElement("div"), i.classList.add(u), o.appendChild(i)), i.classList.remove(x.DISPLAY_NONE), t.target.getAttribute("draggable") || console.warn(
46
+ `Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`
47
+ );
48
+ const a = o.querySelector(
49
+ "." + B
50
+ );
51
+ this._currentDrag.event = t;
52
+ const r = t.target, h = r.cloneNode(!0), g = r.getBoundingClientRect();
53
+ h.style.width = `${g.width}px`, h.style.height = `${g.height}px`, this._currentDrag.ghost = new L(h), this._currentDrag.offset || (this._currentDrag.offset = { x: 0, y: 0 });
54
+ const { clientX: _, clientY: d } = E(
55
+ t,
56
+ this._firefoxDragPosition
57
+ );
58
+ this._currentDrag.offset.x = _ - g.left, this._currentDrag.offset.y = d - g.top, t instanceof DragEvent && t.dataTransfer && t.dataTransfer.setDragImage && t.dataTransfer.setDragImage(a, 0, 0), b(o, this._currentDrag.event || t, this._firefoxDragPosition), this._pendingDragIn = { id: e, type: s }, this._hasEnteredIframe = !1, this.isDragging = !0, this._interactionContainerBb = (await this._instance.getDrawerBoundingClientRect()).final;
59
+ }
60
+ dragUpdate(e) {
61
+ const t = this._mainDomElement.parentNode, { x: s, y: o } = b(t, e, this._firefoxDragPosition);
62
+ if (s === 0 && o === 0)
63
+ return;
64
+ const f = Math.max(1, s), i = Math.max(1, o);
65
+ if (f === 1 && i === 1)
66
+ return;
67
+ const n = this._mainDomElement.getBoundingClientRect(), { clientX: a, clientY: r } = E(
68
+ e,
69
+ this._firefoxDragPosition
70
+ ), h = a >= n.left && a <= n.right && r >= n.top && r <= n.bottom, g = () => {
71
+ if (!(a >= n.left && a <= n.right && r >= n.top && r <= n.bottom))
72
+ return !1;
73
+ if (this._interactionContainerBb) {
74
+ const m = {
75
+ left: this._interactionContainerBb.left + n.left,
76
+ top: this._interactionContainerBb.top + n.top,
77
+ right: this._interactionContainerBb.right + n.left,
78
+ bottom: this._interactionContainerBb.bottom + n.top
79
+ };
80
+ return !(a >= m.left && a <= m.right && r >= m.top && r <= m.bottom);
81
+ }
82
+ return !0;
83
+ };
84
+ if (h && this._pendingDragIn) {
85
+ const l = g();
86
+ l && !this._hasEnteredIframe ? (this._instance.dragInObject(
87
+ this._pendingDragIn.id,
88
+ f,
89
+ i,
90
+ this._pendingDragIn.type
91
+ ), this._hasEnteredIframe = !0) : !l && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
92
+ } else !h && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
93
+ let _ = f, d = i;
94
+ if (v(e)) {
95
+ const l = this._options.settings?.fingerSize || 0;
96
+ _ = Math.max(2, f + l), d = Math.max(2, i - l);
97
+ }
98
+ const {
99
+ x: D,
100
+ y: p,
101
+ options: I
102
+ } = this._onBeforeUpdateDrag(_, d, {}), c = I || { settings: {}, ghost: {} };
103
+ if (c.ghost || (c.ghost = {}), c.ghost.visibleIn && c.ghost.hiddenIn || (c.ghost.hiddenIn = n), this._currentDrag.ghost && this._currentDrag.ghost.updateDragGhost(a, r, c), !this._hasEnteredIframe)
104
+ return;
105
+ const y = typeof D == "number" ? D : _, S = typeof p == "number" ? p : d;
106
+ this._instance.updateDrag(y, S, {});
107
+ }
108
+ dragEnd() {
109
+ this._mainDomElement.style.pointerEvents = "all";
110
+ const e = this._mainDomElement.parentNode;
111
+ this.isDragging = !1, this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = { x: 0, y: 0 }, this._hasEnteredIframe = !1, this._pendingDragIn = null, this._interactionContainerBb = null;
112
+ const t = e.querySelector(
113
+ "." + u
114
+ );
115
+ t && t.classList.add(x.DISPLAY_NONE);
116
+ }
117
+ touchStart(e, t, s = "rml_id") {
118
+ t.preventDefault(), this.dragStart(e, t, s);
119
+ }
120
+ touchMove(e) {
121
+ this._currentTouch && this._currentTouch.onMove(e), this._currentDrag.event && this.dragUpdate(e);
122
+ }
123
+ touchEnd() {
124
+ this.dragEnd();
125
+ }
126
+ dispose() {
127
+ document.removeEventListener("dragover", this._firefoxFallback);
128
+ }
129
+ releaseInput(e) {
130
+ }
131
+ }
132
+ export {
133
+ Y as DragInFromWebsiteStrategy
134
+ };
@@ -0,0 +1 @@
1
+ import{g as t,e,a as n,i}from"./utils-BqTPLNLs.mjs";import{R as r,a,b as s}from"./embedding-plugins-DLVs7ER4.mjs";import{E as o}from"./drag-ghost-B7UAYefM.mjs";class h{_options={};_instance;_mainDomElement;_currentDrag={};_firefoxDragPosition={x:0,y:0};_onBeforeUpdateDrag=()=>({});isDragging=!1;_hasEnteredIframe=!1;_pendingDragIn=null;_canvasBb=null;_overlayBb=null;_interactionContainerBb=null;_currentTouch=null;_firefoxFallback=t=>{if(!this._currentDrag.event)return;t.preventDefault();const e=t||window.event;this._firefoxDragPosition.x=e.pageX||0,this._firefoxDragPosition.y=e.pageY||0};constructor(t,e,n){this._instance=t,this._mainDomElement=e,this._options=n||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback),this._mainDomElement.parentElement?.addEventListener("dragleave",()=>{this._instance.cancelDragIn()})}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}async dragStart(i,h,g="rml_id"){const c=this._mainDomElement.parentNode;if("relative"!==t(c).position)return;this._mainDomElement.style.pointerEvents="none";let _=c.querySelector("."+r);_||(_=document.createElement("div"),_.classList.add(r),c.appendChild(_)),_.classList.remove(a.DISPLAY_NONE),h.target.getAttribute("draggable");const l=c.querySelector("."+s);this._currentDrag.event=h;const d=h.target,f=d.cloneNode(!0),m=d.getBoundingClientRect();f.style.width=`${m.width}px`,f.style.height=`${m.height}px`,this._currentDrag.ghost=new o(f),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:u,clientY:D}=e(h,this._firefoxDragPosition);this._currentDrag.offset.x=u-m.left,this._currentDrag.offset.y=D-m.top,h instanceof DragEvent&&h.dataTransfer&&h.dataTransfer.setDragImage&&h.dataTransfer.setDragImage(l,0,0),n(c,this._currentDrag.event||h,this._firefoxDragPosition),this._pendingDragIn={id:i,type:g},this._hasEnteredIframe=!1,this.isDragging=!0,this._interactionContainerBb=(await this._instance.getDrawerBoundingClientRect()).final}dragUpdate(t){const r=this._mainDomElement.parentNode,{x:a,y:s}=n(r,t,this._firefoxDragPosition);if(0===a&&0===s)return;const o=Math.max(1,a),h=Math.max(1,s);if(1===o&&1===h)return;const g=this._mainDomElement.getBoundingClientRect(),{clientX:c,clientY:_}=e(t,this._firefoxDragPosition),l=c>=g.left&&c<=g.right&&_>=g.top&&_<=g.bottom,d=()=>{if(!(c>=g.left&&c<=g.right&&_>=g.top&&_<=g.bottom))return!1;if(this._interactionContainerBb){const t={left:this._interactionContainerBb.left+g.left,top:this._interactionContainerBb.top+g.top,right:this._interactionContainerBb.right+g.left,bottom:this._interactionContainerBb.bottom+g.top};return!(c>=t.left&&c<=t.right&&_>=t.top&&_<=t.bottom)}return!0};if(l&&this._pendingDragIn){const t=d();t&&!this._hasEnteredIframe?(this._instance.dragInObject(this._pendingDragIn.id,o,h,this._pendingDragIn.type),this._hasEnteredIframe=!0):!t&&this._hasEnteredIframe&&(this._instance.cancelDragIn(),this._hasEnteredIframe=!1)}else!l&&this._hasEnteredIframe&&(this._instance.cancelDragIn(),this._hasEnteredIframe=!1);let f=o,m=h;if(i(t)){const t=this._options.settings?.fingerSize||0;f=Math.max(2,o+t),m=Math.max(2,h-t)}const{x:u,y:D,options:p}=this._onBeforeUpdateDrag(f,m,{}),E=p||{settings:{},ghost:{}};if(E.ghost||(E.ghost={}),E.ghost.visibleIn&&E.ghost.hiddenIn||(E.ghost.hiddenIn=g),this._currentDrag.ghost&&this._currentDrag.ghost.updateDragGhost(c,_,E),!this._hasEnteredIframe)return;const b="number"==typeof u?u:f,I="number"==typeof D?D:m;this._instance.updateDrag(b,I,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const t=this._mainDomElement.parentNode;this.isDragging=!1,this._hasEnteredIframe&&this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0},this._hasEnteredIframe=!1,this._pendingDragIn=null,this._interactionContainerBb=null;const e=t.querySelector("."+r);e&&e.classList.add(a.DISPLAY_NONE)}touchStart(t,e,n="rml_id"){e.preventDefault(),this.dragStart(t,e,n)}touchMove(t){this._currentTouch&&this._currentTouch.onMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(t){}}export{h as DragInFromWebsiteStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomle/embedding-lib",
3
- "version": "6.5.0-alpha.2",
3
+ "version": "6.5.0-alpha.3",
4
4
  "description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
5
5
  "type": "module",
6
6
  "main": "./roomle-embedding-lib.js",
@@ -1,5 +1,5 @@
1
1
  import { DragInOptions } from './plugins/types';
2
- export { RML_DRAG_IN_STYLES_ID, RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, RML_DRAG_IN_DRAG_ELEMENT_ID, RML_DRAG_IN_FALLBACK_GHOST_URL, RML_DRAG_IN_FALLBACK_GHOST_WIDTH, RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, RML_DRAG_GHOST_FADE_IN, RML_DRAG_GHOST_FADE_OUT, } from './plugins/constants';
2
+ export { TARGET_OPACITY, RML_DRAG_IN_STYLES_ID, RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, RML_DRAG_IN_DRAG_ELEMENT_ID, RML_DRAG_IN_FALLBACK_GHOST_URL, RML_DRAG_IN_FALLBACK_GHOST_WIDTH, RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, RML_DRAG_GHOST_FADE_IN, RML_DRAG_GHOST_FADE_OUT, } from './plugins/constants';
3
3
  export type { DragGhostOptions, DragInOptions } from './plugins/types';
4
4
  export type OnBeforeUpdateDragGhost = (x: number, y: number, options: DragInOptions) => {
5
5
  x?: number;
@@ -12,12 +12,14 @@ export declare class DragInFromCustomViewStrategy implements DragInStrategy {
12
12
  private _currentCustomDrag;
13
13
  private _currentBb;
14
14
  private _startTarget;
15
+ private _dragGhost;
15
16
  private _onBeforeUpdateDrag;
16
17
  isDragging: boolean;
17
18
  private _hasEnteredIframe;
18
19
  private _pendingDragIn;
19
20
  private _canvasBb;
20
21
  private _overlayBb;
22
+ private _dragGeneration;
21
23
  private _interactionContainerBb;
22
24
  constructor(instance: ExposedApi, mainDomElement: HTMLIFrameElement, options: DragInSettings, viewName: PossibleCustomViewsAndMain);
23
25
  beforeUpdateGhost(handler: OnBeforeUpdateDragGhost): void;
@@ -8,7 +8,6 @@ export declare class DragInFromWebsiteStrategy implements DragInStrategy {
8
8
  private _instance;
9
9
  private _mainDomElement;
10
10
  private _currentDrag;
11
- private _currentTouch;
12
11
  private _firefoxDragPosition;
13
12
  private _onBeforeUpdateDrag;
14
13
  isDragging: boolean;
@@ -17,6 +16,7 @@ export declare class DragInFromWebsiteStrategy implements DragInStrategy {
17
16
  private _canvasBb;
18
17
  private _overlayBb;
19
18
  private _interactionContainerBb;
19
+ private _currentTouch;
20
20
  private _firefoxFallback;
21
21
  constructor(instance: ExposedApi, mainDomElement: HTMLIFrameElement, options: DragInOptions);
22
22
  beforeUpdateGhost(handler: OnBeforeUpdateDragGhost): void;
@@ -255,7 +255,7 @@ class T {
255
255
  typeof o == "string" && o === "dragIn" ? this.pluginsLoaded.push(
256
256
  new Promise((i, a) => {
257
257
  try {
258
- import("./embedding-plugins-Cm7O1pKC.mjs").then((n) => n.l).then(({ DragIn: n }) => {
258
+ import("./embedding-plugins-DqMSzAJe.mjs").then((n) => n.l).then(({ DragIn: n }) => {
259
259
  const l = new n(this.ui, t, r, this.viewName);
260
260
  l.init().then(() => {
261
261
  this.plugins.dragIn = l, i();
@@ -1 +1 @@
1
- import{expose as e}from"./comlink-CmT64Qi3.mjs";import{g as t}from"./browser-BhHw2H1M.mjs";import{c as s}from"./utils-BqTPLNLs.mjs";class r{_side;_incomingMessageBus=null;_outgoingMessageBus=null;_execMessage=null;constructor(e,t,s,r){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=e=>{if(!e||!e.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let t;try{t=JSON.parse(e.data)}catch(e){return i.port1.close(),i.port2.close(),this._prepareError(e),r(e)}t.error?r(t.error):void 0!==t.result?s(t.result):s(void 0),i.port1.close(),i.port2.close()};let a="";try{a=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(a,"*",[i.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&("string"==typeof e.data||"connect_hi"!==e.data.type)&&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(void 0===r)return;r.then((e={})=>{let s,r;"object"==typeof e&&null!==e&&(s=e.error,r=e.result),s?t.postMessage(JSON.stringify({error:s})):void 0!==r?t.postMessage(JSON.stringify({result:r})):t.postMessage(JSON.stringify({result:e}))},e=>{t.postMessage(JSON.stringify({error:this._prepareError(e)}))})}catch(e){t.postMessage(JSON.stringify({error:this._prepareError(e)}))}}_prepareError(e){return"string"==typeof e?this._side+": "+e:(e.message=this._side+": "+e.message,e.message)}}const i=["127.0.0.1","localhost","0.0.0.0"],a=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=a(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var n=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(n||{});const o={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[n.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!0,enableTwoLevelCatalog:!1,webGpu:!1,localExport3d:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},l=e=>{if(!e)return;const t=Object.keys(e);for(const s of t){const t=e[s];if(!Array.isArray(t)&&"object"==typeof t&&null!==t&&l(t),Array.isArray(t))for(const e of t)l(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},c=()=>/(android)/i.test(navigator.userAgent);class u{_messageHandler=null;isSetupDone=!1;viewName="main";plugins={};pluginsLoaded=[];ui={callbacks:null};extended={callbacks:null};configurator={callbacks:null};analytics={callbacks:{}};rapi={callbacks:{}};global={callbacks:{}};setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(e=>{const t=e.split(h),s=t[0],r=t[1];this[s]||(this[s]={}),this[s][r]=function(){if(this._messageHandler)return this._messageHandler.sendMessage(e,[...arguments])}.bind(this)}),s.forEach(e=>{const t=e.split(h),s=t[0],r=t[1],i=t[2];this[s]||(this[s]={}),this[s][r]||(this[s][r]={}),this[s][r][i]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(h),r=s[0],i=s[1],a=3===s.length?s[2]:null;if(a&&this[r][i][a]){const e=this[r][i][a](...t);return e instanceof Promise?e.then(e=>({result:e})):void 0!==e?Promise.resolve({result:e}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)"string"==typeof r&&"dragIn"===r?this.pluginsLoaded.push(new Promise((e,r)=>{try{import("./embedding-plugins-Dzhuj1By.mjs").then(e=>e.l).then(({DragIn:i})=>{const a=new i(this.ui,t,s,this.viewName);a.init().then(()=>{this.plugins.dragIn=a,e()},r)})}catch(e){r(e)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((e,i)=>{try{r.loader().then(a=>{const n=new a(this.ui,t,s,this.viewName);n.init().then(()=>{this.plugins[r.name]=n,e()},i)})}catch(e){i(e)}}))}}const d=()=>{let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}},g={SDK:"extended",CONFIGURATOR_SDK:"configurator",CALLBACKS:"callbacks",UI:"ui",ANALYTICS:"analytics",GLOBAL:"global",RAPI:"rapi"},h=".",m=g.SDK+h+g.CALLBACKS,p={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},f=["constructor","callbacks"],w=e=>"_"!==e[0]&&!f.includes(e),E=(e,t,s=!1)=>{if(!e)return[];const r=Object.getOwnPropertyNames(e),i=s?g.CALLBACKS+h:"";return r.filter(w).map(e=>t+h+i+e)},S=async(e,t)=>{if("string"!=typeof e)throw new Error('Configurator ID is not a string type: "'+typeof e+'"');const s=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",r=t.overrideTenant||9,i=s+"/configurators/"+e,a="roomle_portal_v2",n="03-"+window.btoa((new Date).toISOString()+";anonymous;"+a),o=new Request(i,{method:"GET",headers:new Headers({apiKey:a,currentTenant:r,locale:"en",language:"en",device:1,token:n,platform:"web"}),mode:"cors",cache:"default"}),l=await fetch(o),{configurator:c}=await l.json();return c},M="data-rml-interaction-container",b=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=e?.mute?e.value:e}})},y=()=>.01*window.innerHeight+"px",T=e=>{e&&setTimeout(()=>e.style.setProperty(v,y()),0)},O="rml-styles",v="--rml-full-height",A="rml-container",N="rml-fill",R="rml-pos",I="rml-android-height",L="rml-overflow-hidden",C=new Map;class P extends u{static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(e,t=[]){const s=new u;s.viewName=e;const{resolve:i,promise:a}=d(),{resolve:n,promise:o}=d(),l=new r("custom-view-"+e,window,window.parent,({message:e,args:t})=>{switch(e){case _.REGISTER_CUSTOM_VIEW_DONE:i();break;case _.RETURN_METHODS:s.handleSetup(t[0]),n();break;default:if(s.isSetupDone)return s.executeMessage({message:e,args:t})}});s.setMessageHandler(l);const c=[e];return l.sendMessage(_.REGISTER_CUSTOM_VIEW,c),await a,l.sendMessage(_.GET_METHODS,c),await o,s.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(e,t,s,r=[]){return this._create(e,t,s,r)}static create(e,t,s,r){return this._create(e,t,s,r)}static createViewer(e,t,s,r=[]){return this._create(e,t,s,r)}static hiMessageHandler=null;static setupHi(t){this.hiMessageHandler&&window.removeEventListener("message",this.hiMessageHandler),this.hiMessageHandler=r=>{if("connect_hi"===r.data.type&&r.data.port){const i=r.data.port;i.start?.(),e(s(t),i)}},window.addEventListener("message",this.hiMessageHandler)}static async _create(e,s,r,n){return new Promise(async(c,u)=>{try{const u=a((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(o);e.locale||(e.locale=t(null,!0)),"(idle)"===e.id&&delete e.id;const s=(()=>{const e=(()=>{try{return window.self!==window.top}catch{return!0}})();let t=window.location.href;if(e){if(!document.referrer)return null;t=document.referrer}const{hostname:s}=new URL(t);return s})();return s&&(e=>{const t=new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);return!!(i.includes(e)||t.test(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com"))})(s)&&(e.configuratorId="demoConfigurator"),e.customApiUrl="https://rubens.alpha.roomle.com/api/v2",e.emails=!1,e})(),(l(d=r),d?.customApiUrl&&(d.customApiUrl=decodeURIComponent(d.customApiUrl)),d.shareUrl&&(d.deeplink=d.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),d));(e=>{e.featureFlags||(e.featureFlags={}),"boolean"!=typeof e.featureFlags.realPartList&&(e.featureFlags.realPartList=!0),"boolean"!=typeof e.featureFlags.globalCallbacks&&(e.featureFlags.globalCallbacks=!0),"boolean"!=typeof e.featureFlags.mocAr&&(e.featureFlags.mocAr=!1)})(u);const g=await S(e,u);r=((e,t)=>{t.configuratorId=e.id;const s=e.settings||{};return!t.overrideTenant&&e.tenant&&(t.overrideTenant=e.tenant),((e,t)=>{const s=JSON.parse(JSON.stringify(e));return a(s,t)})(s,t)})(g,u);const h=new this(g,s,r,n,c);return await Promise.allSettled(h.pluginsLoaded),h}catch(e){return u(e)}var d})}_waitForIframe;_container;_configuratorSettings;_initData={};_iframe;constructor(e,t,s,i,a){if(super(),!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(C.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(O)){const e=s.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=O;const r="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((e,t)=>e+(t+r),"")+r,a=y();t.innerHTML=`\n .${A}{${v}:${a};}\n .${R}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${i}}\n .${N}{width:100%;height:100%;opacity:1}\n .${I}{height:calc(var(${v},1vh)*100)}\n .${L}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const n=new r("website",window,null,this._executeMessage);this.setMessageHandler(n),this._onResize=this._onResize.bind(this),c()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=a,this._container.appendChild(o),this._iframe=o,this.setupPlugins(i,this._iframe),C.set(t,!0)}teardown(){this._container&&C.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){const e=document.createElement("iframe");let t=this._configuratorSettings?.url||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(t=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(t=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(t=this._initData.overrideServerUrl),e.src=t,e.classList.add(A),e.classList.add(N),e}_onResize(){T(this._iframe)}_onUseFullPage(){this._iframe.classList.add(R),document.documentElement.classList.add(L),window.document.body.classList.add(L),c()&&(T(this._iframe),this._iframe.classList.add(I))}_onBackToWebsite(){this._iframe.classList.remove(R),this._iframe.classList.remove(I),document.documentElement.classList.remove(L),window.document.body.classList.remove(L)}_executeMessage({message:e,args:t},s){if(s.source&&s.source===this._iframe?.contentWindow)return e===p.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):Promise.resolve({error:"MessageHandler not set"}):e===p.SETUP?(this.handleSetup(t[0]),b(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),b(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{this._messageHandler&&this._messageHandler.sendMessage(p.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{p as HANDSHAKE_MESSAGES,M as INTERACTION_CONTAINER_SELECTOR,g as NAMESPACE,h as NAMESPACE_SEPARATOR,m as SDK_CALLBACK,_ as WELL_KNOWN_MESSAGES,P as default,S as getConfiguratorSettings,E as getMethodNames,w as isExposable};
1
+ import{expose as e}from"./comlink-CmT64Qi3.mjs";import{g as t}from"./browser-BhHw2H1M.mjs";import{c as s}from"./utils-BqTPLNLs.mjs";class r{_side;_incomingMessageBus=null;_outgoingMessageBus=null;_execMessage=null;constructor(e,t,s,r){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=e=>{if(!e||!e.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let t;try{t=JSON.parse(e.data)}catch(e){return i.port1.close(),i.port2.close(),this._prepareError(e),r(e)}t.error?r(t.error):void 0!==t.result?s(t.result):s(void 0),i.port1.close(),i.port2.close()};let a="";try{a=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(a,"*",[i.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&("string"==typeof e.data||"connect_hi"!==e.data.type)&&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(void 0===r)return;r.then((e={})=>{let s,r;"object"==typeof e&&null!==e&&(s=e.error,r=e.result),s?t.postMessage(JSON.stringify({error:s})):void 0!==r?t.postMessage(JSON.stringify({result:r})):t.postMessage(JSON.stringify({result:e}))},e=>{t.postMessage(JSON.stringify({error:this._prepareError(e)}))})}catch(e){t.postMessage(JSON.stringify({error:this._prepareError(e)}))}}_prepareError(e){return"string"==typeof e?this._side+": "+e:(e.message=this._side+": "+e.message,e.message)}}const i=["127.0.0.1","localhost","0.0.0.0"],a=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=a(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var n=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(n||{});const o={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[n.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!0,enableTwoLevelCatalog:!1,webGpu:!1,localExport3d:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},l=e=>{if(!e)return;const t=Object.keys(e);for(const s of t){const t=e[s];if(!Array.isArray(t)&&"object"==typeof t&&null!==t&&l(t),Array.isArray(t))for(const e of t)l(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},c=()=>/(android)/i.test(navigator.userAgent);class u{_messageHandler=null;isSetupDone=!1;viewName="main";plugins={};pluginsLoaded=[];ui={callbacks:null};extended={callbacks:null};configurator={callbacks:null};analytics={callbacks:{}};rapi={callbacks:{}};global={callbacks:{}};setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(e=>{const t=e.split(h),s=t[0],r=t[1];this[s]||(this[s]={}),this[s][r]=function(){if(this._messageHandler)return this._messageHandler.sendMessage(e,[...arguments])}.bind(this)}),s.forEach(e=>{const t=e.split(h),s=t[0],r=t[1],i=t[2];this[s]||(this[s]={}),this[s][r]||(this[s][r]={}),this[s][r][i]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(h),r=s[0],i=s[1],a=3===s.length?s[2]:null;if(a&&this[r][i][a]){const e=this[r][i][a](...t);return e instanceof Promise?e.then(e=>({result:e})):void 0!==e?Promise.resolve({result:e}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)"string"==typeof r&&"dragIn"===r?this.pluginsLoaded.push(new Promise((e,r)=>{try{import("./embedding-plugins-DLVs7ER4.mjs").then(e=>e.l).then(({DragIn:i})=>{const a=new i(this.ui,t,s,this.viewName);a.init().then(()=>{this.plugins.dragIn=a,e()},r)})}catch(e){r(e)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((e,i)=>{try{r.loader().then(a=>{const n=new a(this.ui,t,s,this.viewName);n.init().then(()=>{this.plugins[r.name]=n,e()},i)})}catch(e){i(e)}}))}}const d=()=>{let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}},g={SDK:"extended",CONFIGURATOR_SDK:"configurator",CALLBACKS:"callbacks",UI:"ui",ANALYTICS:"analytics",GLOBAL:"global",RAPI:"rapi"},h=".",m=g.SDK+h+g.CALLBACKS,p={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},f=["constructor","callbacks"],w=e=>"_"!==e[0]&&!f.includes(e),E=(e,t,s=!1)=>{if(!e)return[];const r=Object.getOwnPropertyNames(e),i=s?g.CALLBACKS+h:"";return r.filter(w).map(e=>t+h+i+e)},S=async(e,t)=>{if("string"!=typeof e)throw new Error('Configurator ID is not a string type: "'+typeof e+'"');const s=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",r=t.overrideTenant||9,i=s+"/configurators/"+e,a="roomle_portal_v2",n="03-"+window.btoa((new Date).toISOString()+";anonymous;"+a),o=new Request(i,{method:"GET",headers:new Headers({apiKey:a,currentTenant:r,locale:"en",language:"en",device:1,token:n,platform:"web"}),mode:"cors",cache:"default"}),l=await fetch(o),{configurator:c}=await l.json();return c},M="data-rml-interaction-container",b=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=e?.mute?e.value:e}})},y=()=>.01*window.innerHeight+"px",T=e=>{e&&setTimeout(()=>e.style.setProperty(v,y()),0)},O="rml-styles",v="--rml-full-height",A="rml-container",N="rml-fill",R="rml-pos",I="rml-android-height",L="rml-overflow-hidden",C=new Map;class P extends u{static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(e,t=[]){const s=new u;s.viewName=e;const{resolve:i,promise:a}=d(),{resolve:n,promise:o}=d(),l=new r("custom-view-"+e,window,window.parent,({message:e,args:t})=>{switch(e){case _.REGISTER_CUSTOM_VIEW_DONE:i();break;case _.RETURN_METHODS:s.handleSetup(t[0]),n();break;default:if(s.isSetupDone)return s.executeMessage({message:e,args:t})}});s.setMessageHandler(l);const c=[e];return l.sendMessage(_.REGISTER_CUSTOM_VIEW,c),await a,l.sendMessage(_.GET_METHODS,c),await o,s.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(e,t,s,r=[]){return this._create(e,t,s,r)}static create(e,t,s,r){return this._create(e,t,s,r)}static createViewer(e,t,s,r=[]){return this._create(e,t,s,r)}static hiMessageHandler=null;static setupHi(t){this.hiMessageHandler&&window.removeEventListener("message",this.hiMessageHandler),this.hiMessageHandler=r=>{if("connect_hi"===r.data.type&&r.data.port){const i=r.data.port;i.start?.(),e(s(t),i)}},window.addEventListener("message",this.hiMessageHandler)}static async _create(e,s,r,n){return new Promise(async(c,u)=>{try{const u=a((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(o);e.locale||(e.locale=t(null,!0)),"(idle)"===e.id&&delete e.id;const s=(()=>{const e=(()=>{try{return window.self!==window.top}catch{return!0}})();let t=window.location.href;if(e){if(!document.referrer)return null;t=document.referrer}const{hostname:s}=new URL(t);return s})();return s&&(e=>{const t=new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);return!!(i.includes(e)||t.test(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com"))})(s)&&(e.configuratorId="demoConfigurator"),e.customApiUrl="https://rubens.alpha.roomle.com/api/v2",e.emails=!1,e})(),(l(d=r),d?.customApiUrl&&(d.customApiUrl=decodeURIComponent(d.customApiUrl)),d.shareUrl&&(d.deeplink=d.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),d));(e=>{e.featureFlags||(e.featureFlags={}),"boolean"!=typeof e.featureFlags.realPartList&&(e.featureFlags.realPartList=!0),"boolean"!=typeof e.featureFlags.globalCallbacks&&(e.featureFlags.globalCallbacks=!0),"boolean"!=typeof e.featureFlags.mocAr&&(e.featureFlags.mocAr=!1)})(u);const g=await S(e,u);r=((e,t)=>{t.configuratorId=e.id;const s=e.settings||{};return!t.overrideTenant&&e.tenant&&(t.overrideTenant=e.tenant),((e,t)=>{const s=JSON.parse(JSON.stringify(e));return a(s,t)})(s,t)})(g,u);const h=new this(g,s,r,n,c);return await Promise.allSettled(h.pluginsLoaded),h}catch(e){return u(e)}var d})}_waitForIframe;_container;_configuratorSettings;_initData={};_iframe;constructor(e,t,s,i,a){if(super(),!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(C.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(O)){const e=s.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=O;const r="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((e,t)=>e+(t+r),"")+r,a=y();t.innerHTML=`\n .${A}{${v}:${a};}\n .${R}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${i}}\n .${N}{width:100%;height:100%;opacity:1}\n .${I}{height:calc(var(${v},1vh)*100)}\n .${L}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const n=new r("website",window,null,this._executeMessage);this.setMessageHandler(n),this._onResize=this._onResize.bind(this),c()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=a,this._container.appendChild(o),this._iframe=o,this.setupPlugins(i,this._iframe),C.set(t,!0)}teardown(){this._container&&C.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){const e=document.createElement("iframe");let t=this._configuratorSettings?.url||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(t=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(t=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(t=this._initData.overrideServerUrl),e.src=t,e.classList.add(A),e.classList.add(N),e}_onResize(){T(this._iframe)}_onUseFullPage(){this._iframe.classList.add(R),document.documentElement.classList.add(L),window.document.body.classList.add(L),c()&&(T(this._iframe),this._iframe.classList.add(I))}_onBackToWebsite(){this._iframe.classList.remove(R),this._iframe.classList.remove(I),document.documentElement.classList.remove(L),window.document.body.classList.remove(L)}_executeMessage({message:e,args:t},s){if(s.source&&s.source===this._iframe?.contentWindow)return e===p.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):Promise.resolve({error:"MessageHandler not set"}):e===p.SETUP?(this.handleSetup(t[0]),b(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),b(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{this._messageHandler&&this._messageHandler.sendMessage(p.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{p as HANDSHAKE_MESSAGES,M as INTERACTION_CONTAINER_SELECTOR,g as NAMESPACE,h as NAMESPACE_SEPARATOR,m as SDK_CALLBACK,_ as WELL_KNOWN_MESSAGES,P as default,S as getConfiguratorSettings,E as getMethodNames,w as isExposable};
@@ -1 +0,0 @@
1
- const t="rml-drag-in-styles",e="rml-drag-in-drag-element",s="rml-drag-in-overlay",a="rml-drag-in-drag-ghost",r="rml-drag-in-fade-in",i="rml-drag-in-fade-out",n={DISPLAY_NONE:"rml-display-none"},o="250ms",d="forwards",m=`@keyframes ${r} {from{opacity: 0;}to {opacity: 0.5;}}`,g=`@keyframes ${i} {from{opacity: 0.5;}to {opacity: 0;}}`,l=`${r} ${o} ${d}`,c=`${i} ${o} ${d}`,h="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",u=112,p=112;class _{_mainDomElement;_instance;_mode="website";_viewName="main";constructor(t,e,s,a){this._instance=t,this._mainDomElement=e,this._mode=s,this._viewName=a}async init(){return Promise.resolve()}}class y extends _{options={};_customDragSignal=new AbortController;_injectStyles(){if(!document.getElementById(t)){const e=document.createElement("style");e.type="text/css",e.id=t,e.innerHTML=`\n .${n.DISPLAY_NONE}{display:none}\n .${s}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}\n .${a}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}\n ${m}\n ${g}\n `,document.head.appendChild(e)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let e=t.querySelector("."+a);e||(e=document.createElement("div"),e.classList.add(a),e.innerText=" ",t.appendChild(e))}constructor(t,e,s,a){super(t,e,s,a),this._mainDomElement=e,this._injectStyles(),this._initializeDragGhost()}async init(){if(await super.init(),"website"===this._mode)try{const{DragInFromWebsiteStrategy:t}=await import("./from-website-ExTzmsnv.mjs");this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw t}else{if("custom-view"!==this._mode)throw new Error("Unsupported mode");try{const{DragInFromCustomViewStrategy:t}=await import("./from-custom-view-CfMGS1-t.mjs");this._strategy=new t(this._instance,this._mainDomElement,this.options,this._viewName)}catch(t){throw t}}}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:a}){a&&this._strategy.beforeUpdateGhost(a);const r=this._customDragSignal.signal,i=e=>{"true"===e.target.getAttribute("data-rml-draggable")&&t(e)},n=t=>{this._strategy.releaseInput(t),this._strategy.isDragging&&e(t)},o=t=>{s(t)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(t=>{t.draggable=!1}),document.addEventListener("mousedown",i,{signal:r}),document.addEventListener("mouseup",n,{signal:r}),document.addEventListener("mousemove",o,{signal:r}),document.addEventListener("mouseleave",n,{signal:r}),document.addEventListener("touchstart",i,{signal:r}),document.addEventListener("touchend",n,{signal:r}),document.addEventListener("touchmove",o,{signal:r})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const D=Object.freeze(Object.defineProperty({__proto__:null,DragIn:y},Symbol.toStringTag,{value:"Module"}));export{y as D,e as R,t as a,m as b,g as c,h as d,u as e,p as f,l as g,c as h,s as i,n as j,a as k,D as l};
@@ -1,197 +0,0 @@
1
- import { e as O, b as D, i as b } from "./utils-Dav4kGNW.mjs";
2
- import { C as v, T as A, a as L, b as w, c as Y } from "./touch-drag-CfMLD_hM.mjs";
3
- import { f as G, e as R, d as c } from "./embedding-plugins-Cm7O1pKC.mjs";
4
- const X = (r) => `[data-rml-custom-view="${r}"]`, g = (r) => {
5
- r.preventDefault(), r.stopPropagation();
6
- }, U = (r, t, s, e) => {
7
- const a = s - r, n = e - t;
8
- return Math.sqrt(a * a + n * n);
9
- };
10
- class M {
11
- _startX = 0;
12
- _startY = 0;
13
- _lastX = 0;
14
- _lastY = 0;
15
- _epsilon;
16
- _isWaiting = !1;
17
- _onCustomDragStart;
18
- constructor({ onCustomDragStart: t }, s = {}) {
19
- this._epsilon = typeof s.epsilon == "number" ? s.epsilon : v, this._onCustomDragStart = t;
20
- }
21
- onMove(t) {
22
- this._lastX = t.clientX, this._lastY = t.clientY, this._isWaiting && U(
23
- this._startX,
24
- this._startY,
25
- this._lastX,
26
- this._lastY
27
- ) > this._epsilon && (this._onCustomDragStart(t), this._isWaiting = !1);
28
- }
29
- onStart(t) {
30
- this._startX = t.clientX, this._startY = t.clientY, this.onMove(t), this._isWaiting = !0;
31
- }
32
- onEnd() {
33
- this._reset();
34
- }
35
- _reset() {
36
- this._startX = 0, this._startY = 0, this._lastX = 0, this._lastY = 0, this._isWaiting = !1;
37
- }
38
- }
39
- const l = "data-rml-old-draggable", H = void 0, p = (r, t) => {
40
- const s = b(r), e = {
41
- delay: s ? w : Y,
42
- epsilon: s ? L : v
43
- };
44
- if (!t)
45
- return e;
46
- if (!s && !(r instanceof MouseEvent))
47
- return console.warn(
48
- "Unsupported event! It is not TouchEvent and also not MouseEvent"
49
- ), e;
50
- const {
51
- delayKey: a,
52
- epsilonKey: n
53
- } = s ? { delayKey: "touchDragDelay", epsilonKey: "touchDragEpsilon" } : { delayKey: "customDragDelay", epsilonKey: "customDragEpsilon" };
54
- return typeof t[a] == "number" && (e.delay = t.touchDragDelay), typeof t[n] == "number" && (e.epsilon = t.touchDragEpsilon), e;
55
- }, x = (r) => {
56
- let t = "", s = R, e = G;
57
- if (!r)
58
- return { url: c, width: s, height: e };
59
- const a = r;
60
- if (a instanceof HTMLElement) {
61
- const n = a.getBoundingClientRect(), i = a.getAttribute("data-rml-ghost-url"), h = a.getAttribute("data-rml-ghost-width"), o = a.getAttribute("data-rml-ghost-height");
62
- i ? t = i : !i && a instanceof HTMLImageElement && a.src && (t = a.src), t ? (s = n.width, e = n.height) : t = c, s = h ? parseInt(h, 10) : s, e = o ? parseInt(o, 10) : e;
63
- }
64
- return { url: t || c, width: s, height: e };
65
- };
66
- class F {
67
- _options = {};
68
- _instance;
69
- _mainDomElement;
70
- _viewName;
71
- _currentCustomDrag = null;
72
- _currentBb = null;
73
- _startTarget = null;
74
- _onBeforeUpdateDrag = () => ({});
75
- isDragging = !1;
76
- _hasEnteredIframe = !1;
77
- _pendingDragIn = null;
78
- _canvasBb = null;
79
- _overlayBb = null;
80
- _interactionContainerBb = null;
81
- constructor(t, s, e, a) {
82
- this._instance = t, this._options = e || {}, this._viewName = a, this._mainDomElement = s, this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
83
- this._instance.cancelDragIn();
84
- });
85
- }
86
- beforeUpdateGhost(t) {
87
- this._onBeforeUpdateDrag = t;
88
- }
89
- async _dragStart(t, s, e = "rml_id") {
90
- this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(
91
- l,
92
- this._startTarget.draggable.toString()
93
- ), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", g), this._startTarget.addEventListener("dragstart", g)), this._currentBb = this._instance.getBoundingClientRect(
94
- X(this._viewName)
95
- ), this._canvasBb = await this._instance.getBoundingClientRect("canvas"), this._overlayBb = (await this._instance.getDrawerBoundingClientRect()).final, this._interactionContainerBb = await this._instance.getBoundingClientRect(
96
- ".interaction-container"
97
- ), this._pendingDragIn = { id: t, type: e }, this._hasEnteredIframe = !1, this.isDragging = !0;
98
- }
99
- _dragUpdate(t) {
100
- if (document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(t), !this._currentBb || !this.isDragging)
101
- return;
102
- const { clientX: s, clientY: e } = O(t), a = s >= 0 && s <= this._currentBb.width && e >= 0 && e <= this._currentBb.height;
103
- if (a && !this._hasEnteredIframe && this._pendingDragIn && D(
104
- s,
105
- e,
106
- this._canvasBb,
107
- this._overlayBb,
108
- this._interactionContainerBb
109
- )) {
110
- const y = this._currentBb.x + s, S = this._currentBb.y + e;
111
- this._instance.dragInObject(
112
- this._pendingDragIn.id,
113
- y,
114
- S,
115
- this._pendingDragIn.type
116
- ), this._hasEnteredIframe = !0;
117
- }
118
- if (a && this._hasEnteredIframe && this._canvasBb && !D(
119
- s,
120
- e,
121
- this._canvasBb,
122
- this._overlayBb,
123
- this._interactionContainerBb
124
- )) {
125
- this._instance.cancelDragIn(), this._hasEnteredIframe = !1;
126
- return;
127
- }
128
- if (!this._hasEnteredIframe)
129
- return;
130
- const { url: n, width: i, height: h } = x(this._startTarget), o = this._currentBb.x + s, u = this._currentBb.y + e, _ = this._options || {}, d = {
131
- ghost: {
132
- visibleIn: {
133
- x: this._currentBb.x - (_.dragInOverlapX || 0),
134
- y: this._currentBb.y + (_.dragInOverlapY || 0),
135
- width: this._currentBb.width + (_.dragInOverlapX || 0),
136
- height: this._currentBb.height + (_.dragInOverlapY || 0)
137
- },
138
- url: n,
139
- width: i,
140
- height: h
141
- },
142
- mode: "custom-view"
143
- }, {
144
- x: m,
145
- y: f,
146
- options: E
147
- } = this._onBeforeUpdateDrag(o, u, d), B = typeof m == "number" ? m : o, T = typeof f == "number" ? f : u, C = E || d;
148
- this._instance.updateDrag(B, T, C);
149
- }
150
- _dragEnd() {
151
- this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._currentCustomDrag = null, this.isDragging = !1, this._currentBb = null, this._canvasBb = null, this._overlayBb = null, this._interactionContainerBb = null, this._resetStartTarget(), this._instance.enableEvents(), this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._hasEnteredIframe = !1, this._pendingDragIn = null;
152
- }
153
- dragStart(t, s, e) {
154
- this._instance.disableEvents(), this._startTarget = s.target;
155
- const a = (n, i) => {
156
- this._dragStart(t, i, e);
157
- };
158
- this._currentCustomDrag = b(s) ? new A(
159
- H,
160
- {
161
- onTouchDragStart: a
162
- },
163
- p(s, this._options)
164
- ) : new M(
165
- {
166
- onCustomDragStart: (n) => this._dragStart(t, n, e)
167
- },
168
- p(s, this._options)
169
- ), this._currentCustomDrag.onStart(s);
170
- }
171
- dragEnd() {
172
- this._dragEnd();
173
- }
174
- dragUpdate(t) {
175
- this._dragUpdate(t);
176
- }
177
- touchStart(t, s, e = "rml_id") {
178
- this.dragStart(t, s, e);
179
- }
180
- touchMove(t) {
181
- this.dragUpdate(t);
182
- }
183
- touchEnd() {
184
- this.dragEnd();
185
- }
186
- dispose() {
187
- }
188
- _resetStartTarget() {
189
- this._startTarget && (this._startTarget.style.pointerEvents = "", this._startTarget.style.userSelect = "", this._startTarget.draggable = this._startTarget.getAttribute(l) === "true", this._startTarget.removeAttribute(l), this._startTarget.removeEventListener("dragstart", g));
190
- }
191
- releaseInput(t) {
192
- this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._resetStartTarget();
193
- }
194
- }
195
- export {
196
- F as DragInFromCustomViewStrategy
197
- };
@@ -1 +0,0 @@
1
- import{e as t,b as e,i as s}from"./utils-BqTPLNLs.mjs";import{C as r,T as a,a as i,b as n,c as h}from"./touch-drag-TGCsdNqP.mjs";import{f as o,e as g,d as _}from"./embedding-plugins-Dzhuj1By.mjs";const l=t=>{t.preventDefault(),t.stopPropagation()};class u{_startX=0;_startY=0;_lastX=0;_lastY=0;_epsilon;_isWaiting=!1;_onCustomDragStart;constructor({onCustomDragStart:t},e={}){this._epsilon="number"==typeof e.epsilon?e.epsilon:r,this._onCustomDragStart=t}onMove(t){this._lastX=t.clientX,this._lastY=t.clientY,this._isWaiting&&((t,e)=>{const s=this._lastX-t,r=this._lastY-e;return Math.sqrt(s*s+r*r)})(this._startX,this._startY)>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 c="data-rml-old-draggable",d=(t,e)=>{const a=s(t),o={delay:a?n:h,epsilon:a?i:r};if(!e)return o;if(!(a||t instanceof MouseEvent))return o;const{delayKey:g,epsilonKey:_}=a?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return"number"==typeof e[g]&&(o.delay=e.touchDragDelay),"number"==typeof e[_]&&(o.epsilon=e.touchDragEpsilon),o};class m{_options={};_instance;_mainDomElement;_viewName;_currentCustomDrag=null;_currentBb=null;_startTarget=null;_onBeforeUpdateDrag=()=>({});isDragging=!1;_hasEnteredIframe=!1;_pendingDragIn=null;_canvasBb=null;_overlayBb=null;_interactionContainerBb=null;constructor(t,e,s,r){this._instance=t,this._options=s||{},this._viewName=r,this._mainDomElement=e,this._mainDomElement.parentElement?.addEventListener("dragleave",()=>{this._instance.cancelDragIn()})}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(c,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",l),this._startTarget.addEventListener("dragstart",l)),this._currentBb=this._instance.getBoundingClientRect(`[data-rml-custom-view="${this._viewName}"]`),this._canvasBb=await this._instance.getBoundingClientRect("canvas"),this._overlayBb=(await this._instance.getDrawerBoundingClientRect()).final,this._interactionContainerBb=await this._instance.getBoundingClientRect(".interaction-container"),this._pendingDragIn={id:t,type:s},this._hasEnteredIframe=!1,this.isDragging=!0}_dragUpdate(s){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(s),!this._currentBb||!this.isDragging)return;const{clientX:r,clientY:a}=t(s),i=r>=0&&r<=this._currentBb.width&&a>=0&&a<=this._currentBb.height;if(i&&!this._hasEnteredIframe&&this._pendingDragIn&&e(r,a,this._canvasBb,this._overlayBb,this._interactionContainerBb)){const t=this._currentBb.x+r,e=this._currentBb.y+a;this._instance.dragInObject(this._pendingDragIn.id,t,e,this._pendingDragIn.type),this._hasEnteredIframe=!0}if(i&&this._hasEnteredIframe&&this._canvasBb&&!e(r,a,this._canvasBb,this._overlayBb,this._interactionContainerBb))return this._instance.cancelDragIn(),void(this._hasEnteredIframe=!1);if(!this._hasEnteredIframe)return;const{url:n,width:h,height:l}=(t=>{let e="",s=g,r=o;if(!t)return{url:_,width:s,height:r};const a=t;if(a instanceof HTMLElement){const t=a.getBoundingClientRect(),i=a.getAttribute("data-rml-ghost-url"),n=a.getAttribute("data-rml-ghost-width"),h=a.getAttribute("data-rml-ghost-height");i?e=i:!i&&a instanceof HTMLImageElement&&a.src&&(e=a.src),e?(s=t.width,r=t.height):e=_,s=n?parseInt(n,10):s,r=h?parseInt(h,10):r}return{url:e||_,width:s,height:r}})(this._startTarget),u=this._currentBb.x+r,c=this._currentBb.y+a,d=this._options||{},m={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:n,width:h,height:l},mode:"custom-view"},{x:p,y:b,options:D}=this._onBeforeUpdateDrag(u,c,m),v="number"==typeof p?p:u,y="number"==typeof b?b:c,B=D||m;this._instance.updateDrag(v,y,B)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._canvasBb=null,this._overlayBb=null,this._interactionContainerBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._hasEnteredIframe&&this._instance.dragInObjectEnd(),this._hasEnteredIframe=!1,this._pendingDragIn=null}dragStart(t,e,r){this._instance.disableEvents(),this._startTarget=e.target,this._currentCustomDrag=s(e)?new a(void 0,{onTouchDragStart:(e,s)=>{this._dragStart(t,s,r)}},d(e,this._options)):new u({onCustomDragStart:e=>this._dragStart(t,e,r)},d(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="true"===this._startTarget.getAttribute(c),this._startTarget.removeAttribute(c),this._startTarget.removeEventListener("dragstart",l))}releaseInput(t){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}export{m as DragInFromCustomViewStrategy};