react-sync-board 1.3.0 → 1.3.1
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.
package/dist/react-sync-board.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import e, { memo as t, useCallback as n, useContext as r
|
|
1
|
+
import e, { memo as t, useCallback as n, useContext as r } from "react";
|
|
2
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
import { createStore as s } from "zustand";
|
|
4
|
+
import { useStoreWithEqualityFn as c } from "zustand/traditional";
|
|
5
|
+
import { shallow as l } from "zustand/shallow";
|
|
6
|
+
import { useDebouncedCallback as u, useDebouncedEffect as d, useEventListener as f, useResizeObserver as p } from "@react-hookz/web";
|
|
2
7
|
//#region \0rolldown/runtime.js
|
|
3
|
-
var
|
|
4
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
8
|
+
var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescriptor, _ = Object.getOwnPropertyNames, v = Object.getPrototypeOf, y = Object.prototype.hasOwnProperty, b = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), x = (e, t, n, r) => {
|
|
9
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = _(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !y.call(e, s) && s !== n && h(e, s, {
|
|
5
10
|
get: ((e) => t[e]).bind(null, s),
|
|
6
|
-
enumerable: !(r =
|
|
11
|
+
enumerable: !(r = g(t, s)) || r.enumerable
|
|
7
12
|
});
|
|
8
13
|
return e;
|
|
9
|
-
},
|
|
14
|
+
}, S = (e, t, n) => (n = e == null ? {} : m(v(e)), x(t || !e || !e.__esModule || !y.call(e, "default") ? h(n, "default", {
|
|
10
15
|
value: e,
|
|
11
16
|
enumerable: !0
|
|
12
|
-
}) : n, e)),
|
|
13
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
14
|
-
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
15
|
-
}), _ = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((e, t) => (t &= 63, e += t < 36 ? t.toString(36) : t < 62 ? (t - 26).toString(36).toUpperCase() : t > 62 ? "-" : "_", e), ""), v = class {
|
|
17
|
+
}) : n, e)), C = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((e, t) => (t &= 63, e += t < 36 ? t.toString(36) : t < 62 ? (t - 26).toString(36).toUpperCase() : t > 62 ? "-" : "_", e), ""), w = class {
|
|
16
18
|
constructor(e, t, n = null) {
|
|
17
19
|
this._socket = e, this.userId = n, this.room = t, this.toUnregister = [() => {
|
|
18
20
|
this._socket.off(`${this.room}.isMaster`), this._socket.off(`${this.room}.roomJoined`), this._socket.off(`${this.room}._call`);
|
|
@@ -26,7 +28,7 @@ var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescr
|
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
async _callServerRPC(e, t) {
|
|
29
|
-
let n =
|
|
31
|
+
let n = C();
|
|
30
32
|
return new Promise((r, i) => {
|
|
31
33
|
this._socket.once(`${this.room}._result.${n}`, (e) => {
|
|
32
34
|
e.hasOwnProperty("ok") ? r(e.ok) : i(e.err);
|
|
@@ -72,8 +74,8 @@ var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescr
|
|
|
72
74
|
params: t
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
|
-
},
|
|
76
|
-
let a = new
|
|
77
|
+
}, T = ({ socket: e, room: t, onJoined: n = () => {}, onMaster: r = () => {}, userId: i = null }) => {
|
|
78
|
+
let a = new w(e, t, i);
|
|
77
79
|
return new Promise((o) => {
|
|
78
80
|
let s = !0;
|
|
79
81
|
e.on(`${t}.isMaster`, () => {
|
|
@@ -90,198 +92,7 @@ var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescr
|
|
|
90
92
|
userId: i
|
|
91
93
|
});
|
|
92
94
|
});
|
|
93
|
-
},
|
|
94
|
-
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
95
|
-
function r(e, n, r) {
|
|
96
|
-
var i = null;
|
|
97
|
-
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
98
|
-
else r = n;
|
|
99
|
-
return n = r.ref, {
|
|
100
|
-
$$typeof: t,
|
|
101
|
-
type: e,
|
|
102
|
-
key: i,
|
|
103
|
-
ref: n === void 0 ? null : n,
|
|
104
|
-
props: r
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
108
|
-
})), x = /* @__PURE__ */ p(((e) => {
|
|
109
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
110
|
-
function t(e) {
|
|
111
|
-
if (e == null) return null;
|
|
112
|
-
if (typeof e == "function") return e.$$typeof === te ? null : e.displayName || e.name || null;
|
|
113
|
-
if (typeof e == "string") return e;
|
|
114
|
-
switch (e) {
|
|
115
|
-
case v: return "Fragment";
|
|
116
|
-
case b: return "Profiler";
|
|
117
|
-
case y: return "StrictMode";
|
|
118
|
-
case w: return "Suspense";
|
|
119
|
-
case T: return "SuspenseList";
|
|
120
|
-
case O: return "Activity";
|
|
121
|
-
case ee: return "ViewTransition";
|
|
122
|
-
}
|
|
123
|
-
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
124
|
-
case _: return "Portal";
|
|
125
|
-
case S: return e.displayName || "Context";
|
|
126
|
-
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
127
|
-
case C:
|
|
128
|
-
var n = e.render;
|
|
129
|
-
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
130
|
-
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
131
|
-
case D:
|
|
132
|
-
n = e._payload, e = e._init;
|
|
133
|
-
try {
|
|
134
|
-
return t(e(n));
|
|
135
|
-
} catch {}
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
function n(e) {
|
|
140
|
-
return "" + e;
|
|
141
|
-
}
|
|
142
|
-
function r(e) {
|
|
143
|
-
try {
|
|
144
|
-
n(e);
|
|
145
|
-
var t = !1;
|
|
146
|
-
} catch {
|
|
147
|
-
t = !0;
|
|
148
|
-
}
|
|
149
|
-
if (t) {
|
|
150
|
-
t = console;
|
|
151
|
-
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
152
|
-
return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function i(e) {
|
|
156
|
-
if (e === v) return "<>";
|
|
157
|
-
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
158
|
-
try {
|
|
159
|
-
var n = t(e);
|
|
160
|
-
return n ? "<" + n + ">" : "<...>";
|
|
161
|
-
} catch {
|
|
162
|
-
return "<...>";
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function a() {
|
|
166
|
-
var e = k.A;
|
|
167
|
-
return e === null ? null : e.getOwner();
|
|
168
|
-
}
|
|
169
|
-
function o() {
|
|
170
|
-
return Error("react-stack-top-frame");
|
|
171
|
-
}
|
|
172
|
-
function s(e) {
|
|
173
|
-
if (ne.call(e, "key")) {
|
|
174
|
-
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
175
|
-
if (t && t.isReactWarning) return !1;
|
|
176
|
-
}
|
|
177
|
-
return e.key !== void 0;
|
|
178
|
-
}
|
|
179
|
-
function c(e, t) {
|
|
180
|
-
function n() {
|
|
181
|
-
ie || (ie = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
182
|
-
}
|
|
183
|
-
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
184
|
-
get: n,
|
|
185
|
-
configurable: !0
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function l() {
|
|
189
|
-
var e = t(this.type);
|
|
190
|
-
return j[e] || (j[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
191
|
-
}
|
|
192
|
-
function u(e, t, n, r, i, a) {
|
|
193
|
-
var o = n.ref;
|
|
194
|
-
return e = {
|
|
195
|
-
$$typeof: h,
|
|
196
|
-
type: e,
|
|
197
|
-
key: t,
|
|
198
|
-
props: n,
|
|
199
|
-
_owner: r
|
|
200
|
-
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
201
|
-
enumerable: !1,
|
|
202
|
-
value: null
|
|
203
|
-
}) : Object.defineProperty(e, "ref", {
|
|
204
|
-
enumerable: !1,
|
|
205
|
-
get: l
|
|
206
|
-
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
207
|
-
configurable: !1,
|
|
208
|
-
enumerable: !1,
|
|
209
|
-
writable: !0,
|
|
210
|
-
value: 0
|
|
211
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
212
|
-
configurable: !1,
|
|
213
|
-
enumerable: !1,
|
|
214
|
-
writable: !0,
|
|
215
|
-
value: null
|
|
216
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
217
|
-
configurable: !1,
|
|
218
|
-
enumerable: !1,
|
|
219
|
-
writable: !0,
|
|
220
|
-
value: i
|
|
221
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
222
|
-
configurable: !1,
|
|
223
|
-
enumerable: !1,
|
|
224
|
-
writable: !0,
|
|
225
|
-
value: a
|
|
226
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
227
|
-
}
|
|
228
|
-
function d(e, n, i, o, l, d) {
|
|
229
|
-
var p = n.children;
|
|
230
|
-
if (p !== void 0) {
|
|
231
|
-
if (o) {
|
|
232
|
-
if (re(p)) {
|
|
233
|
-
for (o = 0; o < p.length; o++) f(p[o]);
|
|
234
|
-
Object.freeze && Object.freeze(p);
|
|
235
|
-
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
236
|
-
} else f(p);
|
|
237
|
-
}
|
|
238
|
-
if (ne.call(n, "key")) {
|
|
239
|
-
p = t(e);
|
|
240
|
-
var m = Object.keys(n).filter(function(e) {
|
|
241
|
-
return e !== "key";
|
|
242
|
-
});
|
|
243
|
-
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", P[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), P[p + o] = !0);
|
|
244
|
-
}
|
|
245
|
-
if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
246
|
-
else i = n;
|
|
247
|
-
return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
|
|
248
|
-
}
|
|
249
|
-
function f(e) {
|
|
250
|
-
p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
251
|
-
}
|
|
252
|
-
function p(e) {
|
|
253
|
-
return typeof e == "object" && !!e && e.$$typeof === h;
|
|
254
|
-
}
|
|
255
|
-
var m = g("react"), h = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), ee = Symbol.for("react.view_transition"), te = Symbol.for("react.client.reference"), k = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ne = Object.prototype.hasOwnProperty, re = Array.isArray, A = console.createTask ? console.createTask : function() {
|
|
256
|
-
return null;
|
|
257
|
-
};
|
|
258
|
-
m = { react_stack_bottom_frame: function(e) {
|
|
259
|
-
return e();
|
|
260
|
-
} };
|
|
261
|
-
var ie, j = {}, M = m.react_stack_bottom_frame.bind(m, o)(), N = A(i(o)), P = {};
|
|
262
|
-
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
263
|
-
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
264
|
-
if (r) {
|
|
265
|
-
var a = Error.stackTraceLimit;
|
|
266
|
-
Error.stackTraceLimit = 10;
|
|
267
|
-
var o = Error("react-stack-top-frame");
|
|
268
|
-
Error.stackTraceLimit = a;
|
|
269
|
-
} else o = M;
|
|
270
|
-
return d(e, t, n, !1, o, r ? A(i(e)) : N);
|
|
271
|
-
}, e.jsxs = function(e, t, n) {
|
|
272
|
-
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
273
|
-
if (r) {
|
|
274
|
-
var a = Error.stackTraceLimit;
|
|
275
|
-
Error.stackTraceLimit = 10;
|
|
276
|
-
var o = Error("react-stack-top-frame");
|
|
277
|
-
Error.stackTraceLimit = a;
|
|
278
|
-
} else o = M;
|
|
279
|
-
return d(e, t, n, !0, o, r ? A(i(e)) : N);
|
|
280
|
-
};
|
|
281
|
-
})();
|
|
282
|
-
})), S = (/* @__PURE__ */ p(((e, t) => {
|
|
283
|
-
t.exports = process.env.NODE_ENV === "production" ? b() : x();
|
|
284
|
-
})))(), C = e.createContext(), w = () => /* @__PURE__ */ (0, S.jsx)("div", {
|
|
95
|
+
}, E = e.createContext(), ee = () => /* @__PURE__ */ a("div", {
|
|
285
96
|
style: {
|
|
286
97
|
position: "absolute",
|
|
287
98
|
top: "0",
|
|
@@ -291,275 +102,56 @@ var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescr
|
|
|
291
102
|
justifyContent: "center",
|
|
292
103
|
alignItems: "center"
|
|
293
104
|
},
|
|
294
|
-
children: /* @__PURE__ */ (
|
|
295
|
-
}),
|
|
296
|
-
let [
|
|
297
|
-
return e.useEffect(() => (
|
|
298
|
-
|
|
105
|
+
children: /* @__PURE__ */ a("h2", { children: "🌀 Loading..." })
|
|
106
|
+
}), D = ({ socket: t, room: n, channel: i = "default", LoadingComponent: o = ee, children: s }) => {
|
|
107
|
+
let [c, l] = e.useState(!1), [u, d] = e.useState(!1), [f, p] = e.useState(null), m = e.useRef(null), h = e.useRef(!1), g = r(E), _ = e.useRef(!1);
|
|
108
|
+
return e.useEffect(() => (h.current = !0, () => {
|
|
109
|
+
h.current = !1;
|
|
299
110
|
}), []), e.useEffect(() => {
|
|
300
111
|
if (!t) return null;
|
|
301
112
|
let e = () => {
|
|
302
|
-
console.log(`Disconnected from ${i}…`),
|
|
113
|
+
console.log(`Disconnected from ${i}…`), h.current && (l(!1), d(!1));
|
|
303
114
|
};
|
|
304
115
|
return t.on("disconnect", e), () => {
|
|
305
116
|
t.off("disconnect", e);
|
|
306
117
|
};
|
|
307
|
-
}, [i, t]), e.useEffect(() => t ? (t.connected || t.connect(), console.log(`Try to connect to wire ${n} on channel ${i}`),
|
|
118
|
+
}, [i, t]), e.useEffect(() => t ? (t.connected || t.connect(), console.log(`Try to connect to wire ${n} on channel ${i}`), _.current || (_.current = !0, T({
|
|
308
119
|
socket: t,
|
|
309
120
|
room: n,
|
|
310
121
|
onMaster: () => {
|
|
311
|
-
console.log(`Is now master on channel ${i}…`),
|
|
122
|
+
console.log(`Is now master on channel ${i}…`), h.current && d(!0);
|
|
312
123
|
},
|
|
313
124
|
onJoined: (e) => {
|
|
314
|
-
console.log(`Connected on channel ${i}…`),
|
|
125
|
+
console.log(`Connected on channel ${i}…`), m.current = e, h.current && (p(e), l(!0));
|
|
315
126
|
}
|
|
316
127
|
})), () => {
|
|
317
|
-
|
|
128
|
+
m.current?.leave();
|
|
318
129
|
}) : null, [
|
|
319
130
|
i,
|
|
320
131
|
n,
|
|
321
132
|
t
|
|
322
|
-
]), !
|
|
133
|
+
]), !c || !f ? /* @__PURE__ */ a(o, {}) : /* @__PURE__ */ a(E.Provider, {
|
|
323
134
|
value: {
|
|
324
|
-
...
|
|
135
|
+
...g,
|
|
325
136
|
[i]: {
|
|
326
|
-
wire:
|
|
327
|
-
joined:
|
|
328
|
-
isMaster:
|
|
137
|
+
wire: f,
|
|
138
|
+
joined: c,
|
|
139
|
+
isMaster: u,
|
|
329
140
|
room: n
|
|
330
141
|
}
|
|
331
142
|
},
|
|
332
|
-
children:
|
|
143
|
+
children: s
|
|
333
144
|
});
|
|
334
|
-
},
|
|
335
|
-
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
|
|
336
|
-
let i = typeof e == "function" ? e(t) : e;
|
|
337
|
-
if (!Object.is(i, t)) {
|
|
338
|
-
let e = t;
|
|
339
|
-
t = r ?? (typeof i != "object" || !i) ? i : Object.assign({}, t, i), n.forEach((n) => n(t, e));
|
|
340
|
-
}
|
|
341
|
-
}, i = () => t, a = {
|
|
342
|
-
setState: r,
|
|
343
|
-
getState: i,
|
|
344
|
-
getInitialState: () => o,
|
|
345
|
-
subscribe: (e) => (n.add(e), () => n.delete(e))
|
|
346
|
-
}, o = t = e(r, i, a);
|
|
347
|
-
return a;
|
|
348
|
-
}, O = ((e) => e ? D(e) : D), ee = /* @__PURE__ */ p(((e) => {
|
|
349
|
-
var t = g("react");
|
|
350
|
-
function n(e, t) {
|
|
351
|
-
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
352
|
-
}
|
|
353
|
-
var r = typeof Object.is == "function" ? Object.is : n, i = t.useState, a = t.useEffect, o = t.useLayoutEffect, s = t.useDebugValue;
|
|
354
|
-
function c(e, t) {
|
|
355
|
-
var n = t(), r = i({ inst: {
|
|
356
|
-
value: n,
|
|
357
|
-
getSnapshot: t
|
|
358
|
-
} }), c = r[0].inst, u = r[1];
|
|
359
|
-
return o(function() {
|
|
360
|
-
c.value = n, c.getSnapshot = t, l(c) && u({ inst: c });
|
|
361
|
-
}, [
|
|
362
|
-
e,
|
|
363
|
-
n,
|
|
364
|
-
t
|
|
365
|
-
]), a(function() {
|
|
366
|
-
return l(c) && u({ inst: c }), e(function() {
|
|
367
|
-
l(c) && u({ inst: c });
|
|
368
|
-
});
|
|
369
|
-
}, [e]), s(n), n;
|
|
370
|
-
}
|
|
371
|
-
function l(e) {
|
|
372
|
-
var t = e.getSnapshot;
|
|
373
|
-
e = e.value;
|
|
374
|
-
try {
|
|
375
|
-
var n = t();
|
|
376
|
-
return !r(e, n);
|
|
377
|
-
} catch {
|
|
378
|
-
return !0;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
function u(e, t) {
|
|
382
|
-
return t();
|
|
383
|
-
}
|
|
384
|
-
var d = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? u : c;
|
|
385
|
-
e.useSyncExternalStore = t.useSyncExternalStore === void 0 ? d : t.useSyncExternalStore;
|
|
386
|
-
})), te = /* @__PURE__ */ p(((e) => {
|
|
387
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
388
|
-
function t(e, t) {
|
|
389
|
-
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
390
|
-
}
|
|
391
|
-
function n(e, t) {
|
|
392
|
-
d || a.startTransition === void 0 || (d = !0, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
393
|
-
var n = t();
|
|
394
|
-
if (!f) {
|
|
395
|
-
var i = t();
|
|
396
|
-
o(n, i) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), f = !0);
|
|
397
|
-
}
|
|
398
|
-
i = s({ inst: {
|
|
399
|
-
value: n,
|
|
400
|
-
getSnapshot: t
|
|
401
|
-
} });
|
|
402
|
-
var p = i[0].inst, m = i[1];
|
|
403
|
-
return l(function() {
|
|
404
|
-
p.value = n, p.getSnapshot = t, r(p) && m({ inst: p });
|
|
405
|
-
}, [
|
|
406
|
-
e,
|
|
407
|
-
n,
|
|
408
|
-
t
|
|
409
|
-
]), c(function() {
|
|
410
|
-
return r(p) && m({ inst: p }), e(function() {
|
|
411
|
-
r(p) && m({ inst: p });
|
|
412
|
-
});
|
|
413
|
-
}, [e]), u(n), n;
|
|
414
|
-
}
|
|
415
|
-
function r(e) {
|
|
416
|
-
var t = e.getSnapshot;
|
|
417
|
-
e = e.value;
|
|
418
|
-
try {
|
|
419
|
-
var n = t();
|
|
420
|
-
return !o(e, n);
|
|
421
|
-
} catch {
|
|
422
|
-
return !0;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
function i(e, t) {
|
|
426
|
-
return t();
|
|
427
|
-
}
|
|
428
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
429
|
-
var a = g("react"), o = typeof Object.is == "function" ? Object.is : t, s = a.useState, c = a.useEffect, l = a.useLayoutEffect, u = a.useDebugValue, d = !1, f = !1, p = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? i : n;
|
|
430
|
-
e.useSyncExternalStore = a.useSyncExternalStore === void 0 ? p : a.useSyncExternalStore, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
431
|
-
})();
|
|
432
|
-
})), k = /* @__PURE__ */ p(((e, t) => {
|
|
433
|
-
t.exports = process.env.NODE_ENV === "production" ? ee() : te();
|
|
434
|
-
})), ne = /* @__PURE__ */ p(((e) => {
|
|
435
|
-
var t = g("react"), n = k();
|
|
436
|
-
function r(e, t) {
|
|
437
|
-
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
438
|
-
}
|
|
439
|
-
var i = typeof Object.is == "function" ? Object.is : r, a = n.useSyncExternalStore, o = t.useRef, s = t.useEffect, c = t.useMemo, l = t.useDebugValue;
|
|
440
|
-
e.useSyncExternalStoreWithSelector = function(e, t, n, r, u) {
|
|
441
|
-
var d = o(null);
|
|
442
|
-
if (d.current === null) {
|
|
443
|
-
var f = {
|
|
444
|
-
hasValue: !1,
|
|
445
|
-
value: null
|
|
446
|
-
};
|
|
447
|
-
d.current = f;
|
|
448
|
-
} else f = d.current;
|
|
449
|
-
d = c(function() {
|
|
450
|
-
function e(e) {
|
|
451
|
-
if (!a) {
|
|
452
|
-
if (a = !0, o = e, e = r(e), u !== void 0 && f.hasValue) {
|
|
453
|
-
var t = f.value;
|
|
454
|
-
if (u(t, e)) return s = t;
|
|
455
|
-
}
|
|
456
|
-
return s = e;
|
|
457
|
-
}
|
|
458
|
-
if (t = s, i(o, e)) return t;
|
|
459
|
-
var n = r(e);
|
|
460
|
-
return u !== void 0 && u(t, n) ? (o = e, t) : (o = e, s = n);
|
|
461
|
-
}
|
|
462
|
-
var a = !1, o, s, c = n === void 0 ? null : n;
|
|
463
|
-
return [function() {
|
|
464
|
-
return e(t());
|
|
465
|
-
}, c === null ? void 0 : function() {
|
|
466
|
-
return e(c());
|
|
467
|
-
}];
|
|
468
|
-
}, [
|
|
469
|
-
t,
|
|
470
|
-
n,
|
|
471
|
-
r,
|
|
472
|
-
u
|
|
473
|
-
]);
|
|
474
|
-
var p = a(e, d[0], d[1]);
|
|
475
|
-
return s(function() {
|
|
476
|
-
f.hasValue = !0, f.value = p;
|
|
477
|
-
}, [p]), l(p), p;
|
|
478
|
-
};
|
|
479
|
-
})), re = /* @__PURE__ */ p(((e) => {
|
|
480
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
481
|
-
function t(e, t) {
|
|
482
|
-
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
483
|
-
}
|
|
484
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
485
|
-
var n = g("react"), r = k(), i = typeof Object.is == "function" ? Object.is : t, a = r.useSyncExternalStore, o = n.useRef, s = n.useEffect, c = n.useMemo, l = n.useDebugValue;
|
|
486
|
-
e.useSyncExternalStoreWithSelector = function(e, t, n, r, u) {
|
|
487
|
-
var d = o(null);
|
|
488
|
-
if (d.current === null) {
|
|
489
|
-
var f = {
|
|
490
|
-
hasValue: !1,
|
|
491
|
-
value: null
|
|
492
|
-
};
|
|
493
|
-
d.current = f;
|
|
494
|
-
} else f = d.current;
|
|
495
|
-
d = c(function() {
|
|
496
|
-
function e(e) {
|
|
497
|
-
if (!a) {
|
|
498
|
-
if (a = !0, o = e, e = r(e), u !== void 0 && f.hasValue) {
|
|
499
|
-
var t = f.value;
|
|
500
|
-
if (u(t, e)) return s = t;
|
|
501
|
-
}
|
|
502
|
-
return s = e;
|
|
503
|
-
}
|
|
504
|
-
if (t = s, i(o, e)) return t;
|
|
505
|
-
var n = r(e);
|
|
506
|
-
return u !== void 0 && u(t, n) ? (o = e, t) : (o = e, s = n);
|
|
507
|
-
}
|
|
508
|
-
var a = !1, o, s, c = n === void 0 ? null : n;
|
|
509
|
-
return [function() {
|
|
510
|
-
return e(t());
|
|
511
|
-
}, c === null ? void 0 : function() {
|
|
512
|
-
return e(c());
|
|
513
|
-
}];
|
|
514
|
-
}, [
|
|
515
|
-
t,
|
|
516
|
-
n,
|
|
517
|
-
r,
|
|
518
|
-
u
|
|
519
|
-
]);
|
|
520
|
-
var p = a(e, d[0], d[1]);
|
|
521
|
-
return s(function() {
|
|
522
|
-
f.hasValue = !0, f.value = p;
|
|
523
|
-
}, [p]), l(p), p;
|
|
524
|
-
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
525
|
-
})();
|
|
526
|
-
})), { useSyncExternalStoreWithSelector: A } = (/* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
527
|
-
t.exports = process.env.NODE_ENV === "production" ? ne() : re();
|
|
528
|
-
})))(), 1)).default, ie = (e) => e;
|
|
529
|
-
function j(t, n = ie, r) {
|
|
530
|
-
let i = A(t.subscribe, t.getState, t.getInitialState, n, r);
|
|
531
|
-
return e.useDebugValue(i), i;
|
|
532
|
-
}
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region node_modules/zustand/esm/vanilla/shallow.mjs
|
|
535
|
-
var M = (e) => Symbol.iterator in e, N = (e) => "entries" in e, P = (e, t) => {
|
|
536
|
-
let n = e instanceof Map ? e : new Map(e.entries()), r = t instanceof Map ? t : new Map(t.entries());
|
|
537
|
-
if (n.size !== r.size) return !1;
|
|
538
|
-
for (let [e, t] of n) if (!r.has(e) || !Object.is(t, r.get(e))) return !1;
|
|
539
|
-
return !0;
|
|
540
|
-
}, ae = (e, t) => {
|
|
541
|
-
let n = e[Symbol.iterator](), r = t[Symbol.iterator](), i = n.next(), a = r.next();
|
|
542
|
-
for (; !i.done && !a.done;) {
|
|
543
|
-
if (!Object.is(i.value, a.value)) return !1;
|
|
544
|
-
i = n.next(), a = r.next();
|
|
545
|
-
}
|
|
546
|
-
return !!i.done && !!a.done;
|
|
547
|
-
};
|
|
548
|
-
function oe(e, t) {
|
|
549
|
-
return Object.is(e, t) ? !0 : typeof e != "object" || !e || typeof t != "object" || !t || Object.getPrototypeOf(e) !== Object.getPrototypeOf(t) ? !1 : M(e) && M(t) ? N(e) && N(t) ? P(e, t) : ae(e, t) : P({ entries: () => Object.entries(e) }, { entries: () => Object.entries(t) });
|
|
550
|
-
}
|
|
551
|
-
//#endregion
|
|
552
|
-
//#region src/lib/utils.js
|
|
553
|
-
var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t) ? e : e.parentNode ? I(e.parentNode, t) : !1, se = ([e, t], [n, r]) => {
|
|
145
|
+
}, O = (e = "default") => (r(E) || {})[e], k = (e, t) => e.classList && e.classList.contains(t), A = (e, t) => k(e, t) ? e : e.parentNode ? A(e.parentNode, t) : !1, j = ([e, t], [n, r]) => {
|
|
554
146
|
let i = Math.abs(e - n), a = Math.abs(t - r);
|
|
555
147
|
return Math.hypot(i, a);
|
|
556
|
-
},
|
|
148
|
+
}, te = (e, t, n) => {
|
|
557
149
|
let r = n * Math.PI / 180;
|
|
558
150
|
return [e * Math.cos(r) - t * Math.sin(r), e * Math.sin(r) + t * Math.cos(r)];
|
|
559
|
-
},
|
|
560
|
-
let [o, s] =
|
|
151
|
+
}, ne = ([e, t], { scale: n, rotate: r, translateX: i, translateY: a }) => te((e - i) / n, (t - a) / n, -r), M = ([e, t], { scale: n, rotate: r, translateX: i, translateY: a }) => {
|
|
152
|
+
let [o, s] = te(e, t, r);
|
|
561
153
|
return [o * n + i, s * n + a];
|
|
562
|
-
},
|
|
154
|
+
}, re = (e, t, n, r) => {
|
|
563
155
|
let i = e.x, a = e.y, o = t.x, s = t.y, c = n.x, l = n.y, u = o - i, d = s - a, f = i - c, p = a - l, m = u * u + d * d, h = 2 * (f * u + p * d), g = f * f + p * p - r * r, _ = h * h - 4 * m * g;
|
|
564
156
|
if (_ < 0) return [];
|
|
565
157
|
let v = (-h + Math.sqrt(_)) / (2 * m), y = (-h - Math.sqrt(_)) / (2 * m), b = [];
|
|
@@ -570,25 +162,25 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
570
162
|
x: i + y * u,
|
|
571
163
|
y: a + y * d
|
|
572
164
|
}), b;
|
|
573
|
-
},
|
|
165
|
+
}, N = (e, t) => e.x > t.left && e.x < t.left + t.width && e.y > t.top && e.y < t.top + t.height, ie = (e, t) => Array.from(e.querySelectorAll(".corner")).every((e) => {
|
|
574
166
|
let { top: n, left: r } = e.getBoundingClientRect();
|
|
575
|
-
return
|
|
167
|
+
return N({
|
|
576
168
|
x: r,
|
|
577
169
|
y: n
|
|
578
170
|
}, t);
|
|
579
|
-
}),
|
|
171
|
+
}), ae = (e, t) => ie(e, t.getBoundingClientRect()), P = (e, t) => {
|
|
580
172
|
try {
|
|
581
173
|
return document.getElementById(`${e}__${t}`);
|
|
582
174
|
} catch {
|
|
583
175
|
console.error(`Error while getting item with id ${t} inside wrapper`, e);
|
|
584
176
|
return;
|
|
585
177
|
}
|
|
586
|
-
},
|
|
178
|
+
}, F = (e) => {
|
|
587
179
|
let t = e?.dataset?.id;
|
|
588
180
|
return t || console.error("getIdFromElem call fails", e, JSON.stringify(e?.dataset), e?.dataset?.id), t;
|
|
589
|
-
},
|
|
181
|
+
}, oe = (e, t) => {
|
|
590
182
|
let n = e.reduce((e, n) => {
|
|
591
|
-
let r =
|
|
183
|
+
let r = P(t, n);
|
|
592
184
|
if (!r) return e || null;
|
|
593
185
|
let { left: i, right: a, top: o, bottom: s } = r.getBoundingClientRect(), c;
|
|
594
186
|
return c = e || {
|
|
@@ -599,10 +191,10 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
599
191
|
}, c.left = Math.min(i, c.left), c.top = Math.min(o, c.top), c.right = Math.max(a, c.right), c.bottom = Math.max(s, c.bottom), c;
|
|
600
192
|
}, null);
|
|
601
193
|
return n && (n.width = n.right - n.left, n.height = n.bottom - n.top, n);
|
|
602
|
-
},
|
|
603
|
-
let r = new Set(
|
|
194
|
+
}, se = (e, t, n = null) => (n === null && (n = /* @__PURE__ */ new Set()), !Array.isArray(t) || t.length === 0 ? [] : t.map((t) => n.has(t) ? [] : (n.add(t), e[t] ? [t, ...se(e, e[t].linkedItems, n)] : [])).flat()), ce = (e, t, n) => {
|
|
195
|
+
let r = new Set(se(e, n));
|
|
604
196
|
return t.filter((e) => r.has(e));
|
|
605
|
-
},
|
|
197
|
+
}, le = ({ x: e, y: t, width: n, height: r }, { type: i = "grid", size: a = 1, offset: o = {
|
|
606
198
|
x: 0,
|
|
607
199
|
y: 0
|
|
608
200
|
} }) => {
|
|
@@ -623,7 +215,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
623
215
|
x: l + o.x - n / 2,
|
|
624
216
|
y: u + o.y - r / 2
|
|
625
217
|
};
|
|
626
|
-
},
|
|
218
|
+
}, ue = /* @__PURE__ */ "#037758.#99092a.#067070.#c6650f.#008726.#3d7004.#348402.#057f58.#b58612.#c44c01.#0a7704.#0e910e.#027377.#c99e02.#054160.#157a01.#b10de2.#0d6289.#bc5d03.#ba0cd1.#d39f10.#0c4c7a.#460782.#a51f10.#cecb10.#9b0943.#607f0c.#007a4b.#bf0daa.#af0ad8".split("."), de = () => ue[Math.floor(Math.random() * ue.length)], fe = ({ wire: e, storeName: t, noSync: n = [], defaultValue: r }, i) => (a, o, s) => {
|
|
627
219
|
a({ ready: !1 });
|
|
628
220
|
let c = [];
|
|
629
221
|
(async () => {
|
|
@@ -647,7 +239,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
647
239
|
return d.unsub = () => {
|
|
648
240
|
c.forEach((e) => e());
|
|
649
241
|
}, d;
|
|
650
|
-
},
|
|
242
|
+
}, pe = e.createContext(), me = (e, t) => ({
|
|
651
243
|
items: {},
|
|
652
244
|
getItems: () => t().items,
|
|
653
245
|
setItems: (t) => e({ items: t }),
|
|
@@ -670,7 +262,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
670
262
|
});
|
|
671
263
|
}), { items: r };
|
|
672
264
|
})
|
|
673
|
-
}),
|
|
265
|
+
}), he = (e, t) => ({
|
|
674
266
|
itemIds: [],
|
|
675
267
|
setItemIds: (t) => e({ itemIds: t }),
|
|
676
268
|
getItemIds: () => t().itemIds,
|
|
@@ -687,7 +279,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
687
279
|
return r[t] = n, { itemIds: r };
|
|
688
280
|
}),
|
|
689
281
|
updateManyItemIds: (t) => e((e) => ({ itemIds: e.itemIds.map((e, n) => t[n] === void 0 ? e : t[n]) }))
|
|
690
|
-
}),
|
|
282
|
+
}), ge = (e, t) => ({
|
|
691
283
|
removeItemsById: (t) => e((e) => ({
|
|
692
284
|
itemIds: e.itemIds.filter((e) => !t.includes(e)),
|
|
693
285
|
items: Object.fromEntries(Object.entries(e.items).filter(([e]) => !t.includes(e)))
|
|
@@ -714,7 +306,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
714
306
|
itemIds: r
|
|
715
307
|
};
|
|
716
308
|
})
|
|
717
|
-
}),
|
|
309
|
+
}), _e = (e, t) => ({
|
|
718
310
|
boardConfig: {},
|
|
719
311
|
getBoardConfig: () => t().boardConfig,
|
|
720
312
|
setBoardConfig: (t) => e({ boardConfig: t }),
|
|
@@ -722,7 +314,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
722
314
|
...e.boardConfig,
|
|
723
315
|
...t
|
|
724
316
|
} }))
|
|
725
|
-
}),
|
|
317
|
+
}), ve = (e, t) => ({
|
|
726
318
|
session: {},
|
|
727
319
|
getSessionInfo: () => t().session,
|
|
728
320
|
setSessionInfo: (t) => e({ session: t }),
|
|
@@ -730,31 +322,34 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
730
322
|
...e.session,
|
|
731
323
|
...t
|
|
732
324
|
} }))
|
|
733
|
-
}),
|
|
734
|
-
let { wire: i } =
|
|
325
|
+
}), ye = ({ storeName: t, children: n, defaultValue: r }) => {
|
|
326
|
+
let { wire: i } = O("room"), [o, c] = e.useState(!1), [l] = e.useState(() => s(fe({
|
|
735
327
|
wire: i,
|
|
736
328
|
storeName: t,
|
|
737
329
|
defaultValue: r
|
|
738
330
|
}, (...e) => ({
|
|
739
|
-
...
|
|
740
|
-
...
|
|
741
|
-
...
|
|
742
|
-
...
|
|
743
|
-
...
|
|
331
|
+
...me(...e),
|
|
332
|
+
...he(...e),
|
|
333
|
+
...ge(...e),
|
|
334
|
+
..._e(...e),
|
|
335
|
+
...ve(...e)
|
|
744
336
|
}))));
|
|
745
337
|
return e.useEffect(() => {
|
|
746
|
-
let e =
|
|
747
|
-
t.ready && (e(),
|
|
338
|
+
let e = l.subscribe((t) => {
|
|
339
|
+
t.ready && (e(), c(!0));
|
|
748
340
|
});
|
|
749
|
-
}, [
|
|
750
|
-
value:
|
|
341
|
+
}, [l]), o ? /* @__PURE__ */ a(pe.Provider, {
|
|
342
|
+
value: l,
|
|
751
343
|
children: n
|
|
752
344
|
}) : null;
|
|
753
|
-
},
|
|
754
|
-
let
|
|
345
|
+
}, I = (e) => {
|
|
346
|
+
let t = r(pe);
|
|
347
|
+
return c(t, e, l);
|
|
348
|
+
}, be = () => {
|
|
349
|
+
let [t, n] = I((e) => [e.itemIds, e.items]);
|
|
755
350
|
return e.useMemo(() => t.map((e) => n[e]), [t, n]);
|
|
756
|
-
},
|
|
757
|
-
let [t, n, r] =
|
|
351
|
+
}, xe = () => {
|
|
352
|
+
let [t, n, r] = I((e) => [
|
|
758
353
|
e.items,
|
|
759
354
|
e.itemIds,
|
|
760
355
|
e.getItemList
|
|
@@ -769,7 +364,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
769
364
|
n,
|
|
770
365
|
r
|
|
771
366
|
]), i;
|
|
772
|
-
},
|
|
367
|
+
}, Se = 5e4, Ce = e.createContext(), we = (e, t) => ({
|
|
773
368
|
config: {
|
|
774
369
|
itemTemplates: {},
|
|
775
370
|
actions: {},
|
|
@@ -780,14 +375,14 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
780
375
|
radius: 0
|
|
781
376
|
},
|
|
782
377
|
boardWrapperRect: {},
|
|
783
|
-
boardSize:
|
|
378
|
+
boardSize: Se
|
|
784
379
|
},
|
|
785
380
|
updateConfiguration: (t) => e((e) => ({ config: {
|
|
786
381
|
...e.config,
|
|
787
382
|
...t
|
|
788
383
|
} })),
|
|
789
384
|
getConfiguration: () => t().config
|
|
790
|
-
}),
|
|
385
|
+
}), Te = (e, t) => ({
|
|
791
386
|
boardState: {
|
|
792
387
|
movingItems: !1,
|
|
793
388
|
selecting: !1,
|
|
@@ -803,7 +398,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
803
398
|
...t
|
|
804
399
|
} })),
|
|
805
400
|
getBoardState: () => t().boardState
|
|
806
|
-
}),
|
|
401
|
+
}), Ee = (e, t) => ({
|
|
807
402
|
interactions: {},
|
|
808
403
|
getInteractions: () => t().interactions,
|
|
809
404
|
register: (t, n) => e((e) => {
|
|
@@ -825,7 +420,7 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
825
420
|
setTimeout(() => e(n), 0);
|
|
826
421
|
});
|
|
827
422
|
}
|
|
828
|
-
}),
|
|
423
|
+
}), De = (e, t) => ({
|
|
829
424
|
selection: [],
|
|
830
425
|
setSelection: (t) => e((e) => JSON.stringify(e.selection) === JSON.stringify(t) ? {} : { selection: t }),
|
|
831
426
|
getSelection: () => t().selection,
|
|
@@ -841,156 +436,28 @@ var F = (e, t) => e.classList && e.classList.contains(t), I = (e, t) => F(e, t)
|
|
|
841
436
|
let n = e.selectionBox;
|
|
842
437
|
return !n || !t || n.top !== t.top || n.left !== t.left || n.width !== t.width || n.height !== t.height ? { selectionBox: t } : {};
|
|
843
438
|
})
|
|
844
|
-
}),
|
|
845
|
-
let [n] = e.useState(() =>
|
|
846
|
-
...
|
|
847
|
-
...
|
|
848
|
-
...
|
|
849
|
-
...
|
|
439
|
+
}), Oe = ({ children: t }) => {
|
|
440
|
+
let [n] = e.useState(() => s((...e) => ({
|
|
441
|
+
...we(...e),
|
|
442
|
+
...Te(...e),
|
|
443
|
+
...Ee(...e),
|
|
444
|
+
...De(...e)
|
|
850
445
|
})));
|
|
851
|
-
return /* @__PURE__ */ (
|
|
446
|
+
return /* @__PURE__ */ a(Ce.Provider, {
|
|
852
447
|
value: n,
|
|
853
448
|
children: t
|
|
854
449
|
});
|
|
855
|
-
},
|
|
856
|
-
let
|
|
450
|
+
}, L = (e) => {
|
|
451
|
+
let t = r(Ce);
|
|
452
|
+
return c(t, e, l);
|
|
453
|
+
}, ke = () => {
|
|
454
|
+
let [e] = L((e) => [e.selection]);
|
|
857
455
|
return e;
|
|
858
|
-
},
|
|
859
|
-
let [e] =
|
|
456
|
+
}, Ae = () => {
|
|
457
|
+
let [e] = L((e) => [e.getSelection]);
|
|
860
458
|
return e;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
//#region node_modules/@react-hookz/web/dist/useSyncedRef/index.js
|
|
864
|
-
function ze(e) {
|
|
865
|
-
let t = o(e);
|
|
866
|
-
return t.current = e, a(() => Object.freeze({ get current() {
|
|
867
|
-
return t.current;
|
|
868
|
-
} }), []);
|
|
869
|
-
}
|
|
870
|
-
//#endregion
|
|
871
|
-
//#region node_modules/@react-hookz/web/dist/useUnmountEffect/index.js
|
|
872
|
-
function Be(e) {
|
|
873
|
-
let t = ze(e);
|
|
874
|
-
i(() => () => {
|
|
875
|
-
t.current();
|
|
876
|
-
}, []);
|
|
877
|
-
}
|
|
878
|
-
//#endregion
|
|
879
|
-
//#region node_modules/@react-hookz/web/dist/useDebouncedCallback/index.js
|
|
880
|
-
function Ve(e, t, n, r = 0) {
|
|
881
|
-
let s = o(void 0), c = o(void 0), l = o(e), u = o(void 0), d = () => {
|
|
882
|
-
s.current &&= (clearTimeout(s.current), void 0), c.current &&= (clearTimeout(c.current), void 0);
|
|
883
|
-
};
|
|
884
|
-
return Be(d), i(() => {
|
|
885
|
-
l.current = e;
|
|
886
|
-
}, t), a(() => {
|
|
887
|
-
let t = () => {
|
|
888
|
-
if (d(), !u.current) return;
|
|
889
|
-
let e = u.current;
|
|
890
|
-
u.current = void 0, l.current.apply(e.this, e.args);
|
|
891
|
-
}, i = function(...e) {
|
|
892
|
-
s.current && clearTimeout(s.current), u.current = {
|
|
893
|
-
args: e,
|
|
894
|
-
this: this
|
|
895
|
-
}, s.current = setTimeout(t, n), r > 0 && !c.current && (c.current = setTimeout(t, r));
|
|
896
|
-
};
|
|
897
|
-
return Object.defineProperties(i, {
|
|
898
|
-
length: { value: e.length },
|
|
899
|
-
name: { value: `${e.name || "anonymous"}__debounced__${n}` }
|
|
900
|
-
}), i;
|
|
901
|
-
}, [
|
|
902
|
-
n,
|
|
903
|
-
r,
|
|
904
|
-
...t
|
|
905
|
-
]);
|
|
906
|
-
}
|
|
907
|
-
//#endregion
|
|
908
|
-
//#region node_modules/@react-hookz/web/dist/util/const.js
|
|
909
|
-
var He = typeof globalThis < "u" && typeof navigator < "u" && typeof document < "u";
|
|
910
|
-
//#endregion
|
|
911
|
-
//#region node_modules/@react-hookz/web/dist/util/misc.js
|
|
912
|
-
function Ue(e, ...t) {
|
|
913
|
-
e?.addEventListener(...t);
|
|
914
|
-
}
|
|
915
|
-
function We(e, ...t) {
|
|
916
|
-
e?.removeEventListener(...t);
|
|
917
|
-
}
|
|
918
|
-
var Ge = (e, t) => Object.hasOwn(e, t);
|
|
919
|
-
//#endregion
|
|
920
|
-
//#region node_modules/@react-hookz/web/dist/useDebouncedEffect/index.js
|
|
921
|
-
function Ke(e, t, n, r = 0) {
|
|
922
|
-
i(Ve(e, t, n, r), t);
|
|
923
|
-
}
|
|
924
|
-
//#endregion
|
|
925
|
-
//#region node_modules/@react-hookz/web/dist/useIsMounted/index.js
|
|
926
|
-
function qe(e = !1) {
|
|
927
|
-
let t = o(e), r = n(() => t.current, []);
|
|
928
|
-
return i(() => (t.current = !0, () => {
|
|
929
|
-
t.current = !1;
|
|
930
|
-
}), []), r;
|
|
931
|
-
}
|
|
932
|
-
//#endregion
|
|
933
|
-
//#region node_modules/@react-hookz/web/dist/useResizeObserver/index.js
|
|
934
|
-
var Je = /* @__PURE__ */ new Map();
|
|
935
|
-
function Ye(e) {
|
|
936
|
-
if (!He) return;
|
|
937
|
-
let t = Je.get(e);
|
|
938
|
-
if (t) return t;
|
|
939
|
-
let n = /* @__PURE__ */ new Map(), r = new ResizeObserver((e) => {
|
|
940
|
-
for (let t of e) {
|
|
941
|
-
let e = n.get(t.target);
|
|
942
|
-
if (e !== void 0 && e.size !== 0) for (let n of e) setTimeout(() => {
|
|
943
|
-
n(t);
|
|
944
|
-
}, 0);
|
|
945
|
-
}
|
|
946
|
-
}), i = {
|
|
947
|
-
observer: r,
|
|
948
|
-
subscribe(t, i) {
|
|
949
|
-
let a = n.get(t);
|
|
950
|
-
a || (a = /* @__PURE__ */ new Set(), n.set(t, a), r.observe(t, { box: e })), a.add(i);
|
|
951
|
-
},
|
|
952
|
-
unsubscribe(e, t) {
|
|
953
|
-
let i = n.get(e);
|
|
954
|
-
i && (i.delete(t), i.size === 0 && (n.delete(e), r.unobserve(e)));
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
return Je.set(e, i), i;
|
|
958
|
-
}
|
|
959
|
-
function Xe(e, t, n = !0, r = "content-box") {
|
|
960
|
-
let a = n && Ye(r), o = ze(t), s = e && "current" in e ? e.current : e;
|
|
961
|
-
i(() => {
|
|
962
|
-
let t = e && "current" in e ? e.current : e;
|
|
963
|
-
if (a === !1 || a === void 0 || t == null) return;
|
|
964
|
-
let n = !0, r = (...e) => {
|
|
965
|
-
n && o.current(...e);
|
|
966
|
-
};
|
|
967
|
-
return a.subscribe(t, r), () => {
|
|
968
|
-
n = !1, a.unsubscribe(t, r);
|
|
969
|
-
};
|
|
970
|
-
}, [s, a]);
|
|
971
|
-
}
|
|
972
|
-
//#endregion
|
|
973
|
-
//#region node_modules/@react-hookz/web/dist/useEventListener/index.js
|
|
974
|
-
function H(e, ...t) {
|
|
975
|
-
let n = qe(), r = ze(t[1]), o = a(() => function(...e) {
|
|
976
|
-
n() && (typeof r.current == "function" ? r.current.apply(this, e) : typeof r.current.handleEvent == "function" && r.current.handleEvent.apply(this, e));
|
|
977
|
-
}, []);
|
|
978
|
-
i(() => {
|
|
979
|
-
let n = Ze(e) ? e.current : e;
|
|
980
|
-
if (!n) return;
|
|
981
|
-
let r = t.slice(2);
|
|
982
|
-
return Ue(n, t[0], o, ...r), () => {
|
|
983
|
-
We(n, t[0], o, ...r);
|
|
984
|
-
};
|
|
985
|
-
}, [e, t[0]]);
|
|
986
|
-
}
|
|
987
|
-
function Ze(e) {
|
|
988
|
-
return typeof e == "object" && !!e && Ge(e, "current");
|
|
989
|
-
}
|
|
990
|
-
//#endregion
|
|
991
|
-
//#region src/lib/board/useDim.js
|
|
992
|
-
var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate: r, itemExtent: i, boardWrapperRect: a, boardSize: o }) => {
|
|
993
|
-
let [s, c] = [e, t], l = le([a.width / 2, a.height / 2], {
|
|
459
|
+
}, je = 100, Me = 1e3, Ne = .8, R = !1, Pe = ({ x: e, y: t, scale: n, rotate: r, itemExtent: i, boardWrapperRect: a, boardSize: o }) => {
|
|
460
|
+
let [s, c] = [e, t], l = ne([a.width / 2, a.height / 2], {
|
|
994
461
|
translateX: s,
|
|
995
462
|
translateY: c,
|
|
996
463
|
scale: n,
|
|
@@ -1001,12 +468,12 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1001
468
|
}, d = {
|
|
1002
469
|
x: o / 2,
|
|
1003
470
|
y: o / 2
|
|
1004
|
-
}, f =
|
|
471
|
+
}, f = j(l, [u.x, u.y]), p = Math.min(a.width, a.height), m = i.radius + p / 2 / n - je / n;
|
|
1005
472
|
if (f > m) {
|
|
1006
|
-
let e =
|
|
473
|
+
let e = re({
|
|
1007
474
|
x: l[0],
|
|
1008
475
|
y: l[1]
|
|
1009
|
-
}, u, u, m - 1 / n)[0], [t, i] =
|
|
476
|
+
}, u, u, m - 1 / n)[0], [t, i] = M([-e.x, -e.y], {
|
|
1010
477
|
translateX: a.width / 2,
|
|
1011
478
|
translateY: a.height / 2,
|
|
1012
479
|
scale: n,
|
|
@@ -1014,14 +481,14 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1014
481
|
});
|
|
1015
482
|
s = t, c = i;
|
|
1016
483
|
}
|
|
1017
|
-
let h =
|
|
484
|
+
let h = j(l, [d.x, d.y]), g = o / 2 - j([0, 0], [a.width, a.height]) / n;
|
|
1018
485
|
if (h > g) {
|
|
1019
|
-
let e =
|
|
486
|
+
let e = re({
|
|
1020
487
|
x: l[0],
|
|
1021
488
|
y: l[1]
|
|
1022
489
|
}, d, d, g - 1 / n)[0];
|
|
1023
490
|
if (e) {
|
|
1024
|
-
let [t, i] =
|
|
491
|
+
let [t, i] = M([-e.x, -e.y], {
|
|
1025
492
|
translateX: a.width / 2,
|
|
1026
493
|
translateY: a.height / 2,
|
|
1027
494
|
scale: n,
|
|
@@ -1031,14 +498,14 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1031
498
|
}
|
|
1032
499
|
}
|
|
1033
500
|
return [s, c];
|
|
1034
|
-
},
|
|
1035
|
-
let [t, n, r, i, a] =
|
|
501
|
+
}, z = () => {
|
|
502
|
+
let [t, n, r, i, a] = L((e) => [
|
|
1036
503
|
e.getBoardState,
|
|
1037
504
|
e.updateBoardState,
|
|
1038
505
|
e.config.itemExtent,
|
|
1039
506
|
e.getConfiguration,
|
|
1040
507
|
e.updateConfiguration
|
|
1041
|
-
]), o = e.useRef([.15, 5]), [s] =
|
|
508
|
+
]), o = e.useRef([.15, 5]), [s] = I((e) => [e.getItemList]), c = e.useCallback(() => {
|
|
1042
509
|
let { translateX: e, translateY: n, scale: r, rotate: i } = t();
|
|
1043
510
|
return {
|
|
1044
511
|
translateX: e,
|
|
@@ -1046,101 +513,101 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1046
513
|
scale: r,
|
|
1047
514
|
rotate: i
|
|
1048
515
|
};
|
|
1049
|
-
}, [t]), l = e.useCallback((e, n) =>
|
|
516
|
+
}, [t]), l = e.useCallback((e, n) => ne([e, n], t()), [t]), d = e.useCallback((e, n) => M([e, n], t()), [t]), f = e.useCallback((e, n) => {
|
|
1050
517
|
let { scale: r, rotate: i } = t();
|
|
1051
|
-
return
|
|
518
|
+
return ne([e, n], {
|
|
1052
519
|
translateX: 0,
|
|
1053
520
|
translateY: 0,
|
|
1054
521
|
rotate: i,
|
|
1055
522
|
scale: r
|
|
1056
523
|
});
|
|
1057
|
-
}, [t]),
|
|
524
|
+
}, [t]), p = e.useCallback((e) => e > o.current[1] ? o.current[1] : e < o.current[0] ? o.current[0] : e, []), m = e.useCallback((e) => {
|
|
1058
525
|
let { itemExtent: r, boardWrapperRect: a, boardSize: o } = i(), s = t(), { translateX: c, translateY: l, scale: u, rotate: d } = {
|
|
1059
526
|
...s,
|
|
1060
527
|
...e(s)
|
|
1061
528
|
};
|
|
1062
|
-
|
|
1063
|
-
let
|
|
1064
|
-
(c !== s.translateX || l !== s.translateY) && ([m, h] =
|
|
529
|
+
R && console.log("New expected values: ", c, l, u, d);
|
|
530
|
+
let f = p(u), [m, h] = [c, l];
|
|
531
|
+
(c !== s.translateX || l !== s.translateY) && ([m, h] = Pe({
|
|
1065
532
|
x: c,
|
|
1066
533
|
y: l,
|
|
1067
|
-
scale:
|
|
534
|
+
scale: f,
|
|
1068
535
|
rotate: d,
|
|
1069
536
|
itemExtent: r,
|
|
1070
537
|
boardWrapperRect: a,
|
|
1071
538
|
boardSize: o
|
|
1072
|
-
})),
|
|
539
|
+
})), R && console.log("New fixed values: ", m, h, f, d), n({
|
|
1073
540
|
translateX: isNaN(m) ? 0 : m,
|
|
1074
541
|
translateY: isNaN(h) ? 0 : h,
|
|
1075
|
-
scale: isNaN(
|
|
542
|
+
scale: isNaN(f) ? p(1) : f,
|
|
1076
543
|
rotate: isNaN(d) ? 0 : d
|
|
1077
544
|
});
|
|
1078
545
|
}, [
|
|
1079
|
-
|
|
546
|
+
p,
|
|
1080
547
|
t,
|
|
1081
548
|
i,
|
|
1082
549
|
n
|
|
1083
|
-
]),
|
|
550
|
+
]), h = e.useCallback((e) => {
|
|
1084
551
|
let t = (t) => ({
|
|
1085
552
|
...t,
|
|
1086
553
|
...e
|
|
1087
554
|
});
|
|
1088
|
-
typeof e == "function" && (t = e),
|
|
555
|
+
typeof e == "function" && (t = e), m((e) => ({
|
|
1089
556
|
...e,
|
|
1090
557
|
...t({
|
|
1091
558
|
translateX: e.translateX,
|
|
1092
559
|
translateY: e.translateY
|
|
1093
560
|
})
|
|
1094
561
|
}));
|
|
1095
|
-
}, [
|
|
562
|
+
}, [m]), g = e.useCallback(({ to: e, factor: n }) => {
|
|
1096
563
|
let { boardWrapperRect: r } = i(), a = e;
|
|
1097
564
|
a ||= {
|
|
1098
565
|
x: r.left + r.width / 2,
|
|
1099
566
|
y: r.top + r.height / 2
|
|
1100
567
|
};
|
|
1101
|
-
let o = t(), s =
|
|
1102
|
-
|
|
568
|
+
let o = t(), s = p(o.scale * n), c = a.x - r.left, l = a.y - r.top, u = c - (c - o.translateX) * s / o.scale, d = l - (l - o.translateY) * s / o.scale;
|
|
569
|
+
m((e) => ({
|
|
1103
570
|
...e,
|
|
1104
571
|
translateX: u,
|
|
1105
572
|
translateY: d,
|
|
1106
573
|
scale: s
|
|
1107
574
|
}));
|
|
1108
575
|
}, [
|
|
1109
|
-
|
|
576
|
+
p,
|
|
1110
577
|
t,
|
|
1111
578
|
i,
|
|
1112
|
-
|
|
1113
|
-
]),
|
|
579
|
+
m
|
|
580
|
+
]), _ = e.useCallback(({ x: e, y: n, radius: r }) => {
|
|
1114
581
|
let { rotate: a } = t(), { boardWrapperRect: o, boardSize: s } = i(), [c, l, u] = [
|
|
1115
582
|
e || 0,
|
|
1116
583
|
n || 0,
|
|
1117
584
|
r || 2e3
|
|
1118
|
-
], d = o.width / (u * 2),
|
|
585
|
+
], d = o.width / (u * 2), f = o.height / (u * 2), h = p(Math.min(d, f) * Ne), [g, _] = M([-s / 2 - c, -s / 2 - l], {
|
|
1119
586
|
translateX: o.width / 2,
|
|
1120
587
|
translateY: o.height / 2,
|
|
1121
588
|
scale: h,
|
|
1122
589
|
rotate: a
|
|
1123
590
|
});
|
|
1124
|
-
|
|
591
|
+
m((e) => ({
|
|
1125
592
|
...e,
|
|
1126
593
|
translateX: g,
|
|
1127
594
|
translateY: _,
|
|
1128
595
|
scale: h
|
|
1129
596
|
}));
|
|
1130
597
|
}, [
|
|
1131
|
-
|
|
598
|
+
p,
|
|
1132
599
|
t,
|
|
1133
600
|
i,
|
|
1134
|
-
|
|
1135
|
-
]),
|
|
601
|
+
m
|
|
602
|
+
]), v = e.useCallback(() => {
|
|
1136
603
|
let { boardWrapperRect: e, boardSize: t } = i(), [n, r] = l(e.width / 2, e.height / 2);
|
|
1137
604
|
return {
|
|
1138
605
|
x: n - t / 2,
|
|
1139
606
|
y: r - t / 2
|
|
1140
607
|
};
|
|
1141
|
-
}, [l, i]),
|
|
608
|
+
}, [l, i]), y = e.useCallback(() => {
|
|
1142
609
|
let e = s(), { boardSize: t, uid: n } = i(), r = e.reduce((e, t) => {
|
|
1143
|
-
let r =
|
|
610
|
+
let r = P(n, t.id);
|
|
1144
611
|
return r && (e.left = Math.min(t.x, e.left), e.top = Math.min(t.y, e.top), e.right = Math.max(t.x + r.offsetWidth, e.right), e.bottom = Math.max(t.y + r.offsetHeight, e.bottom)), e;
|
|
1145
612
|
}, {
|
|
1146
613
|
left: t / 2,
|
|
@@ -1151,43 +618,43 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1151
618
|
x: (r.right + r.left) / 2,
|
|
1152
619
|
y: (r.bottom + r.top) / 2
|
|
1153
620
|
};
|
|
1154
|
-
o.radius = Math.max(
|
|
621
|
+
o.radius = Math.max(j([o.x, o.y], [r.left, r.top]), Me), a({ itemExtent: o });
|
|
1155
622
|
}, [
|
|
1156
623
|
i,
|
|
1157
624
|
s,
|
|
1158
625
|
a
|
|
1159
|
-
]),
|
|
626
|
+
]), b = e.useCallback((e) => {
|
|
1160
627
|
let t = () => e;
|
|
1161
|
-
typeof e == "function" && (t = e),
|
|
628
|
+
typeof e == "function" && (t = e), m((e) => ({
|
|
1162
629
|
...e,
|
|
1163
630
|
rotate: t(e.rotate)
|
|
1164
|
-
})),
|
|
631
|
+
})), y(), _(r);
|
|
1165
632
|
}, [
|
|
1166
633
|
r,
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
]),
|
|
634
|
+
m,
|
|
635
|
+
y,
|
|
636
|
+
_
|
|
637
|
+
]), x = u(() => y(), [y], 200);
|
|
1171
638
|
return e.useEffect(() => {
|
|
1172
|
-
window.debugUpdateExtent = () =>
|
|
1173
|
-
|
|
639
|
+
window.debugUpdateExtent = () => y(), window.debugDisplayExtent = () => console.log(i().itemExtent), window.debugSetDebug = () => {
|
|
640
|
+
R = !0;
|
|
1174
641
|
};
|
|
1175
|
-
}, [i,
|
|
1176
|
-
setDim:
|
|
1177
|
-
rotateBoard:
|
|
1178
|
-
moveBoard:
|
|
642
|
+
}, [i, y]), {
|
|
643
|
+
setDim: m,
|
|
644
|
+
rotateBoard: b,
|
|
645
|
+
moveBoard: h,
|
|
1179
646
|
getDim: c,
|
|
1180
|
-
zoomTo:
|
|
1181
|
-
zoomToCenter:
|
|
1182
|
-
zoomToExtent:
|
|
1183
|
-
getCenter:
|
|
1184
|
-
updateItemExtent:
|
|
1185
|
-
vectorFromWrapperToBoard:
|
|
647
|
+
zoomTo: g,
|
|
648
|
+
zoomToCenter: g,
|
|
649
|
+
zoomToExtent: _,
|
|
650
|
+
getCenter: v,
|
|
651
|
+
updateItemExtent: x,
|
|
652
|
+
vectorFromWrapperToBoard: f,
|
|
1186
653
|
fromWrapperToBoard: l,
|
|
1187
|
-
fromBoardToWrapper:
|
|
654
|
+
fromBoardToWrapper: d
|
|
1188
655
|
};
|
|
1189
|
-
},
|
|
1190
|
-
let [n, r, i] =
|
|
656
|
+
}, B = (t) => {
|
|
657
|
+
let [n, r, i] = L(({ register: e, unregister: t, callInteractions: n }) => [
|
|
1191
658
|
e,
|
|
1192
659
|
t,
|
|
1193
660
|
n
|
|
@@ -1204,13 +671,13 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1204
671
|
i(t, e);
|
|
1205
672
|
}, [i, t])
|
|
1206
673
|
};
|
|
1207
|
-
},
|
|
1208
|
-
let { call: t } =
|
|
674
|
+
}, V = () => {
|
|
675
|
+
let { call: t } = B("place"), { call: n } = B("delete"), { getCenter: r, updateItemExtent: i } = z(), [a, o, s, c] = L((e) => [
|
|
1209
676
|
e.clear,
|
|
1210
677
|
e.reverse,
|
|
1211
678
|
e.unselect,
|
|
1212
679
|
e.getConfiguration
|
|
1213
|
-
]), { getItems: l, getItemIds: u, setItemIds: d, updateItems: f, moveItems: p, removeItemsById: m, getItemList: h, insertItems: g, setItemList: _ } =
|
|
680
|
+
]), { getItems: l, getItemIds: u, setItemIds: d, updateItems: f, moveItems: p, removeItemsById: m, getItemList: h, insertItems: g, setItemList: _ } = I(({ getItems: e, getItemIds: t, setItemIds: n, updateItems: r, moveItems: i, removeItemsById: a, getItemList: o, insertItems: s, setItemList: c }) => ({
|
|
1214
681
|
getItems: e,
|
|
1215
682
|
getItemIds: t,
|
|
1216
683
|
setItemIds: n,
|
|
@@ -1244,7 +711,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1244
711
|
]), b = e.useCallback((e, t, n = !1) => {
|
|
1245
712
|
v([e], t, n);
|
|
1246
713
|
}, [v]), x = e.useCallback((e, t) => {
|
|
1247
|
-
p(
|
|
714
|
+
p(ce(l(), u(), e), t);
|
|
1248
715
|
}, [
|
|
1249
716
|
u,
|
|
1250
717
|
l,
|
|
@@ -1255,7 +722,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1255
722
|
}, [u, d]), C = e.useCallback((e, { type: t, size: n } = {}) => {
|
|
1256
723
|
let { uid: r } = c();
|
|
1257
724
|
v(e, (e) => {
|
|
1258
|
-
let i =
|
|
725
|
+
let i = P(r, e.id);
|
|
1259
726
|
if (!i) return;
|
|
1260
727
|
let a = {
|
|
1261
728
|
type: t || "grid",
|
|
@@ -1266,7 +733,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1266
733
|
},
|
|
1267
734
|
...e.grid
|
|
1268
735
|
};
|
|
1269
|
-
return
|
|
736
|
+
return le({
|
|
1270
737
|
x: e.x,
|
|
1271
738
|
y: e.y,
|
|
1272
739
|
width: i.clientWidth,
|
|
@@ -1274,7 +741,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1274
741
|
}, a);
|
|
1275
742
|
}, !0);
|
|
1276
743
|
}, [c, v]), w = e.useCallback((e, n) => {
|
|
1277
|
-
let r =
|
|
744
|
+
let r = ce(l(), u(), e);
|
|
1278
745
|
S(r), v(r, { moving: !1 }, !0), C(r, n), t(e), i();
|
|
1279
746
|
}, [
|
|
1280
747
|
v,
|
|
@@ -1293,7 +760,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1293
760
|
u,
|
|
1294
761
|
o,
|
|
1295
762
|
d
|
|
1296
|
-
]),
|
|
763
|
+
]), ee = e.useCallback((e, t) => {
|
|
1297
764
|
let n = l(), r = Object.fromEntries(t.map((t, r) => {
|
|
1298
765
|
let i = n[e[r]];
|
|
1299
766
|
return [t, {
|
|
@@ -1309,7 +776,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1309
776
|
v,
|
|
1310
777
|
u,
|
|
1311
778
|
d
|
|
1312
|
-
]),
|
|
779
|
+
]), D = e.useCallback((e, t) => {
|
|
1313
780
|
let n = r(), i = e.map((e, t) => !e.x || !e.y ? {
|
|
1314
781
|
...e,
|
|
1315
782
|
x: n.x + 2 * t,
|
|
@@ -1322,15 +789,15 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1322
789
|
r,
|
|
1323
790
|
g,
|
|
1324
791
|
w
|
|
1325
|
-
]),
|
|
1326
|
-
|
|
1327
|
-
}, [
|
|
792
|
+
]), O = e.useCallback((e, t) => {
|
|
793
|
+
D([e], t);
|
|
794
|
+
}, [D]), j = e.useCallback((e) => {
|
|
1328
795
|
s(e), m(e), n(e);
|
|
1329
796
|
}, [
|
|
1330
797
|
s,
|
|
1331
798
|
m,
|
|
1332
799
|
n
|
|
1333
|
-
]),
|
|
800
|
+
]), te = e.useCallback((e) => {
|
|
1334
801
|
let t = l();
|
|
1335
802
|
return e.map((e) => t[e]);
|
|
1336
803
|
}, [l]);
|
|
@@ -1341,39 +808,39 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1341
808
|
moveItems: x,
|
|
1342
809
|
placeItems: w,
|
|
1343
810
|
updateItem: b,
|
|
1344
|
-
swapItems:
|
|
811
|
+
swapItems: ee,
|
|
1345
812
|
reverseItemsOrder: E,
|
|
1346
813
|
setItemList: y,
|
|
1347
|
-
pushItem:
|
|
1348
|
-
pushItems:
|
|
1349
|
-
removeItems:
|
|
814
|
+
pushItem: O,
|
|
815
|
+
pushItems: D,
|
|
816
|
+
removeItems: j,
|
|
1350
817
|
getItemList: h,
|
|
1351
818
|
findElementUnderPointer: e.useCallback(({ target: e, clientX: t, clientY: n }, { returnLocked: r = !1, passLocked: i = !1 } = {}) => {
|
|
1352
819
|
if (["INPUT", "TEXTAREA"].includes(e.tagName)) return null;
|
|
1353
|
-
let a =
|
|
820
|
+
let a = A(e, "item");
|
|
1354
821
|
if (a) {
|
|
1355
|
-
if (
|
|
1356
|
-
if (!i &&
|
|
1357
|
-
if (
|
|
822
|
+
if (k(a, "selected")) return a;
|
|
823
|
+
if (!i && k(a, "locked") && !k(e, "passthrough")) return r ? a : null;
|
|
824
|
+
if (k(e, "passthrough")) {
|
|
1358
825
|
let e = u(), { uid: r } = c(), o = e.reduce((e, i) => {
|
|
1359
|
-
let a =
|
|
1360
|
-
return
|
|
826
|
+
let a = P(r, i), o = a.getBoundingClientRect();
|
|
827
|
+
return N({
|
|
1361
828
|
x: t,
|
|
1362
829
|
y: n
|
|
1363
830
|
}, o) && e.unshift(a), e;
|
|
1364
831
|
}, []);
|
|
1365
832
|
for (let e = 0; e < o.length; e += 1) {
|
|
1366
833
|
let t = o[e];
|
|
1367
|
-
if (t !== a && (i || !
|
|
834
|
+
if (t !== a && (i || !k(t, "locked"))) return t;
|
|
1368
835
|
}
|
|
1369
836
|
return null;
|
|
1370
837
|
}
|
|
1371
838
|
}
|
|
1372
839
|
return a;
|
|
1373
840
|
}, [c, u]),
|
|
1374
|
-
getItems:
|
|
841
|
+
getItems: te
|
|
1375
842
|
};
|
|
1376
|
-
},
|
|
843
|
+
}, Fe = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
1377
844
|
t.exports = function e(t, n) {
|
|
1378
845
|
if (t === n) return !0;
|
|
1379
846
|
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
@@ -1413,17 +880,17 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1413
880
|
}
|
|
1414
881
|
return t !== t && n !== n;
|
|
1415
882
|
};
|
|
1416
|
-
})))(), 1),
|
|
883
|
+
})))(), 1), Ie = (e, t) => {
|
|
1417
884
|
if (e.type in t) {
|
|
1418
885
|
let n = t[e.type].defaultActions;
|
|
1419
886
|
return typeof n == "function" ? n(e) : n;
|
|
1420
887
|
}
|
|
1421
888
|
return [];
|
|
1422
|
-
},
|
|
1423
|
-
let { actions: n =
|
|
889
|
+
}, Le = (e, t) => {
|
|
890
|
+
let { actions: n = Ie(e, t) } = e;
|
|
1424
891
|
return n.map((e) => typeof e == "string" ? { name: e } : e);
|
|
1425
|
-
},
|
|
1426
|
-
let [t, r] =
|
|
892
|
+
}, Re = () => {
|
|
893
|
+
let [t, r] = I((e) => [e.items, e.getItems]), [i, a, o] = L((e) => [
|
|
1427
894
|
e.config.itemTemplates,
|
|
1428
895
|
e.selection,
|
|
1429
896
|
e.getSelection
|
|
@@ -1431,57 +898,57 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1431
898
|
e.useEffect(() => (l.current = !0, () => {
|
|
1432
899
|
l.current = !1;
|
|
1433
900
|
}), []);
|
|
1434
|
-
let
|
|
901
|
+
let f = e.useCallback((e) => {
|
|
1435
902
|
let t = r();
|
|
1436
903
|
if (e) return [e, e.map((e) => t[e])];
|
|
1437
904
|
let n = o();
|
|
1438
905
|
return [n, n.map((e) => t[e])];
|
|
1439
|
-
}, [r, o]),
|
|
1440
|
-
let [e, t] =
|
|
906
|
+
}, [r, o]), p = n(() => {
|
|
907
|
+
let [e, t] = f();
|
|
1441
908
|
if (e.length > 0) {
|
|
1442
909
|
if (!l.current) return;
|
|
1443
910
|
let e = t.reduce((e, t) => {
|
|
1444
|
-
let n =
|
|
1445
|
-
return e.filter((e) => n.some((t) => (0,
|
|
1446
|
-
},
|
|
911
|
+
let n = Le(t, i);
|
|
912
|
+
return e.filter((e) => n.some((t) => (0, Fe.default)(e, t)));
|
|
913
|
+
}, Le(t[0], i));
|
|
1447
914
|
u(() => {
|
|
1448
915
|
c(e);
|
|
1449
916
|
});
|
|
1450
917
|
} else u(() => {
|
|
1451
918
|
c([]);
|
|
1452
919
|
});
|
|
1453
|
-
}, [
|
|
1454
|
-
return
|
|
920
|
+
}, [f, i]);
|
|
921
|
+
return d(() => p(), [
|
|
1455
922
|
t,
|
|
1456
923
|
a,
|
|
1457
|
-
|
|
924
|
+
p
|
|
1458
925
|
], 100), { availableActions: s };
|
|
1459
|
-
},
|
|
1460
|
-
let [e] =
|
|
926
|
+
}, ze = () => {
|
|
927
|
+
let [e] = L((e) => [e.selectionBox]);
|
|
1461
928
|
return e;
|
|
1462
|
-
},
|
|
929
|
+
}, Be = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", H = (e = 21) => {
|
|
1463
930
|
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
1464
|
-
for (; e--;) t +=
|
|
931
|
+
for (; e--;) t += Be[n[e] & 63];
|
|
1465
932
|
return t;
|
|
1466
|
-
},
|
|
933
|
+
}, Ve = e.createContext(), He = (e) => {
|
|
1467
934
|
localStorage.setItem("user", JSON.stringify(e));
|
|
1468
|
-
},
|
|
935
|
+
}, Ue = () => {
|
|
1469
936
|
if (localStorage.user) {
|
|
1470
937
|
let e = {
|
|
1471
938
|
name: "Player",
|
|
1472
|
-
color:
|
|
1473
|
-
uid:
|
|
939
|
+
color: de(),
|
|
940
|
+
uid: H(),
|
|
1474
941
|
...JSON.parse(localStorage.user)
|
|
1475
942
|
};
|
|
1476
|
-
return
|
|
943
|
+
return He(e), e;
|
|
1477
944
|
}
|
|
1478
945
|
let e = {
|
|
1479
946
|
name: "Player",
|
|
1480
|
-
color:
|
|
1481
|
-
uid:
|
|
947
|
+
color: de(),
|
|
948
|
+
uid: H()
|
|
1482
949
|
};
|
|
1483
|
-
return
|
|
1484
|
-
},
|
|
950
|
+
return He(e), e;
|
|
951
|
+
}, We = (e) => (t, n) => ({
|
|
1485
952
|
isSpaceMaster: !1,
|
|
1486
953
|
users: {},
|
|
1487
954
|
getUser: () => n().users[e],
|
|
@@ -1504,7 +971,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1504
971
|
id: r,
|
|
1505
972
|
uid: t.users[r].uid
|
|
1506
973
|
};
|
|
1507
|
-
return a.id === e &&
|
|
974
|
+
return a.id === e && He(a), setTimeout(() => n().electSpaceMaster(), 100), { users: {
|
|
1508
975
|
...t.users,
|
|
1509
976
|
[r]: a
|
|
1510
977
|
} };
|
|
@@ -1527,7 +994,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1527
994
|
e < i.timestamp && (i.id = t, i.timestamp = e);
|
|
1528
995
|
}), t({ isSpaceMaster: i.id === e });
|
|
1529
996
|
}
|
|
1530
|
-
}),
|
|
997
|
+
}), Ge = (e) => ({
|
|
1531
998
|
cursors: {},
|
|
1532
999
|
moveCursor: (t, n) => e((e) => ({ cursors: {
|
|
1533
1000
|
...e.cursors,
|
|
@@ -1537,12 +1004,12 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1537
1004
|
let n = { ...e.cursors };
|
|
1538
1005
|
return delete n[t], { cursors: n };
|
|
1539
1006
|
})
|
|
1540
|
-
}),
|
|
1541
|
-
let { wire: r, isMaster: i } =
|
|
1007
|
+
}), Ke = ({ storeName: t, children: n }) => {
|
|
1008
|
+
let { wire: r, isMaster: i } = O("room"), [o, c] = e.useState(null), [l, u] = e.useState(!1), d = e.useRef(!1);
|
|
1542
1009
|
return e.useEffect(() => {
|
|
1543
1010
|
let e = !0, n = [];
|
|
1544
|
-
if (!
|
|
1545
|
-
let n =
|
|
1011
|
+
if (!o && !d.current) return d.current = !0, (() => {
|
|
1012
|
+
let n = s(fe({
|
|
1546
1013
|
wire: r,
|
|
1547
1014
|
storeName: t,
|
|
1548
1015
|
noSync: [
|
|
@@ -1552,34 +1019,34 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1552
1019
|
"electSpaceMaster"
|
|
1553
1020
|
]
|
|
1554
1021
|
}, (...e) => ({
|
|
1555
|
-
...
|
|
1556
|
-
...
|
|
1022
|
+
...We(r.userId)(...e),
|
|
1023
|
+
...Ge(...e)
|
|
1557
1024
|
}), r, t)), i = n.subscribe((t) => {
|
|
1558
|
-
t.ready && (i(), e &&
|
|
1025
|
+
t.ready && (i(), e && c(n));
|
|
1559
1026
|
});
|
|
1560
1027
|
})(), () => {
|
|
1561
|
-
e = !1,
|
|
1028
|
+
e = !1, d.current = !1, n.forEach((e) => e());
|
|
1562
1029
|
};
|
|
1563
1030
|
}, [
|
|
1564
|
-
|
|
1031
|
+
o,
|
|
1565
1032
|
t,
|
|
1566
1033
|
r,
|
|
1567
1034
|
r.userId
|
|
1568
1035
|
]), e.useEffect(() => {
|
|
1569
|
-
if (
|
|
1570
|
-
...
|
|
1036
|
+
if (o) return o.getState().addUser({
|
|
1037
|
+
...Ue(),
|
|
1571
1038
|
id: r.userId
|
|
1572
|
-
}),
|
|
1573
|
-
|
|
1039
|
+
}), u(!0), () => {
|
|
1040
|
+
o.getState().removeUser(r.userId);
|
|
1574
1041
|
};
|
|
1575
1042
|
}, [
|
|
1576
1043
|
i,
|
|
1577
|
-
|
|
1044
|
+
o,
|
|
1578
1045
|
r
|
|
1579
1046
|
]), e.useEffect(() => {
|
|
1580
|
-
if (
|
|
1047
|
+
if (o) {
|
|
1581
1048
|
let e = r.subscribe("userLeave", (e) => {
|
|
1582
|
-
|
|
1049
|
+
o.getState().removeUser(e);
|
|
1583
1050
|
});
|
|
1584
1051
|
return () => {
|
|
1585
1052
|
e();
|
|
@@ -1587,20 +1054,23 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1587
1054
|
}
|
|
1588
1055
|
}, [
|
|
1589
1056
|
i,
|
|
1590
|
-
|
|
1057
|
+
o,
|
|
1591
1058
|
r
|
|
1592
1059
|
]), e.useEffect(() => {
|
|
1593
|
-
i &&
|
|
1060
|
+
i && o && o.getState().updateCurrentUser({ isMaster: i });
|
|
1594
1061
|
}, [
|
|
1595
1062
|
i,
|
|
1596
|
-
|
|
1063
|
+
o,
|
|
1597
1064
|
r
|
|
1598
|
-
]),
|
|
1599
|
-
value:
|
|
1065
|
+
]), l ? /* @__PURE__ */ a(Ve.Provider, {
|
|
1066
|
+
value: o,
|
|
1600
1067
|
children: n
|
|
1601
1068
|
}) : null;
|
|
1602
|
-
},
|
|
1603
|
-
let
|
|
1069
|
+
}, U = (e) => {
|
|
1070
|
+
let t = r(Ve);
|
|
1071
|
+
return c(t, e, l);
|
|
1072
|
+
}, qe = () => {
|
|
1073
|
+
let [t, n, r, i, a] = U((e) => [
|
|
1604
1074
|
e.isSpaceMaster,
|
|
1605
1075
|
e.getUser(),
|
|
1606
1076
|
e.users,
|
|
@@ -1618,8 +1088,8 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1618
1088
|
}, [n, o]),
|
|
1619
1089
|
joinSpace: a
|
|
1620
1090
|
};
|
|
1621
|
-
},
|
|
1622
|
-
let [t, n, r] =
|
|
1091
|
+
}, Je = () => {
|
|
1092
|
+
let [t, n, r] = I((e) => [
|
|
1623
1093
|
e.boardConfig,
|
|
1624
1094
|
e.getBoardConfig,
|
|
1625
1095
|
e.setBoardConfig
|
|
@@ -1630,11 +1100,11 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1630
1100
|
let i = n(), a = t(i);
|
|
1631
1101
|
r(a);
|
|
1632
1102
|
}, [n, r])];
|
|
1633
|
-
},
|
|
1634
|
-
let [e] =
|
|
1103
|
+
}, Ye = () => {
|
|
1104
|
+
let [e] = L((e) => [e.boardState]);
|
|
1635
1105
|
return e;
|
|
1636
|
-
},
|
|
1637
|
-
let [e, t, n, r] =
|
|
1106
|
+
}, Xe = () => {
|
|
1107
|
+
let [e, t, n, r] = I((e) => [
|
|
1638
1108
|
e.getSessionInfo,
|
|
1639
1109
|
e.setSessionInfo,
|
|
1640
1110
|
e.updateSessionInfo,
|
|
@@ -1646,7 +1116,7 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1646
1116
|
sessionInfo: r,
|
|
1647
1117
|
updateSessionInfo: n
|
|
1648
1118
|
};
|
|
1649
|
-
},
|
|
1119
|
+
}, Ze = e.createContext(), Qe = ({ user: { name: e, uid: t, color: n }, content: r }) => ({
|
|
1650
1120
|
type: "message",
|
|
1651
1121
|
user: {
|
|
1652
1122
|
name: e,
|
|
@@ -1654,9 +1124,9 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1654
1124
|
color: n
|
|
1655
1125
|
},
|
|
1656
1126
|
content: r,
|
|
1657
|
-
uid:
|
|
1127
|
+
uid: H(),
|
|
1658
1128
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1659
|
-
}),
|
|
1129
|
+
}), $e = (e, t) => ({
|
|
1660
1130
|
messages: [],
|
|
1661
1131
|
setMessages: (t) => e({ messages: t.map((e) => ({
|
|
1662
1132
|
...e,
|
|
@@ -1667,25 +1137,28 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1667
1137
|
timestamp: Date.parse(t.timestamp)
|
|
1668
1138
|
}] })),
|
|
1669
1139
|
sendMessage: (e, n) => {
|
|
1670
|
-
let r =
|
|
1140
|
+
let r = Qe({
|
|
1671
1141
|
user: e,
|
|
1672
1142
|
content: n
|
|
1673
1143
|
});
|
|
1674
1144
|
r && t().addMessage(r);
|
|
1675
1145
|
}
|
|
1676
|
-
}),
|
|
1677
|
-
let { wire: i } =
|
|
1146
|
+
}), et = ({ storeName: t, children: n, defaultValue: r = [] }) => {
|
|
1147
|
+
let { wire: i } = O("room"), [o] = e.useState(() => s(fe({
|
|
1678
1148
|
wire: i,
|
|
1679
1149
|
storeName: t,
|
|
1680
1150
|
defaultValue: r,
|
|
1681
1151
|
noSync: ["sendMessage"]
|
|
1682
|
-
}, (...e) => ({
|
|
1683
|
-
return /* @__PURE__ */ (
|
|
1684
|
-
value:
|
|
1152
|
+
}, (...e) => ({ ...$e(...e) }))));
|
|
1153
|
+
return /* @__PURE__ */ a(Ze.Provider, {
|
|
1154
|
+
value: o,
|
|
1685
1155
|
children: n
|
|
1686
1156
|
});
|
|
1687
|
-
},
|
|
1688
|
-
let
|
|
1157
|
+
}, tt = (e) => {
|
|
1158
|
+
let t = r(Ze);
|
|
1159
|
+
return c(t, e, l);
|
|
1160
|
+
}, nt = () => {}, rt = (t = nt) => {
|
|
1161
|
+
let n = U((e) => e.getUser()), [r, i, a] = tt((e) => [
|
|
1689
1162
|
e.messages,
|
|
1690
1163
|
e.setMessages,
|
|
1691
1164
|
e.sendMessage
|
|
@@ -1699,61 +1172,61 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1699
1172
|
a(n, e);
|
|
1700
1173
|
}, [n, a])
|
|
1701
1174
|
};
|
|
1702
|
-
},
|
|
1703
|
-
let r =
|
|
1175
|
+
}, it = ({ children: t, session: n }) => {
|
|
1176
|
+
let r = U((e) => e.joinSpace);
|
|
1704
1177
|
return e.useEffect(() => (r(n), () => {
|
|
1705
1178
|
r(null);
|
|
1706
1179
|
}), [r, n]), t;
|
|
1707
|
-
},
|
|
1708
|
-
let [
|
|
1180
|
+
}, at = ({ socket: t, room: n, session: r, items: i = [], messages: o = [], LoadingComponent: s, ...c }) => {
|
|
1181
|
+
let [l] = e.useState(n || H()), [u] = e.useState(r || H()), [d] = e.useState(() => ({
|
|
1709
1182
|
itemIds: i.map(({ id: e }) => e),
|
|
1710
1183
|
items: Object.fromEntries(i.map((e) => [e.id, e]))
|
|
1711
1184
|
}));
|
|
1712
|
-
return
|
|
1713
|
-
storeName: `${
|
|
1714
|
-
defaultValue:
|
|
1715
|
-
children: /* @__PURE__ */ (
|
|
1716
|
-
storeName: `${
|
|
1717
|
-
defaultValue:
|
|
1718
|
-
children: /* @__PURE__ */ (
|
|
1719
|
-
...
|
|
1720
|
-
session:
|
|
1185
|
+
return O("room") ? /* @__PURE__ */ a(et, {
|
|
1186
|
+
storeName: `${u}_messages`,
|
|
1187
|
+
defaultValue: o,
|
|
1188
|
+
children: /* @__PURE__ */ a(Oe, { children: /* @__PURE__ */ a(ye, {
|
|
1189
|
+
storeName: `${u}_item`,
|
|
1190
|
+
defaultValue: d,
|
|
1191
|
+
children: /* @__PURE__ */ a(it, {
|
|
1192
|
+
...c,
|
|
1193
|
+
session: u
|
|
1721
1194
|
})
|
|
1722
1195
|
}) })
|
|
1723
|
-
}) : /* @__PURE__ */ (
|
|
1724
|
-
room:
|
|
1196
|
+
}) : /* @__PURE__ */ a(D, {
|
|
1197
|
+
room: l,
|
|
1725
1198
|
channel: "room",
|
|
1726
1199
|
socket: t,
|
|
1727
|
-
LoadingComponent:
|
|
1728
|
-
children: /* @__PURE__ */ (
|
|
1729
|
-
storeName: `${
|
|
1730
|
-
children: /* @__PURE__ */ (
|
|
1731
|
-
storeName: `${
|
|
1732
|
-
defaultValue:
|
|
1733
|
-
children: /* @__PURE__ */ (
|
|
1734
|
-
storeName: `${
|
|
1735
|
-
defaultValue:
|
|
1736
|
-
children: /* @__PURE__ */ (
|
|
1737
|
-
...
|
|
1738
|
-
session:
|
|
1200
|
+
LoadingComponent: s,
|
|
1201
|
+
children: /* @__PURE__ */ a(Ke, {
|
|
1202
|
+
storeName: `${l}_users`,
|
|
1203
|
+
children: /* @__PURE__ */ a(et, {
|
|
1204
|
+
storeName: `${u}_messages`,
|
|
1205
|
+
defaultValue: o,
|
|
1206
|
+
children: /* @__PURE__ */ a(Oe, { children: /* @__PURE__ */ a(ye, {
|
|
1207
|
+
storeName: `${u}_item`,
|
|
1208
|
+
defaultValue: d,
|
|
1209
|
+
children: /* @__PURE__ */ a(it, {
|
|
1210
|
+
...c,
|
|
1211
|
+
session: u
|
|
1739
1212
|
})
|
|
1740
1213
|
}) })
|
|
1741
1214
|
})
|
|
1742
1215
|
})
|
|
1743
1216
|
});
|
|
1744
|
-
},
|
|
1745
|
-
let [
|
|
1746
|
-
return /* @__PURE__ */ (
|
|
1747
|
-
room:
|
|
1217
|
+
}, ot = ({ socket: t, room: n, children: r, LoadingComponent: i }) => {
|
|
1218
|
+
let [o] = e.useState(n || H());
|
|
1219
|
+
return /* @__PURE__ */ a(D, {
|
|
1220
|
+
room: o,
|
|
1748
1221
|
channel: "room",
|
|
1749
1222
|
socket: t,
|
|
1750
1223
|
LoadingComponent: i,
|
|
1751
|
-
children: /* @__PURE__ */ (
|
|
1752
|
-
storeName: `${
|
|
1224
|
+
children: /* @__PURE__ */ a(Ke, {
|
|
1225
|
+
storeName: `${o}_users`,
|
|
1753
1226
|
children: r
|
|
1754
1227
|
})
|
|
1755
1228
|
});
|
|
1756
|
-
},
|
|
1229
|
+
}, st = { data: "" }, ct = (e) => {
|
|
1757
1230
|
if (typeof window == "object") {
|
|
1758
1231
|
let t = (e ? e.querySelector("#_goober") : window._goober) || Object.assign(document.createElement("style"), {
|
|
1759
1232
|
innerHTML: " ",
|
|
@@ -1761,58 +1234,58 @@ var Qe = 100, $e = 1e3, et = .8, tt = !1, nt = ({ x: e, y: t, scale: n, rotate:
|
|
|
1761
1234
|
});
|
|
1762
1235
|
return t.nonce = window.__nonce__, t.parentNode || (e || document.head).appendChild(t), t.firstChild;
|
|
1763
1236
|
}
|
|
1764
|
-
return e ||
|
|
1765
|
-
},
|
|
1237
|
+
return e || st;
|
|
1238
|
+
}, lt = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g, ut = /\/\*[^]*?\*\/| +/g, dt = /\n+/g, W = (e, t) => {
|
|
1766
1239
|
let n = "", r = "", i = "";
|
|
1767
1240
|
for (let a in e) {
|
|
1768
1241
|
let o = e[a];
|
|
1769
|
-
a[0] == "@" ? a[1] == "i" ? n = a + " " + o + ";" : r += a[1] == "f" ?
|
|
1242
|
+
a[0] == "@" ? a[1] == "i" ? n = a + " " + o + ";" : r += a[1] == "f" ? W(o, a) : a + "{" + W(o, a[1] == "k" ? "" : t) + "}" : typeof o == "object" ? r += W(o, t ? t.replace(/([^,])+/g, (e) => a.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g, (t) => /&/.test(t) ? t.replace(/&/g, e) : e ? e + " " + t : t)) : a) : o != null && (a = a[1] == "-" ? a : a.replace(/[A-Z]/g, "-$&").toLowerCase(), i += W.p ? W.p(a, o) : a + ":" + o + ";");
|
|
1770
1243
|
}
|
|
1771
1244
|
return n + (t && i ? t + "{" + i + "}" : i) + r;
|
|
1772
|
-
},
|
|
1245
|
+
}, G = {}, ft = (e) => {
|
|
1773
1246
|
if (typeof e == "object") {
|
|
1774
1247
|
let t = "";
|
|
1775
|
-
for (let n in e) t += n +
|
|
1248
|
+
for (let n in e) t += n + ft(e[n]);
|
|
1776
1249
|
return t;
|
|
1777
1250
|
}
|
|
1778
1251
|
return e;
|
|
1779
|
-
},
|
|
1780
|
-
let a =
|
|
1252
|
+
}, pt = (e, t, n, r, i) => {
|
|
1253
|
+
let a = ft(e), o = G[a] || (G[a] = ((e) => {
|
|
1781
1254
|
let t = 0, n = 11;
|
|
1782
1255
|
for (; t < e.length;) n = 101 * n + e.charCodeAt(t++) >>> 0;
|
|
1783
1256
|
return "go" + n;
|
|
1784
1257
|
})(a));
|
|
1785
|
-
if (!
|
|
1258
|
+
if (!G[o]) {
|
|
1786
1259
|
let t = a === e ? ((e) => {
|
|
1787
1260
|
let t, n, r = [{}];
|
|
1788
|
-
for (; t =
|
|
1261
|
+
for (; t = lt.exec(e.replace(ut, ""));) t[4] ? r.shift() : t[3] ? (n = t[3].replace(dt, " ").trim(), r.unshift(r[0][n] = r[0][n] || {})) : r[0][t[1]] = t[2].replace(dt, " ").trim();
|
|
1789
1262
|
return r[0];
|
|
1790
1263
|
})(e) : e;
|
|
1791
|
-
|
|
1264
|
+
G[o] = W(i ? { ["@keyframes " + o]: t } : t, n ? "" : "." + o);
|
|
1792
1265
|
}
|
|
1793
|
-
let s = n &&
|
|
1794
|
-
return n && (
|
|
1266
|
+
let s = n && G.g;
|
|
1267
|
+
return n && (G.g = G[o]), ((e, t, n, r) => {
|
|
1795
1268
|
r ? t.data = t.data.replace(r, e) : t.data.indexOf(e) === -1 && (t.data = n ? e + t.data : t.data + e);
|
|
1796
|
-
})(
|
|
1797
|
-
},
|
|
1269
|
+
})(G[o], t, r, s), o;
|
|
1270
|
+
}, mt = (e, t, n) => e.reduce((e, r, i) => {
|
|
1798
1271
|
let a = t[i];
|
|
1799
1272
|
if (a && a.call) {
|
|
1800
1273
|
let e = a(n), t = e && e.props && e.props.className || /^go/.test(e) && e;
|
|
1801
|
-
a = t ? "." + t : e && typeof e == "object" ? e.props ? "" :
|
|
1274
|
+
a = t ? "." + t : e && typeof e == "object" ? e.props ? "" : W(e, "") : !1 === e ? "" : e;
|
|
1802
1275
|
}
|
|
1803
1276
|
return e + r + (a ?? "");
|
|
1804
1277
|
}, "");
|
|
1805
|
-
function
|
|
1278
|
+
function K(e) {
|
|
1806
1279
|
let t = this || {}, n = e.call ? e(t.p) : e;
|
|
1807
|
-
return
|
|
1280
|
+
return pt(n.unshift ? n.raw ? mt(n, [].slice.call(arguments, 1), t.p) : n.reduce((e, n) => Object.assign(e, n && n.call ? n(t.p) : n), {}) : n, ct(t.target), t.g, t.o, t.k);
|
|
1808
1281
|
}
|
|
1809
|
-
|
|
1810
|
-
function
|
|
1811
|
-
|
|
1282
|
+
K.bind({ g: 1 }), K.bind({ k: 1 });
|
|
1283
|
+
function ht(e, t, n, r) {
|
|
1284
|
+
W.p = t;
|
|
1812
1285
|
}
|
|
1813
1286
|
//#endregion
|
|
1814
1287
|
//#region src/lib/board/Gesture.jsx
|
|
1815
|
-
var
|
|
1288
|
+
var gt = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
1816
1289
|
t.exports = function e(t, n) {
|
|
1817
1290
|
if (t === n) return !0;
|
|
1818
1291
|
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
@@ -1836,62 +1309,62 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
1836
1309
|
}
|
|
1837
1310
|
return t !== t && n !== n;
|
|
1838
1311
|
};
|
|
1839
|
-
})))(), 1),
|
|
1312
|
+
})))(), 1), _t = () => {
|
|
1840
1313
|
let e = navigator.userAgent.toLowerCase();
|
|
1841
1314
|
return /mac os ?x 10/.test(e);
|
|
1842
|
-
},
|
|
1315
|
+
}, vt = (() => {
|
|
1843
1316
|
let e = document.createElement("iframe");
|
|
1844
1317
|
e.src = "#", document.body.appendChild(e);
|
|
1845
1318
|
let t = e.contentWindow.document;
|
|
1846
1319
|
t.open(), t.write("<!DOCTYPE html><html><head></head><body><span>a</span></body></html>"), t.close();
|
|
1847
1320
|
let n = t.body.firstElementChild.offsetHeight;
|
|
1848
1321
|
return document.body.removeChild(e), n;
|
|
1849
|
-
})(),
|
|
1322
|
+
})(), yt = 800, bt = (e, t) => e[Object.keys(e).map((e) => Number(e)).find((e) => e !== t)], xt = ([e, t], [n, r]) => {
|
|
1850
1323
|
let i = Math.abs(e - n), a = Math.abs(t - r);
|
|
1851
1324
|
return Math.hypot(i, a);
|
|
1852
|
-
},
|
|
1325
|
+
}, q = () => {}, St = (e) => (t) => {
|
|
1853
1326
|
let { event: n } = t;
|
|
1854
1327
|
return n.isPropagationStopped() ? null : e(t);
|
|
1855
|
-
},
|
|
1328
|
+
}, Ct = (e) => async (...t) => {
|
|
1856
1329
|
try {
|
|
1857
1330
|
await e(...t);
|
|
1858
1331
|
} catch (e) {
|
|
1859
1332
|
console.error(e);
|
|
1860
1333
|
}
|
|
1861
|
-
},
|
|
1334
|
+
}, J = new class {
|
|
1862
1335
|
lastPromise = Promise.resolve(!0);
|
|
1863
1336
|
add(e, ...t) {
|
|
1864
1337
|
return new Promise((n, r) => {
|
|
1865
|
-
this.lastPromise = this.lastPromise.then(() =>
|
|
1338
|
+
this.lastPromise = this.lastPromise.then(() => St(Ct(e))(...t)).then(n).catch(r);
|
|
1866
1339
|
});
|
|
1867
1340
|
}
|
|
1868
|
-
}(),
|
|
1869
|
-
let
|
|
1341
|
+
}(), Y = ({ children: t, onDrag: n = q, onDragStart: r = q, onDragEnd: i = q, onPan: o = q, onTap: s = q, onLongTap: c = q, onDoubleTap: l = q, onZoom: u, mainAction: d = "drag" }) => {
|
|
1342
|
+
let f = e.useRef(null), p = e.useRef({
|
|
1870
1343
|
moving: !1,
|
|
1871
1344
|
pointers: {},
|
|
1872
1345
|
mainPointer: void 0
|
|
1873
|
-
}),
|
|
1874
|
-
let { deltaX: t, deltaY: n, clientX: r, clientY: i, deltaMode:
|
|
1875
|
-
if (!(c || s && !
|
|
1876
|
-
if (
|
|
1346
|
+
}), m = (e) => {
|
|
1347
|
+
let { deltaX: t, deltaY: n, clientX: r, clientY: i, deltaMode: a, ctrlKey: s, altKey: c, metaKey: l, target: d } = e;
|
|
1348
|
+
if (!(c || s && !_t())) {
|
|
1349
|
+
if (_t() && !s) J.add(o, {
|
|
1877
1350
|
deltaX: -2 * t,
|
|
1878
1351
|
deltaY: -2 * n,
|
|
1879
1352
|
button: 1,
|
|
1880
1353
|
ctrlKey: s,
|
|
1881
|
-
metaKey:
|
|
1354
|
+
metaKey: l,
|
|
1882
1355
|
target: d,
|
|
1883
1356
|
event: e
|
|
1884
1357
|
});
|
|
1885
1358
|
else {
|
|
1886
|
-
if (
|
|
1359
|
+
if (u === void 0 || !n) return;
|
|
1887
1360
|
let t = n;
|
|
1888
|
-
switch (
|
|
1361
|
+
switch (a) {
|
|
1889
1362
|
case 1:
|
|
1890
|
-
t *=
|
|
1363
|
+
t *= vt;
|
|
1891
1364
|
break;
|
|
1892
|
-
case 2: t *=
|
|
1365
|
+
case 2: t *= yt;
|
|
1893
1366
|
}
|
|
1894
|
-
|
|
1367
|
+
_t() && (t *= 2), J.add(u, {
|
|
1895
1368
|
scale: t,
|
|
1896
1369
|
clientX: r,
|
|
1897
1370
|
clientY: i,
|
|
@@ -1899,15 +1372,15 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
1899
1372
|
});
|
|
1900
1373
|
}
|
|
1901
1374
|
}
|
|
1902
|
-
},
|
|
1903
|
-
let { target: t, button: n, clientX: r, clientY: i, pointerId: a, altKey: o, ctrlKey:
|
|
1904
|
-
if (
|
|
1375
|
+
}, h = (e) => {
|
|
1376
|
+
let { target: t, button: n, clientX: r, clientY: i, pointerId: a, altKey: o, ctrlKey: s, metaKey: l, isPrimary: u } = e;
|
|
1377
|
+
if (p.current.pointers[a] = {
|
|
1905
1378
|
clientX: r,
|
|
1906
1379
|
clientY: i
|
|
1907
|
-
}, u && (
|
|
1908
|
-
if (
|
|
1909
|
-
let { clientX: e, clientY: t } =
|
|
1910
|
-
Object.assign(
|
|
1380
|
+
}, u && (p.current.mainPointer = void 0), p.current.mainPointer !== void 0) {
|
|
1381
|
+
if (p.current.mainPointer !== a) try {
|
|
1382
|
+
let { clientX: e, clientY: t } = bt(p.current.pointers, a), n = (e + r) / 2, o = (t + i) / 2, s = xt([e, t], [r, i]);
|
|
1383
|
+
Object.assign(p.current, {
|
|
1911
1384
|
pressed: !0,
|
|
1912
1385
|
moving: !1,
|
|
1913
1386
|
gestureStart: !1,
|
|
@@ -1919,11 +1392,11 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
1919
1392
|
prevDistance: s
|
|
1920
1393
|
});
|
|
1921
1394
|
} catch (e) {
|
|
1922
|
-
console.log("Error while getting other pointer. Ignoring", e),
|
|
1395
|
+
console.log("Error while getting other pointer. Ignoring", e), p.current.mainPointer;
|
|
1923
1396
|
}
|
|
1924
1397
|
return;
|
|
1925
1398
|
}
|
|
1926
|
-
|
|
1399
|
+
p.current.mainPointer = a, Object.assign(p.current, {
|
|
1927
1400
|
pressed: !0,
|
|
1928
1401
|
moving: !1,
|
|
1929
1402
|
gestureStart: !1,
|
|
@@ -1938,11 +1411,11 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
1938
1411
|
target: t,
|
|
1939
1412
|
timeStart: Date.now(),
|
|
1940
1413
|
longTapTimeout: setTimeout(async () => {
|
|
1941
|
-
|
|
1414
|
+
p.current.noTap = !0, J.add(c, {
|
|
1942
1415
|
clientX: r,
|
|
1943
1416
|
clientY: i,
|
|
1944
1417
|
altKey: o,
|
|
1945
|
-
ctrlKey:
|
|
1418
|
+
ctrlKey: s,
|
|
1946
1419
|
metaKey: l,
|
|
1947
1420
|
target: t,
|
|
1948
1421
|
event: e
|
|
@@ -1954,89 +1427,89 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
1954
1427
|
} catch (e) {
|
|
1955
1428
|
console.log("Fail to capture pointer", e);
|
|
1956
1429
|
}
|
|
1957
|
-
},
|
|
1958
|
-
if (
|
|
1959
|
-
let { pointerId: t, clientX: i, clientY:
|
|
1960
|
-
|
|
1430
|
+
}, g = (e) => {
|
|
1431
|
+
if (p.current.pressed) {
|
|
1432
|
+
let { pointerId: t, clientX: i, clientY: a, altKey: s, shiftKey: c, ctrlKey: l, metaKey: m, buttons: h } = e;
|
|
1433
|
+
p.current.pointers[t] = {
|
|
1961
1434
|
clientX: i,
|
|
1962
|
-
clientY:
|
|
1963
|
-
},
|
|
1964
|
-
let g = Object.keys(
|
|
1435
|
+
clientY: a
|
|
1436
|
+
}, p.current.moving = !0;
|
|
1437
|
+
let g = Object.keys(p.current.pointers).length === 2, _, v, y = 0;
|
|
1965
1438
|
if (g) {
|
|
1966
|
-
let { clientX: e, clientY: n } =
|
|
1967
|
-
_ = (e + i) / 2, v = (n +
|
|
1968
|
-
} else _ = i, v =
|
|
1969
|
-
let b = c || s ||
|
|
1970
|
-
|
|
1439
|
+
let { clientX: e, clientY: n } = bt(p.current.pointers, t);
|
|
1440
|
+
_ = (e + i) / 2, v = (n + a) / 2, y = xt([e, n], [i, a]);
|
|
1441
|
+
} else _ = i, v = a;
|
|
1442
|
+
let b = c || s || l || m || h !== 1;
|
|
1443
|
+
d !== "drag" && (b = !b);
|
|
1971
1444
|
let x = !b, S = b;
|
|
1972
1445
|
if (x) {
|
|
1973
|
-
|
|
1446
|
+
p.current.gestureStart || (f.current.style.cursor = "move", p.current.gestureStart = !0, clearTimeout(p.current.longTapTimeout), J.add(r, {
|
|
1974
1447
|
deltaX: 0,
|
|
1975
1448
|
deltaY: 0,
|
|
1976
|
-
startX:
|
|
1977
|
-
startY:
|
|
1978
|
-
clientX:
|
|
1979
|
-
clientY:
|
|
1449
|
+
startX: p.current.startX,
|
|
1450
|
+
startY: p.current.startY,
|
|
1451
|
+
clientX: p.current.startX,
|
|
1452
|
+
clientY: p.current.startY,
|
|
1980
1453
|
distanceX: 0,
|
|
1981
1454
|
distanceY: 0,
|
|
1982
|
-
button:
|
|
1455
|
+
button: p.current.currentButton,
|
|
1983
1456
|
altKey: s,
|
|
1984
1457
|
shiftKey: c,
|
|
1985
|
-
ctrlKey:
|
|
1458
|
+
ctrlKey: l,
|
|
1986
1459
|
metaKey: m,
|
|
1987
|
-
target:
|
|
1988
|
-
event:
|
|
1460
|
+
target: p.current.target,
|
|
1461
|
+
event: p.current.pointerDownEvent
|
|
1989
1462
|
}));
|
|
1990
|
-
let t = _ -
|
|
1991
|
-
|
|
1463
|
+
let t = _ - p.current.prevX, i = v - p.current.prevY, a = _ - p.current.startX, o = v - p.current.startY;
|
|
1464
|
+
J.add(n, {
|
|
1992
1465
|
deltaX: t,
|
|
1993
1466
|
deltaY: i,
|
|
1994
|
-
startX:
|
|
1995
|
-
startY:
|
|
1467
|
+
startX: p.current.startX,
|
|
1468
|
+
startY: p.current.startY,
|
|
1996
1469
|
clientX: _,
|
|
1997
1470
|
clientY: v,
|
|
1998
1471
|
distanceX: a,
|
|
1999
1472
|
distanceY: o,
|
|
2000
|
-
button:
|
|
1473
|
+
button: p.current.currentButton,
|
|
2001
1474
|
altKey: s,
|
|
2002
1475
|
shiftKey: c,
|
|
2003
|
-
ctrlKey:
|
|
1476
|
+
ctrlKey: l,
|
|
2004
1477
|
metaKey: m,
|
|
2005
|
-
target:
|
|
1478
|
+
target: p.current.target,
|
|
2006
1479
|
event: e
|
|
2007
1480
|
});
|
|
2008
1481
|
}
|
|
2009
1482
|
if (S) {
|
|
2010
|
-
|
|
2011
|
-
let t = _ -
|
|
2012
|
-
if (
|
|
1483
|
+
p.current.gestureStart || (f.current.style.cursor = "move", p.current.gestureStart = !0, clearTimeout(p.current.longTapTimeout));
|
|
1484
|
+
let t = _ - p.current.prevX, n = v - p.current.prevY, { target: r } = p.current;
|
|
1485
|
+
if (J.add(o, {
|
|
2013
1486
|
deltaX: t,
|
|
2014
1487
|
deltaY: n,
|
|
2015
|
-
button:
|
|
1488
|
+
button: p.current.currentButton,
|
|
2016
1489
|
altKey: s,
|
|
2017
1490
|
shiftKey: c,
|
|
2018
|
-
ctrlKey:
|
|
1491
|
+
ctrlKey: l,
|
|
2019
1492
|
metaKey: m,
|
|
2020
1493
|
target: r,
|
|
2021
1494
|
event: e
|
|
2022
|
-
}), y !==
|
|
2023
|
-
let t =
|
|
2024
|
-
Math.abs(t) > 0 && (
|
|
1495
|
+
}), y !== p.current.prevDistance && u) {
|
|
1496
|
+
let t = p.current.prevDistance - y;
|
|
1497
|
+
Math.abs(t) > 0 && (J.add(u, {
|
|
2025
1498
|
scale: t * 3,
|
|
2026
1499
|
clientX: _,
|
|
2027
1500
|
clientY: v,
|
|
2028
1501
|
event: e
|
|
2029
|
-
}),
|
|
1502
|
+
}), p.current.prevDistance = y);
|
|
2030
1503
|
}
|
|
2031
1504
|
}
|
|
2032
|
-
|
|
1505
|
+
p.current.prevX = _, p.current.prevY = v;
|
|
2033
1506
|
}
|
|
2034
|
-
},
|
|
2035
|
-
let { clientX: t, clientY: n, altKey: r, shiftKey: a, ctrlKey:
|
|
2036
|
-
if (
|
|
2037
|
-
if (delete
|
|
2038
|
-
let { clientX: e, clientY: t } =
|
|
2039
|
-
Object.assign(
|
|
1507
|
+
}, _ = (e) => {
|
|
1508
|
+
let { clientX: t, clientY: n, altKey: r, shiftKey: a, ctrlKey: o, metaKey: c, target: l, pointerId: u } = e;
|
|
1509
|
+
if (p.current.pointers[u]) {
|
|
1510
|
+
if (delete p.current.pointers[u], p.current.mainPointer !== u) {
|
|
1511
|
+
let { clientX: e, clientY: t } = p.current.pointers[p.current.mainPointer];
|
|
1512
|
+
Object.assign(p.current, {
|
|
2040
1513
|
prevX: e,
|
|
2041
1514
|
prevY: t,
|
|
2042
1515
|
prevDistance: 0,
|
|
@@ -2044,12 +1517,12 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2044
1517
|
});
|
|
2045
1518
|
return;
|
|
2046
1519
|
}
|
|
2047
|
-
for (; Object.keys(
|
|
2048
|
-
|
|
1520
|
+
for (; Object.keys(p.current.pointers).length > 0;) {
|
|
1521
|
+
p.current.mainPointer = Number(Object.keys(p.current.pointers)[0]);
|
|
2049
1522
|
try {
|
|
2050
|
-
|
|
2051
|
-
let { clientX: e, clientY: t } =
|
|
2052
|
-
Object.assign(
|
|
1523
|
+
p.current.target.setPointerCapture(p.current.mainPointer);
|
|
1524
|
+
let { clientX: e, clientY: t } = p.current.pointers[p.current.mainPointer];
|
|
1525
|
+
Object.assign(p.current, {
|
|
2053
1526
|
prevX: e,
|
|
2054
1527
|
prevY: t,
|
|
2055
1528
|
prevDistance: 0,
|
|
@@ -2057,33 +1530,33 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2057
1530
|
});
|
|
2058
1531
|
return;
|
|
2059
1532
|
} catch (e) {
|
|
2060
|
-
console.log("Fails to set pointer capture", e),
|
|
1533
|
+
console.log("Fails to set pointer capture", e), p.current.mainPointer = void 0, delete p.current.pointers[Object.keys(p.current.pointers)[0]];
|
|
2061
1534
|
}
|
|
2062
1535
|
}
|
|
2063
|
-
if (
|
|
2064
|
-
deltaX: t -
|
|
2065
|
-
deltaY: n -
|
|
2066
|
-
startX:
|
|
2067
|
-
startY:
|
|
1536
|
+
if (p.current.mainPointer = void 0, p.current.pressed = !1, clearTimeout(p.current.longTapTimeout), p.current.moving) p.current.moving = !1, J.add(i, {
|
|
1537
|
+
deltaX: t - p.current.prevX,
|
|
1538
|
+
deltaY: n - p.current.prevY,
|
|
1539
|
+
startX: p.current.startX,
|
|
1540
|
+
startY: p.current.startY,
|
|
2068
1541
|
clientX: t,
|
|
2069
1542
|
clientY: n,
|
|
2070
|
-
distanceX: t -
|
|
2071
|
-
distanceY: n -
|
|
2072
|
-
button:
|
|
1543
|
+
distanceX: t - p.current.startX,
|
|
1544
|
+
distanceY: n - p.current.startY,
|
|
1545
|
+
button: p.current.currentButton,
|
|
2073
1546
|
altKey: r,
|
|
2074
1547
|
shiftKey: a,
|
|
2075
|
-
ctrlKey:
|
|
1548
|
+
ctrlKey: o,
|
|
2076
1549
|
metaKey: c,
|
|
2077
1550
|
event: e
|
|
2078
|
-
}),
|
|
1551
|
+
}), f.current.style.cursor = "auto";
|
|
2079
1552
|
else {
|
|
2080
1553
|
let i = Date.now();
|
|
2081
|
-
|
|
1554
|
+
p.current.noTap ? p.current.noTap = !1 : p.current.timeStart - i < 300 && J.add(s, {
|
|
2082
1555
|
clientX: t,
|
|
2083
1556
|
clientY: n,
|
|
2084
1557
|
altKey: r,
|
|
2085
1558
|
shiftKey: a,
|
|
2086
|
-
ctrlKey:
|
|
1559
|
+
ctrlKey: o,
|
|
2087
1560
|
metaKey: c,
|
|
2088
1561
|
target: l,
|
|
2089
1562
|
event: e
|
|
@@ -2091,17 +1564,17 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2091
1564
|
}
|
|
2092
1565
|
}
|
|
2093
1566
|
};
|
|
2094
|
-
return /* @__PURE__ */ (
|
|
2095
|
-
onWheel:
|
|
2096
|
-
onPointerDown:
|
|
2097
|
-
onPointerMove:
|
|
2098
|
-
onPointerUp:
|
|
2099
|
-
onPointerOut:
|
|
2100
|
-
onPointerLeave:
|
|
2101
|
-
onPointerCancel:
|
|
1567
|
+
return /* @__PURE__ */ a("div", {
|
|
1568
|
+
onWheel: m,
|
|
1569
|
+
onPointerDown: h,
|
|
1570
|
+
onPointerMove: g,
|
|
1571
|
+
onPointerUp: _,
|
|
1572
|
+
onPointerOut: _,
|
|
1573
|
+
onPointerLeave: _,
|
|
1574
|
+
onPointerCancel: _,
|
|
2102
1575
|
onDoubleClick: (e) => {
|
|
2103
1576
|
let { clientX: t, clientY: n, altKey: r, shiftKey: i, ctrlKey: a, metaKey: o, target: s } = e;
|
|
2104
|
-
|
|
1577
|
+
J.add(l, {
|
|
2105
1578
|
clientX: t,
|
|
2106
1579
|
clientY: n,
|
|
2107
1580
|
altKey: r,
|
|
@@ -2113,12 +1586,12 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2113
1586
|
});
|
|
2114
1587
|
},
|
|
2115
1588
|
style: { touchAction: "none" },
|
|
2116
|
-
ref:
|
|
1589
|
+
ref: f,
|
|
2117
1590
|
children: t
|
|
2118
1591
|
});
|
|
2119
|
-
},
|
|
2120
|
-
let [n] =
|
|
2121
|
-
return /* @__PURE__ */ (
|
|
1592
|
+
}, wt = ({ onResize: e, ...t }) => {
|
|
1593
|
+
let [n] = L((e) => [e.getBoardState]);
|
|
1594
|
+
return /* @__PURE__ */ a(Y, {
|
|
2122
1595
|
onDrag: ({ deltaX: t, deltaY: r, event: i }) => {
|
|
2123
1596
|
i.stopPropagation();
|
|
2124
1597
|
let { scale: a } = n();
|
|
@@ -2127,38 +1600,38 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2127
1600
|
height: r / a
|
|
2128
1601
|
});
|
|
2129
1602
|
},
|
|
2130
|
-
children: /* @__PURE__ */ (
|
|
1603
|
+
children: /* @__PURE__ */ a("div", { ...t })
|
|
2131
1604
|
});
|
|
2132
|
-
},
|
|
1605
|
+
}, Tt = K`
|
|
2133
1606
|
display: inline-block;
|
|
2134
1607
|
transition: transform 150ms;
|
|
2135
1608
|
user-select: none;
|
|
2136
1609
|
padding: 2px;
|
|
2137
1610
|
box-sizing: border-box;
|
|
2138
|
-
`,
|
|
1611
|
+
`, Et = K`
|
|
2139
1612
|
border: 2px dashed #db5034;
|
|
2140
1613
|
padding: 0px;
|
|
2141
1614
|
cursor: pointer;
|
|
2142
|
-
`,
|
|
1615
|
+
`, X = K`
|
|
2143
1616
|
position: absolute;
|
|
2144
1617
|
width: 0px;
|
|
2145
1618
|
height: 0px;
|
|
2146
|
-
`,
|
|
1619
|
+
`, Dt = K`
|
|
2147
1620
|
top: 0;
|
|
2148
1621
|
left: 0;
|
|
2149
|
-
`,
|
|
1622
|
+
`, Ot = K`
|
|
2150
1623
|
top: 0;
|
|
2151
1624
|
right: 0;
|
|
2152
|
-
`,
|
|
1625
|
+
`, kt = K`
|
|
2153
1626
|
bottom: 0;
|
|
2154
1627
|
left: 0;
|
|
2155
|
-
`,
|
|
1628
|
+
`, At = K`
|
|
2156
1629
|
bottom: 0;
|
|
2157
1630
|
right: 0;
|
|
2158
|
-
`,
|
|
1631
|
+
`, jt = K`
|
|
2159
1632
|
top: 50%;
|
|
2160
1633
|
left: 50%;
|
|
2161
|
-
`,
|
|
1634
|
+
`, Z = K`
|
|
2162
1635
|
position: absolute;
|
|
2163
1636
|
|
|
2164
1637
|
width: 10px;
|
|
@@ -2166,20 +1639,20 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2166
1639
|
border: 2px solid #db5034;
|
|
2167
1640
|
background-color: #db5034;
|
|
2168
1641
|
cursor: move;
|
|
2169
|
-
`,
|
|
1642
|
+
`, Mt = K`
|
|
2170
1643
|
cursor: ew-resize;
|
|
2171
1644
|
right: -6px;
|
|
2172
1645
|
top: calc(50% - 5px);
|
|
2173
|
-
`,
|
|
1646
|
+
`, Nt = K`
|
|
2174
1647
|
cursor: ns-resize;
|
|
2175
1648
|
bottom: -6px;
|
|
2176
1649
|
left: calc(50% - 5px);
|
|
2177
|
-
`,
|
|
1650
|
+
`, Pt = K`
|
|
2178
1651
|
cursor: nwse-resize;
|
|
2179
1652
|
bottom: -6px;
|
|
2180
1653
|
right: -6px;
|
|
2181
|
-
`,
|
|
2182
|
-
className: `syncboard-error-item ${
|
|
1654
|
+
`, Ft = ({ onReload: e }) => /* @__PURE__ */ o("div", {
|
|
1655
|
+
className: `syncboard-error-item ${K({
|
|
2183
1656
|
width: "100px",
|
|
2184
1657
|
display: "flex",
|
|
2185
1658
|
flexDirection: "column",
|
|
@@ -2187,11 +1660,11 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2187
1660
|
textAlign: "center",
|
|
2188
1661
|
color: "red"
|
|
2189
1662
|
})}`,
|
|
2190
|
-
children: ["Sorry, this item seems broken.", /* @__PURE__ */ (
|
|
1663
|
+
children: ["Sorry, this item seems broken.", /* @__PURE__ */ a("button", {
|
|
2191
1664
|
onClick: e,
|
|
2192
1665
|
children: "Reload it"
|
|
2193
1666
|
})]
|
|
2194
|
-
}),
|
|
1667
|
+
}), It = class extends e.Component {
|
|
2195
1668
|
constructor(e) {
|
|
2196
1669
|
super(e), this.state = {
|
|
2197
1670
|
hasError: !1,
|
|
@@ -2209,11 +1682,11 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2209
1682
|
}
|
|
2210
1683
|
render() {
|
|
2211
1684
|
let { ErrorComponent: e } = this.props;
|
|
2212
|
-
return this.state.hasError ? /* @__PURE__ */ (
|
|
1685
|
+
return this.state.hasError ? /* @__PURE__ */ a(e, { onReload: this.onReload }) : this.props.children;
|
|
2213
1686
|
}
|
|
2214
|
-
},
|
|
1687
|
+
}, Lt = (e) => {
|
|
2215
1688
|
e.target.className = "";
|
|
2216
|
-
},
|
|
1689
|
+
}, Rt = ({ width: e, height: t, actualWidth: n, actualHeight: r, prevState: i, keepRatio: a }) => {
|
|
2217
1690
|
let { width: o, height: s } = i;
|
|
2218
1691
|
if ([o, s] = [parseFloat(o), parseFloat(s)], (!o || Number.isNaN(Number(o))) && (o = n), (!s || Number.isNaN(Number(s))) && (s = r), a) {
|
|
2219
1692
|
let n = o / s;
|
|
@@ -2228,25 +1701,25 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2228
1701
|
width: (o + e).toFixed(1),
|
|
2229
1702
|
height: (s + t).toFixed(1)
|
|
2230
1703
|
};
|
|
2231
|
-
},
|
|
1704
|
+
}, zt = {
|
|
2232
1705
|
w: !0,
|
|
2233
1706
|
h: !0,
|
|
2234
1707
|
b: !0
|
|
2235
|
-
},
|
|
2236
|
-
let
|
|
1708
|
+
}, Bt = t(({ setState: t, state: { type: n, rotation: r = 0, id: s, locked: c, extraClasses: l, ...u } = {}, animate: d = "hvr-pop", isSelected: f, itemMap: p, showResizeHandle: m = !0 }) => {
|
|
1709
|
+
let h = e.useRef(null), [g] = L((e) => [e.config.uid]), { component: _ = () => null, resizeDirections: v = zt, resize: y = Rt } = p[n], b = e.useCallback((e, n = !1) => t(s, e, n), [t, s]);
|
|
2237
1710
|
e.useEffect(() => {
|
|
2238
|
-
|
|
2239
|
-
}, [
|
|
2240
|
-
let
|
|
1711
|
+
h.current.className = d;
|
|
1712
|
+
}, [d]);
|
|
1713
|
+
let x = [
|
|
2241
1714
|
"item",
|
|
2242
|
-
|
|
2243
|
-
|
|
1715
|
+
s,
|
|
1716
|
+
Tt
|
|
2244
1717
|
];
|
|
2245
|
-
|
|
2246
|
-
let
|
|
2247
|
-
|
|
2248
|
-
let { offsetWidth: i, offsetHeight: a } =
|
|
2249
|
-
return
|
|
1718
|
+
c && x.push("locked"), f && (x.push("selected"), x.push(Et)), Array.isArray(l) && x.concat(l);
|
|
1719
|
+
let S = x.join(" "), C = ({ width: e = 0, height: t = 0, keepRatio: n }) => {
|
|
1720
|
+
b((r) => {
|
|
1721
|
+
let { offsetWidth: i, offsetHeight: a } = h.current;
|
|
1722
|
+
return y({
|
|
2250
1723
|
prevState: r,
|
|
2251
1724
|
width: e,
|
|
2252
1725
|
height: t,
|
|
@@ -2255,114 +1728,114 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2255
1728
|
keepRatio: n
|
|
2256
1729
|
});
|
|
2257
1730
|
});
|
|
2258
|
-
}, x = ({ width: e }) => {
|
|
2259
|
-
b({ width: e });
|
|
2260
|
-
}, C = ({ height: e }) => {
|
|
2261
|
-
b({ height: e });
|
|
2262
1731
|
}, w = ({ width: e }) => {
|
|
2263
|
-
|
|
1732
|
+
C({ width: e });
|
|
1733
|
+
}, T = ({ height: e }) => {
|
|
1734
|
+
C({ height: e });
|
|
1735
|
+
}, E = ({ width: e }) => {
|
|
1736
|
+
C({
|
|
2264
1737
|
height: e,
|
|
2265
1738
|
width: e,
|
|
2266
1739
|
keepRatio: !0
|
|
2267
1740
|
});
|
|
2268
1741
|
};
|
|
2269
|
-
return /* @__PURE__ */ (
|
|
1742
|
+
return /* @__PURE__ */ a("div", {
|
|
2270
1743
|
style: { transform: `rotate(${r}deg` },
|
|
2271
|
-
"data-id":
|
|
2272
|
-
id: `${
|
|
2273
|
-
className:
|
|
2274
|
-
children: /* @__PURE__ */ (
|
|
1744
|
+
"data-id": s,
|
|
1745
|
+
id: `${g}__${s}`,
|
|
1746
|
+
className: S,
|
|
1747
|
+
children: /* @__PURE__ */ o("div", {
|
|
2275
1748
|
style: { display: "flex" },
|
|
2276
|
-
ref:
|
|
2277
|
-
onAnimationEnd:
|
|
1749
|
+
ref: h,
|
|
1750
|
+
onAnimationEnd: Lt,
|
|
2278
1751
|
onKeyDown: (e) => e.stopPropagation(),
|
|
2279
1752
|
onKeyUp: (e) => e.stopPropagation(),
|
|
2280
1753
|
children: [
|
|
2281
|
-
/* @__PURE__ */ (
|
|
2282
|
-
itemId:
|
|
2283
|
-
state:
|
|
2284
|
-
ErrorComponent:
|
|
2285
|
-
children: /* @__PURE__ */ (
|
|
2286
|
-
...
|
|
2287
|
-
id:
|
|
2288
|
-
setState:
|
|
1754
|
+
/* @__PURE__ */ a(It, {
|
|
1755
|
+
itemId: s,
|
|
1756
|
+
state: u,
|
|
1757
|
+
ErrorComponent: p?.error?.component || Ft,
|
|
1758
|
+
children: /* @__PURE__ */ a(_, {
|
|
1759
|
+
...u,
|
|
1760
|
+
id: s,
|
|
1761
|
+
setState: b
|
|
2289
1762
|
})
|
|
2290
1763
|
}),
|
|
2291
|
-
/* @__PURE__ */ (
|
|
2292
|
-
/* @__PURE__ */ (
|
|
2293
|
-
/* @__PURE__ */ (
|
|
2294
|
-
/* @__PURE__ */ (
|
|
2295
|
-
/* @__PURE__ */ (
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
className: `${
|
|
2299
|
-
onResize:
|
|
1764
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${Dt}` }),
|
|
1765
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${Ot}` }),
|
|
1766
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${At}` }),
|
|
1767
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${kt}` }),
|
|
1768
|
+
/* @__PURE__ */ a("div", { className: `center ${X} ${jt}` }),
|
|
1769
|
+
m && /* @__PURE__ */ o(i, { children: [
|
|
1770
|
+
v.b && /* @__PURE__ */ a(wt, {
|
|
1771
|
+
className: `${Z} ${Pt}`,
|
|
1772
|
+
onResize: E
|
|
2300
1773
|
}),
|
|
2301
|
-
|
|
2302
|
-
className: `${
|
|
2303
|
-
onResize:
|
|
1774
|
+
v.h && /* @__PURE__ */ a(wt, {
|
|
1775
|
+
className: `${Z} ${Nt}`,
|
|
1776
|
+
onResize: T
|
|
2304
1777
|
}),
|
|
2305
|
-
|
|
2306
|
-
className: `${
|
|
2307
|
-
onResize:
|
|
1778
|
+
v.w && /* @__PURE__ */ a(wt, {
|
|
1779
|
+
className: `${Z} ${Mt}`,
|
|
1780
|
+
onResize: w
|
|
2308
1781
|
})
|
|
2309
1782
|
] })
|
|
2310
1783
|
]
|
|
2311
1784
|
})
|
|
2312
1785
|
});
|
|
2313
|
-
}, ({ state: e, setState: t, isSelected: n, showResizeHandle: r }, { state: i, setState: a, isSelected: o, showResizeHandle: s }) => n === o && r === s && t === a && (0,
|
|
1786
|
+
}, ({ state: e, setState: t, isSelected: n, showResizeHandle: r }, { state: i, setState: a, isSelected: o, showResizeHandle: s }) => n === o && r === s && t === a && (0, gt.default)(e, i)), Vt = (e) => e, Ht = t(({ state: e = {}, getCurrentUser: t, className: n, ...r }) => {
|
|
2314
1787
|
if (!r.itemMap[e.type]) return null;
|
|
2315
|
-
let { stateHook: i =
|
|
2316
|
-
return /* @__PURE__ */ (
|
|
1788
|
+
let { stateHook: i = Vt } = r.itemMap[e.type], { x: o = 0, y: s = 0, layer: c = 0, moving: l, ...u } = i(e, { currentUser: t?.() }), d = (c + 4) * 10 + 100 + (l ? 5 : 0);
|
|
1789
|
+
return /* @__PURE__ */ a("div", {
|
|
2317
1790
|
className: n,
|
|
2318
1791
|
style: {
|
|
2319
|
-
transform: `translate(${
|
|
2320
|
-
zIndex:
|
|
1792
|
+
transform: `translate(${o}px, ${s}px)`,
|
|
1793
|
+
zIndex: d
|
|
2321
1794
|
},
|
|
2322
|
-
children: /* @__PURE__ */ (
|
|
1795
|
+
children: /* @__PURE__ */ a(Bt, {
|
|
2323
1796
|
...r,
|
|
2324
1797
|
showResizeHandle: r.isSelected && r.showResizeHandle,
|
|
2325
|
-
state:
|
|
1798
|
+
state: u
|
|
2326
1799
|
})
|
|
2327
1800
|
});
|
|
2328
|
-
}),
|
|
2329
|
-
let { updateItem: e } =
|
|
1801
|
+
}), Ut = () => {
|
|
1802
|
+
let { updateItem: e } = V(), [t, n] = I((e) => [e.itemIds, e.items]), [r, i, o, s] = L((e) => [
|
|
2330
1803
|
e.config.boardSize,
|
|
2331
1804
|
e.config.showResizeHandle,
|
|
2332
1805
|
e.config.itemTemplates,
|
|
2333
1806
|
e.selection
|
|
2334
|
-
]), [
|
|
1807
|
+
]), [c] = U((e) => [e.getUser]), l = K({
|
|
2335
1808
|
position: "absolute",
|
|
2336
1809
|
top: `${r / 2}px`,
|
|
2337
1810
|
left: `${r / 2}px`,
|
|
2338
1811
|
display: "inline-block",
|
|
2339
1812
|
lineHeight: 0
|
|
2340
1813
|
});
|
|
2341
|
-
return t.map((t) => /* @__PURE__ */ (
|
|
1814
|
+
return t.map((t) => /* @__PURE__ */ a(Ht, {
|
|
2342
1815
|
state: n[t],
|
|
2343
1816
|
setState: e,
|
|
2344
|
-
isSelected:
|
|
2345
|
-
itemMap:
|
|
1817
|
+
isSelected: s.includes(t),
|
|
1818
|
+
itemMap: o,
|
|
2346
1819
|
boardSize: r,
|
|
2347
|
-
getCurrentUser:
|
|
1820
|
+
getCurrentUser: c,
|
|
2348
1821
|
showResizeHandle: i,
|
|
2349
|
-
className:
|
|
1822
|
+
className: l
|
|
2350
1823
|
}, t));
|
|
2351
|
-
},
|
|
1824
|
+
}, Wt = K({
|
|
2352
1825
|
zIndex: 210,
|
|
2353
1826
|
position: "absolute",
|
|
2354
1827
|
backgroundColor: "hsla(0, 40%, 50%, 10%)",
|
|
2355
1828
|
border: "2px solid hsl(0, 55%, 40%)"
|
|
2356
|
-
}),
|
|
1829
|
+
}), Gt = (e, t, n = !1) => {
|
|
2357
1830
|
let r = t.getElementsByClassName("selector");
|
|
2358
1831
|
if (!r.length) return [];
|
|
2359
1832
|
let i = r[0];
|
|
2360
1833
|
return Array.from(t.getElementsByClassName("item")).filter((t) => {
|
|
2361
|
-
let r = e[
|
|
2362
|
-
return !r || !n && r.locked ? !1 :
|
|
2363
|
-
}).map((e) =>
|
|
2364
|
-
},
|
|
2365
|
-
let [r, i,
|
|
1834
|
+
let r = e[F(t)];
|
|
1835
|
+
return !r || !n && r.locked ? !1 : ae(t, i);
|
|
1836
|
+
}).map((e) => F(e));
|
|
1837
|
+
}, Kt = ({ children: t, moveFirst: n }) => {
|
|
1838
|
+
let [r, i, s, c, l, u] = L((e) => [
|
|
2366
1839
|
e.getSelection,
|
|
2367
1840
|
e.clear,
|
|
2368
1841
|
e.setSelection,
|
|
@@ -2370,107 +1843,107 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2370
1843
|
e.getConfiguration,
|
|
2371
1844
|
e.getBoardState,
|
|
2372
1845
|
e.updateBoardState
|
|
2373
|
-
]), { findElementUnderPointer:
|
|
2374
|
-
return
|
|
2375
|
-
e.key === "l" &&
|
|
2376
|
-
}),
|
|
2377
|
-
e.key === "l" &&
|
|
1846
|
+
]), { findElementUnderPointer: d } = V(), [p] = I((e) => [e.getItems]), [m, h] = e.useState({}), [, g] = e.useTransition(), [_, v] = e.useState(!1), y = e.useRef(null), b = e.useRef({ moving: !1 });
|
|
1847
|
+
return f(document, "keydown", (e) => {
|
|
1848
|
+
e.key === "l" && v(!0);
|
|
1849
|
+
}), f(document, "keyup", (e) => {
|
|
1850
|
+
e.key === "l" && v(!1);
|
|
2378
1851
|
}), e.useEffect(() => (i(), () => {
|
|
2379
1852
|
i();
|
|
2380
1853
|
}), [i]), e.useEffect(() => {
|
|
2381
|
-
if (
|
|
2382
|
-
let e =
|
|
2383
|
-
|
|
2384
|
-
|
|
1854
|
+
if (b.current.moving) {
|
|
1855
|
+
let e = p(), { boardWrapper: t } = l(), n = Gt(e, t, _);
|
|
1856
|
+
g(() => {
|
|
1857
|
+
s(n);
|
|
2385
1858
|
});
|
|
2386
1859
|
}
|
|
2387
1860
|
}, [
|
|
1861
|
+
l,
|
|
1862
|
+
p,
|
|
1863
|
+
m,
|
|
2388
1864
|
s,
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
a,
|
|
2392
|
-
m
|
|
2393
|
-
]), /* @__PURE__ */ (0, S.jsx)(qt, {
|
|
1865
|
+
_
|
|
1866
|
+
]), /* @__PURE__ */ a(Y, {
|
|
2394
1867
|
onDragStart: async (e) => {
|
|
2395
|
-
await
|
|
2396
|
-
|
|
2397
|
-
}),
|
|
1868
|
+
await d(e) || (b.current.moving = !0, g(() => {
|
|
1869
|
+
u({ selecting: !0 });
|
|
1870
|
+
}), y.current.style.cursor = "crosshair");
|
|
2398
1871
|
},
|
|
2399
1872
|
onDrag: ({ distanceY: e, distanceX: t, startX: n, startY: r }) => {
|
|
2400
|
-
if (
|
|
2401
|
-
let { top: i, left: a } =
|
|
2402
|
-
t > 0 ? (
|
|
2403
|
-
...
|
|
1873
|
+
if (b.current.moving) {
|
|
1874
|
+
let { top: i, left: a } = y.current.getBoundingClientRect(), o = n - a, s = r - i;
|
|
1875
|
+
t > 0 ? (b.current.left = o, b.current.width = t) : (b.current.left = o + t, b.current.width = -t), e > 0 ? (b.current.top = s, b.current.height = e) : (b.current.top = s + e, b.current.height = -e), h({
|
|
1876
|
+
...b.current,
|
|
2404
1877
|
moving: !0
|
|
2405
1878
|
});
|
|
2406
1879
|
}
|
|
2407
1880
|
},
|
|
2408
1881
|
onDragEnd: () => {
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
}),
|
|
1882
|
+
b.current.moving && (g(() => {
|
|
1883
|
+
u({ selecting: !1 });
|
|
1884
|
+
}), b.current.moving = !1, h({ moving: !1 }), y.current.style.cursor = "auto");
|
|
2412
1885
|
},
|
|
2413
1886
|
onTap: (e) => {
|
|
2414
|
-
let { target: t, ctrlKey: n, metaKey:
|
|
2415
|
-
if (!
|
|
1887
|
+
let { target: t, ctrlKey: n, metaKey: a } = e, o = d(e);
|
|
1888
|
+
if (!o && A(t, "board")) i();
|
|
2416
1889
|
else {
|
|
2417
|
-
let e =
|
|
1890
|
+
let e = F(o);
|
|
2418
1891
|
if (!e) {
|
|
2419
1892
|
i();
|
|
2420
1893
|
return;
|
|
2421
1894
|
}
|
|
2422
1895
|
let t = r();
|
|
2423
|
-
|
|
1896
|
+
o && !t.includes(e) && (n || a ? c([e]) : s([e]));
|
|
2424
1897
|
}
|
|
2425
1898
|
},
|
|
2426
1899
|
onLongTap: ({ target: e }) => {
|
|
2427
|
-
let t =
|
|
1900
|
+
let t = A(e, "item");
|
|
2428
1901
|
if (t) {
|
|
2429
|
-
let e =
|
|
2430
|
-
|
|
1902
|
+
let e = F(t);
|
|
1903
|
+
s([e]);
|
|
2431
1904
|
}
|
|
2432
1905
|
},
|
|
2433
1906
|
mainAction: n ? "pan" : "drag",
|
|
2434
|
-
children: /* @__PURE__ */ (
|
|
2435
|
-
ref:
|
|
2436
|
-
children: [
|
|
1907
|
+
children: /* @__PURE__ */ o("div", {
|
|
1908
|
+
ref: y,
|
|
1909
|
+
children: [m.moving && /* @__PURE__ */ a("div", {
|
|
2437
1910
|
style: {
|
|
2438
|
-
transform: `translate(${
|
|
2439
|
-
height: `${
|
|
2440
|
-
width: `${
|
|
1911
|
+
transform: `translate(${m.left}px, ${m.top}px)`,
|
|
1912
|
+
height: `${m.height}px`,
|
|
1913
|
+
width: `${m.width}px`
|
|
2441
1914
|
},
|
|
2442
|
-
className: `selector ${
|
|
1915
|
+
className: `selector ${Wt}`
|
|
2443
1916
|
}), t]
|
|
2444
1917
|
})
|
|
2445
1918
|
});
|
|
2446
|
-
},
|
|
2447
|
-
let { moveItems: n, placeItems: r, findElementUnderPointer: i } =
|
|
1919
|
+
}, qt = ({ children: t }) => {
|
|
1920
|
+
let { moveItems: n, placeItems: r, findElementUnderPointer: i } = V(), { vectorFromWrapperToBoard: o } = z(), [s, c, l, u, d] = L((e) => [
|
|
2448
1921
|
e.select,
|
|
2449
1922
|
e.setSelection,
|
|
2450
1923
|
e.getSelection,
|
|
2451
1924
|
e.getBoardState,
|
|
2452
1925
|
e.updateBoardState
|
|
2453
|
-
]), [
|
|
2454
|
-
return
|
|
1926
|
+
]), [p] = I((e) => [e.getBoardConfig]), m = e.useRef({}), h = e.useRef({ items: [] });
|
|
1927
|
+
return f(document, "keydown", (e) => {
|
|
2455
1928
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return;
|
|
2456
|
-
let t =
|
|
1929
|
+
let t = l();
|
|
2457
1930
|
if (t.length) {
|
|
2458
|
-
let { gridSize: i = 1 } =
|
|
1931
|
+
let { gridSize: i = 1 } = p(), a = 0, s = 0;
|
|
2459
1932
|
switch (e.key) {
|
|
2460
1933
|
case "ArrowLeft":
|
|
2461
|
-
|
|
1934
|
+
a = -10;
|
|
2462
1935
|
break;
|
|
2463
1936
|
case "ArrowRight":
|
|
2464
|
-
|
|
1937
|
+
a = 10;
|
|
2465
1938
|
break;
|
|
2466
1939
|
case "ArrowUp":
|
|
2467
1940
|
s = -10;
|
|
2468
1941
|
break;
|
|
2469
1942
|
case "ArrowDown": s = 10;
|
|
2470
1943
|
}
|
|
2471
|
-
if (
|
|
2472
|
-
e.shiftKey && (
|
|
2473
|
-
let [c, l] = a
|
|
1944
|
+
if (a || s) {
|
|
1945
|
+
e.shiftKey && (a *= 5, s *= 5), (e.ctrlKey || e.altKey || e.metaKey) && (a /= 10, s /= 10);
|
|
1946
|
+
let [c, l] = o(a, s);
|
|
2474
1947
|
n(t, {
|
|
2475
1948
|
x: c,
|
|
2476
1949
|
y: l
|
|
@@ -2480,62 +1953,62 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2480
1953
|
}), e.preventDefault();
|
|
2481
1954
|
}
|
|
2482
1955
|
}
|
|
2483
|
-
}), /* @__PURE__ */ (
|
|
1956
|
+
}), /* @__PURE__ */ a(Y, {
|
|
2484
1957
|
onDragStart: (e) => {
|
|
2485
1958
|
let { ctrlKey: t, metaKey: n, event: r } = e, a = i(e);
|
|
2486
1959
|
if (a) {
|
|
2487
1960
|
r.stopPropagation();
|
|
2488
|
-
let e =
|
|
2489
|
-
|
|
2490
|
-
let i =
|
|
2491
|
-
e.includes(i) || (t || n ? (
|
|
1961
|
+
let e = l();
|
|
1962
|
+
h.current.items = e;
|
|
1963
|
+
let i = F(a);
|
|
1964
|
+
e.includes(i) || (t || n ? (h.current.items = [...e, i], s([i])) : (h.current.items = [i], c([i]))), Object.assign(m.current, { moving: !0 });
|
|
2492
1965
|
}
|
|
2493
1966
|
},
|
|
2494
1967
|
onDrag: ({ deltaX: e, deltaY: t, event: r }) => {
|
|
2495
|
-
if (
|
|
1968
|
+
if (m.current.moving) {
|
|
2496
1969
|
r.stopPropagation();
|
|
2497
|
-
let { movingItems: i } =
|
|
2498
|
-
n(
|
|
2499
|
-
x:
|
|
1970
|
+
let { movingItems: i } = u(), [a, s] = o(e, t);
|
|
1971
|
+
n(h.current.items, {
|
|
1972
|
+
x: a,
|
|
2500
1973
|
y: s
|
|
2501
|
-
}, !0), i ||
|
|
1974
|
+
}, !0), i || d({ movingItems: !0 });
|
|
2502
1975
|
}
|
|
2503
1976
|
},
|
|
2504
1977
|
onDragEnd: () => {
|
|
2505
|
-
if (
|
|
2506
|
-
let { gridSize: e = 1 } =
|
|
2507
|
-
|
|
1978
|
+
if (m.current.moving) {
|
|
1979
|
+
let { gridSize: e = 1 } = p(), t = e || 1;
|
|
1980
|
+
m.current = { moving: !1 }, r(h.current.items, {
|
|
2508
1981
|
type: "grid",
|
|
2509
1982
|
size: t
|
|
2510
|
-
}),
|
|
1983
|
+
}), d({ movingItems: !1 });
|
|
2511
1984
|
}
|
|
2512
1985
|
},
|
|
2513
1986
|
children: t
|
|
2514
1987
|
});
|
|
2515
|
-
},
|
|
1988
|
+
}, Jt = (t) => {
|
|
2516
1989
|
let n = e.useRef({
|
|
2517
1990
|
hover: !1,
|
|
2518
1991
|
x: 0,
|
|
2519
1992
|
y: 0
|
|
2520
1993
|
});
|
|
2521
|
-
return
|
|
1994
|
+
return f(t, "mousemove", (e) => {
|
|
2522
1995
|
let { clientX: t, clientY: r } = e;
|
|
2523
1996
|
n.current.x = t, n.current.y = r;
|
|
2524
|
-
}),
|
|
1997
|
+
}), f(t, "mouseenter", () => {
|
|
2525
1998
|
n.current.hover = !0;
|
|
2526
|
-
}),
|
|
1999
|
+
}), f(t, "mouseleave", () => {
|
|
2527
2000
|
n.current.hover = !1;
|
|
2528
2001
|
}), e.useCallback(() => n.current, []);
|
|
2529
|
-
},
|
|
2002
|
+
}, Yt = [...[
|
|
2530
2003
|
,
|
|
2531
2004
|
,
|
|
2532
2005
|
,
|
|
2533
2006
|
,
|
|
2534
2007
|
,
|
|
2535
|
-
].keys()].map((e) => `Digit${e + 1}`),
|
|
2536
|
-
let [t, n] = e.useState({}), [r, i] =
|
|
2537
|
-
return
|
|
2538
|
-
if (!["INPUT", "TEXTAREA"].includes(e.target.tagName) &&
|
|
2008
|
+
].keys()].map((e) => `Digit${e + 1}`), Xt = () => {
|
|
2009
|
+
let [t, n] = e.useState({}), [r, i] = L((e) => [e.getBoardState, e.updateBoardState]);
|
|
2010
|
+
return f(document, "keydown", (e) => {
|
|
2011
|
+
if (!["INPUT", "TEXTAREA"].includes(e.target.tagName) && Yt.includes(e.code)) {
|
|
2539
2012
|
let a = e.code, { translateX: o, translateY: s, scale: c } = r();
|
|
2540
2013
|
e.altKey || e.metaKey || e.ctrlKey || e.shiftKey ? n((e) => ({
|
|
2541
2014
|
...e,
|
|
@@ -2547,8 +2020,8 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2547
2020
|
})) : t[a] && i(t[a]), e.preventDefault();
|
|
2548
2021
|
}
|
|
2549
2022
|
}), null;
|
|
2550
|
-
},
|
|
2551
|
-
let r = e.useRef(null), [i,
|
|
2023
|
+
}, Zt = ({ children: t, moveFirst: n = !1 }) => {
|
|
2024
|
+
let r = e.useRef(null), [i, o, s, c, l] = L((e) => [
|
|
2552
2025
|
{
|
|
2553
2026
|
translateX: e.boardState.translateX,
|
|
2554
2027
|
translateY: e.boardState.translateY,
|
|
@@ -2559,19 +2032,19 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2559
2032
|
e.getConfiguration,
|
|
2560
2033
|
e.updateBoardState,
|
|
2561
2034
|
e.getSelection
|
|
2562
|
-
]), { zoomToCenter:
|
|
2563
|
-
|
|
2564
|
-
let
|
|
2565
|
-
let { itemExtent: e } =
|
|
2566
|
-
|
|
2567
|
-
}, [
|
|
2035
|
+
]), { zoomToCenter: u, zoomToExtent: d, moveBoard: p } = z(), [m, h] = e.useState(!1), g = e.useRef({}), _ = Jt(r);
|
|
2036
|
+
Xt();
|
|
2037
|
+
let v = e.useCallback(() => {
|
|
2038
|
+
let { itemExtent: e } = s();
|
|
2039
|
+
d(e);
|
|
2040
|
+
}, [s, d]);
|
|
2568
2041
|
return e.useEffect(() => {
|
|
2569
|
-
!
|
|
2042
|
+
!m && o.radius && (v(), h(!0));
|
|
2570
2043
|
}, [
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
]),
|
|
2044
|
+
v,
|
|
2045
|
+
m,
|
|
2046
|
+
o
|
|
2047
|
+
]), f(document, "keydown", (e) => {
|
|
2575
2048
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return;
|
|
2576
2049
|
let t = 0, n = 0, r = 1;
|
|
2577
2050
|
switch (e.key) {
|
|
@@ -2593,44 +2066,44 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2593
2066
|
case "PageDown": r = .8;
|
|
2594
2067
|
}
|
|
2595
2068
|
if (t || n || r !== 1) {
|
|
2596
|
-
let i =
|
|
2069
|
+
let i = l();
|
|
2597
2070
|
if (r === 1 && i.length) return;
|
|
2598
|
-
e.shiftKey && (t *= 5, n *= 5), (e.ctrlKey || e.altKey || e.metaKey) && (t /= 5, n /= 5),
|
|
2071
|
+
e.shiftKey && (t *= 5, n *= 5), (e.ctrlKey || e.altKey || e.metaKey) && (t /= 5, n /= 5), p(({ translateX: e, translateY: r }) => ({
|
|
2599
2072
|
translateX: e + t,
|
|
2600
2073
|
translateY: r + n
|
|
2601
|
-
})),
|
|
2074
|
+
})), u({ factor: r }), e.preventDefault();
|
|
2602
2075
|
}
|
|
2603
|
-
e.key === " " && !e.repeat &&
|
|
2076
|
+
e.key === " " && !e.repeat && _().hover && u({
|
|
2604
2077
|
factor: 3,
|
|
2605
|
-
to:
|
|
2078
|
+
to: _()
|
|
2606
2079
|
});
|
|
2607
|
-
}),
|
|
2608
|
-
["INPUT", "TEXTAREA"].includes(e.target.tagName) || e.key === " " &&
|
|
2080
|
+
}), f(document, "keyup", (e) => {
|
|
2081
|
+
["INPUT", "TEXTAREA"].includes(e.target.tagName) || e.key === " " && _().hover && u({
|
|
2609
2082
|
factor: 1 / 3,
|
|
2610
|
-
to:
|
|
2083
|
+
to: _()
|
|
2611
2084
|
});
|
|
2612
|
-
}), /* @__PURE__ */ (
|
|
2085
|
+
}), /* @__PURE__ */ a(Y, {
|
|
2613
2086
|
onPan: ({ deltaX: e, deltaY: t }) => {
|
|
2614
|
-
|
|
2087
|
+
p(({ translateX: n, translateY: r }) => ({
|
|
2615
2088
|
translateX: n + e,
|
|
2616
2089
|
translateY: r + t
|
|
2617
|
-
})), clearTimeout(
|
|
2618
|
-
|
|
2619
|
-
}, 200),
|
|
2090
|
+
})), clearTimeout(g.current.pan), g.current.pan = setTimeout(() => {
|
|
2091
|
+
c({ panning: !1 });
|
|
2092
|
+
}, 200), c({ panning: !0 });
|
|
2620
2093
|
},
|
|
2621
2094
|
onZoom: ({ clientX: e, clientY: t, scale: n }) => {
|
|
2622
|
-
|
|
2095
|
+
u({
|
|
2623
2096
|
to: {
|
|
2624
2097
|
x: e,
|
|
2625
2098
|
y: t
|
|
2626
2099
|
},
|
|
2627
2100
|
factor: 1 - n / 500
|
|
2628
|
-
}), clearTimeout(
|
|
2629
|
-
|
|
2630
|
-
}, 200),
|
|
2101
|
+
}), clearTimeout(g.current.zoom), g.current.zoom = setTimeout(() => {
|
|
2102
|
+
c({ zooming: !1 });
|
|
2103
|
+
}, 200), c({ zooming: !0 });
|
|
2631
2104
|
},
|
|
2632
2105
|
mainAction: n ? "pan" : "drag",
|
|
2633
|
-
children: /* @__PURE__ */ (
|
|
2106
|
+
children: /* @__PURE__ */ a("div", {
|
|
2634
2107
|
style: {
|
|
2635
2108
|
display: "inline-block",
|
|
2636
2109
|
transformOrigin: "top left",
|
|
@@ -2641,7 +2114,7 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2641
2114
|
children: t
|
|
2642
2115
|
})
|
|
2643
2116
|
});
|
|
2644
|
-
},
|
|
2117
|
+
}, Qt = K({
|
|
2645
2118
|
position: "absolute",
|
|
2646
2119
|
top: 0,
|
|
2647
2120
|
left: 0,
|
|
@@ -2649,8 +2122,8 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2649
2122
|
backgroundColor: "hsla(0, 40%, 50%, 0%)",
|
|
2650
2123
|
border: "2px dashed hsl(20, 55%, 40%)",
|
|
2651
2124
|
pointerEvents: "none"
|
|
2652
|
-
}),
|
|
2653
|
-
let [t, n, r, i,
|
|
2125
|
+
}), $t = () => {
|
|
2126
|
+
let [t, n, r, i, o, { translateX: s, translateY: c, scale: l }] = L((e) => [
|
|
2654
2127
|
e.selection,
|
|
2655
2128
|
e.getSelection,
|
|
2656
2129
|
e.selectionBox,
|
|
@@ -2661,18 +2134,18 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2661
2134
|
translateY: e.boardState.translateY,
|
|
2662
2135
|
scale: e.boardState.scale
|
|
2663
2136
|
}
|
|
2664
|
-
]), [
|
|
2665
|
-
let e = n(), { boardWrapperRect: t, uid: r } =
|
|
2137
|
+
]), [d] = I((e) => [e.items]), f = e.useCallback(() => {
|
|
2138
|
+
let e = n(), { boardWrapperRect: t, uid: r } = o();
|
|
2666
2139
|
if (e.length === 0) {
|
|
2667
2140
|
i(null);
|
|
2668
2141
|
return;
|
|
2669
2142
|
}
|
|
2670
|
-
let
|
|
2671
|
-
if (!
|
|
2143
|
+
let a = oe(e, r);
|
|
2144
|
+
if (!a) {
|
|
2672
2145
|
i(null);
|
|
2673
2146
|
return;
|
|
2674
2147
|
}
|
|
2675
|
-
let { left: s, top: c, width: l, height: u } =
|
|
2148
|
+
let { left: s, top: c, width: l, height: u } = a, d = {
|
|
2676
2149
|
left: s - t.left,
|
|
2677
2150
|
top: c - t.top,
|
|
2678
2151
|
height: u,
|
|
@@ -2680,44 +2153,44 @@ var zt = /* @__PURE__ */ h((/* @__PURE__ */ p(((e, t) => {
|
|
|
2680
2153
|
};
|
|
2681
2154
|
i(d);
|
|
2682
2155
|
}, [
|
|
2683
|
-
|
|
2156
|
+
o,
|
|
2684
2157
|
n,
|
|
2685
2158
|
i
|
|
2686
|
-
]),
|
|
2159
|
+
]), p = u(f, [f], 300);
|
|
2687
2160
|
return e.useEffect(() => {
|
|
2688
|
-
|
|
2161
|
+
f(), p();
|
|
2689
2162
|
}, [
|
|
2690
2163
|
t,
|
|
2691
|
-
|
|
2692
|
-
o,
|
|
2164
|
+
d,
|
|
2693
2165
|
s,
|
|
2694
2166
|
c,
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2167
|
+
l,
|
|
2168
|
+
f,
|
|
2169
|
+
p
|
|
2170
|
+
]), !r || t.length < 2 ? null : /* @__PURE__ */ a("div", {
|
|
2698
2171
|
style: {
|
|
2699
2172
|
transform: `translate(${r.left}px, ${r.top}px)`,
|
|
2700
2173
|
height: `${r.height}px`,
|
|
2701
2174
|
width: `${r.width}px`
|
|
2702
2175
|
},
|
|
2703
|
-
className: `selection ${
|
|
2176
|
+
className: `selection ${Qt}`
|
|
2704
2177
|
});
|
|
2705
|
-
},
|
|
2706
|
-
let [e] =
|
|
2707
|
-
return e ? null : /* @__PURE__ */ (
|
|
2178
|
+
}, en = () => {
|
|
2179
|
+
let [e] = L((e) => [e.boardState.movingItems]);
|
|
2180
|
+
return e ? null : /* @__PURE__ */ a($t, {});
|
|
2708
2181
|
};
|
|
2709
2182
|
//#endregion
|
|
2710
2183
|
//#region node_modules/color2k/dist/index.exports.import.es.mjs
|
|
2711
|
-
function
|
|
2184
|
+
function tn(e, t, n) {
|
|
2712
2185
|
return Math.min(Math.max(e, n), t);
|
|
2713
2186
|
}
|
|
2714
|
-
var
|
|
2187
|
+
var Q = class extends Error {
|
|
2715
2188
|
constructor(e) {
|
|
2716
2189
|
super(`Failed to parse color: "${e}"`);
|
|
2717
2190
|
}
|
|
2718
2191
|
};
|
|
2719
|
-
function
|
|
2720
|
-
if (typeof e != "string") throw new
|
|
2192
|
+
function nn(e) {
|
|
2193
|
+
if (typeof e != "string") throw new Q(e);
|
|
2721
2194
|
if (e.trim().toLowerCase() === "transparent") return [
|
|
2722
2195
|
0,
|
|
2723
2196
|
0,
|
|
@@ -2725,52 +2198,52 @@ function kn(e) {
|
|
|
2725
2198
|
0
|
|
2726
2199
|
];
|
|
2727
2200
|
let t = e.trim();
|
|
2728
|
-
t =
|
|
2729
|
-
let n =
|
|
2201
|
+
t = fn.test(e) ? sn(e) : e;
|
|
2202
|
+
let n = cn.exec(t);
|
|
2730
2203
|
if (n) {
|
|
2731
2204
|
let e = Array.from(n).slice(1);
|
|
2732
2205
|
return [...e.slice(0, 3).map((e) => parseInt($(e, 2), 16)), parseInt($(e[3] || "f", 2), 16) / 255];
|
|
2733
2206
|
}
|
|
2734
|
-
let r =
|
|
2207
|
+
let r = ln.exec(t);
|
|
2735
2208
|
if (r) {
|
|
2736
2209
|
let e = Array.from(r).slice(1);
|
|
2737
2210
|
return [...e.slice(0, 3).map((e) => parseInt(e, 16)), parseInt(e[3] || "ff", 16) / 255];
|
|
2738
2211
|
}
|
|
2739
|
-
let i =
|
|
2212
|
+
let i = un.exec(t);
|
|
2740
2213
|
if (i) {
|
|
2741
2214
|
let e = Array.from(i).slice(1);
|
|
2742
2215
|
return [...e.slice(0, 3).map((e) => parseInt(e, 10)), parseFloat(e[3] || "1")];
|
|
2743
2216
|
}
|
|
2744
|
-
let a =
|
|
2217
|
+
let a = dn.exec(t);
|
|
2745
2218
|
if (a) {
|
|
2746
2219
|
let [t, n, r, i] = Array.from(a).slice(1).map(parseFloat);
|
|
2747
|
-
if (
|
|
2748
|
-
return [...
|
|
2220
|
+
if (tn(0, 100, n) !== n || tn(0, 100, r) !== r) throw new Q(e);
|
|
2221
|
+
return [...mn(t, n, r), Number.isNaN(i) ? 1 : i];
|
|
2749
2222
|
}
|
|
2750
|
-
throw new
|
|
2223
|
+
throw new Q(e);
|
|
2751
2224
|
}
|
|
2752
|
-
function
|
|
2225
|
+
function rn(e) {
|
|
2753
2226
|
let t = 5381, n = e.length;
|
|
2754
2227
|
for (; n;) t = t * 33 ^ e.charCodeAt(--n);
|
|
2755
2228
|
return (t >>> 0) % 2341;
|
|
2756
2229
|
}
|
|
2757
|
-
var
|
|
2758
|
-
let n =
|
|
2230
|
+
var an = (e) => parseInt(e.replace(/_/g, ""), 36), on = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((e, t) => {
|
|
2231
|
+
let n = an(t.substring(0, 3)), r = an(t.substring(3)).toString(16), i = "";
|
|
2759
2232
|
for (let e = 0; e < 6 - r.length; e++) i += "0";
|
|
2760
2233
|
return e[n] = `${i}${r}`, e;
|
|
2761
2234
|
}, {});
|
|
2762
|
-
function
|
|
2763
|
-
let t =
|
|
2764
|
-
if (!t) throw new
|
|
2235
|
+
function sn(e) {
|
|
2236
|
+
let t = on[rn(e.toLowerCase().trim())];
|
|
2237
|
+
if (!t) throw new Q(e);
|
|
2765
2238
|
return `#${t}`;
|
|
2766
2239
|
}
|
|
2767
|
-
var $ = (e, t) => Array.from(Array(t)).map(() => e).join(""),
|
|
2240
|
+
var $ = (e, t) => Array.from(Array(t)).map(() => e).join(""), cn = RegExp(`^#${$("([a-f0-9])", 3)}([a-f0-9])?$`, "i"), ln = RegExp(`^#${$("([a-f0-9]{2})", 3)}([a-f0-9]{2})?$`, "i"), un = RegExp(`^rgba?\\(\\s*(\\d+)\\s*${$(",\\s*(\\d+)\\s*", 2)}(?:,\\s*([\\d.]+))?\\s*\\)$`, "i"), dn = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i, fn = /^[a-z]+$/i, pn = (e) => Math.round(e * 255), mn = (e, t, n) => {
|
|
2768
2241
|
let r = n / 100;
|
|
2769
2242
|
if (t === 0) return [
|
|
2770
2243
|
r,
|
|
2771
2244
|
r,
|
|
2772
2245
|
r
|
|
2773
|
-
].map(
|
|
2246
|
+
].map(pn);
|
|
2774
2247
|
let i = (e % 360 + 360) % 360 / 60, a = (1 - Math.abs(2 * r - 1)) * (t / 100), o = a * (1 - Math.abs(i % 2 - 1)), s = 0, c = 0, l = 0;
|
|
2775
2248
|
i >= 0 && i < 1 ? (s = a, c = o) : i >= 1 && i < 2 ? (s = o, c = a) : i >= 2 && i < 3 ? (c = a, l = o) : i >= 3 && i < 4 ? (c = o, l = a) : i >= 4 && i < 5 ? (s = o, l = a) : i >= 5 && i < 6 && (s = a, l = o);
|
|
2776
2249
|
let u = r - a / 2;
|
|
@@ -2778,29 +2251,29 @@ var $ = (e, t) => Array.from(Array(t)).map(() => e).join(""), Pn = RegExp(`^#${$
|
|
|
2778
2251
|
s + u,
|
|
2779
2252
|
c + u,
|
|
2780
2253
|
l + u
|
|
2781
|
-
].map(
|
|
2254
|
+
].map(pn);
|
|
2782
2255
|
};
|
|
2783
|
-
function
|
|
2256
|
+
function hn(e) {
|
|
2784
2257
|
if (e === "transparent") return 0;
|
|
2785
2258
|
function t(e) {
|
|
2786
2259
|
let t = e / 255;
|
|
2787
2260
|
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
2788
2261
|
}
|
|
2789
|
-
let [n, r, i] =
|
|
2262
|
+
let [n, r, i] = nn(e);
|
|
2790
2263
|
return .2126 * t(n) + .7152 * t(r) + .0722 * t(i);
|
|
2791
2264
|
}
|
|
2792
|
-
function
|
|
2793
|
-
return
|
|
2265
|
+
function gn(e) {
|
|
2266
|
+
return hn(e) > .179;
|
|
2794
2267
|
}
|
|
2795
2268
|
//#endregion
|
|
2796
2269
|
//#region src/lib/board/Cursors/Cursor.jsx
|
|
2797
|
-
var
|
|
2270
|
+
var _n = K({
|
|
2798
2271
|
display: "flex",
|
|
2799
2272
|
flexDirection: "row",
|
|
2800
2273
|
alignItems: "center",
|
|
2801
2274
|
zIndex: 210,
|
|
2802
2275
|
pointerEvents: "none"
|
|
2803
|
-
}),
|
|
2276
|
+
}), vn = K({
|
|
2804
2277
|
fontWeight: "bold",
|
|
2805
2278
|
padding: "0 0.5em",
|
|
2806
2279
|
borderRadius: "2px",
|
|
@@ -2811,20 +2284,20 @@ var Un = Y({
|
|
|
2811
2284
|
marginTop: "1.7em",
|
|
2812
2285
|
whitespace: "nowrap",
|
|
2813
2286
|
pointerEvents: "none"
|
|
2814
|
-
}),
|
|
2815
|
-
let r =
|
|
2816
|
-
return /* @__PURE__ */ (
|
|
2817
|
-
className:
|
|
2818
|
-
children: [/* @__PURE__ */ (
|
|
2287
|
+
}), yn = e.memo(({ color: e = "#666", size: t = 40, text: n }) => {
|
|
2288
|
+
let r = gn(e) ? "#222" : "#EEE";
|
|
2289
|
+
return /* @__PURE__ */ o("div", {
|
|
2290
|
+
className: _n,
|
|
2291
|
+
children: [/* @__PURE__ */ o("svg", {
|
|
2819
2292
|
version: "1.1",
|
|
2820
2293
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2821
2294
|
viewBox: "1064.7701 445.5539 419.8101 717.0565",
|
|
2822
2295
|
width: t,
|
|
2823
2296
|
height: t,
|
|
2824
|
-
children: [/* @__PURE__ */ (
|
|
2297
|
+
children: [/* @__PURE__ */ a("path", {
|
|
2825
2298
|
d: "m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
|
|
2826
2299
|
style: { fill: r }
|
|
2827
|
-
}), /* @__PURE__ */ (
|
|
2300
|
+
}), /* @__PURE__ */ a("path", {
|
|
2828
2301
|
d: "m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",
|
|
2829
2302
|
style: {
|
|
2830
2303
|
fill: "white",
|
|
@@ -2832,125 +2305,125 @@ var Un = Y({
|
|
|
2832
2305
|
strokeWidth: 20
|
|
2833
2306
|
}
|
|
2834
2307
|
})]
|
|
2835
|
-
}), /* @__PURE__ */ (
|
|
2308
|
+
}), /* @__PURE__ */ a("div", {
|
|
2836
2309
|
style: {
|
|
2837
2310
|
color: r,
|
|
2838
2311
|
backgroundColor: e
|
|
2839
2312
|
},
|
|
2840
|
-
className:
|
|
2313
|
+
className: vn,
|
|
2841
2314
|
children: n
|
|
2842
2315
|
})]
|
|
2843
2316
|
});
|
|
2844
|
-
}),
|
|
2317
|
+
}), bn = K({
|
|
2845
2318
|
top: 0,
|
|
2846
2319
|
left: 0,
|
|
2847
2320
|
zIndex: 210,
|
|
2848
2321
|
position: "fixed",
|
|
2849
2322
|
pointerEvents: "none"
|
|
2850
|
-
}),
|
|
2851
|
-
className:
|
|
2323
|
+
}), xn = ({ pos: e, ...t }) => /* @__PURE__ */ a("div", {
|
|
2324
|
+
className: bn,
|
|
2852
2325
|
style: { transform: `translate(${e.x - 6}px, ${e.y - 15}px)` },
|
|
2853
|
-
children: /* @__PURE__ */ (
|
|
2854
|
-
}),
|
|
2855
|
-
let [t] =
|
|
2326
|
+
children: /* @__PURE__ */ a(yn, { ...t })
|
|
2327
|
+
}), Sn = ({ children: e }) => {
|
|
2328
|
+
let [t] = L((e) => [e.getConfiguration, e.boardState.scale]), { fromWrapperToBoard: n, fromBoardToWrapper: r } = z(), [i, s, c, l] = U((e) => [
|
|
2856
2329
|
e.getUser(),
|
|
2857
2330
|
e.getLocalUsers(),
|
|
2858
2331
|
e.cursors,
|
|
2859
2332
|
e.users
|
|
2860
|
-
]), [
|
|
2861
|
-
let [r, a] = n(e -
|
|
2862
|
-
|
|
2333
|
+
]), [u, d] = U((e) => [e.moveCursor, e.removeCursor]), { boardWrapperRect: f } = t(), p = ({ clientX: e, clientY: t }) => {
|
|
2334
|
+
let [r, a] = n(e - f.left, t - f.top);
|
|
2335
|
+
u(i.id, {
|
|
2863
2336
|
x: r,
|
|
2864
2337
|
y: a
|
|
2865
2338
|
});
|
|
2866
|
-
},
|
|
2867
|
-
|
|
2868
|
-
},
|
|
2869
|
-
return /* @__PURE__ */ (
|
|
2870
|
-
onPointerMove:
|
|
2871
|
-
onPointerLeave:
|
|
2872
|
-
children: [e, Object.entries(
|
|
2873
|
-
let [n, i] = r(t.x, t.y),
|
|
2874
|
-
x: n +
|
|
2875
|
-
y: i +
|
|
2339
|
+
}, m = () => {
|
|
2340
|
+
d(i.id);
|
|
2341
|
+
}, h = s.reduce((e, t) => (t.id !== i.id && c[t.id] && (e[t.id] = c[t.id]), e), {});
|
|
2342
|
+
return /* @__PURE__ */ o("div", {
|
|
2343
|
+
onPointerMove: p,
|
|
2344
|
+
onPointerLeave: m,
|
|
2345
|
+
children: [e, Object.entries(h).map(([e, t]) => {
|
|
2346
|
+
let [n, i] = r(t.x, t.y), o = {
|
|
2347
|
+
x: n + f.left,
|
|
2348
|
+
y: i + f.top
|
|
2876
2349
|
};
|
|
2877
|
-
return
|
|
2878
|
-
pos:
|
|
2879
|
-
text:
|
|
2880
|
-
color:
|
|
2350
|
+
return N(o, f) ? /* @__PURE__ */ a(xn, {
|
|
2351
|
+
pos: o,
|
|
2352
|
+
text: l[e].name,
|
|
2353
|
+
color: l[e].color
|
|
2881
2354
|
}, e) : null;
|
|
2882
2355
|
})]
|
|
2883
2356
|
});
|
|
2884
|
-
},
|
|
2357
|
+
}, Cn = ({ children: e }) => e, wn = {
|
|
2885
2358
|
overflow: "hidden",
|
|
2886
2359
|
position: "absolute",
|
|
2887
2360
|
inset: 0
|
|
2888
|
-
},
|
|
2889
|
-
let
|
|
2361
|
+
}, Tn = ({ moveFirst: t = !0, style: n, wrapperStyle: r, itemTemplates: i = {}, boardSize: s = Se, children: c, showResizeHandle: l = !1, Wrapper: u = Cn }) => {
|
|
2362
|
+
let d = e.useRef(null), [f, m] = L((e) => [e.config.uid, e.updateConfiguration]), { updateItemExtent: h } = z(), g = {
|
|
2890
2363
|
userSelect: "none",
|
|
2891
|
-
width: `${
|
|
2892
|
-
height: `${
|
|
2364
|
+
width: `${s}px`,
|
|
2365
|
+
height: `${s}px`,
|
|
2893
2366
|
backgroundColor: "#333",
|
|
2894
2367
|
...n
|
|
2895
2368
|
};
|
|
2896
2369
|
e.useEffect(() => {
|
|
2897
2370
|
let e = (e) => {
|
|
2898
|
-
|
|
2371
|
+
A(e.target, "board") && e.preventDefault();
|
|
2899
2372
|
};
|
|
2900
2373
|
return document.body.addEventListener("wheel", e, { passive: !1 }), () => {
|
|
2901
2374
|
document.body.removeEventListener("wheel", e);
|
|
2902
2375
|
};
|
|
2903
2376
|
}, []), e.useEffect(() => {
|
|
2904
|
-
|
|
2905
|
-
}, [
|
|
2906
|
-
|
|
2907
|
-
}, [
|
|
2908
|
-
|
|
2377
|
+
m({ boardWrapper: d.current });
|
|
2378
|
+
}, [m]), e.useEffect(() => {
|
|
2379
|
+
f || m({ uid: H() });
|
|
2380
|
+
}, [f, m]), e.useEffect(() => {
|
|
2381
|
+
m({
|
|
2909
2382
|
itemTemplates: i,
|
|
2910
|
-
boardSize:
|
|
2911
|
-
showResizeHandle:
|
|
2383
|
+
boardSize: s,
|
|
2384
|
+
showResizeHandle: l
|
|
2912
2385
|
});
|
|
2913
2386
|
}, [
|
|
2914
2387
|
i,
|
|
2915
|
-
a,
|
|
2916
2388
|
s,
|
|
2917
|
-
|
|
2389
|
+
l,
|
|
2390
|
+
m
|
|
2918
2391
|
]), e.useEffect(() => {
|
|
2919
|
-
|
|
2920
|
-
}, [
|
|
2921
|
-
|
|
2392
|
+
m({ boardWrapperRect: d.current.getBoundingClientRect() }), h(), setTimeout(h, 2e3);
|
|
2393
|
+
}, [m, h]), p(d, () => {
|
|
2394
|
+
d.current && m({ boardWrapperRect: d.current.getBoundingClientRect() });
|
|
2922
2395
|
});
|
|
2923
|
-
let
|
|
2924
|
-
...
|
|
2396
|
+
let _ = K({
|
|
2397
|
+
...wn,
|
|
2925
2398
|
...r
|
|
2926
2399
|
});
|
|
2927
|
-
return /* @__PURE__ */ (
|
|
2928
|
-
ref:
|
|
2929
|
-
id:
|
|
2930
|
-
className: `sync-board ${
|
|
2931
|
-
children: [/* @__PURE__ */ (
|
|
2400
|
+
return /* @__PURE__ */ o("div", {
|
|
2401
|
+
ref: d,
|
|
2402
|
+
id: f,
|
|
2403
|
+
className: `sync-board ${_}`,
|
|
2404
|
+
children: [/* @__PURE__ */ a(Sn, { children: /* @__PURE__ */ a(Kt, {
|
|
2932
2405
|
moveFirst: t,
|
|
2933
|
-
children: /* @__PURE__ */ (
|
|
2406
|
+
children: /* @__PURE__ */ a(Zt, {
|
|
2934
2407
|
moveFirst: t,
|
|
2935
|
-
children: /* @__PURE__ */ (
|
|
2408
|
+
children: /* @__PURE__ */ a(qt, {
|
|
2936
2409
|
moveFirst: t,
|
|
2937
|
-
children: /* @__PURE__ */ (
|
|
2410
|
+
children: /* @__PURE__ */ a(u, { children: /* @__PURE__ */ o("div", {
|
|
2938
2411
|
onContextMenu: (e) => {
|
|
2939
2412
|
e.preventDefault();
|
|
2940
2413
|
},
|
|
2941
|
-
style:
|
|
2414
|
+
style: g,
|
|
2942
2415
|
className: "board",
|
|
2943
|
-
children: [/* @__PURE__ */ (
|
|
2416
|
+
children: [/* @__PURE__ */ a(Ut, {}), c]
|
|
2944
2417
|
}) })
|
|
2945
2418
|
})
|
|
2946
2419
|
})
|
|
2947
|
-
}) }), /* @__PURE__ */ (
|
|
2420
|
+
}) }), /* @__PURE__ */ a(en, {})]
|
|
2948
2421
|
});
|
|
2949
2422
|
};
|
|
2950
2423
|
//#endregion
|
|
2951
2424
|
//#region src/lib/index.js
|
|
2952
|
-
|
|
2425
|
+
ht(e.createElement);
|
|
2953
2426
|
//#endregion
|
|
2954
|
-
export {
|
|
2427
|
+
export { Tn as Board, at as BoardWrapper, ot as RoomWrapper, Re as useAvailableActions, Je as useBoardConfig, z as useBoardPosition, Ye as useBoardState, xe as useDebouncedItems, Ae as useGetSelectedItems, V as useItemActions, B as useItemInteraction, be as useItems, rt as useMessage, ke as useSelectedItems, ze as useSelectionBox, Xe as useSessionInfo, qe as useUsers, O as useWire };
|
|
2955
2428
|
|
|
2956
2429
|
//# sourceMappingURL=react-sync-board.js.map
|