@plurid/plurid-engine 0.0.0-15 → 0.0.0-18

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,4 +1,4 @@
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";
1
+ import { defaultConfiguration, protocols, HTTPS_PROTOCOL, HTTP_PROTOCOL, compareTypes, internationalization, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from "@plurid/plurid-data";
2
2
 
3
3
  import { objects, mathematics, uuid } from "@plurid/plurid-functions";
4
4
 
@@ -46,1337 +46,1337 @@ var index$k = Object.freeze({
46
46
  merge: merge
47
47
  });
48
48
 
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
- });
49
+ const extractPathname = location => {
50
+ const queryIndex = location.indexOf("?");
51
+ const noQueryPath = queryIndex === -1 ? location : location.substring(0, queryIndex);
52
+ const fragmentIndex = noQueryPath.indexOf("#:~:");
53
+ const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
54
+ return noFragmentPath;
55
+ };
56
+
57
+ const extractParametersAndMatch = (location, route) => {
58
+ const routeElements = splitPath(route);
59
+ const parameters = [];
60
+ routeElements.forEach((routeElement => {
61
+ if (routeElement[0] === ":") {
62
+ parameters.push(routeElement);
63
+ } else {
64
+ parameters.push("");
58
65
  }
59
- return treePlane;
60
66
  }));
61
- return updatedTree;
67
+ const {locationElements: locationElements, comparingPath: comparingPath} = computeComparingPath(location, parameters);
68
+ if (comparingPath !== route) {
69
+ return {
70
+ match: false,
71
+ parameters: {},
72
+ elements: locationElements
73
+ };
74
+ }
75
+ const parametersValues = extractParametersValues(parameters, locationElements);
76
+ return {
77
+ match: true,
78
+ parameters: parametersValues,
79
+ elements: locationElements
80
+ };
62
81
  };
63
82
 
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;
83
+ const extractParametersValues = (parameters, pathElements) => {
84
+ const parametersValues = {};
85
+ parameters.forEach(((parameter, index) => {
86
+ if (parameter) {
87
+ const parameterKey = parameter.slice(1);
88
+ parametersValues[parameterKey] = pathElements[index];
78
89
  }
79
- return treePlane;
80
90
  }));
81
- return updatedTree;
91
+ return parametersValues;
82
92
  };
83
93
 
84
- var index$j = Object.freeze({
85
- __proto__: null,
86
- updateTreePlane: updateTreePlane$1,
87
- updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
88
- });
94
+ const computeComparingPath = (path, parameters) => {
95
+ const pathname = extractPathname(path);
96
+ const locationElements = splitPath(pathname);
97
+ const comparingPathElements = [ ...locationElements ];
98
+ for (const index of locationElements.keys()) {
99
+ if (parameters[index]) {
100
+ comparingPathElements[index] = parameters[index];
101
+ }
102
+ }
103
+ const comparingPath = comparingPathElements.join("/");
104
+ return {
105
+ locationElements: locationElements,
106
+ comparingPath: comparingPath
107
+ };
108
+ };
89
109
 
90
- var index$i = Object.freeze({
91
- __proto__: null,
92
- configuration: index$k,
93
- tree: index$j
94
- });
110
+ const splitPath = path => path.split("/").filter((i => i !== ""));
95
111
 
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";
112
+ const extractQuery = path => {
113
+ const fragmentIndex = path.indexOf("#:~:");
114
+ const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
115
+ const querySplit = noFragmentPath.split("?");
116
+ if (querySplit.length === 2) {
117
+ const queryValues = {};
118
+ const query = querySplit[1];
119
+ const queryItems = query.split("&");
120
+ for (const item of queryItems) {
121
+ const queryValue = item.split("=");
122
+ const id = queryValue[0];
123
+ const value = decodeURIComponent(queryValue[1]);
124
+ queryValues[id] = value;
125
+ }
126
+ return queryValues;
127
+ } else {
128
+ return {};
104
129
  }
105
- if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
106
- direction = "right";
130
+ };
131
+
132
+ const extractFragments = location => {
133
+ if (!location) {
134
+ return {
135
+ texts: [],
136
+ elements: []
137
+ };
107
138
  }
108
- if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
109
- direction = "up";
139
+ const split = location.split("#:~:");
140
+ const fragmentsValues = split[1];
141
+ if (!fragmentsValues) {
142
+ return {
143
+ texts: [],
144
+ elements: []
145
+ };
110
146
  }
111
- if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
112
- direction = "down";
147
+ const fragmentItems = fragmentsValues.split("&");
148
+ const textFragments = [];
149
+ const elementFragments = [];
150
+ for (const item of fragmentItems) {
151
+ const parsedFragment = parseFragment(item);
152
+ if (parsedFragment) {
153
+ switch (parsedFragment.type) {
154
+ case "text":
155
+ textFragments.push(parsedFragment);
156
+ break;
157
+
158
+ case "element":
159
+ elementFragments.push(parsedFragment);
160
+ break;
161
+ }
162
+ }
113
163
  }
114
- return direction;
164
+ return {
165
+ texts: textFragments,
166
+ elements: elementFragments
167
+ };
115
168
  };
116
169
 
117
- var index$h = Object.freeze({
118
- __proto__: null,
119
- getWheelDirection: getWheelDirection
120
- });
121
-
122
- const degToRad = deg => deg * .01745329252;
170
+ const parseFragment = fragment => {
171
+ const fragmentData = fragment.split("=");
172
+ const fragmentType = fragmentData[0];
173
+ const fragmentValues = fragmentData[1];
174
+ switch (fragmentType.toLowerCase()) {
175
+ case "text":
176
+ {
177
+ const textValues = fragmentValues.split(",");
178
+ const textStart = textValues[0];
179
+ const textEnd = textValues[1];
180
+ const textOccurence = extractOccurence(textValues[2]);
181
+ if (!textStart) {
182
+ return;
183
+ }
184
+ return {
185
+ type: "text",
186
+ start: textStart,
187
+ end: textEnd || "",
188
+ occurence: textOccurence
189
+ };
190
+ }
123
191
 
124
- const radToDeg = rad => rad * 57.2957795131;
192
+ case "element":
193
+ {
194
+ const elementValues = fragmentValues.split(",");
195
+ const elementID = elementValues[0];
196
+ const elementOccurence = extractOccurence(elementValues[1]);
197
+ if (!elementID) {
198
+ return;
199
+ }
200
+ return {
201
+ type: "element",
202
+ id: elementID,
203
+ occurence: elementOccurence
204
+ };
205
+ }
206
+ }
207
+ return undefined;
208
+ };
125
209
 
126
- const makeQuaternion = (x, y, z, w) => ({
127
- x: x,
128
- y: y,
129
- z: z,
130
- w: w
131
- });
210
+ const extractOccurence = occurence => {
211
+ if (!occurence) {
212
+ return 0;
213
+ }
214
+ const occurenceMatch = occurence.match(/\[(\d*)\]/);
215
+ const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
216
+ return occurenceValue;
217
+ };
132
218
 
133
- const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
219
+ const stringInsertInitial = (value, insert) => {
220
+ if (!value.startsWith(insert)) {
221
+ value = insert + value;
222
+ }
223
+ return value;
224
+ };
134
225
 
135
- function inverseQuaternion(quaternion) {
136
- return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
137
- }
226
+ const stringRemoveTrailing = (value, trail) => {
227
+ if (value.endsWith(trail)) {
228
+ value = value.slice(0, value.length - trail.length);
229
+ }
230
+ return value;
231
+ };
138
232
 
