@sanity/vision 6.7.0-next.5 → 6.7.0-next.51

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