@mountaya/studio 0.1.0 → 0.2.0
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 +30 -0
- package/dist/agent/index.cjs +2561 -2815
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +766 -786
- package/dist/agent/index.d.ts +766 -786
- package/dist/agent/index.js +2553 -2790
- package/dist/agent/index.js.map +1 -1
- package/dist/chunk-3Oi_Zrtm.js +9 -0
- package/dist/chunk-3Oi_Zrtm.js.map +1 -0
- package/dist/chunk-B18OPIu_.js +6 -0
- package/dist/chunk-B18OPIu_.js.map +1 -0
- package/dist/chunk-B5Uz3Qct.cjs +15 -0
- package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
- package/dist/chunk-BBEJwkd3.d.cts +839 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BKMFOe-N.js +171 -0
- package/dist/chunk-BKMFOe-N.js.map +1 -0
- package/dist/chunk-BP4uy7E1.d.ts +11583 -0
- package/dist/chunk-BSHTsFiB.js +1403 -0
- package/dist/chunk-BSHTsFiB.js.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BaPiaz5X.cjs +115 -0
- package/dist/chunk-BaPiaz5X.cjs.map +1 -0
- package/dist/chunk-BeCVpkYr.cjs +542 -0
- package/dist/chunk-BeCVpkYr.cjs.map +1 -0
- package/dist/chunk-BgngsvK8.cjs +6202 -0
- package/dist/chunk-BgngsvK8.cjs.map +1 -0
- package/dist/chunk-BhInd7CJ.d.cts +253 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-By9ZnkVI.js +60 -0
- package/dist/chunk-By9ZnkVI.js.map +1 -0
- package/dist/chunk-BzqPhxsz.cjs +367 -0
- package/dist/chunk-BzqPhxsz.cjs.map +1 -0
- package/dist/chunk-C2mMX81q.d.ts +443 -0
- package/dist/chunk-C2rr9Q0V.cjs +1402 -0
- package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
- package/dist/{directorThreads-CqmvsV8b.d.cts → chunk-CDJCbwIQ.d.cts} +20 -22
- package/dist/chunk-CLGvBOVH.d.cts +1654 -0
- package/dist/chunk-COdw1dc6.d.ts +525 -0
- package/dist/chunk-CQCJnT2i.d.ts +511 -0
- package/dist/chunk-CSyHY67q.cjs +353 -0
- package/dist/chunk-CSyHY67q.cjs.map +1 -0
- package/dist/chunk-CiK1Iqrv.js +950 -0
- package/dist/chunk-CiK1Iqrv.js.map +1 -0
- package/dist/chunk-CmJBgSwZ.cjs +24 -0
- package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
- package/dist/chunk-CnrsRK2u.cjs +83 -0
- package/dist/chunk-CnrsRK2u.cjs.map +1 -0
- package/dist/chunk-Co782_9r.js +326 -0
- package/dist/chunk-Co782_9r.js.map +1 -0
- package/dist/chunk-Csr3KDpZ.cjs +32 -0
- package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
- package/dist/chunk-CwkmccXv.js +89 -0
- package/dist/chunk-CwkmccXv.js.map +1 -0
- package/dist/chunk-D0Q4iL9B.cjs +255 -0
- package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
- package/dist/chunk-DFwiSzUS.cjs +72 -0
- package/dist/chunk-DFwiSzUS.cjs.map +1 -0
- package/dist/chunk-DIFayl2P.d.cts +443 -0
- package/dist/chunk-DIGF58ux.d.cts +525 -0
- package/dist/chunk-DKuuuld5.js +101 -0
- package/dist/chunk-DKuuuld5.js.map +1 -0
- package/dist/chunk-DMePkFEo.js +5054 -0
- package/dist/chunk-DMePkFEo.js.map +1 -0
- package/dist/chunk-DO5SIBgu.js +305 -0
- package/dist/chunk-DO5SIBgu.js.map +1 -0
- package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
- package/dist/{tabs-B2nRO4p_.d.ts → chunk-DThaaNeb.d.cts} +2 -2
- package/dist/{tabs-B2nRO4p_.d.cts → chunk-DThaaNeb.d.ts} +2 -2
- package/dist/{directorThreads-CqmvsV8b.d.ts → chunk-DUQzjUJy.d.ts} +20 -22
- package/dist/chunk-DX37IPhV.cjs +1903 -0
- package/dist/chunk-DX37IPhV.cjs.map +1 -0
- package/dist/chunk-Damps5Tk.cjs +155 -0
- package/dist/chunk-Damps5Tk.cjs.map +1 -0
- package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
- package/dist/chunk-De0vAASv.d.ts +253 -0
- package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
- package/dist/chunk-DjEvqvPA.cjs +43 -0
- package/dist/chunk-DjEvqvPA.cjs.map +1 -0
- package/dist/{saveFile-j-1kkApx.d.cts → chunk-DkwDzwvu.d.cts} +7 -9
- package/dist/{saveFile-j-1kkApx.d.ts → chunk-DkwDzwvu.d.ts} +7 -9
- package/dist/chunk-Dmszv9If.js +71 -0
- package/dist/chunk-Dmszv9If.js.map +1 -0
- package/dist/chunk-Dp_ftNWY.d.cts +511 -0
- package/dist/chunk-DsHQySz0.js +31 -0
- package/dist/chunk-DsHQySz0.js.map +1 -0
- package/dist/chunk-DwoUyHHh.js +281 -0
- package/dist/chunk-DwoUyHHh.js.map +1 -0
- package/dist/chunk-IaIDQflj.d.cts +2315 -0
- package/dist/chunk-IaIDQflj.d.ts +2315 -0
- package/dist/chunk-cVXLsZfL.d.ts +839 -0
- package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
- package/dist/chunk-nJQxbOwQ.cjs +8962 -0
- package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
- package/dist/chunk-o9jaxhCO.js +8852 -0
- package/dist/chunk-o9jaxhCO.js.map +1 -0
- package/dist/chunk-p-Tt_Lwz.js +14 -0
- package/dist/chunk-p-Tt_Lwz.js.map +1 -0
- package/dist/engines/index.cjs +2046 -3401
- package/dist/engines/index.cjs.map +1 -1
- package/dist/engines/index.d.cts +1510 -1550
- package/dist/engines/index.d.ts +1510 -1550
- package/dist/engines/index.js +2039 -3380
- package/dist/engines/index.js.map +1 -1
- package/dist/handlers/index.cjs +47 -93
- package/dist/handlers/index.cjs.map +1 -1
- package/dist/handlers/index.d.cts +61 -103
- package/dist/handlers/index.d.ts +61 -103
- package/dist/handlers/index.js +27 -36
- package/dist/handlers/index.js.map +1 -1
- package/dist/index.cjs +3347 -4398
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7297
- package/dist/index.d.ts +8 -7297
- package/dist/index.js +2997 -3187
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +482 -949
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +44 -61
- package/dist/plugins/index.d.ts +44 -61
- package/dist/plugins/index.js +471 -915
- package/dist/plugins/index.js.map +1 -1
- package/dist/seams/index.cjs +77 -140
- package/dist/seams/index.cjs.map +1 -1
- package/dist/seams/index.d.cts +125 -158
- package/dist/seams/index.d.ts +125 -158
- package/dist/seams/index.js +41 -71
- package/dist/seams/index.js.map +1 -1
- package/dist/strings/fr/index.cjs +2130 -2116
- package/dist/strings/fr/index.cjs.map +1 -1
- package/dist/strings/fr/index.d.cts +3 -5
- package/dist/strings/fr/index.d.ts +3 -5
- package/dist/strings/fr/index.js +2125 -2114
- package/dist/strings/fr/index.js.map +1 -1
- package/dist/strings/index.cjs +2331 -2625
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +3 -731
- package/dist/strings/index.d.ts +3 -731
- package/dist/strings/index.js +2324 -2615
- package/dist/strings/index.js.map +1 -1
- package/dist/testing/index.cjs +214 -276
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +61 -121
- package/dist/testing/index.d.ts +61 -121
- package/dist/testing/index.js +208 -273
- package/dist/testing/index.js.map +1 -1
- package/dist/time/index.cjs +23 -23
- package/dist/time/index.cjs.map +1 -1
- package/dist/time/index.d.cts +5 -7
- package/dist/time/index.d.ts +5 -7
- package/dist/time/index.js +18 -21
- package/dist/time/index.js.map +1 -1
- package/package.json +14 -15
- package/src/agent/rules/stateDelta.ts +1 -0
- package/src/agent/stores/agentThreads.ts +1 -4
- package/src/bus/rules/bus.ts +1 -2
- package/src/bus/rules/defineRegistry.ts +3 -5
- package/src/bus/rules/types.ts +6 -7
- package/src/chrome/stores/uiStore.ts +4 -2
- package/src/embed/rules/fieldDependencies.ts +2 -0
- package/src/embed/rules/safetyRules.ts +2 -0
- package/src/embed/rules/tableCode.ts +4 -3
- package/src/index.ts +6 -27
- package/src/itinerary/rules/import.ts +6 -8
- package/src/plugins/contracts/plugin.ts +4 -2
- package/src/seams/rules/formatters.ts +5 -3
- package/src/testing/index.ts +1 -5
- package/src/viewer/rules/platformViewer.ts +1 -0
- package/dist/bus-BwiNiXdH.d.ts +0 -514
- package/dist/bus-DzmhPwdK.d.cts +0 -514
- package/dist/chainModel-B23pEP_1.d.cts +0 -127
- package/dist/chainModel-B23pEP_1.d.ts +0 -127
- package/dist/chunk-2HFY7ETU.js +0 -5721
- package/dist/chunk-2HFY7ETU.js.map +0 -1
- package/dist/chunk-355TOXSB.js +0 -72
- package/dist/chunk-355TOXSB.js.map +0 -1
- package/dist/chunk-4ZCUZVSV.js +0 -10275
- package/dist/chunk-4ZCUZVSV.js.map +0 -1
- package/dist/chunk-6HEKY3NF.js +0 -95
- package/dist/chunk-6HEKY3NF.js.map +0 -1
- package/dist/chunk-7GFLGGBX.cjs +0 -8
- package/dist/chunk-7GFLGGBX.cjs.map +0 -1
- package/dist/chunk-7NBRCENN.cjs +0 -19
- package/dist/chunk-7NBRCENN.cjs.map +0 -1
- package/dist/chunk-AF5GCXE3.js +0 -8
- package/dist/chunk-AF5GCXE3.js.map +0 -1
- package/dist/chunk-CJDIFRGZ.cjs +0 -2005
- package/dist/chunk-CJDIFRGZ.cjs.map +0 -1
- package/dist/chunk-CNPZY7N3.js +0 -349
- package/dist/chunk-CNPZY7N3.js.map +0 -1
- package/dist/chunk-DZJHTWSF.cjs +0 -45
- package/dist/chunk-DZJHTWSF.cjs.map +0 -1
- package/dist/chunk-EABIHHWA.js +0 -42
- package/dist/chunk-EABIHHWA.js.map +0 -1
- package/dist/chunk-EKZWV6RS.cjs +0 -415
- package/dist/chunk-EKZWV6RS.cjs.map +0 -1
- package/dist/chunk-EOKRXXAC.cjs +0 -24
- package/dist/chunk-EOKRXXAC.cjs.map +0 -1
- package/dist/chunk-F73W2ZTJ.js +0 -1126
- package/dist/chunk-F73W2ZTJ.js.map +0 -1
- package/dist/chunk-H4DVOZ5O.js +0 -1897
- package/dist/chunk-H4DVOZ5O.js.map +0 -1
- package/dist/chunk-HI52PBFT.cjs +0 -10314
- package/dist/chunk-HI52PBFT.cjs.map +0 -1
- package/dist/chunk-IDBXFBLG.cjs +0 -1225
- package/dist/chunk-IDBXFBLG.cjs.map +0 -1
- package/dist/chunk-LBWTJZUJ.js +0 -297
- package/dist/chunk-LBWTJZUJ.js.map +0 -1
- package/dist/chunk-NCLA6DKD.cjs +0 -310
- package/dist/chunk-NCLA6DKD.cjs.map +0 -1
- package/dist/chunk-O4MC5DPD.js +0 -19
- package/dist/chunk-O4MC5DPD.js.map +0 -1
- package/dist/chunk-OP37FKW6.cjs +0 -98
- package/dist/chunk-OP37FKW6.cjs.map +0 -1
- package/dist/chunk-OQSYFH3Z.cjs +0 -5945
- package/dist/chunk-OQSYFH3Z.cjs.map +0 -1
- package/dist/chunk-PACIO4NS.cjs +0 -26
- package/dist/chunk-PACIO4NS.cjs.map +0 -1
- package/dist/chunk-PSZ2R3TC.cjs +0 -75
- package/dist/chunk-PSZ2R3TC.cjs.map +0 -1
- package/dist/chunk-QFO5CZG2.cjs +0 -136
- package/dist/chunk-QFO5CZG2.cjs.map +0 -1
- package/dist/chunk-QL63MUEW.cjs +0 -140
- package/dist/chunk-QL63MUEW.cjs.map +0 -1
- package/dist/chunk-RFUPPVZO.js +0 -17
- package/dist/chunk-RFUPPVZO.js.map +0 -1
- package/dist/chunk-RPG2LWMP.js +0 -23
- package/dist/chunk-RPG2LWMP.js.map +0 -1
- package/dist/chunk-TIBXK6B7.cjs +0 -12
- package/dist/chunk-TIBXK6B7.cjs.map +0 -1
- package/dist/chunk-UU65VNEV.js +0 -381
- package/dist/chunk-UU65VNEV.js.map +0 -1
- package/dist/chunk-VGX6TR2I.js +0 -209
- package/dist/chunk-VGX6TR2I.js.map +0 -1
- package/dist/chunk-WUTDDBVP.js +0 -130
- package/dist/chunk-WUTDDBVP.js.map +0 -1
- package/dist/chunk-WVQQLKCI.cjs +0 -224
- package/dist/chunk-WVQQLKCI.cjs.map +0 -1
- package/dist/chunk-WZYXG3SE.js +0 -111
- package/dist/chunk-WZYXG3SE.js.map +0 -1
- package/dist/chunk-XDI2X3KE.js +0 -6
- package/dist/chunk-XDI2X3KE.js.map +0 -1
- package/dist/chunk-XKHLRIC7.cjs +0 -381
- package/dist/chunk-XKHLRIC7.cjs.map +0 -1
- package/dist/context-DNtd2WUv.d.cts +0 -11666
- package/dist/context-DgB72Bur.d.ts +0 -11666
- package/dist/en-Bu4Ti9Ev.d.cts +0 -2315
- package/dist/en-Bu4Ti9Ev.d.ts +0 -2315
- package/dist/shareLink-B6hlt942.d.ts +0 -144
- package/dist/shareLink-C7rIMb7x.d.ts +0 -527
- package/dist/shareLink-CnTxxXjp.d.cts +0 -144
- package/dist/shareLink-DyZVYH2V.d.cts +0 -527
- package/dist/studioPlugin-C3C7VjMy.d.ts +0 -847
- package/dist/studioPlugin-Cf3OBNUv.d.cts +0 -847
- package/dist/types-BzJRV6UI.d.cts +0 -845
- package/dist/types-BzJRV6UI.d.ts +0 -845
- package/dist/zoneForm-CdYNtnnA.d.cts +0 -320
- package/dist/zoneForm-mG85yt5e.d.ts +0 -320
package/dist/chunk-IDBXFBLG.cjs
DELETED
|
@@ -1,1225 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var z6 = require('zod');
|
|
4
|
-
var errors = require('@mountaya/elements/errors');
|
|
5
|
-
var geo = require('@mountaya/elements/geo');
|
|
6
|
-
var data = require('@mountaya/elements/data');
|
|
7
|
-
var profile = require('@mountaya/elements/profile');
|
|
8
|
-
var units = require('@mountaya/elements/units');
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var z6__namespace = /*#__PURE__*/_interopNamespace(z6);
|
|
29
|
-
|
|
30
|
-
// src/bus/contracts/noData.ts
|
|
31
|
-
var toolNoDataSchema = z6__namespace.undefined();
|
|
32
|
-
var restActivitySlugs = {
|
|
33
|
-
"hiking-and-trail": "hiking-and-trail",
|
|
34
|
-
"professional-trail": "professional-trail",
|
|
35
|
-
running: "running",
|
|
36
|
-
"road-cycling": "road-cycling",
|
|
37
|
-
"gravel-bike": "gravel-bike",
|
|
38
|
-
"mountain-bike": "mountain-bike",
|
|
39
|
-
"backcountry-skiing": "backcountry-skiing",
|
|
40
|
-
"ski-touring": "ski-touring",
|
|
41
|
-
"cross-country-skiing": "cross-country-skiing",
|
|
42
|
-
"snowshoe-walking": "snowshoe-walking"
|
|
43
|
-
};
|
|
44
|
-
var restActivitySlugSchema = z6__namespace.enum(restActivitySlugs);
|
|
45
|
-
var toDataActivity = (slug) => {
|
|
46
|
-
const parsed = restActivitySlugSchema.safeParse(slug);
|
|
47
|
-
if (!parsed.success) {
|
|
48
|
-
throw new errors.MountayaElementsError(
|
|
49
|
-
`toDataActivity: ${JSON.stringify(slug)} is not an activity slug of the REST API; pass one of ${restActivitySlugSchema.options.join(", ")}`,
|
|
50
|
-
{ cause: parsed.error }
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return parsed.data.toUpperCase().replaceAll("-", "_");
|
|
54
|
-
};
|
|
55
|
-
var toRestActivity = (value) => (
|
|
56
|
-
// The same test proves every Data API member's transform is a REST slug.
|
|
57
|
-
value.toLowerCase().replaceAll("_", "-")
|
|
58
|
-
);
|
|
59
|
-
var isRestActivity = (slug) => Object.hasOwn(restActivitySlugs, slug);
|
|
60
|
-
var isDataActivity = (slug) => {
|
|
61
|
-
const rest = slug.toLowerCase().replaceAll("_", "-");
|
|
62
|
-
return isRestActivity(rest) && rest.toUpperCase().replaceAll("-", "_") === slug;
|
|
63
|
-
};
|
|
64
|
-
var resolveActivity = (slug) => {
|
|
65
|
-
if (isRestActivity(slug)) {
|
|
66
|
-
return slug;
|
|
67
|
-
}
|
|
68
|
-
return isDataActivity(slug) ? toRestActivity(slug) : void 0;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// src/zones/rules/zoneDefaults.ts
|
|
72
|
-
var DEFAULT_ZONE_MODE = "circle";
|
|
73
|
-
var DEFAULT_ZONE_CREATE_METHOD = "draw";
|
|
74
|
-
var DEFAULT_ZONE_LEVEL = "info";
|
|
75
|
-
var itinerarySelectionSchema = z6__namespace.discriminatedUnion("kind", [
|
|
76
|
-
z6__namespace.object({ id: z6__namespace.string(), kind: z6__namespace.literal("segment") }),
|
|
77
|
-
z6__namespace.object({ id: z6__namespace.string(), kind: z6__namespace.literal("waypoint") })
|
|
78
|
-
]);
|
|
79
|
-
var mapSegments = (itinerary, transform) => {
|
|
80
|
-
if (!itinerary) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
return { ...itinerary, segments: transform(itinerary.segments) };
|
|
84
|
-
};
|
|
85
|
-
var applyWaypointDetails = (waypoint, details) => {
|
|
86
|
-
const { amenities, ...rest } = details;
|
|
87
|
-
return {
|
|
88
|
-
...waypoint,
|
|
89
|
-
...rest,
|
|
90
|
-
...amenities === void 0 ? {} : { amenities: amenities ?? [] }
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
var mapWaypoints = (itinerary, transform) => {
|
|
94
|
-
if (!itinerary) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return { ...itinerary, waypoints: transform(itinerary.waypoints) };
|
|
98
|
-
};
|
|
99
|
-
var patchSegment = (state, segmentId, patch) => {
|
|
100
|
-
if (!state.activeItinerary?.segments.some((segment) => segment.id === segmentId)) {
|
|
101
|
-
return state;
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
activeItinerary: mapSegments(
|
|
105
|
-
state.activeItinerary,
|
|
106
|
-
(segments) => segments.map((segment) => segment.id === segmentId ? patch(segment) : segment)
|
|
107
|
-
)
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
var patchWaypoint = (state, waypointId, patch) => {
|
|
111
|
-
if (!state.activeItinerary?.waypoints.some((waypoint) => waypoint.id === waypointId)) {
|
|
112
|
-
return state;
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
activeItinerary: mapWaypoints(
|
|
116
|
-
state.activeItinerary,
|
|
117
|
-
(waypoints) => waypoints.map((waypoint) => waypoint.id === waypointId ? patch(waypoint) : waypoint)
|
|
118
|
-
)
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
var renumber = (items) => items.map((item, index) => ({ ...item, position: index }));
|
|
122
|
-
var itineraryInitialState = {
|
|
123
|
-
activeItinerary: null,
|
|
124
|
-
hoveredEntity: null,
|
|
125
|
-
selection: null
|
|
126
|
-
};
|
|
127
|
-
var createItinerarySlice = (set) => ({
|
|
128
|
-
moveWaypoint: (waypointId, geometry) => set(
|
|
129
|
-
(state) => patchWaypoint(state, waypointId, (waypoint) => ({ ...waypoint, geojson: geometry }))
|
|
130
|
-
),
|
|
131
|
-
recolorSegment: (segmentId, color) => set((state) => patchSegment(state, segmentId, (segment) => ({ ...segment, color }))),
|
|
132
|
-
recolorWaypoint: (waypointId, color) => set((state) => patchWaypoint(state, waypointId, (waypoint) => ({ ...waypoint, color }))),
|
|
133
|
-
setWaypointDetails: (waypointId, details) => set(
|
|
134
|
-
(state) => patchWaypoint(state, waypointId, (waypoint) => applyWaypointDetails(waypoint, details))
|
|
135
|
-
),
|
|
136
|
-
renameActiveItinerary: (name) => set(
|
|
137
|
-
(state) => state.activeItinerary ? { activeItinerary: { ...state.activeItinerary, name } } : state
|
|
138
|
-
),
|
|
139
|
-
renameSegment: (segmentId, name) => set((state) => patchSegment(state, segmentId, (segment) => ({ ...segment, name }))),
|
|
140
|
-
renameWaypoint: (waypointId, name) => set((state) => patchWaypoint(state, waypointId, (waypoint) => ({ ...waypoint, name }))),
|
|
141
|
-
select: (selection) => set({ selection }),
|
|
142
|
-
setActiveItinerary: (activeItinerary) => set({ activeItinerary }),
|
|
143
|
-
setHoveredEntity: (hoveredEntity) => (
|
|
144
|
-
// The pointer sweeping a line fires enter and leave over the same feature, at pointer rate.
|
|
145
|
-
// An equal write hands the state back as it stands, which tells no listener, rather than
|
|
146
|
-
// reseating the slot and running every selector of the studio.
|
|
147
|
-
set(
|
|
148
|
-
(state) => state.hoveredEntity?.id === hoveredEntity?.id && state.hoveredEntity?.kind === hoveredEntity?.kind ? state : { hoveredEntity }
|
|
149
|
-
)
|
|
150
|
-
),
|
|
151
|
-
setSegmentGeometry: (segmentId, geometry) => set(
|
|
152
|
-
(state) => patchSegment(state, segmentId, (segment) => ({ ...segment, geojson: geometry }))
|
|
153
|
-
),
|
|
154
|
-
setSegmentSpeed: (segmentId, speed, duration) => set((state) => patchSegment(state, segmentId, (segment) => ({ ...segment, duration, speed }))),
|
|
155
|
-
setWaypointIcon: (waypointId, icon) => set((state) => patchWaypoint(state, waypointId, (waypoint) => ({ ...waypoint, icon })))
|
|
156
|
-
});
|
|
157
|
-
var DISPLAY_NAME_MAX_LENGTH = 30;
|
|
158
|
-
var DISPLAY_NAME_MIN_LENGTH = 2;
|
|
159
|
-
var displayNameSchema = z6__namespace.string().trim().min(DISPLAY_NAME_MIN_LENGTH).max(DISPLAY_NAME_MAX_LENGTH);
|
|
160
|
-
var fitDisplayName = (text) => {
|
|
161
|
-
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
162
|
-
const characters = Array.from(collapsed);
|
|
163
|
-
const lead = characters.slice(0, DISPLAY_NAME_MAX_LENGTH + 1).join("");
|
|
164
|
-
const boundary = lead.lastIndexOf(" ");
|
|
165
|
-
const fitted = characters.length <= DISPLAY_NAME_MAX_LENGTH ? collapsed : boundary > 0 ? lead.slice(0, boundary).trimEnd() : characters.slice(0, DISPLAY_NAME_MAX_LENGTH).join("");
|
|
166
|
-
return displayNameSchema.safeParse(fitted).success ? fitted : "";
|
|
167
|
-
};
|
|
168
|
-
var DESCRIPTION_MAX_LENGTH = 100;
|
|
169
|
-
var descriptionSchema = z6__namespace.string().trim().max(DESCRIPTION_MAX_LENGTH);
|
|
170
|
-
var draftActivityInput = z6__namespace.object({
|
|
171
|
-
activityId: z6__namespace.string().nullable()
|
|
172
|
-
});
|
|
173
|
-
var draftNameInput = z6__namespace.object({
|
|
174
|
-
name: z6__namespace.string()
|
|
175
|
-
});
|
|
176
|
-
var draftOrganizationInput = z6__namespace.object({
|
|
177
|
-
organizationId: z6__namespace.string().nullable()
|
|
178
|
-
});
|
|
179
|
-
var draftPrivateInput = z6__namespace.object({
|
|
180
|
-
isPrivate: z6__namespace.boolean()
|
|
181
|
-
});
|
|
182
|
-
var draftCollectionsInput = z6__namespace.object({
|
|
183
|
-
collectionIds: z6__namespace.array(z6__namespace.string())
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
// src/rules/origin.ts
|
|
187
|
-
var originBase = (origin) => origin.endsWith("/") ? origin.slice(0, -1) : origin;
|
|
188
|
-
|
|
189
|
-
// src/share/rules/link.ts
|
|
190
|
-
var shareLinkTargetSchema = z6__namespace.object({
|
|
191
|
-
id: z6__namespace.string(),
|
|
192
|
-
kind: z6__namespace.enum(["collection", "itinerary"])
|
|
193
|
-
});
|
|
194
|
-
var buildShareSearch = (input) => input.collectionId !== void 0 ? [
|
|
195
|
-
["collection_id", input.collectionId],
|
|
196
|
-
["share_token", input.shareToken]
|
|
197
|
-
] : [
|
|
198
|
-
["itinerary_id", input.itineraryId],
|
|
199
|
-
["share_token", input.shareToken]
|
|
200
|
-
];
|
|
201
|
-
var buildShareSrc = (origin, input) => {
|
|
202
|
-
const params = new URLSearchParams(buildShareSearch(input));
|
|
203
|
-
return `${originBase(origin)}/studio/share?${params.toString()}`;
|
|
204
|
-
};
|
|
205
|
-
var switchOverridesSchema = z6__namespace.object({
|
|
206
|
-
terrain: z6__namespace.string().optional(),
|
|
207
|
-
withAccessRestrictions: z6__namespace.boolean().optional(),
|
|
208
|
-
withDirectionsControl: z6__namespace.boolean().optional(),
|
|
209
|
-
withDownloadControl: z6__namespace.boolean().optional(),
|
|
210
|
-
withNavigationControl: z6__namespace.boolean().optional(),
|
|
211
|
-
withOverlays: z6__namespace.array(z6__namespace.string()).nullable().optional(),
|
|
212
|
-
withOverlaysControl: z6__namespace.boolean().optional(),
|
|
213
|
-
withPreferencesControl: z6__namespace.boolean().optional(),
|
|
214
|
-
withProfileAnalysis: z6__namespace.boolean().optional(),
|
|
215
|
-
withProfileCharacteristics: z6__namespace.boolean().optional(),
|
|
216
|
-
withProfileElevation: z6__namespace.boolean().optional(),
|
|
217
|
-
withProfilePaceControl: z6__namespace.boolean().optional(),
|
|
218
|
-
withStreetviewControl: z6__namespace.boolean().optional(),
|
|
219
|
-
withTerrains: z6__namespace.array(z6__namespace.string()).nullable().optional()
|
|
220
|
-
});
|
|
221
|
-
var embedSetContentInput = switchOverridesSchema.extend({
|
|
222
|
-
itineraryId: z6__namespace.string().nullable()
|
|
223
|
-
});
|
|
224
|
-
var SET_ITINERARY_MESSAGE = "mountaya:setItinerary";
|
|
225
|
-
var READY_MESSAGE = "mountaya:ready";
|
|
226
|
-
var REQUEST_CAMERA_MESSAGE = "mountaya:requestCamera";
|
|
227
|
-
var CAMERA_MESSAGE = "mountaya:camera";
|
|
228
|
-
var requestCameraMessageSchema = z6__namespace.object({
|
|
229
|
-
type: z6__namespace.literal(REQUEST_CAMERA_MESSAGE)
|
|
230
|
-
});
|
|
231
|
-
var cameraMessageSchema = z6__namespace.object({
|
|
232
|
-
bearing: z6__namespace.number(),
|
|
233
|
-
center: z6__namespace.tuple([z6__namespace.number(), z6__namespace.number()]),
|
|
234
|
-
pitch: z6__namespace.number(),
|
|
235
|
-
type: z6__namespace.literal(CAMERA_MESSAGE),
|
|
236
|
-
zoom: z6__namespace.number()
|
|
237
|
-
});
|
|
238
|
-
var REQUEST_SESSION_TOKEN_MESSAGE = "mountaya:requestSessionToken";
|
|
239
|
-
var SET_SESSION_TOKEN_MESSAGE = "mountaya:setSessionToken";
|
|
240
|
-
var requestSessionTokenMessageSchema = z6__namespace.object({
|
|
241
|
-
type: z6__namespace.literal(REQUEST_SESSION_TOKEN_MESSAGE)
|
|
242
|
-
});
|
|
243
|
-
var setSessionTokenMessageSchema = z6__namespace.object({
|
|
244
|
-
expiresAt: z6__namespace.iso.datetime({ offset: true }),
|
|
245
|
-
token: z6__namespace.string().regex(/^sess_\S+$/),
|
|
246
|
-
type: z6__namespace.literal(SET_SESSION_TOKEN_MESSAGE)
|
|
247
|
-
});
|
|
248
|
-
var inboundBridgeMessageSchema = z6__namespace.discriminatedUnion("type", [
|
|
249
|
-
embedSetContentInput.extend({ type: z6__namespace.literal(SET_ITINERARY_MESSAGE) })
|
|
250
|
-
]);
|
|
251
|
-
var readyErrorSchema = z6__namespace.enum(["timeout", "not_found"]).nullable();
|
|
252
|
-
var mapBoundsSchema = z6__namespace.tuple([z6__namespace.number(), z6__namespace.number(), z6__namespace.number(), z6__namespace.number()]).nullable();
|
|
253
|
-
var readyMessageSchema = z6__namespace.object({
|
|
254
|
-
bounds: mapBoundsSchema,
|
|
255
|
-
error: readyErrorSchema,
|
|
256
|
-
itineraryId: z6__namespace.string().nullable(),
|
|
257
|
-
terrain: z6__namespace.string(),
|
|
258
|
-
type: z6__namespace.literal(READY_MESSAGE)
|
|
259
|
-
});
|
|
260
|
-
var surfaceTypes = {
|
|
261
|
-
unknown: "unknown",
|
|
262
|
-
paved: "paved",
|
|
263
|
-
unpaved: "unpaved",
|
|
264
|
-
asphalt: "asphalt",
|
|
265
|
-
concrete: "concrete",
|
|
266
|
-
cobblestone: "cobblestone",
|
|
267
|
-
metal: "metal",
|
|
268
|
-
wood: "wood",
|
|
269
|
-
"compacted-gravel": "compacted-gravel",
|
|
270
|
-
"fine-gravel": "fine-gravel",
|
|
271
|
-
gravel: "gravel",
|
|
272
|
-
dirt: "dirt",
|
|
273
|
-
ground: "ground",
|
|
274
|
-
ice: "ice",
|
|
275
|
-
"paving-stones": "paving-stones",
|
|
276
|
-
sand: "sand",
|
|
277
|
-
woodchips: "woodchips",
|
|
278
|
-
grass: "grass",
|
|
279
|
-
"grass-paver": "grass-paver"
|
|
280
|
-
};
|
|
281
|
-
var surfaceTypeSchema = z6__namespace.enum(surfaceTypes);
|
|
282
|
-
var wayTypes = {
|
|
283
|
-
unknown: "unknown",
|
|
284
|
-
"state-road": "state-road",
|
|
285
|
-
road: "road",
|
|
286
|
-
street: "street",
|
|
287
|
-
path: "path",
|
|
288
|
-
track: "track",
|
|
289
|
-
cycleway: "cycleway",
|
|
290
|
-
footway: "footway",
|
|
291
|
-
steps: "steps",
|
|
292
|
-
ferry: "ferry",
|
|
293
|
-
construction: "construction"
|
|
294
|
-
};
|
|
295
|
-
var wayTypeSchema = z6__namespace.enum(wayTypes);
|
|
296
|
-
var trailDifficultyTypes = {
|
|
297
|
-
unknown: "unknown",
|
|
298
|
-
hiking: "hiking",
|
|
299
|
-
"mountain-hiking": "mountain-hiking",
|
|
300
|
-
"demanding-mountain-hiking": "demanding-mountain-hiking",
|
|
301
|
-
"alpine-hiking": "alpine-hiking",
|
|
302
|
-
"demanding-alpine-hiking": "demanding-alpine-hiking",
|
|
303
|
-
"difficult-alpine-hiking": "difficult-alpine-hiking",
|
|
304
|
-
"mtb-0": "mtb-0",
|
|
305
|
-
"mtb-1": "mtb-1",
|
|
306
|
-
"mtb-2": "mtb-2",
|
|
307
|
-
"mtb-3": "mtb-3",
|
|
308
|
-
"mtb-4": "mtb-4",
|
|
309
|
-
"mtb-5": "mtb-5",
|
|
310
|
-
"mtb-6": "mtb-6"
|
|
311
|
-
};
|
|
312
|
-
var trailDifficultyTypeSchema = z6__namespace.enum(trailDifficultyTypes);
|
|
313
|
-
var indexedInfoSchema = (value) => z6__namespace.object({
|
|
314
|
-
from_index: z6__namespace.number().int(),
|
|
315
|
-
to_index: z6__namespace.number().int(),
|
|
316
|
-
value
|
|
317
|
-
});
|
|
318
|
-
var liveSegmentRouteAnalysisSchema = z6__namespace.object({
|
|
319
|
-
slopeInfo: z6__namespace.array(indexedInfoSchema(z6__namespace.number())),
|
|
320
|
-
speedInfo: z6__namespace.array(indexedInfoSchema(z6__namespace.number())),
|
|
321
|
-
surfaceInfo: z6__namespace.array(indexedInfoSchema(surfaceTypeSchema)),
|
|
322
|
-
trailDifficultyInfo: z6__namespace.array(indexedInfoSchema(trailDifficultyTypeSchema)),
|
|
323
|
-
wayTypeInfo: z6__namespace.array(indexedInfoSchema(wayTypeSchema))
|
|
324
|
-
});
|
|
325
|
-
var liveSegmentRouteElevationSchema = z6__namespace.object({
|
|
326
|
-
altitudeMax: z6__namespace.number(),
|
|
327
|
-
altitudeMin: z6__namespace.number(),
|
|
328
|
-
ascent: z6__namespace.number(),
|
|
329
|
-
descent: z6__namespace.number(),
|
|
330
|
-
gradientMax: z6__namespace.number(),
|
|
331
|
-
gradientMin: z6__namespace.number()
|
|
332
|
-
});
|
|
333
|
-
var dataSurfaceTypes = {
|
|
334
|
-
ASPHALT: "ASPHALT",
|
|
335
|
-
COBBLESTONE: "COBBLESTONE",
|
|
336
|
-
COMPACTED_GRAVEL: "COMPACTED_GRAVEL",
|
|
337
|
-
CONCRETE: "CONCRETE",
|
|
338
|
-
DIRT: "DIRT",
|
|
339
|
-
FINE_GRAVEL: "FINE_GRAVEL",
|
|
340
|
-
GRASS: "GRASS",
|
|
341
|
-
GRASS_PAVER: "GRASS_PAVER",
|
|
342
|
-
GRAVEL: "GRAVEL",
|
|
343
|
-
GROUND: "GROUND",
|
|
344
|
-
ICE: "ICE",
|
|
345
|
-
METAL: "METAL",
|
|
346
|
-
PAVED: "PAVED",
|
|
347
|
-
PAVING_STONES: "PAVING_STONES",
|
|
348
|
-
SAND: "SAND",
|
|
349
|
-
UNKNOWN: "UNKNOWN",
|
|
350
|
-
UNPAVED: "UNPAVED",
|
|
351
|
-
WOOD: "WOOD",
|
|
352
|
-
WOODCHIPS: "WOODCHIPS"
|
|
353
|
-
};
|
|
354
|
-
z6__namespace.enum(dataSurfaceTypes);
|
|
355
|
-
var dataWayTypes = {
|
|
356
|
-
CONSTRUCTION: "CONSTRUCTION",
|
|
357
|
-
CYCLEWAY: "CYCLEWAY",
|
|
358
|
-
FERRY: "FERRY",
|
|
359
|
-
FOOTWAY: "FOOTWAY",
|
|
360
|
-
PATH: "PATH",
|
|
361
|
-
ROAD: "ROAD",
|
|
362
|
-
STATE_ROAD: "STATE_ROAD",
|
|
363
|
-
STEPS: "STEPS",
|
|
364
|
-
STREET: "STREET",
|
|
365
|
-
TRACK: "TRACK",
|
|
366
|
-
UNKNOWN: "UNKNOWN"
|
|
367
|
-
};
|
|
368
|
-
z6__namespace.enum(dataWayTypes);
|
|
369
|
-
var dataTrailDifficultyTypes = {
|
|
370
|
-
ALPINE_HIKING: "ALPINE_HIKING",
|
|
371
|
-
DEMANDING_ALPINE_HIKING: "DEMANDING_ALPINE_HIKING",
|
|
372
|
-
DEMANDING_MOUNTAIN_HIKING: "DEMANDING_MOUNTAIN_HIKING",
|
|
373
|
-
DIFFICULT_ALPINE_HIKING: "DIFFICULT_ALPINE_HIKING",
|
|
374
|
-
HIKING: "HIKING",
|
|
375
|
-
MOUNTAIN_HIKING: "MOUNTAIN_HIKING",
|
|
376
|
-
MTB_0: "MTB_0",
|
|
377
|
-
MTB_1: "MTB_1",
|
|
378
|
-
MTB_2: "MTB_2",
|
|
379
|
-
MTB_3: "MTB_3",
|
|
380
|
-
MTB_4: "MTB_4",
|
|
381
|
-
MTB_5: "MTB_5",
|
|
382
|
-
MTB_6: "MTB_6",
|
|
383
|
-
UNKNOWN: "UNKNOWN"
|
|
384
|
-
};
|
|
385
|
-
z6__namespace.enum(dataTrailDifficultyTypes);
|
|
386
|
-
var dataToRestSurface = {
|
|
387
|
-
ASPHALT: "asphalt",
|
|
388
|
-
COBBLESTONE: "cobblestone",
|
|
389
|
-
COMPACTED_GRAVEL: "compacted-gravel",
|
|
390
|
-
CONCRETE: "concrete",
|
|
391
|
-
DIRT: "dirt",
|
|
392
|
-
FINE_GRAVEL: "fine-gravel",
|
|
393
|
-
GRASS: "grass",
|
|
394
|
-
GRASS_PAVER: "grass-paver",
|
|
395
|
-
GRAVEL: "gravel",
|
|
396
|
-
GROUND: "ground",
|
|
397
|
-
ICE: "ice",
|
|
398
|
-
METAL: "metal",
|
|
399
|
-
PAVED: "paved",
|
|
400
|
-
PAVING_STONES: "paving-stones",
|
|
401
|
-
SAND: "sand",
|
|
402
|
-
UNKNOWN: "unknown",
|
|
403
|
-
UNPAVED: "unpaved",
|
|
404
|
-
WOOD: "wood",
|
|
405
|
-
WOODCHIPS: "woodchips"
|
|
406
|
-
};
|
|
407
|
-
var dataToRestWaytype = {
|
|
408
|
-
CONSTRUCTION: "construction",
|
|
409
|
-
CYCLEWAY: "cycleway",
|
|
410
|
-
FERRY: "ferry",
|
|
411
|
-
FOOTWAY: "footway",
|
|
412
|
-
PATH: "path",
|
|
413
|
-
ROAD: "road",
|
|
414
|
-
STATE_ROAD: "state-road",
|
|
415
|
-
STEPS: "steps",
|
|
416
|
-
STREET: "street",
|
|
417
|
-
TRACK: "track",
|
|
418
|
-
UNKNOWN: "unknown"
|
|
419
|
-
};
|
|
420
|
-
var dataToRestTrailDifficulty = {
|
|
421
|
-
ALPINE_HIKING: "alpine-hiking",
|
|
422
|
-
DEMANDING_ALPINE_HIKING: "demanding-alpine-hiking",
|
|
423
|
-
DEMANDING_MOUNTAIN_HIKING: "demanding-mountain-hiking",
|
|
424
|
-
DIFFICULT_ALPINE_HIKING: "difficult-alpine-hiking",
|
|
425
|
-
HIKING: "hiking",
|
|
426
|
-
MOUNTAIN_HIKING: "mountain-hiking",
|
|
427
|
-
MTB_0: "mtb-0",
|
|
428
|
-
MTB_1: "mtb-1",
|
|
429
|
-
MTB_2: "mtb-2",
|
|
430
|
-
MTB_3: "mtb-3",
|
|
431
|
-
MTB_4: "mtb-4",
|
|
432
|
-
MTB_5: "mtb-5",
|
|
433
|
-
MTB_6: "mtb-6",
|
|
434
|
-
UNKNOWN: "unknown"
|
|
435
|
-
};
|
|
436
|
-
var toRestSurface = (value) => dataToRestSurface[value];
|
|
437
|
-
var toRestWayType = (value) => dataToRestWaytype[value];
|
|
438
|
-
var toRestTrailDifficulty = (value) => dataToRestTrailDifficulty[value];
|
|
439
|
-
var dataToRestRoadAccess = {
|
|
440
|
-
AGRICULTURAL: "agricultural",
|
|
441
|
-
CUSTOMERS: "customers",
|
|
442
|
-
DELIVERY: "delivery",
|
|
443
|
-
DESTINATION: "destination",
|
|
444
|
-
FORESTRY: "forestry",
|
|
445
|
-
NO: "no",
|
|
446
|
-
PERMISSIVE: "permissive",
|
|
447
|
-
PERMIT: "permit",
|
|
448
|
-
PRIVATE: "private",
|
|
449
|
-
RESTRICTED: "restricted",
|
|
450
|
-
SERVICE: "service",
|
|
451
|
-
UNKNOWN: "unknown"
|
|
452
|
-
};
|
|
453
|
-
var graphqlRoadAccessToInfo = (advisories) => advisories.roadAccessInfo.map((info) => ({
|
|
454
|
-
from_index: info.fromIndex,
|
|
455
|
-
to_index: info.toIndex,
|
|
456
|
-
values: info.values.map((value) => dataToRestRoadAccess[value])
|
|
457
|
-
}));
|
|
458
|
-
var toAnalysisEntries = (entries, convert) => entries.map((entry) => ({
|
|
459
|
-
from_index: entry.fromIndex,
|
|
460
|
-
to_index: entry.toIndex,
|
|
461
|
-
value: convert(entry.value)
|
|
462
|
-
}));
|
|
463
|
-
var graphqlElevationToSummary = (elevation) => ({
|
|
464
|
-
altitudeMax: elevation.altitude.max,
|
|
465
|
-
altitudeMin: elevation.altitude.min,
|
|
466
|
-
ascent: elevation.ascent,
|
|
467
|
-
descent: elevation.descent,
|
|
468
|
-
gradientMax: elevation.gradient.max,
|
|
469
|
-
gradientMin: elevation.gradient.min
|
|
470
|
-
});
|
|
471
|
-
var graphqlAnalysisToEntries = (analysis) => ({
|
|
472
|
-
slopeInfo: toAnalysisEntries(analysis.slopeInfo, (value) => value),
|
|
473
|
-
speedInfo: toAnalysisEntries(analysis.speedInfo, (value) => value),
|
|
474
|
-
surfaceInfo: toAnalysisEntries(analysis.surfaceInfo, toRestSurface),
|
|
475
|
-
trailDifficultyInfo: toAnalysisEntries(
|
|
476
|
-
analysis.trailDifficultyInfo,
|
|
477
|
-
toRestTrailDifficulty
|
|
478
|
-
),
|
|
479
|
-
wayTypeInfo: toAnalysisEntries(analysis.wayTypeInfo, toRestWayType)
|
|
480
|
-
});
|
|
481
|
-
var routeLineOf = (geometry) => {
|
|
482
|
-
const lines = geo.extractLines(geometry);
|
|
483
|
-
const [only] = lines;
|
|
484
|
-
if (lines.length === 1 && only !== void 0) {
|
|
485
|
-
return only;
|
|
486
|
-
}
|
|
487
|
-
return { coordinates: geo.segmentLineCoordinates(geometry), type: "LineString" };
|
|
488
|
-
};
|
|
489
|
-
var graphqlRouteToLiveRoute = (itinerary) => ({
|
|
490
|
-
analysis: itinerary.analysis ? graphqlAnalysisToEntries(itinerary.analysis) : void 0,
|
|
491
|
-
distance: itinerary.distance,
|
|
492
|
-
duration: itinerary.duration,
|
|
493
|
-
elevation: itinerary.elevation ? graphqlElevationToSummary(itinerary.elevation) : void 0,
|
|
494
|
-
geometry: itinerary.geometry,
|
|
495
|
-
roadAccessInfo: itinerary.analysis ? graphqlRoadAccessToInfo(itinerary.analysis.advisories) : void 0
|
|
496
|
-
});
|
|
497
|
-
var overlayRouteAnalysis = (base, itinerary) => ({
|
|
498
|
-
...base,
|
|
499
|
-
altitude_max: itinerary.elevation?.altitudeMax ?? base.altitude_max,
|
|
500
|
-
altitude_min: itinerary.elevation?.altitudeMin ?? base.altitude_min,
|
|
501
|
-
ascent: itinerary.elevation?.ascent ?? base.ascent,
|
|
502
|
-
descent: itinerary.elevation?.descent ?? base.descent,
|
|
503
|
-
gradient_max: itinerary.elevation?.gradientMax ?? base.gradient_max,
|
|
504
|
-
gradient_min: itinerary.elevation?.gradientMin ?? base.gradient_min,
|
|
505
|
-
road_access_info: itinerary.roadAccessInfo ? [...itinerary.roadAccessInfo] : null,
|
|
506
|
-
slope_info: itinerary.analysis?.slopeInfo ?? base.slope_info,
|
|
507
|
-
speed_info: itinerary.analysis?.speedInfo ?? base.speed_info,
|
|
508
|
-
surface_info: itinerary.analysis?.surfaceInfo ?? base.surface_info,
|
|
509
|
-
trail_difficulty_info: itinerary.analysis?.trailDifficultyInfo ?? base.trail_difficulty_info,
|
|
510
|
-
way_type_info: itinerary.analysis?.wayTypeInfo ?? base.way_type_info
|
|
511
|
-
});
|
|
512
|
-
var buildLiveSegment = (base, itinerary) => {
|
|
513
|
-
const geojson = {
|
|
514
|
-
geometries: [itinerary.geometry],
|
|
515
|
-
type: "GeometryCollection"
|
|
516
|
-
};
|
|
517
|
-
return {
|
|
518
|
-
...overlayRouteAnalysis(base, itinerary),
|
|
519
|
-
distance: itinerary.distance,
|
|
520
|
-
duration: itinerary.duration,
|
|
521
|
-
geojson
|
|
522
|
-
};
|
|
523
|
-
};
|
|
524
|
-
var substituteLiveSegment = (segments, live, insertAnchor) => {
|
|
525
|
-
if (!live) {
|
|
526
|
-
return segments;
|
|
527
|
-
}
|
|
528
|
-
if (segments.some((segment) => segment.id === live.id)) {
|
|
529
|
-
return segments.map((segment) => segment.id === live.id ? live : segment);
|
|
530
|
-
}
|
|
531
|
-
if (insertAnchor === void 0) {
|
|
532
|
-
return [...segments, live];
|
|
533
|
-
}
|
|
534
|
-
const anchorIndex = insertAnchor === null ? -1 : segments.findIndex((s) => s.id === insertAnchor);
|
|
535
|
-
if (insertAnchor !== null && anchorIndex === -1) {
|
|
536
|
-
return [...segments, live];
|
|
537
|
-
}
|
|
538
|
-
return [...segments.slice(0, anchorIndex + 1), live, ...segments.slice(anchorIndex + 1)];
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
// src/segments/rules/draft.ts
|
|
542
|
-
var draftPositionCount = (geometry) => {
|
|
543
|
-
const leaf = geometry.type === "GeometryCollection" ? geometry.geometries[0] : geometry;
|
|
544
|
-
if (leaf && (leaf.type === "MultiPoint" || leaf.type === "LineString")) {
|
|
545
|
-
return leaf.coordinates.length;
|
|
546
|
-
}
|
|
547
|
-
return 0;
|
|
548
|
-
};
|
|
549
|
-
var draftCoordinates = (draft) => {
|
|
550
|
-
if (!draft) {
|
|
551
|
-
return [];
|
|
552
|
-
}
|
|
553
|
-
const leaves = draft.type === "GeometryCollection" ? draft.geometries : [draft];
|
|
554
|
-
for (const leaf of leaves) {
|
|
555
|
-
if (leaf.type === "MultiPoint" || leaf.type === "LineString") {
|
|
556
|
-
return leaf.coordinates;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
return [];
|
|
560
|
-
};
|
|
561
|
-
var segmentDraftHandles = (draft, seedVias) => draft === null ? seedVias : draftCoordinates(draft);
|
|
562
|
-
var sameHandles = (a, b) => a.length === b.length && a.every((handle, index) => {
|
|
563
|
-
const other = b[index];
|
|
564
|
-
return other !== void 0 && handle[0] === other[0] && handle[1] === other[1];
|
|
565
|
-
});
|
|
566
|
-
var isSegmentDraftDirty = (session) => session !== null && !sameHandles(segmentDraftHandles(session.draft, session.seedVias), session.savedVias);
|
|
567
|
-
|
|
568
|
-
// src/edit/rules/history.ts
|
|
569
|
-
var EDIT_HISTORY_LIMIT = 100;
|
|
570
|
-
var appendHistoryStep = (history, step) => {
|
|
571
|
-
const next = [...history, step];
|
|
572
|
-
return next.length > EDIT_HISTORY_LIMIT ? next.slice(next.length - EDIT_HISTORY_LIMIT) : next;
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
// src/segments/stores/segmentEdit.ts
|
|
576
|
-
var segmentEditModeSchema = z6__namespace.enum(data.SEGMENT_EDIT_MODES);
|
|
577
|
-
var synthesizeDraftSegment = (params) => ({
|
|
578
|
-
altitude_max: null,
|
|
579
|
-
altitude_min: null,
|
|
580
|
-
ascent: null,
|
|
581
|
-
color: params.draftColor,
|
|
582
|
-
created_at: /* @__PURE__ */ new Date(0),
|
|
583
|
-
created_by: { id: "" },
|
|
584
|
-
descent: null,
|
|
585
|
-
description: null,
|
|
586
|
-
distance: null,
|
|
587
|
-
duration: null,
|
|
588
|
-
geojson: null,
|
|
589
|
-
gradient_max: null,
|
|
590
|
-
gradient_min: null,
|
|
591
|
-
group_id: null,
|
|
592
|
-
id: params.segmentId,
|
|
593
|
-
itinerary_id: params.itineraryId,
|
|
594
|
-
mode: params.mode,
|
|
595
|
-
name: params.draftName ?? "",
|
|
596
|
-
position: 0,
|
|
597
|
-
revision: 0,
|
|
598
|
-
road_access_info: null,
|
|
599
|
-
slope_info: [],
|
|
600
|
-
speed: null,
|
|
601
|
-
speed_info: [],
|
|
602
|
-
start_at: null,
|
|
603
|
-
steps: [],
|
|
604
|
-
surface_info: [],
|
|
605
|
-
trail_difficulty_info: [],
|
|
606
|
-
way_type_info: []
|
|
607
|
-
});
|
|
608
|
-
var segmentInsertAnchorSchema = z6__namespace.object({
|
|
609
|
-
afterSegmentId: z6__namespace.string().nullable()
|
|
610
|
-
});
|
|
611
|
-
var segmentEditSessionMark = (session) => session.seedVias;
|
|
612
|
-
var seedViasEqual = (a, b) => {
|
|
613
|
-
if (a.length !== b.length) {
|
|
614
|
-
return false;
|
|
615
|
-
}
|
|
616
|
-
return a.every((via, index) => {
|
|
617
|
-
const other = b[index];
|
|
618
|
-
return other !== void 0 && via[0] === other[0] && via[1] === other[1];
|
|
619
|
-
});
|
|
620
|
-
};
|
|
621
|
-
var pinnedPointsEqual = (a, b) => a === null || b === null ? a === null && b === null : a[0] === b[0] && a[1] === b[1];
|
|
622
|
-
var segmentEditInitialState = {
|
|
623
|
-
editDirtyTick: 0,
|
|
624
|
-
segmentEditSession: null,
|
|
625
|
-
segmentViaPrompt: null
|
|
626
|
-
};
|
|
627
|
-
var createSegmentEditSlice = (set) => ({
|
|
628
|
-
acknowledgeRouteHazards: (keys) => set((state) => {
|
|
629
|
-
const session = state.segmentEditSession;
|
|
630
|
-
if (!session) {
|
|
631
|
-
return {};
|
|
632
|
-
}
|
|
633
|
-
const held = new Set(session.acknowledgedRouteHazards);
|
|
634
|
-
const added = [...new Set(keys)].filter((key) => !held.has(key));
|
|
635
|
-
if (added.length === 0) {
|
|
636
|
-
return {};
|
|
637
|
-
}
|
|
638
|
-
return {
|
|
639
|
-
segmentEditSession: {
|
|
640
|
-
...session,
|
|
641
|
-
acknowledgedRouteHazards: [...session.acknowledgedRouteHazards, ...added]
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
}),
|
|
645
|
-
adoptCreatedSegment: (saved) => set((state) => {
|
|
646
|
-
const session = state.segmentEditSession;
|
|
647
|
-
if (!session) {
|
|
648
|
-
return {};
|
|
649
|
-
}
|
|
650
|
-
const rekeyed = (segment) => segment ? { ...segment, id: saved.id } : null;
|
|
651
|
-
const rekeyedStep = (step) => ({
|
|
652
|
-
draft: step.draft,
|
|
653
|
-
liveSegment: rekeyed(step.liveSegment)
|
|
654
|
-
});
|
|
655
|
-
const itinerary = state.activeItinerary;
|
|
656
|
-
const missing = itinerary !== null && itinerary.id === saved.itinerary_id && !itinerary.segments.some((segment) => segment.id === saved.id);
|
|
657
|
-
return {
|
|
658
|
-
activeItinerary: missing ? {
|
|
659
|
-
...itinerary,
|
|
660
|
-
segments: substituteLiveSegment(
|
|
661
|
-
itinerary.segments,
|
|
662
|
-
saved,
|
|
663
|
-
session.insertAnchor === null ? void 0 : session.insertAnchor.afterSegmentId
|
|
664
|
-
)
|
|
665
|
-
} : itinerary,
|
|
666
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
667
|
-
segmentEditSession: {
|
|
668
|
-
...session,
|
|
669
|
-
draftName: null,
|
|
670
|
-
future: session.future.map(rekeyedStep),
|
|
671
|
-
gestureStart: session.gestureStart && rekeyedStep(session.gestureStart),
|
|
672
|
-
insertAnchor: null,
|
|
673
|
-
liveSegment: rekeyed(session.liveSegment),
|
|
674
|
-
past: session.past.map(rekeyedStep),
|
|
675
|
-
segmentId: saved.id
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
}),
|
|
679
|
-
beginSegmentEdit: (begin) => set((state) => {
|
|
680
|
-
const active = state.segmentEditSession;
|
|
681
|
-
if (active?.segmentId === begin.segmentId && active?.mode === begin.mode && seedViasEqual(active.seedVias, begin.seedVias ?? []) && pinnedPointsEqual(active.pinnedStart, begin.pinnedStart ?? null) && pinnedPointsEqual(active.pinnedEnd, begin.pinnedEnd ?? null)) {
|
|
682
|
-
return {};
|
|
683
|
-
}
|
|
684
|
-
const persisted = state.activeItinerary?.segments?.find(
|
|
685
|
-
(segment) => segment.id === begin.segmentId
|
|
686
|
-
);
|
|
687
|
-
const liveSegment = persisted ? null : synthesizeDraftSegment({
|
|
688
|
-
draftColor: begin.draftColor ?? null,
|
|
689
|
-
draftName: begin.draftName ?? null,
|
|
690
|
-
itineraryId: state.activeItinerary?.id ?? "",
|
|
691
|
-
mode: begin.mode,
|
|
692
|
-
segmentId: begin.segmentId
|
|
693
|
-
});
|
|
694
|
-
return {
|
|
695
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
696
|
-
segmentEditSession: {
|
|
697
|
-
// A fresh session has accepted nothing. Opening a segment that ALREADY crosses a
|
|
698
|
-
// restricted way does not prompt either, but that is the seed pre-acceptance in
|
|
699
|
-
// buildRouteFn rather than a value here: the hazards of the opening shape are not
|
|
700
|
-
// known until it has been routed once.
|
|
701
|
-
acknowledgedRouteHazards: [],
|
|
702
|
-
activitySlug: begin.activitySlug ?? null,
|
|
703
|
-
draft: null,
|
|
704
|
-
draftColor: begin.draftColor ?? null,
|
|
705
|
-
draftName: begin.draftName ?? null,
|
|
706
|
-
future: [],
|
|
707
|
-
gestureStart: null,
|
|
708
|
-
insertAnchor: begin.insertAnchor ?? null,
|
|
709
|
-
liveSegment,
|
|
710
|
-
mode: begin.mode,
|
|
711
|
-
past: [],
|
|
712
|
-
pinnedEnd: begin.pinnedEnd ?? null,
|
|
713
|
-
pinnedStart: begin.pinnedStart ?? null,
|
|
714
|
-
// A copy of its own, never the seed's array, which is the session's mark.
|
|
715
|
-
savedVias: [...begin.savedVias ?? begin.seedVias ?? []],
|
|
716
|
-
// A new array at every begin, carried by reference from here on: it is also what
|
|
717
|
-
// segmentEditSessionMark tells this session by.
|
|
718
|
-
seedVias: [...begin.seedVias ?? []],
|
|
719
|
-
segmentId: begin.segmentId
|
|
720
|
-
},
|
|
721
|
-
// A fresh session supersedes any prompt the previous one left open: its index pointed into
|
|
722
|
-
// a draft that is gone.
|
|
723
|
-
segmentViaPrompt: null,
|
|
724
|
-
selection: null
|
|
725
|
-
};
|
|
726
|
-
}),
|
|
727
|
-
bumpEditDirtyTick: () => set((state) => ({ editDirtyTick: state.editDirtyTick + 1 })),
|
|
728
|
-
// Closing a session drops any open handle prompt with it: the prompt names an
|
|
729
|
-
// index into a draft that no longer exists.
|
|
730
|
-
cancelSegmentEdit: () => set((state) => ({
|
|
731
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
732
|
-
segmentEditSession: null,
|
|
733
|
-
segmentViaPrompt: null
|
|
734
|
-
})),
|
|
735
|
-
commitSegmentEdit: () => set((state) => ({
|
|
736
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
737
|
-
segmentEditSession: null,
|
|
738
|
-
segmentViaPrompt: null
|
|
739
|
-
})),
|
|
740
|
-
markSegmentDraftSaved: (draft) => set((state) => {
|
|
741
|
-
const session = state.segmentEditSession;
|
|
742
|
-
if (!session) {
|
|
743
|
-
return {};
|
|
744
|
-
}
|
|
745
|
-
const saved = segmentDraftHandles(draft, session.seedVias).map(
|
|
746
|
-
([lng = 0, lat = 0]) => [lng, lat]
|
|
747
|
-
);
|
|
748
|
-
return { segmentEditSession: { ...session, savedVias: saved } };
|
|
749
|
-
}),
|
|
750
|
-
pushSegmentDraft: (geometry) => set((state) => {
|
|
751
|
-
if (!state.segmentEditSession) {
|
|
752
|
-
return {};
|
|
753
|
-
}
|
|
754
|
-
const { draft, gestureStart, liveSegment, past } = state.segmentEditSession;
|
|
755
|
-
return {
|
|
756
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
757
|
-
segmentEditSession: {
|
|
758
|
-
...state.segmentEditSession,
|
|
759
|
-
draft: geometry,
|
|
760
|
-
future: [],
|
|
761
|
-
gestureStart: null,
|
|
762
|
-
// Snapshot the prior draft WITH the liveSegment it routed to, so an undo restores
|
|
763
|
-
// the elevation alongside the geometry. A gesture's live frames already moved the
|
|
764
|
-
// draft, so its step is the snapshot it started from. The new draft keeps the
|
|
765
|
-
// current liveSegment until its own itinerary resolves and overwrites it.
|
|
766
|
-
past: appendHistoryStep(past, gestureStart ?? { draft, liveSegment })
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
}),
|
|
770
|
-
recolorSegmentEditLive: (color) => set((state) => {
|
|
771
|
-
const session = state.segmentEditSession;
|
|
772
|
-
if (!session) {
|
|
773
|
-
return {};
|
|
774
|
-
}
|
|
775
|
-
const recolor = (segment) => segment ? { ...segment, color } : null;
|
|
776
|
-
return {
|
|
777
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
778
|
-
segmentEditSession: {
|
|
779
|
-
...session,
|
|
780
|
-
draftColor: color,
|
|
781
|
-
future: session.future.map((snapshot) => ({
|
|
782
|
-
...snapshot,
|
|
783
|
-
liveSegment: recolor(snapshot.liveSegment)
|
|
784
|
-
})),
|
|
785
|
-
// The step an open gesture will record is a snapshot like the rest.
|
|
786
|
-
gestureStart: session.gestureStart && {
|
|
787
|
-
...session.gestureStart,
|
|
788
|
-
liveSegment: recolor(session.gestureStart.liveSegment)
|
|
789
|
-
},
|
|
790
|
-
liveSegment: recolor(session.liveSegment),
|
|
791
|
-
past: session.past.map((snapshot) => ({
|
|
792
|
-
...snapshot,
|
|
793
|
-
liveSegment: recolor(snapshot.liveSegment)
|
|
794
|
-
}))
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
}),
|
|
798
|
-
redoSegmentDraft: () => set((state) => {
|
|
799
|
-
const session = state.segmentEditSession;
|
|
800
|
-
if (!session) {
|
|
801
|
-
return {};
|
|
802
|
-
}
|
|
803
|
-
if (session.future.length === 0) {
|
|
804
|
-
return {};
|
|
805
|
-
}
|
|
806
|
-
const { draft, future, liveSegment, past } = session;
|
|
807
|
-
const [next, ...remaining] = future;
|
|
808
|
-
if (next === void 0) {
|
|
809
|
-
return {};
|
|
810
|
-
}
|
|
811
|
-
return {
|
|
812
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
813
|
-
segmentEditSession: {
|
|
814
|
-
...session,
|
|
815
|
-
draft: next.draft,
|
|
816
|
-
future: remaining,
|
|
817
|
-
gestureStart: null,
|
|
818
|
-
liveSegment: next.liveSegment,
|
|
819
|
-
past: appendHistoryStep(past, { draft, liveSegment })
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
}),
|
|
823
|
-
removeSegment: (segmentId) => set((state) => {
|
|
824
|
-
const activeItinerary = mapSegments(
|
|
825
|
-
state.activeItinerary,
|
|
826
|
-
(segments) => segments.filter((segment) => segment.id !== segmentId)
|
|
827
|
-
);
|
|
828
|
-
if (state.segmentEditSession?.segmentId !== segmentId) {
|
|
829
|
-
return { activeItinerary };
|
|
830
|
-
}
|
|
831
|
-
return {
|
|
832
|
-
activeItinerary,
|
|
833
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
834
|
-
segmentEditSession: null,
|
|
835
|
-
segmentViaPrompt: null
|
|
836
|
-
};
|
|
837
|
-
}),
|
|
838
|
-
setSegmentEditDraft: (geometry) => set(
|
|
839
|
-
(state) => state.segmentEditSession ? { segmentEditSession: { ...state.segmentEditSession, draft: geometry } } : {}
|
|
840
|
-
),
|
|
841
|
-
setSegmentEditLiveDraft: (geometry) => set((state) => {
|
|
842
|
-
const session = state.segmentEditSession;
|
|
843
|
-
if (!session) {
|
|
844
|
-
return {};
|
|
845
|
-
}
|
|
846
|
-
return {
|
|
847
|
-
segmentEditSession: {
|
|
848
|
-
...session,
|
|
849
|
-
draft: geometry,
|
|
850
|
-
gestureStart: session.gestureStart ?? {
|
|
851
|
-
draft: session.draft,
|
|
852
|
-
liveSegment: session.liveSegment
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
};
|
|
856
|
-
}),
|
|
857
|
-
setSegmentEditLiveSegment: (segment, routedFor) => set((state) => {
|
|
858
|
-
const session = state.segmentEditSession;
|
|
859
|
-
if (!session) {
|
|
860
|
-
return {};
|
|
861
|
-
}
|
|
862
|
-
if (routedFor === void 0 || segment === null) {
|
|
863
|
-
return {
|
|
864
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
865
|
-
segmentEditSession: { ...session, liveSegment: segment }
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
|
-
const pair = (step) => sameHandles(segmentDraftHandles(step.draft, session.seedVias), routedFor) ? { ...step, liveSegment: segment } : step;
|
|
869
|
-
return {
|
|
870
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
871
|
-
segmentEditSession: {
|
|
872
|
-
...session,
|
|
873
|
-
future: session.future.map(pair),
|
|
874
|
-
gestureStart: session.gestureStart && pair(session.gestureStart),
|
|
875
|
-
liveSegment: segment,
|
|
876
|
-
past: session.past.map(pair)
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
}),
|
|
880
|
-
setSegmentViaPrompt: (segmentViaPrompt) => set(
|
|
881
|
-
(state) => (
|
|
882
|
-
// A prompt names an index into the armed draft, so it opens only while a
|
|
883
|
-
// session is armed; a dismiss (null) always applies, so a torn-down session
|
|
884
|
-
// can still clear a slot the teardown order left behind.
|
|
885
|
-
segmentViaPrompt !== null && !state.segmentEditSession ? {} : { segmentViaPrompt }
|
|
886
|
-
)
|
|
887
|
-
),
|
|
888
|
-
undoSegmentDraft: () => set((state) => {
|
|
889
|
-
const session = state.segmentEditSession;
|
|
890
|
-
if (!session) {
|
|
891
|
-
return {};
|
|
892
|
-
}
|
|
893
|
-
if (session.past.length === 0) {
|
|
894
|
-
return {};
|
|
895
|
-
}
|
|
896
|
-
const { draft, future, liveSegment, past } = session;
|
|
897
|
-
const previous = past[past.length - 1];
|
|
898
|
-
if (previous === void 0) {
|
|
899
|
-
return {};
|
|
900
|
-
}
|
|
901
|
-
return {
|
|
902
|
-
editDirtyTick: state.editDirtyTick + 1,
|
|
903
|
-
segmentEditSession: {
|
|
904
|
-
...session,
|
|
905
|
-
// Restore the draft AND its routed liveSegment together so the elevation profile
|
|
906
|
-
// reflects the restored geometry at once; the current pair moves to `future`.
|
|
907
|
-
draft: previous.draft,
|
|
908
|
-
future: [{ draft, liveSegment }, ...future],
|
|
909
|
-
// A gesture still open started from a snapshot this undo just moved past.
|
|
910
|
-
gestureStart: null,
|
|
911
|
-
liveSegment: previous.liveSegment,
|
|
912
|
-
past: past.slice(0, -1)
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
})
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
// src/zones/rules/zoneMetadata.ts
|
|
919
|
-
var zoneNameSchema = displayNameSchema;
|
|
920
|
-
var zoneDescriptionSchema = descriptionSchema;
|
|
921
|
-
|
|
922
|
-
// src/viewer/rules/scope.ts
|
|
923
|
-
var defaultStudioScope = {
|
|
924
|
-
isPersonalScope: (organizationId) => organizationId === null || organizationId === void 0
|
|
925
|
-
};
|
|
926
|
-
var writeResourceNames = {
|
|
927
|
-
collection: "a collection",
|
|
928
|
-
itinerary: "an itinerary",
|
|
929
|
-
zone: "a zone"
|
|
930
|
-
};
|
|
931
|
-
var requireWritableScope = (ctx, resource, organizationId) => {
|
|
932
|
-
const refusal = ctx.scope?.writeRefusal?.(resource, organizationId) ?? null;
|
|
933
|
-
const name = writeResourceNames[resource];
|
|
934
|
-
switch (refusal) {
|
|
935
|
-
case "personal":
|
|
936
|
-
return {
|
|
937
|
-
code: "forbidden",
|
|
938
|
-
error: `the personal space holds no ${resource}: write ${name} in an organization whose agreement includes Map Studio`,
|
|
939
|
-
ok: false
|
|
940
|
-
};
|
|
941
|
-
case "agreement":
|
|
942
|
-
return {
|
|
943
|
-
code: "upgrade-required",
|
|
944
|
-
error: `not part of the organization's agreement: writing ${name} needs an organization whose agreement includes Map Studio`,
|
|
945
|
-
ok: false
|
|
946
|
-
};
|
|
947
|
-
default:
|
|
948
|
-
return null;
|
|
949
|
-
}
|
|
950
|
-
};
|
|
951
|
-
var activeStudioScope = (ctx) => {
|
|
952
|
-
const named = ctx.url?.read().organization_id;
|
|
953
|
-
const { isPersonalScope } = ctx.scope ?? defaultStudioScope;
|
|
954
|
-
return named === void 0 || named === "" || isPersonalScope(named) ? null : named;
|
|
955
|
-
};
|
|
956
|
-
var isPublishableScope = (organizationId, isPersonalScope) => Boolean(organizationId) && !isPersonalScope(organizationId);
|
|
957
|
-
var lineLengthMeters = (line) => {
|
|
958
|
-
let meters = 0;
|
|
959
|
-
for (let index = 1; index < line.length; index += 1) {
|
|
960
|
-
const previous = line[index - 1];
|
|
961
|
-
const current = line[index];
|
|
962
|
-
if (previous && current) {
|
|
963
|
-
meters += profile.haversineMeters(previous, current);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return meters;
|
|
967
|
-
};
|
|
968
|
-
var LINESTRING_PROFILE_INTERVAL_METERS = 50;
|
|
969
|
-
var LINESTRING_PROFILE_MIN_SAMPLES = 400;
|
|
970
|
-
var LINESTRING_PROFILE_MAX_SAMPLES = 4e3;
|
|
971
|
-
var profileSampleCap = (lengthMeters) => {
|
|
972
|
-
const needed = Math.floor(lengthMeters / LINESTRING_PROFILE_INTERVAL_METERS) + 2;
|
|
973
|
-
if (!(needed >= LINESTRING_PROFILE_MIN_SAMPLES)) {
|
|
974
|
-
return LINESTRING_PROFILE_MIN_SAMPLES;
|
|
975
|
-
}
|
|
976
|
-
if (needed > LINESTRING_PROFILE_MAX_SAMPLES) {
|
|
977
|
-
return LINESTRING_PROFILE_MAX_SAMPLES;
|
|
978
|
-
}
|
|
979
|
-
return needed;
|
|
980
|
-
};
|
|
981
|
-
var MAX_SEGMENT_POSITIONS = 1e4;
|
|
982
|
-
var freehandInsertBudget = (drawnVertices, sampleCap, keepsVias) => {
|
|
983
|
-
const held = keepsVias ? drawnVertices * 2 : drawnVertices;
|
|
984
|
-
return Math.min(sampleCap, MAX_SEGMENT_POSITIONS - held);
|
|
985
|
-
};
|
|
986
|
-
var FREEHAND_FIT_FIRST_TOLERANCE_METERS = 3;
|
|
987
|
-
var FREEHAND_FIT_ROUNDS = 40;
|
|
988
|
-
var keptWithinTolerance = (line, indices, toleranceMeters, metersPerDegree) => {
|
|
989
|
-
if (indices.length < 3) {
|
|
990
|
-
return [...indices];
|
|
991
|
-
}
|
|
992
|
-
const toleranceSquared = toleranceMeters * toleranceMeters;
|
|
993
|
-
const keep = new Uint8Array(indices.length);
|
|
994
|
-
keep[0] = 1;
|
|
995
|
-
keep[indices.length - 1] = 1;
|
|
996
|
-
const stack = [[0, indices.length - 1]];
|
|
997
|
-
while (stack.length > 0) {
|
|
998
|
-
const span = stack.pop();
|
|
999
|
-
if (!span) {
|
|
1000
|
-
continue;
|
|
1001
|
-
}
|
|
1002
|
-
const [from, to] = span;
|
|
1003
|
-
const start = line[indices[from] ?? -1];
|
|
1004
|
-
const end = line[indices[to] ?? -1];
|
|
1005
|
-
if (to - from < 2 || !start || !end) {
|
|
1006
|
-
continue;
|
|
1007
|
-
}
|
|
1008
|
-
const [startLng = 0, startLat = 0] = start;
|
|
1009
|
-
const lngMeters = metersPerDegree * Math.cos(startLat * units.DEGREES_TO_RADIANS);
|
|
1010
|
-
const endX = geo.longitudeDelta(startLng, end[0] ?? 0) * lngMeters;
|
|
1011
|
-
const endY = ((end[1] ?? 0) - startLat) * metersPerDegree;
|
|
1012
|
-
const lengthSquared = endX * endX + endY * endY;
|
|
1013
|
-
let farthest = -1;
|
|
1014
|
-
let farthestSquared = -1;
|
|
1015
|
-
for (let at = from + 1; at < to; at += 1) {
|
|
1016
|
-
const point = line[indices[at] ?? -1];
|
|
1017
|
-
if (!point) {
|
|
1018
|
-
continue;
|
|
1019
|
-
}
|
|
1020
|
-
const x = geo.longitudeDelta(startLng, point[0] ?? 0) * lngMeters;
|
|
1021
|
-
const y = ((point[1] ?? 0) - startLat) * metersPerDegree;
|
|
1022
|
-
const along = lengthSquared === 0 ? 0 : Math.min(1, Math.max(0, (x * endX + y * endY) / lengthSquared));
|
|
1023
|
-
const offX = x - along * endX;
|
|
1024
|
-
const offY = y - along * endY;
|
|
1025
|
-
const squared = offX * offX + offY * offY;
|
|
1026
|
-
if (squared > farthestSquared) {
|
|
1027
|
-
farthest = at;
|
|
1028
|
-
farthestSquared = squared;
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
if (farthest !== -1 && farthestSquared > toleranceSquared) {
|
|
1032
|
-
keep[farthest] = 1;
|
|
1033
|
-
stack.push([from, farthest], [farthest, to]);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return indices.filter((_index, at) => keep[at] === 1);
|
|
1037
|
-
};
|
|
1038
|
-
var fitFreehandLines = (lines) => {
|
|
1039
|
-
const positions = (sets) => sets.reduce((sum, set) => sum + set.length, 0);
|
|
1040
|
-
if (positions(lines) <= MAX_SEGMENT_POSITIONS) {
|
|
1041
|
-
return null;
|
|
1042
|
-
}
|
|
1043
|
-
const metersPerDegree = geo.EARTH_RADIUS_METERS * units.DEGREES_TO_RADIANS;
|
|
1044
|
-
let tolerance = FREEHAND_FIT_FIRST_TOLERANCE_METERS;
|
|
1045
|
-
let kept = lines.map(
|
|
1046
|
-
(line) => keptWithinTolerance(
|
|
1047
|
-
line,
|
|
1048
|
-
line.map((_position, index) => index),
|
|
1049
|
-
tolerance,
|
|
1050
|
-
metersPerDegree
|
|
1051
|
-
)
|
|
1052
|
-
);
|
|
1053
|
-
for (let round = 0; round < FREEHAND_FIT_ROUNDS && positions(kept) > MAX_SEGMENT_POSITIONS; round += 1) {
|
|
1054
|
-
tolerance *= 2;
|
|
1055
|
-
kept = kept.map(
|
|
1056
|
-
(indices, at) => keptWithinTolerance(lines[at] ?? [], indices, tolerance, metersPerDegree)
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
return kept;
|
|
1060
|
-
};
|
|
1061
|
-
var storedMeters = (meters) => Math.round(meters * 100) / 100;
|
|
1062
|
-
var interpolateGreatCircle = (start, end, fraction) => {
|
|
1063
|
-
const latStart = (start[1] ?? 0) * units.DEGREES_TO_RADIANS;
|
|
1064
|
-
const lngStart = (start[0] ?? 0) * units.DEGREES_TO_RADIANS;
|
|
1065
|
-
const latEnd = (end[1] ?? 0) * units.DEGREES_TO_RADIANS;
|
|
1066
|
-
const lngEnd = (end[0] ?? 0) * units.DEGREES_TO_RADIANS;
|
|
1067
|
-
const delta = 2 * Math.asin(
|
|
1068
|
-
Math.min(
|
|
1069
|
-
1,
|
|
1070
|
-
Math.sqrt(
|
|
1071
|
-
Math.sin((latEnd - latStart) / 2) ** 2 + Math.cos(latStart) * Math.cos(latEnd) * Math.sin((lngEnd - lngStart) / 2) ** 2
|
|
1072
|
-
)
|
|
1073
|
-
)
|
|
1074
|
-
);
|
|
1075
|
-
if (delta === 0) {
|
|
1076
|
-
return [start[0] ?? 0, start[1] ?? 0];
|
|
1077
|
-
}
|
|
1078
|
-
const a = Math.sin((1 - fraction) * delta) / Math.sin(delta);
|
|
1079
|
-
const b = Math.sin(fraction * delta) / Math.sin(delta);
|
|
1080
|
-
const x = a * Math.cos(latStart) * Math.cos(lngStart) + b * Math.cos(latEnd) * Math.cos(lngEnd);
|
|
1081
|
-
const y = a * Math.cos(latStart) * Math.sin(lngStart) + b * Math.cos(latEnd) * Math.sin(lngEnd);
|
|
1082
|
-
const z10 = a * Math.sin(latStart) + b * Math.sin(latEnd);
|
|
1083
|
-
return [
|
|
1084
|
-
Math.atan2(y, x) * units.RADIANS_TO_DEGREES,
|
|
1085
|
-
Math.atan2(z10, Math.hypot(x, y)) * units.RADIANS_TO_DEGREES
|
|
1086
|
-
];
|
|
1087
|
-
};
|
|
1088
|
-
var vertexWithinRange = (vertex) => [
|
|
1089
|
-
geo.wrapLongitudePastRange(vertex[0] ?? 0),
|
|
1090
|
-
vertex[1] ?? 0
|
|
1091
|
-
];
|
|
1092
|
-
var densifyLine = (line, intervalMeters, maxSamples) => {
|
|
1093
|
-
if (line.length < 2) {
|
|
1094
|
-
return line.map(vertexWithinRange);
|
|
1095
|
-
}
|
|
1096
|
-
const totalMeters = lineLengthMeters(line);
|
|
1097
|
-
const interval = totalMeters > 0 ? Math.max(intervalMeters, totalMeters / maxSamples) : intervalMeters;
|
|
1098
|
-
const head = line[0];
|
|
1099
|
-
const densified = head ? [vertexWithinRange(head)] : [];
|
|
1100
|
-
for (let index = 1; index < line.length; index += 1) {
|
|
1101
|
-
const start = line[index - 1];
|
|
1102
|
-
const end = line[index];
|
|
1103
|
-
if (!start || !end) {
|
|
1104
|
-
continue;
|
|
1105
|
-
}
|
|
1106
|
-
const edgeMeters = profile.haversineMeters(start, end);
|
|
1107
|
-
const steps = interval > 0 ? Math.max(1, Math.ceil(edgeMeters / interval)) : 1;
|
|
1108
|
-
for (let step = 1; step < steps; step += 1) {
|
|
1109
|
-
densified.push(interpolateGreatCircle(start, end, step / steps));
|
|
1110
|
-
}
|
|
1111
|
-
densified.push(vertexWithinRange(end));
|
|
1112
|
-
}
|
|
1113
|
-
return densified;
|
|
1114
|
-
};
|
|
1115
|
-
var densifyFreehandLine = (line) => {
|
|
1116
|
-
const meters = lineLengthMeters(line);
|
|
1117
|
-
const keepsVias = line.length < profileSampleCap(storedMeters(meters));
|
|
1118
|
-
const budget = freehandInsertBudget(line.length, profileSampleCap(meters), keepsVias);
|
|
1119
|
-
if (budget <= 0) {
|
|
1120
|
-
return line.map(vertexWithinRange);
|
|
1121
|
-
}
|
|
1122
|
-
return densifyLine(line, LINESTRING_PROFILE_INTERVAL_METERS, budget);
|
|
1123
|
-
};
|
|
1124
|
-
var issuedShareTokenSchema = z6__namespace.strictObject({ shareToken: z6__namespace.string().min(1) });
|
|
1125
|
-
var shareLinkToolContracts = {
|
|
1126
|
-
"studio.shareLink.disable": {
|
|
1127
|
-
capability: "editor",
|
|
1128
|
-
description: "Disable the share link for an itinerary or a collection. The token is revoked and every URL carrying it stops working; a later mint issues a different link.",
|
|
1129
|
-
input: shareLinkTargetSchema,
|
|
1130
|
-
output: toolNoDataSchema
|
|
1131
|
-
},
|
|
1132
|
-
"studio.shareLink.mint": {
|
|
1133
|
-
capability: "editor",
|
|
1134
|
-
description: "Get or create the read-only share link for an itinerary or a collection and return its token. Idempotent: an existing link is returned unchanged rather than replaced.",
|
|
1135
|
-
input: shareLinkTargetSchema,
|
|
1136
|
-
output: issuedShareTokenSchema
|
|
1137
|
-
},
|
|
1138
|
-
"studio.shareLink.rotate": {
|
|
1139
|
-
capability: "editor",
|
|
1140
|
-
description: "Reset the share link for an itinerary or a collection, retiring the current token and returning a fresh one. Every URL already handed out stops working.",
|
|
1141
|
-
input: shareLinkTargetSchema,
|
|
1142
|
-
output: issuedShareTokenSchema
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
exports.CAMERA_MESSAGE = CAMERA_MESSAGE;
|
|
1147
|
-
exports.DEFAULT_ZONE_CREATE_METHOD = DEFAULT_ZONE_CREATE_METHOD;
|
|
1148
|
-
exports.DEFAULT_ZONE_LEVEL = DEFAULT_ZONE_LEVEL;
|
|
1149
|
-
exports.DEFAULT_ZONE_MODE = DEFAULT_ZONE_MODE;
|
|
1150
|
-
exports.DESCRIPTION_MAX_LENGTH = DESCRIPTION_MAX_LENGTH;
|
|
1151
|
-
exports.DISPLAY_NAME_MAX_LENGTH = DISPLAY_NAME_MAX_LENGTH;
|
|
1152
|
-
exports.DISPLAY_NAME_MIN_LENGTH = DISPLAY_NAME_MIN_LENGTH;
|
|
1153
|
-
exports.READY_MESSAGE = READY_MESSAGE;
|
|
1154
|
-
exports.REQUEST_CAMERA_MESSAGE = REQUEST_CAMERA_MESSAGE;
|
|
1155
|
-
exports.REQUEST_SESSION_TOKEN_MESSAGE = REQUEST_SESSION_TOKEN_MESSAGE;
|
|
1156
|
-
exports.SET_ITINERARY_MESSAGE = SET_ITINERARY_MESSAGE;
|
|
1157
|
-
exports.SET_SESSION_TOKEN_MESSAGE = SET_SESSION_TOKEN_MESSAGE;
|
|
1158
|
-
exports.activeStudioScope = activeStudioScope;
|
|
1159
|
-
exports.appendHistoryStep = appendHistoryStep;
|
|
1160
|
-
exports.buildLiveSegment = buildLiveSegment;
|
|
1161
|
-
exports.buildShareSearch = buildShareSearch;
|
|
1162
|
-
exports.buildShareSrc = buildShareSrc;
|
|
1163
|
-
exports.cameraMessageSchema = cameraMessageSchema;
|
|
1164
|
-
exports.createItinerarySlice = createItinerarySlice;
|
|
1165
|
-
exports.createSegmentEditSlice = createSegmentEditSlice;
|
|
1166
|
-
exports.defaultStudioScope = defaultStudioScope;
|
|
1167
|
-
exports.densifyFreehandLine = densifyFreehandLine;
|
|
1168
|
-
exports.descriptionSchema = descriptionSchema;
|
|
1169
|
-
exports.displayNameSchema = displayNameSchema;
|
|
1170
|
-
exports.draftActivityInput = draftActivityInput;
|
|
1171
|
-
exports.draftCollectionsInput = draftCollectionsInput;
|
|
1172
|
-
exports.draftCoordinates = draftCoordinates;
|
|
1173
|
-
exports.draftNameInput = draftNameInput;
|
|
1174
|
-
exports.draftOrganizationInput = draftOrganizationInput;
|
|
1175
|
-
exports.draftPositionCount = draftPositionCount;
|
|
1176
|
-
exports.draftPrivateInput = draftPrivateInput;
|
|
1177
|
-
exports.embedSetContentInput = embedSetContentInput;
|
|
1178
|
-
exports.fitDisplayName = fitDisplayName;
|
|
1179
|
-
exports.fitFreehandLines = fitFreehandLines;
|
|
1180
|
-
exports.graphqlAnalysisToEntries = graphqlAnalysisToEntries;
|
|
1181
|
-
exports.graphqlElevationToSummary = graphqlElevationToSummary;
|
|
1182
|
-
exports.graphqlRoadAccessToInfo = graphqlRoadAccessToInfo;
|
|
1183
|
-
exports.graphqlRouteToLiveRoute = graphqlRouteToLiveRoute;
|
|
1184
|
-
exports.inboundBridgeMessageSchema = inboundBridgeMessageSchema;
|
|
1185
|
-
exports.indexedInfoSchema = indexedInfoSchema;
|
|
1186
|
-
exports.isPublishableScope = isPublishableScope;
|
|
1187
|
-
exports.isSegmentDraftDirty = isSegmentDraftDirty;
|
|
1188
|
-
exports.issuedShareTokenSchema = issuedShareTokenSchema;
|
|
1189
|
-
exports.itineraryInitialState = itineraryInitialState;
|
|
1190
|
-
exports.itinerarySelectionSchema = itinerarySelectionSchema;
|
|
1191
|
-
exports.lineLengthMeters = lineLengthMeters;
|
|
1192
|
-
exports.liveSegmentRouteAnalysisSchema = liveSegmentRouteAnalysisSchema;
|
|
1193
|
-
exports.liveSegmentRouteElevationSchema = liveSegmentRouteElevationSchema;
|
|
1194
|
-
exports.mapBoundsSchema = mapBoundsSchema;
|
|
1195
|
-
exports.mapWaypoints = mapWaypoints;
|
|
1196
|
-
exports.originBase = originBase;
|
|
1197
|
-
exports.overlayRouteAnalysis = overlayRouteAnalysis;
|
|
1198
|
-
exports.readyErrorSchema = readyErrorSchema;
|
|
1199
|
-
exports.readyMessageSchema = readyMessageSchema;
|
|
1200
|
-
exports.renumber = renumber;
|
|
1201
|
-
exports.requestCameraMessageSchema = requestCameraMessageSchema;
|
|
1202
|
-
exports.requestSessionTokenMessageSchema = requestSessionTokenMessageSchema;
|
|
1203
|
-
exports.requireWritableScope = requireWritableScope;
|
|
1204
|
-
exports.resolveActivity = resolveActivity;
|
|
1205
|
-
exports.restActivitySlugSchema = restActivitySlugSchema;
|
|
1206
|
-
exports.routeLineOf = routeLineOf;
|
|
1207
|
-
exports.segmentEditInitialState = segmentEditInitialState;
|
|
1208
|
-
exports.segmentEditModeSchema = segmentEditModeSchema;
|
|
1209
|
-
exports.segmentEditSessionMark = segmentEditSessionMark;
|
|
1210
|
-
exports.segmentInsertAnchorSchema = segmentInsertAnchorSchema;
|
|
1211
|
-
exports.setSessionTokenMessageSchema = setSessionTokenMessageSchema;
|
|
1212
|
-
exports.shareLinkTargetSchema = shareLinkTargetSchema;
|
|
1213
|
-
exports.shareLinkToolContracts = shareLinkToolContracts;
|
|
1214
|
-
exports.substituteLiveSegment = substituteLiveSegment;
|
|
1215
|
-
exports.surfaceTypeSchema = surfaceTypeSchema;
|
|
1216
|
-
exports.switchOverridesSchema = switchOverridesSchema;
|
|
1217
|
-
exports.synthesizeDraftSegment = synthesizeDraftSegment;
|
|
1218
|
-
exports.toDataActivity = toDataActivity;
|
|
1219
|
-
exports.toolNoDataSchema = toolNoDataSchema;
|
|
1220
|
-
exports.trailDifficultyTypeSchema = trailDifficultyTypeSchema;
|
|
1221
|
-
exports.wayTypeSchema = wayTypeSchema;
|
|
1222
|
-
exports.zoneDescriptionSchema = zoneDescriptionSchema;
|
|
1223
|
-
exports.zoneNameSchema = zoneNameSchema;
|
|
1224
|
-
//# sourceMappingURL=chunk-IDBXFBLG.cjs.map
|
|
1225
|
-
//# sourceMappingURL=chunk-IDBXFBLG.cjs.map
|