@plurid/plurid-engine 0.0.0-17 → 0.0.0-19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/distribution/index.d.mts +744 -0
  2. package/distribution/index.d.ts +744 -2
  3. package/distribution/index.js +3319 -2711
  4. package/distribution/index.js.map +1 -1
  5. package/distribution/index.mjs +3432 -0
  6. package/distribution/index.mjs.map +1 -0
  7. package/package.json +71 -78
  8. package/distribution/functions/index.d.ts +0 -2
  9. package/distribution/functions/navigate/index.d.ts +0 -1
  10. package/distribution/functions/template/index.d.ts +0 -1
  11. package/distribution/index.es.js +0 -2810
  12. package/distribution/index.es.js.map +0 -1
  13. package/distribution/modules/general/configuration/index.d.ts +0 -2
  14. package/distribution/modules/general/index.d.ts +0 -3
  15. package/distribution/modules/general/tree/index.d.ts +0 -5
  16. package/distribution/modules/index.d.ts +0 -9
  17. package/distribution/modules/interaction/direction/index.d.ts +0 -2
  18. package/distribution/modules/interaction/index.d.ts +0 -5
  19. package/distribution/modules/interaction/mathematics/matrix/index.d.ts +0 -31
  20. package/distribution/modules/interaction/mathematics/quaternion/index.d.ts +0 -78
  21. package/distribution/modules/interaction/mathematics/transform/general/index.d.ts +0 -37
  22. package/distribution/modules/interaction/mathematics/transform/index.d.ts +0 -3
  23. package/distribution/modules/interaction/mathematics/transform/matrix3d/index.d.ts +0 -68
  24. package/distribution/modules/internationalization/index.d.ts +0 -3
  25. package/distribution/modules/planes/index.d.ts +0 -2
  26. package/distribution/modules/planes/logic/index.d.ts +0 -4
  27. package/distribution/modules/planes/registrar/index.d.ts +0 -3
  28. package/distribution/modules/planes/registrar/object.d.ts +0 -14
  29. package/distribution/modules/planes/registrar/utilities.d.ts +0 -6
  30. package/distribution/modules/routing/IsoMatcher/index.d.ts +0 -44
  31. package/distribution/modules/routing/Parser/index.d.ts +0 -21
  32. package/distribution/modules/routing/Parser/interfaces.d.ts +0 -31
  33. package/distribution/modules/routing/Parser/logic.d.ts +0 -68
  34. package/distribution/modules/routing/index.d.ts +0 -6
  35. package/distribution/modules/routing/logic/general/index.d.ts +0 -8
  36. package/distribution/modules/routing/logic/index.d.ts +0 -3
  37. package/distribution/modules/routing/logic/utilities/index.d.ts +0 -29
  38. package/distribution/modules/routing/logic/validity/index.d.ts +0 -3
  39. package/distribution/modules/space/index.d.ts +0 -6
  40. package/distribution/modules/space/layout/column.d.ts +0 -3
  41. package/distribution/modules/space/layout/faceToFace.d.ts +0 -3
  42. package/distribution/modules/space/layout/index.d.ts +0 -6
  43. package/distribution/modules/space/layout/row.d.ts +0 -3
  44. package/distribution/modules/space/layout/sheaves.d.ts +0 -3
  45. package/distribution/modules/space/layout/zigZag.d.ts +0 -3
  46. package/distribution/modules/space/location/index.d.ts +0 -2
  47. package/distribution/modules/space/location/logic.d.ts +0 -22
  48. package/distribution/modules/space/tree/index.d.ts +0 -3
  49. package/distribution/modules/space/tree/logic.d.ts +0 -44
  50. package/distribution/modules/space/tree/object.d.ts +0 -13
  51. package/distribution/modules/space/utilities/index.d.ts +0 -16
  52. package/distribution/modules/space/view/index.d.ts +0 -2
  53. package/distribution/modules/space/view/logic.d.ts +0 -13
  54. package/distribution/modules/state/compute/index.d.ts +0 -3
  55. package/distribution/modules/state/compute/space/index.d.ts +0 -3
  56. package/distribution/modules/state/compute/themes/index.d.ts +0 -3
  57. package/distribution/modules/state/index.d.ts +0 -3
  58. package/distribution/modules/state/local/index.d.ts +0 -3
  59. package/distribution/modules/utilities/index.d.ts +0 -1
