@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
@@ -1,92 +1,67 @@
1
- import { getIt } from 'get-it';
2
- import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from 'get-it/middleware';
3
- import { Observable, from, lastValueFrom } from 'rxjs';
4
- import { combineLatestWith, map, filter } from 'rxjs/operators';
5
-
6
- const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
1
+ import { getIt } from "get-it";
2
+ import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from "get-it/middleware";
3
+ import { Observable, from, lastValueFrom } from "rxjs";
4
+ import { combineLatestWith, map, filter } from "rxjs/operators";
7
5
  class ClientError extends Error {
8
6
  constructor(res) {
9
7
  const props = extractErrorProps(res);
10
- super(props.message);
11
- this.statusCode = 400;
12
- Object.assign(this, props);
8
+ super(props.message), this.statusCode = 400, Object.assign(this, props);
13
9
  }
14
10
  }
15
11
  class ServerError extends Error {
16
12
  constructor(res) {
17
13
  const props = extractErrorProps(res);
18
- super(props.message);
19
- this.statusCode = 500;
20
- Object.assign(this, props);
14
+ super(props.message), this.statusCode = 500, Object.assign(this, props);
21
15
  }
22
16
  }
23
17
  function extractErrorProps(res) {
24
- const body = res.body;
25
- const props = {
18
+ const body = res.body, props = {
26
19
  response: res,
27
20
  statusCode: res.statusCode,
28
21
  responseBody: stringifyBody(body, res),
29
22
  message: "",
30
23
  details: void 0
31
24
  };
32
- if (body.error && body.message) {
33
- props.message = "".concat(body.error, " - ").concat(body.message);
34
- return props;
35
- }
25
+ if (body.error && body.message)
26
+ return props.message = `${body.error} - ${body.message}`, props;
36
27
  if (isMutationError(body)) {
37
- const allItems = body.error.items || [];
38
- const items = allItems.slice(0, MAX_ITEMS_IN_ERROR_MESSAGE).map((item) => {
28
+ const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
39
29
  var _a;
40
30
  return (_a = item.error) == null ? void 0 : _a.description;
41
31
  }).filter(Boolean);
42
- let itemsStr = items.length ? ":\n- ".concat(items.join("\n- ")) : "";
43
- if (allItems.length > MAX_ITEMS_IN_ERROR_MESSAGE) {
44
- itemsStr += "\n...and ".concat(allItems.length - MAX_ITEMS_IN_ERROR_MESSAGE, " more");
45
- }
46
- props.message = "".concat(body.error.description).concat(itemsStr);
47
- props.details = body.error;
48
- return props;
32
+ let itemsStr = items.length ? `:
33
+ - ${items.join(`
34
+ - `)}` : "";
35
+ return allItems.length > 5 && (itemsStr += `
36
+ ...and ${allItems.length - 5} more`), props.message = `${body.error.description}${itemsStr}`, props.details = body.error, props;
49
37
  }
50
- if (body.error && body.error.description) {
51
- props.message = body.error.description;
52
- props.details = body.error;
53
- return props;
54
- }
55
- props.message = body.error || body.message || httpErrorMessage(res);
56
- return props;
38
+ 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);
57
39
  }
58
40
  function isMutationError(body) {
59
- return isPlainObject(body) && isPlainObject(body.error) && body.error.type === "mutationError" && typeof body.error.description === "string";
41
+ return isPlainObject(body) && isPlainObject(body.error) && body.error.type === "mutationError" && typeof body.error.description == "string";
60
42
  }
61
43
  function isPlainObject(obj) {
62
- return typeof obj === "object" && obj !== null && !Array.isArray(obj);
44
+ return typeof obj == "object" && obj !== null && !Array.isArray(obj);
63
45
  }
64
46
  function httpErrorMessage(res) {
65
- const statusMessage = res.statusMessage ? " ".concat(res.statusMessage) : "";
66
- return "".concat(res.method, "-request to ").concat(res.url, " resulted in HTTP ").concat(res.statusCode).concat(statusMessage);
47
+ const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : "";
48
+ return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}`;
67
49
  }
68
50
  function stringifyBody(body, res) {
69
- const contentType = (res.headers["content-type"] || "").toLowerCase();
70
- const isJson = contentType.indexOf("application/json") !== -1;
71
- return isJson ? JSON.stringify(body, null, 2) : body;
51
+ return (res.headers["content-type"] || "").toLowerCase().indexOf("application/json") !== -1 ? JSON.stringify(body, null, 2) : body;
72
52
  }
73
-
74
53
  const httpError = {
75
54
  onResponse: (res) => {
76
- if (res.statusCode >= 500) {
55
+ if (res.statusCode >= 500)
77
56
  throw new ServerError(res);
78
- } else if (res.statusCode >= 400) {
57
+ if (res.statusCode >= 400)
79
58
  throw new ClientError(res);
80
- }
81
59
  return res;
82
60
  }
83
- };
84
- const printWarnings = {
61
+ }, printWarnings = {
85
62
  onResponse: (res) => {
86
63
  const warn = res.headers["x-sanity-warning"];
87
- const warnings = Array.isArray(warn) ? warn : [warn];
88
- warnings.filter(Boolean).forEach((msg) => console.warn(msg));
89
- return res;
64
+ return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
90
65
  }
91
66
  };
92
67
  function defineHttpRequest(envMiddleware, {
@@ -112,123 +87,82 @@ function defineHttpRequest(envMiddleware, {
112
87
  function httpRequest(options, requester = request) {
113
88
  return requester({ maxRedirects: 0, ...options });
114
89
  }
115
- httpRequest.defaultRequester = request;
116
- return httpRequest;
90
+ return httpRequest.defaultRequester = request, httpRequest;
117
91
  }
118
92
  function shouldRetry(err, attempt, options) {
119
- const isSafe = options.method === "GET" || options.method === "HEAD";
120
- const uri = options.uri || options.url;
121
- const isQuery = uri.startsWith("/data/query");
122
- const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
123
- if ((isSafe || isQuery) && isRetriableResponse)
124
- return true;
125
- return retry.shouldRetry(err, attempt, options);
93
+ 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);
94
+ return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
126
95
  }
127
-
128
96
  function getSelection(sel) {
129
- if (typeof sel === "string") {
97
+ if (typeof sel == "string")
130
98
  return { id: sel };
131
- }
132
- if (Array.isArray(sel)) {
99
+ if (Array.isArray(sel))
133
100
  return { query: "*[_id in $ids]", params: { ids: sel } };
134
- }
135
- if (typeof sel === "object" && sel !== null && "query" in sel && typeof sel.query === "string") {
136
- return "params" in sel && typeof sel.params === "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
137
- }
101
+ if (typeof sel == "object" && sel !== null && "query" in sel && typeof sel.query == "string")
102
+ return "params" in sel && typeof sel.params == "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
138
103
  const selectionOpts = [
139
104
  "* Document ID (<docId>)",
140
105
  "* Array of document IDs",
141
106
  "* Object containing `query`"
142
- ].join("\n");
143
- throw new Error("Unknown selection - must be one of:\n\n".concat(selectionOpts));
144
- }
107
+ ].join(`
108
+ `);
109
+ throw new Error(`Unknown selection - must be one of:
145
110
 
