@sanity/client 6.14.0 → 6.14.2

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.
Files changed (49) hide show
  1. package/dist/_chunks/{browserMiddleware-B2MFFa3m.cjs → browserMiddleware-BHXO2Lcy.cjs} +371 -818
  2. package/dist/_chunks/{browserMiddleware-B2MFFa3m.cjs.map → browserMiddleware-BHXO2Lcy.cjs.map} +1 -1
  3. package/dist/_chunks/{browserMiddleware-nhWQI70y.js → browserMiddleware-jPnXCUlp.js} +371 -819
  4. package/dist/_chunks/{browserMiddleware-nhWQI70y.js.map → browserMiddleware-jPnXCUlp.js.map} +1 -1
  5. package/dist/_chunks/{nodeMiddleware-Me3HWLoB.js → nodeMiddleware-CrO2pNEp.js} +386 -836
  6. package/dist/_chunks/{nodeMiddleware-Me3HWLoB.js.map → nodeMiddleware-CrO2pNEp.js.map} +1 -1
  7. package/dist/_chunks/{nodeMiddleware-CfcASl-f.cjs → nodeMiddleware-JJNfI4Rf.cjs} +384 -833
  8. package/dist/_chunks/{nodeMiddleware-CfcASl-f.cjs.map → nodeMiddleware-JJNfI4Rf.cjs.map} +1 -1
  9. package/dist/_chunks/resolveEditInfo-BNCwZySb.cjs +284 -0
  10. package/dist/_chunks/{resolveEditInfo-CTU2TYdi.cjs.map → resolveEditInfo-BNCwZySb.cjs.map} +1 -1
  11. package/dist/_chunks/resolveEditInfo-qA5twkfC.js +285 -0
  12. package/dist/_chunks/{resolveEditInfo-DX-6auJZ.js.map → resolveEditInfo-qA5twkfC.js.map} +1 -1
  13. package/dist/_chunks/stegaEncodeSourceMap-B9_uz7Zb.cjs +166 -0
  14. package/dist/_chunks/{stegaEncodeSourceMap-DTaF28aJ.cjs.map → stegaEncodeSourceMap-B9_uz7Zb.cjs.map} +1 -1
  15. package/dist/_chunks/stegaEncodeSourceMap-BvBJpbrr.cjs +329 -0
  16. package/dist/_chunks/{stegaEncodeSourceMap-Do4zj2pO.cjs.map → stegaEncodeSourceMap-BvBJpbrr.cjs.map} +1 -1
  17. package/dist/_chunks/stegaEncodeSourceMap-De3F_oJN.js +330 -0
  18. package/dist/_chunks/{stegaEncodeSourceMap-B6IscnhR.js.map → stegaEncodeSourceMap-De3F_oJN.js.map} +1 -1
  19. package/dist/_chunks/stegaEncodeSourceMap-bRxIGJ-b.js +168 -0
  20. package/dist/_chunks/{stegaEncodeSourceMap-DS4_14pP.js.map → stegaEncodeSourceMap-bRxIGJ-b.js.map} +1 -1
  21. package/dist/csm.cjs +23 -57
  22. package/dist/csm.cjs.map +1 -1
  23. package/dist/csm.js +37 -55
  24. package/dist/csm.js.map +1 -1
  25. package/dist/index.browser.cjs +15 -21
  26. package/dist/index.browser.cjs.map +1 -1
  27. package/dist/index.browser.js +24 -15
  28. package/dist/index.browser.js.map +1 -1
  29. package/dist/index.cjs +15 -21
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.js +24 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/stega.browser.cjs +12 -17
  34. package/dist/stega.browser.cjs.map +1 -1
  35. package/dist/stega.browser.js +26 -11
  36. package/dist/stega.browser.js.map +1 -1
  37. package/dist/stega.cjs +12 -17
  38. package/dist/stega.cjs.map +1 -1
  39. package/dist/stega.js +26 -11
  40. package/dist/stega.js.map +1 -1
  41. package/package.json +8 -8
  42. package/umd/sanityClient.js +572 -1447
  43. package/umd/sanityClient.min.js +3 -3
  44. package/dist/_chunks/resolveEditInfo-CTU2TYdi.cjs +0 -422
  45. package/dist/_chunks/resolveEditInfo-DX-6auJZ.js +0 -406
  46. package/dist/_chunks/stegaEncodeSourceMap-B6IscnhR.js +0 -482
  47. package/dist/_chunks/stegaEncodeSourceMap-DS4_14pP.js +0 -225
  48. package/dist/_chunks/stegaEncodeSourceMap-DTaF28aJ.cjs +0 -229
  49. package/dist/_chunks/stegaEncodeSourceMap-Do4zj2pO.cjs +0 -486