@@ -0,0 +1,3432 @@
1
+ import { defaultConfiguration, internationalization, protocols, HTTPS_PROTOCOL, HTTP_PROTOCOL, compareTypes, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from '@plurid/plurid-data';
2
+ import { mathematics, objects, uuid } from '@plurid/plurid-functions';
3
+ import themes, { THEME_NAMES } from '@plurid/plurid-themes';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+
11
+ // source/modules/general/index.ts
12
+ var general_exports = {};
13
+ __export(general_exports, {
14
+ configuration: () => configuration_exports,
15
+ tree: () => tree_exports
16
+ });
17
+
18
+ // source/modules/general/configuration/index.ts
19
+ var configuration_exports = {};
20
+ __export(configuration_exports, {
21
+ definePluridConfiguration: () => definePluridConfiguration,
22
+ merge: () => merge
23
+ });
24
+ var resolveTheme = (theme, type) => {
25
+ if (!theme) {
26
+ return "plurid";
27
+ }
28
+ if (typeof theme === "string") {
29
+ return theme;
30
+ }
31
+ if (typeof theme !== "object") {
32
+ return "plurid";
33
+ }
34
+ const {
35
+ general,
36
+ interaction
37
+ } = theme;
38
+ if (type === "general" && general) {
39
+ return general;
40
+ }
41
+ if (type === "interaction" && interaction) {
42
+ return interaction;
43
+ }
44
+ return "plurid";
45
+ };
46
+ var merge = (configuration, target) => {
47
+ const targetConfiguration = {
48
+ ...objects.clone(defaultConfiguration),
49
+ ...objects.clone(target || {})
50
+ };
51
+ if (!configuration) {
52
+ return targetConfiguration;
53
+ }
54
+ const mergedConfiguration = objects.merge(
55
+ targetConfiguration,
56
+ configuration,
57
+ {
58
+ "global.theme": () => {
59
+ return {
60
+ general: resolveTheme(configuration.global?.theme, "general"),
61
+ interaction: resolveTheme(configuration.global?.theme, "interaction")
62
+ };
63
+ }
64
+ }
65
+ );
66
+ return mergedConfiguration;
67
+ };
68
+ var definePluridConfiguration = (flat = {}) => {
69
+ const partial = {};
70
+ const global = {};
71
+ if (flat.theme !== void 0) {
72
+ global.theme = flat.theme;
73
+ }
74
+ if (flat.micro !== void 0) {
75
+ global.micro = flat.micro;
76
+ }
77
+ if (flat.transparentUI !== void 0) {
78
+ global.transparentUI = flat.transparentUI;
79
+ }
80
+ if (flat.language !== void 0) {
81
+ global.language = flat.language;
82
+ }
83
+ if (Object.keys(global).length > 0) {
84
+ partial.global = global;
85
+ }
86
+ const space = {};
87
+ if (flat.layout !== void 0) {
88
+ space.layout = flat.layout;
89
+ }
90
+ if (flat.perspective !== void 0) {
91
+ space.perspective = flat.perspective;
92
+ }
93
+ if (flat.center !== void 0) {
94
+ space.center = flat.center;
95
+ }
96
+ if (flat.firstPerson !== void 0) {
97
+ space.firstPerson = flat.firstPerson;
98
+ }
99
+ if (flat.collaboration !== void 0) {
100
+ space.collaboration = flat.collaboration;
101
+ }
102
+ if (flat.undo !== void 0) {
103
+ space.undo = flat.undo;
104
+ }
105
+ if (flat.viewpointURLWrite !== void 0) {
106
+ space.viewpointURLWrite = flat.viewpointURLWrite;
107
+ }
108
+ if (flat.viewpointURLRestore !== void 0) {
109
+ space.viewpointURLRestore = flat.viewpointURLRestore;
110
+ }
111
+ if (flat.viewpointURLParam !== void 0) {
112
+ space.viewpointURLParam = flat.viewpointURLParam;
113
+ }
114
+ if (flat.viewpointURLDebounce !== void 0) {
115
+ space.viewpointURLDebounce = flat.viewpointURLDebounce;
116
+ }
117
+ if (flat.timings !== void 0) {
118
+ space.timings = flat.timings;
119
+ }
120
+ if (flat.gestures !== void 0) {
121
+ space.gestures = flat.gestures;
122
+ }
123
+ if (flat.shortcuts !== void 0) {
124
+ space.shortcuts = flat.shortcuts;
125
+ }
126
+ if (flat.transformLocks !== void 0) {
127
+ space.transformLocks = flat.transformLocks;
128
+ }
129
+ if (flat.opaque !== void 0) {
130
+ space.opaque = flat.opaque;
131
+ }
132
+ if (flat.camera !== void 0) {
133
+ space.camera = flat.camera;
134
+ }
135
+ if (flat.transformOrigin !== void 0) {
136
+ space.transformOrigin = flat.transformOrigin;
137
+ }
138
+ if (flat.transformMode !== void 0) {
139
+ space.transformMode = flat.transformMode;
140
+ }
141
+ if (flat.transformMultimode !== void 0) {
142
+ space.transformMultimode = flat.transformMultimode;
143
+ }
144
+ if (flat.transformTouch !== void 0) {
145
+ space.transformTouch = flat.transformTouch;
146
+ }
147
+ if (flat.cullingDistance !== void 0) {
148
+ space.cullingDistance = flat.cullingDistance;
149
+ }
150
+ if (flat.fadeInTime !== void 0) {
151
+ space.fadeInTime = flat.fadeInTime;
152
+ }
153
+ if (flat.bridgeLength !== void 0 || flat.bridgePlaneAngle !== void 0) {
154
+ space.bridge = {};
155
+ if (flat.bridgeLength !== void 0) {
156
+ space.bridge.length = flat.bridgeLength;
157
+ }
158
+ if (flat.bridgePlaneAngle !== void 0) {
159
+ space.bridge.planeAngle = flat.bridgePlaneAngle;
160
+ }
161
+ }
162
+ if (Object.keys(space).length > 0) {
163
+ partial.space = space;
164
+ }
165
+ const elements = {};
166
+ const plane = {};
167
+ if (flat.planeWidth !== void 0) {
168
+ plane.width = flat.planeWidth;
169
+ }
170
+ if (flat.planeOpacity !== void 0) {
171
+ plane.opacity = flat.planeOpacity;
172
+ }
173
+ if (flat.planeControls !== void 0) {
174
+ plane.controls = { show: flat.planeControls };
175
+ }
176
+ if (Object.keys(plane).length > 0) {
177
+ elements.plane = plane;
178
+ }
179
+ if (flat.toolbar !== void 0) {
180
+ elements.toolbar = { show: flat.toolbar };
181
+ }
182
+ if (flat.viewcube !== void 0) {
183
+ elements.viewcube = { show: flat.viewcube };
184
+ }
185
+ if (flat.minimap !== void 0) {
186
+ elements.minimap = { show: flat.minimap };
187
+ }
188
+ if (Object.keys(elements).length > 0) {
189
+ partial.elements = elements;
190
+ }
191
+ const resolved = flat.extend ? objects.merge(partial, flat.extend) : partial;
192
+ return merge(resolved);
193
+ };
194
+
195
+ // source/modules/general/tree/index.ts
196
+ var tree_exports = {};
197
+ __export(tree_exports, {
198
+ updateTreeByPlaneIDWithLinkCoordinates: () => updateTreeByPlaneIDWithLinkCoordinates,
199
+ updateTreePlane: () => updateTreePlane
200
+ });
201
+ var updateTreePlane = (tree, page) => {
202
+ const updatedTree = tree.map((treePlane) => {
203
+ if (treePlane.planeID === page.planeID) {
204
+ return {
205
+ ...page
206
+ };
207
+ }
208
+ if (treePlane.children) {
209
+ return {
210
+ ...treePlane,
211
+ children: updateTreePlane(treePlane.children, page)
212
+ };
213
+ }
214
+ return treePlane;
215
+ });
216
+ return updatedTree;
217
+ };
218
+ var updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
219
+ let changed = false;
220
+ const updatedTree = tree.map((treePlane) => {
221
+ if (treePlane.planeID === planeID) {
222
+ changed = true;
223
+ return {
224
+ ...treePlane,
225
+ linkCoordinates
226
+ };
227
+ }
228
+ if (treePlane.children) {
229
+ const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(
230
+ treePlane.children,
231
+ planeID,
232
+ linkCoordinates
233
+ );
234
+ if (updatedChildren !== treePlane.children) {
235
+ changed = true;
236
+ return {
237
+ ...treePlane,
238
+ children: updatedChildren
239
+ };
240
+ }
241
+ }
242
+ return treePlane;
243
+ });
244
+ return changed ? updatedTree : tree;
245
+ };
246
+
247
+ // source/modules/interaction/index.ts
248
+ var interaction_exports = {};
249
+ __export(interaction_exports, {
250
+ direction: () => direction_exports,
251
+ matrix: () => matrix_exports,
252
+ quaternion: () => quaternion_exports,
253
+ transform: () => transform_exports
254
+ });
255
+
256
+ // source/modules/interaction/direction/index.ts
257
+ var direction_exports = {};
258
+ __export(direction_exports, {
259
+ getWheelDirection: () => getWheelDirection
260
+ });
261
+ var getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
262
+ let direction = "left";
263
+ const wheelDeltaX = deltas.deltaX;
264
+ const wheelDeltaY = deltas.deltaY;
265
+ const absWheelDeltaX = Math.abs(wheelDeltaX);
266
+ const absWheelDeltaY = Math.abs(wheelDeltaY);
267
+ if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
268
+ direction = "left";
269
+ }
270
+ if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
271
+ direction = "right";
272
+ }
273
+ if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
274
+ direction = "up";
275
+ }
276
+ if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
277
+ direction = "down";
278
+ }
279
+ return direction;
280
+ };
281
+
282
+ // source/modules/interaction/mathematics/matrix/index.ts
283
+ var matrix_exports = {};
284
+ __export(matrix_exports, {
285
+ matrixArrayToCSSMatrix: () => matrixArrayToCSSMatrix,
286
+ multiplyArrayOfMatrices: () => multiplyArrayOfMatrices,
287
+ multiplyMatrices: () => multiplyMatrices,
288
+ rotateMatrix: () => rotateMatrix,
289
+ scaleMatrix: () => scaleMatrix,
290
+ translateMatrix: () => translateMatrix
291
+ });
292
+
293
+ // source/modules/interaction/mathematics/quaternion/index.ts
294
+ var quaternion_exports = {};
295
+ __export(quaternion_exports, {
296
+ computeQuaternionFromEulers: () => computeQuaternionFromEulers,
297
+ conjugateQuaternion: () => conjugateQuaternion,
298
+ degToRad: () => degToRad,
299
+ inverseQuaternion: () => inverseQuaternion,
300
+ makeQuaternion: () => makeQuaternion,
301
+ makeRotationMatrixFromQuaternion: () => makeRotationMatrixFromQuaternion,
302
+ quaternionFromAxisAngle: () => quaternionFromAxisAngle,
303
+ quaternionMultiply: () => quaternionMultiply,
304
+ radToDeg: () => radToDeg,
305
+ rotatePointViaQuaternion: () => rotatePointViaQuaternion,
306
+ zeroQuaternion: () => zeroQuaternion
307
+ });
308
+ var degToRad = (deg) => {
309
+ return deg * 0.01745329252;
310
+ };
311
+ var radToDeg = (rad) => {
312
+ return rad * 57.2957795131;
313
+ };
314
+ var makeQuaternion = (x, y, z, w) => {
315
+ return {
316
+ x,
317
+ y,
318
+ z,
319
+ w
320
+ };
321
+ };
322
+ var zeroQuaternion = () => {
323
+ return makeQuaternion(0, 0, 0, 0);
324
+ };
325
+ function inverseQuaternion(quaternion) {
326
+ return makeQuaternion(
327
+ quaternion.x,
328
+ quaternion.y,
329
+ quaternion.z,
330
+ -quaternion.w
331
+ );
332
+ }
333
+ function conjugateQuaternion(quaternion) {
334
+ return makeQuaternion(
335
+ -quaternion.x,
336
+ -quaternion.y,
337
+ -quaternion.z,
338
+ quaternion.w
339
+ );
340
+ }
341
+ function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
342
+ const x = radians ? beta : degToRad(beta);
343
+ const y = radians ? gamma : degToRad(gamma);
344
+ const z = radians ? alpha : degToRad(alpha);
345
+ const cX = Math.cos(x / 2);
346
+ const cY = Math.cos(y / 2);
347
+ const cZ = Math.cos(z / 2);
348
+ const sX = Math.sin(x / 2);
349
+ const sY = Math.sin(y / 2);
350
+ const sZ = Math.sin(z / 2);
351
+ const xQ = sX * cY * cZ - cX * sY * sZ;
352
+ const yQ = cX * sY * cZ + sX * cY * sZ;
353
+ const zQ = cX * cY * sZ + sX * sY * cZ;
354
+ const wQ = cX * cY * cZ - sX * sY * sZ;
355
+ return makeQuaternion(xQ, yQ, zQ, wQ);
356
+ }
357
+ function quaternionFromAxisAngle(x, y, z, angle) {
358
+ const q = zeroQuaternion();
359
+ const halfAngle = angle / 2;
360
+ const sine = Math.sin(halfAngle);
361
+ q.x = x * sine;
362
+ q.y = y * sine;
363
+ q.z = z * sine;
364
+ q.w = Math.cos(halfAngle);
365
+ return q;
366
+ }
367
+ function quaternionMultiply(quaternionArray) {
368
+ const firstQuaternion = quaternionArray[0];
369
+ const valueQuaternion = {
370
+ ...firstQuaternion
371
+ };
372
+ for (let i = 1; i < quaternionArray.length; i++) {
373
+ const nextQuaternion = quaternionArray[i];
374
+ const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
375
+ const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
376
+ const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
377
+ const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
378
+ valueQuaternion.x = x;
379
+ valueQuaternion.y = y;
380
+ valueQuaternion.z = z;
381
+ valueQuaternion.w = w;
382
+ }
383
+ return valueQuaternion;
384
+ }
385
+ function rotatePointViaQuaternion(pointRotate, quaternion) {
386
+ const temporaryQuaternion = {
387
+ x: pointRotate[0],
388
+ y: pointRotate[1],
389
+ z: pointRotate[2],
390
+ w: 0
391
+ };
392
+ const rotatedPointQuaternion = quaternionMultiply([
393
+ quaternion,
394
+ temporaryQuaternion,
395
+ conjugateQuaternion(quaternion)
396
+ ]);
397
+ return rotatedPointQuaternion;
398
+ }
399
+ function makeRotationMatrixFromQuaternion(quaternion) {
400
+ const num = quaternion.x * 2;
401
+ const num2 = quaternion.y * 2;
402
+ const num3 = quaternion.z * 2;
403
+ const num4 = quaternion.x * num;
404
+ const num5 = quaternion.y * num2;
405
+ const num6 = quaternion.z * num3;
406
+ const num7 = quaternion.x * num2;
407
+ const num8 = quaternion.x * num3;
408
+ const num9 = quaternion.y * num3;
409
+ const num10 = quaternion.w * num;
410
+ const num11 = quaternion.w * num2;
411
+ const num12 = quaternion.w * num3;
412
+ return [
413
+ 1 - (num5 + num6),
414
+ num7 - num12,
415
+ num8 + num11,
416
+ 0,
417
+ num7 + num12,
418
+ 1 - (num4 + num6),
419
+ num9 - num10,
420
+ 0,
421
+ num8 - num11,
422
+ num9 + num10,
423
+ 1 - (num4 + num5),
424
+ 0,
425
+ 0,
426
+ 0,
427
+ 0,
428
+ 1
429
+ ];
430
+ }
431
+
432
+ // source/modules/interaction/mathematics/matrix/index.ts
433
+ function rotateMatrix(xAngle, yAngle, zAngle = 0) {
434
+ const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
435
+ const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
436
+ const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
437
+ const quartenionMultiplication = quaternionMultiply([
438
+ yQuaternion,
439
+ xQuaternion,
440
+ zQuaternion
441
+ ]);
442
+ const rotationMatrix = makeRotationMatrixFromQuaternion(
443
+ quartenionMultiplication
444
+ );
445
+ return rotationMatrix;
446
+ }
447
+ function translateMatrix(x, y, z) {
448
+ return [
449
+ 1,
450
+ 0,
451
+ 0,
452
+ 0,
453
+ 0,
454
+ 1,
455
+ 0,
456
+ 0,
457
+ 0,
458
+ 0,
459
+ 1,
460
+ 0,
461
+ x,
462
+ y,
463
+ z,
464
+ 1
465
+ ];
466
+ }
467
+ function scaleMatrix(s) {
468
+ return [
469
+ s,
470
+ 0,
471
+ 0,
472
+ 0,
473
+ 0,
474
+ s,
475
+ 0,
476
+ 0,
477
+ 0,
478
+ 0,
479
+ s,
480
+ 0,
481
+ 0,
482
+ 0,
483
+ 0,
484
+ 1
485
+ ];
486
+ }
487
+ function multiplyMatrices(matrixA, matrixB) {
488
+ const result = [];
489
+ const a00 = matrixA[0];
490
+ const a01 = matrixA[1];
491
+ const a02 = matrixA[2];
492
+ const a03 = matrixA[3];
493
+ const a10 = matrixA[4];
494
+ const a11 = matrixA[5];
495
+ const a12 = matrixA[6];
496
+ const a13 = matrixA[7];
497
+ const a20 = matrixA[8];
498
+ const a21 = matrixA[9];
499
+ const a22 = matrixA[10];
500
+ const a23 = matrixA[11];
501
+ const a30 = matrixA[12];
502
+ const a31 = matrixA[13];
503
+ const a32 = matrixA[14];
504
+ const a33 = matrixA[15];
505
+ let b0 = matrixB[0];
506
+ let b1 = matrixB[1];
507
+ let b2 = matrixB[2];
508
+ let b3 = matrixB[3];
509
+ result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
510
+ result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
511
+ result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
512
+ result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
513
+ b0 = matrixB[4];
514
+ b1 = matrixB[5];
515
+ b2 = matrixB[6];
516
+ b3 = matrixB[7];
517
+ result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
518
+ result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
519
+ result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
520
+ result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
521
+ b0 = matrixB[8];
522
+ b1 = matrixB[9];
523
+ b2 = matrixB[10];
524
+ b3 = matrixB[11];
525
+ result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
526
+ result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
527
+ result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
528
+ result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
529
+ b0 = matrixB[12];
530
+ b1 = matrixB[13];
531
+ b2 = matrixB[14];
532
+ b3 = matrixB[15];
533
+ result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
534
+ result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
535
+ result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
536
+ result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
537
+ return result;
538
+ }
539
+ function multiplyArrayOfMatrices(matrices) {
540
+ let inputMatrix = matrices[0];
541
+ for (let i = 1; i < matrices.length; i++) {
542
+ inputMatrix = multiplyMatrices(inputMatrix, matrices[i]);
543
+ }
544
+ return inputMatrix;
545
+ }
546
+ function matrixArrayToCSSMatrix(array) {
547
+ return "matrix3d(" + array.join(",") + ")";
548
+ }
549
+
550
+ // source/modules/interaction/mathematics/transform/index.ts
551
+ var transform_exports = {};
552
+ __export(transform_exports, {
553
+ general: () => general_exports2,
554
+ matrix3d: () => matrix3d_exports
555
+ });
556
+
557
+ // source/modules/interaction/mathematics/transform/general/index.ts
558
+ var general_exports2 = {};
559
+ __export(general_exports2, {
560
+ arrayToMatrix: () => arrayToMatrix,
561
+ getInitialMatrix: () => getInitialMatrix,
562
+ identityMatrix: () => identityMatrix,
563
+ inverseMatrix: () => inverseMatrix,
564
+ matrix3DToMatrix: () => matrix3DToMatrix,
565
+ matrixToArray: () => matrixToArray,
566
+ matrixToCSSMatrix: () => matrixToCSSMatrix,
567
+ multiplyMatrices: () => multiplyMatrices2,
568
+ multiplyMatricesArray: () => multiplyMatricesArray,
569
+ rotateXMatrix: () => rotateXMatrix,
570
+ rotateYMatrix: () => rotateYMatrix,
571
+ rotateZMatrix: () => rotateZMatrix,
572
+ rotationMatrixFromQuaternion: () => rotationMatrixFromQuaternion,
573
+ scaleMatrix: () => scaleMatrix2,
574
+ translateMatrix: () => translateMatrix2
575
+ });
576
+ var getInitialMatrix = () => {
577
+ const matrix = [
578
+ [1, 0, 0, 0],
579
+ [0, 1, 0, 0],
580
+ [0, 0, 1, 0],
581
+ [0, 0, 0, 1]
582
+ ];
583
+ return matrix;
584
+ };
585
+ var multiplyMatrices2 = (m1, m2) => {
586
+ const result = [];
587
+ for (let i = 0; i < m1.length; i++) {
588
+ result[i] = [];
589
+ for (let j = 0; j < m2[0].length; j++) {
590
+ let sum = 0;
591
+ for (let k = 0; k < m1[0].length; k++) {
592
+ sum += m1[i][k] * m2[k][j];
593
+ }
594
+ result[i][j] = sum;
595
+ }
596
+ }
597
+ return result;
598
+ };
599
+ var multiplyMatricesArray = (matrices) => {
600
+ if (matrices.length < 2) {
601
+ throw new Error("invalid number of matrices");
602
+ }
603
+ const first = matrices[0];
604
+ let result = first;
605
+ for (const [index, matrix] of matrices.entries()) {
606
+ if (index === 0) {
607
+ continue;
608
+ }
609
+ result = multiplyMatrices2(
610
+ result,
611
+ matrix
612
+ );
613
+ }
614
+ return result;
615
+ };
616
+ var arrayToMatrix = (array) => {
617
+ const matrix = [];
618
+ for (let i = 0; i < array.length; i += 4) {
619
+ const row = [];
620
+ row.push(array[i]);
621
+ row.push(array[i + 1]);
622
+ row.push(array[i + 2]);
623
+ row.push(array[i + 3]);
624
+ matrix.push(row);
625
+ }
626
+ return matrix;
627
+ };
628
+ var matrixToArray = (matrix) => {
629
+ return matrix.flat();
630
+ };
631
+ var matrix3DToMatrix = (value) => {
632
+ const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val) => parseFloat(val));
633
+ return arrayToMatrix(values);
634
+ };
635
+ var rotateXMatrix = (angle) => {
636
+ const x = Math.cos(angle);
637
+ const y = -1 * Math.sin(angle);
638
+ const z = Math.sin(angle);
639
+ const m = [
640
+ [1, 0, 0, 0],
641
+ [0, x, y, 0],
642
+ [0, z, x, 0],
643
+ [0, 0, 0, 1]
644
+ ];
645
+ return m;
646
+ };
647
+ var rotateYMatrix = (angle) => {
648
+ const x = Math.cos(angle);
649
+ const y = -1 * Math.sin(angle);
650
+ const z = Math.sin(angle);
651
+ const m = [
652
+ [x, 0, z, 0],
653
+ [0, 1, 0, 0],
654
+ [y, 0, x, 0],
655
+ [0, 0, 0, 1]
656
+ ];
657
+ return m;
658
+ };
659
+ var rotateZMatrix = (angle) => {
660
+ const x = Math.cos(angle);
661
+ const y = -1 * Math.sin(angle);
662
+ const z = Math.sin(angle);
663
+ const m = [
664
+ [x, y, 0, 0],
665
+ [z, x, 0, 0],
666
+ [0, 0, 1, 0],
667
+ [0, 0, 0, 1]
668
+ ];
669
+ return m;
670
+ };
671
+ var translateMatrix2 = (x = 0, y = 0, z = 0) => {
672
+ const m = [
673
+ [1, 0, 0, 0],
674
+ [0, 1, 0, 0],
675
+ [0, 0, 1, 0],
676
+ [x, y, z, 1]
677
+ ];
678
+ return m;
679
+ };
680
+ var scaleMatrix2 = (s) => {
681
+ return [
682
+ [s, 0, 0, 0],
683
+ [0, s, 0, 0],
684
+ [0, 0, s, 0],
685
+ [0, 0, 0, 1]
686
+ ];
687
+ };
688
+ function rotationMatrixFromQuaternion(quaternion) {
689
+ const num = quaternion.x * 2;
690
+ const num2 = quaternion.y * 2;
691
+ const num3 = quaternion.z * 2;
692
+ const num4 = quaternion.x * num;
693
+ const num5 = quaternion.y * num2;
694
+ const num6 = quaternion.z * num3;
695
+ const num7 = quaternion.x * num2;
696
+ const num8 = quaternion.x * num3;
697
+ const num9 = quaternion.y * num3;
698
+ const num10 = quaternion.w * num;
699
+ const num11 = quaternion.w * num2;
700
+ const num12 = quaternion.w * num3;
701
+ return [
702
+ [1 - (num5 + num6), num7 - num12, num8 + num11, 0],
703
+ [num7 + num12, 1 - (num4 + num6), num9 - num10, 0],
704
+ [num8 - num11, num9 + num10, 1 - (num4 + num5), 0],
705
+ [0, 0, 0, 1]
706
+ ];
707
+ }
708
+ var matrixToCSSMatrix = (matrix) => {
709
+ const value = matrix.flat().join(",");
710
+ return `matrix3d(${value})`;
711
+ };
712
+ var identityMatrix = () => {
713
+ const matrix = [
714
+ [1, 0, 0, 0],
715
+ [0, 1, 0, 0],
716
+ [0, 0, 1, 0],
717
+ [0, 0, 0, 1]
718
+ ];
719
+ return matrix;
720
+ };
721
+ var inverseMatrix = (matrix) => {
722
+ const cols = 4;
723
+ const rows = 4;
724
+ const A = matrix.map((row) => [...row]);
725
+ const B = identityMatrix();
726
+ let r;
727
+ let s;
728
+ let f;
729
+ let temp;
730
+ for (let c = 0; c < cols; c++) {
731
+ let ABig = Math.abs(A[c][c]);
732
+ let rBig = c;
733
+ r = c + 1;
734
+ while (r < rows) {
735
+ if (Math.abs(A[r][c]) > ABig) {
736
+ ABig = Math.abs(A[r][c]);
737
+ rBig = r;
738
+ }
739
+ r++;
740
+ }
741
+ if (ABig === 0) {
742
+ throw Error("Cannot calculate inverse, determinant is zero");
743
+ }
744
+ r = rBig;
745
+ if (r !== c) {
746
+ temp = A[c];
747
+ A[c] = A[r];
748
+ A[r] = temp;
749
+ temp = B[c];
750
+ B[c] = B[r];
751
+ B[r] = temp;
752
+ }
753
+ const Ac = A[c];
754
+ const Bc = B[c];
755
+ for (r = 0; r < rows; r++) {
756
+ const Ar = A[r];
757
+ const Br = B[r];
758
+ if (r !== c) {
759
+ if (Ar[c] !== 0) {
760
+ f = -Ar[c] / Ac[c];
761
+ for (s = c; s < cols; s++) {
762
+ Ar[s] = Ar[s] + f * Ac[s];
763
+ }
764
+ for (s = 0; s < cols; s++) {
765
+ Br[s] = Br[s] + f * Bc[s];
766
+ }
767
+ }
768
+ } else {
769
+ f = Ac[c];
770
+ for (s = c; s < cols; s++) {
771
+ Ar[s] = Ar[s] / f;
772
+ }
773
+ for (s = 0; s < cols; s++) {
774
+ Br[s] = Br[s] / f;
775
+ }
776
+ }
777
+ }
778
+ }
779
+ return B;
780
+ };
781
+
782
+ // source/modules/interaction/mathematics/transform/matrix3d/index.ts
783
+ var matrix3d_exports = {};
784
+ __export(matrix3d_exports, {
785
+ getMatrixValues: () => getMatrixValues,
786
+ getRotationMatrix: () => getRotationMatrix,
787
+ getScalationValue: () => getScalationValue,
788
+ getTransformRotate: () => getTransformRotate,
789
+ getTransformScale: () => getTransformScale,
790
+ getTransformTranslate: () => getTransformTranslate,
791
+ getTranslationMatrix: () => getTranslationMatrix,
792
+ setTransform: () => setTransform
793
+ });
794
+ function getMatrixValues(matrix3d) {
795
+ const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
796
+ const matrixValuesInt = [];
797
+ for (let i = 0; i < matrixValues.length; i++) {
798
+ matrixValuesInt[i] = parseFloat(matrixValues[i]);
799
+ }
800
+ return matrixValuesInt;
801
+ }
802
+ function getRotationMatrix(matrix3d) {
803
+ const valuesMatrix = getMatrixValues(matrix3d);
804
+ const scale = getScalationValue(matrix3d);
805
+ if (valuesMatrix.length === 16) {
806
+ for (let i = 0; i < 11; i++) {
807
+ valuesMatrix[i] /= scale;
808
+ }
809
+ } else if (valuesMatrix.length === 6) {
810
+ for (let i = 0; i < 4; i++) {
811
+ valuesMatrix[i] /= scale;
812
+ }
813
+ }
814
+ const rotationMatrix = valuesMatrix;
815
+ return rotationMatrix;
816
+ }
817
+ function getTranslationMatrix(matrix3d) {
818
+ const valuesMatrix = getMatrixValues(matrix3d);
819
+ let translationMatrix;
820
+ if (valuesMatrix.length === 16) {
821
+ translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
822
+ } else if (valuesMatrix.length === 6) {
823
+ translationMatrix = getMatrixValues(matrix3d).slice(4);
824
+ }
825
+ return translationMatrix;
826
+ }
827
+ function getScalationValue(matrix3d) {
828
+ const valuesMatrix = getMatrixValues(matrix3d);
829
+ let temp = 0;
830
+ let scale;
831
+ if (valuesMatrix.length === 16) {
832
+ const scaleMatrix4 = getMatrixValues(matrix3d).slice(0, 4);
833
+ scale = 0;
834
+ for (const el of scaleMatrix4) {
835
+ scale += parseFloat(el) * parseFloat(el);
836
+ }
837
+ scale = parseFloat(Math.sqrt(scale).toPrecision(4));
838
+ } else if (valuesMatrix.length === 6) {
839
+ temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
840
+ scale = parseFloat(Math.sqrt(temp).toPrecision(4));
841
+ }
842
+ return scale;
843
+ }
844
+ function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
845
+ const transformMatrix = multiplyArrayOfMatrices([
846
+ translationMatrix,
847
+ rotationMatrix,
848
+ scalationMatrix
849
+ ]);
850
+ return matrixArrayToCSSMatrix(transformMatrix);
851
+ }
852
+ function getTransformRotate(matrix3d) {
853
+ const pi = Math.PI;
854
+ const values = getRotationMatrix(matrix3d);
855
+ let rotateX = 0;
856
+ let rotateY = 0;
857
+ if (values.length === 6) {
858
+ const cosa = values[0];
859
+ const sina = values[1];
860
+ if (cosa === 1 && sina === 0) {
861
+ rotateX = Math.asin(sina);
862
+ rotateY = Math.acos(cosa);
863
+ }
864
+ }
865
+ if (values.length === 16) {
866
+ const cosaX1 = values[5];
867
+ const sinaX3 = values[9];
868
+ if (sinaX3 <= 0) {
869
+ rotateX = Math.acos(cosaX1);
870
+ }
871
+ if (sinaX3 > 0) {
872
+ rotateX = 2 * pi - Math.acos(cosaX1);
873
+ }
874
+ const cosaY1 = values[0];
875
+ const sinaY2 = values[2];
876
+ if (sinaY2 <= 0) {
877
+ rotateY = Math.acos(cosaY1);
878
+ }
879
+ if (sinaY2 > 0) {
880
+ rotateY = 2 * pi - Math.acos(cosaY1);
881
+ }
882
+ rotateX = Math.atan2(values[9], values[5]);
883
+ rotateY = Math.atan2(values[2], values[0]);
884
+ }
885
+ return {
886
+ rotateX,
887
+ rotateY,
888
+ rotateZ: 0
889
+ };
890
+ }
891
+ function getTransformTranslate(matrix3d) {
892
+ const values = getTranslationMatrix(matrix3d);
893
+ const translateX = values[0];
894
+ const translateY = values[1];
895
+ const translateZ = values[2];
896
+ return {
897
+ translateX,
898
+ translateY,
899
+ translateZ
900
+ };
901
+ }
902
+ function getTransformScale(matrix3d) {
903
+ const scale = getScalationValue(matrix3d);
904
+ return {
905
+ scale
906
+ };
907
+ }
908
+ var internatiolate = (lamguage, field) => {
909
+ return internationalization[lamguage]?.[field] ?? internationalization.english?.[field] ?? field;
910
+ };
911
+ var internationalization_default = internatiolate;
912
+
913
+ // source/modules/planes/index.ts
914
+ var planes_exports = {};
915
+ __export(planes_exports, {
916
+ Registrar: () => object_default,
917
+ getPlanesRegistrar: () => getPlanesRegistrar,
918
+ getPluridPlaneIDByData: () => getPluridPlaneIDByData,
919
+ getRegisteredPlane: () => getRegisteredPlane,
920
+ getRegisteredPlanes: () => getRegisteredPlanes,
921
+ registerPlanes: () => registerPlanes,
922
+ resolvePluridPlaneData: () => resolvePluridPlaneData,
923
+ resolvePluridRoutePlaneData: () => resolvePluridRoutePlaneData
924
+ });
925
+
926
+ // source/modules/planes/logic/index.ts
927
+ var resolvePluridPlaneData = (plane) => {
928
+ if (Array.isArray(plane)) {
929
+ const [
930
+ route,
931
+ component,
932
+ options
933
+ ] = plane;
934
+ return {
935
+ route,
936
+ component,
937
+ ...options
938
+ };
939
+ }
940
+ return plane;
941
+ };
942
+ var resolvePluridRoutePlaneData = (plane) => {
943
+ if (Array.isArray(plane)) {
944
+ const [
945
+ value,
946
+ component,
947
+ options
948
+ ] = plane;
949
+ return {
950
+ value,
951
+ component,
952
+ ...options
953
+ };
954
+ }
955
+ return plane;
956
+ };
957
+ var getPluridPlaneIDByData = (element) => {
958
+ if (!element) {
959
+ return "";
960
+ }
961
+ const parent = element.parentElement;
962
+ if (parent && parent.dataset.pluridPlane) {
963
+ return parent.dataset.pluridPlane;
964
+ }
965
+ return getPluridPlaneIDByData(parent);
966
+ };
967
+
968
+ // source/modules/routing/index.ts
969
+ var routing_exports = {};
970
+ __export(routing_exports, {
971
+ IsoMatcher: () => IsoMatcher_default,
972
+ RouteParser: () => Parser,
973
+ checkParameterLength: () => checkParameterLength,
974
+ checkPlaneAddressType: () => checkPlaneAddressType,
975
+ checkValidPath: () => checkValidPath,
976
+ cleanPathValue: () => cleanPathValue,
977
+ cleanupPath: () => cleanupPath,
978
+ computePlaneAddress: () => computePlaneAddress,
979
+ extractQuery: () => extractQuery,
980
+ isAbsolutePlane: () => isAbsolutePlane,
981
+ pluridLinkPathDivider: () => pluridLinkPathDivider,
982
+ removeTrailingSlash: () => removeTrailingSlash,
983
+ resolveRoute: () => resolveRoute,
984
+ stringInsertInitial: () => stringInsertInitial,
985
+ stringRemoveTrailing: () => stringRemoveTrailing
986
+ });
987
+
988
+ // source/modules/routing/Parser/logic.ts
989
+ var extractPathname = (location2) => {
990
+ const queryIndex = location2.indexOf("?");
991
+ const noQueryPath = queryIndex === -1 ? location2 : location2.substring(0, queryIndex);
992
+ const fragmentIndex = noQueryPath.indexOf("#:~:");
993
+ const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
994
+ return noFragmentPath;
995
+ };
996
+ var extractParametersAndMatch = (location2, route) => {
997
+ const routeElements = splitPath(route);
998
+ const parameters = [];
999
+ routeElements.forEach((routeElement) => {
1000
+ if (routeElement[0] === ":") {
1001
+ parameters.push(routeElement);
1002
+ } else {
1003
+ parameters.push("");
1004
+ }
1005
+ });
1006
+ const {
1007
+ locationElements,
1008
+ comparingPath
1009
+ } = computeComparingPath(location2, parameters);
1010
+ if (comparingPath !== route) {
1011
+ return {
1012
+ match: false,
1013
+ parameters: {},
1014
+ elements: locationElements
1015
+ };
1016
+ }
1017
+ const parametersValues = extractParametersValues(
1018
+ parameters,
1019
+ locationElements
1020
+ );
1021
+ return {
1022
+ match: true,
1023
+ parameters: parametersValues,
1024
+ elements: locationElements
1025
+ };
1026
+ };
1027
+ var extractParametersValues = (parameters, pathElements) => {
1028
+ const parametersValues = {};
1029
+ parameters.forEach(
1030
+ (parameter, index) => {
1031
+ if (parameter) {
1032
+ const parameterKey = parameter.slice(1);
1033
+ parametersValues[parameterKey] = pathElements[index];
1034
+ }
1035
+ }
1036
+ );
1037
+ return parametersValues;
1038
+ };
1039
+ var computeComparingPath = (path, parameters) => {
1040
+ const pathname = extractPathname(path);
1041
+ const locationElements = splitPath(pathname);
1042
+ const comparingPathElements = [...locationElements];
1043
+ for (const index of locationElements.keys()) {
1044
+ if (parameters[index]) {
1045
+ comparingPathElements[index] = parameters[index];
1046
+ }
1047
+ }
1048
+ const comparingPath = comparingPathElements.join("/");
1049
+ return {
1050
+ locationElements,
1051
+ comparingPath
1052
+ };
1053
+ };
1054
+ var splitPath = (path) => {
1055
+ return path.split("/").filter((i) => i !== "");
1056
+ };
1057
+ var extractQuery = (path) => {
1058
+ const fragmentIndex = path.indexOf("#:~:");
1059
+ const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
1060
+ const querySplit = noFragmentPath.split("?");
1061
+ if (querySplit.length === 2) {
1062
+ const queryValues = {};
1063
+ const query = querySplit[1];
1064
+ const params = new URLSearchParams(query);
1065
+ for (const [id, value] of params) {
1066
+ queryValues[id] = value;
1067
+ }
1068
+ return queryValues;
1069
+ } else {
1070
+ return {};
1071
+ }
1072
+ };
1073
+ var extractFragments = (location2) => {
1074
+ if (!location2) {
1075
+ return {
1076
+ texts: [],
1077
+ elements: []
1078
+ };
1079
+ }
1080
+ const split = location2.split("#:~:");
1081
+ const fragmentsValues = split[1];
1082
+ if (!fragmentsValues) {
1083
+ return {
1084
+ texts: [],
1085
+ elements: []
1086
+ };
1087
+ }
1088
+ const fragmentItems = fragmentsValues.split("&");
1089
+ const textFragments = [];
1090
+ const elementFragments = [];
1091
+ for (const item of fragmentItems) {
1092
+ const parsedFragment = parseFragment(item);
1093
+ if (parsedFragment) {
1094
+ switch (parsedFragment.type) {
1095
+ case "text":
1096
+ textFragments.push(parsedFragment);
1097
+ break;
1098
+ case "element":
1099
+ elementFragments.push(parsedFragment);
1100
+ break;
1101
+ }
1102
+ }
1103
+ }
1104
+ return {
1105
+ texts: textFragments,
1106
+ elements: elementFragments
1107
+ };
1108
+ };
1109
+ var parseFragment = (fragment) => {
1110
+ const fragmentData = fragment.split("=");
1111
+ const fragmentType = fragmentData[0];
1112
+ const fragmentValues = fragmentData[1];
1113
+ switch (fragmentType.toLowerCase()) {
1114
+ case "text": {
1115
+ const textValues = fragmentValues.split(",");
1116
+ const textStart = textValues[0];
1117
+ const textEnd = textValues[1];
1118
+ const textOccurence = extractOccurence(textValues[2]);
1119
+ if (!textStart) {
1120
+ return;
1121
+ }
1122
+ return {
1123
+ type: "text",
1124
+ start: textStart,
1125
+ end: textEnd || "",
1126
+ occurence: textOccurence
1127
+ };
1128
+ }
1129
+ case "element": {
1130
+ const elementValues = fragmentValues.split(",");
1131
+ const elementID = elementValues[0];
1132
+ const elementOccurence = extractOccurence(elementValues[1]);
1133
+ if (!elementID) {
1134
+ return;
1135
+ }
1136
+ return {
1137
+ type: "element",
1138
+ id: elementID,
1139
+ occurence: elementOccurence
1140
+ };
1141
+ }
1142
+ }
1143
+ return void 0;
1144
+ };
1145
+ var extractOccurence = (occurence) => {
1146
+ if (!occurence) {
1147
+ return 0;
1148
+ }
1149
+ const occurenceMatch = occurence.match(/\[(\d*)\]/);
1150
+ const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
1151
+ return occurenceValue;
1152
+ };
1153
+
1154
+ // source/modules/routing/logic/general/index.ts
1155
+ var stringInsertInitial = (value, insert) => {
1156
+ if (!value.startsWith(insert)) {
1157
+ value = insert + value;
1158
+ }
1159
+ return value;
1160
+ };
1161
+ var stringRemoveTrailing = (value, trail) => {
1162
+ if (value.endsWith(trail)) {
1163
+ value = value.slice(0, value.length - trail.length);
1164
+ }
1165
+ return value;
1166
+ };
1167
+ var PATH_SEPARATOR = "/";
1168
+ var cleanupPath = (value) => {
1169
+ value = stringInsertInitial(value, PATH_SEPARATOR);
1170
+ value = stringRemoveTrailing(value, PATH_SEPARATOR);
1171
+ return value;
1172
+ };
1173
+ var computePlaneAddress = (plane, route, origin = "origin") => {
1174
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
1175
+ origin = location.host;
1176
+ }
1177
+ const cleanPlane = extractPathname(plane);
1178
+ const planeAddressType = checkPlaneAddressType(cleanPlane);
1179
+ switch (planeAddressType) {
1180
+ case "http":
1181
+ case "https":
1182
+ case "pttp":
1183
+ return cleanPlane;
1184
+ }
1185
+ origin = stringRemoveTrailing(origin, "/");
1186
+ const absolutePlane = isAbsolutePlane(plane);
1187
+ const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
1188
+ const planeAddress = protocols.plurid + origin + path;
1189
+ return planeAddress;
1190
+ };
1191
+ var isAbsolutePlane = (value) => {
1192
+ return value[0] === "/";
1193
+ };
1194
+ var checkPlaneAddressType = (value) => {
1195
+ value = value.toLowerCase().trim();
1196
+ if (value.startsWith(protocols.plurid)) {
1197
+ return "pttp";
1198
+ }
1199
+ if (value.startsWith(protocols.https)) {
1200
+ return HTTPS_PROTOCOL;
1201
+ }
1202
+ if (value.startsWith(protocols.http)) {
1203
+ return HTTP_PROTOCOL;
1204
+ }
1205
+ return "relative";
1206
+ };
1207
+ var removeTrailingSlash = (value) => {
1208
+ if (value.endsWith("/") && value.length > 1) {
1209
+ return value.slice(0, value.length - 1);
1210
+ }
1211
+ return value;
1212
+ };
1213
+ var cleanPathValue = (value) => {
1214
+ const queryStart = value.indexOf("?");
1215
+ if (queryStart < 0) {
1216
+ return removeTrailingSlash(
1217
+ value
1218
+ );
1219
+ }
1220
+ return removeTrailingSlash(
1221
+ value.substring(0, queryStart)
1222
+ );
1223
+ };
1224
+ var checkParameterLength = (parameter, length, compareType) => {
1225
+ const parameterLength = parameter.length;
1226
+ switch (compareType) {
1227
+ case compareTypes.equal:
1228
+ return parameterLength === length;
1229
+ case compareTypes.equalLessThan:
1230
+ return parameterLength <= length;
1231
+ case compareTypes.lessThan:
1232
+ return parameterLength < length;
1233
+ case compareTypes.equalGreaterThan:
1234
+ return parameterLength >= length;
1235
+ case compareTypes.greaterThan:
1236
+ return parameterLength > length;
1237
+ default:
1238
+ return parameterLength <= length;
1239
+ }
1240
+ };
1241
+ var checkValidPath = (validationParameters, parameters) => {
1242
+ if (validationParameters) {
1243
+ for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
1244
+ const {
1245
+ length,
1246
+ lengthType,
1247
+ startsWith,
1248
+ endsWith,
1249
+ includes
1250
+ } = parameterData;
1251
+ const paramaterValue = parameters[parameterKey];
1252
+ if (!paramaterValue) {
1253
+ return false;
1254
+ }
1255
+ if (startsWith && !paramaterValue.startsWith(startsWith)) {
1256
+ return false;
1257
+ }
1258
+ if (endsWith && !paramaterValue.endsWith(endsWith)) {
1259
+ return false;
1260
+ }
1261
+ if (includes && !includes.includes(paramaterValue)) {
1262
+ return false;
1263
+ }
1264
+ if (length) {
1265
+ const validLength = checkParameterLength(
1266
+ paramaterValue,
1267
+ length,
1268
+ lengthType
1269
+ );
1270
+ if (!validLength) {
1271
+ return false;
1272
+ }
1273
+ }
1274
+ }
1275
+ }
1276
+ return true;
1277
+ };
1278
+
1279
+ // source/modules/utilities/index.ts
1280
+ var utilities_exports = {};
1281
+ __export(utilities_exports, {
1282
+ cleanPathElement: () => cleanPathElement
1283
+ });
1284
+ var cleanPathElement = (path) => {
1285
+ if (path[0] === "/") {
1286
+ return path.slice(1);
1287
+ }
1288
+ return path;
1289
+ };
1290
+
1291
+ // source/modules/routing/logic/utilities/index.ts
1292
+ var pluridLinkPathDivider = (route) => {
1293
+ const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
1294
+ const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
1295
+ const split = route.split("://").filter((value) => value !== "").map((value) => cleanPathElement(value));
1296
+ let protocol = windowProtocol;
1297
+ const host = {
1298
+ value: windowHost,
1299
+ controlled: false
1300
+ };
1301
+ const path = {
1302
+ value: "",
1303
+ parameters: {},
1304
+ query: {}
1305
+ };
1306
+ const space = {
1307
+ value: "",
1308
+ parameters: {},
1309
+ query: {}
1310
+ };
1311
+ const universe = {
1312
+ value: "",
1313
+ parameters: {},
1314
+ query: {}
1315
+ };
1316
+ const cluster = {
1317
+ value: "",
1318
+ parameters: {},
1319
+ query: {}
1320
+ };
1321
+ const plane = {
1322
+ value: "",
1323
+ parameters: {},
1324
+ query: {},
1325
+ fragments: {
1326
+ texts: [],
1327
+ elements: []
1328
+ }
1329
+ };
1330
+ const valid = false;
1331
+ if (split.length === 0 || split.length > 7) {
1332
+ const url2 = {
1333
+ protocol: {
1334
+ value: protocol,
1335
+ secure: true
1336
+ },
1337
+ host,
1338
+ path,
1339
+ space,
1340
+ universe,
1341
+ cluster,
1342
+ plane,
1343
+ valid
1344
+ };
1345
+ return url2;
1346
+ }
1347
+ if (route.startsWith("/://")) {
1348
+ const routeSplit = split.slice(1);
1349
+ switch (routeSplit.length) {
1350
+ case 1:
1351
+ path.value = routeSplit[0];
1352
+ break;
1353
+ case 5:
1354
+ path.value = routeSplit[0];
1355
+ space.value = routeSplit[1];
1356
+ universe.value = routeSplit[2];
1357
+ cluster.value = routeSplit[3];
1358
+ plane.value = routeSplit[4];
1359
+ break;
1360
+ }
1361
+ const url2 = {
1362
+ protocol: {
1363
+ value: protocol,
1364
+ secure: true
1365
+ },
1366
+ host,
1367
+ path,
1368
+ space,
1369
+ universe,
1370
+ cluster,
1371
+ plane,
1372
+ valid: true
1373
+ };
1374
+ return url2;
1375
+ }
1376
+ if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
1377
+ switch (split.length) {
1378
+ case 1:
1379
+ plane.value = split[0];
1380
+ break;
1381
+ case 2:
1382
+ cluster.value = split[0];
1383
+ plane.value = split[1];
1384
+ break;
1385
+ case 3:
1386
+ universe.value = split[0];
1387
+ cluster.value = split[1];
1388
+ plane.value = split[2];
1389
+ break;
1390
+ case 4:
1391
+ space.value = split[0];
1392
+ universe.value = split[1];
1393
+ cluster.value = split[2];
1394
+ plane.value = split[3];
1395
+ break;
1396
+ case 5:
1397
+ path.value = split[0];
1398
+ space.value = split[1];
1399
+ universe.value = split[2];
1400
+ cluster.value = split[3];
1401
+ plane.value = split[4];
1402
+ break;
1403
+ case 6:
1404
+ host.value = split[0];
1405
+ path.value = split[1];
1406
+ space.value = split[2];
1407
+ universe.value = split[3];
1408
+ cluster.value = split[4];
1409
+ plane.value = split[5];
1410
+ break;
1411
+ default:
1412
+ const url2 = {
1413
+ protocol: {
1414
+ value: protocol,
1415
+ secure: true
1416
+ },
1417
+ host,
1418
+ path,
1419
+ space,
1420
+ universe,
1421
+ cluster,
1422
+ plane,
1423
+ valid
1424
+ };
1425
+ return url2;
1426
+ }
1427
+ } else {
1428
+ switch (split.length) {
1429
+ case 3:
1430
+ protocol = split[0];
1431
+ host.value = split[1];
1432
+ path.value = split[2];
1433
+ break;
1434
+ case 7:
1435
+ protocol = split[0];
1436
+ host.value = split[1];
1437
+ path.value = split[2];
1438
+ space.value = split[3];
1439
+ universe.value = split[4];
1440
+ cluster.value = split[5];
1441
+ plane.value = split[6];
1442
+ break;
1443
+ default:
1444
+ const url2 = {
1445
+ protocol: {
1446
+ value: protocol,
1447
+ secure: true
1448
+ },
1449
+ host,
1450
+ path,
1451
+ space,
1452
+ universe,
1453
+ cluster,
1454
+ plane,
1455
+ valid
1456
+ };
1457
+ return url2;
1458
+ }
1459
+ }
1460
+ const url = {
1461
+ protocol: {
1462
+ value: protocol,
1463
+ secure: true
1464
+ },
1465
+ host,
1466
+ path,
1467
+ space,
1468
+ universe,
1469
+ cluster,
1470
+ plane,
1471
+ valid: true
1472
+ };
1473
+ return url;
1474
+ };
1475
+ var resolveRoute = (route, protocol, host) => {
1476
+ const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
1477
+ const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
1478
+ const divisions = pluridLinkPathDivider(route);
1479
+ const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
1480
+ const protocolDivision = divisions.protocol.value || windowProtocol;
1481
+ const hostDivision = divisions.host.value ? divisions.host : {
1482
+ value: windowHost,
1483
+ controlled: true
1484
+ };
1485
+ const path = divisions.path.value ? divisions.path : {
1486
+ value: defaultPathname,
1487
+ parameters: {},
1488
+ query: {}
1489
+ };
1490
+ const space = divisions.space.value ? divisions.space : {
1491
+ value: "s",
1492
+ parameters: {},
1493
+ query: {}
1494
+ };
1495
+ const universe = divisions.universe.value ? divisions.universe : {
1496
+ value: "u",
1497
+ parameters: {},
1498
+ query: {}
1499
+ };
1500
+ const cluster = divisions.cluster.value ? divisions.cluster : {
1501
+ value: "c",
1502
+ parameters: {},
1503
+ query: {}
1504
+ };
1505
+ const plane = divisions.plane;
1506
+ const separator = "://";
1507
+ if (!plane.value && route !== "/") {
1508
+ const resolvers2 = [
1509
+ protocolDivision,
1510
+ hostDivision.value,
1511
+ path.value
1512
+ ];
1513
+ const absoluteRoute2 = resolvers2.join(separator);
1514
+ return {
1515
+ protocol: protocolDivision,
1516
+ host: hostDivision,
1517
+ path,
1518
+ space,
1519
+ universe,
1520
+ cluster,
1521
+ plane,
1522
+ route: absoluteRoute2
1523
+ };
1524
+ }
1525
+ [
1526
+ protocolDivision,
1527
+ hostDivision.value,
1528
+ path.value,
1529
+ space.value,
1530
+ universe.value,
1531
+ cluster.value,
1532
+ cleanPathElement(plane.value)
1533
+ ];
1534
+ return {
1535
+ protocol: "",
1536
+ host: "",
1537
+ path,
1538
+ space: "",
1539
+ universe: "",
1540
+ cluster: "",
1541
+ plane: "",
1542
+ route
1543
+ };
1544
+ };
1545
+
1546
+ // source/modules/routing/IsoMatcher/index.ts
1547
+ var IsoMatcher = class {
1548
+ origin;
1549
+ routesIndex = /* @__PURE__ */ new Map();
1550
+ planesIndex = /* @__PURE__ */ new Map();
1551
+ routesKeys = [];
1552
+ planesKeys = [];
1553
+ constructor(data, origin = "origin") {
1554
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
1555
+ this.origin = location.host;
1556
+ } else {
1557
+ this.origin = origin;
1558
+ }
1559
+ this.updateIndexes(
1560
+ data.routes || [],
1561
+ data.routePlanes || [],
1562
+ data.planes || []
1563
+ );
1564
+ }
1565
+ match(path, context = "plane") {
1566
+ switch (context) {
1567
+ case "plane":
1568
+ return this.matchPlane(path);
1569
+ case "route":
1570
+ return this.matchRoute(path);
1571
+ }
1572
+ }
1573
+ /**
1574
+ * Dynammically update the planes and routes indexes.
1575
+ *
1576
+ * @param data
1577
+ */
1578
+ index(data) {
1579
+ this.updateIndexes(
1580
+ data.routes || [],
1581
+ data.routePlanes || [],
1582
+ data.planes || []
1583
+ );
1584
+ }
1585
+ /**
1586
+ * Clear all data.
1587
+ *
1588
+ */
1589
+ clear() {
1590
+ this.routesIndex = /* @__PURE__ */ new Map();
1591
+ this.planesIndex = /* @__PURE__ */ new Map();
1592
+ this.routesKeys = [];
1593
+ this.planesKeys = [];
1594
+ }
1595
+ getPlanesIndex() {
1596
+ return this.planesIndex;
1597
+ }
1598
+ /**
1599
+ * Creates a common data structure able to match and route accordingly.
1600
+ *
1601
+ */
1602
+ updateIndexes(routes, routePlanes, planes) {
1603
+ this.indexPlanes(
1604
+ planes,
1605
+ "Plane"
1606
+ );
1607
+ this.indexPlanes(
1608
+ routePlanes,
1609
+ "RoutePlane"
1610
+ );
1611
+ for (const route of routes) {
1612
+ if (route.planes) {
1613
+ this.indexPlanes(
1614
+ route.planes,
1615
+ "RoutePlane",
1616
+ route.value
1617
+ );
1618
+ }
1619
+ this.routesIndex.set(
1620
+ route.value,
1621
+ {
1622
+ data: {
1623
+ ...route
1624
+ }
1625
+ }
1626
+ );
1627
+ }
1628
+ this.routesKeys = Array.from(this.routesIndex.keys());
1629
+ this.planesKeys = Array.from(this.planesIndex.keys());
1630
+ }
1631
+ indexPlanes(planes, kind, parent) {
1632
+ for (const plane of planes) {
1633
+ const planeData = kind === "Plane" ? resolvePluridPlaneData(plane) : resolvePluridRoutePlaneData(plane);
1634
+ const address = computePlaneAddress(
1635
+ kind === "Plane" ? planeData.route : planeData.value,
1636
+ parent,
1637
+ this.origin
1638
+ );
1639
+ const indexedPlane = {
1640
+ kind,
1641
+ data: {
1642
+ ...planeData
1643
+ }
1644
+ };
1645
+ if (parent) {
1646
+ indexedPlane["parent"] = parent;
1647
+ }
1648
+ this.planesIndex.set(
1649
+ address,
1650
+ indexedPlane
1651
+ );
1652
+ }
1653
+ }
1654
+ matchPlane(value) {
1655
+ const planeAddress = computePlaneAddress(
1656
+ value,
1657
+ void 0,
1658
+ this.origin
1659
+ );
1660
+ const plane = this.planesIndex.get(planeAddress);
1661
+ if (plane) {
1662
+ const query = extractQuery(
1663
+ value
1664
+ );
1665
+ const fragments = extractFragments(
1666
+ value
1667
+ );
1668
+ const match = {
1669
+ value: planeAddress,
1670
+ fragments,
1671
+ query,
1672
+ parameters: {}
1673
+ };
1674
+ if (plane.kind === "Plane") {
1675
+ const {
1676
+ kind,
1677
+ data,
1678
+ parent
1679
+ } = plane;
1680
+ const result = {
1681
+ kind,
1682
+ data,
1683
+ parent,
1684
+ match
1685
+ };
1686
+ return result;
1687
+ }
1688
+ if (plane.kind === "RoutePlane") {
1689
+ const {
1690
+ kind,
1691
+ data,
1692
+ parent
1693
+ } = plane;
1694
+ const result = {
1695
+ kind,
1696
+ data,
1697
+ parent,
1698
+ match
1699
+ };
1700
+ return result;
1701
+ }
1702
+ }
1703
+ for (const planePath of this.planesKeys) {
1704
+ const normalizedPlanePath = planePath.replace(protocols.plurid, "");
1705
+ const normalizedPlaneAddress = planeAddress.replace(protocols.plurid, "");
1706
+ const planePathSplit = normalizedPlanePath.split("/");
1707
+ const planeAddressSplit = normalizedPlaneAddress.split("/");
1708
+ if (planePathSplit[0] !== planeAddressSplit[0]) {
1709
+ continue;
1710
+ }
1711
+ if (planePathSplit.length !== planeAddressSplit.length) {
1712
+ continue;
1713
+ }
1714
+ const parametersAndMatch = extractParametersAndMatch(
1715
+ normalizedPlaneAddress,
1716
+ normalizedPlanePath
1717
+ );
1718
+ if (parametersAndMatch.match) {
1719
+ const plane2 = this.planesIndex.get(planePath);
1720
+ if (!plane2) {
1721
+ continue;
1722
+ }
1723
+ const {
1724
+ parameters
1725
+ } = parametersAndMatch;
1726
+ const validPath = checkValidPath(
1727
+ plane2.data.parameters,
1728
+ parameters
1729
+ );
1730
+ if (!validPath) {
1731
+ continue;
1732
+ }
1733
+ const query = extractQuery(
1734
+ value
1735
+ );
1736
+ const fragments = extractFragments(
1737
+ value
1738
+ );
1739
+ const match = {
1740
+ value: planeAddress,
1741
+ fragments,
1742
+ query,
1743
+ parameters
1744
+ };
1745
+ if (plane2.kind === "Plane") {
1746
+ const {
1747
+ kind,
1748
+ data,
1749
+ parent
1750
+ } = plane2;
1751
+ const result = {
1752
+ kind,
1753
+ data,
1754
+ parent,
1755
+ match
1756
+ };
1757
+ return result;
1758
+ }
1759
+ if (plane2.kind === "RoutePlane") {
1760
+ const {
1761
+ kind,
1762
+ data,
1763
+ parent
1764
+ } = plane2;
1765
+ const result = {
1766
+ kind,
1767
+ data,
1768
+ parent,
1769
+ match
1770
+ };
1771
+ return result;
1772
+ }
1773
+ }
1774
+ }
1775
+ return;
1776
+ }
1777
+ matchRoute(value) {
1778
+ const routeValue = cleanPathValue(value);
1779
+ const route = this.routesIndex.get(routeValue);
1780
+ if (route) {
1781
+ const query = extractQuery(
1782
+ value
1783
+ );
1784
+ const result = {
1785
+ kind: "Route",
1786
+ data: route.data,
1787
+ match: {
1788
+ // value: extractPathname(value),
1789
+ value: routeValue,
1790
+ query,
1791
+ parameters: {}
1792
+ }
1793
+ };
1794
+ return result;
1795
+ }
1796
+ for (const routePath of this.routesKeys) {
1797
+ const routeSplit = routePath.split("/");
1798
+ const valueSplit = routeValue.split("/");
1799
+ if (routeSplit.length !== valueSplit.length) {
1800
+ continue;
1801
+ }
1802
+ const parametersAndMatch = extractParametersAndMatch(
1803
+ routeValue.slice(1),
1804
+ routePath.slice(1)
1805
+ );
1806
+ if (parametersAndMatch.match) {
1807
+ const route2 = this.routesIndex.get(routePath);
1808
+ if (!route2) {
1809
+ continue;
1810
+ }
1811
+ const {
1812
+ parameters
1813
+ } = parametersAndMatch;
1814
+ const validPath = checkValidPath(
1815
+ route2.data.parameters,
1816
+ parameters
1817
+ );
1818
+ if (!validPath) {
1819
+ continue;
1820
+ }
1821
+ const query = extractQuery(
1822
+ value
1823
+ );
1824
+ const match = {
1825
+ // value: extractPathname(value),
1826
+ value: routeValue,
1827
+ query,
1828
+ parameters
1829
+ };
1830
+ if (route2) {
1831
+ const result = {
1832
+ kind: "Route",
1833
+ data: route2.data,
1834
+ match
1835
+ };
1836
+ return result;
1837
+ }
1838
+ }
1839
+ }
1840
+ const routePlane = this.matchPlane(routeValue);
1841
+ if (routePlane) {
1842
+ const result = {
1843
+ kind: "RoutePlane",
1844
+ data: routePlane.data,
1845
+ // HACK
1846
+ match: {
1847
+ // value: extractPathname(value),
1848
+ value: routeValue,
1849
+ query: routePlane.match.query,
1850
+ parameters: routePlane.match.parameters
1851
+ }
1852
+ };
1853
+ return result;
1854
+ }
1855
+ return;
1856
+ }
1857
+ };
1858
+ var IsoMatcher_default = IsoMatcher;
1859
+
1860
+ // source/modules/routing/Parser/index.ts
1861
+ var Parser = class {
1862
+ /** properties */
1863
+ location;
1864
+ path;
1865
+ options;
1866
+ /** constructor */
1867
+ constructor(location2, path, options) {
1868
+ this.location = location2;
1869
+ this.path = path;
1870
+ this.options = this.handleOptions(options);
1871
+ }
1872
+ /** private */
1873
+ handleOptions(options) {
1874
+ const parserOptions = {
1875
+ fragment: options?.fragment || true
1876
+ };
1877
+ return parserOptions;
1878
+ }
1879
+ extractPathname() {
1880
+ const pathname = extractPathname(
1881
+ this.location
1882
+ );
1883
+ return pathname;
1884
+ }
1885
+ extractParametersAndMatch() {
1886
+ const parametersAndMatch = extractParametersAndMatch(
1887
+ this.location,
1888
+ this.path.value
1889
+ );
1890
+ return parametersAndMatch;
1891
+ }
1892
+ extractQuery() {
1893
+ const query = extractQuery(
1894
+ this.location
1895
+ );
1896
+ return query;
1897
+ }
1898
+ extractFragments() {
1899
+ const fragments = this.options.fragment ? extractFragments(this.location) : extractFragments();
1900
+ return fragments;
1901
+ }
1902
+ /** public */
1903
+ /**
1904
+ * Extract pathname, parameters, query, and fragment, if available.
1905
+ */
1906
+ extract() {
1907
+ const pathname = this.extractPathname();
1908
+ const {
1909
+ match,
1910
+ parameters,
1911
+ elements
1912
+ } = this.extractParametersAndMatch();
1913
+ const query = this.extractQuery();
1914
+ const queryData = Object.entries(query).map(([key, value]) => {
1915
+ return key + "=" + value;
1916
+ }).join("&");
1917
+ const queryString = queryData ? "?" + queryData : "";
1918
+ const fragments = this.extractFragments();
1919
+ const parserResponse = {
1920
+ path: this.path,
1921
+ pathname,
1922
+ elements,
1923
+ match,
1924
+ parameters,
1925
+ query,
1926
+ fragments,
1927
+ route: pathname + queryString
1928
+ };
1929
+ return parserResponse;
1930
+ }
1931
+ };
1932
+
1933
+ // source/modules/planes/registrar/object.ts
1934
+ var PluridPlanesRegistrar = class {
1935
+ isoMatcher;
1936
+ constructor(planes, origin = "origin") {
1937
+ this.isoMatcher = new IsoMatcher_default(
1938
+ {
1939
+ planes
1940
+ },
1941
+ origin
1942
+ );
1943
+ }
1944
+ register(planes) {
1945
+ this.isoMatcher.index({
1946
+ planes
1947
+ });
1948
+ }
1949
+ identify() {
1950
+ const planes = this.isoMatcher.getPlanesIndex();
1951
+ return [...planes.keys()];
1952
+ }
1953
+ get(route) {
1954
+ const match = this.isoMatcher.match(route);
1955
+ if (match) {
1956
+ const absoluteRoute = match.kind === "Plane" ? match.data.route : match.data.value;
1957
+ const registeredPlane = {
1958
+ route: {
1959
+ absolute: absoluteRoute,
1960
+ fragments: match.match.fragments,
1961
+ parameters: match.match.parameters,
1962
+ query: match.match.query
1963
+ },
1964
+ component: match.data.component
1965
+ };
1966
+ return registeredPlane;
1967
+ }
1968
+ return;
1969
+ }
1970
+ getAll() {
1971
+ const planes = this.isoMatcher.getPlanesIndex();
1972
+ const all = /* @__PURE__ */ new Map();
1973
+ for (const [path, plane] of planes) {
1974
+ const absoluteRoute = plane.kind === "Plane" ? plane.data.route : plane.data.value;
1975
+ const registeredPlane = {
1976
+ route: {
1977
+ absolute: absoluteRoute,
1978
+ fragments: {
1979
+ elements: [],
1980
+ texts: []
1981
+ },
1982
+ parameters: {},
1983
+ query: {}
1984
+ },
1985
+ component: plane.data.component
1986
+ };
1987
+ all.set(
1988
+ path,
1989
+ registeredPlane
1990
+ );
1991
+ }
1992
+ return all;
1993
+ }
1994
+ };
1995
+ var object_default = PluridPlanesRegistrar;
1996
+
1997
+ // source/modules/planes/registrar/utilities.ts
1998
+ var registerPlanes = (planes, planesRegistrar, origin = "origin") => {
1999
+ if (!planes) {
2000
+ return;
2001
+ }
2002
+ if (planesRegistrar) {
2003
+ planesRegistrar.register(planes);
2004
+ return;
2005
+ }
2006
+ if (typeof window === "undefined") {
2007
+ return;
2008
+ }
2009
+ if (typeof window.__pluridPlanesRegistrar__ === "undefined") {
2010
+ const pluridPlanesRegistrar = new object_default([], origin);
2011
+ window.__pluridPlanesRegistrar__ = pluridPlanesRegistrar;
2012
+ window.__pluridPlanesRegistrar__.register(planes);
2013
+ return;
2014
+ }
2015
+ window.__pluridPlanesRegistrar__.register(planes);
2016
+ return;
2017
+ };
2018
+ var getPlanesRegistrar = (planesRegistrar) => {
2019
+ if (planesRegistrar) {
2020
+ return planesRegistrar;
2021
+ }
2022
+ if (typeof window !== "undefined") {
2023
+ if (window.__pluridPlanesRegistrar__ !== void 0) {
2024
+ return window.__pluridPlanesRegistrar__;
2025
+ }
2026
+ }
2027
+ return;
2028
+ };
2029
+ var getRegisteredPlanes = (planesRegistrar) => {
2030
+ if (planesRegistrar) {
2031
+ return planesRegistrar.getAll();
2032
+ }
2033
+ if (typeof window !== "undefined") {
2034
+ if (window.__pluridPlanesRegistrar__ !== void 0) {
2035
+ return window.__pluridPlanesRegistrar__.getAll();
2036
+ }
2037
+ }
2038
+ return /* @__PURE__ */ new Map();
2039
+ };
2040
+ var getRegisteredPlane = (route, planesRegistrar) => {
2041
+ if (planesRegistrar) {
2042
+ return planesRegistrar.get(route);
2043
+ }
2044
+ if (typeof window !== "undefined") {
2045
+ if (window.__pluridPlanesRegistrar__ !== void 0) {
2046
+ return window.__pluridPlanesRegistrar__.get(route);
2047
+ }
2048
+ }
2049
+ return;
2050
+ };
2051
+
2052
+ // source/modules/space/index.ts
2053
+ var space_exports = {};
2054
+ __export(space_exports, {
2055
+ layout: () => layout_exports,
2056
+ location: () => location_exports,
2057
+ tree: () => tree_exports2,
2058
+ utilities: () => utilities_exports2,
2059
+ view: () => view_exports
2060
+ });
2061
+
2062
+ // source/modules/space/layout/index.ts
2063
+ var layout_exports = {};
2064
+ __export(layout_exports, {
2065
+ computeColumnLayout: () => column_default,
2066
+ computeFaceToFaceLayout: () => faceToFace_default,
2067
+ computeRowLayout: () => row_default,
2068
+ computeSheavesLayout: () => sheaves_default,
2069
+ computeZigZagLayout: () => zigZag_default
2070
+ });
2071
+
2072
+ // source/modules/space/location/index.ts
2073
+ var location_exports = {};
2074
+ __export(location_exports, {
2075
+ computePath: () => computePath,
2076
+ computePluridPlaneLocation: () => computePluridPlaneLocation,
2077
+ recomputeChildrenLocation: () => recomputeChildrenLocation
2078
+ });
2079
+
2080
+ // source/modules/space/utilities/index.ts
2081
+ var utilities_exports2 = {};
2082
+ __export(utilities_exports2, {
2083
+ computeSpaceSize: () => computeSpaceSize,
2084
+ findPage: () => findPage,
2085
+ getTreePlaneByPlaneID: () => getTreePlaneByPlaneID,
2086
+ splitIntoGroups: () => splitIntoGroups
2087
+ });
2088
+ var computeSpaceSize = (tree) => {
2089
+ let width = 0;
2090
+ let height = 0;
2091
+ let depth = 0;
2092
+ const topCorner = {
2093
+ x: 0,
2094
+ y: 0,
2095
+ z: 0
2096
+ };
2097
+ tree.map((treePage) => {
2098
+ const spaceWidth = treePage.location.translateX + treePage.width;
2099
+ if (spaceWidth > width) {
2100
+ width = spaceWidth;
2101
+ }
2102
+ const spaceHeight = treePage.location.translateY + treePage.height;
2103
+ if (spaceHeight > height) {
2104
+ height = spaceHeight;
2105
+ }
2106
+ const spaceDepth = treePage.location.translateZ;
2107
+ if (spaceDepth > depth) {
2108
+ depth = spaceDepth;
2109
+ }
2110
+ });
2111
+ return {
2112
+ width,
2113
+ height,
2114
+ depth,
2115
+ topCorner
2116
+ };
2117
+ };
2118
+ var findPage = (view, pages) => {
2119
+ for (const page of pages) {
2120
+ if (page.route === view) {
2121
+ return page;
2122
+ }
2123
+ }
2124
+ return;
2125
+ };
2126
+ var splitIntoGroups = (data, length) => {
2127
+ const initialArray = [...data];
2128
+ const groups = [];
2129
+ while (initialArray.length) {
2130
+ const group = initialArray.splice(0, length);
2131
+ groups.push(group);
2132
+ }
2133
+ return groups;
2134
+ };
2135
+ var getTreePlaneByPlaneID = (tree, planeID) => {
2136
+ let _page = null;
2137
+ for (const page of tree) {
2138
+ if (page.planeID === planeID) {
2139
+ _page = page;
2140
+ }
2141
+ if (page.children && !_page) {
2142
+ _page = getTreePlaneByPlaneID(page.children, planeID);
2143
+ }
2144
+ if (_page) {
2145
+ break;
2146
+ }
2147
+ }
2148
+ return _page;
2149
+ };
2150
+
2151
+ // source/modules/space/location/logic.ts
2152
+ var toRadians = mathematics.geometry.toRadians;
2153
+ var computePath = (tree, planeID) => {
2154
+ const path = [];
2155
+ const page = getTreePlaneByPlaneID(tree, planeID);
2156
+ if (page) {
2157
+ path.push({ ...page });
2158
+ let parentID = page.parentPlaneID;
2159
+ if (!parentID) {
2160
+ return path;
2161
+ }
2162
+ while (parentID) {
2163
+ const parentPage = getTreePlaneByPlaneID(tree, parentID);
2164
+ if (parentPage) {
2165
+ const page2 = { ...parentPage };
2166
+ page2.children = [];
2167
+ path.push(page2);
2168
+ parentID = parentPage.parentPlaneID;
2169
+ }
2170
+ }
2171
+ }
2172
+ return path.reverse();
2173
+ };
2174
+ var computePluridPlaneLocation = (linkCoordinates, treePageParent, bridgeLength = 100, linkPlaneAngle = 90) => {
2175
+ const parentAngleRadians = toRadians(treePageParent.location.rotateY);
2176
+ const linkPoint = {
2177
+ x: treePageParent.location.translateX + linkCoordinates.x * Math.cos(parentAngleRadians),
2178
+ z: treePageParent.location.translateZ - linkCoordinates.x * Math.sin(parentAngleRadians)
2179
+ };
2180
+ const linkAngleRadians = toRadians(linkPlaneAngle + treePageParent.location.rotateY);
2181
+ const x = linkPoint.x + bridgeLength * Math.cos(linkAngleRadians);
2182
+ const z = linkPoint.z - bridgeLength * Math.sin(linkAngleRadians);
2183
+ const y = treePageParent.location.translateY + linkCoordinates.y;
2184
+ const locationCoordinates = {
2185
+ x,
2186
+ y,
2187
+ z
2188
+ };
2189
+ return locationCoordinates;
2190
+ };
2191
+ var recomputeChildrenLocation = (page) => {
2192
+ if (!page.children) {
2193
+ return [];
2194
+ }
2195
+ const updatedChildren = [];
2196
+ for (const child of page.children) {
2197
+ if (child.linkCoordinates) {
2198
+ const location2 = computePluridPlaneLocation(
2199
+ child.linkCoordinates,
2200
+ page,
2201
+ child.bridgeLength,
2202
+ child.planeAngle
2203
+ );
2204
+ const updatedChild = {
2205
+ ...child,
2206
+ location: {
2207
+ ...child.location,
2208
+ translateX: location2.x,
2209
+ translateY: location2.y,
2210
+ translateZ: location2.z
2211
+ }
2212
+ };
2213
+ const children = updatedChild.children ? recomputeChildrenLocation(updatedChild) : [];
2214
+ const updatedChildWithChildren = {
2215
+ ...updatedChild,
2216
+ children
2217
+ };
2218
+ updatedChildren.push(updatedChildWithChildren);
2219
+ }
2220
+ }
2221
+ return updatedChildren;
2222
+ };
2223
+
2224
+ // source/modules/space/layout/column.ts
2225
+ var computeColumnLayout = (roots, columns = 1, columnLength, gap = ROOTS_GAP, configuration = defaultConfiguration) => {
2226
+ const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
2227
+ const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
2228
+ const tree = [];
2229
+ const configurationWidth = configuration.elements.plane.width;
2230
+ const width = mathematics.numbers.checkIntegerNonUnit(configurationWidth) ? configurationWidth : configurationWidth * windowInnerWidth;
2231
+ const height = windowInnerHeight;
2232
+ const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
2233
+ const safeColumns = columns > 0 ? columns : 1;
2234
+ const length = columnLength && columnLength > 0 ? columnLength : Math.ceil(roots.length / safeColumns);
2235
+ for (const [index, root] of roots.entries()) {
2236
+ const rowIndex = index % length;
2237
+ const columnIndex = Math.floor(index / length);
2238
+ const translateX = columnIndex * (width + gapValue);
2239
+ const translateY = rowIndex * (height + gapValue);
2240
+ const treePage = {
2241
+ ...root,
2242
+ location: {
2243
+ translateX,
2244
+ translateY,
2245
+ translateZ: 0,
2246
+ rotateX: 0,
2247
+ rotateY: 0
2248
+ }
2249
+ };
2250
+ const children = recomputeChildrenLocation(treePage);
2251
+ const treePageWithChildren = {
2252
+ ...treePage,
2253
+ children
2254
+ };
2255
+ tree.push(treePageWithChildren);
2256
+ }
2257
+ return tree;
2258
+ };
2259
+ var column_default = computeColumnLayout;
2260
+ var computeRowLayout = (roots, rows = 1, rowLength, gap = ROOTS_GAP, configuration = defaultConfiguration) => {
2261
+ const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
2262
+ const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
2263
+ const tree = [];
2264
+ const configurationWidth = configuration.elements.plane.width;
2265
+ const width = mathematics.numbers.checkIntegerNonUnit(configurationWidth) ? configurationWidth : configurationWidth * windowInnerWidth;
2266
+ const height = windowInnerHeight;
2267
+ const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
2268
+ const safeRows = rows > 0 ? rows : 1;
2269
+ const length = rowLength && rowLength > 0 ? rowLength : Math.ceil(roots.length / safeRows);
2270
+ for (const [index, root] of roots.entries()) {
2271
+ const rowIndex = Math.floor(index / length);
2272
+ const columnIndex = index % length;
2273
+ const translateX = columnIndex * (width + gapValue);
2274
+ const translateY = rowIndex * (height + gapValue);
2275
+ const treePage = {
2276
+ ...root,
2277
+ location: {
2278
+ translateX,
2279
+ translateY,
2280
+ translateZ: 0,
2281
+ rotateX: 0,
2282
+ rotateY: 0
2283
+ }
2284
+ };
2285
+ const children = recomputeChildrenLocation(treePage);
2286
+ const treePageWithChildren = {
2287
+ ...treePage,
2288
+ children
2289
+ };
2290
+ tree.push(treePageWithChildren);
2291
+ }
2292
+ return tree;
2293
+ };
2294
+ var row_default = computeRowLayout;
2295
+ var toRadians2 = mathematics.geometry.toRadians;
2296
+ var computeFaceToFaceTranslateZ = (width, angle, first) => {
2297
+ if (first) {
2298
+ return width * Math.sin(toRadians2(angle));
2299
+ }
2300
+ return 0;
2301
+ };
2302
+ var computeFaceToFaceTranslateX = (width, angle, gap, first, index) => {
2303
+ const firstTranslateX = width * Math.cos(toRadians2(angle));
2304
+ if (first) {
2305
+ return firstTranslateX;
2306
+ }
2307
+ const value = width * (index - 1) + 2 * firstTranslateX + gap * index;
2308
+ return value;
2309
+ };
2310
+ var computeFaceToFaceRotateY = (angle, first, last) => {
2311
+ const rotateY = first ? angle : last ? -angle : 0;
2312
+ return rotateY;
2313
+ };
2314
+ var computeFaceToFaceLayout = (roots, angle = 45, gap = 0, middle = 0, configuration = defaultConfiguration) => {
2315
+ const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
2316
+ const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
2317
+ const tree = [];
2318
+ const width = mathematics.numbers.checkIntegerNonUnit(configuration.elements.plane.width) ? configuration.elements.plane.width : configuration.elements.plane.width * windowInnerWidth;
2319
+ const height = windowInnerHeight;
2320
+ const planeAngle = 90 - angle / 2;
2321
+ const columns = 2 + middle;
2322
+ const rows = splitIntoGroups(roots, columns);
2323
+ const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
2324
+ for (const [rowIndex, row] of rows.entries()) {
2325
+ const translateY = rowIndex * (height + gapValue);
2326
+ for (const [index, page] of row.entries()) {
2327
+ const first = index === 0;
2328
+ const last = index === row.length - 1;
2329
+ const translateZ = computeFaceToFaceTranslateZ(
2330
+ width,
2331
+ planeAngle,
2332
+ first
2333
+ );
2334
+ const translateX = computeFaceToFaceTranslateX(
2335
+ width,
2336
+ planeAngle,
2337
+ gapValue,
2338
+ first,
2339
+ index
2340
+ );
2341
+ const rotateY = computeFaceToFaceRotateY(
2342
+ planeAngle,
2343
+ first,
2344
+ last
2345
+ );
2346
+ const treePage = {
2347
+ ...page,
2348
+ location: {
2349
+ translateX,
2350
+ translateY,
2351
+ translateZ,
2352
+ rotateX: 0,
2353
+ rotateY
2354
+ }
2355
+ };
2356
+ const children = recomputeChildrenLocation(treePage);
2357
+ const treePageWithChildren = {
2358
+ ...treePage,
2359
+ children
2360
+ };
2361
+ tree.push(treePageWithChildren);
2362
+ }
2363
+ }
2364
+ return tree;
2365
+ };
2366
+ var faceToFace_default = computeFaceToFaceLayout;
2367
+ var computeSheavesLayout = (roots, depth = 0.3, offsetX = 0, offsetY = 0, configuration = defaultConfiguration) => {
2368
+ const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
2369
+ const tree = [];
2370
+ const width = mathematics.numbers.checkIntegerNonUnit(configuration.elements.plane.width) ? configuration.elements.plane.width : configuration.elements.plane.width * windowInnerWidth;
2371
+ const depthStep = mathematics.numbers.checkIntegerNonUnit(depth) ? depth : depth * width;
2372
+ for (const [index, page] of roots.entries()) {
2373
+ const translateX = index * offsetX;
2374
+ const translateY = index * offsetY;
2375
+ const translateZ = -index * depthStep;
2376
+ const treePage = {
2377
+ ...page,
2378
+ location: {
2379
+ translateX,
2380
+ translateY,
2381
+ translateZ,
2382
+ rotateX: 0,
2383
+ rotateY: 0
2384
+ }
2385
+ };
2386
+ const children = recomputeChildrenLocation(treePage);
2387
+ const treePageWithChildren = {
2388
+ ...treePage,
2389
+ children
2390
+ };
2391
+ tree.push(treePageWithChildren);
2392
+ }
2393
+ return tree;
2394
+ };
2395
+ var sheaves_default = computeSheavesLayout;
2396
+ var computeZigZagLayout = (pages, angle = 45, configuration = defaultConfiguration) => {
2397
+ const tree = [];
2398
+ const singleColumnedRoots = column_default(pages, 1);
2399
+ for (const [index, page] of singleColumnedRoots.entries()) {
2400
+ const value = index % 2 === 0 ? 1 : -1;
2401
+ page.location.rotateY = value * angle;
2402
+ const children = recomputeChildrenLocation(page);
2403
+ const treePageWithChildren = {
2404
+ ...page,
2405
+ children
2406
+ };
2407
+ tree.push(
2408
+ { ...treePageWithChildren }
2409
+ );
2410
+ }
2411
+ return tree;
2412
+ };
2413
+ var zigZag_default = computeZigZagLayout;
2414
+
2415
+ // source/modules/space/tree/index.ts
2416
+ var tree_exports2 = {};
2417
+ __export(tree_exports2, {
2418
+ Tree: () => Tree,
2419
+ logic: () => logic_exports
2420
+ });
2421
+
2422
+ // source/modules/space/tree/logic.ts
2423
+ var logic_exports = {};
2424
+ __export(logic_exports, {
2425
+ computeSpaceTree: () => computeSpaceTree,
2426
+ getTreePlaneByID: () => getTreePlaneByID,
2427
+ reconcileTree: () => reconcileTree,
2428
+ removePlaneFromTree: () => removePlaneFromTree,
2429
+ removeRootFromTree: () => removeRootFromTree,
2430
+ resolveViewItem: () => resolveViewItem,
2431
+ toggleAllChildren: () => toggleAllChildren,
2432
+ toggleChildren: () => toggleChildren,
2433
+ togglePlaneFromTree: () => togglePlaneFromTree,
2434
+ updatePlaneLocation: () => updatePlaneLocation,
2435
+ updateTreePlane: () => updateTreePlane2,
2436
+ updateTreeWithNewPage: () => updateTreeWithNewPage,
2437
+ updateTreeWithNewPlane: () => updateTreeWithNewPlane
2438
+ });
2439
+ var resolveViewItem = (planes, view, configuration, origin = "origin", getCount) => {
2440
+ const {
2441
+ protocol,
2442
+ host
2443
+ } = configuration.network;
2444
+ const viewData = typeof view === "string" ? view : view.plane;
2445
+ const viewAddress = computePlaneAddress(
2446
+ viewData,
2447
+ void 0,
2448
+ origin
2449
+ );
2450
+ const iPlanes = planes.values();
2451
+ const pluridPlanes = [];
2452
+ for (const iPlane of iPlanes) {
2453
+ const plane = {
2454
+ route: iPlane.route.absolute,
2455
+ component: iPlane.component
2456
+ };
2457
+ pluridPlanes.push(plane);
2458
+ }
2459
+ const isoMatcher = new IsoMatcher_default(
2460
+ {
2461
+ planes: pluridPlanes
2462
+ },
2463
+ origin
2464
+ );
2465
+ const match = isoMatcher.match(viewData);
2466
+ if (match) {
2467
+ const route = match.match.value;
2468
+ const count = getCount ? getCount() : uuid.generate();
2469
+ const planeID = route + "@" + count;
2470
+ const treePlane = {
2471
+ sourceID: route,
2472
+ planeID,
2473
+ // route: resolvedView.route,
2474
+ route: viewAddress,
2475
+ routeDivisions: {
2476
+ protocol: {
2477
+ value: "",
2478
+ secure: false
2479
+ },
2480
+ host: {
2481
+ value: host,
2482
+ controlled: true
2483
+ },
2484
+ path: {
2485
+ parameters: {},
2486
+ query: {},
2487
+ value: ""
2488
+ },
2489
+ space: {
2490
+ parameters: {},
2491
+ query: {},
2492
+ value: ""
2493
+ },
2494
+ universe: {
2495
+ parameters: {},
2496
+ query: {},
2497
+ value: ""
2498
+ },
2499
+ cluster: {
2500
+ parameters: {},
2501
+ query: {},
2502
+ value: ""
2503
+ },
2504
+ plane: {
2505
+ parameters: {},
2506
+ fragments: {
2507
+ elements: [],
2508
+ texts: []
2509
+ },
2510
+ query: {},
2511
+ value: ""
2512
+ },
2513
+ valid: true
2514
+ },
2515
+ height: 0,
2516
+ width: 0,
2517
+ location: {
2518
+ translateX: 0,
2519
+ translateY: 0,
2520
+ translateZ: 0,
2521
+ rotateX: 0,
2522
+ rotateY: 0
2523
+ },
2524
+ show: true
2525
+ };
2526
+ return treePlane;
2527
+ }
2528
+ return;
2529
+ };
2530
+ var computeSpaceTree = (planes, view, configuration, layout, origin = "origin", getCount) => {
2531
+ const treePlanes = [];
2532
+ for (const viewItem of view) {
2533
+ const treePlane = resolveViewItem(
2534
+ planes,
2535
+ viewItem,
2536
+ configuration,
2537
+ origin,
2538
+ getCount
2539
+ );
2540
+ if (treePlane) {
2541
+ treePlanes.push(treePlane);
2542
+ }
2543
+ }
2544
+ if (!layout) {
2545
+ const layoutlessTreePlanes = treePlanes.map((plane) => {
2546
+ return {
2547
+ ...plane,
2548
+ location: {
2549
+ rotateX: 0,
2550
+ rotateY: 0,
2551
+ translateX: 0,
2552
+ translateY: 0,
2553
+ translateZ: 0
2554
+ }
2555
+ };
2556
+ });
2557
+ return layoutlessTreePlanes;
2558
+ }
2559
+ switch (configuration.space.layout.type) {
2560
+ case LAYOUT_TYPES.COLUMNS: {
2561
+ const {
2562
+ columns,
2563
+ columnLength,
2564
+ gap
2565
+ } = configuration.space.layout;
2566
+ const columnLayoutTree = column_default(
2567
+ treePlanes,
2568
+ columns,
2569
+ columnLength,
2570
+ gap,
2571
+ configuration
2572
+ );
2573
+ return columnLayoutTree;
2574
+ }
2575
+ case LAYOUT_TYPES.ROWS: {
2576
+ const {
2577
+ rows,
2578
+ rowLength,
2579
+ gap
2580
+ } = configuration.space.layout;
2581
+ const rowLayoutTree = row_default(
2582
+ treePlanes,
2583
+ rows,
2584
+ rowLength,
2585
+ gap,
2586
+ configuration
2587
+ );
2588
+ return rowLayoutTree;
2589
+ }
2590
+ case LAYOUT_TYPES.ZIG_ZAG: {
2591
+ const {
2592
+ angle
2593
+ } = configuration.space.layout;
2594
+ const zigzagLayoutTree = zigZag_default(
2595
+ treePlanes,
2596
+ angle,
2597
+ configuration
2598
+ );
2599
+ return zigzagLayoutTree;
2600
+ }
2601
+ case LAYOUT_TYPES.FACE_TO_FACE: {
2602
+ const {
2603
+ angle,
2604
+ gap,
2605
+ middle
2606
+ } = configuration.space.layout;
2607
+ const faceToFaceLayoutTree = faceToFace_default(
2608
+ treePlanes,
2609
+ angle,
2610
+ gap,
2611
+ middle,
2612
+ configuration
2613
+ );
2614
+ return faceToFaceLayoutTree;
2615
+ }
2616
+ case LAYOUT_TYPES.SHEAVES: {
2617
+ const {
2618
+ depth,
2619
+ offsetX,
2620
+ offsetY
2621
+ } = configuration.space.layout;
2622
+ const sheavesLayoutTree = sheaves_default(
2623
+ treePlanes,
2624
+ depth,
2625
+ offsetX,
2626
+ offsetY,
2627
+ configuration
2628
+ );
2629
+ return sheavesLayoutTree;
2630
+ }
2631
+ case LAYOUT_TYPES.META: {
2632
+ return [];
2633
+ }
2634
+ default:
2635
+ return [];
2636
+ }
2637
+ };
2638
+ var updateTreePlane2 = (tree, updatedPlane) => {
2639
+ let changed = false;
2640
+ const mapped = tree.map((treePlane) => {
2641
+ if (treePlane.planeID === updatedPlane.planeID) {
2642
+ changed = true;
2643
+ return updatedPlane;
2644
+ }
2645
+ if (treePlane.children) {
2646
+ const newChildren = updateTreePlane2(
2647
+ treePlane.children,
2648
+ updatedPlane
2649
+ );
2650
+ if (newChildren !== treePlane.children) {
2651
+ changed = true;
2652
+ return {
2653
+ ...treePlane,
2654
+ children: newChildren
2655
+ };
2656
+ }
2657
+ }
2658
+ return treePlane;
2659
+ });
2660
+ return changed ? mapped : tree;
2661
+ };
2662
+ var updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration, hostname = "origin") => {
2663
+ const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2664
+ if (!parentPlane) {
2665
+ return {
2666
+ pluridPlaneID: "",
2667
+ updatedTree: tree
2668
+ };
2669
+ }
2670
+ const location2 = computePluridPlaneLocation(
2671
+ linkCoordinates,
2672
+ parentPlane,
2673
+ // Couple the parent→child GAP to the same configured length the bridge renders at,
2674
+ // otherwise the bridge visual (width) overshoots/undershoots the actual gap.
2675
+ configuration.space.bridge?.length ?? 100
2676
+ );
2677
+ const treePlane = resolveViewItem(
2678
+ planesRegistry,
2679
+ planeRoute,
2680
+ configuration,
2681
+ hostname
2682
+ );
2683
+ if (!treePlane) {
2684
+ return {
2685
+ pluridPlaneID: "",
2686
+ updatedTree: tree
2687
+ };
2688
+ }
2689
+ const updatedTreePlane = {
2690
+ ...treePlane,
2691
+ parentPlaneID,
2692
+ location: {
2693
+ translateX: location2.x,
2694
+ translateY: location2.y,
2695
+ translateZ: location2.z,
2696
+ rotateX: 0,
2697
+ rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
2698
+ },
2699
+ // Configurable bridge geometry (defaults preserve the original 100 / 90).
2700
+ bridgeLength: configuration.space.bridge?.length ?? 100,
2701
+ planeAngle: configuration.space.bridge?.planeAngle ?? 90,
2702
+ linkCoordinates
2703
+ };
2704
+ const updatedParentPlane = {
2705
+ ...parentPlane,
2706
+ children: parentPlane.children ? [...parentPlane.children, updatedTreePlane] : [updatedTreePlane]
2707
+ };
2708
+ const updatedTree = updateTreePlane2(tree, updatedParentPlane);
2709
+ return {
2710
+ pluridPlaneID: updatedTreePlane.planeID,
2711
+ updatedTree,
2712
+ updatedTreePlane
2713
+ };
2714
+ };
2715
+ var updatePlaneLocation = (tree, parentPlaneID, planeID, linkCoordinates) => {
2716
+ const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2717
+ const plane = getTreePlaneByPlaneID(tree, planeID);
2718
+ if (!parentPlane || !plane) {
2719
+ return tree;
2720
+ }
2721
+ const location2 = computePluridPlaneLocation(
2722
+ linkCoordinates,
2723
+ parentPlane,
2724
+ // Use the plane's STORED bridge geometry (set at spawn from config), otherwise this
2725
+ // recompute resets the gap to the default 100 and the bridge visual overshoots.
2726
+ plane.bridgeLength,
2727
+ plane.planeAngle
2728
+ );
2729
+ const updatedPlane = {
2730
+ ...plane,
2731
+ location: {
2732
+ translateX: location2.x,
2733
+ translateY: location2.y,
2734
+ translateZ: location2.z,
2735
+ rotateX: 0,
2736
+ rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
2737
+ }
2738
+ };
2739
+ const updatedTree = updateTreePlane2(
2740
+ tree,
2741
+ updatedPlane
2742
+ );
2743
+ return updatedTree;
2744
+ };
2745
+ var updateTreeWithNewPage = (tree, treePageParentPlaneID, pagePath, pageID, linkCoordinates, parameters) => {
2746
+ const treePageParent = getTreePlaneByPlaneID(tree, treePageParentPlaneID);
2747
+ if (treePageParent) {
2748
+ const location2 = computePluridPlaneLocation(
2749
+ linkCoordinates,
2750
+ treePageParent
2751
+ );
2752
+ const planeID = uuid.generate();
2753
+ const newTreePlane = {
2754
+ sourceID: pageID,
2755
+ route: pagePath,
2756
+ routeDivisions: {
2757
+ protocol: {
2758
+ value: "",
2759
+ secure: false
2760
+ },
2761
+ host: {
2762
+ value: "",
2763
+ controlled: false
2764
+ },
2765
+ path: {
2766
+ value: "",
2767
+ parameters: {},
2768
+ query: {}
2769
+ },
2770
+ space: {
2771
+ value: "",
2772
+ parameters: {},
2773
+ query: {}
2774
+ },
2775
+ universe: {
2776
+ value: "",
2777
+ parameters: {},
2778
+ query: {}
2779
+ },
2780
+ cluster: {
2781
+ value: "",
2782
+ parameters: {},
2783
+ query: {}
2784
+ },
2785
+ plane: {
2786
+ value: "",
2787
+ parameters: {},
2788
+ query: {},
2789
+ fragments: {
2790
+ texts: [],
2791
+ elements: []
2792
+ }
2793
+ },
2794
+ valid: false
2795
+ },
2796
+ // parameters: extractedParameters,
2797
+ // parameters: {},
2798
+ planeID,
2799
+ width: 0,
2800
+ height: 0,
2801
+ parentPlaneID: treePageParentPlaneID,
2802
+ location: {
2803
+ translateX: location2.x,
2804
+ translateY: location2.y,
2805
+ translateZ: location2.z,
2806
+ rotateX: 0,
2807
+ rotateY: treePageParent.location.rotateY + PLANE_DEFAULT_ANGLE
2808
+ },
2809
+ show: true,
2810
+ bridgeLength: 100,
2811
+ planeAngle: 90,
2812
+ linkCoordinates
2813
+ };
2814
+ const updatedTreePlaneParent = {
2815
+ ...treePageParent,
2816
+ children: treePageParent.children ? [...treePageParent.children, newTreePlane] : [newTreePlane]
2817
+ };
2818
+ const updatedTree = updateTreePlane2(tree, updatedTreePlaneParent);
2819
+ return {
2820
+ pluridPlaneID: planeID,
2821
+ updatedTree
2822
+ };
2823
+ }
2824
+ return {
2825
+ pluridPlaneID: "",
2826
+ updatedTree: tree
2827
+ };
2828
+ };
2829
+ var toggleChildren = (children) => {
2830
+ const updatedChildren = children.map((child) => {
2831
+ if (child.children) {
2832
+ const updatedChild2 = {
2833
+ ...child,
2834
+ show: !child.show,
2835
+ children: toggleChildren(child.children)
2836
+ };
2837
+ return updatedChild2;
2838
+ }
2839
+ const updatedChild = {
2840
+ ...child,
2841
+ show: !child.show
2842
+ };
2843
+ return updatedChild;
2844
+ });
2845
+ return updatedChildren;
2846
+ };
2847
+ var toggleAllChildren = (tree, show) => {
2848
+ return tree.map((plane) => ({
2849
+ ...plane,
2850
+ show,
2851
+ children: plane.children ? toggleAllChildren(plane.children, show) : plane.children
2852
+ }));
2853
+ };
2854
+ var togglePlaneFromTree = (tree, pluridPlaneID, forceShow) => {
2855
+ const updatedTree = [];
2856
+ let updatedPlane;
2857
+ for (const plane of tree) {
2858
+ if (plane.planeID === pluridPlaneID) {
2859
+ const show = forceShow ?? !plane.show;
2860
+ const treeUpdatedPlane = {
2861
+ ...plane,
2862
+ show
2863
+ };
2864
+ if (treeUpdatedPlane.children) {
2865
+ const children = toggleAllChildren(
2866
+ treeUpdatedPlane.children,
2867
+ show
2868
+ );
2869
+ treeUpdatedPlane.children = children;
2870
+ }
2871
+ updatedTree.push(treeUpdatedPlane);
2872
+ updatedPlane = {
2873
+ ...treeUpdatedPlane
2874
+ };
2875
+ continue;
2876
+ }
2877
+ if (plane.children) {
2878
+ const {
2879
+ updatedTree: childrenUpdatedTree,
2880
+ updatedPlane: childrenUpdatedPlane
2881
+ } = togglePlaneFromTree(
2882
+ plane.children,
2883
+ pluridPlaneID,
2884
+ forceShow
2885
+ );
2886
+ updatedTree.push({
2887
+ ...plane,
2888
+ children: [...childrenUpdatedTree]
2889
+ });
2890
+ if (childrenUpdatedPlane) {
2891
+ updatedPlane = {
2892
+ ...childrenUpdatedPlane
2893
+ };
2894
+ }
2895
+ continue;
2896
+ }
2897
+ updatedTree.push(plane);
2898
+ }
2899
+ return {
2900
+ updatedTree,
2901
+ updatedPlane
2902
+ };
2903
+ };
2904
+ var getTreePlaneByID = (stateTree, id) => {
2905
+ if (!id) {
2906
+ return;
2907
+ }
2908
+ for (const plane of stateTree) {
2909
+ if (plane.planeID === id) {
2910
+ return plane;
2911
+ }
2912
+ if (plane.children) {
2913
+ const found = getTreePlaneByID(
2914
+ plane.children,
2915
+ id
2916
+ );
2917
+ if (found) {
2918
+ return found;
2919
+ }
2920
+ }
2921
+ }
2922
+ return;
2923
+ };
2924
+ var removeRootFromTree = (tree, pluridPlaneID) => {
2925
+ const updatedTree = tree.filter((plane) => plane.planeID !== pluridPlaneID);
2926
+ return {
2927
+ updatedTree
2928
+ };
2929
+ };
2930
+ var removePlaneFromTree = (tree, pluridPlaneID) => {
2931
+ let changed = false;
2932
+ const updatedTree = [];
2933
+ for (const plane of tree) {
2934
+ if (plane.planeID === pluridPlaneID) {
2935
+ changed = true;
2936
+ continue;
2937
+ }
2938
+ if (plane.children) {
2939
+ const children = removePlaneFromTree(
2940
+ plane.children,
2941
+ pluridPlaneID
2942
+ );
2943
+ if (children !== plane.children) {
2944
+ changed = true;
2945
+ updatedTree.push({ ...plane, children });
2946
+ continue;
2947
+ }
2948
+ }
2949
+ updatedTree.push(plane);
2950
+ }
2951
+ return changed ? updatedTree : tree;
2952
+ };
2953
+ var carriedDimension = (next, previous) => !next && previous ? previous : next;
2954
+ var sameLocation = (a, b) => a.translateX === b.translateX && a.translateY === b.translateY && a.translateZ === b.translateZ && a.rotateX === b.rotateX && a.rotateY === b.rotateY;
2955
+ var sameNodeOwnFieldsExceptLocation = (a, b) => a.sourceID === b.sourceID && a.planeID === b.planeID && a.parentPlaneID === b.parentPlaneID && a.route === b.route && a.show === b.show && a.bridgeLength === b.bridgeLength && a.planeAngle === b.planeAngle;
2956
+ var sameNodeOwnFields = (a, b) => sameNodeOwnFieldsExceptLocation(a, b) && sameLocation(a.location, b.location);
2957
+ function reconcileNodeList(previous, next) {
2958
+ if (!previous || previous.length === 0) {
2959
+ return next;
2960
+ }
2961
+ const previousByID = /* @__PURE__ */ new Map();
2962
+ for (const node of previous) {
2963
+ if (node.planeID) {
2964
+ previousByID.set(node.planeID, node);
2965
+ }
2966
+ }
2967
+ let everyReused = previous.length === next.length;
2968
+ const reconciled = next.map((nextNode, index) => {
2969
+ const previousNode = nextNode.planeID && previousByID.get(nextNode.planeID) || previous[index];
2970
+ const result = reconcileNode(previousNode, nextNode);
2971
+ if (result !== previous[index]) {
2972
+ everyReused = false;
2973
+ }
2974
+ return result;
2975
+ });
2976
+ return everyReused ? previous : reconciled;
2977
+ }
2978
+ function reconcileNode(previous, next) {
2979
+ if (!previous || previous === next) {
2980
+ return next;
2981
+ }
2982
+ let children = next.children;
2983
+ if (next.children && next.children.length > 0) {
2984
+ children = reconcileNodeList(previous.children, next.children);
2985
+ } else if ((!next.children || next.children.length === 0) && previous.children && previous.children.length === 0) {
2986
+ children = previous.children;
2987
+ }
2988
+ const width = carriedDimension(next.width, previous.width);
2989
+ const height = carriedDimension(next.height, previous.height);
2990
+ const pinned = previous.manuallyPositioned === true;
2991
+ const location2 = pinned ? previous.location : next.location;
2992
+ const manuallyPositioned = pinned ? true : next.manuallyPositioned;
2993
+ const ownUnchanged = pinned ? sameNodeOwnFieldsExceptLocation(previous, next) : sameNodeOwnFields(previous, next);
2994
+ const unchanged = ownUnchanged && children === previous.children && width === previous.width && height === previous.height && manuallyPositioned === previous.manuallyPositioned;
2995
+ if (unchanged) {
2996
+ return previous;
2997
+ }
2998
+ if (children !== next.children || width !== next.width || height !== next.height || location2 !== next.location || manuallyPositioned !== next.manuallyPositioned) {
2999
+ return {
3000
+ ...next,
3001
+ width,
3002
+ height,
3003
+ children,
3004
+ location: location2,
3005
+ manuallyPositioned
3006
+ };
3007
+ }
3008
+ return next;
3009
+ }
3010
+ var reconcileTree = (previousTree, nextTree) => {
3011
+ if (!previousTree || previousTree === nextTree) {
3012
+ return nextTree;
3013
+ }
3014
+ return reconcileNodeList(previousTree, nextTree);
3015
+ };
3016
+
3017
+ // source/modules/space/tree/object.ts
3018
+ var Tree = class {
3019
+ data;
3020
+ origin;
3021
+ count = 0;
3022
+ constructor(data, origin = "origin") {
3023
+ this.data = data;
3024
+ this.origin = origin;
3025
+ }
3026
+ compute() {
3027
+ const {
3028
+ planes,
3029
+ view,
3030
+ configuration,
3031
+ layout
3032
+ } = this.data;
3033
+ return computeSpaceTree(
3034
+ planes,
3035
+ view,
3036
+ configuration,
3037
+ layout,
3038
+ this.origin,
3039
+ this.getCount.bind(this)
3040
+ );
3041
+ }
3042
+ getCount() {
3043
+ return this.count++;
3044
+ }
3045
+ };
3046
+
3047
+ // source/modules/space/view/index.ts
3048
+ var view_exports = {};
3049
+ __export(view_exports, {
3050
+ checkPageInView: () => checkPageInView,
3051
+ computeCulledView: () => computeCulledView,
3052
+ computeViewTree: () => computeViewTree
3053
+ });
3054
+
3055
+ // source/modules/space/view/logic.ts
3056
+ var computeViewTree = (pages, view) => {
3057
+ const viewTree = [];
3058
+ for (const pageView of view) {
3059
+ const page = pages.find((p) => p.route === pageView);
3060
+ if (page) {
3061
+ viewTree.push(page);
3062
+ }
3063
+ }
3064
+ return viewTree;
3065
+ };
3066
+ var computeCulledView = (pages, view, location2, radius = 8e3) => {
3067
+ const culledView = [];
3068
+ for (const viewPage of view) {
3069
+ const path = typeof viewPage === "string" ? viewPage : viewPage.plane;
3070
+ const page = findPage(
3071
+ path,
3072
+ pages
3073
+ );
3074
+ if (!page) {
3075
+ return;
3076
+ }
3077
+ const pageInView = checkPageInView(
3078
+ page,
3079
+ location2,
3080
+ radius
3081
+ );
3082
+ if (pageInView) {
3083
+ culledView.push(
3084
+ page.route
3085
+ );
3086
+ }
3087
+ }
3088
+ return culledView;
3089
+ };
3090
+ var checkPageInView = (page, location2, radius) => {
3091
+ const radiusLeft = location2.translationX < 0 ? Math.abs(location2.translationX) - radius : -1 * location2.translationX - radius;
3092
+ const radiusRight = location2.translationX < 0 ? Math.abs(location2.translationX) + radius : -1 * location2.translationX + radius;
3093
+ const locationX = page.location.translateX;
3094
+ const radiusTop = location2.translationY < 0 ? Math.abs(location2.translationY) - radius : -1 * location2.translationY - radius;
3095
+ const radiusBottom = location2.translationY < 0 ? Math.abs(location2.translationY) + radius : -1 * location2.translationY + radius;
3096
+ const locationY = page.location.translateY;
3097
+ const inViewOnX = radiusLeft <= locationX && locationX <= radiusRight;
3098
+ const inViewOnY = radiusTop <= locationY && locationY <= radiusBottom;
3099
+ if (inViewOnX && inViewOnY) {
3100
+ return true;
3101
+ }
3102
+ return false;
3103
+ };
3104
+
3105
+ // source/modules/state/index.ts
3106
+ var state_exports = {};
3107
+ __export(state_exports, {
3108
+ compute: () => compute_default,
3109
+ local: () => local_exports
3110
+ });
3111
+
3112
+ // source/modules/state/compute/space/index.ts
3113
+ var resolveSpace = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
3114
+ const registeredPlanes = getRegisteredPlanes(planesRegistrar);
3115
+ const spaceTree = new tree_exports2.Tree(
3116
+ {
3117
+ planes: registeredPlanes,
3118
+ configuration,
3119
+ view
3120
+ },
3121
+ hostname
3122
+ );
3123
+ const computedTree = spaceTree.compute();
3124
+ const stateSpace = {
3125
+ loading: true,
3126
+ resolvedLayout: false,
3127
+ animatedTransform: false,
3128
+ transformTime: 450,
3129
+ scale: 1,
3130
+ rotationX: 0,
3131
+ rotationY: 0,
3132
+ translationX: 0,
3133
+ translationY: 0,
3134
+ translationZ: 0,
3135
+ transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
3136
+ activeUniverseID: "",
3137
+ camera: {
3138
+ x: 0,
3139
+ y: 0,
3140
+ z: 0
3141
+ },
3142
+ viewSize: {
3143
+ width: 771,
3144
+ height: 764
3145
+ },
3146
+ spaceSize: {
3147
+ width: 771,
3148
+ height: 764,
3149
+ depth: 0,
3150
+ topCorner: {
3151
+ x: 0,
3152
+ y: 0,
3153
+ z: 0
3154
+ }
3155
+ },
3156
+ culledView: [],
3157
+ activePlaneID: "",
3158
+ isolatePlane: "",
3159
+ lastClosedPlane: "",
3160
+ selectedPlaneIDs: [],
3161
+ draggingSelection: false,
3162
+ tree: computedTree,
3163
+ links: [],
3164
+ ...precomputedState?.space,
3165
+ ...contextState?.space,
3166
+ ...localState?.space,
3167
+ ...currentState?.space,
3168
+ view
3169
+ };
3170
+ if (currentState) {
3171
+ stateSpace.translationX = currentState.space.translationX;
3172
+ stateSpace.translationY = currentState.space.translationY;
3173
+ stateSpace.translationZ = currentState.space.translationZ;
3174
+ stateSpace.rotationX = currentState.space.rotationX;
3175
+ stateSpace.rotationY = currentState.space.rotationY;
3176
+ stateSpace.scale = currentState.space.scale;
3177
+ }
3178
+ if (localState && !currentState) {
3179
+ stateSpace.translationX = localState.space.translationX;
3180
+ stateSpace.translationY = localState.space.translationY;
3181
+ stateSpace.translationZ = localState.space.translationZ;
3182
+ stateSpace.rotationX = localState.space.rotationX;
3183
+ stateSpace.rotationY = localState.space.rotationY;
3184
+ stateSpace.scale = localState.space.scale;
3185
+ }
3186
+ return stateSpace;
3187
+ };
3188
+ var resolveThemes = (configuration, precomputedState) => {
3189
+ let generalTheme;
3190
+ let interactionTheme;
3191
+ if (typeof configuration.global.theme === "object") {
3192
+ const {
3193
+ general,
3194
+ interaction
3195
+ } = configuration.global.theme;
3196
+ if (typeof general === "string") {
3197
+ if (Object.keys(THEME_NAMES).includes(general)) {
3198
+ generalTheme = themes[general];
3199
+ }
3200
+ }
3201
+ if (typeof interaction === "string") {
3202
+ if (Object.keys(THEME_NAMES).includes(interaction)) {
3203
+ interactionTheme = themes[interaction];
3204
+ }
3205
+ }
3206
+ } else {
3207
+ if (Object.keys(THEME_NAMES).includes(configuration.global.theme)) {
3208
+ generalTheme = themes[configuration.global.theme];
3209
+ interactionTheme = themes[configuration.global.theme];
3210
+ }
3211
+ }
3212
+ const stateThemes = {
3213
+ general: generalTheme || themes.plurid,
3214
+ interaction: interactionTheme || themes.plurid,
3215
+ ...precomputedState?.themes
3216
+ };
3217
+ return stateThemes;
3218
+ };
3219
+
3220
+ // source/modules/state/compute/index.ts
3221
+ var compute = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
3222
+ let stateConfiguration = configuration_exports.merge(configuration);
3223
+ const configurations = [
3224
+ precomputedState?.configuration,
3225
+ contextState?.configuration,
3226
+ localState?.configuration,
3227
+ currentState?.configuration
3228
+ ];
3229
+ for (const layer of configurations) {
3230
+ if (layer) {
3231
+ stateConfiguration = configuration_exports.merge(layer, stateConfiguration);
3232
+ }
3233
+ }
3234
+ const stateSpace = resolveSpace(
3235
+ view,
3236
+ stateConfiguration,
3237
+ planesRegistrar,
3238
+ currentState,
3239
+ localState,
3240
+ precomputedState,
3241
+ contextState,
3242
+ hostname
3243
+ );
3244
+ const stateThemes = resolveThemes(
3245
+ stateConfiguration,
3246
+ precomputedState
3247
+ );
3248
+ const state = {
3249
+ configuration: {
3250
+ ...stateConfiguration
3251
+ },
3252
+ shortcuts: {
3253
+ global: true,
3254
+ ...precomputedState?.shortcuts
3255
+ },
3256
+ space: {
3257
+ ...stateSpace
3258
+ },
3259
+ themes: {
3260
+ ...stateThemes
3261
+ },
3262
+ ui: {
3263
+ toolbarScrollPosition: 0,
3264
+ ...precomputedState?.ui,
3265
+ ...contextState?.ui
3266
+ }
3267
+ };
3268
+ return state;
3269
+ };
3270
+ var compute_default = compute;
3271
+
3272
+ // source/modules/state/local/index.ts
3273
+ var local_exports = {};
3274
+ __export(local_exports, {
3275
+ load: () => load,
3276
+ loadContent: () => loadContent,
3277
+ save: () => save,
3278
+ saveContent: () => saveContent,
3279
+ serialize: () => serialize
3280
+ });
3281
+ var PERSISTED_STATE_VERSION = 2;
3282
+ var STORAGE_PREFIX = "pluridState-";
3283
+ var serializeFailureWarned = false;
3284
+ var PERSISTED_SPACE_FIELDS = [
3285
+ "rotationX",
3286
+ "rotationY",
3287
+ "scale",
3288
+ "translationX",
3289
+ "translationY",
3290
+ "translationZ",
3291
+ "transform",
3292
+ "camera",
3293
+ "activePlaneID",
3294
+ "isolatePlane",
3295
+ "lastClosedPlane",
3296
+ "tree",
3297
+ "links"
3298
+ ];
3299
+ var storageKey = (id) => STORAGE_PREFIX + (id || "default");
3300
+ var localStorageAdapter = () => {
3301
+ if (typeof localStorage === "undefined") {
3302
+ return void 0;
3303
+ }
3304
+ return {
3305
+ getItem: (key) => localStorage.getItem(key),
3306
+ setItem: (key, value) => {
3307
+ localStorage.setItem(key, value);
3308
+ },
3309
+ removeItem: (key) => {
3310
+ localStorage.removeItem(key);
3311
+ }
3312
+ };
3313
+ };
3314
+ var resolveAdapter = (adapter) => adapter || localStorageAdapter();
3315
+ var serialize = (state) => {
3316
+ const space = {};
3317
+ for (const field of PERSISTED_SPACE_FIELDS) {
3318
+ const value = state.space[field];
3319
+ if (value !== void 0) {
3320
+ space[field] = value;
3321
+ }
3322
+ }
3323
+ const snapshot = {
3324
+ version: PERSISTED_STATE_VERSION,
3325
+ space
3326
+ };
3327
+ return JSON.stringify(snapshot);
3328
+ };
3329
+ var save = (id, state, adapter) => {
3330
+ const store = resolveAdapter(adapter);
3331
+ if (!state || !store) {
3332
+ return;
3333
+ }
3334
+ let serialized;
3335
+ try {
3336
+ serialized = serialize(state);
3337
+ } catch (error) {
3338
+ if (!serializeFailureWarned && typeof console !== "undefined") {
3339
+ serializeFailureWarned = true;
3340
+ console.warn(
3341
+ "[plurid] state persistence skipped \u2014 could not serialize the space snapshot. A non-serializable value (cycle, DOM node, or function) is in the persisted fields. Persistence is disabled until it is removed.",
3342
+ error
3343
+ );
3344
+ }
3345
+ return;
3346
+ }
3347
+ try {
3348
+ store.setItem(
3349
+ storageKey(id),
3350
+ serialized
3351
+ );
3352
+ } catch (_error) {
3353
+ }
3354
+ };
3355
+ var load = (id, useLocalStorage, adapter) => {
3356
+ if (!useLocalStorage) {
3357
+ return;
3358
+ }
3359
+ const store = resolveAdapter(adapter);
3360
+ if (!store) {
3361
+ return;
3362
+ }
3363
+ try {
3364
+ const stateData = store.getItem(storageKey(id));
3365
+ if (!stateData) {
3366
+ return;
3367
+ }
3368
+ const snapshot = JSON.parse(stateData);
3369
+ if (!snapshot || snapshot.version !== PERSISTED_STATE_VERSION) {
3370
+ return;
3371
+ }
3372
+ if (!snapshot.space) {
3373
+ return;
3374
+ }
3375
+ return { space: snapshot.space };
3376
+ } catch (_error) {
3377
+ return;
3378
+ }
3379
+ };
3380
+ var CONTENT_PREFIX = "pluridContent-";
3381
+ var contentKey = (id) => CONTENT_PREFIX + (id || "default");
3382
+ var saveContent = (id, content, adapter) => {
3383
+ const store = resolveAdapter(adapter);
3384
+ if (content === void 0 || !store) {
3385
+ return;
3386
+ }
3387
+ try {
3388
+ store.setItem(
3389
+ contentKey(id),
3390
+ JSON.stringify(content)
3391
+ );
3392
+ } catch (_error) {
3393
+ }
3394
+ };
3395
+ var loadContent = (id, adapter) => {
3396
+ const store = resolveAdapter(adapter);
3397
+ if (!store) {
3398
+ return void 0;
3399
+ }
3400
+ try {
3401
+ const raw = store.getItem(contentKey(id));
3402
+ if (!raw) {
3403
+ return void 0;
3404
+ }
3405
+ return JSON.parse(raw);
3406
+ } catch (_error) {
3407
+ return void 0;
3408
+ }
3409
+ };
3410
+
3411
+ // source/functions/template/index.ts
3412
+ var cleanTemplate = (template) => {
3413
+ return template.replace(/(?:\r\n|\r|\n)/g, " ").replace(/ +/g, " ").trim();
3414
+ };
3415
+ var pluridRouterNavigate = (path) => {
3416
+ if (typeof CustomEvent === "undefined" || typeof window === "undefined") {
3417
+ return;
3418
+ }
3419
+ const event = new CustomEvent(
3420
+ PLURID_ROUTER_LOCATION_CHANGED,
3421
+ {
3422
+ detail: {
3423
+ path
3424
+ }
3425
+ }
3426
+ );
3427
+ window.dispatchEvent(event);
3428
+ };
3429
+
3430
+ export { IsoMatcher_default as IsoMatcher, Parser as RouteParser, cleanTemplate, definePluridConfiguration, general_exports as general, interaction_exports as interaction, internationalization_default as internatiolate, planes_exports as planes, pluridRouterNavigate, routing_exports as routing, space_exports as space, state_exports as state, utilities_exports as utilities };
3431
+ //# sourceMappingURL=index.mjs.map
3432
+ //# sourceMappingURL=index.mjs.map