@plurid/plurid-engine 0.0.0-11 → 0.0.0-14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { defaultConfiguration, protocols, HTTPS_PROTOCOL, HTTP_PROTOCOL, compareTypes, defaultTreePlane, internationalization, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from "@plurid/plurid-data";
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
2
 
3
- import { objects, uuid, mathematics } from "@plurid/plurid-functions";
3
+ import { objects, mathematics, uuid } from "@plurid/plurid-functions";
4
4
 
5
5
  import themes, { THEME_NAMES } from "@plurid/plurid-themes";
6
6
 
@@ -25,91 +25,17 @@ const resolveTheme = (theme, type) => {
25
25
  };
26
26
 
27
27
  const merge = (configuration, target) => {
28
- var _a, _b, _c, _d, _e;
29
- const targetConfiguration = Object.assign(Object.assign({}, defaultConfiguration), target);
28
+ const targetConfiguration = Object.assign(Object.assign({}, objects.clone(defaultConfiguration)), objects.clone(target || {}));
30
29
  if (!configuration) {
31
- return Object.assign({}, targetConfiguration);
30
+ return targetConfiguration;
32
31
  }
33
- const specifiedOrDefault = (path, type, configuration) => {
34
- const item = objects.getNested(configuration, path);
35
- if (typeof item === type) {
36
- return item;
37
- }
38
- return objects.getNested(targetConfiguration, path);
39
- };
40
- const layout = configuration && configuration.space && typeof configuration.space.layout === "object" ? configuration.space.layout : targetConfiguration.space.layout;
41
- const mergedConfiguration = Object.assign(Object.assign({}, targetConfiguration), {
42
- global: {
43
- micro: specifiedOrDefault("global.micro", "boolean", configuration),
44
- transparentUI: specifiedOrDefault("global.transparentUI", "boolean", configuration),
45
- language: specifiedOrDefault("global.language", "string", configuration),
46
- render: specifiedOrDefault("global.render", "string", configuration),
47
- theme: {
32
+ const mergedConfiguration = objects.merge(targetConfiguration, configuration, {
33
+ "global.theme": () => {
34
+ var _a, _b;
35
+ return {
48
36
  general: resolveTheme((_a = configuration.global) === null || _a === void 0 ? void 0 : _a.theme, "general"),
49
37
  interaction: resolveTheme((_b = configuration.global) === null || _b === void 0 ? void 0 : _b.theme, "interaction")
50
- }
51
- },
52
- elements: Object.assign(Object.assign({}, targetConfiguration.elements), {
53
- toolbar: {
54
- show: specifiedOrDefault("elements.toolbar.show", "boolean", configuration),
55
- opaque: specifiedOrDefault("elements.toolbar.opaque", "boolean", configuration),
56
- conceal: specifiedOrDefault("elements.toolbar.conceal", "boolean", configuration),
57
- transformIcons: specifiedOrDefault("elements.toolbar.transformIcons", "boolean", configuration),
58
- transformButtons: specifiedOrDefault("elements.toolbar.transformButtons", "boolean", configuration),
59
- drawers: configuration.elements && configuration.elements.toolbar && configuration.elements.toolbar.drawers ? configuration.elements.toolbar.drawers : targetConfiguration.elements.toolbar.drawers,
60
- toggledDrawers: configuration.elements && configuration.elements.toolbar && configuration.elements.toolbar.toggledDrawers ? configuration.elements.toolbar.toggledDrawers : targetConfiguration.elements.toolbar.toggledDrawers
61
- },
62
- viewcube: {
63
- show: specifiedOrDefault("elements.viewcube.show", "boolean", configuration),
64
- opaque: specifiedOrDefault("elements.viewcube.opaque", "boolean", configuration),
65
- conceal: specifiedOrDefault("elements.viewcube.conceal", "boolean", configuration),
66
- buttons: specifiedOrDefault("elements.viewcube.buttons", "boolean", configuration)
67
- },
68
- plane: {
69
- width: specifiedOrDefault("elements.plane.width", "number", configuration),
70
- opacity: specifiedOrDefault("elements.plane.opacity", "number", configuration),
71
- controls: {
72
- show: specifiedOrDefault("elements.plane.controls.show", "boolean", configuration),
73
- pathbar: {
74
- domainURL: specifiedOrDefault("elements.plane.controls.pathbar.domainURL", "boolean", configuration)
75
- }
76
- }
77
- },
78
- switch: {
79
- show: (_e = (_d = (_c = configuration === null || configuration === void 0 ? void 0 : configuration.elements) === null || _c === void 0 ? void 0 : _c.switch) === null || _d === void 0 ? void 0 : _d.show) !== null && _e !== void 0 ? _e : false
80
- }
81
- }),
82
- space: Object.assign(Object.assign({}, targetConfiguration.space), {
83
- layout: layout,
84
- camera: specifiedOrDefault("space.camera", "string", configuration),
85
- perspective: specifiedOrDefault("space.perspective", "number", configuration),
86
- opaque: specifiedOrDefault("space.opaque", "boolean", configuration),
87
- fadeInTime: specifiedOrDefault("space.fadeInTime", "number", configuration),
88
- center: specifiedOrDefault("space.center", "boolean", configuration),
89
- transformOrigin: {
90
- show: specifiedOrDefault("space.transformOrigin.show", "boolean", configuration),
91
- size: specifiedOrDefault("space.transformOrigin.size", "string", configuration)
92
- },
93
- transformLocks: {
94
- rotationX: specifiedOrDefault("space.transformLocks.rotationX", "boolean", configuration),
95
- rotationY: specifiedOrDefault("space.transformLocks.rotationY", "boolean", configuration),
96
- translationX: specifiedOrDefault("space.transformLocks.translationX", "boolean", configuration),
97
- translationY: specifiedOrDefault("space.transformLocks.translationY", "boolean", configuration),
98
- translationZ: specifiedOrDefault("space.transformLocks.translationZ", "boolean", configuration),
99
- scale: specifiedOrDefault("space.transformLocks.scale", "boolean", configuration)
100
- },
101
- transformMode: specifiedOrDefault("space.transformMode", "string", configuration),
102
- transformMultimode: specifiedOrDefault("space.transformMultimode", "boolean", configuration),
103
- transformTouch: specifiedOrDefault("space.transformTouch", "string", configuration),
104
- firstPerson: specifiedOrDefault("space.firstPerson", "boolean", configuration)
105
- }),
106
- network: {
107
- host: specifiedOrDefault("network.host", "string", configuration),
108
- protocol: specifiedOrDefault("network.protocol", "string", configuration)
109
- },
110
- development: {
111
- planeDebugger: specifiedOrDefault("development.planeDebugger", "boolean", configuration),
112
- spaceDebugger: specifiedOrDefault("development.spaceDebugger", "boolean", configuration)
38
+ };
113
39
  }
114
40
  });
115
41
  return mergedConfiguration;
@@ -120,1263 +46,1337 @@ var index$k = Object.freeze({
120
46
  merge: merge
121
47
  });
122
48
 
123
- const extractPathname = location => {
124
- const queryIndex = location.indexOf("?");
125
- const noQueryPath = queryIndex === -1 ? location : location.substring(0, queryIndex);
126
- const fragmentIndex = noQueryPath.indexOf("#:~:");
127
- const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
128
- return noFragmentPath;
129
- };
130
-
131
- const extractParametersAndMatch = (location, route) => {
132
- const routeElements = splitPath(route);
133
- const parameters = [];
134
- routeElements.forEach((routeElement => {
135
- if (routeElement[0] === ":") {
136
- parameters.push(routeElement);
137
- } else {
138
- parameters.push("");
49
+ const updateTreePlane$1 = (tree, page) => {
50
+ const updatedTree = tree.map((treePlane => {
51
+ if (treePlane.planeID === page.planeID) {
52
+ return Object.assign({}, page);
53
+ }
54
+ if (treePlane.children) {
55
+ return Object.assign(Object.assign({}, treePlane), {
56
+ children: updateTreePlane$1(treePlane.children, page)
57
+ });
139
58
  }
59
+ return treePlane;
140
60
  }));
141
- const {locationElements: locationElements, comparingPath: comparingPath} = computeComparingPath(location, parameters);
142
- if (comparingPath !== route) {
143
- return {
144
- match: false,
145
- parameters: {},
146
- elements: locationElements
147
- };
148
- }
149
- const parametersValues = extractParametersValues(parameters, locationElements);
150
- return {
151
- match: true,
152
- parameters: parametersValues,
153
- elements: locationElements
154
- };
61
+ return updatedTree;
155
62
  };
156
63
 
157
- const extractParametersValues = (parameters, pathElements) => {
158
- const parametersValues = {};
159
- parameters.forEach(((parameter, index) => {
160
- if (parameter) {
161
- const parameterKey = parameter.slice(1);
162
- parametersValues[parameterKey] = pathElements[index];
64
+ const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
65
+ const updatedTree = tree.map((treePlane => {
66
+ if (treePlane.planeID === planeID) {
67
+ const updatedPlane = Object.assign(Object.assign({}, treePlane), {
68
+ linkCoordinates: linkCoordinates
69
+ });
70
+ return updatedPlane;
71
+ }
72
+ if (treePlane.children) {
73
+ const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(treePlane.children, planeID, linkCoordinates);
74
+ const updatedPlane = Object.assign(Object.assign({}, treePlane), {
75
+ children: updatedChildren
76
+ });
77
+ return updatedPlane;
163
78
  }
79
+ return treePlane;
164
80
  }));
165
- return parametersValues;
81
+ return updatedTree;
166
82
  };
167
83
 
168
- const computeComparingPath = (path, parameters) => {
169
- const pathname = extractPathname(path);
170
- const locationElements = splitPath(pathname);
171
- const comparingPathElements = [ ...locationElements ];
172
- for (const index of locationElements.keys()) {
173
- if (parameters[index]) {
174
- comparingPathElements[index] = parameters[index];
175
- }
176
- }
177
- const comparingPath = comparingPathElements.join("/");
178
- return {
179
- locationElements: locationElements,
180
- comparingPath: comparingPath
181
- };
182
- };
84
+ var index$j = Object.freeze({
85
+ __proto__: null,
86
+ updateTreePlane: updateTreePlane$1,
87
+ updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
88
+ });
183
89
 
184
- const splitPath = path => path.split("/").filter((i => i !== ""));
90
+ var index$i = Object.freeze({
91
+ __proto__: null,
92
+ configuration: index$k,
93
+ tree: index$j
94
+ });
185
95
 
186
- const extractQuery = path => {
187
- const fragmentIndex = path.indexOf("#:~:");
188
- const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
189
- const querySplit = noFragmentPath.split("?");
190
- if (querySplit.length === 2) {
191
- const queryValues = {};
192
- const query = querySplit[1];
193
- const queryItems = query.split("&");
194
- for (const item of queryItems) {
195
- const queryValue = item.split("=");
196
- const id = queryValue[0];
197
- const value = decodeURIComponent(queryValue[1]);
198
- queryValues[id] = value;
199
- }
200
- return queryValues;
201
- } else {
202
- return {};
96
+ const getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
97
+ let direction = "left";
98
+ const wheelDeltaX = deltas.deltaX;
99
+ const wheelDeltaY = deltas.deltaY;
100
+ const absWheelDeltaX = Math.abs(wheelDeltaX);
101
+ const absWheelDeltaY = Math.abs(wheelDeltaY);
102
+ if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
103
+ direction = "left";
203
104
  }
204
- };
205
-
206
- const extractFragments = location => {
207
- if (!location) {
208
- return {
209
- texts: [],
210
- elements: []
211
- };
105
+ if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
106
+ direction = "right";
212
107
  }
213
- const split = location.split("#:~:");
214
- const fragmentsValues = split[1];
215
- if (!fragmentsValues) {
216
- return {
217
- texts: [],
218
- elements: []
219
- };
108
+ if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
109
+ direction = "up";
220
110
  }
221
- const fragmentItems = fragmentsValues.split("&");
222
- const textFragments = [];
223
- const elementFragments = [];
224
- for (const item of fragmentItems) {
225
- const parsedFragment = parseFragment(item);
226
- if (parsedFragment) {
227
- switch (parsedFragment.type) {
228
- case "text":
229
- textFragments.push(parsedFragment);
230
- break;
231
-
232
- case "element":
233
- elementFragments.push(parsedFragment);
234
- break;
235
- }
236
- }
111
+ if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
112
+ direction = "down";
237
113
  }
238
- return {
239
- texts: textFragments,
240
- elements: elementFragments
241
- };
114
+ return direction;
242
115
  };
243
116
 
244
- const parseFragment = fragment => {
245
- const fragmentData = fragment.split("=");
246
- const fragmentType = fragmentData[0];
247
- const fragmentValues = fragmentData[1];
248
- switch (fragmentType.toLowerCase()) {
249
- case "text":
250
- {
251
- const textValues = fragmentValues.split(",");
252
- const textStart = textValues[0];
253
- const textEnd = textValues[1];
254
- const textOccurence = extractOccurence(textValues[2]);
255
- if (!textStart) {
256
- return;
257
- }
258
- return {
259
- type: "text",
260
- start: textStart,
261
- end: textEnd || "",
262
- occurence: textOccurence
263
- };
264
- }
117
+ var index$h = Object.freeze({
118
+ __proto__: null,
119
+ getWheelDirection: getWheelDirection
120
+ });
265
121
 
266
- case "element":
267
- {
268
- const elementValues = fragmentValues.split(",");
269
- const elementID = elementValues[0];
270
- const elementOccurence = extractOccurence(elementValues[1]);
271
- if (!elementID) {
272
- return;
273
- }
274
- return {
275
- type: "element",
276
- id: elementID,
277
- occurence: elementOccurence
278
- };
279
- }
280
- }
281
- return undefined;
282
- };
122
+ const degToRad = deg => deg * .01745329252;
283
123
 
284
- const extractOccurence = occurence => {
285
- if (!occurence) {
286
- return 0;
287
- }
288
- const occurenceMatch = occurence.match(/\[(\d*)\]/);
289
- const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
290
- return occurenceValue;
291
- };
124
+ const radToDeg = rad => rad * 57.2957795131;
292
125
 
293
- const stringInsertInitial = (value, insert) => {
294
- if (!value.startsWith(insert)) {
295
- value = insert + value;
296
- }
297
- return value;
298
- };
126
+ const makeQuaternion = (x, y, z, w) => ({
127
+ x: x,
128
+ y: y,
129
+ z: z,
130
+ w: w
131
+ });
299
132
 
300
- const stringRemoveTrailing = (value, trail) => {
301
- if (value.endsWith(trail)) {
302
- value = value.slice(0, value.length - trail.length);
303
- }
304
- return value;
305
- };
133
+ const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
306
134
 
307
- const PATH_SEPARATOR = "/";
135
+ function inverseQuaternion(quaternion) {
136
+ return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
137
+ }
308
138
 
309
- const cleanupPath = value => {
310
- value = stringInsertInitial(value, PATH_SEPARATOR);
311
- value = stringRemoveTrailing(value, PATH_SEPARATOR);
312
- return value;
313
- };
139
+ function conjugateQuaternion(quaternion) {
140
+ return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
141
+ }
314
142
 
315
- const computePlaneAddress = (plane, route, origin = "origin") => {
316
- if (origin === "origin" && typeof location !== "undefined") {
317
- origin = location.host;
318
- }
319
- const cleanPlane = extractPathname(plane);
320
- const planeAddressType = checkPlaneAddressType(cleanPlane);
321
- switch (planeAddressType) {
322
- case "http":
323
- case "https":
324
- case "pttp":
325
- return cleanPlane;
326
- }
327
- origin = stringRemoveTrailing(origin, "/");
328
- const absolutePlane = isAbsolutePlane(plane);
329
- const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
330
- const planeAddress = protocols.plurid + origin + path;
331
- return planeAddress;
332
- };
143
+ function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
144
+ const x = radians ? beta : degToRad(beta);
145
+ const y = radians ? gamma : degToRad(gamma);
146
+ const z = radians ? alpha : degToRad(alpha);
147
+ const cX = Math.cos(x / 2);
148
+ const cY = Math.cos(y / 2);
149
+ const cZ = Math.cos(z / 2);
150
+ const sX = Math.sin(x / 2);
151
+ const sY = Math.sin(y / 2);
152
+ const sZ = Math.sin(z / 2);
153
+ const xQ = sX * cY * cZ - cX * sY * sZ;
154
+ const yQ = cX * sY * cZ + sX * cY * sZ;
155
+ const zQ = cX * cY * sZ + sX * sY * cZ;
156
+ const wQ = cX * cY * cZ - sX * sY * sZ;
157
+ return makeQuaternion(xQ, yQ, zQ, wQ);
158
+ }
333
159
 
334
- const isAbsolutePlane = value => value[0] === "/";
160
+ function quaternionFromAxisAngle(x, y, z, angle) {
161
+ const q = zeroQuaternion();
162
+ const halfAngle = angle / 2;
163
+ const sine = Math.sin(halfAngle);
164
+ q.x = x * sine;
165
+ q.y = y * sine;
166
+ q.z = z * sine;
167
+ q.w = Math.cos(halfAngle);
168
+ return q;
169
+ }
335
170
 
336
- const checkPlaneAddressType = value => {
337
- value = value.toLowerCase().trim();
338
- if (value.startsWith(protocols.plurid)) {
339
- return "pttp";
340
- }
341
- if (value.startsWith(protocols.https)) {
342
- return HTTPS_PROTOCOL;
343
- }
344
- if (value.startsWith(protocols.http)) {
345
- return HTTP_PROTOCOL;
346
- }
347
- return "relative";
348
- };
171
+ function quaternionMultiply(quaternionArray) {
172
+ const firstQuaternion = quaternionArray[0];
173
+ const valueQuaternion = Object.assign({}, firstQuaternion);
174
+ for (let i = 1; i < quaternionArray.length; i++) {
175
+ const nextQuaternion = quaternionArray[i];
176
+ const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
177
+ const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
178
+ const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
179
+ const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
180
+ valueQuaternion.x = x;
181
+ valueQuaternion.y = y;
182
+ valueQuaternion.z = z;
183
+ valueQuaternion.w = w;
184
+ }
185
+ return valueQuaternion;
186
+ }
349
187
 
350
- const removeTrailingSlash = value => {
351
- if (value.endsWith("/") && value.length > 1) {
352
- return value.slice(0, value.length - 1);
353
- }
354
- return value;
355
- };
188
+ function rotatePointViaQuaternion(pointRotate, quaternion) {
189
+ const temporaryQuaternion = {
190
+ x: pointRotate[0],
191
+ y: pointRotate[1],
192
+ z: pointRotate[2],
193
+ w: 0
194
+ };
195
+ const rotatedPointQuaternion = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
196
+ return rotatedPointQuaternion;
197
+ }
356
198
 
357
- const cleanPathValue = value => {
358
- const queryStart = value.indexOf("?");
359
- if (queryStart < 0) {
360
- return removeTrailingSlash(value);
361
- }
362
- return removeTrailingSlash(value.substring(0, queryStart));
363
- };
199
+ function makeRotationMatrixFromQuaternion(quaternion) {
200
+ const num = quaternion.x * 2;
201
+ const num2 = quaternion.y * 2;
202
+ const num3 = quaternion.z * 2;
203
+ const num4 = quaternion.x * num;
204
+ const num5 = quaternion.y * num2;
205
+ const num6 = quaternion.z * num3;
206
+ const num7 = quaternion.x * num2;
207
+ const num8 = quaternion.x * num3;
208
+ const num9 = quaternion.y * num3;
209
+ const num10 = quaternion.w * num;
210
+ const num11 = quaternion.w * num2;
211
+ const num12 = quaternion.w * num3;
212
+ return [ 1 - (num5 + num6), num7 - num12, num8 + num11, 0, num7 + num12, 1 - (num4 + num6), num9 - num10, 0, num8 - num11, num9 + num10, 1 - (num4 + num5), 0, 0, 0, 0, 1 ];
213
+ }
364
214
 
365
- const checkParameterLength = (parameter, length, compareType) => {
366
- const parameterLength = parameter.length;
367
- switch (compareType) {
368
- case compareTypes.equal:
369
- return parameterLength === length;
215
+ var index$g = Object.freeze({
216
+ __proto__: null,
217
+ degToRad: degToRad,
218
+ radToDeg: radToDeg,
219
+ makeQuaternion: makeQuaternion,
220
+ zeroQuaternion: zeroQuaternion,
221
+ inverseQuaternion: inverseQuaternion,
222
+ conjugateQuaternion: conjugateQuaternion,
223
+ computeQuaternionFromEulers: computeQuaternionFromEulers,
224
+ quaternionFromAxisAngle: quaternionFromAxisAngle,
225
+ quaternionMultiply: quaternionMultiply,
226
+ rotatePointViaQuaternion: rotatePointViaQuaternion,
227
+ makeRotationMatrixFromQuaternion: makeRotationMatrixFromQuaternion
228
+ });
370
229
 
371
- case compareTypes.equalLessThan:
372
- return parameterLength <= length;
230
+ function rotateMatrix(xAngle, yAngle, zAngle = 0) {
231
+ const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
232
+ const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
233
+ const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
234
+ const quartenionMultiplication = quaternionMultiply([ yQuaternion, xQuaternion, zQuaternion ]);
235
+ const rotationMatrix = makeRotationMatrixFromQuaternion(quartenionMultiplication);
236
+ return rotationMatrix;
237
+ }
373
238
 
374
- case compareTypes.lessThan:
375
- return parameterLength < length;
239
+ function translateMatrix$1(x, y, z) {
240
+ return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
241
+ }
376
242
 
377
- case compareTypes.equalGreaterThan:
378
- return parameterLength >= length;
243
+ function scaleMatrix$1(s) {
244
+ return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
245
+ }
379
246
 
380
- case compareTypes.greaterThan:
381
- return parameterLength > length;
247
+ function multiplyMatrices$1(matrixA, matrixB) {
248
+ const result = [];
249
+ const a00 = matrixA[0];
250
+ const a01 = matrixA[1];
251
+ const a02 = matrixA[2];
252
+ const a03 = matrixA[3];
253
+ const a10 = matrixA[4];
254
+ const a11 = matrixA[5];
255
+ const a12 = matrixA[6];
256
+ const a13 = matrixA[7];
257
+ const a20 = matrixA[8];
258
+ const a21 = matrixA[9];
259
+ const a22 = matrixA[10];
260
+ const a23 = matrixA[11];
261
+ const a30 = matrixA[12];
262
+ const a31 = matrixA[13];
263
+ const a32 = matrixA[14];
264
+ const a33 = matrixA[15];
265
+ let b0 = matrixB[0];
266
+ let b1 = matrixB[1];
267
+ let b2 = matrixB[2];
268
+ let b3 = matrixB[3];
269
+ result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
270
+ result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
271
+ result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
272
+ result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
273
+ b0 = matrixB[4];
274
+ b1 = matrixB[5];
275
+ b2 = matrixB[6];
276
+ b3 = matrixB[7];
277
+ result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
278
+ result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
279
+ result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
280
+ result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
281
+ b0 = matrixB[8];
282
+ b1 = matrixB[9];
283
+ b2 = matrixB[10];
284
+ b3 = matrixB[11];
285
+ result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
286
+ result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
287
+ result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
288
+ result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
289
+ b0 = matrixB[12];
290
+ b1 = matrixB[13];
291
+ b2 = matrixB[14];
292
+ b3 = matrixB[15];
293
+ result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
294
+ result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
295
+ result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
296
+ result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
297
+ return result;
298
+ }
382
299
 
383
- default:
384
- return parameterLength <= length;
300
+ function multiplyArrayOfMatrices(matrices) {
301
+ let inputMatrix = matrices[0];
302
+ for (let i = 1; i < matrices.length; i++) {
303
+ inputMatrix = multiplyMatrices$1(inputMatrix, matrices[i]);
385
304
  }
305
+ return inputMatrix;
306
+ }
307
+
308
+ function matrixArrayToCSSMatrix(array) {
309
+ return "matrix3d(" + array.join(",") + ")";
310
+ }
311
+
312
+ var index$f = Object.freeze({
313
+ __proto__: null,
314
+ rotateMatrix: rotateMatrix,
315
+ translateMatrix: translateMatrix$1,
316
+ scaleMatrix: scaleMatrix$1,
317
+ multiplyMatrices: multiplyMatrices$1,
318
+ multiplyArrayOfMatrices: multiplyArrayOfMatrices,
319
+ matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
320
+ });
321
+
322
+ const getInitialMatrix = () => {
323
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
324
+ return matrix;
386
325
  };
387
326
 
388
- const checkValidPath = (validationParameters, parameters) => {
389
- if (validationParameters) {
390
- for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
391
- const {length: length, lengthType: lengthType, startsWith: startsWith, endsWith: endsWith, includes: includes} = parameterData;
392
- const paramaterValue = parameters[parameterKey];
393
- if (!paramaterValue) {
394
- return false;
395
- }
396
- if (startsWith && !paramaterValue.startsWith(startsWith)) {
397
- return false;
398
- }
399
- if (endsWith && !paramaterValue.endsWith(endsWith)) {
400
- return false;
401
- }
402
- if (includes && !includes.includes(paramaterValue)) {
403
- return false;
404
- }
405
- if (length) {
406
- const validLength = checkParameterLength(paramaterValue, length, lengthType);
407
- return validLength;
327
+ const multiplyMatrices = (m1, m2) => {
328
+ const result = [];
329
+ for (let i = 0; i < m1.length; i++) {
330
+ result[i] = [];
331
+ for (let j = 0; j < m2[0].length; j++) {
332
+ let sum = 0;
333
+ for (let k = 0; k < m1[0].length; k++) {
334
+ sum += m1[i][k] * m2[k][j];
408
335
  }
336
+ result[i][j] = sum;
409
337
  }
410
338
  }
411
- return true;
339
+ return result;
412
340
  };
413
341
 
414
- const cleanPathElement = path => {
415
- if (path[0] === "/") {
416
- return path.slice(1);
342
+ const multiplyMatricesArray = matrices => {
343
+ if (matrices.length < 2) {
344
+ throw new Error("invalid number of matrices");
417
345
  }
418
- return path;
419
- };
420
-
421
- var index$j = Object.freeze({
422
- __proto__: null,
423
- cleanPathElement: cleanPathElement
424
- });
425
-
426
- const mapPathsToRoutes = (paths, view) => {
427
- const routes = [];
428
- for (const [key, path] of Object.entries(paths)) {
429
- const pathView = view[key];
430
- if (pathView) {
431
- const route = {
432
- value: ""
433
- };
434
- routes.push(route);
346
+ const first = matrices[0];
347
+ let result = first;
348
+ for (const [index, matrix] of matrices.entries()) {
349
+ if (index === 0) {
350
+ continue;
435
351
  }
352
+ result = multiplyMatrices(result, matrix);
436
353
  }
437
- return routes;
354
+ return result;
438
355
  };
439
356
 
440
- const pluridLinkPathDivider = route => {
441
- const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
442
- const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
443
- const split = route.split("://").filter((value => value !== "")).map((value => cleanPathElement(value)));
444
- let protocol = windowProtocol;
445
- const host = {
446
- value: windowHost,
447
- controlled: false
448
- };
449
- const path = {
450
- value: "",
451
- parameters: {},
452
- query: {}
453
- };
454
- const space = {
455
- value: "",
456
- parameters: {},
457
- query: {}
458
- };
459
- const universe = {
460
- value: "",
461
- parameters: {},
462
- query: {}
463
- };
464
- const cluster = {
465
- value: "",
466
- parameters: {},
467
- query: {}
468
- };
469
- const plane = {
470
- value: "",
471
- parameters: {},
472
- query: {},
473
- fragments: {
474
- texts: [],
475
- elements: []
476
- }
477
- };
478
- const valid = false;
479
- if (split.length === 0 || split.length > 7) {
480
- const url = {
481
- protocol: {
482
- value: protocol,
483
- secure: true
484
- },
485
- host: host,
486
- path: path,
487
- space: space,
488
- universe: universe,
489
- cluster: cluster,
490
- plane: plane,
491
- valid: valid
492
- };
493
- return url;
357
+ const arrayToMatrix = array => {
358
+ const matrix = [];
359
+ for (let i = 0; i < array.length; i += 4) {
360
+ const row = [];
361
+ row.push(array[i]);
362
+ row.push(array[i + 1]);
363
+ row.push(array[i + 2]);
364
+ row.push(array[i + 3]);
365
+ matrix.push(row);
494
366
  }
495
- if (route.startsWith("/://")) {
496
- const routeSplit = split.slice(1);
497
- switch (routeSplit.length) {
498
- case 1:
499
- path.value = routeSplit[0];
500
- break;
367
+ return matrix;
368
+ };
501
369
 
502
- case 5:
503
- path.value = routeSplit[0];
504
- space.value = routeSplit[1];
505
- universe.value = routeSplit[2];
506
- cluster.value = routeSplit[3];
507
- plane.value = routeSplit[4];
508
- break;
370
+ const matrixToArray = matrix => matrix.flat();
371
+
372
+ const matrix3DToMatrix = value => {
373
+ const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val => parseFloat(val)));
374
+ return arrayToMatrix(values);
375
+ };
376
+
377
+ const printMatrix = (matrix, name) => {
378
+ const normalize = value => {
379
+ if (value === 1 || value === 0) {
380
+ return value + " ";
509
381
  }
510
- const url = {
511
- protocol: {
512
- value: protocol,
513
- secure: true
514
- },
515
- host: host,
516
- path: path,
517
- space: space,
518
- universe: universe,
519
- cluster: cluster,
520
- plane: plane,
521
- valid: true
522
- };
523
- return url;
382
+ if (value > 0) {
383
+ return value.toFixed(2) + " ";
384
+ }
385
+ return value.toFixed(2) + " ";
386
+ };
387
+ console.log("matrix", name + ":");
388
+ for (const row of matrix) {
389
+ console.log(normalize(row[0]), normalize(row[1]), normalize(row[2]), normalize(row[3]));
524
390
  }
525
- if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
526
- switch (split.length) {
527
- case 1:
528
- plane.value = split[0];
529
- break;
391
+ console.log(`matrix3d(${matrix.flat().join(",")})`);
392
+ console.log();
393
+ };
530
394
 
531
- case 2:
532
- cluster.value = split[0];
533
- plane.value = split[1];
534
- break;
395
+ const rotateXMatrix = angle => {
396
+ const x = Math.cos(angle);
397
+ const y = -1 * Math.sin(angle);
398
+ const z = Math.sin(angle);
399
+ const m = [ [ 1, 0, 0, 0 ], [ 0, x, y, 0 ], [ 0, z, x, 0 ], [ 0, 0, 0, 1 ] ];
400
+ return m;
401
+ };
535
402
 
536
- case 3:
537
- universe.value = split[0];
538
- cluster.value = split[1];
539
- plane.value = split[2];
540
- break;
403
+ const rotateYMatrix = angle => {
404
+ const x = Math.cos(angle);
405
+ const y = -1 * Math.sin(angle);
406
+ const z = Math.sin(angle);
407
+ const m = [ [ x, 0, z, 0 ], [ 0, 1, 0, 0 ], [ y, 0, x, 0 ], [ 0, 0, 0, 1 ] ];
408
+ return m;
409
+ };
541
410
 
542
- case 4:
543
- space.value = split[0];
544
- universe.value = split[1];
545
- cluster.value = split[2];
546
- plane.value = split[3];
547
- break;
411
+ const rotateZMatrix = angle => {
412
+ const x = Math.cos(angle);
413
+ const y = -1 * Math.sin(angle);
414
+ const z = Math.sin(angle);
415
+ const m = [ [ x, y, 0, 0 ], [ z, x, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
416
+ return m;
417
+ };
548
418
 
549
- case 5:
550
- path.value = split[0];
551
- space.value = split[1];
552
- universe.value = split[2];
553
- cluster.value = split[3];
554
- plane.value = split[4];
555
- break;
419
+ const translateMatrix = (x = 0, y = 0, z = 0) => {
420
+ const m = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ x, y, z, 1 ] ];
421
+ return m;
422
+ };
556
423
 
557
- case 6:
558
- host.value = split[0];
559
- path.value = split[1];
560
- space.value = split[2];
561
- universe.value = split[3];
562
- cluster.value = split[4];
563
- plane.value = split[5];
564
- break;
424
+ const scaleMatrix = s => [ [ s, 0, 0, 0 ], [ 0, s, 0, 0 ], [ 0, 0, s, 0 ], [ 0, 0, 0, 1 ] ];
565
425
 
566
- default:
567
- const url = {
568
- protocol: {
569
- value: protocol,
570
- secure: true
571
- },
572
- host: host,
573
- path: path,
574
- space: space,
575
- universe: universe,
576
- cluster: cluster,
577
- plane: plane,
578
- valid: valid
579
- };
580
- return url;
581
- }
582
- } else {
583
- switch (split.length) {
584
- case 3:
585
- protocol = split[0];
586
- host.value = split[1];
587
- path.value = split[2];
588
- break;
426
+ function rotationMatrixFromQuaternion(quaternion) {
427
+ const num = quaternion.x * 2;
428
+ const num2 = quaternion.y * 2;
429
+ const num3 = quaternion.z * 2;
430
+ const num4 = quaternion.x * num;
431
+ const num5 = quaternion.y * num2;
432
+ const num6 = quaternion.z * num3;
433
+ const num7 = quaternion.x * num2;
434
+ const num8 = quaternion.x * num3;
435
+ const num9 = quaternion.y * num3;
436
+ const num10 = quaternion.w * num;
437
+ const num11 = quaternion.w * num2;
438
+ const num12 = quaternion.w * num3;
439
+ return [ [ 1 - (num5 + num6), num7 - num12, num8 + num11, 0 ], [ num7 + num12, 1 - (num4 + num6), num9 - num10, 0 ], [ num8 - num11, num9 + num10, 1 - (num4 + num5), 0 ], [ 0, 0, 0, 1 ] ];
440
+ }
589
441
 
590
- case 7:
591
- protocol = split[0];
592
- host.value = split[1];
593
- path.value = split[2];
594
- space.value = split[3];
595
- universe.value = split[4];
596
- cluster.value = split[5];
597
- plane.value = split[6];
598
- break;
442
+ const matrixToCSSMatrix = matrix => {
443
+ const value = matrix.flat().join(",");
444
+ return `matrix3d(${value})`;
445
+ };
599
446
 
600
- default:
601
- const url = {
602
- protocol: {
603
- value: protocol,
604
- secure: true
605
- },
606
- host: host,
607
- path: path,
608
- space: space,
609
- universe: universe,
610
- cluster: cluster,
611
- plane: plane,
612
- valid: valid
613
- };
614
- return url;
447
+ const identityMatrix = () => {
448
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
449
+ return matrix;
450
+ };
451
+
452
+ const inverseMatrix = matrix => {
453
+ const cols = 4;
454
+ const rows = 4;
455
+ const A = [ ...matrix ];
456
+ const B = identityMatrix();
457
+ let r;
458
+ let s;
459
+ let f;
460
+ let temp;
461
+ for (let c = 0; c < cols; c++) {
462
+ let ABig = Math.abs(A[c][c]);
463
+ let rBig = c;
464
+ r = c + 1;
465
+ while (r < rows) {
466
+ if (Math.abs(A[r][c]) > ABig) {
467
+ ABig = Math.abs(A[r][c]);
468
+ rBig = r;
469
+ }
470
+ r++;
471
+ }
472
+ if (ABig === 0) {
473
+ throw Error("Cannot calculate inverse, determinant is zero");
474
+ }
475
+ r = rBig;
476
+ if (r !== c) {
477
+ temp = A[c];
478
+ A[c] = A[r];
479
+ A[r] = temp;
480
+ temp = B[c];
481
+ B[c] = B[r];
482
+ B[r] = temp;
483
+ }
484
+ const Ac = A[c];
485
+ const Bc = B[c];
486
+ for (r = 0; r < rows; r++) {
487
+ const Ar = A[r];
488
+ const Br = B[r];
489
+ if (r !== c) {
490
+ if (Ar[c] !== 0) {
491
+ f = -Ar[c] / Ac[c];
492
+ for (s = c; s < cols; s++) {
493
+ Ar[s] = Ar[s] + f * Ac[s];
494
+ }
495
+ for (s = 0; s < cols; s++) {
496
+ Br[s] = Br[s] + f * Bc[s];
497
+ }
498
+ }
499
+ } else {
500
+ f = Ac[c];
501
+ for (s = c; s < cols; s++) {
502
+ Ar[s] = Ar[s] / f;
503
+ }
504
+ for (s = 0; s < cols; s++) {
505
+ Br[s] = Br[s] / f;
506
+ }
507
+ }
615
508
  }
616
509
  }
617
- const url = {
618
- protocol: {
619
- value: protocol,
620
- secure: true
621
- },
622
- host: host,
623
- path: path,
624
- space: space,
625
- universe: universe,
626
- cluster: cluster,
627
- plane: plane,
628
- valid: true
629
- };
630
- return url;
510
+ return B;
631
511
  };
632
512
 
633
- const resolveRoute = (route, protocol, host) => {
634
- const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
635
- const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
636
- const divisions = pluridLinkPathDivider(route);
637
- const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
638
- const protocolDivision = divisions.protocol.value || windowProtocol;
639
- const hostDivision = divisions.host.value ? divisions.host : {
640
- value: windowHost,
641
- controlled: true
642
- };
643
- const path = divisions.path.value ? divisions.path : {
644
- value: defaultPathname,
645
- parameters: {},
646
- query: {}
647
- };
648
- const space = divisions.space.value ? divisions.space : {
649
- value: "s",
650
- parameters: {},
651
- query: {}
652
- };
653
- const universe = divisions.universe.value ? divisions.universe : {
654
- value: "u",
655
- parameters: {},
656
- query: {}
657
- };
658
- const cluster = divisions.cluster.value ? divisions.cluster : {
659
- value: "c",
660
- parameters: {},
661
- query: {}
662
- };
663
- const plane = divisions.plane;
664
- const separator = "://";
665
- if (!plane.value && route !== "/") {
666
- const resolvers = [ protocolDivision, hostDivision.value, path.value ];
667
- const absoluteRoute = resolvers.join(separator);
668
- return {
669
- protocol: protocolDivision,
670
- host: hostDivision,
671
- path: path,
672
- space: space,
673
- universe: universe,
674
- cluster: cluster,
675
- plane: plane,
676
- route: absoluteRoute
677
- };
678
- }
679
- [ protocolDivision, hostDivision.value, path.value, space.value, universe.value, cluster.value, cleanPathElement(plane.value) ];
680
- return {
681
- protocol: "",
682
- host: "",
683
- path: path,
684
- space: "",
685
- universe: "",
686
- cluster: "",
687
- plane: "",
688
- route: route
689
- };
690
- };
513
+ var index$e = Object.freeze({
514
+ __proto__: null,
515
+ getInitialMatrix: getInitialMatrix,
516
+ multiplyMatrices: multiplyMatrices,
517
+ multiplyMatricesArray: multiplyMatricesArray,
518
+ arrayToMatrix: arrayToMatrix,
519
+ matrixToArray: matrixToArray,
520
+ matrix3DToMatrix: matrix3DToMatrix,
521
+ printMatrix: printMatrix,
522
+ rotateXMatrix: rotateXMatrix,
523
+ rotateYMatrix: rotateYMatrix,
524
+ rotateZMatrix: rotateZMatrix,
525
+ translateMatrix: translateMatrix,
526
+ scaleMatrix: scaleMatrix,
527
+ rotationMatrixFromQuaternion: rotationMatrixFromQuaternion,
528
+ matrixToCSSMatrix: matrixToCSSMatrix,
529
+ identityMatrix: identityMatrix,
530
+ inverseMatrix: inverseMatrix
531
+ });
691
532
 
692
- const createTreePlane = (contextPlane, documentPlane) => {
693
- const routeDivisions = pluridLinkPathDivider(contextPlane.path);
694
- const treePlane = Object.assign(Object.assign({}, defaultTreePlane), {
695
- routeDivisions: routeDivisions,
696
- sourceID: contextPlane.id,
697
- planeID: uuid.generate(),
698
- route: contextPlane.path,
699
- show: true
700
- });
701
- return treePlane;
702
- };
533
+ function getMatrixValues(matrix3d) {
534
+ const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
535
+ const matrixValuesInt = [];
536
+ for (let i = 0; i < matrixValues.length; i++) {
537
+ matrixValuesInt[i] = parseFloat(matrixValues[i]);
538
+ }
539
+ return matrixValuesInt;
540
+ }
703
541
 
704
- const updateTreePlane$1 = (tree, page) => {
705
- const updatedTree = tree.map((treePlane => {
706
- if (treePlane.planeID === page.planeID) {
707
- return Object.assign({}, page);
542
+ function getRotationMatrix(matrix3d) {
543
+ const valuesMatrix = getMatrixValues(matrix3d);
544
+ const scale = getScalationValue(matrix3d);
545
+ if (valuesMatrix.length === 16) {
546
+ for (let i = 0; i < 11; i++) {
547
+ valuesMatrix[i] /= scale;
708
548
  }
709
- if (treePlane.children) {
710
- return Object.assign(Object.assign({}, treePlane), {
711
- children: updateTreePlane$1(treePlane.children, page)
712
- });
549
+ } else if (valuesMatrix.length === 6) {
550
+ for (let i = 0; i < 4; i++) {
551
+ valuesMatrix[i] /= scale;
713
552
  }
714
- return treePlane;
715
- }));
716
- return updatedTree;
717
- };
553
+ }
554
+ const rotationMatrix = valuesMatrix;
555
+ return rotationMatrix;
556
+ }
718
557
 
719
- const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
720
- const updatedTree = tree.map((treePlane => {
721
- if (treePlane.planeID === planeID) {
722
- const updatedPlane = Object.assign(Object.assign({}, treePlane), {
723
- linkCoordinates: linkCoordinates
724
- });
725
- return updatedPlane;
726
- }
727
- if (treePlane.children) {
728
- const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(treePlane.children, planeID, linkCoordinates);
729
- const updatedPlane = Object.assign(Object.assign({}, treePlane), {
730
- children: updatedChildren
731
- });
732
- return updatedPlane;
733
- }
734
- return treePlane;
735
- }));
736
- return updatedTree;
737
- };
558
+ function getTranslationMatrix(matrix3d) {
559
+ const valuesMatrix = getMatrixValues(matrix3d);
560
+ let translationMatrix;
561
+ if (valuesMatrix.length === 16) {
562
+ translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
563
+ } else if (valuesMatrix.length === 6) {
564
+ translationMatrix = getMatrixValues(matrix3d).slice(4);
565
+ }
566
+ return translationMatrix;
567
+ }
738
568
 
739
- var index$i = Object.freeze({
740
- __proto__: null,
741
- createTreePlane: createTreePlane,
742
- updateTreePlane: updateTreePlane$1,
743
- updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
744
- });
569
+ function getScalationValue(matrix3d) {
570
+ const valuesMatrix = getMatrixValues(matrix3d);
571
+ let temp = 0;
572
+ let scale;
573
+ if (valuesMatrix.length === 16) {
574
+ const scaleMatrix = getMatrixValues(matrix3d).slice(0, 4);
575
+ scale = 0;
576
+ for (const el of scaleMatrix) {
577
+ scale += parseFloat(el) * parseFloat(el);
578
+ }
579
+ scale = parseFloat(Math.sqrt(scale).toPrecision(4));
580
+ } else if (valuesMatrix.length === 6) {
581
+ temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
582
+ scale = parseFloat(Math.sqrt(temp).toPrecision(4));
583
+ }
584
+ return scale;
585
+ }
745
586
 
746
- var index$h = Object.freeze({
747
- __proto__: null,
748
- configuration: index$k,
749
- tree: index$i
750
- });
587
+ function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
588
+ const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
589
+ return matrixArrayToCSSMatrix(transformMatrix);
590
+ }
751
591
 
752
- const getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
753
- let direction = "left";
754
- const wheelDeltaX = deltas.deltaX;
755
- const wheelDeltaY = deltas.deltaY;
756
- const absWheelDeltaX = Math.abs(wheelDeltaX);
757
- const absWheelDeltaY = Math.abs(wheelDeltaY);
758
- if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
759
- direction = "left";
760
- }
761
- if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
762
- direction = "right";
763
- }
764
- if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
765
- direction = "up";
592
+ function getTransformRotate(matrix3d) {
593
+ const pi = Math.PI;
594
+ const values = getRotationMatrix(matrix3d);
595
+ let rotateX = 0;
596
+ let rotateY = 0;
597
+ if (values.length === 6) {
598
+ const cosa = values[0];
599
+ const sina = values[1];
600
+ if (cosa === 1 && sina === 0) {
601
+ rotateX = Math.asin(sina);
602
+ rotateY = Math.acos(cosa);
603
+ }
766
604
  }
767
- if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
768
- direction = "down";
605
+ if (values.length === 16) {
606
+ const cosaX1 = values[5];
607
+ const sinaX3 = values[9];
608
+ if (sinaX3 <= 0) {
609
+ rotateX = Math.acos(cosaX1);
610
+ }
611
+ if (sinaX3 > 0) {
612
+ rotateX = 2 * pi - Math.acos(cosaX1);
613
+ }
614
+ const cosaY1 = values[0];
615
+ const sinaY2 = values[2];
616
+ if (sinaY2 <= 0) {
617
+ rotateY = Math.acos(cosaY1);
618
+ }
619
+ if (sinaY2 > 0) {
620
+ rotateY = 2 * pi - Math.acos(cosaY1);
621
+ }
622
+ rotateX = Math.atan2(values[9], values[5]);
623
+ rotateY = Math.atan2(values[2], values[0]);
769
624
  }
770
- return direction;
771
- };
772
-
773
- var index$g = Object.freeze({
774
- __proto__: null,
775
- getWheelDirection: getWheelDirection
776
- });
777
-
778
- const degToRad = deg => deg * .01745329252;
779
-
780
- const radToDeg = rad => rad * 57.2957795131;
781
-
782
- const makeQuaternion = (x, y, z, w) => ({
783
- x: x,
784
- y: y,
785
- z: z,
786
- w: w
787
- });
788
-
789
- const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
625
+ return {
626
+ rotateX: rotateX,
627
+ rotateY: rotateY,
628
+ rotateZ: 0
629
+ };
630
+ }
790
631
 
791
- function inverseQuaternion(quaternion) {
792
- return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
632
+ function getTransformTranslate(matrix3d) {
633
+ const values = getTranslationMatrix(matrix3d);
634
+ const translateX = values[0];
635
+ const translateY = values[1];
636
+ const translateZ = values[2];
637
+ return {
638
+ translateX: translateX,
639
+ translateY: translateY,
640
+ translateZ: translateZ
641
+ };
793
642
  }
794
643
 
795
- function conjugateQuaternion(quaternion) {
796
- return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
644
+ function getTransformScale(matrix3d) {
645
+ const scale = getScalationValue(matrix3d);
646
+ return {
647
+ scale: scale
648
+ };
797
649
  }
798
650
 
799
- function computeQuaternionFromEulers(alpha, beta, gamma) {
800
- const x = beta;
801
- const y = gamma;
802
- const z = alpha;
803
- const cX = Math.cos(x / 2);
804
- const cY = Math.cos(y / 2);
805
- const cZ = Math.cos(z / 2);
806
- const sX = Math.sin(x / 2);
807
- const sY = Math.sin(y / 2);
808
- const sZ = Math.sin(z / 2);
809
- const xQ = sX * cY * cZ - cX * sY * sZ;
810
- const yQ = cX * sY * cZ + sX * cY * sZ;
811
- const zQ = cX * cY * sZ + sX * sY * cZ;
812
- const wQ = cX * cY * cZ - sX * sY * sZ;
813
- return makeQuaternion(xQ, yQ, zQ, wQ);
814
- }
815
-
816
- function quaternionFromAxisAngle(x, y, z, angle) {
817
- const q = zeroQuaternion();
818
- const halfAngle = angle / 2;
819
- q.x = x * Math.sin(halfAngle);
820
- q.y = y * Math.sin(halfAngle);
821
- q.z = z * Math.sin(halfAngle);
822
- q.w = Math.cos(halfAngle);
823
- return q;
824
- }
825
-
826
- function quaternionMultiply(quaternionArray) {
827
- const temporaryQuaternion = quaternionArray[0];
828
- const copyQuaternion = {
829
- x: temporaryQuaternion.x,
830
- y: temporaryQuaternion.y,
831
- z: temporaryQuaternion.z,
832
- w: temporaryQuaternion.w
833
- };
834
- for (let i = 1; i < quaternionArray.length; i++) {
835
- const secondaryTemporaryQuaternion = quaternionArray[i];
836
- const nextQuaternion = {
837
- x: secondaryTemporaryQuaternion.x,
838
- y: secondaryTemporaryQuaternion.y,
839
- z: secondaryTemporaryQuaternion.z,
840
- w: secondaryTemporaryQuaternion.w
841
- };
842
- const w = copyQuaternion.w * nextQuaternion.w - copyQuaternion.x * nextQuaternion.x - copyQuaternion.y * nextQuaternion.y - copyQuaternion.z * nextQuaternion.z;
843
- const x = copyQuaternion.x * nextQuaternion.w + copyQuaternion.w * nextQuaternion.x + copyQuaternion.y * nextQuaternion.z - copyQuaternion.z * nextQuaternion.y;
844
- const y = copyQuaternion.y * nextQuaternion.w + copyQuaternion.w * nextQuaternion.y + copyQuaternion.z * nextQuaternion.x - copyQuaternion.x * nextQuaternion.z;
845
- const z = copyQuaternion.z * nextQuaternion.w + copyQuaternion.w * nextQuaternion.z + copyQuaternion.x * nextQuaternion.y - copyQuaternion.y * nextQuaternion.x;
846
- copyQuaternion.x = x;
847
- copyQuaternion.y = y;
848
- copyQuaternion.z = z;
849
- copyQuaternion.w = w;
850
- }
851
- return copyQuaternion;
651
+ function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
652
+ const transformRotate = getTransformRotate(matrix3d);
653
+ const rotateX = transformRotate.rotateX;
654
+ let rotateY = transformRotate.rotateY;
655
+ const rotateZ = transformRotate.rotateZ;
656
+ const transformTranslate = getTransformTranslate(matrix3d);
657
+ const translateX = transformTranslate.translateX;
658
+ const translateY = transformTranslate.translateY;
659
+ const translateZ = transformTranslate.translateZ;
660
+ const scale = getTransformScale(matrix3d).scale;
661
+ let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
662
+ const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
663
+ const valScalationMatrix = scaleMatrix$1(scale);
664
+ if (direction === "left") {
665
+ rotateY -= angleIncrement;
666
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
667
+ }
668
+ if (direction === "right") {
669
+ rotateY += angleIncrement;
670
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
671
+ }
672
+ if (direction === "up") {
673
+ rotateY -= angleIncrement;
674
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
675
+ }
676
+ if (direction === "down") {
677
+ rotateY += angleIncrement;
678
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
679
+ }
680
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
681
+ return transformedMatrix3d;
852
682
  }
853
683
 
854
- function rotatePointViaQuaternion(pointRotate, quaternion) {
855
- const temporaryQuaternion = {
856
- x: pointRotate[0],
857
- y: pointRotate[1],
858
- z: pointRotate[2],
859
- w: 0
860
- };
861
- const rotatedPoint = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
862
- return {
863
- x: rotatedPoint.x,
864
- y: rotatedPoint.y,
865
- z: rotatedPoint.z,
866
- w: rotatedPoint.w
867
- };
684
+ function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
685
+ const transformRotate = getTransformRotate(matrix3d);
686
+ const rotateX = transformRotate.rotateX;
687
+ const rotateY = transformRotate.rotateY;
688
+ const rotateZ = transformRotate.rotateZ;
689
+ const transformTranslate = getTransformTranslate(matrix3d);
690
+ let translateX = transformTranslate.translateX;
691
+ let translateY = transformTranslate.translateY;
692
+ const translateZ = transformTranslate.translateZ;
693
+ const scale = getTransformScale(matrix3d).scale;
694
+ const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
695
+ let valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
696
+ const valScalationMatrix = scaleMatrix$1(scale);
697
+ scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
698
+ if (direction === "left") {
699
+ translateX += linearIncrement;
700
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
701
+ }
702
+ if (direction === "right") {
703
+ translateX -= linearIncrement;
704
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
705
+ }
706
+ if (direction === "up") {
707
+ translateY += linearIncrement;
708
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
709
+ }
710
+ if (direction === "down") {
711
+ translateY -= linearIncrement;
712
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
713
+ }
714
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
715
+ return transformedMatrix3d;
868
716
  }
869
717
 
870
- function makeRotationMatrixFromQuaternion(quaternion) {
871
- const num = quaternion.x * 2;
872
- const num2 = quaternion.y * 2;
873
- const num3 = quaternion.z * 2;
874
- const num4 = quaternion.x * num;
875
- const num5 = quaternion.y * num2;
876
- const num6 = quaternion.z * num3;
877
- const num7 = quaternion.x * num2;
878
- const num8 = quaternion.x * num3;
879
- const num9 = quaternion.y * num3;
880
- const num10 = quaternion.w * num;
881
- const num11 = quaternion.w * num2;
882
- const num12 = quaternion.w * num3;
883
- return [ 1 - (num5 + num6), num7 - num12, num8 + num11, 0, num7 + num12, 1 - (num4 + num6), num9 - num10, 0, num8 - num11, num9 + num10, 1 - (num4 + num5), 0, 0, 0, 0, 1 ];
718
+ function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
719
+ const transformRotate = getTransformRotate(matrix3d);
720
+ const rotateX = transformRotate.rotateX;
721
+ const rotateY = transformRotate.rotateY;
722
+ const rotateZ = transformRotate.rotateZ;
723
+ const transformTranslate = getTransformTranslate(matrix3d);
724
+ const translateX = transformTranslate.translateX;
725
+ const translateY = transformTranslate.translateY;
726
+ const translateZ = transformTranslate.translateZ;
727
+ let scale = getTransformScale(matrix3d).scale;
728
+ const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
729
+ const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
730
+ let valScalationMatrix = scaleMatrix$1(scale);
731
+ if (direction === "up") {
732
+ scale -= scaleIncrement;
733
+ if (scale < .1) {
734
+ scale = .1;
735
+ }
736
+ valScalationMatrix = scaleMatrix$1(scale);
737
+ }
738
+ if (direction === "down") {
739
+ scale += scaleIncrement;
740
+ if (scale > 4) {
741
+ scale = 4;
742
+ }
743
+ valScalationMatrix = scaleMatrix$1(scale);
744
+ }
745
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
746
+ return transformedMatrix3d;
884
747
  }
885
748
 
886
- var index$f = Object.freeze({
749
+ var index$d = Object.freeze({
887
750
  __proto__: null,
888
- degToRad: degToRad,
889
- radToDeg: radToDeg,
890
- makeQuaternion: makeQuaternion,
891
- zeroQuaternion: zeroQuaternion,
892
- inverseQuaternion: inverseQuaternion,
893
- conjugateQuaternion: conjugateQuaternion,
894
- computeQuaternionFromEulers: computeQuaternionFromEulers,
895
- quaternionFromAxisAngle: quaternionFromAxisAngle,
896
- quaternionMultiply: quaternionMultiply,
897
- rotatePointViaQuaternion: rotatePointViaQuaternion,
898
- makeRotationMatrixFromQuaternion: makeRotationMatrixFromQuaternion
751
+ getMatrixValues: getMatrixValues,
752
+ getRotationMatrix: getRotationMatrix,
753
+ getTranslationMatrix: getTranslationMatrix,
754
+ getScalationValue: getScalationValue,
755
+ setTransform: setTransform,
756
+ getTransformRotate: getTransformRotate,
757
+ getTransformTranslate: getTransformTranslate,
758
+ getTransformScale: getTransformScale,
759
+ rotatePlurid: rotatePlurid,
760
+ translatePlurid: translatePlurid,
761
+ scalePlurid: scalePlurid
899
762
  });
900
763
 
901
- function rotateMatrix(xAngle, yAngle, zAngle = 0) {
902
- const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
903
- const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
904
- const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
905
- const quartenionMultiplication = quaternionMultiply([ yQuaternion, xQuaternion, zQuaternion ]);
906
- const rotationMatrix = makeRotationMatrixFromQuaternion(quartenionMultiplication);
907
- return rotationMatrix;
908
- }
764
+ var index$c = Object.freeze({
765
+ __proto__: null,
766
+ general: index$e,
767
+ matrix3d: index$d
768
+ });
909
769
 
910
- function translateMatrix$1(x, y, z) {
911
- return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
912
- }
770
+ var index$b = Object.freeze({
771
+ __proto__: null,
772
+ direction: index$h,
773
+ matrix: index$f,
774
+ quaternion: index$g,
775
+ transform: index$c
776
+ });
913
777
 
914
- function scaleMatrix(s) {
915
- return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
916
- }
778
+ const internatiolate = (lamguage, field) => internationalization[lamguage][field];
917
779
 
918
- function multiplyMatrices$1(matrixA, matrixB) {
919
- const result = [];
920
- const a00 = matrixA[0];
921
- const a01 = matrixA[1];
922
- const a02 = matrixA[2];
923
- const a03 = matrixA[3];
924
- const a10 = matrixA[4];
925
- const a11 = matrixA[5];
926
- const a12 = matrixA[6];
927
- const a13 = matrixA[7];
928
- const a20 = matrixA[8];
929
- const a21 = matrixA[9];
930
- const a22 = matrixA[10];
931
- const a23 = matrixA[11];
932
- const a30 = matrixA[12];
933
- const a31 = matrixA[13];
934
- const a32 = matrixA[14];
935
- const a33 = matrixA[15];
936
- let b0 = matrixB[0];
937
- let b1 = matrixB[1];
938
- let b2 = matrixB[2];
939
- let b3 = matrixB[3];
940
- result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
941
- result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
942
- result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
943
- result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
944
- b0 = matrixB[4];
945
- b1 = matrixB[5];
946
- b2 = matrixB[6];
947
- b3 = matrixB[7];
948
- result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
949
- result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
950
- result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
951
- result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
952
- b0 = matrixB[8];
953
- b1 = matrixB[9];
954
- b2 = matrixB[10];
955
- b3 = matrixB[11];
956
- result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
957
- result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
958
- result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
959
- result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
960
- b0 = matrixB[12];
961
- b1 = matrixB[13];
962
- b2 = matrixB[14];
963
- b3 = matrixB[15];
964
- result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
965
- result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
966
- result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
967
- result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
968
- return result;
969
- }
780
+ const resolvePluridPlaneData = plane => {
781
+ if (Array.isArray(plane)) {
782
+ const [route, component, options] = plane;
783
+ return Object.assign({
784
+ route: route,
785
+ component: component
786
+ }, options);
787
+ }
788
+ return plane;
789
+ };
970
790
 
971
- function multiplyArrayOfMatrices(matrices) {
972
- let inputMatrix = matrices[0];
973
- for (let i = 1; i < matrices.length; i++) {
974
- inputMatrix = multiplyMatrices$1(inputMatrix, matrices[i]);
791
+ const resolvePluridRoutePlaneData = plane => {
792
+ if (Array.isArray(plane)) {
793
+ const [value, component, options] = plane;
794
+ return Object.assign({
795
+ value: value,
796
+ component: component
797
+ }, options);
975
798
  }
976
- return inputMatrix;
977
- }
799
+ return plane;
800
+ };
978
801
 
979
- function matrixArrayToCSSMatrix(array) {
980
- return "matrix3d(" + array.join(",") + ")";
981
- }
802
+ const getPluridPlaneIDByData = element => {
803
+ if (!element) {
804
+ return "";
805
+ }
806
+ const parent = element.parentElement;
807
+ if (parent && parent.dataset.pluridPlane) {
808
+ return parent.dataset.pluridPlane;
809
+ }
810
+ return getPluridPlaneIDByData(parent);
811
+ };
982
812
 
983
- var index$e = Object.freeze({
984
- __proto__: null,
985
- rotateMatrix: rotateMatrix,
986
- translateMatrix: translateMatrix$1,
987
- scaleMatrix: scaleMatrix,
988
- multiplyMatrices: multiplyMatrices$1,
989
- multiplyArrayOfMatrices: multiplyArrayOfMatrices,
990
- matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
991
- });
813
+ const extractPathname = location => {
814
+ const queryIndex = location.indexOf("?");
815
+ const noQueryPath = queryIndex === -1 ? location : location.substring(0, queryIndex);
816
+ const fragmentIndex = noQueryPath.indexOf("#:~:");
817
+ const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
818
+ return noFragmentPath;
819
+ };
992
820
 
993
- const multiplyMatrices = (m1, m2) => {
994
- const result = [];
995
- for (let i = 0; i < m1.length; i++) {
996
- result[i] = [];
997
- for (let j = 0; j < m2[0].length; j++) {
998
- let sum = 0;
999
- for (let k = 0; k < m1[0].length; k++) {
1000
- sum += m1[i][k] * m2[k][j];
1001
- }
1002
- result[i][j] = sum;
821
+ const extractParametersAndMatch = (location, route) => {
822
+ const routeElements = splitPath(route);
823
+ const parameters = [];
824
+ routeElements.forEach((routeElement => {
825
+ if (routeElement[0] === ":") {
826
+ parameters.push(routeElement);
827
+ } else {
828
+ parameters.push("");
1003
829
  }
830
+ }));
831
+ const {locationElements: locationElements, comparingPath: comparingPath} = computeComparingPath(location, parameters);
832
+ if (comparingPath !== route) {
833
+ return {
834
+ match: false,
835
+ parameters: {},
836
+ elements: locationElements
837
+ };
1004
838
  }
1005
- return result;
839
+ const parametersValues = extractParametersValues(parameters, locationElements);
840
+ return {
841
+ match: true,
842
+ parameters: parametersValues,
843
+ elements: locationElements
844
+ };
1006
845
  };
1007
846
 
1008
- const arrayToMatrix = array => {
1009
- const matrix = [];
1010
- for (let i = 0; i < array.length; i += 4) {
1011
- const row = [];
1012
- row.push(array[i]);
1013
- row.push(array[i + 1]);
1014
- row.push(array[i + 2]);
1015
- row.push(array[i + 3]);
1016
- matrix.push(row);
847
+ const extractParametersValues = (parameters, pathElements) => {
848
+ const parametersValues = {};
849
+ parameters.forEach(((parameter, index) => {
850
+ if (parameter) {
851
+ const parameterKey = parameter.slice(1);
852
+ parametersValues[parameterKey] = pathElements[index];
853
+ }
854
+ }));
855
+ return parametersValues;
856
+ };
857
+
858
+ const computeComparingPath = (path, parameters) => {
859
+ const pathname = extractPathname(path);
860
+ const locationElements = splitPath(pathname);
861
+ const comparingPathElements = [ ...locationElements ];
862
+ for (const index of locationElements.keys()) {
863
+ if (parameters[index]) {
864
+ comparingPathElements[index] = parameters[index];
865
+ }
1017
866
  }
1018
- return matrix;
867
+ const comparingPath = comparingPathElements.join("/");
868
+ return {
869
+ locationElements: locationElements,
870
+ comparingPath: comparingPath
871
+ };
1019
872
  };
1020
873
 
1021
- const matrixToArray = matrix => matrix.flat();
874
+ const splitPath = path => path.split("/").filter((i => i !== ""));
1022
875
 
1023
- const printMatrix = (matrix, name) => {
1024
- const normalize = value => {
1025
- if (value === 1 || value === 0) {
1026
- return value + " ";
1027
- }
1028
- if (value > 0) {
1029
- return value.toFixed(2) + " ";
876
+ const extractQuery = path => {
877
+ const fragmentIndex = path.indexOf("#:~:");
878
+ const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
879
+ const querySplit = noFragmentPath.split("?");
880
+ if (querySplit.length === 2) {
881
+ const queryValues = {};
882
+ const query = querySplit[1];
883
+ const queryItems = query.split("&");
884
+ for (const item of queryItems) {
885
+ const queryValue = item.split("=");
886
+ const id = queryValue[0];
887
+ const value = decodeURIComponent(queryValue[1]);
888
+ queryValues[id] = value;
1030
889
  }
1031
- return value.toFixed(2) + " ";
1032
- };
1033
- console.log("matrix", name + ":");
1034
- for (const row of matrix) {
1035
- console.log(normalize(row[0]), normalize(row[1]), normalize(row[2]), normalize(row[3]));
890
+ return queryValues;
891
+ } else {
892
+ return {};
1036
893
  }
1037
- console.log(`matrix3d(${matrix.flat().join(",")})`);
1038
- console.log();
1039
894
  };
1040
895
 
1041
- const rotateXMatrix = angle => {
1042
- const x = Math.cos(angle);
1043
- const y = -1 * Math.sin(angle);
1044
- const z = Math.sin(angle);
1045
- const m = [ [ 1, 0, 0, 0 ], [ 0, x, y, 0 ], [ 0, z, x, 0 ], [ 0, 0, 0, 1 ] ];
1046
- return m;
1047
- };
896
+ const extractFragments = location => {
897
+ if (!location) {
898
+ return {
899
+ texts: [],
900
+ elements: []
901
+ };
902
+ }
903
+ const split = location.split("#:~:");
904
+ const fragmentsValues = split[1];
905
+ if (!fragmentsValues) {
906
+ return {
907
+ texts: [],
908
+ elements: []
909
+ };
910
+ }
911
+ const fragmentItems = fragmentsValues.split("&");
912
+ const textFragments = [];
913
+ const elementFragments = [];
914
+ for (const item of fragmentItems) {
915
+ const parsedFragment = parseFragment(item);
916
+ if (parsedFragment) {
917
+ switch (parsedFragment.type) {
918
+ case "text":
919
+ textFragments.push(parsedFragment);
920
+ break;
1048
921
 
1049
- const rotateYMatrix = angle => {
1050
- const x = Math.cos(angle);
1051
- const y = -1 * Math.sin(angle);
1052
- const z = Math.sin(angle);
1053
- const m = [ [ x, 0, z, 0 ], [ 0, 1, 0, 0 ], [ y, 0, x, 0 ], [ 0, 0, 0, 1 ] ];
1054
- return m;
922
+ case "element":
923
+ elementFragments.push(parsedFragment);
924
+ break;
925
+ }
926
+ }
927
+ }
928
+ return {
929
+ texts: textFragments,
930
+ elements: elementFragments
931
+ };
1055
932
  };
1056
933
 
1057
- const rotateZMatrix = angle => {
1058
- const x = Math.cos(angle);
1059
- const y = -1 * Math.sin(angle);
1060
- const z = Math.sin(angle);
1061
- const m = [ [ x, y, 0, 0 ], [ z, x, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
1062
- return m;
934
+ const parseFragment = fragment => {
935
+ const fragmentData = fragment.split("=");
936
+ const fragmentType = fragmentData[0];
937
+ const fragmentValues = fragmentData[1];
938
+ switch (fragmentType.toLowerCase()) {
939
+ case "text":
940
+ {
941
+ const textValues = fragmentValues.split(",");
942
+ const textStart = textValues[0];
943
+ const textEnd = textValues[1];
944
+ const textOccurence = extractOccurence(textValues[2]);
945
+ if (!textStart) {
946
+ return;
947
+ }
948
+ return {
949
+ type: "text",
950
+ start: textStart,
951
+ end: textEnd || "",
952
+ occurence: textOccurence
953
+ };
954
+ }
955
+
956
+ case "element":
957
+ {
958
+ const elementValues = fragmentValues.split(",");
959
+ const elementID = elementValues[0];
960
+ const elementOccurence = extractOccurence(elementValues[1]);
961
+ if (!elementID) {
962
+ return;
963
+ }
964
+ return {
965
+ type: "element",
966
+ id: elementID,
967
+ occurence: elementOccurence
968
+ };
969
+ }
970
+ }
971
+ return undefined;
1063
972
  };
1064
973
 
1065
- const translateMatrix = (x = 0, y = 0, z = 0) => {
1066
- const m = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ x, y, z, 1 ] ];
1067
- return m;
974
+ const extractOccurence = occurence => {
975
+ if (!occurence) {
976
+ return 0;
977
+ }
978
+ const occurenceMatch = occurence.match(/\[(\d*)\]/);
979
+ const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
980
+ return occurenceValue;
1068
981
  };
1069
982
 
1070
- var index$d = Object.freeze({
1071
- __proto__: null,
1072
- multiplyMatrices: multiplyMatrices,
1073
- arrayToMatrix: arrayToMatrix,
1074
- matrixToArray: matrixToArray,
1075
- printMatrix: printMatrix,
1076
- rotateXMatrix: rotateXMatrix,
1077
- rotateYMatrix: rotateYMatrix,
1078
- rotateZMatrix: rotateZMatrix,
1079
- translateMatrix: translateMatrix
1080
- });
983
+ const stringInsertInitial = (value, insert) => {
984
+ if (!value.startsWith(insert)) {
985
+ value = insert + value;
986
+ }
987
+ return value;
988
+ };
1081
989
 
1082
- function getMatrixValues(matrix3d) {
1083
- const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
1084
- const matrixValuesInt = [];
1085
- for (let i = 0; i < matrixValues.length; i++) {
1086
- matrixValuesInt[i] = parseFloat(matrixValues[i]);
990
+ const stringRemoveTrailing = (value, trail) => {
991
+ if (value.endsWith(trail)) {
992
+ value = value.slice(0, value.length - trail.length);
1087
993
  }
1088
- return matrixValuesInt;
1089
- }
994
+ return value;
995
+ };
1090
996
 
1091
- function getRotationMatrix(matrix3d) {
1092
- const valuesMatrix = getMatrixValues(matrix3d);
1093
- const scale = getScalationValue(matrix3d);
1094
- if (valuesMatrix.length === 16) {
1095
- for (let i = 0; i < 11; i++) {
1096
- valuesMatrix[i] /= scale;
1097
- }
1098
- } else if (valuesMatrix.length === 6) {
1099
- for (let i = 0; i < 4; i++) {
1100
- valuesMatrix[i] /= scale;
1101
- }
1102
- }
1103
- const rotationMatrix = valuesMatrix;
1104
- return rotationMatrix;
1105
- }
1106
-
1107
- function getTranslationMatrix(matrix3d) {
1108
- const valuesMatrix = getMatrixValues(matrix3d);
1109
- let translationMatrix;
1110
- if (valuesMatrix.length === 16) {
1111
- translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
1112
- } else if (valuesMatrix.length === 6) {
1113
- translationMatrix = getMatrixValues(matrix3d).slice(4);
1114
- }
1115
- return translationMatrix;
1116
- }
1117
-
1118
- function getScalationValue(matrix3d) {
1119
- const valuesMatrix = getMatrixValues(matrix3d);
1120
- let temp = 0;
1121
- let scale;
1122
- if (valuesMatrix.length === 16) {
1123
- const scaleMatrix = getMatrixValues(matrix3d).slice(0, 4);
1124
- scale = 0;
1125
- for (const el of scaleMatrix) {
1126
- scale += parseFloat(el) * parseFloat(el);
1127
- }
1128
- scale = parseFloat(Math.sqrt(scale).toPrecision(4));
1129
- } else if (valuesMatrix.length === 6) {
1130
- temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
1131
- scale = parseFloat(Math.sqrt(temp).toPrecision(4));
1132
- }
1133
- return scale;
1134
- }
997
+ const PATH_SEPARATOR = "/";
1135
998
 
1136
- function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
1137
- const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
1138
- return matrixArrayToCSSMatrix(transformMatrix);
1139
- }
999
+ const cleanupPath = value => {
1000
+ value = stringInsertInitial(value, PATH_SEPARATOR);
1001
+ value = stringRemoveTrailing(value, PATH_SEPARATOR);
1002
+ return value;
1003
+ };
1140
1004
 
1141
- function getTransformRotate(matrix3d) {
1142
- const pi = Math.PI;
1143
- const values = getRotationMatrix(matrix3d);
1144
- let rotateX = 0;
1145
- let rotateY = 0;
1146
- if (values.length === 6) {
1147
- const cosa = values[0];
1148
- const sina = values[1];
1149
- if (cosa === 1 && sina === 0) {
1150
- rotateX = Math.asin(sina);
1151
- rotateY = Math.acos(cosa);
1152
- }
1005
+ const computePlaneAddress = (plane, route, origin = "origin") => {
1006
+ if (origin === "origin" && typeof location !== "undefined") {
1007
+ origin = location.host;
1153
1008
  }
1154
- if (values.length === 16) {
1155
- const cosaX1 = values[5];
1156
- const sinaX3 = values[9];
1157
- if (sinaX3 <= 0) {
1158
- rotateX = Math.acos(cosaX1);
1159
- }
1160
- if (sinaX3 > 0) {
1161
- rotateX = 2 * pi - Math.acos(cosaX1);
1162
- }
1163
- const cosaY1 = values[0];
1164
- const sinaY2 = values[2];
1165
- if (sinaY2 <= 0) {
1166
- rotateY = Math.acos(cosaY1);
1167
- }
1168
- if (sinaY2 > 0) {
1169
- rotateY = 2 * pi - Math.acos(cosaY1);
1170
- }
1171
- rotateX = Math.atan2(values[9], values[5]);
1172
- rotateY = Math.atan2(values[2], values[0]);
1009
+ const cleanPlane = extractPathname(plane);
1010
+ const planeAddressType = checkPlaneAddressType(cleanPlane);
1011
+ switch (planeAddressType) {
1012
+ case "http":
1013
+ case "https":
1014
+ case "pttp":
1015
+ return cleanPlane;
1173
1016
  }
1174
- return {
1175
- rotateX: rotateX,
1176
- rotateY: rotateY,
1177
- rotateZ: 0
1178
- };
1179
- }
1180
-
1181
- function getTransformTranslate(matrix3d) {
1182
- const values = getTranslationMatrix(matrix3d);
1183
- const translateX = values[0];
1184
- const translateY = values[1];
1185
- const translateZ = values[2];
1186
- return {
1187
- translateX: translateX,
1188
- translateY: translateY,
1189
- translateZ: translateZ
1190
- };
1191
- }
1017
+ origin = stringRemoveTrailing(origin, "/");
1018
+ const absolutePlane = isAbsolutePlane(plane);
1019
+ const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
1020
+ const planeAddress = protocols.plurid + origin + path;
1021
+ return planeAddress;
1022
+ };
1192
1023
 
1193
- function getTransformScale(matrix3d) {
1194
- const scale = getScalationValue(matrix3d);
1195
- return {
1196
- scale: scale
1197
- };
1198
- }
1024
+ const isAbsolutePlane = value => value[0] === "/";
1199
1025
 
1200
- function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
1201
- const transformRotate = getTransformRotate(matrix3d);
1202
- const rotateX = transformRotate.rotateX;
1203
- let rotateY = transformRotate.rotateY;
1204
- const rotateZ = transformRotate.rotateZ;
1205
- const transformTranslate = getTransformTranslate(matrix3d);
1206
- const translateX = transformTranslate.translateX;
1207
- const translateY = transformTranslate.translateY;
1208
- const translateZ = transformTranslate.translateZ;
1209
- const scale = getTransformScale(matrix3d).scale;
1210
- let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1211
- const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1212
- const valScalationMatrix = scaleMatrix(scale);
1213
- if (direction === "left") {
1214
- rotateY -= angleIncrement;
1215
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1026
+ const checkPlaneAddressType = value => {
1027
+ value = value.toLowerCase().trim();
1028
+ if (value.startsWith(protocols.plurid)) {
1029
+ return "pttp";
1216
1030
  }
1217
- if (direction === "right") {
1218
- rotateY += angleIncrement;
1219
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1031
+ if (value.startsWith(protocols.https)) {
1032
+ return HTTPS_PROTOCOL;
1220
1033
  }
1221
- if (direction === "up") {
1222
- rotateY -= angleIncrement;
1223
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1034
+ if (value.startsWith(protocols.http)) {
1035
+ return HTTP_PROTOCOL;
1224
1036
  }
1225
- if (direction === "down") {
1226
- rotateY += angleIncrement;
1227
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1037
+ return "relative";
1038
+ };
1039
+
1040
+ const removeTrailingSlash = value => {
1041
+ if (value.endsWith("/") && value.length > 1) {
1042
+ return value.slice(0, value.length - 1);
1228
1043
  }
1229
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1230
- return transformedMatrix3d;
1231
- }
1044
+ return value;
1045
+ };
1232
1046
 
1233
- function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
1234
- const transformRotate = getTransformRotate(matrix3d);
1235
- const rotateX = transformRotate.rotateX;
1236
- const rotateY = transformRotate.rotateY;
1237
- const rotateZ = transformRotate.rotateZ;
1238
- const transformTranslate = getTransformTranslate(matrix3d);
1239
- let translateX = transformTranslate.translateX;
1240
- let translateY = transformTranslate.translateY;
1241
- const translateZ = transformTranslate.translateZ;
1242
- const scale = getTransformScale(matrix3d).scale;
1243
- const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1244
- let valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1245
- const valScalationMatrix = scaleMatrix(scale);
1246
- scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
1247
- if (direction === "left") {
1248
- translateX += linearIncrement;
1249
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1047
+ const cleanPathValue = value => {
1048
+ const queryStart = value.indexOf("?");
1049
+ if (queryStart < 0) {
1050
+ return removeTrailingSlash(value);
1250
1051
  }
1251
- if (direction === "right") {
1252
- translateX -= linearIncrement;
1253
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1052
+ return removeTrailingSlash(value.substring(0, queryStart));
1053
+ };
1054
+
1055
+ const checkParameterLength = (parameter, length, compareType) => {
1056
+ const parameterLength = parameter.length;
1057
+ switch (compareType) {
1058
+ case compareTypes.equal:
1059
+ return parameterLength === length;
1060
+
1061
+ case compareTypes.equalLessThan:
1062
+ return parameterLength <= length;
1063
+
1064
+ case compareTypes.lessThan:
1065
+ return parameterLength < length;
1066
+
1067
+ case compareTypes.equalGreaterThan:
1068
+ return parameterLength >= length;
1069
+
1070
+ case compareTypes.greaterThan:
1071
+ return parameterLength > length;
1072
+
1073
+ default:
1074
+ return parameterLength <= length;
1254
1075
  }
1255
- if (direction === "up") {
1256
- translateY += linearIncrement;
1257
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1076
+ };
1077
+
1078
+ const checkValidPath = (validationParameters, parameters) => {
1079
+ if (validationParameters) {
1080
+ for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
1081
+ const {length: length, lengthType: lengthType, startsWith: startsWith, endsWith: endsWith, includes: includes} = parameterData;
1082
+ const paramaterValue = parameters[parameterKey];
1083
+ if (!paramaterValue) {
1084
+ return false;
1085
+ }
1086
+ if (startsWith && !paramaterValue.startsWith(startsWith)) {
1087
+ return false;
1088
+ }
1089
+ if (endsWith && !paramaterValue.endsWith(endsWith)) {
1090
+ return false;
1091
+ }
1092
+ if (includes && !includes.includes(paramaterValue)) {
1093
+ return false;
1094
+ }
1095
+ if (length) {
1096
+ const validLength = checkParameterLength(paramaterValue, length, lengthType);
1097
+ return validLength;
1098
+ }
1099
+ }
1258
1100
  }
1259
- if (direction === "down") {
1260
- translateY -= linearIncrement;
1261
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1101
+ return true;
1102
+ };
1103
+
1104
+ const cleanPathElement = path => {
1105
+ if (path[0] === "/") {
1106
+ return path.slice(1);
1262
1107
  }
1263
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1264
- return transformedMatrix3d;
1265
- }
1108
+ return path;
1109
+ };
1266
1110
 
1267
- function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
1268
- const transformRotate = getTransformRotate(matrix3d);
1269
- const rotateX = transformRotate.rotateX;
1270
- const rotateY = transformRotate.rotateY;
1271
- const rotateZ = transformRotate.rotateZ;
1272
- const transformTranslate = getTransformTranslate(matrix3d);
1273
- const translateX = transformTranslate.translateX;
1274
- const translateY = transformTranslate.translateY;
1275
- const translateZ = transformTranslate.translateZ;
1276
- let scale = getTransformScale(matrix3d).scale;
1277
- const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1278
- const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1279
- let valScalationMatrix = scaleMatrix(scale);
1280
- if (direction === "up") {
1281
- scale -= scaleIncrement;
1282
- if (scale < .1) {
1283
- scale = .1;
1111
+ var index$a = Object.freeze({
1112
+ __proto__: null,
1113
+ cleanPathElement: cleanPathElement
1114
+ });
1115
+
1116
+ const mapPathsToRoutes = (paths, view) => {
1117
+ const routes = [];
1118
+ for (const [key, path] of Object.entries(paths)) {
1119
+ const pathView = view[key];
1120
+ if (pathView) {
1121
+ const route = {
1122
+ value: ""
1123
+ };
1124
+ routes.push(route);
1284
1125
  }
1285
- valScalationMatrix = scaleMatrix(scale);
1286
1126
  }
1287
- if (direction === "down") {
1288
- scale += scaleIncrement;
1289
- if (scale > 4) {
1290
- scale = 4;
1127
+ return routes;
1128
+ };
1129
+
1130
+ const pluridLinkPathDivider = route => {
1131
+ const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
1132
+ const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
1133
+ const split = route.split("://").filter((value => value !== "")).map((value => cleanPathElement(value)));
1134
+ let protocol = windowProtocol;
1135
+ const host = {
1136
+ value: windowHost,
1137
+ controlled: false
1138
+ };
1139
+ const path = {
1140
+ value: "",
1141
+ parameters: {},
1142
+ query: {}
1143
+ };
1144
+ const space = {
1145
+ value: "",
1146
+ parameters: {},
1147
+ query: {}
1148
+ };
1149
+ const universe = {
1150
+ value: "",
1151
+ parameters: {},
1152
+ query: {}
1153
+ };
1154
+ const cluster = {
1155
+ value: "",
1156
+ parameters: {},
1157
+ query: {}
1158
+ };
1159
+ const plane = {
1160
+ value: "",
1161
+ parameters: {},
1162
+ query: {},
1163
+ fragments: {
1164
+ texts: [],
1165
+ elements: []
1291
1166
  }
1292
- valScalationMatrix = scaleMatrix(scale);
1167
+ };
1168
+ const valid = false;
1169
+ if (split.length === 0 || split.length > 7) {
1170
+ const url = {
1171
+ protocol: {
1172
+ value: protocol,
1173
+ secure: true
1174
+ },
1175
+ host: host,
1176
+ path: path,
1177
+ space: space,
1178
+ universe: universe,
1179
+ cluster: cluster,
1180
+ plane: plane,
1181
+ valid: valid
1182
+ };
1183
+ return url;
1184
+ }
1185
+ if (route.startsWith("/://")) {
1186
+ const routeSplit = split.slice(1);
1187
+ switch (routeSplit.length) {
1188
+ case 1:
1189
+ path.value = routeSplit[0];
1190
+ break;
1191
+
1192
+ case 5:
1193
+ path.value = routeSplit[0];
1194
+ space.value = routeSplit[1];
1195
+ universe.value = routeSplit[2];
1196
+ cluster.value = routeSplit[3];
1197
+ plane.value = routeSplit[4];
1198
+ break;
1199
+ }
1200
+ const url = {
1201
+ protocol: {
1202
+ value: protocol,
1203
+ secure: true
1204
+ },
1205
+ host: host,
1206
+ path: path,
1207
+ space: space,
1208
+ universe: universe,
1209
+ cluster: cluster,
1210
+ plane: plane,
1211
+ valid: true
1212
+ };
1213
+ return url;
1293
1214
  }
1294
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1295
- return transformedMatrix3d;
1296
- }
1215
+ if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
1216
+ switch (split.length) {
1217
+ case 1:
1218
+ plane.value = split[0];
1219
+ break;
1297
1220
 
1298
- var index$c = Object.freeze({
1299
- __proto__: null,
1300
- getMatrixValues: getMatrixValues,
1301
- getRotationMatrix: getRotationMatrix,
1302
- getTranslationMatrix: getTranslationMatrix,
1303
- getScalationValue: getScalationValue,
1304
- setTransform: setTransform,
1305
- getTransformRotate: getTransformRotate,
1306
- getTransformTranslate: getTransformTranslate,
1307
- getTransformScale: getTransformScale,
1308
- rotatePlurid: rotatePlurid,
1309
- translatePlurid: translatePlurid,
1310
- scalePlurid: scalePlurid
1311
- });
1221
+ case 2:
1222
+ cluster.value = split[0];
1223
+ plane.value = split[1];
1224
+ break;
1312
1225
 
1313
- var index$b = Object.freeze({
1314
- __proto__: null,
1315
- general: index$d,
1316
- matrix3d: index$c
1317
- });
1226
+ case 3:
1227
+ universe.value = split[0];
1228
+ cluster.value = split[1];
1229
+ plane.value = split[2];
1230
+ break;
1318
1231
 
1319
- var index$a = Object.freeze({
1320
- __proto__: null,
1321
- direction: index$g,
1322
- matrix: index$e,
1323
- quaternion: index$f,
1324
- transform: index$b
1325
- });
1232
+ case 4:
1233
+ space.value = split[0];
1234
+ universe.value = split[1];
1235
+ cluster.value = split[2];
1236
+ plane.value = split[3];
1237
+ break;
1326
1238
 
1327
- const internatiolate = (lamguage, field) => internationalization[lamguage][field];
1239
+ case 5:
1240
+ path.value = split[0];
1241
+ space.value = split[1];
1242
+ universe.value = split[2];
1243
+ cluster.value = split[3];
1244
+ plane.value = split[4];
1245
+ break;
1328
1246
 
1329
- const resolvePluridPlaneData = plane => {
1330
- if (Array.isArray(plane)) {
1331
- const [route, component, options] = plane;
1332
- return Object.assign({
1333
- route: route,
1334
- component: component
1335
- }, options);
1336
- }
1337
- return plane;
1338
- };
1247
+ case 6:
1248
+ host.value = split[0];
1249
+ path.value = split[1];
1250
+ space.value = split[2];
1251
+ universe.value = split[3];
1252
+ cluster.value = split[4];
1253
+ plane.value = split[5];
1254
+ break;
1339
1255
 
1340
- const resolvePluridRoutePlaneData = plane => {
1341
- if (Array.isArray(plane)) {
1342
- const [value, component, options] = plane;
1343
- return Object.assign({
1344
- value: value,
1345
- component: component
1346
- }, options);
1347
- }
1348
- return plane;
1349
- };
1256
+ default:
1257
+ const url = {
1258
+ protocol: {
1259
+ value: protocol,
1260
+ secure: true
1261
+ },
1262
+ host: host,
1263
+ path: path,
1264
+ space: space,
1265
+ universe: universe,
1266
+ cluster: cluster,
1267
+ plane: plane,
1268
+ valid: valid
1269
+ };
1270
+ return url;
1271
+ }
1272
+ } else {
1273
+ switch (split.length) {
1274
+ case 3:
1275
+ protocol = split[0];
1276
+ host.value = split[1];
1277
+ path.value = split[2];
1278
+ break;
1350
1279
 
1351
- const createInternalStatePlane = plane => {
1352
- const planeData = resolvePluridPlaneData(plane);
1353
- const statePlane = {
1354
- id: uuid.generate(),
1355
- path: planeData.route
1356
- };
1357
- return statePlane;
1358
- };
1280
+ case 7:
1281
+ protocol = split[0];
1282
+ host.value = split[1];
1283
+ path.value = split[2];
1284
+ space.value = split[3];
1285
+ universe.value = split[4];
1286
+ cluster.value = split[5];
1287
+ plane.value = split[6];
1288
+ break;
1359
1289
 
1360
- const createInternalContextPlane = plane => {
1361
- const planeData = resolvePluridPlaneData(plane);
1362
- const {route: route, component: component} = planeData;
1363
- const contextPlane = {
1364
- id: uuid.generate(),
1365
- path: route,
1366
- component: component
1290
+ default:
1291
+ const url = {
1292
+ protocol: {
1293
+ value: protocol,
1294
+ secure: true
1295
+ },
1296
+ host: host,
1297
+ path: path,
1298
+ space: space,
1299
+ universe: universe,
1300
+ cluster: cluster,
1301
+ plane: plane,
1302
+ valid: valid
1303
+ };
1304
+ return url;
1305
+ }
1306
+ }
1307
+ const url = {
1308
+ protocol: {
1309
+ value: protocol,
1310
+ secure: true
1311
+ },
1312
+ host: host,
1313
+ path: path,
1314
+ space: space,
1315
+ universe: universe,
1316
+ cluster: cluster,
1317
+ plane: plane,
1318
+ valid: true
1367
1319
  };
1368
- return contextPlane;
1320
+ return url;
1369
1321
  };
1370
1322
 
1371
- const getPluridPlaneIDByData = element => {
1372
- if (!element) {
1373
- return "";
1374
- }
1375
- const parent = element.parentElement;
1376
- if (parent && parent.dataset.pluridPlane) {
1377
- return parent.dataset.pluridPlane;
1323
+ const resolveRoute = (route, protocol, host) => {
1324
+ const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
1325
+ const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
1326
+ const divisions = pluridLinkPathDivider(route);
1327
+ const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
1328
+ const protocolDivision = divisions.protocol.value || windowProtocol;
1329
+ const hostDivision = divisions.host.value ? divisions.host : {
1330
+ value: windowHost,
1331
+ controlled: true
1332
+ };
1333
+ const path = divisions.path.value ? divisions.path : {
1334
+ value: defaultPathname,
1335
+ parameters: {},
1336
+ query: {}
1337
+ };
1338
+ const space = divisions.space.value ? divisions.space : {
1339
+ value: "s",
1340
+ parameters: {},
1341
+ query: {}
1342
+ };
1343
+ const universe = divisions.universe.value ? divisions.universe : {
1344
+ value: "u",
1345
+ parameters: {},
1346
+ query: {}
1347
+ };
1348
+ const cluster = divisions.cluster.value ? divisions.cluster : {
1349
+ value: "c",
1350
+ parameters: {},
1351
+ query: {}
1352
+ };
1353
+ const plane = divisions.plane;
1354
+ const separator = "://";
1355
+ if (!plane.value && route !== "/") {
1356
+ const resolvers = [ protocolDivision, hostDivision.value, path.value ];
1357
+ const absoluteRoute = resolvers.join(separator);
1358
+ return {
1359
+ protocol: protocolDivision,
1360
+ host: hostDivision,
1361
+ path: path,
1362
+ space: space,
1363
+ universe: universe,
1364
+ cluster: cluster,
1365
+ plane: plane,
1366
+ route: absoluteRoute
1367
+ };
1378
1368
  }
1379
- return getPluridPlaneIDByData(parent);
1369
+ [ protocolDivision, hostDivision.value, path.value, space.value, universe.value, cluster.value, cleanPathElement(plane.value) ];
1370
+ return {
1371
+ protocol: "",
1372
+ host: "",
1373
+ path: path,
1374
+ space: "",
1375
+ universe: "",
1376
+ cluster: "",
1377
+ plane: "",
1378
+ route: route
1379
+ };
1380
1380
  };
1381
1381
 
1382
1382
  class IsoMatcher {
@@ -1664,10 +1664,10 @@ var index$9 = Object.freeze({
1664
1664
  });
1665
1665
 
1666
1666
  class PluridPlanesRegistrar {
1667
- constructor(planes) {
1667
+ constructor(planes, origin = "origin") {
1668
1668
  this.isoMatcher = new IsoMatcher({
1669
1669
  planes: planes
1670
- });
1670
+ }, origin);
1671
1671
  }
1672
1672
  register(planes) {
1673
1673
  this.isoMatcher.index({
@@ -1718,7 +1718,7 @@ class PluridPlanesRegistrar {
1718
1718
  }
1719
1719
  }
1720
1720
 
1721
- const registerPlanes = (planes, planesRegistrar) => {
1721
+ const registerPlanes = (planes, planesRegistrar, origin = "origin") => {
1722
1722
  if (!planes) {
1723
1723
  return;
1724
1724
  }
@@ -1730,7 +1730,7 @@ const registerPlanes = (planes, planesRegistrar) => {
1730
1730
  return;
1731
1731
  }
1732
1732
  if (typeof window.__pluridPlanesRegistrar__ === "undefined") {
1733
- const pluridPlanesRegistrar = new PluridPlanesRegistrar;
1733
+ const pluridPlanesRegistrar = new PluridPlanesRegistrar([], origin);
1734
1734
  window.__pluridPlanesRegistrar__ = pluridPlanesRegistrar;
1735
1735
  window.__pluridPlanesRegistrar__.register(planes);
1736
1736
  return;
@@ -1779,8 +1779,6 @@ var index$8 = Object.freeze({
1779
1779
  __proto__: null,
1780
1780
  resolvePluridPlaneData: resolvePluridPlaneData,
1781
1781
  resolvePluridRoutePlaneData: resolvePluridRoutePlaneData,
1782
- createInternalStatePlane: createInternalStatePlane,
1783
- createInternalContextPlane: createInternalContextPlane,
1784
1782
  getPluridPlaneIDByData: getPluridPlaneIDByData,
1785
1783
  registerPlanes: registerPlanes,
1786
1784
  getPlanesRegistrar: getPlanesRegistrar,
@@ -2110,10 +2108,10 @@ var index$5 = Object.freeze({
2110
2108
  computeZigZagLayout: computeZigZagLayout
2111
2109
  });
2112
2110
 
2113
- const resolveViewItem = (planes, view, configuration) => {
2111
+ const resolveViewItem = (planes, view, configuration, origin = "origin") => {
2114
2112
  const {protocol: protocol, host: host} = configuration.network;
2115
2113
  const viewData = typeof view === "string" ? view : view.plane;
2116
- const viewAddress = computePlaneAddress(viewData);
2114
+ const viewAddress = computePlaneAddress(viewData, undefined, origin);
2117
2115
  const iPlanes = planes.values();
2118
2116
  const pluridPlanes = [];
2119
2117
  for (const iPlane of iPlanes) {
@@ -2125,7 +2123,7 @@ const resolveViewItem = (planes, view, configuration) => {
2125
2123
  }
2126
2124
  const isoMatcher = new IsoMatcher({
2127
2125
  planes: pluridPlanes
2128
- });
2126
+ }, origin);
2129
2127
  const match = isoMatcher.match(viewData);
2130
2128
  if (match) {
2131
2129
  const route = match.match.value;
@@ -2189,10 +2187,10 @@ const resolveViewItem = (planes, view, configuration) => {
2189
2187
  return;
2190
2188
  };
2191
2189
 
2192
- const computeSpaceTree = (planes, view, configuration) => {
2190
+ const computeSpaceTree = (planes, view, configuration, origin = "origin") => {
2193
2191
  const treePlanes = [];
2194
2192
  for (const viewItem of view) {
2195
- const treePlane = resolveViewItem(planes, viewItem, configuration);
2193
+ const treePlane = resolveViewItem(planes, viewItem, configuration, origin);
2196
2194
  if (treePlane) {
2197
2195
  treePlanes.push(treePlane);
2198
2196
  }
@@ -2276,14 +2274,14 @@ const assignPagesFromView = (planes, view) => {
2276
2274
  return tree;
2277
2275
  };
2278
2276
 
2279
- const updateTreePlane = (tree, updatedPage) => {
2277
+ const updateTreePlane = (tree, updatedPlane) => {
2280
2278
  const updatedTree = tree.map((treePlane => {
2281
- if (treePlane.planeID === updatedPage.planeID) {
2282
- return updatedPage;
2279
+ if (treePlane.planeID === updatedPlane.planeID) {
2280
+ return updatedPlane;
2283
2281
  }
2284
2282
  if (treePlane.children) {
2285
- const pageTree = updateTreePlane(treePlane.children, updatedPage);
2286
- treePlane.children = pageTree;
2283
+ const children = updateTreePlane(treePlane.children, updatedPlane);
2284
+ treePlane.children = children;
2287
2285
  return treePlane;
2288
2286
  }
2289
2287
  return treePlane;
@@ -2291,7 +2289,7 @@ const updateTreePlane = (tree, updatedPage) => {
2291
2289
  return updatedTree;
2292
2290
  };
2293
2291
 
2294
- const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration) => {
2292
+ const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration, hostname = "origin") => {
2295
2293
  const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2296
2294
  if (!parentPlane) {
2297
2295
  return {
@@ -2300,7 +2298,7 @@ const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree
2300
2298
  };
2301
2299
  }
2302
2300
  const location = computePluridPlaneLocation(linkCoordinates, parentPlane);
2303
- const treePlane = resolveViewItem(planesRegistry, planeRoute, configuration);
2301
+ const treePlane = resolveViewItem(planesRegistry, planeRoute, configuration, hostname);
2304
2302
  if (!treePlane) {
2305
2303
  return {
2306
2304
  pluridPlaneID: "",
@@ -2334,6 +2332,24 @@ const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree
2334
2332
  };
2335
2333
  };
2336
2334
 
2335
+ const updatePlaneLocation = (tree, parentPlaneID, planeID, linkCoordinates) => {
2336
+ const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2337
+ const plane = getTreePlaneByPlaneID(tree, planeID);
2338
+ if (!parentPlane || !plane) {
2339
+ return tree;
2340
+ }
2341
+ const location = computePluridPlaneLocation(linkCoordinates, parentPlane);
2342
+ plane.location = {
2343
+ translateX: location.x,
2344
+ translateY: location.y,
2345
+ translateZ: location.z,
2346
+ rotateX: 0,
2347
+ rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
2348
+ };
2349
+ const updatedTree = updateTreePlane(tree, plane);
2350
+ return updatedTree;
2351
+ };
2352
+
2337
2353
  const updateTreeWithNewPage = (tree, treePageParentPlaneID, pagePath, pageID, linkCoordinates, parameters) => {
2338
2354
  const treePageParent = getTreePlaneByPlaneID(tree, treePageParentPlaneID);
2339
2355
  if (treePageParent) {
@@ -2448,21 +2464,35 @@ const toggleChildren = children => {
2448
2464
  return updatedChildren;
2449
2465
  };
2450
2466
 
2451
- const togglePlaneFromTree = (tree, pluridPlaneID) => {
2467
+ const toggleAllChildren = (tree, show) => {
2468
+ for (const plane of tree) {
2469
+ if (plane.children) {
2470
+ plane.children = toggleAllChildren(plane.children, show);
2471
+ }
2472
+ plane.show = show;
2473
+ }
2474
+ return tree;
2475
+ };
2476
+
2477
+ const togglePlaneFromTree = (tree, pluridPlaneID, forceShow) => {
2452
2478
  const updatedTree = [];
2453
2479
  let updatedPlane;
2454
2480
  for (const plane of tree) {
2455
2481
  if (plane.planeID === pluridPlaneID) {
2482
+ const show = forceShow !== null && forceShow !== void 0 ? forceShow : !plane.show;
2456
2483
  const treeUpdatedPlane = Object.assign(Object.assign({}, plane), {
2457
- show: !plane.show,
2458
- children: []
2484
+ show: show
2459
2485
  });
2486
+ if (treeUpdatedPlane.children) {
2487
+ const children = toggleAllChildren(treeUpdatedPlane.children, show);
2488
+ treeUpdatedPlane.children = children;
2489
+ }
2460
2490
  updatedTree.push(treeUpdatedPlane);
2461
2491
  updatedPlane = Object.assign({}, treeUpdatedPlane);
2462
2492
  continue;
2463
2493
  }
2464
2494
  if (plane.children) {
2465
- const {updatedTree: childrenUpdatedTree, updatedPlane: childrenUpdatedPlane} = togglePlaneFromTree(plane.children, pluridPlaneID);
2495
+ const {updatedTree: childrenUpdatedTree, updatedPlane: childrenUpdatedPlane} = togglePlaneFromTree(plane.children, pluridPlaneID, forceShow);
2466
2496
  plane.children = [ ...childrenUpdatedTree ];
2467
2497
  updatedTree.push(plane);
2468
2498
  if (childrenUpdatedPlane) {
@@ -2478,6 +2508,46 @@ const togglePlaneFromTree = (tree, pluridPlaneID) => {
2478
2508
  };
2479
2509
  };
2480
2510
 
2511
+ const getTreePlaneByID = (stateTree, id) => {
2512
+ if (!id) {
2513
+ return;
2514
+ }
2515
+ for (const plane of stateTree) {
2516
+ if (plane.planeID === id) {
2517
+ return plane;
2518
+ }
2519
+ if (plane.children) {
2520
+ const found = getTreePlaneByID(plane.children, id);
2521
+ if (found) {
2522
+ return found;
2523
+ }
2524
+ }
2525
+ }
2526
+ return;
2527
+ };
2528
+
2529
+ const removeRootFromTree = (tree, pluridPlaneID) => {
2530
+ const updatedTree = tree.filter((plane => plane.planeID !== pluridPlaneID));
2531
+ return {
2532
+ updatedTree: updatedTree
2533
+ };
2534
+ };
2535
+
2536
+ const removePlaneFromTree = (tree, pluridPlaneID) => {
2537
+ const updatedTree = [];
2538
+ for (const plane of tree) {
2539
+ if (plane.planeID === pluridPlaneID) {
2540
+ continue;
2541
+ }
2542
+ if (plane.children) {
2543
+ const children = removePlaneFromTree(plane.children, pluridPlaneID);
2544
+ plane.children = children;
2545
+ }
2546
+ updatedTree.push(plane);
2547
+ }
2548
+ return updatedTree;
2549
+ };
2550
+
2481
2551
  var logic = Object.freeze({
2482
2552
  __proto__: null,
2483
2553
  resolveViewItem: resolveViewItem,
@@ -2487,19 +2557,25 @@ var logic = Object.freeze({
2487
2557
  assignPagesFromView: assignPagesFromView,
2488
2558
  updateTreePlane: updateTreePlane,
2489
2559
  updateTreeWithNewPlane: updateTreeWithNewPlane,
2560
+ updatePlaneLocation: updatePlaneLocation,
2490
2561
  updateTreeWithNewPage: updateTreeWithNewPage,
2491
2562
  removePageFromTree: removePageFromTree,
2492
2563
  toggleChildren: toggleChildren,
2493
- togglePlaneFromTree: togglePlaneFromTree
2564
+ toggleAllChildren: toggleAllChildren,
2565
+ togglePlaneFromTree: togglePlaneFromTree,
2566
+ getTreePlaneByID: getTreePlaneByID,
2567
+ removeRootFromTree: removeRootFromTree,
2568
+ removePlaneFromTree: removePlaneFromTree
2494
2569
  });
2495
2570
 
2496
2571
  class Tree {
2497
- constructor(data) {
2572
+ constructor(data, origin = "origin") {
2498
2573
  this.data = data;
2574
+ this.origin = origin;
2499
2575
  }
2500
2576
  compute() {
2501
2577
  const {planes: planes, view: view, configuration: configuration} = this.data;
2502
- return computeSpaceTree(planes, view, configuration);
2578
+ return computeSpaceTree(planes, view, configuration, this.origin);
2503
2579
  }
2504
2580
  }
2505
2581
 
@@ -2567,15 +2643,15 @@ var index$2 = Object.freeze({
2567
2643
  view: index$3
2568
2644
  });
2569
2645
 
2570
- const resolveSpace = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState) => {
2646
+ const resolveSpace = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
2571
2647
  const registeredPlanes = getRegisteredPlanes(planesRegistrar);
2572
2648
  const spaceTree = new Tree({
2573
2649
  planes: registeredPlanes,
2574
2650
  configuration: configuration,
2575
2651
  view: view
2576
- });
2652
+ }, hostname);
2577
2653
  const computedTree = spaceTree.compute();
2578
- const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2654
+ const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign({
2579
2655
  loading: true,
2580
2656
  animatedTransform: false,
2581
2657
  transformTime: 450,
@@ -2605,12 +2681,10 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2605
2681
  z: 0
2606
2682
  }
2607
2683
  },
2608
- culledView: []
2609
- }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.space), contextState === null || contextState === void 0 ? void 0 : contextState.space), localState === null || localState === void 0 ? void 0 : localState.space), currentState === null || currentState === void 0 ? void 0 : currentState.space), {
2684
+ culledView: [],
2610
2685
  view: view,
2611
- initialTree: computedTree,
2612
2686
  tree: computedTree
2613
- });
2687
+ }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.space), contextState === null || contextState === void 0 ? void 0 : contextState.space), localState === null || localState === void 0 ? void 0 : localState.space), currentState === null || currentState === void 0 ? void 0 : currentState.space);
2614
2688
  if (currentState) {
2615
2689
  stateSpace.translationX = currentState.space.translationX;
2616
2690
  stateSpace.translationY = currentState.space.translationY;
@@ -2658,10 +2732,15 @@ const resolveThemes = (configuration, precomputedState) => {
2658
2732
  return stateThemes;
2659
2733
  };
2660
2734
 
2661
- const compute = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState) => {
2662
- const specifiedConfiguration = merge(configuration);
2663
- const stateConfiguration = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, specifiedConfiguration), precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.configuration), contextState === null || contextState === void 0 ? void 0 : contextState.configuration), localState === null || localState === void 0 ? void 0 : localState.configuration), currentState === null || currentState === void 0 ? void 0 : currentState.configuration);
2664
- const stateSpace = resolveSpace(view, stateConfiguration, planesRegistrar, currentState, localState, precomputedState, contextState);
2735
+ const compute = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname = "origin") => {
2736
+ let stateConfiguration = merge(configuration);
2737
+ const configurations = [ precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.configuration, contextState === null || contextState === void 0 ? void 0 : contextState.configuration, localState === null || localState === void 0 ? void 0 : localState.configuration, currentState === null || currentState === void 0 ? void 0 : currentState.configuration ];
2738
+ for (const configuration of configurations) {
2739
+ if (configuration) {
2740
+ stateConfiguration = merge(configuration);
2741
+ }
2742
+ }
2743
+ const stateSpace = resolveSpace(view, stateConfiguration, planesRegistrar, currentState, localState, precomputedState, contextState, hostname);
2665
2744
  const stateThemes = resolveThemes(stateConfiguration, precomputedState);
2666
2745
  const state = {
2667
2746
  configuration: Object.assign({}, stateConfiguration),
@@ -2722,5 +2801,5 @@ const pluridRouterNavigate = path => {
2722
2801
  window.dispatchEvent(event);
2723
2802
  };
2724
2803
 
2725
- export { cleanTemplate, index$h as general, index$a as interaction, internatiolate, index$8 as planes, pluridRouterNavigate, index$9 as routing, index$2 as space, index as state, index$j as utilities };
2804
+ export { cleanTemplate, index$i as general, index$b as interaction, internatiolate, index$8 as planes, pluridRouterNavigate, index$9 as routing, index$2 as space, index as state, index$a as utilities };
2726
2805
  //# sourceMappingURL=index.es.js.map