@roomle/embedding-lib 6.5.0 → 6.6.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.
Files changed (38) hide show
  1. package/browser-C_Dfiou7.mjs +18 -0
  2. package/browser-DRgK3Fk8.mjs +16 -0
  3. package/comlink-BipJ8Ikr.mjs +237 -0
  4. package/comlink-Dds_bpug.mjs +220 -0
  5. package/docs/md/web/embedding/CHANGELOG.md +32 -150
  6. package/drag-ghost-BGZWgVa7.mjs +60 -0
  7. package/drag-ghost-DGgvJ4Lm.mjs +65 -0
  8. package/drag-in-AFSAsnAN.mjs +102 -0
  9. package/drag-in-BwqVwCBp.mjs +96 -0
  10. package/embedding-plugins.js +2 -14
  11. package/embedding-plugins.min.js +2 -1
  12. package/from-custom-view-B-eXMXF1.mjs +207 -0
  13. package/from-custom-view-tZcYF-zX.mjs +206 -0
  14. package/from-website--UCl1aQs.mjs +113 -0
  15. package/from-website-BesXdvcV.mjs +118 -0
  16. package/hi.js +72 -119
  17. package/hi.min.js +71 -1
  18. package/package.json +1 -1
  19. package/rolldown-runtime-C-QNzSnW.mjs +11 -0
  20. package/rolldown-runtime-C017PlDO.mjs +9 -0
  21. package/roomle-embedding-lib.js +394 -576
  22. package/roomle-embedding-lib.min.js +365 -1
  23. package/utils-BnWKaFPc.mjs +126 -0
  24. package/utils-DfC2ZLUc.mjs +118 -0
  25. package/browser-BhHw2H1M.mjs +0 -1
  26. package/browser-CUgD7zyH.mjs +0 -21
  27. package/comlink-BAiXCcU9.mjs +0 -258
  28. package/comlink-CmT64Qi3.mjs +0 -1
  29. package/drag-ghost-B7UAYefM.mjs +0 -1
  30. package/drag-ghost-DHrf_Evu.mjs +0 -81
  31. package/embedding-plugins-DLVs7ER4.mjs +0 -1
  32. package/embedding-plugins-DqMSzAJe.mjs +0 -140
  33. package/from-custom-view-CaDOooe4.mjs +0 -1
  34. package/from-custom-view-T67aFIDR.mjs +0 -249
  35. package/from-website-Bvd5Pi0i.mjs +0 -134
  36. package/from-website-nKwD78_u.mjs +0 -1
  37. package/utils-BqTPLNLs.mjs +0 -1
  38. package/utils-Dav4kGNW.mjs +0 -150