139
- function conjugateQuaternion(quaternion) {
140
- return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
141
- }
233
+ const PATH_SEPARATOR = "/";
142
234
 
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
- }
235
+ const cleanupPath = value => {
236
+ value = stringInsertInitial(value, PATH_SEPARATOR);
237
+ value = stringRemoveTrailing(value, PATH_SEPARATOR);
238
+ return value;
239
+ };
159
240
 
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
- }
170
-
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;
241
+ const computePlaneAddress = (plane, route, origin = "origin") => {
242
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
243
+ origin = location.host;
184
244
  }
185
- return valueQuaternion;
186
- }
187
-
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
- }
245
+ const cleanPlane = extractPathname(plane);
246
+ const planeAddressType = checkPlaneAddressType(cleanPlane);
247
+ switch (planeAddressType) {
248
+ case "http":
249
+ case "https":
250
+ case "pttp":
251
+ return cleanPlane;
252
+ }
253
+ origin = stringRemoveTrailing(origin, "/");
254
+ const absolutePlane = isAbsolutePlane(plane);
255
+ const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
256
+ const planeAddress = protocols.plurid + origin + path;
257
+ return planeAddress;
258
+ };
198
259
 
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
- }
260
+ const isAbsolutePlane = value => value[0] === "/";
214
261
 
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
- });
262
+ const checkPlaneAddressType = value => {
263
+ value = value.toLowerCase().trim();
264
+ if (value.startsWith(protocols.plurid)) {
265
+ return "pttp";
266
+ }
267
+ if (value.startsWith(protocols.https)) {
268
+ return HTTPS_PROTOCOL;
269
+ }
270
+ if (value.startsWith(protocols.http)) {
271
+ return HTTP_PROTOCOL;
272
+ }
273
+ return "relative";
274
+ };
229
275
 
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
- }
276
+ const removeTrailingSlash = value => {
277
+ if (value.endsWith("/") && value.length > 1) {
278
+ return value.slice(0, value.length - 1);
279
+ }
280
+ return value;
281
+ };
238
282
 
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
- }
283
+ const cleanPathValue = value => {
284
+ const queryStart = value.indexOf("?");
285
+ if (queryStart < 0) {
286
+ return removeTrailingSlash(value);
287
+ }
288
+ return removeTrailingSlash(value.substring(0, queryStart));
289
+ };
242
290
 
243
- function scaleMatrix$1(s) {
244
- return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
245
- }
291
+ const checkParameterLength = (parameter, length, compareType) => {
292
+ const parameterLength = parameter.length;
293
+ switch (compareType) {
294
+ case compareTypes.equal:
295
+ return parameterLength === length;
246
296
 
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
- }
297
+ case compareTypes.equalLessThan:
298
+ return parameterLength <= length;
299
299
 
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]);
304
- }
305
- return inputMatrix;
306
- }
300
+ case compareTypes.lessThan:
301
+ return parameterLength < length;
307
302
 
308
- function matrixArrayToCSSMatrix(array) {
309
- return "matrix3d(" + array.join(",") + ")";
310
- }
303
+ case compareTypes.equalGreaterThan:
304
+ return parameterLength >= length;
311
305
 
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
- });
306
+ case compareTypes.greaterThan:
307
+ return parameterLength > length;
321
308
 
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;
309
+ default:
310
+ return parameterLength <= length;
311
+ }
325
312
  };
326
313
 
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];
314
+ const checkValidPath = (validationParameters, parameters) => {
315
+ if (validationParameters) {
316
+ for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
317
+ const {length: length, lengthType: lengthType, startsWith: startsWith, endsWith: endsWith, includes: includes} = parameterData;
318
+ const paramaterValue = parameters[parameterKey];
319
+ if (!paramaterValue) {
320
+ return false;
321
+ }
322
+ if (startsWith && !paramaterValue.startsWith(startsWith)) {
323
+ return false;
324
+ }
325
+ if (endsWith && !paramaterValue.endsWith(endsWith)) {
326
+ return false;
327
+ }
328
+ if (includes && !includes.includes(paramaterValue)) {
329
+ return false;
330
+ }
331
+ if (length) {
332
+ const validLength = checkParameterLength(paramaterValue, length, lengthType);
333
+ return validLength;
335
334
  }
336
- result[i][j] = sum;
337
335
  }
338
336
  }
339
- return result;
337
+ return true;
340
338
  };
341
339
 
342
- const multiplyMatricesArray = matrices => {
343
- if (matrices.length < 2) {
344
- throw new Error("invalid number of matrices");
340
+ const cleanPathElement = path => {
341
+ if (path[0] === "/") {
342
+ return path.slice(1);
345
343
  }
346
- const first = matrices[0];
347
- let result = first;
348
- for (const [index, matrix] of matrices.entries()) {
349
- if (index === 0) {
350
- continue;
351
- }
352
- result = multiplyMatrices(result, matrix);
353
- }
354
- return result;
355
- };
356
-
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);
366
- }
367
- return matrix;
344
+ return path;
368
345
  };
369
346
 
370
- const matrixToArray = matrix => matrix.flat();
347
+ var index$j = Object.freeze({
348
+ __proto__: null,
349
+ cleanPathElement: cleanPathElement
350
+ });
371
351
 
372
- const matrix3DToMatrix = value => {
373
- const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val => parseFloat(val)));
374
- return arrayToMatrix(values);
352
+ const mapPathsToRoutes = (paths, view) => {
353
+ const routes = [];
354
+ for (const [key, path] of Object.entries(paths)) {
355
+ const pathView = view[key];
356
+ if (pathView) {
357
+ const route = {
358
+ value: ""
359
+ };
360
+ routes.push(route);
361
+ }
362
+ }
363
+ return routes;
375
364
  };
376
365
 
377
- const printMatrix = (matrix, name) => {
378
- const normalize = value => {
379
- if (value === 1 || value === 0) {
380
- return value + " ";
381
- }
382
- if (value > 0) {
383
- return value.toFixed(2) + " ";
366
+ const pluridLinkPathDivider = route => {
367
+ const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
368
+ const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
369
+ const split = route.split("://").filter((value => value !== "")).map((value => cleanPathElement(value)));
370
+ let protocol = windowProtocol;
371
+ const host = {
372
+ value: windowHost,
373
+ controlled: false
374
+ };
375
+ const path = {
376
+ value: "",
377
+ parameters: {},
378
+ query: {}
379
+ };
380
+ const space = {
381
+ value: "",
382
+ parameters: {},
383
+ query: {}
384
+ };
385
+ const universe = {
386
+ value: "",
387
+ parameters: {},
388
+ query: {}
389
+ };
390
+ const cluster = {
391
+ value: "",
392
+ parameters: {},
393
+ query: {}
394
+ };
395
+ const plane = {
396
+ value: "",
397
+ parameters: {},
398
+ query: {},
399
+ fragments: {
400
+ texts: [],
401
+ elements: []
384
402
  }
385
- return value.toFixed(2) + " ";
386
403
  };
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]));
404
+ const valid = false;
405
+ if (split.length === 0 || split.length > 7) {
406
+ const url = {
407
+ protocol: {
408
+ value: protocol,
409
+ secure: true
410
+ },
411
+ host: host,
412
+ path: path,
413
+ space: space,
414
+ universe: universe,
415
+ cluster: cluster,
416
+ plane: plane,
417
+ valid: valid
418
+ };
419
+ return url;
390
420
  }
391
- console.log(`matrix3d(${matrix.flat().join(",")})`);
392
- console.log();
393
- };
421
+ if (route.startsWith("/://")) {
422
+ const routeSplit = split.slice(1);
423
+ switch (routeSplit.length) {
424
+ case 1:
425
+ path.value = routeSplit[0];
426
+ break;
394
427
 
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
- };
428
+ case 5:
429
+ path.value = routeSplit[0];
430
+ space.value = routeSplit[1];
431
+ universe.value = routeSplit[2];
432
+ cluster.value = routeSplit[3];
433
+ plane.value = routeSplit[4];
434
+ break;
435
+ }
436
+ const url = {
437
+ protocol: {
438
+ value: protocol,
439
+ secure: true
440
+ },
441
+ host: host,
442
+ path: path,
443
+ space: space,
444
+ universe: universe,
445
+ cluster: cluster,
446
+ plane: plane,
447
+ valid: true
448
+ };
449
+ return url;
450
+ }
451
+ if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
452
+ switch (split.length) {
453
+ case 1:
454
+ plane.value = split[0];
455
+ break;
402
456
 
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
- };
457
+ case 2:
458
+ cluster.value = split[0];
459
+ plane.value = split[1];
460
+ break;
410
461
 
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
- };
462
+ case 3:
463
+ universe.value = split[0];
464
+ cluster.value = split[1];
465
+ plane.value = split[2];
466
+ break;
418
467
 
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
- };
468
+ case 4:
469
+ space.value = split[0];
470
+ universe.value = split[1];
471
+ cluster.value = split[2];
472
+ plane.value = split[3];
473
+ break;
423
474
 