@@ -4,55 +4,34 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
8
- const defaultOptions$1 = { timeout: isReactNative ? 6e4 : 12e4 };
9
- const processOptions = function processOptions2(opts) {
7
+ const isReactNative = typeof navigator > "u" ? !1 : navigator.product === "ReactNative", defaultOptions$1 = { timeout: isReactNative ? 6e4 : 12e4 }, processOptions = function(opts) {
10
8
  const options = {
11
9
  ...defaultOptions$1,
12
- ...typeof opts === "string" ? { url: opts } : opts
13
- };
14
- const { searchParams } = new URL(options.url, "http://localhost");
15
- options.timeout = normalizeTimeout(options.timeout);
16
- if (options.query) {
17
- for (const [key, value] of Object.entries(options.query)) {
18
- if (value !== void 0) {
19
- if (Array.isArray(value)) {
20
- for (const v of value) {
10
+ ...typeof opts == "string" ? { url: opts } : opts
11
+ }, { searchParams } = new URL(options.url, "http://localhost");
12
+ if (options.timeout = normalizeTimeout(options.timeout), options.query) {
13
+ for (const [key, value] of Object.entries(options.query))
14
+ if (value !== void 0)
15
+ if (Array.isArray(value))
16
+ for (const v of value)
21
17
  searchParams.append(key, v);
22
- }
23
- } else {
18
+ else
24
19
  searchParams.append(key, value);
25
- }
26
- }
27
- }
28
- }
29
- const [url] = options.url.split("?");
30
- const search = searchParams.toString();
31
- if (search) {
32
- options.url = "".concat(url, "?").concat(search);
33
20
  }
34
- options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
35
- return options;
21
+ const [url] = options.url.split("?"), search = searchParams.toString();
22
+ return search && (options.url = `${url}?${search}`), options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase(), options;
36
23
  };
37
24
  function normalizeTimeout(time) {
38
- if (time === false || time === 0) {
39
- return false;
40
- }
41
- if (time.connect || time.socket) {
25
+ if (time === !1 || time === 0)
26
+ return !1;
27
+ if (time.connect || time.socket)
42
28
  return time;
43
- }
44
29
  const delay = Number(time);
45
- if (isNaN(delay)) {
46
- return normalizeTimeout(defaultOptions$1.timeout);
47
- }
48
- return { connect: delay, socket: delay };
30
+ return isNaN(delay) ? normalizeTimeout(defaultOptions$1.timeout) : { connect: delay, socket: delay };
49
31
  }
50
-
51
- const validUrl = /^https?:\/\//i;
52
- const validateOptions = function validateOptions2(options) {
53
- if (!validUrl.test(options.url)) {
54
- throw new Error('"'.concat(options.url, '" is not a valid URL'));
55
- }
32
+ const validUrl = /^https?:\/\//i, validateOptions = function(options) {
33
+ if (!validUrl.test(options.url))
34
+ throw new Error(`"${options.url}" is not a valid URL`);
56
35
  };
57
36
 
58
37
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -96,48 +75,41 @@
96
75
 
97
76
  var parseHeaders$1 = /*@__PURE__*/getDefaultExportFromCjs(parseHeaders);
98
77
 
99
- const middlewareReducer = (middleware) => function applyMiddleware(hook, defaultValue, ...args) {
78
+ const middlewareReducer = (middleware) => function(hook, defaultValue, ...args) {
100
79
  const bailEarly = hook === "onError";
101
80
  let value = defaultValue;
102
81
  for (let i = 0; i < middleware[hook].length; i++) {
103
82
  const handler = middleware[hook][i];
104
- value = handler(value, ...args);
105
- if (bailEarly && !value) {
83
+ if (value = handler(value, ...args), bailEarly && !value)
106
84
  break;
107
- }
108
85
  }
109
86
  return value;
110
87
  };
111
-
112
88
  function createPubSub() {
113
89
  const subscribers = /* @__PURE__ */ Object.create(null);
114
90
  let nextId = 0;
115
91
  function subscribe(subscriber) {
116
92
  const id = nextId++;
117
- subscribers[id] = subscriber;
118
- return function unsubscribe() {
93
+ return subscribers[id] = subscriber, function() {
119
94
  delete subscribers[id];
120
95
  };
121
96
  }
122
97
  function publish(event) {
123
- for (const id in subscribers) {
98
+ for (const id in subscribers)
124
99
  subscribers[id](event);
125
- }
126
100
  }
127
101
  return {
128
102
  publish,
129
103
  subscribe
130
104
  };
131
105
  }
132
-
133
106
  const channelNames = [
134
107
  "request",
135
108
  "response",
136
109
  "progress",
137
110
  "error",
138
111
  "abort"
139
- ];
140
- const middlehooks = [
112
+ ], middlehooks = [
141
113
  "processOptions",
142
114
  "validateOptions",
143
115
  "interceptRequest",
@@ -149,12 +121,8 @@
149
121
  "onHeaders"
150
122
  ];
151
123
  function createRequester(initMiddleware, httpRequest) {
152
- const loadedMiddleware = [];
153
- const middleware = middlehooks.reduce(
154
- (ware, name) => {
155
- ware[name] = ware[name] || [];
156
- return ware;
157
- },
124
+ const loadedMiddleware = [], middleware = middlehooks.reduce(
125
+ (ware, name) => (ware[name] = ware[name] || [], ware),
158
126
  {
159
127
  processOptions: [processOptions],
160
128
  validateOptions: [validateOptions]
@@ -162,29 +130,15 @@
162
130
  );
163
131
  function request(opts) {
164
132
  const onResponse = (reqErr, res, ctx) => {
165
- let error = reqErr;
166
- let response = res;
167
- if (!error) {
133
+ let error = reqErr, response = res;
134
+ if (!error)
168
135
  try {
169
136
  response = applyMiddleware("onResponse", res, ctx);
170
137
  } catch (err) {
171
- response = null;
172
- error = err;
138
+ response = null, error = err;
173
139
  }
174
- }
175
- error = error && applyMiddleware("onError", error, ctx);
176
- if (error) {
177
- channels.error.publish(error);
178
- } else if (response) {
179
- channels.response.publish(response);
180
- }
181
- };
182
- const channels = channelNames.reduce((target, name) => {
183
- target[name] = createPubSub();
184
- return target;
185
- }, {});
186
- const applyMiddleware = middlewareReducer(middleware);
187
- const options = applyMiddleware("processOptions", opts);
140
+ error = error && applyMiddleware("onError", error, ctx), error ? channels.error.publish(error) : response && channels.response.publish(response);
141
+ }, channels = channelNames.reduce((target, name) => (target[name] = createPubSub(), target), {}), applyMiddleware = middlewareReducer(middleware), options = applyMiddleware("processOptions", opts);
188
142
  applyMiddleware("validateOptions", options);
189
143
  const context = { options, channels, applyMiddleware };
190
144
  let ongoingRequest;
@@ -192,94 +146,45 @@
192
146
  ongoingRequest = httpRequest(ctx, (err, res) => onResponse(err, res, ctx));
193
147
  });
194
148
  channels.abort.subscribe(() => {
195
- unsubscribe();
196
- if (ongoingRequest) {
197
- ongoingRequest.abort();
198
- }
149
+ unsubscribe(), ongoingRequest && ongoingRequest.abort();
199
150
  });
200
151
  const returnValue = applyMiddleware("onReturn", channels, context);
201
- if (returnValue === channels) {
202
- channels.request.publish(context);
203
- }
204
- return returnValue;
152
+ return returnValue === channels && channels.request.publish(context), returnValue;
205
153
  }
206
- request.use = function use(newMiddleware) {
207
- if (!newMiddleware) {
154
+ return request.use = function(newMiddleware) {
155
+ if (!newMiddleware)
208
156
  throw new Error("Tried to add middleware that resolved to falsey value");
209
- }
210
- if (typeof newMiddleware === "function") {
157
+ if (typeof newMiddleware == "function")
211
158
  throw new Error(
212
159
  "Tried to add middleware that was a function. It probably expects you to pass options to it."
213
160
  );
214
- }
215
- if (newMiddleware.onReturn && middleware.onReturn.length > 0) {
161
+ if (newMiddleware.onReturn && middleware.onReturn.length > 0)
216
162
  throw new Error(
217
163
  "Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event"
218
164
  );
219
- }
220
- middlehooks.forEach((key) => {
221
- if (newMiddleware[key]) {
222
- middleware[key].push(newMiddleware[key]);
223
- }
224
- });
225
- loadedMiddleware.push(newMiddleware);
226
- return request;
227
- };
228
- request.clone = () => createRequester(loadedMiddleware, httpRequest);
229
- initMiddleware.forEach(request.use);
230
- return request;
165
+ return middlehooks.forEach((key) => {
166
+ newMiddleware[key] && middleware[key].push(newMiddleware[key]);
167
+ }), loadedMiddleware.push(newMiddleware), request;
168
+ }, request.clone = () => createRequester(loadedMiddleware, httpRequest), initMiddleware.forEach(request.use), request;
231
169
  }
232
-
233
170
  var __accessCheck$7 = (obj, member, msg) => {
234
171
  if (!member.has(obj))
235
172
  throw TypeError("Cannot " + msg);
236
- };
237
- var __privateGet$7 = (obj, member, getter) => {
238
- __accessCheck$7(obj, member, "read from private field");
239
- return getter ? getter.call(obj) : member.get(obj);
240
- };
241
- var __privateAdd$7 = (obj, member, value) => {
173
+ }, __privateGet$7 = (obj, member, getter) => (__accessCheck$7(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$7 = (obj, member, value) => {
242
174
  if (member.has(obj))
243
175
  throw TypeError("Cannot add the same private member more than once");
244
176
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
245
- };
246
- var __privateSet$7 = (obj, member, value, setter) => {
247
- __accessCheck$7(obj, member, "write to private field");
248
- setter ? setter.call(obj, value) : member.set(obj, value);
249
- return value;
250
- };
251
- var _method, _url, _resHeaders, _headers, _controller, _init, _useAbortSignal;
177
+ }, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _method, _url, _resHeaders, _headers, _controller, _init, _useAbortSignal;
252
178
  class FetchXhr {
253
179
  constructor() {
254
- /**
255
- * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
256
- */
257
- this.readyState = 0;
258
- this.responseType = "";
259
- /**
260
- * Private implementation details
261
- */
262
- __privateAdd$7(this, _method, void 0);
263
- __privateAdd$7(this, _url, void 0);
264
- __privateAdd$7(this, _resHeaders, void 0);
265
- __privateAdd$7(this, _headers, {});
266
- __privateAdd$7(this, _controller, void 0);
267
- __privateAdd$7(this, _init, {});
268
- __privateAdd$7(this, _useAbortSignal, void 0);
180
+ this.readyState = 0, this.responseType = "", __privateAdd$7(this, _method, void 0), __privateAdd$7(this, _url, void 0), __privateAdd$7(this, _resHeaders, void 0), __privateAdd$7(this, _headers, {}), __privateAdd$7(this, _controller, void 0), __privateAdd$7(this, _init, {}), __privateAdd$7(this, _useAbortSignal, void 0);
269
181
  }
270
182
  // eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
271
183
  open(method, url, _async) {
272
- __privateSet$7(this, _method, method);
273
- __privateSet$7(this, _url, url);
274
- __privateSet$7(this, _resHeaders, "");
275
- this.readyState = 1;
276
- this.onreadystatechange();
277
- __privateSet$7(this, _controller, void 0);
184
+ __privateSet$7(this, _method, method), __privateSet$7(this, _url, url), __privateSet$7(this, _resHeaders, ""), this.readyState = 1, this.onreadystatechange(), __privateSet$7(this, _controller, void 0);
278
185
  }
279
186
  abort() {
280
- if (__privateGet$7(this, _controller)) {
281
- __privateGet$7(this, _controller).abort();
282
- }
187
+ __privateGet$7(this, _controller) && __privateGet$7(this, _controller).abort();
283
188
  }
284
189
  getAllResponseHeaders() {
285
190
  return __privateGet$7(this, _resHeaders);
@@ -288,178 +193,93 @@
288
193
  __privateGet$7(this, _headers)[name] = value;
289
194
  }
290
195
  // Allow setting extra fetch init options, needed for runtimes such as Vercel Edge to set `cache` and other options in React Server Components
291
- setInit(init, useAbortSignal = true) {
292
- __privateSet$7(this, _init, init);
293
- __privateSet$7(this, _useAbortSignal, useAbortSignal);
196
+ setInit(init, useAbortSignal = !0) {
197
+ __privateSet$7(this, _init, init), __privateSet$7(this, _useAbortSignal, useAbortSignal);
294
198
  }
295
199
  send(body) {
296
- const textBody = this.responseType !== "arraybuffer";
297
- const options = {
200
+ const textBody = this.responseType !== "arraybuffer", options = {
298
201
  ...__privateGet$7(this, _init),
299
202
  method: __privateGet$7(this, _method),
300
203
  headers: __privateGet$7(this, _headers),
301
204
  body
302
205
  };
303
- if (typeof AbortController === "function" && __privateGet$7(this, _useAbortSignal)) {
304
- __privateSet$7(this, _controller, new AbortController());
305
- if (typeof EventTarget !== "undefined" && __privateGet$7(this, _controller).signal instanceof EventTarget) {
306
- options.signal = __privateGet$7(this, _controller).signal;
307
- }
308
- }
309
- if (typeof document !== "undefined") {
310
- options.credentials = this.withCredentials ? "include" : "omit";
311
- }
312
- fetch(__privateGet$7(this, _url), options).then((res) => {
313
- res.headers.forEach((value, key) => {
314
- __privateSet$7(this, _resHeaders, __privateGet$7(this, _resHeaders) + "".concat(key, ": ").concat(value, "\r\n"));
315
- });
316
- this.status = res.status;
317
- this.statusText = res.statusText;
318
- this.readyState = 3;
319
- return textBody ? res.text() : res.arrayBuffer();
320
- }).then((resBody) => {
321
- if (typeof resBody === "string") {
322
- this.responseText = resBody;
323
- } else {
324
- this.response = resBody;
325
- }
326
- this.readyState = 4;
327
- this.onreadystatechange();
206
+ typeof AbortController == "function" && __privateGet$7(this, _useAbortSignal) && (__privateSet$7(this, _controller, new AbortController()), typeof EventTarget < "u" && __privateGet$7(this, _controller).signal instanceof EventTarget && (options.signal = __privateGet$7(this, _controller).signal)), typeof document < "u" && (options.credentials = this.withCredentials ? "include" : "omit"), fetch(__privateGet$7(this, _url), options).then((res) => (res.headers.forEach((value, key) => {
207
+ __privateSet$7(this, _resHeaders, __privateGet$7(this, _resHeaders) + `${key}: ${value}\r
208
+ `);
209
+ }), this.status = res.status, this.statusText = res.statusText, this.readyState = 3, textBody ? res.text() : res.arrayBuffer())).then((resBody) => {
210
+ typeof resBody == "string" ? this.responseText = resBody : this.response = resBody, this.readyState = 4, this.onreadystatechange();
328
211
  }).catch((err) => {
329
212
  var _a;
330
213
  if (err.name === "AbortError") {
331
214
  this.onabort();
332
215
  return;
333
216
  }
334
- (_a = this.onerror) == null ? void 0 : _a.call(this, err);
217
+ (_a = this.onerror) == null || _a.call(this, err);
335
218
  });
336
219
  }
337
220
  }
338
- _method = new WeakMap();
339
- _url = new WeakMap();
340
- _resHeaders = new WeakMap();
341
- _headers = new WeakMap();
342
- _controller = new WeakMap();
343
- _init = new WeakMap();
344
- _useAbortSignal = new WeakMap();
345
-
346
- const adapter = typeof XMLHttpRequest === "function" ? "xhr" : "fetch";
347
- const XmlHttpRequest = adapter === "xhr" ? XMLHttpRequest : FetchXhr;
348
- const httpRequester = (context, callback) => {
221
+ _method = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _resHeaders = /* @__PURE__ */ new WeakMap(), _headers = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _init = /* @__PURE__ */ new WeakMap(), _useAbortSignal = /* @__PURE__ */ new WeakMap();
222
+ const adapter = typeof XMLHttpRequest == "function" ? "xhr" : "fetch", XmlHttpRequest = adapter === "xhr" ? XMLHttpRequest : FetchXhr, httpRequester = (context, callback) => {
349
223
  var _a;
350
- const opts = context.options;
351
- const options = context.applyMiddleware("finalizeOptions", opts);
352
- const timers = {};
353
- const injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
224
+ const opts = context.options, options = context.applyMiddleware("finalizeOptions", opts), timers = {}, injectedResponse = context.applyMiddleware("interceptRequest", void 0, {
354
225
  adapter,
355
226
  context
356
227
  });
357
228
  if (injectedResponse) {
358
229
  const cbTimer = setTimeout(callback, 0, null, injectedResponse);
359
- const cancel = () => clearTimeout(cbTimer);
360
- return { abort: cancel };
230
+ return { abort: () => clearTimeout(cbTimer) };
361
231
  }
362
232
  let xhr = new XmlHttpRequest();
363
- if (xhr instanceof FetchXhr && typeof options.fetch === "object") {
364
- xhr.setInit(options.fetch, (_a = options.useAbortSignal) != null ? _a : true);
365
- }
366
- const headers = options.headers;
367
- const delays = options.timeout;
368
- let aborted = false;
369
- let loaded = false;
370
- let timedOut = false;
371
- xhr.onerror = (event) => {
233
+ xhr instanceof FetchXhr && typeof options.fetch == "object" && xhr.setInit(options.fetch, (_a = options.useAbortSignal) != null ? _a : !0);
234
+ const headers = options.headers, delays = options.timeout;
235
+ let aborted = !1, loaded = !1, timedOut = !1;
236
+ if (xhr.onerror = (event) => {
372
237
  onError(
373
238
  new Error(
374
- "Request error while attempting to reach ".concat(options.url).concat(event.lengthComputable ? "(".concat(event.loaded, " of ").concat(event.total, " bytes transferred)") : "")
239
+ `Request error while attempting to reach ${options.url}${event.lengthComputable ? `(${event.loaded} of ${event.total} bytes transferred)` : ""}`
375
240
  )
376
241
  );
377
- };
378
- xhr.ontimeout = (event) => {
242
+ }, xhr.ontimeout = (event) => {
379
243
  onError(
380
244
  new Error(
381
- "Request timeout while attempting to reach ".concat(options.url).concat(event.lengthComputable ? "(".concat(event.loaded, " of ").concat(event.total, " bytes transferred)") : "")
245
+ `Request timeout while attempting to reach ${options.url}${event.lengthComputable ? `(${event.loaded} of ${event.total} bytes transferred)` : ""}`
382
246
  )
383
247
  );
384
- };
385
- xhr.onabort = () => {
386
- stopTimers(true);
387
- aborted = true;
388
- };
389
- xhr.onreadystatechange = () => {
390
- resetTimers();
391
- if (aborted || xhr.readyState !== 4) {
392
- return;
393
- }
394
- if (xhr.status === 0) {
395
- return;
396
- }
397
- onLoad();
398
- };
399
- xhr.open(
248
+ }, xhr.onabort = () => {
249
+ stopTimers(!0), aborted = !0;
250
+ }, xhr.onreadystatechange = () => {
251
+ resetTimers(), !(aborted || xhr.readyState !== 4) && xhr.status !== 0 && onLoad();
252
+ }, xhr.open(
400
253
  options.method,
401
254
  options.url,
402
- true
255
+ !0
403
256
  // Always async
404
- );
405
- xhr.withCredentials = !!options.withCredentials;
406
- if (headers && xhr.setRequestHeader) {
407
- for (const key in headers) {
408
- if (headers.hasOwnProperty(key)) {
409
- xhr.setRequestHeader(key, headers[key]);
410
- }
411
- }
412
- }
413
- if (options.rawBody) {
414
- xhr.responseType = "arraybuffer";
415
- }
416
- context.applyMiddleware("onRequest", { options, adapter, request: xhr, context });
417
- xhr.send(options.body || null);
418
- if (delays) {
419
- timers.connect = setTimeout(() => timeoutRequest("ETIMEDOUT"), delays.connect);
420
- }
421
- return { abort };
257
+ ), xhr.withCredentials = !!options.withCredentials, headers && xhr.setRequestHeader)
258
+ for (const key in headers)
259
+ headers.hasOwnProperty(key) && xhr.setRequestHeader(key, headers[key]);
260
+ return options.rawBody && (xhr.responseType = "arraybuffer"), context.applyMiddleware("onRequest", { options, adapter, request: xhr, context }), xhr.send(options.body || null), delays && (timers.connect = setTimeout(() => timeoutRequest("ETIMEDOUT"), delays.connect)), { abort };
422
261
  function abort() {
423
- aborted = true;
424
- if (xhr) {
425
- xhr.abort();
426
- }
262
+ aborted = !0, xhr && xhr.abort();
427
263
  }
428
264
  function timeoutRequest(code) {
429
- timedOut = true;
430
- xhr.abort();
265
+ timedOut = !0, xhr.abort();
431
266
  const error = new Error(
432
- code === "ESOCKETTIMEDOUT" ? "Socket timed out on request to ".concat(options.url) : "Connection timed out on request to ".concat(options.url)
267
+ code === "ESOCKETTIMEDOUT" ? `Socket timed out on request to ${options.url}` : `Connection timed out on request to ${options.url}`
433
268
  );
434
- error.code = code;
435
- context.channels.error.publish(error);
269
+ error.code = code, context.channels.error.publish(error);
436
270
  }
437
271
  function resetTimers() {
438
- if (!delays) {
439
- return;
440
- }
441
- stopTimers();
442
- timers.socket = setTimeout(() => timeoutRequest("ESOCKETTIMEDOUT"), delays.socket);
272
+ delays && (stopTimers(), timers.socket = setTimeout(() => timeoutRequest("ESOCKETTIMEDOUT"), delays.socket));
443
273
  }
444
274
  function stopTimers(force) {
445
- if (force || aborted || xhr.readyState >= 2 && timers.connect) {
446
- clearTimeout(timers.connect);
447
- }
448
- if (timers.socket) {
449
- clearTimeout(timers.socket);
450
- }
275
+ (force || aborted || xhr.readyState >= 2 && timers.connect) && clearTimeout(timers.connect), timers.socket && clearTimeout(timers.socket);
451
276
  }
452
277
  function onError(error) {
453
- if (loaded) {
278
+ if (loaded)
454
279
  return;
455
- }
456
- stopTimers(true);
457
- loaded = true;
458
- xhr = null;
459
- const err = error || new Error("Network error while attempting to reach ".concat(options.url));
460
- err.isNetworkError = true;
461
- err.request = options;
462
- callback(err);
280
+ stopTimers(!0), loaded = !0, xhr = null;
281
+ const err = error || new Error(`Network error while attempting to reach ${options.url}`);
282
+ err.isNetworkError = !0, err.request = options, callback(err);
463
283
  }
464
284
  function reduceResponse() {
465
285
  return {
@@ -472,21 +292,15 @@
472
292
  };
473
293
  }
474
294
  function onLoad() {
475
- if (aborted || loaded || timedOut) {
476
- return;
477
- }
478
- if (xhr.status === 0) {
479
- onError(new Error("Unknown XHR error"));
480
- return;
295
+ if (!(aborted || loaded || timedOut)) {
296
+ if (xhr.status === 0) {
297
+ onError(new Error("Unknown XHR error"));
298
+ return;
299
+ }
300
+ stopTimers(), loaded = !0, callback(null, reduceResponse());
481
301
  }
482
- stopTimers();
483
- loaded = true;
484
- callback(null, reduceResponse());
485
302
  }
486
- };
487
-
488
- const getIt = (initMiddleware = [], httpRequest = httpRequester) => createRequester(initMiddleware, httpRequest);
489
- const environment = "browser";
303
+ }, getIt = (initMiddleware = [], httpRequest = httpRequester) => createRequester(initMiddleware, httpRequest), environment = "browser";
490
304
 
491
305
  var browser$3 = {exports: {}};
492
306
 
@@ -1240,22 +1054,12 @@
1240
1054
  return true;
1241
1055
  }
1242
1056
 
1243
- const isBuffer = typeof Buffer === "undefined" ? () => false : (obj) => Buffer.isBuffer(obj);
1244
-
1245
- const serializeTypes = ["boolean", "string", "number"];
1057
+ const isBuffer = typeof Buffer > "u" ? () => !1 : (obj) => Buffer.isBuffer(obj), serializeTypes = ["boolean", "string", "number"];
1246
1058
  function jsonRequest() {
1247
1059
  return {
1248
1060
  processOptions: (options) => {
1249
1061
  const body = options.body;
1250
- if (!body) {
1251
- return options;
1252
- }
1253
- const isStream = typeof body.pipe === "function";
1254
- const shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1(body));
1255
- if (!shouldSerialize) {
1256
- return options;
1257
- }
1258
- return Object.assign({}, options, {
1062
+ return !body || !(typeof body.pipe != "function" && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1(body))) ? options : Object.assign({}, options, {
1259
1063
  body: JSON.stringify(options.body),
1260
1064
  headers: Object.assign({}, options.headers, {
1261
1065
  "Content-Type": "application/json"
@@ -1264,16 +1068,11 @@
1264
1068
  }
1265
1069
  };
1266
1070
  }
1267
-
1268
1071
  function jsonResponse(opts) {
1269
1072
  return {
1270
1073
  onResponse: (response) => {
1271
- const contentType = response.headers["content-type"] || "";
1272
- const shouldDecode = opts && opts.force || contentType.indexOf("application/json") !== -1;
1273
- if (!response.body || !contentType || !shouldDecode) {
1274
- return response;
1275
- }
1276
- return Object.assign({}, response, { body: tryParse(response.body) });
1074
+ const contentType = response.headers["content-type"] || "", shouldDecode = opts && opts.force || contentType.indexOf("application/json") !== -1;
1075
+ return !response.body || !contentType || !shouldDecode ? response : Object.assign({}, response, { body: tryParse(response.body) });
1277
1076
  },
1278
1077
  processOptions: (options) => Object.assign({}, options, {
1279
1078
  headers: Object.assign({ Accept: "application/json" }, options.headers)
@@ -1283,64 +1082,37 @@
1283
1082
  try {
1284
1083
  return JSON.parse(body);
1285
1084
  } catch (err) {
1286
- err.message = "Failed to parsed response body as JSON: ".concat(err.message);
1287
- throw err;
1085
+ throw err.message = `Failed to parsed response body as JSON: ${err.message}`, err;
1288
1086
  }
1289
1087
  }
1290
1088
  }
1291
-
1292
1089
  let actualGlobal = {};
1293
- if (typeof globalThis !== "undefined") {
1294
- actualGlobal = globalThis;
1295
- } else if (typeof window !== "undefined") {
1296
- actualGlobal = window;
1297
- } else if (typeof global !== "undefined") {
1298
- actualGlobal = global;
1299
- } else if (typeof self !== "undefined") {
1300
- actualGlobal = self;
1301
- }
1090
+ typeof globalThis < "u" ? actualGlobal = globalThis : typeof window < "u" ? actualGlobal = window : typeof global < "u" ? actualGlobal = global : typeof self < "u" && (actualGlobal = self);
1302
1091
  var global$1 = actualGlobal;
1303
-
1304
1092
  function observable$1(opts = {}) {
1305
1093
  const Observable = (
1306
1094
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- @TODO consider dropping checking for a global Observable since it's not on a standards track
1307
1095
  opts.implementation || global$1.Observable
1308
1096
  );
1309
- if (!Observable) {
1097
+ if (!Observable)
1310
1098
  throw new Error(
1311
1099
  "`Observable` is not available in global scope, and no implementation was passed"
1312
1100
  );
1313
- }
1314
1101
  return {
1315
- onReturn: (channels, context) => new Observable((observer) => {
1316
- channels.error.subscribe((err) => observer.error(err));
1317
- channels.progress.subscribe(
1318
- (event) => observer.next(Object.assign({ type: "progress" }, event))
1319
- );
1320
- channels.response.subscribe((response) => {
1321
- observer.next(Object.assign({ type: "response" }, response));
1322
- observer.complete();
1323
- });
1324
- channels.request.publish(context);
1325
- return () => channels.abort.publish();
1326
- })
1102
+ onReturn: (channels, context) => new Observable((observer) => (channels.error.subscribe((err) => observer.error(err)), channels.progress.subscribe(
1103
+ (event) => observer.next(Object.assign({ type: "progress" }, event))
1104
+ ), channels.response.subscribe((response) => {
1105
+ observer.next(Object.assign({ type: "response" }, response)), observer.complete();
1106
+ }), channels.request.publish(context), () => channels.abort.publish()))
1327
1107
  };
1328
1108
  }
1329
-
1330
1109
  function progress() {
1331
1110
  return {
1332
1111
  onRequest: (evt) => {
1333
- if (evt.adapter !== "xhr") {
1112
+ if (evt.adapter !== "xhr")
1334
1113
  return;
1335
- }
1336
- const xhr = evt.request;
1337
- const context = evt.context;
1338
- if ("upload" in xhr && "onprogress" in xhr.upload) {
1339
- xhr.upload.onprogress = handleProgress("upload");
1340
- }
1341
- if ("onprogress" in xhr) {
1342
- xhr.onprogress = handleProgress("download");
1343
- }
1114
+ const xhr = evt.request, context = evt.context;
1115
+ "upload" in xhr && "onprogress" in xhr.upload && (xhr.upload.onprogress = handleProgress("upload")), "onprogress" in xhr && (xhr.onprogress = handleProgress("download"));
1344
1116
  function handleProgress(stage) {
1345
1117
  return (event) => {
1346
1118
  const percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
@@ -1358,78 +1130,52 @@
1358
1130
  }
1359
1131
  class Cancel {
1360
1132
  constructor(message) {
1361
- this.__CANCEL__ = true;
1362
- this.message = message;
1133
+ this.__CANCEL__ = !0, this.message = message;
1363
1134
  }
1364
1135
  toString() {
1365
- return "Cancel".concat(this.message ? ": ".concat(this.message) : "");
1136
+ return `Cancel${this.message ? `: ${this.message}` : ""}`;
1366
1137
  }
1367
1138
  }
1368
- const _CancelToken = class _CancelToken {
1139
+ const _CancelToken = class {
1369
1140
  constructor(executor) {
1370
- if (typeof executor !== "function") {
1141
+ if (typeof executor != "function")
1371
1142
  throw new TypeError("executor must be a function.");
1372
- }
1373
1143
  let resolvePromise = null;
1374
1144
  this.promise = new Promise((resolve) => {
1375
1145
  resolvePromise = resolve;
1376
- });
1377
- executor((message) => {
1378
- if (this.reason) {
1379
- return;
1380
- }
1381
- this.reason = new Cancel(message);
1382
- resolvePromise(this.reason);
1146
+ }), executor((message) => {
1147
+ this.reason || (this.reason = new Cancel(message), resolvePromise(this.reason));
1383
1148
  });
1384
1149
  }
1385
1150
  };
1386
1151
  _CancelToken.source = () => {
1387
1152
  let cancel;
1388
- const token = new _CancelToken((can) => {
1389
- cancel = can;
1390
- });
1391
1153
  return {
1392
- token,
1154
+ token: new _CancelToken((can) => {
1155
+ cancel = can;
1156
+ }),
1393
1157
  cancel
1394
1158
  };
1395
1159
  };
1396
-
1397
- var defaultShouldRetry = (err, attempt, options) => {
1398
- if (options.method !== "GET" && options.method !== "HEAD") {
1399
- return false;
1400
- }
1401
- return err.isNetworkError || false;
1402
- };
1403
-
1404
- const isStream = (stream) => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
1160
+ var defaultShouldRetry = (err, attempt, options) => options.method !== "GET" && options.method !== "HEAD" ? !1 : err.isNetworkError || !1;
1161
+ const isStream = (stream) => stream !== null && typeof stream == "object" && typeof stream.pipe == "function";
1405
1162
  var sharedRetry = (opts) => {
1406
- const maxRetries = opts.maxRetries || 5;
1407
- const retryDelay = opts.retryDelay || getRetryDelay;
1408
- const allowRetry = opts.shouldRetry;
1163
+ const maxRetries = opts.maxRetries || 5, retryDelay = opts.retryDelay || getRetryDelay, allowRetry = opts.shouldRetry;
1409
1164
  return {
1410
1165
  onError: (err, context) => {
1411
- const options = context.options;
1412
- const max = options.maxRetries || maxRetries;
1413
- const shouldRetry = options.shouldRetry || allowRetry;
1414
- const attemptNumber = options.attemptNumber || 0;
1415
- if (isStream(options.body)) {
1416
- return err;
1417
- }
1418
- if (!shouldRetry(err, attemptNumber, options) || attemptNumber >= max) {
1166
+ const options = context.options, max = options.maxRetries || maxRetries, shouldRetry = options.shouldRetry || allowRetry, attemptNumber = options.attemptNumber || 0;
1167
+ if (isStream(options.body) || !shouldRetry(err, attemptNumber, options) || attemptNumber >= max)
1419
1168
  return err;
1420
- }
1421
1169
  const newContext = Object.assign({}, context, {
1422
1170
  options: Object.assign({}, options, { attemptNumber: attemptNumber + 1 })
1423
1171
  });
1424
- setTimeout(() => context.channels.request.publish(newContext), retryDelay(attemptNumber));
1425
- return null;
1172
+ return setTimeout(() => context.channels.request.publish(newContext), retryDelay(attemptNumber)), null;
1426
1173
  }
1427
1174
  };
1428
1175
  };
1429
1176
  function getRetryDelay(attemptNum) {
1430
1177
  return 100 * Math.pow(2, attemptNum) + Math.random() * 100;
1431
1178
  }
1432
-
1433
1179
  const retry = (opts = {}) => sharedRetry({ shouldRetry: defaultShouldRetry, ...opts });
1434
1180
  retry.shouldRetry = defaultShouldRetry;
1435
1181
 
@@ -2603,93 +2349,69 @@
2603
2349
  return combineLatest.apply(void 0, __spreadArray([], __read(otherSources)));
2604
2350
  }
2605
2351
 
2606
- const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
2607
2352
  class ClientError extends Error {
2608
2353
  constructor(res) {
2609
2354
  const props = extractErrorProps(res);
2610
- super(props.message);
2611
- this.statusCode = 400;
2612
- Object.assign(this, props);
2355
+ super(props.message), this.statusCode = 400, Object.assign(this, props);
2613
2356
  }
2614
2357
  }
2615
2358
  class ServerError extends Error {
2616
2359
  constructor(res) {
2617
2360
  const props = extractErrorProps(res);
2618
- super(props.message);
2619
- this.statusCode = 500;
2620
- Object.assign(this, props);
2361
+ super(props.message), this.statusCode = 500, Object.assign(this, props);
2621
2362
  }
2622
2363
  }
2623
2364
  function extractErrorProps(res) {
2624
- const body = res.body;
2625
- const props = {
2365
+ const body = res.body, props = {
2626
2366
  response: res,
2627
2367
  statusCode: res.statusCode,
2628
2368
  responseBody: stringifyBody(body, res),
2629
2369
  message: "",
2630
2370
  details: void 0
2631
2371
  };
2632
- if (body.error && body.message) {
2633
- props.message = "".concat(body.error, " - ").concat(body.message);
2634
- return props;
2635
- }
2372
+ if (body.error && body.message)
2373
+ return props.message = `${body.error} - ${body.message}`, props;
2636
2374
  if (isMutationError(body)) {
2637
- const allItems = body.error.items || [];
2638
- const items = allItems.slice(0, MAX_ITEMS_IN_ERROR_MESSAGE).map((item) => {
2375
+ const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
2639
2376
  var _a;
2640
2377
  return (_a = item.error) == null ? void 0 : _a.description;
2641
2378
  }).filter(Boolean);
2642
- let itemsStr = items.length ? ":\n- ".concat(items.join("\n- ")) : "";
2643
- if (allItems.length > MAX_ITEMS_IN_ERROR_MESSAGE) {
2644
- itemsStr += "\n...and ".concat(allItems.length - MAX_ITEMS_IN_ERROR_MESSAGE, " more");
2645
- }
2646
- props.message = "".concat(body.error.description).concat(itemsStr);
2647
- props.details = body.error;
2648
- return props;
2649
- }
2650
- if (body.error && body.error.description) {
2651
- props.message = body.error.description;
2652
- props.details = body.error;
2653
- return props;
2379
+ let itemsStr = items.length ? `:
2380
+ - ${items.join(`
2381
+ - `)}` : "";
2382
+ return allItems.length > 5 && (itemsStr += `
2383
+ ...and ${allItems.length - 5} more`), props.message = `${body.error.description}${itemsStr}`, props.details = body.error, props;
2654
2384
  }
2655
- props.message = body.error || body.message || httpErrorMessage(res);
2656
- return props;
2385
+ return body.error && body.error.description ? (props.message = body.error.description, props.details = body.error, props) : (props.message = body.error || body.message || httpErrorMessage(res), props);
2657
2386
  }
2658
2387
  function isMutationError(body) {
2659
- return isPlainObject(body) && isPlainObject(body.error) && body.error.type === "mutationError" && typeof body.error.description === "string";
2388
+ return isPlainObject(body) && isPlainObject(body.error) && body.error.type === "mutationError" && typeof body.error.description == "string";
2660
2389
  }
2661
2390
  function isPlainObject(obj) {
2662
- return typeof obj === "object" && obj !== null && !Array.isArray(obj);
2391
+ return typeof obj == "object" && obj !== null && !Array.isArray(obj);
2663
2392
  }
2664
2393
  function httpErrorMessage(res) {
2665
- const statusMessage = res.statusMessage ? " ".concat(res.statusMessage) : "";
2666
- return "".concat(res.method, "-request to ").concat(res.url, " resulted in HTTP ").concat(res.statusCode).concat(statusMessage);
2394
+ const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : "";
2395
+ return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}`;
2667
2396
  }
2668
2397
  function stringifyBody(body, res) {
2669
- const contentType = (res.headers["content-type"] || "").toLowerCase();
2670
- const isJson = contentType.indexOf("application/json") !== -1;
2671
- return isJson ? JSON.stringify(body, null, 2) : body;
2398
+ return (res.headers["content-type"] || "").toLowerCase().indexOf("application/json") !== -1 ? JSON.stringify(body, null, 2) : body;
2672
2399
  }
2673
-
2674
2400
  const httpError = {
2675
2401
  onResponse: (res) => {
2676
- if (res.statusCode >= 500) {
2402
+ if (res.statusCode >= 500)
2677
2403
  throw new ServerError(res);
2678
- } else if (res.statusCode >= 400) {
2404
+ if (res.statusCode >= 400)
2679
2405
  throw new ClientError(res);
2680
- }
2681
2406
  return res;
2682
2407
  }
2683
- };
2684
- const printWarnings = {
2408
+ }, printWarnings = {
2685
2409
  onResponse: (res) => {
2686
2410
  const warn = res.headers["x-sanity-warning"];
2687
- const warnings = Array.isArray(warn) ? warn : [warn];
2688
- warnings.filter(Boolean).forEach((msg) => console.warn(msg));
2689
- return res;
2411
+ return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
2690
2412
  }
2691
2413
  };
2692
- function defineHttpRequest(envMiddleware, {
2414
+ function defineHttpRequest(envMiddleware2, {
2693
2415
  maxRetries = 5,
2694
2416
  retryDelay
2695
2417
  }) {
@@ -2701,7 +2423,7 @@
2701
2423
  maxRetries,
2702
2424
  shouldRetry
2703
2425
  }) : {},
2704
- ...envMiddleware,
2426
+ ...envMiddleware2,
2705
2427
  printWarnings,
2706
2428
  jsonRequest(),
2707
2429
  jsonResponse(),
@@ -2712,123 +2434,82 @@
2712
2434
  function httpRequest(options, requester = request) {
2713
2435
  return requester({ maxRedirects: 0, ...options });
2714
2436
  }
2715
- httpRequest.defaultRequester = request;
2716
- return httpRequest;
2437
+ return httpRequest.defaultRequester = request, httpRequest;
2717
2438
  }
2718
2439
  function shouldRetry(err, attempt, options) {
2719
- const isSafe = options.method === "GET" || options.method === "HEAD";
2720
- const uri = options.uri || options.url;
2721
- const isQuery = uri.startsWith("/data/query");
2722
- const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
2723
- if ((isSafe || isQuery) && isRetriableResponse)
2724
- return true;
2725
- return retry.shouldRetry(err, attempt, options);
2440
+ const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
2441
+ return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
2726
2442
  }
2727
-
2728
2443
  function getSelection(sel) {
2729
- if (typeof sel === "string") {
2444
+ if (typeof sel == "string")
2730
2445
  return { id: sel };
2731
- }
2732
- if (Array.isArray(sel)) {
2446
+ if (Array.isArray(sel))
2733
2447
  return { query: "*[_id in $ids]", params: { ids: sel } };
2734
- }
2735
- if (typeof sel === "object" && sel !== null && "query" in sel && typeof sel.query === "string") {
2736
- return "params" in sel && typeof sel.params === "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
2737
- }
2448
+ if (typeof sel == "object" && sel !== null && "query" in sel && typeof sel.query == "string")
2449
+ return "params" in sel && typeof sel.params == "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
2738
2450
  const selectionOpts = [
2739
2451
  "* Document ID (<docId>)",
2740
2452
  "* Array of document IDs",
2741
2453
  "* Object containing `query`"
2742
- ].join("\n");
2743
- throw new Error("Unknown selection - must be one of:\n\n".concat(selectionOpts));
2744
- }
2454
+ ].join(`
2455
+ `);
2456
+ throw new Error(`Unknown selection - must be one of:
2745
2457
 
2746
- const VALID_ASSET_TYPES = ["image", "file"];
2747
- const VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
2748
- const dataset = (name) => {
2749
- if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
2458
+ ${selectionOpts}`);
2459
+ }
2460
+ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before", "after", "replace"], dataset = (name) => {
2461
+ if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name))
2750
2462
  throw new Error(
2751
2463
  "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
2752
2464
  );
2753
- }
2754
- };
2755
- const projectId = (id) => {
2756
- if (!/^[-a-z0-9]+$/i.test(id)) {
2465
+ }, projectId = (id) => {
2466
+ if (!/^[-a-z0-9]+$/i.test(id))
2757
2467
  throw new Error("`projectId` can only contain only a-z, 0-9 and dashes");
2758
- }
2759
- };
2760
- const validateAssetType = (type) => {
2761
- if (VALID_ASSET_TYPES.indexOf(type) === -1) {
2762
- throw new Error("Invalid asset type: ".concat(type, ". Must be one of ").concat(VALID_ASSET_TYPES.join(", ")));
2763
- }
2764
- };
2765
- const validateObject = (op, val) => {
2766
- if (val === null || typeof val !== "object" || Array.isArray(val)) {
2767
- throw new Error("".concat(op, "() takes an object of properties"));
2768
- }
2769
- };
2770
- const validateDocumentId = (op, id) => {
2771
- if (typeof id !== "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes("..")) {
2772
- throw new Error("".concat(op, '(): "').concat(id, '" is not a valid document ID'));
2773
- }
2774
- };
2775
- const requireDocumentId = (op, doc) => {
2776
- if (!doc._id) {
2777
- throw new Error("".concat(op, '() requires that the document contains an ID ("_id" property)'));
2778
- }
2468
+ }, validateAssetType = (type) => {
2469
+ if (VALID_ASSET_TYPES.indexOf(type) === -1)
2470
+ throw new Error(`Invalid asset type: ${type}. Must be one of ${VALID_ASSET_TYPES.join(", ")}`);
2471
+ }, validateObject = (op, val) => {
2472
+ if (val === null || typeof val != "object" || Array.isArray(val))
2473
+ throw new Error(`${op}() takes an object of properties`);
2474
+ }, validateDocumentId = (op, id) => {
2475
+ if (typeof id != "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes(".."))
2476
+ throw new Error(`${op}(): "${id}" is not a valid document ID`);
2477
+ }, requireDocumentId = (op, doc) => {
2478
+ if (!doc._id)
2479
+ throw new Error(`${op}() requires that the document contains an ID ("_id" property)`);
2779
2480
  validateDocumentId(op, doc._id);
2780
- };
2781
- const validateInsert = (at, selector, items) => {
2481
+ }, validateInsert = (at, selector, items) => {
2782
2482
  const signature = "insert(at, selector, items)";
2783
2483
  if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
2784
- const valid = VALID_INSERT_LOCATIONS.map((loc) => '"'.concat(loc, '"')).join(", ");
2785
- throw new Error("".concat(signature, ' takes an "at"-argument which is one of: ').concat(valid));
2786
- }
2787
- if (typeof selector !== "string") {
2788
- throw new Error("".concat(signature, ' takes a "selector"-argument which must be a string'));
2789
- }
2790
- if (!Array.isArray(items)) {
2791
- throw new Error("".concat(signature, ' takes an "items"-argument which must be an array'));
2792
- }
2793
- };
2794
- const hasDataset = (config) => {
2795
- if (!config.dataset) {
2484
+ const valid = VALID_INSERT_LOCATIONS.map((loc) => `"${loc}"`).join(", ");
2485
+ throw new Error(`${signature} takes an "at"-argument which is one of: ${valid}`);
2486
+ }
2487
+ if (typeof selector != "string")
2488
+ throw new Error(`${signature} takes a "selector"-argument which must be a string`);
2489
+ if (!Array.isArray(items))
2490
+ throw new Error(`${signature} takes an "items"-argument which must be an array`);
2491
+ }, hasDataset = (config) => {
2492
+ if (!config.dataset)
2796
2493
  throw new Error("`dataset` must be provided to perform queries");
2797
- }
2798
2494
  return config.dataset || "";
2799
- };
2800
- const requestTag = (tag) => {
2801
- if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
2495
+ }, requestTag = (tag) => {
2496
+ if (typeof tag != "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag))
2802
2497
  throw new Error(
2803
2498
  "Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long."
2804
2499
  );
2805
- }
2806
2500
  return tag;
2807
2501
  };
2808
-
2809
2502
  var __accessCheck$6 = (obj, member, msg) => {
2810
2503
  if (!member.has(obj))
2811
2504
  throw TypeError("Cannot " + msg);
2812
- };
2813
- var __privateGet$6 = (obj, member, getter) => {
2814
- __accessCheck$6(obj, member, "read from private field");
2815
- return getter ? getter.call(obj) : member.get(obj);
2816
- };
2817
- var __privateAdd$6 = (obj, member, value) => {
2505
+ }, __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$6 = (obj, member, value) => {
2818
2506
  if (member.has(obj))
2819
2507
  throw TypeError("Cannot add the same private member more than once");
2820
2508
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2821
- };
2822
- var __privateSet$6 = (obj, member, value, setter) => {
2823
- __accessCheck$6(obj, member, "write to private field");
2824
- setter ? setter.call(obj, value) : member.set(obj, value);
2825
- return value;
2826
- };
2827
- var _client$5, _client2$5;
2509
+ }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2828
2510
  class BasePatch {
2829
2511
  constructor(selection, operations = {}) {
2830
- this.selection = selection;
2831
- this.operations = operations;
2512
+ this.selection = selection, this.operations = operations;
2832
2513
  }
2833
2514
  /**
2834
2515
  * Sets the given attributes to the document. Does NOT merge objects.
@@ -2855,8 +2536,7 @@
2855
2536
  * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
2856
2537
  */
2857
2538
  diffMatchPatch(attrs) {
2858
- validateObject("diffMatchPatch", attrs);
2859
- return this._assign("diffMatchPatch", attrs);
2539
+ return validateObject("diffMatchPatch", attrs), this._assign("diffMatchPatch", attrs);
2860
2540
  }
2861
2541
  /**
2862
2542
  * Unsets the attribute paths provided.
@@ -2865,11 +2545,9 @@
2865
2545
  * @param attrs - Attribute paths to unset.
2866
2546
  */
2867
2547
  unset(attrs) {
2868
- if (!Array.isArray(attrs)) {
2548
+ if (!Array.isArray(attrs))
2869
2549
  throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
2870
- }
2871
- this.operations = Object.assign({}, this.operations, { unset: attrs });
2872
- return this;
2550
+ return this.operations = Object.assign({}, this.operations, { unset: attrs }), this;
2873
2551
  }
2874
2552
  /**
2875
2553
  * Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
@@ -2895,8 +2573,7 @@
2895
2573
  * @param items - Array of items to insert/replace
2896
2574
  */
2897
2575
  insert(at, selector, items) {
2898
- validateInsert(at, selector, items);
2899
- return this._assign("insert", { [at]: selector, items });
2576
+ return validateInsert(at, selector, items), this._assign("insert", { [at]: selector, items });
2900
2577
  }
2901
2578
  /**
2902
2579
  * Append the given items to the array at the given JSONPath
@@ -2905,7 +2582,7 @@
2905
2582
  * @param items - Array of items to append to the array
2906
2583
  */
2907
2584
  append(selector, items) {
2908
- return this.insert("after", "".concat(selector, "[-1]"), items);
2585
+ return this.insert("after", `${selector}[-1]`, items);
2909
2586
  }
2910
2587
  /**
2911
2588
  * Prepend the given items to the array at the given JSONPath
@@ -2914,7 +2591,7 @@
2914
2591
  * @param items - Array of items to prepend to the array
2915
2592
  */
2916
2593
  prepend(selector, items) {
2917
- return this.insert("before", "".concat(selector, "[0]"), items);
2594
+ return this.insert("before", `${selector}[0]`, items);
2918
2595
  }
2919
2596
  /**
2920
2597
  * Change the contents of an array by removing existing elements and/or adding new elements.
@@ -2925,11 +2602,7 @@
2925
2602
  * @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
2926
2603
  */
2927
2604
  splice(selector, start, deleteCount, items) {
2928
- const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
2929
- const startIndex = start < 0 ? start - 1 : start;
2930
- const delCount = delAll ? -1 : Math.max(0, start + deleteCount);
2931
- const delRange = startIndex < 0 && delCount >= 0 ? "" : delCount;
2932
- const rangeSelector = "".concat(selector, "[").concat(startIndex, ":").concat(delRange, "]");
2605
+ const delAll = typeof deleteCount > "u" || deleteCount === -1, startIndex = start < 0 ? start - 1 : start, delCount = delAll ? -1 : Math.max(0, start + deleteCount), delRange = startIndex < 0 && delCount >= 0 ? "" : delCount, rangeSelector = `${selector}[${startIndex}:${delRange}]`;
2933
2606
  return this.insert("replace", rangeSelector, items || []);
2934
2607
  }
2935
2608
  /**
@@ -2938,8 +2611,7 @@
2938
2611
  * @param rev - Revision to lock the patch to
2939
2612
  */
2940
2613
  ifRevisionId(rev) {
2941
- this.operations.ifRevisionID = rev;
2942
- return this;
2614
+ return this.operations.ifRevisionID = rev, this;
2943
2615
  }
2944
2616
  /**
2945
2617
  * Return a plain JSON representation of the patch
@@ -2957,95 +2629,73 @@
2957
2629
  * Clears the patch of all operations
2958
2630
  */
2959
2631
  reset() {
2960
- this.operations = {};
2961
- return this;
2632
+ return this.operations = {}, this;
2962
2633
  }
2963
- _assign(op, props, merge = true) {
2964
- validateObject(op, props);
2965
- this.operations = Object.assign({}, this.operations, {
2634
+ _assign(op, props, merge = !0) {
2635
+ return validateObject(op, props), this.operations = Object.assign({}, this.operations, {
2966
2636
  [op]: Object.assign({}, merge && this.operations[op] || {}, props)
2967
- });
2968
- return this;
2637
+ }), this;
2969
2638
  }
2970
2639
  _set(op, props) {
2971
- return this._assign(op, props, false);
2640
+ return this._assign(op, props, !1);
2972
2641
  }
2973
2642
  }
2974
- const _ObservablePatch = class _ObservablePatch extends BasePatch {
2643
+ var _client$5;
2644
+ const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
2975
2645
  constructor(selection, operations, client) {
2976
- super(selection, operations);
2977
- __privateAdd$6(this, _client$5, void 0);
2978
- __privateSet$6(this, _client$5, client);
2646
+ super(selection, operations), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
2979
2647
  }
2980
2648
  /**
2981
2649
  * Clones the patch
2982
2650
  */
2983
2651
  clone() {
2984
- return new _ObservablePatch(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
2652
+ return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
2985
2653
  }
2986
2654
  commit(options) {
2987
- if (!__privateGet$6(this, _client$5)) {
2655
+ if (!__privateGet$6(this, _client$5))
2988
2656
  throw new Error(
2989
2657
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2990
2658
  );
2991
- }
2992
- const returnFirst = typeof this.selection === "string";
2993
- const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
2659
+ const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
2994
2660
  return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
2995
2661
  }
2996
2662
  };
2997
- _client$5 = new WeakMap();
2663
+ _client$5 = /* @__PURE__ */ new WeakMap();
2998
2664
  let ObservablePatch = _ObservablePatch;
2999
- const _Patch = class _Patch extends BasePatch {
2665
+ var _client2$5;
2666
+ const _Patch = class _Patch2 extends BasePatch {
3000
2667
  constructor(selection, operations, client) {
3001
- super(selection, operations);
3002
- __privateAdd$6(this, _client2$5, void 0);
3003
- __privateSet$6(this, _client2$5, client);
2668
+ super(selection, operations), __privateAdd$6(this, _client2$5, void 0), __privateSet$6(this, _client2$5, client);
3004
2669
  }
3005
2670
  /**
3006
2671
  * Clones the patch
3007
2672
  */
3008
2673
  clone() {
3009
- return new _Patch(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
2674
+ return new _Patch2(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
3010
2675
  }
3011
2676
  commit(options) {
3012
- if (!__privateGet$6(this, _client2$5)) {
2677
+ if (!__privateGet$6(this, _client2$5))
3013
2678
  throw new Error(
3014
2679
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
3015
2680
  );
3016
- }
3017
- const returnFirst = typeof this.selection === "string";
3018
- const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
2681
+ const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
3019
2682
  return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
3020
2683
  }
3021
2684
  };
3022
- _client2$5 = new WeakMap();
2685
+ _client2$5 = /* @__PURE__ */ new WeakMap();
3023
2686
  let Patch = _Patch;
3024
-
3025
2687
  var __accessCheck$5 = (obj, member, msg) => {
3026
2688
  if (!member.has(obj))
3027
2689
  throw TypeError("Cannot " + msg);
3028
- };
3029
- var __privateGet$5 = (obj, member, getter) => {
3030
- __accessCheck$5(obj, member, "read from private field");
3031
- return getter ? getter.call(obj) : member.get(obj);
3032
- };
3033
- var __privateAdd$5 = (obj, member, value) => {
2690
+ }, __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$5 = (obj, member, value) => {
3034
2691
  if (member.has(obj))
3035
2692
  throw TypeError("Cannot add the same private member more than once");
3036
2693
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3037
- };
3038
- var __privateSet$5 = (obj, member, value, setter) => {
3039
- __accessCheck$5(obj, member, "write to private field");
3040
- setter ? setter.call(obj, value) : member.set(obj, value);
3041
- return value;
3042
- };
3043
- var _client$4, _client2$4;
3044
- const defaultMutateOptions = { returnDocuments: false };
2694
+ }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
2695
+ const defaultMutateOptions = { returnDocuments: !1 };
3045
2696
  class BaseTransaction {
3046
2697
  constructor(operations = [], transactionId) {
3047
- this.operations = operations;
3048
- this.trxId = transactionId;
2698
+ this.operations = operations, this.trxId = transactionId;
3049
2699
  }
3050
2700
  /**
3051
2701
  * Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.
@@ -3054,8 +2704,7 @@
3054
2704
  * @param doc - Document to create. Requires a `_type` property.
3055
2705
  */
3056
2706
  create(doc) {
3057
- validateObject("create", doc);
3058
- return this._add({ create: doc });
2707
+ return validateObject("create", doc), this._add({ create: doc });
3059
2708
  }
3060
2709
  /**
3061
2710
  * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
@@ -3065,9 +2714,7 @@
3065
2714
  */
3066
2715
  createIfNotExists(doc) {
3067
2716
  const op = "createIfNotExists";
3068
- validateObject(op, doc);
3069
- requireDocumentId(op, doc);
3070
- return this._add({ [op]: doc });
2717
+ return validateObject(op, doc), requireDocumentId(op, doc), this._add({ [op]: doc });
3071
2718
  }
3072
2719
  /**
3073
2720
  * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
@@ -3077,9 +2724,7 @@
3077
2724
  */
3078
2725
  createOrReplace(doc) {
3079
2726
  const op = "createOrReplace";
3080
- validateObject(op, doc);
3081
- requireDocumentId(op, doc);
3082
- return this._add({ [op]: doc });
2727
+ return validateObject(op, doc), requireDocumentId(op, doc), this._add({ [op]: doc });
3083
2728
  }
3084
2729
  /**
3085
2730
  * Deletes the document with the given document ID
@@ -3088,15 +2733,10 @@
3088
2733
  * @param documentId - Document ID to delete
3089
2734
  */
3090
2735
  delete(documentId) {
3091
- validateDocumentId("delete", documentId);
3092
- return this._add({ delete: { id: documentId } });
2736
+ return validateDocumentId("delete", documentId), this._add({ delete: { id: documentId } });
3093
2737
  }
3094
2738
  transactionId(id) {
3095
- if (!id) {
3096
- return this.trxId;
3097
- }
3098
- this.trxId = id;
3099
- return this;
2739
+ return id ? (this.trxId = id, this) : this.trxId;
3100
2740
  }
3101
2741
  /**
3102
2742
  * Return a plain JSON representation of the transaction
@@ -3114,162 +2754,124 @@
3114
2754
  * Clears the transaction of all operations
3115
2755
  */
3116
2756
  reset() {
3117
- this.operations = [];
3118
- return this;
2757
+ return this.operations = [], this;
3119
2758
  }
3120
2759
  _add(mut) {
3121
- this.operations.push(mut);
3122
- return this;
2760
+ return this.operations.push(mut), this;
3123
2761
  }
3124
2762
  }
3125
- const _Transaction = class _Transaction extends BaseTransaction {
2763
+ var _client$4;
2764
+ const _Transaction = class _Transaction2 extends BaseTransaction {
3126
2765
  constructor(operations, client, transactionId) {
3127
- super(operations, transactionId);
3128
- __privateAdd$5(this, _client$4, void 0);
3129
- __privateSet$5(this, _client$4, client);
2766
+ super(operations, transactionId), __privateAdd$5(this, _client$4, void 0), __privateSet$5(this, _client$4, client);
3130
2767
  }
3131
2768
  /**
3132
2769
  * Clones the transaction
3133
2770
  */
3134
2771
  clone() {
3135
- return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
2772
+ return new _Transaction2([...this.operations], __privateGet$5(this, _client$4), this.trxId);
3136
2773
  }
3137
2774
  commit(options) {
3138
- if (!__privateGet$5(this, _client$4)) {
2775
+ if (!__privateGet$5(this, _client$4))
3139
2776
  throw new Error(
3140
2777
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
3141
2778
  );
3142
- }
3143
2779
  return __privateGet$5(this, _client$4).mutate(
3144
2780
  this.serialize(),
3145
2781
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
3146
2782
  );
3147
2783
  }
3148
2784
  patch(patchOrDocumentId, patchOps) {
3149
- const isBuilder = typeof patchOps === "function";
3150
- const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof Patch;
3151
- if (isPatch) {
2785
+ const isBuilder = typeof patchOps == "function";
2786
+ if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
3152
2787
  return this._add({ patch: patchOrDocumentId.serialize() });
3153
- }
3154
2788
  if (isBuilder) {
3155
2789
  const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
3156
- if (!(patch instanceof Patch)) {
2790
+ if (!(patch instanceof Patch))
3157
2791
  throw new Error("function passed to `patch()` must return the patch");
3158
- }
3159
2792
  return this._add({ patch: patch.serialize() });
3160
2793
  }
3161
2794
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
3162
2795
  }
3163
2796
  };
3164
- _client$4 = new WeakMap();
2797
+ _client$4 = /* @__PURE__ */ new WeakMap();
3165
2798
  let Transaction = _Transaction;
3166
- const _ObservableTransaction = class _ObservableTransaction extends BaseTransaction {
2799
+ var _client2$4;
2800
+ const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
3167
2801
  constructor(operations, client, transactionId) {
3168
- super(operations, transactionId);
3169
- __privateAdd$5(this, _client2$4, void 0);
3170
- __privateSet$5(this, _client2$4, client);
2802
+ super(operations, transactionId), __privateAdd$5(this, _client2$4, void 0), __privateSet$5(this, _client2$4, client);
3171
2803
  }
3172
2804
  /**
3173
2805
  * Clones the transaction
3174
2806
  */
3175
2807
  clone() {
3176
- return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
2808
+ return new _ObservableTransaction2([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
3177
2809
  }
3178
2810
  commit(options) {
3179
- if (!__privateGet$5(this, _client2$4)) {
2811
+ if (!__privateGet$5(this, _client2$4))
3180
2812
  throw new Error(
3181
2813
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
3182
2814
  );
3183
- }
3184
2815
  return __privateGet$5(this, _client2$4).mutate(
3185
2816
  this.serialize(),
3186
2817
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
3187
2818
  );
3188
2819
  }
3189
2820
  patch(patchOrDocumentId, patchOps) {
3190
- const isBuilder = typeof patchOps === "function";
3191
- const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof ObservablePatch;
3192
- if (isPatch) {
2821
+ const isBuilder = typeof patchOps == "function";
2822
+ if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
3193
2823
  return this._add({ patch: patchOrDocumentId.serialize() });
3194
- }
3195
2824
  if (isBuilder) {
3196
2825
  const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
3197
- if (!(patch instanceof ObservablePatch)) {
2826
+ if (!(patch instanceof ObservablePatch))
3198
2827
  throw new Error("function passed to `patch()` must return the patch");
3199
- }
3200
2828
  return this._add({ patch: patch.serialize() });
3201
2829
  }
3202
2830
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
3203
2831
  }
3204
2832
  };
3205
- _client2$4 = new WeakMap();
2833
+ _client2$4 = /* @__PURE__ */ new WeakMap();
3206
2834
  let ObservableTransaction = _ObservableTransaction;
3207
-
3208
2835
  const BASE_URL = "https://www.sanity.io/help/";
3209
2836
  function generateHelpUrl(slug) {
3210
2837
  return BASE_URL + slug;
3211
2838
  }
3212
-
3213
2839
  function once(fn) {
3214
- let didCall = false;
3215
- let returnValue;
3216
- return (...args) => {
3217
- if (didCall) {
3218
- return returnValue;
3219
- }
3220
- returnValue = fn(...args);
3221
- didCall = true;
3222
- return returnValue;
3223
- };
2840
+ let didCall = !1, returnValue;
2841
+ return (...args) => (didCall || (returnValue = fn(...args), didCall = !0), returnValue);
3224
2842
  }
3225
-
3226
2843
  const createWarningPrinter = (message) => (
3227
2844
  // eslint-disable-next-line no-console
3228
2845
  once((...args) => console.warn(message.join(" "), ...args))
3229
- );
3230
- const printCdnWarning = createWarningPrinter([
2846
+ ), printCdnWarning = createWarningPrinter([
3231
2847
  "Since you haven't set a value for `useCdn`, we will deliver content using our",
3232
2848
  "global, edge-cached API-CDN. If you wish to have content delivered faster, set",
3233
2849
  "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
3234
- ]);
3235
- const printCdnPreviewDraftsWarning = createWarningPrinter([
2850
+ ]), printCdnPreviewDraftsWarning = createWarningPrinter([
3236
2851
  "The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
3237
2852
  "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
3238
- ]);
3239
- const printBrowserTokenWarning = createWarningPrinter([
2853
+ ]), printBrowserTokenWarning = createWarningPrinter([
3240
2854
  "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
3241
- "See ".concat(generateHelpUrl(
3242
- "js-client-browser-token"
3243
- ), " for more information and how to hide this warning.")
3244
- ]);
3245
- const printNoApiVersionSpecifiedWarning = createWarningPrinter([
2855
+ `See ${generateHelpUrl(
2856
+ "js-client-browser-token"
2857
+ )} for more information and how to hide this warning.`
2858
+ ]), printNoApiVersionSpecifiedWarning = createWarningPrinter([
3246
2859
  "Using the Sanity client without specifying an API version is deprecated.",
3247
- "See ".concat(generateHelpUrl("js-client-api-version"))
3248
- ]);
3249
- const printNoDefaultExport = createWarningPrinter([
2860
+ `See ${generateHelpUrl("js-client-api-version")}`
2861
+ ]), printNoDefaultExport = createWarningPrinter([
3250
2862
  "The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."
3251
- ]);
3252
-
3253
- const defaultCdnHost = "apicdn.sanity.io";
3254
- const defaultConfig = {
2863
+ ]), defaultCdnHost = "apicdn.sanity.io", defaultConfig = {
3255
2864
  apiHost: "https://api.sanity.io",
3256
2865
  apiVersion: "1",
3257
- useProjectHostname: true,
3258
- stega: { enabled: false }
3259
- };
3260
- const LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
3261
- const isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
3262
- const validateApiVersion = function validateApiVersion2(apiVersion) {
3263
- if (apiVersion === "1" || apiVersion === "X") {
2866
+ useProjectHostname: !0,
2867
+ stega: { enabled: !1 }
2868
+ }, LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"], isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1, validateApiVersion = function(apiVersion) {
2869
+ if (apiVersion === "1" || apiVersion === "X")
3264
2870
  return;
3265
- }
3266
2871
  const apiDate = new Date(apiVersion);
3267
- const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
3268
- if (!apiVersionValid) {
2872
+ if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
3269
2873
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
3270
- }
3271
- };
3272
- const validateApiPerspective = function validateApiPerspective2(perspective) {
2874
+ }, validateApiPerspective = function(perspective) {
3273
2875
  switch (perspective) {
3274
2876
  case "previewDrafts":
3275
2877
  case "published":
@@ -3280,196 +2882,141 @@
3280
2882
  "Invalid API perspective string, expected `published`, `previewDrafts` or `raw`"
3281
2883
  );
3282
2884
  }
3283
- };
3284
- const initConfig = (config, prevConfig) => {
2885
+ }, initConfig = (config, prevConfig) => {
3285
2886
  const specifiedConfig = {
3286
2887
  ...prevConfig,
3287
2888
  ...config,
3288
2889
  stega: {
3289
- ...typeof prevConfig.stega === "boolean" ? { enabled: prevConfig.stega } : prevConfig.stega || defaultConfig.stega,
3290
- ...typeof config.stega === "boolean" ? { enabled: config.stega } : config.stega || {}
2890
+ ...typeof prevConfig.stega == "boolean" ? { enabled: prevConfig.stega } : prevConfig.stega || defaultConfig.stega,
2891
+ ...typeof config.stega == "boolean" ? { enabled: config.stega } : config.stega || {}
3291
2892
  }
3292
2893
  };
3293
- if (!specifiedConfig.apiVersion) {
3294
- printNoApiVersionSpecifiedWarning();
3295
- }
2894
+ specifiedConfig.apiVersion || printNoApiVersionSpecifiedWarning();
3296
2895
  const newConfig = {
3297
2896
  ...defaultConfig,
3298
2897
  ...specifiedConfig
3299
- };
3300
- const projectBased = newConfig.useProjectHostname;
3301
- if (typeof Promise === "undefined") {
2898
+ }, projectBased = newConfig.useProjectHostname;
2899
+ if (typeof Promise > "u") {
3302
2900
  const helpUrl = generateHelpUrl("js-client-promise-polyfill");
3303
- throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(helpUrl));
2901
+ throw new Error(`No native Promise-implementation found, polyfill needed - see ${helpUrl}`);
3304
2902
  }
3305
- if (projectBased && !newConfig.projectId) {
2903
+ if (projectBased && !newConfig.projectId)
3306
2904
  throw new Error("Configuration must contain `projectId`");
3307
- }
3308
- if (typeof newConfig.perspective === "string") {
3309
- validateApiPerspective(newConfig.perspective);
3310
- }
3311
- if ("encodeSourceMap" in newConfig) {
2905
+ if (typeof newConfig.perspective == "string" && validateApiPerspective(newConfig.perspective), "encodeSourceMap" in newConfig)
3312
2906
  throw new Error(
3313
2907
  "It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?"
3314
2908
  );
3315
- }
3316
- if ("encodeSourceMapAtPath" in newConfig) {
2909
+ if ("encodeSourceMapAtPath" in newConfig)
3317
2910
  throw new Error(
3318
2911
  "It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?"
3319
2912
  );
3320
- }
3321
- if (typeof newConfig.stega.enabled !== "boolean") {
3322
- throw new Error("stega.enabled must be a boolean, received ".concat(newConfig.stega.enabled));
3323
- }
3324
- if (newConfig.stega.enabled && newConfig.stega.studioUrl === void 0) {
2913
+ if (typeof newConfig.stega.enabled != "boolean")
2914
+ throw new Error(`stega.enabled must be a boolean, received ${newConfig.stega.enabled}`);
2915
+ if (newConfig.stega.enabled && newConfig.stega.studioUrl === void 0)
3325
2916
  throw new Error("stega.studioUrl must be defined when stega.enabled is true");
3326
- }
3327
- if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl !== "string" && typeof newConfig.stega.studioUrl !== "function") {
2917
+ if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl != "string" && typeof newConfig.stega.studioUrl != "function")
3328
2918
  throw new Error(
3329
- "stega.studioUrl must be a string or a function, received ".concat(newConfig.stega.studioUrl)
2919
+ `stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
3330
2920
  );
3331
- }
3332
- const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
3333
- const isLocalhost = isBrowser && isLocal(window.location.hostname);
3334
- if (isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true) {
3335
- printBrowserTokenWarning();
3336
- } else if (typeof newConfig.useCdn === "undefined") {
3337
- printCdnWarning();
3338
- }
3339
- if (projectBased) {
3340
- projectId(newConfig.projectId);
3341
- }
3342
- if (newConfig.dataset) {
3343
- dataset(newConfig.dataset);
3344
- }
3345
- if ("requestTagPrefix" in newConfig) {
3346
- newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0;
3347
- }
3348
- newConfig.apiVersion = "".concat(newConfig.apiVersion).replace(/^v/, "");
3349
- newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost;
3350
- newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials;
3351
- validateApiVersion(newConfig.apiVersion);
3352
- const hostParts = newConfig.apiHost.split("://", 2);
3353
- const protocol = hostParts[0];
3354
- const host = hostParts[1];
3355
- const cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
3356
- if (newConfig.useProjectHostname) {
3357
- newConfig.url = "".concat(protocol, "://").concat(newConfig.projectId, ".").concat(host, "/v").concat(newConfig.apiVersion);
3358
- newConfig.cdnUrl = "".concat(protocol, "://").concat(newConfig.projectId, ".").concat(cdnHost, "/v").concat(newConfig.apiVersion);
3359
- } else {
3360
- newConfig.url = "".concat(newConfig.apiHost, "/v").concat(newConfig.apiVersion);
3361
- newConfig.cdnUrl = newConfig.url;
3362
- }
3363
- return newConfig;
3364
- };
3365
-
3366
- const projectHeader = "X-Sanity-Project-ID";
2921
+ const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
2922
+ isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== !0 ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn = newConfig.useCdn !== !1 && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
2923
+ const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
2924
+ return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig;
2925
+ }, projectHeader = "X-Sanity-Project-ID";
3367
2926
  function requestOptions(config, overrides = {}) {
3368
- const headers = {};
3369
- const token = overrides.token || config.token;
3370
- if (token) {
3371
- headers.Authorization = "Bearer ".concat(token);
3372
- }
3373
- if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
3374
- headers[projectHeader] = config.projectId;
3375
- }
3376
- const withCredentials = Boolean(
3377
- typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
3378
- );
3379
- const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
2927
+ const headers = {}, token = overrides.token || config.token;
2928
+ token && (headers.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config.useProjectHostname && config.projectId && (headers[projectHeader] = config.projectId);
2929
+ const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.token || config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
3380
2930
  return Object.assign({}, overrides, {
3381
2931
  headers: Object.assign({}, headers, overrides.headers || {}),
3382
- timeout: typeof timeout === "undefined" ? 5 * 60 * 1e3 : timeout,
2932
+ timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
3383
2933
  proxy: overrides.proxy || config.proxy,
3384
- json: true,
2934
+ json: !0,
3385
2935
  withCredentials,
3386
- fetch: typeof overrides.fetch === "object" && typeof config.fetch === "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
2936
+ fetch: typeof overrides.fetch == "object" && typeof config.fetch == "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
3387
2937
  });
3388
2938
  }
3389
-
3390
- var s={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},c={0:8203,1:8204,2:8205,3:65279},d=new Array(4).fill(String.fromCodePoint(c[0])).join("");function E(t){let e=JSON.stringify(t);return `${d}${Array.from(e).map(r=>{let n=r.charCodeAt(0);if(n>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);return Array.from(n.toString(4).padStart(4,"0")).map(o=>String.fromCodePoint(c[o])).join("")}).join("")}`}function I(t){return Number.isNaN(Number(t))?Boolean(Date.parse(t)):!1}function x(t){try{new URL(t,t.startsWith("/")?"https://acme.com":void 0);}catch{return !1}return !0}function b(t,e,r="auto"){return r===!0||r==="auto"&&(I(t)||x(t))?t:`${t}${E(e)}`}Object.fromEntries(Object.entries(c).map(t=>t.reverse()));Object.fromEntries(Object.entries(s).map(t=>t.reverse()));var S=`${Object.values(s).map(t=>`\\u{${t.toString(16)}}`).join("")}`,f=new RegExp(`[${S}]{4,}`,"gu");function X(t){var e;return {cleaned:t.replace(f,""),encoded:((e=t.match(f))==null?void 0:e[0])||""}}
3391
-
2939
+ var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 }, d = new Array(4).fill(String.fromCodePoint(c[0])).join("");
2940
+ function E(t) {
2941
+ let e = JSON.stringify(t);
2942
+ return `${d}${Array.from(e).map((r) => {
2943
+ let n = r.charCodeAt(0);
2944
+ if (n > 255)
2945
+ throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
2946
+ return Array.from(n.toString(4).padStart(4, "0")).map((o) => String.fromCodePoint(c[o])).join("");
2947
+ }).join("")}`;
2948
+ }
2949
+ function I(t) {
2950
+ return Number.isNaN(Number(t)) ? !!Date.parse(t) : !1;
2951
+ }
2952
+ function x(t) {
2953
+ try {
2954
+ new URL(t, t.startsWith("/") ? "https://acme.com" : void 0);
2955
+ } catch {
2956
+ return !1;
2957
+ }
2958
+ return !0;
2959
+ }
2960
+ function b(t, e, r = "auto") {
2961
+ return r === !0 || r === "auto" && (I(t) || x(t)) ? t : `${t}${E(e)}`;
2962
+ }
2963
+ Object.fromEntries(Object.entries(c).map((t) => t.reverse()));
2964
+ Object.fromEntries(Object.entries(s).map((t) => t.reverse()));
2965
+ var S = `${Object.values(s).map((t) => `\\u{${t.toString(16)}}`).join("")}`, f = new RegExp(`[${S}]{4,}`, "gu");
2966
+ function X(t) {
2967
+ var e;
2968
+ return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ? void 0 : e[0]) || "" };
2969
+ }
3392
2970
  function vercelStegaCleanAll(result) {
3393
2971
  try {
3394
2972
  return JSON.parse(
3395
- JSON.stringify(result, (key, value) => {
3396
- if (typeof value !== "string")
3397
- return value;
3398
- return X(value).cleaned;
3399
- })
2973
+ JSON.stringify(result, (key, value) => typeof value != "string" ? value : X(value).cleaned)
3400
2974
  );
3401
2975
  } catch {
3402
2976
  return result;
3403
2977
  }
3404
2978
  }
3405
-
3406
2979
  const encodeQueryString = ({
3407
2980
  query,
3408
2981
  params = {},
3409
2982
  options = {}
3410
2983
  }) => {
3411
- const searchParams = new URLSearchParams();
3412
- const { tag, returnQuery, ...opts } = options;
3413
- if (tag)
3414
- searchParams.append("tag", tag);
3415
- searchParams.append("query", query);
3416
- for (const [key, value] of Object.entries(params)) {
3417
- searchParams.append("$".concat(key), JSON.stringify(value));
3418
- }
3419
- for (const [key, value] of Object.entries(opts)) {
3420
- if (value)
3421
- searchParams.append(key, "".concat(value));
3422
- }
3423
- if (returnQuery === false)
3424
- searchParams.append("returnQuery", "false");
3425
- return "?".concat(searchParams);
3426
- };
3427
-
3428
- const excludeFalsey = (param, defValue) => {
3429
- const value = typeof param === "undefined" ? defValue : param;
3430
- return param === false ? void 0 : value;
3431
- };
3432
- const getMutationQuery = (options = {}) => {
3433
- return {
3434
- dryRun: options.dryRun,
3435
- returnIds: true,
3436
- returnDocuments: excludeFalsey(options.returnDocuments, true),
3437
- visibility: options.visibility || "sync",
3438
- autoGenerateArrayKeys: options.autoGenerateArrayKeys,
3439
- skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
3440
- };
3441
- };
3442
- const isResponse = (event) => event.type === "response";
3443
- const getBody = (event) => event.body;
3444
- const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
3445
- indexed[attr(doc)] = doc;
3446
- return indexed;
3447
- }, /* @__PURE__ */ Object.create(null));
3448
- const getQuerySizeLimit = 11264;
2984
+ const searchParams = new URLSearchParams(), { tag, returnQuery, ...opts } = options;
2985
+ tag && searchParams.append("tag", tag), searchParams.append("query", query);
2986
+ for (const [key, value] of Object.entries(params))
2987
+ searchParams.append(`$${key}`, JSON.stringify(value));
2988
+ for (const [key, value] of Object.entries(opts))
2989
+ value && searchParams.append(key, `${value}`);
2990
+ return returnQuery === !1 && searchParams.append("returnQuery", "false"), `?${searchParams}`;
2991
+ }, excludeFalsey = (param, defValue) => param === !1 ? void 0 : typeof param > "u" ? defValue : param, getMutationQuery = (options = {}) => ({
2992
+ dryRun: options.dryRun,
2993
+ returnIds: !0,
2994
+ returnDocuments: excludeFalsey(options.returnDocuments, !0),
2995
+ visibility: options.visibility || "sync",
2996
+ autoGenerateArrayKeys: options.autoGenerateArrayKeys,
2997
+ skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
2998
+ }), isResponse = (event) => event.type === "response", getBody = (event) => event.body, indexBy = (docs, attr) => docs.reduce((indexed, doc) => (indexed[attr(doc)] = doc, indexed), /* @__PURE__ */ Object.create(null)), getQuerySizeLimit = 11264;
3449
2999
  function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
3450
3000
  const stega = "stega" in options ? {
3451
3001
  ..._stega || {},
3452
- ...typeof options.stega === "boolean" ? { enabled: options.stega } : options.stega || {}
3453
- } : _stega;
3454
- const params = stega.enabled ? vercelStegaCleanAll(_params) : _params;
3455
- const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
3456
- const { cache, next, ...opts } = {
3002
+ ...typeof options.stega == "boolean" ? { enabled: options.stega } : options.stega || {}
3003
+ } : _stega, params = stega.enabled ? vercelStegaCleanAll(_params) : _params, mapResponse = options.filterResponse === !1 ? (res) => res : (res) => res.result, { cache, next, ...opts } = {
3457
3004
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
3458
3005
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
3459
- useAbortSignal: typeof options.signal !== "undefined",
3006
+ useAbortSignal: typeof options.signal < "u",
3460
3007
  // Set `resultSourceMap' when stega is enabled, as it's required for encoding.
3461
3008
  resultSourceMap: stega.enabled ? "withKeyArraySelector" : options.resultSourceMap,
3462
3009
  ...options,
3463
3010
  // Default to not returning the query, unless `filterResponse` is `false`,
3464
3011
  // or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy
3465
- returnQuery: options.filterResponse === false && options.returnQuery !== false
3466
- };
3467
- const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
3468
- const $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
3012
+ returnQuery: options.filterResponse === !1 && options.returnQuery !== !1
3013
+ }, reqOpts = typeof cache < "u" || typeof next < "u" ? { ...opts, fetch: { cache, next } } : opts, $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
3469
3014
  return stega.enabled ? $request.pipe(
3470
3015
  combineLatestWith(
3471
3016
  from(
3472
- Promise.resolve().then(function () { return stegaEncodeSourceMapB6IscnhR; }).then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
3017
+ Promise.resolve().then(function () { return stegaEncodeSourceMapDe3F_oJN; }).then(function(n) {
3018
+ return n.stegaEncodeSourceMap$1;
3019
+ }).then(
3473
3020
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
3474
3021
  )
3475
3022
  )
@@ -3483,14 +3030,14 @@
3483
3030
  ) : $request.pipe(map(mapResponse));
3484
3031
  }
3485
3032
  function _getDocument(client, httpRequest, id, opts = {}) {
3486
- const options = { uri: _getDataUrl(client, "doc", id), json: true, tag: opts.tag };
3033
+ const options = { uri: _getDataUrl(client, "doc", id), json: !0, tag: opts.tag };
3487
3034
  return _requestObservable(client, httpRequest, options).pipe(
3488
3035
  filter(isResponse),
3489
3036
  map((event) => event.body.documents && event.body.documents[0])
3490
3037
  );
3491
3038
  }
3492
3039
  function _getDocuments(client, httpRequest, ids, opts = {}) {
3493
- const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: true, tag: opts.tag };
3040
+ const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: !0, tag: opts.tag };
3494
3041
  return _requestObservable(client, httpRequest, options).pipe(
3495
3042
  filter(isResponse),
3496
3043
  map((event) => {
@@ -3500,12 +3047,10 @@
3500
3047
  );
3501
3048
  }
3502
3049
  function _createIfNotExists(client, httpRequest, doc, options) {
3503
- requireDocumentId("createIfNotExists", doc);
3504
- return _create(client, httpRequest, doc, "createIfNotExists", options);
3050
+ return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
3505
3051
  }
3506
3052
  function _createOrReplace(client, httpRequest, doc, options) {
3507
- requireDocumentId("createOrReplace", doc);
3508
- return _create(client, httpRequest, doc, "createOrReplace", options);
3053
+ return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
3509
3054
  }
3510
3055
  function _delete(client, httpRequest, selection, options) {
3511
3056
  return _dataRequest(
@@ -3518,30 +3063,15 @@
3518
3063
  }
3519
3064
  function _mutate(client, httpRequest, mutations, options) {
3520
3065
  let mut;
3521
- if (mutations instanceof Patch || mutations instanceof ObservablePatch) {
3522
- mut = { patch: mutations.serialize() };
3523
- } else if (mutations instanceof Transaction || mutations instanceof ObservableTransaction) {
3524
- mut = mutations.serialize();
3525
- } else {
3526
- mut = mutations;
3527
- }
3528
- const muts = Array.isArray(mut) ? mut : [mut];
3529
- const transactionId = options && options.transactionId || void 0;
3066
+ mutations instanceof Patch || mutations instanceof ObservablePatch ? mut = { patch: mutations.serialize() } : mutations instanceof Transaction || mutations instanceof ObservableTransaction ? mut = mutations.serialize() : mut = mutations;
3067
+ const muts = Array.isArray(mut) ? mut : [mut], transactionId = options && options.transactionId || void 0;
3530
3068
  return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
3531
3069
  }
3532
3070
  function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
3533
- const isMutation = endpoint === "mutate";
3534
- const isQuery = endpoint === "query";
3535
- const strQuery = isMutation ? "" : encodeQueryString(body);
3536
- const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
3537
- const stringQuery = useGet ? strQuery : "";
3538
- const returnFirst = options.returnFirst;
3539
- const { timeout, token, tag, headers, returnQuery } = options;
3540
- const uri = _getDataUrl(client, endpoint, stringQuery);
3541
- const reqOptions = {
3071
+ const isMutation = endpoint === "mutate", isQuery = endpoint === "query", strQuery = isMutation ? "" : encodeQueryString(body), useGet = !isMutation && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers, returnQuery } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
3542
3072
  method: useGet ? "GET" : "POST",
3543
3073
  uri,
3544
- json: true,
3074
+ json: !0,
3545
3075
  body: useGet ? void 0 : body,
3546
3076
  query: isMutation && getMutationQuery(options),
3547
3077
  timeout,
@@ -3561,15 +3091,12 @@
3561
3091
  filter(isResponse),
3562
3092
  map(getBody),
3563
3093
  map((res) => {
3564
- if (!isMutation) {
3094
+ if (!isMutation)
3565
3095
  return res;
3566
- }
3567
3096
  const results = res.results || [];
3568
- if (options.returnDocuments) {
3097
+ if (options.returnDocuments)
3569
3098
  return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
3570
- }
3571
- const key = returnFirst ? "documentId" : "documentIds";
3572
- const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
3099
+ const key = returnFirst ? "documentId" : "documentIds", ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
3573
3100
  return {
3574
3101
  transactionId: res.transactionId,
3575
3102
  results,
@@ -3579,139 +3106,91 @@
3579
3106
  );
3580
3107
  }
3581
3108
  function _create(client, httpRequest, doc, op, options = {}) {
3582
- const mutation = { [op]: doc };
3583
- const opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
3109
+ const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
3584
3110
  return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
3585
3111
  }
3586
3112
  function _requestObservable(client, httpRequest, options) {
3587
3113
  var _a, _b;
3588
- const uri = options.url || options.uri;
3589
- const config = client.config();
3590
- const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
3114
+ const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
3591
3115
  let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
3592
3116
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
3593
- if (tag && options.tag !== null) {
3594
- options.query = { tag: requestTag(tag), ...options.query };
3595
- }
3596
- if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
3117
+ if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
3597
3118
  const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
3598
- if (resultSourceMap !== void 0 && resultSourceMap !== false) {
3599
- options.query = { resultSourceMap, ...options.query };
3600
- }
3119
+ resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
3601
3120
  const perspective = options.perspective || config.perspective;
3602
- if (typeof perspective === "string" && perspective !== "raw") {
3603
- validateApiPerspective(perspective);
3604
- options.query = { perspective, ...options.query };
3605
- if (perspective === "previewDrafts" && useCdn) {
3606
- useCdn = false;
3607
- printCdnPreviewDraftsWarning();
3608
- }
3609
- }
3610
- if (options.returnQuery === false) {
3611
- options.query = { returnQuery: "false", ...options.query };
3612
- }
3121
+ typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
3613
3122
  }
3614
3123
  const reqOptions = requestOptions(
3615
3124
  config,
3616
3125
  Object.assign({}, options, {
3617
3126
  url: _getUrl(client, uri, useCdn)
3618
3127
  })
3619
- );
3620
- const request = new Observable(
3128
+ ), request = new Observable(
3621
3129
  (subscriber) => httpRequest(reqOptions, config.requester).subscribe(subscriber)
3622
3130
  );
3623
3131
  return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request;
3624
3132
  }
3625
3133
  function _request(client, httpRequest, options) {
3626
- const observable = _requestObservable(client, httpRequest, options).pipe(
3134
+ return _requestObservable(client, httpRequest, options).pipe(
3627
3135
  filter((event) => event.type === "response"),
3628
3136
  map((event) => event.body)
3629
3137
  );
3630
- return observable;
3631
3138
  }
3632
3139
  function _getDataUrl(client, operation, path) {
3633
- const config = client.config();
3634
- const catalog = hasDataset(config);
3635
- const baseUri = "/".concat(operation, "/").concat(catalog);
3636
- const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
3637
- return "/data".concat(uri).replace(/\/($|\?)/, "$1");
3140
+ const config = client.config(), catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
3141
+ return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
3638
3142
  }
3639
- function _getUrl(client, uri, canUseCdn = false) {
3143
+ function _getUrl(client, uri, canUseCdn = !1) {
3640
3144
  const { url, cdnUrl } = client.config();
3641
- const base = canUseCdn ? cdnUrl : url;
3642
- return "".concat(base, "/").concat(uri.replace(/^\//, ""));
3145
+ return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
3643
3146
  }
3644
3147
  function _withAbortSignal(signal) {
3645
- return (input) => {
3646
- return new Observable((observer) => {
3647
- const abort = () => observer.error(_createAbortError(signal));
3648
- if (signal && signal.aborted) {
3649
- abort();
3650
- return;
3651
- }
3652
- const subscription = input.subscribe(observer);
3653
- signal.addEventListener("abort", abort);
3654
- return () => {
3655
- signal.removeEventListener("abort", abort);
3656
- subscription.unsubscribe();
3657
- };
3658
- });
3659
- };
3148
+ return (input) => new Observable((observer) => {
3149
+ const abort = () => observer.error(_createAbortError(signal));
3150
+ if (signal && signal.aborted) {
3151
+ abort();
3152
+ return;
3153
+ }
3154
+ const subscription = input.subscribe(observer);
3155
+ return signal.addEventListener("abort", abort), () => {
3156
+ signal.removeEventListener("abort", abort), subscription.unsubscribe();
3157
+ };
3158
+ });
3660
3159
  }
3661
- const isDomExceptionSupported = Boolean(globalThis.DOMException);
3160
+ const isDomExceptionSupported = !!globalThis.DOMException;
3662
3161
  function _createAbortError(signal) {
3663
3162
  var _a, _b;
3664
- if (isDomExceptionSupported) {
3163
+ if (isDomExceptionSupported)
3665
3164
  return new DOMException((_a = signal == null ? void 0 : signal.reason) != null ? _a : "The operation was aborted.", "AbortError");
3666
- }
3667
3165
  const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
3668
- error.name = "AbortError";
3669
- return error;
3166
+ return error.name = "AbortError", error;
3670
3167
  }
3671
-
3672
3168
  var __accessCheck$4 = (obj, member, msg) => {
3673
3169
  if (!member.has(obj))
3674
3170
  throw TypeError("Cannot " + msg);
3675
- };
3676
- var __privateGet$4 = (obj, member, getter) => {
3677
- __accessCheck$4(obj, member, "read from private field");
3678
- return getter ? getter.call(obj) : member.get(obj);
3679
- };
3680
- var __privateAdd$4 = (obj, member, value) => {
3171
+ }, __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$4 = (obj, member, value) => {
3681
3172
  if (member.has(obj))
3682
3173
  throw TypeError("Cannot add the same private member more than once");
3683
3174
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3684
- };
3685
- var __privateSet$4 = (obj, member, value, setter) => {
3686
- __accessCheck$4(obj, member, "write to private field");
3687
- setter ? setter.call(obj, value) : member.set(obj, value);
3688
- return value;
3689
- };
3690
- var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
3175
+ }, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client$3, _httpRequest$4;
3691
3176
  class ObservableAssetsClient {
3692
3177
  constructor(client, httpRequest) {
3693
- __privateAdd$4(this, _client$3, void 0);
3694
- __privateAdd$4(this, _httpRequest$4, void 0);
3695
- __privateSet$4(this, _client$3, client);
3696
- __privateSet$4(this, _httpRequest$4, httpRequest);
3178
+ __privateAdd$4(this, _client$3, void 0), __privateAdd$4(this, _httpRequest$4, void 0), __privateSet$4(this, _client$3, client), __privateSet$4(this, _httpRequest$4, httpRequest);
3697
3179
  }
3698
3180
  upload(assetType, body, options) {
3699
3181
  return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
3700
3182
  }
3701
3183
  }
3702
- _client$3 = new WeakMap();
3703
- _httpRequest$4 = new WeakMap();
3184
+ _client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
3185
+ var _client2$3, _httpRequest2$4;
3704
3186
  class AssetsClient {
3705
3187
  constructor(client, httpRequest) {
3706
- __privateAdd$4(this, _client2$3, void 0);
3707
- __privateAdd$4(this, _httpRequest2$4, void 0);
3708
- __privateSet$4(this, _client2$3, client);
3709
- __privateSet$4(this, _httpRequest2$4, httpRequest);
3188
+ __privateAdd$4(this, _client2$3, void 0), __privateAdd$4(this, _httpRequest2$4, void 0), __privateSet$4(this, _client2$3, client), __privateSet$4(this, _httpRequest2$4, httpRequest);
3710
3189
  }
3711
3190
  upload(assetType, body, options) {
3712
- const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
3191
+ const observable2 = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
3713
3192
  return lastValueFrom(
3714
- observable.pipe(
3193
+ observable2.pipe(
3715
3194
  filter((event) => event.type === "response"),
3716
3195
  map(
3717
3196
  (event) => event.body.document
@@ -3720,19 +3199,12 @@
3720
3199
  );
3721
3200
  }
3722
3201
  }
3723
- _client2$3 = new WeakMap();
3724
- _httpRequest2$4 = new WeakMap();
3202
+ _client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
3725
3203
  function _upload(client, httpRequest, assetType, body, opts = {}) {
3726
3204
  validateAssetType(assetType);
3727
3205
  let meta = opts.extract || void 0;
3728
- if (meta && !meta.length) {
3729
- meta = ["none"];
3730
- }
3731
- const dataset = hasDataset(client.config());
3732
- const assetEndpoint = assetType === "image" ? "images" : "files";
3733
- const options = optionsFromFile(opts, body);
3734
- const { tag, label, title, description, creditLine, filename, source } = options;
3735
- const query = {
3206
+ meta && !meta.length && (meta = ["none"]);
3207
+ const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
3736
3208
  label,
3737
3209
  title,
3738
3210
  description,
@@ -3740,102 +3212,52 @@
3740
3212
  meta,
3741
3213
  creditLine
3742
3214
  };
3743
- if (source) {
3744
- query.sourceId = source.id;
3745
- query.sourceName = source.name;
3746
- query.sourceUrl = source.url;
3747
- }
3748
- return _requestObservable(client, httpRequest, {
3215
+ return source && (query.sourceId = source.id, query.sourceName = source.name, query.sourceUrl = source.url), _requestObservable(client, httpRequest, {
3749
3216
  tag,
3750
3217
  method: "POST",
3751
3218
  timeout: options.timeout || 0,
3752
- uri: "/assets/".concat(assetEndpoint, "/").concat(dataset),
3219
+ uri: `/assets/${assetEndpoint}/${dataset2}`,
3753
3220
  headers: options.contentType ? { "Content-Type": options.contentType } : {},
3754
3221
  query,
3755
3222
  body
3756
3223
  });
3757
3224
  }
3758
3225
  function optionsFromFile(opts, file) {
3759
- if (typeof File === "undefined" || !(file instanceof File)) {
3760
- return opts;
3761
- }
3762
- return Object.assign(
3226
+ return typeof File > "u" || !(file instanceof File) ? opts : Object.assign(
3763
3227
  {
3764
- filename: opts.preserveFilename === false ? void 0 : file.name,
3228
+ filename: opts.preserveFilename === !1 ? void 0 : file.name,
3765
3229
  contentType: file.type
3766
3230
  },
3767
3231
  opts
3768
3232
  );
3769
3233
  }
3770
-
3771
- var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => {
3772
- target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
3773
- return target;
3774
- }, {});
3775
-
3776
- const pick = (obj, props) => props.reduce((selection, prop) => {
3777
- if (typeof obj[prop] === "undefined") {
3778
- return selection;
3779
- }
3780
- selection[prop] = obj[prop];
3781
- return selection;
3782
- }, {});
3783
-
3784
- const MAX_URL_LENGTH = 16e3 - 1200;
3785
- const possibleOptions = [
3234
+ var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = typeof obj[prop] > "u" ? defaults2[prop] : obj[prop], target), {});
3235
+ const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), MAX_URL_LENGTH = 14800, possibleOptions = [
3786
3236
  "includePreviousRevision",
3787
3237
  "includeResult",
3788
3238
  "visibility",
3789
3239
  "effectFormat",
3790
3240
  "tag"
3791
- ];
3792
- const defaultOptions = {
3793
- includeResult: true
3241
+ ], defaultOptions = {
3242
+ includeResult: !0
3794
3243
  };
3795
3244
  function _listen(query, params, opts = {}) {
3796
- const { url, token, withCredentials, requestTagPrefix } = this.config();
3797
- const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag;
3798
- const options = { ...defaults(opts, defaultOptions), tag };
3799
- const listenOpts = pick(options, possibleOptions);
3800
- const qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } });
3801
- const uri = "".concat(url).concat(_getDataUrl(this, "listen", qs));
3802
- if (uri.length > MAX_URL_LENGTH) {
3245
+ const { url, token, withCredentials, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = { ...defaults(opts, defaultOptions), tag }, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } }), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
3246
+ if (uri.length > MAX_URL_LENGTH)
3803
3247
  return new Observable((observer) => observer.error(new Error("Query too large for listener")));
3804
- }
3805
- const listenFor = options.events ? options.events : ["mutation"];
3806
- const shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
3807
- const esOptions = {};
3808
- if (token || withCredentials) {
3809
- esOptions.withCredentials = true;
3810
- }
3811
- if (token) {
3812
- esOptions.headers = {
3813
- Authorization: "Bearer ".concat(token)
3814
- };
3815
- }
3816
- return new Observable((observer) => {
3248
+ const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1, esOptions = {};
3249
+ return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
3250
+ Authorization: `Bearer ${token}`
3251
+ }), new Observable((observer) => {
3817
3252
  let es;
3818
3253
  getEventSource().then((eventSource) => {
3819
3254
  es = eventSource;
3820
3255
  }).catch((reason) => {
3821
- observer.error(reason);
3822
- stop();
3256
+ observer.error(reason), stop();
3823
3257
  });
3824
- let reconnectTimer;
3825
- let stopped = false;
3258
+ let reconnectTimer, stopped = !1;
3826
3259
  function onError() {
3827
- if (stopped) {
3828
- return;
3829
- }
3830
- emitReconnect();
3831
- if (stopped) {
3832
- return;
3833
- }
3834
- if (es.readyState === es.CLOSED) {
3835
- unsubscribe();
3836
- clearTimeout(reconnectTimer);
3837
- reconnectTimer = setTimeout(open, 100);
3838
- }
3260
+ stopped || (emitReconnect(), !stopped && es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100)));
3839
3261
  }
3840
3262
  function onChannelError(err) {
3841
3263
  observer.error(cooerceError(err));
@@ -3845,44 +3267,27 @@
3845
3267
  return event instanceof Error ? observer.error(event) : observer.next(event);
3846
3268
  }
3847
3269
  function onDisconnect() {
3848
- stopped = true;
3849
- unsubscribe();
3850
- observer.complete();
3270
+ stopped = !0, unsubscribe(), observer.complete();
3851
3271
  }
3852
3272
  function unsubscribe() {
3853
- if (!es)
3854
- return;
3855
- es.removeEventListener("error", onError);
3856
- es.removeEventListener("channelError", onChannelError);
3857
- es.removeEventListener("disconnect", onDisconnect);
3858
- listenFor.forEach((type) => es.removeEventListener(type, onMessage));
3859
- es.close();
3273
+ es && (es.removeEventListener("error", onError), es.removeEventListener("channelError", onChannelError), es.removeEventListener("disconnect", onDisconnect), listenFor.forEach((type) => es.removeEventListener(type, onMessage)), es.close());
3860
3274
  }
3861
3275
  function emitReconnect() {
3862
- if (shouldEmitReconnect) {
3863
- observer.next({ type: "reconnect" });
3864
- }
3276
+ shouldEmitReconnect && observer.next({ type: "reconnect" });
3865
3277
  }
3866
3278
  async function getEventSource() {
3867
- const { default: EventSource } = await Promise.resolve().then(function () { return browser$2; });
3868
- const evs = new EventSource(uri, esOptions);
3869
- evs.addEventListener("error", onError);
3870
- evs.addEventListener("channelError", onChannelError);
3871
- evs.addEventListener("disconnect", onDisconnect);
3872
- listenFor.forEach((type) => evs.addEventListener(type, onMessage));
3873
- return evs;
3279
+ const { default: EventSource } = await Promise.resolve().then(function () { return browser$2; }), evs = new EventSource(uri, esOptions);
3280
+ return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
3874
3281
  }
3875
3282
  function open() {
3876
3283
  getEventSource().then((eventSource) => {
3877
3284
  es = eventSource;
3878
3285
  }).catch((reason) => {
3879
- observer.error(reason);
3880
- stop();
3286
+ observer.error(reason), stop();
3881
3287
  });
3882
3288
  }
3883
3289
  function stop() {
3884
- stopped = true;
3885
- unsubscribe();
3290
+ stopped = !0, unsubscribe();
3886
3291
  }
3887
3292
  return stop;
3888
3293
  });
@@ -3896,47 +3301,25 @@
3896
3301
  }
3897
3302
  }
3898
3303
  function cooerceError(err) {
3899
- if (err instanceof Error) {
3304
+ if (err instanceof Error)
3900
3305
  return err;
3901
- }
3902
3306
  const evt = parseEvent(err);
3903
3307
  return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
3904
3308
  }
3905
3309
  function extractErrorMessage(err) {
3906
- if (!err.error) {
3907
- return err.message || "Unknown listener error";
3908
- }
3909
- if (err.error.description) {
3910
- return err.error.description;
3911
- }
3912
- return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
3310
+ return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
3913
3311
  }
3914
-
3915
3312
  var __accessCheck$3 = (obj, member, msg) => {
3916
3313
  if (!member.has(obj))
3917
3314
  throw TypeError("Cannot " + msg);
3918
- };
3919
- var __privateGet$3 = (obj, member, getter) => {
3920
- __accessCheck$3(obj, member, "read from private field");
3921
- return getter ? getter.call(obj) : member.get(obj);
3922
- };
3923
- var __privateAdd$3 = (obj, member, value) => {
3315
+ }, __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$3 = (obj, member, value) => {
3924
3316
  if (member.has(obj))
3925
3317
  throw TypeError("Cannot add the same private member more than once");
3926
3318
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3927
- };
3928
- var __privateSet$3 = (obj, member, value, setter) => {
3929
- __accessCheck$3(obj, member, "write to private field");
3930
- setter ? setter.call(obj, value) : member.set(obj, value);
3931
- return value;
3932
- };
3933
- var _client$2, _httpRequest$3, _client2$2, _httpRequest2$3;
3319
+ }, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client$2, _httpRequest$3;
3934
3320
  class ObservableDatasetsClient {
3935
3321
  constructor(client, httpRequest) {
3936
- __privateAdd$3(this, _client$2, void 0);
3937
- __privateAdd$3(this, _httpRequest$3, void 0);
3938
- __privateSet$3(this, _client$2, client);
3939
- __privateSet$3(this, _httpRequest$3, httpRequest);
3322
+ __privateAdd$3(this, _client$2, void 0), __privateAdd$3(this, _httpRequest$3, void 0), __privateSet$3(this, _client$2, client), __privateSet$3(this, _httpRequest$3, httpRequest);
3940
3323
  }
3941
3324
  /**
3942
3325
  * Create a new dataset with the given name
@@ -3974,14 +3357,11 @@
3974
3357
  });
3975
3358
  }
3976
3359
  }
3977
- _client$2 = new WeakMap();
3978
- _httpRequest$3 = new WeakMap();
3360
+ _client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
3361
+ var _client2$2, _httpRequest2$3;
3979
3362
  class DatasetsClient {
3980
3363
  constructor(client, httpRequest) {
3981
- __privateAdd$3(this, _client2$2, void 0);
3982
- __privateAdd$3(this, _httpRequest2$3, void 0);
3983
- __privateSet$3(this, _client2$2, client);
3984
- __privateSet$3(this, _httpRequest2$3, httpRequest);
3364
+ __privateAdd$3(this, _client2$2, void 0), __privateAdd$3(this, _httpRequest2$3, void 0), __privateSet$3(this, _client2$2, client), __privateSet$3(this, _httpRequest2$3, httpRequest);
3985
3365
  }
3986
3366
  /**
3987
3367
  * Create a new dataset with the given name
@@ -4022,46 +3402,29 @@
4022
3402
  );
4023
3403
  }
4024
3404
  }
4025
- _client2$2 = new WeakMap();
4026
- _httpRequest2$3 = new WeakMap();
3405
+ _client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
4027
3406
  function _modify(client, httpRequest, method, name, options) {
4028
- dataset(name);
4029
- return _request(client, httpRequest, {
3407
+ return dataset(name), _request(client, httpRequest, {
4030
3408
  method,
4031
- uri: "/datasets/".concat(name),
3409
+ uri: `/datasets/${name}`,
4032
3410
  body: options,
4033
3411
  tag: null
4034
3412
  });
4035
3413
  }
4036
-
4037
3414
  var __accessCheck$2 = (obj, member, msg) => {
4038
3415
  if (!member.has(obj))
4039
3416
  throw TypeError("Cannot " + msg);
4040
- };
4041
- var __privateGet$2 = (obj, member, getter) => {
4042
- __accessCheck$2(obj, member, "read from private field");
4043
- return getter ? getter.call(obj) : member.get(obj);
4044
- };
4045
- var __privateAdd$2 = (obj, member, value) => {
3417
+ }, __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$2 = (obj, member, value) => {
4046
3418
  if (member.has(obj))
4047
3419
  throw TypeError("Cannot add the same private member more than once");
4048
3420
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4049
- };
4050
- var __privateSet$2 = (obj, member, value, setter) => {
4051
- __accessCheck$2(obj, member, "write to private field");
4052
- setter ? setter.call(obj, value) : member.set(obj, value);
4053
- return value;
4054
- };
4055
- var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
3421
+ }, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client$1, _httpRequest$2;
4056
3422
  class ObservableProjectsClient {
4057
3423
  constructor(client, httpRequest) {
4058
- __privateAdd$2(this, _client$1, void 0);
4059
- __privateAdd$2(this, _httpRequest$2, void 0);
4060
- __privateSet$2(this, _client$1, client);
4061
- __privateSet$2(this, _httpRequest$2, httpRequest);
3424
+ __privateAdd$2(this, _client$1, void 0), __privateAdd$2(this, _httpRequest$2, void 0), __privateSet$2(this, _client$1, client), __privateSet$2(this, _httpRequest$2, httpRequest);
4062
3425
  }
4063
3426
  list(options) {
4064
- const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
3427
+ const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
4065
3428
  return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
4066
3429
  }
4067
3430
  /**
@@ -4069,21 +3432,18 @@
4069
3432
  *
4070
3433
  * @param projectId - ID of the project to fetch
4071
3434
  */
4072
- getById(projectId) {
4073
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: "/projects/".concat(projectId) });
3435
+ getById(projectId2) {
3436
+ return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
4074
3437
  }
4075
3438
  }
4076
- _client$1 = new WeakMap();
4077
- _httpRequest$2 = new WeakMap();
3439
+ _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
3440
+ var _client2$1, _httpRequest2$2;
4078
3441
  class ProjectsClient {
4079
3442
  constructor(client, httpRequest) {
4080
- __privateAdd$2(this, _client2$1, void 0);
4081
- __privateAdd$2(this, _httpRequest2$2, void 0);
4082
- __privateSet$2(this, _client2$1, client);
4083
- __privateSet$2(this, _httpRequest2$2, httpRequest);
3443
+ __privateAdd$2(this, _client2$1, void 0), __privateAdd$2(this, _httpRequest2$2, void 0), __privateSet$2(this, _client2$1, client), __privateSet$2(this, _httpRequest2$2, httpRequest);
4084
3444
  }
4085
3445
  list(options) {
4086
- const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
3446
+ const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
4087
3447
  return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
4088
3448
  }
4089
3449
  /**
@@ -4091,40 +3451,24 @@
4091
3451
  *
4092
3452
  * @param projectId - ID of the project to fetch
4093
3453
  */
4094
- getById(projectId) {
3454
+ getById(projectId2) {
4095
3455
  return lastValueFrom(
4096
- _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: "/projects/".concat(projectId) })
3456
+ _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
4097
3457
  );
4098
3458
  }
4099
3459
  }
4100
- _client2$1 = new WeakMap();
4101
- _httpRequest2$2 = new WeakMap();
4102
-
3460
+ _client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
4103
3461
  var __accessCheck$1 = (obj, member, msg) => {
4104
3462
  if (!member.has(obj))
4105
3463
  throw TypeError("Cannot " + msg);
4106
- };
4107
- var __privateGet$1 = (obj, member, getter) => {
4108
- __accessCheck$1(obj, member, "read from private field");
4109
- return getter ? getter.call(obj) : member.get(obj);
4110
- };
4111
- var __privateAdd$1 = (obj, member, value) => {
3464
+ }, __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$1 = (obj, member, value) => {
4112
3465
  if (member.has(obj))
4113
3466
  throw TypeError("Cannot add the same private member more than once");
4114
3467
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4115
- };
4116
- var __privateSet$1 = (obj, member, value, setter) => {
4117
- __accessCheck$1(obj, member, "write to private field");
4118
- setter ? setter.call(obj, value) : member.set(obj, value);
4119
- return value;
4120
- };
4121
- var _client, _httpRequest$1, _client2, _httpRequest2$1;
3468
+ }, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _client, _httpRequest$1;
4122
3469
  class ObservableUsersClient {
4123
3470
  constructor(client, httpRequest) {
4124
- __privateAdd$1(this, _client, void 0);
4125
- __privateAdd$1(this, _httpRequest$1, void 0);
4126
- __privateSet$1(this, _client, client);
4127
- __privateSet$1(this, _httpRequest$1, httpRequest);
3471
+ __privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
4128
3472
  }
4129
3473
  /**
4130
3474
  * Fetch a user by user ID
@@ -4135,18 +3479,15 @@
4135
3479
  return _request(
4136
3480
  __privateGet$1(this, _client),
4137
3481
  __privateGet$1(this, _httpRequest$1),
4138
- { uri: "/users/".concat(id) }
3482
+ { uri: `/users/${id}` }
4139
3483
  );
4140
3484
  }
4141
3485
  }
4142
- _client = new WeakMap();
4143
- _httpRequest$1 = new WeakMap();
3486
+ _client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
3487
+ var _client2, _httpRequest2$1;
4144
3488
  class UsersClient {
4145
3489
  constructor(client, httpRequest) {
4146
- __privateAdd$1(this, _client2, void 0);
4147
- __privateAdd$1(this, _httpRequest2$1, void 0);
4148
- __privateSet$1(this, _client2, client);
4149
- __privateSet$1(this, _httpRequest2$1, httpRequest);
3490
+ __privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
4150
3491
  }
4151
3492
  /**
4152
3493
  * Fetch a user by user ID
@@ -4156,68 +3497,38 @@
4156
3497
  getById(id) {
4157
3498
  return lastValueFrom(
4158
3499
  _request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
4159
- uri: "/users/".concat(id)
3500
+ uri: `/users/${id}`
4160
3501
  })
4161
3502
  );
4162
3503
  }
4163
3504
  }
4164
- _client2 = new WeakMap();
4165
- _httpRequest2$1 = new WeakMap();
4166
-
3505
+ _client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
4167
3506
  var __accessCheck = (obj, member, msg) => {
4168
3507
  if (!member.has(obj))
4169
3508
  throw TypeError("Cannot " + msg);
4170
- };
4171
- var __privateGet = (obj, member, getter) => {
4172
- __accessCheck(obj, member, "read from private field");
4173
- return getter ? getter.call(obj) : member.get(obj);
4174
- };
4175
- var __privateAdd = (obj, member, value) => {
3509
+ }, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
4176
3510
  if (member.has(obj))
4177
3511
  throw TypeError("Cannot add the same private member more than once");
4178
3512
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4179
- };
4180
- var __privateSet = (obj, member, value, setter) => {
4181
- __accessCheck(obj, member, "write to private field");
4182
- setter ? setter.call(obj, value) : member.set(obj, value);
4183
- return value;
4184
- };
4185
- var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
4186
- const _ObservableSanityClient = class _ObservableSanityClient {
3513
+ }, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _clientConfig, _httpRequest;
3514
+ const _ObservableSanityClient = class _ObservableSanityClient2 {
4187
3515
  constructor(httpRequest, config = defaultConfig) {
4188
- /**
4189
- * Private properties
4190
- */
4191
- __privateAdd(this, _clientConfig, void 0);
4192
- __privateAdd(this, _httpRequest, void 0);
4193
- /**
4194
- * Instance properties
4195
- */
4196
- this.listen = _listen;
4197
- this.config(config);
4198
- __privateSet(this, _httpRequest, httpRequest);
4199
- this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
4200
- this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
4201
- this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
4202
- this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
3516
+ __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), this.listen = _listen, this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
4203
3517
  }
4204
3518
  /**
4205
3519
  * Clone the client - returns a new instance
4206
3520
  */
4207
3521
  clone() {
4208
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
3522
+ return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
4209
3523
  }
4210
3524
  config(newConfig) {
4211
- if (newConfig === void 0) {
3525
+ if (newConfig === void 0)
4212
3526
  return { ...__privateGet(this, _clientConfig) };
4213
- }
4214
- if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === false) {
3527
+ if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
4215
3528
  throw new Error(
4216
3529
  "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
4217
3530
  );
4218
- }
4219
- __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
4220
- return this;
3531
+ return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
4221
3532
  }
4222
3533
  /**
4223
3534
  * Clone the client with a new (partial) configuration.
@@ -4226,12 +3537,12 @@
4226
3537
  */
4227
3538
  withConfig(newConfig) {
4228
3539
  const thisConfig = this.config();
4229
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
3540
+ return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
4230
3541
  ...thisConfig,
4231
3542
  ...newConfig,
4232
3543
  stega: {
4233
3544
  ...thisConfig.stega || {},
4234
- ...typeof (newConfig == null ? void 0 : newConfig.stega) === "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
3545
+ ...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
4235
3546
  }
4236
3547
  });