@@ -0,0 +1,207 @@
1
+ import { a as e, n as t, o as n } from "./utils-BnWKaFPc.mjs";
2
+ import { d as r } from "./drag-in-AFSAsnAN.mjs";
3
+ import { t as i } from "./drag-ghost-DGgvJ4Lm.mjs";
4
+ var a = (e, t = 0) => n(e) ? {
5
+ clientX: e.touches[t].clientX,
6
+ clientY: e.touches[t].clientY
7
+ } : {
8
+ clientX: e.clientX,
9
+ clientY: e.clientY
10
+ }, o = (e) => e && n(e) ? e.touches.length > 0 : !0, s = class {
11
+ _touchDragTimeOut;
12
+ _onTouchDragStart;
13
+ _payload = null;
14
+ _delay = 500;
15
+ _firstTouch = null;
16
+ _lastTouch = null;
17
+ _epsilon = 10;
18
+ constructor(e, { onTouchDragStart: t }, n = {}) {
19
+ this._payload = e, this._onTouchDragStart = t, this._delay = typeof n.delay == "number" ? n.delay : 500, this._epsilon = typeof n.epsilon == "number" ? n.epsilon : 10;
20
+ }
21
+ onStart(e) {
22
+ o(e) && (this._touchDragTimeOut ||= (this._firstTouch = a(e, n(e) ? e.touches.length - 1 : 0), setTimeout(() => {
23
+ this._clearTimeout(), this._lastTouch ||= a(e), this._checkXDistance(e)();
24
+ }, this._delay)));
25
+ }
26
+ onEnd() {
27
+ this._resetTouches();
28
+ }
29
+ onMove(e) {
30
+ o(e) && (this._lastTouch = a(e));
31
+ }
32
+ _clearTimeout() {
33
+ this._touchDragTimeOut &&= (clearTimeout(this._touchDragTimeOut), null);
34
+ }
35
+ _resetTouches() {
36
+ this._clearTimeout(), this._lastTouch = null, this._firstTouch = null, this._payload = null;
37
+ }
38
+ _checkXDistance(e) {
39
+ return () => {
40
+ if (!this._firstTouch || !this._lastTouch) return;
41
+ let t = !1;
42
+ t = Math.abs(this._firstTouch.clientX - this._lastTouch.clientX) < this._epsilon, t && (this._onTouchDragStart(this._payload, e), this._resetTouches());
43
+ };
44
+ }
45
+ }, c = (e) => `[data-rml-custom-view="${e}"]`, l = (e) => {
46
+ e.preventDefault(), e.stopPropagation();
47
+ }, u = (e, t, n, r) => {
48
+ let i = n - e, a = r - t;
49
+ return Math.sqrt(i * i + a * a);
50
+ }, d = class {
51
+ _startX = 0;
52
+ _startY = 0;
53
+ _lastX = 0;
54
+ _lastY = 0;
55
+ _epsilon;
56
+ _isWaiting = !1;
57
+ _onCustomDragStart;
58
+ constructor({ onCustomDragStart: e }, t = {}) {
59
+ this._epsilon = typeof t.epsilon == "number" ? t.epsilon : 15, this._onCustomDragStart = e;
60
+ }
61
+ onMove(e) {
62
+ this._lastX = e.clientX, this._lastY = e.clientY, this._isWaiting && u(this._startX, this._startY, this._lastX, this._lastY) > this._epsilon && (this._onCustomDragStart(e), this._isWaiting = !1);
63
+ }
64
+ onStart(e) {
65
+ this._startX = e.clientX, this._startY = e.clientY, this.onMove(e), this._isWaiting = !0;
66
+ }
67
+ onEnd() {
68
+ this._reset();
69
+ }
70
+ _reset() {
71
+ this._startX = 0, this._startY = 0, this._lastX = 0, this._lastY = 0, this._isWaiting = !1;
72
+ }
73
+ }, f = "data-rml-old-draggable", p = void 0, m = (e, t) => {
74
+ let r = n(e), i = {
75
+ delay: r ? 500 : 100,
76
+ epsilon: r ? 10 : 15
77
+ };
78
+ if (!t) return i;
79
+ if (!r && !(e instanceof MouseEvent)) return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"), i;
80
+ let { delayKey: a, epsilonKey: o } = r ? {
81
+ delayKey: "touchDragDelay",
82
+ epsilonKey: "touchDragEpsilon"
83
+ } : {
84
+ delayKey: "customDragDelay",
85
+ epsilonKey: "customDragEpsilon"
86
+ };
87
+ return typeof t[a] == "number" && (i.delay = t.touchDragDelay), typeof t[o] == "number" && (i.epsilon = t.touchDragEpsilon), i;
88
+ }, h = (e) => {
89
+ let t = "", n = 112, i = 112;
90
+ if (!e) return {
91
+ url: r,
92
+ width: n,
93
+ height: i
94
+ };
95
+ let a = e;
96
+ if (a instanceof HTMLElement) {
97
+ let e = a.getBoundingClientRect(), o = a.getAttribute("data-rml-ghost-url"), s = a.getAttribute("data-rml-ghost-width"), c = a.getAttribute("data-rml-ghost-height");
98
+ o ? t = o : !o && a instanceof HTMLImageElement && a.src && (t = a.src), t ? (n = e.width, i = e.height) : t = r, n = s ? parseInt(s, 10) : n, i = c ? parseInt(c, 10) : i;
99
+ }
100
+ return {
101
+ url: t || "https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",
102
+ width: n,
103
+ height: i
104
+ };
105
+ }, g = class {
106
+ _options = {};
107
+ _instance;
108
+ _mainDomElement;
109
+ _viewName;
110
+ _currentCustomDrag = null;
111
+ _currentBb = null;
112
+ _startTarget = null;
113
+ _dragGhost = null;
114
+ _onBeforeUpdateDrag = () => ({});
115
+ isDragging = !1;
116
+ _hasEnteredIframe = !1;
117
+ _pendingDragIn = null;
118
+ _canvasBb = null;
119
+ _overlayBb = null;
120
+ _dragGeneration = 0;
121
+ _interactionContainerBb = null;
122
+ constructor(e, t, n, r) {
123
+ this._instance = e, this._options = n || {}, this._viewName = r, this._mainDomElement = t, this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
124
+ this._instance.cancelDragIn();
125
+ });
126
+ }
127
+ beforeUpdateGhost(e) {
128
+ this._onBeforeUpdateDrag = e;
129
+ }
130
+ async _dragStart(e, t, n = "rml_id") {
131
+ let r = ++this._dragGeneration;
132
+ if (this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(f, this._startTarget.draggable.toString()), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", l), this._startTarget.addEventListener("dragstart", l)), this._startTarget) {
133
+ let e = this._startTarget.getBoundingClientRect(), t = this._startTarget.cloneNode(!0);
134
+ t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, this._dragGhost = new i(t);
135
+ } else this._dragGhost = new i();
136
+ this._currentBb = await this._instance.getBoundingClientRect(c(this._viewName)), this._canvasBb = await this._instance.getBoundingClientRect("canvas"), this._overlayBb = (await this._instance.getDrawerBoundingClientRect()).final, this._interactionContainerBb = await this._instance.getBoundingClientRect(".interaction-container"), r === this._dragGeneration && (this._pendingDragIn = {
137
+ id: e,
138
+ type: n
139
+ }, this._hasEnteredIframe = !1, this.isDragging = !0);
140
+ }
141
+ _dragUpdate(n) {
142
+ document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(n);
143
+ let { clientX: r, clientY: i } = t(n);
144
+ if (this._dragGhost) {
145
+ let { width: e, height: t } = this._mainDomElement.getBoundingClientRect();
146
+ this._dragGhost.updateDragGhost(r, i, { ghost: { visibleIn: {
147
+ x: 0,
148
+ y: 0,
149
+ width: e,
150
+ height: t
151
+ } } });
152
+ }
153
+ if (!this._currentBb || !this.isDragging) return;
154
+ let a = this._currentBb.x + r, o = this._currentBb.y + i, s = e(a, o, this._canvasBb, this._overlayBb, this._interactionContainerBb);
155
+ if (s && !this._hasEnteredIframe && this._pendingDragIn && (this._instance.dragInObject(this._pendingDragIn.id, a, o, this._pendingDragIn.type), this._hasEnteredIframe = !0), !s && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1), !this._hasEnteredIframe) return;
156
+ let { url: c, width: l, height: u } = h(this._startTarget), d = this._options || {}, f = {
157
+ ghost: {
158
+ visibleIn: {
159
+ x: this._currentBb.x - (d.dragInOverlapX || 0),
160
+ y: this._currentBb.y + (d.dragInOverlapY || 0),
161
+ width: this._currentBb.width + (d.dragInOverlapX || 0),
162
+ height: this._currentBb.height + (d.dragInOverlapY || 0)
163
+ },
164
+ url: c,
165
+ width: l,
166
+ height: u
167
+ },
168
+ mode: "custom-view"
169
+ }, { x: p, y: m, options: g } = this._onBeforeUpdateDrag(a, o, f), _ = typeof p == "number" ? p : a, v = typeof m == "number" ? m : o, y = g || f;
170
+ this._instance.updateDrag(_, v, y);
171
+ }
172
+ _dragEnd() {
173
+ 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._dragGhost &&= (this._dragGhost.removeDragGhost(), null), this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._hasEnteredIframe = !1, this._pendingDragIn = null;
174
+ }
175
+ dragStart(e, t, r) {
176
+ this._instance.disableEvents(), this._startTarget = t.target, this._currentCustomDrag = n(t) ? new s(p, { onTouchDragStart: (t, n) => {
177
+ this._dragStart(e, n, r);
178
+ } }, {
179
+ ...m(t, this._options),
180
+ delay: 0
181
+ }) : new d({ onCustomDragStart: (t) => this._dragStart(e, t, r) }, m(t, this._options)), this._currentCustomDrag.onStart(t);
182
+ }
183
+ dragEnd() {
184
+ this._dragEnd();
185
+ }
186
+ dragUpdate(e) {
187
+ this._dragUpdate(e);
188
+ }
189
+ touchStart(e, t, n = "rml_id") {
190
+ this.dragStart(e, t, n);
191
+ }
192
+ touchMove(e) {
193
+ this.dragUpdate(e);
194
+ }
195
+ touchEnd() {
196
+ this.dragEnd();
197
+ }
198
+ dispose() {}
199
+ _resetStartTarget() {
200
+ this._startTarget && (this._startTarget.style.pointerEvents = "", this._startTarget.style.userSelect = "", this._startTarget.draggable = this._startTarget.getAttribute(f) === "true", this._startTarget.removeAttribute(f), this._startTarget.removeEventListener("dragstart", l));
201
+ }
202
+ releaseInput(e) {
203
+ this._dragGeneration++, this._dragEnd();
204
+ }
205
+ };
206
+ //#endregion
207
+ export { g as DragInFromCustomViewStrategy };
@@ -0,0 +1,206 @@
1
+ import { a as e, n as t, o as n } from "./utils-DfC2ZLUc.mjs";
2
+ import { d as r } from "./drag-in-BwqVwCBp.mjs";
3
+ import { t as i } from "./drag-ghost-BGZWgVa7.mjs";
4
+ var a = (e, t = 0) => n(e) ? {
5
+ clientX: e.touches[t].clientX,
6
+ clientY: e.touches[t].clientY
7
+ } : {
8
+ clientX: e.clientX,
9
+ clientY: e.clientY
10
+ }, o = (e) => !e || !n(e) || e.touches.length > 0, s = class {
11
+ _touchDragTimeOut;
12
+ _onTouchDragStart;
13
+ _payload = null;
14
+ _delay = 500;
15
+ _firstTouch = null;
16
+ _lastTouch = null;
17
+ _epsilon = 10;
18
+ constructor(e, { onTouchDragStart: t }, n = {}) {
19
+ this._payload = e, this._onTouchDragStart = t, this._delay = typeof n.delay == "number" ? n.delay : 500, this._epsilon = typeof n.epsilon == "number" ? n.epsilon : 10;
20
+ }
21
+ onStart(e) {
22
+ o(e) && (this._touchDragTimeOut ||= (this._firstTouch = a(e, n(e) ? e.touches.length - 1 : 0), setTimeout(() => {
23
+ this._clearTimeout(), this._lastTouch ||= a(e), this._checkXDistance(e)();
24
+ }, this._delay)));
25
+ }
26
+ onEnd() {
27
+ this._resetTouches();
28
+ }
29
+ onMove(e) {
30
+ o(e) && (this._lastTouch = a(e));
31
+ }
32
+ _clearTimeout() {
33
+ this._touchDragTimeOut &&= (clearTimeout(this._touchDragTimeOut), null);
34
+ }
35
+ _resetTouches() {
36
+ this._clearTimeout(), this._lastTouch = null, this._firstTouch = null, this._payload = null;
37
+ }
38
+ _checkXDistance(e) {
39
+ return () => {
40
+ if (!this._firstTouch || !this._lastTouch) return;
41
+ let t = !1;
42
+ t = Math.abs(this._firstTouch.clientX - this._lastTouch.clientX) < this._epsilon, t && (this._onTouchDragStart(this._payload, e), this._resetTouches());
43
+ };
44
+ }
45
+ }, c = (e) => {
46
+ e.preventDefault(), e.stopPropagation();
47
+ }, l = class {
48
+ _startX = 0;
49
+ _startY = 0;
50
+ _lastX = 0;
51
+ _lastY = 0;
52
+ _epsilon;
53
+ _isWaiting = !1;
54
+ _onCustomDragStart;
55
+ constructor({ onCustomDragStart: e }, t = {}) {
56
+ this._epsilon = typeof t.epsilon == "number" ? t.epsilon : 15, this._onCustomDragStart = e;
57
+ }
58
+ onMove(e) {
59
+ this._lastX = e.clientX, this._lastY = e.clientY, this._isWaiting && ((e, t) => {
60
+ let n = this._lastX - e, r = this._lastY - t;
61
+ return Math.sqrt(n * n + r * r);
62
+ })(this._startX, this._startY) > this._epsilon && (this._onCustomDragStart(e), this._isWaiting = !1);
63
+ }
64
+ onStart(e) {
65
+ this._startX = e.clientX, this._startY = e.clientY, this.onMove(e), this._isWaiting = !0;
66
+ }
67
+ onEnd() {
68
+ this._reset();
69
+ }
70
+ _reset() {
71
+ this._startX = 0, this._startY = 0, this._lastX = 0, this._lastY = 0, this._isWaiting = !1;
72
+ }
73
+ }, u = "data-rml-old-draggable", d = (e, t) => {
74
+ let r = n(e), i = {
75
+ delay: r ? 500 : 100,
76
+ epsilon: r ? 10 : 15
77
+ };
78
+ if (!t || !(r || e instanceof MouseEvent)) return i;
79
+ let { delayKey: a, epsilonKey: o } = r ? {
80
+ delayKey: "touchDragDelay",
81
+ epsilonKey: "touchDragEpsilon"
82
+ } : {
83
+ delayKey: "customDragDelay",
84
+ epsilonKey: "customDragEpsilon"
85
+ };
86
+ return typeof t[a] == "number" && (i.delay = t.touchDragDelay), typeof t[o] == "number" && (i.epsilon = t.touchDragEpsilon), i;
87
+ }, f = class {
88
+ _options = {};
89
+ _instance;
90
+ _mainDomElement;
91
+ _viewName;
92
+ _currentCustomDrag = null;
93
+ _currentBb = null;
94
+ _startTarget = null;
95
+ _dragGhost = null;
96
+ _onBeforeUpdateDrag = () => ({});
97
+ isDragging = !1;
98
+ _hasEnteredIframe = !1;
99
+ _pendingDragIn = null;
100
+ _canvasBb = null;
101
+ _overlayBb = null;
102
+ _dragGeneration = 0;
103
+ _interactionContainerBb = null;
104
+ constructor(e, t, n, r) {
105
+ this._instance = e, this._options = n || {}, this._viewName = r, this._mainDomElement = t, this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
106
+ this._instance.cancelDragIn();
107
+ });
108
+ }
109
+ beforeUpdateGhost(e) {
110
+ this._onBeforeUpdateDrag = e;
111
+ }
112
+ async _dragStart(e, t, n = "rml_id") {
113
+ let r = ++this._dragGeneration;
114
+ if (this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(u, this._startTarget.draggable.toString()), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", c), this._startTarget.addEventListener("dragstart", c)), this._startTarget) {
115
+ let e = this._startTarget.getBoundingClientRect(), t = this._startTarget.cloneNode(!0);
116
+ t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, this._dragGhost = new i(t);
117
+ } else this._dragGhost = new i();
118
+ var a;
119
+ this._currentBb = await this._instance.getBoundingClientRect((a = this._viewName, `[data-rml-custom-view="${a}"]`)), this._canvasBb = await this._instance.getBoundingClientRect("canvas"), this._overlayBb = (await this._instance.getDrawerBoundingClientRect()).final, this._interactionContainerBb = await this._instance.getBoundingClientRect(".interaction-container"), r === this._dragGeneration && (this._pendingDragIn = {
120
+ id: e,
121
+ type: n
122
+ }, this._hasEnteredIframe = !1, this.isDragging = !0);
123
+ }
124
+ _dragUpdate(n) {
125
+ document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(n);
126
+ let { clientX: i, clientY: a } = t(n);
127
+ if (this._dragGhost) {
128
+ let { width: e, height: t } = this._mainDomElement.getBoundingClientRect();
129
+ this._dragGhost.updateDragGhost(i, a, { ghost: { visibleIn: {
130
+ x: 0,
131
+ y: 0,
132
+ width: e,
133
+ height: t
134
+ } } });
135
+ }
136
+ if (!this._currentBb || !this.isDragging) return;
137
+ let o = this._currentBb.x + i, s = this._currentBb.y + a, c = e(o, s, this._canvasBb, this._overlayBb, this._interactionContainerBb);
138
+ if (c && !this._hasEnteredIframe && this._pendingDragIn && (this._instance.dragInObject(this._pendingDragIn.id, o, s, this._pendingDragIn.type), this._hasEnteredIframe = !0), !c && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1), !this._hasEnteredIframe) return;
139
+ let { url: l, width: u, height: d } = ((e) => {
140
+ let t = "", n = 112, i = 112;
141
+ if (!e) return {
142
+ url: r,
143
+ width: n,
144
+ height: i
145
+ };
146
+ let a = e;
147
+ if (a instanceof HTMLElement) {
148
+ let e = a.getBoundingClientRect(), o = a.getAttribute("data-rml-ghost-url"), s = a.getAttribute("data-rml-ghost-width"), c = a.getAttribute("data-rml-ghost-height");
149
+ o ? t = o : !o && a instanceof HTMLImageElement && a.src && (t = a.src), t ? (n = e.width, i = e.height) : t = r, n = s ? parseInt(s, 10) : n, i = c ? parseInt(c, 10) : i;
150
+ }
151
+ return {
152
+ url: t || "https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",
153
+ width: n,
154
+ height: i
155
+ };
156
+ })(this._startTarget), f = this._options || {}, p = {
157
+ ghost: {
158
+ visibleIn: {
159
+ x: this._currentBb.x - (f.dragInOverlapX || 0),
160
+ y: this._currentBb.y + (f.dragInOverlapY || 0),
161
+ width: this._currentBb.width + (f.dragInOverlapX || 0),
162
+ height: this._currentBb.height + (f.dragInOverlapY || 0)
163
+ },
164
+ url: l,
165
+ width: u,
166
+ height: d
167
+ },
168
+ mode: "custom-view"
169
+ }, { x: m, y: h, options: g } = this._onBeforeUpdateDrag(o, s, p), _ = typeof m == "number" ? m : o, v = typeof h == "number" ? h : s, y = g || p;
170
+ this._instance.updateDrag(_, v, y);
171
+ }
172
+ _dragEnd() {
173
+ 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._dragGhost &&= (this._dragGhost.removeDragGhost(), null), this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._hasEnteredIframe = !1, this._pendingDragIn = null;
174
+ }
175
+ dragStart(e, t, r) {
176
+ this._instance.disableEvents(), this._startTarget = t.target, this._currentCustomDrag = n(t) ? new s(void 0, { onTouchDragStart: (t, n) => {
177
+ this._dragStart(e, n, r);
178
+ } }, {
179
+ ...d(t, this._options),
180
+ delay: 0
181
+ }) : new l({ onCustomDragStart: (t) => this._dragStart(e, t, r) }, d(t, this._options)), this._currentCustomDrag.onStart(t);
182
+ }
183
+ dragEnd() {
184
+ this._dragEnd();
185
+ }
186
+ dragUpdate(e) {
187
+ this._dragUpdate(e);
188
+ }
189
+ touchStart(e, t, n = "rml_id") {
190
+ this.dragStart(e, t, n);
191
+ }
192
+ touchMove(e) {
193
+ this.dragUpdate(e);
194
+ }
195
+ touchEnd() {
196
+ this.dragEnd();
197
+ }
198
+ dispose() {}
199
+ _resetStartTarget() {
200
+ this._startTarget && (this._startTarget.style.pointerEvents = "", this._startTarget.style.userSelect = "", this._startTarget.draggable = this._startTarget.getAttribute(u) === "true", this._startTarget.removeAttribute(u), this._startTarget.removeEventListener("dragstart", c));
201
+ }
202
+ releaseInput(e) {
203
+ this._dragGeneration++, this._dragEnd();
204
+ }
205
+ };
206
+ export { f as DragInFromCustomViewStrategy };
@@ -0,0 +1,113 @@
1
+ import { i as e, n as t, o as n, r } from "./utils-DfC2ZLUc.mjs";
2
+ import { l as i, p as a, r as o } from "./drag-in-BwqVwCBp.mjs";
3
+ import { t as s } from "./drag-ghost-BGZWgVa7.mjs";
4
+ var c = class {
5
+ _options = {};
6
+ _instance;
7
+ _mainDomElement;
8
+ _currentDrag = {};
9
+ _firefoxDragPosition = {
10
+ x: 0,
11
+ y: 0
12
+ };
13
+ _onBeforeUpdateDrag = () => ({});
14
+ isDragging = !1;
15
+ _hasEnteredIframe = !1;
16
+ _pendingDragIn = null;
17
+ _canvasBb = null;
18
+ _overlayBb = null;
19
+ _interactionContainerBb = null;
20
+ _currentTouch = null;
21
+ _firefoxFallback = (e) => {
22
+ if (!this._currentDrag.event) return;
23
+ e.preventDefault();
24
+ let t = e || window.event;
25
+ this._firefoxDragPosition.x = t.pageX || 0, this._firefoxDragPosition.y = t.pageY || 0;
26
+ };
27
+ constructor(e, t, n) {
28
+ this._instance = e, this._mainDomElement = t, this._options = n || {}, this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback), this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
29
+ this._instance.cancelDragIn();
30
+ });
31
+ }
32
+ beforeUpdateGhost(e) {
33
+ this._onBeforeUpdateDrag = e;
34
+ }
35
+ async dragStart(n, c, l = "rml_id") {
36
+ let u = this._mainDomElement.parentNode;
37
+ if (r(u).position !== "relative") return;
38
+ this._mainDomElement.style.pointerEvents = "none";
39
+ let d = u.querySelector("." + a);
40
+ d || (d = document.createElement("div"), d.classList.add(a), u.appendChild(d)), d.classList.remove(o.DISPLAY_NONE), c.target.getAttribute("draggable");
41
+ let f = u.querySelector("." + i);
42
+ this._currentDrag.event = c;
43
+ let p = c.target, m = p.cloneNode(!0), h = p.getBoundingClientRect();
44
+ m.style.width = `${h.width}px`, m.style.height = `${h.height}px`, this._currentDrag.ghost = new s(m), this._currentDrag.offset || (this._currentDrag.offset = {
45
+ x: 0,
46
+ y: 0
47
+ });
48
+ let { clientX: g, clientY: _ } = t(c, this._firefoxDragPosition);
49
+ this._currentDrag.offset.x = g - h.left, this._currentDrag.offset.y = _ - h.top, c instanceof DragEvent && c.dataTransfer && c.dataTransfer.setDragImage && c.dataTransfer.setDragImage(f, 0, 0), e(u, this._currentDrag.event || c, this._firefoxDragPosition), this._pendingDragIn = {
50
+ id: n,
51
+ type: l
52
+ }, this._hasEnteredIframe = !1, this.isDragging = !0, this._interactionContainerBb = (await this._instance.getDrawerBoundingClientRect()).final;
53
+ }
54
+ dragUpdate(r) {
55
+ let i = this._mainDomElement.parentNode, { x: a, y: o } = e(i, r, this._firefoxDragPosition);
56
+ if (a === 0 && o === 0) return;
57
+ let s = Math.max(1, a), c = Math.max(1, o);
58
+ if (s === 1 && c === 1) return;
59
+ let l = this._mainDomElement.getBoundingClientRect(), { clientX: u, clientY: d } = t(r, this._firefoxDragPosition), f = u >= l.left && u <= l.right && d >= l.top && d <= l.bottom, p = () => {
60
+ if (!(u >= l.left && u <= l.right && d >= l.top && d <= l.bottom)) return !1;
61
+ if (this._interactionContainerBb) {
62
+ let e = {
63
+ left: this._interactionContainerBb.left + l.left,
64
+ top: this._interactionContainerBb.top + l.top,
65
+ right: this._interactionContainerBb.right + l.left,
66
+ bottom: this._interactionContainerBb.bottom + l.top
67
+ };
68
+ return !(u >= e.left && u <= e.right && d >= e.top && d <= e.bottom);
69
+ }
70
+ return !0;
71
+ };
72
+ if (f && this._pendingDragIn) {
73
+ let e = p();
74
+ e && !this._hasEnteredIframe ? (this._instance.dragInObject(this._pendingDragIn.id, s, c, this._pendingDragIn.type), this._hasEnteredIframe = !0) : !e && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
75
+ } else !f && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
76
+ let m = s, h = c;
77
+ if (n(r)) {
78
+ let e = this._options.settings?.fingerSize || 0;
79
+ m = Math.max(2, s + e), h = Math.max(2, c - e);
80
+ }
81
+ let { x: g, y: _, options: v } = this._onBeforeUpdateDrag(m, h, {}), y = v || {
82
+ settings: {},
83
+ ghost: {}
84
+ };
85
+ if (y.ghost ||= {}, y.ghost.visibleIn && y.ghost.hiddenIn || (y.ghost.hiddenIn = l), this._currentDrag.ghost && this._currentDrag.ghost.updateDragGhost(u, d, y), !this._hasEnteredIframe) return;
86
+ let b = typeof g == "number" ? g : m, x = typeof _ == "number" ? _ : h;
87
+ this._instance.updateDrag(b, x, {});
88
+ }
89
+ dragEnd() {
90
+ this._mainDomElement.style.pointerEvents = "all";
91
+ let e = this._mainDomElement.parentNode;
92
+ this.isDragging = !1, this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = {
93
+ x: 0,
94
+ y: 0
95
+ }, this._hasEnteredIframe = !1, this._pendingDragIn = null, this._interactionContainerBb = null;
96
+ let t = e.querySelector("." + a);
97
+ t && t.classList.add(o.DISPLAY_NONE);
98
+ }
99
+ touchStart(e, t, n = "rml_id") {
100
+ t.preventDefault(), this.dragStart(e, t, n);
101
+ }
102
+ touchMove(e) {
103
+ this._currentTouch && this._currentTouch.onMove(e), this._currentDrag.event && this.dragUpdate(e);
104
+ }
105
+ touchEnd() {
106
+ this.dragEnd();
107
+ }
108
+ dispose() {
109
+ document.removeEventListener("dragover", this._firefoxFallback);
110
+ }
111
+ releaseInput(e) {}
112
+ };
113
+ export { c as DragInFromWebsiteStrategy };
@@ -0,0 +1,118 @@
1
+ import { i as e, n as t, o as n, r } from "./utils-BnWKaFPc.mjs";
2
+ import { l as i, p as a, r as o } from "./drag-in-AFSAsnAN.mjs";
3
+ import { t as s } from "./drag-ghost-DGgvJ4Lm.mjs";
4
+ //#region packages/embedding-lib/src/plugins/strategy/from-website.ts
5
+ var c = class {
6
+ _options = {};
7
+ _instance;
8
+ _mainDomElement;
9
+ _currentDrag = {};
10
+ _firefoxDragPosition = {
11
+ x: 0,
12
+ y: 0
13
+ };
14
+ _onBeforeUpdateDrag = () => ({});
15
+ isDragging = !1;
16
+ _hasEnteredIframe = !1;
17
+ _pendingDragIn = null;
18
+ _canvasBb = null;
19
+ _overlayBb = null;
20
+ _interactionContainerBb = null;
21
+ _currentTouch = null;
22
+ _firefoxFallback = (e) => {
23
+ if (!this._currentDrag.event) return;
24
+ e.preventDefault();
25
+ let t = e || window.event;
26
+ this._firefoxDragPosition.x = t.pageX || 0, this._firefoxDragPosition.y = t.pageY || 0;
27
+ };
28
+ constructor(e, t, n) {
29
+ this._instance = e, this._mainDomElement = t, this._options = n || {}, this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback), this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
30
+ this._instance.cancelDragIn();
31
+ });
32
+ }
33
+ beforeUpdateGhost(e) {
34
+ this._onBeforeUpdateDrag = e;
35
+ }
36
+ async dragStart(n, c, l = "rml_id") {
37
+ let u = this._mainDomElement.parentNode;
38
+ if (r(u).position !== "relative") {
39
+ console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");
40
+ return;
41
+ }
42
+ this._mainDomElement.style.pointerEvents = "none";
43
+ let d = u.querySelector("." + a);
44
+ d || (d = document.createElement("div"), d.classList.add(a), u.appendChild(d)), d.classList.remove(o.DISPLAY_NONE), c.target.getAttribute("draggable") || console.warn("Draggable not detected correctly! Did you add draggable=\"true\" to the element? In Sarafi only 'draggable' is too less");
45
+ let f = u.querySelector("." + i);
46
+ this._currentDrag.event = c;
47
+ let p = c.target, m = p.cloneNode(!0), h = p.getBoundingClientRect();
48
+ m.style.width = `${h.width}px`, m.style.height = `${h.height}px`, this._currentDrag.ghost = new s(m), this._currentDrag.offset || (this._currentDrag.offset = {
49
+ x: 0,
50
+ y: 0
51
+ });
52
+ let { clientX: g, clientY: _ } = t(c, this._firefoxDragPosition);
53
+ this._currentDrag.offset.x = g - h.left, this._currentDrag.offset.y = _ - h.top, c instanceof DragEvent && c.dataTransfer && c.dataTransfer.setDragImage && c.dataTransfer.setDragImage(f, 0, 0), e(u, this._currentDrag.event || c, this._firefoxDragPosition), this._pendingDragIn = {
54
+ id: n,
55
+ type: l
56
+ }, this._hasEnteredIframe = !1, this.isDragging = !0, this._interactionContainerBb = (await this._instance.getDrawerBoundingClientRect()).final;
57
+ }
58
+ dragUpdate(r) {
59
+ let i = this._mainDomElement.parentNode, { x: a, y: o } = e(i, r, this._firefoxDragPosition);
60
+ if (a === 0 && o === 0) return;
61
+ let s = Math.max(1, a), c = Math.max(1, o);
62
+ if (s === 1 && c === 1) return;
63
+ let l = this._mainDomElement.getBoundingClientRect(), { clientX: u, clientY: d } = t(r, this._firefoxDragPosition), f = u >= l.left && u <= l.right && d >= l.top && d <= l.bottom, p = () => {
64
+ if (!(u >= l.left && u <= l.right && d >= l.top && d <= l.bottom)) return !1;
65
+ if (this._interactionContainerBb) {
66
+ let e = {
67
+ left: this._interactionContainerBb.left + l.left,
68
+ top: this._interactionContainerBb.top + l.top,
69
+ right: this._interactionContainerBb.right + l.left,
70
+ bottom: this._interactionContainerBb.bottom + l.top
71
+ };
72
+ return !(u >= e.left && u <= e.right && d >= e.top && d <= e.bottom);
73
+ }
74
+ return !0;
75
+ };
76
+ if (f && this._pendingDragIn) {
77
+ let e = p();
78
+ e && !this._hasEnteredIframe ? (this._instance.dragInObject(this._pendingDragIn.id, s, c, this._pendingDragIn.type), this._hasEnteredIframe = !0) : !e && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
79
+ } else !f && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
80
+ let m = s, h = c;
81
+ if (n(r)) {
82
+ let e = this._options.settings?.fingerSize || 0;
83
+ m = Math.max(2, s + e), h = Math.max(2, c - e);
84
+ }
85
+ let { x: g, y: _, options: v } = this._onBeforeUpdateDrag(m, h, {}), y = v || {
86
+ settings: {},
87
+ ghost: {}
88
+ };
89
+ if (y.ghost ||= {}, y.ghost.visibleIn && y.ghost.hiddenIn || (y.ghost.hiddenIn = l), this._currentDrag.ghost && this._currentDrag.ghost.updateDragGhost(u, d, y), !this._hasEnteredIframe) return;
90
+ let b = typeof g == "number" ? g : m, x = typeof _ == "number" ? _ : h;
91
+ this._instance.updateDrag(b, x, {});
92
+ }
93
+ dragEnd() {
94
+ this._mainDomElement.style.pointerEvents = "all";
95
+ let e = this._mainDomElement.parentNode;
96
+ this.isDragging = !1, this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = {
97
+ x: 0,
98
+ y: 0
99
+ }, this._hasEnteredIframe = !1, this._pendingDragIn = null, this._interactionContainerBb = null;
100
+ let t = e.querySelector("." + a);
101
+ t && t.classList.add(o.DISPLAY_NONE);
102
+ }
103
+ touchStart(e, t, n = "rml_id") {
104
+ t.preventDefault(), this.dragStart(e, t, n);
105
+ }
106
+ touchMove(e) {
107
+ this._currentTouch && this._currentTouch.onMove(e), this._currentDrag.event && this.dragUpdate(e);
108
+ }
109
+ touchEnd() {
110
+ this.dragEnd();
111
+ }
112
+ dispose() {
113
+ document.removeEventListener("dragover", this._firefoxFallback);
114
+ }
115
+ releaseInput(e) {}
116
+ };
117
+ //#endregion
118
+ export { c as DragInFromWebsiteStrategy };