424
- const scaleMatrix = s => [ [ s, 0, 0, 0 ], [ 0, s, 0, 0 ], [ 0, 0, s, 0 ], [ 0, 0, 0, 1 ] ];
475
+ case 5:
476
+ path.value = split[0];
477
+ space.value = split[1];
478
+ universe.value = split[2];
479
+ cluster.value = split[3];
480
+ plane.value = split[4];
481
+ break;
425
482
 
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
- }
483
+ case 6:
484
+ host.value = split[0];
485
+ path.value = split[1];
486
+ space.value = split[2];
487
+ universe.value = split[3];
488
+ cluster.value = split[4];
489
+ plane.value = split[5];
490
+ break;
441
491
 
442
- const matrixToCSSMatrix = matrix => {
443
- const value = matrix.flat().join(",");
444
- return `matrix3d(${value})`;
445
- };
492
+ default:
493
+ const url = {
494
+ protocol: {
495
+ value: protocol,
496
+ secure: true
497
+ },
498
+ host: host,
499
+ path: path,
500
+ space: space,
501
+ universe: universe,
502
+ cluster: cluster,
503
+ plane: plane,
504
+ valid: valid
505
+ };
506
+ return url;
507
+ }
508
+ } else {
509
+ switch (split.length) {
510
+ case 3:
511
+ protocol = split[0];
512
+ host.value = split[1];
513
+ path.value = split[2];
514
+ break;
446
515
 
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
- };
516
+ case 7:
517
+ protocol = split[0];
518
+ host.value = split[1];
519
+ path.value = split[2];
520
+ space.value = split[3];
521
+ universe.value = split[4];
522
+ cluster.value = split[5];
523
+ plane.value = split[6];
524
+ break;
451
525
 
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++;
526
+ default:
527
+ const url = {
528
+ protocol: {
529
+ value: protocol,
530
+ secure: true
531
+ },
532
+ host: host,
533
+ path: path,
534
+ space: space,
535
+ universe: universe,
536
+ cluster: cluster,
537
+ plane: plane,
538
+ valid: valid
539
+ };
540
+ return url;
471
541
  }
472
- if (ABig === 0) {
473
- throw Error("Cannot calculate inverse, determinant is zero");
542
+ }
543
+ const url = {
544
+ protocol: {
545
+ value: protocol,
546
+ secure: true
547
+ },
548
+ host: host,
549
+ path: path,
550
+ space: space,
551
+ universe: universe,
552
+ cluster: cluster,
553
+ plane: plane,
554
+ valid: true
555
+ };
556
+ return url;
557
+ };
558
+
559
+ const resolveRoute = (route, protocol, host) => {
560
+ const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
561
+ const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
562
+ const divisions = pluridLinkPathDivider(route);
563
+ const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
564
+ const protocolDivision = divisions.protocol.value || windowProtocol;
565
+ const hostDivision = divisions.host.value ? divisions.host : {
566
+ value: windowHost,
567
+ controlled: true
568
+ };
569
+ const path = divisions.path.value ? divisions.path : {
570
+ value: defaultPathname,
571
+ parameters: {},
572
+ query: {}
573
+ };
574
+ const space = divisions.space.value ? divisions.space : {
575
+ value: "s",
576
+ parameters: {},
577
+ query: {}
578
+ };
579
+ const universe = divisions.universe.value ? divisions.universe : {
580
+ value: "u",
581
+ parameters: {},
582
+ query: {}
583
+ };
584
+ const cluster = divisions.cluster.value ? divisions.cluster : {
585
+ value: "c",
586
+ parameters: {},
587
+ query: {}
588
+ };
589
+ const plane = divisions.plane;
590
+ const separator = "://";
591
+ if (!plane.value && route !== "/") {
592
+ const resolvers = [ protocolDivision, hostDivision.value, path.value ];
593
+ const absoluteRoute = resolvers.join(separator);
594
+ return {
595
+ protocol: protocolDivision,
596
+ host: hostDivision,
597
+ path: path,
598
+ space: space,
599
+ universe: universe,
600
+ cluster: cluster,
601
+ plane: plane,
602
+ route: absoluteRoute
603
+ };
604
+ }
605
+ [ protocolDivision, hostDivision.value, path.value, space.value, universe.value, cluster.value, cleanPathElement(plane.value) ];
606
+ return {
607
+ protocol: "",
608
+ host: "",
609
+ path: path,
610
+ space: "",
611
+ universe: "",
612
+ cluster: "",
613
+ plane: "",
614
+ route: route
615
+ };
616
+ };
617
+
618
+ const updateTreePlane$1 = (tree, page) => {
619
+ const updatedTree = tree.map((treePlane => {
620
+ if (treePlane.planeID === page.planeID) {
621
+ return Object.assign({}, page);
474
622
  }
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;
623
+ if (treePlane.children) {
624
+ return Object.assign(Object.assign({}, treePlane), {
625
+ children: updateTreePlane$1(treePlane.children, page)
626
+ });
483
627
  }
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
- }
628
+ return treePlane;
629
+ }));
630
+ return updatedTree;
631
+ };
632
+
633
+ const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
634
+ const updatedTree = tree.map((treePlane => {
635
+ if (treePlane.planeID === planeID) {
636
+ const updatedPlane = Object.assign(Object.assign({}, treePlane), {
637
+ linkCoordinates: linkCoordinates
638
+ });
639
+ return updatedPlane;
508
640
  }
509
- }
510
- return B;
641
+ if (treePlane.children) {
642
+ const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(treePlane.children, planeID, linkCoordinates);
643
+ const updatedPlane = Object.assign(Object.assign({}, treePlane), {
644
+ children: updatedChildren
645
+ });
646
+ return updatedPlane;
647
+ }
648
+ return treePlane;
649
+ }));
650
+ return updatedTree;
511
651
  };
512
652
 
513
- var index$e = Object.freeze({
653
+ var index$i = Object.freeze({
514
654
  __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
655
+ updateTreePlane: updateTreePlane$1,
656
+ updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
531
657
  });
532
658
 
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]);
659
+ var index$h = Object.freeze({
660
+ __proto__: null,
661
+ configuration: index$k,
662
+ tree: index$i
663
+ });
664
+
665
+ const getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
666
+ let direction = "left";
667
+ const wheelDeltaX = deltas.deltaX;
668
+ const wheelDeltaY = deltas.deltaY;
669
+ const absWheelDeltaX = Math.abs(wheelDeltaX);
670
+ const absWheelDeltaY = Math.abs(wheelDeltaY);
671
+ if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
672
+ direction = "left";
538
673
  }
