@osmix/shared 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assert.d.ts +24 -0
- package/dist/assert.d.ts.map +1 -0
- package/dist/assert.js +28 -0
- package/dist/assert.js.map +1 -0
- package/dist/bbox-intersects.d.ts +15 -0
- package/dist/bbox-intersects.d.ts.map +1 -0
- package/dist/bbox-intersects.js +24 -0
- package/dist/bbox-intersects.js.map +1 -0
- package/dist/bytes-to-stream.d.ts +18 -0
- package/dist/bytes-to-stream.d.ts.map +1 -0
- package/dist/bytes-to-stream.js +25 -0
- package/dist/bytes-to-stream.js.map +1 -0
- package/dist/color.d.ts +4 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +33 -0
- package/dist/color.js.map +1 -0
- package/dist/concat-bytes.d.ts +5 -0
- package/dist/concat-bytes.d.ts.map +1 -0
- package/dist/concat-bytes.js +14 -0
- package/dist/concat-bytes.js.map +1 -0
- package/dist/coordinates.d.ts +28 -0
- package/dist/coordinates.d.ts.map +1 -0
- package/dist/coordinates.js +38 -0
- package/dist/coordinates.js.map +1 -0
- package/dist/haversine-distance.d.ts +16 -0
- package/dist/haversine-distance.d.ts.map +1 -0
- package/dist/haversine-distance.js +26 -0
- package/dist/haversine-distance.js.map +1 -0
- package/dist/lineclip.d.ts +2 -0
- package/dist/lineclip.d.ts.map +1 -0
- package/dist/lineclip.js +3 -0
- package/dist/lineclip.js.map +1 -0
- package/dist/progress.d.ts +42 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +53 -0
- package/dist/progress.js.map +1 -0
- package/dist/relation-kind.d.ts +69 -0
- package/dist/relation-kind.d.ts.map +1 -0
- package/dist/relation-kind.js +375 -0
- package/dist/relation-kind.js.map +1 -0
- package/dist/relation-multipolygon.d.ts +43 -0
- package/dist/relation-multipolygon.d.ts.map +1 -0
- package/dist/relation-multipolygon.js +195 -0
- package/dist/relation-multipolygon.js.map +1 -0
- package/dist/src/color.d.ts +4 -0
- package/dist/src/color.d.ts.map +1 -0
- package/dist/src/color.js +33 -0
- package/dist/src/color.js.map +1 -0
- package/dist/src/progress.d.ts +4 -2
- package/dist/src/progress.d.ts.map +1 -1
- package/dist/src/progress.js +17 -4
- package/dist/src/progress.js.map +1 -1
- package/dist/src/test/fixtures.d.ts.map +1 -1
- package/dist/src/test/fixtures.js +3 -0
- package/dist/src/test/fixtures.js.map +1 -1
- package/dist/stream-to-bytes.d.ts +18 -0
- package/dist/stream-to-bytes.d.ts.map +1 -0
- package/dist/stream-to-bytes.js +30 -0
- package/dist/stream-to-bytes.js.map +1 -0
- package/dist/test/fixtures.d.ts +36 -0
- package/dist/test/fixtures.d.ts.map +1 -0
- package/dist/test/fixtures.js +175 -0
- package/dist/test/fixtures.js.map +1 -0
- package/dist/throttle.d.ts +25 -0
- package/dist/throttle.d.ts.map +1 -0
- package/dist/throttle.js +34 -0
- package/dist/throttle.js.map +1 -0
- package/dist/tile.d.ts +34 -0
- package/dist/tile.d.ts.map +1 -0
- package/dist/tile.js +72 -0
- package/dist/tile.js.map +1 -0
- package/dist/transform-bytes.d.ts +24 -0
- package/dist/transform-bytes.d.ts.map +1 -0
- package/dist/transform-bytes.js +28 -0
- package/dist/transform-bytes.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +70 -0
- package/dist/utils.js.map +1 -0
- package/dist/way-is-area.d.ts +24 -0
- package/dist/way-is-area.d.ts.map +1 -0
- package/dist/way-is-area.js +104 -0
- package/dist/way-is-area.js.map +1 -0
- package/dist/zigzag.d.ts +33 -0
- package/dist/zigzag.d.ts.map +1 -0
- package/dist/zigzag.js +40 -0
- package/dist/zigzag.js.map +1 -0
- package/package.json +8 -7
- package/src/color.ts +37 -0
- package/src/progress.ts +23 -4
- package/src/test/fixtures.ts +3 -0
- package/tsconfig.build.json +5 -0
package/CHANGELOG.md
CHANGED
package/dist/assert.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion utilities for defensive programming.
|
|
3
|
+
*
|
|
4
|
+
* Provides typed assertion helpers that throw errors when conditions are not met,
|
|
5
|
+
* commonly used for index bounds checking and null/undefined guards.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Assert that a value is neither null nor undefined.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The value to check.
|
|
13
|
+
* @param message - Optional error message if assertion fails.
|
|
14
|
+
* @throws Error if value is null or undefined.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const item = array[index]
|
|
19
|
+
* assertValue(item, `No item at index ${index}`)
|
|
20
|
+
* // TypeScript now knows item is non-nullable
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertValue<T>(value?: T, message?: string): asserts value is NonNullable<T>;
|
|
24
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC5B,KAAK,CAAC,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAIjC"}
|
package/dist/assert.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assertion utilities for defensive programming.
|
|
3
|
+
*
|
|
4
|
+
* Provides typed assertion helpers that throw errors when conditions are not met,
|
|
5
|
+
* commonly used for index bounds checking and null/undefined guards.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Assert that a value is neither null nor undefined.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The value to check.
|
|
13
|
+
* @param message - Optional error message if assertion fails.
|
|
14
|
+
* @throws Error if value is null or undefined.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const item = array[index]
|
|
19
|
+
* assertValue(item, `No item at index ${index}`)
|
|
20
|
+
* // TypeScript now knows item is non-nullable
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function assertValue(value, message) {
|
|
24
|
+
if (value === undefined || value === null) {
|
|
25
|
+
throw Error(message ?? "Value is undefined or null");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAS,EACT,OAAgB;IAEhB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3C,MAAM,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAA;IACrD,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounding box intersection and containment utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions for checking spatial relationships between
|
|
5
|
+
* geographic bounding boxes (west, south, east, north format).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { GeoBbox2D } from "./types";
|
|
10
|
+
/**
|
|
11
|
+
* Check if two bounding boxes intersect or contain each other.
|
|
12
|
+
* Handles both partial overlaps and complete containment.
|
|
13
|
+
*/
|
|
14
|
+
export declare function bboxContainsOrIntersects(bb1: GeoBbox2D, bb2: GeoBbox2D): boolean;
|
|
15
|
+
//# sourceMappingURL=bbox-intersects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bbox-intersects.d.ts","sourceRoot":"","sources":["../src/bbox-intersects.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,WActE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounding box intersection and containment utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions for checking spatial relationships between
|
|
5
|
+
* geographic bounding boxes (west, south, east, north format).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Check if two bounding boxes intersect or contain each other.
|
|
11
|
+
* Handles both partial overlaps and complete containment.
|
|
12
|
+
*/
|
|
13
|
+
export function bboxContainsOrIntersects(bb1, bb2) {
|
|
14
|
+
const westIn = (bb1[0] >= bb2[0] && bb1[0] <= bb2[2]) ||
|
|
15
|
+
(bb2[0] >= bb1[0] && bb2[0] <= bb1[2]);
|
|
16
|
+
const eastIn = (bb1[2] >= bb2[0] && bb1[2] <= bb2[2]) ||
|
|
17
|
+
(bb2[2] >= bb1[0] && bb2[2] <= bb1[2]);
|
|
18
|
+
const northIn = (bb1[1] >= bb2[1] && bb1[1] <= bb2[3]) ||
|
|
19
|
+
(bb2[1] >= bb1[1] && bb2[1] <= bb1[3]);
|
|
20
|
+
const southIn = (bb1[3] >= bb2[1] && bb1[3] <= bb2[3]) ||
|
|
21
|
+
(bb2[3] >= bb1[1] && bb2[3] <= bb1[3]);
|
|
22
|
+
return (westIn || eastIn) && (northIn || southIn);
|
|
23
|
+
}
|
|
24
|
+
//# sourceM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AAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte array to stream conversion.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a Uint8Array in a ReadableStream for use with streaming APIs.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Create a ReadableStream from a Uint8Array.
|
|
10
|
+
*
|
|
11
|
+
* The stream will emit the entire byte array as a single chunk,
|
|
12
|
+
* then close immediately.
|
|
13
|
+
*
|
|
14
|
+
* @param bytes - The byte array to wrap.
|
|
15
|
+
* @returns A ReadableStream that emits the bytes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function bytesToStream(bytes: Uint8Array<ArrayBuffer>): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
18
|
+
//# sourceMappingURL=bytes-to-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes-to-stream.d.ts","sourceRoot":"","sources":["../src/bytes-to-stream.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,2CAO3D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte array to stream conversion.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a Uint8Array in a ReadableStream for use with streaming APIs.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Create a ReadableStream from a Uint8Array.
|
|
10
|
+
*
|
|
11
|
+
* The stream will emit the entire byte array as a single chunk,
|
|
12
|
+
* then close immediately.
|
|
13
|
+
*
|
|
14
|
+
* @param bytes - The byte array to wrap.
|
|
15
|
+
* @returns A ReadableStream that emits the bytes.
|
|
16
|
+
*/
|
|
17
|
+
export function bytesToStream(bytes) {
|
|
18
|
+
return new ReadableStream({
|
|
19
|
+
start(controller) {
|
|
20
|
+
controller.enqueue(bytes);
|
|
21
|
+
controller.close();
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=bytes-to-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes-to-stream.js","sourceRoot":"","sources":["../src/bytes-to-stream.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,KAA8B;IAC3D,OAAO,IAAI,cAAc,CAA0B;QAClD,KAAK,CAAC,UAAU;YACf,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACzB,UAAU,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;KACD,CAAC,CAAA;AACH,CAAC"}
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Rgba } from "./types";
|
|
2
|
+
export declare function normalizeHexColor(value: string | number | null | undefined): string | undefined;
|
|
3
|
+
export declare function hexColorToRgba(value: string | number | null | undefined): Rgba | undefined;
|
|
4
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInC,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,MAAM,GAAG,SAAS,CAiBpB;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,IAAI,GAAG,SAAS,CASlB"}
|
package/dist/color.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const hexPattern = /^[0-9a-fA-F]+$/;
|
|
2
|
+
export function normalizeHexColor(value) {
|
|
3
|
+
if (value === null || value === undefined)
|
|
4
|
+
return;
|
|
5
|
+
const raw = String(value).trim();
|
|
6
|
+
if (!raw)
|
|
7
|
+
return;
|
|
8
|
+
let hex = raw.startsWith("#") ? raw.slice(1) : raw;
|
|
9
|
+
if (!hexPattern.test(hex))
|
|
10
|
+
return;
|
|
11
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
12
|
+
hex = hex
|
|
13
|
+
.split("")
|
|
14
|
+
.map((char) => `${char}${char}`)
|
|
15
|
+
.join("");
|
|
16
|
+
}
|
|
17
|
+
else if (hex.length !== 6 && hex.length !== 8) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return `#${hex.toUpperCase()}`;
|
|
21
|
+
}
|
|
22
|
+
export function hexColorToRgba(value) {
|
|
23
|
+
const normalized = normalizeHexColor(value);
|
|
24
|
+
if (!normalized)
|
|
25
|
+
return;
|
|
26
|
+
const hex = normalized.slice(1);
|
|
27
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
28
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
29
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
30
|
+
const a = hex.length === 8 ? Number.parseInt(hex.slice(6, 8), 16) : 255;
|
|
31
|
+
return [r, g, b, a];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAEnC,MAAM,UAAU,iBAAiB,CAChC,KAAyC;IAEzC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CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACvE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concat-bytes.d.ts","sourceRoot":"","sources":["../src/concat-bytes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,GAC9B,UAAU,CAAC,WAAW,CAAC,CASzB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concatenates multiple `Uint8Array` segments into a contiguous array.
|
|
3
|
+
*/
|
|
4
|
+
export function concatBytes(parts) {
|
|
5
|
+
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
6
|
+
const out = new Uint8Array(new ArrayBuffer(total));
|
|
7
|
+
let offset = 0;
|
|
8
|
+
for (const p of parts) {
|
|
9
|
+
out.set(p, offset);
|
|
10
|
+
offset += p.length;
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=concat-bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concat-bytes.js","sourceRoot":"","sources":["../src/concat-bytes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAgC;IAEhC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACrD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAc,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/D,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QAClB,MAAM,IAAI,CAAC,CAAC,MAAM,CAAA;IACnB,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinate precision utilities for OSM data.
|
|
3
|
+
*
|
|
4
|
+
* OSM stores coordinates as integer microdegrees (7 decimal places) for
|
|
5
|
+
* compact storage and consistent precision. This module provides conversions
|
|
6
|
+
* between floating-point degrees and integer microdegrees.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { GeoBbox2D } from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* OSM coordinate scale: coordinates are stored as integer microdegrees.
|
|
13
|
+
* 1 microdegree = 1e-7 degrees = 0.0000001 degrees
|
|
14
|
+
*/
|
|
15
|
+
export declare const OSM_COORD_SCALE = 10000000;
|
|
16
|
+
/**
|
|
17
|
+
* Convert degrees to microdegrees (integer).
|
|
18
|
+
*/
|
|
19
|
+
export declare function toMicroDegrees(degrees: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Convert microdegrees (integer) to degrees (float).
|
|
22
|
+
*/
|
|
23
|
+
export declare function microToDegrees(microdegrees: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Convert a bounding box from degrees to microdegrees.
|
|
26
|
+
*/
|
|
27
|
+
export declare function bboxToMicroDegrees(bbox: GeoBbox2D): [minLon: number, minLat: number, maxLon: number, maxLat: number];
|
|
28
|
+
//# sourceMappingURL=coordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.d.ts","sourceRoot":"","sources":["../src/coordinates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;GAGG;AACH,eAAO,MAAM,eAAe,WAAM,CAAA;AAElC;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,SAAS,GACb,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAOlE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinate precision utilities for OSM data.
|
|
3
|
+
*
|
|
4
|
+
* OSM stores coordinates as integer microdegrees (7 decimal places) for
|
|
5
|
+
* compact storage and consistent precision. This module provides conversions
|
|
6
|
+
* between floating-point degrees and integer microdegrees.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* OSM coordinate scale: coordinates are stored as integer microdegrees.
|
|
12
|
+
* 1 microdegree = 1e-7 degrees = 0.0000001 degrees
|
|
13
|
+
*/
|
|
14
|
+
export const OSM_COORD_SCALE = 1e7;
|
|
15
|
+
/**
|
|
16
|
+
* Convert degrees to microdegrees (integer).
|
|
17
|
+
*/
|
|
18
|
+
export function toMicroDegrees(degrees) {
|
|
19
|
+
return Math.round(degrees * OSM_COORD_SCALE);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Convert microdegrees (integer) to degrees (float).
|
|
23
|
+
*/
|
|
24
|
+
export function microToDegrees(microdegrees) {
|
|
25
|
+
return microdegrees / OSM_COORD_SCALE;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert a bounding box from degrees to microdegrees.
|
|
29
|
+
*/
|
|
30
|
+
export function bboxToMicroDegrees(bbox) {
|
|
31
|
+
return [
|
|
32
|
+
toMicroDegrees(bbox[0]),
|
|
33
|
+
toMicroDegrees(bbox[1]),
|
|
34
|
+
toMicroDegrees(bbox[2]),
|
|
35
|
+
toMicroDegrees(bbox[3]),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=coordinates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.js","sourceRoot":"","sources":["../src/coordinates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,eAAe,CAAC,CAAA;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB;IAClD,OAAO,YAAY,GAAG,eAAe,CAAA;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAe;IAEf,OAAO;QACN,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACvB,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great-circle distance calculation using the Haversine formula.
|
|
3
|
+
*
|
|
4
|
+
* Computes the shortest distance between two points on a sphere,
|
|
5
|
+
* accounting for Earth's curvature. Accurate for most geographic distances.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Calculate the great-circle distance between two geographic points.
|
|
11
|
+
* @param p1 - The first point
|
|
12
|
+
* @param p2 - The second point
|
|
13
|
+
* @returns The haversine distance in meters
|
|
14
|
+
*/
|
|
15
|
+
export declare function haversineDistance(p1: [number, number], p2: [number, number]): number;
|
|
16
|
+
//# sourceMappingURL=haversine-distance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"haversine-distance.d.ts","sourceRoot":"","sources":["../src/haversine-distance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACpB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAClB,MAAM,CAWR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great-circle distance calculation using the Haversine formula.
|
|
3
|
+
*
|
|
4
|
+
* Computes the shortest distance between two points on a sphere,
|
|
5
|
+
* accounting for Earth's curvature. Accurate for most geographic distances.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Calculate the great-circle distance between two geographic points.
|
|
11
|
+
* @param p1 - The first point
|
|
12
|
+
* @param p2 - The second point
|
|
13
|
+
* @returns The haversine distance in meters
|
|
14
|
+
*/
|
|
15
|
+
export function haversineDistance(p1, p2) {
|
|
16
|
+
const R = 6371008.8; // Earth's radius in meters
|
|
17
|
+
const dLat = (p2[1] - p1[1]) * (Math.PI / 180);
|
|
18
|
+
const dLon = (p2[0] - p1[0]) * (Math.PI / 180);
|
|
19
|
+
const lat1 = p1[1] * (Math.PI / 180);
|
|
20
|
+
const lat2 = p2[1] * (Math.PI / 180);
|
|
21
|
+
const a = Math.sin(dLat / 2) ** 2 +
|
|
22
|
+
Math.sin(dLon / 2) ** 2 * Math.cos(lat1) * Math.cos(lat2);
|
|
23
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
24
|
+
return R * c;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=haversine-distance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"haversine-distance.js","sourceRoot":"","sources":["../src/haversine-distance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAChC,EAAoB,EACpB,EAAoB;IAEpB,MAAM,CAAC,GAAG,SAAS,CAAA,CAAC,2BAA2B;IAC/C,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IAC9C,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IAC9C,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IACpC,MAAM,CAAC,GACN,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC1D,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACxD,OAAO,CAAC,GAAG,CAAC,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineclip.d.ts","sourceRoot":"","sources":["../src/lineclip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/lineclip.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineclip.js","sourceRoot":"","sources":["../src/lineclip.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress event helpers for long-running operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides a standard interface for reporting progress from workers and
|
|
5
|
+
* async operations. Uses CustomEvent for cross-context communication.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export type ProgressLevel = "info" | "warn" | "error";
|
|
10
|
+
/**
|
|
11
|
+
* Progress payload containing a message and timestamp.
|
|
12
|
+
* Planned expansion to include percentage completion.
|
|
13
|
+
*/
|
|
14
|
+
export type Progress = {
|
|
15
|
+
msg: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
level: ProgressLevel;
|
|
18
|
+
};
|
|
19
|
+
/** CustomEvent carrying progress details. */
|
|
20
|
+
export interface ProgressEvent extends CustomEvent<Progress> {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Progress payload with current timestamp.
|
|
24
|
+
* @param msg - The progress message.
|
|
25
|
+
*/
|
|
26
|
+
export declare function progress(msg: string, level?: ProgressLevel): Progress;
|
|
27
|
+
/**
|
|
28
|
+
* Create a ProgressEvent with the given message.
|
|
29
|
+
* @param msg - The progress message.
|
|
30
|
+
*/
|
|
31
|
+
export declare function progressEvent(msg: string, level?: ProgressLevel): ProgressEvent;
|
|
32
|
+
/**
|
|
33
|
+
* Extract the message string from a progress event.
|
|
34
|
+
* @param event - The event to extract from.
|
|
35
|
+
*/
|
|
36
|
+
export declare function progressEventMessage(event: Event): string;
|
|
37
|
+
/**
|
|
38
|
+
* Log a progress event's message to the console.
|
|
39
|
+
* @param progress - The progress event to log.
|
|
40
|
+
*/
|
|
41
|
+
export declare function logProgress(progress: ProgressEvent): void;
|
|
42
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAErD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,aAAa,CAAA;CACpB,CAAA;AAED,6CAA6C;AAC7C,MAAM,WAAW,aAAc,SAAQ,WAAW,CAAC,QAAQ,CAAC;CAAG;AAE/D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,aAAsB,GAAG,QAAQ,CAM7E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,aAAsB,GAC3B,aAAa,CAEf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,QAclD"}
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress event helpers for long-running operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides a standard interface for reporting progress from workers and
|
|
5
|
+
* async operations. Uses CustomEvent for cross-context communication.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Create a Progress payload with current timestamp.
|
|
11
|
+
* @param msg - The progress message.
|
|
12
|
+
*/
|
|
13
|
+
export function progress(msg, level = "info") {
|
|
14
|
+
return {
|
|
15
|
+
msg,
|
|
16
|
+
timestamp: Date.now(),
|
|
17
|
+
level,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a ProgressEvent with the given message.
|
|
22
|
+
* @param msg - The progress message.
|
|
23
|
+
*/
|
|
24
|
+
export function progressEvent(msg, level = "info") {
|
|
25
|
+
return new CustomEvent("progress", { detail: progress(msg, level) });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Extract the message string from a progress event.
|
|
29
|
+
* @param event - The event to extract from.
|
|
30
|
+
*/
|
|
31
|
+
export function progressEventMessage(event) {
|
|
32
|
+
return event.detail.msg;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Log a progress event's message to the console.
|
|
36
|
+
* @param progress - The progress event to log.
|
|
37
|
+
*/
|
|
38
|
+
export function logProgress(progress) {
|
|
39
|
+
const level = progress.detail.level;
|
|
40
|
+
const message = progressEventMessage(progress);
|
|
41
|
+
switch (level) {
|
|
42
|
+
case "info":
|
|
43
|
+
console.log(message);
|
|
44
|
+
break;
|
|
45
|
+
case "warn":
|
|
46
|
+
console.warn(message);
|
|
47
|
+
break;
|
|
48
|
+
case "error":
|
|
49
|
+
console.error(message);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,QAAuB,MAAM;IAClE,OAAO;QACN,GAAG;QACH,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,KAAK;KACL,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC5B,GAAW,EACX,QAAuB,MAAM;IAE7B,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAY;IAChD,OAAQ,KAAuB,CAAC,MAAM,CAAC,GAAG,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,QAAuB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAA;IACnC,MAAM,OAAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAC9C,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,MAAM;YACV,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACpB,MAAK;QACN,KAAK,MAAM;YACV,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,MAAK;QACN,KAAK,OAAO;YACX,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACtB,MAAK;IACP,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relation kind detection and geometry building.
|
|
3
|
+
*
|
|
4
|
+
* Determines the semantic type of OSM relations (area, line, point, logic, super)
|
|
5
|
+
* based on their type tag and member structure. Also provides utilities for
|
|
6
|
+
* building geometries from relation members.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { LonLat, OsmRelation, OsmWay, RelationKind, RelationKindMetadata } from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* Get the semantic kind of a relation based on its type tag.
|
|
13
|
+
* Based on [OSM relation documentation](https://wiki.openstreetmap.org/wiki/Relation):
|
|
14
|
+
* - Areas: multipolygon, boundary, site
|
|
15
|
+
* - Lines: route, waterway, multilinestring, canal
|
|
16
|
+
* - Points: multipoint
|
|
17
|
+
* - Logic: restriction, route_master, network, collection
|
|
18
|
+
* - [Super: relations that contain other relations](https://wiki.openstreetmap.org/wiki/Super-relation)
|
|
19
|
+
*/
|
|
20
|
+
export declare function getRelationKind(relation: OsmRelation): RelationKind;
|
|
21
|
+
/**
|
|
22
|
+
* Get metadata about a relation kind.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getRelationKindMetadata(relation: OsmRelation): RelationKindMetadata;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a relation is an area relation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isAreaRelation(relation: OsmRelation): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a relation is a line relation.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isLineRelation(relation: OsmRelation): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a relation is a point relation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isPointRelation(relation: OsmRelation): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a relation is a super-relation (contains other relations).
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSuperRelation(relation: OsmRelation): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if a relation is a logical relation (non-geometric).
|
|
43
|
+
*/
|
|
44
|
+
export declare function isLogicRelation(relation: OsmRelation): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Build MultiLineString geometry from a line relation by connecting way members.
|
|
47
|
+
* Orders way members using their refs and handles role-based reversal.
|
|
48
|
+
* Returns an array of LineString coordinates (each LineString is an array of LonLat).
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildRelationLineStrings(relation: OsmRelation, getWay: (wayId: number) => OsmWay | null, getNodeCoordinates: (nodeId: number) => LonLat | undefined): LonLat[][];
|
|
51
|
+
/**
|
|
52
|
+
* Collect point coordinates from a point relation.
|
|
53
|
+
* Returns an array of LonLat coordinates from node members.
|
|
54
|
+
*/
|
|
55
|
+
export declare function collectRelationPoints(relation: OsmRelation, getNodeCoordinates: (nodeId: number) => LonLat | undefined): LonLat[];
|
|
56
|
+
/**
|
|
57
|
+
* Resolve nested relation members, flattening the hierarchy with cycle detection.
|
|
58
|
+
* Returns all nodes, ways, and relations that are members (directly or indirectly).
|
|
59
|
+
* @param relation - The relation to resolve
|
|
60
|
+
* @param getRelation - Function to get a relation by ID
|
|
61
|
+
* @param maxDepth - Maximum recursion depth (default: 10)
|
|
62
|
+
* @param visited - Set of relation IDs already visited (for cycle detection)
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveRelationMembers(relation: OsmRelation, getRelation: (relationId: number) => OsmRelation | null, maxDepth?: number, visited?: Set<number>): {
|
|
65
|
+
nodes: number[];
|
|
66
|
+
ways: number[];
|
|
67
|
+
relations: number[];
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=relation-kind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-kind.d.ts","sourceRoot":"","sources":["../src/relation-kind.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,MAAM,EACN,WAAW,EAEX,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,MAAM,SAAS,CAAA;AAEhB;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,CA4CnE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,WAAW,GACnB,oBAAoB,CAyCtB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,GA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