146
- const VALID_ASSET_TYPES = ["image", "file"];
147
- const VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
148
- const dataset = (name) => {
149
- if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
111
+ ${selectionOpts}`);
112
+ }
113
+ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before", "after", "replace"], dataset = (name2) => {
114
+ if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name2))
150
115
  throw new Error(
151
116
  "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
152
117
  );
153
- }
154
- };
155
- const projectId = (id) => {
156
- if (!/^[-a-z0-9]+$/i.test(id)) {
118
+ }, projectId = (id) => {
119
+ if (!/^[-a-z0-9]+$/i.test(id))
157
120
  throw new Error("`projectId` can only contain only a-z, 0-9 and dashes");
158
- }
159
- };
160
- const validateAssetType = (type) => {
161
- if (VALID_ASSET_TYPES.indexOf(type) === -1) {
162
- throw new Error("Invalid asset type: ".concat(type, ". Must be one of ").concat(VALID_ASSET_TYPES.join(", ")));
163
- }
164
- };
165
- const validateObject = (op, val) => {
166
- if (val === null || typeof val !== "object" || Array.isArray(val)) {
167
- throw new Error("".concat(op, "() takes an object of properties"));
168
- }
169
- };
170
- const validateDocumentId = (op, id) => {
171
- if (typeof id !== "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes("..")) {
172
- throw new Error("".concat(op, '(): "').concat(id, '" is not a valid document ID'));
173
- }
174
- };
175
- const requireDocumentId = (op, doc) => {
176
- if (!doc._id) {
177
- throw new Error("".concat(op, '() requires that the document contains an ID ("_id" property)'));
178
- }
121
+ }, validateAssetType = (type) => {
122
+ if (VALID_ASSET_TYPES.indexOf(type) === -1)
123
+ throw new Error(`Invalid asset type: ${type}. Must be one of ${VALID_ASSET_TYPES.join(", ")}`);
124
+ }, validateObject = (op, val) => {
125
+ if (val === null || typeof val != "object" || Array.isArray(val))
126
+ throw new Error(`${op}() takes an object of properties`);
127
+ }, validateDocumentId = (op, id) => {
128
+ if (typeof id != "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes(".."))
129
+ throw new Error(`${op}(): "${id}" is not a valid document ID`);
130
+ }, requireDocumentId = (op, doc) => {
131
+ if (!doc._id)
132
+ throw new Error(`${op}() requires that the document contains an ID ("_id" property)`);
179
133
  validateDocumentId(op, doc._id);
180
- };
181
- const validateInsert = (at, selector, items) => {
134
+ }, validateInsert = (at, selector, items) => {
182
135
  const signature = "insert(at, selector, items)";
183
136
  if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
184
- const valid = VALID_INSERT_LOCATIONS.map((loc) => '"'.concat(loc, '"')).join(", ");
185
- throw new Error("".concat(signature, ' takes an "at"-argument which is one of: ').concat(valid));
186
- }
187
- if (typeof selector !== "string") {
188
- throw new Error("".concat(signature, ' takes a "selector"-argument which must be a string'));
189
- }
190
- if (!Array.isArray(items)) {
191
- throw new Error("".concat(signature, ' takes an "items"-argument which must be an array'));
192
- }
193
- };
194
- const hasDataset = (config) => {
195
- if (!config.dataset) {
137
+ const valid = VALID_INSERT_LOCATIONS.map((loc) => `"${loc}"`).join(", ");
138
+ throw new Error(`${signature} takes an "at"-argument which is one of: ${valid}`);
139
+ }
140
+ if (typeof selector != "string")
141
+ throw new Error(`${signature} takes a "selector"-argument which must be a string`);
142
+ if (!Array.isArray(items))
143
+ throw new Error(`${signature} takes an "items"-argument which must be an array`);
144
+ }, hasDataset = (config) => {
145
+ if (!config.dataset)
196
146
  throw new Error("`dataset` must be provided to perform queries");
197
- }
198
147
  return config.dataset || "";
199
- };
200
- const requestTag = (tag) => {
201
- if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
148
+ }, requestTag = (tag) => {
149
+ if (typeof tag != "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag))
202
150
  throw new Error(
203
151
  "Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long."
204
152
  );
205
- }
206
153
  return tag;
207
154
  };
208
-
209
155
  var __accessCheck$6 = (obj, member, msg) => {
210
156
  if (!member.has(obj))
211
157
  throw TypeError("Cannot " + msg);
212
- };
213
- var __privateGet$6 = (obj, member, getter) => {
214
- __accessCheck$6(obj, member, "read from private field");
215
- return getter ? getter.call(obj) : member.get(obj);
216
- };
217
- var __privateAdd$6 = (obj, member, value) => {
158
+ }, __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) => {
218
159
  if (member.has(obj))
219
160
  throw TypeError("Cannot add the same private member more than once");
220
161
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
221
- };
222
- var __privateSet$6 = (obj, member, value, setter) => {
223
- __accessCheck$6(obj, member, "write to private field");
224
- setter ? setter.call(obj, value) : member.set(obj, value);
225
- return value;
226
- };
227
- var _client$5, _client2$5;
162
+ }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
228
163
  class BasePatch {
229
164
  constructor(selection, operations = {}) {
230
- this.selection = selection;
231
- this.operations = operations;
165
+ this.selection = selection, this.operations = operations;
232
166
  }
233
167
  /**
234
168
  * Sets the given attributes to the document. Does NOT merge objects.
@@ -255,8 +189,7 @@ class BasePatch {
255
189
  * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
256
190
  */
257
191
  diffMatchPatch(attrs) {
258
- validateObject("diffMatchPatch", attrs);
259
- return this._assign("diffMatchPatch", attrs);
192
+ return validateObject("diffMatchPatch", attrs), this._assign("diffMatchPatch", attrs);
260
193
  }
261
194
  /**
262
195
  * Unsets the attribute paths provided.
@@ -265,11 +198,9 @@ class BasePatch {
265
198
  * @param attrs - Attribute paths to unset.
266
199
  */
267
200
  unset(attrs) {
268
- if (!Array.isArray(attrs)) {
201
+ if (!Array.isArray(attrs))
269
202
  throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
270
- }
271
- this.operations = Object.assign({}, this.operations, { unset: attrs });
272
- return this;
203
+ return this.operations = Object.assign({}, this.operations, { unset: attrs }), this;
273
204
  }
274
205
  /**
275
206
  * 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.
@@ -295,8 +226,7 @@ class BasePatch {
295
226
  * @param items - Array of items to insert/replace
296
227
  */
297
228
  insert(at, selector, items) {
298
- validateInsert(at, selector, items);
299
- return this._assign("insert", { [at]: selector, items });
229
+ return validateInsert(at, selector, items), this._assign("insert", { [at]: selector, items });
300
230
  }
301
231
  /**
302
232
  * Append the given items to the array at the given JSONPath
@@ -305,7 +235,7 @@ class BasePatch {
305
235
  * @param items - Array of items to append to the array
306
236
  */
307
237
  append(selector, items) {
308
- return this.insert("after", "".concat(selector, "[-1]"), items);
238
+ return this.insert("after", `${selector}[-1]`, items);
309
239
  }
310
240
  /**
311
241
  * Prepend the given items to the array at the given JSONPath
@@ -314,7 +244,7 @@ class BasePatch {
314
244
  * @param items - Array of items to prepend to the array
315
245
  */
316
246
  prepend(selector, items) {
317
- return this.insert("before", "".concat(selector, "[0]"), items);
247
+ return this.insert("before", `${selector}[0]`, items);
318
248
  }
319
249
  /**
320
250
  * Change the contents of an array by removing existing elements and/or adding new elements.
@@ -325,11 +255,7 @@ class BasePatch {
325
255
  * @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.
326
256
  */
327
257
  splice(selector, start, deleteCount, items) {
328
- const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
329
- const startIndex = start < 0 ? start - 1 : start;
330
- const delCount = delAll ? -1 : Math.max(0, start + deleteCount);
331
- const delRange = startIndex < 0 && delCount >= 0 ? "" : delCount;
332
- const rangeSelector = "".concat(selector, "[").concat(startIndex, ":").concat(delRange, "]");
258
+ 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}]`;
333
259
  return this.insert("replace", rangeSelector, items || []);
334
260
  }
335
261
  /**
@@ -338,8 +264,7 @@ class BasePatch {
338
264
  * @param rev - Revision to lock the patch to
339
265
  */
340
266
  ifRevisionId(rev) {
341
- this.operations.ifRevisionID = rev;
342
- return this;
267
+ return this.operations.ifRevisionID = rev, this;
343
268
  }
344
269
  /**
345
270
  * Return a plain JSON representation of the patch
@@ -357,95 +282,73 @@ class BasePatch {
357
282
  * Clears the patch of all operations
358
283
  */
359
284
  reset() {
360
- this.operations = {};
361
- return this;
285
+ return this.operations = {}, this;
362
286
  }
363
- _assign(op, props, merge = true) {
364
- validateObject(op, props);
365
- this.operations = Object.assign({}, this.operations, {
287
+ _assign(op, props, merge = !0) {
288
+ return validateObject(op, props), this.operations = Object.assign({}, this.operations, {
366
289
  [op]: Object.assign({}, merge && this.operations[op] || {}, props)
367
- });
368
- return this;
290
+ }), this;
369
291
  }
370
292
  _set(op, props) {
371
- return this._assign(op, props, false);
293
+ return this._assign(op, props, !1);
372
294
  }
373
295
  }