539
- return matrixValuesInt;
674
+ if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
675
+ direction = "right";
676
+ }
677
+ if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
678
+ direction = "up";
679
+ }
680
+ if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
681
+ direction = "down";
682
+ }
683
+ return direction;
684
+ };
685
+
686
+ var index$g = Object.freeze({
687
+ __proto__: null,
688
+ getWheelDirection: getWheelDirection
689
+ });
690
+
691
+ const degToRad = deg => deg * .01745329252;
692
+
693
+ const radToDeg = rad => rad * 57.2957795131;
694
+
695
+ const makeQuaternion = (x, y, z, w) => ({
696
+ x: x,
697
+ y: y,
698
+ z: z,
699
+ w: w
700
+ });
701
+
702
+ const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
703
+
704
+ function inverseQuaternion(quaternion) {
705
+ return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
540
706
  }
541
707
 
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;
548
- }
549
- } else if (valuesMatrix.length === 6) {
550
- for (let i = 0; i < 4; i++) {
551
- valuesMatrix[i] /= scale;
552
- }
553
- }
554
- const rotationMatrix = valuesMatrix;
555
- return rotationMatrix;
708
+ function conjugateQuaternion(quaternion) {
709
+ return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
556
710
  }
557
711
 
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;
712
+ function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
713
+ const x = radians ? beta : degToRad(beta);
714
+ const y = radians ? gamma : degToRad(gamma);
715
+ const z = radians ? alpha : degToRad(alpha);
716
+ const cX = Math.cos(x / 2);
717
+ const cY = Math.cos(y / 2);
718
+ const cZ = Math.cos(z / 2);
719
+ const sX = Math.sin(x / 2);
720
+ const sY = Math.sin(y / 2);
721
+ const sZ = Math.sin(z / 2);
722
+ const xQ = sX * cY * cZ - cX * sY * sZ;
723
+ const yQ = cX * sY * cZ + sX * cY * sZ;
724
+ const zQ = cX * cY * sZ + sX * sY * cZ;
725
+ const wQ = cX * cY * cZ - sX * sY * sZ;
726
+ return makeQuaternion(xQ, yQ, zQ, wQ);
567
727
  }
568
728
 
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;
729
+ function quaternionFromAxisAngle(x, y, z, angle) {
730
+ const q = zeroQuaternion();
731
+ const halfAngle = angle / 2;
732
+ const sine = Math.sin(halfAngle);
733
+ q.x = x * sine;
734
+ q.y = y * sine;
735
+ q.z = z * sine;
736
+ q.w = Math.cos(halfAngle);
737
+ return q;
585
738
  }
586
739
 
587
- function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
588
- const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
589
- return matrixArrayToCSSMatrix(transformMatrix);
740
+ function quaternionMultiply(quaternionArray) {
741
+ const firstQuaternion = quaternionArray[0];
742
+ const valueQuaternion = Object.assign({}, firstQuaternion);
743
+ for (let i = 1; i < quaternionArray.length; i++) {
744
+ const nextQuaternion = quaternionArray[i];
745
+ const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
746
+ const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
747
+ const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
748
+ const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
749
+ valueQuaternion.x = x;
750
+ valueQuaternion.y = y;
751
+ valueQuaternion.z = z;
752
+ valueQuaternion.w = w;
753
+ }
754
+ return valueQuaternion;
590
755
  }
591
756
 
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
- }
604
- }
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]);
624
- }
625
- return {
626
- rotateX: rotateX,
627
- rotateY: rotateY,
628
- rotateZ: 0
757
+ function rotatePointViaQuaternion(pointRotate, quaternion) {
758
+ const temporaryQuaternion = {
759
+ x: pointRotate[0],
760
+ y: pointRotate[1],
761
+ z: pointRotate[2],
762
+ w: 0
629
763
  };
764
+ const rotatedPointQuaternion = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
765
+ return rotatedPointQuaternion;
630
766
  }
631
767
 
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
- };
768
+ function makeRotationMatrixFromQuaternion(quaternion) {
769
+ const num = quaternion.x * 2;
770
+ const num2 = quaternion.y * 2;
771
+ const num3 = quaternion.z * 2;
772
+ const num4 = quaternion.x * num;
773
+ const num5 = quaternion.y * num2;
774
+ const num6 = quaternion.z * num3;
775
+ const num7 = quaternion.x * num2;
776
+ const num8 = quaternion.x * num3;
777
+ const num9 = quaternion.y * num3;
778
+ const num10 = quaternion.w * num;
779
+ const num11 = quaternion.w * num2;
780
+ const num12 = quaternion.w * num3;
781
+ 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 ];
642
782
  }
643
783
 
