@depup/sanity 5.17.1-depup.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/LICENSE +21 -0
- package/README.md +57 -0
- package/bin/sanity +209 -0
- package/changes.json +114 -0
- package/lib/_chunks-dts/ActiveWorkspaceMatcherContext.d.ts +16164 -0
- package/lib/_chunks-dts/index.d.ts +780 -0
- package/lib/_chunks-dts/types.d.ts +2765 -0
- package/lib/_chunks-dts/types2.d.ts +656 -0
- package/lib/_chunks-dts/types3.d.ts +303 -0
- package/lib/_chunks-es/BroadcastDisplayedDocument.js +20 -0
- package/lib/_chunks-es/BroadcastDisplayedDocument.js.map +1 -0
- package/lib/_chunks-es/DisplayedDocumentBroadcaster.js +32 -0
- package/lib/_chunks-es/DisplayedDocumentBroadcaster.js.map +1 -0
- package/lib/_chunks-es/LiveQueries.js +339 -0
- package/lib/_chunks-es/LiveQueries.js.map +1 -0
- package/lib/_chunks-es/MenuGroup.js +106 -0
- package/lib/_chunks-es/MenuGroup.js.map +1 -0
- package/lib/_chunks-es/PostMessageDocuments.js +72 -0
- package/lib/_chunks-es/PostMessageDocuments.js.map +1 -0
- package/lib/_chunks-es/PostMessagePerspective.js +23 -0
- package/lib/_chunks-es/PostMessagePerspective.js.map +1 -0
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js +69 -0
- package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -0
- package/lib/_chunks-es/PostMessageRefreshMutations.js +74 -0
- package/lib/_chunks-es/PostMessageRefreshMutations.js.map +1 -0
- package/lib/_chunks-es/PostMessageSchema.js +502 -0
- package/lib/_chunks-es/PostMessageSchema.js.map +1 -0
- package/lib/_chunks-es/PostMessageTelemetry.js +21 -0
- package/lib/_chunks-es/PostMessageTelemetry.js.map +1 -0
- package/lib/_chunks-es/PresentationToolGrantsCheck.js +3848 -0
- package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -0
- package/lib/_chunks-es/QRCodeSVG.js +692 -0
- package/lib/_chunks-es/QRCodeSVG.js.map +1 -0
- package/lib/_chunks-es/StructureToolProvider.js +2360 -0
- package/lib/_chunks-es/StructureToolProvider.js.map +1 -0
- package/lib/_chunks-es/VideoPlayer.js +22 -0
- package/lib/_chunks-es/VideoPlayer.js.map +1 -0
- package/lib/_chunks-es/ViteDevServerStopped.js +52 -0
- package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -0
- package/lib/_chunks-es/index.js +285 -0
- package/lib/_chunks-es/index.js.map +1 -0
- package/lib/_chunks-es/index2.js +105 -0
- package/lib/_chunks-es/index2.js.map +1 -0
- package/lib/_chunks-es/index3.js +139 -0
- package/lib/_chunks-es/index3.js.map +1 -0
- package/lib/_chunks-es/index4.js +1020 -0
- package/lib/_chunks-es/index4.js.map +1 -0
- package/lib/_chunks-es/pane.js +5 -0
- package/lib/_chunks-es/pane.js.map +1 -0
- package/lib/_chunks-es/pane2.js +5 -0
- package/lib/_chunks-es/pane2.js.map +1 -0
- package/lib/_chunks-es/presentation.js +549 -0
- package/lib/_chunks-es/presentation.js.map +1 -0
- package/lib/_chunks-es/resources.js +303 -0
- package/lib/_chunks-es/resources.js.map +1 -0
- package/lib/_chunks-es/resources2.js +459 -0
- package/lib/_chunks-es/resources2.js.map +1 -0
- package/lib/_chunks-es/resources3.js +281 -0
- package/lib/_chunks-es/resources3.js.map +1 -0
- package/lib/_chunks-es/resources4.js +184 -0
- package/lib/_chunks-es/resources4.js.map +1 -0
- package/lib/_chunks-es/resources5.js +161 -0
- package/lib/_chunks-es/resources5.js.map +1 -0
- package/lib/_chunks-es/resources6.js +141 -0
- package/lib/_chunks-es/resources6.js.map +1 -0
- package/lib/_chunks-es/resources7.js +24 -0
- package/lib/_chunks-es/resources7.js.map +1 -0
- package/lib/_chunks-es/resources8.js +603 -0
- package/lib/_chunks-es/resources8.js.map +1 -0
- package/lib/_chunks-es/resources9.js +126 -0
- package/lib/_chunks-es/resources9.js.map +1 -0
- package/lib/_chunks-es/structureTool.js +13673 -0
- package/lib/_chunks-es/structureTool.js.map +1 -0
- package/lib/_chunks-es/version.js +17 -0
- package/lib/_chunks-es/version.js.map +1 -0
- package/lib/_createContext.d.ts +12 -0
- package/lib/_createContext.js +38 -0
- package/lib/_createContext.js.map +1 -0
- package/lib/_internal.d.ts +9 -0
- package/lib/_internal.js +12 -0
- package/lib/_internal.js.map +1 -0
- package/lib/_singletons.d.ts +951 -0
- package/lib/_singletons.js +284 -0
- package/lib/_singletons.js.map +1 -0
- package/lib/cli.d.ts +3 -0
- package/lib/cli.js +9 -0
- package/lib/cli.js.map +1 -0
- package/lib/desk.d.ts +910 -0
- package/lib/desk.js +71 -0
- package/lib/desk.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +92934 -0
- package/lib/index.js.map +1 -0
- package/lib/media-library.d.ts +85 -0
- package/lib/media-library.js +11 -0
- package/lib/media-library.js.map +1 -0
- package/lib/migrate.d.ts +1 -0
- package/lib/migrate.js +2 -0
- package/lib/migrate.js.map +1 -0
- package/lib/presentation.d.ts +28 -0
- package/lib/presentation.js +10 -0
- package/lib/presentation.js.map +1 -0
- package/lib/router.d.ts +560 -0
- package/lib/router.js +777 -0
- package/lib/router.js.map +1 -0
- package/lib/structure.d.ts +3 -0
- package/lib/structure.js +639 -0
- package/lib/structure.js.map +1 -0
- package/mock-browser-env-stub-loader.mjs +27 -0
- package/package.json +383 -0
- package/static/favicons/apple-touch-icon.png +0 -0
- package/static/favicons/favicon-192.png +0 -0
- package/static/favicons/favicon-512.png +0 -0
- package/static/favicons/favicon-96.png +0 -0
- package/static/favicons/favicon.ico +0 -0
- package/static/favicons/favicon.svg +12 -0
|
@@ -0,0 +1,3848 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useSelector, useActorRef } from "@xstate/react";
|
|
4
|
+
import { presentationLocaleNamespace, usePresentationTool, PresentationSpinner, API_VERSION, MAX_TIME_TO_OVERLAYS_CONNECTION, usePresentationNavigate, POPUP_CHECK_INTERVAL, DEFAULT_TOOL_NAME, EDIT_INTENT_MODE } from "./presentation.js";
|
|
5
|
+
import { createController, createConnectionMachine } from "@sanity/comlink";
|
|
6
|
+
import { createCompatibilityActors } from "@sanity/presentation-comlink";
|
|
7
|
+
import { urlSearchParamPreviewPerspective, fetchSharedAccessQuery, urlSearchParamVercelProtectionBypass, urlSearchParamVercelSetBypassCookie, urlSearchParamPreviewSecret, urlSearchParamPreviewPathname, schemaTypeSingleton, schemaIdSingleton, schemaType } from "@sanity/preview-url-secret/constants";
|
|
8
|
+
import { Card, Text, Stack, Inline, Box, Flex, Container as Container$1, Code, Label, TextInput, Spinner, useToast, Grid, Switch, MenuDivider, Menu, Hotkeys, usePrefersReducedMotion, BoundaryElementProvider } from "@sanity/ui";
|
|
9
|
+
import { memo, useEffect, useRef, useContext, useLayoutEffect, useState, forwardRef, Suspense, useId as useId$1, useImperativeHandle, lazy, useMemo, useCallback, useSyncExternalStore, useEffectEvent, useReducer } from "react";
|
|
10
|
+
import { useTranslation, getPublishedId, pathToString, useUnique, useDocumentPreviewStore, usePerspective, getPreviewStateObservable, useSchema, getPreviewValueWithFallback, SanityDefaultPreview, PreviewCard, Translate, CommentsIntentProvider, useActiveWorkspace, useClient, useCurrentUser, useProjectId, useDataset, useWorkspace, COMMENTS_INSPECTOR_NAME, useGrantsStore } from "sanity";
|
|
11
|
+
import { StateLink, useRouter, decodeJsonParams } from "sanity/router";
|
|
12
|
+
import { styled, createGlobalStyle } from "styled-components";
|
|
13
|
+
import { setup, assign, fromPromise, fromObservable, log } from "xstate";
|
|
14
|
+
import { PresentationSharedStateContext, PresentationPanelsContext, PresentationNavigateContext, PresentationParamsContext, PresentationContext } from "sanity/_singletons";
|
|
15
|
+
import { WarningOutlineIcon, LaunchIcon, ResetIcon, CopyIcon, ShareIcon, PanelLeftIcon, MobileDeviceIcon, DesktopIcon, RefreshIcon } from "@sanity/icons";
|
|
16
|
+
import { PaneRouterContext, PaneLayout, StructureToolProvider, DocumentListPane as DocumentListPane$1, DocumentPane as DocumentPane$1 } from "sanity/structure";
|
|
17
|
+
import { Button, ErrorBoundary, Tooltip, MenuItem, MenuButton, TooltipDelayGroupProvider } from "./index.js";
|
|
18
|
+
import "react-i18next";
|
|
19
|
+
import { toString } from "@sanity/util/paths";
|
|
20
|
+
import { StructureToolProvider as StructureToolProvider$1 } from "./StructureToolProvider.js";
|
|
21
|
+
import { studioPath } from "@sanity/client/csm";
|
|
22
|
+
import { DisplayedDocumentBroadcasterProvider } from "./DisplayedDocumentBroadcaster.js";
|
|
23
|
+
import { v4 } from "uuid";
|
|
24
|
+
import { motion, AnimatePresence, MotionConfig } from "motion/react";
|
|
25
|
+
import { flushSync } from "react-dom";
|
|
26
|
+
import { setSecretSearchParams, withoutSecretSearchParams } from "@sanity/preview-url-secret/without-secret-search-params";
|
|
27
|
+
import { SanityMonogram } from "@sanity/logos";
|
|
28
|
+
import { disablePreviewAccessSharing, enablePreviewAccessSharing } from "@sanity/preview-url-secret/toggle-preview-access-sharing";
|
|
29
|
+
import { validateApiPerspective } from "@sanity/client";
|
|
30
|
+
import isEqual from "fast-deep-equal";
|
|
31
|
+
import { match } from "path-to-regexp";
|
|
32
|
+
import { createPreviewSecret } from "@sanity/preview-url-secret/create-secret";
|
|
33
|
+
import { uuid } from "@sanity/uuid";
|
|
34
|
+
import { throwError } from "rxjs";
|
|
35
|
+
import { subscribeToVercelProtectionBypass } from "@sanity/preview-url-secret/toggle-vercel-protection-bypass";
|
|
36
|
+
const PostMessageFeatures$1 = (props) => {
|
|
37
|
+
const $ = c(3), {
|
|
38
|
+
comlink
|
|
39
|
+
} = props;
|
|
40
|
+
let t0, t1;
|
|
41
|
+
return $[0] !== comlink ? (t0 = () => comlink.on("visual-editing/features", _temp$h), t1 = [comlink], $[0] = comlink, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), null;
|
|
42
|
+
};
|
|
43
|
+
var PostMessageFeatures = memo(PostMessageFeatures$1);
|
|
44
|
+
function _temp$h() {
|
|
45
|
+
return {
|
|
46
|
+
features: {
|
|
47
|
+
optimistic: !0
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const presentationMachine = setup({
|
|
52
|
+
types: {},
|
|
53
|
+
actions: {
|
|
54
|
+
//
|
|
55
|
+
},
|
|
56
|
+
actors: {
|
|
57
|
+
//
|
|
58
|
+
},
|
|
59
|
+
guards: {
|
|
60
|
+
//
|
|
61
|
+
}
|
|
62
|
+
}).createMachine({
|
|
63
|
+
// eslint-disable-next-line tsdoc/syntax
|
|
64
|
+
/** @xstate-layout N4IgpgJg5mDOIC5QAUBOcwDsAuBDbAlgPaYAEAKkUQDYDEBAZqrgLZinrVG4QDaADAF1EoAA5FYBQiREgAHogAsAJgA0IAJ6IAHAEYAdIoCcJowFY9R-vzPLlAX3vq0GHPmJlKNfVx4FMUPRMrOy+EJACwkgg4pLSmLIKCLoAbIr6Zoop2tqKAMxpJnnF6loIZkbK+uZ5umapKXmK-Cm6js7osFh48RRU1D7c4RC02ERQUNTsAG4EsACuuNSkkFL+UKRE02Co1LgasJGysWsy0UnaZinVyrpGAOx1Rim2efeliPe3hma1Zvy6XT8W4OJwgFxdNy9LwDMKQILMNgcMBMOAACyO0RO8USiAK930LWU-3uiiB9yaKXemkQjW01V+txS-GKqUe7XBnW67hIfW8cJGjER7E4Q0xYgkpwS5zxVMJKWJ-FJ5Mp1LKFn4Pz+DSaLTaYIh3Oh-UGPEg+nQqNgaPWCJCpAF4pikpxMoQKWZ+gp+TSZLy1hSH3deXpNSZLNqVP1HVcPQ8fNhQ3Nor8ATtSMdQmOLo8uPdnu9BUUfoDQY1WrqOuarUcYMwRHC8Gihqh8Zh2biubdAFpAzSEL2OS247yYfodqgiKgO1K8yog7ptATFL9dFljMDrHkh1zW6OTWF1jPXaAkmY1YgKnktfxtC9dPd+Io9DvYzzPAekxBj13T3i7vKirKkqqpBsYVQ1HUFjFs0t6KK+kIjh+-JfvoBAQFMP5nH+CDaMo16KjYyjMvUNh5GWOT6MoLL8A8ygrk0dQIUabafmaEAWiinQ2gEWHSjhjJUYuj73Pcd63noQaNEYFb-Dk2S0cxe7IYm7GcYevFYjm2HyJeeQQb8tFkikVjGNoFGajUt73o+z61vYQA */
|
|
65
|
+
id: "Presentation Tool",
|
|
66
|
+
context: {
|
|
67
|
+
url: null,
|
|
68
|
+
error: null,
|
|
69
|
+
visualEditingOverlaysEnabled: !1
|
|
70
|
+
},
|
|
71
|
+
on: {
|
|
72
|
+
"iframe reload": {
|
|
73
|
+
actions: assign({
|
|
74
|
+
url: null
|
|
75
|
+
}),
|
|
76
|
+
target: ".loading"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
states: {
|
|
80
|
+
error: {
|
|
81
|
+
description: "Failed to load, either because of a misconfiguration, a network error, or an unexpected error",
|
|
82
|
+
tags: ["error"]
|
|
83
|
+
},
|
|
84
|
+
loading: {
|
|
85
|
+
on: {
|
|
86
|
+
"iframe loaded": {
|
|
87
|
+
target: "loaded"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
tags: ["busy"]
|
|
91
|
+
},
|
|
92
|
+
loaded: {
|
|
93
|
+
on: {
|
|
94
|
+
"toggle visual editing overlays": {
|
|
95
|
+
actions: assign({
|
|
96
|
+
visualEditingOverlaysEnabled: ({
|
|
97
|
+
event
|
|
98
|
+
}) => event.enabled
|
|
99
|
+
})
|
|
100
|
+
},
|
|
101
|
+
"iframe refresh": {
|
|
102
|
+
target: ".refreshing"
|
|
103
|
+
},
|
|
104
|
+
"iframe reload": {
|
|
105
|
+
target: ".reloading"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
states: {
|
|
109
|
+
idle: {},
|
|
110
|
+
refreshing: {
|
|
111
|
+
on: {
|
|
112
|
+
"iframe loaded": {
|
|
113
|
+
target: "idle"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
tags: ["busy"]
|
|
117
|
+
},
|
|
118
|
+
reloading: {
|
|
119
|
+
on: {
|
|
120
|
+
"iframe loaded": {
|
|
121
|
+
target: "idle"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
tags: ["busy"]
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
initial: "idle"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
initial: "loading"
|
|
131
|
+
}), SharedStateProvider = function(props) {
|
|
132
|
+
const $ = c(14), {
|
|
133
|
+
comlink,
|
|
134
|
+
children
|
|
135
|
+
} = props;
|
|
136
|
+
let t0;
|
|
137
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0];
|
|
138
|
+
const sharedState = useRef(t0);
|
|
139
|
+
let t1, t2;
|
|
140
|
+
$[1] !== comlink ? (t1 = () => comlink?.on("visual-editing/shared-state", () => ({
|
|
141
|
+
state: sharedState.current
|
|
142
|
+
})), t2 = [comlink], $[1] = comlink, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2);
|
|
143
|
+
let t3;
|
|
144
|
+
$[4] !== comlink ? (t3 = (key, value) => {
|
|
145
|
+
sharedState.current[key] = value, comlink?.post("presentation/shared-state", {
|
|
146
|
+
key,
|
|
147
|
+
value
|
|
148
|
+
});
|
|
149
|
+
}, $[4] = comlink, $[5] = t3) : t3 = $[5];
|
|
150
|
+
const setValue = t3;
|
|
151
|
+
let t4;
|
|
152
|
+
$[6] !== comlink ? (t4 = (key_0) => {
|
|
153
|
+
comlink?.post("presentation/shared-state", {
|
|
154
|
+
key: key_0
|
|
155
|
+
}), delete sharedState.current[key_0];
|
|
156
|
+
}, $[6] = comlink, $[7] = t4) : t4 = $[7];
|
|
157
|
+
const removeValue = t4;
|
|
158
|
+
let t5;
|
|
159
|
+
$[8] !== removeValue || $[9] !== setValue ? (t5 = {
|
|
160
|
+
removeValue,
|
|
161
|
+
setValue
|
|
162
|
+
}, $[8] = removeValue, $[9] = setValue, $[10] = t5) : t5 = $[10];
|
|
163
|
+
const context = t5;
|
|
164
|
+
let t6;
|
|
165
|
+
return $[11] !== children || $[12] !== context ? (t6 = /* @__PURE__ */ jsx(PresentationSharedStateContext.Provider, { value: context, children }), $[11] = children, $[12] = context, $[13] = t6) : t6 = $[13], t6;
|
|
166
|
+
}, Root$1 = styled.div.withConfig({
|
|
167
|
+
displayName: "Root",
|
|
168
|
+
componentId: "sc-1auuvvr-0"
|
|
169
|
+
})`overflow:hidden;flex-basis:0;flex-shrink:1;`, Panel = function(t0) {
|
|
170
|
+
const $ = c(15), {
|
|
171
|
+
children,
|
|
172
|
+
defaultSize: t1,
|
|
173
|
+
id,
|
|
174
|
+
minWidth,
|
|
175
|
+
maxWidth,
|
|
176
|
+
order: t2
|
|
177
|
+
} = t0, defaultSize = t1 === void 0 ? null : t1, order = t2 === void 0 ? 0 : t2, context = useContext(PresentationPanelsContext);
|
|
178
|
+
if (context === null)
|
|
179
|
+
throw Error("Panel components must be rendered within a PanelGroup container");
|
|
180
|
+
const {
|
|
181
|
+
getPanelStyle,
|
|
182
|
+
registerElement,
|
|
183
|
+
unregisterElement
|
|
184
|
+
} = context;
|
|
185
|
+
let t3;
|
|
186
|
+
$[0] !== getPanelStyle || $[1] !== id ? (t3 = getPanelStyle(id), $[0] = getPanelStyle, $[1] = id, $[2] = t3) : t3 = $[2];
|
|
187
|
+
const style = t3;
|
|
188
|
+
let t4, t5;
|
|
189
|
+
$[3] !== defaultSize || $[4] !== id || $[5] !== maxWidth || $[6] !== minWidth || $[7] !== order || $[8] !== registerElement || $[9] !== unregisterElement ? (t4 = () => (registerElement(id, {
|
|
190
|
+
id,
|
|
191
|
+
type: "panel",
|
|
192
|
+
defaultSize,
|
|
193
|
+
maxWidth: maxWidth ?? null,
|
|
194
|
+
minWidth: minWidth ?? 0,
|
|
195
|
+
order
|
|
196
|
+
}), () => {
|
|
197
|
+
unregisterElement(id);
|
|
198
|
+
}), t5 = [id, defaultSize, order, maxWidth, minWidth, registerElement, unregisterElement], $[3] = defaultSize, $[4] = id, $[5] = maxWidth, $[6] = minWidth, $[7] = order, $[8] = registerElement, $[9] = unregisterElement, $[10] = t4, $[11] = t5) : (t4 = $[10], t5 = $[11]), useLayoutEffect(t4, t5);
|
|
199
|
+
let t6;
|
|
200
|
+
return $[12] !== children || $[13] !== style ? (t6 = /* @__PURE__ */ jsx(Root$1, { style, children }), $[12] = children, $[13] = style, $[14] = t6) : t6 = $[14], t6;
|
|
201
|
+
};
|
|
202
|
+
function debounce(fn, timeout) {
|
|
203
|
+
let timer;
|
|
204
|
+
return (...args) => {
|
|
205
|
+
clearTimeout(timer), timer = setTimeout(() => {
|
|
206
|
+
fn.apply(fn, args);
|
|
207
|
+
}, timeout);
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const itemKey = "presentation/panels", getStoredItem = () => JSON.parse(localStorage.getItem(itemKey) || "{}"), setStoredItem = (data) => {
|
|
211
|
+
localStorage.setItem(itemKey, JSON.stringify(data));
|
|
212
|
+
}, getKeyForPanels = (panels) => panels.map((panel) => [panel.id, panel.order].join(":")).join(",");
|
|
213
|
+
function usePanelsStorage() {
|
|
214
|
+
const $ = c(1), get = _temp2$9, set = _temp3$4;
|
|
215
|
+
let t0;
|
|
216
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
217
|
+
const setDebounced = debounce(set, 100);
|
|
218
|
+
t0 = {
|
|
219
|
+
get,
|
|
220
|
+
set,
|
|
221
|
+
setDebounced
|
|
222
|
+
}, $[0] = t0;
|
|
223
|
+
} else
|
|
224
|
+
t0 = $[0];
|
|
225
|
+
return t0;
|
|
226
|
+
}
|
|
227
|
+
function _temp3$4(panels_0, widths) {
|
|
228
|
+
const stored_0 = getStoredItem(), key_0 = getKeyForPanels(panels_0), data = {
|
|
229
|
+
...stored_0,
|
|
230
|
+
[key_0]: widths
|
|
231
|
+
};
|
|
232
|
+
setStoredItem(data);
|
|
233
|
+
}
|
|
234
|
+
function _temp2$9(panels) {
|
|
235
|
+
const stored = getStoredItem(), key = getKeyForPanels(panels);
|
|
236
|
+
return Array.isArray(stored[key]) && stored[key].some(_temp$g) ? void 0 : stored[key];
|
|
237
|
+
}
|
|
238
|
+
function _temp$g(val) {
|
|
239
|
+
return val === null;
|
|
240
|
+
}
|
|
241
|
+
function getNextWidth(panel, nextWidth, containerWidth) {
|
|
242
|
+
const {
|
|
243
|
+
maxWidth: maxWidthPx,
|
|
244
|
+
minWidth: minWidthPx
|
|
245
|
+
} = panel, maxWidth = maxWidthPx == null ? 100 : maxWidthPx / containerWidth * 100, minWidth = minWidthPx / containerWidth * 100;
|
|
246
|
+
return Math.min(maxWidth, Math.max(minWidth, nextWidth));
|
|
247
|
+
}
|
|
248
|
+
function getNextWidths(delta, containerWidth, panelBefore, panelAfter, panelsState, initialDragState) {
|
|
249
|
+
const {
|
|
250
|
+
panels,
|
|
251
|
+
widths: prevWidths
|
|
252
|
+
} = panelsState, {
|
|
253
|
+
widths: initialWidths
|
|
254
|
+
} = initialDragState, widths = initialWidths || prevWidths, nextWidths = [...widths];
|
|
255
|
+
{
|
|
256
|
+
const pivotPanel2 = delta < 0 ? panelAfter : panelBefore, index2 = panels.findIndex((panel) => panel.id === pivotPanel2.id), width = widths[index2], nextWidth = getNextWidth(pivotPanel2, width + Math.abs(delta), containerWidth);
|
|
257
|
+
if (width === nextWidth)
|
|
258
|
+
return widths;
|
|
259
|
+
delta = delta < 0 ? width - nextWidth : nextWidth - width;
|
|
260
|
+
}
|
|
261
|
+
let deltaApplied = 0, pivotPanel = delta < 0 ? panelBefore : panelAfter, index = panels.findIndex((panel) => panel.id === pivotPanel.id);
|
|
262
|
+
for (; ; ) {
|
|
263
|
+
const panel = panels[index], width = widths[index], deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied), nextWidth = getNextWidth(panel, width - deltaRemaining, containerWidth);
|
|
264
|
+
if (width !== nextWidth && (deltaApplied += width - nextWidth, nextWidths[index] = nextWidth, deltaApplied.toPrecision(10).localeCompare(Math.abs(delta).toPrecision(10), void 0, {
|
|
265
|
+
numeric: !0
|
|
266
|
+
}) >= 0))
|
|
267
|
+
break;
|
|
268
|
+
if (delta < 0) {
|
|
269
|
+
if (--index < 0)
|
|
270
|
+
break;
|
|
271
|
+
} else if (++index >= panels.length)
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
return deltaApplied === 0 ? widths : (pivotPanel = delta < 0 ? panelAfter : panelBefore, index = panels.findIndex((panel) => panel.id === pivotPanel.id), nextWidths[index] = widths[index] + deltaApplied, nextWidths);
|
|
275
|
+
}
|
|
276
|
+
function getPanelWidth(panels, id, widths) {
|
|
277
|
+
if (panels.length === 1) return "100";
|
|
278
|
+
const index = panels.findIndex((panel) => panel.id === id), width = widths[index];
|
|
279
|
+
return width == null ? "0" : width.toPrecision(10);
|
|
280
|
+
}
|
|
281
|
+
function getOffset(event, handleElement, initialOffset = 0, initialHandleElementRect = null) {
|
|
282
|
+
const pointerOffset = event.clientX, elementOffset = (initialHandleElementRect || handleElement.getBoundingClientRect()).left;
|
|
283
|
+
return pointerOffset - elementOffset - initialOffset;
|
|
284
|
+
}
|
|
285
|
+
function isPanel(element) {
|
|
286
|
+
return element.type === "panel";
|
|
287
|
+
}
|
|
288
|
+
function isResizer(element) {
|
|
289
|
+
return element.type === "resizer";
|
|
290
|
+
}
|
|
291
|
+
function getSortedElements(elements) {
|
|
292
|
+
return Array.from(elements.values()).sort(({
|
|
293
|
+
order: a
|
|
294
|
+
}, {
|
|
295
|
+
order: b
|
|
296
|
+
}) => a == null && b == null ? 0 : a == null ? -1 : b == null ? 1 : a - b);
|
|
297
|
+
}
|
|
298
|
+
function validateWidths(panels, widthsToValidate, containerWidth) {
|
|
299
|
+
const total = widthsToValidate.reduce((total2, width) => total2 + width, 0), widths = [...widthsToValidate].map((width) => width / total * 100);
|
|
300
|
+
let remainingWidth = 0;
|
|
301
|
+
for (let index = 0; index < panels.length; index++) {
|
|
302
|
+
const panel = panels[index], width = widths[index], nextWidth = getNextWidth(panel, width, containerWidth);
|
|
303
|
+
width != nextWidth && (remainingWidth += width - nextWidth, widths[index] = nextWidth);
|
|
304
|
+
}
|
|
305
|
+
if (remainingWidth.toFixed(3) !== "0.000")
|
|
306
|
+
for (let index = 0; index < panels.length; index++) {
|
|
307
|
+
const panel = panels[index];
|
|
308
|
+
let {
|
|
309
|
+
maxWidth,
|
|
310
|
+
minWidth
|
|
311
|
+
} = panel;
|
|
312
|
+
minWidth = minWidth / containerWidth * 100, maxWidth != null && (maxWidth = maxWidth / containerWidth * 100);
|
|
313
|
+
const width = Math.min(maxWidth ?? 100, Math.max(minWidth, widths[index] + remainingWidth));
|
|
314
|
+
if (width !== widths[index] && (remainingWidth -= width - widths[index], widths[index] = width, Math.abs(remainingWidth).toFixed(3) === "0.000"))
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
return widths;
|
|
318
|
+
}
|
|
319
|
+
function getDefaultWidths(panels) {
|
|
320
|
+
let panelsWithoutWidth = panels.length, remainingWidthTotal = 100;
|
|
321
|
+
const widthsWithNulls = panels.map((panel) => panel.defaultSize ? (remainingWidthTotal -= panel.defaultSize, panelsWithoutWidth -= 1, panel.defaultSize) : null), defaultWidth = remainingWidthTotal / panelsWithoutWidth;
|
|
322
|
+
return widthsWithNulls.map((width) => width === null ? defaultWidth : width);
|
|
323
|
+
}
|
|
324
|
+
const PanelsWrapper = styled.div.withConfig({
|
|
325
|
+
displayName: "PanelsWrapper",
|
|
326
|
+
componentId: "sc-17hl5hb-0"
|
|
327
|
+
})`display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%;`, Panels = function(t0) {
|
|
328
|
+
const $ = c(46), {
|
|
329
|
+
children
|
|
330
|
+
} = t0, panelsEl = useRef(null);
|
|
331
|
+
let t1;
|
|
332
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ new Map(), $[0] = t1) : t1 = $[0];
|
|
333
|
+
const [elements, setElements] = useState(t1);
|
|
334
|
+
let t2;
|
|
335
|
+
$[1] !== elements ? (t2 = getSortedElements(elements).filter(isPanel), $[1] = elements, $[2] = t2) : t2 = $[2];
|
|
336
|
+
const panels = t2;
|
|
337
|
+
let t3;
|
|
338
|
+
$[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = [], $[3] = t3) : t3 = $[3];
|
|
339
|
+
const [widths, setWidths] = useState(t3), [activeResizer, setActiveResizer] = useState(null);
|
|
340
|
+
let t4;
|
|
341
|
+
$[4] !== elements || $[5] !== panels || $[6] !== widths ? (t4 = {
|
|
342
|
+
elements,
|
|
343
|
+
panels,
|
|
344
|
+
widths
|
|
345
|
+
}, $[4] = elements, $[5] = panels, $[6] = widths, $[7] = t4) : t4 = $[7];
|
|
346
|
+
const panelsRef = useRef(t4);
|
|
347
|
+
let t5;
|
|
348
|
+
$[8] !== activeResizer || $[9] !== panels || $[10] !== widths ? (t5 = (id) => ({
|
|
349
|
+
flexGrow: getPanelWidth(panels, id, widths),
|
|
350
|
+
pointerEvents: activeResizer === null ? void 0 : "none"
|
|
351
|
+
}), $[8] = activeResizer, $[9] = panels, $[10] = widths, $[11] = t5) : t5 = $[11];
|
|
352
|
+
const getPanelStyle = t5;
|
|
353
|
+
let t6;
|
|
354
|
+
$[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = (id_0, data) => {
|
|
355
|
+
setElements((prev) => {
|
|
356
|
+
if (prev.has(id_0))
|
|
357
|
+
return prev;
|
|
358
|
+
const next = new Map(prev);
|
|
359
|
+
return next.set(id_0, data), next;
|
|
360
|
+
});
|
|
361
|
+
}, $[12] = t6) : t6 = $[12];
|
|
362
|
+
const registerElement = t6;
|
|
363
|
+
let t7;
|
|
364
|
+
$[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = (id_1) => {
|
|
365
|
+
setElements((prev_0) => {
|
|
366
|
+
if (!prev_0.has(id_1))
|
|
367
|
+
return prev_0;
|
|
368
|
+
const next_0 = new Map(prev_0);
|
|
369
|
+
return next_0.delete(id_1), next_0;
|
|
370
|
+
});
|
|
371
|
+
}, $[13] = t7) : t7 = $[13];
|
|
372
|
+
const unregisterElement = t7;
|
|
373
|
+
let t8;
|
|
374
|
+
$[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = {
|
|
375
|
+
containerWidth: window.innerWidth,
|
|
376
|
+
dragOffset: 0,
|
|
377
|
+
panelAfter: null,
|
|
378
|
+
panelBefore: null,
|
|
379
|
+
resizerIndex: -1,
|
|
380
|
+
resizerRect: null,
|
|
381
|
+
startX: 0,
|
|
382
|
+
widths: []
|
|
383
|
+
}, $[14] = t8) : t8 = $[14];
|
|
384
|
+
const dragRef = useRef(t8);
|
|
385
|
+
let t9;
|
|
386
|
+
$[15] !== elements ? (t9 = (id_2, event) => {
|
|
387
|
+
const elementsArr = getSortedElements(elements), index = elementsArr.findIndex((el) => el.id === id_2), resizer = elements.get(id_2);
|
|
388
|
+
if (!resizer || !isResizer(resizer))
|
|
389
|
+
return;
|
|
390
|
+
const resizeElement = resizer.el.current;
|
|
391
|
+
resizeElement && (dragRef.current = {
|
|
392
|
+
resizerIndex: index,
|
|
393
|
+
panelBefore: elementsArr.reduce((acc, el_0, i) => isPanel(el_0) && i < index ? el_0 : acc, null),
|
|
394
|
+
panelAfter: elementsArr.reduce((acc_0, el_1, i_0) => acc_0 === null && isPanel(el_1) && i_0 > index ? el_1 : acc_0, null),
|
|
395
|
+
containerWidth: window.innerWidth,
|
|
396
|
+
startX: event.pageX,
|
|
397
|
+
dragOffset: getOffset(event, resizeElement),
|
|
398
|
+
resizerRect: resizeElement.getBoundingClientRect(),
|
|
399
|
+
widths: panelsRef.current.widths
|
|
400
|
+
}, setActiveResizer(id_2));
|
|
401
|
+
}, $[15] = elements, $[16] = t9) : t9 = $[16];
|
|
402
|
+
const startDragging = t9;
|
|
403
|
+
let t10;
|
|
404
|
+
$[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = () => {
|
|
405
|
+
setActiveResizer(null);
|
|
406
|
+
}, $[17] = t10) : t10 = $[17];
|
|
407
|
+
const stopDragging = t10;
|
|
408
|
+
let t11;
|
|
409
|
+
$[18] !== elements ? (t11 = (id_3, event_0) => {
|
|
410
|
+
event_0.preventDefault(), event_0.stopPropagation();
|
|
411
|
+
const {
|
|
412
|
+
containerWidth,
|
|
413
|
+
dragOffset,
|
|
414
|
+
panelBefore,
|
|
415
|
+
panelAfter,
|
|
416
|
+
resizerRect
|
|
417
|
+
} = dragRef.current;
|
|
418
|
+
if (panelBefore == null || panelAfter == null)
|
|
419
|
+
return;
|
|
420
|
+
const resizer_0 = elements.get(id_3);
|
|
421
|
+
if (!resizer_0 || !isResizer(resizer_0))
|
|
422
|
+
return;
|
|
423
|
+
const resizeElement_0 = resizer_0.el.current;
|
|
424
|
+
if (!resizeElement_0)
|
|
425
|
+
return;
|
|
426
|
+
const offset = getOffset(event_0, resizeElement_0, dragOffset, resizerRect);
|
|
427
|
+
if (offset === 0)
|
|
428
|
+
return;
|
|
429
|
+
const {
|
|
430
|
+
widths: prevWidths
|
|
431
|
+
} = panelsRef.current, rect = panelsEl.current.getBoundingClientRect(), delta = offset / rect.width * 100, nextWidths = getNextWidths(delta, containerWidth, panelBefore, panelAfter, panelsRef.current, dragRef.current);
|
|
432
|
+
prevWidths.some((prevWidth, i_1) => prevWidth !== nextWidths[i_1]) && setWidths(nextWidths);
|
|
433
|
+
}, $[18] = elements, $[19] = t11) : t11 = $[19];
|
|
434
|
+
const drag = t11;
|
|
435
|
+
let t12, t13;
|
|
436
|
+
$[20] !== elements || $[21] !== panels || $[22] !== widths ? (t12 = () => {
|
|
437
|
+
panelsRef.current.elements = elements, panelsRef.current.panels = panels, panelsRef.current.widths = widths;
|
|
438
|
+
}, t13 = [elements, panels, widths], $[20] = elements, $[21] = panels, $[22] = widths, $[23] = t12, $[24] = t13) : (t12 = $[23], t13 = $[24]), useLayoutEffect(t12, t13);
|
|
439
|
+
const storage = usePanelsStorage();
|
|
440
|
+
let t14, t15;
|
|
441
|
+
$[25] !== panels || $[26] !== storage ? (t14 = () => {
|
|
442
|
+
const {
|
|
443
|
+
widths: widths_0
|
|
444
|
+
} = panelsRef.current;
|
|
445
|
+
if (widths_0.length === panels.length)
|
|
446
|
+
return;
|
|
447
|
+
const storedWidths = storage.get(panels);
|
|
448
|
+
if (storedWidths) {
|
|
449
|
+
const validatedStoredWidths = validateWidths(panels, storedWidths, window.innerWidth);
|
|
450
|
+
setWidths(validatedStoredWidths);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const defaultWidths = getDefaultWidths(panels);
|
|
454
|
+
setWidths(defaultWidths);
|
|
455
|
+
}, t15 = [storage, panels], $[25] = panels, $[26] = storage, $[27] = t14, $[28] = t15) : (t14 = $[27], t15 = $[28]), useLayoutEffect(t14, t15);
|
|
456
|
+
let t16, t17;
|
|
457
|
+
$[29] !== panels || $[30] !== storage || $[31] !== widths ? (t16 = () => {
|
|
458
|
+
widths.length && storage.setDebounced(panels, widths);
|
|
459
|
+
}, t17 = [storage, panels, widths], $[29] = panels, $[30] = storage, $[31] = widths, $[32] = t16, $[33] = t17) : (t16 = $[32], t17 = $[33]), useEffect(t16, t17);
|
|
460
|
+
let t18, t19;
|
|
461
|
+
$[34] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t18 = () => {
|
|
462
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
463
|
+
const {
|
|
464
|
+
panels: panels_0,
|
|
465
|
+
widths: prevWidths_0
|
|
466
|
+
} = panelsRef.current, nextWidths_0 = validateWidths(panels_0, prevWidths_0, window.innerWidth);
|
|
467
|
+
prevWidths_0.some((prevWidth_0, i_2) => prevWidth_0 !== nextWidths_0[i_2]) && setWidths(nextWidths_0);
|
|
468
|
+
});
|
|
469
|
+
return resizeObserver.observe(panelsEl.current), () => {
|
|
470
|
+
resizeObserver.disconnect();
|
|
471
|
+
};
|
|
472
|
+
}, t19 = [], $[34] = t18, $[35] = t19) : (t18 = $[34], t19 = $[35]), useLayoutEffect(t18, t19);
|
|
473
|
+
let t20;
|
|
474
|
+
$[36] !== activeResizer || $[37] !== drag || $[38] !== getPanelStyle || $[39] !== startDragging ? (t20 = {
|
|
475
|
+
activeResizer,
|
|
476
|
+
drag,
|
|
477
|
+
getPanelStyle,
|
|
478
|
+
registerElement,
|
|
479
|
+
startDragging,
|
|
480
|
+
stopDragging,
|
|
481
|
+
unregisterElement
|
|
482
|
+
}, $[36] = activeResizer, $[37] = drag, $[38] = getPanelStyle, $[39] = startDragging, $[40] = t20) : t20 = $[40];
|
|
483
|
+
const context = t20;
|
|
484
|
+
let t21;
|
|
485
|
+
$[41] !== children ? (t21 = /* @__PURE__ */ jsx(PanelsWrapper, { ref: panelsEl, children }), $[41] = children, $[42] = t21) : t21 = $[42];
|
|
486
|
+
let t22;
|
|
487
|
+
return $[43] !== context || $[44] !== t21 ? (t22 = /* @__PURE__ */ jsx(PresentationPanelsContext.Provider, { value: context, children: t21 }), $[43] = context, $[44] = t21, $[45] = t22) : t22 = $[45], t22;
|
|
488
|
+
};
|
|
489
|
+
function ErrorCard(props) {
|
|
490
|
+
const $ = c(37);
|
|
491
|
+
let children, message, onContinueAnyway, onRetry, restProps;
|
|
492
|
+
$[0] !== props ? ({
|
|
493
|
+
children,
|
|
494
|
+
message,
|
|
495
|
+
onRetry,
|
|
496
|
+
onContinueAnyway,
|
|
497
|
+
...restProps
|
|
498
|
+
} = props, $[0] = props, $[1] = children, $[2] = message, $[3] = onContinueAnyway, $[4] = onRetry, $[5] = restProps) : (children = $[1], message = $[2], onContinueAnyway = $[3], onRetry = $[4], restProps = $[5]);
|
|
499
|
+
const {
|
|
500
|
+
t
|
|
501
|
+
} = useTranslation(presentationLocaleNamespace);
|
|
502
|
+
let t0;
|
|
503
|
+
$[6] !== t ? (t0 = t("error-card.retry-button.text"), $[6] = t, $[7] = t0) : t0 = $[7];
|
|
504
|
+
let t1;
|
|
505
|
+
$[8] !== onRetry || $[9] !== t0 ? (t1 = /* @__PURE__ */ jsx(Button, { mode: "ghost", onClick: onRetry, text: t0 }), $[8] = onRetry, $[9] = t0, $[10] = t1) : t1 = $[10];
|
|
506
|
+
const retryButton = t1;
|
|
507
|
+
let t2;
|
|
508
|
+
$[11] !== t ? (t2 = t("error-card.continue-button.text"), $[11] = t, $[12] = t2) : t2 = $[12];
|
|
509
|
+
let t3;
|
|
510
|
+
$[13] !== onContinueAnyway || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(Button, { mode: "ghost", tone: "critical", onClick: onContinueAnyway, text: t2 }), $[13] = onContinueAnyway, $[14] = t2, $[15] = t3) : t3 = $[15];
|
|
511
|
+
const continueAnywayButton = t3;
|
|
512
|
+
let t4;
|
|
513
|
+
$[16] !== t ? (t4 = t("error-card.title"), $[16] = t, $[17] = t4) : t4 = $[17];
|
|
514
|
+
let t5;
|
|
515
|
+
$[18] !== t4 ? (t5 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: t4 }), $[18] = t4, $[19] = t5) : t5 = $[19];
|
|
516
|
+
let t6;
|
|
517
|
+
$[20] !== message ? (t6 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: message }), $[20] = message, $[21] = t6) : t6 = $[21];
|
|
518
|
+
let t7;
|
|
519
|
+
$[22] !== t5 || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
520
|
+
t5,
|
|
521
|
+
t6
|
|
522
|
+
] }), $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24];
|
|
523
|
+
let t8;
|
|
524
|
+
$[25] !== continueAnywayButton || $[26] !== onContinueAnyway || $[27] !== onRetry || $[28] !== retryButton ? (t8 = onRetry && onContinueAnyway ? /* @__PURE__ */ jsxs(Inline, { space: 2, children: [
|
|
525
|
+
retryButton,
|
|
526
|
+
continueAnywayButton
|
|
527
|
+
] }) : onRetry ? /* @__PURE__ */ jsx(Box, { children: retryButton }) : onContinueAnyway ? /* @__PURE__ */ jsx(Box, { children: continueAnywayButton }) : null, $[25] = continueAnywayButton, $[26] = onContinueAnyway, $[27] = onRetry, $[28] = retryButton, $[29] = t8) : t8 = $[29];
|
|
528
|
+
let t9;
|
|
529
|
+
$[30] !== children || $[31] !== t7 || $[32] !== t8 ? (t9 = /* @__PURE__ */ jsx(Flex, { align: "center", height: "fill", justify: "center", children: /* @__PURE__ */ jsx(Container$1, { padding: 4, sizing: "border", width: 0, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
530
|
+
t7,
|
|
531
|
+
children,
|
|
532
|
+
t8
|
|
533
|
+
] }) }) }), $[30] = children, $[31] = t7, $[32] = t8, $[33] = t9) : t9 = $[33];
|
|
534
|
+
let t10;
|
|
535
|
+
return $[34] !== restProps || $[35] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { height: "fill", ...restProps, children: t9 }), $[34] = restProps, $[35] = t9, $[36] = t10) : t10 = $[36], t10;
|
|
536
|
+
}
|
|
537
|
+
const ChildLink = forwardRef(function(props, ref) {
|
|
538
|
+
const $ = c(17);
|
|
539
|
+
let childId, childParameters, childType, rest, searchParams;
|
|
540
|
+
if ($[0] !== props) {
|
|
541
|
+
const {
|
|
542
|
+
childId: t02,
|
|
543
|
+
childType: t12,
|
|
544
|
+
childPayload,
|
|
545
|
+
childParameters: t22,
|
|
546
|
+
searchParams: t3,
|
|
547
|
+
...t4
|
|
548
|
+
} = props;
|
|
549
|
+
childId = t02, childType = t12, childParameters = t22, searchParams = t3, rest = t4, $[0] = props, $[1] = childId, $[2] = childParameters, $[3] = childType, $[4] = rest, $[5] = searchParams;
|
|
550
|
+
} else
|
|
551
|
+
childId = $[1], childParameters = $[2], childType = $[3], rest = $[4], searchParams = $[5];
|
|
552
|
+
let t0;
|
|
553
|
+
$[6] !== childParameters || $[7] !== searchParams ? (t0 = Object.entries({
|
|
554
|
+
...searchParams,
|
|
555
|
+
...childParameters
|
|
556
|
+
}), $[6] = childParameters, $[7] = searchParams, $[8] = t0) : t0 = $[8];
|
|
557
|
+
let t1;
|
|
558
|
+
$[9] !== childId || $[10] !== childType || $[11] !== t0 ? (t1 = {
|
|
559
|
+
id: childId,
|
|
560
|
+
type: childType,
|
|
561
|
+
_searchParams: t0
|
|
562
|
+
}, $[9] = childId, $[10] = childType, $[11] = t0, $[12] = t1) : t1 = $[12];
|
|
563
|
+
let t2;
|
|
564
|
+
return $[13] !== ref || $[14] !== rest || $[15] !== t1 ? (t2 = /* @__PURE__ */ jsx(StateLink, { ...rest, ref, state: t1 }), $[13] = ref, $[14] = rest, $[15] = t1, $[16] = t2) : t2 = $[16], t2;
|
|
565
|
+
}), ReferenceChildLink = forwardRef(function(props, ref) {
|
|
566
|
+
const $ = c(24);
|
|
567
|
+
let documentId, documentType, parentRefPath, rest, searchParams, template;
|
|
568
|
+
$[0] !== props ? ({
|
|
569
|
+
documentId,
|
|
570
|
+
documentType,
|
|
571
|
+
parentRefPath,
|
|
572
|
+
template,
|
|
573
|
+
searchParams,
|
|
574
|
+
...rest
|
|
575
|
+
} = props, $[0] = props, $[1] = documentId, $[2] = documentType, $[3] = parentRefPath, $[4] = rest, $[5] = searchParams, $[6] = template) : (documentId = $[1], documentType = $[2], parentRefPath = $[3], rest = $[4], searchParams = $[5], template = $[6]);
|
|
576
|
+
let t0;
|
|
577
|
+
$[7] !== documentId ? (t0 = getPublishedId(documentId), $[7] = documentId, $[8] = t0) : t0 = $[8];
|
|
578
|
+
const t1 = template?.params;
|
|
579
|
+
let t2;
|
|
580
|
+
$[9] !== parentRefPath ? (t2 = pathToString(parentRefPath), $[9] = parentRefPath, $[10] = t2) : t2 = $[10];
|
|
581
|
+
let t3;
|
|
582
|
+
$[11] !== template ? (t3 = template && {
|
|
583
|
+
template: template?.id
|
|
584
|
+
}, $[11] = template, $[12] = t3) : t3 = $[12];
|
|
585
|
+
let t4;
|
|
586
|
+
$[13] !== t2 || $[14] !== t3 ? (t4 = {
|
|
587
|
+
parentRefPath: t2,
|
|
588
|
+
...t3
|
|
589
|
+
}, $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15];
|
|
590
|
+
let t5;
|
|
591
|
+
return $[16] !== documentType || $[17] !== ref || $[18] !== rest || $[19] !== searchParams || $[20] !== t0 || $[21] !== t1 || $[22] !== t4 ? (t5 = /* @__PURE__ */ jsx(ChildLink, { ...rest, ref, childId: t0, childType: documentType, childPayload: t1, childParameters: t4, searchParams }), $[16] = documentType, $[17] = ref, $[18] = rest, $[19] = searchParams, $[20] = t0, $[21] = t1, $[22] = t4, $[23] = t5) : t5 = $[23], t5;
|
|
592
|
+
});
|
|
593
|
+
function encodeQueryString(params = {}) {
|
|
594
|
+
const parts = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
595
|
+
return parts.length ? `?${parts}` : "";
|
|
596
|
+
}
|
|
597
|
+
function resolveQueryStringFromParams(nextParams) {
|
|
598
|
+
const allowed = ["comment", "inspect", "instruction", "pathKey", "rev", "since", "template", "view"], safeNextParams = Object.entries(nextParams).filter(([key]) => allowed.includes(key)).reduce((obj, [key, value]) => value == null ? obj : {
|
|
599
|
+
...obj,
|
|
600
|
+
[key]: value
|
|
601
|
+
}, {});
|
|
602
|
+
return encodeQueryString(safeNextParams);
|
|
603
|
+
}
|
|
604
|
+
const BackLink = forwardRef(function(props, ref) {
|
|
605
|
+
const $ = c(9);
|
|
606
|
+
let restProps, searchParams;
|
|
607
|
+
$[0] !== props ? ({
|
|
608
|
+
searchParams,
|
|
609
|
+
...restProps
|
|
610
|
+
} = props, $[0] = props, $[1] = restProps, $[2] = searchParams) : (restProps = $[1], searchParams = $[2]);
|
|
611
|
+
let t0;
|
|
612
|
+
$[3] !== searchParams ? (t0 = {
|
|
613
|
+
type: void 0,
|
|
614
|
+
_searchParams: Object.entries(searchParams)
|
|
615
|
+
}, $[3] = searchParams, $[4] = t0) : t0 = $[4];
|
|
616
|
+
let t1;
|
|
617
|
+
return $[5] !== ref || $[6] !== restProps || $[7] !== t0 ? (t1 = /* @__PURE__ */ jsx(StateLink, { ...restProps, ref, state: t0, title: void 0 }), $[5] = ref, $[6] = restProps, $[7] = t0, $[8] = t1) : t1 = $[8], t1;
|
|
618
|
+
});
|
|
619
|
+
function PresentationPaneRouterProvider(props) {
|
|
620
|
+
const $ = c(28), {
|
|
621
|
+
children,
|
|
622
|
+
onEditReference,
|
|
623
|
+
onStructureParams,
|
|
624
|
+
structureParams,
|
|
625
|
+
searchParams,
|
|
626
|
+
refs
|
|
627
|
+
} = props, {
|
|
628
|
+
state: routerState,
|
|
629
|
+
resolvePathFromState
|
|
630
|
+
} = useRouter();
|
|
631
|
+
let t0;
|
|
632
|
+
$[0] !== routerState._searchParams ? (t0 = Object.fromEntries(routerState._searchParams || []), $[0] = routerState._searchParams, $[1] = t0) : t0 = $[1];
|
|
633
|
+
const routerSearchParams = useUnique(t0);
|
|
634
|
+
let t1;
|
|
635
|
+
$[2] !== resolvePathFromState || $[3] !== routerSearchParams || $[4] !== routerState ? (t1 = (nextParams) => {
|
|
636
|
+
const path = resolvePathFromState(routerState), qs = resolveQueryStringFromParams({
|
|
637
|
+
...routerSearchParams,
|
|
638
|
+
...nextParams
|
|
639
|
+
});
|
|
640
|
+
return `${path}${qs}`;
|
|
641
|
+
}, $[2] = resolvePathFromState, $[3] = routerSearchParams, $[4] = routerState, $[5] = t1) : t1 = $[5];
|
|
642
|
+
const createPathWithParams = t1;
|
|
643
|
+
let t2;
|
|
644
|
+
$[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[6] = t2) : t2 = $[6];
|
|
645
|
+
const t3 = structureParams;
|
|
646
|
+
let t4;
|
|
647
|
+
$[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = [], $[7] = t4) : t4 = $[7];
|
|
648
|
+
let t5;
|
|
649
|
+
$[8] !== refs || $[9] !== searchParams ? (t5 = forwardRef(function(childLinkProps, ref) {
|
|
650
|
+
const {
|
|
651
|
+
childId,
|
|
652
|
+
...rest
|
|
653
|
+
} = childLinkProps, doc = refs?.find((r) => r._id === childId || getPublishedId(r._id) === childId);
|
|
654
|
+
return doc ? /* @__PURE__ */ jsx(ChildLink, { ...rest, ref, childId, childType: doc._type, searchParams }) : (console.warn(`ChildLink: No document found for childId "${childId}"`), null);
|
|
655
|
+
}), $[8] = refs, $[9] = searchParams, $[10] = t5) : t5 = $[10];
|
|
656
|
+
let t6;
|
|
657
|
+
$[11] !== searchParams ? (t6 = forwardRef(function(backLinkProps, ref_0) {
|
|
658
|
+
return /* @__PURE__ */ jsx(BackLink, { ...backLinkProps, ref: ref_0, searchParams });
|
|
659
|
+
}), $[11] = searchParams, $[12] = t6) : t6 = $[12];
|
|
660
|
+
let t7;
|
|
661
|
+
$[13] !== searchParams ? (t7 = forwardRef(function(childLinkProps_0, ref_1) {
|
|
662
|
+
return /* @__PURE__ */ jsx(ReferenceChildLink, { ...childLinkProps_0, ref: ref_1, searchParams });
|
|
663
|
+
}), $[13] = searchParams, $[14] = t7) : t7 = $[14];
|
|
664
|
+
let t8;
|
|
665
|
+
$[15] !== onEditReference ? (t8 = (options) => {
|
|
666
|
+
const {
|
|
667
|
+
id,
|
|
668
|
+
template,
|
|
669
|
+
type,
|
|
670
|
+
parentRefPath,
|
|
671
|
+
version
|
|
672
|
+
} = options;
|
|
673
|
+
onEditReference({
|
|
674
|
+
state: {
|
|
675
|
+
id,
|
|
676
|
+
type
|
|
677
|
+
},
|
|
678
|
+
params: {
|
|
679
|
+
template: template.id,
|
|
680
|
+
parentRefPath: toString(parentRefPath),
|
|
681
|
+
version
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}, $[15] = onEditReference, $[16] = t8) : t8 = $[16];
|
|
685
|
+
let t9;
|
|
686
|
+
$[17] !== createPathWithParams || $[18] !== onStructureParams || $[19] !== t3 || $[20] !== t5 || $[21] !== t6 || $[22] !== t7 || $[23] !== t8 ? (t9 = {
|
|
687
|
+
index: 0,
|
|
688
|
+
groupIndex: 0,
|
|
689
|
+
siblingIndex: 0,
|
|
690
|
+
payload: t2,
|
|
691
|
+
params: t3,
|
|
692
|
+
hasGroupSiblings: !1,
|
|
693
|
+
groupLength: 1,
|
|
694
|
+
routerPanesState: t4,
|
|
695
|
+
ChildLink: t5,
|
|
696
|
+
BackLink: t6,
|
|
697
|
+
ReferenceChildLink: t7,
|
|
698
|
+
ParameterizedLink: _temp$f,
|
|
699
|
+
closeCurrentAndAfter: _temp2$8,
|
|
700
|
+
handleEditReference: t8,
|
|
701
|
+
replaceCurrent: _temp3$3,
|
|
702
|
+
closeCurrent: _temp4$2,
|
|
703
|
+
duplicateCurrent: _temp5$2,
|
|
704
|
+
setView: _temp6$1,
|
|
705
|
+
setParams: onStructureParams,
|
|
706
|
+
setPayload: _temp7$1,
|
|
707
|
+
navigateIntent: _temp8,
|
|
708
|
+
createPathWithParams
|
|
709
|
+
}, $[17] = createPathWithParams, $[18] = onStructureParams, $[19] = t3, $[20] = t5, $[21] = t6, $[22] = t7, $[23] = t8, $[24] = t9) : t9 = $[24];
|
|
710
|
+
const context = t9;
|
|
711
|
+
let t10;
|
|
712
|
+
return $[25] !== children || $[26] !== context ? (t10 = /* @__PURE__ */ jsx(PaneRouterContext.Provider, { value: context, children }), $[25] = children, $[26] = context, $[27] = t10) : t10 = $[27], t10;
|
|
713
|
+
}
|
|
714
|
+
function _temp8(intentName, intentParams, options_0) {
|
|
715
|
+
console.warn("navigateIntent", intentName, intentParams, options_0);
|
|
716
|
+
}
|
|
717
|
+
function _temp7$1(payload) {
|
|
718
|
+
console.warn("setPayload", payload);
|
|
719
|
+
}
|
|
720
|
+
function _temp6$1(viewId) {
|
|
721
|
+
console.warn("setView", viewId);
|
|
722
|
+
}
|
|
723
|
+
function _temp5$2(pane_0) {
|
|
724
|
+
console.warn("duplicateCurrent", pane_0);
|
|
725
|
+
}
|
|
726
|
+
function _temp4$2() {
|
|
727
|
+
console.warn("closeCurrent");
|
|
728
|
+
}
|
|
729
|
+
function _temp3$3(pane) {
|
|
730
|
+
console.warn("replaceCurrent", pane);
|
|
731
|
+
}
|
|
732
|
+
function _temp2$8() {
|
|
733
|
+
console.warn("closeCurrentAndAfter");
|
|
734
|
+
}
|
|
735
|
+
function _temp$f() {
|
|
736
|
+
throw new Error("ParameterizedLink not implemented");
|
|
737
|
+
}
|
|
738
|
+
const RootLayout = styled(PaneLayout).withConfig({
|
|
739
|
+
displayName: "RootLayout",
|
|
740
|
+
componentId: "sc-18wb5dr-0"
|
|
741
|
+
})`height:100%;`, Root = styled(Flex).withConfig({
|
|
742
|
+
displayName: "Root",
|
|
743
|
+
componentId: "sc-18wb5dr-1"
|
|
744
|
+
})`& > div{min-width:none !important;max-width:none !important;}`, WrappedCode$1 = styled(Code).withConfig({
|
|
745
|
+
displayName: "WrappedCode",
|
|
746
|
+
componentId: "sc-18wb5dr-2"
|
|
747
|
+
})`white-space:pre-wrap;`;
|
|
748
|
+
function DocumentListPane(props) {
|
|
749
|
+
const $ = c(34), {
|
|
750
|
+
mainDocumentState,
|
|
751
|
+
onEditReference,
|
|
752
|
+
onStructureParams,
|
|
753
|
+
searchParams,
|
|
754
|
+
refs
|
|
755
|
+
} = props, {
|
|
756
|
+
t
|
|
757
|
+
} = useTranslation(presentationLocaleNamespace), {
|
|
758
|
+
devMode
|
|
759
|
+
} = usePresentationTool();
|
|
760
|
+
let t0;
|
|
761
|
+
if ($[0] !== mainDocumentState?.document?._id || $[1] !== refs) {
|
|
762
|
+
let t12;
|
|
763
|
+
$[3] !== mainDocumentState?.document?._id ? (t12 = (r) => getPublishedId(r._id) !== mainDocumentState?.document?._id, $[3] = mainDocumentState?.document?._id, $[4] = t12) : t12 = $[4], t0 = refs.filter(t12).map(_temp$e), $[0] = mainDocumentState?.document?._id, $[1] = refs, $[2] = t0;
|
|
764
|
+
} else
|
|
765
|
+
t0 = $[2];
|
|
766
|
+
const ids = t0;
|
|
767
|
+
let t1;
|
|
768
|
+
$[5] !== ids ? (t1 = {
|
|
769
|
+
filter: "_id in $ids",
|
|
770
|
+
params: {
|
|
771
|
+
ids
|
|
772
|
+
}
|
|
773
|
+
}, $[5] = ids, $[6] = t1) : t1 = $[6];
|
|
774
|
+
let t2;
|
|
775
|
+
$[7] !== t ? (t2 = t("document-list-pane.document-list.title"), $[7] = t, $[8] = t2) : t2 = $[8];
|
|
776
|
+
let t3;
|
|
777
|
+
$[9] !== t1 || $[10] !== t2 ? (t3 = {
|
|
778
|
+
id: "$root",
|
|
779
|
+
options: t1,
|
|
780
|
+
schemaTypeName: "",
|
|
781
|
+
title: t2,
|
|
782
|
+
type: "documentList"
|
|
783
|
+
}, $[9] = t1, $[10] = t2, $[11] = t3) : t3 = $[11];
|
|
784
|
+
const pane = t3, [errorParams, setErrorParams] = useState(null);
|
|
785
|
+
let t4;
|
|
786
|
+
$[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setErrorParams(null), $[12] = t4) : t4 = $[12];
|
|
787
|
+
const handleRetry = t4, [structureParams] = useState(_temp2$7);
|
|
788
|
+
let t5;
|
|
789
|
+
$[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = () => setErrorParams(null), $[13] = t5) : t5 = $[13];
|
|
790
|
+
let t6;
|
|
791
|
+
if ($[14] !== refs ? (t6 = [refs], $[14] = refs, $[15] = t6) : t6 = $[15], useEffect(t5, t6), errorParams) {
|
|
792
|
+
let t72;
|
|
793
|
+
$[16] !== t ? (t72 = t("document-list-pane.error.text"), $[16] = t, $[17] = t72) : t72 = $[17];
|
|
794
|
+
let t82;
|
|
795
|
+
$[18] !== devMode || $[19] !== errorParams || $[20] !== t ? (t82 = devMode && /* @__PURE__ */ jsx(Card, { overflow: "auto", padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
796
|
+
/* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: t("presentation-error.label") }),
|
|
797
|
+
/* @__PURE__ */ jsx(WrappedCode$1, { size: 1, children: errorParams.error.message })
|
|
798
|
+
] }) }), $[18] = devMode, $[19] = errorParams, $[20] = t, $[21] = t82) : t82 = $[21];
|
|
799
|
+
let t9;
|
|
800
|
+
return $[22] !== t72 || $[23] !== t82 ? (t9 = /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t72, onRetry: handleRetry, children: t82 }), $[22] = t72, $[23] = t82, $[24] = t9) : t9 = $[24], t9;
|
|
801
|
+
}
|
|
802
|
+
let t7;
|
|
803
|
+
$[25] !== pane ? (t7 = /* @__PURE__ */ jsx(Root, { direction: "column", flex: 1, children: /* @__PURE__ */ jsx(DocumentListPane$1, { index: 0, itemId: "$root", pane, paneKey: "$root" }) }), $[25] = pane, $[26] = t7) : t7 = $[26];
|
|
804
|
+
let t8;
|
|
805
|
+
return $[27] !== onEditReference || $[28] !== onStructureParams || $[29] !== refs || $[30] !== searchParams || $[31] !== structureParams || $[32] !== t7 ? (t8 = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsx(RootLayout, { children: /* @__PURE__ */ jsx(StructureToolProvider, { children: /* @__PURE__ */ jsx(PresentationPaneRouterProvider, { onEditReference, onStructureParams, structureParams, searchParams, refs, children: t7 }) }) }) }), $[27] = onEditReference, $[28] = onStructureParams, $[29] = refs, $[30] = searchParams, $[31] = structureParams, $[32] = t7, $[33] = t8) : t8 = $[33], t8;
|
|
806
|
+
}
|
|
807
|
+
function _temp2$7() {
|
|
808
|
+
return {};
|
|
809
|
+
}
|
|
810
|
+
function _temp$e(r_0) {
|
|
811
|
+
return getPublishedId(r_0._id);
|
|
812
|
+
}
|
|
813
|
+
const WrappedCode = styled(Code).withConfig({
|
|
814
|
+
displayName: "WrappedCode",
|
|
815
|
+
componentId: "sc-m0u57n-0"
|
|
816
|
+
})`white-space:pre-wrap;`;
|
|
817
|
+
function DocumentPane(props) {
|
|
818
|
+
const $ = c(40), {
|
|
819
|
+
documentId,
|
|
820
|
+
documentType,
|
|
821
|
+
onFocusPath,
|
|
822
|
+
onEditReference,
|
|
823
|
+
onStructureParams,
|
|
824
|
+
searchParams,
|
|
825
|
+
structureParams
|
|
826
|
+
} = props, {
|
|
827
|
+
template,
|
|
828
|
+
templateParams
|
|
829
|
+
} = structureParams, {
|
|
830
|
+
t
|
|
831
|
+
} = useTranslation(presentationLocaleNamespace), {
|
|
832
|
+
devMode
|
|
833
|
+
} = usePresentationTool();
|
|
834
|
+
let t0;
|
|
835
|
+
$[0] !== templateParams ? (t0 = decodeJsonParams(templateParams), $[0] = templateParams, $[1] = t0) : t0 = $[1];
|
|
836
|
+
let t1;
|
|
837
|
+
$[2] !== documentId || $[3] !== documentType || $[4] !== t0 || $[5] !== template ? (t1 = {
|
|
838
|
+
id: documentId,
|
|
839
|
+
type: documentType,
|
|
840
|
+
template,
|
|
841
|
+
templateParameters: t0
|
|
842
|
+
}, $[2] = documentId, $[3] = documentType, $[4] = t0, $[5] = template, $[6] = t1) : t1 = $[6];
|
|
843
|
+
let t2;
|
|
844
|
+
$[7] !== documentId || $[8] !== t1 ? (t2 = {
|
|
845
|
+
id: documentId,
|
|
846
|
+
options: t1,
|
|
847
|
+
title: "",
|
|
848
|
+
type: "document"
|
|
849
|
+
}, $[7] = documentId, $[8] = t1, $[9] = t2) : t2 = $[9];
|
|
850
|
+
const paneDocumentNode = t2;
|
|
851
|
+
let t3;
|
|
852
|
+
$[10] !== documentId || $[11] !== documentType || $[12] !== onFocusPath ? (t3 = (path) => onFocusPath({
|
|
853
|
+
id: documentId,
|
|
854
|
+
type: documentType,
|
|
855
|
+
path: studioPath.toString(path)
|
|
856
|
+
}), $[10] = documentId, $[11] = documentType, $[12] = onFocusPath, $[13] = t3) : t3 = $[13];
|
|
857
|
+
const handleFocusPath = t3, [errorParams, setErrorParams] = useState(null);
|
|
858
|
+
let t4;
|
|
859
|
+
$[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setErrorParams(null), $[14] = t4) : t4 = $[14];
|
|
860
|
+
const handleRetry = t4;
|
|
861
|
+
let t5;
|
|
862
|
+
$[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
863
|
+
setErrorParams(null);
|
|
864
|
+
}, $[15] = t5) : t5 = $[15];
|
|
865
|
+
let t6;
|
|
866
|
+
if ($[16] !== documentId || $[17] !== documentType || $[18] !== structureParams ? (t6 = [documentId, documentType, structureParams], $[16] = documentId, $[17] = documentType, $[18] = structureParams, $[19] = t6) : t6 = $[19], useEffect(t5, t6), errorParams) {
|
|
867
|
+
let t72;
|
|
868
|
+
$[20] !== t ? (t72 = t("document-pane.error.text"), $[20] = t, $[21] = t72) : t72 = $[21];
|
|
869
|
+
let t82;
|
|
870
|
+
$[22] !== devMode || $[23] !== errorParams || $[24] !== t ? (t82 = devMode && /* @__PURE__ */ jsx(Card, { overflow: "auto", padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
871
|
+
/* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: t("presentation-error.label") }),
|
|
872
|
+
/* @__PURE__ */ jsx(WrappedCode, { size: 1, children: errorParams.error.message })
|
|
873
|
+
] }) }), $[22] = devMode, $[23] = errorParams, $[24] = t, $[25] = t82) : t82 = $[25];
|
|
874
|
+
let t92;
|
|
875
|
+
return $[26] !== t72 || $[27] !== t82 ? (t92 = /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t72, onRetry: handleRetry, children: t82 }), $[26] = t72, $[27] = t82, $[28] = t92) : t92 = $[28], t92;
|
|
876
|
+
}
|
|
877
|
+
let t7;
|
|
878
|
+
$[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = {
|
|
879
|
+
height: "100%"
|
|
880
|
+
}, $[29] = t7) : t7 = $[29];
|
|
881
|
+
let t8;
|
|
882
|
+
$[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[30] = t8) : t8 = $[30];
|
|
883
|
+
let t9;
|
|
884
|
+
$[31] !== handleFocusPath || $[32] !== paneDocumentNode ? (t9 = /* @__PURE__ */ jsx(Suspense, { fallback: t8, children: /* @__PURE__ */ jsx(DocumentPane$1, { paneKey: "document", index: 1, itemId: "document", pane: paneDocumentNode, onFocusPath: handleFocusPath }) }), $[31] = handleFocusPath, $[32] = paneDocumentNode, $[33] = t9) : t9 = $[33];
|
|
885
|
+
let t10;
|
|
886
|
+
return $[34] !== onEditReference || $[35] !== onStructureParams || $[36] !== searchParams || $[37] !== structureParams || $[38] !== t9 ? (t10 = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch: setErrorParams, children: /* @__PURE__ */ jsx(PaneLayout, { style: t7, children: /* @__PURE__ */ jsx(PresentationPaneRouterProvider, { searchParams, onEditReference, onStructureParams, structureParams, children: t9 }) }) }), $[34] = onEditReference, $[35] = onStructureParams, $[36] = searchParams, $[37] = structureParams, $[38] = t9, $[39] = t10) : t10 = $[39], t10;
|
|
887
|
+
}
|
|
888
|
+
function DocumentPanel(props) {
|
|
889
|
+
const $ = c(8), {
|
|
890
|
+
documentId,
|
|
891
|
+
documentType,
|
|
892
|
+
onFocusPath,
|
|
893
|
+
onEditReference,
|
|
894
|
+
onStructureParams,
|
|
895
|
+
searchParams,
|
|
896
|
+
structureParams
|
|
897
|
+
} = props;
|
|
898
|
+
let t0;
|
|
899
|
+
return $[0] !== documentId || $[1] !== documentType || $[2] !== onEditReference || $[3] !== onFocusPath || $[4] !== onStructureParams || $[5] !== searchParams || $[6] !== structureParams ? (t0 = /* @__PURE__ */ jsx(StructureToolProvider$1, { children: /* @__PURE__ */ jsx(DocumentPane, { documentId, documentType, onEditReference, onFocusPath, onStructureParams, searchParams, structureParams }) }), $[0] = documentId, $[1] = documentType, $[2] = onEditReference, $[3] = onFocusPath, $[4] = onStructureParams, $[5] = searchParams, $[6] = structureParams, $[7] = t0) : t0 = $[7], t0;
|
|
900
|
+
}
|
|
901
|
+
function usePreviewState(documentId, schemaType2) {
|
|
902
|
+
const $ = c(7), documentPreviewStore = useDocumentPreviewStore();
|
|
903
|
+
let t0;
|
|
904
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0];
|
|
905
|
+
const [preview, setPreview] = useState(t0), {
|
|
906
|
+
perspectiveStack
|
|
907
|
+
} = usePerspective();
|
|
908
|
+
let t1, t2;
|
|
909
|
+
return $[1] !== documentId || $[2] !== documentPreviewStore || $[3] !== perspectiveStack || $[4] !== schemaType2 ? (t1 = () => {
|
|
910
|
+
if (!schemaType2)
|
|
911
|
+
return;
|
|
912
|
+
const subscription = getPreviewStateObservable(documentPreviewStore, schemaType2, documentId, perspectiveStack).subscribe((state) => {
|
|
913
|
+
setPreview(state);
|
|
914
|
+
});
|
|
915
|
+
return () => {
|
|
916
|
+
subscription?.unsubscribe();
|
|
917
|
+
};
|
|
918
|
+
}, t2 = [documentPreviewStore, schemaType2, documentId, perspectiveStack], $[1] = documentId, $[2] = documentPreviewStore, $[3] = perspectiveStack, $[4] = schemaType2, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2), preview;
|
|
919
|
+
}
|
|
920
|
+
function ContentEditor(props) {
|
|
921
|
+
const $ = c(40), {
|
|
922
|
+
documentId,
|
|
923
|
+
documentType,
|
|
924
|
+
mainDocumentState,
|
|
925
|
+
onEditReference,
|
|
926
|
+
onFocusPath,
|
|
927
|
+
onStructureParams,
|
|
928
|
+
refs,
|
|
929
|
+
searchParams,
|
|
930
|
+
structureParams
|
|
931
|
+
} = props, {
|
|
932
|
+
t
|
|
933
|
+
} = useTranslation(presentationLocaleNamespace), schema = useSchema();
|
|
934
|
+
let t0;
|
|
935
|
+
$[0] !== mainDocumentState?.document?._id || $[1] !== mainDocumentState?.document?._type || $[2] !== searchParams ? (t0 = (props_0) => /* @__PURE__ */ jsx(StateLink, { ...props_0, state: {
|
|
936
|
+
id: mainDocumentState?.document?._id,
|
|
937
|
+
type: mainDocumentState?.document?._type,
|
|
938
|
+
_searchParams: Object.entries(searchParams)
|
|
939
|
+
} }), $[0] = mainDocumentState?.document?._id, $[1] = mainDocumentState?.document?._type, $[2] = searchParams, $[3] = t0) : t0 = $[3];
|
|
940
|
+
const MainDocumentLink = t0;
|
|
941
|
+
let t1;
|
|
942
|
+
$[4] !== mainDocumentState?.document?._type || $[5] !== schema ? (t1 = schema.get(mainDocumentState?.document?._type || "shoe"), $[4] = mainDocumentState?.document?._type, $[5] = schema, $[6] = t1) : t1 = $[6];
|
|
943
|
+
const schemaType2 = t1, previewState = usePreviewState(mainDocumentState?.document?._id || "", schemaType2);
|
|
944
|
+
let t2;
|
|
945
|
+
bb0: {
|
|
946
|
+
if (!mainDocumentState?.document) {
|
|
947
|
+
t2 = null;
|
|
948
|
+
break bb0;
|
|
949
|
+
}
|
|
950
|
+
let t32;
|
|
951
|
+
$[7] !== mainDocumentState.document || $[8] !== previewState.snapshot ? (t32 = getPreviewValueWithFallback({
|
|
952
|
+
snapshot: previewState.snapshot,
|
|
953
|
+
fallback: mainDocumentState.document
|
|
954
|
+
}), $[7] = mainDocumentState.document, $[8] = previewState.snapshot, $[9] = t32) : t32 = $[9];
|
|
955
|
+
let t42;
|
|
956
|
+
$[10] !== t ? (t42 = t("main-document.label"), $[10] = t, $[11] = t42) : t42 = $[11];
|
|
957
|
+
let t52;
|
|
958
|
+
$[12] !== t42 ? (t52 = /* @__PURE__ */ jsx(Card, { padding: 1, radius: 2, shadow: 1, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 0, weight: "medium", children: t42 }) }), $[12] = t42, $[13] = t52) : t52 = $[13];
|
|
959
|
+
let t6;
|
|
960
|
+
$[14] !== schemaType2 || $[15] !== t32 || $[16] !== t52 ? (t6 = /* @__PURE__ */ jsx(SanityDefaultPreview, { ...t32, schemaType: schemaType2, status: t52 }), $[14] = schemaType2, $[15] = t32, $[16] = t52, $[17] = t6) : t6 = $[17], t2 = t6;
|
|
961
|
+
}
|
|
962
|
+
const preview = t2;
|
|
963
|
+
if (documentId && documentType) {
|
|
964
|
+
let t32;
|
|
965
|
+
return $[18] !== documentId || $[19] !== documentType || $[20] !== onEditReference || $[21] !== onFocusPath || $[22] !== onStructureParams || $[23] !== searchParams || $[24] !== structureParams ? (t32 = /* @__PURE__ */ jsx(DocumentPanel, { documentId, documentType, onEditReference, onFocusPath, onStructureParams, searchParams, structureParams }), $[18] = documentId, $[19] = documentType, $[20] = onEditReference, $[21] = onFocusPath, $[22] = onStructureParams, $[23] = searchParams, $[24] = structureParams, $[25] = t32) : t32 = $[25], t32;
|
|
966
|
+
}
|
|
967
|
+
let t3;
|
|
968
|
+
$[26] !== MainDocumentLink || $[27] !== mainDocumentState || $[28] !== preview || $[29] !== t ? (t3 = mainDocumentState && /* @__PURE__ */ jsx(Card, { padding: 3, tone: mainDocumentState.document ? "inherit" : "caution", children: mainDocumentState.document ? /* @__PURE__ */ jsx(PreviewCard, { __unstable_focusRing: !0, as: MainDocumentLink, "data-as": "a", radius: 2, sizing: "border", tone: "inherit", children: preview }) : /* @__PURE__ */ jsx(Card, { padding: 2, radius: 2, tone: "inherit", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
|
|
969
|
+
/* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(WarningOutlineIcon, {}) }) }),
|
|
970
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Translate, { t, i18nKey: "main-document.missing.text", components: {
|
|
971
|
+
Code: "code"
|
|
972
|
+
}, values: {
|
|
973
|
+
path: mainDocumentState.path
|
|
974
|
+
} }) }) })
|
|
975
|
+
] }) }) }), $[26] = MainDocumentLink, $[27] = mainDocumentState, $[28] = preview, $[29] = t, $[30] = t3) : t3 = $[30];
|
|
976
|
+
let t4;
|
|
977
|
+
$[31] !== mainDocumentState || $[32] !== onEditReference || $[33] !== onStructureParams || $[34] !== refs || $[35] !== searchParams ? (t4 = /* @__PURE__ */ jsx(DocumentListPane, { mainDocumentState, onEditReference, onStructureParams, searchParams, refs }), $[31] = mainDocumentState, $[32] = onEditReference, $[33] = onStructureParams, $[34] = refs, $[35] = searchParams, $[36] = t4) : t4 = $[36];
|
|
978
|
+
let t5;
|
|
979
|
+
return $[37] !== t3 || $[38] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, { direction: "column", flex: 1, height: "fill", children: [
|
|
980
|
+
t3,
|
|
981
|
+
t4
|
|
982
|
+
] }), $[37] = t3, $[38] = t4, $[39] = t5) : t5 = $[39], t5;
|
|
983
|
+
}
|
|
984
|
+
function usePanelId(id) {
|
|
985
|
+
const $ = c(2);
|
|
986
|
+
let t0;
|
|
987
|
+
$[0] !== id ? (t0 = () => id || v4(), $[0] = id, $[1] = t0) : t0 = $[1];
|
|
988
|
+
const [panelId] = useState(t0);
|
|
989
|
+
return panelId;
|
|
990
|
+
}
|
|
991
|
+
const Resizer = styled.div.withConfig({
|
|
992
|
+
displayName: "Resizer",
|
|
993
|
+
componentId: "sc-1ov4oxw-0"
|
|
994
|
+
})`position:relative;`, ResizerInner = styled.div.withConfig({
|
|
995
|
+
displayName: "ResizerInner",
|
|
996
|
+
componentId: "sc-1ov4oxw-1"
|
|
997
|
+
})`position:absolute;top:0;bottom:0;left:-5px;width:9px;z-index:10;cursor:${({
|
|
998
|
+
$disabled
|
|
999
|
+
}) => $disabled ? "auto" : "ew-resize"};& > span:nth-child(1){display:block;border-left:1px solid var(--card-border-color);position:absolute;top:0;left:4px;bottom:0;transition:opacity 200ms;}${({
|
|
1000
|
+
$disabled
|
|
1001
|
+
}) => !$disabled && `
|
|
1002
|
+
/* Hover effect */
|
|
1003
|
+
& > span:nth-child(2) {
|
|
1004
|
+
display: block;
|
|
1005
|
+
position: absolute;
|
|
1006
|
+
top: 0;
|
|
1007
|
+
left: 0;
|
|
1008
|
+
width: 9px;
|
|
1009
|
+
bottom: 0;
|
|
1010
|
+
background-color: var(--card-border-color);
|
|
1011
|
+
opacity: 0;
|
|
1012
|
+
transition: opacity 150ms;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
@media (hover: hover) {
|
|
1016
|
+
&:hover > span:nth-child(2) {
|
|
1017
|
+
opacity: 0.2;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
`}`, PanelResizer = function(t0) {
|
|
1021
|
+
const $ = c(27), {
|
|
1022
|
+
id: propId,
|
|
1023
|
+
order,
|
|
1024
|
+
disabled: t1
|
|
1025
|
+
} = t0, disabled = t1 === void 0 ? !1 : t1, el = useRef(null), context = useContext(PresentationPanelsContext);
|
|
1026
|
+
if (context === null)
|
|
1027
|
+
throw Error("Panel components must be rendered within a PanelGroup container");
|
|
1028
|
+
const id = usePanelId(propId), {
|
|
1029
|
+
activeResizer,
|
|
1030
|
+
drag,
|
|
1031
|
+
startDragging,
|
|
1032
|
+
stopDragging,
|
|
1033
|
+
registerElement,
|
|
1034
|
+
unregisterElement
|
|
1035
|
+
} = context, isDragging = activeResizer === id;
|
|
1036
|
+
if (context === null)
|
|
1037
|
+
throw Error("Panel components must be rendered within a PanelGroup container");
|
|
1038
|
+
let t2;
|
|
1039
|
+
$[0] !== id || $[1] !== startDragging ? (t2 = (event) => {
|
|
1040
|
+
startDragging(id, event.nativeEvent);
|
|
1041
|
+
}, $[0] = id, $[1] = startDragging, $[2] = t2) : t2 = $[2];
|
|
1042
|
+
const onMouseDown = t2;
|
|
1043
|
+
let t3;
|
|
1044
|
+
$[3] !== drag || $[4] !== id ? (t3 = (e) => {
|
|
1045
|
+
drag(id, e);
|
|
1046
|
+
}, $[3] = drag, $[4] = id, $[5] = t3) : t3 = $[5];
|
|
1047
|
+
const onDrag = t3;
|
|
1048
|
+
let t4;
|
|
1049
|
+
$[6] !== stopDragging ? (t4 = () => {
|
|
1050
|
+
el.current.blur(), stopDragging();
|
|
1051
|
+
}, $[6] = stopDragging, $[7] = t4) : t4 = $[7];
|
|
1052
|
+
const onDragStop = t4;
|
|
1053
|
+
let t5, t6;
|
|
1054
|
+
$[8] !== disabled || $[9] !== isDragging || $[10] !== onDrag || $[11] !== onDragStop ? (t5 = () => {
|
|
1055
|
+
if (!isDragging || disabled)
|
|
1056
|
+
return;
|
|
1057
|
+
const resetDocumentStyles = (function() {
|
|
1058
|
+
const bodyStyle = document.body.style, documentStyle = document.documentElement.style, {
|
|
1059
|
+
cursor
|
|
1060
|
+
} = documentStyle, {
|
|
1061
|
+
userSelect
|
|
1062
|
+
} = bodyStyle;
|
|
1063
|
+
return documentStyle.cursor = "ew-resize", bodyStyle.userSelect = "none", () => {
|
|
1064
|
+
cursor ? documentStyle.cursor = cursor : documentStyle.removeProperty("cursor"), userSelect ? bodyStyle.userSelect = userSelect : bodyStyle.removeProperty("user-select");
|
|
1065
|
+
};
|
|
1066
|
+
})();
|
|
1067
|
+
return window.addEventListener("mousemove", onDrag), window.addEventListener("mouseup", onDragStop), window.addEventListener("contextmenu", onDragStop), () => {
|
|
1068
|
+
resetDocumentStyles(), window.removeEventListener("mousemove", onDrag), window.removeEventListener("mouseup", onDragStop), window.removeEventListener("contextmenu", onDragStop);
|
|
1069
|
+
};
|
|
1070
|
+
}, t6 = [disabled, isDragging, onDrag, onDragStop], $[8] = disabled, $[9] = isDragging, $[10] = onDrag, $[11] = onDragStop, $[12] = t5, $[13] = t6) : (t5 = $[12], t6 = $[13]), useEffect(t5, t6);
|
|
1071
|
+
let t7, t8;
|
|
1072
|
+
$[14] !== id || $[15] !== order || $[16] !== registerElement || $[17] !== unregisterElement ? (t7 = () => (registerElement(id, {
|
|
1073
|
+
id,
|
|
1074
|
+
order,
|
|
1075
|
+
type: "resizer",
|
|
1076
|
+
el
|
|
1077
|
+
}), () => {
|
|
1078
|
+
unregisterElement(id);
|
|
1079
|
+
}), t8 = [id, order, registerElement, unregisterElement], $[14] = id, $[15] = order, $[16] = registerElement, $[17] = unregisterElement, $[18] = t7, $[19] = t8) : (t7 = $[18], t8 = $[19]), useLayoutEffect(t7, t8);
|
|
1080
|
+
let t10, t9;
|
|
1081
|
+
$[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx("span", {}), t10 = /* @__PURE__ */ jsx("span", {}), $[20] = t10, $[21] = t9) : (t10 = $[20], t9 = $[21]);
|
|
1082
|
+
let t11;
|
|
1083
|
+
$[22] !== disabled ? (t11 = /* @__PURE__ */ jsxs(ResizerInner, { $disabled: disabled, children: [
|
|
1084
|
+
t9,
|
|
1085
|
+
t10
|
|
1086
|
+
] }), $[22] = disabled, $[23] = t11) : t11 = $[23];
|
|
1087
|
+
let t12;
|
|
1088
|
+
return $[24] !== onMouseDown || $[25] !== t11 ? (t12 = /* @__PURE__ */ jsx(Resizer, { onMouseDown, ref: el, children: t11 }), $[24] = onMouseDown, $[25] = t11, $[26] = t12) : t12 = $[26], t12;
|
|
1089
|
+
}, PresentationContentWrapper = (props) => {
|
|
1090
|
+
const $ = c(8), {
|
|
1091
|
+
documentId,
|
|
1092
|
+
setDisplayedDocument,
|
|
1093
|
+
getCommentIntent
|
|
1094
|
+
} = props;
|
|
1095
|
+
let t0;
|
|
1096
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(PanelResizer, { order: 4 }), $[0] = t0) : t0 = $[0];
|
|
1097
|
+
let t1;
|
|
1098
|
+
$[1] !== getCommentIntent || $[2] !== props.children ? (t1 = /* @__PURE__ */ jsx(CommentsIntentProvider, { getIntent: getCommentIntent, children: props.children }), $[1] = getCommentIntent, $[2] = props.children, $[3] = t1) : t1 = $[3];
|
|
1099
|
+
let t2;
|
|
1100
|
+
return $[4] !== documentId || $[5] !== setDisplayedDocument || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1101
|
+
t0,
|
|
1102
|
+
/* @__PURE__ */ jsx(Panel, { id: "content", minWidth: 325, order: 5, children: /* @__PURE__ */ jsx(DisplayedDocumentBroadcasterProvider, { documentId, setDisplayedDocument, children: t1 }) })
|
|
1103
|
+
] }), $[4] = documentId, $[5] = setDisplayedDocument, $[6] = t1, $[7] = t2) : t2 = $[7], t2;
|
|
1104
|
+
}, PresentationContent = (props) => {
|
|
1105
|
+
const $ = c(15), {
|
|
1106
|
+
documentId,
|
|
1107
|
+
documentsOnPage,
|
|
1108
|
+
documentType,
|
|
1109
|
+
getCommentIntent,
|
|
1110
|
+
mainDocumentState,
|
|
1111
|
+
onEditReference,
|
|
1112
|
+
onFocusPath,
|
|
1113
|
+
onStructureParams,
|
|
1114
|
+
searchParams,
|
|
1115
|
+
setDisplayedDocument,
|
|
1116
|
+
structureParams
|
|
1117
|
+
} = props;
|
|
1118
|
+
let t0;
|
|
1119
|
+
$[0] !== documentId || $[1] !== documentType || $[2] !== documentsOnPage || $[3] !== mainDocumentState || $[4] !== onEditReference || $[5] !== onFocusPath || $[6] !== onStructureParams || $[7] !== searchParams || $[8] !== structureParams ? (t0 = /* @__PURE__ */ jsx(ContentEditor, { documentId, documentType, mainDocumentState, onEditReference, onFocusPath, onStructureParams, refs: documentsOnPage, searchParams, structureParams }), $[0] = documentId, $[1] = documentType, $[2] = documentsOnPage, $[3] = mainDocumentState, $[4] = onEditReference, $[5] = onFocusPath, $[6] = onStructureParams, $[7] = searchParams, $[8] = structureParams, $[9] = t0) : t0 = $[9];
|
|
1120
|
+
let t1;
|
|
1121
|
+
return $[10] !== documentId || $[11] !== getCommentIntent || $[12] !== setDisplayedDocument || $[13] !== t0 ? (t1 = /* @__PURE__ */ jsx(PresentationContentWrapper, { documentId, getCommentIntent, setDisplayedDocument, children: t0 }), $[10] = documentId, $[11] = getCommentIntent, $[12] = setDisplayedDocument, $[13] = t0, $[14] = t1) : t1 = $[14], t1;
|
|
1122
|
+
}, PresentationNavigateProvider = function(props) {
|
|
1123
|
+
const $ = c(5), {
|
|
1124
|
+
children,
|
|
1125
|
+
navigate: _navigate
|
|
1126
|
+
} = props;
|
|
1127
|
+
let t0;
|
|
1128
|
+
$[0] !== _navigate ? (t0 = (preview, document2) => {
|
|
1129
|
+
if (preview || document2) {
|
|
1130
|
+
const obj = {};
|
|
1131
|
+
preview && (obj.params = {
|
|
1132
|
+
preview
|
|
1133
|
+
}), document2 && (obj.state = document2), _navigate(obj);
|
|
1134
|
+
}
|
|
1135
|
+
}, $[0] = _navigate, $[1] = t0) : t0 = $[1];
|
|
1136
|
+
const navigate = t0;
|
|
1137
|
+
let t1;
|
|
1138
|
+
return $[2] !== children || $[3] !== navigate ? (t1 = /* @__PURE__ */ jsx(PresentationNavigateContext.Provider, { value: navigate, children }), $[2] = children, $[3] = navigate, $[4] = t1) : t1 = $[4], t1;
|
|
1139
|
+
};
|
|
1140
|
+
function useLocalState(key, defaultValue) {
|
|
1141
|
+
const $ = c(9);
|
|
1142
|
+
let t0;
|
|
1143
|
+
$[0] !== defaultValue || $[1] !== key ? (t0 = () => JSON.parse(localStorage.getItem(key) ?? JSON.stringify(defaultValue)), $[0] = defaultValue, $[1] = key, $[2] = t0) : t0 = $[2];
|
|
1144
|
+
const [value, setValue] = useState(t0);
|
|
1145
|
+
let t1, t2;
|
|
1146
|
+
$[3] !== key || $[4] !== value ? (t1 = () => {
|
|
1147
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
1148
|
+
}, t2 = [key, value], $[3] = key, $[4] = value, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2);
|
|
1149
|
+
let t3;
|
|
1150
|
+
return $[7] !== value ? (t3 = [value, setValue], $[7] = value, $[8] = t3) : t3 = $[8], t3;
|
|
1151
|
+
}
|
|
1152
|
+
function usePresentationNavigator(props) {
|
|
1153
|
+
const $ = c(11), {
|
|
1154
|
+
unstable_navigator
|
|
1155
|
+
} = props, navigatorProvided = !!unstable_navigator?.component, [_navigatorEnabled, setNavigatorEnabled] = useLocalState("presentation/navigator", navigatorProvided), navigatorEnabled = navigatorProvided ? _navigatorEnabled : !1;
|
|
1156
|
+
let t0;
|
|
1157
|
+
bb0: {
|
|
1158
|
+
if (!navigatorProvided) {
|
|
1159
|
+
t0 = void 0;
|
|
1160
|
+
break bb0;
|
|
1161
|
+
}
|
|
1162
|
+
let t12;
|
|
1163
|
+
$[0] !== setNavigatorEnabled ? (t12 = () => setNavigatorEnabled(_temp$d), $[0] = setNavigatorEnabled, $[1] = t12) : t12 = $[1], t0 = t12;
|
|
1164
|
+
}
|
|
1165
|
+
const toggleNavigator = t0;
|
|
1166
|
+
let t1;
|
|
1167
|
+
$[2] !== navigatorEnabled || $[3] !== unstable_navigator ? (t1 = function() {
|
|
1168
|
+
return /* @__PURE__ */ jsx(Fragment, { children: navigatorEnabled && /* @__PURE__ */ jsx(Navigator, { ...unstable_navigator }) });
|
|
1169
|
+
}, $[2] = navigatorEnabled, $[3] = unstable_navigator, $[4] = t1) : t1 = $[4];
|
|
1170
|
+
const Component = t1;
|
|
1171
|
+
let t2;
|
|
1172
|
+
$[5] !== navigatorEnabled || $[6] !== toggleNavigator ? (t2 = {
|
|
1173
|
+
navigatorEnabled,
|
|
1174
|
+
toggleNavigator
|
|
1175
|
+
}, $[5] = navigatorEnabled, $[6] = toggleNavigator, $[7] = t2) : t2 = $[7];
|
|
1176
|
+
let t3;
|
|
1177
|
+
return $[8] !== Component || $[9] !== t2 ? (t3 = [t2, Component], $[8] = Component, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
|
|
1178
|
+
}
|
|
1179
|
+
function _temp$d(enabled) {
|
|
1180
|
+
return !enabled;
|
|
1181
|
+
}
|
|
1182
|
+
function NavigatorComponent(props) {
|
|
1183
|
+
const $ = c(11), {
|
|
1184
|
+
minWidth,
|
|
1185
|
+
maxWidth,
|
|
1186
|
+
component: NavigatorComponent2
|
|
1187
|
+
} = props, navigatorDisabled = minWidth != null && maxWidth != null && minWidth === maxWidth;
|
|
1188
|
+
let t0;
|
|
1189
|
+
$[0] !== NavigatorComponent2 ? (t0 = /* @__PURE__ */ jsx(NavigatorComponent2, {}), $[0] = NavigatorComponent2, $[1] = t0) : t0 = $[1];
|
|
1190
|
+
let t1;
|
|
1191
|
+
$[2] !== maxWidth || $[3] !== minWidth || $[4] !== t0 ? (t1 = /* @__PURE__ */ jsx(Panel, { id: "navigator", minWidth, maxWidth, order: 1, children: t0 }), $[2] = maxWidth, $[3] = minWidth, $[4] = t0, $[5] = t1) : t1 = $[5];
|
|
1192
|
+
let t2;
|
|
1193
|
+
$[6] !== navigatorDisabled ? (t2 = /* @__PURE__ */ jsx(PanelResizer, { order: 2, disabled: navigatorDisabled }), $[6] = navigatorDisabled, $[7] = t2) : t2 = $[7];
|
|
1194
|
+
let t3;
|
|
1195
|
+
return $[8] !== t1 || $[9] !== t2 ? (t3 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1196
|
+
t1,
|
|
1197
|
+
t2
|
|
1198
|
+
] }), $[8] = t1, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
|
|
1199
|
+
}
|
|
1200
|
+
const Navigator = memo(NavigatorComponent), PresentationParamsProvider = function(props) {
|
|
1201
|
+
const $ = c(3), {
|
|
1202
|
+
children,
|
|
1203
|
+
params
|
|
1204
|
+
} = props, context = params;
|
|
1205
|
+
let t0;
|
|
1206
|
+
return $[0] !== children || $[1] !== context ? (t0 = /* @__PURE__ */ jsx(PresentationParamsContext.Provider, { value: context, children }), $[0] = children, $[1] = context, $[2] = t0) : t0 = $[2], t0;
|
|
1207
|
+
}, PresentationProvider = function(props) {
|
|
1208
|
+
const $ = c(10), {
|
|
1209
|
+
children,
|
|
1210
|
+
devMode,
|
|
1211
|
+
name,
|
|
1212
|
+
navigate,
|
|
1213
|
+
params,
|
|
1214
|
+
searchParams,
|
|
1215
|
+
structureParams
|
|
1216
|
+
} = props;
|
|
1217
|
+
let t0;
|
|
1218
|
+
$[0] !== devMode || $[1] !== name || $[2] !== navigate || $[3] !== params || $[4] !== searchParams || $[5] !== structureParams ? (t0 = {
|
|
1219
|
+
devMode,
|
|
1220
|
+
name,
|
|
1221
|
+
navigate,
|
|
1222
|
+
params,
|
|
1223
|
+
searchParams,
|
|
1224
|
+
structureParams
|
|
1225
|
+
}, $[0] = devMode, $[1] = name, $[2] = navigate, $[3] = params, $[4] = searchParams, $[5] = structureParams, $[6] = t0) : t0 = $[6];
|
|
1226
|
+
const context = t0;
|
|
1227
|
+
let t1;
|
|
1228
|
+
return $[7] !== children || $[8] !== context ? (t1 = /* @__PURE__ */ jsx(PresentationContext.Provider, { value: context, children }), $[7] = children, $[8] = context, $[9] = t1) : t1 = $[9], t1;
|
|
1229
|
+
};
|
|
1230
|
+
function useAllowPatterns(previewUrlRef) {
|
|
1231
|
+
const allowPatterns = useSelector(previewUrlRef, _temp$c);
|
|
1232
|
+
if (!Array.isArray(allowPatterns))
|
|
1233
|
+
throw new TypeError("allowPatterns must be an array");
|
|
1234
|
+
return allowPatterns;
|
|
1235
|
+
}
|
|
1236
|
+
function _temp$c(state) {
|
|
1237
|
+
return state.context.allowOrigins;
|
|
1238
|
+
}
|
|
1239
|
+
function encodeStudioPerspective(studioPerspective) {
|
|
1240
|
+
return Array.isArray(studioPerspective) ? studioPerspective.join(",") : studioPerspective;
|
|
1241
|
+
}
|
|
1242
|
+
function useId() {
|
|
1243
|
+
const $ = c(2), id = useId$1();
|
|
1244
|
+
let t0;
|
|
1245
|
+
return $[0] !== id ? (t0 = id.startsWith(":") ? id.replace(/^:(.+):$/, "\xAB$1\xBB") : id, $[0] = id, $[1] = t0) : t0 = $[1], t0;
|
|
1246
|
+
}
|
|
1247
|
+
const IFrame = forwardRef(function(props, forwardedRef) {
|
|
1248
|
+
const $ = c(19), {
|
|
1249
|
+
animate,
|
|
1250
|
+
initial,
|
|
1251
|
+
onLoad,
|
|
1252
|
+
preventClick,
|
|
1253
|
+
src,
|
|
1254
|
+
variants,
|
|
1255
|
+
style
|
|
1256
|
+
} = props, ref = useRef(null);
|
|
1257
|
+
let t0;
|
|
1258
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = () => ref.current, $[0] = t0) : t0 = $[0], useImperativeHandle(forwardedRef, t0);
|
|
1259
|
+
let t1, t2;
|
|
1260
|
+
$[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
|
|
1261
|
+
if (!ref.current)
|
|
1262
|
+
return;
|
|
1263
|
+
const instance = ref.current, handleBlur = function() {
|
|
1264
|
+
instance === document.activeElement && instance.dispatchEvent(new MouseEvent("mousedown", {
|
|
1265
|
+
bubbles: !0,
|
|
1266
|
+
cancelable: !0
|
|
1267
|
+
}));
|
|
1268
|
+
};
|
|
1269
|
+
return window.addEventListener("blur", handleBlur), () => {
|
|
1270
|
+
window.removeEventListener("blur", handleBlur);
|
|
1271
|
+
};
|
|
1272
|
+
}, t2 = [], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), useEffect(t1, t2);
|
|
1273
|
+
const viewTransitionName = useId();
|
|
1274
|
+
let t3;
|
|
1275
|
+
$[3] !== style || $[4] !== viewTransitionName ? (t3 = {
|
|
1276
|
+
...style,
|
|
1277
|
+
viewTransitionName
|
|
1278
|
+
}, $[3] = style, $[4] = viewTransitionName, $[5] = t3) : t3 = $[5];
|
|
1279
|
+
let t4;
|
|
1280
|
+
$[6] !== animate || $[7] !== initial || $[8] !== onLoad || $[9] !== src || $[10] !== t3 || $[11] !== variants ? (t4 = /* @__PURE__ */ jsx(IFrameElement, { style: t3, animate, initial, onLoad, ref, src, variants }), $[6] = animate, $[7] = initial, $[8] = onLoad, $[9] = src, $[10] = t3, $[11] = variants, $[12] = t4) : t4 = $[12];
|
|
1281
|
+
let t5;
|
|
1282
|
+
$[13] !== preventClick ? (t5 = preventClick && /* @__PURE__ */ jsx(IFrameOverlay, {}), $[13] = preventClick, $[14] = t5) : t5 = $[14];
|
|
1283
|
+
let t6;
|
|
1284
|
+
$[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = /* @__PURE__ */ jsx(GlobalViewTransition, {}), $[15] = t6) : t6 = $[15];
|
|
1285
|
+
let t7;
|
|
1286
|
+
return $[16] !== t4 || $[17] !== t5 ? (t7 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1287
|
+
t4,
|
|
1288
|
+
t5,
|
|
1289
|
+
t6
|
|
1290
|
+
] }), $[16] = t4, $[17] = t5, $[18] = t7) : t7 = $[18], t7;
|
|
1291
|
+
}), IFrameElement = motion.create(styled.iframe.withConfig({
|
|
1292
|
+
displayName: "IFrameElement",
|
|
1293
|
+
componentId: "sc-yizz5y-0"
|
|
1294
|
+
})`box-shadow:0 0 0 1px var(--card-border-color);border:0;max-height:100%;width:100%;view-transition-class:presentation-tool-iframe;`), IFrameOverlay = styled(Box).withConfig({
|
|
1295
|
+
displayName: "IFrameOverlay",
|
|
1296
|
+
componentId: "sc-yizz5y-1"
|
|
1297
|
+
})`position:absolute;inset:0;background:transparent;`, GlobalViewTransition = createGlobalStyle`
|
|
1298
|
+
html:active-view-transition-type(sanity-iframe-viewport) {
|
|
1299
|
+
view-transition-name: none;
|
|
1300
|
+
&::view-transition {
|
|
1301
|
+
pointer-events: none;
|
|
1302
|
+
}
|
|
1303
|
+
/* &::view-transition-old(root) {
|
|
1304
|
+
display: none;
|
|
1305
|
+
}
|
|
1306
|
+
&::view-transition-new(root) {
|
|
1307
|
+
animation: none;
|
|
1308
|
+
} */
|
|
1309
|
+
}
|
|
1310
|
+
`;
|
|
1311
|
+
function OpenPreviewButton(props) {
|
|
1312
|
+
const $ = c(21), {
|
|
1313
|
+
openPopup,
|
|
1314
|
+
previewLocationOrigin,
|
|
1315
|
+
previewLocationRoute,
|
|
1316
|
+
perspective,
|
|
1317
|
+
targetOrigin
|
|
1318
|
+
} = props;
|
|
1319
|
+
let url;
|
|
1320
|
+
$[0] !== perspective || $[1] !== previewLocationOrigin || $[2] !== previewLocationRoute || $[3] !== targetOrigin ? (url = new URL(previewLocationRoute, previewLocationOrigin || targetOrigin), url.searchParams.set(urlSearchParamPreviewPerspective, encodeStudioPerspective(perspective)), $[0] = perspective, $[1] = previewLocationOrigin, $[2] = previewLocationRoute, $[3] = targetOrigin, $[4] = url) : url = $[4];
|
|
1321
|
+
const {
|
|
1322
|
+
pathname,
|
|
1323
|
+
search
|
|
1324
|
+
} = url, openPreviewLink = `${previewLocationOrigin}${pathname}${search}`, {
|
|
1325
|
+
t
|
|
1326
|
+
} = useTranslation(presentationLocaleNamespace);
|
|
1327
|
+
let t0;
|
|
1328
|
+
$[5] !== openPopup ? (t0 = (event) => {
|
|
1329
|
+
event.preventDefault(), openPopup(event.currentTarget.href);
|
|
1330
|
+
}, $[5] = openPopup, $[6] = t0) : t0 = $[6];
|
|
1331
|
+
const handleOpenPopup = t0;
|
|
1332
|
+
let t1;
|
|
1333
|
+
$[7] !== t ? (t1 = t("share-url.menu-item.open.text"), $[7] = t, $[8] = t1) : t1 = $[8];
|
|
1334
|
+
let t2;
|
|
1335
|
+
$[9] !== t1 ? (t2 = /* @__PURE__ */ jsx(Text, { size: 1, children: t1 }), $[9] = t1, $[10] = t2) : t2 = $[10];
|
|
1336
|
+
let t3;
|
|
1337
|
+
$[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = ["bottom-start"], $[11] = t3) : t3 = $[11];
|
|
1338
|
+
let t4;
|
|
1339
|
+
$[12] !== t ? (t4 = t("share-url.menu-item.open.text"), $[12] = t, $[13] = t4) : t4 = $[13];
|
|
1340
|
+
let t5;
|
|
1341
|
+
$[14] !== handleOpenPopup || $[15] !== openPreviewLink || $[16] !== t4 ? (t5 = /* @__PURE__ */ jsx(Button, { as: "a", "aria-label": t4, icon: LaunchIcon, mode: "bleed", href: openPreviewLink, rel: "opener", target: "_blank", tooltipProps: null, onClick: handleOpenPopup }), $[14] = handleOpenPopup, $[15] = openPreviewLink, $[16] = t4, $[17] = t5) : t5 = $[17];
|
|
1342
|
+
let t6;
|
|
1343
|
+
return $[18] !== t2 || $[19] !== t5 ? (t6 = /* @__PURE__ */ jsx(Tooltip, { animate: !0, content: t2, fallbackPlacements: t3, placement: "bottom", portal: !0, children: t5 }), $[18] = t2, $[19] = t5, $[20] = t6) : t6 = $[20], t6;
|
|
1344
|
+
}
|
|
1345
|
+
function useTargetOrigin(previewUrlRef) {
|
|
1346
|
+
const targetOrigin = useSelector(previewUrlRef, _temp$b);
|
|
1347
|
+
if (!targetOrigin)
|
|
1348
|
+
throw new TypeError("targetOrigin is required");
|
|
1349
|
+
return targetOrigin;
|
|
1350
|
+
}
|
|
1351
|
+
function _temp$b(state) {
|
|
1352
|
+
return state.context.previewUrl?.origin;
|
|
1353
|
+
}
|
|
1354
|
+
function PreviewLocationInput(props) {
|
|
1355
|
+
const $ = c(32), {
|
|
1356
|
+
fontSize: t0,
|
|
1357
|
+
onChange,
|
|
1358
|
+
padding: t1,
|
|
1359
|
+
prefix,
|
|
1360
|
+
suffix,
|
|
1361
|
+
value,
|
|
1362
|
+
previewUrlRef
|
|
1363
|
+
} = props, fontSize = t0 === void 0 ? 1 : t0, padding = t1 === void 0 ? 3 : t1, allowOrigins = useAllowPatterns(previewUrlRef), targetOrigin = useTargetOrigin(previewUrlRef), {
|
|
1364
|
+
t
|
|
1365
|
+
} = useTranslation(presentationLocaleNamespace), {
|
|
1366
|
+
basePath: t2
|
|
1367
|
+
} = useActiveWorkspace()?.activeWorkspace || {}, basePath = t2 === void 0 ? "/" : t2, inputRef = useRef(null), [sessionValue, setSessionValue] = useState(void 0), [customValidity, setCustomValidity] = useState(void 0);
|
|
1368
|
+
let t3;
|
|
1369
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = (event) => {
|
|
1370
|
+
setSessionValue(event.currentTarget.value);
|
|
1371
|
+
}, $[0] = t3) : t3 = $[0];
|
|
1372
|
+
const handleChange = t3;
|
|
1373
|
+
let t4;
|
|
1374
|
+
$[1] !== allowOrigins || $[2] !== basePath || $[3] !== onChange || $[4] !== sessionValue || $[5] !== t || $[6] !== targetOrigin ? (t4 = (event_0) => {
|
|
1375
|
+
if (event_0.key === "Enter") {
|
|
1376
|
+
if (sessionValue === void 0)
|
|
1377
|
+
return;
|
|
1378
|
+
let absoluteValue = sessionValue;
|
|
1379
|
+
try {
|
|
1380
|
+
absoluteValue = new URL(sessionValue, targetOrigin).toString();
|
|
1381
|
+
} catch {
|
|
1382
|
+
}
|
|
1383
|
+
if (Array.isArray(allowOrigins)) {
|
|
1384
|
+
if (!allowOrigins.some((pattern) => pattern.test(absoluteValue))) {
|
|
1385
|
+
setCustomValidity(t("preview-location-input.error", {
|
|
1386
|
+
origin: targetOrigin,
|
|
1387
|
+
context: "origin-not-allowed"
|
|
1388
|
+
})), event_0.currentTarget.reportValidity();
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
} else if (!targetOrigin && (absoluteValue.startsWith(`${basePath}/`) || absoluteValue === basePath)) {
|
|
1392
|
+
setCustomValidity(t("preview-location-input.error", {
|
|
1393
|
+
basePath,
|
|
1394
|
+
context: "same-base-path"
|
|
1395
|
+
}));
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
const nextValue = absoluteValue === targetOrigin ? `${targetOrigin}/` : absoluteValue;
|
|
1399
|
+
setCustomValidity(void 0), setSessionValue(void 0), onChange(nextValue), inputRef.current?.blur();
|
|
1400
|
+
}
|
|
1401
|
+
event_0.key === "Escape" && (setCustomValidity(void 0), setSessionValue(void 0));
|
|
1402
|
+
}, $[1] = allowOrigins, $[2] = basePath, $[3] = onChange, $[4] = sessionValue, $[5] = t, $[6] = targetOrigin, $[7] = t4) : t4 = $[7];
|
|
1403
|
+
const handleKeyDown = t4;
|
|
1404
|
+
let t5;
|
|
1405
|
+
$[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
1406
|
+
setCustomValidity(void 0), setSessionValue(void 0);
|
|
1407
|
+
}, $[8] = t5) : t5 = $[8];
|
|
1408
|
+
const handleBlur = t5;
|
|
1409
|
+
let t6;
|
|
1410
|
+
$[9] !== targetOrigin || $[10] !== value ? (t6 = () => {
|
|
1411
|
+
setCustomValidity(void 0);
|
|
1412
|
+
let nextValue_0 = value;
|
|
1413
|
+
try {
|
|
1414
|
+
nextValue_0 = new URL(value, targetOrigin).toString();
|
|
1415
|
+
} catch {
|
|
1416
|
+
}
|
|
1417
|
+
setSessionValue(nextValue_0);
|
|
1418
|
+
}, $[9] = targetOrigin, $[10] = value, $[11] = t6) : t6 = $[11];
|
|
1419
|
+
const handleClear = t6;
|
|
1420
|
+
let t7;
|
|
1421
|
+
$[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = () => {
|
|
1422
|
+
setCustomValidity(void 0), setSessionValue(void 0);
|
|
1423
|
+
}, $[12] = t7) : t7 = $[12];
|
|
1424
|
+
let t8;
|
|
1425
|
+
$[13] !== targetOrigin || $[14] !== value ? (t8 = [targetOrigin, value], $[13] = targetOrigin, $[14] = value, $[15] = t8) : t8 = $[15], useEffect(t7, t8);
|
|
1426
|
+
let t9;
|
|
1427
|
+
$[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = {
|
|
1428
|
+
icon: ResetIcon
|
|
1429
|
+
}, $[16] = t9) : t9 = $[16];
|
|
1430
|
+
const t10 = customValidity ? t9 : void 0;
|
|
1431
|
+
let t11;
|
|
1432
|
+
$[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = {
|
|
1433
|
+
zIndex: 1
|
|
1434
|
+
}, $[17] = t11) : t11 = $[17];
|
|
1435
|
+
let t12;
|
|
1436
|
+
$[18] !== sessionValue || $[19] !== targetOrigin || $[20] !== value ? (t12 = sessionValue === void 0 ? new URL(value, targetOrigin).toString() : sessionValue, $[18] = sessionValue, $[19] = targetOrigin, $[20] = value, $[21] = t12) : t12 = $[21];
|
|
1437
|
+
let t13;
|
|
1438
|
+
return $[22] !== customValidity || $[23] !== fontSize || $[24] !== handleClear || $[25] !== handleKeyDown || $[26] !== padding || $[27] !== prefix || $[28] !== suffix || $[29] !== t10 || $[30] !== t12 ? (t13 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(TextInput, { clearButton: t10, customValidity, fontSize, onBlur: handleBlur, onClear: handleClear, onChange: handleChange, onKeyDownCapture: handleKeyDown, padding, prefix, style: t11, radius: 2, ref: inputRef, space: padding, suffix, value: t12 }) }), $[22] = customValidity, $[23] = fontSize, $[24] = handleClear, $[25] = handleKeyDown, $[26] = padding, $[27] = prefix, $[28] = suffix, $[29] = t10, $[30] = t12, $[31] = t13) : t13 = $[31], t13;
|
|
1439
|
+
}
|
|
1440
|
+
const QRCodeSVG = lazy(() => import("./QRCodeSVG.js")), QrCodeLogoSize = 24, QrCodeLogoPadding = 16, QrSize = 224, StyledSanityMonogram = styled(SanityMonogram).withConfig({
|
|
1441
|
+
displayName: "StyledSanityMonogram",
|
|
1442
|
+
componentId: "sc-wa94k4-0"
|
|
1443
|
+
})`position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);height:${QrCodeLogoSize}px;width:${QrCodeLogoSize}px;`, MotionSpinner = motion.create(Spinner), MotionText = motion.create(Text), MotionMonogram = motion.create(StyledSanityMonogram);
|
|
1444
|
+
function SharePreviewMenu(props) {
|
|
1445
|
+
const $ = c(47), {
|
|
1446
|
+
canToggleSharePreviewAccess,
|
|
1447
|
+
canUseSharedPreviewAccess,
|
|
1448
|
+
initialUrl,
|
|
1449
|
+
previewLocationRoute,
|
|
1450
|
+
perspective
|
|
1451
|
+
} = props, {
|
|
1452
|
+
t
|
|
1453
|
+
} = useTranslation(presentationLocaleNamespace), {
|
|
1454
|
+
push: pushToast
|
|
1455
|
+
} = useToast();
|
|
1456
|
+
let t0;
|
|
1457
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
1458
|
+
apiVersion: API_VERSION
|
|
1459
|
+
}, $[0] = t0) : t0 = $[0];
|
|
1460
|
+
const client = useClient(t0), currentUser = useCurrentUser(), [loading, setLoading] = useState(!0), [enabling, setEnabling] = useState(!1), [disabling, setDisabling] = useState(!1), [secret, setSecret] = useState(null), busy = enabling || disabling || loading;
|
|
1461
|
+
let t1;
|
|
1462
|
+
$[1] !== initialUrl || $[2] !== perspective || $[3] !== previewLocationRoute || $[4] !== secret ? (t1 = secret ? setSecretSearchParams(initialUrl, secret, previewLocationRoute, encodeStudioPerspective(perspective)) : null, $[1] = initialUrl, $[2] = perspective, $[3] = previewLocationRoute, $[4] = secret, $[5] = t1) : t1 = $[5];
|
|
1463
|
+
const url = t1, [error, setError] = useState(null);
|
|
1464
|
+
if (error)
|
|
1465
|
+
throw error;
|
|
1466
|
+
let t2;
|
|
1467
|
+
$[6] !== pushToast || $[7] !== t ? (t2 = () => {
|
|
1468
|
+
pushToast({
|
|
1469
|
+
closable: !0,
|
|
1470
|
+
status: "warning",
|
|
1471
|
+
title: t("share-preview-menu.error_toggle-sharing", {
|
|
1472
|
+
context: "toggle-sharing"
|
|
1473
|
+
})
|
|
1474
|
+
});
|
|
1475
|
+
}, $[6] = pushToast, $[7] = t, $[8] = t2) : t2 = $[8];
|
|
1476
|
+
const handleUnableToToggle = t2;
|
|
1477
|
+
let t3;
|
|
1478
|
+
$[9] !== client || $[10] !== currentUser?.id ? (t3 = async () => {
|
|
1479
|
+
const run = async () => {
|
|
1480
|
+
setDisabling(!0), await disablePreviewAccessSharing(client, "sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id), setSecret(null);
|
|
1481
|
+
};
|
|
1482
|
+
try {
|
|
1483
|
+
await run();
|
|
1484
|
+
} catch (t42) {
|
|
1485
|
+
setError(t42);
|
|
1486
|
+
}
|
|
1487
|
+
setDisabling(!1);
|
|
1488
|
+
}, $[9] = client, $[10] = currentUser?.id, $[11] = t3) : t3 = $[11];
|
|
1489
|
+
const handleDisableSharing = t3;
|
|
1490
|
+
let t4;
|
|
1491
|
+
$[12] !== client || $[13] !== currentUser?.id ? (t4 = async () => {
|
|
1492
|
+
const run_0 = async () => {
|
|
1493
|
+
setEnabling(!0);
|
|
1494
|
+
const previewUrlSecret = await enablePreviewAccessSharing(client, "sanity/presentation", typeof window > "u" ? "" : location.href, currentUser?.id);
|
|
1495
|
+
setSecret(previewUrlSecret.secret);
|
|
1496
|
+
};
|
|
1497
|
+
try {
|
|
1498
|
+
await run_0();
|
|
1499
|
+
} catch (t52) {
|
|
1500
|
+
setError(t52);
|
|
1501
|
+
}
|
|
1502
|
+
setEnabling(!1);
|
|
1503
|
+
}, $[12] = client, $[13] = currentUser?.id, $[14] = t4) : t4 = $[14];
|
|
1504
|
+
const handleEnableSharing = t4;
|
|
1505
|
+
let t5;
|
|
1506
|
+
$[15] !== pushToast || $[16] !== t || $[17] !== url ? (t5 = async () => {
|
|
1507
|
+
const run_1 = async () => {
|
|
1508
|
+
if (!url)
|
|
1509
|
+
throw new Error("No URL to copy");
|
|
1510
|
+
await navigator.clipboard.writeText(url.toString()), pushToast({
|
|
1511
|
+
closable: !0,
|
|
1512
|
+
status: "success",
|
|
1513
|
+
title: t("share-url.clipboard.status", {
|
|
1514
|
+
context: "success"
|
|
1515
|
+
})
|
|
1516
|
+
});
|
|
1517
|
+
};
|
|
1518
|
+
try {
|
|
1519
|
+
await run_1();
|
|
1520
|
+
} catch (t62) {
|
|
1521
|
+
setError(t62);
|
|
1522
|
+
}
|
|
1523
|
+
}, $[15] = pushToast, $[16] = t, $[17] = url, $[18] = t5) : t5 = $[18];
|
|
1524
|
+
const handleCopyUrl = t5;
|
|
1525
|
+
let t6, t7;
|
|
1526
|
+
$[19] !== client ? (t6 = () => {
|
|
1527
|
+
let controller = new AbortController(), usedTags = [];
|
|
1528
|
+
const fetchShareSecret = async function(lastLiveEventId, signal) {
|
|
1529
|
+
const {
|
|
1530
|
+
result,
|
|
1531
|
+
syncTags
|
|
1532
|
+
} = await client.fetch(fetchSharedAccessQuery, {}, {
|
|
1533
|
+
filterResponse: !1,
|
|
1534
|
+
lastLiveEventId,
|
|
1535
|
+
tag: "presentation.fetch-shared-access-secret"
|
|
1536
|
+
});
|
|
1537
|
+
Array.isArray(syncTags) && (usedTags = syncTags), signal.aborted || setSecret(result);
|
|
1538
|
+
}, subscription = client.live.events().subscribe({
|
|
1539
|
+
next: (event) => {
|
|
1540
|
+
event.type === "message" && (controller.abort(), controller = new AbortController(), event.tags.some((tag) => usedTags.includes(tag)) && fetchShareSecret(event.id, controller.signal));
|
|
1541
|
+
},
|
|
1542
|
+
error: setError
|
|
1543
|
+
});
|
|
1544
|
+
return fetchShareSecret(null, controller.signal).finally(() => setLoading(!1)), () => {
|
|
1545
|
+
subscription.unsubscribe(), controller.abort();
|
|
1546
|
+
};
|
|
1547
|
+
}, t7 = [client], $[19] = client, $[20] = t6, $[21] = t7) : (t6 = $[20], t7 = $[21]), useEffect(t6, t7);
|
|
1548
|
+
let t8;
|
|
1549
|
+
$[22] !== t ? (t8 = t("preview-frame.share-button.aria-label"), $[22] = t, $[23] = t8) : t8 = $[23];
|
|
1550
|
+
let t9;
|
|
1551
|
+
$[24] !== t8 ? (t9 = /* @__PURE__ */ jsx(Button, { "aria-label": t8, icon: ShareIcon, mode: "bleed", tooltipProps: null }), $[24] = t8, $[25] = t9) : t9 = $[25];
|
|
1552
|
+
let t10;
|
|
1553
|
+
$[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = {
|
|
1554
|
+
maxWidth: 248
|
|
1555
|
+
}, $[26] = t10) : t10 = $[26];
|
|
1556
|
+
const t11 = canUseSharedPreviewAccess ? void 0 : 0;
|
|
1557
|
+
let t12;
|
|
1558
|
+
$[27] !== busy || $[28] !== canToggleSharePreviewAccess || $[29] !== canUseSharedPreviewAccess || $[30] !== disabling || $[31] !== enabling || $[32] !== handleCopyUrl || $[33] !== handleDisableSharing || $[34] !== handleEnableSharing || $[35] !== handleUnableToToggle || $[36] !== loading || $[37] !== t || $[38] !== url ? (t12 = canUseSharedPreviewAccess ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1559
|
+
/* @__PURE__ */ jsx("label", { style: {
|
|
1560
|
+
cursor: "pointer"
|
|
1561
|
+
}, children: /* @__PURE__ */ jsxs(Grid, { columns: 2, rows: 2, gapX: 3, gapY: 1, style: {
|
|
1562
|
+
justifyContent: "center",
|
|
1563
|
+
alignItems: "center",
|
|
1564
|
+
gridTemplateColumns: "min-content 1fr",
|
|
1565
|
+
gridTemplateRows: "min-content"
|
|
1566
|
+
}, paddingTop: 3, paddingX: 3, children: [
|
|
1567
|
+
/* @__PURE__ */ jsx(Tooltip, { animate: !0, content: /* @__PURE__ */ jsx(Text, { size: 1, children: t("share-preview-menu.toggle-button.tooltip", {
|
|
1568
|
+
context: url ? "disable" : "enable"
|
|
1569
|
+
}) }), fallbackPlacements: ["bottom-start"], placement: "bottom", portal: !0, children: /* @__PURE__ */ jsx(Switch, { checked: enabling || url !== null && !disabling, readOnly: enabling || disabling, indeterminate: loading, onChange: canToggleSharePreviewAccess ? url ? handleDisableSharing : handleEnableSharing : handleUnableToToggle }) }),
|
|
1570
|
+
/* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t("share-preview-menu.toggle-button.label", {
|
|
1571
|
+
context: "first-line"
|
|
1572
|
+
}) }),
|
|
1573
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1574
|
+
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t("share-preview-menu.toggle-button.label", {
|
|
1575
|
+
context: "second-line"
|
|
1576
|
+
}) })
|
|
1577
|
+
] }) }),
|
|
1578
|
+
/* @__PURE__ */ jsx(Box, { padding: 3, paddingTop: 2, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
1579
|
+
/* @__PURE__ */ jsx(Card, { tone: busy || !url ? "transparent" : void 0, style: {
|
|
1580
|
+
position: "relative",
|
|
1581
|
+
aspectRatio: "1 / 1",
|
|
1582
|
+
display: "flex",
|
|
1583
|
+
alignItems: "center",
|
|
1584
|
+
justifyContent: "center"
|
|
1585
|
+
}, children: /* @__PURE__ */ jsx(AnimatePresence, { children: busy ? /* @__PURE__ */ jsx(MotionSpinner, { muted: !0, initial: {
|
|
1586
|
+
opacity: 0
|
|
1587
|
+
}, animate: {
|
|
1588
|
+
opacity: 1
|
|
1589
|
+
}, exit: {
|
|
1590
|
+
opacity: 0
|
|
1591
|
+
} }) : url ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Suspense, { fallback: /* @__PURE__ */ jsx(Spinner, {}), children: [
|
|
1592
|
+
/* @__PURE__ */ jsx(QRCodeSVG, { title: t("share-preview-menu.qr-code.title", {
|
|
1593
|
+
url: url.toString()
|
|
1594
|
+
}), value: url.toString(), size: QrSize, color: "var(--card-fg-color)", logoSize: QrCodeLogoSize + QrCodeLogoPadding }),
|
|
1595
|
+
/* @__PURE__ */ jsx(MotionMonogram, { initial: {
|
|
1596
|
+
opacity: -0.5
|
|
1597
|
+
}, animate: {
|
|
1598
|
+
opacity: 1.5
|
|
1599
|
+
}, exit: {
|
|
1600
|
+
opacity: 0
|
|
1601
|
+
} })
|
|
1602
|
+
] }) }) : /* @__PURE__ */ jsx(MotionText, { muted: !0, size: 1, style: {
|
|
1603
|
+
maxWidth: "100px",
|
|
1604
|
+
textWrap: "pretty",
|
|
1605
|
+
textAlign: "center"
|
|
1606
|
+
}, initial: {
|
|
1607
|
+
opacity: 0
|
|
1608
|
+
}, animate: {
|
|
1609
|
+
opacity: 1
|
|
1610
|
+
}, exit: {
|
|
1611
|
+
opacity: 0
|
|
1612
|
+
}, children: t("share-preview-menu.qr-code.placeholder") }) }) }),
|
|
1613
|
+
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t("share-preview-menu.qr-code.instructions") })
|
|
1614
|
+
] }) }),
|
|
1615
|
+
/* @__PURE__ */ jsx(MenuDivider, {}),
|
|
1616
|
+
/* @__PURE__ */ jsx(MenuItem, { disabled: !url || disabling, icon: CopyIcon, onClick: handleCopyUrl, text: t("share-preview-menu.copy-url.text") })
|
|
1617
|
+
] }) : /* @__PURE__ */ jsx(Card, { padding: 2, tone: "caution", radius: 3, children: /* @__PURE__ */ jsx(Text, { style: {
|
|
1618
|
+
textWrap: "pretty"
|
|
1619
|
+
}, children: t("share-preview-menu.error", {
|
|
1620
|
+
context: "missing-grants"
|
|
1621
|
+
}) }) }), $[27] = busy, $[28] = canToggleSharePreviewAccess, $[29] = canUseSharedPreviewAccess, $[30] = disabling, $[31] = enabling, $[32] = handleCopyUrl, $[33] = handleDisableSharing, $[34] = handleEnableSharing, $[35] = handleUnableToToggle, $[36] = loading, $[37] = t, $[38] = url, $[39] = t12) : t12 = $[39];
|
|
1622
|
+
let t13;
|
|
1623
|
+
$[40] !== t11 || $[41] !== t12 ? (t13 = /* @__PURE__ */ jsx(Menu, { style: t10, padding: t11, children: t12 }), $[40] = t11, $[41] = t12, $[42] = t13) : t13 = $[42];
|
|
1624
|
+
let t14;
|
|
1625
|
+
$[43] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t14 = {
|
|
1626
|
+
constrainSize: !0,
|
|
1627
|
+
placement: "bottom",
|
|
1628
|
+
portal: !0
|
|
1629
|
+
}, $[43] = t14) : t14 = $[43];
|
|
1630
|
+
let t15;
|
|
1631
|
+
return $[44] !== t13 || $[45] !== t9 ? (t15 = /* @__PURE__ */ jsx(MenuButton, { button: t9, id: "share-menu", menu: t13, popover: t14 }), $[44] = t13, $[45] = t9, $[46] = t15) : t15 = $[46], t15;
|
|
1632
|
+
}
|
|
1633
|
+
const PreviewHeaderDefault = (props) => {
|
|
1634
|
+
const $ = c(110), {
|
|
1635
|
+
canSharePreviewAccess,
|
|
1636
|
+
canToggleSharePreviewAccess,
|
|
1637
|
+
canUseSharedPreviewAccess,
|
|
1638
|
+
iframeRef,
|
|
1639
|
+
initialUrl,
|
|
1640
|
+
navigatorEnabled,
|
|
1641
|
+
onPathChange,
|
|
1642
|
+
onRefresh,
|
|
1643
|
+
openPopup,
|
|
1644
|
+
overlaysConnection,
|
|
1645
|
+
presentationRef,
|
|
1646
|
+
perspective,
|
|
1647
|
+
previewUrl,
|
|
1648
|
+
setViewport,
|
|
1649
|
+
targetOrigin,
|
|
1650
|
+
toggleNavigator,
|
|
1651
|
+
toggleOverlay,
|
|
1652
|
+
viewport,
|
|
1653
|
+
previewUrlRef
|
|
1654
|
+
} = props, {
|
|
1655
|
+
t
|
|
1656
|
+
} = useTranslation(presentationLocaleNamespace);
|
|
1657
|
+
let t0;
|
|
1658
|
+
$[0] !== setViewport || $[1] !== viewport ? (t0 = () => setViewport(viewport === "desktop" ? "mobile" : "desktop"), $[0] = setViewport, $[1] = viewport, $[2] = t0) : t0 = $[2];
|
|
1659
|
+
const toggleViewportSize = t0, previewLocationOrigin = targetOrigin === location.origin ? "" : targetOrigin;
|
|
1660
|
+
let t1;
|
|
1661
|
+
$[3] !== iframeRef || $[4] !== onRefresh || $[5] !== presentationRef || $[6] !== previewUrl || $[7] !== targetOrigin ? (t1 = () => {
|
|
1662
|
+
onRefresh(() => {
|
|
1663
|
+
iframeRef.current && (presentationRef.send({
|
|
1664
|
+
type: "iframe reload"
|
|
1665
|
+
}), Object.assign(iframeRef.current, {
|
|
1666
|
+
src: new URL(previewUrl || "/", targetOrigin).toString()
|
|
1667
|
+
}));
|
|
1668
|
+
});
|
|
1669
|
+
}, $[3] = iframeRef, $[4] = onRefresh, $[5] = presentationRef, $[6] = previewUrl, $[7] = targetOrigin, $[8] = t1) : t1 = $[8];
|
|
1670
|
+
const handleRefresh = t1, isLoading = useSelector(presentationRef, _temp$a), isLoaded = useSelector(presentationRef, _temp2$6), isRefreshing = useSelector(presentationRef, _temp3$2), isReloading = useSelector(presentationRef, _temp4$1), overlaysEnabled = useSelector(presentationRef, _temp5$1);
|
|
1671
|
+
let t2;
|
|
1672
|
+
if ($[9] !== previewUrl || $[10] !== targetOrigin) {
|
|
1673
|
+
const previewURL = new URL(previewUrl || "/", targetOrigin);
|
|
1674
|
+
t2 = withoutSecretSearchParams(previewURL), $[9] = previewUrl, $[10] = targetOrigin, $[11] = t2;
|
|
1675
|
+
} else
|
|
1676
|
+
t2 = $[11];
|
|
1677
|
+
const {
|
|
1678
|
+
pathname,
|
|
1679
|
+
search
|
|
1680
|
+
} = t2, previewLocationRoute = `${pathname}${search}`, perspectiveToggleTooltipId = useId(), previewUrlBusy = useSelector(previewUrlRef, _temp6);
|
|
1681
|
+
let t3;
|
|
1682
|
+
$[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = {
|
|
1683
|
+
width: "100%"
|
|
1684
|
+
}, $[12] = t3) : t3 = $[12];
|
|
1685
|
+
let t4;
|
|
1686
|
+
$[13] !== navigatorEnabled || $[14] !== t || $[15] !== toggleNavigator ? (t4 = toggleNavigator && /* @__PURE__ */ jsx(Button, { "aria-label": t("preview-frame.navigator.toggle-button.aria-label"), icon: PanelLeftIcon, mode: "bleed", onClick: toggleNavigator, selected: navigatorEnabled, tooltipProps: {
|
|
1687
|
+
content: /* @__PURE__ */ jsx(Text, { size: 1, children: t("preview-frame.navigator.toggle-button.tooltip") }),
|
|
1688
|
+
fallbackPlacements: ["bottom-start"],
|
|
1689
|
+
placement: "bottom"
|
|
1690
|
+
} }), $[13] = navigatorEnabled, $[14] = t, $[15] = toggleNavigator, $[16] = t4) : t4 = $[16];
|
|
1691
|
+
let t5;
|
|
1692
|
+
$[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = {
|
|
1693
|
+
whiteSpace: "nowrap"
|
|
1694
|
+
}, $[17] = t5) : t5 = $[17];
|
|
1695
|
+
const t6 = overlaysEnabled ? "disable" : "enable";
|
|
1696
|
+
let t7;
|
|
1697
|
+
$[18] !== t || $[19] !== t6 ? (t7 = t("preview-frame.overlay.toggle-button.tooltip", {
|
|
1698
|
+
context: t6
|
|
1699
|
+
}), $[18] = t, $[19] = t6, $[20] = t7) : t7 = $[20];
|
|
1700
|
+
let t8;
|
|
1701
|
+
$[21] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, children: t7 }) }), $[21] = t7, $[22] = t8) : t8 = $[22];
|
|
1702
|
+
let t9;
|
|
1703
|
+
$[23] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx(Box, { paddingY: 1, children: /* @__PURE__ */ jsx(Hotkeys, { keys: ["Alt"], style: {
|
|
1704
|
+
marginTop: -4,
|
|
1705
|
+
marginBottom: -4
|
|
1706
|
+
} }) }), $[23] = t9) : t9 = $[23];
|
|
1707
|
+
let t10;
|
|
1708
|
+
$[24] !== t8 ? (t10 = /* @__PURE__ */ jsxs(Flex, { align: "center", style: t5, children: [
|
|
1709
|
+
t8,
|
|
1710
|
+
t9
|
|
1711
|
+
] }), $[24] = t8, $[25] = t10) : t10 = $[25];
|
|
1712
|
+
let t11;
|
|
1713
|
+
$[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = ["bottom-start"], $[26] = t11) : t11 = $[26];
|
|
1714
|
+
let t12;
|
|
1715
|
+
$[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = {
|
|
1716
|
+
lineHeight: 0,
|
|
1717
|
+
borderRadius: 999,
|
|
1718
|
+
userSelect: "none"
|
|
1719
|
+
}, $[27] = t12) : t12 = $[27];
|
|
1720
|
+
const t13 = overlaysEnabled ? "transparent" : void 0;
|
|
1721
|
+
let t14;
|
|
1722
|
+
$[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t14 = {
|
|
1723
|
+
margin: -4
|
|
1724
|
+
}, $[28] = t14) : t14 = $[28];
|
|
1725
|
+
const t15 = !isLoaded, t16 = isLoading || overlaysConnection !== "connected";
|
|
1726
|
+
let t17;
|
|
1727
|
+
$[29] !== overlaysEnabled || $[30] !== t15 || $[31] !== t16 || $[32] !== toggleOverlay ? (t17 = /* @__PURE__ */ jsx("div", { style: t14, children: /* @__PURE__ */ jsx(Switch, { indeterminate: t15, checked: overlaysEnabled, onChange: toggleOverlay, disabled: t16 }) }), $[29] = overlaysEnabled, $[30] = t15, $[31] = t16, $[32] = toggleOverlay, $[33] = t17) : t17 = $[33];
|
|
1728
|
+
const t18 = !overlaysEnabled;
|
|
1729
|
+
let t19;
|
|
1730
|
+
$[34] !== t ? (t19 = t("preview-frame.overlay.toggle-button.text"), $[34] = t, $[35] = t19) : t19 = $[35];
|
|
1731
|
+
let t20;
|
|
1732
|
+
$[36] !== t18 || $[37] !== t19 ? (t20 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { muted: t18, size: 1, weight: "medium", children: t19 }) }), $[36] = t18, $[37] = t19, $[38] = t20) : t20 = $[38];
|
|
1733
|
+
let t21;
|
|
1734
|
+
$[39] !== t17 || $[40] !== t20 ? (t21 = /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, children: [
|
|
1735
|
+
t17,
|
|
1736
|
+
t20
|
|
1737
|
+
] }), $[39] = t17, $[40] = t20, $[41] = t21) : t21 = $[41];
|
|
1738
|
+
let t22;
|
|
1739
|
+
$[42] !== t13 || $[43] !== t21 ? (t22 = /* @__PURE__ */ jsx(Card, { as: "label", flex: "none", padding: 3, marginX: 1, style: t12, tone: t13, children: t21 }), $[42] = t13, $[43] = t21, $[44] = t22) : t22 = $[44];
|
|
1740
|
+
let t23;
|
|
1741
|
+
$[45] !== t10 || $[46] !== t22 ? (t23 = /* @__PURE__ */ jsx(Tooltip, { animate: !0, content: t10, fallbackPlacements: t11, placement: "bottom", portal: !0, children: t22 }), $[45] = t10, $[46] = t22, $[47] = t23) : t23 = $[47];
|
|
1742
|
+
let t24;
|
|
1743
|
+
$[48] !== isLoaded || $[49] !== isLoading || $[50] !== isRefreshing || $[51] !== isReloading || $[52] !== t ? (t24 = isLoaded ? t("preview-frame.refresh-button.tooltip") : t("preview-frame.status", {
|
|
1744
|
+
context: isLoading ? "loading" : isRefreshing ? "refreshing" : isReloading ? "reloading" : "unknown"
|
|
1745
|
+
}), $[48] = isLoaded, $[49] = isLoading, $[50] = isRefreshing, $[51] = isReloading, $[52] = t, $[53] = t24) : t24 = $[53];
|
|
1746
|
+
let t25;
|
|
1747
|
+
$[54] !== t24 ? (t25 = /* @__PURE__ */ jsx(Text, { size: 1, children: t24 }), $[54] = t24, $[55] = t25) : t25 = $[55];
|
|
1748
|
+
let t26;
|
|
1749
|
+
$[56] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t26 = ["bottom-end"], $[56] = t26) : t26 = $[56];
|
|
1750
|
+
let t27;
|
|
1751
|
+
$[57] !== t ? (t27 = t("preview-frame.refresh-button.aria-label"), $[57] = t, $[58] = t27) : t27 = $[58];
|
|
1752
|
+
const t28 = isReloading || isRefreshing || previewUrlBusy;
|
|
1753
|
+
let t29;
|
|
1754
|
+
$[59] !== handleRefresh || $[60] !== t27 || $[61] !== t28 ? (t29 = /* @__PURE__ */ jsx(Button, { "aria-label": t27, icon: RefreshIcon, mode: "bleed", loading: t28, onClick: handleRefresh, tooltipProps: null }), $[59] = handleRefresh, $[60] = t27, $[61] = t28, $[62] = t29) : t29 = $[62];
|
|
1755
|
+
let t30;
|
|
1756
|
+
$[63] !== t25 || $[64] !== t29 ? (t30 = /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Tooltip, { animate: !0, content: t25, fallbackPlacements: t26, placement: "bottom", portal: !0, children: t29 }) }), $[63] = t25, $[64] = t29, $[65] = t30) : t30 = $[65];
|
|
1757
|
+
let t31;
|
|
1758
|
+
$[66] !== openPopup || $[67] !== perspective || $[68] !== previewLocationOrigin || $[69] !== previewLocationRoute || $[70] !== targetOrigin ? (t31 = /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(OpenPreviewButton, { openPopup, previewLocationOrigin, previewLocationRoute, perspective, targetOrigin }) }), $[66] = openPopup, $[67] = perspective, $[68] = previewLocationOrigin, $[69] = previewLocationRoute, $[70] = targetOrigin, $[71] = t31) : t31 = $[71];
|
|
1759
|
+
let t32;
|
|
1760
|
+
$[72] !== onPathChange || $[73] !== previewLocationRoute || $[74] !== previewUrlRef || $[75] !== t30 || $[76] !== t31 ? (t32 = /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(PreviewLocationInput, { previewUrlRef, prefix: t30, onChange: onPathChange, suffix: t31, value: previewLocationRoute }) }), $[72] = onPathChange, $[73] = previewLocationRoute, $[74] = previewUrlRef, $[75] = t30, $[76] = t31, $[77] = t32) : t32 = $[77];
|
|
1761
|
+
let t33;
|
|
1762
|
+
$[78] !== perspectiveToggleTooltipId ? (t33 = (node) => {
|
|
1763
|
+
node?.style.setProperty("view-transition-name", perspectiveToggleTooltipId);
|
|
1764
|
+
}, $[78] = perspectiveToggleTooltipId, $[79] = t33) : t33 = $[79];
|
|
1765
|
+
const t34 = viewport === "desktop" ? "narrow" : "full";
|
|
1766
|
+
let t35;
|
|
1767
|
+
$[80] !== t || $[81] !== t34 ? (t35 = t("preview-frame.viewport-button.tooltip", {
|
|
1768
|
+
context: t34
|
|
1769
|
+
}), $[80] = t, $[81] = t34, $[82] = t35) : t35 = $[82];
|
|
1770
|
+
let t36;
|
|
1771
|
+
$[83] !== t35 ? (t36 = /* @__PURE__ */ jsx(Text, { size: 1, children: t35 }), $[83] = t35, $[84] = t36) : t36 = $[84];
|
|
1772
|
+
let t37;
|
|
1773
|
+
$[85] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t37 = ["bottom-start"], $[85] = t37) : t37 = $[85];
|
|
1774
|
+
let t38;
|
|
1775
|
+
$[86] !== t ? (t38 = t("preview-frame.viewport-button.aria-label"), $[86] = t, $[87] = t38) : t38 = $[87];
|
|
1776
|
+
const t39 = viewport === "desktop" ? MobileDeviceIcon : DesktopIcon;
|
|
1777
|
+
let t40;
|
|
1778
|
+
$[88] !== t38 || $[89] !== t39 || $[90] !== toggleViewportSize || $[91] !== viewport ? (t40 = /* @__PURE__ */ jsx(Button, { "data-testid": "preview-viewport-toggle", "data-viewport": viewport, "aria-label": t38, icon: t39, mode: "bleed", onClick: toggleViewportSize, tooltipProps: null }), $[88] = t38, $[89] = t39, $[90] = toggleViewportSize, $[91] = viewport, $[92] = t40) : t40 = $[92];
|
|
1779
|
+
let t41;
|
|
1780
|
+
$[93] !== t33 || $[94] !== t36 || $[95] !== t40 ? (t41 = /* @__PURE__ */ jsx(Flex, { align: "center", flex: "none", gap: 1, children: /* @__PURE__ */ jsx(Tooltip, { animate: !0, ref: t33, content: t36, fallbackPlacements: t37, placement: "bottom", portal: !0, children: t40 }) }), $[93] = t33, $[94] = t36, $[95] = t40, $[96] = t41) : t41 = $[96];
|
|
1781
|
+
let t42;
|
|
1782
|
+
$[97] !== canSharePreviewAccess || $[98] !== canToggleSharePreviewAccess || $[99] !== canUseSharedPreviewAccess || $[100] !== initialUrl || $[101] !== perspective || $[102] !== previewLocationRoute ? (t42 = canSharePreviewAccess && /* @__PURE__ */ jsx(Flex, { align: "center", flex: "none", gap: 1, children: /* @__PURE__ */ jsx(SharePreviewMenu, { canToggleSharePreviewAccess, canUseSharedPreviewAccess, previewLocationRoute, initialUrl, perspective }) }), $[97] = canSharePreviewAccess, $[98] = canToggleSharePreviewAccess, $[99] = canUseSharedPreviewAccess, $[100] = initialUrl, $[101] = perspective, $[102] = previewLocationRoute, $[103] = t42) : t42 = $[103];
|
|
1783
|
+
let t43;
|
|
1784
|
+
return $[104] !== t23 || $[105] !== t32 || $[106] !== t4 || $[107] !== t41 || $[108] !== t42 ? (t43 = /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 1, paddingX: 1, style: t3, children: [
|
|
1785
|
+
t4,
|
|
1786
|
+
t23,
|
|
1787
|
+
t32,
|
|
1788
|
+
t41,
|
|
1789
|
+
t42
|
|
1790
|
+
] }), $[104] = t23, $[105] = t32, $[106] = t4, $[107] = t41, $[108] = t42, $[109] = t43) : t43 = $[109], t43;
|
|
1791
|
+
};
|
|
1792
|
+
function PreviewHeader(props) {
|
|
1793
|
+
const $ = c(7), renderDefault = _temp7, HeaderComponent = props.options?.component;
|
|
1794
|
+
let t0;
|
|
1795
|
+
$[0] !== HeaderComponent || $[1] !== props ? (t0 = HeaderComponent ? /* @__PURE__ */ jsx(HeaderComponent, { ...props, renderDefault }) : renderDefault(props), $[0] = HeaderComponent, $[1] = props, $[2] = t0) : t0 = $[2];
|
|
1796
|
+
const header = t0;
|
|
1797
|
+
let t1;
|
|
1798
|
+
$[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
1799
|
+
position: "relative"
|
|
1800
|
+
}, $[3] = t1) : t1 = $[3];
|
|
1801
|
+
let t2;
|
|
1802
|
+
$[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
1803
|
+
minHeight: 0
|
|
1804
|
+
}, $[4] = t2) : t2 = $[4];
|
|
1805
|
+
let t3;
|
|
1806
|
+
return $[5] !== header ? (t3 = /* @__PURE__ */ jsx(Card, { flex: "none", padding: 2, borderBottom: !0, style: t1, children: /* @__PURE__ */ jsx(Flex, { align: "center", style: t2, children: header }) }), $[5] = header, $[6] = t3) : t3 = $[6], t3;
|
|
1807
|
+
}
|
|
1808
|
+
function _temp7(props_0) {
|
|
1809
|
+
return /* @__PURE__ */ jsx(PreviewHeaderDefault, { ...props_0 });
|
|
1810
|
+
}
|
|
1811
|
+
function _temp$a(state) {
|
|
1812
|
+
return state.matches("loading");
|
|
1813
|
+
}
|
|
1814
|
+
function _temp2$6(state_0) {
|
|
1815
|
+
return state_0.matches("loaded");
|
|
1816
|
+
}
|
|
1817
|
+
function _temp3$2(state_1) {
|
|
1818
|
+
return state_1.matches({
|
|
1819
|
+
loaded: "refreshing"
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
function _temp4$1(state_2) {
|
|
1823
|
+
return state_2.matches({
|
|
1824
|
+
loaded: "reloading"
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
function _temp5$1(state_3) {
|
|
1828
|
+
return state_3.context.visualEditingOverlaysEnabled;
|
|
1829
|
+
}
|
|
1830
|
+
function _temp6(state_4) {
|
|
1831
|
+
return state_4.hasTag("busy");
|
|
1832
|
+
}
|
|
1833
|
+
const MotionFlex = motion.create(Flex), Preview = memo(forwardRef(function(props, forwardedRef) {
|
|
1834
|
+
const {
|
|
1835
|
+
header,
|
|
1836
|
+
initialUrl,
|
|
1837
|
+
loadersConnection,
|
|
1838
|
+
overlaysConnection,
|
|
1839
|
+
perspective,
|
|
1840
|
+
viewport,
|
|
1841
|
+
vercelProtectionBypass,
|
|
1842
|
+
presentationRef,
|
|
1843
|
+
previewUrlRef
|
|
1844
|
+
} = props, [stablePerspective, setStablePerspective] = useState(null), urlPerspective = encodeStudioPerspective(stablePerspective === null ? perspective : stablePerspective), previewUrl = useMemo(() => {
|
|
1845
|
+
const url = new URL(initialUrl);
|
|
1846
|
+
return url.searchParams.get(urlSearchParamPreviewPerspective) || url.searchParams.set(urlSearchParamPreviewPerspective, urlPerspective), (vercelProtectionBypass || url.searchParams.get(urlSearchParamVercelProtectionBypass)) && url.searchParams.set(urlSearchParamVercelSetBypassCookie, "samesitenone"), vercelProtectionBypass && !url.searchParams.get(urlSearchParamVercelProtectionBypass) && url.searchParams.set(urlSearchParamVercelProtectionBypass, vercelProtectionBypass), url;
|
|
1847
|
+
}, [initialUrl, urlPerspective, vercelProtectionBypass]);
|
|
1848
|
+
useEffect(() => {
|
|
1849
|
+
loadersConnection === "connected" && setStablePerspective((prev) => prev === null ? perspective : prev);
|
|
1850
|
+
}, [loadersConnection, perspective]);
|
|
1851
|
+
const {
|
|
1852
|
+
t
|
|
1853
|
+
} = useTranslation(presentationLocaleNamespace), {
|
|
1854
|
+
devMode
|
|
1855
|
+
} = usePresentationTool(), prefersReducedMotion = usePrefersReducedMotion(), ref = useRef(null), previewHeader = /* @__PURE__ */ jsx(PreviewHeader, { ...props, iframeRef: ref, options: header });
|
|
1856
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
1857
|
+
const isLoading = useSelector(presentationRef, (state) => state.matches("loading") || state.matches({
|
|
1858
|
+
loaded: "reloading"
|
|
1859
|
+
})), [timedOut, setTimedOut] = useState(!1), isRefreshing = useSelector(presentationRef, (state_0) => state_0.matches({
|
|
1860
|
+
loaded: "refreshing"
|
|
1861
|
+
})), [somethingIsWrong, setSomethingIsWrong] = useState(!1), iframeIsBusy = isLoading || isRefreshing || overlaysConnection === "connecting", handleRetry = useCallback(() => {
|
|
1862
|
+
ref.current && (ref.current.src = previewUrl.toString(), presentationRef.send({
|
|
1863
|
+
type: "iframe reload"
|
|
1864
|
+
}));
|
|
1865
|
+
}, [presentationRef, previewUrl]), [continueAnyway, setContinueAnyway] = useState(!1), handleContinueAnyway = useCallback(() => {
|
|
1866
|
+
setContinueAnyway(!0);
|
|
1867
|
+
}, []), [showOverlaysConnectionStatus, setShowOverlaysConnectionState] = useState(!1);
|
|
1868
|
+
useEffect(() => {
|
|
1869
|
+
if (!(isLoading || isRefreshing) && (overlaysConnection === "connecting" || overlaysConnection === "reconnecting")) {
|
|
1870
|
+
const timeout = setTimeout(() => {
|
|
1871
|
+
setShowOverlaysConnectionState(!0);
|
|
1872
|
+
}, 5e3);
|
|
1873
|
+
return () => clearTimeout(timeout);
|
|
1874
|
+
}
|
|
1875
|
+
}, [overlaysConnection, isLoading, isRefreshing]), useEffect(() => {
|
|
1876
|
+
if (!(isLoading || isRefreshing || !showOverlaysConnectionStatus)) {
|
|
1877
|
+
if (overlaysConnection === "connected" && (setSomethingIsWrong(!1), setShowOverlaysConnectionState(!1), setTimedOut(!1), setContinueAnyway(!1)), overlaysConnection === "connecting") {
|
|
1878
|
+
const timeout_0 = setTimeout(() => {
|
|
1879
|
+
setTimedOut(!0), console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly");
|
|
1880
|
+
}, MAX_TIME_TO_OVERLAYS_CONNECTION);
|
|
1881
|
+
return () => clearTimeout(timeout_0);
|
|
1882
|
+
}
|
|
1883
|
+
if (overlaysConnection === "reconnecting") {
|
|
1884
|
+
const timeout_1 = setTimeout(() => {
|
|
1885
|
+
setTimedOut(!0), setSomethingIsWrong(!0);
|
|
1886
|
+
}, MAX_TIME_TO_OVERLAYS_CONNECTION);
|
|
1887
|
+
return () => clearTimeout(timeout_1);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}, [isLoading, overlaysConnection, isRefreshing, showOverlaysConnectionStatus]);
|
|
1891
|
+
const onIFrameLoad = useCallback(() => {
|
|
1892
|
+
presentationRef.send({
|
|
1893
|
+
type: "iframe loaded"
|
|
1894
|
+
});
|
|
1895
|
+
}, [presentationRef]), preventIframeInteraction = useMemo(() => (isLoading || overlaysConnection === "connecting" && !isRefreshing) && !continueAnyway, [continueAnyway, isLoading, isRefreshing, overlaysConnection]), canUseViewTransition = useSyncExternalStore(
|
|
1896
|
+
// eslint-disable-next-line no-empty-function
|
|
1897
|
+
useCallback(() => () => {
|
|
1898
|
+
}, []),
|
|
1899
|
+
() => CSS.supports("(view-transition-name: test)")
|
|
1900
|
+
), iframeAnimations = useMemo(() => [
|
|
1901
|
+
preventIframeInteraction ? "background" : "active",
|
|
1902
|
+
isLoading ? "reloading" : "idle",
|
|
1903
|
+
// If CSS View Transitions are supported, then transition iframe viewport dimensions with that instead of Motion
|
|
1904
|
+
canUseViewTransition ? "" : viewport,
|
|
1905
|
+
showOverlaysConnectionStatus && !continueAnyway ? "timedOut" : ""
|
|
1906
|
+
], [canUseViewTransition, continueAnyway, isLoading, preventIframeInteraction, showOverlaysConnectionStatus, viewport]), [currentViewport, setCurrentViewport] = useState(viewport), [iframeStyle, setIframeStyle] = useState(iframeVariants[viewport]);
|
|
1907
|
+
useEffect(() => {
|
|
1908
|
+
if (canUseViewTransition && viewport !== currentViewport) {
|
|
1909
|
+
const update = () => {
|
|
1910
|
+
setCurrentViewport(viewport), setIframeStyle(iframeVariants[viewport]);
|
|
1911
|
+
};
|
|
1912
|
+
!prefersReducedMotion && "startViewTransition" in document && typeof document.startViewTransition == "function" ? document.startViewTransition({
|
|
1913
|
+
update: () => flushSync(() => update()),
|
|
1914
|
+
types: ["sanity-iframe-viewport"]
|
|
1915
|
+
}) : update();
|
|
1916
|
+
}
|
|
1917
|
+
}, [canUseViewTransition, prefersReducedMotion, currentViewport, viewport]);
|
|
1918
|
+
const toast = useToast(), allowOrigins = useAllowPatterns(previewUrlRef), [checkOrigin, setCheckOrigin] = useState(!1), [reportedMismatches] = useState(/* @__PURE__ */ new Set()), reportMismatchingOrigin = useEffectEvent((reportedOrigin) => {
|
|
1919
|
+
if (allowOrigins.some((allow) => allow.test(reportedOrigin))) {
|
|
1920
|
+
setCheckOrigin(reportedOrigin);
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
reportedMismatches.has(reportedOrigin) || (reportedMismatches.add(reportedOrigin), console.warn("Visual Editing is here but misconfigured", {
|
|
1924
|
+
reportedOrigin
|
|
1925
|
+
}), toast.push({
|
|
1926
|
+
closable: !0,
|
|
1927
|
+
id: `presentation-iframe-origin-mismatch-${reportedOrigin}`,
|
|
1928
|
+
status: "error",
|
|
1929
|
+
duration: 1 / 0,
|
|
1930
|
+
title: t("preview-frame.configuration.error.title"),
|
|
1931
|
+
description: /* @__PURE__ */ jsx(Translate, { t, i18nKey: "preview-frame.configuration.error.description", components: {
|
|
1932
|
+
Code: "code"
|
|
1933
|
+
}, values: {
|
|
1934
|
+
targetOrigin: previewUrl.origin,
|
|
1935
|
+
reportedOrigin
|
|
1936
|
+
} })
|
|
1937
|
+
}));
|
|
1938
|
+
}), navigate = usePresentationNavigate(), navigateEvent = useEffectEvent((url_0) => {
|
|
1939
|
+
if (!checkOrigin) return;
|
|
1940
|
+
const nextUrl = new URL(url_0, checkOrigin);
|
|
1941
|
+
navigate(`${checkOrigin}${nextUrl.pathname}${nextUrl.search}${nextUrl.hash}`);
|
|
1942
|
+
});
|
|
1943
|
+
return useEffect(() => {
|
|
1944
|
+
if (!checkOrigin)
|
|
1945
|
+
return;
|
|
1946
|
+
const target = ref.current?.contentWindow;
|
|
1947
|
+
if (!target)
|
|
1948
|
+
return;
|
|
1949
|
+
const controller = createController({
|
|
1950
|
+
targetOrigin: checkOrigin
|
|
1951
|
+
});
|
|
1952
|
+
controller.addTarget(target);
|
|
1953
|
+
const comlink = controller.createChannel({
|
|
1954
|
+
name: "presentation",
|
|
1955
|
+
heartbeat: !0,
|
|
1956
|
+
connectTo: "visual-editing"
|
|
1957
|
+
}, createConnectionMachine().provide({
|
|
1958
|
+
actors: createCompatibilityActors()
|
|
1959
|
+
}));
|
|
1960
|
+
comlink.on("visual-editing/navigate", (data) => {
|
|
1961
|
+
navigateEvent(data.url);
|
|
1962
|
+
});
|
|
1963
|
+
const stop = comlink.start();
|
|
1964
|
+
return () => {
|
|
1965
|
+
stop(), controller.destroy();
|
|
1966
|
+
};
|
|
1967
|
+
}, [checkOrigin]), useEffect(() => {
|
|
1968
|
+
if (overlaysConnection === "connecting" || overlaysConnection === "reconnecting") {
|
|
1969
|
+
const interval = setInterval(() => {
|
|
1970
|
+
ref.current?.contentWindow?.postMessage(
|
|
1971
|
+
{
|
|
1972
|
+
domain: "sanity/channels",
|
|
1973
|
+
from: "presentation",
|
|
1974
|
+
type: "presentation/status"
|
|
1975
|
+
},
|
|
1976
|
+
/**
|
|
1977
|
+
* The targetOrigin is set to '*' intentionally here, as we need to find out if the iframe is misconfigured and has the wrong origin
|
|
1978
|
+
*/
|
|
1979
|
+
"*"
|
|
1980
|
+
);
|
|
1981
|
+
}, 1e3), controller_0 = new AbortController();
|
|
1982
|
+
return window.addEventListener("message", ({
|
|
1983
|
+
data: data_0
|
|
1984
|
+
}) => {
|
|
1985
|
+
data_0 && typeof data_0 == "object" && "domain" in data_0 && data_0.domain === "sanity/channels" && "type" in data_0 && data_0.type === "visual-editing/status" && "data" in data_0 && typeof data_0.data == "object" && data_0.data && "origin" in data_0.data && typeof data_0.data.origin == "string" && reportMismatchingOrigin(data_0.data.origin);
|
|
1986
|
+
}, {
|
|
1987
|
+
signal: controller_0.signal
|
|
1988
|
+
}), () => {
|
|
1989
|
+
controller_0.abort(), clearInterval(interval);
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
}, [overlaysConnection, timedOut]), /* @__PURE__ */ jsx(MotionConfig, { transition: prefersReducedMotion ? {
|
|
1993
|
+
duration: 0
|
|
1994
|
+
} : void 0, children: /* @__PURE__ */ jsxs(TooltipDelayGroupProvider, { children: [
|
|
1995
|
+
previewHeader,
|
|
1996
|
+
/* @__PURE__ */ jsx(Card, { flex: 1, tone: "transparent", children: /* @__PURE__ */ jsxs(Flex, { align: "center", height: "fill", justify: "center", padding: (canUseViewTransition ? currentViewport : viewport) === "desktop" ? 0 : 2, sizing: "border", style: {
|
|
1997
|
+
position: "relative",
|
|
1998
|
+
cursor: iframeIsBusy ? "wait" : void 0
|
|
1999
|
+
}, children: [
|
|
2000
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: !somethingIsWrong && !isLoading && !isRefreshing && // viewport, // using CSS View Transitions instead of framer motion to drive this
|
|
2001
|
+
showOverlaysConnectionStatus && !continueAnyway ? /* @__PURE__ */ jsx(MotionFlex, { initial: "initial", animate: "animate", exit: "exit", variants: spinnerVariants, justify: "center", align: "center", style: {
|
|
2002
|
+
inset: "0",
|
|
2003
|
+
position: "absolute",
|
|
2004
|
+
backdropFilter: timedOut ? "blur(16px) saturate(0.5) grayscale(0.5)" : "blur(2px)",
|
|
2005
|
+
transition: "backdrop-filter 0.2s ease-in-out",
|
|
2006
|
+
// @TODO Because of Safari we have to do this
|
|
2007
|
+
WebkitBackdropFilter: timedOut ? "blur(16px) saturate(0.5) grayscale(0.5)" : "blur(2px)",
|
|
2008
|
+
WebkitTransition: "-webkit-backdrop-filter 0.2s ease-in-out",
|
|
2009
|
+
zIndex: 1
|
|
2010
|
+
}, children: /* @__PURE__ */ jsxs(Flex, { style: {
|
|
2011
|
+
...sizes[viewport]
|
|
2012
|
+
}, justify: "center", align: "center", direction: "column", gap: 4, children: [
|
|
2013
|
+
timedOut && /* @__PURE__ */ jsx(Button, { disabled: !0, mode: "ghost", text: t("preview-frame.continue-button.text"), style: {
|
|
2014
|
+
opacity: 0
|
|
2015
|
+
} }),
|
|
2016
|
+
/* @__PURE__ */ jsx(Card, { radius: 2, tone: timedOut ? "caution" : "inherit", padding: 4, shadow: 1, children: /* @__PURE__ */ jsxs(Flex, { justify: "center", align: "center", direction: "column", gap: 4, children: [
|
|
2017
|
+
/* @__PURE__ */ jsx(Spinner, { muted: !0 }),
|
|
2018
|
+
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: timedOut ? t("preview-frame.status", {
|
|
2019
|
+
context: "timeout"
|
|
2020
|
+
}) : t("preview-frame.status", {
|
|
2021
|
+
context: "connecting"
|
|
2022
|
+
}) })
|
|
2023
|
+
] }) }),
|
|
2024
|
+
timedOut && /* @__PURE__ */ jsx(
|
|
2025
|
+
Button,
|
|
2026
|
+
{
|
|
2027
|
+
tone: "critical",
|
|
2028
|
+
onClick: handleContinueAnyway,
|
|
2029
|
+
text: t("preview-frame.continue-button.text")
|
|
2030
|
+
}
|
|
2031
|
+
)
|
|
2032
|
+
] }) }) : (isLoading || overlaysConnection === "connecting" && !isRefreshing) && !continueAnyway ? /* @__PURE__ */ jsx(MotionFlex, { initial: "initial", animate: "animate", exit: "exit", variants: spinnerVariants, justify: "center", align: "center", style: {
|
|
2033
|
+
inset: "0",
|
|
2034
|
+
position: "absolute"
|
|
2035
|
+
// boxShadow: '0 0 0 1px var(--card-shadow-outline-color)',
|
|
2036
|
+
}, children: /* @__PURE__ */ jsxs(Flex, { style: {
|
|
2037
|
+
...sizes[viewport]
|
|
2038
|
+
}, justify: "center", align: "center", direction: "column", gap: 4, children: [
|
|
2039
|
+
/* @__PURE__ */ jsx(Spinner, { muted: !0 }),
|
|
2040
|
+
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t("preview-frame.status", {
|
|
2041
|
+
context: "loading"
|
|
2042
|
+
}) })
|
|
2043
|
+
] }) }) : somethingIsWrong && !continueAnyway ? /* @__PURE__ */ jsx(MotionFlex, { initial: "initial", animate: "animate", exit: "exit", variants: errorVariants, justify: "center", align: "center", style: {
|
|
2044
|
+
background: "var(--card-bg-color)",
|
|
2045
|
+
inset: "0",
|
|
2046
|
+
position: "absolute"
|
|
2047
|
+
}, children: /* @__PURE__ */ jsx(ErrorCard, { flex: 1, message: t("preview-frame.connection.error.text"), onRetry: handleRetry, onContinueAnyway: handleContinueAnyway, children: devMode && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2048
|
+
overlaysConnection !== "connected" && /* @__PURE__ */ jsx(Card, { padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
2049
|
+
/* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: t("preview-frame.overlay.connection-status.label") }),
|
|
2050
|
+
/* @__PURE__ */ jsx(Code, { size: 1, children: t("channel.status", {
|
|
2051
|
+
context: overlaysConnection
|
|
2052
|
+
}) })
|
|
2053
|
+
] }) }),
|
|
2054
|
+
loadersConnection !== "connected" && /* @__PURE__ */ jsx(Card, { padding: 3, radius: 2, tone: "critical", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
2055
|
+
/* @__PURE__ */ jsx(Label, { muted: !0, size: 0, children: t("preview-frame.loader.connection-status.label") }),
|
|
2056
|
+
/* @__PURE__ */ jsx(Code, { size: 1, children: t("channel.status", {
|
|
2057
|
+
context: loadersConnection
|
|
2058
|
+
}) })
|
|
2059
|
+
] }) })
|
|
2060
|
+
] }) }) }) : null }),
|
|
2061
|
+
/* @__PURE__ */ jsx(IFrame, { animate: iframeAnimations, initial: ["background"], onLoad: onIFrameLoad, preventClick: preventIframeInteraction, ref, src: previewUrl.toString(), style: iframeStyle, variants: iframeVariants })
|
|
2062
|
+
] }) })
|
|
2063
|
+
] }) });
|
|
2064
|
+
}));
|
|
2065
|
+
Preview.displayName = "Memo(ForwardRef(Preview))";
|
|
2066
|
+
const sizes = {
|
|
2067
|
+
desktop: {
|
|
2068
|
+
width: "100%",
|
|
2069
|
+
height: "100%"
|
|
2070
|
+
},
|
|
2071
|
+
mobile: {
|
|
2072
|
+
width: 375,
|
|
2073
|
+
height: 650
|
|
2074
|
+
}
|
|
2075
|
+
}, spinnerVariants = {
|
|
2076
|
+
initial: {
|
|
2077
|
+
opacity: 1
|
|
2078
|
+
},
|
|
2079
|
+
animate: {
|
|
2080
|
+
opacity: [0, 0, 1]
|
|
2081
|
+
},
|
|
2082
|
+
exit: {
|
|
2083
|
+
opacity: [1, 0, 0]
|
|
2084
|
+
}
|
|
2085
|
+
}, errorVariants = {
|
|
2086
|
+
initial: {
|
|
2087
|
+
opacity: 1
|
|
2088
|
+
},
|
|
2089
|
+
animate: {
|
|
2090
|
+
opacity: [0, 0, 1]
|
|
2091
|
+
},
|
|
2092
|
+
exit: {
|
|
2093
|
+
opacity: [1, 0, 0]
|
|
2094
|
+
}
|
|
2095
|
+
}, iframeVariants = {
|
|
2096
|
+
desktop: {
|
|
2097
|
+
...sizes.desktop,
|
|
2098
|
+
boxShadow: "0 0 0 0px var(--card-border-color)"
|
|
2099
|
+
},
|
|
2100
|
+
mobile: {
|
|
2101
|
+
...sizes.mobile,
|
|
2102
|
+
boxShadow: "0 0 0 1px var(--card-border-color)"
|
|
2103
|
+
},
|
|
2104
|
+
background: {
|
|
2105
|
+
opacity: 0,
|
|
2106
|
+
scale: 1
|
|
2107
|
+
},
|
|
2108
|
+
idle: {
|
|
2109
|
+
scale: 1
|
|
2110
|
+
},
|
|
2111
|
+
reloading: {
|
|
2112
|
+
scale: [1, 1, 1, 0.98]
|
|
2113
|
+
},
|
|
2114
|
+
active: {
|
|
2115
|
+
opacity: [0, 0, 1],
|
|
2116
|
+
scale: 1
|
|
2117
|
+
},
|
|
2118
|
+
timedOut: {
|
|
2119
|
+
opacity: [0, 0, 1]
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
function defineWarnOnce() {
|
|
2123
|
+
let warned = !1;
|
|
2124
|
+
return (...args) => {
|
|
2125
|
+
warned || (console.warn(...args), warned = !0);
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
const warnOnceAboutCrossDatasetReference = defineWarnOnce();
|
|
2129
|
+
function useDocumentsOnPage(perspective, frameStateRef) {
|
|
2130
|
+
const $ = c(11);
|
|
2131
|
+
validateApiPerspective(perspective);
|
|
2132
|
+
let t0;
|
|
2133
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0];
|
|
2134
|
+
const [published, setPublished] = useState(t0);
|
|
2135
|
+
let t1;
|
|
2136
|
+
$[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = {}, $[1] = t1) : t1 = $[1];
|
|
2137
|
+
const [previewDrafts, setPreviewDrafts] = useState(t1), urlRef = useRef("");
|
|
2138
|
+
let t2;
|
|
2139
|
+
$[2] !== frameStateRef ? (t2 = (key, perspective_0, t32) => {
|
|
2140
|
+
const documents = (t32 === void 0 ? [] : t32).filter(_temp$9);
|
|
2141
|
+
(perspective_0 === "published" ? setPublished : setPreviewDrafts)((cache) => {
|
|
2142
|
+
const next = {};
|
|
2143
|
+
for (const document2 of documents)
|
|
2144
|
+
next[document2._id] = document2;
|
|
2145
|
+
if (urlRef.current !== frameStateRef.current.url)
|
|
2146
|
+
return urlRef.current = frameStateRef.current.url, {
|
|
2147
|
+
[key]: next
|
|
2148
|
+
};
|
|
2149
|
+
const prev = cache[key];
|
|
2150
|
+
return isEqual(prev, next) ? cache : {
|
|
2151
|
+
...cache,
|
|
2152
|
+
[key]: next
|
|
2153
|
+
};
|
|
2154
|
+
});
|
|
2155
|
+
}, $[2] = frameStateRef, $[3] = t2) : t2 = $[3];
|
|
2156
|
+
const setDocumentsOnPage = t2, keyedCache = perspective === "published" ? published : previewDrafts;
|
|
2157
|
+
let t3;
|
|
2158
|
+
$[4] !== keyedCache ? (t3 = Object.values(keyedCache).reduce(_temp2$5, {}), $[4] = keyedCache, $[5] = t3) : t3 = $[5];
|
|
2159
|
+
const uniqueDocuments = t3;
|
|
2160
|
+
let t4;
|
|
2161
|
+
$[6] !== uniqueDocuments ? (t4 = Object.values(uniqueDocuments), $[6] = uniqueDocuments, $[7] = t4) : t4 = $[7];
|
|
2162
|
+
const documentsOnPage = t4;
|
|
2163
|
+
let t5;
|
|
2164
|
+
return $[8] !== documentsOnPage || $[9] !== setDocumentsOnPage ? (t5 = [documentsOnPage, setDocumentsOnPage], $[8] = documentsOnPage, $[9] = setDocumentsOnPage, $[10] = t5) : t5 = $[10], t5;
|
|
2165
|
+
}
|
|
2166
|
+
function _temp2$5(acc, cache_0) {
|
|
2167
|
+
return Object.values(cache_0).forEach((doc) => {
|
|
2168
|
+
acc[doc._id] = doc;
|
|
2169
|
+
}), acc;
|
|
2170
|
+
}
|
|
2171
|
+
function _temp$9(sourceDocument) {
|
|
2172
|
+
return "_projectId" in sourceDocument && sourceDocument._projectId ? (warnOnceAboutCrossDatasetReference("Cross dataset references are not supported yet, ignoring source document", sourceDocument), !1) : sourceDocument;
|
|
2173
|
+
}
|
|
2174
|
+
function fnOrObj(arg, context) {
|
|
2175
|
+
return arg instanceof Function ? arg(context) : arg;
|
|
2176
|
+
}
|
|
2177
|
+
function getQueryFromResult(resolver, context) {
|
|
2178
|
+
if (resolver.resolve) {
|
|
2179
|
+
const filter = resolver.resolve(context)?.filter;
|
|
2180
|
+
return filter ? `// groq
|
|
2181
|
+
*[${filter}][0]{_id, _type}` : void 0;
|
|
2182
|
+
}
|
|
2183
|
+
return "type" in resolver ? `// groq
|
|
2184
|
+
*[_type == "${resolver.type}"][0]{_id, _type}` : `// groq
|
|
2185
|
+
*[${fnOrObj(resolver.filter, context)}][0]{_id, _type}`;
|
|
2186
|
+
}
|
|
2187
|
+
function getParamsFromResult(resolver, context) {
|
|
2188
|
+
return resolver.resolve ? resolver.resolve(context)?.params ?? context.params : "type" in resolver ? {} : fnOrObj(resolver.params, context) ?? context.params;
|
|
2189
|
+
}
|
|
2190
|
+
function getRouteContext(route, url) {
|
|
2191
|
+
const routes = Array.isArray(route) ? route : [route];
|
|
2192
|
+
for (route of routes) {
|
|
2193
|
+
let {
|
|
2194
|
+
origin: origin2
|
|
2195
|
+
} = url, path = route;
|
|
2196
|
+
if (typeof route == "string")
|
|
2197
|
+
try {
|
|
2198
|
+
const absolute = new URL(route);
|
|
2199
|
+
if (absolute.origin !== origin2) continue;
|
|
2200
|
+
origin2 = absolute.origin, path = absolute.pathname;
|
|
2201
|
+
} catch {
|
|
2202
|
+
}
|
|
2203
|
+
try {
|
|
2204
|
+
const result = match(path, {
|
|
2205
|
+
decode: decodeURIComponent
|
|
2206
|
+
})(url.pathname);
|
|
2207
|
+
if (result) {
|
|
2208
|
+
const {
|
|
2209
|
+
params,
|
|
2210
|
+
path: path2
|
|
2211
|
+
} = result;
|
|
2212
|
+
return {
|
|
2213
|
+
origin: origin2,
|
|
2214
|
+
params,
|
|
2215
|
+
path: path2
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
} catch (e) {
|
|
2219
|
+
throw new Error(`"${route}" is not a valid route pattern`, {
|
|
2220
|
+
cause: e
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
function useMainDocument(props) {
|
|
2226
|
+
const $ = c(22), {
|
|
2227
|
+
navigate,
|
|
2228
|
+
navigationHistory,
|
|
2229
|
+
path,
|
|
2230
|
+
targetOrigin,
|
|
2231
|
+
resolvers: t0,
|
|
2232
|
+
perspective
|
|
2233
|
+
} = props;
|
|
2234
|
+
let t1;
|
|
2235
|
+
$[0] !== t0 ? (t1 = t0 === void 0 ? [] : t0, $[0] = t0, $[1] = t1) : t1 = $[1];
|
|
2236
|
+
const resolvers = t1, {
|
|
2237
|
+
state: routerState
|
|
2238
|
+
} = useRouter();
|
|
2239
|
+
let t2;
|
|
2240
|
+
$[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
2241
|
+
apiVersion: API_VERSION
|
|
2242
|
+
}, $[2] = t2) : t2 = $[2];
|
|
2243
|
+
const client = useClient(t2);
|
|
2244
|
+
let t3;
|
|
2245
|
+
$[3] !== path || $[4] !== routerState ? (t3 = path || routerState._searchParams?.find(_temp$8)?.[1] || "", $[3] = path, $[4] = routerState, $[5] = t3) : t3 = $[5];
|
|
2246
|
+
const relativeUrl = t3, [mainDocumentState, setMainDocumentState] = useState(void 0), mainDocumentIdRef = useRef(void 0);
|
|
2247
|
+
let t4;
|
|
2248
|
+
$[6] !== navigate || $[7] !== navigationHistory ? (t4 = (doc, url) => {
|
|
2249
|
+
(!doc || mainDocumentIdRef.current !== doc._id) && (setMainDocumentState({
|
|
2250
|
+
document: doc,
|
|
2251
|
+
path: url.pathname
|
|
2252
|
+
}), mainDocumentIdRef.current = doc?._id, navigationHistory.at(-1)?.id === navigationHistory.at(-2)?.id && navigate?.({
|
|
2253
|
+
state: {
|
|
2254
|
+
id: doc?._id,
|
|
2255
|
+
type: doc?._type
|
|
2256
|
+
}
|
|
2257
|
+
}));
|
|
2258
|
+
}, $[6] = navigate, $[7] = navigationHistory, $[8] = t4) : t4 = $[8];
|
|
2259
|
+
const handleResponse = useEffectEvent(t4);
|
|
2260
|
+
let t5;
|
|
2261
|
+
$[9] !== client || $[10] !== handleResponse || $[11] !== perspective || $[12] !== relativeUrl || $[13] !== resolvers || $[14] !== targetOrigin ? (t5 = () => {
|
|
2262
|
+
const url_0 = new URL(relativeUrl, targetOrigin);
|
|
2263
|
+
if (resolvers.length) {
|
|
2264
|
+
let result;
|
|
2265
|
+
for (const resolver of resolvers) {
|
|
2266
|
+
const context = getRouteContext(resolver.route, url_0);
|
|
2267
|
+
if (context) {
|
|
2268
|
+
result = {
|
|
2269
|
+
context,
|
|
2270
|
+
resolver
|
|
2271
|
+
};
|
|
2272
|
+
break;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
if (result) {
|
|
2276
|
+
const query = getQueryFromResult(result.resolver, result.context), params = getParamsFromResult(result.resolver, result.context);
|
|
2277
|
+
if (query) {
|
|
2278
|
+
const controller = new AbortController(), options = {
|
|
2279
|
+
perspective,
|
|
2280
|
+
signal: controller.signal,
|
|
2281
|
+
tag: "use-main-document"
|
|
2282
|
+
};
|
|
2283
|
+
return client.fetch(query, params, options).then((doc_0) => handleResponse(doc_0, url_0)).catch((e) => {
|
|
2284
|
+
e instanceof Error && e.name === "AbortError" || (setMainDocumentState({
|
|
2285
|
+
document: void 0,
|
|
2286
|
+
path: url_0.pathname
|
|
2287
|
+
}), mainDocumentIdRef.current = void 0);
|
|
2288
|
+
}), () => {
|
|
2289
|
+
controller.abort();
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
setMainDocumentState(void 0), mainDocumentIdRef.current = void 0;
|
|
2295
|
+
}, $[9] = client, $[10] = handleResponse, $[11] = perspective, $[12] = relativeUrl, $[13] = resolvers, $[14] = targetOrigin, $[15] = t5) : t5 = $[15];
|
|
2296
|
+
let t6;
|
|
2297
|
+
return $[16] !== client || $[17] !== perspective || $[18] !== relativeUrl || $[19] !== resolvers || $[20] !== targetOrigin ? (t6 = [client, perspective, relativeUrl, resolvers, targetOrigin], $[16] = client, $[17] = perspective, $[18] = relativeUrl, $[19] = resolvers, $[20] = targetOrigin, $[21] = t6) : t6 = $[21], useEffect(t5, t6), mainDocumentState;
|
|
2298
|
+
}
|
|
2299
|
+
function _temp$8(t0) {
|
|
2300
|
+
const [key] = t0;
|
|
2301
|
+
return key === "preview";
|
|
2302
|
+
}
|
|
2303
|
+
const RE_SEGMENT_WITH_INDEX = /^([\w-]+):(0|[1-9][0-9]*)$/, RE_SEGMENT_WITH_TUPLE = /^([\w-]+):([0-9]+),([0-9]+)$/, RE_SEGMENT_WITH_KEY = /^([\w-]+):([\w-]+)$/;
|
|
2304
|
+
function urlStringToPath(str) {
|
|
2305
|
+
const path = [];
|
|
2306
|
+
for (const segment of str.split(".")) {
|
|
2307
|
+
const withIndex = RE_SEGMENT_WITH_INDEX.exec(segment);
|
|
2308
|
+
if (withIndex) {
|
|
2309
|
+
path.push(withIndex[1], Number(withIndex[2]));
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
const withTuple = RE_SEGMENT_WITH_TUPLE.exec(segment);
|
|
2313
|
+
if (withTuple) {
|
|
2314
|
+
path.push(withTuple[1], [Number(withTuple[2]), Number(withTuple[3])]);
|
|
2315
|
+
continue;
|
|
2316
|
+
}
|
|
2317
|
+
const withKey = RE_SEGMENT_WITH_KEY.exec(segment);
|
|
2318
|
+
if (withKey) {
|
|
2319
|
+
path.push(withKey[1], {
|
|
2320
|
+
_key: withKey[2]
|
|
2321
|
+
});
|
|
2322
|
+
continue;
|
|
2323
|
+
}
|
|
2324
|
+
path.push(segment);
|
|
2325
|
+
}
|
|
2326
|
+
return path;
|
|
2327
|
+
}
|
|
2328
|
+
function parseId(rawId) {
|
|
2329
|
+
if (rawId === void 0)
|
|
2330
|
+
return;
|
|
2331
|
+
const segments = decodeURIComponent(rawId)?.split(".");
|
|
2332
|
+
return segments[0] === "drafts" && segments.shift(), segments.join(".");
|
|
2333
|
+
}
|
|
2334
|
+
function parsePath(rawPath) {
|
|
2335
|
+
if (rawPath !== void 0)
|
|
2336
|
+
return studioPath.toString(urlStringToPath(decodeURIComponent(rawPath)));
|
|
2337
|
+
}
|
|
2338
|
+
function parseRouterState(state) {
|
|
2339
|
+
return {
|
|
2340
|
+
id: parseId(state.id),
|
|
2341
|
+
path: parsePath(state.path),
|
|
2342
|
+
type: state.type
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
function pruneObject(obj) {
|
|
2346
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0 && value !== "" && value !== null));
|
|
2347
|
+
}
|
|
2348
|
+
const exhaustiveTupleOf = () => (array) => array, maintainOnDocumentChange = exhaustiveTupleOf()(["perspective", "preview", "viewport"]), maintainOnSameDocument = exhaustiveTupleOf()(["changesInspectorTab", "comment", "inspect", "instruction", "scheduledDraft", "parentRefPath", "path", "pathKey", "rev", "since", "template", "templateParams", "version", "view"]);
|
|
2349
|
+
function useParams(t0) {
|
|
2350
|
+
const $ = c(56), {
|
|
2351
|
+
initialPreviewUrl,
|
|
2352
|
+
routerNavigate,
|
|
2353
|
+
routerState,
|
|
2354
|
+
routerSearchParams
|
|
2355
|
+
} = t0;
|
|
2356
|
+
let t1;
|
|
2357
|
+
$[0] !== routerState ? (t1 = parseRouterState(routerState), $[0] = routerState, $[1] = t1) : t1 = $[1];
|
|
2358
|
+
const {
|
|
2359
|
+
id,
|
|
2360
|
+
path,
|
|
2361
|
+
type
|
|
2362
|
+
} = t1;
|
|
2363
|
+
let t2;
|
|
2364
|
+
$[2] !== initialPreviewUrl || $[3] !== routerSearchParams.preview ? (t2 = routerSearchParams.preview || initialPreviewUrl.toString(), $[2] = initialPreviewUrl, $[3] = routerSearchParams.preview, $[4] = t2) : t2 = $[4];
|
|
2365
|
+
const t3 = routerSearchParams.changesInspectorTab;
|
|
2366
|
+
let t4;
|
|
2367
|
+
$[5] !== id || $[6] !== path || $[7] !== routerSearchParams.comment || $[8] !== routerSearchParams.inspect || $[9] !== routerSearchParams.instruction || $[10] !== routerSearchParams.parentRefPath || $[11] !== routerSearchParams.pathKey || $[12] !== routerSearchParams.perspective || $[13] !== routerSearchParams.rev || $[14] !== routerSearchParams.scheduledDraft || $[15] !== routerSearchParams.since || $[16] !== routerSearchParams.template || $[17] !== routerSearchParams.templateParams || $[18] !== routerSearchParams.view || $[19] !== routerSearchParams.viewport || $[20] !== t2 || $[21] !== t3 || $[22] !== type ? (t4 = {
|
|
2368
|
+
id,
|
|
2369
|
+
type,
|
|
2370
|
+
path,
|
|
2371
|
+
preview: t2,
|
|
2372
|
+
perspective: routerSearchParams.perspective,
|
|
2373
|
+
viewport: routerSearchParams.viewport,
|
|
2374
|
+
inspect: routerSearchParams.inspect,
|
|
2375
|
+
scheduledDraft: routerSearchParams.scheduledDraft,
|
|
2376
|
+
parentRefPath: routerSearchParams.parentRefPath,
|
|
2377
|
+
rev: routerSearchParams.rev,
|
|
2378
|
+
since: routerSearchParams.since,
|
|
2379
|
+
template: routerSearchParams.template,
|
|
2380
|
+
templateParams: routerSearchParams.templateParams,
|
|
2381
|
+
view: routerSearchParams.view,
|
|
2382
|
+
pathKey: routerSearchParams.pathKey,
|
|
2383
|
+
instruction: routerSearchParams.instruction,
|
|
2384
|
+
comment: routerSearchParams.comment,
|
|
2385
|
+
changesInspectorTab: t3
|
|
2386
|
+
}, $[5] = id, $[6] = path, $[7] = routerSearchParams.comment, $[8] = routerSearchParams.inspect, $[9] = routerSearchParams.instruction, $[10] = routerSearchParams.parentRefPath, $[11] = routerSearchParams.pathKey, $[12] = routerSearchParams.perspective, $[13] = routerSearchParams.rev, $[14] = routerSearchParams.scheduledDraft, $[15] = routerSearchParams.since, $[16] = routerSearchParams.template, $[17] = routerSearchParams.templateParams, $[18] = routerSearchParams.view, $[19] = routerSearchParams.viewport, $[20] = t2, $[21] = t3, $[22] = type, $[23] = t4) : t4 = $[23];
|
|
2387
|
+
const params = t4;
|
|
2388
|
+
let t5;
|
|
2389
|
+
$[24] !== params.changesInspectorTab || $[25] !== params.comment || $[26] !== params.inspect || $[27] !== params.instruction || $[28] !== params.parentRefPath || $[29] !== params.path || $[30] !== params.pathKey || $[31] !== params.rev || $[32] !== params.scheduledDraft || $[33] !== params.since || $[34] !== params.template || $[35] !== params.templateParams || $[36] !== params.view ? (t5 = pruneObject({
|
|
2390
|
+
inspect: params.inspect,
|
|
2391
|
+
scheduledDraft: params.scheduledDraft,
|
|
2392
|
+
path: params.path,
|
|
2393
|
+
parentRefPath: params.parentRefPath,
|
|
2394
|
+
rev: params.rev,
|
|
2395
|
+
since: params.since,
|
|
2396
|
+
template: params.template,
|
|
2397
|
+
templateParams: params.templateParams,
|
|
2398
|
+
view: params.view,
|
|
2399
|
+
pathKey: params.pathKey,
|
|
2400
|
+
instruction: params.instruction,
|
|
2401
|
+
comment: params.comment,
|
|
2402
|
+
changesInspectorTab: params.changesInspectorTab
|
|
2403
|
+
}), $[24] = params.changesInspectorTab, $[25] = params.comment, $[26] = params.inspect, $[27] = params.instruction, $[28] = params.parentRefPath, $[29] = params.path, $[30] = params.pathKey, $[31] = params.rev, $[32] = params.scheduledDraft, $[33] = params.since, $[34] = params.template, $[35] = params.templateParams, $[36] = params.view, $[37] = t5) : t5 = $[37];
|
|
2404
|
+
const structureParams = t5;
|
|
2405
|
+
let t6;
|
|
2406
|
+
$[38] !== params.perspective || $[39] !== params.preview || $[40] !== params.viewport ? (t6 = pruneObject({
|
|
2407
|
+
perspective: params.perspective,
|
|
2408
|
+
preview: params.preview,
|
|
2409
|
+
viewport: params.viewport
|
|
2410
|
+
}), $[38] = params.perspective, $[39] = params.preview, $[40] = params.viewport, $[41] = t6) : t6 = $[41];
|
|
2411
|
+
const searchParams = t6, routerStateRef = useRef(routerState);
|
|
2412
|
+
let t7, t8;
|
|
2413
|
+
$[42] !== routerState ? (t7 = () => {
|
|
2414
|
+
routerStateRef.current = routerState;
|
|
2415
|
+
}, t8 = [routerState], $[42] = routerState, $[43] = t7, $[44] = t8) : (t7 = $[43], t8 = $[44]), useLayoutEffect(t7, t8);
|
|
2416
|
+
let t9;
|
|
2417
|
+
$[45] !== routerState ? (t9 = [routerState], $[45] = routerState, $[46] = t9) : t9 = $[46];
|
|
2418
|
+
const [navigationHistory, setNavigationHistory] = useState(t9);
|
|
2419
|
+
let t10;
|
|
2420
|
+
$[47] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = (t112) => {
|
|
2421
|
+
const {
|
|
2422
|
+
id: id_0,
|
|
2423
|
+
type: type_0
|
|
2424
|
+
} = t112, {
|
|
2425
|
+
current
|
|
2426
|
+
} = routerStateRef;
|
|
2427
|
+
return id_0 === current.id && type_0 === current.type;
|
|
2428
|
+
}, $[47] = t10) : t10 = $[47];
|
|
2429
|
+
const isSameDocument = t10;
|
|
2430
|
+
let t11;
|
|
2431
|
+
$[48] !== routerNavigate ? (t11 = (options) => {
|
|
2432
|
+
const {
|
|
2433
|
+
state,
|
|
2434
|
+
params: params_0,
|
|
2435
|
+
replace: t122
|
|
2436
|
+
} = options, replace = t122 === void 0 ? !1 : t122;
|
|
2437
|
+
state?.id && (state.id = getPublishedId(state.id));
|
|
2438
|
+
const {
|
|
2439
|
+
current: current_0
|
|
2440
|
+
} = routerStateRef, currentState = {
|
|
2441
|
+
id: current_0.id,
|
|
2442
|
+
type: current_0.type,
|
|
2443
|
+
path: current_0.path
|
|
2444
|
+
}, currentParams = Object.fromEntries(current_0._searchParams || []), nextState = state || currentState, nextParams = {
|
|
2445
|
+
...[...maintainOnDocumentChange, ...isSameDocument(nextState) ? maintainOnSameDocument : []].reduce((acc, key) => (acc[key] = currentParams[key], acc), {}),
|
|
2446
|
+
...params_0
|
|
2447
|
+
}, nextRouterState = {
|
|
2448
|
+
...nextState,
|
|
2449
|
+
_searchParams: Object.entries(nextParams).reduce(_temp$7, [])
|
|
2450
|
+
};
|
|
2451
|
+
setNavigationHistory((prev) => [...prev, nextRouterState]), routerNavigate(nextRouterState, {
|
|
2452
|
+
replace
|
|
2453
|
+
});
|
|
2454
|
+
}, $[48] = routerNavigate, $[49] = t11) : t11 = $[49];
|
|
2455
|
+
const navigate = t11;
|
|
2456
|
+
let t12;
|
|
2457
|
+
return $[50] !== navigate || $[51] !== navigationHistory || $[52] !== params || $[53] !== searchParams || $[54] !== structureParams ? (t12 = {
|
|
2458
|
+
isSameDocument,
|
|
2459
|
+
navigate,
|
|
2460
|
+
navigationHistory,
|
|
2461
|
+
params,
|
|
2462
|
+
searchParams,
|
|
2463
|
+
structureParams
|
|
2464
|
+
}, $[50] = navigate, $[51] = navigationHistory, $[52] = params, $[53] = searchParams, $[54] = structureParams, $[55] = t12) : t12 = $[55], t12;
|
|
2465
|
+
}
|
|
2466
|
+
function _temp$7(acc_0, t0) {
|
|
2467
|
+
const [key_0, value] = t0;
|
|
2468
|
+
return [...acc_0, [key_0, value]];
|
|
2469
|
+
}
|
|
2470
|
+
const usePopups = (controller) => {
|
|
2471
|
+
const $ = c(10), [popups, setPopups] = useState(_temp$6);
|
|
2472
|
+
let t0;
|
|
2473
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = (url) => {
|
|
2474
|
+
const source = window.open(url, "_blank");
|
|
2475
|
+
source && setPopups((prev) => new Set(prev).add(source));
|
|
2476
|
+
}, $[0] = t0) : t0 = $[0];
|
|
2477
|
+
const open = t0;
|
|
2478
|
+
let t1, t2;
|
|
2479
|
+
$[1] !== controller || $[2] !== popups ? (t1 = () => {
|
|
2480
|
+
const unsubs = [];
|
|
2481
|
+
if (popups.size && controller)
|
|
2482
|
+
for (const source_0 of popups)
|
|
2483
|
+
source_0 && "closed" in source_0 && !source_0.closed && unsubs.push(controller.addTarget(source_0));
|
|
2484
|
+
return () => {
|
|
2485
|
+
unsubs.forEach(_temp2$4);
|
|
2486
|
+
};
|
|
2487
|
+
}, t2 = [controller, popups], $[1] = controller, $[2] = popups, $[3] = t1, $[4] = t2) : (t1 = $[3], t2 = $[4]), useEffect(t1, t2);
|
|
2488
|
+
let t3, t4;
|
|
2489
|
+
$[5] !== popups ? (t3 = () => {
|
|
2490
|
+
if (popups.size) {
|
|
2491
|
+
const interval = setInterval(() => {
|
|
2492
|
+
const closed = /* @__PURE__ */ new Set();
|
|
2493
|
+
for (const source_1 of popups)
|
|
2494
|
+
source_1 && "closed" in source_1 && source_1.closed && closed.add(source_1);
|
|
2495
|
+
closed.size && setPopups((prev_0) => {
|
|
2496
|
+
const next = new Set(prev_0);
|
|
2497
|
+
for (const source_2 of closed)
|
|
2498
|
+
next.delete(source_2);
|
|
2499
|
+
return next;
|
|
2500
|
+
});
|
|
2501
|
+
}, POPUP_CHECK_INTERVAL);
|
|
2502
|
+
return () => {
|
|
2503
|
+
clearInterval(interval);
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
}, t4 = [popups], $[5] = popups, $[6] = t3, $[7] = t4) : (t3 = $[6], t4 = $[7]), useEffect(t3, t4);
|
|
2507
|
+
let t5;
|
|
2508
|
+
return $[8] !== popups ? (t5 = {
|
|
2509
|
+
popups,
|
|
2510
|
+
open
|
|
2511
|
+
}, $[8] = popups, $[9] = t5) : t5 = $[9], t5;
|
|
2512
|
+
};
|
|
2513
|
+
function _temp$6() {
|
|
2514
|
+
return /* @__PURE__ */ new Set();
|
|
2515
|
+
}
|
|
2516
|
+
function _temp2$4(unsub) {
|
|
2517
|
+
return unsub();
|
|
2518
|
+
}
|
|
2519
|
+
function usePresentationPerspective(t0) {
|
|
2520
|
+
const $ = c(5), {
|
|
2521
|
+
scheduledDraft
|
|
2522
|
+
} = t0, {
|
|
2523
|
+
selectedPerspectiveName: t1,
|
|
2524
|
+
selectedReleaseId,
|
|
2525
|
+
perspectiveStack
|
|
2526
|
+
} = usePerspective(), selectedPerspectiveName = t1 === void 0 ? "drafts" : t1;
|
|
2527
|
+
let t2;
|
|
2528
|
+
return $[0] !== perspectiveStack || $[1] !== scheduledDraft || $[2] !== selectedPerspectiveName || $[3] !== selectedReleaseId ? (t2 = selectedReleaseId || scheduledDraft ? scheduledDraft ? [scheduledDraft, ...perspectiveStack] : perspectiveStack : selectedPerspectiveName === "published" ? "published" : "drafts", $[0] = perspectiveStack, $[1] = scheduledDraft, $[2] = selectedPerspectiveName, $[3] = selectedReleaseId, $[4] = t2) : t2 = $[4], t2;
|
|
2529
|
+
}
|
|
2530
|
+
function useStatus() {
|
|
2531
|
+
const $ = c(4);
|
|
2532
|
+
let t0;
|
|
2533
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ new Map(), $[0] = t0) : t0 = $[0];
|
|
2534
|
+
const [statusMap, setStatusMap] = useState(t0);
|
|
2535
|
+
let t1;
|
|
2536
|
+
bb0: {
|
|
2537
|
+
const values = Array.from(statusMap.values());
|
|
2538
|
+
if (values.find(_temp$5)) {
|
|
2539
|
+
t1 = "connected";
|
|
2540
|
+
break bb0;
|
|
2541
|
+
}
|
|
2542
|
+
const handshaking = values.filter(_temp2$3);
|
|
2543
|
+
if (handshaking.length) {
|
|
2544
|
+
t1 = handshaking.some(_temp3$1) ? "connecting" : "reconnecting";
|
|
2545
|
+
break bb0;
|
|
2546
|
+
}
|
|
2547
|
+
t1 = "idle";
|
|
2548
|
+
}
|
|
2549
|
+
const memoStatus = t1;
|
|
2550
|
+
let t2;
|
|
2551
|
+
$[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = (event) => {
|
|
2552
|
+
setStatusMap((prev) => {
|
|
2553
|
+
const next = new Map(prev);
|
|
2554
|
+
if (event.status === "disconnected")
|
|
2555
|
+
next.delete(event.connection);
|
|
2556
|
+
else {
|
|
2557
|
+
const hasConnected_0 = next.get(event.connection)?.hasConnected || event.status === "connected", status_1 = event.status === "handshaking" ? "connecting" : event.status;
|
|
2558
|
+
next.set(event.connection, {
|
|
2559
|
+
status: status_1,
|
|
2560
|
+
hasConnected: hasConnected_0
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
return next;
|
|
2564
|
+
});
|
|
2565
|
+
}, $[1] = t2) : t2 = $[1];
|
|
2566
|
+
const setStatusFromEvent = t2;
|
|
2567
|
+
let t3;
|
|
2568
|
+
return $[2] !== memoStatus ? (t3 = [memoStatus, setStatusFromEvent], $[2] = memoStatus, $[3] = t3) : t3 = $[3], t3;
|
|
2569
|
+
}
|
|
2570
|
+
function _temp3$1(t0) {
|
|
2571
|
+
const {
|
|
2572
|
+
hasConnected
|
|
2573
|
+
} = t0;
|
|
2574
|
+
return !hasConnected;
|
|
2575
|
+
}
|
|
2576
|
+
function _temp2$3(t0) {
|
|
2577
|
+
const {
|
|
2578
|
+
status: status_0
|
|
2579
|
+
} = t0;
|
|
2580
|
+
return status_0 === "connecting";
|
|
2581
|
+
}
|
|
2582
|
+
function _temp$5(t0) {
|
|
2583
|
+
const {
|
|
2584
|
+
status
|
|
2585
|
+
} = t0;
|
|
2586
|
+
return status === "connected";
|
|
2587
|
+
}
|
|
2588
|
+
const LiveQueries = lazy(() => import("./LiveQueries.js")), PostMessageDocuments = lazy(() => import("./PostMessageDocuments.js")), PostMessageRefreshMutations = lazy(() => import("./PostMessageRefreshMutations.js")), PostMessagePerspective = lazy(() => import("./PostMessagePerspective.js")), PostMessagePreviewSnapshots = lazy(() => import("./PostMessagePreviewSnapshots.js")), PostMessageSchema = lazy(() => import("./PostMessageSchema.js")), PostMessageTelemetry = lazy(() => import("./PostMessageTelemetry.js")), Container = styled(Flex).withConfig({
|
|
2589
|
+
displayName: "Container",
|
|
2590
|
+
componentId: "sc-1f7om43-0"
|
|
2591
|
+
})`overflow-x:auto;`;
|
|
2592
|
+
function PresentationTool(props) {
|
|
2593
|
+
const $ = c(196), {
|
|
2594
|
+
canToggleSharePreviewAccess,
|
|
2595
|
+
canUseSharedPreviewAccess,
|
|
2596
|
+
tool,
|
|
2597
|
+
vercelProtectionBypass,
|
|
2598
|
+
initialPreviewUrl,
|
|
2599
|
+
previewUrlRef
|
|
2600
|
+
} = props, allowOrigins = useAllowPatterns(previewUrlRef), targetOrigin = useTargetOrigin(previewUrlRef), components = tool.options?.components, name = tool.name || DEFAULT_TOOL_NAME;
|
|
2601
|
+
let t0;
|
|
2602
|
+
$[0] !== components ? (t0 = components || {}, $[0] = components, $[1] = t0) : t0 = $[1];
|
|
2603
|
+
const {
|
|
2604
|
+
unstable_navigator,
|
|
2605
|
+
unstable_header
|
|
2606
|
+
} = t0, {
|
|
2607
|
+
navigate: routerNavigate,
|
|
2608
|
+
state: routerState
|
|
2609
|
+
} = useRouter();
|
|
2610
|
+
let t1;
|
|
2611
|
+
$[2] !== routerState._searchParams ? (t1 = Object.fromEntries(routerState._searchParams || []), $[2] = routerState._searchParams, $[3] = t1) : t1 = $[3];
|
|
2612
|
+
const routerSearchParams = useUnique(t1), canSharePreviewAccess = useSelector(previewUrlRef, _temp$4);
|
|
2613
|
+
let t2;
|
|
2614
|
+
$[4] !== tool.options?.devMode ? (t2 = () => {
|
|
2615
|
+
const option = tool.options?.devMode;
|
|
2616
|
+
return typeof option == "function" ? option() : typeof option == "boolean" ? option : typeof window < "u" && window.location.hostname === "localhost";
|
|
2617
|
+
}, $[4] = tool.options?.devMode, $[5] = t2) : t2 = $[5];
|
|
2618
|
+
const [devMode] = useState(t2), iframeRef = useRef(null), [controller, setController] = useState(), [visualEditingComlink, setVisualEditingComlink] = useState(null);
|
|
2619
|
+
let t3;
|
|
2620
|
+
$[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = {
|
|
2621
|
+
title: void 0,
|
|
2622
|
+
url: void 0
|
|
2623
|
+
}, $[6] = t3) : t3 = $[6];
|
|
2624
|
+
const frameStateRef = useRef(t3);
|
|
2625
|
+
let t4;
|
|
2626
|
+
$[7] !== initialPreviewUrl || $[8] !== routerNavigate || $[9] !== routerSearchParams || $[10] !== routerState ? (t4 = {
|
|
2627
|
+
initialPreviewUrl,
|
|
2628
|
+
routerNavigate,
|
|
2629
|
+
routerState,
|
|
2630
|
+
routerSearchParams,
|
|
2631
|
+
frameStateRef
|
|
2632
|
+
}, $[7] = initialPreviewUrl, $[8] = routerNavigate, $[9] = routerSearchParams, $[10] = routerState, $[11] = t4) : t4 = $[11];
|
|
2633
|
+
const {
|
|
2634
|
+
isSameDocument,
|
|
2635
|
+
navigate,
|
|
2636
|
+
navigationHistory,
|
|
2637
|
+
params,
|
|
2638
|
+
searchParams,
|
|
2639
|
+
structureParams
|
|
2640
|
+
} = useParams(t4);
|
|
2641
|
+
let t5;
|
|
2642
|
+
$[12] !== params.scheduledDraft ? (t5 = {
|
|
2643
|
+
scheduledDraft: params.scheduledDraft
|
|
2644
|
+
}, $[12] = params.scheduledDraft, $[13] = t5) : t5 = $[13];
|
|
2645
|
+
const perspective = usePresentationPerspective(t5), presentationRef = useActorRef(presentationMachine), viewport = params.viewport ? "mobile" : "desktop", [documentsOnPage, setDocumentsOnPage] = useDocumentsOnPage(perspective, frameStateRef), projectId = useProjectId(), dataset = useDataset(), t6 = tool.options?.resolve?.mainDocuments;
|
|
2646
|
+
let t7;
|
|
2647
|
+
$[14] !== navigate || $[15] !== navigationHistory || $[16] !== params.preview || $[17] !== perspective || $[18] !== t6 || $[19] !== targetOrigin ? (t7 = {
|
|
2648
|
+
navigate,
|
|
2649
|
+
navigationHistory,
|
|
2650
|
+
path: params.preview,
|
|
2651
|
+
targetOrigin,
|
|
2652
|
+
resolvers: t6,
|
|
2653
|
+
perspective
|
|
2654
|
+
}, $[14] = navigate, $[15] = navigationHistory, $[16] = params.preview, $[17] = perspective, $[18] = t6, $[19] = targetOrigin, $[20] = t7) : t7 = $[20];
|
|
2655
|
+
const mainDocumentState = useMainDocument(t7), [overlaysConnection, setOverlaysConnection] = useStatus(), [loadersConnection, setLoadersConnection] = useStatus(), [previewKitConnection, setPreviewKitConnection] = useStatus(), {
|
|
2656
|
+
open: handleOpenPopup
|
|
2657
|
+
} = usePopups(controller), isLoading = useSelector(presentationRef, _temp2$2);
|
|
2658
|
+
let t8, t9;
|
|
2659
|
+
$[21] !== isLoading || $[22] !== targetOrigin ? (t8 = () => {
|
|
2660
|
+
const target = iframeRef.current?.contentWindow;
|
|
2661
|
+
if (!target || isLoading)
|
|
2662
|
+
return;
|
|
2663
|
+
const controller_0 = createController({
|
|
2664
|
+
targetOrigin
|
|
2665
|
+
});
|
|
2666
|
+
return controller_0.addTarget(target), setController(controller_0), () => {
|
|
2667
|
+
controller_0.destroy(), setController(void 0);
|
|
2668
|
+
};
|
|
2669
|
+
}, t9 = [targetOrigin, isLoading], $[21] = isLoading, $[22] = targetOrigin, $[23] = t8, $[24] = t9) : (t8 = $[23], t9 = $[24]), useEffect(t8, t9);
|
|
2670
|
+
let t10;
|
|
2671
|
+
$[25] !== navigate ? (t10 = (options) => {
|
|
2672
|
+
navigate(options);
|
|
2673
|
+
}, $[25] = navigate, $[26] = t10) : t10 = $[26];
|
|
2674
|
+
const handleNavigate = useEffectEvent(t10), refreshRef = useRef(void 0);
|
|
2675
|
+
let t11;
|
|
2676
|
+
$[27] !== controller || $[28] !== handleNavigate || $[29] !== presentationRef || $[30] !== setDocumentsOnPage || $[31] !== setOverlaysConnection || $[32] !== targetOrigin ? (t11 = () => {
|
|
2677
|
+
if (!controller)
|
|
2678
|
+
return;
|
|
2679
|
+
const comlink = controller.createChannel({
|
|
2680
|
+
name: "presentation",
|
|
2681
|
+
heartbeat: !0,
|
|
2682
|
+
connectTo: "visual-editing"
|
|
2683
|
+
}, createConnectionMachine().provide({
|
|
2684
|
+
actors: createCompatibilityActors()
|
|
2685
|
+
}));
|
|
2686
|
+
comlink.on("visual-editing/focus", (data) => {
|
|
2687
|
+
"id" in data && handleNavigate({
|
|
2688
|
+
state: {
|
|
2689
|
+
type: data.type,
|
|
2690
|
+
id: data.id,
|
|
2691
|
+
path: data.path
|
|
2692
|
+
}
|
|
2693
|
+
});
|
|
2694
|
+
}), comlink.on("visual-editing/navigate", (data_0) => {
|
|
2695
|
+
const {
|
|
2696
|
+
title
|
|
2697
|
+
} = data_0;
|
|
2698
|
+
let url = data_0.url;
|
|
2699
|
+
if (!url.startsWith("http"))
|
|
2700
|
+
try {
|
|
2701
|
+
url = new URL(url, targetOrigin).toString();
|
|
2702
|
+
} catch {
|
|
2703
|
+
}
|
|
2704
|
+
if (frameStateRef.current.url !== url) {
|
|
2705
|
+
const run = () => {
|
|
2706
|
+
const [urlWithoutSearch, search] = url.split("?"), searchParams_0 = new URLSearchParams(search);
|
|
2707
|
+
searchParams_0.delete(urlSearchParamVercelProtectionBypass), searchParams_0.delete(urlSearchParamVercelSetBypassCookie), handleNavigate({
|
|
2708
|
+
params: {
|
|
2709
|
+
preview: `${urlWithoutSearch}${searchParams_0.size > 0 ? "?" : ""}${searchParams_0}`
|
|
2710
|
+
}
|
|
2711
|
+
});
|
|
2712
|
+
};
|
|
2713
|
+
try {
|
|
2714
|
+
run();
|
|
2715
|
+
} catch {
|
|
2716
|
+
handleNavigate({
|
|
2717
|
+
params: {
|
|
2718
|
+
preview: url
|
|
2719
|
+
}
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
frameStateRef.current = {
|
|
2724
|
+
title,
|
|
2725
|
+
url
|
|
2726
|
+
};
|
|
2727
|
+
}), comlink.on("visual-editing/meta", (data_1) => {
|
|
2728
|
+
frameStateRef.current.title = data_1.title;
|
|
2729
|
+
}), comlink.on("visual-editing/toggle", (data_2) => {
|
|
2730
|
+
presentationRef.send({
|
|
2731
|
+
type: "toggle visual editing overlays",
|
|
2732
|
+
enabled: data_2.enabled
|
|
2733
|
+
});
|
|
2734
|
+
}), comlink.on("visual-editing/documents", (data_3) => {
|
|
2735
|
+
setDocumentsOnPage("visual-editing", data_3.perspective, data_3.documents);
|
|
2736
|
+
}), comlink.on("visual-editing/refreshing", (data_4) => {
|
|
2737
|
+
data_4.source === "manual" ? clearTimeout(refreshRef.current) : data_4.source === "mutation" && presentationRef.send({
|
|
2738
|
+
type: "iframe refresh"
|
|
2739
|
+
});
|
|
2740
|
+
}), comlink.on("visual-editing/refreshed", () => {
|
|
2741
|
+
presentationRef.send({
|
|
2742
|
+
type: "iframe loaded"
|
|
2743
|
+
});
|
|
2744
|
+
}), comlink.onStatus(setOverlaysConnection);
|
|
2745
|
+
const stop = comlink.start();
|
|
2746
|
+
return setVisualEditingComlink(comlink), () => {
|
|
2747
|
+
stop(), setVisualEditingComlink(null);
|
|
2748
|
+
};
|
|
2749
|
+
}, $[27] = controller, $[28] = handleNavigate, $[29] = presentationRef, $[30] = setDocumentsOnPage, $[31] = setOverlaysConnection, $[32] = targetOrigin, $[33] = t11) : t11 = $[33];
|
|
2750
|
+
let t12;
|
|
2751
|
+
$[34] !== controller || $[35] !== presentationRef || $[36] !== setDocumentsOnPage || $[37] !== setOverlaysConnection || $[38] !== targetOrigin ? (t12 = [controller, presentationRef, setDocumentsOnPage, setOverlaysConnection, targetOrigin], $[34] = controller, $[35] = presentationRef, $[36] = setDocumentsOnPage, $[37] = setOverlaysConnection, $[38] = targetOrigin, $[39] = t12) : t12 = $[39], useEffect(t11, t12);
|
|
2752
|
+
let t13;
|
|
2753
|
+
$[40] !== controller || $[41] !== dataset || $[42] !== projectId || $[43] !== setDocumentsOnPage || $[44] !== setPreviewKitConnection ? (t13 = () => {
|
|
2754
|
+
if (!controller)
|
|
2755
|
+
return;
|
|
2756
|
+
const comlink_0 = controller.createChannel({
|
|
2757
|
+
name: "presentation",
|
|
2758
|
+
connectTo: "preview-kit",
|
|
2759
|
+
heartbeat: !0
|
|
2760
|
+
}, createConnectionMachine().provide({
|
|
2761
|
+
actors: createCompatibilityActors()
|
|
2762
|
+
}));
|
|
2763
|
+
return comlink_0.onStatus(setPreviewKitConnection), comlink_0.on("preview-kit/documents", (data_5) => {
|
|
2764
|
+
data_5.projectId === projectId && data_5.dataset === dataset && setDocumentsOnPage("preview-kit", data_5.perspective, data_5.documents);
|
|
2765
|
+
}), comlink_0.start();
|
|
2766
|
+
}, $[40] = controller, $[41] = dataset, $[42] = projectId, $[43] = setDocumentsOnPage, $[44] = setPreviewKitConnection, $[45] = t13) : t13 = $[45];
|
|
2767
|
+
let t14;
|
|
2768
|
+
$[46] !== controller || $[47] !== dataset || $[48] !== projectId || $[49] !== setDocumentsOnPage || $[50] !== setPreviewKitConnection || $[51] !== targetOrigin ? (t14 = [controller, dataset, projectId, setDocumentsOnPage, setPreviewKitConnection, targetOrigin], $[46] = controller, $[47] = dataset, $[48] = projectId, $[49] = setDocumentsOnPage, $[50] = setPreviewKitConnection, $[51] = targetOrigin, $[52] = t14) : t14 = $[52], useEffect(t13, t14);
|
|
2769
|
+
let t15;
|
|
2770
|
+
$[53] !== isSameDocument || $[54] !== navigate ? (t15 = debounce((state_1) => {
|
|
2771
|
+
isSameDocument(state_1) && navigate({
|
|
2772
|
+
state: state_1,
|
|
2773
|
+
replace: !0
|
|
2774
|
+
});
|
|
2775
|
+
}, 0), $[53] = isSameDocument, $[54] = navigate, $[55] = t15) : t15 = $[55];
|
|
2776
|
+
const handleFocusPath = t15;
|
|
2777
|
+
let t16;
|
|
2778
|
+
$[56] !== allowOrigins || $[57] !== navigate || $[58] !== params.preview || $[59] !== targetOrigin ? (t16 = (nextPath) => {
|
|
2779
|
+
const url_0 = new URL(nextPath, targetOrigin), preview = url_0.toString();
|
|
2780
|
+
params.preview !== preview && (Array.isArray(allowOrigins) ? allowOrigins.some((pattern) => pattern.test(preview)) && navigate({
|
|
2781
|
+
params: {
|
|
2782
|
+
preview
|
|
2783
|
+
}
|
|
2784
|
+
}) : url_0.origin === targetOrigin && navigate({
|
|
2785
|
+
params: {
|
|
2786
|
+
preview
|
|
2787
|
+
}
|
|
2788
|
+
}));
|
|
2789
|
+
}, $[56] = allowOrigins, $[57] = navigate, $[58] = params.preview, $[59] = targetOrigin, $[60] = t16) : t16 = $[60];
|
|
2790
|
+
const handlePreviewPath = t16;
|
|
2791
|
+
let t17;
|
|
2792
|
+
$[61] !== navigate ? (t17 = (params_0) => {
|
|
2793
|
+
navigate({
|
|
2794
|
+
params: params_0
|
|
2795
|
+
});
|
|
2796
|
+
}, $[61] = navigate, $[62] = t17) : t17 = $[62];
|
|
2797
|
+
const handleStructureParams = t17;
|
|
2798
|
+
let t18;
|
|
2799
|
+
$[63] !== navigate ? (t18 = (options_0) => {
|
|
2800
|
+
navigate(options_0);
|
|
2801
|
+
}, $[63] = navigate, $[64] = t18) : t18 = $[64];
|
|
2802
|
+
const handleEditReference = t18;
|
|
2803
|
+
let t19, t20;
|
|
2804
|
+
$[65] !== params.id || $[66] !== params.path || $[67] !== visualEditingComlink ? (t19 = () => {
|
|
2805
|
+
params.id && params.path ? visualEditingComlink?.post("presentation/focus", {
|
|
2806
|
+
id: params.id,
|
|
2807
|
+
path: params.path
|
|
2808
|
+
}) : visualEditingComlink?.post("presentation/blur");
|
|
2809
|
+
}, t20 = [params.id, params.path, visualEditingComlink], $[65] = params.id, $[66] = params.path, $[67] = visualEditingComlink, $[68] = t19, $[69] = t20) : (t19 = $[68], t20 = $[69]), useEffect(t19, t20);
|
|
2810
|
+
let t21, t22;
|
|
2811
|
+
$[70] !== overlaysConnection || $[71] !== params.preview || $[72] !== targetOrigin || $[73] !== visualEditingComlink ? (t21 = () => {
|
|
2812
|
+
if (frameStateRef.current.url && params.preview && frameStateRef.current.url !== params.preview) {
|
|
2813
|
+
try {
|
|
2814
|
+
const frameOrigin = new URL(frameStateRef.current.url, targetOrigin).origin, previewOrigin = new URL(params.preview, targetOrigin).origin;
|
|
2815
|
+
if (frameOrigin !== previewOrigin)
|
|
2816
|
+
return;
|
|
2817
|
+
} catch {
|
|
2818
|
+
}
|
|
2819
|
+
if (frameStateRef.current.url = params.preview, overlaysConnection === "connected") {
|
|
2820
|
+
let url_1 = params.preview;
|
|
2821
|
+
if (url_1.startsWith("http"))
|
|
2822
|
+
try {
|
|
2823
|
+
const newUrl = new URL(params.preview, targetOrigin);
|
|
2824
|
+
url_1 = newUrl.pathname + newUrl.search + newUrl.hash;
|
|
2825
|
+
} catch {
|
|
2826
|
+
}
|
|
2827
|
+
visualEditingComlink?.post("presentation/navigate", {
|
|
2828
|
+
url: url_1,
|
|
2829
|
+
type: "replace"
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
}, t22 = [overlaysConnection, targetOrigin, params.preview, visualEditingComlink], $[70] = overlaysConnection, $[71] = params.preview, $[72] = targetOrigin, $[73] = visualEditingComlink, $[74] = t21, $[75] = t22) : (t21 = $[74], t22 = $[75]), useEffect(t21, t22);
|
|
2834
|
+
let t23;
|
|
2835
|
+
$[76] !== visualEditingComlink ? (t23 = () => visualEditingComlink?.post("presentation/toggle-overlay"), $[76] = visualEditingComlink, $[77] = t23) : t23 = $[77];
|
|
2836
|
+
const toggleOverlay = t23, [displayedDocument, setDisplayedDocument] = useState(null);
|
|
2837
|
+
let t24, t25;
|
|
2838
|
+
$[78] !== toggleOverlay ? (t24 = () => {
|
|
2839
|
+
const handleKeyUp = (e) => {
|
|
2840
|
+
isAltKey(e) && toggleOverlay();
|
|
2841
|
+
}, handleKeydown = (e_0) => {
|
|
2842
|
+
isAltKey(e_0) && toggleOverlay(), isHotkey(["mod", "\\"], e_0) && toggleOverlay();
|
|
2843
|
+
};
|
|
2844
|
+
return window.addEventListener("keydown", handleKeydown), window.addEventListener("keyup", handleKeyUp), () => {
|
|
2845
|
+
window.removeEventListener("keydown", handleKeydown), window.removeEventListener("keyup", handleKeyUp);
|
|
2846
|
+
};
|
|
2847
|
+
}, t25 = [toggleOverlay], $[78] = toggleOverlay, $[79] = t24, $[80] = t25) : (t24 = $[79], t25 = $[80]), useEffect(t24, t25);
|
|
2848
|
+
const [boundaryElement, setBoundaryElement] = useState(null);
|
|
2849
|
+
let t26;
|
|
2850
|
+
$[81] !== unstable_navigator ? (t26 = {
|
|
2851
|
+
unstable_navigator
|
|
2852
|
+
}, $[81] = unstable_navigator, $[82] = t26) : t26 = $[82];
|
|
2853
|
+
const [t27, PresentationNavigator] = usePresentationNavigator(t26), {
|
|
2854
|
+
navigatorEnabled,
|
|
2855
|
+
toggleNavigator
|
|
2856
|
+
} = t27;
|
|
2857
|
+
let t28;
|
|
2858
|
+
$[83] !== loadersConnection || $[84] !== presentationRef || $[85] !== previewKitConnection || $[86] !== visualEditingComlink ? (t28 = (fallback) => {
|
|
2859
|
+
if (presentationRef.send({
|
|
2860
|
+
type: "iframe refresh"
|
|
2861
|
+
}), visualEditingComlink) {
|
|
2862
|
+
refreshRef.current = window.setTimeout(fallback, 300), visualEditingComlink.post("presentation/refresh", {
|
|
2863
|
+
source: "manual",
|
|
2864
|
+
livePreviewEnabled: previewKitConnection === "connected" || loadersConnection === "connected"
|
|
2865
|
+
});
|
|
2866
|
+
return;
|
|
2867
|
+
}
|
|
2868
|
+
fallback();
|
|
2869
|
+
}, $[83] = loadersConnection, $[84] = presentationRef, $[85] = previewKitConnection, $[86] = visualEditingComlink, $[87] = t28) : t28 = $[87];
|
|
2870
|
+
const handleRefresh = t28, workspace = useWorkspace();
|
|
2871
|
+
let t29;
|
|
2872
|
+
$[88] !== params.preview || $[89] !== workspace.name ? (t29 = (t302) => {
|
|
2873
|
+
const {
|
|
2874
|
+
id,
|
|
2875
|
+
type,
|
|
2876
|
+
path
|
|
2877
|
+
} = t302;
|
|
2878
|
+
if (frameStateRef.current.url)
|
|
2879
|
+
return {
|
|
2880
|
+
title: frameStateRef.current.title || frameStateRef.current.url,
|
|
2881
|
+
name: "edit",
|
|
2882
|
+
params: {
|
|
2883
|
+
id,
|
|
2884
|
+
path,
|
|
2885
|
+
type,
|
|
2886
|
+
inspect: COMMENTS_INSPECTOR_NAME,
|
|
2887
|
+
workspace: workspace.name,
|
|
2888
|
+
mode: EDIT_INTENT_MODE,
|
|
2889
|
+
preview: params.preview
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
}, $[88] = params.preview, $[89] = workspace.name, $[90] = t29) : t29 = $[90];
|
|
2893
|
+
const getCommentIntent = t29;
|
|
2894
|
+
let t30;
|
|
2895
|
+
$[91] !== navigate ? (t30 = (next) => {
|
|
2896
|
+
navigate({
|
|
2897
|
+
params: {
|
|
2898
|
+
viewport: next === "desktop" ? void 0 : "mobile"
|
|
2899
|
+
},
|
|
2900
|
+
replace: !0
|
|
2901
|
+
});
|
|
2902
|
+
}, $[91] = navigate, $[92] = t30) : t30 = $[92];
|
|
2903
|
+
const setViewport = t30;
|
|
2904
|
+
let t31;
|
|
2905
|
+
$[93] !== PresentationNavigator ? (t31 = /* @__PURE__ */ jsx(PresentationNavigator, {}), $[93] = PresentationNavigator, $[94] = t31) : t31 = $[94];
|
|
2906
|
+
const t32 = navigatorEnabled ? 50 : 75;
|
|
2907
|
+
let t33;
|
|
2908
|
+
$[95] !== canSharePreviewAccess || $[96] !== canToggleSharePreviewAccess || $[97] !== canUseSharedPreviewAccess || $[98] !== handleOpenPopup || $[99] !== handlePreviewPath || $[100] !== handleRefresh || $[101] !== initialPreviewUrl || $[102] !== loadersConnection || $[103] !== navigatorEnabled || $[104] !== overlaysConnection || $[105] !== params.preview || $[106] !== perspective || $[107] !== presentationRef || $[108] !== previewUrlRef || $[109] !== setViewport || $[110] !== targetOrigin || $[111] !== toggleNavigator || $[112] !== toggleOverlay || $[113] !== unstable_header || $[114] !== vercelProtectionBypass || $[115] !== viewport ? (t33 = /* @__PURE__ */ jsx(Preview, { canSharePreviewAccess, canToggleSharePreviewAccess, canUseSharedPreviewAccess, header: unstable_header, initialUrl: initialPreviewUrl, loadersConnection, navigatorEnabled, onPathChange: handlePreviewPath, onRefresh: handleRefresh, openPopup: handleOpenPopup, overlaysConnection, previewUrl: params.preview, perspective, ref: iframeRef, setViewport, targetOrigin, toggleNavigator, toggleOverlay, viewport, vercelProtectionBypass, presentationRef, previewUrlRef }, targetOrigin), $[95] = canSharePreviewAccess, $[96] = canToggleSharePreviewAccess, $[97] = canUseSharedPreviewAccess, $[98] = handleOpenPopup, $[99] = handlePreviewPath, $[100] = handleRefresh, $[101] = initialPreviewUrl, $[102] = loadersConnection, $[103] = navigatorEnabled, $[104] = overlaysConnection, $[105] = params.preview, $[106] = perspective, $[107] = presentationRef, $[108] = previewUrlRef, $[109] = setViewport, $[110] = targetOrigin, $[111] = toggleNavigator, $[112] = toggleOverlay, $[113] = unstable_header, $[114] = vercelProtectionBypass, $[115] = viewport, $[116] = t33) : t33 = $[116];
|
|
2909
|
+
let t34;
|
|
2910
|
+
$[117] !== boundaryElement || $[118] !== t33 ? (t34 = /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 1, height: "fill", ref: setBoundaryElement, children: /* @__PURE__ */ jsx(BoundaryElementProvider, { element: boundaryElement, children: t33 }) }), $[117] = boundaryElement, $[118] = t33, $[119] = t34) : t34 = $[119];
|
|
2911
|
+
let t35;
|
|
2912
|
+
$[120] !== t32 || $[121] !== t34 ? (t35 = /* @__PURE__ */ jsx(Panel, { id: "preview", minWidth: 325, defaultSize: t32, order: 3, children: t34 }), $[120] = t32, $[121] = t34, $[122] = t35) : t35 = $[122];
|
|
2913
|
+
let t36;
|
|
2914
|
+
$[123] !== documentsOnPage || $[124] !== getCommentIntent || $[125] !== handleEditReference || $[126] !== handleFocusPath || $[127] !== handleStructureParams || $[128] !== mainDocumentState || $[129] !== params.id || $[130] !== params.type || $[131] !== searchParams || $[132] !== structureParams ? (t36 = /* @__PURE__ */ jsx(PresentationContent, { documentId: params.id, documentsOnPage, documentType: params.type, getCommentIntent, mainDocumentState, onEditReference: handleEditReference, onFocusPath: handleFocusPath, onStructureParams: handleStructureParams, searchParams, setDisplayedDocument, structureParams }), $[123] = documentsOnPage, $[124] = getCommentIntent, $[125] = handleEditReference, $[126] = handleFocusPath, $[127] = handleStructureParams, $[128] = mainDocumentState, $[129] = params.id, $[130] = params.type, $[131] = searchParams, $[132] = structureParams, $[133] = t36) : t36 = $[133];
|
|
2915
|
+
let t37;
|
|
2916
|
+
$[134] !== t31 || $[135] !== t35 || $[136] !== t36 ? (t37 = /* @__PURE__ */ jsx(Container, { "data-testid": "presentation-root", height: "fill", children: /* @__PURE__ */ jsxs(Panels, { children: [
|
|
2917
|
+
t31,
|
|
2918
|
+
t35,
|
|
2919
|
+
t36
|
|
2920
|
+
] }) }), $[134] = t31, $[135] = t35, $[136] = t36, $[137] = t37) : t37 = $[137];
|
|
2921
|
+
let t38;
|
|
2922
|
+
$[138] !== t37 || $[139] !== visualEditingComlink ? (t38 = /* @__PURE__ */ jsx(SharedStateProvider, { comlink: visualEditingComlink, children: t37 }), $[138] = t37, $[139] = visualEditingComlink, $[140] = t38) : t38 = $[140];
|
|
2923
|
+
let t39;
|
|
2924
|
+
$[141] !== params || $[142] !== t38 ? (t39 = /* @__PURE__ */ jsx(PresentationParamsProvider, { params, children: t38 }), $[141] = params, $[142] = t38, $[143] = t39) : t39 = $[143];
|
|
2925
|
+
let t40;
|
|
2926
|
+
$[144] !== navigate || $[145] !== t39 ? (t40 = /* @__PURE__ */ jsx(PresentationNavigateProvider, { navigate, children: t39 }), $[144] = navigate, $[145] = t39, $[146] = t40) : t40 = $[146];
|
|
2927
|
+
let t41;
|
|
2928
|
+
$[147] !== devMode || $[148] !== name || $[149] !== navigate || $[150] !== params || $[151] !== searchParams || $[152] !== structureParams || $[153] !== t40 ? (t41 = /* @__PURE__ */ jsx(PresentationProvider, { devMode, name, navigate, params, searchParams, structureParams, children: t40 }), $[147] = devMode, $[148] = name, $[149] = navigate, $[150] = params, $[151] = searchParams, $[152] = structureParams, $[153] = t40, $[154] = t41) : t41 = $[154];
|
|
2929
|
+
let t42;
|
|
2930
|
+
$[155] !== controller || $[156] !== displayedDocument || $[157] !== perspective || $[158] !== setDocumentsOnPage || $[159] !== setLoadersConnection ? (t42 = controller && /* @__PURE__ */ jsx(LiveQueries, { controller, perspective, liveDocument: displayedDocument, onDocumentsOnPage: setDocumentsOnPage, onLoadersConnection: setLoadersConnection }), $[155] = controller, $[156] = displayedDocument, $[157] = perspective, $[158] = setDocumentsOnPage, $[159] = setLoadersConnection, $[160] = t42) : t42 = $[160];
|
|
2931
|
+
let t43;
|
|
2932
|
+
$[161] !== loadersConnection || $[162] !== params.id || $[163] !== params.type || $[164] !== previewKitConnection || $[165] !== visualEditingComlink ? (t43 = visualEditingComlink && params.id && params.type && /* @__PURE__ */ jsx(PostMessageRefreshMutations, { comlink: visualEditingComlink, id: params.id, type: params.type, loadersConnection, previewKitConnection }), $[161] = loadersConnection, $[162] = params.id, $[163] = params.type, $[164] = previewKitConnection, $[165] = visualEditingComlink, $[166] = t43) : t43 = $[166];
|
|
2933
|
+
let t44;
|
|
2934
|
+
$[167] !== perspective || $[168] !== visualEditingComlink ? (t44 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageSchema, { comlink: visualEditingComlink, perspective }), $[167] = perspective, $[168] = visualEditingComlink, $[169] = t44) : t44 = $[169];
|
|
2935
|
+
let t45;
|
|
2936
|
+
$[170] !== documentsOnPage || $[171] !== perspective || $[172] !== visualEditingComlink ? (t45 = visualEditingComlink && documentsOnPage.length > 0 && /* @__PURE__ */ jsx(PostMessagePreviewSnapshots, { comlink: visualEditingComlink, perspective, refs: documentsOnPage }), $[170] = documentsOnPage, $[171] = perspective, $[172] = visualEditingComlink, $[173] = t45) : t45 = $[173];
|
|
2937
|
+
let t46;
|
|
2938
|
+
$[174] !== perspective || $[175] !== visualEditingComlink ? (t46 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageDocuments, { comlink: visualEditingComlink, perspective }), $[174] = perspective, $[175] = visualEditingComlink, $[176] = t46) : t46 = $[176];
|
|
2939
|
+
let t47;
|
|
2940
|
+
$[177] !== visualEditingComlink ? (t47 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageFeatures, { comlink: visualEditingComlink }), $[177] = visualEditingComlink, $[178] = t47) : t47 = $[178];
|
|
2941
|
+
let t48;
|
|
2942
|
+
$[179] !== perspective || $[180] !== visualEditingComlink ? (t48 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessagePerspective, { comlink: visualEditingComlink, perspective }), $[179] = perspective, $[180] = visualEditingComlink, $[181] = t48) : t48 = $[181];
|
|
2943
|
+
let t49;
|
|
2944
|
+
$[182] !== visualEditingComlink ? (t49 = visualEditingComlink && /* @__PURE__ */ jsx(PostMessageTelemetry, { comlink: visualEditingComlink }), $[182] = visualEditingComlink, $[183] = t49) : t49 = $[183];
|
|
2945
|
+
let t50;
|
|
2946
|
+
$[184] !== t42 || $[185] !== t43 || $[186] !== t44 || $[187] !== t45 || $[188] !== t46 || $[189] !== t47 || $[190] !== t48 || $[191] !== t49 ? (t50 = /* @__PURE__ */ jsxs(Suspense, { children: [
|
|
2947
|
+
t42,
|
|
2948
|
+
t43,
|
|
2949
|
+
t44,
|
|
2950
|
+
t45,
|
|
2951
|
+
t46,
|
|
2952
|
+
t47,
|
|
2953
|
+
t48,
|
|
2954
|
+
t49
|
|
2955
|
+
] }), $[184] = t42, $[185] = t43, $[186] = t44, $[187] = t45, $[188] = t46, $[189] = t47, $[190] = t48, $[191] = t49, $[192] = t50) : t50 = $[192];
|
|
2956
|
+
let t51;
|
|
2957
|
+
return $[193] !== t41 || $[194] !== t50 ? (t51 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2958
|
+
t41,
|
|
2959
|
+
t50
|
|
2960
|
+
] }), $[193] = t41, $[194] = t50, $[195] = t51) : t51 = $[195], t51;
|
|
2961
|
+
}
|
|
2962
|
+
function _temp2$2(state_0) {
|
|
2963
|
+
return state_0.matches("loading");
|
|
2964
|
+
}
|
|
2965
|
+
function _temp$4(state) {
|
|
2966
|
+
return state.context.previewMode?.shareAccess !== !1;
|
|
2967
|
+
}
|
|
2968
|
+
function isAltKey(event) {
|
|
2969
|
+
return event.key === "Alt";
|
|
2970
|
+
}
|
|
2971
|
+
const IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform), MODIFIERS = {
|
|
2972
|
+
alt: "altKey",
|
|
2973
|
+
ctrl: "ctrlKey",
|
|
2974
|
+
mod: IS_MAC ? "metaKey" : "ctrlKey",
|
|
2975
|
+
shift: "shiftKey"
|
|
2976
|
+
};
|
|
2977
|
+
function isHotkey(keys, event) {
|
|
2978
|
+
return keys.every((key) => MODIFIERS[key] ? event[MODIFIERS[key]] : event.key === key.toUpperCase());
|
|
2979
|
+
}
|
|
2980
|
+
function defineCreatePreviewSecretActor({
|
|
2981
|
+
client,
|
|
2982
|
+
currentUserId
|
|
2983
|
+
}) {
|
|
2984
|
+
return fromPromise(async () => await createPreviewSecret(client, "sanity/presentation", location.href, currentUserId));
|
|
2985
|
+
}
|
|
2986
|
+
function defineReadSharedSecretActor({
|
|
2987
|
+
client
|
|
2988
|
+
}) {
|
|
2989
|
+
return fromPromise(async () => client.fetch(fetchSharedAccessQuery, {}, {
|
|
2990
|
+
tag: "presentation.fallback-to-shared-access-secret"
|
|
2991
|
+
}));
|
|
2992
|
+
}
|
|
2993
|
+
function defineResolveAllowPatternsActor({
|
|
2994
|
+
client,
|
|
2995
|
+
allowOption
|
|
2996
|
+
}) {
|
|
2997
|
+
return fromPromise(async ({
|
|
2998
|
+
input
|
|
2999
|
+
}) => {
|
|
3000
|
+
const {
|
|
3001
|
+
initialUrl
|
|
3002
|
+
} = input;
|
|
3003
|
+
if (typeof URLPattern > "u" && await import("urlpattern-polyfill"), !allowOption)
|
|
3004
|
+
return [new URLPattern(initialUrl.origin)];
|
|
3005
|
+
const maybePatterns = typeof allowOption == "function" ? await allowOption({
|
|
3006
|
+
client,
|
|
3007
|
+
origin,
|
|
3008
|
+
initialUrl
|
|
3009
|
+
}) : allowOption, urlPatterns = (Array.isArray(maybePatterns) ? maybePatterns : [maybePatterns]).map((value) => {
|
|
3010
|
+
const urlPattern = new URLPattern(value);
|
|
3011
|
+
if (urlPattern.hostname === "*")
|
|
3012
|
+
throw new Error("It's insecure to allow any hostname, it could disclose data to a malicious site");
|
|
3013
|
+
return urlPattern;
|
|
3014
|
+
});
|
|
3015
|
+
return urlPatterns.some((pattern) => pattern.test(initialUrl.origin)) ? urlPatterns : [...urlPatterns, new URLPattern(initialUrl.origin)];
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
3018
|
+
function defineResolveInitialUrlActor({
|
|
3019
|
+
client,
|
|
3020
|
+
studioBasePath,
|
|
3021
|
+
previewUrlOption,
|
|
3022
|
+
perspective
|
|
3023
|
+
}) {
|
|
3024
|
+
return fromPromise(async ({
|
|
3025
|
+
input
|
|
3026
|
+
}) => {
|
|
3027
|
+
const {
|
|
3028
|
+
origin: origin2
|
|
3029
|
+
} = location;
|
|
3030
|
+
if (typeof previewUrlOption == "function") {
|
|
3031
|
+
const initial = await previewUrlOption({
|
|
3032
|
+
client,
|
|
3033
|
+
studioBasePath,
|
|
3034
|
+
// @TODO handle checking permissions here, and then generating a secret
|
|
3035
|
+
previewUrlSecret: "",
|
|
3036
|
+
studioPreviewPerspective: encodeStudioPerspective(perspective),
|
|
3037
|
+
previewSearchParam: input.previewSearchParam
|
|
3038
|
+
});
|
|
3039
|
+
return new URL(initial, origin2);
|
|
3040
|
+
}
|
|
3041
|
+
if (!previewUrlOption)
|
|
3042
|
+
return new URL("/", origin2);
|
|
3043
|
+
if (typeof previewUrlOption == "string")
|
|
3044
|
+
return new URL(previewUrlOption, origin2);
|
|
3045
|
+
if (typeof previewUrlOption.initial == "function") {
|
|
3046
|
+
const initial = await previewUrlOption.initial({
|
|
3047
|
+
client,
|
|
3048
|
+
origin: origin2
|
|
3049
|
+
});
|
|
3050
|
+
return new URL(initial, origin2);
|
|
3051
|
+
}
|
|
3052
|
+
return typeof previewUrlOption.initial == "string" ? new URL(previewUrlOption.initial, origin2) : new URL(previewUrlOption.preview || "/", previewUrlOption.origin || origin2);
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
function defineResolvePreviewModeActor({
|
|
3056
|
+
client,
|
|
3057
|
+
previewUrlOption
|
|
3058
|
+
}) {
|
|
3059
|
+
return fromPromise(async ({
|
|
3060
|
+
input
|
|
3061
|
+
}) => {
|
|
3062
|
+
const {
|
|
3063
|
+
targetOrigin
|
|
3064
|
+
} = input;
|
|
3065
|
+
if (typeof previewUrlOption == "object" && previewUrlOption?.draftMode)
|
|
3066
|
+
return {
|
|
3067
|
+
enable: previewUrlOption.draftMode.enable,
|
|
3068
|
+
shareAccess: previewUrlOption.draftMode.shareAccess ?? !0
|
|
3069
|
+
};
|
|
3070
|
+
if (!previewUrlOption || typeof previewUrlOption == "string" || typeof previewUrlOption == "function" || !previewUrlOption.previewMode)
|
|
3071
|
+
return !1;
|
|
3072
|
+
const previewMode = typeof previewUrlOption.previewMode == "function" ? await previewUrlOption.previewMode({
|
|
3073
|
+
client,
|
|
3074
|
+
origin,
|
|
3075
|
+
targetOrigin
|
|
3076
|
+
}) : previewUrlOption.previewMode;
|
|
3077
|
+
return previewMode === !1 ? !1 : {
|
|
3078
|
+
enable: previewMode.enable,
|
|
3079
|
+
shareAccess: previewMode.shareAccess ?? !0
|
|
3080
|
+
};
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
function defineResolvePreviewModeUrlActor({
|
|
3084
|
+
client,
|
|
3085
|
+
studioBasePath,
|
|
3086
|
+
previewUrlOption,
|
|
3087
|
+
perspective
|
|
3088
|
+
}) {
|
|
3089
|
+
return fromPromise(async ({
|
|
3090
|
+
input
|
|
3091
|
+
}) => {
|
|
3092
|
+
const {
|
|
3093
|
+
previewUrlSecret,
|
|
3094
|
+
resolvedPreviewMode,
|
|
3095
|
+
initialUrl
|
|
3096
|
+
} = input;
|
|
3097
|
+
if (typeof previewUrlOption == "function") {
|
|
3098
|
+
const initial = await previewUrlOption({
|
|
3099
|
+
client,
|
|
3100
|
+
studioBasePath,
|
|
3101
|
+
previewUrlSecret,
|
|
3102
|
+
studioPreviewPerspective: encodeStudioPerspective(perspective),
|
|
3103
|
+
previewSearchParam: initialUrl.toString()
|
|
3104
|
+
});
|
|
3105
|
+
return new URL(initial, initialUrl);
|
|
3106
|
+
}
|
|
3107
|
+
if (!resolvedPreviewMode)
|
|
3108
|
+
throw new Error("Resolved preview mode is false");
|
|
3109
|
+
const url = new URL(resolvedPreviewMode.enable, initialUrl);
|
|
3110
|
+
return url.searchParams.set(urlSearchParamPreviewSecret, previewUrlSecret), url.searchParams.set(urlSearchParamPreviewPerspective, encodeStudioPerspective(perspective)), initialUrl.pathname !== url.pathname && url.searchParams.set(urlSearchParamPreviewPathname, `${initialUrl.pathname}${initialUrl.search}${initialUrl.hash}`), url;
|
|
3111
|
+
});
|
|
3112
|
+
}
|
|
3113
|
+
const resolveUrlFromPreviewSearchParamActor = fromPromise(async ({
|
|
3114
|
+
input
|
|
3115
|
+
}) => {
|
|
3116
|
+
const {
|
|
3117
|
+
previewSearchParam,
|
|
3118
|
+
initialUrl,
|
|
3119
|
+
allowOrigins
|
|
3120
|
+
} = input;
|
|
3121
|
+
if (!previewSearchParam)
|
|
3122
|
+
return initialUrl;
|
|
3123
|
+
try {
|
|
3124
|
+
const previewSearchParamUrl = new URL(previewSearchParam, initialUrl.origin);
|
|
3125
|
+
return allowOrigins.some((pattern) => pattern.test(previewSearchParamUrl.origin)) ? previewSearchParamUrl : initialUrl;
|
|
3126
|
+
} catch {
|
|
3127
|
+
return initialUrl;
|
|
3128
|
+
}
|
|
3129
|
+
}), shareAccessSingletonDocument = {
|
|
3130
|
+
_id: schemaIdSingleton,
|
|
3131
|
+
_type: schemaTypeSingleton
|
|
3132
|
+
}, previewUrlSecretDocument = {
|
|
3133
|
+
_id: `drafts.${uuid()}`,
|
|
3134
|
+
_type: schemaType
|
|
3135
|
+
}, previewUrlMachine = setup({
|
|
3136
|
+
types: {},
|
|
3137
|
+
actions: {
|
|
3138
|
+
"notify preview will likely fail": log("Missing permissions to create preview secret, or read shared preview secret. Preview will likely fail loading."),
|
|
3139
|
+
"assign preview search param": assign({
|
|
3140
|
+
previewSearchParam: (_, params) => params.previewSearchParam
|
|
3141
|
+
}),
|
|
3142
|
+
"assign error": assign({
|
|
3143
|
+
error: (_, params) => params.error instanceof Error ? params.error : new Error(params.message, {
|
|
3144
|
+
cause: params.error
|
|
3145
|
+
})
|
|
3146
|
+
})
|
|
3147
|
+
},
|
|
3148
|
+
actors: {
|
|
3149
|
+
"check permission": fromObservable(() => throwError(() => new Error("The 'check permission' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'check permission': fromObservable(({input}: {input: CheckPermissionInput}) => ...)}})"))),
|
|
3150
|
+
"resolve initial url": fromPromise(() => Promise.reject(new Error("The 'resolve initial url' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve initial url': fromPromise(...)}})"))),
|
|
3151
|
+
"resolve allow patterns": fromPromise(() => Promise.reject(new Error("The 'resolve allow patterns' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve allow pattern': fromPromise(...)}})"))),
|
|
3152
|
+
"resolve url from preview search param": resolveUrlFromPreviewSearchParamActor,
|
|
3153
|
+
"resolve preview mode": fromPromise(() => Promise.reject(new Error("The 'resolve preview mode' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve preview mode': fromPromise(...)}})"))),
|
|
3154
|
+
"create preview secret": fromPromise(async () => Promise.reject(new Error("The 'create preview secret' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'create preview secret': fromPromise(...)}})"))),
|
|
3155
|
+
"read shared preview secret": fromPromise(async () => Promise.reject(new Error("The 'read shared preview secret' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'read shared preview secret': fromPromise(...)}})"))),
|
|
3156
|
+
"resolve preview mode url": fromPromise(() => Promise.reject(new Error("The 'resolve preview mode url' actor is not implemented. Add it to previewUrlMachine.provide({actors: {'resolve preview mode url': fromPromise(...)}})")))
|
|
3157
|
+
},
|
|
3158
|
+
guards: {
|
|
3159
|
+
"has checked permissions": ({
|
|
3160
|
+
context
|
|
3161
|
+
}) => !!(context.previewAccessSharingCreatePermission && context.previewAccessSharingReadPermission && context.previewAccessSharingUpdatePermission && context.previewUrlSecretPermission),
|
|
3162
|
+
"search param has new origin": ({
|
|
3163
|
+
context,
|
|
3164
|
+
event
|
|
3165
|
+
}) => {
|
|
3166
|
+
if (!context.previewUrl || !event.previewSearchParam)
|
|
3167
|
+
return !1;
|
|
3168
|
+
try {
|
|
3169
|
+
const previewSearchParamUrl = new URL(event.previewSearchParam, context.previewUrl);
|
|
3170
|
+
return context.previewUrl.origin !== previewSearchParamUrl.origin;
|
|
3171
|
+
} catch {
|
|
3172
|
+
return !1;
|
|
3173
|
+
}
|
|
3174
|
+
},
|
|
3175
|
+
"can create preview secret": ({
|
|
3176
|
+
context
|
|
3177
|
+
}) => context.previewUrlSecretPermission?.granted === !0,
|
|
3178
|
+
"has preview mode with created secret": ({
|
|
3179
|
+
context
|
|
3180
|
+
}, params) => params === !1 ? !1 : context.previewUrlSecretPermission?.granted === !0,
|
|
3181
|
+
"has preview mode with share access": ({
|
|
3182
|
+
context
|
|
3183
|
+
}, params) => params === !1 ? !1 : context.previewAccessSharingReadPermission?.granted === !0,
|
|
3184
|
+
"has preview mode without permissions": ({
|
|
3185
|
+
context
|
|
3186
|
+
}, params) => params === !1 ? !1 : context.previewAccessSharingReadPermission?.granted === !1 && context.previewUrlSecretPermission?.granted === !1
|
|
3187
|
+
},
|
|
3188
|
+
delays: {
|
|
3189
|
+
expiredSecret: ({
|
|
3190
|
+
context
|
|
3191
|
+
}) => {
|
|
3192
|
+
if (!context.previewUrlSecret?.expiresAt)
|
|
3193
|
+
return 0;
|
|
3194
|
+
const now = Date.now(), expiresAt = context.previewUrlSecret.expiresAt.getTime();
|
|
3195
|
+
return Math.max(expiresAt - now, 0);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
}).createMachine({
|
|
3199
|
+
// eslint-disable-next-line tsdoc/syntax
|
|
3200
|
+
/** @xstate-layout N4IgpgJg5mDOIC5QAUBOYBuBLMB3ABAKoBKAMgMRiqoD2qAdAA4A2AhgC4BmdAtvWphwESpBFgB2GGgGMOWGuIDaABgC6K1YlCMasLO3nitIAB6IArAA56AZgCcAdkcBGS8vMAmO+YBszgDQgAJ6Izs4+9M7KACzKztGWHg4OPubmAL7pgQLYeERklNR0TGxcvPzoucJkYpIycgqKzupqxjp6BgrGZggAtM520ZHRdjZjNjFe7oEhCGERUbHxicmpGVkgOUL5FFS0DCwc3Kh8W3kitVKynUoeLZpIIO36ht2IvV62Hl7elmE2lh83xmoXCkRicQSSRS5gSmWylW2IkK+xKR3KZ2qogkVwaShs9zauheXUePV6gPo3jSUyi-xBczBi0hKxh5mc8M2iPOBVgYHY+EY3IIfNYqGkAAtBWLWDwNESOq8yaCbM56A4bB5fGllHYvD4fAz4h56CNfG5LKqHMpLdFOZidvRJWBpABrCRQZBUHhYWB6BSwcjyx7PG5vPrs5TqjWqyyjTXRDwMjwxei68J2ZQ2nyWXN2jYOkT0dCwGjMbDiKAASXEL1YzEIqGY5AgCjA9BxNFd7cLZGLcDLFertYM9cbzEu9RuGmD2mJYeVfRGdipyh86Yc0XiE3MDK3JssIwcrmtPjGSXzCMEPNI-dL5Y9NbrDabKOKhzKJwq16xd8Hj5HLAxybSdrkMGdWhDeclVAclN3odlzBsKwBjSSxjwcZM7DVeJ1w8P4xmidk7HtYVHRLf9KwAQWYZgaFwZAOHYKhxEDVtxHbTtu2-KpyIHB9qNo+jGPYZjUFY0C8Qgh450VUlYPedkHHoHwnDSZDVOiGwfGiBlUhXXwwjsQYtKSYzSJ-Pj7yHGi6IYpiWMDPZ31KY5TjIosKIEqBbOEhzxNgSTpzUWcnmg+TTHePV6Hw3MYgzaItJ0hlYRNTNkLiHxBl1GILN4zz+KHccADFaB4TEAGUwDFSVGNQWUWzbDs6m43tby8oqm1KmhyuFKqaolOrZSC8CQsg2SSSMRdel8ZSNUTdlcw8M07AZQZrDXdaDRtUZnHWK98r7DqPRKsrKuq8VBplHg3wOVyMQ8o7CpOrqzr6i7auukbGjGmSwrkqaFL6MJlLiWFlC1EGty0hknAiXVVPMRx12UJwOQLR72ueytMQAWRoCAwEajjmqkVrMb-by8YJsBvqUX6FUm8Nem2+hbWPUZErGTcjS8NUJg8AE9T1ZwHHwvKkSe6yPWpwnic4lqewp46ceFfHCbpmdmkZhcgZmyxzFsDmTPcXUUiNRKDy3ZQJlVLSkYlm9KaHWWifYhWyaVyyCul1Wf3V2nOzAn71DuHWYMivovGsBxPCy74beWaJDWCUJzBSFTrUcQYdMzIFHd-FXPTVmn5dJrsvcOrHfeL-2ac1kKCXDiLyWcNKJiiHM-BtONwgtnMEM1DVNwhhI7B8AurMo2uqgD260U-dzval6fXYbwkoIB5moijLLkm5tvYRBo1nGQtND11ZaIdzEiMeX6vV5LuW+QFIVLNFS7pXquVxv+pnF1FtYP4OY7AG3QohJMqcEDeGUq4NwYQBhLEnkWWAABXaQ0g4CBhfoKMiH9JRf1lKFUMEceiizVPA0+7gtQQy8LzXU6obaJTFtEJwHhXDIL7G-WepccHcO2PgqUjBrrEPCoDSOFI3C2AGHtQ8sIiJJGTILZS7JRaeGSKw7CnDbz8LwAHJ06AOBgHOtIdA7Ay5cUrpLHRT92ymOqsxExZj16iK3gAqI6oaQ6QtE4YylhkynzmkCBGNgNR7VvgdaxTBbEGIccY969jzHOTuuiL8bVol10JrEoxTj+QuN-iQlu7xwjKX1P8bSTC0hGhcKaBIOZAQGkBKE7RGSeFZMMRACqEoxRgCohgrBFjFY8Sibo3A+iOldJ6X0zBfp8l-UKeIshjgqTGTiPYPaGotS7igd8QWtgsp6iQnFOEd8q6tKEOM6qnTunoGmQM5JC83LDKdqMy5rBrlTP6bMoOUkGab3-kDU+ERVEpnsEjDRVSdljBXKeQY3h5gOBaa8mmzt4k-nHIMz2zzfzIvaYVNFVRxxzObosxAfg1Q2jSOERIh5kIBNGKaNZ2lvjhFhEimJHUCVCAxQ8j8Tz0m4vbJyzERKfnBQ3hNXWkdyWeJsCMVhqNsK6mTO4Q2Q9DysLCEhDw7LMntjQV8wMJhYDsCMfQVgnAxIAAowAmEYFgdAnSXRmIAJTkAFTEg1MzYCuIBZHKYKlUiqWwrCMJkDZgDAYceRMfwUisPYZYTIGxxA03gI8NqJLmZ6msKqENcjErqIZL0cethvDGXLew9hiYWnOjdDLb0vp-SsUzdNcwEMEJ7WTohDMfgU4RpTCpUJnhYrHghuEFpRcnyjhfMwFtet2Q2FNOwsWZarBan8TsuMkRvhIzPJGDwmkWnJLnf6g0aZl0mQTURDdsxYiGwwsRIEgwEwTuxj5IS9lRKORPeSJCOF4XgrUZqbZsxwZszcJtbC4RUg2FfTXU6PVzoDSGjwH9ik-gxRGG4NtxkkZblhgyxIhFQG5lSPEODj89VoYjKqGKURkij0zImXSUCwiozZuDLUCQQY6tOVEr1WDqMsxNCkP4RFPBZj+I4I0qoRMODjIlceBzkK6raWAIT7DDZlNPhUuVkKI0pEXbHBISF1yAiIqpi5KL7E5ISWYoTna2b6Qg+DcFN7EAphLdpdOWVoPJ0RXxl5HKrmTNuYahzaQviaQPVERa8mlGeBUnnQyDStSwcCzi4L1kuV4HHNR4DCFdRaVVFSzcZ4VVIVsDEVhZ5QnWlYZZvRKLj3-KlT0FIKjVRZghkCXwqkjQGzVFxvOMisoWYy46QV9ABN+mo3mFZZ427lp032jzVa2bJGtCUtciak1AA */
|
|
3201
|
+
id: "Preview URL",
|
|
3202
|
+
context: ({
|
|
3203
|
+
input
|
|
3204
|
+
}) => ({
|
|
3205
|
+
initialUrl: null,
|
|
3206
|
+
previewUrl: null,
|
|
3207
|
+
error: null,
|
|
3208
|
+
allowOrigins: null,
|
|
3209
|
+
previewSearchParam: input.previewSearchParam,
|
|
3210
|
+
previewUrlSecret: null,
|
|
3211
|
+
previewAccessSharingCreatePermission: null,
|
|
3212
|
+
previewAccessSharingReadPermission: null,
|
|
3213
|
+
previewAccessSharingUpdatePermission: null,
|
|
3214
|
+
previewUrlSecretPermission: null,
|
|
3215
|
+
previewMode: null
|
|
3216
|
+
}),
|
|
3217
|
+
invoke: [{
|
|
3218
|
+
src: "check permission",
|
|
3219
|
+
input: () => ({
|
|
3220
|
+
checkPermissionName: "read",
|
|
3221
|
+
document: shareAccessSingletonDocument
|
|
3222
|
+
}),
|
|
3223
|
+
onError: {
|
|
3224
|
+
target: ".error",
|
|
3225
|
+
actions: {
|
|
3226
|
+
type: "assign error",
|
|
3227
|
+
params: ({
|
|
3228
|
+
event
|
|
3229
|
+
}) => ({
|
|
3230
|
+
message: "Failed to check permission",
|
|
3231
|
+
error: event.error
|
|
3232
|
+
})
|
|
3233
|
+
}
|
|
3234
|
+
},
|
|
3235
|
+
onSnapshot: {
|
|
3236
|
+
actions: assign({
|
|
3237
|
+
previewAccessSharingReadPermission: ({
|
|
3238
|
+
event
|
|
3239
|
+
}) => event.snapshot.context ?? null
|
|
3240
|
+
})
|
|
3241
|
+
}
|
|
3242
|
+
}, {
|
|
3243
|
+
src: "check permission",
|
|
3244
|
+
input: () => ({
|
|
3245
|
+
checkPermissionName: "create",
|
|
3246
|
+
document: shareAccessSingletonDocument
|
|
3247
|
+
}),
|
|
3248
|
+
onError: {
|
|
3249
|
+
target: ".error",
|
|
3250
|
+
actions: {
|
|
3251
|
+
type: "assign error",
|
|
3252
|
+
params: ({
|
|
3253
|
+
event
|
|
3254
|
+
}) => ({
|
|
3255
|
+
message: "Failed to check permission",
|
|
3256
|
+
error: event.error
|
|
3257
|
+
})
|
|
3258
|
+
}
|
|
3259
|
+
},
|
|
3260
|
+
onSnapshot: {
|
|
3261
|
+
actions: assign({
|
|
3262
|
+
previewAccessSharingCreatePermission: ({
|
|
3263
|
+
event
|
|
3264
|
+
}) => event.snapshot.context ?? null
|
|
3265
|
+
})
|
|
3266
|
+
}
|
|
3267
|
+
}, {
|
|
3268
|
+
src: "check permission",
|
|
3269
|
+
input: () => ({
|
|
3270
|
+
checkPermissionName: "update",
|
|
3271
|
+
document: shareAccessSingletonDocument
|
|
3272
|
+
}),
|
|
3273
|
+
onError: {
|
|
3274
|
+
target: ".error",
|
|
3275
|
+
actions: {
|
|
3276
|
+
type: "assign error",
|
|
3277
|
+
params: ({
|
|
3278
|
+
event
|
|
3279
|
+
}) => ({
|
|
3280
|
+
message: "Failed to check permission",
|
|
3281
|
+
error: event.error
|
|
3282
|
+
})
|
|
3283
|
+
}
|
|
3284
|
+
},
|
|
3285
|
+
onSnapshot: {
|
|
3286
|
+
actions: assign({
|
|
3287
|
+
previewAccessSharingUpdatePermission: ({
|
|
3288
|
+
event
|
|
3289
|
+
}) => event.snapshot.context ?? null
|
|
3290
|
+
})
|
|
3291
|
+
}
|
|
3292
|
+
}, {
|
|
3293
|
+
src: "check permission",
|
|
3294
|
+
input: () => ({
|
|
3295
|
+
checkPermissionName: "create",
|
|
3296
|
+
document: previewUrlSecretDocument
|
|
3297
|
+
}),
|
|
3298
|
+
onError: {
|
|
3299
|
+
target: ".error",
|
|
3300
|
+
actions: {
|
|
3301
|
+
type: "assign error",
|
|
3302
|
+
params: ({
|
|
3303
|
+
event
|
|
3304
|
+
}) => ({
|
|
3305
|
+
message: "Failed to check permission",
|
|
3306
|
+
error: event.error
|
|
3307
|
+
})
|
|
3308
|
+
}
|
|
3309
|
+
},
|
|
3310
|
+
onSnapshot: {
|
|
3311
|
+
actions: assign({
|
|
3312
|
+
previewUrlSecretPermission: ({
|
|
3313
|
+
event
|
|
3314
|
+
}) => event.snapshot.context ?? null
|
|
3315
|
+
})
|
|
3316
|
+
}
|
|
3317
|
+
}],
|
|
3318
|
+
on: {
|
|
3319
|
+
"set preview search param": {
|
|
3320
|
+
actions: {
|
|
3321
|
+
type: "assign preview search param",
|
|
3322
|
+
params: ({
|
|
3323
|
+
event
|
|
3324
|
+
}) => ({
|
|
3325
|
+
previewSearchParam: event.previewSearchParam
|
|
3326
|
+
})
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
},
|
|
3330
|
+
states: {
|
|
3331
|
+
checkingPermissions: {
|
|
3332
|
+
always: {
|
|
3333
|
+
guard: "has checked permissions",
|
|
3334
|
+
target: "resolvingInitialUrl"
|
|
3335
|
+
},
|
|
3336
|
+
tags: "busy"
|
|
3337
|
+
},
|
|
3338
|
+
resolvingInitialUrl: {
|
|
3339
|
+
invoke: {
|
|
3340
|
+
src: "resolve initial url",
|
|
3341
|
+
input: ({
|
|
3342
|
+
context
|
|
3343
|
+
}) => ({
|
|
3344
|
+
previewSearchParam: context.previewSearchParam
|
|
3345
|
+
}),
|
|
3346
|
+
onError: {
|
|
3347
|
+
target: "error",
|
|
3348
|
+
actions: {
|
|
3349
|
+
type: "assign error",
|
|
3350
|
+
params: ({
|
|
3351
|
+
event
|
|
3352
|
+
}) => ({
|
|
3353
|
+
message: "Failed to resolve initial url",
|
|
3354
|
+
error: event.error
|
|
3355
|
+
})
|
|
3356
|
+
}
|
|
3357
|
+
},
|
|
3358
|
+
onDone: {
|
|
3359
|
+
target: "resolvingAllowPatterns",
|
|
3360
|
+
actions: assign({
|
|
3361
|
+
initialUrl: ({
|
|
3362
|
+
event
|
|
3363
|
+
}) => event.output
|
|
3364
|
+
})
|
|
3365
|
+
}
|
|
3366
|
+
},
|
|
3367
|
+
tags: "busy"
|
|
3368
|
+
},
|
|
3369
|
+
error: {
|
|
3370
|
+
type: "final",
|
|
3371
|
+
tags: "error"
|
|
3372
|
+
},
|
|
3373
|
+
resolvingAllowPatterns: {
|
|
3374
|
+
invoke: {
|
|
3375
|
+
src: "resolve allow patterns",
|
|
3376
|
+
input: ({
|
|
3377
|
+
context
|
|
3378
|
+
}) => ({
|
|
3379
|
+
initialUrl: context.initialUrl
|
|
3380
|
+
}),
|
|
3381
|
+
onError: {
|
|
3382
|
+
target: "error",
|
|
3383
|
+
actions: {
|
|
3384
|
+
type: "assign error",
|
|
3385
|
+
params: ({
|
|
3386
|
+
event
|
|
3387
|
+
}) => ({
|
|
3388
|
+
message: "Failed to resolve preview url allow patterns",
|
|
3389
|
+
error: event.error
|
|
3390
|
+
})
|
|
3391
|
+
}
|
|
3392
|
+
},
|
|
3393
|
+
onDone: {
|
|
3394
|
+
target: "resolvingUrlFromPreviewSearchParam",
|
|
3395
|
+
actions: assign({
|
|
3396
|
+
allowOrigins: ({
|
|
3397
|
+
event
|
|
3398
|
+
}) => event.output
|
|
3399
|
+
})
|
|
3400
|
+
}
|
|
3401
|
+
},
|
|
3402
|
+
tags: ["busy"]
|
|
3403
|
+
},
|
|
3404
|
+
resolvingUrlFromPreviewSearchParam: {
|
|
3405
|
+
id: "loop",
|
|
3406
|
+
invoke: {
|
|
3407
|
+
src: "resolve url from preview search param",
|
|
3408
|
+
input: ({
|
|
3409
|
+
context
|
|
3410
|
+
}) => ({
|
|
3411
|
+
initialUrl: context.initialUrl,
|
|
3412
|
+
allowOrigins: context.allowOrigins,
|
|
3413
|
+
previewSearchParam: context.previewSearchParam
|
|
3414
|
+
}),
|
|
3415
|
+
onError: {
|
|
3416
|
+
target: "error",
|
|
3417
|
+
actions: {
|
|
3418
|
+
type: "assign error",
|
|
3419
|
+
params: ({
|
|
3420
|
+
event
|
|
3421
|
+
}) => ({
|
|
3422
|
+
message: "Failed to resolve preview url from search param",
|
|
3423
|
+
error: event.error
|
|
3424
|
+
})
|
|
3425
|
+
}
|
|
3426
|
+
},
|
|
3427
|
+
onDone: {
|
|
3428
|
+
target: "resolvingPreviewMode",
|
|
3429
|
+
actions: assign({
|
|
3430
|
+
initialUrl: ({
|
|
3431
|
+
event
|
|
3432
|
+
}) => event.output
|
|
3433
|
+
})
|
|
3434
|
+
}
|
|
3435
|
+
},
|
|
3436
|
+
tags: ["busy"]
|
|
3437
|
+
},
|
|
3438
|
+
resolvingPreviewMode: {
|
|
3439
|
+
on: {
|
|
3440
|
+
"set preview search param": {
|
|
3441
|
+
guard: "search param has new origin",
|
|
3442
|
+
actions: {
|
|
3443
|
+
type: "assign preview search param",
|
|
3444
|
+
params: ({
|
|
3445
|
+
event
|
|
3446
|
+
}) => ({
|
|
3447
|
+
previewSearchParam: event.previewSearchParam
|
|
3448
|
+
})
|
|
3449
|
+
},
|
|
3450
|
+
target: "#loop",
|
|
3451
|
+
reenter: !0
|
|
3452
|
+
}
|
|
3453
|
+
},
|
|
3454
|
+
invoke: {
|
|
3455
|
+
src: "resolve preview mode",
|
|
3456
|
+
input: ({
|
|
3457
|
+
context
|
|
3458
|
+
}) => ({
|
|
3459
|
+
targetOrigin: context.initialUrl.origin
|
|
3460
|
+
}),
|
|
3461
|
+
onError: {
|
|
3462
|
+
target: "error",
|
|
3463
|
+
actions: {
|
|
3464
|
+
type: "assign error",
|
|
3465
|
+
params: ({
|
|
3466
|
+
event
|
|
3467
|
+
}) => ({
|
|
3468
|
+
message: "Failed to resolve preview url allow patterns",
|
|
3469
|
+
error: event.error
|
|
3470
|
+
})
|
|
3471
|
+
}
|
|
3472
|
+
},
|
|
3473
|
+
onDone: [{
|
|
3474
|
+
guard: {
|
|
3475
|
+
type: "has preview mode with created secret",
|
|
3476
|
+
params: ({
|
|
3477
|
+
event
|
|
3478
|
+
}) => event.output
|
|
3479
|
+
},
|
|
3480
|
+
actions: assign({
|
|
3481
|
+
previewMode: ({
|
|
3482
|
+
event
|
|
3483
|
+
}) => event.output
|
|
3484
|
+
}),
|
|
3485
|
+
target: "previewMode.createPreviewSecret"
|
|
3486
|
+
}, {
|
|
3487
|
+
guard: {
|
|
3488
|
+
type: "has preview mode with share access",
|
|
3489
|
+
params: ({
|
|
3490
|
+
event
|
|
3491
|
+
}) => event.output
|
|
3492
|
+
},
|
|
3493
|
+
actions: assign({
|
|
3494
|
+
previewMode: ({
|
|
3495
|
+
event
|
|
3496
|
+
}) => event.output
|
|
3497
|
+
}),
|
|
3498
|
+
target: "previewMode.readShareAccess"
|
|
3499
|
+
}, {
|
|
3500
|
+
guard: {
|
|
3501
|
+
type: "has preview mode without permissions",
|
|
3502
|
+
params: ({
|
|
3503
|
+
event
|
|
3504
|
+
}) => event.output
|
|
3505
|
+
},
|
|
3506
|
+
actions: [assign({
|
|
3507
|
+
previewUrl: ({
|
|
3508
|
+
context
|
|
3509
|
+
}) => context.initialUrl
|
|
3510
|
+
}), "notify preview will likely fail"],
|
|
3511
|
+
target: "success"
|
|
3512
|
+
}, {
|
|
3513
|
+
actions: assign({
|
|
3514
|
+
previewUrl: ({
|
|
3515
|
+
context
|
|
3516
|
+
}) => context.initialUrl
|
|
3517
|
+
}),
|
|
3518
|
+
target: "success"
|
|
3519
|
+
}]
|
|
3520
|
+
},
|
|
3521
|
+
tags: ["busy"]
|
|
3522
|
+
},
|
|
3523
|
+
success: {
|
|
3524
|
+
on: {
|
|
3525
|
+
"set preview search param": {
|
|
3526
|
+
guard: "search param has new origin",
|
|
3527
|
+
actions: {
|
|
3528
|
+
type: "assign preview search param",
|
|
3529
|
+
params: ({
|
|
3530
|
+
event
|
|
3531
|
+
}) => ({
|
|
3532
|
+
previewSearchParam: event.previewSearchParam
|
|
3533
|
+
})
|
|
3534
|
+
},
|
|
3535
|
+
target: "#loop",
|
|
3536
|
+
reenter: !0
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
},
|
|
3540
|
+
previewMode: {
|
|
3541
|
+
on: {
|
|
3542
|
+
"set preview search param": {
|
|
3543
|
+
guard: "search param has new origin",
|
|
3544
|
+
actions: {
|
|
3545
|
+
type: "assign preview search param",
|
|
3546
|
+
params: ({
|
|
3547
|
+
event
|
|
3548
|
+
}) => ({
|
|
3549
|
+
previewSearchParam: event.previewSearchParam
|
|
3550
|
+
})
|
|
3551
|
+
},
|
|
3552
|
+
target: "#loop",
|
|
3553
|
+
reenter: !0
|
|
3554
|
+
}
|
|
3555
|
+
},
|
|
3556
|
+
states: {
|
|
3557
|
+
createPreviewSecret: {
|
|
3558
|
+
invoke: {
|
|
3559
|
+
src: "create preview secret",
|
|
3560
|
+
onError: {
|
|
3561
|
+
target: "error",
|
|
3562
|
+
actions: {
|
|
3563
|
+
type: "assign error",
|
|
3564
|
+
params: ({
|
|
3565
|
+
event
|
|
3566
|
+
}) => ({
|
|
3567
|
+
message: "Failed to create preview secret",
|
|
3568
|
+
error: event.error
|
|
3569
|
+
})
|
|
3570
|
+
}
|
|
3571
|
+
},
|
|
3572
|
+
onDone: {
|
|
3573
|
+
target: "resolvePreviewUrl",
|
|
3574
|
+
actions: assign({
|
|
3575
|
+
previewUrlSecret: ({
|
|
3576
|
+
event
|
|
3577
|
+
}) => event.output
|
|
3578
|
+
})
|
|
3579
|
+
}
|
|
3580
|
+
},
|
|
3581
|
+
tags: ["busy"]
|
|
3582
|
+
},
|
|
3583
|
+
readShareAccess: {
|
|
3584
|
+
invoke: {
|
|
3585
|
+
src: "read shared preview secret",
|
|
3586
|
+
onError: {
|
|
3587
|
+
target: "error",
|
|
3588
|
+
actions: {
|
|
3589
|
+
type: "assign error",
|
|
3590
|
+
params: ({
|
|
3591
|
+
event
|
|
3592
|
+
}) => ({
|
|
3593
|
+
message: "Failed to read shared preview secret",
|
|
3594
|
+
error: event.error
|
|
3595
|
+
})
|
|
3596
|
+
}
|
|
3597
|
+
},
|
|
3598
|
+
onDone: {
|
|
3599
|
+
target: "resolvePreviewUrl",
|
|
3600
|
+
actions: assign({
|
|
3601
|
+
previewUrlSecret: ({
|
|
3602
|
+
event
|
|
3603
|
+
}) => ({
|
|
3604
|
+
secret: event.output,
|
|
3605
|
+
expiresAt: new Date(Date.now() + 1e3 * 60 * 60 * 60 * 24)
|
|
3606
|
+
})
|
|
3607
|
+
})
|
|
3608
|
+
}
|
|
3609
|
+
},
|
|
3610
|
+
tags: ["busy"]
|
|
3611
|
+
},
|
|
3612
|
+
resolvePreviewUrl: {
|
|
3613
|
+
invoke: {
|
|
3614
|
+
src: "resolve preview mode url",
|
|
3615
|
+
input: ({
|
|
3616
|
+
context
|
|
3617
|
+
}) => ({
|
|
3618
|
+
initialUrl: context.initialUrl,
|
|
3619
|
+
resolvedPreviewMode: context.previewMode,
|
|
3620
|
+
previewUrlSecret: context.previewUrlSecret.secret
|
|
3621
|
+
}),
|
|
3622
|
+
onError: {
|
|
3623
|
+
target: "error",
|
|
3624
|
+
actions: {
|
|
3625
|
+
type: "assign error",
|
|
3626
|
+
params: ({
|
|
3627
|
+
event
|
|
3628
|
+
}) => ({
|
|
3629
|
+
message: "Failed to resolve preview url",
|
|
3630
|
+
error: event.error
|
|
3631
|
+
})
|
|
3632
|
+
}
|
|
3633
|
+
},
|
|
3634
|
+
onDone: {
|
|
3635
|
+
target: "success",
|
|
3636
|
+
actions: assign({
|
|
3637
|
+
previewUrl: ({
|
|
3638
|
+
event
|
|
3639
|
+
}) => event.output
|
|
3640
|
+
})
|
|
3641
|
+
}
|
|
3642
|
+
},
|
|
3643
|
+
tags: ["busy"]
|
|
3644
|
+
},
|
|
3645
|
+
error: {
|
|
3646
|
+
type: "final",
|
|
3647
|
+
tags: ["error"]
|
|
3648
|
+
},
|
|
3649
|
+
success: {
|
|
3650
|
+
after: {
|
|
3651
|
+
expiredSecret: {
|
|
3652
|
+
guard: "can create preview secret",
|
|
3653
|
+
actions: assign({
|
|
3654
|
+
previewUrlSecret: null
|
|
3655
|
+
}),
|
|
3656
|
+
target: "createPreviewSecret",
|
|
3657
|
+
reenter: !0
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
},
|
|
3662
|
+
initial: "readShareAccess"
|
|
3663
|
+
}
|
|
3664
|
+
},
|
|
3665
|
+
initial: "checkingPermissions"
|
|
3666
|
+
});
|
|
3667
|
+
function usePreviewUrlActorRef(previewUrlOption, allowOption) {
|
|
3668
|
+
const $ = c(25), grantsStore = useGrantsStore();
|
|
3669
|
+
let t0;
|
|
3670
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
3671
|
+
apiVersion: API_VERSION
|
|
3672
|
+
}, $[0] = t0) : t0 = $[0];
|
|
3673
|
+
const client = useClient(t0), currentUserId = useCurrentUser()?.id, studioBasePath = useActiveWorkspace()?.activeWorkspace?.basePath || "/", router = useRouter();
|
|
3674
|
+
let t1;
|
|
3675
|
+
$[1] !== router.state._searchParams ? (t1 = new URLSearchParams(router.state._searchParams).get("preview"), $[1] = router.state._searchParams, $[2] = t1) : t1 = $[2];
|
|
3676
|
+
const previewSearchParam = t1, {
|
|
3677
|
+
push: pushToast
|
|
3678
|
+
} = useToast(), {
|
|
3679
|
+
t
|
|
3680
|
+
} = useTranslation(presentationLocaleNamespace);
|
|
3681
|
+
let t2;
|
|
3682
|
+
$[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
3683
|
+
scheduledDraft: void 0
|
|
3684
|
+
}, $[3] = t2) : t2 = $[3];
|
|
3685
|
+
const perspective = usePresentationPerspective(t2);
|
|
3686
|
+
let t3;
|
|
3687
|
+
if ($[4] !== allowOption || $[5] !== client || $[6] !== currentUserId || $[7] !== grantsStore || $[8] !== perspective || $[9] !== previewUrlOption || $[10] !== pushToast || $[11] !== studioBasePath || $[12] !== t) {
|
|
3688
|
+
let t42;
|
|
3689
|
+
$[14] !== pushToast || $[15] !== t ? (t42 = () => pushToast({
|
|
3690
|
+
id: "preview-url-secret.missing-grants",
|
|
3691
|
+
closable: !0,
|
|
3692
|
+
status: "error",
|
|
3693
|
+
duration: 1 / 0,
|
|
3694
|
+
title: t("preview-url-secret.missing-grants")
|
|
3695
|
+
}), $[14] = pushToast, $[15] = t, $[16] = t42) : t42 = $[16];
|
|
3696
|
+
let t52;
|
|
3697
|
+
$[17] !== grantsStore ? (t52 = (t62) => {
|
|
3698
|
+
const {
|
|
3699
|
+
input
|
|
3700
|
+
} = t62;
|
|
3701
|
+
return grantsStore.checkDocumentPermission(input.checkPermissionName, input.document);
|
|
3702
|
+
}, $[17] = grantsStore, $[18] = t52) : t52 = $[18], t3 = previewUrlMachine.provide({
|
|
3703
|
+
actions: {
|
|
3704
|
+
"notify preview will likely fail": t42
|
|
3705
|
+
},
|
|
3706
|
+
actors: {
|
|
3707
|
+
"create preview secret": defineCreatePreviewSecretActor({
|
|
3708
|
+
client,
|
|
3709
|
+
currentUserId
|
|
3710
|
+
}),
|
|
3711
|
+
"read shared preview secret": defineReadSharedSecretActor({
|
|
3712
|
+
client
|
|
3713
|
+
}),
|
|
3714
|
+
"resolve allow patterns": defineResolveAllowPatternsActor({
|
|
3715
|
+
client,
|
|
3716
|
+
allowOption
|
|
3717
|
+
}),
|
|
3718
|
+
"resolve initial url": defineResolveInitialUrlActor({
|
|
3719
|
+
client,
|
|
3720
|
+
studioBasePath,
|
|
3721
|
+
previewUrlOption,
|
|
3722
|
+
perspective
|
|
3723
|
+
}),
|
|
3724
|
+
"resolve preview mode": defineResolvePreviewModeActor({
|
|
3725
|
+
client,
|
|
3726
|
+
previewUrlOption
|
|
3727
|
+
}),
|
|
3728
|
+
"resolve preview mode url": defineResolvePreviewModeUrlActor({
|
|
3729
|
+
client,
|
|
3730
|
+
studioBasePath,
|
|
3731
|
+
previewUrlOption,
|
|
3732
|
+
perspective
|
|
3733
|
+
}),
|
|
3734
|
+
"check permission": fromObservable(t52)
|
|
3735
|
+
}
|
|
3736
|
+
}), $[4] = allowOption, $[5] = client, $[6] = currentUserId, $[7] = grantsStore, $[8] = perspective, $[9] = previewUrlOption, $[10] = pushToast, $[11] = studioBasePath, $[12] = t, $[13] = t3;
|
|
3737
|
+
} else
|
|
3738
|
+
t3 = $[13];
|
|
3739
|
+
let t4;
|
|
3740
|
+
$[19] !== previewSearchParam ? (t4 = {
|
|
3741
|
+
input: {
|
|
3742
|
+
previewSearchParam
|
|
3743
|
+
}
|
|
3744
|
+
}, $[19] = previewSearchParam, $[20] = t4) : t4 = $[20];
|
|
3745
|
+
const actorRef = useActorRef(t3, t4);
|
|
3746
|
+
let t5, t6;
|
|
3747
|
+
$[21] !== actorRef || $[22] !== previewSearchParam ? (t5 = () => {
|
|
3748
|
+
actorRef.send({
|
|
3749
|
+
type: "set preview search param",
|
|
3750
|
+
previewSearchParam
|
|
3751
|
+
});
|
|
3752
|
+
}, t6 = [actorRef, previewSearchParam], $[21] = actorRef, $[22] = previewSearchParam, $[23] = t5, $[24] = t6) : (t5 = $[23], t6 = $[24]), useEffect(t5, t6);
|
|
3753
|
+
const error = useSelector(actorRef, _temp$3);
|
|
3754
|
+
if (error)
|
|
3755
|
+
throw error;
|
|
3756
|
+
return actorRef;
|
|
3757
|
+
}
|
|
3758
|
+
function _temp$3(state) {
|
|
3759
|
+
return state.status === "error" ? state.error : state.hasTag("error") ? state.context.error : null;
|
|
3760
|
+
}
|
|
3761
|
+
function useReportInvalidPreviewSearchParam(previewUrlRef) {
|
|
3762
|
+
const $ = c(9), {
|
|
3763
|
+
t
|
|
3764
|
+
} = useTranslation(presentationLocaleNamespace), {
|
|
3765
|
+
push: pushToast
|
|
3766
|
+
} = useToast(), router = useRouter();
|
|
3767
|
+
let t0;
|
|
3768
|
+
$[0] !== router.state._searchParams ? (t0 = new URLSearchParams(router.state._searchParams).get("preview"), $[0] = router.state._searchParams, $[1] = t0) : t0 = $[1];
|
|
3769
|
+
const previewSearchParam = t0, allowOrigins = useSelector(previewUrlRef, _temp$2), currentOrigin = useSelector(previewUrlRef, _temp2$1);
|
|
3770
|
+
let t1, t2;
|
|
3771
|
+
$[2] !== allowOrigins || $[3] !== currentOrigin || $[4] !== previewSearchParam || $[5] !== pushToast || $[6] !== t ? (t1 = () => {
|
|
3772
|
+
if (!Array.isArray(allowOrigins) || !previewSearchParam || !currentOrigin)
|
|
3773
|
+
return;
|
|
3774
|
+
const nextOrigin = new URL(previewSearchParam, currentOrigin).origin;
|
|
3775
|
+
allowOrigins.some((pattern) => pattern.test(nextOrigin)) || pushToast({
|
|
3776
|
+
closable: !0,
|
|
3777
|
+
id: `presentation-iframe-origin-mismatch-${nextOrigin}`,
|
|
3778
|
+
status: "error",
|
|
3779
|
+
duration: 1 / 0,
|
|
3780
|
+
title: t("preview-search-param.configuration.error.title"),
|
|
3781
|
+
description: /* @__PURE__ */ jsx(Translate, { t, i18nKey: "preview-search-param.configuration.error.description", components: {
|
|
3782
|
+
Code: "code"
|
|
3783
|
+
}, values: {
|
|
3784
|
+
previewSearchParam,
|
|
3785
|
+
blockedOrigin: nextOrigin
|
|
3786
|
+
} })
|
|
3787
|
+
});
|
|
3788
|
+
}, t2 = [allowOrigins, currentOrigin, previewSearchParam, pushToast, t], $[2] = allowOrigins, $[3] = currentOrigin, $[4] = previewSearchParam, $[5] = pushToast, $[6] = t, $[7] = t1, $[8] = t2) : (t1 = $[7], t2 = $[8]), useEffect(t1, t2);
|
|
3789
|
+
}
|
|
3790
|
+
function _temp2$1(state_0) {
|
|
3791
|
+
return state_0.context.previewUrl?.origin;
|
|
3792
|
+
}
|
|
3793
|
+
function _temp$2(state) {
|
|
3794
|
+
return state.context.allowOrigins;
|
|
3795
|
+
}
|
|
3796
|
+
function useVercelBypassSecret() {
|
|
3797
|
+
const $ = c(7);
|
|
3798
|
+
let t0;
|
|
3799
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
3800
|
+
apiVersion: API_VERSION
|
|
3801
|
+
}, $[0] = t0) : t0 = $[0];
|
|
3802
|
+
const client = useClient(t0), [vercelProtectionBypassReadyState, ready] = useReducer(_temp$1, "loading"), [vercelProtectionBypassSecret, setVercelProtectionBypassSecret] = useState(null);
|
|
3803
|
+
let t1, t2;
|
|
3804
|
+
$[1] !== client ? (t1 = () => {
|
|
3805
|
+
const unsubscribe = subscribeToVercelProtectionBypass(client, (secret) => {
|
|
3806
|
+
setVercelProtectionBypassSecret(secret), ready();
|
|
3807
|
+
});
|
|
3808
|
+
return () => unsubscribe();
|
|
3809
|
+
}, t2 = [client], $[1] = client, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2);
|
|
3810
|
+
let t3;
|
|
3811
|
+
return $[4] !== vercelProtectionBypassReadyState || $[5] !== vercelProtectionBypassSecret ? (t3 = [vercelProtectionBypassSecret, vercelProtectionBypassReadyState], $[4] = vercelProtectionBypassReadyState, $[5] = vercelProtectionBypassSecret, $[6] = t3) : t3 = $[6], t3;
|
|
3812
|
+
}
|
|
3813
|
+
function _temp$1() {
|
|
3814
|
+
return "ready";
|
|
3815
|
+
}
|
|
3816
|
+
function PresentationToolGrantsCheck(t0) {
|
|
3817
|
+
const $ = c(8), {
|
|
3818
|
+
tool
|
|
3819
|
+
} = t0, previewUrlRef = usePreviewUrlActorRef(tool.options?.previewUrl, tool.options?.allowOrigins);
|
|
3820
|
+
useReportInvalidPreviewSearchParam(previewUrlRef);
|
|
3821
|
+
const previewAccessSharingCreatePermission = useSelector(previewUrlRef, _temp), previewAccessSharingUpdatePermission = useSelector(previewUrlRef, _temp2), previewAccessSharingReadPermission = useSelector(previewUrlRef, _temp3), previewUrlSecretPermission = useSelector(previewUrlRef, _temp4), url = useSelector(previewUrlRef, _temp5), [vercelProtectionBypass, vercelProtectionBypassReadyState] = useVercelBypassSecret();
|
|
3822
|
+
if (!url || vercelProtectionBypassReadyState === "loading" || !previewAccessSharingCreatePermission || typeof previewAccessSharingCreatePermission.granted > "u" || !previewAccessSharingUpdatePermission || typeof previewAccessSharingUpdatePermission.granted > "u" || !previewUrlSecretPermission || !previewAccessSharingReadPermission || typeof previewAccessSharingReadPermission.granted > "u" || typeof previewUrlSecretPermission.granted > "u") {
|
|
3823
|
+
let t12;
|
|
3824
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[0] = t12) : t12 = $[0], t12;
|
|
3825
|
+
}
|
|
3826
|
+
const t1 = !!previewAccessSharingCreatePermission?.granted && !!previewAccessSharingUpdatePermission?.granted, t2 = !!previewAccessSharingReadPermission?.granted;
|
|
3827
|
+
let t3;
|
|
3828
|
+
return $[1] !== previewUrlRef || $[2] !== t1 || $[3] !== t2 || $[4] !== tool || $[5] !== url || $[6] !== vercelProtectionBypass ? (t3 = /* @__PURE__ */ jsx(PresentationTool, { tool, initialPreviewUrl: url, vercelProtectionBypass, canToggleSharePreviewAccess: t1, canUseSharedPreviewAccess: t2, previewUrlRef }), $[1] = previewUrlRef, $[2] = t1, $[3] = t2, $[4] = tool, $[5] = url, $[6] = vercelProtectionBypass, $[7] = t3) : t3 = $[7], t3;
|
|
3829
|
+
}
|
|
3830
|
+
function _temp5(state_3) {
|
|
3831
|
+
return state_3.context.previewUrl;
|
|
3832
|
+
}
|
|
3833
|
+
function _temp4(state_2) {
|
|
3834
|
+
return state_2.context.previewUrlSecretPermission;
|
|
3835
|
+
}
|
|
3836
|
+
function _temp3(state_1) {
|
|
3837
|
+
return state_1.context.previewAccessSharingReadPermission;
|
|
3838
|
+
}
|
|
3839
|
+
function _temp2(state_0) {
|
|
3840
|
+
return state_0.context.previewAccessSharingUpdatePermission;
|
|
3841
|
+
}
|
|
3842
|
+
function _temp(state) {
|
|
3843
|
+
return state.context.previewAccessSharingCreatePermission;
|
|
3844
|
+
}
|
|
3845
|
+
export {
|
|
3846
|
+
PresentationToolGrantsCheck as default
|
|
3847
|
+
};
|
|
3848
|
+
//# sourceMappingURL=PresentationToolGrantsCheck.js.map
|