@sanity/vision 4.19.0 → 4.19.1-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2042 +0,0 @@
1
- "use strict";
2
- var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), react = require("react"), reactSplitPane = require("@rexxars/react-split-pane"), icons = require("@sanity/icons"), isHotkeyEsm = require("is-hotkey-esm"), useEffectEvent = require("use-effect-event"), CodeMirror = require("@uiw/react-codemirror"), autocomplete = require("@codemirror/autocomplete"), commands = require("@codemirror/commands"), langJavascript = require("@codemirror/lang-javascript"), language = require("@codemirror/language"), search = require("@codemirror/search"), view = require("@codemirror/view"), highlight = require("@lezer/highlight"), color = require("@sanity/color"), styledComponents = require("styled-components"), index = require("./index.js"), debounce = require("lodash/debounce.js"), JSON5 = require("json5"), isEqual = require("lodash/isEqual.js"), uuid = require("@sanity/uuid"), operators = require("rxjs/operators"), json2Csv = require("json-2-csv"), reactJsonInspector = require("@rexxars/react-json-inspector"), LRU = require("quick-lru"), router = require("sanity/router"), reactRx = require("react-rx"), rxjs = require("rxjs");
3
- function _interopDefaultCompat(e) {
4
- return e && typeof e == "object" && "default" in e ? e : { default: e };
5
- }
6
- var CodeMirror__default = /* @__PURE__ */ _interopDefaultCompat(CodeMirror), debounce__default = /* @__PURE__ */ _interopDefaultCompat(debounce), JSON5__default = /* @__PURE__ */ _interopDefaultCompat(JSON5), isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual), LRU__default = /* @__PURE__ */ _interopDefaultCompat(LRU);
7
- const API_VERSIONS = ["v1", "vX", "v2021-03-25", "v2021-10-21", "v2022-03-07", "v2025-02-19", `v${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`], [DEFAULT_API_VERSION] = API_VERSIONS.slice(-1);
8
- function DelayedSpinner(props) {
9
- const $ = reactCompilerRuntime.c(5), [show, setShow] = react.useState(!1);
10
- let t0, t1;
11
- $[0] !== props.delay ? (t0 = () => {
12
- const timer = setTimeout(() => setShow(!0), props.delay || 500);
13
- return () => clearTimeout(timer);
14
- }, t1 = [props.delay], $[0] = props.delay, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), react.useEffect(t0, t1);
15
- let t2;
16
- return $[3] !== show ? (t2 = show ? /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { muted: !0, size: 4 }) : null, $[3] = show, $[4] = t2) : t2 = $[4], t2;
17
- }
18
- const codemirrorExtensions = [[langJavascript.javascriptLanguage], view.lineNumbers(), view.highlightActiveLine(), view.highlightActiveLineGutter(), search.highlightSelectionMatches(), view.highlightSpecialChars(), language.indentOnInput(), language.bracketMatching(), autocomplete.closeBrackets(), commands.history(), view.drawSelection(), language.syntaxHighlighting(language.defaultHighlightStyle, {
19
- fallback: !0
20
- }), view.keymap.of([
21
- // Override the default keymap for Mod-Enter to not insert a new line, we have a custom event handler for executing queries
22
- {
23
- key: "Mod-Enter",
24
- run: () => !0
25
- },
26
- // Add the default keymap and history keymap
27
- commands.defaultKeymap,
28
- commands.historyKeymap
29
- ].flat().filter(Boolean))];
30
- function useCodemirrorTheme(theme) {
31
- const $ = reactCompilerRuntime.c(7);
32
- let t0;
33
- $[0] !== theme ? (t0 = createTheme(theme), $[0] = theme, $[1] = t0) : t0 = $[1];
34
- const cmTheme = t0;
35
- let t1;
36
- $[2] !== theme ? (t1 = language.syntaxHighlighting(createHighlight(theme)), $[2] = theme, $[3] = t1) : t1 = $[3];
37
- const cmHighlight = t1;
38
- let t2;
39
- return $[4] !== cmHighlight || $[5] !== cmTheme ? (t2 = [cmTheme, cmHighlight], $[4] = cmHighlight, $[5] = cmTheme, $[6] = t2) : t2 = $[6], t2;
40
- }
41
- function createTheme(theme) {
42
- const {
43
- color: color$1,
44
- fonts
45
- } = theme.sanity, card = color$1.card.enabled, cursor = color.hues.blue[color$1.dark ? 400 : 500].hex, selection = color.hues.gray[theme.sanity.color.dark ? 900 : 100].hex;
46
- return view.EditorView.theme({
47
- "&": {
48
- color: card.fg,
49
- backgroundColor: card.bg
50
- },
51
- ".cm-content": {
52
- caretColor: cursor
53
- },
54
- ".cm-editor": {
55
- fontFamily: fonts.code.family,
56
- fontSize: ui.rem(fonts.code.sizes[1].fontSize),
57
- lineHeight: "inherit"
58
- },
59
- ".cm-cursor, .cm-dropCursor": {
60
- borderLeftColor: cursor
61
- },
62
- "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": {
63
- backgroundColor: selection
64
- },
65
- ".cm-panels": {
66
- backgroundColor: card.bg,
67
- color: card.fg
68
- },
69
- ".cm-panels.cm-panels-top": {
70
- borderBottom: `2px solid ${card.border}`
71
- },
72
- ".cm-panels.cm-panels-bottom": {
73
- borderTop: `2px solid ${card.border}`
74
- }
75
- }, {
76
- dark: color$1.dark
77
- });
78
- }
79
- function createHighlight(theme) {
80
- const c = theme.sanity.color.base, s = theme.sanity.color.syntax;
81
- return language.HighlightStyle.define([{
82
- tag: highlight.tags.keyword,
83
- color: s.keyword
84
- }, {
85
- tag: [highlight.tags.propertyName, highlight.tags.name, highlight.tags.deleted, highlight.tags.character, highlight.tags.macroName],
86
- color: s.property
87
- }, {
88
- tag: [highlight.tags.function(highlight.tags.variableName), highlight.tags.labelName],
89
- color: s.function
90
- }, {
91
- tag: [highlight.tags.color, highlight.tags.constant(highlight.tags.name), highlight.tags.standard(highlight.tags.name)],
92
- color: s.variable
93
- }, {
94
- tag: [highlight.tags.definition(highlight.tags.name), highlight.tags.separator],
95
- color: s.constant
96
- }, {
97
- tag: [highlight.tags.typeName, highlight.tags.className, highlight.tags.number, highlight.tags.changed, highlight.tags.annotation, highlight.tags.modifier, highlight.tags.self, highlight.tags.namespace],
98
- color: s.number
99
- }, {
100
- tag: [highlight.tags.operator, highlight.tags.operatorKeyword, highlight.tags.url, highlight.tags.escape, highlight.tags.regexp, highlight.tags.link, highlight.tags.special(highlight.tags.string)],
101
- color: s.operator
102
- }, {
103
- tag: [highlight.tags.meta, highlight.tags.comment],
104
- color: s.comment
105
- }, {
106
- tag: highlight.tags.strong,
107
- fontWeight: "bold"
108
- }, {
109
- tag: highlight.tags.emphasis,
110
- fontStyle: "italic"
111
- }, {
112
- tag: highlight.tags.strikethrough,
113
- textDecoration: "line-through"
114
- }, {
115
- tag: highlight.tags.heading,
116
- fontWeight: "bold",
117
- color: s.property
118
- }, {
119
- tag: [highlight.tags.atom, highlight.tags.bool, highlight.tags.special(highlight.tags.variableName)],
120
- color: s.boolean
121
- }, {
122
- tag: [highlight.tags.processingInstruction, highlight.tags.string, highlight.tags.inserted],
123
- color: s.string
124
- }, {
125
- tag: highlight.tags.invalid,
126
- color: c.fg
127
- }]);
128
- }
129
- const EditorRoot = styledComponents.styled.div`
130
- width: 100%;
131
- box-sizing: border-box;
132
- height: 100%;
133
- overflow: hidden;
134
- overflow: clip;
135
- position: relative;
136
- display: flex;
137
-
138
- & .cm-theme {
139
- width: 100%;
140
- }
141
-
142
- & .cm-editor {
143
- height: 100%;
144
-
145
- font-size: 16px;
146
- line-height: 21px;
147
- }
148
-
149
- & .cm-line {
150
- padding-left: ${({
151
- theme
152
- }) => ui.rem(theme.sanity.space[3])};
153
- }
154
-
155
- & .cm-content {
156
- border-right-width: ${({
157
- theme
158
- }) => ui.rem(theme.sanity.space[4])} !important;
159
- padding-top: ${({
160
- theme
161
- }) => ui.rem(theme.sanity.space[5])};
162
- }
163
- `, VisionCodeMirror = react.forwardRef((props, ref) => {
164
- const $ = reactCompilerRuntime.c(7), [initialValue] = react.useState(props.initialValue), sanityTheme = ui.useTheme(), theme = useCodemirrorTheme(sanityTheme), codeMirrorRef = react.useRef(null);
165
- let t0;
166
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (newContent) => {
167
- const editorView = codeMirrorRef.current?.view;
168
- if (!editorView)
169
- return;
170
- const currentDoc = editorView.state.doc.toString();
171
- newContent !== currentDoc && editorView.dispatch({
172
- changes: {
173
- from: 0,
174
- to: currentDoc.length,
175
- insert: newContent
176
- },
177
- selection: CodeMirror.EditorSelection.cursor(newContent.length)
178
- });
179
- }, $[0] = t0) : t0 = $[0];
180
- const resetEditorContent = t0;
181
- let t1, t2;
182
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => ({
183
- resetEditorContent
184
- }), t2 = [resetEditorContent], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), react.useImperativeHandle(ref, t1, t2);
185
- let t3;
186
- return $[3] !== initialValue || $[4] !== props.onChange || $[5] !== theme ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(EditorRoot, { children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror__default.default, { ref: codeMirrorRef, basicSetup: !1, theme, extensions: codemirrorExtensions, value: initialValue, onChange: props.onChange }) }), $[3] = initialValue, $[4] = props.onChange, $[5] = theme, $[6] = t3) : t3 = $[6], t3;
187
- });
188
- VisionCodeMirror.displayName = "VisionCodeMirror";
189
- const SUPPORTED_PERSPECTIVES = ["pinnedRelease", "scheduledDrafts", "raw", "published", "drafts"], VIRTUAL_PERSPECTIVES = ["pinnedRelease", "scheduledDrafts"];
190
- function isSupportedPerspective(p) {
191
- return SUPPORTED_PERSPECTIVES.includes(p);
192
- }
193
- function isVirtualPerspective(maybeVirtualPerspective) {
194
- return typeof maybeVirtualPerspective == "string" && VIRTUAL_PERSPECTIVES.includes(maybeVirtualPerspective);
195
- }
196
- function hasPinnedPerspective({
197
- selectedPerspectiveName
198
- }) {
199
- return typeof selectedPerspectiveName < "u";
200
- }
201
- function getActivePerspective({
202
- visionPerspective,
203
- perspectiveStack,
204
- scheduledDraftsStack
205
- }) {
206
- return visionPerspective === "pinnedRelease" ? perspectiveStack : visionPerspective === "scheduledDrafts" ? scheduledDraftsStack : visionPerspective;
207
- }
208
- function encodeQueryString(query, params = {}, options = {}) {
209
- const searchParams = new URLSearchParams();
210
- searchParams.set("query", query);
211
- for (const [key, value] of Object.entries(params))
212
- searchParams.set(`$${key}`, JSON.stringify(value));
213
- for (const [key, value] of Object.entries(options))
214
- value && searchParams.set(key, `${value}`);
215
- return `?${searchParams}`;
216
- }
217
- function isPlainObject(obj) {
218
- return !!obj && typeof obj == "object" && Object.prototype.toString.call(obj) === "[object Object]";
219
- }
220
- const hasLocalStorage = supportsLocalStorage(), keyPrefix = "sanityVision:";
221
- function clearLocalStorage() {
222
- if (hasLocalStorage)
223
- for (let i = 0; i < localStorage.length; i++) {
224
- const key = localStorage.key(i);
225
- key?.startsWith(keyPrefix) && localStorage.removeItem(key);
226
- }
227
- }
228
- function getLocalStorage(namespace) {
229
- const storageKey = `${keyPrefix}${namespace}`;
230
- let loadedState = null;
231
- return {
232
- get,
233
- set,
234
- merge
235
- };
236
- function get(key, defaultVal) {
237
- const state = ensureState();
238
- return typeof state[key] > "u" ? defaultVal : state[key];
239
- }
240
- function set(key, value) {
241
- const state = ensureState();
242
- return state[key] = value, localStorage.setItem(storageKey, JSON.stringify(loadedState)), value;
243
- }
244
- function merge(props) {
245
- const state = {
246
- ...ensureState(),
247
- ...props
248
- };
249
- return localStorage.setItem(storageKey, JSON.stringify(state)), state;
250
- }
251
- function ensureState() {
252
- return loadedState === null && (loadedState = loadState()), loadedState;
253
- }
254
- function loadState() {
255
- if (!hasLocalStorage)
256
- return {};
257
- try {
258
- const stored = JSON.parse(localStorage.getItem(storageKey) || "{}");
259
- return isPlainObject(stored) ? stored : {};
260
- } catch {
261
- return {};
262
- }
263
- }
264
- }
265
- function supportsLocalStorage() {
266
- const mod = "lsCheck";
267
- try {
268
- return localStorage.setItem(mod, mod), localStorage.removeItem(mod), !0;
269
- } catch {
270
- return !1;
271
- }
272
- }
273
- function parseApiQueryString(qs) {
274
- const params = {}, options = {};
275
- for (const [key, value] of qs.entries()) {
276
- if (key[0] === "$") {
277
- params[key.slice(1)] = JSON.parse(value);
278
- continue;
279
- }
280
- if (key === "perspective") {
281
- options[key] = value;
282
- continue;
283
- }
284
- }
285
- return {
286
- query: qs.get("query") || "",
287
- params,
288
- options
289
- };
290
- }
291
- function prefixApiVersion(version) {
292
- return version[0] !== "v" && version !== "other" ? `v${version}` : version;
293
- }
294
- function validateApiVersion(apiVersion) {
295
- const parseableApiVersion = apiVersion.replace(/^v/, "").trim().toUpperCase();
296
- return parseableApiVersion.length > 0 && (parseableApiVersion === "X" || parseableApiVersion === "1" || /^\d{4}-\d{2}-\d{2}$/.test(parseableApiVersion) && !isNaN(Date.parse(parseableApiVersion)));
297
- }
298
- function tryParseParams(val, t) {
299
- try {
300
- const parsed = val ? JSON5__default.default.parse(val) : {};
301
- return typeof parsed == "object" && parsed && !Array.isArray(parsed) ? parsed : {};
302
- } catch (err) {
303
- return err.message = `${t("params.error.params-invalid-json")}:
304
-
305
- ${err.message.replace("JSON5:", "")}`, err;
306
- }
307
- }
308
- const Root = styledComponents.styled(ui.Flex)`
309
- .sidebarPanes .Pane {
310
- overflow-y: auto;
311
- overflow-x: hidden;
312
- }
313
-
314
- & .Resizer {
315
- background: var(--card-border-color);
316
- opacity: 1;
317
- z-index: 1;
318
- box-sizing: border-box;
319
- background-clip: padding-box;
320
- border: solid transparent;
321
- }
322
-
323
- & .Resizer:hover {
324
- border-color: var(--card-shadow-ambient-color);
325
- }
326
-
327
- & .Resizer.horizontal {
328
- height: 11px;
329
- margin: -5px 0;
330
- border-width: 5px 0;
331
- cursor: row-resize;
332
- width: 100%;
333
- z-index: 4;
334
- }
335
-
336
- & .Resizer.vertical {
337
- width: 11px;
338
- margin: 0 -5px;
339
- border-width: 0 5px;
340
- cursor: col-resize;
341
- z-index: 2; /* To prevent the resizer from being hidden behind CodeMirror scroll area */
342
- }
343
-
344
- .Resizer.disabled {
345
- cursor: not-allowed;
346
- }
347
-
348
- .Resizer.disabled:hover {
349
- border-color: transparent;
350
- }
351
- `;
352
- Root.displayName = "Root";
353
- const Header = styledComponents.styled(ui.Card)`
354
- border-bottom: 1px solid var(--card-border-color);
355
- `, StyledLabel = styledComponents.styled(ui.Label)`
356
- flex: 1;
357
- `, SplitpaneContainer = styledComponents.styled(ui.Box)`
358
- position: relative;
359
- `, QueryCopyLink = styledComponents.styled.a`
360
- cursor: pointer;
361
- margin-right: auto;
362
- `, InputBackgroundContainer = styledComponents.styled(ui.Box)`
363
- position: absolute;
364
- top: 1rem;
365
- left: 0;
366
- padding: 0;
367
- margin: 0;
368
- z-index: 10;
369
- right: 0;
370
-
371
- ${StyledLabel} {
372
- user-select: none;
373
- }
374
- `, InputBackgroundContainerLeft = styledComponents.styled(InputBackgroundContainer)`
375
- // This is so its aligned with the gutters of CodeMirror
376
- left: 33px;
377
- `, InputContainer = styledComponents.styled(ui.Card)`
378
- width: 100%;
379
- height: 100%;
380
- position: relative;
381
- flex-direction: column;
382
- `, ResultOuterContainer = styledComponents.styled(ui.Flex)`
383
- height: 100%;
384
- `, ResultInnerContainer = styledComponents.styled(ui.Box)`
385
- position: relative;
386
- `, ResultContainer = styledComponents.styled(ui.Card)`
387
- height: 100%;
388
- width: 100%;
389
- position: absolute;
390
- max-width: 100%;
391
-
392
- ${({
393
- $isInvalid
394
- }) => $isInvalid && styledComponents.css`
395
- &:after {
396
- background-color: var(--card-bg-color);
397
- content: '';
398
- position: absolute;
399
- top: 0;
400
- bottom: 0;
401
- left: 0;
402
- width: 100%;
403
- }
404
- `}
405
- `, Result = styledComponents.styled(ui.Box)`
406
- position: relative;
407
- width: 100%;
408
- height: 100%;
409
- z-index: 20;
410
- `, ResultFooter = styledComponents.styled(ui.Flex)`
411
- border-top: 1px solid var(--card-border-color);
412
- `, TimingsCard = styledComponents.styled(ui.Card)`
413
- position: relative;
414
- `;
415
- styledComponents.styled(ui.Box)`
416
- width: 100%;
417
- height: 100%;
418
- `;
419
- const TimingsTextContainer = styledComponents.styled(ui.Flex)`
420
- height: 100%;
421
- min-height: ${({
422
- theme
423
- }) => ui.rem(theme.sanity.space[3] * 2 + theme.sanity.fonts.text.sizes[2].lineHeight - theme.sanity.fonts.text.sizes[2].ascenderHeight - theme.sanity.fonts.text.sizes[2].descenderHeight)};
424
- `, DownloadsCard = styledComponents.styled(ui.Card)`
425
- position: relative;
426
- `, SaveResultLabel = styledComponents.styled(ui.Text)`
427
- transform: initial;
428
- &:before,
429
- &:after {
430
- content: none;
431
- }
432
- > span {
433
- display: flex !important;
434
- gap: ${({
435
- theme
436
- }) => ui.rem(theme.sanity.space[3])};
437
- align-items: center;
438
- }
439
- `, ControlsContainer = styledComponents.styled(ui.Box)`
440
- border-top: 1px solid var(--card-border-color);
441
- `, defaultValue$1 = `{
442
-
443
- }`;
444
- function ParamsEditor(props) {
445
- const $ = reactCompilerRuntime.c(21), {
446
- onChange,
447
- paramsError,
448
- hasValidParams,
449
- editorRef
450
- } = props, {
451
- t
452
- } = sanity.useTranslation(index.visionLocaleNamespace);
453
- let t0;
454
- $[0] !== onChange ? (t0 = (newValue) => {
455
- onChange(newValue);
456
- }, $[0] = onChange, $[1] = t0) : t0 = $[1];
457
- const handleChangeRaw = t0;
458
- let t1;
459
- $[2] !== handleChangeRaw ? (t1 = debounce__default.default(handleChangeRaw, 333), $[2] = handleChangeRaw, $[3] = t1) : t1 = $[3];
460
- const handleChange = t1, t2 = hasValidParams ? "default" : "critical";
461
- let t3;
462
- $[4] !== t ? (t3 = t("params.label"), $[4] = t, $[5] = t3) : t3 = $[5];
463
- let t4;
464
- $[6] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { muted: !0, children: t3 }), $[6] = t3, $[7] = t4) : t4 = $[7];
465
- let t5;
466
- $[8] !== paramsError ? (t5 = paramsError && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { animate: !0, placement: "top", portal: !0, content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: paramsError }), children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, marginX: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.ErrorOutlineIcon, {}) }) }) }), $[8] = paramsError, $[9] = t5) : t5 = $[9];
467
- let t6;
468
- $[10] !== t4 || $[11] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(InputBackgroundContainerLeft, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { children: [
469
- t4,
470
- t5
471
- ] }) }), $[10] = t4, $[11] = t5, $[12] = t6) : t6 = $[12];
472
- const t7 = props.value || defaultValue$1;
473
- let t8;
474
- $[13] !== editorRef || $[14] !== handleChange || $[15] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(VisionCodeMirror, { ref: editorRef, initialValue: t7, onChange: handleChange }), $[13] = editorRef, $[14] = handleChange, $[15] = t7, $[16] = t8) : t8 = $[16];
475
- let t9;
476
- return $[17] !== t2 || $[18] !== t6 || $[19] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Card, { flex: 1, tone: t2, "data-testid": "params-editor", children: [
477
- t6,
478
- t8
479
- ] }), $[17] = t2, $[18] = t6, $[19] = t8, $[20] = t9) : t9 = $[20], t9;
480
- }
481
- function parseParams(value, t) {
482
- const parsedParams = tryParseParams(value, t), params = parsedParams instanceof Error ? {} : parsedParams, validationError = parsedParams instanceof Error ? parsedParams.message : void 0;
483
- return {
484
- parsed: params,
485
- raw: value,
486
- valid: !validationError,
487
- error: validationError
488
- };
489
- }
490
- const STORED_QUERIES_NAMESPACE = "studio.vision-tool.saved-queries", defaultValue = {
491
- queries: []
492
- }, keyValueStoreKey = STORED_QUERIES_NAMESPACE;
493
- function useSavedQueries() {
494
- const $ = reactCompilerRuntime.c(27), keyValueStore = sanity.useKeyValueStore(), [value, setValue] = react.useState(defaultValue), [saving, setSaving] = react.useState(!1);
495
- let t0;
496
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
497
- const [deleting, setDeleting] = react.useState(t0), [saveQueryError, setSaveQueryError] = react.useState(), [deleteQueryError, setDeleteQueryError] = react.useState(), [error, setError] = react.useState();
498
- let t1;
499
- $[1] !== keyValueStore ? (t1 = keyValueStore.getKey(keyValueStoreKey), $[1] = keyValueStore, $[2] = t1) : t1 = $[2];
500
- const queries = t1;
501
- let t2;
502
- $[3] !== queries ? (t2 = () => {
503
- const sub = queries.pipe(operators.startWith(defaultValue), operators.map(_temp$5)).subscribe({
504
- next: setValue,
505
- error: (err) => setError(err)
506
- });
507
- return () => sub?.unsubscribe();
508
- }, $[3] = queries, $[4] = t2) : t2 = $[4];
509
- let t3;
510
- $[5] !== keyValueStore || $[6] !== queries ? (t3 = [queries, keyValueStore], $[5] = keyValueStore, $[6] = queries, $[7] = t3) : t3 = $[7], react.useEffect(t2, t3);
511
- let t4;
512
- $[8] !== keyValueStore || $[9] !== value.queries ? (t4 = async (query) => {
513
- setSaving(!0), setSaveQueryError(void 0);
514
- try {
515
- const newQueries = [{
516
- ...query,
517
- _key: uuid.uuid()
518
- }, ...value.queries];
519
- setValue({
520
- queries: newQueries
521
- }), await keyValueStore.setKey(keyValueStoreKey, {
522
- queries: newQueries
523
- });
524
- } catch (t52) {
525
- setSaveQueryError(t52);
526
- }
527
- setSaving(!1);
528
- }, $[8] = keyValueStore, $[9] = value.queries, $[10] = t4) : t4 = $[10];
529
- const saveQuery = t4;
530
- let t5;
531
- $[11] !== keyValueStore || $[12] !== value.queries ? (t5 = async (query_0) => {
532
- setSaving(!0), setSaveQueryError(void 0);
533
- try {
534
- const updatedQueries = value.queries.map((q) => q._key === query_0._key ? {
535
- ...q,
536
- ...query_0
537
- } : q);
538
- setValue({
539
- queries: updatedQueries
540
- }), await keyValueStore.setKey(keyValueStoreKey, {
541
- queries: updatedQueries
542
- });
543
- } catch (t62) {
544
- setSaveQueryError(t62);
545
- }
546
- setSaving(!1);
547
- }, $[11] = keyValueStore, $[12] = value.queries, $[13] = t5) : t5 = $[13];
548
- const updateQuery = t5;
549
- let t6;
550
- $[14] !== keyValueStore || $[15] !== value.queries ? (t6 = async (key) => {
551
- setDeleting((prev) => [...prev, key]), setDeleteQueryError(void 0);
552
- try {
553
- const filteredQueries = value.queries.filter((q_0) => q_0._key !== key);
554
- setValue({
555
- queries: filteredQueries
556
- }), await keyValueStore.setKey(keyValueStoreKey, {
557
- queries: filteredQueries
558
- });
559
- } catch (t72) {
560
- setDeleteQueryError(t72);
561
- }
562
- setDeleting((prev_0) => prev_0.filter((k) => k !== key));
563
- }, $[14] = keyValueStore, $[15] = value.queries, $[16] = t6) : t6 = $[16];
564
- const deleteQuery = t6;
565
- let t7;
566
- return $[17] !== deleteQuery || $[18] !== deleteQueryError || $[19] !== deleting || $[20] !== error || $[21] !== saveQuery || $[22] !== saveQueryError || $[23] !== saving || $[24] !== updateQuery || $[25] !== value.queries ? (t7 = {
567
- queries: value.queries,
568
- saveQuery,
569
- updateQuery,
570
- deleteQuery,
571
- saving,
572
- deleting,
573
- saveQueryError,
574
- deleteQueryError,
575
- error
576
- }, $[17] = deleteQuery, $[18] = deleteQueryError, $[19] = deleting, $[20] = error, $[21] = saveQuery, $[22] = saveQueryError, $[23] = saving, $[24] = updateQuery, $[25] = value.queries, $[26] = t7) : t7 = $[26], t7;
577
- }
578
- function _temp$5(data) {
579
- return data || defaultValue;
580
- }
581
- const FixedHeader = styledComponents.styled(ui.Stack)`
582
- position: sticky;
583
- top: 0;
584
- background: ${({
585
- theme
586
- }) => theme.sanity.color.base.bg};
587
- z-index: 1;
588
- `, ScrollContainer = styledComponents.styled(ui.Box)`
589
- height: 100%;
590
- overflow-y: auto;
591
- overflow-x: hidden;
592
-
593
- &::-webkit-scrollbar {
594
- width: 8px;
595
- }
596
-
597
- &::-webkit-scrollbar-track {
598
- background: transparent;
599
- }
600
-
601
- &::-webkit-scrollbar-thumb {
602
- background: ${({
603
- theme
604
- }) => theme.sanity.color.base.border};
605
- border-radius: 4px;
606
- }
607
- `;
608
- function QueryRecall(t0) {
609
- const $ = reactCompilerRuntime.c(80), {
610
- url,
611
- getStateFromUrl,
612
- setStateFromParsedUrl,
613
- currentQuery,
614
- currentParams,
615
- generateUrl
616
- } = t0, toast = ui.useToast(), {
617
- saveQuery,
618
- updateQuery,
619
- queries,
620
- deleteQuery,
621
- saving,
622
- saveQueryError
623
- } = useSavedQueries(), {
624
- t
625
- } = sanity.useTranslation(index.visionLocaleNamespace);
626
- let t1;
627
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
628
- month: "short",
629
- day: "numeric",
630
- year: "numeric",
631
- hour: "numeric",
632
- minute: "2-digit",
633
- hour12: !0
634
- }, $[0] = t1) : t1 = $[0];
635
- const formatDate = sanity.useDateTimeFormat(t1), [editingKey, setEditingKey] = react.useState(null), [editingTitle, setEditingTitle] = react.useState("");
636
- let t2;
637
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[1] = t2) : t2 = $[1];
638
- const [optimisticTitles, setOptimisticTitles] = react.useState(t2), [searchQuery, setSearchQuery] = react.useState(""), [selectedUrl, setSelectedUrl] = react.useState(url);
639
- let t3;
640
- $[2] !== currentParams || $[3] !== currentQuery || $[4] !== formatDate || $[5] !== generateUrl || $[6] !== getStateFromUrl || $[7] !== queries || $[8] !== saveQuery || $[9] !== saveQueryError || $[10] !== t || $[11] !== toast ? (t3 = async () => {
641
- const newUrl = generateUrl(currentQuery, currentParams);
642
- if (queries?.some((q) => {
643
- const savedQueryObj = getStateFromUrl(q.url);
644
- return savedQueryObj && savedQueryObj.query === currentQuery && isEqual__default.default(savedQueryObj.params, currentParams);
645
- })) {
646
- const duplicateQuery = queries?.find((q_0) => {
647
- const savedQueryObj_0 = getStateFromUrl(q_0.url);
648
- return savedQueryObj_0 && savedQueryObj_0.query === currentQuery && isEqual__default.default(savedQueryObj_0.params, currentParams);
649
- });
650
- toast.push({
651
- closable: !0,
652
- status: "warning",
653
- title: t("save-query.already-saved"),
654
- description: `${duplicateQuery?.title} - ${formatDate.format(new Date(duplicateQuery?.savedAt || ""))}`
655
- });
656
- return;
657
- }
658
- newUrl && (await saveQuery({
659
- url: newUrl,
660
- savedAt: (/* @__PURE__ */ new Date()).toISOString(),
661
- title: "Untitled"
662
- }), setSelectedUrl(newUrl)), saveQueryError ? toast.push({
663
- closable: !0,
664
- status: "error",
665
- title: t("save-query.error"),
666
- description: saveQueryError.message
667
- }) : toast.push({
668
- closable: !0,
669
- status: "success",
670
- title: t("save-query.success")
671
- });
672
- }, $[2] = currentParams, $[3] = currentQuery, $[4] = formatDate, $[5] = generateUrl, $[6] = getStateFromUrl, $[7] = queries, $[8] = saveQuery, $[9] = saveQueryError, $[10] = t, $[11] = toast, $[12] = t3) : t3 = $[12];
673
- const handleSave = t3;
674
- let t4;
675
- $[13] !== t || $[14] !== toast || $[15] !== updateQuery ? (t4 = async (query, newTitle) => {
676
- setEditingKey(null), setOptimisticTitles((prev) => ({
677
- ...prev,
678
- [query._key]: newTitle
679
- }));
680
- try {
681
- await updateQuery({
682
- ...query,
683
- title: newTitle
684
- }), setOptimisticTitles((prev_1) => {
685
- const next_0 = {
686
- ...prev_1
687
- };
688
- return delete next_0[query._key], next_0;
689
- });
690
- } catch (t52) {
691
- const err = t52;
692
- setOptimisticTitles((prev_0) => {
693
- const next = {
694
- ...prev_0
695
- };
696
- return delete next[query._key], next;
697
- }), toast.push({
698
- closable: !0,
699
- status: "error",
700
- title: t("save-query.error"),
701
- description: err.message
702
- });
703
- }
704
- }, $[13] = t, $[14] = toast, $[15] = updateQuery, $[16] = t4) : t4 = $[16];
705
- const handleTitleSave = t4;
706
- let t5;
707
- $[17] !== currentParams || $[18] !== currentQuery || $[19] !== formatDate || $[20] !== generateUrl || $[21] !== getStateFromUrl || $[22] !== queries || $[23] !== t || $[24] !== toast || $[25] !== updateQuery ? (t5 = async (query_0) => {
708
- const newUrl_0 = generateUrl(currentQuery, currentParams);
709
- if (queries?.some((q_1) => {
710
- if (q_1._key === query_0._key)
711
- return !1;
712
- const savedQueryObj_1 = getStateFromUrl(q_1.url);
713
- return savedQueryObj_1 && savedQueryObj_1.query === currentQuery && isEqual__default.default(savedQueryObj_1.params, currentParams);
714
- })) {
715
- const duplicateQuery_0 = queries?.find((q_2) => {
716
- if (q_2._key === query_0._key)
717
- return !1;
718
- const savedQueryObj_2 = getStateFromUrl(q_2.url);
719
- return savedQueryObj_2 && savedQueryObj_2.query === currentQuery && isEqual__default.default(savedQueryObj_2.params, currentParams);
720
- });
721
- toast.push({
722
- closable: !0,
723
- status: "warning",
724
- title: t("save-query.already-saved"),
725
- description: `${duplicateQuery_0?.title} - ${formatDate.format(new Date(duplicateQuery_0?.savedAt || ""))}`
726
- });
727
- return;
728
- }
729
- try {
730
- await updateQuery({
731
- ...query_0,
732
- url: newUrl_0,
733
- savedAt: (/* @__PURE__ */ new Date()).toISOString()
734
- }), setSelectedUrl(newUrl_0), toast.push({
735
- closable: !0,
736
- status: "success",
737
- title: t("save-query.success")
738
- });
739
- } catch (t62) {
740
- const err_0 = t62;
741
- toast.push({
742
- closable: !0,
743
- status: "error",
744
- title: t("save-query.error"),
745
- description: err_0.message
746
- });
747
- }
748
- }, $[17] = currentParams, $[18] = currentQuery, $[19] = formatDate, $[20] = generateUrl, $[21] = getStateFromUrl, $[22] = queries, $[23] = t, $[24] = toast, $[25] = updateQuery, $[26] = t5) : t5 = $[26];
749
- const handleUpdate = t5;
750
- let T0, T1, t6, t7, t8;
751
- if ($[27] !== currentParams || $[28] !== currentQuery || $[29] !== deleteQuery || $[30] !== editingKey || $[31] !== editingTitle || $[32] !== formatDate || $[33] !== getStateFromUrl || $[34] !== handleSave || $[35] !== handleTitleSave || $[36] !== handleUpdate || $[37] !== optimisticTitles || $[38] !== queries || $[39] !== saving || $[40] !== searchQuery || $[41] !== selectedUrl || $[42] !== setStateFromParsedUrl || $[43] !== t) {
752
- const filteredQueries = queries?.filter((q_3) => q_3?.title?.toLowerCase().includes(searchQuery.toLowerCase()));
753
- T1 = ScrollContainer;
754
- let t92;
755
- $[49] === Symbol.for("react.memo_cache_sentinel") ? (t92 = {
756
- textTransform: "capitalize"
757
- }, $[49] = t92) : t92 = $[49];
758
- let t102;
759
- $[50] !== t ? (t102 = t("label.saved-queries"), $[50] = t, $[51] = t102) : t102 = $[51];
760
- let t11;
761
- $[52] !== t102 ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", style: t92, size: 4, children: t102 }), $[52] = t102, $[53] = t11) : t11 = $[53];
762
- let t12;
763
- $[54] !== t ? (t12 = t("action.save-query"), $[54] = t, $[55] = t12) : t12 = $[55];
764
- let t13;
765
- $[56] !== handleSave || $[57] !== saving || $[58] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { label: t12, icon: icons.AddIcon, disabled: saving, onClick: handleSave, mode: "bleed" }), $[56] = handleSave, $[57] = saving, $[58] = t12, $[59] = t13) : t13 = $[59];
766
- let t14;
767
- $[60] !== t11 || $[61] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { padding: 3, paddingTop: 4, paddingBottom: 0, justify: "space-between", align: "center", children: [
768
- t11,
769
- t13
770
- ] }), $[60] = t11, $[61] = t13, $[62] = t14) : t14 = $[62];
771
- let t15;
772
- $[63] !== t ? (t15 = t("label.search-queries"), $[63] = t, $[64] = t15) : t15 = $[64];
773
- let t16;
774
- $[65] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (event) => setSearchQuery(event.currentTarget.value), $[65] = t16) : t16 = $[65];
775
- let t17;
776
- $[66] !== searchQuery || $[67] !== t15 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, paddingTop: 0, children: /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { placeholder: t15, icon: icons.SearchIcon, value: searchQuery, onChange: t16 }) }), $[66] = searchQuery, $[67] = t15, $[68] = t17) : t17 = $[68], $[69] !== t14 || $[70] !== t17 ? (t8 = /* @__PURE__ */ jsxRuntime.jsxs(FixedHeader, { space: 3, children: [
777
- t14,
778
- t17
779
- ] }), $[69] = t14, $[70] = t17, $[71] = t8) : t8 = $[71], T0 = ui.Stack, t6 = 3, t7 = filteredQueries?.map((q_4) => {
780
- const queryObj = getStateFromUrl(q_4.url), isSelected = selectedUrl === q_4.url, areQueriesEqual = queryObj && currentQuery === queryObj.query && isEqual__default.default(currentParams, queryObj.params), isEdited = isSelected && !areQueriesEqual;
781
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { width: "fill", padding: 4, border: !0, tone: isSelected ? "positive" : "default", onClick: () => {
782
- setSelectedUrl(q_4.url);
783
- const parsedUrl = getStateFromUrl(q_4.url);
784
- parsedUrl && setStateFromParsedUrl(parsedUrl);
785
- }, style: {
786
- position: "relative"
787
- }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
788
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "space-between", align: "center", children: [
789
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, paddingRight: 1, children: [
790
- editingKey === q_4._key ? /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { value: editingTitle, onChange: (event_0) => setEditingTitle(event_0.currentTarget.value), onKeyDown: (event_1) => {
791
- event_1.key === "Enter" ? handleTitleSave(q_4, editingTitle) : event_1.key === "Escape" && setEditingKey(null);
792
- }, onBlur: () => handleTitleSave(q_4, editingTitle), autoFocus: !0, style: {
793
- maxWidth: "170px",
794
- height: "24px"
795
- } }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "bold", size: 3, textOverflow: "ellipsis", style: {
796
- maxWidth: "170px",
797
- cursor: "pointer",
798
- padding: "4px 0"
799
- }, title: optimisticTitles[q_4._key] || q_4.title || q_4._key.slice(q_4._key.length - 5, q_4._key.length), onClick: () => {
800
- setEditingKey(q_4._key), setEditingTitle(q_4.title || q_4._key.slice(0, 5));
801
- }, children: optimisticTitles[q_4._key] || q_4.title || q_4._key.slice(q_4._key.length - 5, q_4._key.length) }),
802
- isEdited && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: {
803
- width: "6px",
804
- height: "6px",
805
- borderRadius: "50%",
806
- backgroundColor: "var(--card-focus-ring-color)"
807
- } })
808
- ] }),
809
- /* @__PURE__ */ jsxRuntime.jsx(ui.MenuButton, { button: /* @__PURE__ */ jsxRuntime.jsx(sanity.ContextMenuButton, {}), id: `${q_4._key}-menu`, menu: /* @__PURE__ */ jsxRuntime.jsx(ui.Menu, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.MenuItem, { tone: "critical", padding: 3, icon: icons.TrashIcon, text: t("action.delete"), onClick: (event_2) => {
810
- event_2.stopPropagation(), deleteQuery(q_4._key);
811
- } }) }), popover: {
812
- portal: !0,
813
- placement: "bottom-end",
814
- tone: "default"
815
- } })
816
- ] }),
817
- /* @__PURE__ */ jsxRuntime.jsx(ui.Code, { muted: !0, children: queryObj?.query.split("{")[0] }),
818
- /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: formatDate.format(new Date(q_4.savedAt || "")) }) }),
819
- isEdited && /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { mode: "ghost", tone: "default", size: 1, padding: 2, style: {
820
- height: "24px",
821
- position: "absolute",
822
- right: "16px",
823
- bottom: "16px",
824
- fontSize: "12px"
825
- }, text: t("action.update"), onClick: (e) => {
826
- e.stopPropagation(), handleUpdate(q_4);
827
- } })
828
- ] }) }, q_4._key);
829
- }), $[27] = currentParams, $[28] = currentQuery, $[29] = deleteQuery, $[30] = editingKey, $[31] = editingTitle, $[32] = formatDate, $[33] = getStateFromUrl, $[34] = handleSave, $[35] = handleTitleSave, $[36] = handleUpdate, $[37] = optimisticTitles, $[38] = queries, $[39] = saving, $[40] = searchQuery, $[41] = selectedUrl, $[42] = setStateFromParsedUrl, $[43] = t, $[44] = T0, $[45] = T1, $[46] = t6, $[47] = t7, $[48] = t8;
830
- } else
831
- T0 = $[44], T1 = $[45], t6 = $[46], t7 = $[47], t8 = $[48];
832
- let t9;
833
- $[72] !== T0 || $[73] !== t6 || $[74] !== t7 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(T0, { paddingY: t6, children: t7 }), $[72] = T0, $[73] = t6, $[74] = t7, $[75] = t9) : t9 = $[75];
834
- let t10;
835
- return $[76] !== T1 || $[77] !== t8 || $[78] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsxs(T1, { children: [
836
- t8,
837
- t9
838
- ] }), $[76] = T1, $[77] = t8, $[78] = t9, $[79] = t10) : t10 = $[79], t10;
839
- }
840
- function narrowBreakpoint() {
841
- return typeof window < "u" && window.innerWidth > 600;
842
- }
843
- function calculatePaneSizeOptions(height) {
844
- let rootHeight = height;
845
- return rootHeight || (rootHeight = typeof window < "u" && typeof document < "u" ? document.body.getBoundingClientRect().height - 60 : 0), {
846
- defaultSize: rootHeight / (narrowBreakpoint() ? 2 : 1),
847
- size: rootHeight > 550 ? void 0 : rootHeight * 0.4,
848
- allowResize: rootHeight > 550,
849
- minSize: Math.min(170, Math.max(170, rootHeight / 2)),
850
- maxSize: rootHeight > 650 ? rootHeight * 0.7 : rootHeight * 0.6
851
- };
852
- }
853
- function usePaneSize(t0) {
854
- const $ = reactCompilerRuntime.c(6), {
855
- visionRootRef
856
- } = t0, [isNarrowBreakpoint, setIsNarrowBreakpoint] = react.useState(_temp$4), [paneSizeOptions, setPaneSizeOptions] = react.useState(_temp2$3);
857
- let t1, t2;
858
- $[0] !== visionRootRef ? (t1 = () => {
859
- if (!visionRootRef.current)
860
- return;
861
- const handleResize = (entries) => {
862
- setIsNarrowBreakpoint(narrowBreakpoint());
863
- const entry = entries?.[0];
864
- entry && setPaneSizeOptions(calculatePaneSizeOptions(entry.contentRect.height));
865
- }, resizeObserver = new ResizeObserver(handleResize);
866
- return resizeObserver.observe(visionRootRef.current), () => {
867
- resizeObserver.disconnect();
868
- };
869
- }, t2 = [visionRootRef], $[0] = visionRootRef, $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), react.useEffect(t1, t2);
870
- let t3;
871
- return $[3] !== isNarrowBreakpoint || $[4] !== paneSizeOptions ? (t3 = {
872
- paneSizeOptions,
873
- isNarrowBreakpoint
874
- }, $[3] = isNarrowBreakpoint, $[4] = paneSizeOptions, $[5] = t3) : t3 = $[5], t3;
875
- }
876
- function _temp2$3() {
877
- return calculatePaneSizeOptions(void 0);
878
- }
879
- function _temp$4() {
880
- return narrowBreakpoint();
881
- }
882
- function VisionGuiControls(t0) {
883
- const $ = reactCompilerRuntime.c(30), {
884
- hasValidParams,
885
- listenInProgress,
886
- queryInProgress,
887
- onQueryExecution,
888
- onListenExecution
889
- } = t0, {
890
- t
891
- } = sanity.useTranslation(index.visionLocaleNamespace);
892
- let t1;
893
- $[0] !== t ? (t1 = t("params.error.params-invalid-json"), $[0] = t, $[1] = t1) : t1 = $[1];
894
- let t2;
895
- $[2] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: t1 }) }), $[2] = t1, $[3] = t2) : t2 = $[3];
896
- let t3;
897
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Hotkeys, { keys: ["Ctrl", "Enter"] }) }), $[4] = t3) : t3 = $[4];
898
- const t4 = queryInProgress ? icons.StopIcon : icons.PlayIcon, t5 = listenInProgress || !hasValidParams, t6 = queryInProgress ? "positive" : "primary";
899
- let t7;
900
- $[5] !== queryInProgress || $[6] !== t ? (t7 = t(queryInProgress ? "action.query-cancel" : "action.query-execute"), $[5] = queryInProgress, $[6] = t, $[7] = t7) : t7 = $[7];
901
- let t8;
902
- $[8] !== onQueryExecution || $[9] !== t4 || $[10] !== t5 || $[11] !== t6 || $[12] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: t3, placement: "top", portal: !0, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { width: "fill", onClick: onQueryExecution, type: "button", icon: t4, disabled: t5, tone: t6, text: t7 }) }) }), $[8] = onQueryExecution, $[9] = t4, $[10] = t5, $[11] = t6, $[12] = t7, $[13] = t8) : t8 = $[13];
903
- const t9 = listenInProgress ? icons.StopIcon : icons.PlayIcon;
904
- let t10;
905
- $[14] !== listenInProgress || $[15] !== t ? (t10 = t(listenInProgress ? "action.listen-cancel" : "action.listen-execute"), $[14] = listenInProgress, $[15] = t, $[16] = t10) : t10 = $[16];
906
- const t11 = !hasValidParams, t12 = listenInProgress ? "positive" : "default";
907
- let t13;
908
- $[17] !== onListenExecution || $[18] !== t10 || $[19] !== t11 || $[20] !== t12 || $[21] !== t9 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, marginLeft: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { width: "fill", onClick: onListenExecution, type: "button", icon: t9, text: t10, mode: "ghost", disabled: t11, tone: t12 }) }), $[17] = onListenExecution, $[18] = t10, $[19] = t11, $[20] = t12, $[21] = t9, $[22] = t13) : t13 = $[22];
909
- let t14;
910
- $[23] !== t13 || $[24] !== t8 ? (t14 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "space-evenly", children: [
911
- t8,
912
- t13
913
- ] }), $[23] = t13, $[24] = t8, $[25] = t14) : t14 = $[25];
914
- let t15;
915
- return $[26] !== hasValidParams || $[27] !== t14 || $[28] !== t2 ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(ControlsContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 3, paddingX: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: t2, placement: "top", disabled: hasValidParams, portal: !0, children: t14 }) }) }), $[26] = hasValidParams, $[27] = t14, $[28] = t2, $[29] = t15) : t15 = $[29], t15;
916
- }
917
- const PerspectivePopoverContent = styledComponents.styled(ui.Box)`
918
- /* This limits the width of the popover content */
919
- max-width: 240px;
920
- `, PerspectivePopoverLink = styledComponents.styled.a`
921
- cursor: pointer;
922
- margin-right: auto;
923
- `, Dot = styledComponents.styled.div`
924
- width: 4px;
925
- height: 4px;
926
- border-radius: 3px;
927
- box-shadow: 0 0 0 1px var(--card-bg-color);
928
- background-color: ${({
929
- $tone
930
- }) => `var(--card-badge-${$tone}-dot-color)`};
931
- `;
932
- function PerspectivePopover() {
933
- const $ = reactCompilerRuntime.c(39), [open, setOpen] = react.useState(!1), buttonRef = react.useRef(null), popoverRef = react.useRef(null);
934
- let t0;
935
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => setOpen(_temp$3), $[0] = t0) : t0 = $[0];
936
- const handleClick = t0, {
937
- t
938
- } = sanity.useTranslation(index.visionLocaleNamespace);
939
- let t1, t2;
940
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setOpen(!1), t2 = () => [buttonRef.current, popoverRef.current], $[1] = t1, $[2] = t2) : (t1 = $[1], t2 = $[2]), ui.useClickOutsideEvent(t1, t2);
941
- let t3;
942
- $[3] !== t ? (t3 = t("settings.perspectives.title"), $[3] = t, $[4] = t3) : t3 = $[4];
943
- let t4;
944
- $[5] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(ui.Inline, { space: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "medium", children: t3 }) }), $[5] = t3, $[6] = t4) : t4 = $[6];
945
- let t5;
946
- $[7] !== t ? (t5 = t("settings.perspectives.description"), $[7] = t, $[8] = t5) : t5 = $[8];
947
- let t6;
948
- $[9] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, children: t5 }) }), $[9] = t5, $[10] = t6) : t6 = $[10];
949
- let t7;
950
- $[11] !== t ? (t7 = t("label.new"), $[11] = t, $[12] = t7) : t7 = $[12];
951
- let t8;
952
- $[13] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { tone: "primary", children: t7 }) }), $[13] = t7, $[14] = t8) : t8 = $[14];
953
- let t9;
954
- $[15] !== t ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { t, i18nKey: "settings.perspective.preview-drafts-renamed-to-drafts.description" }) }), $[15] = t, $[16] = t9) : t9 = $[16];
955
- let t10;
956
- $[17] !== t8 || $[18] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
957
- t8,
958
- t9
959
- ] }) }), $[17] = t8, $[18] = t9, $[19] = t10) : t10 = $[19];
960
- let t11;
961
- $[20] !== t ? (t11 = null, $[20] = t, $[21] = t11) : t11 = $[21];
962
- let t12;
963
- $[22] !== t ? (t12 = t("settings.perspectives.action.docs-link"), $[22] = t, $[23] = t12) : t12 = $[23];
964
- let t13;
965
- $[24] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: /* @__PURE__ */ jsxRuntime.jsxs(PerspectivePopoverLink, { href: "https://www.sanity.io/docs/perspectives", target: "_blank", children: [
966
- t12,
967
- " \u2192"
968
- ] }) }) }), $[24] = t12, $[25] = t13) : t13 = $[25];
969
- let t14;
970
- $[26] !== t10 || $[27] !== t11 || $[28] !== t13 || $[29] !== t4 || $[30] !== t6 ? (t14 = /* @__PURE__ */ jsxRuntime.jsx(PerspectivePopoverContent, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
971
- t4,
972
- t6,
973
- t10,
974
- t11,
975
- t13
976
- ] }) }), $[26] = t10, $[27] = t11, $[28] = t13, $[29] = t4, $[30] = t6, $[31] = t14) : t14 = $[31];
977
- let t15;
978
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(Dot, { $tone: "primary" }), $[32] = t15) : t15 = $[32];
979
- let t16;
980
- $[33] !== open ? (t16 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { icon: icons.HelpCircleIcon, mode: "bleed", padding: 2, paddingRight: 1, tone: "primary", fontSize: 1, ref: buttonRef, onClick: handleClick, selected: open, children: t15 }), $[33] = open, $[34] = t16) : t16 = $[34];
981
- let t17;
982
- return $[35] !== open || $[36] !== t14 || $[37] !== t16 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(ui.Popover, { content: t14, placement: "bottom-start", portal: !0, padding: 3, ref: popoverRef, open, children: t16 }), $[35] = open, $[36] = t14, $[37] = t16, $[38] = t17) : t17 = $[38], t17;
983
- }
984
- function _temp$3(o) {
985
- return !o;
986
- }
987
- const PinnedReleasePerspectiveOption = (t0) => {
988
- const $ = reactCompilerRuntime.c(11), {
989
- pinnedPerspective,
990
- t
991
- } = t0, name = typeof pinnedPerspective.selectedPerspective == "object" ? pinnedPerspective.selectedPerspective.metadata.title : pinnedPerspective.selectedPerspectiveName;
992
- let t1;
993
- $[0] !== pinnedPerspective || $[1] !== t ? (t1 = hasPinnedPerspective(pinnedPerspective) ? `(${t("settings.perspectives.pinned-release-label")})` : t("settings.perspectives.pinned-release-label"), $[0] = pinnedPerspective, $[1] = t, $[2] = t1) : t1 = $[2];
994
- const label = t1;
995
- let t2;
996
- $[3] !== label || $[4] !== name ? (t2 = [name, label].filter(_temp$2), $[3] = label, $[4] = name, $[5] = t2) : t2 = $[5];
997
- const text = t2.join(" ");
998
- let t3;
999
- $[6] !== pinnedPerspective ? (t3 = hasPinnedPerspective(pinnedPerspective), $[6] = pinnedPerspective, $[7] = t3) : t3 = $[7];
1000
- const t4 = !t3;
1001
- let t5;
1002
- return $[8] !== t4 || $[9] !== text ? (t5 = /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pinnedRelease", disabled: t4, children: text }), $[8] = t4, $[9] = text, $[10] = t5) : t5 = $[10], t5;
1003
- };
1004
- function VisionGuiHeader(t0) {
1005
- const $ = reactCompilerRuntime.c(65), {
1006
- onChangeDataset,
1007
- dataset,
1008
- customApiVersion,
1009
- apiVersion,
1010
- onChangeApiVersion,
1011
- datasets,
1012
- customApiVersionElementRef,
1013
- onCustomApiVersionChange,
1014
- isValidApiVersion,
1015
- onChangePerspective,
1016
- url,
1017
- perspective,
1018
- isScheduledDraftsEnabled
1019
- } = t0, pinnedPerspective = sanity.usePerspective(), {
1020
- t
1021
- } = sanity.useTranslation(index.visionLocaleNamespace), operationUrlElement = react.useRef(null);
1022
- let t1;
1023
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
1024
- const el = operationUrlElement.current;
1025
- if (el)
1026
- try {
1027
- el.select(), document.execCommand("copy");
1028
- } catch {
1029
- console.error("Unable to copy to clipboard :(");
1030
- }
1031
- }, $[0] = t1) : t1 = $[0];
1032
- const handleCopyUrl = t1;
1033
- let t2;
1034
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [1, 4, 8, 12], $[1] = t2) : t2 = $[1];
1035
- let t3;
1036
- $[2] !== t ? (t3 = t("settings.dataset-label"), $[2] = t, $[3] = t3) : t3 = $[3];
1037
- let t4;
1038
- $[4] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingTop: 2, paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { children: t3 }) }), $[4] = t3, $[5] = t4) : t4 = $[5];
1039
- let t5;
1040
- $[6] !== datasets ? (t5 = datasets.map(_temp2$2), $[6] = datasets, $[7] = t5) : t5 = $[7];
1041
- let t6;
1042
- $[8] !== dataset || $[9] !== onChangeDataset || $[10] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ui.Select, { value: dataset, onChange: onChangeDataset, children: t5 }), $[8] = dataset, $[9] = onChangeDataset, $[10] = t5, $[11] = t6) : t6 = $[11];
1043
- let t7;
1044
- $[12] !== t4 || $[13] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, column: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
1045
- t4,
1046
- t6
1047
- ] }) }), $[12] = t4, $[13] = t6, $[14] = t7) : t7 = $[14];
1048
- let t8;
1049
- $[15] !== t ? (t8 = t("settings.api-version-label"), $[15] = t, $[16] = t8) : t8 = $[16];
1050
- let t9;
1051
- $[17] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingTop: 2, paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { children: t8 }) }), $[17] = t8, $[18] = t9) : t9 = $[18];
1052
- const t10 = customApiVersion === !1 ? apiVersion : "other";
1053
- let t11;
1054
- $[19] === Symbol.for("react.memo_cache_sentinel") ? (t11 = API_VERSIONS.map(_temp3$1), $[19] = t11) : t11 = $[19];
1055
- let t12;
1056
- $[20] !== t ? (t12 = t("settings.other-api-version-label"), $[20] = t, $[21] = t12) : t12 = $[21];
1057
- let t13;
1058
- $[22] !== t12 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx("option", { value: "other", children: t12 }, "other"), $[22] = t12, $[23] = t13) : t13 = $[23];
1059
- let t14;
1060
- $[24] !== onChangeApiVersion || $[25] !== t10 || $[26] !== t13 ? (t14 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { "data-testid": "api-version-selector", value: t10, onChange: onChangeApiVersion, children: [
1061
- t11,
1062
- t13
1063
- ] }), $[24] = onChangeApiVersion, $[25] = t10, $[26] = t13, $[27] = t14) : t14 = $[27];
1064
- let t15;
1065
- $[28] !== t14 || $[29] !== t9 ? (t15 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, column: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
1066
- t9,
1067
- t14
1068
- ] }) }), $[28] = t14, $[29] = t9, $[30] = t15) : t15 = $[30];
1069
- let t16;
1070
- $[31] !== customApiVersion || $[32] !== customApiVersionElementRef || $[33] !== isValidApiVersion || $[34] !== onCustomApiVersionChange || $[35] !== t ? (t16 = customApiVersion !== !1 && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, column: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
1071
- /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingTop: 2, paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { textOverflow: "ellipsis", children: t("settings.custom-api-version-label") }) }),
1072
- /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { ref: customApiVersionElementRef, value: customApiVersion, onChange: onCustomApiVersionChange, customValidity: isValidApiVersion ? void 0 : t("settings.error.invalid-api-version"), maxLength: 11 })
1073
- ] }) }), $[31] = customApiVersion, $[32] = customApiVersionElementRef, $[33] = isValidApiVersion, $[34] = onCustomApiVersionChange, $[35] = t, $[36] = t16) : t16 = $[36];
1074
- let t17;
1075
- $[37] !== t ? (t17 = t("settings.perspective-label"), $[37] = t, $[38] = t17) : t17 = $[38];
1076
- let t18;
1077
- $[39] !== t17 ? (t18 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { children: t17 }) }), $[39] = t17, $[40] = t18) : t18 = $[40];
1078
- let t19;
1079
- $[41] === Symbol.for("react.memo_cache_sentinel") ? (t19 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(PerspectivePopover, {}) }), $[41] = t19) : t19 = $[41];
1080
- let t20;
1081
- $[42] !== t18 ? (t20 = /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingBottom: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Inline, { space: 1, children: [
1082
- t18,
1083
- t19
1084
- ] }) }), $[42] = t18, $[43] = t20) : t20 = $[43];
1085
- const t21 = perspective || "default";
1086
- let t22;
1087
- $[44] !== isScheduledDraftsEnabled || $[45] !== pinnedPerspective || $[46] !== t ? (t22 = SUPPORTED_PERSPECTIVES.map((perspectiveName) => perspectiveName === "pinnedRelease" ? /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
1088
- /* @__PURE__ */ jsxRuntime.jsx(PinnedReleasePerspectiveOption, { pinnedPerspective, t }),
1089
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "default", children: t("settings.perspectives.default") }, "default"),
1090
- /* @__PURE__ */ jsxRuntime.jsx("hr", {})
1091
- ] }, "pinnedRelease") : perspectiveName === "scheduledDrafts" ? isScheduledDraftsEnabled ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "scheduledDrafts", children: t("settings.perspectives.scheduled-drafts") }, "scheduledDrafts") : null : /* @__PURE__ */ jsxRuntime.jsx("option", { children: perspectiveName }, perspectiveName)), $[44] = isScheduledDraftsEnabled, $[45] = pinnedPerspective, $[46] = t, $[47] = t22) : t22 = $[47];
1092
- let t23;
1093
- $[48] !== onChangePerspective || $[49] !== t21 || $[50] !== t22 ? (t23 = /* @__PURE__ */ jsxRuntime.jsx(ui.Select, { value: t21, onChange: onChangePerspective, children: t22 }), $[48] = onChangePerspective, $[49] = t21, $[50] = t22, $[51] = t23) : t23 = $[51];
1094
- let t24;
1095
- $[52] !== t20 || $[53] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, column: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
1096
- t20,
1097
- t23
1098
- ] }) }), $[52] = t20, $[53] = t23, $[54] = t24) : t24 = $[54];
1099
- let t25;
1100
- $[55] !== customApiVersion || $[56] !== t || $[57] !== url ? (t25 = typeof url == "string" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, flex: 1, column: customApiVersion === !1 ? 6 : 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
1101
- /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { paddingTop: 2, paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(StyledLabel, { children: [
1102
- t("query.url"),
1103
- "\xA0",
1104
- /* @__PURE__ */ jsxRuntime.jsxs(QueryCopyLink, { onClick: handleCopyUrl, children: [
1105
- "[",
1106
- t("action.copy-url-to-clipboard"),
1107
- "]"
1108
- ] })
1109
- ] }) }),
1110
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { flex: 1, gap: 1, children: [
1111
- /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { readOnly: !0, type: "url", ref: operationUrlElement, value: url }) }),
1112
- /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: t("action.copy-url-to-clipboard"), children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { "aria-label": t("action.copy-url-to-clipboard"), type: "button", mode: "ghost", icon: icons.CopyIcon, onClick: handleCopyUrl }) })
1113
- ] })
1114
- ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1 }), $[55] = customApiVersion, $[56] = t, $[57] = url, $[58] = t25) : t25 = $[58];
1115
- let t26;
1116
- return $[59] !== t15 || $[60] !== t16 || $[61] !== t24 || $[62] !== t25 || $[63] !== t7 ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(Header, { paddingX: 3, paddingY: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { columns: t2, children: [
1117
- t7,
1118
- t15,
1119
- t16,
1120
- t24,
1121
- t25
1122
- ] }) }), $[59] = t15, $[60] = t16, $[61] = t24, $[62] = t25, $[63] = t7, $[64] = t26) : t26 = $[64], t26;
1123
- }
1124
- function _temp3$1(version) {
1125
- return /* @__PURE__ */ jsxRuntime.jsx("option", { children: version }, version);
1126
- }
1127
- function _temp2$2(ds) {
1128
- return /* @__PURE__ */ jsxRuntime.jsx("option", { children: ds }, ds);
1129
- }
1130
- function _temp$2(value) {
1131
- return typeof value < "u";
1132
- }
1133
- function getBlobUrl(content, mimeType) {
1134
- return URL.createObjectURL(new Blob([content], {
1135
- type: mimeType
1136
- }));
1137
- }
1138
- function getMemoizedBlobUrlResolver(mimeType, stringEncoder) {
1139
- return /* @__PURE__ */ (() => {
1140
- let prevResult = "", prevContent = "";
1141
- return (input) => {
1142
- const content = stringEncoder(input);
1143
- if (!(typeof content != "string" || content === ""))
1144
- return content === prevContent || (prevContent = content, prevResult && URL.revokeObjectURL(prevResult), prevResult = getBlobUrl(content, mimeType)), prevResult;
1145
- };
1146
- })();
1147
- }
1148
- const getJsonBlobUrl = getMemoizedBlobUrlResolver("application/json", (input) => JSON.stringify(input, null, 2)), getCsvBlobUrl = getMemoizedBlobUrlResolver("text/csv", (input) => json2Csv.json2csv(Array.isArray(input) ? input : [input]).trim()), ErrorCode = styledComponents.styled(ui.Code)`
1149
- color: ${({
1150
- theme
1151
- }) => theme.sanity.color.muted.critical.enabled.fg};
1152
- `;
1153
- function QueryErrorDetails(t0) {
1154
- const $ = reactCompilerRuntime.c(20), {
1155
- error
1156
- } = t0, {
1157
- t
1158
- } = sanity.useTranslation(index.visionLocaleNamespace);
1159
- if (!("details" in error))
1160
- return null;
1161
- const t1 = error.details;
1162
- let T0, details, t2, t3, t4, t5;
1163
- if ($[0] !== error.details) {
1164
- t5 = Symbol.for("react.early_return_sentinel");
1165
- bb0: {
1166
- if (details = {
1167
- ...t1,
1168
- ...mapToLegacyDetails(error.details)
1169
- }, !details.line) {
1170
- t5 = null;
1171
- break bb0;
1172
- }
1173
- T0 = ErrorCode, t4 = 1, t2 = details.line, t3 = dashLine(details.column, details.columnEnd);
1174
- }
1175
- $[0] = error.details, $[1] = T0, $[2] = details, $[3] = t2, $[4] = t3, $[5] = t4, $[6] = t5;
1176
- } else
1177
- T0 = $[1], details = $[2], t2 = $[3], t3 = $[4], t4 = $[5], t5 = $[6];
1178
- if (t5 !== Symbol.for("react.early_return_sentinel"))
1179
- return t5;
1180
- const t6 = `${t2}
1181
- ${t3}`;
1182
- let t7;
1183
- $[7] !== T0 || $[8] !== t4 || $[9] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(T0, { size: t4, children: t6 }), $[7] = T0, $[8] = t4, $[9] = t6, $[10] = t7) : t7 = $[10];
1184
- let t8;
1185
- $[11] !== t ? (t8 = t("query.error.line"), $[11] = t, $[12] = t8) : t8 = $[12];
1186
- const t9 = details.lineNumber;
1187
- let t10;
1188
- $[13] !== t ? (t10 = t("query.error.column"), $[13] = t, $[14] = t10) : t10 = $[14];
1189
- const t11 = `${t8}: ${t9}
1190
- ${t10}: ${details.column}`;
1191
- let t12;
1192
- $[15] !== t11 ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorCode, { size: 1, children: t11 }) }), $[15] = t11, $[16] = t12) : t12 = $[16];
1193
- let t13;
1194
- return $[17] !== t12 || $[18] !== t7 ? (t13 = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1195
- t7,
1196
- t12
1197
- ] }), $[17] = t12, $[18] = t7, $[19] = t13) : t13 = $[19], t13;
1198
- }
1199
- function mapToLegacyDetails(details) {
1200
- if (!details || typeof details.query != "string" || typeof details.start != "number")
1201
- return {};
1202
- const {
1203
- query,
1204
- start,
1205
- end
1206
- } = details, lineStart = query.slice(0, start).lastIndexOf(`
1207
- `) + 1, lineNumber = (query.slice(0, lineStart).match(/\n/g) || []).length, line = query.slice(lineStart, query.indexOf(`
1208
- `, lineStart)), column = start - lineStart, columnEnd = typeof end == "number" ? end - lineStart : void 0;
1209
- return {
1210
- line,
1211
- lineNumber,
1212
- column,
1213
- columnEnd
1214
- };
1215
- }
1216
- function dashLine(column, columnEnd) {
1217
- const line = "-".repeat(column), hats = "^".repeat(columnEnd ? columnEnd - column : 1);
1218
- return `${line}${hats}`;
1219
- }
1220
- function QueryErrorDialog(props) {
1221
- const $ = reactCompilerRuntime.c(7);
1222
- let t0;
1223
- $[0] !== props.error.message ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(ErrorCode, { size: 1, children: props.error.message }), $[0] = props.error.message, $[1] = t0) : t0 = $[1];
1224
- let t1;
1225
- $[2] !== props.error ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(QueryErrorDetails, { error: props.error }), $[2] = props.error, $[3] = t1) : t1 = $[3];
1226
- let t2;
1227
- return $[4] !== t0 || $[5] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 5, marginTop: 2, children: [
1228
- t0,
1229
- t1
1230
- ] }), $[4] = t0, $[5] = t1, $[6] = t2) : t2 = $[6], t2;
1231
- }
1232
- const ResultViewWrapper = styledComponents.styled.div(({
1233
- theme
1234
- }) => {
1235
- const {
1236
- color: color2,
1237
- fonts,
1238
- space
1239
- } = theme.sanity;
1240
- return styledComponents.css`
1241
- & .json-inspector,
1242
- & .json-inspector .json-inspector__selection {
1243
- font-family: ${fonts.code.family};
1244
- font-size: ${fonts.code.sizes[2].fontSize}px;
1245
- line-height: ${fonts.code.sizes[2].lineHeight}px;
1246
- color: var(--card-code-fg-color);
1247
- }
1248
-
1249
- & .json-inspector .json-inspector__leaf {
1250
- padding-left: ${ui.rem(space[4])};
1251
- }
1252
-
1253
- & .json-inspector .json-inspector__leaf.json-inspector__leaf_root {
1254
- padding-top: ${ui.rem(space[0])};
1255
- padding-left: 0;
1256
- }
1257
-
1258
- & .json-inspector > .json-inspector__leaf_root > .json-inspector__line > .json-inspector__key {
1259
- display: none;
1260
- }
1261
-
1262
- & .json-inspector .json-inspector__line {
1263
- display: block;
1264
- position: relative;
1265
- cursor: default;
1266
- }
1267
-
1268
- & .json-inspector .json-inspector__line::after {
1269
- content: '';
1270
- position: absolute;
1271
- top: 0;
1272
- left: -200px;
1273
- right: -50px;
1274
- bottom: 0;
1275
- z-index: -1;
1276
- pointer-events: none;
1277
- }
1278
-
1279
- & .json-inspector .json-inspector__line:hover::after {
1280
- background: var(--card-code-bg-color);
1281
- }
1282
-
1283
- & .json-inspector .json-inspector__leaf_composite > .json-inspector__line {
1284
- cursor: pointer;
1285
- }
1286
-
1287
- & .json-inspector .json-inspector__leaf_composite > .json-inspector__line::before {
1288
- content: '▸ ';
1289
- margin-left: calc(0px - ${ui.rem(space[4])});
1290
- font-size: ${fonts.code.sizes[2].fontSize}px;
1291
- line-height: ${fonts.code.sizes[2].lineHeight}px;
1292
- }
1293
-
1294
- &
1295
- .json-inspector
1296
- .json-inspector__leaf_expanded.json-inspector__leaf_composite
1297
- > .json-inspector__line::before {
1298
- content: '▾ ';
1299
- font-size: ${fonts.code.sizes[2].fontSize}px;
1300
- line-height: ${fonts.code.sizes[2].lineHeight}px;
1301
- }
1302
-
1303
- & .json-inspector .json-inspector__radio,
1304
- & .json-inspector .json-inspector__flatpath {
1305
- display: none;
1306
- }
1307
-
1308
- & .json-inspector .json-inspector__value {
1309
- margin-left: ${ui.rem(space[4] / 2)};
1310
- }
1311
-
1312
- &
1313
- .json-inspector
1314
- > .json-inspector__leaf_root
1315
- > .json-inspector__line
1316
- > .json-inspector__key
1317
- + .json-inspector__value {
1318
- margin: 0;
1319
- }
1320
-
1321
- & .json-inspector .json-inspector__key {
1322
- color: ${color2.syntax.property};
1323
- }
1324
-
1325
- & .json-inspector .json-inspector__value_helper,
1326
- & .json-inspector .json-inspector__value_null {
1327
- color: ${color2.syntax.constant};
1328
- }
1329
-
1330
- & .json-inspector .json-inspector__not-found {
1331
- padding-top: ${ui.rem(space[2])};
1332
- }
1333
-
1334
- & .json-inspector .json-inspector__value_string {
1335
- color: ${color2.syntax.string};
1336
- word-break: break-word;
1337
- }
1338
-
1339
- & .json-inspector .json-inspector__value_boolean {
1340
- color: ${color2.syntax.boolean};
1341
- }
1342
-
1343
- & .json-inspector .json-inspector__value_number {
1344
- color: ${color2.syntax.number};
1345
- }
1346
-
1347
- & .json-inspector .json-inspector__show-original {
1348
- display: inline-block;
1349
- padding: 0 6px;
1350
- cursor: pointer;
1351
- }
1352
-
1353
- & .json-inspector .json-inspector__show-original:hover {
1354
- color: inherit;
1355
- }
1356
-
1357
- & .json-inspector .json-inspector__show-original::before {
1358
- content: '↔';
1359
- }
1360
-
1361
- & .json-inspector .json-inspector__show-original:hover::after {
1362
- content: ' expand';
1363
- }
1364
- `;
1365
- }), lru = new LRU__default.default({
1366
- maxSize: 5e4
1367
- });
1368
- function ResultView(props) {
1369
- const $ = reactCompilerRuntime.c(7), {
1370
- data,
1371
- datasetName
1372
- } = props, workspaceDataset = sanity.useDataset();
1373
- if (isRecord(data) || Array.isArray(data)) {
1374
- const t02 = workspaceDataset === datasetName ? DocumentEditLabel : void 0;
1375
- let t12;
1376
- return $[0] !== data || $[1] !== t02 ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(ResultViewWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(reactJsonInspector.JsonInspector, { data, search: !1, isExpanded, onClick: toggleExpanded, interactiveLabel: t02 }) }), $[0] = data, $[1] = t02, $[2] = t12) : t12 = $[2], t12;
1377
- }
1378
- let t0;
1379
- $[3] !== data ? (t0 = JSON.stringify(data), $[3] = data, $[4] = t0) : t0 = $[4];
1380
- let t1;
1381
- return $[5] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(ui.Code, { language: "json", children: t0 }), $[5] = t0, $[6] = t1) : t1 = $[6], t1;
1382
- }
1383
- function DocumentEditLabel(props) {
1384
- const $ = reactCompilerRuntime.c(5);
1385
- if (props.isKey || !props.keypath.endsWith("_id") && !props.keypath.endsWith("_ref"))
1386
- return null;
1387
- let t0;
1388
- $[0] !== props.value ? (t0 = {
1389
- id: props.value
1390
- }, $[0] = props.value, $[1] = t0) : t0 = $[1];
1391
- let t1;
1392
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(icons.LinkIcon, {}), $[2] = t1) : t1 = $[2];
1393
- let t2;
1394
- return $[3] !== t0 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(router.IntentLink, { intent: "edit", params: t0, children: t1 }), $[3] = t0, $[4] = t2) : t2 = $[4], t2;
1395
- }
1396
- function isExpanded(keyPath, value) {
1397
- const cached = lru.get(keyPath);
1398
- if (typeof cached == "boolean")
1399
- return cached;
1400
- const segments = keyPath.split(".", 4);
1401
- return segments.length === 4 ? !1 : Array.isArray(value) ? !0 : isRecord(value) && !segments.some((key) => isArrayKeyOverLimit(key));
1402
- }
1403
- function toggleExpanded(event) {
1404
- const {
1405
- path
1406
- } = event, current = lru.get(path);
1407
- current !== void 0 && lru.set(path, !current);
1408
- }
1409
- function isRecord(value) {
1410
- return value !== null && typeof value == "object" && !Array.isArray(value);
1411
- }
1412
- const numeric = /^\d+$/;
1413
- function isArrayKeyOverLimit(segment, limit = 10) {
1414
- return numeric.test(segment) && parseInt(segment, 10) > limit;
1415
- }
1416
- function preventSave(evt) {
1417
- return evt.preventDefault();
1418
- }
1419
- function SaveCsvButton(t0) {
1420
- const $ = reactCompilerRuntime.c(9), {
1421
- blobUrl
1422
- } = t0, {
1423
- t
1424
- } = sanity.useTranslation(index.visionLocaleNamespace), isDisabled = !blobUrl, t1 = isDisabled ? void 0 : "query-result.csv", t2 = isDisabled ? preventSave : void 0;
1425
- let t3;
1426
- $[0] !== blobUrl || $[1] !== isDisabled || $[2] !== t1 || $[3] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { as: "a", disabled: isDisabled, download: t1, href: blobUrl, icon: icons.DocumentSheetIcon, mode: "ghost", onClick: t2, text: "CSV", tone: "default" }), $[0] = blobUrl, $[1] = isDisabled, $[2] = t1, $[3] = t2, $[4] = t3) : t3 = $[4];
1427
- const button = t3;
1428
- let t4;
1429
- return $[5] !== button || $[6] !== isDisabled || $[7] !== t ? (t4 = isDisabled ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: t("result.save-result-as-csv.not-csv-encodable"), placement: "top", children: button }) : button, $[5] = button, $[6] = isDisabled, $[7] = t, $[8] = t4) : t4 = $[8], t4;
1430
- }
1431
- function SaveJsonButton(t0) {
1432
- const $ = reactCompilerRuntime.c(2), {
1433
- blobUrl
1434
- } = t0;
1435
- let t1;
1436
- return $[0] !== blobUrl ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { as: "a", download: "query-result.json", href: blobUrl, icon: icons.DocumentSheetIcon, mode: "ghost", text: "JSON", tone: "default" }), $[0] = blobUrl, $[1] = t1) : t1 = $[1], t1;
1437
- }
1438
- function VisionGuiResult(t0) {
1439
- const $ = reactCompilerRuntime.c(67), {
1440
- error,
1441
- queryInProgress,
1442
- queryResult,
1443
- listenInProgress,
1444
- listenMutations,
1445
- dataset,
1446
- queryTime,
1447
- e2eTime
1448
- } = t0, {
1449
- t
1450
- } = sanity.useTranslation(index.visionLocaleNamespace), hasResult = !error && !queryInProgress && typeof queryResult < "u";
1451
- let t1;
1452
- $[0] !== hasResult || $[1] !== queryResult ? (t1 = hasResult ? getJsonBlobUrl(queryResult) : "", $[0] = hasResult, $[1] = queryResult, $[2] = t1) : t1 = $[2];
1453
- const jsonUrl = t1;
1454
- let t2;
1455
- $[3] !== hasResult || $[4] !== queryResult ? (t2 = hasResult ? getCsvBlobUrl(queryResult) : "", $[3] = hasResult, $[4] = queryResult, $[5] = t2) : t2 = $[5];
1456
- const csvUrl = t2, t3 = error ? "critical" : "default", t4 = !!error;
1457
- let t5;
1458
- $[6] !== t ? (t5 = t("result.label"), $[6] = t, $[7] = t5) : t5 = $[7];
1459
- let t6;
1460
- $[8] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(InputBackgroundContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginLeft: 3, children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { muted: !0, children: t5 }) }) }), $[8] = t5, $[9] = t6) : t6 = $[9];
1461
- let t7;
1462
- $[10] !== listenInProgress || $[11] !== listenMutations || $[12] !== queryInProgress ? (t7 = (queryInProgress || listenInProgress && listenMutations.length === 0) && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 3, children: /* @__PURE__ */ jsxRuntime.jsx(DelayedSpinner, {}) }), $[10] = listenInProgress, $[11] = listenMutations, $[12] = queryInProgress, $[13] = t7) : t7 = $[13];
1463
- let t8;
1464
- $[14] !== error ? (t8 = error && /* @__PURE__ */ jsxRuntime.jsx(QueryErrorDialog, { error }), $[14] = error, $[15] = t8) : t8 = $[15];
1465
- let t9;
1466
- $[16] !== dataset || $[17] !== hasResult || $[18] !== queryResult ? (t9 = hasResult && /* @__PURE__ */ jsxRuntime.jsx(ResultView, { data: queryResult, datasetName: dataset }), $[16] = dataset, $[17] = hasResult, $[18] = queryResult, $[19] = t9) : t9 = $[19];
1467
- let t10;
1468
- $[20] !== dataset || $[21] !== listenInProgress || $[22] !== listenMutations ? (t10 = listenInProgress && listenMutations.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ResultView, { data: listenMutations, datasetName: dataset }), $[20] = dataset, $[21] = listenInProgress, $[22] = listenMutations, $[23] = t10) : t10 = $[23];
1469
- let t11;
1470
- $[24] !== t10 || $[25] !== t7 || $[26] !== t8 || $[27] !== t9 ? (t11 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { padding: 3, paddingTop: 5, children: [
1471
- t7,
1472
- t8,
1473
- t9,
1474
- t10
1475
- ] }), $[24] = t10, $[25] = t7, $[26] = t8, $[27] = t9, $[28] = t11) : t11 = $[28];
1476
- let t12;
1477
- $[29] !== t11 || $[30] !== t6 ? (t12 = /* @__PURE__ */ jsxRuntime.jsxs(Result, { overflow: "auto", children: [
1478
- t6,
1479
- t11
1480
- ] }), $[29] = t11, $[30] = t6, $[31] = t12) : t12 = $[31];
1481
- let t13;
1482
- $[32] !== t12 || $[33] !== t3 || $[34] !== t4 ? (t13 = /* @__PURE__ */ jsxRuntime.jsx(ResultInnerContainer, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ResultContainer, { flex: 1, overflow: "hidden", tone: t3, $isInvalid: t4, children: t12 }) }), $[32] = t12, $[33] = t3, $[34] = t4, $[35] = t13) : t13 = $[35];
1483
- let t14;
1484
- $[36] === Symbol.for("react.memo_cache_sentinel") ? (t14 = ["column", "column", "row"], $[36] = t14) : t14 = $[36];
1485
- let t15;
1486
- $[37] !== t ? (t15 = t("result.execution-time-label"), $[37] = t, $[38] = t15) : t15 = $[38];
1487
- let t16;
1488
- $[39] !== queryTime || $[40] !== t ? (t16 = typeof queryTime == "number" ? `${queryTime}ms` : t("result.timing-not-applicable"), $[39] = queryTime, $[40] = t, $[41] = t16) : t16 = $[41];
1489
- let t17;
1490
- $[42] !== t15 || $[43] !== t16 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, children: [
1491
- t15,
1492
- ":",
1493
- " ",
1494
- t16
1495
- ] }) }), $[42] = t15, $[43] = t16, $[44] = t17) : t17 = $[44];
1496
- let t18;
1497
- $[45] !== t ? (t18 = t("result.end-to-end-time-label"), $[45] = t, $[46] = t18) : t18 = $[46];
1498
- let t19;
1499
- $[47] !== e2eTime || $[48] !== t ? (t19 = typeof e2eTime == "number" ? `${e2eTime}ms` : t("result.timing-not-applicable"), $[47] = e2eTime, $[48] = t, $[49] = t19) : t19 = $[49];
1500
- let t20;
1501
- $[50] !== t18 || $[51] !== t19 ? (t20 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginLeft: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, children: [
1502
- t18,
1503
- ":",
1504
- " ",
1505
- t19
1506
- ] }) }), $[50] = t18, $[51] = t19, $[52] = t20) : t20 = $[52];
1507
- let t21;
1508
- $[53] !== t17 || $[54] !== t20 ? (t21 = /* @__PURE__ */ jsxRuntime.jsx(TimingsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsxs(TimingsTextContainer, { align: "center", children: [
1509
- t17,
1510
- t20
1511
- ] }) }), $[53] = t17, $[54] = t20, $[55] = t21) : t21 = $[55];
1512
- let t22;
1513
- $[56] !== csvUrl || $[57] !== hasResult || $[58] !== jsonUrl || $[59] !== t ? (t22 = hasResult && /* @__PURE__ */ jsxRuntime.jsx(DownloadsCard, { paddingX: 4, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsx(SaveResultLabel, { muted: !0, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.Translate, { components: {
1514
- SaveResultButtons: () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1515
- /* @__PURE__ */ jsxRuntime.jsx(SaveJsonButton, { blobUrl: jsonUrl }),
1516
- /* @__PURE__ */ jsxRuntime.jsx(SaveCsvButton, { blobUrl: csvUrl })
1517
- ] })
1518
- }, i18nKey: "result.save-result-as-format", t }) }) }), $[56] = csvUrl, $[57] = hasResult, $[58] = jsonUrl, $[59] = t, $[60] = t22) : t22 = $[60];
1519
- let t23;
1520
- $[61] !== t21 || $[62] !== t22 ? (t23 = /* @__PURE__ */ jsxRuntime.jsxs(ResultFooter, { justify: "space-between", direction: t14, children: [
1521
- t21,
1522
- t22
1523
- ] }), $[61] = t21, $[62] = t22, $[63] = t23) : t23 = $[63];
1524
- let t24;
1525
- return $[64] !== t13 || $[65] !== t23 ? (t24 = /* @__PURE__ */ jsxRuntime.jsxs(ResultOuterContainer, { direction: "column", "data-testid": "vision-result", children: [
1526
- t13,
1527
- t23
1528
- ] }), $[64] = t13, $[65] = t23, $[66] = t24) : t24 = $[66], t24;
1529
- }
1530
- function nodeContains(node, other) {
1531
- return !node || !other ? !1 : node === other || !!(node.compareDocumentPosition(other) & 16);
1532
- }
1533
- const sanityUrl = /\.(?:api|apicdn)\.sanity\.(?:io|work)\/(vX|v1|v\d{4}-\d\d-\d\d)\/.*?(?:query|listen)\/(.*?)\?(.*)/, isRunHotkey = (event) => isHotkeyEsm.isHotkey("ctrl+enter", event) || isHotkeyEsm.isHotkey("mod+enter", event);
1534
- function VisionGui(props) {
1535
- const $ = reactCompilerRuntime.c(210), {
1536
- datasets,
1537
- config,
1538
- projectId,
1539
- defaultDataset
1540
- } = props, toast = ui.useToast(), {
1541
- t
1542
- } = sanity.useTranslation(index.visionLocaleNamespace), {
1543
- perspectiveStack
1544
- } = sanity.usePerspective(), isScheduledDraftsEnabled = sanity.useScheduledDraftsEnabled(), {
1545
- data: t0
1546
- } = sanity.useActiveReleases();
1547
- let t1;
1548
- $[0] !== t0 ? (t1 = t0 === void 0 ? [] : t0, $[0] = t0, $[1] = t1) : t1 = $[1];
1549
- const releases = t1, isDraftModelEnabled = sanity.useWorkspace().document.drafts.enabled, editorQueryRef = react.useRef(null), editorParamsRef = react.useRef(null), visionRootRef = react.useRef(null), customApiVersionElementRef = react.useRef(null), querySubscriptionRef = react.useRef(void 0), listenSubscriptionRef = react.useRef(void 0);
1550
- let t2;
1551
- $[2] !== projectId ? (t2 = () => getLocalStorage(projectId || "default"), $[2] = projectId, $[3] = t2) : t2 = $[3];
1552
- const [localStorage2] = react.useState(t2);
1553
- let t3;
1554
- $[4] !== defaultDataset || $[5] !== localStorage2 ? (t3 = localStorage2.get("dataset", defaultDataset), $[4] = defaultDataset, $[5] = localStorage2, $[6] = t3) : t3 = $[6];
1555
- const storedDataset = t3;
1556
- let t4;
1557
- $[7] !== config.defaultApiVersion || $[8] !== localStorage2 ? (t4 = localStorage2.get("apiVersion", prefixApiVersion(`${config.defaultApiVersion}`)), $[7] = config.defaultApiVersion, $[8] = localStorage2, $[9] = t4) : t4 = $[9];
1558
- const storedApiVersion = t4;
1559
- let t5;
1560
- $[10] !== localStorage2 ? (t5 = localStorage2.get("query", ""), $[10] = localStorage2, $[11] = t5) : t5 = $[11];
1561
- const storedQuery = t5;
1562
- let t6;
1563
- $[12] !== localStorage2 ? (t6 = localStorage2.get("params", `{
1564
-
1565
- }`), $[12] = localStorage2, $[13] = t6) : t6 = $[13];
1566
- const storedParams = t6;
1567
- let t7;
1568
- $[14] !== localStorage2 ? (t7 = localStorage2.get("perspective", void 0), $[14] = localStorage2, $[15] = t7) : t7 = $[15];
1569
- const storedPerspective = t7;
1570
- let t8;
1571
- $[16] !== datasets || $[17] !== defaultDataset || $[18] !== storedDataset ? (t8 = () => datasets.includes(storedDataset) ? storedDataset : datasets.includes(defaultDataset) ? defaultDataset : datasets[0], $[16] = datasets, $[17] = defaultDataset, $[18] = storedDataset, $[19] = t8) : t8 = $[19];
1572
- const [dataset, setDataset] = react.useState(t8);
1573
- let t9;
1574
- $[20] !== storedApiVersion ? (t9 = () => API_VERSIONS.includes(storedApiVersion) ? storedApiVersion : DEFAULT_API_VERSION, $[20] = storedApiVersion, $[21] = t9) : t9 = $[21];
1575
- const [apiVersion, setApiVersion] = react.useState(t9);
1576
- let t10;
1577
- $[22] !== storedApiVersion ? (t10 = () => API_VERSIONS.includes(storedApiVersion) ? !1 : storedApiVersion, $[22] = storedApiVersion, $[23] = t10) : t10 = $[23];
1578
- const [customApiVersion, setCustomApiVersion] = react.useState(t10), [perspective, setPerspectiveState] = react.useState(storedPerspective || "raw");
1579
- let t11;
1580
- $[24] !== customApiVersion ? (t11 = customApiVersion ? validateApiVersion(customApiVersion) : !0, $[24] = customApiVersion, $[25] = t11) : t11 = $[25];
1581
- const isValidApiVersion = t11, [url, setUrl] = react.useState(void 0);
1582
- let t12;
1583
- $[26] !== storedQuery ? (t12 = () => typeof storedQuery == "string" ? storedQuery : "", $[26] = storedQuery, $[27] = t12) : t12 = $[27];
1584
- const [query, setQuery] = react.useState(t12), [rawParams, setRawParams] = react.useState(storedParams);
1585
- let t13;
1586
- $[28] !== rawParams || $[29] !== t ? (t13 = parseParams(rawParams, t), $[28] = rawParams, $[29] = t, $[30] = t13) : t13 = $[30];
1587
- const params = t13, [queryResult, setQueryResult] = react.useState(void 0);
1588
- let t14;
1589
- $[31] === Symbol.for("react.memo_cache_sentinel") ? (t14 = [], $[31] = t14) : t14 = $[31];
1590
- const [listenMutations, setListenMutations] = react.useState(t14), [error, setError] = react.useState(void 0), [queryTime, setQueryTime] = react.useState(void 0), [e2eTime, setE2eTime] = react.useState(void 0), [queryInProgress, setQueryInProgress] = react.useState(!1), [listenInProgress, setListenInProgress] = react.useState(!1), [isQueryRecallCollapsed, setIsQueryRecallCollapsed] = react.useState(!1);
1591
- let t15;
1592
- $[32] === Symbol.for("react.memo_cache_sentinel") ? (t15 = {
1593
- visionRootRef
1594
- }, $[32] = t15) : t15 = $[32];
1595
- const {
1596
- paneSizeOptions,
1597
- isNarrowBreakpoint
1598
- } = usePaneSize(t15);
1599
- let t16;
1600
- bb0: {
1601
- if (!isScheduledDraftsEnabled) {
1602
- t16 = void 0;
1603
- break bb0;
1604
- }
1605
- let t172;
1606
- if ($[33] !== isDraftModelEnabled || $[34] !== releases) {
1607
- const scheduledDraftReleases = releases.filter(_temp$1), releaseIds = sanity.sortReleases(scheduledDraftReleases).map(_temp2$1);
1608
- let t182;
1609
- $[36] !== isDraftModelEnabled ? (t182 = isDraftModelEnabled ? ["drafts"] : ["published"], $[36] = isDraftModelEnabled, $[37] = t182) : t182 = $[37];
1610
- const defaultPerspective = t182;
1611
- t172 = [...releaseIds, ...defaultPerspective], $[33] = isDraftModelEnabled, $[34] = releases, $[35] = t172;
1612
- } else
1613
- t172 = $[35];
1614
- t16 = t172;
1615
- }
1616
- const scheduledDraftsStack = t16, t17 = isValidApiVersion && customApiVersion ? customApiVersion : apiVersion;
1617
- let t18;
1618
- $[38] !== t17 ? (t18 = {
1619
- apiVersion: t17
1620
- }, $[38] = t17, $[39] = t18) : t18 = $[39];
1621
- const _client = sanity.useClient(t18);
1622
- let t19;
1623
- $[40] !== _client || $[41] !== apiVersion || $[42] !== customApiVersion || $[43] !== dataset || $[44] !== isValidApiVersion || $[45] !== perspective || $[46] !== perspectiveStack || $[47] !== scheduledDraftsStack ? (t19 = _client.withConfig({
1624
- apiVersion: isValidApiVersion && customApiVersion ? customApiVersion : apiVersion,
1625
- perspective: getActivePerspective({
1626
- visionPerspective: perspective,
1627
- perspectiveStack,
1628
- scheduledDraftsStack
1629
- }),
1630
- dataset,
1631
- allowReconfigure: !0
1632
- }), $[40] = _client, $[41] = apiVersion, $[42] = customApiVersion, $[43] = dataset, $[44] = isValidApiVersion, $[45] = perspective, $[46] = perspectiveStack, $[47] = scheduledDraftsStack, $[48] = t19) : t19 = $[48];
1633
- const client = t19;
1634
- let t20;
1635
- $[49] === Symbol.for("react.memo_cache_sentinel") ? (t20 = () => {
1636
- querySubscriptionRef.current && (querySubscriptionRef.current.unsubscribe(), querySubscriptionRef.current = void 0);
1637
- }, $[49] = t20) : t20 = $[49];
1638
- const cancelQuerySubscription = t20;
1639
- let t21;
1640
- $[50] === Symbol.for("react.memo_cache_sentinel") ? (t21 = () => {
1641
- listenSubscriptionRef.current && (listenSubscriptionRef.current.unsubscribe(), listenSubscriptionRef.current = void 0);
1642
- }, $[50] = t21) : t21 = $[50];
1643
- const cancelListenerSubscription = t21;
1644
- let t22;
1645
- $[51] !== apiVersion || $[52] !== client || $[53] !== customApiVersion || $[54] !== dataset || $[55] !== isValidApiVersion || $[56] !== localStorage2 || $[57] !== params.parsed || $[58] !== perspective || $[59] !== perspectiveStack || $[60] !== query || $[61] !== queryInProgress || $[62] !== scheduledDraftsStack || $[63] !== t ? (t22 = (options) => {
1646
- if (queryInProgress) {
1647
- cancelQuerySubscription(), cancelListenerSubscription(), setQueryInProgress(!1);
1648
- return;
1649
- }
1650
- const context = {
1651
- query: options?.query || query,
1652
- dataset: options?.dataset || dataset,
1653
- params: parseParams(JSON.stringify(options?.params || params.parsed, null, 2), t),
1654
- perspective: getActivePerspective({
1655
- visionPerspective: options && "perspective" in options ? options.perspective : perspective,
1656
- perspectiveStack,
1657
- scheduledDraftsStack
1658
- }),
1659
- apiVersion: options?.apiVersion || (customApiVersion && isValidApiVersion ? customApiVersion : apiVersion)
1660
- };
1661
- if (localStorage2.set("query", context.query), localStorage2.set("params", context.params.raw), cancelListenerSubscription(), setQueryInProgress(!context.params.error && !!context.query), setListenInProgress(!1), setListenMutations([]), setError(context.params.error ? new Error(context.params.error) : void 0), setQueryResult(void 0), setQueryTime(void 0), setE2eTime(void 0), context.params.error)
1662
- return;
1663
- const urlQueryOpts = {
1664
- perspective: context.perspective ?? []
1665
- }, ctxClient = client.withConfig({
1666
- apiVersion: context.apiVersion,
1667
- dataset: context.dataset,
1668
- perspective: context.perspective
1669
- }), newUrl = ctxClient.getUrl(ctxClient.getDataUrl("query", encodeQueryString(context.query, context.params.parsed, urlQueryOpts)));
1670
- setUrl(newUrl);
1671
- const queryStart = Date.now();
1672
- querySubscriptionRef.current = ctxClient.observable.fetch(context.query, context.params.parsed, {
1673
- filterResponse: !1,
1674
- tag: "vision"
1675
- }).subscribe({
1676
- next: (res) => {
1677
- setQueryTime(res.ms), setE2eTime(Date.now() - queryStart), setQueryResult(res.result), setQueryInProgress(!1), setError(void 0);
1678
- },
1679
- error: (err) => {
1680
- setError(err), setQueryInProgress(!1);
1681
- }
1682
- });
1683
- }, $[51] = apiVersion, $[52] = client, $[53] = customApiVersion, $[54] = dataset, $[55] = isValidApiVersion, $[56] = localStorage2, $[57] = params.parsed, $[58] = perspective, $[59] = perspectiveStack, $[60] = query, $[61] = queryInProgress, $[62] = scheduledDraftsStack, $[63] = t, $[64] = t22) : t22 = $[64];
1684
- const handleQueryExecution = t22;
1685
- let t23;
1686
- $[65] !== handleQueryExecution || $[66] !== localStorage2 ? (t23 = (newPerspective) => {
1687
- newPerspective !== void 0 && !isSupportedPerspective(newPerspective) || (setPerspectiveState(newPerspective), localStorage2.set("perspective", newPerspective), handleQueryExecution({
1688
- perspective: newPerspective
1689
- }));
1690
- }, $[65] = handleQueryExecution, $[66] = localStorage2, $[67] = t23) : t23 = $[67];
1691
- const setPerspective = t23;
1692
- let t24;
1693
- $[68] !== handleQueryExecution || $[69] !== localStorage2 ? (t24 = (evt) => {
1694
- const newDataset = evt.target.value;
1695
- localStorage2.set("dataset", newDataset), setDataset(newDataset), handleQueryExecution({
1696
- dataset: newDataset
1697
- });
1698
- }, $[68] = handleQueryExecution, $[69] = localStorage2, $[70] = t24) : t24 = $[70];
1699
- const handleChangeDataset = t24;
1700
- let t25;
1701
- $[71] !== handleQueryExecution || $[72] !== localStorage2 ? (t25 = (evt_0) => {
1702
- const newApiVersion = evt_0.target.value;
1703
- if (newApiVersion?.toLowerCase() === "other") {
1704
- setCustomApiVersion("v"), customApiVersionElementRef.current?.focus();
1705
- return;
1706
- }
1707
- setApiVersion(newApiVersion), setCustomApiVersion(!1), localStorage2.set("apiVersion", newApiVersion), handleQueryExecution({
1708
- apiVersion: newApiVersion
1709
- });
1710
- }, $[71] = handleQueryExecution, $[72] = localStorage2, $[73] = t25) : t25 = $[73];
1711
- const handleChangeApiVersion = t25;
1712
- let t26;
1713
- $[74] !== handleQueryExecution || $[75] !== localStorage2 ? (t26 = (evt_1) => {
1714
- const newCustomApiVersion = evt_1.target.value || "";
1715
- setCustomApiVersion(newCustomApiVersion || "v"), validateApiVersion(newCustomApiVersion) && (setApiVersion(newCustomApiVersion), localStorage2.set("apiVersion", newCustomApiVersion), handleQueryExecution({
1716
- apiVersion: newCustomApiVersion
1717
- }));
1718
- }, $[74] = handleQueryExecution, $[75] = localStorage2, $[76] = t26) : t26 = $[76];
1719
- const handleCustomApiVersionChange = t26;
1720
- let t27;
1721
- $[77] !== setPerspective ? (t27 = (evt_2) => {
1722
- const newPerspective_0 = evt_2.target.value;
1723
- setPerspective(newPerspective_0 === "default" ? void 0 : newPerspective_0);
1724
- }, $[77] = setPerspective, $[78] = t27) : t27 = $[78];
1725
- const handleChangePerspective = t27;
1726
- let t28;
1727
- $[79] === Symbol.for("react.memo_cache_sentinel") ? (t28 = (evt_3) => {
1728
- evt_3.type === "mutation" && setListenMutations((prevMutations) => prevMutations.length === 50 ? [evt_3, ...prevMutations.slice(0, 49)] : [evt_3, ...prevMutations]);
1729
- }, $[79] = t28) : t28 = $[79];
1730
- const handleListenerEvent = t28;
1731
- let t29;
1732
- $[80] !== client || $[81] !== listenInProgress || $[82] !== localStorage2 || $[83] !== params.error || $[84] !== params.parsed || $[85] !== params.raw || $[86] !== query ? (t29 = () => {
1733
- if (listenInProgress) {
1734
- cancelListenerSubscription(), setListenInProgress(!1);
1735
- return;
1736
- }
1737
- const newUrl_0 = client.getDataUrl("listen", encodeQueryString(query, params.parsed, {})), shouldExecute = !params.error && query.trim().length > 0;
1738
- localStorage2.set("query", query), localStorage2.set("params", params.raw), cancelQuerySubscription(), setUrl(newUrl_0), setListenMutations([]), setQueryInProgress(!1), setQueryResult(void 0), setListenInProgress(shouldExecute), setError(params.error ? new Error(params.error) : void 0), setQueryTime(void 0), setE2eTime(void 0), shouldExecute && (listenSubscriptionRef.current = client.listen(query, params.parsed, {
1739
- events: ["mutation", "welcome"],
1740
- includeAllVersions: !0
1741
- }).subscribe({
1742
- next: handleListenerEvent,
1743
- error: (err_0) => {
1744
- setError(err_0), setListenInProgress(!1);
1745
- }
1746
- }));
1747
- }, $[80] = client, $[81] = listenInProgress, $[82] = localStorage2, $[83] = params.error, $[84] = params.parsed, $[85] = params.raw, $[86] = query, $[87] = t29) : t29 = $[87];
1748
- const handleListenExecution = t29;
1749
- let t30;
1750
- $[88] !== localStorage2 ? (t30 = (value) => {
1751
- setRawParams(value), localStorage2.set("params", value);
1752
- }, $[88] = localStorage2, $[89] = t30) : t30 = $[89];
1753
- const handleParamsChange = t30;
1754
- let t31;
1755
- $[90] !== apiVersion || $[91] !== dataset || $[92] !== datasets || $[93] !== perspective || $[94] !== toast ? (t31 = (data) => {
1756
- const match = data.match(sanityUrl);
1757
- if (!match)
1758
- return null;
1759
- const [, usedApiVersion, usedDataset, urlQuery] = match, qs = new URLSearchParams(urlQuery), parts = parseApiQueryString(qs);
1760
- if (!parts)
1761
- return null;
1762
- let newApiVersion_0, newCustomApiVersion_0;
1763
- validateApiVersion(usedApiVersion) && (API_VERSIONS.includes(usedApiVersion) ? (newApiVersion_0 = usedApiVersion, newCustomApiVersion_0 = !1) : newCustomApiVersion_0 = usedApiVersion);
1764
- const newPerspective_1 = isSupportedPerspective(parts.options.perspective) && !isVirtualPerspective(parts.options.perspective) ? parts.options.perspective : void 0;
1765
- return newPerspective_1 && (!isSupportedPerspective(parts.options.perspective) || isVirtualPerspective(parts.options.perspective)) && toast.push({
1766
- closable: !0,
1767
- id: "vision-paste-unsupported-perspective",
1768
- status: "warning",
1769
- title: 'Perspective in pasted url is currently not supported. Falling back to "raw"'
1770
- }), {
1771
- query: parts.query,
1772
- params: parts.params,
1773
- rawParams: JSON.stringify(parts.params, null, 2),
1774
- dataset: datasets.includes(usedDataset) ? usedDataset : dataset,
1775
- apiVersion: newApiVersion_0 || apiVersion,
1776
- customApiVersion: newCustomApiVersion_0,
1777
- perspective: newPerspective_1 || perspective,
1778
- url: data
1779
- };
1780
- }, $[90] = apiVersion, $[91] = dataset, $[92] = datasets, $[93] = perspective, $[94] = toast, $[95] = t31) : t31 = $[95];
1781
- const getStateFromUrl = t31;
1782
- let t32;
1783
- $[96] !== handleQueryExecution || $[97] !== localStorage2 ? (t32 = (parsedUrlObj) => {
1784
- setDataset(parsedUrlObj.dataset), setQuery(parsedUrlObj.query), setRawParams(parsedUrlObj.rawParams), setApiVersion(parsedUrlObj.apiVersion), parsedUrlObj.customApiVersion && setCustomApiVersion(parsedUrlObj.customApiVersion), setPerspectiveState(parsedUrlObj.perspective), setUrl(parsedUrlObj.url), editorQueryRef.current?.resetEditorContent(parsedUrlObj.query), editorParamsRef.current?.resetEditorContent(parsedUrlObj.rawParams), localStorage2.merge({
1785
- query: parsedUrlObj.query,
1786
- params: parsedUrlObj.rawParams,
1787
- dataset: parsedUrlObj.dataset,
1788
- apiVersion: parsedUrlObj.customApiVersion || parsedUrlObj.apiVersion,
1789
- perspective: parsedUrlObj.perspective
1790
- }), handleQueryExecution(parsedUrlObj);
1791
- }, $[96] = handleQueryExecution, $[97] = localStorage2, $[98] = t32) : t32 = $[98];
1792
- const setStateFromParsedUrl = t32;
1793
- let t33;
1794
- $[99] !== getStateFromUrl || $[100] !== setStateFromParsedUrl || $[101] !== toast ? (t33 = (evt_4) => {
1795
- if (!evt_4.clipboardData)
1796
- return;
1797
- const data_0 = evt_4.clipboardData.getData("text/plain");
1798
- evt_4.preventDefault();
1799
- const urlState = getStateFromUrl(data_0);
1800
- urlState && (setStateFromParsedUrl(urlState), toast.push({
1801
- closable: !0,
1802
- id: "vision-paste",
1803
- status: "info",
1804
- title: "Parsed URL to query"
1805
- }));
1806
- }, $[99] = getStateFromUrl, $[100] = setStateFromParsedUrl, $[101] = toast, $[102] = t33) : t33 = $[102];
1807
- const handlePaste = t33;
1808
- let t34;
1809
- $[103] !== handleQueryExecution || $[104] !== params.valid ? (t34 = (event) => {
1810
- const isWithinRoot = visionRootRef.current && nodeContains(visionRootRef.current, event.target);
1811
- isRunHotkey(event) && isWithinRoot && params.valid && (handleQueryExecution(), event.preventDefault(), event.stopPropagation());
1812
- }, $[103] = handleQueryExecution, $[104] = params.valid, $[105] = t34) : t34 = $[105];
1813
- const handleKeyDown = t34;
1814
- let t35, t36;
1815
- $[106] !== handleKeyDown || $[107] !== handlePaste ? (t35 = () => (window.document.addEventListener("paste", handlePaste), window.document.addEventListener("keydown", handleKeyDown), () => {
1816
- window.document.removeEventListener("paste", handlePaste), window.document.removeEventListener("keydown", handleKeyDown);
1817
- }), t36 = [handleKeyDown, handlePaste], $[106] = handleKeyDown, $[107] = handlePaste, $[108] = t35, $[109] = t36) : (t35 = $[108], t36 = $[109]), react.useEffect(t35, t36);
1818
- let t37, t38;
1819
- $[110] === Symbol.for("react.memo_cache_sentinel") ? (t37 = () => () => {
1820
- cancelQuerySubscription(), cancelListenerSubscription();
1821
- }, t38 = [cancelQuerySubscription, cancelListenerSubscription], $[110] = t37, $[111] = t38) : (t37 = $[110], t38 = $[111]), react.useEffect(t37, t38);
1822
- let t39;
1823
- $[112] !== setPerspective ? (t39 = (stack) => {
1824
- stack.length > 0 && setPerspective("pinnedRelease");
1825
- }, $[112] = setPerspective, $[113] = t39) : t39 = $[113];
1826
- const handleStudioPerspectiveChange = useEffectEvent.useEffectEvent(t39);
1827
- let t40;
1828
- $[114] !== handleStudioPerspectiveChange || $[115] !== perspectiveStack ? (t40 = () => {
1829
- handleStudioPerspectiveChange(perspectiveStack);
1830
- }, $[114] = handleStudioPerspectiveChange, $[115] = perspectiveStack, $[116] = t40) : t40 = $[116];
1831
- let t41;
1832
- $[117] !== perspectiveStack ? (t41 = [perspectiveStack], $[117] = perspectiveStack, $[118] = t41) : t41 = $[118], react.useEffect(t40, t41);
1833
- let t42;
1834
- $[119] !== client || $[120] !== perspective || $[121] !== perspectiveStack || $[122] !== scheduledDraftsStack ? (t42 = (queryString, queryParams) => {
1835
- const urlQueryOpts_0 = {
1836
- perspective: getActivePerspective({
1837
- visionPerspective: perspective,
1838
- perspectiveStack,
1839
- scheduledDraftsStack
1840
- }) ?? []
1841
- };
1842
- return client.getUrl(client.getDataUrl("query", encodeQueryString(queryString, queryParams, urlQueryOpts_0)));
1843
- }, $[119] = client, $[120] = perspective, $[121] = perspectiveStack, $[122] = scheduledDraftsStack, $[123] = t42) : t42 = $[123];
1844
- const generateUrl = t42;
1845
- let t43;
1846
- $[124] !== apiVersion || $[125] !== customApiVersion || $[126] !== dataset || $[127] !== datasets || $[128] !== handleChangeApiVersion || $[129] !== handleChangeDataset || $[130] !== handleChangePerspective || $[131] !== handleCustomApiVersionChange || $[132] !== isScheduledDraftsEnabled || $[133] !== isValidApiVersion || $[134] !== perspective || $[135] !== url ? (t43 = /* @__PURE__ */ jsxRuntime.jsx(VisionGuiHeader, { apiVersion, customApiVersion, dataset, datasets, onChangeDataset: handleChangeDataset, onChangeApiVersion: handleChangeApiVersion, customApiVersionElementRef, onCustomApiVersionChange: handleCustomApiVersionChange, isValidApiVersion, onChangePerspective: handleChangePerspective, url, perspective, isScheduledDraftsEnabled }), $[124] = apiVersion, $[125] = customApiVersion, $[126] = dataset, $[127] = datasets, $[128] = handleChangeApiVersion, $[129] = handleChangeDataset, $[130] = handleChangePerspective, $[131] = handleCustomApiVersionChange, $[132] = isScheduledDraftsEnabled, $[133] = isValidApiVersion, $[134] = perspective, $[135] = url, $[136] = t43) : t43 = $[136];
1847
- const t44 = isQueryRecallCollapsed ? window.innerWidth : window.innerWidth - 275, t45 = isNarrowBreakpoint ? "vertical" : "horizontal", t46 = isNarrowBreakpoint ? paneSizeOptions.defaultSize : paneSizeOptions.minSize, t47 = paneSizeOptions.size, t48 = paneSizeOptions.allowResize, t49 = isNarrowBreakpoint ? paneSizeOptions.minSize : 100, t50 = paneSizeOptions.maxSize;
1848
- let t51;
1849
- $[137] !== t ? (t51 = t("query.label"), $[137] = t, $[138] = t51) : t51 = $[138];
1850
- let t52;
1851
- $[139] !== t51 ? (t52 = /* @__PURE__ */ jsxRuntime.jsx(InputBackgroundContainerLeft, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { muted: !0, children: t51 }) }) }), $[139] = t51, $[140] = t52) : t52 = $[140];
1852
- let t53;
1853
- $[141] !== query ? (t53 = /* @__PURE__ */ jsxRuntime.jsx(VisionCodeMirror, { initialValue: query, onChange: setQuery, ref: editorQueryRef }), $[141] = query, $[142] = t53) : t53 = $[142];
1854
- let t54;
1855
- $[143] !== t52 || $[144] !== t53 ? (t54 = /* @__PURE__ */ jsxRuntime.jsx(InputContainer, { display: "flex", "data-testid": "vision-query-editor", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { flex: 1, children: [
1856
- t52,
1857
- t53
1858
- ] }) }), $[143] = t52, $[144] = t53, $[145] = t54) : t54 = $[145];
1859
- let t55;
1860
- $[146] !== handleParamsChange || $[147] !== params.error || $[148] !== params.raw || $[149] !== params.valid ? (t55 = /* @__PURE__ */ jsxRuntime.jsx(ParamsEditor, { value: params.raw, onChange: handleParamsChange, paramsError: params.error, hasValidParams: params.valid, editorRef: editorParamsRef }), $[146] = handleParamsChange, $[147] = params.error, $[148] = params.raw, $[149] = params.valid, $[150] = t55) : t55 = $[150];
1861
- let t56;
1862
- $[151] !== handleListenExecution || $[152] !== handleQueryExecution || $[153] !== listenInProgress || $[154] !== params.valid || $[155] !== queryInProgress ? (t56 = /* @__PURE__ */ jsxRuntime.jsx(VisionGuiControls, { hasValidParams: params.valid, queryInProgress, listenInProgress, onQueryExecution: handleQueryExecution, onListenExecution: handleListenExecution }), $[151] = handleListenExecution, $[152] = handleQueryExecution, $[153] = listenInProgress, $[154] = params.valid, $[155] = queryInProgress, $[156] = t56) : t56 = $[156];
1863
- let t57;
1864
- $[157] !== t55 || $[158] !== t56 ? (t57 = /* @__PURE__ */ jsxRuntime.jsxs(InputContainer, { display: "flex", children: [
1865
- t55,
1866
- t56
1867
- ] }), $[157] = t55, $[158] = t56, $[159] = t57) : t57 = $[159];
1868
- let t58;
1869
- $[160] !== paneSizeOptions.allowResize || $[161] !== paneSizeOptions.maxSize || $[162] !== paneSizeOptions.size || $[163] !== t46 || $[164] !== t49 || $[165] !== t54 || $[166] !== t57 ? (t58 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { height: "stretch", flex: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(reactSplitPane.SplitPane, { className: "sidebarPanes", split: "horizontal", defaultSize: t46, size: t47, allowResize: t48, minSize: t49, maxSize: t50, primary: "first", children: [
1870
- t54,
1871
- t57
1872
- ] }) }), $[160] = paneSizeOptions.allowResize, $[161] = paneSizeOptions.maxSize, $[162] = paneSizeOptions.size, $[163] = t46, $[164] = t49, $[165] = t54, $[166] = t57, $[167] = t58) : t58 = $[167];
1873
- let t59;
1874
- $[168] !== dataset || $[169] !== e2eTime || $[170] !== error || $[171] !== listenInProgress || $[172] !== listenMutations || $[173] !== queryInProgress || $[174] !== queryResult || $[175] !== queryTime ? (t59 = /* @__PURE__ */ jsxRuntime.jsx(VisionGuiResult, { error, queryInProgress, queryResult, listenInProgress, listenMutations, dataset, queryTime, e2eTime }), $[168] = dataset, $[169] = e2eTime, $[170] = error, $[171] = listenInProgress, $[172] = listenMutations, $[173] = queryInProgress, $[174] = queryResult, $[175] = queryTime, $[176] = t59) : t59 = $[176];
1875
- let t60;
1876
- $[177] !== t45 || $[178] !== t58 || $[179] !== t59 ? (t60 = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { height: "stretch", flex: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(reactSplitPane.SplitPane, { className: "sidebarPanes", split: t45, minSize: 300, children: [
1877
- t58,
1878
- t59
1879
- ] }) }), $[177] = t45, $[178] = t58, $[179] = t59, $[180] = t60) : t60 = $[180];
1880
- let t61;
1881
- $[181] === Symbol.for("react.memo_cache_sentinel") ? (t61 = {
1882
- position: "relative",
1883
- height: "100%"
1884
- }, $[181] = t61) : t61 = $[181];
1885
- let t62;
1886
- $[182] === Symbol.for("react.memo_cache_sentinel") ? (t62 = {
1887
- position: "absolute",
1888
- left: -32,
1889
- top: "50%",
1890
- transform: "translateY(-50%)",
1891
- zIndex: 100,
1892
- pointerEvents: "auto"
1893
- }, $[182] = t62) : t62 = $[182];
1894
- let t63;
1895
- $[183] !== isQueryRecallCollapsed ? (t63 = () => setIsQueryRecallCollapsed(!isQueryRecallCollapsed), $[183] = isQueryRecallCollapsed, $[184] = t63) : t63 = $[184];
1896
- let t64;
1897
- $[185] === Symbol.for("react.memo_cache_sentinel") ? (t64 = {
1898
- display: "flex",
1899
- alignItems: "center",
1900
- height: "100%"
1901
- }, $[185] = t64) : t64 = $[185];
1902
- let t65;
1903
- $[186] !== isQueryRecallCollapsed ? (t65 = /* @__PURE__ */ jsxRuntime.jsx("div", { style: t64, children: isQueryRecallCollapsed ? /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronLeftIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}) }), $[186] = isQueryRecallCollapsed, $[187] = t65) : t65 = $[187];
1904
- let t66;
1905
- $[188] !== t63 || $[189] !== t65 ? (t66 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { mode: "ghost", padding: 2, style: t62, onClick: t63, children: t65 }), $[188] = t63, $[189] = t65, $[190] = t66) : t66 = $[190];
1906
- let t67;
1907
- $[191] !== params.parsed ? (t67 = params.parsed || {}, $[191] = params.parsed, $[192] = t67) : t67 = $[192];
1908
- let t68;
1909
- $[193] !== generateUrl || $[194] !== getStateFromUrl || $[195] !== query || $[196] !== setStateFromParsedUrl || $[197] !== t67 || $[198] !== url ? (t68 = /* @__PURE__ */ jsxRuntime.jsx(QueryRecall, { url, getStateFromUrl, setStateFromParsedUrl, currentQuery: query, currentParams: t67, generateUrl }), $[193] = generateUrl, $[194] = getStateFromUrl, $[195] = query, $[196] = setStateFromParsedUrl, $[197] = t67, $[198] = url, $[199] = t68) : t68 = $[199];
1910
- let t69;
1911
- $[200] !== t66 || $[201] !== t68 ? (t69 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { style: t61, children: [
1912
- t66,
1913
- t68
1914
- ] }), $[200] = t66, $[201] = t68, $[202] = t69) : t69 = $[202];
1915
- let t70;
1916
- $[203] !== t44 || $[204] !== t60 || $[205] !== t69 ? (t70 = /* @__PURE__ */ jsxRuntime.jsx(SplitpaneContainer, { flex: "auto", children: /* @__PURE__ */ jsxRuntime.jsxs(reactSplitPane.SplitPane, { minSize: 800, defaultSize: window.innerWidth - 275, size: t44, maxSize: -225, primary: "first", children: [
1917
- t60,
1918
- t69
1919
- ] }) }), $[203] = t44, $[204] = t60, $[205] = t69, $[206] = t70) : t70 = $[206];
1920
- let t71;
1921
- return $[207] !== t43 || $[208] !== t70 ? (t71 = /* @__PURE__ */ jsxRuntime.jsxs(Root, { direction: "column", height: "fill", ref: visionRootRef, sizing: "border", overflow: "hidden", "data-testid": "vision-root", children: [
1922
- t43,
1923
- t70
1924
- ] }), $[207] = t43, $[208] = t70, $[209] = t71) : t71 = $[209], t71;
1925
- }
1926
- function _temp2$1(release_0) {
1927
- return sanity.getReleaseIdFromReleaseDocumentId(release_0._id);
1928
- }
1929
- function _temp$1(release) {
1930
- return sanity.isCardinalityOneRelease(release) && release.state === "scheduled";
1931
- }
1932
- function useDatasets(t0) {
1933
- const $ = reactCompilerRuntime.c(7), {
1934
- client,
1935
- datasets: configDatasets
1936
- } = t0;
1937
- let t1;
1938
- bb0: {
1939
- if (Array.isArray(configDatasets)) {
1940
- let t22;
1941
- $[0] !== configDatasets ? (t22 = rxjs.of(configDatasets), $[0] = configDatasets, $[1] = t22) : t22 = $[1], t1 = t22;
1942
- break bb0;
1943
- }
1944
- let t2;
1945
- if ($[2] !== client.observable.datasets || $[3] !== configDatasets) {
1946
- let t3;
1947
- $[5] !== configDatasets ? (t3 = (result) => typeof configDatasets == "function" ? configDatasets(result).map(_temp) : result.map(_temp2), $[5] = configDatasets, $[6] = t3) : t3 = $[6], t2 = client.observable.datasets.list().pipe(rxjs.map(t3), rxjs.catchError(_temp3)), $[2] = client.observable.datasets, $[3] = configDatasets, $[4] = t2;
1948
- } else
1949
- t2 = $[4];
1950
- t1 = t2;
1951
- }
1952
- return reactRx.useObservable(t1, null);
1953
- }
1954
- function _temp3(err) {
1955
- return rxjs.of(err);
1956
- }
1957
- function _temp2(ds) {
1958
- return ds.name;
1959
- }
1960
- function _temp(d) {
1961
- return d.name;
1962
- }
1963
- function VisionContainer(props) {
1964
- const $ = reactCompilerRuntime.c(19);
1965
- let t0;
1966
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
1967
- apiVersion: "v2025-06-27"
1968
- }, $[0] = t0) : t0 = $[0];
1969
- const datasetsClient = sanity.useClient(t0);
1970
- let t1;
1971
- $[1] !== datasetsClient || $[2] !== props.config.datasets ? (t1 = {
1972
- client: datasetsClient,
1973
- datasets: props.config.datasets
1974
- }, $[1] = datasetsClient, $[2] = props.config.datasets, $[3] = t1) : t1 = $[3];
1975
- const loadedDatasets = useDatasets(t1);
1976
- if (!loadedDatasets) {
1977
- let t22;
1978
- return $[4] === Symbol.for("react.memo_cache_sentinel") ? (t22 = /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", height: "fill", justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(DelayedSpinner, {}) }), $[4] = t22) : t22 = $[4], t22;
1979
- }
1980
- let t2;
1981
- $[5] !== loadedDatasets || $[6] !== props.client ? (t2 = loadedDatasets instanceof Error ? [props.client.config().dataset || "production"] : loadedDatasets, $[5] = loadedDatasets, $[6] = props.client, $[7] = t2) : t2 = $[7];
1982
- const datasets = t2;
1983
- let t3;
1984
- $[8] !== props.client ? (t3 = props.client.config(), $[8] = props.client, $[9] = t3) : t3 = $[9];
1985
- const projectId = t3.projectId;
1986
- let t4;
1987
- $[10] !== datasets || $[11] !== props.client || $[12] !== props.config.defaultDataset ? (t4 = props.config.defaultDataset || props.client.config().dataset || datasets[0], $[10] = datasets, $[11] = props.client, $[12] = props.config.defaultDataset, $[13] = t4) : t4 = $[13];
1988
- const defaultDataset = t4;
1989
- let t5;
1990
- return $[14] !== datasets || $[15] !== defaultDataset || $[16] !== projectId || $[17] !== props ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(VisionGui, { ...props, datasets, projectId, defaultDataset }, projectId), $[14] = datasets, $[15] = defaultDataset, $[16] = projectId, $[17] = props, $[18] = t5) : t5 = $[18], t5;
1991
- }
1992
- class VisionErrorBoundary extends react.Component {
1993
- constructor(props) {
1994
- super(props), this.state = {
1995
- error: null,
1996
- numRetries: 0
1997
- };
1998
- }
1999
- static getDerivedStateFromError(error) {
2000
- return {
2001
- error: error instanceof Error ? error.message : `${error}`
2002
- };
2003
- }
2004
- handleRetryRender = () => this.setState((prev) => ({
2005
- error: null,
2006
- numRetries: prev.numRetries + 1
2007
- }));
2008
- handleRetryWithCacheClear = () => {
2009
- clearLocalStorage(), this.handleRetryRender();
2010
- };
2011
- render() {
2012
- if (!this.state.error)
2013
- return this.props.children;
2014
- const message = this.state.error, withCacheClear = this.state.numRetries > 0;
2015
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { height: "fill", overflow: "auto", paddingY: [4, 5, 6, 7], paddingX: 4, sizing: "border", tone: "critical", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { width: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
2016
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: withCacheClear ? this.handleRetryWithCacheClear : this.handleRetryRender, text: withCacheClear ? "Clear cache and retry" : "Retry", tone: "default" }) }),
2017
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "An error occurred" }),
2018
- /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, radius: 2, overflow: "auto", padding: 4, tone: "inherit", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 4, children: message && /* @__PURE__ */ jsxRuntime.jsx(ui.Code, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
2019
- "Error: ",
2020
- message
2021
- ] }) }) }) })
2022
- ] }) }) });
2023
- }
2024
- }
2025
- function SanityVision(props) {
2026
- const $ = reactCompilerRuntime.c(6);
2027
- let t0;
2028
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
2029
- apiVersion: "1"
2030
- }, $[0] = t0) : t0 = $[0];
2031
- const client = sanity.useClient(t0);
2032
- let t1;
2033
- $[1] !== props.tool.options ? (t1 = {
2034
- defaultApiVersion: DEFAULT_API_VERSION,
2035
- ...props.tool.options
2036
- }, $[1] = props.tool.options, $[2] = t1) : t1 = $[2];
2037
- const config = t1;
2038
- let t2;
2039
- return $[3] !== client || $[4] !== config ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(VisionErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(VisionContainer, { client, config }) }), $[3] = client, $[4] = config, $[5] = t2) : t2 = $[5], t2;
2040
- }
2041
- exports.default = SanityVision;
2042
- //# sourceMappingURL=SanityVision.js.map