644
- function getTransformScale(matrix3d) {
645
- const scale = getScalationValue(matrix3d);
646
- return {
647
- scale: scale
648
- };
784
+ var index$f = Object.freeze({
785
+ __proto__: null,
786
+ degToRad: degToRad,
787
+ radToDeg: radToDeg,
788
+ makeQuaternion: makeQuaternion,
789
+ zeroQuaternion: zeroQuaternion,
790
+ inverseQuaternion: inverseQuaternion,
791
+ conjugateQuaternion: conjugateQuaternion,
792
+ computeQuaternionFromEulers: computeQuaternionFromEulers,
793
+ quaternionFromAxisAngle: quaternionFromAxisAngle,
794
+ quaternionMultiply: quaternionMultiply,
795
+ rotatePointViaQuaternion: rotatePointViaQuaternion,
796
+ makeRotationMatrixFromQuaternion: makeRotationMatrixFromQuaternion
797
+ });
798
+
799
+ function rotateMatrix(xAngle, yAngle, zAngle = 0) {
800
+ const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
801
+ const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
802
+ const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
803
+ const quartenionMultiplication = quaternionMultiply([ yQuaternion, xQuaternion, zQuaternion ]);
804
+ const rotationMatrix = makeRotationMatrixFromQuaternion(quartenionMultiplication);
805
+ return rotationMatrix;
649
806
  }
650
807
 
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;
808
+ function translateMatrix$1(x, y, z) {
809
+ return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
682
810
  }
683
811
 
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;
812
+ function scaleMatrix$1(s) {
813
+ return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
716
814
  }
717
815
 
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;
816
+ function multiplyMatrices$1(matrixA, matrixB) {
817
+ const result = [];
818
+ const a00 = matrixA[0];
819
+ const a01 = matrixA[1];
820
+ const a02 = matrixA[2];
821
+ const a03 = matrixA[3];
822
+ const a10 = matrixA[4];
823
+ const a11 = matrixA[5];
824
+ const a12 = matrixA[6];
825
+ const a13 = matrixA[7];
826
+ const a20 = matrixA[8];
827
+ const a21 = matrixA[9];
828
+ const a22 = matrixA[10];
829
+ const a23 = matrixA[11];
830
+ const a30 = matrixA[12];
831
+ const a31 = matrixA[13];
832
+ const a32 = matrixA[14];
833
+ const a33 = matrixA[15];
834
+ let b0 = matrixB[0];
835
+ let b1 = matrixB[1];
836
+ let b2 = matrixB[2];
837
+ let b3 = matrixB[3];
838
+ result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
839
+ result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
840
+ result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
841
+ result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
842
+ b0 = matrixB[4];
843
+ b1 = matrixB[5];
844
+ b2 = matrixB[6];
845
+ b3 = matrixB[7];
846
+ result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
847
+ result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
848
+ result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
849
+ result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
850
+ b0 = matrixB[8];
851
+ b1 = matrixB[9];
852
+ b2 = matrixB[10];
853
+ b3 = matrixB[11];
854
+ result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
855
+ result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
856
+ result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
857
+ result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
858
+ b0 = matrixB[12];
859
+ b1 = matrixB[13];
860
+ b2 = matrixB[14];
861
+ b3 = matrixB[15];
862
+ result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
863
+ result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
864
+ result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
865
+ result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
866
+ return result;
747
867
  }
748
868
 
749
- var index$d = Object.freeze({
750
- __proto__: null,
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
762
- });
869
+ function multiplyArrayOfMatrices(matrices) {
870
+ let inputMatrix = matrices[0];
871
+ for (let i = 1; i < matrices.length; i++) {
872
+ inputMatrix = multiplyMatrices$1(inputMatrix, matrices[i]);
873
+ }
874
+ return inputMatrix;
875
+ }
763
876
 
764
- var index$c = Object.freeze({
765
- __proto__: null,
766
- general: index$e,
767
- matrix3d: index$d
768
- });
877
+ function matrixArrayToCSSMatrix(array) {
878
+ return "matrix3d(" + array.join(",") + ")";
879
+ }
769
880
 
770
- var index$b = Object.freeze({
881
+ var index$e = Object.freeze({
771
882
  __proto__: null,
772
- direction: index$h,
773
- matrix: index$f,
774
- quaternion: index$g,
775
- transform: index$c
883
+ rotateMatrix: rotateMatrix,
884
+ translateMatrix: translateMatrix$1,
885
+ scaleMatrix: scaleMatrix$1,
886
+ multiplyMatrices: multiplyMatrices$1,
887
+ multiplyArrayOfMatrices: multiplyArrayOfMatrices,
888
+ matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
776
889
  });
777
890
 
778
- const internatiolate = (lamguage, field) => internationalization[lamguage][field];
779
-
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;
891
+ const getInitialMatrix = () => {
892
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
893
+ return matrix;
789
894
  };
790
895
 
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);
896
+ const multiplyMatrices = (m1, m2) => {
897
+ const result = [];
898
+ for (let i = 0; i < m1.length; i++) {
899
+ result[i] = [];
900
+ for (let j = 0; j < m2[0].length; j++) {
901
+ let sum = 0;
902
+ for (let k = 0; k < m1[0].length; k++) {
903
+ sum += m1[i][k] * m2[k][j];
904
+ }
905
+ result[i][j] = sum;
906
+ }
798
907
  }
799
- return plane;
908
+ return result;
800
909
  };
801
910
 
802
- const getPluridPlaneIDByData = element => {
803
- if (!element) {
804
- return "";
911
+ const multiplyMatricesArray = matrices => {
912
+ if (matrices.length < 2) {
913
+ throw new Error("invalid number of matrices");
805
914
  }
806
- const parent = element.parentElement;
807
- if (parent && parent.dataset.pluridPlane) {
808
- return parent.dataset.pluridPlane;
915
+ const first = matrices[0];
916
+ let result = first;
917
+ for (const [index, matrix] of matrices.entries()) {
918
+ if (index === 0) {
919
+ continue;
920
+ }
921
+ result = multiplyMatrices(result, matrix);
809
922
  }
810
- return getPluridPlaneIDByData(parent);
811
- };
812
-
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;
923
+ return result;
819
924
  };
820
925
 
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("");
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
- };
926
+ const arrayToMatrix = array => {
927
+ const matrix = [];
928
+ for (let i = 0; i < array.length; i += 4) {
929
+ const row = [];
930
+ row.push(array[i]);
931
+ row.push(array[i + 1]);
932
+ row.push(array[i + 2]);
933
+ row.push(array[i + 3]);
934
+ matrix.push(row);
838
935
  }
839
- const parametersValues = extractParametersValues(parameters, locationElements);
840
- return {
841
- match: true,
842
- parameters: parametersValues,
843
- elements: locationElements
844
- };
936
+ return matrix;
845
937
  };
846
938
 
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;
939
+ const matrixToArray = matrix => matrix.flat();
940
+
941
+ const matrix3DToMatrix = value => {
942
+ const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val => parseFloat(val)));
943
+ return arrayToMatrix(values);
856
944
  };
857
945
 
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];
946
+ const printMatrix = (matrix, name) => {
947
+ const normalize = value => {
948
+ if (value === 1 || value === 0) {
949
+ return value + " ";
865
950
  }
866
- }
867
- const comparingPath = comparingPathElements.join("/");
868
- return {
869
- locationElements: locationElements,
870
- comparingPath: comparingPath
951
+ if (value > 0) {
952
+ return value.toFixed(2) + " ";
953
+ }
954
+ return value.toFixed(2) + " ";
871
955
  };
956
+ console.log("matrix", name + ":");
957
+ for (const row of matrix) {
958
+ console.log(normalize(row[0]), normalize(row[1]), normalize(row[2]), normalize(row[3]));
959
+ }
960
+ console.log(`matrix3d(${matrix.flat().join(",")})`);
961
+ console.log();
872
962
  };
873
963
 
874
- const splitPath = path => path.split("/").filter((i => i !== ""));
964
+ const rotateXMatrix = angle => {
965
+ const x = Math.cos(angle);
966
+ const y = -1 * Math.sin(angle);
967
+ const z = Math.sin(angle);
968
+ const m = [ [ 1, 0, 0, 0 ], [ 0, x, y, 0 ], [ 0, z, x, 0 ], [ 0, 0, 0, 1 ] ];
969
+ return m;
970
+ };
875
971
 
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;
889
- }
890
- return queryValues;
891
- } else {
892
- return {};
893
- }
972
+ const rotateYMatrix = angle => {
973
+ const x = Math.cos(angle);
974
+ const y = -1 * Math.sin(angle);
975
+ const z = Math.sin(angle);
976
+ const m = [ [ x, 0, z, 0 ], [ 0, 1, 0, 0 ], [ y, 0, x, 0 ], [ 0, 0, 0, 1 ] ];
977
+ return m;
894
978
  };
895
979
 
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;
980
+ const rotateZMatrix = angle => {
981
+ const x = Math.cos(angle);
982
+ const y = -1 * Math.sin(angle);
983
+ const z = Math.sin(angle);
984
+ const m = [ [ x, y, 0, 0 ], [ z, x, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
985
+ return m;
986
+ };
921
987
 
922
- case "element":
923
- elementFragments.push(parsedFragment);
924
- break;
925
- }
926
- }
927
- }
928
- return {
929
- texts: textFragments,
930
- elements: elementFragments
931
- };
988
+ const translateMatrix = (x = 0, y = 0, z = 0) => {
989
+ const m = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ x, y, z, 1 ] ];
990
+ return m;
932
991
  };