4237
3548
  }
@@ -4326,48 +3637,27 @@
4326
3637
  return _getDataUrl(this, operation, path);
4327
3638
  }
4328
3639
  };
4329
- _clientConfig = new WeakMap();
4330
- _httpRequest = new WeakMap();
3640
+ _clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
4331
3641
  let ObservableSanityClient = _ObservableSanityClient;
4332
- const _SanityClient = class _SanityClient {
3642
+ var _clientConfig2, _httpRequest2;
3643
+ const _SanityClient = class _SanityClient2 {
4333
3644
  constructor(httpRequest, config = defaultConfig) {
4334
- /**
4335
- * Private properties
4336
- */
4337
- __privateAdd(this, _clientConfig2, void 0);
4338
- __privateAdd(this, _httpRequest2, void 0);
4339
- /**
4340
- * Instance properties
4341
- */
4342
- this.listen = _listen;
4343
- this.config(config);
4344
- __privateSet(this, _httpRequest2, httpRequest);
4345
- this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
4346
- this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
4347
- this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
4348
- this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
4349
- this.observable = new ObservableSanityClient(httpRequest, config);
3645
+ __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), this.listen = _listen, this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
4350
3646
  }
4351
3647
  /**
4352
3648
  * Clone the client - returns a new instance
4353
3649
  */
4354
3650
  clone() {
4355
- return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
3651
+ return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
4356
3652
  }
4357
3653
  config(newConfig) {
4358
- if (newConfig === void 0) {
3654
+ if (newConfig === void 0)
4359
3655
  return { ...__privateGet(this, _clientConfig2) };
4360
- }
4361
- if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
3656
+ if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
4362
3657
  throw new Error(
4363
3658
  "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
4364
3659
  );
4365
- }
4366
- if (this.observable) {
4367
- this.observable.config(newConfig);
4368
- }
4369
- __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
4370
- return this;
3660
+ return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
4371
3661
  }