374
- const _ObservablePatch = class _ObservablePatch extends BasePatch {
296
+ var _client$5;
297
+ const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
375
298
  constructor(selection, operations, client) {
376
- super(selection, operations);
377
- __privateAdd$6(this, _client$5, void 0);
378
- __privateSet$6(this, _client$5, client);
299
+ super(selection, operations), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
379
300
  }
380
301
  /**
381
302
  * Clones the patch
382
303
  */
383
304
  clone() {
384
- return new _ObservablePatch(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
305
+ return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
385
306
  }
386
307
  commit(options) {
387
- if (!__privateGet$6(this, _client$5)) {
308
+ if (!__privateGet$6(this, _client$5))
388
309
  throw new Error(
389
310
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
390
311
  );
391
- }
392
- const returnFirst = typeof this.selection === "string";
393
- const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
312
+ const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
394
313
  return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
395
314
  }
396
315
  };
397
- _client$5 = new WeakMap();
316
+ _client$5 = /* @__PURE__ */ new WeakMap();
398
317
  let ObservablePatch = _ObservablePatch;
399
- const _Patch = class _Patch extends BasePatch {
318
+ var _client2$5;
319
+ const _Patch = class _Patch2 extends BasePatch {
400
320
  constructor(selection, operations, client) {
401
- super(selection, operations);
402
- __privateAdd$6(this, _client2$5, void 0);
403
- __privateSet$6(this, _client2$5, client);
321
+ super(selection, operations), __privateAdd$6(this, _client2$5, void 0), __privateSet$6(this, _client2$5, client);
404
322
  }
405
323
  /**
406
324
  * Clones the patch
407
325
  */
408
326
  clone() {
409
- return new _Patch(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
327
+ return new _Patch2(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
410
328
  }
411
329
  commit(options) {
412
- if (!__privateGet$6(this, _client2$5)) {
330
+ if (!__privateGet$6(this, _client2$5))
413
331
  throw new Error(
414
332
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
415
333
  );
416
- }
417
- const returnFirst = typeof this.selection === "string";
418
- const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
334
+ const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
419
335
  return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
420
336
  }
421
337
  };
422
- _client2$5 = new WeakMap();
338
+ _client2$5 = /* @__PURE__ */ new WeakMap();
423
339
  let Patch = _Patch;
424
-
425
340
  var __accessCheck$5 = (obj, member, msg) => {
426
341
  if (!member.has(obj))
427
342
  throw TypeError("Cannot " + msg);
428
- };
429
- var __privateGet$5 = (obj, member, getter) => {
430
- __accessCheck$5(obj, member, "read from private field");
431
- return getter ? getter.call(obj) : member.get(obj);
432
- };
433
- var __privateAdd$5 = (obj, member, value) => {
343
+ }, __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) => {
434
344
  if (member.has(obj))
435
345
  throw TypeError("Cannot add the same private member more than once");
436
346
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
437
- };
438
- var __privateSet$5 = (obj, member, value, setter) => {
439
- __accessCheck$5(obj, member, "write to private field");
440
- setter ? setter.call(obj, value) : member.set(obj, value);
441
- return value;
442
- };
443
- var _client$4, _client2$4;
444
- const defaultMutateOptions = { returnDocuments: false };
347
+ }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
348
+ const defaultMutateOptions = { returnDocuments: !1 };
445
349
  class BaseTransaction {
446
350
  constructor(operations = [], transactionId) {
447
- this.operations = operations;
448
- this.trxId = transactionId;
351
+ this.operations = operations, this.trxId = transactionId;
449
352
  }
450
353
  /**
451
354
  * 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.
@@ -454,8 +357,7 @@ class BaseTransaction {
454
357
  * @param doc - Document to create. Requires a `_type` property.
455
358
  */
456
359
  create(doc) {
457
- validateObject("create", doc);
458
- return this._add({ create: doc });
360
+ return validateObject("create", doc), this._add({ create: doc });
459
361
  }
460
362
  /**
461
363
  * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
@@ -465,9 +367,7 @@ class BaseTransaction {
465
367
  */
466
368
  createIfNotExists(doc) {
467
369
  const op = "createIfNotExists";
468
- validateObject(op, doc);
469
- requireDocumentId(op, doc);
470
- return this._add({ [op]: doc });
370
+ return validateObject(op, doc), requireDocumentId(op, doc), this._add({ [op]: doc });
471
371
  }
472
372
  /**
473
373
  * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
@@ -477,9 +377,7 @@ class BaseTransaction {
477
377
  */
478
378
  createOrReplace(doc) {
479
379
  const op = "createOrReplace";
480
- validateObject(op, doc);
481
- requireDocumentId(op, doc);
482
- return this._add({ [op]: doc });
380
+ return validateObject(op, doc), requireDocumentId(op, doc), this._add({ [op]: doc });
483
381
  }
484
382
  /**
485
383
  * Deletes the document with the given document ID
@@ -488,15 +386,10 @@ class BaseTransaction {
488
386
  * @param documentId - Document ID to delete
489
387
  */
490
388
  delete(documentId) {
491
- validateDocumentId("delete", documentId);
492
- return this._add({ delete: { id: documentId } });
389
+ return validateDocumentId("delete", documentId), this._add({ delete: { id: documentId } });
493
390
  }
494
391
  transactionId(id) {
495
- if (!id) {
496
- return this.trxId;
497
- }
498
- this.trxId = id;
499
- return this;
392
+ return id ? (this.trxId = id, this) : this.trxId;
500
393
  }
501
394
  /**
502
395
  * Return a plain JSON representation of the transaction
@@ -514,162 +407,124 @@ class BaseTransaction {
514
407
  * Clears the transaction of all operations
515
408
  */
516
409
  reset() {
517
- this.operations = [];
518
- return this;
410
+ return this.operations = [], this;
519
411
  }
520
412
  _add(mut) {
521
- this.operations.push(mut);
522
- return this;
413
+ return this.operations.push(mut), this;
523
414
  }
524
415
  }
525
- const _Transaction = class _Transaction extends BaseTransaction {
416
+ var _client$4;
417
+ const _Transaction = class _Transaction2 extends BaseTransaction {
526
418
  constructor(operations, client, transactionId) {
527
- super(operations, transactionId);
528
- __privateAdd$5(this, _client$4, void 0);
529
- __privateSet$5(this, _client$4, client);
419
+ super(operations, transactionId), __privateAdd$5(this, _client$4, void 0), __privateSet$5(this, _client$4, client);
530
420
  }
531
421
  /**
532
422
  * Clones the transaction
533
423
  */
534
424
  clone() {
535
- return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
425
+ return new _Transaction2([...this.operations], __privateGet$5(this, _client$4), this.trxId);
536
426
  }
537
427
  commit(options) {
538
- if (!__privateGet$5(this, _client$4)) {
428
+ if (!__privateGet$5(this, _client$4))
539
429
  throw new Error(
540
430
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
541
431
  );
542
- }
543
432
  return __privateGet$5(this, _client$4).mutate(
544
433
  this.serialize(),
545
434
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
546
435
  );
547
436
  }
548
437
  patch(patchOrDocumentId, patchOps) {
549
- const isBuilder = typeof patchOps === "function";
550
- const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof Patch;
551
- if (isPatch) {
438
+ const isBuilder = typeof patchOps == "function";
439
+ if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
552
440
  return this._add({ patch: patchOrDocumentId.serialize() });
553
- }
554
441
  if (isBuilder) {
555
442
  const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
556
- if (!(patch instanceof Patch)) {
443
+ if (!(patch instanceof Patch))
557
444
  throw new Error("function passed to `patch()` must return the patch");
558
- }
559
445
  return this._add({ patch: patch.serialize() });
560
446
  }
561
447
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
562
448
  }
563
449
  };
564
- _client$4 = new WeakMap();
450
+ _client$4 = /* @__PURE__ */ new WeakMap();
565
451
  let Transaction = _Transaction;
566
- const _ObservableTransaction = class _ObservableTransaction extends BaseTransaction {
452
+ var _client2$4;
453
+ const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
567
454
  constructor(operations, client, transactionId) {
568
- super(operations, transactionId);
569
- __privateAdd$5(this, _client2$4, void 0);
570
- __privateSet$5(this, _client2$4, client);
455
+ super(operations, transactionId), __privateAdd$5(this, _client2$4, void 0), __privateSet$5(this, _client2$4, client);
571
456
  }
572
457
  /**
573
458
  * Clones the transaction
574
459
  */
575
460
  clone() {
576
- return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
461
+ return new _ObservableTransaction2([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
577
462
  }
578
463
  commit(options) {
579
- if (!__privateGet$5(this, _client2$4)) {
464
+ if (!__privateGet$5(this, _client2$4))
580
465
  throw new Error(
581
466
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
582
467
  );
583
- }
584
468
  return __privateGet$5(this, _client2$4).mutate(
585
469
  this.serialize(),
586
470
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
587
471
  );
588
472
  }
589
473
  patch(patchOrDocumentId, patchOps) {
590
- const isBuilder = typeof patchOps === "function";
591
- const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof ObservablePatch;
592
- if (isPatch) {
474
+ const isBuilder = typeof patchOps == "function";
475
+ if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
593
476
  return this._add({ patch: patchOrDocumentId.serialize() });
594
- }
595
477
  if (isBuilder) {
596
478
  const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
597
- if (!(patch instanceof ObservablePatch)) {
479
+ if (!(patch instanceof ObservablePatch))
598
480
  throw new Error("function passed to `patch()` must return the patch");
599
- }
600
481
  return this._add({ patch: patch.serialize() });
601
482
  }
602
483
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
603
484
  }
604
485
  };
605
- _client2$4 = new WeakMap();
486
+ _client2$4 = /* @__PURE__ */ new WeakMap();
606
487
  let ObservableTransaction = _ObservableTransaction;
607
-
608
488
  const BASE_URL = "https://www.sanity.io/help/";
609
489
  function generateHelpUrl(slug) {
610
490
  return BASE_URL + slug;
611
491
  }
612
-
613
492
  function once(fn) {
614
- let didCall = false;
615
- let returnValue;
616
- return (...args) => {
617
- if (didCall) {
618
- return returnValue;
619
- }
620
- returnValue = fn(...args);
621
- didCall = true;
622
- return returnValue;
623
- };
493
+ let didCall = !1, returnValue;
494
+ return (...args) => (didCall || (returnValue = fn(...args), didCall = !0), returnValue);
624
495
  }
625
-
626
496
  const createWarningPrinter = (message) => (
627
497
  // eslint-disable-next-line no-console
628
498
  once((...args) => console.warn(message.join(" "), ...args))
629
- );
630
- const printCdnWarning = createWarningPrinter([
499
+ ), printCdnWarning = createWarningPrinter([
631
500
  "Since you haven't set a value for `useCdn`, we will deliver content using our",
632
501
  "global, edge-cached API-CDN. If you wish to have content delivered faster, set",
633
502
  "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
634
- ]);
635
- const printCdnPreviewDraftsWarning = createWarningPrinter([
503
+ ]), printCdnPreviewDraftsWarning = createWarningPrinter([
636
504
  "The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
637
505
  "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
638
- ]);
639
- const printBrowserTokenWarning = createWarningPrinter([
506
+ ]), printBrowserTokenWarning = createWarningPrinter([
640
507
  "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
641
- "See ".concat(generateHelpUrl(
508
+ `See ${generateHelpUrl(
642
509
  "js-client-browser-token"
643
- ), " for more information and how to hide this warning.")
644
- ]);
645
- const printNoApiVersionSpecifiedWarning = createWarningPrinter([
510
+ )} for more information and how to hide this warning.`
511
+ ]), printNoApiVersionSpecifiedWarning = createWarningPrinter([
646
512
  "Using the Sanity client without specifying an API version is deprecated.",
647
- "See ".concat(generateHelpUrl("js-client-api-version"))
648
- ]);
649
- const printNoDefaultExport = createWarningPrinter([
513
+ `See ${generateHelpUrl("js-client-api-version")}`
514
+ ]), printNoDefaultExport = createWarningPrinter([
650
515
  "The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."
651
- ]);
652
-
653
- const defaultCdnHost = "apicdn.sanity.io";
654
- const defaultConfig = {
516
+ ]), defaultCdnHost = "apicdn.sanity.io", defaultConfig = {
655
517
  apiHost: "https://api.sanity.io",
656
518
  apiVersion: "1",
657
- useProjectHostname: true,
658
- stega: { enabled: false }
659
- };
660
- const LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
661
- const isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
662
- const validateApiVersion = function validateApiVersion2(apiVersion) {
663
- if (apiVersion === "1" || apiVersion === "X") {
519
+ useProjectHostname: !0,
520
+ stega: { enabled: !1 }
521
+ }, LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"], isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1, validateApiVersion = function(apiVersion) {
522
+ if (apiVersion === "1" || apiVersion === "X")
664
523
  return;
665
- }
666
524
  const apiDate = new Date(apiVersion);
667
- const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
668
- if (!apiVersionValid) {
525
+ if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
669
526
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
670
- }
671
- };
672
- const validateApiPerspective = function validateApiPerspective2(perspective) {
527
+ }, validateApiPerspective = function(perspective) {
673
528
  switch (perspective) {
674
529
  case "previewDrafts":
675
530
  case "published":
@@ -680,196 +535,141 @@ const validateApiPerspective = function validateApiPerspective2(perspective) {
680
535
  "Invalid API perspective string, expected `published`, `previewDrafts` or `raw`"
681
536
  );
682
537
  }
683
- };
684
- const initConfig = (config, prevConfig) => {
538
+ }, initConfig = (config, prevConfig) => {
685
539
  const specifiedConfig = {
686
540
  ...prevConfig,
687
541
  ...config,
688
542
  stega: {
689
- ...typeof prevConfig.stega === "boolean" ? { enabled: prevConfig.stega } : prevConfig.stega || defaultConfig.stega,
690
- ...typeof config.stega === "boolean" ? { enabled: config.stega } : config.stega || {}
543
+ ...typeof prevConfig.stega == "boolean" ? { enabled: prevConfig.stega } : prevConfig.stega || defaultConfig.stega,
544
+ ...typeof config.stega == "boolean" ? { enabled: config.stega } : config.stega || {}
691
545
  }
692
546
  };
693
- if (!specifiedConfig.apiVersion) {
694
- printNoApiVersionSpecifiedWarning();
695
- }
547
+ specifiedConfig.apiVersion || printNoApiVersionSpecifiedWarning();
696
548
  const newConfig = {
697
549
  ...defaultConfig,
698
550
  ...specifiedConfig
699
- };
700
- const projectBased = newConfig.useProjectHostname;
701
- if (typeof Promise === "undefined") {
551
+ }, projectBased = newConfig.useProjectHostname;
552
+ if (typeof Promise > "u") {
702
553
  const helpUrl = generateHelpUrl("js-client-promise-polyfill");
703
- throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(helpUrl));
554
+ throw new Error(`No native Promise-implementation found, polyfill needed - see ${helpUrl}`);
704
555
  }
705
- if (projectBased && !newConfig.projectId) {
556
+ if (projectBased && !newConfig.projectId)
706
557
  throw new Error("Configuration must contain `projectId`");
707
- }
708
- if (typeof newConfig.perspective === "string") {
709
- validateApiPerspective(newConfig.perspective);
710
- }
711
- if ("encodeSourceMap" in newConfig) {
558
+ if (typeof newConfig.perspective == "string" && validateApiPerspective(newConfig.perspective), "encodeSourceMap" in newConfig)
712
559
  throw new Error(
713
560
  "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'?"
714
561
  );
715
- }
716
- if ("encodeSourceMapAtPath" in newConfig) {
562
+ if ("encodeSourceMapAtPath" in newConfig)
717
563
  throw new Error(
718
564
  "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'?"
719
565
  );
720
- }
721
- if (typeof newConfig.stega.enabled !== "boolean") {
722
- throw new Error("stega.enabled must be a boolean, received ".concat(newConfig.stega.enabled));
723
- }
724
- if (newConfig.stega.enabled && newConfig.stega.studioUrl === void 0) {
566
+ if (typeof newConfig.stega.enabled != "boolean")
567
+ throw new Error(`stega.enabled must be a boolean, received ${newConfig.stega.enabled}`);
568
+ if (newConfig.stega.enabled && newConfig.stega.studioUrl === void 0)
725
569
  throw new Error("stega.studioUrl must be defined when stega.enabled is true");
726
- }
727
- if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl !== "string" && typeof newConfig.stega.studioUrl !== "function") {
570
+ if (newConfig.stega.enabled && typeof newConfig.stega.studioUrl != "string" && typeof newConfig.stega.studioUrl != "function")
728
571
  throw new Error(
729
- "stega.studioUrl must be a string or a function, received ".concat(newConfig.stega.studioUrl)
572
+ `stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
730
573
  );
731
- }
732
- const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
733
- const isLocalhost = isBrowser && isLocal(window.location.hostname);
734
- if (isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true) {
735
- printBrowserTokenWarning();
736
- } else if (typeof newConfig.useCdn === "undefined") {
737
- printCdnWarning();
738
- }
739
- if (projectBased) {
740
- projectId(newConfig.projectId);
741
- }
742
- if (newConfig.dataset) {
743
- dataset(newConfig.dataset);
744
- }
745
- if ("requestTagPrefix" in newConfig) {
746
- newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0;
747
- }
748
- newConfig.apiVersion = "".concat(newConfig.apiVersion).replace(/^v/, "");
749
- newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost;
750
- newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials;
751
- validateApiVersion(newConfig.apiVersion);
752
- const hostParts = newConfig.apiHost.split("://", 2);
753
- const protocol = hostParts[0];
754
- const host = hostParts[1];
755
- const cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
756
- if (newConfig.useProjectHostname) {
757
- newConfig.url = "".concat(protocol, "://").concat(newConfig.projectId, ".").concat(host, "/v").concat(newConfig.apiVersion);
758
- newConfig.cdnUrl = "".concat(protocol, "://").concat(newConfig.projectId, ".").concat(cdnHost, "/v").concat(newConfig.apiVersion);
759
- } else {
760
- newConfig.url = "".concat(newConfig.apiHost, "/v").concat(newConfig.apiVersion);
761
- newConfig.cdnUrl = newConfig.url;
762
- }
763
- return newConfig;
764
- };
765
-
766
- const projectHeader = "X-Sanity-Project-ID";
574
+ const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
575
+ 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);
576
+ const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
577
+ 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;
578
+ }, projectHeader = "X-Sanity-Project-ID";
767
579
  function requestOptions(config, overrides = {}) {
768
- const headers = {};
769
- const token = overrides.token || config.token;
770
- if (token) {
771
- headers.Authorization = "Bearer ".concat(token);
772
- }
773
- if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
774
- headers[projectHeader] = config.projectId;
775
- }
776
- const withCredentials = Boolean(
777
- typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
778
- );
779
- const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
580
+ const headers2 = {}, token = overrides.token || config.token;
581
+ token && (headers2.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config.useProjectHostname && config.projectId && (headers2[projectHeader] = config.projectId);
582
+ const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.token || config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
780
583
  return Object.assign({}, overrides, {
781
- headers: Object.assign({}, headers, overrides.headers || {}),
782
- timeout: typeof timeout === "undefined" ? 5 * 60 * 1e3 : timeout,
584
+ headers: Object.assign({}, headers2, overrides.headers || {}),
585
+ timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
783
586
  proxy: overrides.proxy || config.proxy,
784
- json: true,
587
+ json: !0,
785
588
  withCredentials,
786
- fetch: typeof overrides.fetch === "object" && typeof config.fetch === "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
589
+ fetch: typeof overrides.fetch == "object" && typeof config.fetch == "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
787
590
  });
788
591
  }
789
-
790
- 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])||""}}
791
-
592
+ 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("");
593
+ function E(t) {
594
+ let e = JSON.stringify(t);
595
+ return `${d}${Array.from(e).map((r) => {
596
+ let n = r.charCodeAt(0);
597
+ if (n > 255)
598
+ throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
599
+ return Array.from(n.toString(4).padStart(4, "0")).map((o) => String.fromCodePoint(c[o])).join("");
600
+ }).join("")}`;
601
+ }
602
+ function I(t) {
603
+ return Number.isNaN(Number(t)) ? !!Date.parse(t) : !1;
604
+ }
605
+ function x(t) {
606
+ try {
607
+ new URL(t, t.startsWith("/") ? "https://acme.com" : void 0);
608
+ } catch {
609
+ return !1;
610
+ }
611
+ return !0;
612
+ }
613
+ function b(t, e, r = "auto") {
614
+ return r === !0 || r === "auto" && (I(t) || x(t)) ? t : `${t}${E(e)}`;
615
+ }
616
+ Object.fromEntries(Object.entries(c).map((t) => t.reverse()));
617
+ Object.fromEntries(Object.entries(s).map((t) => t.reverse()));
618
+ var S = `${Object.values(s).map((t) => `\\u{${t.toString(16)}}`).join("")}`, f = new RegExp(`[${S}]{4,}`, "gu");
619
+ function X(t) {
620
+ var e;
621
+ return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ? void 0 : e[0]) || "" };
622
+ }
792
623
  function vercelStegaCleanAll(result) {
793
624
  try {
794
625
  return JSON.parse(
795
- JSON.stringify(result, (key, value) => {
796
- if (typeof value !== "string")
797
- return value;
798
- return X(value).cleaned;
799
- })
626
+ JSON.stringify(result, (key, value) => typeof value != "string" ? value : X(value).cleaned)
800
627
  );
801
628
  } catch {
802
629
  return result;
803
630
  }
804
631
  }
805
-
806
632
  const encodeQueryString = ({
807
633
  query,
808
634
  params = {},
809
635
  options = {}
810
636
  }) => {
811
- const searchParams = new URLSearchParams();
812
- const { tag, returnQuery, ...opts } = options;
813
- if (tag)
814
- searchParams.append("tag", tag);
815
- searchParams.append("query", query);
816
- for (const [key, value] of Object.entries(params)) {
817
- searchParams.append("$".concat(key), JSON.stringify(value));
818
- }
819
- for (const [key, value] of Object.entries(opts)) {
820
- if (value)
821
- searchParams.append(key, "".concat(value));
822
- }
823
- if (returnQuery === false)
824
- searchParams.append("returnQuery", "false");
825
- return "?".concat(searchParams);
826
- };
827
-
828
- const excludeFalsey = (param, defValue) => {
829
- const value = typeof param === "undefined" ? defValue : param;
830
- return param === false ? void 0 : value;
831
- };
832
- const getMutationQuery = (options = {}) => {
833
- return {
834
- dryRun: options.dryRun,
835
- returnIds: true,
836
- returnDocuments: excludeFalsey(options.returnDocuments, true),
837
- visibility: options.visibility || "sync",
838
- autoGenerateArrayKeys: options.autoGenerateArrayKeys,
839
- skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
840
- };
841
- };
842
- const isResponse = (event) => event.type === "response";
843
- const getBody = (event) => event.body;
844
- const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
845
- indexed[attr(doc)] = doc;
846
- return indexed;
847
- }, /* @__PURE__ */ Object.create(null));
848
- const getQuerySizeLimit = 11264;
637
+ const searchParams = new URLSearchParams(), { tag, returnQuery, ...opts } = options;
638
+ tag && searchParams.append("tag", tag), searchParams.append("query", query);
639
+ for (const [key, value] of Object.entries(params))
640
+ searchParams.append(`$${key}`, JSON.stringify(value));
641
+ for (const [key, value] of Object.entries(opts))
642
+ value && searchParams.append(key, `${value}`);
643
+ return returnQuery === !1 && searchParams.append("returnQuery", "false"), `?${searchParams}`;
644
+ }, excludeFalsey = (param, defValue) => param === !1 ? void 0 : typeof param > "u" ? defValue : param, getMutationQuery = (options = {}) => ({
645
+ dryRun: options.dryRun,
646
+ returnIds: !0,
647
+ returnDocuments: excludeFalsey(options.returnDocuments, !0),
648
+ visibility: options.visibility || "sync",
649
+ autoGenerateArrayKeys: options.autoGenerateArrayKeys,
650
+ skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
651
+ }), 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;
849
652
  function _fetch(client, httpRequest, _stega, query, _params = {}, options = {}) {
850
653
  const stega = "stega" in options ? {
851
654
  ..._stega || {},
852
- ...typeof options.stega === "boolean" ? { enabled: options.stega } : options.stega || {}
853
- } : _stega;
854
- const params = stega.enabled ? vercelStegaCleanAll(_params) : _params;
855
- const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
856
- const { cache, next, ...opts } = {
655
+ ...typeof options.stega == "boolean" ? { enabled: options.stega } : options.stega || {}
656
+ } : _stega, params = stega.enabled ? vercelStegaCleanAll(_params) : _params, mapResponse = options.filterResponse === !1 ? (res) => res : (res) => res.result, { cache, next, ...opts } = {
857
657
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
858
658
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
859
- useAbortSignal: typeof options.signal !== "undefined",
659
+ useAbortSignal: typeof options.signal < "u",
860
660
  // Set `resultSourceMap' when stega is enabled, as it's required for encoding.
861
661
  resultSourceMap: stega.enabled ? "withKeyArraySelector" : options.resultSourceMap,
862
662
  ...options,
863
663
  // Default to not returning the query, unless `filterResponse` is `false`,
864
664
  // or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy
865
- returnQuery: options.filterResponse === false && options.returnQuery !== false
866
- };
867
- const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
868
- const $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
665
+ returnQuery: options.filterResponse === !1 && options.returnQuery !== !1
666
+ }, reqOpts = typeof cache < "u" || typeof next < "u" ? { ...opts, fetch: { cache, next } } : opts, $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
869
667
  return stega.enabled ? $request.pipe(
870
668
  combineLatestWith(
871
669
  from(
872
- import('./stegaEncodeSourceMap-DS4_14pP.js').then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
670
+ import("./stegaEncodeSourceMap-bRxIGJ-b.js").then(function(n) {
671
+ return n.stegaEncodeSourceMap$1;
672
+ }).then(
873
673
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
874
674
  )
875
675
  )
@@ -883,14 +683,14 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
883
683
  ) : $request.pipe(map(mapResponse));
884
684
  }
885
685
  function _getDocument(client, httpRequest, id, opts = {}) {
886
- const options = { uri: _getDataUrl(client, "doc", id), json: true, tag: opts.tag };
686
+ const options = { uri: _getDataUrl(client, "doc", id), json: !0, tag: opts.tag };
887
687
  return _requestObservable(client, httpRequest, options).pipe(
888
688
  filter(isResponse),
889
689
  map((event) => event.body.documents && event.body.documents[0])
890
690
  );
891
691
  }
892
692
  function _getDocuments(client, httpRequest, ids, opts = {}) {
893
- const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: true, tag: opts.tag };
693
+ const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: !0, tag: opts.tag };
894
694
  return _requestObservable(client, httpRequest, options).pipe(
895
695
  filter(isResponse),
896
696
  map((event) => {
@@ -900,12 +700,10 @@ function _getDocuments(client, httpRequest, ids, opts = {}) {
900
700
  );
901
701
  }
902
702
  function _createIfNotExists(client, httpRequest, doc, options) {
903
- requireDocumentId("createIfNotExists", doc);
904
- return _create(client, httpRequest, doc, "createIfNotExists", options);
703
+ return requireDocumentId("createIfNotExists", doc), _create(client, httpRequest, doc, "createIfNotExists", options);
905
704
  }
906
705
  function _createOrReplace(client, httpRequest, doc, options) {
907
- requireDocumentId("createOrReplace", doc);
908
- return _create(client, httpRequest, doc, "createOrReplace", options);
706
+ return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
909
707
  }
910
708
  function _delete(client, httpRequest, selection, options) {
911
709
  return _dataRequest(
@@ -918,34 +716,19 @@ function _delete(client, httpRequest, selection, options) {
918
716
  }
919
717
  function _mutate(client, httpRequest, mutations, options) {
920
718
  let mut;
921
- if (mutations instanceof Patch || mutations instanceof ObservablePatch) {
922
- mut = { patch: mutations.serialize() };
923
- } else if (mutations instanceof Transaction || mutations instanceof ObservableTransaction) {
924
- mut = mutations.serialize();
925
- } else {
926
- mut = mutations;
927
- }
928
- const muts = Array.isArray(mut) ? mut : [mut];
929
- const transactionId = options && options.transactionId || void 0;
719
+ mutations instanceof Patch || mutations instanceof ObservablePatch ? mut = { patch: mutations.serialize() } : mutations instanceof Transaction || mutations instanceof ObservableTransaction ? mut = mutations.serialize() : mut = mutations;
720
+ const muts = Array.isArray(mut) ? mut : [mut], transactionId = options && options.transactionId || void 0;
930
721
  return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
931
722
  }
932
723
  function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
933
- const isMutation = endpoint === "mutate";
934
- const isQuery = endpoint === "query";
935
- const strQuery = isMutation ? "" : encodeQueryString(body);
936
- const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
937
- const stringQuery = useGet ? strQuery : "";
938
- const returnFirst = options.returnFirst;
939
- const { timeout, token, tag, headers, returnQuery } = options;
940
- const uri = _getDataUrl(client, endpoint, stringQuery);
941
- const reqOptions = {
724
+ 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: headers2, returnQuery } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
942
725
  method: useGet ? "GET" : "POST",
943
726
  uri,
944
- json: true,
727
+ json: !0,
945
728
  body: useGet ? void 0 : body,
946
729
  query: isMutation && getMutationQuery(options),
947
730
  timeout,
948
- headers,
731
+ headers: headers2,
949
732
  token,
950
733
  tag,
951
734
  returnQuery,
@@ -961,15 +744,12 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
961
744
  filter(isResponse),
962
745
  map(getBody),
963
746
  map((res) => {
964
- if (!isMutation) {
747
+ if (!isMutation)
965
748
  return res;
966
- }
967
749
  const results = res.results || [];
968
- if (options.returnDocuments) {
750
+ if (options.returnDocuments)
969
751
  return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
970
- }
971
- const key = returnFirst ? "documentId" : "documentIds";
972
- const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
752
+ const key = returnFirst ? "documentId" : "documentIds", ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
973
753
  return {
974
754
  transactionId: res.transactionId,
975
755
  results,
@@ -979,139 +759,91 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
979
759
  );
980
760
  }
981
761
  function _create(client, httpRequest, doc, op, options = {}) {
982
- const mutation = { [op]: doc };
983
- const opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
762
+ const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
984
763
  return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
985
764
  }
986
765
  function _requestObservable(client, httpRequest, options) {
987
766
  var _a, _b;
988
- const uri = options.url || options.uri;
989
- const config = client.config();
990
- const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
767
+ 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;
991
768
  let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
992
769
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
993
- if (tag && options.tag !== null) {
994
- options.query = { tag: requestTag(tag), ...options.query };
995
- }
996
- if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
770
+ 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) {
997
771
  const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
998
- if (resultSourceMap !== void 0 && resultSourceMap !== false) {
999
- options.query = { resultSourceMap, ...options.query };
1000
- }
772
+ resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
1001
773
  const perspective = options.perspective || config.perspective;
1002
- if (typeof perspective === "string" && perspective !== "raw") {
1003
- validateApiPerspective(perspective);
1004
- options.query = { perspective, ...options.query };
1005
- if (perspective === "previewDrafts" && useCdn) {
1006
- useCdn = false;
1007
- printCdnPreviewDraftsWarning();
1008
- }
1009
- }
1010
- if (options.returnQuery === false) {
1011
- options.query = { returnQuery: "false", ...options.query };
1012
- }
774
+ 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 });
1013
775
  }
1014
776
  const reqOptions = requestOptions(
1015
777
  config,
1016
778
  Object.assign({}, options, {
1017
779
  url: _getUrl(client, uri, useCdn)
1018
780
  })
1019
- );
1020
- const request = new Observable(
781
+ ), request = new Observable(
1021
782
  (subscriber) => httpRequest(reqOptions, config.requester).subscribe(subscriber)
1022
783
  );
1023
784
  return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request;
1024
785
  }
1025
786
  function _request(client, httpRequest, options) {
1026
- const observable = _requestObservable(client, httpRequest, options).pipe(
787
+ return _requestObservable(client, httpRequest, options).pipe(
1027
788
  filter((event) => event.type === "response"),
1028
789
  map((event) => event.body)
1029
790
  );
1030
- return observable;
1031
791
  }
1032
792
  function _getDataUrl(client, operation, path) {
1033
- const config = client.config();
1034
- const catalog = hasDataset(config);
1035
- const baseUri = "/".concat(operation, "/").concat(catalog);
1036
- const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1037
- return "/data".concat(uri).replace(/\/($|\?)/, "$1");
793
+ const config = client.config(), catalog = hasDataset(config), baseUri = `/${operation}/${catalog}`;
794
+ return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
1038
795
  }
1039
- function _getUrl(client, uri, canUseCdn = false) {
796
+ function _getUrl(client, uri, canUseCdn = !1) {
1040
797
  const { url, cdnUrl } = client.config();
1041
- const base = canUseCdn ? cdnUrl : url;
1042
- return "".concat(base, "/").concat(uri.replace(/^\//, ""));
798
+ return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
1043
799
  }
1044
800
  function _withAbortSignal(signal) {
1045
- return (input) => {
1046
- return new Observable((observer) => {
1047
- const abort = () => observer.error(_createAbortError(signal));
1048
- if (signal && signal.aborted) {
1049
- abort();
1050
- return;
1051
- }
1052
- const subscription = input.subscribe(observer);
1053
- signal.addEventListener("abort", abort);
1054
- return () => {
1055
- signal.removeEventListener("abort", abort);
1056
- subscription.unsubscribe();
1057
- };
1058
- });
1059
- };
801
+ return (input) => new Observable((observer) => {
802
+ const abort = () => observer.error(_createAbortError(signal));
803
+ if (signal && signal.aborted) {
804
+ abort();
805
+ return;
806
+ }
807
+ const subscription = input.subscribe(observer);
808
+ return signal.addEventListener("abort", abort), () => {
809
+ signal.removeEventListener("abort", abort), subscription.unsubscribe();
810
+ };
811
+ });
1060
812
  }
1061
- const isDomExceptionSupported = Boolean(globalThis.DOMException);
813
+ const isDomExceptionSupported = !!globalThis.DOMException;
1062
814
  function _createAbortError(signal) {
1063
815
  var _a, _b;
1064
- if (isDomExceptionSupported) {
816
+ if (isDomExceptionSupported)
1065
817
  return new DOMException((_a = signal == null ? void 0 : signal.reason) != null ? _a : "The operation was aborted.", "AbortError");
1066
- }
1067
818
  const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
1068
- error.name = "AbortError";
1069
- return error;
819
+ return error.name = "AbortError", error;
1070
820
  }
1071
-
1072
821
  var __accessCheck$4 = (obj, member, msg) => {
1073
822
  if (!member.has(obj))
1074
823
  throw TypeError("Cannot " + msg);
1075
- };
1076
- var __privateGet$4 = (obj, member, getter) => {
1077
- __accessCheck$4(obj, member, "read from private field");
1078
- return getter ? getter.call(obj) : member.get(obj);
1079
- };
1080
- var __privateAdd$4 = (obj, member, value) => {
824
+ }, __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) => {
1081
825
  if (member.has(obj))
1082
826
  throw TypeError("Cannot add the same private member more than once");
1083
827
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1084
- };
1085
- var __privateSet$4 = (obj, member, value, setter) => {
1086
- __accessCheck$4(obj, member, "write to private field");
1087
- setter ? setter.call(obj, value) : member.set(obj, value);
1088
- return value;
1089
- };
1090
- var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
828
+ }, __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;
1091
829
  class ObservableAssetsClient {
1092
830
  constructor(client, httpRequest) {
1093
- __privateAdd$4(this, _client$3, void 0);
1094
- __privateAdd$4(this, _httpRequest$4, void 0);
1095
- __privateSet$4(this, _client$3, client);
1096
- __privateSet$4(this, _httpRequest$4, httpRequest);
831
+ __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);
1097
832
  }
1098
833
  upload(assetType, body, options) {
1099
834
  return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
1100
835
  }
1101
836
  }
1102
- _client$3 = new WeakMap();
1103
- _httpRequest$4 = new WeakMap();
837
+ _client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
838
+ var _client2$3, _httpRequest2$4;
1104
839
  class AssetsClient {
1105
840
  constructor(client, httpRequest) {
1106
- __privateAdd$4(this, _client2$3, void 0);
1107
- __privateAdd$4(this, _httpRequest2$4, void 0);
1108
- __privateSet$4(this, _client2$3, client);
1109
- __privateSet$4(this, _httpRequest2$4, httpRequest);
841
+ __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);
1110
842
  }
1111
843
  upload(assetType, body, options) {
1112
- const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
844
+ const observable2 = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
1113
845
  return lastValueFrom(
1114
- observable.pipe(
846
+ observable2.pipe(
1115
847
  filter((event) => event.type === "response"),
1116
848
  map(
1117
849
  (event) => event.body.document
@@ -1120,19 +852,12 @@ class AssetsClient {
1120
852
  );
1121
853
  }
1122
854
  }
1123
- _client2$3 = new WeakMap();
1124
- _httpRequest2$4 = new WeakMap();
855
+ _client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
1125
856
  function _upload(client, httpRequest, assetType, body, opts = {}) {
1126
857
  validateAssetType(assetType);
1127
858
  let meta = opts.extract || void 0;
1128
- if (meta && !meta.length) {
1129
- meta = ["none"];
1130
- }
1131
- const dataset = hasDataset(client.config());
1132
- const assetEndpoint = assetType === "image" ? "images" : "files";
1133
- const options = optionsFromFile(opts, body);
1134
- const { tag, label, title, description, creditLine, filename, source } = options;
1135
- const query = {
859
+ meta && !meta.length && (meta = ["none"]);
860
+ const dataset2 = hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
1136
861
  label,
1137
862
  title,
1138
863
  description,
@@ -1140,102 +865,52 @@ function _upload(client, httpRequest, assetType, body, opts = {}) {
1140
865
  meta,
1141
866
  creditLine
1142
867
  };
1143
- if (source) {
1144
- query.sourceId = source.id;
1145
- query.sourceName = source.name;
1146
- query.sourceUrl = source.url;
1147
- }
1148
- return _requestObservable(client, httpRequest, {
868
+ return source && (query.sourceId = source.id, query.sourceName = source.name, query.sourceUrl = source.url), _requestObservable(client, httpRequest, {
1149
869
  tag,
1150
870
  method: "POST",
1151
871
  timeout: options.timeout || 0,
1152
- uri: "/assets/".concat(assetEndpoint, "/").concat(dataset),
872
+ uri: `/assets/${assetEndpoint}/${dataset2}`,
1153
873
  headers: options.contentType ? { "Content-Type": options.contentType } : {},
1154
874
  query,
1155
875
  body
1156
876
  });
1157
877
  }
1158
878
  function optionsFromFile(opts, file) {
1159
- if (typeof File === "undefined" || !(file instanceof File)) {
1160
- return opts;
1161
- }
1162
- return Object.assign(
879
+ return typeof File > "u" || !(file instanceof File) ? opts : Object.assign(
1163
880
  {
1164
- filename: opts.preserveFilename === false ? void 0 : file.name,
881
+ filename: opts.preserveFilename === !1 ? void 0 : file.name,
1165
882
  contentType: file.type
1166
883
  },
1167
884
  opts
1168
885
  );
1169
886
  }
1170
-
1171
- var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => {
1172
- target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
1173
- return target;
1174
- }, {});
1175
-
1176
- const pick = (obj, props) => props.reduce((selection, prop) => {
1177
- if (typeof obj[prop] === "undefined") {
1178
- return selection;
1179
- }
1180
- selection[prop] = obj[prop];
1181
- return selection;
1182
- }, {});
1183
-
1184
- const MAX_URL_LENGTH = 16e3 - 1200;
1185
- const possibleOptions = [
887
+ 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), {});
888
+ const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), MAX_URL_LENGTH = 14800, possibleOptions = [
1186
889
  "includePreviousRevision",
1187
890
  "includeResult",
1188
891
  "visibility",
1189
892
  "effectFormat",
1190
893
  "tag"
1191
- ];
1192
- const defaultOptions = {
1193
- includeResult: true
894
+ ], defaultOptions = {
895
+ includeResult: !0
1194
896
  };
1195
897
  function _listen(query, params, opts = {}) {
1196
- const { url, token, withCredentials, requestTagPrefix } = this.config();
1197
- const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag;
1198
- const options = { ...defaults(opts, defaultOptions), tag };
1199
- const listenOpts = pick(options, possibleOptions);
1200
- const qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } });
1201
- const uri = "".concat(url).concat(_getDataUrl(this, "listen", qs));
1202
- if (uri.length > MAX_URL_LENGTH) {
898
+ 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)}`;
899
+ if (uri.length > MAX_URL_LENGTH)
1203
900
  return new Observable((observer) => observer.error(new Error("Query too large for listener")));
1204
- }
1205
- const listenFor = options.events ? options.events : ["mutation"];
1206
- const shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
1207
- const esOptions = {};
1208
- if (token || withCredentials) {
1209
- esOptions.withCredentials = true;
1210
- }
1211
- if (token) {
1212
- esOptions.headers = {
1213
- Authorization: "Bearer ".concat(token)
1214
- };
1215
- }
1216
- return new Observable((observer) => {
901
+ const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1, esOptions = {};
902
+ return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
903
+ Authorization: `Bearer ${token}`
904
+ }), new Observable((observer) => {
1217
905
  let es;
1218
906
  getEventSource().then((eventSource) => {
1219
907
  es = eventSource;
1220
908
  }).catch((reason) => {
1221
- observer.error(reason);
1222
- stop();
909
+ observer.error(reason), stop();
1223
910
  });
1224
- let reconnectTimer;
1225
- let stopped = false;
911
+ let reconnectTimer, stopped = !1;
1226
912
  function onError() {
1227
- if (stopped) {
1228
- return;
1229
- }
1230
- emitReconnect();
1231
- if (stopped) {
1232
- return;
1233
- }
1234
- if (es.readyState === es.CLOSED) {
1235
- unsubscribe();
1236
- clearTimeout(reconnectTimer);
1237
- reconnectTimer = setTimeout(open, 100);
1238
- }
913
+ stopped || (emitReconnect(), !stopped && es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100)));
1239
914
  }
1240
915
  function onChannelError(err) {
1241
916
  observer.error(cooerceError(err));
@@ -1245,44 +920,27 @@ function _listen(query, params, opts = {}) {
1245
920
  return event instanceof Error ? observer.error(event) : observer.next(event);
1246
921
  }
1247
922
  function onDisconnect() {
1248
- stopped = true;
1249
- unsubscribe();
1250
- observer.complete();
923
+ stopped = !0, unsubscribe(), observer.complete();
1251
924
  }
1252
925
  function unsubscribe() {
1253
- if (!es)
1254
- return;
1255
- es.removeEventListener("error", onError);
1256
- es.removeEventListener("channelError", onChannelError);
1257
- es.removeEventListener("disconnect", onDisconnect);
1258
- listenFor.forEach((type) => es.removeEventListener(type, onMessage));
1259
- es.close();
926
+ es && (es.removeEventListener("error", onError), es.removeEventListener("channelError", onChannelError), es.removeEventListener("disconnect", onDisconnect), listenFor.forEach((type) => es.removeEventListener(type, onMessage)), es.close());
1260
927
  }
1261
928
  function emitReconnect() {
1262
- if (shouldEmitReconnect) {
1263
- observer.next({ type: "reconnect" });
1264
- }
929
+ shouldEmitReconnect && observer.next({ type: "reconnect" });
1265
930
  }
1266
931
  async function getEventSource() {
1267
- const { default: EventSource } = await import('@sanity/eventsource');
1268
- const evs = new EventSource(uri, esOptions);
1269
- evs.addEventListener("error", onError);
1270
- evs.addEventListener("channelError", onChannelError);
1271
- evs.addEventListener("disconnect", onDisconnect);
1272
- listenFor.forEach((type) => evs.addEventListener(type, onMessage));
1273
- return evs;
932
+ const { default: EventSource } = await import("@sanity/eventsource"), evs = new EventSource(uri, esOptions);
933
+ return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
1274
934
  }
1275
935
  function open() {
1276
936
  getEventSource().then((eventSource) => {
1277
937
  es = eventSource;
1278
938
  }).catch((reason) => {
1279
- observer.error(reason);
1280
- stop();
939
+ observer.error(reason), stop();
1281
940
  });
1282
941
  }
1283
942
  function stop() {
1284
- stopped = true;
1285
- unsubscribe();
943
+ stopped = !0, unsubscribe();
1286
944
  }
1287
945
  return stop;
1288
946
  });
@@ -1296,47 +954,25 @@ function parseEvent(event) {
1296
954
  }
1297
955
  }
1298
956
  function cooerceError(err) {
1299
- if (err instanceof Error) {
957
+ if (err instanceof Error)
1300
958
  return err;
1301
- }
1302
959
  const evt = parseEvent(err);
1303
960
  return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
1304
961
  }
1305
962
  function extractErrorMessage(err) {
1306
- if (!err.error) {
1307
- return err.message || "Unknown listener error";
1308
- }
1309
- if (err.error.description) {
1310
- return err.error.description;
1311
- }
1312
- return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
963
+ 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";
1313
964
  }
1314
-
1315
965
  var __accessCheck$3 = (obj, member, msg) => {
1316
966
  if (!member.has(obj))
1317
967
  throw TypeError("Cannot " + msg);
1318
- };
1319
- var __privateGet$3 = (obj, member, getter) => {
1320
- __accessCheck$3(obj, member, "read from private field");
1321
- return getter ? getter.call(obj) : member.get(obj);
1322
- };
1323
- var __privateAdd$3 = (obj, member, value) => {
968
+ }, __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) => {
1324
969
  if (member.has(obj))
1325
970
  throw TypeError("Cannot add the same private member more than once");
1326
971
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1327
- };
1328
- var __privateSet$3 = (obj, member, value, setter) => {
1329
- __accessCheck$3(obj, member, "write to private field");
1330
- setter ? setter.call(obj, value) : member.set(obj, value);
1331
- return value;
1332
- };
1333
- var _client$2, _httpRequest$3, _client2$2, _httpRequest2$3;
972
+ }, __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;
1334
973
  class ObservableDatasetsClient {
1335
974
  constructor(client, httpRequest) {
1336
- __privateAdd$3(this, _client$2, void 0);
1337
- __privateAdd$3(this, _httpRequest$3, void 0);
1338
- __privateSet$3(this, _client$2, client);
1339
- __privateSet$3(this, _httpRequest$3, httpRequest);
975
+ __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);
1340
976
  }
1341
977
  /**
1342
978
  * Create a new dataset with the given name
@@ -1344,8 +980,8 @@ class ObservableDatasetsClient {
1344
980
  * @param name - Name of the dataset to create
1345
981
  * @param options - Options for the dataset
1346
982
  */
1347
- create(name, options) {
1348
- return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name, options);
983
+ create(name2, options) {
984
+ return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name2, options);
1349
985
  }
1350
986
  /**
1351
987
  * Edit a dataset with the given name
@@ -1353,16 +989,16 @@ class ObservableDatasetsClient {
1353
989
  * @param name - Name of the dataset to edit
1354
990
  * @param options - New options for the dataset
1355
991
  */
1356
- edit(name, options) {
1357
- return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name, options);
992
+ edit(name2, options) {
993
+ return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name2, options);
1358
994
  }
1359
995
  /**
1360
996
  * Delete a dataset with the given name
1361
997
  *
1362
998
  * @param name - Name of the dataset to delete
1363
999
  */
1364
- delete(name) {
1365
- return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name);
1000
+ delete(name2) {
1001
+ return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name2);
1366
1002
  }
1367
1003
  /**
1368
1004
  * Fetch a list of datasets for the configured project
@@ -1374,14 +1010,11 @@ class ObservableDatasetsClient {
1374
1010
  });
1375
1011
  }
1376
1012
  }
1377
- _client$2 = new WeakMap();
1378
- _httpRequest$3 = new WeakMap();
1013
+ _client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
1014
+ var _client2$2, _httpRequest2$3;
1379
1015
  class DatasetsClient {
1380
1016
  constructor(client, httpRequest) {
1381
- __privateAdd$3(this, _client2$2, void 0);
1382
- __privateAdd$3(this, _httpRequest2$3, void 0);
1383
- __privateSet$3(this, _client2$2, client);
1384
- __privateSet$3(this, _httpRequest2$3, httpRequest);
1017
+ __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);
1385
1018
  }
1386
1019
  /**
1387
1020
  * Create a new dataset with the given name
@@ -1389,9 +1022,9 @@ class DatasetsClient {
1389
1022
  * @param name - Name of the dataset to create
1390
1023
  * @param options - Options for the dataset
1391
1024
  */
1392
- create(name, options) {
1025
+ create(name2, options) {
1393
1026
  return lastValueFrom(
1394
- _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options)
1027
+ _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name2, options)
1395
1028
  );
1396
1029
  }
1397
1030
  /**
@@ -1400,9 +1033,9 @@ class DatasetsClient {
1400
1033
  * @param name - Name of the dataset to edit
1401
1034
  * @param options - New options for the dataset
1402
1035
  */
1403
- edit(name, options) {
1036
+ edit(name2, options) {
1404
1037
  return lastValueFrom(
1405
- _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options)
1038
+ _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name2, options)
1406
1039
  );
1407
1040
  }
1408
1041
  /**
@@ -1410,8 +1043,8 @@ class DatasetsClient {
1410
1043
  *
1411
1044
  * @param name - Name of the dataset to delete
1412
1045
  */
1413
- delete(name) {
1414
- return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name));
1046
+ delete(name2) {
1047
+ return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name2));
1415
1048
  }
1416
1049
  /**
1417
1050
  * Fetch a list of datasets for the configured project
@@ -1422,46 +1055,29 @@ class DatasetsClient {
1422
1055
  );
1423
1056
  }
1424
1057
  }
1425
- _client2$2 = new WeakMap();
1426
- _httpRequest2$3 = new WeakMap();
1427
- function _modify(client, httpRequest, method, name, options) {
1428
- dataset(name);
1429
- return _request(client, httpRequest, {
1058
+ _client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
1059
+ function _modify(client, httpRequest, method, name2, options) {
1060
+ return dataset(name2), _request(client, httpRequest, {
1430
1061
  method,
1431
- uri: "/datasets/".concat(name),
1062
+ uri: `/datasets/${name2}`,
1432
1063
  body: options,
1433
1064
  tag: null
1434
1065
  });
1435
1066
  }
1436
-
1437
1067
  var __accessCheck$2 = (obj, member, msg) => {
1438
1068
  if (!member.has(obj))
1439
1069
  throw TypeError("Cannot " + msg);
1440
- };
1441
- var __privateGet$2 = (obj, member, getter) => {
1442
- __accessCheck$2(obj, member, "read from private field");
1443
- return getter ? getter.call(obj) : member.get(obj);
1444
- };
1445
- var __privateAdd$2 = (obj, member, value) => {
1070
+ }, __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) => {
1446
1071
  if (member.has(obj))
1447
1072
  throw TypeError("Cannot add the same private member more than once");
1448
1073
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1449
- };
1450
- var __privateSet$2 = (obj, member, value, setter) => {
1451
- __accessCheck$2(obj, member, "write to private field");
1452
- setter ? setter.call(obj, value) : member.set(obj, value);
1453
- return value;
1454
- };
1455
- var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
1074
+ }, __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;
1456
1075
  class ObservableProjectsClient {
1457
1076
  constructor(client, httpRequest) {
1458
- __privateAdd$2(this, _client$1, void 0);
1459
- __privateAdd$2(this, _httpRequest$2, void 0);
1460
- __privateSet$2(this, _client$1, client);
1461
- __privateSet$2(this, _httpRequest$2, httpRequest);
1077
+ __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);
1462
1078
  }
1463
1079
  list(options) {
1464
- const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
1080
+ const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
1465
1081
  return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
1466
1082
  }
1467
1083
  /**
@@ -1469,21 +1085,18 @@ class ObservableProjectsClient {
1469
1085
  *
1470
1086
  * @param projectId - ID of the project to fetch
1471
1087
  */
1472
- getById(projectId) {
1473
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: "/projects/".concat(projectId) });
1088
+ getById(projectId2) {
1089
+ return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
1474
1090
  }
1475
1091
  }
1476
- _client$1 = new WeakMap();
1477
- _httpRequest$2 = new WeakMap();
1092
+ _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
1093
+ var _client2$1, _httpRequest2$2;
1478
1094
  class ProjectsClient {
1479
1095
  constructor(client, httpRequest) {
1480
- __privateAdd$2(this, _client2$1, void 0);
1481
- __privateAdd$2(this, _httpRequest2$2, void 0);
1482
- __privateSet$2(this, _client2$1, client);
1483
- __privateSet$2(this, _httpRequest2$2, httpRequest);
1096
+ __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);
1484
1097
  }
1485
1098
  list(options) {
1486
- const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
1099
+ const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
1487
1100
  return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
1488
1101
  }
1489
1102
  /**
@@ -1491,40 +1104,24 @@ class ProjectsClient {
1491
1104
  *
1492
1105
  * @param projectId - ID of the project to fetch
1493
1106
  */
1494
- getById(projectId) {
1107
+ getById(projectId2) {
1495
1108
  return lastValueFrom(
1496
- _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: "/projects/".concat(projectId) })
1109
+ _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
1497
1110
  );
1498
1111
  }
1499
1112
  }
1500
- _client2$1 = new WeakMap();
1501
- _httpRequest2$2 = new WeakMap();
1502
-
1113
+ _client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
1503
1114
  var __accessCheck$1 = (obj, member, msg) => {
1504
1115
  if (!member.has(obj))
1505
1116
  throw TypeError("Cannot " + msg);
1506
- };
1507
- var __privateGet$1 = (obj, member, getter) => {
1508
- __accessCheck$1(obj, member, "read from private field");
1509
- return getter ? getter.call(obj) : member.get(obj);
1510
- };
1511
- var __privateAdd$1 = (obj, member, value) => {
1117
+ }, __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) => {
1512
1118
  if (member.has(obj))
1513
1119
  throw TypeError("Cannot add the same private member more than once");
1514
1120
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1515
- };
1516
- var __privateSet$1 = (obj, member, value, setter) => {
1517
- __accessCheck$1(obj, member, "write to private field");
1518
- setter ? setter.call(obj, value) : member.set(obj, value);
1519
- return value;
1520
- };
1521
- var _client, _httpRequest$1, _client2, _httpRequest2$1;
1121
+ }, __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;
1522
1122
  class ObservableUsersClient {
1523
1123
  constructor(client, httpRequest) {
1524
- __privateAdd$1(this, _client, void 0);
1525
- __privateAdd$1(this, _httpRequest$1, void 0);
1526
- __privateSet$1(this, _client, client);
1527
- __privateSet$1(this, _httpRequest$1, httpRequest);
1124
+ __privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
1528
1125
  }
1529
1126
  /**
1530
1127
  * Fetch a user by user ID
@@ -1535,18 +1132,15 @@ class ObservableUsersClient {
1535
1132
  return _request(
1536
1133
  __privateGet$1(this, _client),
1537
1134
  __privateGet$1(this, _httpRequest$1),
1538
- { uri: "/users/".concat(id) }
1135
+ { uri: `/users/${id}` }
1539
1136
  );
1540
1137
  }
1541
1138
  }
1542
- _client = new WeakMap();
1543
- _httpRequest$1 = new WeakMap();
1139
+ _client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
1140
+ var _client2, _httpRequest2$1;
1544
1141
  class UsersClient {
1545
1142
  constructor(client, httpRequest) {
1546
- __privateAdd$1(this, _client2, void 0);
1547
- __privateAdd$1(this, _httpRequest2$1, void 0);
1548
- __privateSet$1(this, _client2, client);
1549
- __privateSet$1(this, _httpRequest2$1, httpRequest);
1143
+ __privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
1550
1144
  }
1551
1145
  /**
1552
1146
  * Fetch a user by user ID
@@ -1556,68 +1150,38 @@ class UsersClient {
1556
1150
  getById(id) {
1557
1151
  return lastValueFrom(
1558
1152
  _request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
1559
- uri: "/users/".concat(id)
1153
+ uri: `/users/${id}`
1560
1154
  })
1561
1155
  );
1562
1156
  }
1563
1157
  }
1564
- _client2 = new WeakMap();
1565
- _httpRequest2$1 = new WeakMap();
1566
-
1158
+ _client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
1567
1159
  var __accessCheck = (obj, member, msg) => {
1568
1160
  if (!member.has(obj))
1569
1161
  throw TypeError("Cannot " + msg);
1570
- };
1571
- var __privateGet = (obj, member, getter) => {
1572
- __accessCheck(obj, member, "read from private field");
1573
- return getter ? getter.call(obj) : member.get(obj);
1574
- };
1575
- var __privateAdd = (obj, member, value) => {
1162
+ }, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
1576
1163
  if (member.has(obj))
1577
1164
  throw TypeError("Cannot add the same private member more than once");
1578
1165
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1579
- };
1580
- var __privateSet = (obj, member, value, setter) => {
1581
- __accessCheck(obj, member, "write to private field");
1582
- setter ? setter.call(obj, value) : member.set(obj, value);
1583
- return value;
1584
- };
1585
- var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1586
- const _ObservableSanityClient = class _ObservableSanityClient {
1166
+ }, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), _clientConfig, _httpRequest;
1167
+ const _ObservableSanityClient = class _ObservableSanityClient2 {
1587
1168
  constructor(httpRequest, config = defaultConfig) {
1588
- /**
1589
- * Private properties
1590
- */
1591
- __privateAdd(this, _clientConfig, void 0);
1592
- __privateAdd(this, _httpRequest, void 0);
1593
- /**
1594
- * Instance properties
1595
- */
1596
- this.listen = _listen;
1597
- this.config(config);
1598
- __privateSet(this, _httpRequest, httpRequest);
1599
- this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1600
- this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
1601
- this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
1602
- this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
1169
+ __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));
1603
1170
  }
1604
1171
  /**
1605
1172
  * Clone the client - returns a new instance
1606
1173
  */
1607
1174
  clone() {
1608
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
1175
+ return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
1609
1176
  }
1610
1177
  config(newConfig) {
1611
- if (newConfig === void 0) {
1178
+ if (newConfig === void 0)
1612
1179
  return { ...__privateGet(this, _clientConfig) };
1613
- }
1614
- if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === false) {
1180
+ if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
1615
1181
  throw new Error(
1616
1182
  "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
1617
1183
  );
1618
- }
1619
- __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
1620
- return this;
1184
+ return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
1621
1185
  }
1622
1186
  /**
1623
1187
  * Clone the client with a new (partial) configuration.
@@ -1626,12 +1190,12 @@ const _ObservableSanityClient = class _ObservableSanityClient {
1626
1190
  */
1627
1191
  withConfig(newConfig) {
1628
1192
  const thisConfig = this.config();
1629
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
1193
+ return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
1630
1194
  ...thisConfig,
1631
1195
  ...newConfig,
1632
1196
  stega: {
1633
1197
  ...thisConfig.stega || {},
1634
- ...typeof (newConfig == null ? void 0 : newConfig.stega) === "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
1198
+ ...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
1635
1199
  }
1636
1200
  });
1637
1201
  }
@@ -1726,48 +1290,27 @@ const _ObservableSanityClient = class _ObservableSanityClient {
1726
1290
  return _getDataUrl(this, operation, path);
1727
1291
  }
1728
1292
  };
1729
- _clientConfig = new WeakMap();
1730
- _httpRequest = new WeakMap();
1293
+ _clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
1731
1294
  let ObservableSanityClient = _ObservableSanityClient;
1732
- const _SanityClient = class _SanityClient {
1295
+ var _clientConfig2, _httpRequest2;
1296
+ const _SanityClient = class _SanityClient2 {
1733
1297
  constructor(httpRequest, config = defaultConfig) {
1734
- /**
1735
- * Private properties
1736
- */
1737
- __privateAdd(this, _clientConfig2, void 0);
1738
- __privateAdd(this, _httpRequest2, void 0);
1739
- /**
1740
- * Instance properties
1741
- */
1742
- this.listen = _listen;
1743
- this.config(config);
1744
- __privateSet(this, _httpRequest2, httpRequest);
1745
- this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
1746
- this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
1747
- this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
1748
- this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
1749
- this.observable = new ObservableSanityClient(httpRequest, config);
1298
+ __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);
1750
1299
  }
1751
1300
  /**
1752
1301
  * Clone the client - returns a new instance
1753
1302
  */
1754
1303
  clone() {
1755
- return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
1304
+ return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
1756
1305
  }
1757
1306
  config(newConfig) {
1758
- if (newConfig === void 0) {
1307
+ if (newConfig === void 0)
1759
1308
  return { ...__privateGet(this, _clientConfig2) };
1760
- }
1761
- if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1309
+ if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
1762
1310
  throw new Error(
1763
1311
  "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
1764
1312
  );
1765
- }
1766
- if (this.observable) {
1767
- this.observable.config(newConfig);
1768
- }
1769
- __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
1770
- return this;
1313
+ return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
1771
1314
  }
1772
1315
  /**
1773
1316
  * Clone the client with a new (partial) configuration.
@@ -1776,12 +1319,12 @@ const _SanityClient = class _SanityClient {
1776
1319
  */
1777
1320
  withConfig(newConfig) {
1778
1321
  const thisConfig = this.config();
1779
- return new _SanityClient(__privateGet(this, _httpRequest2), {
1322
+ return new _SanityClient2(__privateGet(this, _httpRequest2), {
1780
1323
  ...thisConfig,
1781
1324
  ...newConfig,
1782
1325
  stega: {
1783
1326
  ...thisConfig.stega || {},
1784
- ...typeof (newConfig == null ? void 0 : newConfig.stega) === "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
1327
+ ...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
1785
1328
  }
1786
1329
  });
1787
1330
  }
@@ -1899,29 +1442,21 @@ const _SanityClient = class _SanityClient {
1899
1442
  return _getDataUrl(this, operation, path);
1900
1443
  }
1901
1444
  };
1902
- _clientConfig2 = new WeakMap();
1903
- _httpRequest2 = new WeakMap();
1445
+ _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
1904
1446
  let SanityClient = _SanityClient;
1905
-
1906
1447
  function defineCreateClientExports(envMiddleware, ClassConstructor) {
1907
- const httpRequest = defineHttpRequest(envMiddleware, {});
1908
- const requester = httpRequest.defaultRequester;
1909
- const createClient = (config) => new ClassConstructor(
1448
+ return { requester: defineHttpRequest(envMiddleware, {}).defaultRequester, createClient: (config) => new ClassConstructor(
1910
1449
  defineHttpRequest(envMiddleware, {
1911
1450
  maxRetries: config.maxRetries,
1912
1451
  retryDelay: config.retryDelay
1913
1452
  }),
1914
1453
  config
1915
- );
1916
- return { requester, createClient };
1454
+ ) };
1917
1455
  }
1918
-
1919
- var name = "@sanity/client";
1920
- var version = "6.14.0";
1921
-
1456
+ var name = "@sanity/client", version = "6.14.2";
1922
1457
  const middleware = [
1923
- debug({ verbose: true, namespace: "sanity:client" }),
1924
- headers({ "User-Agent": "".concat(name, " ").concat(version) }),
1458
+ debug({ verbose: !0, namespace: "sanity:client" }),
1459
+ headers({ "User-Agent": `${name} ${version}` }),
1925
1460
  // Enable keep-alive, and in addition limit the number of sockets that can be opened.
1926
1461
  // This avoids opening too many connections to the server if someone tries to execute
1927
1462
  // a bunch of requests in parallel. It's recommended to have a concurrency limit
@@ -1931,11 +1466,26 @@ const middleware = [
1931
1466
  // We're currently matching the same defaults as browsers:
1932
1467
  // https://stackoverflow.com/questions/26003756/is-there-a-limit-practical-or-otherwise-to-the-number-of-web-sockets-a-page-op
1933
1468
  agent({
1934
- keepAlive: true,
1469
+ keepAlive: !0,
1935
1470
  maxSockets: 30,
1936
1471
  maxTotalSockets: 256
1937
1472
  })
1938
1473
  ];
1939
-
1940
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, b, defineCreateClientExports, middleware, printNoDefaultExport, vercelStegaCleanAll };
1941
- //# sourceMappingURL=nodeMiddleware-Me3HWLoB.js.map
1474
+ export {
1475
+ BasePatch,
1476
+ BaseTransaction,
1477
+ ClientError,
1478
+ ObservablePatch,
1479
+ ObservableSanityClient,
1480
+ ObservableTransaction,
1481
+ Patch,
1482
+ SanityClient,
1483
+ ServerError,
1484
+ Transaction,
1485
+ b,
1486
+ defineCreateClientExports,
1487
+ middleware,
1488
+ printNoDefaultExport,
1489
+ vercelStegaCleanAll
1490
+ };
1491
+ //# sourceMappingURL=nodeMiddleware-CrO2pNEp.js.map