933
992
 
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;
993
+ const scaleMatrix = s => [ [ s, 0, 0, 0 ], [ 0, s, 0, 0 ], [ 0, 0, s, 0 ], [ 0, 0, 0, 1 ] ];
994
+
995
+ function rotationMatrixFromQuaternion(quaternion) {
996
+ const num = quaternion.x * 2;
997
+ const num2 = quaternion.y * 2;
998
+ const num3 = quaternion.z * 2;
999
+ const num4 = quaternion.x * num;
1000
+ const num5 = quaternion.y * num2;
1001
+ const num6 = quaternion.z * num3;
1002
+ const num7 = quaternion.x * num2;
1003
+ const num8 = quaternion.x * num3;
1004
+ const num9 = quaternion.y * num3;
1005
+ const num10 = quaternion.w * num;
1006
+ const num11 = quaternion.w * num2;
1007
+ const num12 = quaternion.w * num3;
1008
+ 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 ] ];
1009
+ }
1010
+
1011
+ const matrixToCSSMatrix = matrix => {
1012
+ const value = matrix.flat().join(",");
1013
+ return `matrix3d(${value})`;
1014
+ };
1015
+
1016
+ const identityMatrix = () => {
1017
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
1018
+ return matrix;
1019
+ };
1020
+
1021
+ const inverseMatrix = matrix => {
1022
+ const cols = 4;
1023
+ const rows = 4;
1024
+ const A = [ ...matrix ];
1025
+ const B = identityMatrix();
1026
+ let r;
1027
+ let s;
1028
+ let f;
1029
+ let temp;
1030
+ for (let c = 0; c < cols; c++) {
1031
+ let ABig = Math.abs(A[c][c]);
1032
+ let rBig = c;
1033
+ r = c + 1;
1034
+ while (r < rows) {
1035
+ if (Math.abs(A[r][c]) > ABig) {
1036
+ ABig = Math.abs(A[r][c]);
1037
+ rBig = r;
947
1038
  }
948
- return {
949
- type: "text",
950
- start: textStart,
951
- end: textEnd || "",
952
- occurence: textOccurence
953
- };
1039
+ r++;
954
1040
  }
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;
1041
+ if (ABig === 0) {
1042
+ throw Error("Cannot calculate inverse, determinant is zero");
1043
+ }
1044
+ r = rBig;
1045
+ if (r !== c) {
1046
+ temp = A[c];
1047
+ A[c] = A[r];
1048
+ A[r] = temp;
1049
+ temp = B[c];
1050
+ B[c] = B[r];
1051
+ B[r] = temp;
1052
+ }
1053
+ const Ac = A[c];
1054
+ const Bc = B[c];
1055
+ for (r = 0; r < rows; r++) {
1056
+ const Ar = A[r];
1057
+ const Br = B[r];
1058
+ if (r !== c) {
1059
+ if (Ar[c] !== 0) {
1060
+ f = -Ar[c] / Ac[c];
1061
+ for (s = c; s < cols; s++) {
1062
+ Ar[s] = Ar[s] + f * Ac[s];
1063
+ }
1064
+ for (s = 0; s < cols; s++) {
1065
+ Br[s] = Br[s] + f * Bc[s];
1066
+ }
1067
+ }
1068
+ } else {
1069
+ f = Ac[c];
1070
+ for (s = c; s < cols; s++) {
1071
+ Ar[s] = Ar[s] / f;
1072
+ }
1073
+ for (s = 0; s < cols; s++) {
1074
+ Br[s] = Br[s] / f;
1075
+ }
963
1076
  }
964
- return {
965
- type: "element",
966
- id: elementID,
967
- occurence: elementOccurence
968
- };
969
1077
  }
970
1078
  }
971
- return undefined;
1079
+ return B;
972
1080
  };
973
1081
 