4372
3662
  /**
4373
3663
  * Clone the client with a new (partial) configuration.
@@ -4376,12 +3666,12 @@
4376
3666
  */
4377
3667
  withConfig(newConfig) {
4378
3668
  const thisConfig = this.config();
4379
- return new _SanityClient(__privateGet(this, _httpRequest2), {
3669
+ return new _SanityClient2(__privateGet(this, _httpRequest2), {
4380
3670
  ...thisConfig,
4381
3671
  ...newConfig,
4382
3672
  stega: {
4383
3673
  ...thisConfig.stega || {},
4384
- ...typeof (newConfig == null ? void 0 : newConfig.stega) === "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
3674
+ ...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
4385
3675
  }
4386
3676
  });
4387
3677
  }
@@ -4499,68 +3789,48 @@
4499
3789
  return _getDataUrl(this, operation, path);
4500
3790
  }
4501
3791
  };
4502
- _clientConfig2 = new WeakMap();
4503
- _httpRequest2 = new WeakMap();
3792
+ _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
4504
3793
  let SanityClient = _SanityClient;
4505
-
4506
- function defineCreateClientExports(envMiddleware, ClassConstructor) {
4507
- const httpRequest = defineHttpRequest(envMiddleware, {});
4508
- const requester = httpRequest.defaultRequester;
4509
- const createClient = (config) => new ClassConstructor(
4510
- defineHttpRequest(envMiddleware, {
3794
+ function defineCreateClientExports(envMiddleware2, ClassConstructor) {
3795
+ return { requester: defineHttpRequest(envMiddleware2, {}).defaultRequester, createClient: (config) => new ClassConstructor(
3796
+ defineHttpRequest(envMiddleware2, {
4511
3797
  maxRetries: config.maxRetries,
4512
3798
  retryDelay: config.retryDelay
4513
3799
  }),
4514
3800
  config
4515
- );
4516
- return { requester, createClient };
3801
+ ) };
4517
3802
  }
4518
-
4519
3803
  var envMiddleware = [];
4520
3804
 
4521
- function defineDeprecatedCreateClient(createClient) {
4522
- return function deprecatedCreateClient(config) {
4523
- printNoDefaultExport();
4524
- return createClient(config);
3805
+ function defineDeprecatedCreateClient(createClient2) {
3806
+ return function(config) {
3807
+ return printNoDefaultExport(), createClient2(config);
4525
3808
  };
4526
3809
  }
4527
-
4528
- const exp = defineCreateClientExports(envMiddleware, SanityClient);
4529
- const requester = exp.requester;
4530
- const createClient = exp.createClient;
4531
- const deprecatedCreateClient = defineDeprecatedCreateClient(createClient);
3810
+ const exp = defineCreateClientExports(envMiddleware, SanityClient), requester = exp.requester, createClient = exp.createClient, deprecatedCreateClient = defineDeprecatedCreateClient(createClient);
4532
3811
 
4533
3812
  const reKeySegment = /_key\s*==\s*['"](.*)['"]/;
4534
3813
  function isKeySegment(segment) {
4535
- if (typeof segment === "string") {
4536
- return reKeySegment.test(segment.trim());
4537
- }
4538
- return typeof segment === "object" && "_key" in segment;
3814
+ return typeof segment == "string" ? reKeySegment.test(segment.trim()) : typeof segment == "object" && "_key" in segment;
4539
3815
  }
4540
3816
  function toString(path) {
4541
- if (!Array.isArray(path)) {
3817
+ if (!Array.isArray(path))
4542
3818
  throw new Error("Path is not an array");
4543
- }
4544
3819
  return path.reduce((target, segment, i) => {
4545
3820
  const segmentType = typeof segment;
4546
- if (segmentType === "number") {
4547
- return "".concat(target, "[").concat(segment, "]");
4548
- }
4549
- if (segmentType === "string") {
4550
- const separator = i === 0 ? "" : ".";
4551
- return "".concat(target).concat(separator).concat(segment);
4552
- }
4553
- if (isKeySegment(segment) && segment._key) {
4554
- return "".concat(target, '[_key=="').concat(segment._key, '"]');
4555
- }
3821
+ if (segmentType === "number")
3822
+ return `${target}[${segment}]`;
3823
+ if (segmentType === "string")
3824
+ return `${target}${i === 0 ? "" : "."}${segment}`;
3825
+ if (isKeySegment(segment) && segment._key)
3826
+ return `${target}[_key=="${segment._key}"]`;
4556
3827
  if (Array.isArray(segment)) {
4557
3828
  const [from, to] = segment;
4558
- return "".concat(target, "[").concat(from, ":").concat(to, "]");
3829
+ return `${target}[${from}:${to}]`;
4559
3830
  }
4560
- throw new Error("Unsupported path segment `".concat(JSON.stringify(segment), "`"));
3831
+ throw new Error(`Unsupported path segment \`${JSON.stringify(segment)}\``);
4561
3832
  }, "");
4562
3833
  }
4563
-
4564
3834
  const ESCAPE = {
4565
3835
  "\f": "\\f",
4566
3836
  "\n": "\\n",
@@ -4568,44 +3838,24 @@
4568
3838
  " ": "\\t",
4569
3839
  "'": "\\'",
4570
3840
  "\\": "\\\\"
4571
- };
4572
- const UNESCAPE = {
3841
+ }, UNESCAPE = {
4573
3842
  "\\f": "\f",
4574
- "\\n": "\n",
3843
+ "\\n": `
3844
+ `,
4575
3845
  "\\r": "\r",
4576
3846
  "\\t": " ",
4577
3847
  "\\'": "'",
4578
3848
  "\\\\": "\\"
4579
3849
  };
4580
3850
  function jsonPath(path) {
4581
- return "$".concat(path.map((segment) => {
4582
- if (typeof segment === "string") {
4583
- const escapedKey = segment.replace(/[\f\n\r\t'\\]/g, (match) => {
4584
- return ESCAPE[match];
4585
- });
4586
- return "['".concat(escapedKey, "']");
4587
- }
4588
- if (typeof segment === "number") {
4589
- return "[".concat(segment, "]");
4590
- }
4591
- if (segment._key !== "") {
4592
- const escapedKey = segment._key.replace(/['\\]/g, (match) => {
4593
- return ESCAPE[match];
4594
- });
4595
- return "[?(@._key=='".concat(escapedKey, "')]");
4596
- }
4597
- return "[".concat(segment._index, "]");
4598
- }).join(""));
3851
+ return `$${path.map((segment) => typeof segment == "string" ? `['${segment.replace(/[\f\n\r\t'\\]/g, (match) => ESCAPE[match])}']` : typeof segment == "number" ? `[${segment}]` : segment._key !== "" ? `[?(@._key=='${segment._key.replace(/['\\]/g, (match) => ESCAPE[match])}')]` : `[${segment._index}]`).join("")}`;
4599
3852
  }
4600
3853
  function parseJsonPath(path) {
4601
- const parsed = [];
4602
- const parseRe = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;
3854
+ const parsed = [], parseRe = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;
4603
3855
  let match;
4604
- while ((match = parseRe.exec(path)) !== null) {
3856
+ for (; (match = parseRe.exec(path)) !== null; ) {
4605
3857
  if (match[1] !== void 0) {
4606
- const key = match[1].replace(/\\(\\|f|n|r|t|')/g, (m) => {
4607
- return UNESCAPE[m];
4608
- });
3858
+ const key = match[1].replace(/\\(\\|f|n|r|t|')/g, (m) => UNESCAPE[m]);
4609
3859
  parsed.push(key);
4610
3860
  continue;
4611
3861
  }
@@ -4614,9 +3864,7 @@
4614
3864
  continue;
4615
3865
  }
4616
3866
  if (match[3] !== void 0) {
4617
- const _key = match[3].replace(/\\(\\')/g, (m) => {
4618
- return UNESCAPE[m];
4619
- });
3867
+ const _key = match[3].replace(/\\(\\')/g, (m) => UNESCAPE[m]);
4620
3868
  parsed.push({
4621
3869
  _key,
4622
3870
  _index: -1
@@ -4628,106 +3876,69 @@
4628
3876
  }
4629
3877
  function jsonPathToStudioPath(path) {
4630
3878
  return path.map((segment) => {
4631
- if (typeof segment === "string") {
4632
- return segment;
4633
- }
4634
- if (typeof segment === "number") {
3879
+ if (typeof segment == "string" || typeof segment == "number")
4635
3880
  return segment;
4636
- }
4637
- if (segment._key !== "") {
3881
+ if (segment._key !== "")
4638
3882
  return { _key: segment._key };
4639
- }
4640
- if (segment._index !== -1) {
3883
+ if (segment._index !== -1)
4641
3884
  return segment._index;
4642
- }
4643
- throw new Error("invalid segment:".concat(JSON.stringify(segment)));
3885
+ throw new Error(`invalid segment:${JSON.stringify(segment)}`);
4644
3886
  });
4645
3887
  }
4646
3888
  function jsonPathToMappingPath(path) {
4647
3889
  return path.map((segment) => {
4648
- if (typeof segment === "string") {
3890
+ if (typeof segment == "string" || typeof segment == "number")
4649
3891
  return segment;
4650
- }
4651
- if (typeof segment === "number") {
4652
- return segment;
4653
- }
4654
- if (segment._index !== -1) {
3892
+ if (segment._index !== -1)
4655
3893
  return segment._index;
4656
- }
4657
- throw new Error("invalid segment:".concat(JSON.stringify(segment)));
3894
+ throw new Error(`invalid segment:${JSON.stringify(segment)}`);
4658
3895
  });
4659
3896
  }
4660
-
4661
3897
  function resolveMapping(resultPath, csm) {
4662
- if (!(csm == null ? void 0 : csm.mappings)) {
4663
- return void 0;
4664
- }
3898
+ if (!(csm != null && csm.mappings))
3899
+ return;
4665
3900
  const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
4666
- if (csm.mappings[resultMappingPath] !== void 0) {
3901
+ if (csm.mappings[resultMappingPath] !== void 0)
4667
3902
  return {
4668
3903
  mapping: csm.mappings[resultMappingPath],
4669
3904
  matchedPath: resultMappingPath,
4670
3905
  pathSuffix: ""
4671
3906
  };
4672
- }
4673
3907
  const mappings = Object.entries(csm.mappings).filter(([key]) => resultMappingPath.startsWith(key)).sort(([key1], [key2]) => key2.length - key1.length);
4674
- if (mappings.length == 0) {
4675
- return void 0;
4676
- }
4677
- const [matchedPath, mapping] = mappings[0];
4678
- const pathSuffix = resultMappingPath.substring(matchedPath.length);
3908
+ if (mappings.length == 0)
3909
+ return;
3910
+ const [matchedPath, mapping] = mappings[0], pathSuffix = resultMappingPath.substring(matchedPath.length);
4679
3911
  return { mapping, matchedPath, pathSuffix };
4680
3912
  }
4681
-
4682
3913
  function isArray(value) {
4683
3914
  return value !== null && Array.isArray(value);
4684
3915
  }
4685
-
4686
3916
  function isRecord(value) {
4687
- return typeof value === "object" && value !== null;
3917
+ return typeof value == "object" && value !== null;
4688
3918
  }
4689
-
4690
3919
  function walkMap(value, mappingFn, path = []) {
4691
- if (isArray(value)) {
4692
- return value.map((v, idx) => {
4693
- if (isRecord(v)) {
4694
- const _key = v["_key"];
4695
- if (typeof _key === "string") {
4696
- return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
4697
- }
4698
- }
4699
- return walkMap(v, mappingFn, path.concat(idx));
4700
- });
4701
- }
4702
- if (isRecord(value)) {
4703
- return Object.fromEntries(
4704
- Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])
4705
- );
4706
- }
4707
- return mappingFn(value, path);
3920
+ return isArray(value) ? value.map((v, idx) => {
3921
+ if (isRecord(v)) {
3922
+ const _key = v._key;
3923
+ if (typeof _key == "string")
3924
+ return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
3925
+ }
3926
+ return walkMap(v, mappingFn, path.concat(idx));
3927
+ }) : isRecord(value) ? Object.fromEntries(
3928
+ Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])
3929
+ ) : mappingFn(value, path);
4708
3930
  }
4709
-
4710
3931
  function encodeIntoResult(result, csm, encoder) {
4711
3932
  return walkMap(result, (value, path) => {
4712
- if (typeof value !== "string") {
3933
+ if (typeof value != "string")
4713
3934
  return value;
4714
- }
4715
3935
  const resolveMappingResult = resolveMapping(path, csm);
4716
- if (!resolveMappingResult) {
3936
+ if (!resolveMappingResult)
4717
3937
  return value;
4718
- }
4719
3938
  const { mapping, matchedPath } = resolveMappingResult;
4720
- if (mapping.type !== "value") {
4721
- return value;
4722
- }
4723
- if (mapping.source.type !== "documentValue") {
3939
+ if (mapping.type !== "value" || mapping.source.type !== "documentValue")
4724
3940
  return value;
4725
- }
4726
- const sourceDocument = csm.documents[mapping.source.document];
4727
- const sourcePath = csm.paths[mapping.source.path];
4728
- const matchPathSegments = parseJsonPath(matchedPath);
4729
- const sourcePathSegments = parseJsonPath(sourcePath);
4730
- const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length));
3941
+ const sourceDocument = csm.documents[mapping.source.document], sourcePath = csm.paths[mapping.source.path], matchPathSegments = parseJsonPath(matchedPath), fullSourceSegments = parseJsonPath(sourcePath).concat(path.slice(matchPathSegments.length));
4731
3942
  return encoder({
4732
3943
  sourcePath: fullSourceSegments,
4733
3944
  sourceDocument,
@@ -4736,15 +3947,10 @@
4736
3947
  });
4737
3948
  });
4738
3949
  }
4739
-
4740
3950
  const DRAFTS_PREFIX = "drafts.";
4741
3951
  function getPublishedId(id) {
4742
- if (id.startsWith(DRAFTS_PREFIX)) {
4743
- return id.slice(DRAFTS_PREFIX.length);
4744
- }
4745
- return id;
3952
+ return id.startsWith(DRAFTS_PREFIX) ? id.slice(DRAFTS_PREFIX.length) : id;
4746
3953
  }
4747
-
4748
3954
  function createEditUrl(options) {
4749
3955
  const {
4750
3956
  baseUrl,
@@ -4756,99 +3962,43 @@
4756
3962
  projectId,
4757
3963
  dataset
4758
3964
  } = options;
4759
- if (!baseUrl) {
3965
+ if (!baseUrl)
4760
3966
  throw new Error("baseUrl is required");
4761
- }
4762
- if (!path) {
3967
+ if (!path)
4763
3968
  throw new Error("path is required");
4764
- }
4765
- if (!_id) {
3969
+ if (!_id)
4766
3970
  throw new Error("id is required");
4767
- }
4768
- if (baseUrl !== "/" && baseUrl.endsWith("/")) {
3971
+ if (baseUrl !== "/" && baseUrl.endsWith("/"))
4769
3972
  throw new Error("baseUrl must not end with a slash");
4770
- }
4771
- const workspace = _workspace === "default" ? void 0 : _workspace;
4772
- const tool = _tool === "default" ? void 0 : _tool;
4773
- const id = getPublishedId(_id);
4774
- const stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path;
4775
- const searchParams = new URLSearchParams({
3973
+ const workspace = _workspace === "default" ? void 0 : _workspace, tool = _tool === "default" ? void 0 : _tool, id = getPublishedId(_id), stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path, searchParams = new URLSearchParams({
4776
3974
  baseUrl,
4777
3975
  id,
4778
3976
  type,
4779
3977
  path: stringifiedPath
4780
3978
  });
4781
- if (workspace) {
4782
- searchParams.set("workspace", workspace);
4783
- }
4784
- if (tool) {
4785
- searchParams.set("tool", tool);
4786
- }
4787
- if (projectId) {
4788
- searchParams.set("projectId", projectId);
4789
- }
4790
- if (dataset) {
4791
- searchParams.set("dataset", dataset);
4792
- }
3979
+ workspace && searchParams.set("workspace", workspace), tool && searchParams.set("tool", tool), projectId && searchParams.set("projectId", projectId), dataset && searchParams.set("dataset", dataset);
4793
3980
  const segments = [baseUrl === "/" ? "" : baseUrl];
4794
- if (workspace) {
4795
- segments.push(workspace);
4796
- }
3981
+ workspace && segments.push(workspace);
4797
3982
  const routerParams = [
4798
3983
  "mode=presentation",
4799
- "id=".concat(id),
4800
- "type=".concat(type),
4801
- "path=".concat(encodeURIComponent(stringifiedPath))
3984
+ `id=${id}`,
3985
+ `type=${type}`,
3986
+ `path=${encodeURIComponent(stringifiedPath)}`
4802
3987
  ];
4803
- if (tool) {
4804
- routerParams.push("tool=".concat(tool));
4805
- }
4806
- segments.push("intent", "edit", "".concat(routerParams.join(";"), "?").concat(searchParams));
4807
- return segments.join("/");
3988
+ return tool && routerParams.push(`tool=${tool}`), segments.push("intent", "edit", `${routerParams.join(";")}?${searchParams}`), segments.join("/");
4808
3989
  }
4809
-
4810
3990
  function resolveStudioBaseRoute(studioUrl) {
4811
- let baseUrl = typeof studioUrl === "string" ? studioUrl : studioUrl.baseUrl;
4812
- if (baseUrl !== "/") {
4813
- baseUrl = baseUrl.replace(/\/$/, "");
4814
- }
4815
- if (typeof studioUrl === "string") {
4816
- return { baseUrl };
4817
- }
4818
- return { ...studioUrl, baseUrl };
3991
+ let baseUrl = typeof studioUrl == "string" ? studioUrl : studioUrl.baseUrl;
3992
+ return baseUrl !== "/" && (baseUrl = baseUrl.replace(/\/$/, "")), typeof studioUrl == "string" ? { baseUrl } : { ...studioUrl, baseUrl };
4819
3993
  }
4820
-
4821
3994
  const filterDefault = ({ sourcePath, value }) => {
4822
- if (isValidDate(value) || isValidURL(value)) {
4823
- return false;
4824
- }
3995
+ if (isValidDate(value) || isValidURL(value))
3996
+ return !1;
4825
3997
  const endPath = sourcePath.at(-1);
4826
- if (sourcePath.at(-2) === "slug" && endPath === "current") {
4827
- return false;
4828
- }
4829
- if (typeof endPath === "string" && endPath.startsWith("_")) {
4830
- return false;
4831
- }
4832
- if (typeof endPath === "number" && sourcePath.at(-2) === "marks") {
4833
- return false;
4834
- }
4835
- if (endPath === "href" && typeof sourcePath.at(-2) === "number" && sourcePath.at(-3) === "markDefs") {
4836
- return false;
4837
- }
4838
- if (endPath === "style" || endPath === "listItem") {
4839
- return false;
4840
- }
4841
- if (sourcePath.some(
3998
+ return !(sourcePath.at(-2) === "slug" && endPath === "current" || typeof endPath == "string" && endPath.startsWith("_") || typeof endPath == "number" && sourcePath.at(-2) === "marks" || endPath === "href" && typeof sourcePath.at(-2) == "number" && sourcePath.at(-3) === "markDefs" || endPath === "style" || endPath === "listItem" || sourcePath.some(
4842
3999
  (path) => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo"
4843
- )) {
4844
- return false;
4845
- }
4846
- if (typeof endPath === "string" && denylist.has(endPath)) {
4847
- return false;
4848
- }
4849
- return true;
4850
- };
4851
- const denylist = /* @__PURE__ */ new Set([
4000
+ ) || typeof endPath == "string" && denylist.has(endPath));
4001
+ }, denylist = /* @__PURE__ */ new Set([
4852
4002
  "color",
4853
4003
  "colour",
4854
4004
  "currency",
@@ -4889,66 +4039,54 @@
4889
4039
  "website"
4890
4040
  ]);
4891
4041
  function isValidDate(dateString) {
4892
- return /^\d{4}-\d{2}-\d{2}/.test(dateString) ? Boolean(Date.parse(dateString)) : false;
4042
+ return /^\d{4}-\d{2}-\d{2}/.test(dateString) ? !!Date.parse(dateString) : !1;
4893
4043
  }
4894
4044
  function isValidURL(url) {
4895
4045
  try {
4896
4046
  new URL(url, url.startsWith("/") ? "https://acme.com" : void 0);
4897
4047
  } catch {
4898
- return false;
4048
+ return !1;
4899
4049
  }
4900
- return true;
4050
+ return !0;
4901
4051
  }
4902
-
4903
4052
  const TRUNCATE_LENGTH = 20;
4904
4053
  function stegaEncodeSourceMap(result, resultSourceMap, config) {
4905
4054
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4906
4055
  const { filter, logger, enabled } = config;
4907
4056
  if (!enabled) {
4908
4057
  const msg = "config.enabled must be true, don't call this function otherwise";
4909
- (_a = logger == null ? void 0 : logger.error) == null ? void 0 : _a.call(logger, "[@sanity/client]: ".concat(msg), { result, resultSourceMap, config });
4910
- throw new TypeError(msg);
4058
+ throw (_a = logger == null ? void 0 : logger.error) == null || _a.call(logger, `[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
4911
4059
  }
4912
- if (!resultSourceMap) {
4913
- (_b = logger == null ? void 0 : logger.error) == null ? void 0 : _b.call(logger, "[@sanity/client]: Missing Content Source Map from response body", {
4060
+ if (!resultSourceMap)
4061
+ return (_b = logger == null ? void 0 : logger.error) == null || _b.call(logger, "[@sanity/client]: Missing Content Source Map from response body", {
4914
4062
  result,
4915
4063
  resultSourceMap,
4916
4064
  config
4917
- });
4918
- return result;
4919
- }
4065
+ }), result;
4920
4066
  if (!config.studioUrl) {
4921
4067
  const msg = "config.studioUrl must be defined";
4922
- (_c = logger == null ? void 0 : logger.error) == null ? void 0 : _c.call(logger, "[@sanity/client]: ".concat(msg), { result, resultSourceMap, config });
4923
- throw new TypeError(msg);
4068
+ throw (_c = logger == null ? void 0 : logger.error) == null || _c.call(logger, `[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);
4924
4069
  }
4925
4070
  const report = {
4926
4071
  encoded: [],
4927
4072
  skipped: []
4928
- };
4929
- const resultWithStega = encodeIntoResult(
4073
+ }, resultWithStega = encodeIntoResult(
4930
4074
  result,
4931
4075
  resultSourceMap,
4932
4076
  ({ sourcePath, sourceDocument, resultPath, value }) => {
4933
- if ((typeof filter === "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === false) {
4934
- if (logger) {
4935
- report.skipped.push({
4936
- path: prettyPathForLogging(sourcePath),
4937
- value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
4938
- length: value.length
4939
- });
4940
- }
4941
- return value;
4942
- }
4943
- if (logger) {
4944
- report.encoded.push({
4077
+ if ((typeof filter == "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === !1)
4078
+ return logger && report.skipped.push({
4945
4079
  path: prettyPathForLogging(sourcePath),
4946
- value: "".concat(value.slice(0, TRUNCATE_LENGTH)).concat(value.length > TRUNCATE_LENGTH ? "..." : ""),
4080
+ value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? "..." : ""}`,
4947
4081
  length: value.length
4948
- });
4949
- }
4082
+ }), value;
4083
+ logger && report.encoded.push({
4084
+ path: prettyPathForLogging(sourcePath),
4085
+ value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? "..." : ""}`,
4086
+ length: value.length
4087
+ });
4950
4088
  const { baseUrl, workspace, tool } = resolveStudioBaseRoute(
4951
- typeof config.studioUrl === "function" ? config.studioUrl(sourceDocument) : config.studioUrl
4089
+ typeof config.studioUrl == "function" ? config.studioUrl(sourceDocument) : config.studioUrl
4952
4090
  );
4953
4091
  if (!baseUrl)
4954
4092
  return value;
@@ -4968,47 +4106,34 @@
4968
4106
  })
4969
4107
  },
4970
4108
  // We use custom logic to determine if we should skip encoding
4971
- false
4109
+ !1
4972
4110
  );
4973
4111
  }
4974
4112
  );
4975
4113
  if (logger) {
4976
- const isSkipping = report.skipped.length;
4977
- const isEncoding = report.encoded.length;
4978
- if (isSkipping || isEncoding) {
4979
- (_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null ? void 0 : _d("[@sanity/client]: Encoding source map into result");
4980
- (_e = logger.log) == null ? void 0 : _e.call(
4981
- logger,
4982
- "[@sanity/client]: Paths encoded: ".concat(report.encoded.length, ", skipped: ").concat(report.skipped.length)
4983
- );
4984
- }
4985
- if (report.encoded.length > 0) {
4986
- (_f = logger == null ? void 0 : logger.log) == null ? void 0 : _f.call(logger, "[@sanity/client]: Table of encoded paths");
4987
- (_g = (logger == null ? void 0 : logger.table) || logger.log) == null ? void 0 : _g(report.encoded);
4988
- }
4989
- if (report.skipped.length > 0) {
4114
+ const isSkipping = report.skipped.length, isEncoding = report.encoded.length;
4115
+ if ((isSkipping || isEncoding) && ((_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null || _d("[@sanity/client]: Encoding source map into result"), (_e = logger.log) == null || _e.call(
4116
+ logger,
4117
+ `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`
4118
+ )), report.encoded.length > 0 && ((_f = logger == null ? void 0 : logger.log) == null || _f.call(logger, "[@sanity/client]: Table of encoded paths"), (_g = (logger == null ? void 0 : logger.table) || logger.log) == null || _g(report.encoded)), report.skipped.length > 0) {
4990
4119
  const skipped = /* @__PURE__ */ new Set();
4991
- for (const { path } of report.skipped) {
4120
+ for (const { path } of report.skipped)
4992
4121
  skipped.add(path.replace(reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
4993
- }
4994
- (_h = logger == null ? void 0 : logger.log) == null ? void 0 : _h.call(logger, "[@sanity/client]: List of skipped paths", [...skipped.values()]);
4995
- }
4996
- if (isSkipping || isEncoding) {
4997
- (_i = logger == null ? void 0 : logger.groupEnd) == null ? void 0 : _i.call(logger);
4122
+ (_h = logger == null ? void 0 : logger.log) == null || _h.call(logger, "[@sanity/client]: List of skipped paths", [...skipped.values()]);
4998
4123
  }
4124
+ (isSkipping || isEncoding) && ((_i = logger == null ? void 0 : logger.groupEnd) == null || _i.call(logger));
4999
4125
  }
5000
4126
  return resultWithStega;
5001
4127
  }
5002
4128
  function prettyPathForLogging(path) {
5003
4129
  return toString(jsonPathToStudioPath(path));
5004
4130
  }
5005
-
5006
- var stegaEncodeSourceMap$1 = /*#__PURE__*/Object.freeze({
4131
+ var stegaEncodeSourceMap$1 = /* @__PURE__ */ Object.freeze({
5007
4132
  __proto__: null,
5008
- stegaEncodeSourceMap: stegaEncodeSourceMap
4133
+ stegaEncodeSourceMap
5009
4134
  });
5010
4135
 
5011
- var stegaEncodeSourceMapB6IscnhR = /*#__PURE__*/Object.freeze({
4136
+ var stegaEncodeSourceMapDe3F_oJN = /*#__PURE__*/Object.freeze({
5012
4137
  __proto__: null,
5013
4138
  encodeIntoResult: encodeIntoResult,
5014
4139
  stegaEncodeSourceMap: stegaEncodeSourceMap,