@sanity/client 6.16.0 → 6.17.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +53 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +33 -0
- package/dist/index.browser.d.ts +33 -0
- package/dist/index.browser.js +53 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +54 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +54 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/SanityClient.ts +4 -0
- package/src/data/syncTags.ts +88 -0
- package/src/types.ts +22 -0
- package/umd/sanityClient.js +53 -2
- package/umd/sanityClient.min.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.17.1-canary.0",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@edge-runtime/vm": "^3.2.0",
|
|
127
127
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
128
128
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
129
|
-
"@sanity/pkg-utils": "^6.8.
|
|
129
|
+
"@sanity/pkg-utils": "^6.8.10",
|
|
130
130
|
"@types/json-diff": "^1.0.3",
|
|
131
131
|
"@types/node": "^20.8.8",
|
|
132
132
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
package/src/SanityClient.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {defaultConfig, initConfig} from './config'
|
|
|
5
5
|
import * as dataMethods from './data/dataMethods'
|
|
6
6
|
import {_listen} from './data/listen'
|
|
7
7
|
import {ObservablePatch, Patch} from './data/patch'
|
|
8
|
+
import {_syncTags} from './data/syncTags'
|
|
8
9
|
import {ObservableTransaction, Transaction} from './data/transaction'
|
|
9
10
|
import {DatasetsClient, ObservableDatasetsClient} from './datasets/DatasetsClient'
|
|
10
11
|
import {ObservableProjectsClient, ProjectsClient} from './projects/ProjectsClient'
|
|
@@ -41,6 +42,7 @@ import {ObservableUsersClient, UsersClient} from './users/UsersClient'
|
|
|
41
42
|
|
|
42
43
|
export type {
|
|
43
44
|
_listen,
|
|
45
|
+
_syncTags,
|
|
44
46
|
AssetsClient,
|
|
45
47
|
DatasetsClient,
|
|
46
48
|
ObservableAssetsClient,
|
|
@@ -68,6 +70,7 @@ export class ObservableSanityClient {
|
|
|
68
70
|
* Instance properties
|
|
69
71
|
*/
|
|
70
72
|
listen = _listen
|
|
73
|
+
syncTags = _syncTags
|
|
71
74
|
|
|
72
75
|
constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {
|
|
73
76
|
this.config(config)
|
|
@@ -713,6 +716,7 @@ export class SanityClient {
|
|
|
713
716
|
* Instance properties
|
|
714
717
|
*/
|
|
715
718
|
listen = _listen
|
|
719
|
+
syncTags = _syncTags
|
|
716
720
|
|
|
717
721
|
constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {
|
|
718
722
|
this.config(config)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {Observable} from 'rxjs'
|
|
2
|
+
|
|
3
|
+
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
4
|
+
import type {
|
|
5
|
+
SyncTagsChangeEvent,
|
|
6
|
+
SyncTagsErrorEvent,
|
|
7
|
+
SyncTagsOptions,
|
|
8
|
+
SyncTagsRestartEvent,
|
|
9
|
+
} from '../types'
|
|
10
|
+
import {_getDataUrl} from './dataMethods'
|
|
11
|
+
|
|
12
|
+
/** @public */
|
|
13
|
+
export function _syncTags(
|
|
14
|
+
this: SanityClient | ObservableSanityClient,
|
|
15
|
+
opts: SyncTagsOptions = {},
|
|
16
|
+
): Observable<SyncTagsChangeEvent | SyncTagsErrorEvent | SyncTagsRestartEvent> {
|
|
17
|
+
const path = _getDataUrl(this, 'sync-tags')
|
|
18
|
+
const url = new URL(this.getUrl(path, true))
|
|
19
|
+
if (opts.pos) {
|
|
20
|
+
url.searchParams.append('start', opts.pos)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return new Observable((observer) => {
|
|
24
|
+
const controller = new AbortController()
|
|
25
|
+
const {signal} = controller
|
|
26
|
+
fetch(url, {signal})
|
|
27
|
+
.then(async (res) => {
|
|
28
|
+
if (!res.body) {
|
|
29
|
+
throw new TypeError('Response body is not readable')
|
|
30
|
+
}
|
|
31
|
+
const reader = res.body
|
|
32
|
+
.pipeThrough(new TextDecoderStream())
|
|
33
|
+
.pipeThrough(splitStream('\n'))
|
|
34
|
+
.pipeThrough(parseJSON())
|
|
35
|
+
.getReader()
|
|
36
|
+
|
|
37
|
+
const results = {
|
|
38
|
+
[Symbol.asyncIterator]() {
|
|
39
|
+
return {
|
|
40
|
+
next: () => reader.read(),
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for await (const chunk of results) {
|
|
46
|
+
if (signal.aborted) break
|
|
47
|
+
if (chunk.type === 'error') {
|
|
48
|
+
observer.error(chunk)
|
|
49
|
+
break
|
|
50
|
+
}
|
|
51
|
+
observer.next(chunk)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
if (err?.name !== 'TimeoutError' && err?.name !== 'AbortError') {
|
|
56
|
+
observer.error(err)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
return () => {
|
|
60
|
+
controller.abort()
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function splitStream(splitOn: string) {
|
|
66
|
+
let buffer = ''
|
|
67
|
+
|
|
68
|
+
return new TransformStream({
|
|
69
|
+
transform(chunk, controller) {
|
|
70
|
+
buffer += chunk
|
|
71
|
+
const parts = buffer.split(splitOn)
|
|
72
|
+
parts.slice(0, -1).forEach((part) => controller.enqueue(part))
|
|
73
|
+
buffer = parts[parts.length - 1]
|
|
74
|
+
},
|
|
75
|
+
flush(controller) {
|
|
76
|
+
if (buffer) controller.enqueue(buffer)
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseJSON() {
|
|
82
|
+
return new TransformStream({
|
|
83
|
+
transform(chunk, controller) {
|
|
84
|
+
if (!chunk) return
|
|
85
|
+
controller.enqueue(JSON.parse(chunk))
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -381,6 +381,7 @@ export interface SanityProject {
|
|
|
381
381
|
maxRetentionDays?: number
|
|
382
382
|
members: SanityProjectMember[]
|
|
383
383
|
metadata: {
|
|
384
|
+
cliInitializedAt?: string
|
|
384
385
|
color?: string
|
|
385
386
|
externalStudioHost?: string
|
|
386
387
|
}
|
|
@@ -784,6 +785,7 @@ export interface RawQueryResponse<R> {
|
|
|
784
785
|
ms: number
|
|
785
786
|
result: R
|
|
786
787
|
resultSourceMap?: ContentSourceMap
|
|
788
|
+
syncTags?: `s1:${string}`[]
|
|
787
789
|
}
|
|
788
790
|
|
|
789
791
|
/** @public */
|
|
@@ -998,6 +1000,26 @@ export interface ContentSourceMap {
|
|
|
998
1000
|
paths: ContentSourceMapPaths
|
|
999
1001
|
}
|
|
1000
1002
|
|
|
1003
|
+
/** @public */
|
|
1004
|
+
export interface SyncTagsOptions {
|
|
1005
|
+
pos?: string
|
|
1006
|
+
}
|
|
1007
|
+
/** @public */
|
|
1008
|
+
export interface SyncTagsErrorEvent {
|
|
1009
|
+
type: 'error'
|
|
1010
|
+
status: number
|
|
1011
|
+
message: string
|
|
1012
|
+
}
|
|
1013
|
+
/** @public */
|
|
1014
|
+
export interface SyncTagsRestartEvent {
|
|
1015
|
+
type: 'restart'
|
|
1016
|
+
}
|
|
1017
|
+
/** @public */
|
|
1018
|
+
export interface SyncTagsChangeEvent {
|
|
1019
|
+
tags: `s1:${string}`[]
|
|
1020
|
+
pos: string
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1001
1023
|
export type {
|
|
1002
1024
|
ContentSourceMapParsedPath,
|
|
1003
1025
|
ContentSourceMapParsedPathKeyedSegment,
|
package/umd/sanityClient.js
CHANGED
|
@@ -2732,6 +2732,57 @@ ${selectionOpts}`);
|
|
|
2732
2732
|
function extractErrorMessage(err) {
|
|
2733
2733
|
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";
|
|
2734
2734
|
}
|
|
2735
|
+
function _syncTags(opts = {}) {
|
|
2736
|
+
const path = _getDataUrl(this, "sync-tags"), url = new URL(this.getUrl(path, !0));
|
|
2737
|
+
return opts.pos && url.searchParams.append("start", opts.pos), new Observable((observer) => {
|
|
2738
|
+
const controller = new AbortController(), { signal } = controller;
|
|
2739
|
+
return fetch(url, { signal }).then(async (res) => {
|
|
2740
|
+
if (!res.body)
|
|
2741
|
+
throw new TypeError("Response body is not readable");
|
|
2742
|
+
const reader = res.body.pipeThrough(new TextDecoderStream()).pipeThrough(splitStream(`
|
|
2743
|
+
`)).pipeThrough(parseJSON()).getReader(), results = {
|
|
2744
|
+
[Symbol.asyncIterator]() {
|
|
2745
|
+
return {
|
|
2746
|
+
next: () => reader.read()
|
|
2747
|
+
};
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
for await (const chunk of results) {
|
|
2751
|
+
if (signal.aborted)
|
|
2752
|
+
break;
|
|
2753
|
+
if (chunk.type === "error") {
|
|
2754
|
+
observer.error(chunk);
|
|
2755
|
+
break;
|
|
2756
|
+
}
|
|
2757
|
+
observer.next(chunk);
|
|
2758
|
+
}
|
|
2759
|
+
}).catch((err) => {
|
|
2760
|
+
(err == null ? void 0 : err.name) !== "TimeoutError" && (err == null ? void 0 : err.name) !== "AbortError" && observer.error(err);
|
|
2761
|
+
}), () => {
|
|
2762
|
+
controller.abort();
|
|
2763
|
+
};
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2766
|
+
function splitStream(splitOn) {
|
|
2767
|
+
let buffer = "";
|
|
2768
|
+
return new TransformStream({
|
|
2769
|
+
transform(chunk, controller) {
|
|
2770
|
+
buffer += chunk;
|
|
2771
|
+
const parts = buffer.split(splitOn);
|
|
2772
|
+
parts.slice(0, -1).forEach((part) => controller.enqueue(part)), buffer = parts[parts.length - 1];
|
|
2773
|
+
},
|
|
2774
|
+
flush(controller) {
|
|
2775
|
+
buffer && controller.enqueue(buffer);
|
|
2776
|
+
}
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
function parseJSON() {
|
|
2780
|
+
return new TransformStream({
|
|
2781
|
+
transform(chunk, controller) {
|
|
2782
|
+
chunk && controller.enqueue(JSON.parse(chunk));
|
|
2783
|
+
}
|
|
2784
|
+
});
|
|
2785
|
+
}
|
|
2735
2786
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
2736
2787
|
if (!member.has(obj))
|
|
2737
2788
|
throw TypeError("Cannot " + msg);
|
|
@@ -2936,7 +2987,7 @@ ${selectionOpts}`);
|
|
|
2936
2987
|
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
|
|
2937
2988
|
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
|
2938
2989
|
constructor(httpRequest, config = defaultConfig) {
|
|
2939
|
-
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(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));
|
|
2990
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), __publicField(this, "syncTags", _syncTags), 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));
|
|
2940
2991
|
}
|
|
2941
2992
|
/**
|
|
2942
2993
|
* Clone the client - returns a new instance
|
|
@@ -3065,7 +3116,7 @@ ${selectionOpts}`);
|
|
|
3065
3116
|
var _clientConfig2, _httpRequest2;
|
|
3066
3117
|
const _SanityClient = class _SanityClient2 {
|
|
3067
3118
|
constructor(httpRequest, config = defaultConfig) {
|
|
3068
|
-
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(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);
|
|
3119
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), __publicField(this, "syncTags", _syncTags), 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);
|
|
3069
3120
|
}
|
|
3070
3121
|
/**
|
|
3071
3122
|
* Clone the client - returns a new instance
|
package/umd/sanityClient.min.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
6
|
* Released under the MIT License.
|
|
7
|
-
*/;function F(e){return"[object Object]"===Object.prototype.toString.call(e)}const q=["boolean","string","number"];function N(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||D(t)||-1===q.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===F(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===F(r)||!1===r.hasOwnProperty("isPrototypeOf"))}(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function U(e){return{onResponse:e=>{const r=e.headers["content-type"]||"",n=-1!==r.indexOf("application/json");return e.body&&r&&n?Object.assign({},e,{body:t(e.body)}):e},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let W={};typeof globalThis<"u"?W=globalThis:typeof window<"u"?W=window:typeof global<"u"?W=global:typeof self<"u"&&(W=self);var L=W;function H(e={}){const t=e.implementation||L.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,r)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(r),()=>e.abort.publish())))}}var z=Object.defineProperty,B=(e,t,r)=>(((e,t,r)=>{t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class J{constructor(e){B(this,"__CANCEL__",!0),B(this,"message"),this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const G=class{constructor(e){if(B(this,"promise"),B(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new J(e),t(this.reason))}))}};B(G,"source",(()=>{let e;return{token:new G((t=>{e=t})),cancel:e}}));var V=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function Q(e){return 100*Math.pow(2,e)+100*Math.random()}const Y=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||Q,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,u=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!u(e,c,s)||c>=i)return e;var l;const h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(h)),a(c)),null}}})({shouldRetry:V,...e});Y.shouldRetry=V;var X=function(e,t){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},X(e,t)};function K(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}X(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))}function ee(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function te(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function re(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function ne(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function oe(e){return this instanceof oe?(this.v=e,this):new oe(e)}function se(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=o[e](t)).value instanceof oe?Promise.resolve(r.value.v).then(u,c):l(s[0][2],r)}catch(e){l(s[0][3],e)}var r}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ie(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=te(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function ae(e){return"function"==typeof e}function ue(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var ce=ue((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function le(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var he=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=te(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var u=this.initialTeardown;if(ae(u))try{u()}catch(e){o=e instanceof ce?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=te(c),h=l.next();!h.done;h=l.next()){var d=h.value;try{fe(d)}catch(e){o=null!=o?o:[],e instanceof ce?o=ne(ne([],re(o)),re(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new ce(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)fe(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&le(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&le(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function de(e){return e instanceof he||e&&"closed"in e&&ae(e.remove)&&ae(e.add)&&ae(e.unsubscribe)}function fe(e){ae(e)?e():e.unsubscribe()}he.EMPTY;var pe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ye={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,ne([e,t],re(r)))},clearTimeout:function(e){var t=ye.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function me(e){ye.setTimeout((function(){throw e}))}function ge(){}var be=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,de(t)&&t.add(r)):r.destination=Se,r}return K(t,e),t.create=function(e,t,r){return new Ee(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(he),ve=Function.prototype.bind;function we(e,t){return ve.call(e,t)}var Ce=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){xe(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){xe(e)}else xe(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){xe(e)}},e}(),Ee=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ae(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&pe.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&we(t.next,s),error:t.error&&we(t.error,s),complete:t.complete&&we(t.complete,s)}):o=t;return i.destination=new Ce(o),i}return K(t,e),t}(be);function xe(e){me(e)}var Se={closed:!0,next:ge,error:function(e){throw e},complete:ge},Te="function"==typeof Symbol&&Symbol.observable||"@@observable";function _e(e){return e}function Oe(e){return 0===e.length?_e:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var je=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof be||function(e){return e&&ae(e.next)&&ae(e.error)&&ae(e.complete)}(n)&&de(n)?e:new Ee(e,t,r);return function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))}(),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=$e(t))((function(t,n){var o=new Ee({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[Te]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Oe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=$e(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function $e(e){var t;return null!==(t=null!=e?e:pe.Promise)&&void 0!==t?t:Promise}function ke(e){return function(t){if(function(e){return ae(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function Ae(e,t,r,n,o){return new Pe(e,t,r,n,o)}var Pe=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return K(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(be);var Ie=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};var Re="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Me(e){if(e instanceof je)return e;if(null!=e){if(function(e){return ae(e[Te])}(e))return s=e,new je((function(e){var t=s[Te]();if(ae(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Ie(e))return o=e,new je((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(ae(null==(n=e)?void 0:n.then))return r=e,new je((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,me)}));if(function(e){return Symbol.asyncIterator&&ae(null==e?void 0:e[Symbol.asyncIterator])}(e))return De(e);if(function(e){return ae(null==e?void 0:e[Re])}(e))return t=e,new je((function(e){var r,n;try{for(var o=te(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(function(e){return ae(null==e?void 0:e.getReader)}(e))return De(function(e){return se(this,arguments,(function(){var t,r,n;return ee(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,oe(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,oe(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,oe(n)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e))}var t,r,n,o,s;throw function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(e)}function De(e){return new je((function(t){(function(e,t){var r,n,o,s;return Z(this,void 0,void 0,(function(){var i,a;return ee(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=ie(e),u.label=1;case 1:return[4,r.next()];case 2:if((n=u.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Fe(e,t){return Me(e)}var qe=ue((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ne(e,t){return new Promise((function(t,r){var n,o=!1;e.subscribe({next:function(e){n=e,o=!0},error:r,complete:function(){o?t(n):r(new qe)}})}))}function Ue(e,t){return ke((function(r,n){var o=0;r.subscribe(Ae(n,(function(r){n.next(e.call(t,r,o++))})))}))}var We=Array.isArray;function Le(e){return Ue((function(t){return function(e,t){return We(t)?e.apply(void 0,ne([],re(t))):e(t)}(e,t)}))}function He(e,t,r){t()}var ze=Array.isArray;function Be(e,t){return ke((function(r,n){var o=0;r.subscribe(Ae(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Je(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ae((t=e)[t.length-1])?e.pop():void 0;var t}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Oe(e)}(Je.apply(void 0,ne([],re(e))),Le(r)):ke((function(t,r){var n,o;(n=ne([t],re(function(e){return 1===e.length&&ze(e[0])?e[0]:e}(e))),void 0===o&&(o=_e),function(e){He(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){He(0,(function(){var a=Fe(n[t]),u=!1;a.subscribe(Ae(e,(function(n){r[t]=n,u||(u=!0,i--),i||e.next(o(r.slice()))}),(function(){--s||e.complete()})))}))},u=0;u<t;u++)a(u)}))})(r)}))}var Ge={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},Ve={0:8203,1:8204,2:8205,3:65279},Qe=new Array(4).fill(String.fromCodePoint(Ve[0])).join("");function Ye(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!!Number.isNaN(Number(e))&&!!Date.parse(e)}(e)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(e))?e:`${e}${function(e){let t=JSON.stringify(e);return`${Qe}${Array.from(t).map((e=>{let r=e.charCodeAt(0);if(r>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${t} on character ${e} (${r})`);return Array.from(r.toString(4).padStart(4,"0")).map((e=>String.fromCodePoint(Ve[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Ve).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Ge).map((e=>e.reverse())));var Xe=`${Object.values(Ge).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,Ke=new RegExp(`[${Xe}]{4,}`,"gu");function Ze(e){return JSON.parse(function(e){var t;return{cleaned:e.replace(Ke,""),encoded:(null==(t=e.match(Ke))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}var et=Object.defineProperty,tt=(e,t,r)=>(((e,t,r)=>{t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class rt extends Error{constructor(e){const t=ot(e);super(t.message),tt(this,"response"),tt(this,"statusCode",400),tt(this,"responseBody"),tt(this,"details"),Object.assign(this,t)}}class nt extends Error{constructor(e){const t=ot(e);super(t.message),tt(this,"response"),tt(this,"statusCode",500),tt(this,"responseBody"),tt(this,"details"),Object.assign(this,t)}}function ot(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:it(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return st(e)&&st(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?`:\n- ${n.join("\n- ")}`:"";return e.length>5&&(o+=`\n...and ${e.length-5} more`),r.message=`${t.error.description}${o}`,r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?` ${e.statusMessage}`:"";return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${t}`}(e),r)}function st(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function it(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const at={onResponse:e=>{if(e.statusCode>=500)throw new nt(e);if(e.statusCode>=400)throw new rt(e);return e}},ut={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function ct(e,t,r){if(0===r.maxRetries)return!1;const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||Y.shouldRetry(e,t,r)}function lt(e){if("string"==typeof e)return{id:e};if(Array.isArray(e))return{query:"*[_id in $ids]",params:{ids:e}};if("object"==typeof e&&null!==e&&"query"in e&&"string"==typeof e.query)return"params"in e&&"object"==typeof e.params&&null!==e.params?{query:e.query,params:e.params}:{query:e.query};const t=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error(`Unknown selection - must be one of:\n\n${t}`)}const ht=["image","file"],dt=["before","after","replace"],ft=e=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(e))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},pt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},yt=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error(`${e}(): "${t}" is not a valid document ID`)},mt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);yt(e,t._id)},gt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},bt=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};var vt,wt=Object.defineProperty,Ct=(e,t,r)=>(((e,t,r)=>{t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Et=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},xt=(e,t,r)=>(Et(e,t,"read from private field"),r?r.call(e):t.get(e)),St=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tt=(e,t,r,n)=>(Et(e,t,"write to private field"),t.set(e,r),r);class _t{constructor(e,t={}){Ct(this,"selection"),Ct(this,"operations"),this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return pt("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,t,r){return((e,t,r)=>{const n="insert(at, selector, items)";if(-1===dt.indexOf(e)){const e=dt.map((e=>`"${e}"`)).join(", ");throw new Error(`${n} takes an "at"-argument which is one of: ${e}`)}if("string"!=typeof t)throw new Error(`${n} takes a "selector"-argument which must be a string`);if(!Array.isArray(r))throw new Error(`${n} takes an "items"-argument which must be an array`)})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after",`${e}[-1]`,t)}prepend(e,t){return this.insert("before",`${e}[0]`,t)}splice(e,t,r,n){const o=t<0?t-1:t,s=typeof r>"u"||-1===r?-1:Math.max(0,t+r),i=`${e}[${o}:${o<0&&s>=0?"":s}]`;return this.insert("replace",i,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...lt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return pt(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},r&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}vt=new WeakMap;let Ot=class e extends _t{constructor(e,t,r){super(e,t),St(this,vt,void 0),Tt(this,vt,r)}clone(){return new e(this.selection,{...this.operations},xt(this,vt))}commit(e){if(!xt(this,vt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return xt(this,vt).mutate({patch:this.serialize()},r)}};var jt;jt=new WeakMap;let $t=class e extends _t{constructor(e,t,r){super(e,t),St(this,jt,void 0),Tt(this,jt,r)}clone(){return new e(this.selection,{...this.operations},xt(this,jt))}commit(e){if(!xt(this,jt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return xt(this,jt).mutate({patch:this.serialize()},r)}};var kt=Object.defineProperty,At=(e,t,r)=>(((e,t,r)=>{t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Pt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},It=(e,t,r)=>(Pt(e,t,"read from private field"),r?r.call(e):t.get(e)),Rt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Mt=(e,t,r,n)=>(Pt(e,t,"write to private field"),t.set(e,r),r);const Dt={returnDocuments:!1};class Ft{constructor(e=[],t){At(this,"operations"),At(this,"trxId"),this.operations=e,this.trxId=t}create(e){return pt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return pt(t,e),mt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return pt(t,e),mt(t,e),this._add({[t]:e})}delete(e){return yt("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}var qt;qt=new WeakMap;let Nt=class e extends Ft{constructor(e,t,r){super(e,r),Rt(this,qt,void 0),Mt(this,qt,t)}clone(){return new e([...this.operations],It(this,qt),this.trxId)}commit(e){if(!It(this,qt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return It(this,qt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Dt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof $t)return this._add({patch:e.serialize()});if(r){const r=t(new $t(e,{},It(this,qt)));if(!(r instanceof $t))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};var Ut;Ut=new WeakMap;let Wt=class e extends Ft{constructor(e,t,r){super(e,r),Rt(this,Ut,void 0),Mt(this,Ut,t)}clone(){return new e([...this.operations],It(this,Ut),this.trxId)}commit(e){if(!It(this,Ut))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return It(this,Ut).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Dt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Ot)return this._add({patch:e.serialize()});if(r){const r=t(new Ot(e,{},It(this,Ut)));if(!(r instanceof Ot))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};function Lt(e){return"https://www.sanity.io/help/"+e}const Ht=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),zt=Ht(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),Bt=Ht(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),Jt=Ht(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Lt("js-client-browser-token")} for more information and how to hide this warning.`]),Gt=Ht(["Using the Sanity client without specifying an API version is deprecated.",`See ${Lt("js-client-api-version")}`]),Vt=Ht(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Qt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Yt=["localhost","127.0.0.1","0.0.0.0"];const Xt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},Kt=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Qt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Gt();const n={...Qt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=Lt("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${e}`)}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&Xt(n.perspective),"encodeSourceMap"in n)throw new Error("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'?");if("encodeSourceMapAtPath"in n)throw new Error("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'?");if("boolean"!=typeof n.stega.enabled)throw new Error(`stega.enabled must be a boolean, received ${n.stega.enabled}`);if(n.stega.enabled&&void 0===n.stega.studioUrl)throw new Error("stega.studioUrl must be defined when stega.enabled is true");if(n.stega.enabled&&"string"!=typeof n.stega.studioUrl&&"function"!=typeof n.stega.studioUrl)throw new Error(`stega.studioUrl must be a string or a function, received ${n.stega.studioUrl}`);const s=typeof window<"u"&&window.location&&window.location.hostname,i=s&&(e=>-1!==Yt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Jt():typeof n.useCdn>"u"&&zt(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&ft(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?bt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Qt.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),u=a[0],c=a[1],l=n.isDefaultApi?"apicdn.sanity.io":c;return n.useProjectHostname?(n.url=`${u}://${n.projectId}.${c}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n},Zt="X-Sanity-Project-ID";const er=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,returnQuery:s,...i}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(i))t&&n.append(e,`${t}`);return!1===s&&n.append("returnQuery","false"),`?${n}`},tr=(e={})=>{return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:typeof t>"u"?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},rr=e=>"response"===e.type,nr=e=>e.body,or=11264;function sr(e,t,r,n,o={},s={}){const i="stega"in s?{...r||{},..."boolean"==typeof s.stega?{enabled:s.stega}:s.stega||{}}:r,a=i.enabled?function(e){try{return Ze(e)}catch{return e}}(o):o,u=!1===s.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},d=dr(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...h,fetch:{cache:c,next:l}}:h);return i.enabled?d.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Je.apply(void 0,ne([],re(e)))}(Fe(Promise.resolve().then((function(){return Gn})).then((function(e){return e.a})).then((({stegaEncodeSourceMap:e})=>e)))),Ue((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):d.pipe(Ue(u))}function ir(e,t,r,n={}){return pr(e,t,{uri:mr(e,"doc",r),json:!0,tag:n.tag}).pipe(Be(rr),Ue((e=>e.body.documents&&e.body.documents[0])))}function ar(e,t,r,n={}){return pr(e,t,{uri:mr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Be(rr),Ue((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function ur(e,t,r,n){return mt("createIfNotExists",r),fr(e,t,r,"createIfNotExists",n)}function cr(e,t,r,n){return mt("createOrReplace",r),fr(e,t,r,"createOrReplace",n)}function lr(e,t,r,n){return dr(e,t,"mutate",{mutations:[{delete:lt(r)}]},n)}function hr(e,t,r,n){let o;o=r instanceof $t||r instanceof Ot?{patch:r.serialize()}:r instanceof Nt||r instanceof Wt?r.serialize():r;return dr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function dr(e,t,r,n,o={}){const s="mutate"===r,i="query"===r,a=s?"":er(n),u=!s&&a.length<or,c=u?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p,returnQuery:y}=o;return pr(e,t,{method:u?"GET":"POST",uri:mr(e,r,c),json:!0,body:u?void 0:n,query:s&&tr(o),timeout:h,headers:p,token:d,tag:f,returnQuery:y,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Be(rr),Ue(nr),Ue((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function fr(e,t,r,n,o={}){return dr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function pr(e,t,r){var n,o;const s=r.url||r.uri,i=e.config(),a=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/"):r.canUseCdn;let u=(null!=(n=r.useCdn)?n:i.useCdn)&&a;const c=r.tag&&i.requestTagPrefix?[i.requestTagPrefix,r.tag].join("."):r.tag||i.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:bt(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/query/")){const e=null!=(o=r.resultSourceMap)?o:i.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||i.perspective;"string"==typeof t&&"raw"!==t&&(Xt(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Bt())),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query})}const l=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r[Zt]=e.projectId);const o=!!(typeof t.withCredentials>"u"?e.token||e.withCredentials:t.withCredentials),s=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof s>"u"?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(i,Object.assign({},r,{url:gr(e,s,u)})),h=new je((e=>t(l,i.requester).subscribe(e)));return r.signal?h.pipe((d=r.signal,e=>new je((t=>{const r=()=>t.error(function(e){var t,r;if(br)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const n=new Error(null!=(r=null==e?void 0:e.reason)?r:"The operation was aborted.");return n.name="AbortError",n}(d));if(d&&d.aborted)return void r();const n=e.subscribe(t);return d.addEventListener("abort",r),()=>{d.removeEventListener("abort",r),n.unsubscribe()}})))):h;var d}function yr(e,t,r){return pr(e,t,r).pipe(Be((e=>"response"===e.type)),Ue((e=>e.body)))}function mr(e,t,r){const n=e.config(),o=`/${t}/${gt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function gr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const br=!!globalThis.DOMException;var vr,wr,Cr,Er,xr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Sr=(e,t,r)=>(xr(e,t,"read from private field"),r?r.call(e):t.get(e)),Tr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},_r=(e,t,r,n)=>(xr(e,t,"write to private field"),t.set(e,r),r);class Or{constructor(e,t){Tr(this,vr,void 0),Tr(this,wr,void 0),_r(this,vr,e),_r(this,wr,t)}upload(e,t,r){return $r(Sr(this,vr),Sr(this,wr),e,t,r)}}vr=new WeakMap,wr=new WeakMap;class jr{constructor(e,t){Tr(this,Cr,void 0),Tr(this,Er,void 0),_r(this,Cr,e),_r(this,Er,t)}upload(e,t,r){return Ne($r(Sr(this,Cr),Sr(this,Er),e,t,r).pipe(Be((e=>"response"===e.type)),Ue((e=>e.body.document))))}}function $r(e,t,r,n,o={}){(e=>{if(-1===ht.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${ht.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=gt(e.config()),a="image"===r?"images":"files",u=function(e,t){return typeof File>"u"||!(t instanceof File)?e:Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:c,label:l,title:h,description:d,creditLine:f,filename:p,source:y}=u,m={label:l,title:h,description:d,filename:p,meta:s,creditLine:f};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.sourceUrl=y.url),pr(e,t,{tag:c,method:"POST",timeout:u.timeout||0,uri:`/assets/${a}/${i}`,headers:u.contentType?{"Content-Type":u.contentType}:{},query:m,body:n})}Cr=new WeakMap,Er=new WeakMap;const kr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Ar={includeResult:!0};function Pr(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,u={...(h=r,d=Ar,Object.keys(d).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?d[t]:h[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,kr),l=`${n}${mr(this,"listen",er({query:e,params:t,options:{tag:a,...c}}))}`;var h,d;if(l.length>14800)return new je((e=>e.error(new Error("Query too large for listener"))));const f=u.events?u.events:["mutation"],p=-1!==f.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new je((e=>{let t;c().then((e=>{t=e})).catch((t=>{e.error(t),d()}));let r,n=!1;function o(){n||(p&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(u(),clearTimeout(r),r=setTimeout(h,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=Ir(e);return t instanceof Error?t:new Error(function(e){return e.error?e.error.description?e.error.description:"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2):e.message||"Unknown listener error"}(t))}(t))}function i(t){const r=Ir(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,u(),e.complete()}function u(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),f.forEach((e=>t.removeEventListener(e,i))),t.close())}async function c(){const{default:e}=await Promise.resolve().then((function(){return Kn})),t=new e(l,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),f.forEach((e=>t.addEventListener(e,i))),t}function h(){c().then((e=>{t=e})).catch((t=>{e.error(t),d()}))}function d(){n=!0,u()}return d}))}function Ir(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var Rr,Mr,Dr,Fr,qr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Nr=(e,t,r)=>(qr(e,t,"read from private field"),r?r.call(e):t.get(e)),Ur=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Wr=(e,t,r,n)=>(qr(e,t,"write to private field"),t.set(e,r),r);class Lr{constructor(e,t){Ur(this,Rr,void 0),Ur(this,Mr,void 0),Wr(this,Rr,e),Wr(this,Mr,t)}create(e,t){return zr(Nr(this,Rr),Nr(this,Mr),"PUT",e,t)}edit(e,t){return zr(Nr(this,Rr),Nr(this,Mr),"PATCH",e,t)}delete(e){return zr(Nr(this,Rr),Nr(this,Mr),"DELETE",e)}list(){return yr(Nr(this,Rr),Nr(this,Mr),{uri:"/datasets",tag:null})}}Rr=new WeakMap,Mr=new WeakMap;class Hr{constructor(e,t){Ur(this,Dr,void 0),Ur(this,Fr,void 0),Wr(this,Dr,e),Wr(this,Fr,t)}create(e,t){return Ne(zr(Nr(this,Dr),Nr(this,Fr),"PUT",e,t))}edit(e,t){return Ne(zr(Nr(this,Dr),Nr(this,Fr),"PATCH",e,t))}delete(e){return Ne(zr(Nr(this,Dr),Nr(this,Fr),"DELETE",e))}list(){return Ne(yr(Nr(this,Dr),Nr(this,Fr),{uri:"/datasets",tag:null}))}}function zr(e,t,r,n,o){return ft(n),yr(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Dr=new WeakMap,Fr=new WeakMap;var Br,Jr,Gr,Vr,Qr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Yr=(e,t,r)=>(Qr(e,t,"read from private field"),r?r.call(e):t.get(e)),Xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Kr=(e,t,r,n)=>(Qr(e,t,"write to private field"),t.set(e,r),r);class Zr{constructor(e,t){Xr(this,Br,void 0),Xr(this,Jr,void 0),Kr(this,Br,e),Kr(this,Jr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return yr(Yr(this,Br),Yr(this,Jr),{uri:t})}getById(e){return yr(Yr(this,Br),Yr(this,Jr),{uri:`/projects/${e}`})}}Br=new WeakMap,Jr=new WeakMap;class en{constructor(e,t){Xr(this,Gr,void 0),Xr(this,Vr,void 0),Kr(this,Gr,e),Kr(this,Vr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ne(yr(Yr(this,Gr),Yr(this,Vr),{uri:t}))}getById(e){return Ne(yr(Yr(this,Gr),Yr(this,Vr),{uri:`/projects/${e}`}))}}Gr=new WeakMap,Vr=new WeakMap;var tn,rn,nn,on,sn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},an=(e,t,r)=>(sn(e,t,"read from private field"),r?r.call(e):t.get(e)),un=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},cn=(e,t,r,n)=>(sn(e,t,"write to private field"),t.set(e,r),r);class ln{constructor(e,t){un(this,tn,void 0),un(this,rn,void 0),cn(this,tn,e),cn(this,rn,t)}getById(e){return yr(an(this,tn),an(this,rn),{uri:`/users/${e}`})}}tn=new WeakMap,rn=new WeakMap;class hn{constructor(e,t){un(this,nn,void 0),un(this,on,void 0),cn(this,nn,e),cn(this,on,t)}getById(e){return Ne(yr(an(this,nn),an(this,on),{uri:`/users/${e}`}))}}nn=new WeakMap,on=new WeakMap;var dn,fn,pn=Object.defineProperty,yn=(e,t,r)=>(((e,t,r)=>{t in e?pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),mn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},gn=(e,t,r)=>(mn(e,t,"read from private field"),r?r.call(e):t.get(e)),bn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},vn=(e,t,r,n)=>(mn(e,t,"write to private field"),t.set(e,r),r);dn=new WeakMap,fn=new WeakMap;let wn=class e{constructor(e,t=Qt){yn(this,"assets"),yn(this,"datasets"),yn(this,"projects"),yn(this,"users"),bn(this,dn,void 0),bn(this,fn,void 0),yn(this,"listen",Pr),this.config(t),vn(this,fn,e),this.assets=new Or(this,gn(this,fn)),this.datasets=new Lr(this,gn(this,fn)),this.projects=new Zr(this,gn(this,fn)),this.users=new ln(this,gn(this,fn))}clone(){return new e(gn(this,fn),this.config())}config(e){if(void 0===e)return{...gn(this,dn)};if(gn(this,dn)&&!1===gn(this,dn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return vn(this,dn,Kt(e,gn(this,dn)||{})),this}withConfig(t){const r=this.config();return new e(gn(this,fn),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return sr(this,gn(this,fn),gn(this,dn).stega,e,t,r)}getDocument(e,t){return ir(this,gn(this,fn),e,t)}getDocuments(e,t){return ar(this,gn(this,fn),e,t)}create(e,t){return fr(this,gn(this,fn),e,"create",t)}createIfNotExists(e,t){return ur(this,gn(this,fn),e,t)}createOrReplace(e,t){return cr(this,gn(this,fn),e,t)}delete(e,t){return lr(this,gn(this,fn),e,t)}mutate(e,t){return hr(this,gn(this,fn),e,t)}patch(e,t){return new Ot(e,t,this)}transaction(e){return new Wt(e,this)}request(e){return yr(this,gn(this,fn),e)}getUrl(e,t){return gr(this,e,t)}getDataUrl(e,t){return mr(this,e,t)}};var Cn,En;Cn=new WeakMap,En=new WeakMap;let xn=class e{constructor(e,t=Qt){yn(this,"assets"),yn(this,"datasets"),yn(this,"projects"),yn(this,"users"),yn(this,"observable"),bn(this,Cn,void 0),bn(this,En,void 0),yn(this,"listen",Pr),this.config(t),vn(this,En,e),this.assets=new jr(this,gn(this,En)),this.datasets=new Hr(this,gn(this,En)),this.projects=new en(this,gn(this,En)),this.users=new hn(this,gn(this,En)),this.observable=new wn(e,t)}clone(){return new e(gn(this,En),this.config())}config(e){if(void 0===e)return{...gn(this,Cn)};if(gn(this,Cn)&&!1===gn(this,Cn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),vn(this,Cn,Kt(e,gn(this,Cn)||{})),this}withConfig(t){const r=this.config();return new e(gn(this,En),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return Ne(sr(this,gn(this,En),gn(this,Cn).stega,e,t,r))}getDocument(e,t){return Ne(ir(this,gn(this,En),e,t))}getDocuments(e,t){return Ne(ar(this,gn(this,En),e,t))}create(e,t){return Ne(fr(this,gn(this,En),e,"create",t))}createIfNotExists(e,t){return Ne(ur(this,gn(this,En),e,t))}createOrReplace(e,t){return Ne(cr(this,gn(this,En),e,t))}delete(e,t){return Ne(lr(this,gn(this,En),e,t))}mutate(e,t){return Ne(hr(this,gn(this,En),e,t))}patch(e,t){return new $t(e,t,this)}transaction(e){return new Nt(e,this)}request(e){return Ne(yr(this,gn(this,En),e))}dataRequest(e,t,r){return Ne(dr(this,gn(this,En),e,t,r))}getUrl(e,t){return gr(this,e,t)}getDataUrl(e,t){return mr(this,e,t)}};const Sn=function(e,t){const r=function(e){return k([Y({shouldRetry:ct}),...e,ut,N(),U(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},at,H({implementation:je})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],xn),Tn=Sn.requester,_n=Sn.createClient,On=(jn=_n,function(e){return Vt(),jn(e)});var jn;const $n=/_key\s*==\s*['"](.*)['"]/;function kn(e){if(!Array.isArray(e))throw new Error("Path is not an array");return e.reduce(((e,t,r)=>{const n=typeof t;if("number"===n)return`${e}[${t}]`;if("string"===n)return`${e}${0===r?"":"."}${t}`;if(function(e){return"string"==typeof e?$n.test(e.trim()):"object"==typeof e&&"_key"in e}(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){const[r,n]=t;return`${e}[${r}:${n}]`}throw new Error(`Unsupported path segment \`${JSON.stringify(t)}\``)}),"")}const An={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},Pn={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function In(e){const t=[],r=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;let n;for(;null!==(n=r.exec(e));)if(void 0===n[1])if(void 0===n[2])if(void 0===n[3]);else{const e=n[3].replace(/\\(\\')/g,(e=>Pn[e]));t.push({_key:e,_index:-1})}else t.push(parseInt(n[2],10));else{const e=n[1].replace(/\\(\\|f|n|r|t|')/g,(e=>Pn[e]));t.push(e)}return t}function Rn(e){return e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(""!==e._key)return{_key:e._key};if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)}))}function Mn(e,t){if(null==t||!t.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>An[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>An[e]))}')]`:`[${e._index}]`)).join("")}`}(e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)})));if(void 0!==t.mappings[r])return{mapping:t.mappings[r],matchedPath:r,pathSuffix:""};const n=Object.entries(t.mappings).filter((([e])=>r.startsWith(e))).sort((([e],[t])=>t.length-e.length));if(0==n.length)return;const[o,s]=n[0];return{mapping:s,matchedPath:o,pathSuffix:r.substring(o.length)}}function Dn(e){return"object"==typeof e&&null!==e}function Fn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Dn(e)){const o=e._key;if("string"==typeof o)return Fn(e,t,r.concat({_key:o,_index:n}))}return Fn(e,t,r.concat(n))})):Dn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,Fn(n,t,r.concat(e))]))):t(e,r)}function qn(e,t,r){return Fn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Mn(n,t);if(!o)return e;const{mapping:s,matchedPath:i}=o;if("value"!==s.type||"documentValue"!==s.source.type)return e;const a=t.documents[s.source.document],u=t.paths[s.source.path],c=In(i),l=In(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Nn="drafts.";function Un(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:u}=e;if(!t)throw new Error("baseUrl is required");if(!i)throw new Error("path is required");if(!o)throw new Error("id is required");if("/"!==t&&t.endsWith("/"))throw new Error("baseUrl must not end with a slash");const c="default"===r?void 0:r,l="default"===n?void 0:n,h=function(e){return e.startsWith(Nn)?e.slice(Nn.length):e}(o),d=Array.isArray(i)?kn(Rn(i)):i,f=new URLSearchParams({baseUrl:t,id:h,type:s,path:d});c&&f.set("workspace",c),l&&f.set("tool",l),a&&f.set("projectId",a),u&&f.set("dataset",u),o.startsWith(Nn)&&f.set("isDraft","");const p=["/"===t?"":t];c&&p.push(c);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),p.push("intent","edit",`${y.join(";")}?${f}`),p.join("/")}const Wn=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(r))return!1;var n;const o=e.at(-1);return!("slug"===e.at(-2)&&"current"===o||"string"==typeof o&&o.startsWith("_")||"number"==typeof o&&"marks"===e.at(-2)||"href"===o&&"number"==typeof e.at(-2)&&"markDefs"===e.at(-3)||"style"===o||"listItem"===o||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||Hn(e)||Hn(t)||"string"==typeof o&&Ln.has(o))},Ln=new Set(["color","colour","currency","email","format","gid","hex","href","hsl","hsla","icon","id","index","key","language","layout","link","linkAction","locale","lqip","page","path","ref","rgb","rgba","route","secret","slug","status","tag","template","theme","type","unit","url","username","variant","website"]);function Hn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function zn(e,t,r){var n,o,s,i,a,u,c,l,h;const{filter:d,logger:f,enabled:p}=r;if(!p){const o="config.enabled must be true, don't call this function otherwise";throw null==(n=null==f?void 0:f.error)||n.call(f,`[@sanity/client]: ${o}`,{result:e,resultSourceMap:t,config:r}),new TypeError(o)}if(!t)return null==(o=null==f?void 0:f.error)||o.call(f,"[@sanity/client]: Missing Content Source Map from response body",{result:e,resultSourceMap:t,config:r}),e;if(!r.studioUrl){const n="config.studioUrl must be defined";throw null==(s=null==f?void 0:f.error)||s.call(f,`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const y={encoded:[],skipped:[]},m=qn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof d?d({sourcePath:e,resultPath:n,filterDefault:Wn,sourceDocument:t,value:o}):Wn({sourcePath:e,resultPath:n,filterDefault:Wn,sourceDocument:t,value:o})))return f&&y.skipped.push({path:Bn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;f&&y.encoded.push({path:Bn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length});const{baseUrl:s,workspace:i,tool:a}=function(e){let t="string"==typeof e?e:e.baseUrl;return"/"!==t&&(t=t.replace(/\/$/,"")),"string"==typeof e?{baseUrl:t}:{...e,baseUrl:t}}("function"==typeof r.studioUrl?r.studioUrl(t):r.studioUrl);if(!s)return o;const{_id:u,_type:c,_projectId:l,_dataset:h}=t;return Ye(o,{origin:"sanity.io",href:Un({baseUrl:s,workspace:i,tool:a,id:u,type:c,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:h,projectId:l}})},!1)}));if(f){const e=y.skipped.length,t=y.encoded.length;if((e||t)&&(null==(i=(null==f?void 0:f.groupCollapsed)||f.log)||i("[@sanity/client]: Encoding source map into result"),null==(a=f.log)||a.call(f,`[@sanity/client]: Paths encoded: ${y.encoded.length}, skipped: ${y.skipped.length}`)),y.encoded.length>0&&(null==(u=null==f?void 0:f.log)||u.call(f,"[@sanity/client]: Table of encoded paths"),null==(c=(null==f?void 0:f.table)||f.log)||c(y.encoded)),y.skipped.length>0){const e=new Set;for(const{path:t}of y.skipped)e.add(t.replace($n,"0").replace(/\[\d+\]/g,"[]"));null==(l=null==f?void 0:f.log)||l.call(f,"[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&(null==(h=null==f?void 0:f.groupEnd)||h.call(f))}return m}function Bn(e){return kn(Rn(e))}var Jn=Object.freeze({__proto__:null,stegaEncodeSourceMap:zn}),Gn=Object.freeze({__proto__:null,a:Jn,e:qn,s:zn}),Vn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Qn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yn={exports:{}};
|
|
7
|
+
*/;function F(e){return"[object Object]"===Object.prototype.toString.call(e)}const q=["boolean","string","number"];function N(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||D(t)||-1===q.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===F(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===F(r)||!1===r.hasOwnProperty("isPrototypeOf"))}(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function U(e){return{onResponse:e=>{const r=e.headers["content-type"]||"",n=-1!==r.indexOf("application/json");return e.body&&r&&n?Object.assign({},e,{body:t(e.body)}):e},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let W={};typeof globalThis<"u"?W=globalThis:typeof window<"u"?W=window:typeof global<"u"?W=global:typeof self<"u"&&(W=self);var L=W;function H(e={}){const t=e.implementation||L.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,r)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(r),()=>e.abort.publish())))}}var z=Object.defineProperty,B=(e,t,r)=>(((e,t,r)=>{t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class J{constructor(e){B(this,"__CANCEL__",!0),B(this,"message"),this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const G=class{constructor(e){if(B(this,"promise"),B(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new J(e),t(this.reason))}))}};B(G,"source",(()=>{let e;return{token:new G((t=>{e=t})),cancel:e}}));var V=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function Q(e){return 100*Math.pow(2,e)+100*Math.random()}const Y=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||Q,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,u=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!u(e,c,s)||c>=i)return e;var l;const h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(h)),a(c)),null}}})({shouldRetry:V,...e});Y.shouldRetry=V;var X=function(e,t){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},X(e,t)};function K(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}X(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))}function ee(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function te(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function re(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function ne(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function oe(e){return this instanceof oe?(this.v=e,this):new oe(e)}function se(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=o[e](t)).value instanceof oe?Promise.resolve(r.value.v).then(u,c):l(s[0][2],r)}catch(e){l(s[0][3],e)}var r}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ie(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=te(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function ae(e){return"function"==typeof e}function ue(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var ce=ue((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function le(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var he=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=te(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var u=this.initialTeardown;if(ae(u))try{u()}catch(e){o=e instanceof ce?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=te(c),h=l.next();!h.done;h=l.next()){var d=h.value;try{fe(d)}catch(e){o=null!=o?o:[],e instanceof ce?o=ne(ne([],re(o)),re(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new ce(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)fe(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&le(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&le(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function de(e){return e instanceof he||e&&"closed"in e&&ae(e.remove)&&ae(e.add)&&ae(e.unsubscribe)}function fe(e){ae(e)?e():e.unsubscribe()}he.EMPTY;var pe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ye={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,ne([e,t],re(r)))},clearTimeout:function(e){var t=ye.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function me(e){ye.setTimeout((function(){throw e}))}function ge(){}var be=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,de(t)&&t.add(r)):r.destination=Se,r}return K(t,e),t.create=function(e,t,r){return new Ee(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(he),ve=Function.prototype.bind;function we(e,t){return ve.call(e,t)}var Ce=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){xe(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){xe(e)}else xe(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){xe(e)}},e}(),Ee=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ae(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&pe.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&we(t.next,s),error:t.error&&we(t.error,s),complete:t.complete&&we(t.complete,s)}):o=t;return i.destination=new Ce(o),i}return K(t,e),t}(be);function xe(e){me(e)}var Se={closed:!0,next:ge,error:function(e){throw e},complete:ge},Te="function"==typeof Symbol&&Symbol.observable||"@@observable";function _e(e){return e}function Oe(e){return 0===e.length?_e:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var je=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof be||function(e){return e&&ae(e.next)&&ae(e.error)&&ae(e.complete)}(n)&&de(n)?e:new Ee(e,t,r);return function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))}(),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=$e(t))((function(t,n){var o=new Ee({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[Te]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Oe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=$e(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function $e(e){var t;return null!==(t=null!=e?e:pe.Promise)&&void 0!==t?t:Promise}function ke(e){return function(t){if(function(e){return ae(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function Ae(e,t,r,n,o){return new Pe(e,t,r,n,o)}var Pe=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return K(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(be);var Ie=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};var Re="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Me(e){if(e instanceof je)return e;if(null!=e){if(function(e){return ae(e[Te])}(e))return s=e,new je((function(e){var t=s[Te]();if(ae(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Ie(e))return o=e,new je((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(ae(null==(n=e)?void 0:n.then))return r=e,new je((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,me)}));if(function(e){return Symbol.asyncIterator&&ae(null==e?void 0:e[Symbol.asyncIterator])}(e))return De(e);if(function(e){return ae(null==e?void 0:e[Re])}(e))return t=e,new je((function(e){var r,n;try{for(var o=te(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(function(e){return ae(null==e?void 0:e.getReader)}(e))return De(function(e){return se(this,arguments,(function(){var t,r,n;return ee(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,oe(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,oe(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,oe(n)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e))}var t,r,n,o,s;throw function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(e)}function De(e){return new je((function(t){(function(e,t){var r,n,o,s;return Z(this,void 0,void 0,(function(){var i,a;return ee(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=ie(e),u.label=1;case 1:return[4,r.next()];case 2:if((n=u.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Fe(e,t){return Me(e)}var qe=ue((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ne(e,t){return new Promise((function(t,r){var n,o=!1;e.subscribe({next:function(e){n=e,o=!0},error:r,complete:function(){o?t(n):r(new qe)}})}))}function Ue(e,t){return ke((function(r,n){var o=0;r.subscribe(Ae(n,(function(r){n.next(e.call(t,r,o++))})))}))}var We=Array.isArray;function Le(e){return Ue((function(t){return function(e,t){return We(t)?e.apply(void 0,ne([],re(t))):e(t)}(e,t)}))}function He(e,t,r){t()}var ze=Array.isArray;function Be(e,t){return ke((function(r,n){var o=0;r.subscribe(Ae(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Je(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ae((t=e)[t.length-1])?e.pop():void 0;var t}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Oe(e)}(Je.apply(void 0,ne([],re(e))),Le(r)):ke((function(t,r){var n,o;(n=ne([t],re(function(e){return 1===e.length&&ze(e[0])?e[0]:e}(e))),void 0===o&&(o=_e),function(e){He(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){He(0,(function(){var a=Fe(n[t]),u=!1;a.subscribe(Ae(e,(function(n){r[t]=n,u||(u=!0,i--),i||e.next(o(r.slice()))}),(function(){--s||e.complete()})))}))},u=0;u<t;u++)a(u)}))})(r)}))}var Ge={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},Ve={0:8203,1:8204,2:8205,3:65279},Qe=new Array(4).fill(String.fromCodePoint(Ve[0])).join("");function Ye(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!!Number.isNaN(Number(e))&&!!Date.parse(e)}(e)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(e))?e:`${e}${function(e){let t=JSON.stringify(e);return`${Qe}${Array.from(t).map((e=>{let r=e.charCodeAt(0);if(r>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${t} on character ${e} (${r})`);return Array.from(r.toString(4).padStart(4,"0")).map((e=>String.fromCodePoint(Ve[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Ve).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Ge).map((e=>e.reverse())));var Xe=`${Object.values(Ge).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,Ke=new RegExp(`[${Xe}]{4,}`,"gu");function Ze(e){return JSON.parse(function(e){var t;return{cleaned:e.replace(Ke,""),encoded:(null==(t=e.match(Ke))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}var et=Object.defineProperty,tt=(e,t,r)=>(((e,t,r)=>{t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class rt extends Error{constructor(e){const t=ot(e);super(t.message),tt(this,"response"),tt(this,"statusCode",400),tt(this,"responseBody"),tt(this,"details"),Object.assign(this,t)}}class nt extends Error{constructor(e){const t=ot(e);super(t.message),tt(this,"response"),tt(this,"statusCode",500),tt(this,"responseBody"),tt(this,"details"),Object.assign(this,t)}}function ot(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:it(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return st(e)&&st(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?`:\n- ${n.join("\n- ")}`:"";return e.length>5&&(o+=`\n...and ${e.length-5} more`),r.message=`${t.error.description}${o}`,r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?` ${e.statusMessage}`:"";return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${t}`}(e),r)}function st(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function it(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const at={onResponse:e=>{if(e.statusCode>=500)throw new nt(e);if(e.statusCode>=400)throw new rt(e);return e}},ut={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function ct(e,t,r){if(0===r.maxRetries)return!1;const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||Y.shouldRetry(e,t,r)}function lt(e){if("string"==typeof e)return{id:e};if(Array.isArray(e))return{query:"*[_id in $ids]",params:{ids:e}};if("object"==typeof e&&null!==e&&"query"in e&&"string"==typeof e.query)return"params"in e&&"object"==typeof e.params&&null!==e.params?{query:e.query,params:e.params}:{query:e.query};const t=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error(`Unknown selection - must be one of:\n\n${t}`)}const ht=["image","file"],dt=["before","after","replace"],ft=e=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(e))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},pt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},yt=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error(`${e}(): "${t}" is not a valid document ID`)},mt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);yt(e,t._id)},gt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},bt=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};var vt,wt=Object.defineProperty,Ct=(e,t,r)=>(((e,t,r)=>{t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Et=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},xt=(e,t,r)=>(Et(e,t,"read from private field"),r?r.call(e):t.get(e)),St=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tt=(e,t,r,n)=>(Et(e,t,"write to private field"),t.set(e,r),r);class _t{constructor(e,t={}){Ct(this,"selection"),Ct(this,"operations"),this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return pt("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,t,r){return((e,t,r)=>{const n="insert(at, selector, items)";if(-1===dt.indexOf(e)){const e=dt.map((e=>`"${e}"`)).join(", ");throw new Error(`${n} takes an "at"-argument which is one of: ${e}`)}if("string"!=typeof t)throw new Error(`${n} takes a "selector"-argument which must be a string`);if(!Array.isArray(r))throw new Error(`${n} takes an "items"-argument which must be an array`)})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after",`${e}[-1]`,t)}prepend(e,t){return this.insert("before",`${e}[0]`,t)}splice(e,t,r,n){const o=t<0?t-1:t,s=typeof r>"u"||-1===r?-1:Math.max(0,t+r),i=`${e}[${o}:${o<0&&s>=0?"":s}]`;return this.insert("replace",i,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...lt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return pt(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},r&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}vt=new WeakMap;let Ot=class e extends _t{constructor(e,t,r){super(e,t),St(this,vt,void 0),Tt(this,vt,r)}clone(){return new e(this.selection,{...this.operations},xt(this,vt))}commit(e){if(!xt(this,vt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return xt(this,vt).mutate({patch:this.serialize()},r)}};var jt;jt=new WeakMap;let $t=class e extends _t{constructor(e,t,r){super(e,t),St(this,jt,void 0),Tt(this,jt,r)}clone(){return new e(this.selection,{...this.operations},xt(this,jt))}commit(e){if(!xt(this,jt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return xt(this,jt).mutate({patch:this.serialize()},r)}};var kt=Object.defineProperty,At=(e,t,r)=>(((e,t,r)=>{t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Pt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},It=(e,t,r)=>(Pt(e,t,"read from private field"),r?r.call(e):t.get(e)),Rt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Mt=(e,t,r,n)=>(Pt(e,t,"write to private field"),t.set(e,r),r);const Dt={returnDocuments:!1};class Ft{constructor(e=[],t){At(this,"operations"),At(this,"trxId"),this.operations=e,this.trxId=t}create(e){return pt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return pt(t,e),mt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return pt(t,e),mt(t,e),this._add({[t]:e})}delete(e){return yt("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}var qt;qt=new WeakMap;let Nt=class e extends Ft{constructor(e,t,r){super(e,r),Rt(this,qt,void 0),Mt(this,qt,t)}clone(){return new e([...this.operations],It(this,qt),this.trxId)}commit(e){if(!It(this,qt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return It(this,qt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Dt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof $t)return this._add({patch:e.serialize()});if(r){const r=t(new $t(e,{},It(this,qt)));if(!(r instanceof $t))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};var Ut;Ut=new WeakMap;let Wt=class e extends Ft{constructor(e,t,r){super(e,r),Rt(this,Ut,void 0),Mt(this,Ut,t)}clone(){return new e([...this.operations],It(this,Ut),this.trxId)}commit(e){if(!It(this,Ut))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return It(this,Ut).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Dt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Ot)return this._add({patch:e.serialize()});if(r){const r=t(new Ot(e,{},It(this,Ut)));if(!(r instanceof Ot))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};function Lt(e){return"https://www.sanity.io/help/"+e}const Ht=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),zt=Ht(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),Bt=Ht(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),Jt=Ht(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Lt("js-client-browser-token")} for more information and how to hide this warning.`]),Gt=Ht(["Using the Sanity client without specifying an API version is deprecated.",`See ${Lt("js-client-api-version")}`]),Vt=Ht(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Qt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Yt=["localhost","127.0.0.1","0.0.0.0"];const Xt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},Kt=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Qt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Gt();const n={...Qt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=Lt("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${e}`)}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&Xt(n.perspective),"encodeSourceMap"in n)throw new Error("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'?");if("encodeSourceMapAtPath"in n)throw new Error("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'?");if("boolean"!=typeof n.stega.enabled)throw new Error(`stega.enabled must be a boolean, received ${n.stega.enabled}`);if(n.stega.enabled&&void 0===n.stega.studioUrl)throw new Error("stega.studioUrl must be defined when stega.enabled is true");if(n.stega.enabled&&"string"!=typeof n.stega.studioUrl&&"function"!=typeof n.stega.studioUrl)throw new Error(`stega.studioUrl must be a string or a function, received ${n.stega.studioUrl}`);const s=typeof window<"u"&&window.location&&window.location.hostname,i=s&&(e=>-1!==Yt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Jt():typeof n.useCdn>"u"&&zt(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&ft(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?bt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Qt.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),u=a[0],c=a[1],l=n.isDefaultApi?"apicdn.sanity.io":c;return n.useProjectHostname?(n.url=`${u}://${n.projectId}.${c}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n},Zt="X-Sanity-Project-ID";const er=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,returnQuery:s,...i}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(i))t&&n.append(e,`${t}`);return!1===s&&n.append("returnQuery","false"),`?${n}`},tr=(e={})=>{return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:typeof t>"u"?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},rr=e=>"response"===e.type,nr=e=>e.body,or=11264;function sr(e,t,r,n,o={},s={}){const i="stega"in s?{...r||{},..."boolean"==typeof s.stega?{enabled:s.stega}:s.stega||{}}:r,a=i.enabled?function(e){try{return Ze(e)}catch{return e}}(o):o,u=!1===s.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},d=dr(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...h,fetch:{cache:c,next:l}}:h);return i.enabled?d.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Je.apply(void 0,ne([],re(e)))}(Fe(Promise.resolve().then((function(){return Vn})).then((function(e){return e.a})).then((({stegaEncodeSourceMap:e})=>e)))),Ue((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):d.pipe(Ue(u))}function ir(e,t,r,n={}){return pr(e,t,{uri:mr(e,"doc",r),json:!0,tag:n.tag}).pipe(Be(rr),Ue((e=>e.body.documents&&e.body.documents[0])))}function ar(e,t,r,n={}){return pr(e,t,{uri:mr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Be(rr),Ue((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function ur(e,t,r,n){return mt("createIfNotExists",r),fr(e,t,r,"createIfNotExists",n)}function cr(e,t,r,n){return mt("createOrReplace",r),fr(e,t,r,"createOrReplace",n)}function lr(e,t,r,n){return dr(e,t,"mutate",{mutations:[{delete:lt(r)}]},n)}function hr(e,t,r,n){let o;o=r instanceof $t||r instanceof Ot?{patch:r.serialize()}:r instanceof Nt||r instanceof Wt?r.serialize():r;return dr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function dr(e,t,r,n,o={}){const s="mutate"===r,i="query"===r,a=s?"":er(n),u=!s&&a.length<or,c=u?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p,returnQuery:y}=o;return pr(e,t,{method:u?"GET":"POST",uri:mr(e,r,c),json:!0,body:u?void 0:n,query:s&&tr(o),timeout:h,headers:p,token:d,tag:f,returnQuery:y,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Be(rr),Ue(nr),Ue((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function fr(e,t,r,n,o={}){return dr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function pr(e,t,r){var n,o;const s=r.url||r.uri,i=e.config(),a=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/"):r.canUseCdn;let u=(null!=(n=r.useCdn)?n:i.useCdn)&&a;const c=r.tag&&i.requestTagPrefix?[i.requestTagPrefix,r.tag].join("."):r.tag||i.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:bt(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/query/")){const e=null!=(o=r.resultSourceMap)?o:i.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||i.perspective;"string"==typeof t&&"raw"!==t&&(Xt(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Bt())),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query})}const l=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r[Zt]=e.projectId);const o=!!(typeof t.withCredentials>"u"?e.token||e.withCredentials:t.withCredentials),s=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof s>"u"?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(i,Object.assign({},r,{url:gr(e,s,u)})),h=new je((e=>t(l,i.requester).subscribe(e)));return r.signal?h.pipe((d=r.signal,e=>new je((t=>{const r=()=>t.error(function(e){var t,r;if(br)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const n=new Error(null!=(r=null==e?void 0:e.reason)?r:"The operation was aborted.");return n.name="AbortError",n}(d));if(d&&d.aborted)return void r();const n=e.subscribe(t);return d.addEventListener("abort",r),()=>{d.removeEventListener("abort",r),n.unsubscribe()}})))):h;var d}function yr(e,t,r){return pr(e,t,r).pipe(Be((e=>"response"===e.type)),Ue((e=>e.body)))}function mr(e,t,r){const n=e.config(),o=`/${t}/${gt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function gr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const br=!!globalThis.DOMException;var vr,wr,Cr,Er,xr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Sr=(e,t,r)=>(xr(e,t,"read from private field"),r?r.call(e):t.get(e)),Tr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},_r=(e,t,r,n)=>(xr(e,t,"write to private field"),t.set(e,r),r);class Or{constructor(e,t){Tr(this,vr,void 0),Tr(this,wr,void 0),_r(this,vr,e),_r(this,wr,t)}upload(e,t,r){return $r(Sr(this,vr),Sr(this,wr),e,t,r)}}vr=new WeakMap,wr=new WeakMap;class jr{constructor(e,t){Tr(this,Cr,void 0),Tr(this,Er,void 0),_r(this,Cr,e),_r(this,Er,t)}upload(e,t,r){return Ne($r(Sr(this,Cr),Sr(this,Er),e,t,r).pipe(Be((e=>"response"===e.type)),Ue((e=>e.body.document))))}}function $r(e,t,r,n,o={}){(e=>{if(-1===ht.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${ht.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=gt(e.config()),a="image"===r?"images":"files",u=function(e,t){return typeof File>"u"||!(t instanceof File)?e:Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:c,label:l,title:h,description:d,creditLine:f,filename:p,source:y}=u,m={label:l,title:h,description:d,filename:p,meta:s,creditLine:f};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.sourceUrl=y.url),pr(e,t,{tag:c,method:"POST",timeout:u.timeout||0,uri:`/assets/${a}/${i}`,headers:u.contentType?{"Content-Type":u.contentType}:{},query:m,body:n})}Cr=new WeakMap,Er=new WeakMap;const kr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Ar={includeResult:!0};function Pr(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,u={...(h=r,d=Ar,Object.keys(d).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?d[t]:h[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,kr),l=`${n}${mr(this,"listen",er({query:e,params:t,options:{tag:a,...c}}))}`;var h,d;if(l.length>14800)return new je((e=>e.error(new Error("Query too large for listener"))));const f=u.events?u.events:["mutation"],p=-1!==f.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new je((e=>{let t;c().then((e=>{t=e})).catch((t=>{e.error(t),d()}));let r,n=!1;function o(){n||(p&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(u(),clearTimeout(r),r=setTimeout(h,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=Ir(e);return t instanceof Error?t:new Error(function(e){return e.error?e.error.description?e.error.description:"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2):e.message||"Unknown listener error"}(t))}(t))}function i(t){const r=Ir(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,u(),e.complete()}function u(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),f.forEach((e=>t.removeEventListener(e,i))),t.close())}async function c(){const{default:e}=await Promise.resolve().then((function(){return Zn})),t=new e(l,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),f.forEach((e=>t.addEventListener(e,i))),t}function h(){c().then((e=>{t=e})).catch((t=>{e.error(t),d()}))}function d(){n=!0,u()}return d}))}function Ir(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}function Rr(e={}){const t=mr(this,"sync-tags"),r=new URL(this.getUrl(t,!0));return e.pos&&r.searchParams.append("start",e.pos),new je((e=>{const t=new AbortController,{signal:n}=t;return fetch(r,{signal:n}).then((async t=>{if(!t.body)throw new TypeError("Response body is not readable");const r=t.body.pipeThrough(new TextDecoderStream).pipeThrough(function(e){let t="";return new TransformStream({transform(r,n){t+=r;const o=t.split(e);o.slice(0,-1).forEach((e=>n.enqueue(e))),t=o[o.length-1]},flush(e){t&&e.enqueue(t)}})}("\n")).pipeThrough(new TransformStream({transform(e,t){e&&t.enqueue(JSON.parse(e))}})).getReader(),o={[Symbol.asyncIterator]:()=>({next:()=>r.read()})};for await(const t of o){if(n.aborted)break;if("error"===t.type){e.error(t);break}e.next(t)}})).catch((t=>{"TimeoutError"!==(null==t?void 0:t.name)&&"AbortError"!==(null==t?void 0:t.name)&&e.error(t)})),()=>{t.abort()}}))}var Mr,Dr,Fr,qr,Nr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ur=(e,t,r)=>(Nr(e,t,"read from private field"),r?r.call(e):t.get(e)),Wr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Lr=(e,t,r,n)=>(Nr(e,t,"write to private field"),t.set(e,r),r);class Hr{constructor(e,t){Wr(this,Mr,void 0),Wr(this,Dr,void 0),Lr(this,Mr,e),Lr(this,Dr,t)}create(e,t){return Br(Ur(this,Mr),Ur(this,Dr),"PUT",e,t)}edit(e,t){return Br(Ur(this,Mr),Ur(this,Dr),"PATCH",e,t)}delete(e){return Br(Ur(this,Mr),Ur(this,Dr),"DELETE",e)}list(){return yr(Ur(this,Mr),Ur(this,Dr),{uri:"/datasets",tag:null})}}Mr=new WeakMap,Dr=new WeakMap;class zr{constructor(e,t){Wr(this,Fr,void 0),Wr(this,qr,void 0),Lr(this,Fr,e),Lr(this,qr,t)}create(e,t){return Ne(Br(Ur(this,Fr),Ur(this,qr),"PUT",e,t))}edit(e,t){return Ne(Br(Ur(this,Fr),Ur(this,qr),"PATCH",e,t))}delete(e){return Ne(Br(Ur(this,Fr),Ur(this,qr),"DELETE",e))}list(){return Ne(yr(Ur(this,Fr),Ur(this,qr),{uri:"/datasets",tag:null}))}}function Br(e,t,r,n,o){return ft(n),yr(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Fr=new WeakMap,qr=new WeakMap;var Jr,Gr,Vr,Qr,Yr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Xr=(e,t,r)=>(Yr(e,t,"read from private field"),r?r.call(e):t.get(e)),Kr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Zr=(e,t,r,n)=>(Yr(e,t,"write to private field"),t.set(e,r),r);class en{constructor(e,t){Kr(this,Jr,void 0),Kr(this,Gr,void 0),Zr(this,Jr,e),Zr(this,Gr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return yr(Xr(this,Jr),Xr(this,Gr),{uri:t})}getById(e){return yr(Xr(this,Jr),Xr(this,Gr),{uri:`/projects/${e}`})}}Jr=new WeakMap,Gr=new WeakMap;class tn{constructor(e,t){Kr(this,Vr,void 0),Kr(this,Qr,void 0),Zr(this,Vr,e),Zr(this,Qr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ne(yr(Xr(this,Vr),Xr(this,Qr),{uri:t}))}getById(e){return Ne(yr(Xr(this,Vr),Xr(this,Qr),{uri:`/projects/${e}`}))}}Vr=new WeakMap,Qr=new WeakMap;var rn,nn,on,sn,an=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},un=(e,t,r)=>(an(e,t,"read from private field"),r?r.call(e):t.get(e)),cn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},ln=(e,t,r,n)=>(an(e,t,"write to private field"),t.set(e,r),r);class hn{constructor(e,t){cn(this,rn,void 0),cn(this,nn,void 0),ln(this,rn,e),ln(this,nn,t)}getById(e){return yr(un(this,rn),un(this,nn),{uri:`/users/${e}`})}}rn=new WeakMap,nn=new WeakMap;class dn{constructor(e,t){cn(this,on,void 0),cn(this,sn,void 0),ln(this,on,e),ln(this,sn,t)}getById(e){return Ne(yr(un(this,on),un(this,sn),{uri:`/users/${e}`}))}}on=new WeakMap,sn=new WeakMap;var fn,pn,yn=Object.defineProperty,mn=(e,t,r)=>(((e,t,r)=>{t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),gn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},bn=(e,t,r)=>(gn(e,t,"read from private field"),r?r.call(e):t.get(e)),vn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},wn=(e,t,r,n)=>(gn(e,t,"write to private field"),t.set(e,r),r);fn=new WeakMap,pn=new WeakMap;let Cn=class e{constructor(e,t=Qt){mn(this,"assets"),mn(this,"datasets"),mn(this,"projects"),mn(this,"users"),vn(this,fn,void 0),vn(this,pn,void 0),mn(this,"listen",Pr),mn(this,"syncTags",Rr),this.config(t),wn(this,pn,e),this.assets=new Or(this,bn(this,pn)),this.datasets=new Hr(this,bn(this,pn)),this.projects=new en(this,bn(this,pn)),this.users=new hn(this,bn(this,pn))}clone(){return new e(bn(this,pn),this.config())}config(e){if(void 0===e)return{...bn(this,fn)};if(bn(this,fn)&&!1===bn(this,fn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return wn(this,fn,Kt(e,bn(this,fn)||{})),this}withConfig(t){const r=this.config();return new e(bn(this,pn),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return sr(this,bn(this,pn),bn(this,fn).stega,e,t,r)}getDocument(e,t){return ir(this,bn(this,pn),e,t)}getDocuments(e,t){return ar(this,bn(this,pn),e,t)}create(e,t){return fr(this,bn(this,pn),e,"create",t)}createIfNotExists(e,t){return ur(this,bn(this,pn),e,t)}createOrReplace(e,t){return cr(this,bn(this,pn),e,t)}delete(e,t){return lr(this,bn(this,pn),e,t)}mutate(e,t){return hr(this,bn(this,pn),e,t)}patch(e,t){return new Ot(e,t,this)}transaction(e){return new Wt(e,this)}request(e){return yr(this,bn(this,pn),e)}getUrl(e,t){return gr(this,e,t)}getDataUrl(e,t){return mr(this,e,t)}};var En,xn;En=new WeakMap,xn=new WeakMap;let Sn=class e{constructor(e,t=Qt){mn(this,"assets"),mn(this,"datasets"),mn(this,"projects"),mn(this,"users"),mn(this,"observable"),vn(this,En,void 0),vn(this,xn,void 0),mn(this,"listen",Pr),mn(this,"syncTags",Rr),this.config(t),wn(this,xn,e),this.assets=new jr(this,bn(this,xn)),this.datasets=new zr(this,bn(this,xn)),this.projects=new tn(this,bn(this,xn)),this.users=new dn(this,bn(this,xn)),this.observable=new Cn(e,t)}clone(){return new e(bn(this,xn),this.config())}config(e){if(void 0===e)return{...bn(this,En)};if(bn(this,En)&&!1===bn(this,En).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),wn(this,En,Kt(e,bn(this,En)||{})),this}withConfig(t){const r=this.config();return new e(bn(this,xn),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return Ne(sr(this,bn(this,xn),bn(this,En).stega,e,t,r))}getDocument(e,t){return Ne(ir(this,bn(this,xn),e,t))}getDocuments(e,t){return Ne(ar(this,bn(this,xn),e,t))}create(e,t){return Ne(fr(this,bn(this,xn),e,"create",t))}createIfNotExists(e,t){return Ne(ur(this,bn(this,xn),e,t))}createOrReplace(e,t){return Ne(cr(this,bn(this,xn),e,t))}delete(e,t){return Ne(lr(this,bn(this,xn),e,t))}mutate(e,t){return Ne(hr(this,bn(this,xn),e,t))}patch(e,t){return new $t(e,t,this)}transaction(e){return new Nt(e,this)}request(e){return Ne(yr(this,bn(this,xn),e))}dataRequest(e,t,r){return Ne(dr(this,bn(this,xn),e,t,r))}getUrl(e,t){return gr(this,e,t)}getDataUrl(e,t){return mr(this,e,t)}};const Tn=function(e,t){const r=function(e){return k([Y({shouldRetry:ct}),...e,ut,N(),U(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},at,H({implementation:je})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],Sn),_n=Tn.requester,On=Tn.createClient,jn=($n=On,function(e){return Vt(),$n(e)});var $n;const kn=/_key\s*==\s*['"](.*)['"]/;function An(e){if(!Array.isArray(e))throw new Error("Path is not an array");return e.reduce(((e,t,r)=>{const n=typeof t;if("number"===n)return`${e}[${t}]`;if("string"===n)return`${e}${0===r?"":"."}${t}`;if(function(e){return"string"==typeof e?kn.test(e.trim()):"object"==typeof e&&"_key"in e}(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){const[r,n]=t;return`${e}[${r}:${n}]`}throw new Error(`Unsupported path segment \`${JSON.stringify(t)}\``)}),"")}const Pn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},In={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function Rn(e){const t=[],r=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;let n;for(;null!==(n=r.exec(e));)if(void 0===n[1])if(void 0===n[2])if(void 0===n[3]);else{const e=n[3].replace(/\\(\\')/g,(e=>In[e]));t.push({_key:e,_index:-1})}else t.push(parseInt(n[2],10));else{const e=n[1].replace(/\\(\\|f|n|r|t|')/g,(e=>In[e]));t.push(e)}return t}function Mn(e){return e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(""!==e._key)return{_key:e._key};if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)}))}function Dn(e,t){if(null==t||!t.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Pn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Pn[e]))}')]`:`[${e._index}]`)).join("")}`}(e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)})));if(void 0!==t.mappings[r])return{mapping:t.mappings[r],matchedPath:r,pathSuffix:""};const n=Object.entries(t.mappings).filter((([e])=>r.startsWith(e))).sort((([e],[t])=>t.length-e.length));if(0==n.length)return;const[o,s]=n[0];return{mapping:s,matchedPath:o,pathSuffix:r.substring(o.length)}}function Fn(e){return"object"==typeof e&&null!==e}function qn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Fn(e)){const o=e._key;if("string"==typeof o)return qn(e,t,r.concat({_key:o,_index:n}))}return qn(e,t,r.concat(n))})):Fn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,qn(n,t,r.concat(e))]))):t(e,r)}function Nn(e,t,r){return qn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Dn(n,t);if(!o)return e;const{mapping:s,matchedPath:i}=o;if("value"!==s.type||"documentValue"!==s.source.type)return e;const a=t.documents[s.source.document],u=t.paths[s.source.path],c=Rn(i),l=Rn(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Un="drafts.";function Wn(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:u}=e;if(!t)throw new Error("baseUrl is required");if(!i)throw new Error("path is required");if(!o)throw new Error("id is required");if("/"!==t&&t.endsWith("/"))throw new Error("baseUrl must not end with a slash");const c="default"===r?void 0:r,l="default"===n?void 0:n,h=function(e){return e.startsWith(Un)?e.slice(Un.length):e}(o),d=Array.isArray(i)?An(Mn(i)):i,f=new URLSearchParams({baseUrl:t,id:h,type:s,path:d});c&&f.set("workspace",c),l&&f.set("tool",l),a&&f.set("projectId",a),u&&f.set("dataset",u),o.startsWith(Un)&&f.set("isDraft","");const p=["/"===t?"":t];c&&p.push(c);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),p.push("intent","edit",`${y.join(";")}?${f}`),p.join("/")}const Ln=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(r))return!1;var n;const o=e.at(-1);return!("slug"===e.at(-2)&&"current"===o||"string"==typeof o&&o.startsWith("_")||"number"==typeof o&&"marks"===e.at(-2)||"href"===o&&"number"==typeof e.at(-2)&&"markDefs"===e.at(-3)||"style"===o||"listItem"===o||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||zn(e)||zn(t)||"string"==typeof o&&Hn.has(o))},Hn=new Set(["color","colour","currency","email","format","gid","hex","href","hsl","hsla","icon","id","index","key","language","layout","link","linkAction","locale","lqip","page","path","ref","rgb","rgba","route","secret","slug","status","tag","template","theme","type","unit","url","username","variant","website"]);function zn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function Bn(e,t,r){var n,o,s,i,a,u,c,l,h;const{filter:d,logger:f,enabled:p}=r;if(!p){const o="config.enabled must be true, don't call this function otherwise";throw null==(n=null==f?void 0:f.error)||n.call(f,`[@sanity/client]: ${o}`,{result:e,resultSourceMap:t,config:r}),new TypeError(o)}if(!t)return null==(o=null==f?void 0:f.error)||o.call(f,"[@sanity/client]: Missing Content Source Map from response body",{result:e,resultSourceMap:t,config:r}),e;if(!r.studioUrl){const n="config.studioUrl must be defined";throw null==(s=null==f?void 0:f.error)||s.call(f,`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const y={encoded:[],skipped:[]},m=Nn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof d?d({sourcePath:e,resultPath:n,filterDefault:Ln,sourceDocument:t,value:o}):Ln({sourcePath:e,resultPath:n,filterDefault:Ln,sourceDocument:t,value:o})))return f&&y.skipped.push({path:Jn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;f&&y.encoded.push({path:Jn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length});const{baseUrl:s,workspace:i,tool:a}=function(e){let t="string"==typeof e?e:e.baseUrl;return"/"!==t&&(t=t.replace(/\/$/,"")),"string"==typeof e?{baseUrl:t}:{...e,baseUrl:t}}("function"==typeof r.studioUrl?r.studioUrl(t):r.studioUrl);if(!s)return o;const{_id:u,_type:c,_projectId:l,_dataset:h}=t;return Ye(o,{origin:"sanity.io",href:Wn({baseUrl:s,workspace:i,tool:a,id:u,type:c,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:h,projectId:l}})},!1)}));if(f){const e=y.skipped.length,t=y.encoded.length;if((e||t)&&(null==(i=(null==f?void 0:f.groupCollapsed)||f.log)||i("[@sanity/client]: Encoding source map into result"),null==(a=f.log)||a.call(f,`[@sanity/client]: Paths encoded: ${y.encoded.length}, skipped: ${y.skipped.length}`)),y.encoded.length>0&&(null==(u=null==f?void 0:f.log)||u.call(f,"[@sanity/client]: Table of encoded paths"),null==(c=(null==f?void 0:f.table)||f.log)||c(y.encoded)),y.skipped.length>0){const e=new Set;for(const{path:t}of y.skipped)e.add(t.replace(kn,"0").replace(/\[\d+\]/g,"[]"));null==(l=null==f?void 0:f.log)||l.call(f,"[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&(null==(h=null==f?void 0:f.groupEnd)||h.call(f))}return m}function Jn(e){return An(Mn(e))}var Gn=Object.freeze({__proto__:null,stegaEncodeSourceMap:Bn}),Vn=Object.freeze({__proto__:null,a:Gn,e:Nn,s:Bn}),Qn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Yn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xn={exports:{}};
|
|
8
8
|
/** @license
|
|
9
9
|
* eventsource.js
|
|
10
10
|
* Available under MIT License (MIT)
|
|
11
11
|
* https://github.com/Yaffle/EventSource/
|
|
12
|
-
*/!function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,u=r.EventSource,c=r.document,l=r.Promise,h=r.fetch,d=r.Response,f=r.TextDecoder,p=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===c||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var m=h;h=function(e,t){var r=t.signal;return m(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==s&&(u<128||u>191||!t(i<<6|63&u,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(u>=0&&u<=127?(s=0,i=u):u>=192&&u<=223?(s=6,i=31&u):u>=224&&u<=239?(s=12,i=15&u):u>=240&&u<=247?(s=18,i=7&u):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&u),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=f&&null!=p&&function(){try{return"test"===(new f).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(f=g);var b=function(){};function v(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function S(){}function T(){this._listeners=Object.create(null)}function _(e){n((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function j(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function $(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function k(e,t){O.call(this,e),this.error=t.error}v.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,u=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=b,i.onerror=b,i.onabort=b,i.onprogress=b,i.onreadystatechange=b,i.abort(),0!==u&&(o(u),u=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:b}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},d=function(){u=n((function(){d()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){h("load",e)}),"onerror"in i&&(i.onerror=function(e){h("error",e)}),"onabort"in i&&(i.onabort=function(e){h("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||h(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&c())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(u=n((function(){d()}),0))},v.prototype.abort=function(){this._abort(!1)},v.prototype.getResponseHeader=function(e){return this._contentType},v.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},v.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},v.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},S.prototype.open=function(e,t,r,n,o,s,i){var a=null,u=new y,c=u.signal,d=new f;return h(o,{headers:i,credentials:s?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=d.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},T.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){_(e)}}},T.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},T.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},j.prototype=Object.create(O.prototype),$.prototype=Object.create(O.prototype),k.prototype=Object.create(O.prototype);var A=-1,P=0,I=1,R=2,M=-1,D=0,F=1,q=2,N=3,U=/^text\/event\-stream(;.*)?$/i,W=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),L(r)},L=function(e){return Math.min(Math.max(e,1e3),18e6)},H=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){_(e)}};function z(e,t){T.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),u=r.lastEventIdQueryParameterName||"lastEventId",c=L(1e3),l=W(r.heartbeatTimeout,45e3),h="",d=c,f=!1,p=0,y=r.headers||{},m=r.Transport,g=B&&null==m?void 0:new v(null!=m?new m:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),b=null!=m&&"string"!=typeof m?new m:null==g?new S:new E,w=void 0,C=0,x=A,T="",_="",O="",z="",J=D,G=0,V=0,Q=function(t,r,n,o){if(x===P)if(200===t&&null!=n&&U.test(n)){x=I,f=Date.now(),d=c,e.readyState=I;var s=new $("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",K();s=new $("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onerror,s),console.error(i)}},Y=function(t){if(x===I){for(var r=-1,s=0;s<t.length;s+=1){(u=t.charCodeAt(s))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?z:"")+t.slice(0,r+1);z=(-1===r?z:"")+t.slice(r+1),""!==t&&(f=Date.now(),p+=t.length);for(var a=0;a<i.length;a+=1){var u=i.charCodeAt(a);if(J===M&&u==="\n".charCodeAt(0))J=D;else if(J===M&&(J=D),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(J!==D){J===F&&(V=a+1);var y=i.slice(G,V-1),m=i.slice(V+(V<a&&i.charCodeAt(V)===" ".charCodeAt(0)?1:0),a);"data"===y?(T+="\n",T+=m):"id"===y?_=m:"event"===y?O=m:"retry"===y?(c=W(m,c),d=c):"heartbeatTimeout"===y&&(l=W(m,l),0!==C&&(o(C),C=n((function(){Z()}),l)))}if(J===D){if(""!==T){h=_,""===O&&(O="message");var g=new j(O,{data:T.slice(1),lastEventId:_});if(e.dispatchEvent(g),"open"===O?H(e,e.onopen,g):"message"===O?H(e,e.onmessage,g):"error"===O&&H(e,e.onerror,g),x===R)return}T="",O=""}J=u==="\r".charCodeAt(0)?M:D}else J===D&&(G=a,J=F),J===F?u===":".charCodeAt(0)&&(V=a+1,J=q):J===q&&(J=N)}}},X=function(t){if(x===I||x===P){x=A,0!==C&&(o(C),C=0),C=n((function(){Z()}),d),d=L(Math.min(16*c,2*d)),e.readyState=P;var r=new k("error",{error:t});e.dispatchEvent(r),H(e,e.onerror,r),null!=t&&console.error(t)}},K=function(){x=R,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=R},Z=function(){if(C=0,x===A){f=!1,p=0,C=n((function(){Z()}),l),x=P,T="",O="",_=h,z="",G=0,V=0,J=D;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===u?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(h)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(i[c]=a[c]);try{w=b.open(g,Q,Y,X,r,s,i)}catch(e){throw K(),e}}else if(f||null==w){var d=Math.max((f||Date.now())+l-Date.now(),1);f=!1,C=n((function(){Z()}),d)}else X(new Error("No activity within "+l+" milliseconds. "+(x===P?"No response received.":p+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=P,e.withCredentials=a,e.headers=y,e._close=K,Z()}(this,e,t)}var B=null!=h&&null!=d&&"body"in d.prototype;z.prototype=Object.create(T.prototype),z.prototype.CONNECTING=P,z.prototype.OPEN=I,z.prototype.CLOSED=R,z.prototype.close=function(){this._close()},z.CONNECTING=P,z.OPEN=I,z.CLOSED=R,z.prototype.withCredentials=void 0;var J,G=u;null==s||null!=u&&"withCredentials"in u.prototype||(G=z),J=function(e){e.EventSourcePolyfill=z,e.NativeEventSource=u,e.EventSource=G}(t),void 0!==J&&(e.exports=J)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:Vn:globalThis)}(Yn,Yn.exports);var Xn=Qn(Yn.exports.EventSourcePolyfill),Kn=Object.freeze({__proto__:null,default:Xn});e.BasePatch=_t,e.BaseTransaction=Ft,e.ClientError=rt,e.ObservablePatch=Ot,e.ObservableSanityClient=wn,e.ObservableTransaction=Wt,e.Patch=$t,e.SanityClient=xn,e.ServerError=nt,e.Transaction=Nt,e.createClient=_n,e.default=On,e.requester=Tn,e.unstable__adapter=O,e.unstable__environment="browser",Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
12
|
+
*/!function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,u=r.EventSource,c=r.document,l=r.Promise,h=r.fetch,d=r.Response,f=r.TextDecoder,p=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===c||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var m=h;h=function(e,t){var r=t.signal;return m(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==s&&(u<128||u>191||!t(i<<6|63&u,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(u>=0&&u<=127?(s=0,i=u):u>=192&&u<=223?(s=6,i=31&u):u>=224&&u<=239?(s=12,i=15&u):u>=240&&u<=247?(s=18,i=7&u):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&u),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=f&&null!=p&&function(){try{return"test"===(new f).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(f=g);var b=function(){};function v(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function S(){}function T(){this._listeners=Object.create(null)}function _(e){n((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function j(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function $(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function k(e,t){O.call(this,e),this.error=t.error}v.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,u=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=b,i.onerror=b,i.onabort=b,i.onprogress=b,i.onreadystatechange=b,i.abort(),0!==u&&(o(u),u=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:b}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},d=function(){u=n((function(){d()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){h("load",e)}),"onerror"in i&&(i.onerror=function(e){h("error",e)}),"onabort"in i&&(i.onabort=function(e){h("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||h(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&c())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(u=n((function(){d()}),0))},v.prototype.abort=function(){this._abort(!1)},v.prototype.getResponseHeader=function(e){return this._contentType},v.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},v.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},v.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},S.prototype.open=function(e,t,r,n,o,s,i){var a=null,u=new y,c=u.signal,d=new f;return h(o,{headers:i,credentials:s?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=d.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},T.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){_(e)}}},T.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},T.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},j.prototype=Object.create(O.prototype),$.prototype=Object.create(O.prototype),k.prototype=Object.create(O.prototype);var A=-1,P=0,I=1,R=2,M=-1,D=0,F=1,q=2,N=3,U=/^text\/event\-stream(;.*)?$/i,W=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),L(r)},L=function(e){return Math.min(Math.max(e,1e3),18e6)},H=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){_(e)}};function z(e,t){T.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),u=r.lastEventIdQueryParameterName||"lastEventId",c=L(1e3),l=W(r.heartbeatTimeout,45e3),h="",d=c,f=!1,p=0,y=r.headers||{},m=r.Transport,g=B&&null==m?void 0:new v(null!=m?new m:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),b=null!=m&&"string"!=typeof m?new m:null==g?new S:new E,w=void 0,C=0,x=A,T="",_="",O="",z="",J=D,G=0,V=0,Q=function(t,r,n,o){if(x===P)if(200===t&&null!=n&&U.test(n)){x=I,f=Date.now(),d=c,e.readyState=I;var s=new $("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",K();s=new $("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onerror,s),console.error(i)}},Y=function(t){if(x===I){for(var r=-1,s=0;s<t.length;s+=1){(u=t.charCodeAt(s))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?z:"")+t.slice(0,r+1);z=(-1===r?z:"")+t.slice(r+1),""!==t&&(f=Date.now(),p+=t.length);for(var a=0;a<i.length;a+=1){var u=i.charCodeAt(a);if(J===M&&u==="\n".charCodeAt(0))J=D;else if(J===M&&(J=D),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(J!==D){J===F&&(V=a+1);var y=i.slice(G,V-1),m=i.slice(V+(V<a&&i.charCodeAt(V)===" ".charCodeAt(0)?1:0),a);"data"===y?(T+="\n",T+=m):"id"===y?_=m:"event"===y?O=m:"retry"===y?(c=W(m,c),d=c):"heartbeatTimeout"===y&&(l=W(m,l),0!==C&&(o(C),C=n((function(){Z()}),l)))}if(J===D){if(""!==T){h=_,""===O&&(O="message");var g=new j(O,{data:T.slice(1),lastEventId:_});if(e.dispatchEvent(g),"open"===O?H(e,e.onopen,g):"message"===O?H(e,e.onmessage,g):"error"===O&&H(e,e.onerror,g),x===R)return}T="",O=""}J=u==="\r".charCodeAt(0)?M:D}else J===D&&(G=a,J=F),J===F?u===":".charCodeAt(0)&&(V=a+1,J=q):J===q&&(J=N)}}},X=function(t){if(x===I||x===P){x=A,0!==C&&(o(C),C=0),C=n((function(){Z()}),d),d=L(Math.min(16*c,2*d)),e.readyState=P;var r=new k("error",{error:t});e.dispatchEvent(r),H(e,e.onerror,r),null!=t&&console.error(t)}},K=function(){x=R,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=R},Z=function(){if(C=0,x===A){f=!1,p=0,C=n((function(){Z()}),l),x=P,T="",O="",_=h,z="",G=0,V=0,J=D;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===u?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(h)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(i[c]=a[c]);try{w=b.open(g,Q,Y,X,r,s,i)}catch(e){throw K(),e}}else if(f||null==w){var d=Math.max((f||Date.now())+l-Date.now(),1);f=!1,C=n((function(){Z()}),d)}else X(new Error("No activity within "+l+" milliseconds. "+(x===P?"No response received.":p+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=P,e.withCredentials=a,e.headers=y,e._close=K,Z()}(this,e,t)}var B=null!=h&&null!=d&&"body"in d.prototype;z.prototype=Object.create(T.prototype),z.prototype.CONNECTING=P,z.prototype.OPEN=I,z.prototype.CLOSED=R,z.prototype.close=function(){this._close()},z.CONNECTING=P,z.OPEN=I,z.CLOSED=R,z.prototype.withCredentials=void 0;var J,G=u;null==s||null!=u&&"withCredentials"in u.prototype||(G=z),J=function(e){e.EventSourcePolyfill=z,e.NativeEventSource=u,e.EventSource=G}(t),void 0!==J&&(e.exports=J)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:Qn:globalThis)}(Xn,Xn.exports);var Kn=Yn(Xn.exports.EventSourcePolyfill),Zn=Object.freeze({__proto__:null,default:Kn});e.BasePatch=_t,e.BaseTransaction=Ft,e.ClientError=rt,e.ObservablePatch=Ot,e.ObservableSanityClient=Cn,e.ObservableTransaction=Wt,e.Patch=$t,e.SanityClient=Sn,e.ServerError=nt,e.Transaction=Nt,e.createClient=On,e.default=jn,e.requester=_n,e.unstable__adapter=O,e.unstable__environment="browser",Object.defineProperty(e,"__esModule",{value:!0})}));
|