974
- const extractOccurence = occurence => {
975
- if (!occurence) {
976
- return 0;
1082
+ var index$d = Object.freeze({
1083
+ __proto__: null,
1084
+ getInitialMatrix: getInitialMatrix,
1085
+ multiplyMatrices: multiplyMatrices,
1086
+ multiplyMatricesArray: multiplyMatricesArray,
1087
+ arrayToMatrix: arrayToMatrix,
1088
+ matrixToArray: matrixToArray,
1089
+ matrix3DToMatrix: matrix3DToMatrix,
1090
+ printMatrix: printMatrix,
1091
+ rotateXMatrix: rotateXMatrix,
1092
+ rotateYMatrix: rotateYMatrix,
1093
+ rotateZMatrix: rotateZMatrix,
1094
+ translateMatrix: translateMatrix,
1095
+ scaleMatrix: scaleMatrix,
1096
+ rotationMatrixFromQuaternion: rotationMatrixFromQuaternion,
1097
+ matrixToCSSMatrix: matrixToCSSMatrix,
1098
+ identityMatrix: identityMatrix,
1099
+ inverseMatrix: inverseMatrix
1100
+ });
1101
+
1102
+ function getMatrixValues(matrix3d) {
1103
+ const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
1104
+ const matrixValuesInt = [];
1105
+ for (let i = 0; i < matrixValues.length; i++) {
1106
+ matrixValuesInt[i] = parseFloat(matrixValues[i]);
977
1107
  }
978
- const occurenceMatch = occurence.match(/\[(\d*)\]/);
979
- const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
980
- return occurenceValue;
981
- };
1108
+ return matrixValuesInt;
1109
+ }
982
1110
 
983
- const stringInsertInitial = (value, insert) => {
984
- if (!value.startsWith(insert)) {
985
- value = insert + value;
1111
+ function getRotationMatrix(matrix3d) {
1112
+ const valuesMatrix = getMatrixValues(matrix3d);
1113
+ const scale = getScalationValue(matrix3d);
1114
+ if (valuesMatrix.length === 16) {
1115
+ for (let i = 0; i < 11; i++) {
1116
+ valuesMatrix[i] /= scale;
1117
+ }
1118
+ } else if (valuesMatrix.length === 6) {
1119
+ for (let i = 0; i < 4; i++) {
1120
+ valuesMatrix[i] /= scale;
1121
+ }
986
1122
  }
987
- return value;
988
- };
1123
+ const rotationMatrix = valuesMatrix;
1124
+ return rotationMatrix;
1125
+ }
989
1126
 
990
- const stringRemoveTrailing = (value, trail) => {
991
- if (value.endsWith(trail)) {
992
- value = value.slice(0, value.length - trail.length);
1127
+ function getTranslationMatrix(matrix3d) {
1128
+ const valuesMatrix = getMatrixValues(matrix3d);
1129
+ let translationMatrix;
1130
+ if (valuesMatrix.length === 16) {
1131
+ translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
1132
+ } else if (valuesMatrix.length === 6) {
1133
+ translationMatrix = getMatrixValues(matrix3d).slice(4);
993
1134
  }
994
- return value;
995
- };
1135
+ return translationMatrix;
1136
+ }
996
1137
 
997
- const PATH_SEPARATOR = "/";
1138
+ function getScalationValue(matrix3d) {
1139
+ const valuesMatrix = getMatrixValues(matrix3d);
1140
+ let temp = 0;
1141
+ let scale;
1142
+ if (valuesMatrix.length === 16) {
1143
+ const scaleMatrix = getMatrixValues(matrix3d).slice(0, 4);
1144
+ scale = 0;
1145
+ for (const el of scaleMatrix) {
1146
+ scale += parseFloat(el) * parseFloat(el);
1147
+ }
1148
+ scale = parseFloat(Math.sqrt(scale).toPrecision(4));
1149
+ } else if (valuesMatrix.length === 6) {
1150
+ temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
1151
+ scale = parseFloat(Math.sqrt(temp).toPrecision(4));
1152
+ }
1153
+ return scale;
1154
+ }
998
1155
 
999
- const cleanupPath = value => {
1000
- value = stringInsertInitial(value, PATH_SEPARATOR);
1001
- value = stringRemoveTrailing(value, PATH_SEPARATOR);
1002
- return value;
1003
- };
1156
+ function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
1157
+ const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
1158
+ return matrixArrayToCSSMatrix(transformMatrix);
1159
+ }
1004
1160
 
1005
- const computePlaneAddress = (plane, route, origin = "origin") => {
1006
- if (origin === "origin" && typeof location !== "undefined" && location.host) {
1007
- origin = location.host;
1008
- }
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;
1161
+ function getTransformRotate(matrix3d) {
1162
+ const pi = Math.PI;
1163
+ const values = getRotationMatrix(matrix3d);
1164
+ let rotateX = 0;
1165
+ let rotateY = 0;
1166
+ if (values.length === 6) {
1167
+ const cosa = values[0];
1168
+ const sina = values[1];
1169
+ if (cosa === 1 && sina === 0) {
1170
+ rotateX = Math.asin(sina);
1171
+ rotateY = Math.acos(cosa);
1172
+ }
1016
1173
  }
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
- };
1174
+ if (values.length === 16) {
1175
+ const cosaX1 = values[5];
1176
+ const sinaX3 = values[9];
1177
+ if (sinaX3 <= 0) {
1178
+ rotateX = Math.acos(cosaX1);
1179
+ }
1180
+ if (sinaX3 > 0) {
1181
+ rotateX = 2 * pi - Math.acos(cosaX1);
1182
+ }
1183
+ const cosaY1 = values[0];
1184
+ const sinaY2 = values[2];
1185
+ if (sinaY2 <= 0) {
1186
+ rotateY = Math.acos(cosaY1);
1187
+ }
1188
+ if (sinaY2 > 0) {
1189
+ rotateY = 2 * pi - Math.acos(cosaY1);
1190
+ }
1191
+ rotateX = Math.atan2(values[9], values[5]);
1192
+ rotateY = Math.atan2(values[2], values[0]);
1193
+ }
1194
+ return {
1195
+ rotateX: rotateX,
1196
+ rotateY: rotateY,
1197
+ rotateZ: 0
1198
+ };
1199
+ }
1023
1200
 
1024
- const isAbsolutePlane = value => value[0] === "/";
1201
+ function getTransformTranslate(matrix3d) {
1202
+ const values = getTranslationMatrix(matrix3d);
1203
+ const translateX = values[0];
1204
+ const translateY = values[1];
1205
+ const translateZ = values[2];
1206
+ return {
1207
+ translateX: translateX,
1208
+ translateY: translateY,
1209
+ translateZ: translateZ
1210
+ };
1211
+ }
1025
1212
 
1026
- const checkPlaneAddressType = value => {
1027
- value = value.toLowerCase().trim();
1028
- if (value.startsWith(protocols.plurid)) {
1029
- return "pttp";
1030
- }
1031
- if (value.startsWith(protocols.https)) {
1032
- return HTTPS_PROTOCOL;
1213
+ function getTransformScale(matrix3d) {
1214
+ const scale = getScalationValue(matrix3d);
1215
+ return {
1216
+ scale: scale
1217
+ };
1218
+ }
1219
+
1220
+ function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
1221
+ const transformRotate = getTransformRotate(matrix3d);
1222
+ const rotateX = transformRotate.rotateX;
1223
+ let rotateY = transformRotate.rotateY;
1224
+ const rotateZ = transformRotate.rotateZ;
1225
+ const transformTranslate = getTransformTranslate(matrix3d);
1226
+ const translateX = transformTranslate.translateX;
1227
+ const translateY = transformTranslate.translateY;
1228
+ const translateZ = transformTranslate.translateZ;
1229
+ const scale = getTransformScale(matrix3d).scale;
1230
+ let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1231
+ const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1232
+ const valScalationMatrix = scaleMatrix$1(scale);
1233
+ if (direction === "left") {
1234
+ rotateY -= angleIncrement;
1235
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1033
1236
  }
1034
- if (value.startsWith(protocols.http)) {
1035
- return HTTP_PROTOCOL;
1237
+ if (direction === "right") {
1238
+ rotateY += angleIncrement;
1239
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1036
1240
  }
1037
- return "relative";
1038
- };
1039
-
1040
- const removeTrailingSlash = value => {
1041
- if (value.endsWith("/") && value.length > 1) {
1042
- return value.slice(0, value.length - 1);
1241
+ if (direction === "up") {
1242
+ rotateY -= angleIncrement;
1243
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1043
1244
  }
1044
- return value;
1045
- };
1046
-
1047
- const cleanPathValue = value => {
1048
- const queryStart = value.indexOf("?");
1049
- if (queryStart < 0) {
1050
- return removeTrailingSlash(value);
1245
+ if (direction === "down") {
1246
+ rotateY += angleIncrement;
1247
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1051
1248
  }
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;
1249
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1250
+ return transformedMatrix3d;
1251
+ }
1072
1252
 
1073
- default:
1074
- return parameterLength <= length;
1253
+ function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
1254
+ const transformRotate = getTransformRotate(matrix3d);
1255
+ const rotateX = transformRotate.rotateX;
1256
+ const rotateY = transformRotate.rotateY;
1257
+ const rotateZ = transformRotate.rotateZ;
1258
+ const transformTranslate = getTransformTranslate(matrix3d);
1259
+ let translateX = transformTranslate.translateX;
1260
+ let translateY = transformTranslate.translateY;
1261
+ const translateZ = transformTranslate.translateZ;
1262
+ const scale = getTransformScale(matrix3d).scale;
1263
+ const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1264
+ let valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1265
+ const valScalationMatrix = scaleMatrix$1(scale);
1266
+ scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
1267
+ if (direction === "left") {
1268
+ translateX += linearIncrement;
1269
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1075
1270
  }
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
- }
1271
+ if (direction === "right") {
1272
+ translateX -= linearIncrement;
1273
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1100
1274
  }
1101
- return true;
1102
- };
1103
-
1104
- const cleanPathElement = path => {
1105
- if (path[0] === "/") {
1106
- return path.slice(1);
1275
+ if (direction === "up") {
1276
+ translateY += linearIncrement;
1277
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1107
1278
  }
1108
- return path;
1109
- };
1110
-
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);
1125
- }
1279
+ if (direction === "down") {
1280
+ translateY -= linearIncrement;
1281
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1126
1282
  }
1127
- return routes;
1128
- };
1283
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1284
+ return transformedMatrix3d;
1285
+ }
1129
1286
 
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: []
1166
- }
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;
1287
+ function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
1288
+ const transformRotate = getTransformRotate(matrix3d);
1289
+ const rotateX = transformRotate.rotateX;
1290
+ const rotateY = transformRotate.rotateY;
1291
+ const rotateZ = transformRotate.rotateZ;
1292
+ const transformTranslate = getTransformTranslate(matrix3d);
1293
+ const translateX = transformTranslate.translateX;
1294
+ const translateY = transformTranslate.translateY;
1295
+ const translateZ = transformTranslate.translateZ;
1296
+ let scale = getTransformScale(matrix3d).scale;
1297
+ const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1298
+ const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1299
+ let valScalationMatrix = scaleMatrix$1(scale);
1300
+ if (direction === "up") {
1301
+ scale -= scaleIncrement;
1302
+ if (scale < .1) {
1303
+ scale = .1;
1304
+ }
1305
+ valScalationMatrix = scaleMatrix$1(scale);
1184
1306
  }
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;
1307
+ if (direction === "down") {
1308
+ scale += scaleIncrement;
1309
+ if (scale > 4) {
1310
+ scale = 4;
1199
1311
  }
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;
1312
+ valScalationMatrix = scaleMatrix$1(scale);
1214
1313
  }
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;
1220
-
1221
- case 2:
1222
- cluster.value = split[0];
1223
- plane.value = split[1];
1224
- break;
1225
-
1226
- case 3:
1227
- universe.value = split[0];
1228
- cluster.value = split[1];
1229
- plane.value = split[2];
1230
- break;
1314
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1315
+ return transformedMatrix3d;
1316
+ }
1231
1317
 
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;
1318
+ var index$c = Object.freeze({
1319
+ __proto__: null,
1320
+ getMatrixValues: getMatrixValues,
1321
+ getRotationMatrix: getRotationMatrix,
1322
+ getTranslationMatrix: getTranslationMatrix,
1323
+ getScalationValue: getScalationValue,
1324
+ setTransform: setTransform,
1325
+ getTransformRotate: getTransformRotate,
1326
+ getTransformTranslate: getTransformTranslate,
1327
+ getTransformScale: getTransformScale,
1328
+ rotatePlurid: rotatePlurid,
1329
+ translatePlurid: translatePlurid,
1330
+ scalePlurid: scalePlurid
1331
+ });
1238
1332
 
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;
1333
+ var index$b = Object.freeze({
1334
+ __proto__: null,
1335
+ general: index$d,
1336
+ matrix3d: index$c
1337
+ });
1246
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
+ var index$a = Object.freeze({
1340
+ __proto__: null,
1341
+ direction: index$g,
1342
+ matrix: index$e,
1343
+ quaternion: index$f,
1344
+ transform: index$b
1345
+ });
1255
1346
 
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;
1347
+ const internatiolate = (lamguage, field) => internationalization[lamguage][field];
1279
1348
 
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;
1349
+ const resolvePluridPlaneData = plane => {
1350
+ if (Array.isArray(plane)) {
1351
+ const [route, component, options] = plane;
1352
+ return Object.assign({
1353
+ route: route,
1354
+ component: component
1355
+ }, options);
1356
+ }
1357
+ return plane;
1358
+ };
1289
1359
 
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
- }
1360
+ const resolvePluridRoutePlaneData = plane => {
1361
+ if (Array.isArray(plane)) {
1362
+ const [value, component, options] = plane;
1363
+ return Object.assign({
1364
+ value: value,
1365
+ component: component
1366
+ }, options);
1306
1367
  }
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
1319
- };
1320
- return url;
1368
+ return plane;
1321
1369
  };
1322
1370
 
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
- };
1371
+ const getPluridPlaneIDByData = element => {
1372
+ if (!element) {
1373
+ return "";
1368
1374
  }
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
- };
1375
+ const parent = element.parentElement;
1376
+ if (parent && parent.dataset.pluridPlane) {
1377
+ return parent.dataset.pluridPlane;
1378
+ }
1379
+ return getPluridPlaneIDByData(parent);
1380
1380
  };
1381
1381
 
1382
1382
  class IsoMatcher {
@@ -2108,7 +2108,7 @@ var index$5 = Object.freeze({
2108
2108
  computeZigZagLayout: computeZigZagLayout
2109
2109
  });
2110
2110
 
2111
- const resolveViewItem = (planes, view, configuration, origin = "origin") => {
2111
+ const resolveViewItem = (planes, view, configuration, origin = "origin", getCount) => {
2112
2112
  const {protocol: protocol, host: host} = configuration.network;
2113
2113
  const viewData = typeof view === "string" ? view : view.plane;
2114
2114
  const viewAddress = computePlaneAddress(viewData, undefined, origin);
@@ -2127,9 +2127,11 @@ const resolveViewItem = (planes, view, configuration, origin = "origin") => {
2127
2127
  const match = isoMatcher.match(viewData);
2128
2128
  if (match) {
2129
2129
  const route = match.match.value;
2130
+ const count = getCount ? getCount() : uuid.generate();
2131
+ const planeID = route + "@" + count;
2130
2132
  const treePlane = {
2131
2133
  sourceID: route,
2132
- planeID: uuid.generate(),
2134
+ planeID: planeID,
2133
2135
  route: viewAddress,
2134
2136
  routeDivisions: {
2135
2137
  protocol: {
@@ -2187,14 +2189,26 @@ const resolveViewItem = (planes, view, configuration, origin = "origin") => {
2187
2189
  return;
2188
2190
  };
2189
2191
 
2190
- const computeSpaceTree = (planes, view, configuration, origin = "origin") => {
2192
+ const computeSpaceTree = (planes, view, configuration, layout, origin = "origin", getCount) => {
2191
2193
  const treePlanes = [];
2192
2194
  for (const viewItem of view) {
2193
- const treePlane = resolveViewItem(planes, viewItem, configuration, origin);
2195
+ const treePlane = resolveViewItem(planes, viewItem, configuration, origin, getCount);
2194
2196
  if (treePlane) {
2195
2197
  treePlanes.push(treePlane);
2196
2198
  }
2197
2199
  }
2200
+ if (!layout) {
2201
+ const layoutlessTreePlanes = treePlanes.map((plane => Object.assign(Object.assign({}, plane), {
2202
+ location: {
2203
+ rotateX: 0,
2204
+ rotateY: 0,
2205
+ translateX: 0,
2206
+ translateY: 0,
2207
+ translateZ: 0
2208
+ }
2209
+ })));
2210
+ return layoutlessTreePlanes;
2211
+ }
2198
2212
  switch (configuration.space.layout.type) {
2199
2213
  case LAYOUT_TYPES.COLUMNS:
2200
2214
  {
@@ -2570,12 +2584,16 @@ var logic = Object.freeze({
2570
2584
 
2571
2585
  class Tree {
2572
2586
  constructor(data, origin = "origin") {
2587
+ this.count = 0;
2573
2588
  this.data = data;
2574
2589
  this.origin = origin;
2575
2590
  }
2576
2591
  compute() {
2577
- const {planes: planes, view: view, configuration: configuration} = this.data;
2578
- return computeSpaceTree(planes, view, configuration, this.origin);
2592
+ const {planes: planes, view: view, configuration: configuration, layout: layout} = this.data;
2593
+ return computeSpaceTree(planes, view, configuration, layout, this.origin, this.getCount.bind(this));
2594
+ }
2595
+ getCount() {
2596
+ return this.count++;
2579
2597
  }
2580
2598
  }
2581
2599
 
@@ -2651,8 +2669,9 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2651
2669
  view: view
2652
2670
  }, hostname);
2653
2671
  const computedTree = spaceTree.compute();
2654
- const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign({
2672
+ const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2655
2673
  loading: true,
2674
+ resolvedLayout: false,
2656
2675
  animatedTransform: false,
2657
2676
  transformTime: 450,
2658
2677
  scale: 1,
@@ -2661,6 +2680,7 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2661
2680
  translationX: 0,
2662
2681
  translationY: 0,
2663
2682
  translationZ: 0,
2683
+ transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
2664
2684
  activeUniverseID: "",
2665
2685
  camera: {
2666
2686
  x: 0,
@@ -2682,9 +2702,13 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2682
2702
  }
2683
2703
  },
2684
2704
  culledView: [],
2685
- view: view,
2705
+ activePlaneID: "",
2706
+ isolatePlane: "",
2707
+ lastClosedPlane: "",
2686
2708
  tree: computedTree
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);
2709
+ }, 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), {
2710
+ view: view
2711
+ });
2688
2712
  if (currentState) {
2689
2713
  stateSpace.translationX = currentState.space.translationX;
2690
2714
  stateSpace.translationY = currentState.space.translationY;
@@ -2801,5 +2825,5 @@ const pluridRouterNavigate = path => {
2801
2825
  window.dispatchEvent(event);
2802
2826
  };
2803
2827
 
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 };
2828
+ 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 };
2805
2829
  //# sourceMappingURL=index.es.js.map