@sanity/client 7.2.1 → 7.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2401,7 +2401,7 @@ function defineDeprecatedCreateClient(createClient2) {
2401
2401
  return config.printNoDefaultExport(), createClient2(config$1);
2402
2402
  };
2403
2403
  }
2404
- var name = "@sanity/client", version = "7.2.1";
2404
+ var name = "@sanity/client", version = "7.2.2";
2405
2405
  const middleware = [
2406
2406
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
2407
2407
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),
package/dist/index.js CHANGED
@@ -2386,7 +2386,7 @@ function defineDeprecatedCreateClient(createClient2) {
2386
2386
  return printNoDefaultExport(), createClient2(config);
2387
2387
  };
2388
2388
  }
2389
- var name = "@sanity/client", version = "7.2.1";
2389
+ var name = "@sanity/client", version = "7.2.2";
2390
2390
  const middleware = [
2391
2391
  debug({ verbose: !0, namespace: "sanity:client" }),
2392
2392
  headers({ "User-Agent": `${name} ${version}` }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "7.2.1",
3
+ "version": "7.2.2",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -93,6 +93,7 @@
93
93
  "benchmark": "npm test -- bench",
94
94
  "prebuild": "npm run clean",
95
95
  "build": "pkg build --strict && pkg --strict && npm run rollup && npm run minify",
96
+ "check-esm-compatibility": "node scripts/check-esm-compatibility.mjs",
96
97
  "clean": "npx rimraf dist coverage umd/*.js",
97
98
  "coverage": "vitest run --coverage",
98
99
  "lint": "eslint . --max-warnings 0",
@@ -120,7 +121,7 @@
120
121
  },
121
122
  "dependencies": {
122
123
  "@sanity/eventsource": "^5.0.2",
123
- "get-it": "^8.6.7",
124
+ "get-it": "^8.6.9",
124
125
  "nanoid": "^3.3.11",
125
126
  "rxjs": "^7.0.0"
126
127
  },
@@ -21,7 +21,7 @@
21
21
 
22
22
  const e=!(typeof navigator>"u")&&"ReactNative"===navigator.product,t={timeout:e?6e4:12e4},r=function(r){const a={...t,..."string"==typeof r?{url:r}:r};if(a.timeout=n$1(a.timeout),a.query){const{url:t,searchParams:r}=function(t){const r=t.indexOf("?");if(-1===r)return {url:t,searchParams:new URLSearchParams};const n=t.slice(0,r),a=t.slice(r+1);if(!e)return {url:n,searchParams:new URLSearchParams(a)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const s=new URLSearchParams;for(const e of a.split("&")){const[t,r]=e.split("=");t&&s.append(o$1(t),o$1(r||""));}return {url:n,searchParams:s}}(a.url);for(const[e,o]of Object.entries(a.query)){if(void 0!==o)if(Array.isArray(o))for(const t of o)r.append(e,t);else r.append(e,o);const n=r.toString();n&&(a.url=`${t}?${n}`);}}return a.method=a.body&&!a.method?"POST":(a.method||"GET").toUpperCase(),a};function o$1(e){return decodeURIComponent(e.replace(/\+/g," "))}function n$1(e){if(false===e||0===e)return false;if(e.connect||e.socket)return e;const r=Number(e);return isNaN(r)?n$1(t.timeout):{connect:r,socket:r}}const a$2=/^https?:\/\//i,s$2=function(e){if(!a$2.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c$3(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
23
23
 
24
- const o=["request","response","progress","error","abort"],s$1=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r$1,a){const i=[],u=s$1.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=/* @__PURE__ */Object.create(null);let t=0;return {publish:function(t){for(const r in e)e[r](t);},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o];}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0, e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s);}catch(e){a=null,n=e;}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a);})(o,s,e)));}));t.abort.subscribe((()=>{l(),i&&i.abort();}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s$1.forEach((t=>{e[t]&&u[t].push(e[t]);})),i.push(e),l},l.clone=()=>n(i,a),r$1.forEach(l.use),l}var a$1,i,u$2=/* @__PURE__ */c$3(function(){if(i)return a$1;i=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return a$1=function(t){if(!t)return {};for(var r={},o=e(t).split("\n"),s=0;s<o.length;s++){var n=o[s],a=n.indexOf(":"),i=e(n.slice(0,a)).toLowerCase(),u=e(n.slice(a+1));typeof r[i]>"u"?r[i]=u:(l=r[i],"[object Array]"===Object.prototype.toString.call(l)?r[i].push(u):r[i]=[r[i],u]);}var l;return r}}());let l$1 = class l{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=void 0;}abort(){this.#s&&this.#s.abort();}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t;}setInit(e,t=true){this.#n=e,this.#a=t;}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#s=new AbortController,typeof EventTarget<"u"&&this.#s.signal instanceof EventTarget&&(r.signal=this.#s.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`;})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.();})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.();}));}};const c$2="function"==typeof XMLHttpRequest?"xhr":"fetch",h="xhr"===c$2?XMLHttpRequest:l$1,d$1=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),s={},n=e.applyMiddleware("interceptRequest",void 0,{adapter:c$2,context:e});if(n){const e=setTimeout(t,0,null,n);return {abort:()=>clearTimeout(e)}}let a=new h;a instanceof l$1&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??true);const i=o.headers,d=o.timeout;let p=false,f=false,b=false;if(a.onerror=e=>{m(a instanceof l$1?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.onabort=()=>{w(true),p=true;},a.onreadystatechange=()=>{d&&(w(),s.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=true,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:u$2(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText});}}();},a.open(o.method,o.url,true),a.withCredentials=!!o.withCredentials,i&&a.setRequestHeader)for(const e in i)i.hasOwnProperty(e)&&a.setRequestHeader(e,i[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:c$2,request:a,context:e}),a.send(o.body||null),d&&(s.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=true,a&&a.abort();}};function y(t){b=true,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r);}function w(e){(e||p||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket);}function m(e){if(f)return;w(true),f=true,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=true,r.request=o,t(r);}},p$1=(e=[],t=d$1)=>n(e,t),f$1="browser";
24
+ const o=["request","response","progress","error","abort"],n=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function s$1(r$1,a){const i=[],u=n.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=/* @__PURE__ */Object.create(null);let t=0;return {publish:function(t){for(const r in e)e[r](t);},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o];}}}}(),e)),{}),r=(e=>function(t,r,...o){const n="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0, e[t][r])(s,...o),!n||s);r++);return s})(u),n=r("processOptions",e);r("validateOptions",n);const s={options:n,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,n)=>((e,o,n)=>{let s=e,a=o;if(!s)try{a=r("onResponse",o,n);}catch(e){a=null,s=e;}s=s&&r("onError",s,n),s?t.error.publish(s):a&&t.response.publish(a);})(o,n,e)));}));t.abort.subscribe((()=>{l(),i&&i.abort();}));const c=r("onReturn",t,s);return c===t&&t.request.publish(s),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return n.forEach((t=>{e[t]&&u[t].push(e[t]);})),i.push(e),l},l.clone=()=>s$1(i,a),r$1.forEach(l.use),l}var a$1,i,u$2=/* @__PURE__ */c$3(function(){if(i)return a$1;i=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return a$1=function(t){if(!t)return {};for(var r={},o=e(t).split("\n"),n=0;n<o.length;n++){var s=o[n],a=s.indexOf(":"),i=e(s.slice(0,a)).toLowerCase(),u=e(s.slice(a+1));typeof r[i]>"u"?r[i]=u:(l=r[i],"[object Array]"===Object.prototype.toString.call(l)?r[i].push(u):r[i]=[r[i],u]);}var l;return r}}());let l$1 = class l{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#n;#s={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#n=void 0;}abort(){this.#n&&this.#n.abort();}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t;}setInit(e,t=true){this.#s=e,this.#a=t;}send(e){const t="arraybuffer"!==this.responseType,r={...this.#s,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#n=new AbortController,typeof EventTarget<"u"&&this.#n.signal instanceof EventTarget&&(r.signal=this.#n.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`;})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.();})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.();}));}};const c$2="function"==typeof XMLHttpRequest?"xhr":"fetch",h="xhr"===c$2?XMLHttpRequest:l$1,d$1=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),n={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:c$2,context:e});if(s){const e=setTimeout(t,0,null,s);return {abort:()=>clearTimeout(e)}}let a=new h;a instanceof l$1&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??true);const i=o.headers,d=o.timeout;let p=false,f=false,b=false;if(a.onerror=e=>{m(a instanceof l$1?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.onabort=()=>{w(true),p=true;},a.onreadystatechange=function(){d&&(w(),n.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&a&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=true,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:u$2(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText});}}();},a.open(o.method,o.url,true),a.withCredentials=!!o.withCredentials,i&&a.setRequestHeader)for(const e in i)i.hasOwnProperty(e)&&a.setRequestHeader(e,i[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:c$2,request:a,context:e}),a.send(o.body||null),d&&(n.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=true,a&&a.abort();}};function y(t){b=true,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r);}function w(e){(e||p||a&&a.readyState>=2&&n.connect)&&clearTimeout(n.connect),n.socket&&clearTimeout(n.socket);}function m(e){if(f)return;w(true),f=true,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=true,r.request=o,t(r);}},p$1=(e=[],t=d$1)=>s$1(e,t),f$1="browser";
25
25
 
26
26
  var a,c$1,u$1,l,p,d={exports:{}};/* @__PURE__ */c$3((p||(p=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n));})),t.splice(r,0,s);},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug");}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug");}catch{}return !e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return true;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return false;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=/* @__PURE__ */(()=>{let e=false;return ()=>{e||(e=true,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(l?u$1:(l=1,u$1=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(/* @__PURE__ */new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return "%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--;}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e);}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:true,configurable:false,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e;}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e,t){let s=0,n=0,r=-1,o=0;for(;s<e.length;)if(n<t.length&&(t[n]===e[s]||"*"===t[n]))"*"===t[n]?(r=n,o=s,n++):(s++,n++);else {if(-1===r)return false;n=r+1,o++,s=o;}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of s)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e);},t.enabled=function(e){for(const s of t.skips)if(n(e,s))return false;for(const s of t.names)if(n(e,s))return true;return false},t.humanize=function(){if(c$1)return a;c$1=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n;function o(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(o){if(!((o=String(o)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case "years":case "year":case "yrs":case "yr":case "y":return 315576e5*a;case "weeks":case "week":case "w":return a*r;case "days":case "day":case "d":return a*n;case "hours":case "hour":case "hrs":case "hr":case "h":return a*s;case "minutes":case "minute":case "mins":case "min":case "m":return a*t;case "seconds":case "second":case "secs":case "sec":case "s":return a*e;case "milliseconds":case "millisecond":case "msecs":case "msec":case "ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?o(c,u,n,"day"):u>=s?o(c,u,s,"hour"):u>=t?o(c,u,t,"minute"):u>=e?o(c,u,e,"second"):c+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");},Object.keys(e).forEach((s=>{t[s]=e[s];})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return "[UnexpectedJSONParseError]: "+e.message}};}(d,d.exports)),d.exports));const F=typeof Buffer>"u"?()=>false:e=>Buffer.isBuffer(e);function O$1(e){return "[object Object]"===Object.prototype.toString.call(e)}function j(e){if(false===O$1(e))return false;const t=e.constructor;if(void 0===t)return true;const s=t.prototype;return !(false===O$1(s)||false===s.hasOwnProperty("isPrototypeOf"))}const v=["boolean","string","number"];function x(){return {processOptions:e=>{const t=e.body;return !t||"function"==typeof t.pipe||F(t)||-1===v.indexOf(typeof t)&&!Array.isArray(t)&&!j(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function E$1(e){return {onResponse:s=>{const n=s.headers["content-type"]||"",r=e&&e.force||-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},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 R={};typeof globalThis<"u"?R=globalThis:typeof window<"u"?R=window:typeof global<"u"?R=global:typeof self<"u"&&(R=self);var q=R;function A(e={}){const t=e.implementation||q.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return {onReturn:(e,s)=>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(s),()=>e.abort.publish())))}}function S$1(){return {onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,s=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;s.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"));}}}var $=(e,t,s)=>("GET"===s.method||"HEAD"===s.method)&&(e.isNetworkError||false);function _$1(e){return 100*Math.pow(2,e)+100*Math.random()}const P=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||_$1,n=e.shouldRetry;return {onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,a=o.retryDelay||s,c=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(l=o.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,o)||u>=i)return e;var l;const p=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(p)),a(u)),null}}})({shouldRetry:$,...e});P.shouldRetry=$;
27
27
 
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}const r=!(typeof navigator>"u")&&"ReactNative"===navigator.product,n={timeout:r?6e4:12e4},o=function(e){const t={...n,..."string"==typeof e?{url:e}:e};if(t.timeout=i(t.timeout),t.query){const{url:e,searchParams:n}=function(e){const t=e.indexOf("?");if(-1===t)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,t),o=e.slice(t+1);if(!r)return{url:n,searchParams:new URLSearchParams(o)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const i=new URLSearchParams;for(const e of o.split("&")){const[t,r]=e.split("=");t&&i.append(s(t),s(r||""))}return{url:n,searchParams:i}}(t.url);for(const[r,o]of Object.entries(t.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)n.append(r,e);else n.append(r,o);const s=n.toString();s&&(t.url=`${e}?${s}`)}}return t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t};function s(e){return decodeURIComponent(e.replace(/\+/g," "))}function i(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?i(n.timeout):{connect:t,socket:t}}const a=/^https?:\/\//i,c=function(e){if(!a.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const l=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const r=[],n=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[o],validateOptions:[c]});function s(e){const r=l.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),o=(e=>function(t,r,...n){const o="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...n),!o||s);r++);return s})(n),s=o("processOptions",e);o("validateOptions",s);const i={options:s,channels:r,applyMiddleware:o};let a;const c=r.request.subscribe((e=>{a=t(e,((t,n)=>((e,t,n)=>{let s=e,i=t;if(!s)try{i=o("onResponse",t,n)}catch(e){i=null,s=e}s=s&&o("onError",s,n),s?r.error.publish(s):i&&r.response.publish(i)})(t,n,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=o("onReturn",r,i);return u===r&&r.request.publish(i),u}return s.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&n.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return h.forEach((t=>{e[t]&&n[t].push(e[t])})),r.push(e),s},s.clone=()=>d(r,t),e.forEach(s.use),s}var p,f,y=u(function(){if(f)return p;f=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return p=function(t){if(!t)return{};for(var r={},n=e(t).split("\n"),o=0;o<n.length;o++){var s=n[o],i=s.indexOf(":"),a=e(s.slice(0,i)).toLowerCase(),c=e(s.slice(i+1));typeof r[a]>"u"?r[a]=c:(u=r[a],"[object Array]"===Object.prototype.toString.call(u)?r[a].push(c):r[a]=[r[a],c])}var u;return r}}());let b=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#s={};#i;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#n[e]=t}setInit(e,t=!0){this.#s=e,this.#i=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#s,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#i&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}};const g="function"==typeof XMLHttpRequest?"xhr":"fetch",v="xhr"===g?XMLHttpRequest:b,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:g,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new v;i instanceof b&&"object"==typeof n.fetch&&i.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,h=!1;if(i.onerror=e=>{f(i instanceof b?e instanceof Error?e:new Error(`Request error while attempting to reach is ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.ontimeout=e=>{f(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.onabort=()=>{p(!0),u=!0},i.onreadystatechange=()=>{c&&(p(),o.socket=setTimeout((()=>d("ESOCKETTIMEDOUT")),c.socket)),!u&&4===i.readyState&&0!==i.status&&function(){if(!(u||l||h)){if(0===i.status)return void f(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:i.response||(""===i.responseType||"text"===i.responseType?i.responseText:""),url:n.url,method:n.method,headers:y(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}}()},i.open(n.method,n.url,!0),i.withCredentials=!!n.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return n.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:g,request:i,context:e}),i.send(n.body||null),c&&(o.connect=setTimeout((()=>d("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,i&&i.abort()}};function d(t){h=!0,i.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function p(e){(e||u||i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function f(e){if(l)return;p(!0),l=!0,i=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},w=(e=[],t=m)=>d(e,t);var C,E,I,_,x,R={exports:{}};x||(x=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(_?I:(_=1,I=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,o=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,s=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=function(){if(E)return C;E=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return C=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(s){if(!((s=String(s)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=r?s(c,u,r,"hour"):u>=t?s(c,u,t,"minute"):u>=e?s(c,u,e,"second"):c+" ms"):function(o){var s=Math.abs(o);return s>=n?Math.round(o/n)+"d":s>=r?Math.round(o/r)+"h":s>=t?Math.round(o/t)+"m":s>=e?Math.round(o/e)+"s":o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(R,R.exports));const S=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function q(e){return"[object Object]"===Object.prototype.toString.call(e)}const $=["boolean","string","number"];function T(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||S(t)||-1===$.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===q(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 O(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},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 j={};typeof globalThis<"u"?j=globalThis:typeof window<"u"?j=window:typeof global<"u"?j=global:typeof self<"u"&&(j=self);var A=j;function P(e={}){const t=e.implementation||A.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 D=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function k(e){return 100*Math.pow(2,e)+100*Math.random()}const F=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||k,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,c=s.shouldRetry||n,u=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,s)||u>=i)return e;var l;const h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(h)),a(u)),null}}})({shouldRetry:D,...e});F.shouldRetry=D;var M=function(e,t){return M=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])},M(e,t)};function U(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}M(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function N(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function z(e,t){var r,n,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)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 s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}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,c])}}}function L(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 H(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 V(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 B(e){return this instanceof B?(this.v=e,this):new B(e)}function W(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof B?Promise.resolve(e.value.v).then(c,u):l(s[0][2],e)}(o[e](t))}catch(e){l(s[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function J(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=L(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 G(e){return"function"==typeof e}function Y(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 Q=Y((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 X(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var K=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=L(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 c=this.initialTeardown;if(G(c))try{c()}catch(e){o=e instanceof Q?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=L(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{te(d)}catch(e){o=null!=o?o:[],e instanceof Q?o=V(V([],H(o)),H(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 Q(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)te(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)&&X(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&X(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),Z=K.EMPTY;function ee(e){return e instanceof K||e&&"closed"in e&&G(e.remove)&&G(e.add)&&G(e.unsubscribe)}function te(e){G(e)?e():e.unsubscribe()}var re={Promise:void 0},ne=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,V([e,t],H(r)))};function oe(e){ne((function(){throw e}))}function se(){}function ie(e){e()}var ae=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ee(t)&&t.add(r)):r.destination=he,r}return U(t,e),t.create=function(e,t,r){return new ue(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}(K),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){le(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){le(e)}else le(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){le(e)}},e}(),ue=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=G(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new ce(o),s}return U(t,e),t}(ae);function le(e){oe(e)}var he={closed:!0,next:se,error:function(e){throw e},complete:se},de="function"==typeof Symbol&&Symbol.observable||"@@observable";function pe(e){return e}function fe(e){return 0===e.length?pe:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ye=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 ae||function(e){return e&&G(e.next)&&G(e.error)&&G(e.complete)}(n)&&ee(n)?e:new ue(e,t,r);return ie((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=be(t))((function(t,n){var o=new ue({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[de]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=be(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 be(e){var t;return null!==(t=null!=e?e:re.Promise)&&void 0!==t?t:Promise}function ge(e){return function(t){if(function(e){return G(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 ve(e,t,r,n,o){return new me(e,t,r,n,o)}var me=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 U(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}(ae),we=Y((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Ce=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return U(t,e),t.prototype.lift=function(e){var t=new Ee(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new we},t.prototype.next=function(e){var t=this;ie((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=L(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;ie((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;ie((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,s=r.observers;return n||o?Z:(this.currentObservers=null,s.push(e),new K((function(){t.currentObservers=null,X(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new ye;return e.source=this,e},t.create=function(e,t){return new Ee(e,t)},t}(ye),Ee=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return U(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:Z},t}(Ce),Ie={now:function(){return(Ie.delegate||Date).now()},delegate:void 0},_e=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Ie);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=r,o._timestampProvider=n,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,r),o}return U(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,i=r._timestampProvider,a=r._windowTime;n||(o.push(t),!s&&o.push(i.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,s=(o?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!o){for(var i=r.now(),a=0,c=1;c<n.length&&n[c]<=i;c+=2)a=c;a&&n.splice(0,a+1)}},t}(Ce),xe=function(e){function t(t,r){return e.call(this)||this}return U(t,e),t.prototype.schedule=function(e,t){return this},t}(K),Re=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,V([e,t],H(r)))},Se=function(e){return clearInterval(e)},qe=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return U(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,o=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(o,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),Re(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&Se(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,X(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(xe),$e=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Ie.now,e}(),Te=new(function(e){function t(t,r){void 0===r&&(r=$e.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return U(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}($e))(qe),Oe=new ye((function(e){return e.complete()}));function je(e){return e[e.length-1]}function Ae(e){return(t=je(e))&&G(t.schedule)?e.pop():void 0;var t}var Pe=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function De(e){return G(null==e?void 0:e.then)}function ke(e){return G(e[de])}function Fe(e){return Symbol.asyncIterator&&G(null==e?void 0:e[Symbol.asyncIterator])}function Me(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.")}var Ue="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ne(e){return G(null==e?void 0:e[Ue])}function ze(e){return W(this,arguments,(function(){var t,r,n;return z(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,B(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,B(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,B(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]}}))}))}function Le(e){return G(null==e?void 0:e.getReader)}function He(e){if(e instanceof ye)return e;if(null!=e){if(ke(e))return o=e,new ye((function(e){var t=o[de]();if(G(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Pe(e))return n=e,new ye((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(De(e))return r=e,new ye((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,oe)}));if(Fe(e))return Ve(e);if(Ne(e))return t=e,new ye((function(e){var r,n;try{for(var o=L(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(Le(e))return Ve(ze(e))}var t,r,n,o;throw Me(e)}function Ve(e){return new ye((function(t){(function(e,t){var r,n,o,s;return N(this,void 0,void 0,(function(){var i,a;return z(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=J(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.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 Be(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),ge((function(r,n){r.subscribe(ve(n,(function(r){return Be(n,e,(function(){return n.next(r)}),t)}),(function(){return Be(n,e,(function(){return n.complete()}),t)}),(function(r){return Be(n,e,(function(){return n.error(r)}),t)})))}))}function Je(e,t){return void 0===t&&(t=0),ge((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function Ge(e,t){if(!e)throw new Error("Iterable cannot be null");return new ye((function(r){Be(r,t,(function(){var n=e[Symbol.asyncIterator]();Be(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function Ye(e,t){if(null!=e){if(ke(e))return function(e,t){return He(e).pipe(Je(t),We(t))}(e,t);if(Pe(e))return function(e,t){return new ye((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(De(e))return function(e,t){return He(e).pipe(Je(t),We(t))}(e,t);if(Fe(e))return Ge(e,t);if(Ne(e))return function(e,t){return new ye((function(r){var n;return Be(r,t,(function(){n=e[Ue](),Be(r,t,(function(){var e,t,o;try{t=(e=n.next()).value,o=e.done}catch(e){return void r.error(e)}o?r.complete():r.next(t)}),0,!0)})),function(){return G(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(Le(e))return function(e,t){return Ge(ze(e),t)}(e,t)}throw Me(e)}function Qe(e,t){return t?Ye(e,t):He(e)}function Xe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qe(e,Ae(e))}function Ke(e,t){var r=G(e)?e:function(){return e};return new ye((function(e){return e.error(r())}))}var Ze=Y((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function et(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 Ze)}})}))}function tt(e,t){return new Promise((function(t,r){var n=new ue({next:function(e){t(e),n.unsubscribe()},error:r,complete:function(){r(new Ze)}});e.subscribe(n)}))}function rt(e,t){return ge((function(r,n){var o=0;r.subscribe(ve(n,(function(r){n.next(e.call(t,r,o++))})))}))}var nt=Array.isArray;function ot(e){return rt((function(t){return function(e,t){return nt(t)?e.apply(void 0,V([],H(t))):e(t)}(e,t)}))}function st(e,t,r){t()}function it(e,t,r){return void 0===r&&(r=1/0),G(t)?it((function(r,n){return rt((function(e,o){return t(r,e,n,o)}))(He(e(r,n)))}),r):("number"==typeof t&&(r=t),ge((function(t,n){return function(e,t,r,n,o,s,i){var a=[],c=0,u=0,l=!1,h=function(){!l||a.length||c||t.complete()},d=function(e){c++;var o=!1;He(r(e,u++)).subscribe(ve(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{for(c--;a.length&&c<n;)e=void 0,e=a.shift(),i||d(e);h()}catch(e){t.error(e)}var e})))};return e.subscribe(ve(t,(function(e){return c<n?d(e):a.push(e)}),(function(){l=!0,h()}))),function(){}}(t,n,e,r)})))}function at(e){return void 0===e&&(e=1/0),it(pe,e)}function ct(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return at(1)(Qe(e,Ae(e)))}function ut(e){return new ye((function(t){He(e()).subscribe(t)}))}function lt(e,t,r){return void 0===r&&(r=Te),new ye((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?1e3-r.now():e;o<0&&(o=0);var s=0;return r.schedule((function(){t.closed||(t.next(s++),t.complete())}),o)}))}function ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Ae(e),n=function(e,t){return"number"==typeof je(e)?e.pop():t}(e,1/0),o=e;return o.length?1===o.length?He(o[0]):at(n)(Qe(o,r)):Oe}var dt=Array.isArray;function pt(e,t){return ge((function(r,n){var o=0;r.subscribe(ve(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function ft(e){return ge((function(t,r){var n,o=null,s=!1;o=t.subscribe(ve(r,void 0,void 0,(function(i){n=He(e(i,ft(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):s=!0}))),s&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function yt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return G(je(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fe(e)}(yt.apply(void 0,V([],H(e))),ot(r)):ge((function(t,r){var n,o,s;(n=V([t],H(function(e){return 1===e.length&&dt(e[0])?e[0]:e}(e))),void 0===s&&(s=pe),function(e){st(0,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,c=function(t){st(0,(function(){var c=Qe(n[t],o),u=!1;c.subscribe(ve(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function bt(e){return ge((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}function gt(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new Ce}:t,n=e.resetOnError,o=void 0===n||n,s=e.resetOnComplete,i=void 0===s||s,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,s,a=0,u=!1,l=!1,h=function(){null==n||n.unsubscribe(),n=void 0},d=function(){h(),t=s=void 0,u=l=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return ge((function(e,f){a++,l||u||h();var y=s=null!=s?s:r();f.add((function(){0!==--a||l||u||(n=vt(p,c))})),y.subscribe(f),!t&&a>0&&(t=new ue({next:function(e){return y.next(e)},error:function(e){l=!0,h(),n=vt(d,o,e),y.error(e)},complete:function(){u=!0,h(),n=vt(d,i),y.complete()}}),He(e).subscribe(t))}))(e)}}function vt(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var o=new ue({next:function(){o.unsubscribe(),e()}});return He(t.apply(void 0,V([],H(r)))).subscribe(o)}}else e()}var mt={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},wt={0:8203,1:8204,2:8205,3:65279},Ct=new Array(4).fill(String.fromCodePoint(wt[0])).join("");function Et(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!(!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(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`${Ct}${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(wt[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(wt).map((e=>e.reverse()))),Object.fromEntries(Object.entries(mt).map((e=>e.reverse())));var It=`${Object.values(mt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,_t=new RegExp(`[${It}]{4,}`,"gu");function xt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(_t,""),encoded:(null==(t=e.match(_t))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}const Rt=".",St=`drafts${Rt}`,qt=`versions${Rt}`;function $t(e){return e.startsWith(St)}function Tt(e){return e.startsWith(qt)}function Ot(e,t){if("drafts"===t||"published"===t)throw new Error('Version can not be "published" or "drafts"');return`${qt}${t}${Rt}${At(e)}`}function jt(e){if(!Tt(e))return;const[t,r,...n]=e.split(Rt);return r}function At(e){return Tt(e)?e.split(Rt).slice(2).join(Rt):$t(e)?e.slice(St.length):e}let Pt=e=>crypto.getRandomValues(new Uint8Array(e));class Dt extends Error{response;statusCode=400;responseBody;details;constructor(e){const t=Ft(e);super(t.message),Object.assign(this,t)}}class kt extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=Ft(e);super(t.message),Object.assign(this,t)}}function Ft(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Ut(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return Mt(e)&&Mt(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return Mt(e)&&Mt(e.error)&&"actionError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>e.error?.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 Mt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ut(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class Nt extends Error{projectId;addOriginUrl;constructor({projectId:e}){super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e;const t=new URL(`https://sanity.io/manage/project/${e}/api`);if(typeof location<"u"){const{origin:e}=location;t.searchParams.set("cors","add"),t.searchParams.set("origin",e),this.addOriginUrl=t,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${t}`}else this.message=`The current origin is not allowed to connect to the Live Content API. Change your configuration here: ${t}`}}const zt={onResponse:e=>{if(e.statusCode>=500)throw new kt(e);if(e.statusCode>=400)throw new Dt(e);return e}};function Lt(){const e={};return{onResponse:t=>{const r=t.headers["x-sanity-warning"],n=Array.isArray(r)?r:[r];for(const t of n)!t||e[t]||(e[t]=!0,console.warn(t));return t}}}function Ht(e){return w([F({shouldRetry:Vt}),...e,Lt(),T(),O(),{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"))}},zt,P({implementation:ye})])}function Vt(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)||F.shouldRetry(e,t,r)}function Bt(e){return"https://www.sanity.io/help/"+e}const Wt=["image","file"],Jt=["before","after","replace"],Gt=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")},Yt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},Qt=(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`)},Xt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);Qt(e,t._id)},Kt=(e,t)=>{if(!t._type)throw new Error(`\`${e}()\` requires that the document contains a type (\`_type\` property)`);((e,t)=>{if("string"!=typeof t)throw new Error(`\`${e}()\`: \`${t}\` is not a valid document type`)})(e,t._type)},Zt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},er=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},tr=e=>{if(!e["~experimental_resource"])throw new Error("`resource` must be provided to perform resource queries");const{type:t,id:r}=e["~experimental_resource"];switch(t){case"dataset":if(2!==r.split(".").length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return;case"dashboard":case"media-library":case"canvas":return;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}},rr=(e,t)=>{if(t["~experimental_resource"])throw new Error(`\`${e}\` does not support resource-based operations`)};const nr=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),or=nr(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),sr=nr(["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."]),ir=nr(["The Sanity client is configured with the `perspective` set to `drafts` or `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."]),ar=nr(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),cr=nr(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Bt("js-client-browser-token")} for more information and how to hide this warning.`]),ur=nr(["You have configured Sanity client to use a token, but also provided `withCredentials: true`.","This is no longer supported - only token will be used - remove `withCredentials: true`."]),lr=nr(["Using the Sanity client without specifying an API version is deprecated.",`See ${Bt("js-client-api-version")}`]),hr=nr(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),dr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},pr=["localhost","127.0.0.1","0.0.0.0"];function fr(e){if(Array.isArray(e)&&e.length>1&&e.includes("raw"))throw new TypeError('Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives')}const yr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||dr.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||lr();const n={...dr,...r},o=n.useProjectHostname&&!n["~experimental_resource"];if(typeof Promise>"u"){const e=Bt("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(n["~experimental_resource"]&&tr(n),typeof n.perspective<"u"&&fr(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!==pr.indexOf(e))(window.location.hostname),a=!!n.token;n.withCredentials&&a&&(ur(),n.withCredentials=!1),s&&i&&a&&!0!==n.ignoreBrowserTokenWarning?cr():typeof n.useCdn>"u"&&sr(),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&&Gt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?er(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===dr.apiHost,!0===n.useCdn&&n.withCredentials&&or(),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 c=n.apiHost.split("://",2),u=c[0],l=c[1],h=n.isDefaultApi?"apicdn.sanity.io":l;return o?(n.url=`${u}://${n.projectId}.${l}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${h}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n};class br extends Error{name="ConnectionFailedError"}class gr extends Error{name="DisconnectError";reason;constructor(e,t,r={}){super(e,r),this.reason=t}}class vr extends Error{name="ChannelError";data;constructor(e,t){super(e),this.data=t}}class mr extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class wr extends Error{name="MessageParseError"}const Cr=["channelError","disconnect"];function Er(e,t){return ut((()=>{const t=e();return(r=t)&&(r instanceof ye||G(r.lift)&&G(r.subscribe))?t:Xe(t);var r})).pipe(it((e=>function(e,t){return new ye((r=>{const n=t.includes("open"),o=t.includes("reconnect");function s(t){if("data"in t){const[e,n]=Ir(t);r.error(e?new wr("Unable to parse EventSource error message",{cause:n}):new mr((n?.data).message,n))}else e.readyState===e.CLOSED?r.error(new br("EventSource connection failed")):o&&r.next({type:"reconnect"})}function i(){r.next({type:"open"})}function a(e){const[t,n]=Ir(e);var o;t?r.error(new wr("Unable to parse EventSource message",{cause:t})):"channelError"!==e.type?"disconnect"!==e.type?r.next({type:e.type,id:e.lastEventId,...n.data?{data:n.data}:{}}):r.error(new gr(`Server disconnected client: ${n.data?.reason||"unknown error"}`)):r.error(new vr((o=n?.data,o.error?o.error.description?o.error.description:"string"==typeof o.error?o.error:JSON.stringify(o.error,null,2):o.message||"Unknown listener error"),n.data))}e.addEventListener("error",s),n&&e.addEventListener("open",i);const c=[...new Set([...Cr,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return c.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",s),n&&e.removeEventListener("open",i),c.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function Ir(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,..._r(t)?{}:{data:t}}]}catch(e){return[e,null]}}function _r(e){for(const t in e)return!1;return!0}function xr(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}`)}class Rr{selection;operations;constructor(e,t={}){this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Yt("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===Jt.indexOf(e)){const e=Jt.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{...xr(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return Yt(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)}}class Sr extends Rr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new Sr(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}class qr extends Rr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new qr(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}const $r={returnDocuments:!1};class Tr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return Yt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Yt(t,e),Xt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Yt(t,e),Xt(t,e),this._add({[t]:e})}delete(e){return Qt("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}}class Or extends Tr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Or([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},$r,e||{}))}patch(e,t){const r="function"==typeof t,n="object"==typeof e&&("query"in e||"id"in e);if("string"!=typeof e&&e instanceof qr)return this._add({patch:e.serialize()});if(r){const r=t(new qr(e,{},this.#a));if(!(r instanceof qr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new qr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class jr extends Tr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new jr([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},$r,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Sr)return this._add({patch:e.serialize()});if(r){const r=t(new Sr(e,{},this.#a));if(!(r instanceof Sr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}const Ar=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:s,returnQuery:i,...a}=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(a))t&&n.append(e,`${t}`);return!1===i&&n.append("returnQuery","false"),!1===s&&n.append("includeMutations","false"),`?${n}`},Pr=(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},Dr=e=>"response"===e.type,kr=e=>e.body;function Fr(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?xt(o):o,c=!1===s.filterResponse?e=>e:e=>e.result,{cache:u,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},d=Qr(e,t,"query",{query:n,params:a},typeof u<"u"||typeof l<"u"?{...h,fetch:{cache:u,next:l}}:h);return i.enabled?d.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yt.apply(void 0,V([],H(e)))}(Qe(Promise.resolve().then((function(){return wo})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),rt((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return c({...e,result:r})}))):d.pipe(rt(c))}function Mr(e,t,r,n={}){return tn(e,t,{uri:nn(e,"doc",(()=>{if(!n.releaseId)return r;const e=jt(r);if(!e){if($t(r))throw new Error(`The document ID (\`${r}\`) is a draft, but \`options.releaseId\` is set as \`${n.releaseId}\``);return Ot(r,n.releaseId)}if(e!==n.releaseId)throw new Error(`The document ID (\`${r}\`) is already a version of \`${e}\` release, but this does not match the provided \`options.releaseId\` (\`${n.releaseId}\`)`);return r})()),json:!0,tag:n.tag,signal:n.signal}).pipe(pt(Dr),rt((e=>e.body.documents&&e.body.documents[0])))}function Ur(e,t,r,n={}){return tn(e,t,{uri:nn(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(pt(Dr),rt((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 Nr(e,t,r,n={}){return Qr(e,t,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:r}},n)}function zr(e,t,r,n){return Xt("createIfNotExists",r),Xr(e,t,r,"createIfNotExists",n)}function Lr(e,t,r,n){return Xt("createOrReplace",r),Xr(e,t,r,"createOrReplace",n)}function Hr(e,t,r,n,o){return Xt("createVersion",r),Kt("createVersion",r),Yr(e,t,{actionType:"sanity.action.document.version.create",publishedId:n,document:r},o)}function Vr(e,t,r,n){return Qr(e,t,"mutate",{mutations:[{delete:xr(r)}]},n)}function Br(e,t,r,n=!1,o){return Yr(e,t,{actionType:"sanity.action.document.version.discard",versionId:r,purge:n},o)}function Wr(e,t,r,n){return Xt("replaceVersion",r),Kt("replaceVersion",r),Yr(e,t,{actionType:"sanity.action.document.version.replace",document:r},n)}function Jr(e,t,r,n,o){return Yr(e,t,{actionType:"sanity.action.document.version.unpublish",versionId:r,publishedId:n},o)}function Gr(e,t,r,n){let o;o=r instanceof qr||r instanceof Sr?{patch:r.serialize()}:r instanceof Or||r instanceof jr?r.serialize():r;return Qr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function Yr(e,t,r,n){return Qr(e,t,"actions",{actions:Array.isArray(r)?r:[r],transactionId:n&&n.transactionId||void 0,skipCrossDatasetReferenceValidation:n&&n.skipCrossDatasetReferenceValidation||void 0,dryRun:n&&n.dryRun||void 0},n)}function Qr(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,c=s||i?"":Ar(n),u=!s&&!i&&c.length<11264,l=u?c:"",h=o.returnFirst,{timeout:d,token:p,tag:f,headers:y,returnQuery:b,lastLiveEventId:g,cacheMode:v}=o;return tn(e,t,{method:u?"GET":"POST",uri:nn(e,r,l),json:!0,body:u?void 0:n,query:s&&Pr(o),timeout:d,headers:y,token:p,tag:f,returnQuery:b,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(g)?g[0]:g,cacheMode:v,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(pt(Dr),rt(kr),rt((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return h?t[0]&&t[0].document:t.map((e=>e.document));const r=h?"documentId":"documentIds",n=h?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function Xr(e,t,r,n,o={}){return Qr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}const Kr=e=>void 0!==e.config().dataset&&void 0!==e.config().projectId||void 0!==e.config()["~experimental_resource"],Zr=(e,t)=>Kr(e)&&t.startsWith(nn(e,"query")),en=(e,t)=>t.startsWith("/data/")||Zr(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"mutate")))(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"doc","")))(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"listen")))(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"history","")))(e,t);function tn(e,t,r){const n=r.url||r.uri,o=e.config(),s=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&en(e,n):r.canUseCdn;let i=(r.useCdn??o.useCdn)&&s;const a=r.tag&&o.requestTagPrefix?[o.requestTagPrefix,r.tag].join("."):r.tag||o.requestTagPrefix;if(a&&null!==r.tag&&(r.query={tag:er(a),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&Zr(e,n)){const e=r.resultSourceMap??o.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||o.perspective;typeof t<"u"&&("previewDrafts"===t&&ar(),fr(t),r.query={perspective:Array.isArray(t)?t.join(","):t,...r.query},(Array.isArray(t)&&t.length>0||"previewDrafts"===t||"drafts"===t)&&i&&(i=!1,ir())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query}),i&&"noStale"==r.cacheMode&&(r.query={cacheMode:"noStale",...r.query})}const c=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r["X-Sanity-Project-ID"]=e.projectId);const o=!!(typeof t.withCredentials>"u"?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})}(o,Object.assign({},r,{url:on(e,n,i)})),u=new ye((e=>t(c,o.requester).subscribe(e)));return r.signal?u.pipe((l=r.signal,e=>new ye((t=>{const r=()=>t.error(function(e){if(sn)return new DOMException(e?.reason??"The operation was aborted.","AbortError");const t=new Error(e?.reason??"The operation was aborted.");return t.name="AbortError",t}(l));if(l&&l.aborted)return void r();const n=e.subscribe(t);return l.addEventListener("abort",r),()=>{l.removeEventListener("abort",r),n.unsubscribe()}})))):u;var l}function rn(e,t,r){return tn(e,t,r).pipe(pt((e=>"response"===e.type)),rt((e=>e.body)))}function nn(e,t,r){const n=e.config();if(n["~experimental_resource"]){tr(n);return`${an(n)}/${void 0!==r?`${t}/${r}`:t}`.replace(/\/($|\?)/,"$1")}const o=`/${t}/${Zt(n)}`;return`/data${void 0!==r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function on(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const sn=!!globalThis.DOMException;const an=e=>{if(!e["~experimental_resource"])throw new Error("`resource` must be provided to perform resource queries");const{type:t,id:r}=e["~experimental_resource"];switch(t){case"dataset":{const e=r.split(".");if(2!==e.length)throw new Error('Dataset ID must be in the format "project.dataset"');return`/projects/${e[0]}/datasets/${e[1]}`}case"canvas":return`/canvases/${r}`;case"media-library":return`/media-libraries/${r}`;case"dashboard":return`/dashboards/${r}`;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}};function cn(e,t,r){const n=Zt(e.config());return rn(e,t,{method:"POST",uri:`/agent/action/generate/${n}`,body:r})}function un(e,t,r){const n=Zt(e.config());return rn(e,t,{method:"POST",uri:`/agent/action/transform/${n}`,body:r})}function ln(e,t,r){const n=Zt(e.config());return rn(e,t,{method:"POST",uri:`/agent/action/translate/${n}`,body:r})}class hn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return cn(this.#a,this.#c,e)}transform(e){return un(this.#a,this.#c,e)}translate(e){return ln(this.#a,this.#c,e)}}class dn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return et(cn(this.#a,this.#c,e))}transform(e){return et(un(this.#a,this.#c,e))}translate(e){return et(ln(this.#a,this.#c,e))}}class pn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return yn(this.#a,this.#c,e,t,r)}}class fn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return et(yn(this.#a,this.#c,e,t,r).pipe(pt((e=>"response"===e.type)),rt((e=>e.body.document))))}}function yn(e,t,r,n,o={}){(e=>{if(-1===Wt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${Wt.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=e.config(),a=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:u,title:l,description:h,creditLine:d,filename:p,source:f}=a,y={label:u,title:l,description:h,filename:p,meta:s,creditLine:d};return f&&(y.sourceId=f.id,y.sourceName=f.name,y.sourceUrl=f.url),tn(e,t,{tag:c,method:"POST",timeout:a.timeout||0,uri:bn(i,r),headers:a.contentType?{"Content-Type":a.contentType}:{},query:y,body:n})}function bn(e,t){const r="image"===t?"images":"files";if(e["~experimental_resource"]){const{type:t,id:n}=e["~experimental_resource"];switch(t){case"dataset":throw new Error("Assets are not supported for dataset resources, yet. Configure the client with `{projectId: <projectId>, dataset: <datasetId>}` instead.");case"canvas":return`/canvases/${n}/assets/${r}`;case"media-library":return`/media-libraries/${n}/upload`;case"dashboard":return`/dashboards/${n}/assets/${r}`;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}}return`assets/${r}/${Zt(e)}`}const gn=ut((()=>Promise.resolve().then((function(){return To})))).pipe(rt((({default:e})=>e)),(wn=1,gt({connector:function(){return new _e(wn,vn,mn)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})));var vn,mn,wn;function Cn(){return function(e){return e.pipe(ft(((e,t)=>e instanceof br?ct(Xe({type:"reconnect"}),lt(1e3).pipe(it((()=>t)))):Ke((()=>e)))))}}const En=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","tag"],In={includeResult:!0};function _n(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...(h=r,d=In,Object.keys(d).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?d[t]:h[t],e)),{})),tag:a},u=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(c,En),l=`${n}${nn(this,"listen",Ar({query:e,params:t,options:{tag:a,...u}}))}`;var h,d;if(l.length>14800)return Ke((()=>new Error("Query too large for listener")));const p=c.events?c.events:["mutation"],f={};return s&&(f.withCredentials=!0),o&&(f.headers={Authorization:`Bearer ${o}`}),Er((()=>(typeof EventSource>"u"||f.headers?gn:Xe(EventSource)).pipe(rt((e=>new e(l,f))))),p).pipe(Cn(),pt((e=>p.includes(e.type))),rt((e=>({type:e.type,..."data"in e?e.data:{}}))))}function xn(e,t){return function(e){return t=>{let r,n=!1;const{predicate:o,...s}=e,i=t.pipe((l=G(a=t=>{e.predicate(t)&&(n=!0,r=t)})||c||u?{next:a,error:c,complete:u}:a)?ge((function(e,t){var r;null===(r=l.subscribe)||void 0===r||r.call(l);var n=!0;e.subscribe(ve(t,(function(e){var r;null===(r=l.next)||void 0===r||r.call(l,e),t.next(e)}),(function(){var e;n=!1,null===(e=l.complete)||void 0===e||e.call(l),t.complete()}),(function(e){var r;n=!1,null===(r=l.error)||void 0===r||r.call(l,e),t.error(e)}),(function(){var e,t;n&&(null===(e=l.unsubscribe)||void 0===e||e.call(l)),null===(t=l.finalize)||void 0===t||t.call(l)})))})):pe,bt((()=>{n=!1,r=void 0})),gt(s));var a,c,u,l;return ht(i,new ye((e=>{n&&e.next(r),e.complete()})))}}("function"==typeof e?{predicate:e,...t}:e)}const Rn="2021-03-25";class Sn{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t}={}){rr("live",this.#a.config());const{projectId:r,apiVersion:n,token:o,withCredentials:s,requestTagPrefix:i}=this.#a.config(),a=n.replace(/^v/,"");if("X"!==a&&a<Rn)throw new Error(`The live events API requires API version ${Rn} or later. The current API version is ${a}. Please update your API version to use this feature.`);if(e&&!o&&!s)throw new Error("The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role.");const c=nn(this.#a,"live/events"),u=new URL(this.#a.getUrl(c,!1)),l=t&&i?[i,t].join("."):t;l&&u.searchParams.set("tag",l),e&&u.searchParams.set("includeDrafts","true");const h={};e&&o&&(h.headers={Authorization:`Bearer ${o}`}),e&&s&&(h.withCredentials=!0);const d=`${u.href}::${JSON.stringify(h)}`,p=qn.get(d);if(p)return p;const f=Er((()=>(typeof EventSource>"u"||h.headers?gn:Xe(EventSource)).pipe(rt((e=>new e(u.href,h))))),["message","restart","welcome","reconnect","goaway"]).pipe(Cn(),rt((e=>{if("message"===e.type){const{data:t,...r}=e;return{...r,tags:t.tags}}return e}))),y=function(e,t){return new ye((r=>{const n=new AbortController,o=n.signal;return fetch(e,{...t,signal:n.signal}).then((e=>{r.next(e),r.complete()}),(e=>{o.aborted||r.error(e)})),()=>n.abort()}))}(u,{method:"OPTIONS",mode:"cors",credentials:h.withCredentials?"include":"omit",headers:h.headers}).pipe(it((()=>Oe)),ft((()=>{throw new Nt({projectId:r})}))),b=ct(y,f).pipe(bt((()=>qn.delete(d))),xn({predicate:e=>"welcome"===e.type}));return qn.set(d,b),b}}const qn=new Map;class $n{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return On(this.#a,this.#c,"PUT",e,t)}edit(e,t){return On(this.#a,this.#c,"PATCH",e,t)}delete(e){return On(this.#a,this.#c,"DELETE",e)}list(){return rn(this.#a,this.#c,{uri:"/datasets",tag:null})}}class Tn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return rr("dataset",this.#a.config()),et(On(this.#a,this.#c,"PUT",e,t))}edit(e,t){return rr("dataset",this.#a.config()),et(On(this.#a,this.#c,"PATCH",e,t))}delete(e){return rr("dataset",this.#a.config()),et(On(this.#a,this.#c,"DELETE",e))}list(){return rr("dataset",this.#a.config()),et(rn(this.#a,this.#c,{uri:"/datasets",tag:null}))}}function On(e,t,r,n,o){return rr("dataset",e.config()),Gt(n),rn(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class jn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){rr("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return rn(this.#a,this.#c,{uri:t})}getById(e){return rr("projects",this.#a.config()),rn(this.#a,this.#c,{uri:`/projects/${e}`})}}class An{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){rr("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return et(rn(this.#a,this.#c,{uri:t}))}getById(e){return rr("projects",this.#a.config()),et(rn(this.#a,this.#c,{uri:`/projects/${e}`}))}}const Pn=((e,t=21)=>((e,t,r)=>{let n=(2<<Math.log(e.length-1)/Math.LN2)-1,o=-~(1.6*n*t/e.length);return(s=t)=>{let i="";for(;;){let t=r(o),a=0|o;for(;a--;)if(i+=e[t[a]&n]||"",i.length===s)return i}}})(e,t,Pt))("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),Dn=(e,t)=>t?Ot(e,t):function(e){if(Tt(e)){const t=At(e);return St+t}return $t(e)?e:St+e}(e);function kn(e,{releaseId:t,publishedId:r,document:n}){if(r&&n._id){const e=Dn(r,t);return((e,t)=>{if(t._id&&t._id!==e)throw new Error(`The provided document ID (\`${t._id}\`) does not match the generated version ID (\`${e}\`)`)})(e,n),e}if(n._id){const r=$t(n._id),o=Tt(n._id);if(!r&&!o)throw new Error(`\`${e}()\` requires a document with an \`_id\` that is a version or draft ID`);if(t){if(r)throw new Error(`\`${e}()\` was called with a document ID (\`${n._id}\`) that is a draft ID, but a release ID (\`${t}\`) was also provided.`);const o=jt(n._id);if(o!==t)throw new Error(`\`${e}()\` was called with a document ID (\`${n._id}\`) that is a version ID, but the release ID (\`${t}\`) does not match the document's version ID (\`${o}\`).`)}return n._id}if(r)return Dn(r,t);throw new Error(`\`${e}()\` requires either a publishedId or a document with an \`_id\``)}const Fn=(e,t)=>{const[r,n,o]=((e,t)=>{if("object"==typeof e&&null!==e&&("releaseId"in e||"metadata"in e)){const{releaseId:r=Pn(),metadata:n={}}=e;return[r,n,t]}return[Pn(),{},e]})(e,t);return{action:{actionType:"sanity.action.release.create",releaseId:r,metadata:{...n,releaseType:n.releaseType||"undecided"}},options:o}};class Mn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Mr(this.#a,this.#c,`_.releases.${e}`,t)}create(e,t){const{action:r,options:n}=Fn(e,t),{releaseId:o,metadata:s}=r;return Yr(this.#a,this.#c,r,n).pipe(rt((e=>({...e,releaseId:o,metadata:s}))))}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return Yr(this.#a,this.#c,n,r)}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return Yr(this.#a,this.#c,r,t)}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return Yr(this.#a,this.#c,r,t)}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return Yr(this.#a,this.#c,r,t)}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return Yr(this.#a,this.#c,n,r)}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return Yr(this.#a,this.#c,r,t)}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return Yr(this.#a,this.#c,r,t)}fetchDocuments({releaseId:e},t){return Nr(this.#a,this.#c,e,t)}}class Un{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return et(Mr(this.#a,this.#c,`_.releases.${e}`,t))}async create(e,t){const{action:r,options:n}=Fn(e,t),{releaseId:o,metadata:s}=r;return{...await et(Yr(this.#a,this.#c,r,n)),releaseId:o,metadata:s}}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return et(Yr(this.#a,this.#c,n,r))}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return et(Yr(this.#a,this.#c,n,r))}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}fetchDocuments({releaseId:e},t){return et(Nr(this.#a,this.#c,e,t))}}class Nn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return rn(this.#a,this.#c,{uri:`/users/${e}`})}}class zn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return et(rn(this.#a,this.#c,{uri:`/users/${e}`}))}}class Ln{assets;datasets;live;projects;users;agent;releases;#u;#c;listen=_n;constructor(e,t=dr){this.config(t),this.#c=e,this.assets=new pn(this,this.#c),this.datasets=new $n(this,this.#c),this.live=new Sn(this),this.projects=new jn(this,this.#c),this.users=new Nn(this,this.#c),this.agent={action:new hn(this,this.#c)},this.releases=new Mn(this,this.#c)}clone(){return new Ln(this.#c,this.config())}config(e){if(void 0===e)return{...this.#u};if(this.#u&&!1===this.#u.allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.#u=yr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Ln(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Fr(this,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){return Mr(this,this.#c,e,t)}getDocuments(e,t){return Ur(this,this.#c,e,t)}create(e,t){return Xr(this,this.#c,e,"create",t)}createIfNotExists(e,t){return zr(this,this.#c,e,t)}createOrReplace(e,t){return Lr(this,this.#c,e,t)}createVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("createVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o},i=t||At(e._id);return Hr(this,this.#c,s,i,n)}delete(e,t){return Vr(this,this.#c,e,t)}discardVersion({releaseId:e,publishedId:t},r,n){const o=Dn(t,e);return Br(this,this.#c,o,r,n)}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return Wr(this,this.#c,s,n)}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ot(t,e);return Jr(this,this.#c,n,t,r)}mutate(e,t){return Gr(this,this.#c,e,t)}patch(e,t){return new Sr(e,t,this)}transaction(e){return new jr(e,this)}action(e,t){return Yr(this,this.#c,e,t)}request(e){return rn(this,this.#c,e)}getUrl(e,t){return on(this,e,t)}getDataUrl(e,t){return nn(this,e,t)}}class Hn{assets;datasets;live;projects;users;agent;releases;observable;#u;#c;listen=_n;constructor(e,t=dr){this.config(t),this.#c=e,this.assets=new fn(this,this.#c),this.datasets=new Tn(this,this.#c),this.live=new Sn(this),this.projects=new An(this,this.#c),this.users=new zn(this,this.#c),this.agent={action:new dn(this,this.#c)},this.releases=new Un(this,this.#c),this.observable=new Ln(e,t)}clone(){return new Hn(this.#c,this.config())}config(e){if(void 0===e)return{...this.#u};if(this.#u&&!1===this.#u.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),this.#u=yr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Hn(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return et(Fr(this,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){return et(Mr(this,this.#c,e,t))}getDocuments(e,t){return et(Ur(this,this.#c,e,t))}create(e,t){return et(Xr(this,this.#c,e,"create",t))}createIfNotExists(e,t){return et(zr(this,this.#c,e,t))}createOrReplace(e,t){return et(Lr(this,this.#c,e,t))}createVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("createVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o},i=t||At(e._id);return tt(Hr(this,this.#c,s,i,n))}delete(e,t){return et(Vr(this,this.#c,e,t))}discardVersion({releaseId:e,publishedId:t},r,n){const o=Dn(t,e);return et(Br(this,this.#c,o,r,n))}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return tt(Wr(this,this.#c,s,n))}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ot(t,e);return et(Jr(this,this.#c,n,t,r))}mutate(e,t){return et(Gr(this,this.#c,e,t))}patch(e,t){return new qr(e,t,this)}transaction(e){return new Or(e,this)}action(e,t){return et(Yr(this,this.#c,e,t))}request(e){return et(rn(this,this.#c,e))}dataRequest(e,t,r){return et(Qr(this,this.#c,e,t,r))}getUrl(e,t){return on(this,e,t)}getDataUrl(e,t){return nn(this,e,t)}}const Vn=(Qn=Hn,{requester:Ht(Yn=[]),createClient:e=>{const t=Ht(Yn);return new Qn(((r,n)=>(n||t)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...r})),e)}}),Bn=Vn.requester,Wn=Vn.createClient,Jn=(Gn=Wn,function(e){return hr(),Gn(e)});var Gn,Yn,Qn;const Xn=/_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?Xn.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 Zn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},eo={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function to(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=>eo[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=>eo[e]));t.push(e)}return t}function ro(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 no(e,t){if(!t?.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Zn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Zn[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 oo(e){return"object"==typeof e&&null!==e}function so(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(oo(e)){const o=e._key;if("string"==typeof o)return so(e,t,r.concat({_key:o,_index:n}))}return so(e,t,r.concat(n))}));if(oo(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=so(e.children,t,r.concat("children")):"span"===e._type&&(n.text=so(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,so(n,t,r.concat(e))])))}return t(e,r)}function io(e,t,r){return so(e,((e,n)=>{if("string"!=typeof e)return e;const o=no(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],c=t.paths[s.source.path],u=to(i),l=to(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const ao=".",co=`drafts${ao}`,uo=`versions${ao}`;function lo(e){return e.startsWith(co)}function ho(e){return e.startsWith(uo)}function po(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:c}=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 u="default"===r?void 0:r,l="default"===n?void 0:n,h=function(e){return ho(e)?e.split(ao).slice(2).join(ao):lo(e)?e.slice(co.length):e}(o),d=Array.isArray(i)?Kn(ro(i)):i,p=new URLSearchParams({baseUrl:t,id:h,type:s,path:d});if(u&&p.set("workspace",u),l&&p.set("tool",l),a&&p.set("projectId",a),c&&p.set("dataset",c),function(e){return!lo(e)&&!ho(e)}(o))p.set("perspective","published");else if(ho(o)){const e=function(e){if(!ho(e))return;const[t,r,...n]=e.split(ao);return r}(o);p.set("perspective",e)}const f=["/"===t?"":t];u&&f.push(u);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),f.push("intent","edit",`${y.join(";")}?${p}`),f.join("/")}const fo=({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("_")||o.endsWith("Id"))||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||bo(e)||bo(t)||"string"==typeof o&&yo.has(o))},yo=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","textTheme","unit","url","username","variant","website"]);function bo(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function go(e,t,r){const{filter:n,logger:o,enabled:s}=r;if(!s){const n="config.enabled must be true, don't call this function otherwise";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}if(!t)return o?.error?.("[@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 o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const i={encoded:[],skipped:[]},a=io(e,t,(({sourcePath:e,sourceDocument:t,resultPath:s,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:s,filterDefault:fo,sourceDocument:t,value:a}):fo({sourcePath:e,resultPath:s,value:a})))return o&&i.skipped.push({path:vo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&i.encoded.push({path:vo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length});const{baseUrl:c,workspace:u,tool:l}=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(!c)return a;const{_id:h,_type:d,_projectId:p,_dataset:f}=t;return Et(a,{origin:"sanity.io",href:po({baseUrl:c,workspace:u,tool:l,id:h,type:d,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:p}})},!1)}));if(o){const e=i.skipped.length,t=i.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${i.encoded.length}, skipped: ${i.skipped.length}`)),i.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(i.encoded)),i.skipped.length>0){const e=new Set;for(const{path:t}of i.skipped)e.add(t.replace(Xn,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function vo(e){return Kn(ro(e))}var mo=Object.freeze({__proto__:null,stegaEncodeSourceMap:go}),wo=Object.freeze({__proto__:null,encodeIntoResult:io,stegaEncodeSourceMap:go,stegaEncodeSourceMap$1:mo});function Co(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Eo,Io,_o,xo={exports:{}},Ro=xo.exports;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}const r=!(typeof navigator>"u")&&"ReactNative"===navigator.product,n={timeout:r?6e4:12e4},o=function(e){const t={...n,..."string"==typeof e?{url:e}:e};if(t.timeout=i(t.timeout),t.query){const{url:e,searchParams:n}=function(e){const t=e.indexOf("?");if(-1===t)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,t),o=e.slice(t+1);if(!r)return{url:n,searchParams:new URLSearchParams(o)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const i=new URLSearchParams;for(const e of o.split("&")){const[t,r]=e.split("=");t&&i.append(s(t),s(r||""))}return{url:n,searchParams:i}}(t.url);for(const[r,o]of Object.entries(t.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)n.append(r,e);else n.append(r,o);const s=n.toString();s&&(t.url=`${e}?${s}`)}}return t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t};function s(e){return decodeURIComponent(e.replace(/\+/g," "))}function i(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?i(n.timeout):{connect:t,socket:t}}const a=/^https?:\/\//i,c=function(e){if(!a.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const l=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const r=[],n=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[o],validateOptions:[c]});function s(e){const r=l.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),o=(e=>function(t,r,...n){const o="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...n),!o||s);r++);return s})(n),s=o("processOptions",e);o("validateOptions",s);const i={options:s,channels:r,applyMiddleware:o};let a;const c=r.request.subscribe((e=>{a=t(e,((t,n)=>((e,t,n)=>{let s=e,i=t;if(!s)try{i=o("onResponse",t,n)}catch(e){i=null,s=e}s=s&&o("onError",s,n),s?r.error.publish(s):i&&r.response.publish(i)})(t,n,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=o("onReturn",r,i);return u===r&&r.request.publish(i),u}return s.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&n.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return h.forEach((t=>{e[t]&&n[t].push(e[t])})),r.push(e),s},s.clone=()=>d(r,t),e.forEach(s.use),s}var p,f,y=u(function(){if(f)return p;f=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return p=function(t){if(!t)return{};for(var r={},n=e(t).split("\n"),o=0;o<n.length;o++){var s=n[o],i=s.indexOf(":"),a=e(s.slice(0,i)).toLowerCase(),c=e(s.slice(i+1));typeof r[a]>"u"?r[a]=c:(u=r[a],"[object Array]"===Object.prototype.toString.call(u)?r[a].push(c):r[a]=[r[a],c])}var u;return r}}());let b=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#s={};#i;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#n[e]=t}setInit(e,t=!0){this.#s=e,this.#i=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#s,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#i&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}};const g="function"==typeof XMLHttpRequest?"xhr":"fetch",v="xhr"===g?XMLHttpRequest:b,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:g,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new v;i instanceof b&&"object"==typeof n.fetch&&i.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,h=!1;if(i.onerror=e=>{f(i instanceof b?e instanceof Error?e:new Error(`Request error while attempting to reach is ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.ontimeout=e=>{f(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.onabort=()=>{p(!0),u=!0},i.onreadystatechange=function(){c&&(p(),o.socket=setTimeout((()=>d("ESOCKETTIMEDOUT")),c.socket)),!u&&i&&4===i.readyState&&0!==i.status&&function(){if(!(u||l||h)){if(0===i.status)return void f(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:i.response||(""===i.responseType||"text"===i.responseType?i.responseText:""),url:n.url,method:n.method,headers:y(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}}()},i.open(n.method,n.url,!0),i.withCredentials=!!n.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return n.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:g,request:i,context:e}),i.send(n.body||null),c&&(o.connect=setTimeout((()=>d("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,i&&i.abort()}};function d(t){h=!0,i.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function p(e){(e||u||i&&i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function f(e){if(l)return;p(!0),l=!0,i=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},w=(e=[],t=m)=>d(e,t);var C,E,I,_,x,R={exports:{}};x||(x=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(_?I:(_=1,I=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,o=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,s=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=function(){if(E)return C;E=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return C=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(s){if(!((s=String(s)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=r?s(c,u,r,"hour"):u>=t?s(c,u,t,"minute"):u>=e?s(c,u,e,"second"):c+" ms"):function(o){var s=Math.abs(o);return s>=n?Math.round(o/n)+"d":s>=r?Math.round(o/r)+"h":s>=t?Math.round(o/t)+"m":s>=e?Math.round(o/e)+"s":o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(R,R.exports));const S=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function q(e){return"[object Object]"===Object.prototype.toString.call(e)}const $=["boolean","string","number"];function T(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||S(t)||-1===$.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===q(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 O(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},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 j={};typeof globalThis<"u"?j=globalThis:typeof window<"u"?j=window:typeof global<"u"?j=global:typeof self<"u"&&(j=self);var A=j;function P(e={}){const t=e.implementation||A.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 D=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function k(e){return 100*Math.pow(2,e)+100*Math.random()}const F=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||k,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,c=s.shouldRetry||n,u=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,s)||u>=i)return e;var l;const h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(h)),a(u)),null}}})({shouldRetry:D,...e});F.shouldRetry=D;var M=function(e,t){return M=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])},M(e,t)};function U(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}M(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function N(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function z(e,t){var r,n,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)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 s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}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,c])}}}function L(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 H(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 V(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 B(e){return this instanceof B?(this.v=e,this):new B(e)}function W(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof B?Promise.resolve(e.value.v).then(c,u):l(s[0][2],e)}(o[e](t))}catch(e){l(s[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function J(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=L(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 G(e){return"function"==typeof e}function Y(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 Q=Y((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 X(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var K=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=L(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 c=this.initialTeardown;if(G(c))try{c()}catch(e){o=e instanceof Q?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=L(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{te(d)}catch(e){o=null!=o?o:[],e instanceof Q?o=V(V([],H(o)),H(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 Q(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)te(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)&&X(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&X(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),Z=K.EMPTY;function ee(e){return e instanceof K||e&&"closed"in e&&G(e.remove)&&G(e.add)&&G(e.unsubscribe)}function te(e){G(e)?e():e.unsubscribe()}var re={Promise:void 0},ne=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,V([e,t],H(r)))};function oe(e){ne((function(){throw e}))}function se(){}function ie(e){e()}var ae=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ee(t)&&t.add(r)):r.destination=he,r}return U(t,e),t.create=function(e,t,r){return new ue(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}(K),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){le(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){le(e)}else le(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){le(e)}},e}(),ue=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=G(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new ce(o),s}return U(t,e),t}(ae);function le(e){oe(e)}var he={closed:!0,next:se,error:function(e){throw e},complete:se},de="function"==typeof Symbol&&Symbol.observable||"@@observable";function pe(e){return e}function fe(e){return 0===e.length?pe:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ye=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 ae||function(e){return e&&G(e.next)&&G(e.error)&&G(e.complete)}(n)&&ee(n)?e:new ue(e,t,r);return ie((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=be(t))((function(t,n){var o=new ue({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[de]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=be(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 be(e){var t;return null!==(t=null!=e?e:re.Promise)&&void 0!==t?t:Promise}function ge(e){return function(t){if(function(e){return G(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 ve(e,t,r,n,o){return new me(e,t,r,n,o)}var me=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 U(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}(ae),we=Y((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Ce=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return U(t,e),t.prototype.lift=function(e){var t=new Ee(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new we},t.prototype.next=function(e){var t=this;ie((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=L(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;ie((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;ie((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,s=r.observers;return n||o?Z:(this.currentObservers=null,s.push(e),new K((function(){t.currentObservers=null,X(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new ye;return e.source=this,e},t.create=function(e,t){return new Ee(e,t)},t}(ye),Ee=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return U(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:Z},t}(Ce),Ie={now:function(){return(Ie.delegate||Date).now()},delegate:void 0},_e=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Ie);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=r,o._timestampProvider=n,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,r),o}return U(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,i=r._timestampProvider,a=r._windowTime;n||(o.push(t),!s&&o.push(i.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,s=(o?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!o){for(var i=r.now(),a=0,c=1;c<n.length&&n[c]<=i;c+=2)a=c;a&&n.splice(0,a+1)}},t}(Ce),xe=function(e){function t(t,r){return e.call(this)||this}return U(t,e),t.prototype.schedule=function(e,t){return this},t}(K),Re=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,V([e,t],H(r)))},Se=function(e){return clearInterval(e)},qe=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return U(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,o=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(o,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),Re(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&Se(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,X(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(xe),$e=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Ie.now,e}(),Te=new(function(e){function t(t,r){void 0===r&&(r=$e.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return U(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}($e))(qe),Oe=new ye((function(e){return e.complete()}));function je(e){return e[e.length-1]}function Ae(e){return(t=je(e))&&G(t.schedule)?e.pop():void 0;var t}var Pe=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function De(e){return G(null==e?void 0:e.then)}function ke(e){return G(e[de])}function Fe(e){return Symbol.asyncIterator&&G(null==e?void 0:e[Symbol.asyncIterator])}function Me(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.")}var Ue="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ne(e){return G(null==e?void 0:e[Ue])}function ze(e){return W(this,arguments,(function(){var t,r,n;return z(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,B(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,B(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,B(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]}}))}))}function Le(e){return G(null==e?void 0:e.getReader)}function He(e){if(e instanceof ye)return e;if(null!=e){if(ke(e))return o=e,new ye((function(e){var t=o[de]();if(G(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Pe(e))return n=e,new ye((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(De(e))return r=e,new ye((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,oe)}));if(Fe(e))return Ve(e);if(Ne(e))return t=e,new ye((function(e){var r,n;try{for(var o=L(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(Le(e))return Ve(ze(e))}var t,r,n,o;throw Me(e)}function Ve(e){return new ye((function(t){(function(e,t){var r,n,o,s;return N(this,void 0,void 0,(function(){var i,a;return z(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=J(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.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 Be(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),ge((function(r,n){r.subscribe(ve(n,(function(r){return Be(n,e,(function(){return n.next(r)}),t)}),(function(){return Be(n,e,(function(){return n.complete()}),t)}),(function(r){return Be(n,e,(function(){return n.error(r)}),t)})))}))}function Je(e,t){return void 0===t&&(t=0),ge((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function Ge(e,t){if(!e)throw new Error("Iterable cannot be null");return new ye((function(r){Be(r,t,(function(){var n=e[Symbol.asyncIterator]();Be(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function Ye(e,t){if(null!=e){if(ke(e))return function(e,t){return He(e).pipe(Je(t),We(t))}(e,t);if(Pe(e))return function(e,t){return new ye((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(De(e))return function(e,t){return He(e).pipe(Je(t),We(t))}(e,t);if(Fe(e))return Ge(e,t);if(Ne(e))return function(e,t){return new ye((function(r){var n;return Be(r,t,(function(){n=e[Ue](),Be(r,t,(function(){var e,t,o;try{t=(e=n.next()).value,o=e.done}catch(e){return void r.error(e)}o?r.complete():r.next(t)}),0,!0)})),function(){return G(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(Le(e))return function(e,t){return Ge(ze(e),t)}(e,t)}throw Me(e)}function Qe(e,t){return t?Ye(e,t):He(e)}function Xe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qe(e,Ae(e))}function Ke(e,t){var r=G(e)?e:function(){return e};return new ye((function(e){return e.error(r())}))}var Ze=Y((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function et(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 Ze)}})}))}function tt(e,t){return new Promise((function(t,r){var n=new ue({next:function(e){t(e),n.unsubscribe()},error:r,complete:function(){r(new Ze)}});e.subscribe(n)}))}function rt(e,t){return ge((function(r,n){var o=0;r.subscribe(ve(n,(function(r){n.next(e.call(t,r,o++))})))}))}var nt=Array.isArray;function ot(e){return rt((function(t){return function(e,t){return nt(t)?e.apply(void 0,V([],H(t))):e(t)}(e,t)}))}function st(e,t,r){t()}function it(e,t,r){return void 0===r&&(r=1/0),G(t)?it((function(r,n){return rt((function(e,o){return t(r,e,n,o)}))(He(e(r,n)))}),r):("number"==typeof t&&(r=t),ge((function(t,n){return function(e,t,r,n,o,s,i){var a=[],c=0,u=0,l=!1,h=function(){!l||a.length||c||t.complete()},d=function(e){c++;var o=!1;He(r(e,u++)).subscribe(ve(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{for(c--;a.length&&c<n;)e=void 0,e=a.shift(),i||d(e);h()}catch(e){t.error(e)}var e})))};return e.subscribe(ve(t,(function(e){return c<n?d(e):a.push(e)}),(function(){l=!0,h()}))),function(){}}(t,n,e,r)})))}function at(e){return void 0===e&&(e=1/0),it(pe,e)}function ct(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return at(1)(Qe(e,Ae(e)))}function ut(e){return new ye((function(t){He(e()).subscribe(t)}))}function lt(e,t,r){return void 0===r&&(r=Te),new ye((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?1e3-r.now():e;o<0&&(o=0);var s=0;return r.schedule((function(){t.closed||(t.next(s++),t.complete())}),o)}))}function ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Ae(e),n=function(e,t){return"number"==typeof je(e)?e.pop():t}(e,1/0),o=e;return o.length?1===o.length?He(o[0]):at(n)(Qe(o,r)):Oe}var dt=Array.isArray;function pt(e,t){return ge((function(r,n){var o=0;r.subscribe(ve(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function ft(e){return ge((function(t,r){var n,o=null,s=!1;o=t.subscribe(ve(r,void 0,void 0,(function(i){n=He(e(i,ft(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):s=!0}))),s&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function yt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return G(je(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fe(e)}(yt.apply(void 0,V([],H(e))),ot(r)):ge((function(t,r){var n,o,s;(n=V([t],H(function(e){return 1===e.length&&dt(e[0])?e[0]:e}(e))),void 0===s&&(s=pe),function(e){st(0,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,c=function(t){st(0,(function(){var c=Qe(n[t],o),u=!1;c.subscribe(ve(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function bt(e){return ge((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}function gt(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new Ce}:t,n=e.resetOnError,o=void 0===n||n,s=e.resetOnComplete,i=void 0===s||s,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,s,a=0,u=!1,l=!1,h=function(){null==n||n.unsubscribe(),n=void 0},d=function(){h(),t=s=void 0,u=l=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return ge((function(e,f){a++,l||u||h();var y=s=null!=s?s:r();f.add((function(){0!==--a||l||u||(n=vt(p,c))})),y.subscribe(f),!t&&a>0&&(t=new ue({next:function(e){return y.next(e)},error:function(e){l=!0,h(),n=vt(d,o,e),y.error(e)},complete:function(){u=!0,h(),n=vt(d,i),y.complete()}}),He(e).subscribe(t))}))(e)}}function vt(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var o=new ue({next:function(){o.unsubscribe(),e()}});return He(t.apply(void 0,V([],H(r)))).subscribe(o)}}else e()}var mt={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},wt={0:8203,1:8204,2:8205,3:65279},Ct=new Array(4).fill(String.fromCodePoint(wt[0])).join("");function Et(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!(!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(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`${Ct}${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(wt[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(wt).map((e=>e.reverse()))),Object.fromEntries(Object.entries(mt).map((e=>e.reverse())));var It=`${Object.values(mt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,_t=new RegExp(`[${It}]{4,}`,"gu");function xt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(_t,""),encoded:(null==(t=e.match(_t))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}const Rt=".",St=`drafts${Rt}`,qt=`versions${Rt}`;function $t(e){return e.startsWith(St)}function Tt(e){return e.startsWith(qt)}function Ot(e,t){if("drafts"===t||"published"===t)throw new Error('Version can not be "published" or "drafts"');return`${qt}${t}${Rt}${At(e)}`}function jt(e){if(!Tt(e))return;const[t,r,...n]=e.split(Rt);return r}function At(e){return Tt(e)?e.split(Rt).slice(2).join(Rt):$t(e)?e.slice(St.length):e}let Pt=e=>crypto.getRandomValues(new Uint8Array(e));class Dt extends Error{response;statusCode=400;responseBody;details;constructor(e){const t=Ft(e);super(t.message),Object.assign(this,t)}}class kt extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=Ft(e);super(t.message),Object.assign(this,t)}}function Ft(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Ut(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return Mt(e)&&Mt(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return Mt(e)&&Mt(e.error)&&"actionError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>e.error?.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 Mt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ut(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class Nt extends Error{projectId;addOriginUrl;constructor({projectId:e}){super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e;const t=new URL(`https://sanity.io/manage/project/${e}/api`);if(typeof location<"u"){const{origin:e}=location;t.searchParams.set("cors","add"),t.searchParams.set("origin",e),this.addOriginUrl=t,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${t}`}else this.message=`The current origin is not allowed to connect to the Live Content API. Change your configuration here: ${t}`}}const zt={onResponse:e=>{if(e.statusCode>=500)throw new kt(e);if(e.statusCode>=400)throw new Dt(e);return e}};function Lt(){const e={};return{onResponse:t=>{const r=t.headers["x-sanity-warning"],n=Array.isArray(r)?r:[r];for(const t of n)!t||e[t]||(e[t]=!0,console.warn(t));return t}}}function Ht(e){return w([F({shouldRetry:Vt}),...e,Lt(),T(),O(),{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"))}},zt,P({implementation:ye})])}function Vt(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)||F.shouldRetry(e,t,r)}function Bt(e){return"https://www.sanity.io/help/"+e}const Wt=["image","file"],Jt=["before","after","replace"],Gt=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")},Yt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},Qt=(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`)},Xt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);Qt(e,t._id)},Kt=(e,t)=>{if(!t._type)throw new Error(`\`${e}()\` requires that the document contains a type (\`_type\` property)`);((e,t)=>{if("string"!=typeof t)throw new Error(`\`${e}()\`: \`${t}\` is not a valid document type`)})(e,t._type)},Zt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},er=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},tr=e=>{if(!e["~experimental_resource"])throw new Error("`resource` must be provided to perform resource queries");const{type:t,id:r}=e["~experimental_resource"];switch(t){case"dataset":if(2!==r.split(".").length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return;case"dashboard":case"media-library":case"canvas":return;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}},rr=(e,t)=>{if(t["~experimental_resource"])throw new Error(`\`${e}\` does not support resource-based operations`)};const nr=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),or=nr(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),sr=nr(["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."]),ir=nr(["The Sanity client is configured with the `perspective` set to `drafts` or `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."]),ar=nr(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),cr=nr(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Bt("js-client-browser-token")} for more information and how to hide this warning.`]),ur=nr(["You have configured Sanity client to use a token, but also provided `withCredentials: true`.","This is no longer supported - only token will be used - remove `withCredentials: true`."]),lr=nr(["Using the Sanity client without specifying an API version is deprecated.",`See ${Bt("js-client-api-version")}`]),hr=nr(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),dr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},pr=["localhost","127.0.0.1","0.0.0.0"];function fr(e){if(Array.isArray(e)&&e.length>1&&e.includes("raw"))throw new TypeError('Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives')}const yr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||dr.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||lr();const n={...dr,...r},o=n.useProjectHostname&&!n["~experimental_resource"];if(typeof Promise>"u"){const e=Bt("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(n["~experimental_resource"]&&tr(n),typeof n.perspective<"u"&&fr(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!==pr.indexOf(e))(window.location.hostname),a=!!n.token;n.withCredentials&&a&&(ur(),n.withCredentials=!1),s&&i&&a&&!0!==n.ignoreBrowserTokenWarning?cr():typeof n.useCdn>"u"&&sr(),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&&Gt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?er(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===dr.apiHost,!0===n.useCdn&&n.withCredentials&&or(),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 c=n.apiHost.split("://",2),u=c[0],l=c[1],h=n.isDefaultApi?"apicdn.sanity.io":l;return o?(n.url=`${u}://${n.projectId}.${l}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${h}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n};class br extends Error{name="ConnectionFailedError"}class gr extends Error{name="DisconnectError";reason;constructor(e,t,r={}){super(e,r),this.reason=t}}class vr extends Error{name="ChannelError";data;constructor(e,t){super(e),this.data=t}}class mr extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class wr extends Error{name="MessageParseError"}const Cr=["channelError","disconnect"];function Er(e,t){return ut((()=>{const t=e();return(r=t)&&(r instanceof ye||G(r.lift)&&G(r.subscribe))?t:Xe(t);var r})).pipe(it((e=>function(e,t){return new ye((r=>{const n=t.includes("open"),o=t.includes("reconnect");function s(t){if("data"in t){const[e,n]=Ir(t);r.error(e?new wr("Unable to parse EventSource error message",{cause:n}):new mr((n?.data).message,n))}else e.readyState===e.CLOSED?r.error(new br("EventSource connection failed")):o&&r.next({type:"reconnect"})}function i(){r.next({type:"open"})}function a(e){const[t,n]=Ir(e);var o;t?r.error(new wr("Unable to parse EventSource message",{cause:t})):"channelError"!==e.type?"disconnect"!==e.type?r.next({type:e.type,id:e.lastEventId,...n.data?{data:n.data}:{}}):r.error(new gr(`Server disconnected client: ${n.data?.reason||"unknown error"}`)):r.error(new vr((o=n?.data,o.error?o.error.description?o.error.description:"string"==typeof o.error?o.error:JSON.stringify(o.error,null,2):o.message||"Unknown listener error"),n.data))}e.addEventListener("error",s),n&&e.addEventListener("open",i);const c=[...new Set([...Cr,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return c.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",s),n&&e.removeEventListener("open",i),c.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function Ir(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,..._r(t)?{}:{data:t}}]}catch(e){return[e,null]}}function _r(e){for(const t in e)return!1;return!0}function xr(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}`)}class Rr{selection;operations;constructor(e,t={}){this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Yt("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===Jt.indexOf(e)){const e=Jt.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{...xr(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return Yt(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)}}class Sr extends Rr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new Sr(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}class qr extends Rr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new qr(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}const $r={returnDocuments:!1};class Tr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return Yt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Yt(t,e),Xt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Yt(t,e),Xt(t,e),this._add({[t]:e})}delete(e){return Qt("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}}class Or extends Tr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Or([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},$r,e||{}))}patch(e,t){const r="function"==typeof t,n="object"==typeof e&&("query"in e||"id"in e);if("string"!=typeof e&&e instanceof qr)return this._add({patch:e.serialize()});if(r){const r=t(new qr(e,{},this.#a));if(!(r instanceof qr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new qr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class jr extends Tr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new jr([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},$r,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Sr)return this._add({patch:e.serialize()});if(r){const r=t(new Sr(e,{},this.#a));if(!(r instanceof Sr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}const Ar=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:s,returnQuery:i,...a}=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(a))t&&n.append(e,`${t}`);return!1===i&&n.append("returnQuery","false"),!1===s&&n.append("includeMutations","false"),`?${n}`},Pr=(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},Dr=e=>"response"===e.type,kr=e=>e.body;function Fr(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?xt(o):o,c=!1===s.filterResponse?e=>e:e=>e.result,{cache:u,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},d=Qr(e,t,"query",{query:n,params:a},typeof u<"u"||typeof l<"u"?{...h,fetch:{cache:u,next:l}}:h);return i.enabled?d.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yt.apply(void 0,V([],H(e)))}(Qe(Promise.resolve().then((function(){return wo})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),rt((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return c({...e,result:r})}))):d.pipe(rt(c))}function Mr(e,t,r,n={}){return tn(e,t,{uri:nn(e,"doc",(()=>{if(!n.releaseId)return r;const e=jt(r);if(!e){if($t(r))throw new Error(`The document ID (\`${r}\`) is a draft, but \`options.releaseId\` is set as \`${n.releaseId}\``);return Ot(r,n.releaseId)}if(e!==n.releaseId)throw new Error(`The document ID (\`${r}\`) is already a version of \`${e}\` release, but this does not match the provided \`options.releaseId\` (\`${n.releaseId}\`)`);return r})()),json:!0,tag:n.tag,signal:n.signal}).pipe(pt(Dr),rt((e=>e.body.documents&&e.body.documents[0])))}function Ur(e,t,r,n={}){return tn(e,t,{uri:nn(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(pt(Dr),rt((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 Nr(e,t,r,n={}){return Qr(e,t,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:r}},n)}function zr(e,t,r,n){return Xt("createIfNotExists",r),Xr(e,t,r,"createIfNotExists",n)}function Lr(e,t,r,n){return Xt("createOrReplace",r),Xr(e,t,r,"createOrReplace",n)}function Hr(e,t,r,n,o){return Xt("createVersion",r),Kt("createVersion",r),Yr(e,t,{actionType:"sanity.action.document.version.create",publishedId:n,document:r},o)}function Vr(e,t,r,n){return Qr(e,t,"mutate",{mutations:[{delete:xr(r)}]},n)}function Br(e,t,r,n=!1,o){return Yr(e,t,{actionType:"sanity.action.document.version.discard",versionId:r,purge:n},o)}function Wr(e,t,r,n){return Xt("replaceVersion",r),Kt("replaceVersion",r),Yr(e,t,{actionType:"sanity.action.document.version.replace",document:r},n)}function Jr(e,t,r,n,o){return Yr(e,t,{actionType:"sanity.action.document.version.unpublish",versionId:r,publishedId:n},o)}function Gr(e,t,r,n){let o;o=r instanceof qr||r instanceof Sr?{patch:r.serialize()}:r instanceof Or||r instanceof jr?r.serialize():r;return Qr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function Yr(e,t,r,n){return Qr(e,t,"actions",{actions:Array.isArray(r)?r:[r],transactionId:n&&n.transactionId||void 0,skipCrossDatasetReferenceValidation:n&&n.skipCrossDatasetReferenceValidation||void 0,dryRun:n&&n.dryRun||void 0},n)}function Qr(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,c=s||i?"":Ar(n),u=!s&&!i&&c.length<11264,l=u?c:"",h=o.returnFirst,{timeout:d,token:p,tag:f,headers:y,returnQuery:b,lastLiveEventId:g,cacheMode:v}=o;return tn(e,t,{method:u?"GET":"POST",uri:nn(e,r,l),json:!0,body:u?void 0:n,query:s&&Pr(o),timeout:d,headers:y,token:p,tag:f,returnQuery:b,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(g)?g[0]:g,cacheMode:v,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(pt(Dr),rt(kr),rt((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return h?t[0]&&t[0].document:t.map((e=>e.document));const r=h?"documentId":"documentIds",n=h?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function Xr(e,t,r,n,o={}){return Qr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}const Kr=e=>void 0!==e.config().dataset&&void 0!==e.config().projectId||void 0!==e.config()["~experimental_resource"],Zr=(e,t)=>Kr(e)&&t.startsWith(nn(e,"query")),en=(e,t)=>t.startsWith("/data/")||Zr(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"mutate")))(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"doc","")))(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"listen")))(e,t)||((e,t)=>Kr(e)&&t.startsWith(nn(e,"history","")))(e,t);function tn(e,t,r){const n=r.url||r.uri,o=e.config(),s=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&en(e,n):r.canUseCdn;let i=(r.useCdn??o.useCdn)&&s;const a=r.tag&&o.requestTagPrefix?[o.requestTagPrefix,r.tag].join("."):r.tag||o.requestTagPrefix;if(a&&null!==r.tag&&(r.query={tag:er(a),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&Zr(e,n)){const e=r.resultSourceMap??o.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||o.perspective;typeof t<"u"&&("previewDrafts"===t&&ar(),fr(t),r.query={perspective:Array.isArray(t)?t.join(","):t,...r.query},(Array.isArray(t)&&t.length>0||"previewDrafts"===t||"drafts"===t)&&i&&(i=!1,ir())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query}),i&&"noStale"==r.cacheMode&&(r.query={cacheMode:"noStale",...r.query})}const c=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r["X-Sanity-Project-ID"]=e.projectId);const o=!!(typeof t.withCredentials>"u"?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})}(o,Object.assign({},r,{url:on(e,n,i)})),u=new ye((e=>t(c,o.requester).subscribe(e)));return r.signal?u.pipe((l=r.signal,e=>new ye((t=>{const r=()=>t.error(function(e){if(sn)return new DOMException(e?.reason??"The operation was aborted.","AbortError");const t=new Error(e?.reason??"The operation was aborted.");return t.name="AbortError",t}(l));if(l&&l.aborted)return void r();const n=e.subscribe(t);return l.addEventListener("abort",r),()=>{l.removeEventListener("abort",r),n.unsubscribe()}})))):u;var l}function rn(e,t,r){return tn(e,t,r).pipe(pt((e=>"response"===e.type)),rt((e=>e.body)))}function nn(e,t,r){const n=e.config();if(n["~experimental_resource"]){tr(n);return`${an(n)}/${void 0!==r?`${t}/${r}`:t}`.replace(/\/($|\?)/,"$1")}const o=`/${t}/${Zt(n)}`;return`/data${void 0!==r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function on(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const sn=!!globalThis.DOMException;const an=e=>{if(!e["~experimental_resource"])throw new Error("`resource` must be provided to perform resource queries");const{type:t,id:r}=e["~experimental_resource"];switch(t){case"dataset":{const e=r.split(".");if(2!==e.length)throw new Error('Dataset ID must be in the format "project.dataset"');return`/projects/${e[0]}/datasets/${e[1]}`}case"canvas":return`/canvases/${r}`;case"media-library":return`/media-libraries/${r}`;case"dashboard":return`/dashboards/${r}`;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}};function cn(e,t,r){const n=Zt(e.config());return rn(e,t,{method:"POST",uri:`/agent/action/generate/${n}`,body:r})}function un(e,t,r){const n=Zt(e.config());return rn(e,t,{method:"POST",uri:`/agent/action/transform/${n}`,body:r})}function ln(e,t,r){const n=Zt(e.config());return rn(e,t,{method:"POST",uri:`/agent/action/translate/${n}`,body:r})}class hn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return cn(this.#a,this.#c,e)}transform(e){return un(this.#a,this.#c,e)}translate(e){return ln(this.#a,this.#c,e)}}class dn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return et(cn(this.#a,this.#c,e))}transform(e){return et(un(this.#a,this.#c,e))}translate(e){return et(ln(this.#a,this.#c,e))}}class pn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return yn(this.#a,this.#c,e,t,r)}}class fn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return et(yn(this.#a,this.#c,e,t,r).pipe(pt((e=>"response"===e.type)),rt((e=>e.body.document))))}}function yn(e,t,r,n,o={}){(e=>{if(-1===Wt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${Wt.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=e.config(),a=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:u,title:l,description:h,creditLine:d,filename:p,source:f}=a,y={label:u,title:l,description:h,filename:p,meta:s,creditLine:d};return f&&(y.sourceId=f.id,y.sourceName=f.name,y.sourceUrl=f.url),tn(e,t,{tag:c,method:"POST",timeout:a.timeout||0,uri:bn(i,r),headers:a.contentType?{"Content-Type":a.contentType}:{},query:y,body:n})}function bn(e,t){const r="image"===t?"images":"files";if(e["~experimental_resource"]){const{type:t,id:n}=e["~experimental_resource"];switch(t){case"dataset":throw new Error("Assets are not supported for dataset resources, yet. Configure the client with `{projectId: <projectId>, dataset: <datasetId>}` instead.");case"canvas":return`/canvases/${n}/assets/${r}`;case"media-library":return`/media-libraries/${n}/upload`;case"dashboard":return`/dashboards/${n}/assets/${r}`;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}}return`assets/${r}/${Zt(e)}`}const gn=ut((()=>Promise.resolve().then((function(){return To})))).pipe(rt((({default:e})=>e)),(wn=1,gt({connector:function(){return new _e(wn,vn,mn)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})));var vn,mn,wn;function Cn(){return function(e){return e.pipe(ft(((e,t)=>e instanceof br?ct(Xe({type:"reconnect"}),lt(1e3).pipe(it((()=>t)))):Ke((()=>e)))))}}const En=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","tag"],In={includeResult:!0};function _n(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...(h=r,d=In,Object.keys(d).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?d[t]:h[t],e)),{})),tag:a},u=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(c,En),l=`${n}${nn(this,"listen",Ar({query:e,params:t,options:{tag:a,...u}}))}`;var h,d;if(l.length>14800)return Ke((()=>new Error("Query too large for listener")));const p=c.events?c.events:["mutation"],f={};return s&&(f.withCredentials=!0),o&&(f.headers={Authorization:`Bearer ${o}`}),Er((()=>(typeof EventSource>"u"||f.headers?gn:Xe(EventSource)).pipe(rt((e=>new e(l,f))))),p).pipe(Cn(),pt((e=>p.includes(e.type))),rt((e=>({type:e.type,..."data"in e?e.data:{}}))))}function xn(e,t){return function(e){return t=>{let r,n=!1;const{predicate:o,...s}=e,i=t.pipe((l=G(a=t=>{e.predicate(t)&&(n=!0,r=t)})||c||u?{next:a,error:c,complete:u}:a)?ge((function(e,t){var r;null===(r=l.subscribe)||void 0===r||r.call(l);var n=!0;e.subscribe(ve(t,(function(e){var r;null===(r=l.next)||void 0===r||r.call(l,e),t.next(e)}),(function(){var e;n=!1,null===(e=l.complete)||void 0===e||e.call(l),t.complete()}),(function(e){var r;n=!1,null===(r=l.error)||void 0===r||r.call(l,e),t.error(e)}),(function(){var e,t;n&&(null===(e=l.unsubscribe)||void 0===e||e.call(l)),null===(t=l.finalize)||void 0===t||t.call(l)})))})):pe,bt((()=>{n=!1,r=void 0})),gt(s));var a,c,u,l;return ht(i,new ye((e=>{n&&e.next(r),e.complete()})))}}("function"==typeof e?{predicate:e,...t}:e)}const Rn="2021-03-25";class Sn{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t}={}){rr("live",this.#a.config());const{projectId:r,apiVersion:n,token:o,withCredentials:s,requestTagPrefix:i}=this.#a.config(),a=n.replace(/^v/,"");if("X"!==a&&a<Rn)throw new Error(`The live events API requires API version ${Rn} or later. The current API version is ${a}. Please update your API version to use this feature.`);if(e&&!o&&!s)throw new Error("The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role.");const c=nn(this.#a,"live/events"),u=new URL(this.#a.getUrl(c,!1)),l=t&&i?[i,t].join("."):t;l&&u.searchParams.set("tag",l),e&&u.searchParams.set("includeDrafts","true");const h={};e&&o&&(h.headers={Authorization:`Bearer ${o}`}),e&&s&&(h.withCredentials=!0);const d=`${u.href}::${JSON.stringify(h)}`,p=qn.get(d);if(p)return p;const f=Er((()=>(typeof EventSource>"u"||h.headers?gn:Xe(EventSource)).pipe(rt((e=>new e(u.href,h))))),["message","restart","welcome","reconnect","goaway"]).pipe(Cn(),rt((e=>{if("message"===e.type){const{data:t,...r}=e;return{...r,tags:t.tags}}return e}))),y=function(e,t){return new ye((r=>{const n=new AbortController,o=n.signal;return fetch(e,{...t,signal:n.signal}).then((e=>{r.next(e),r.complete()}),(e=>{o.aborted||r.error(e)})),()=>n.abort()}))}(u,{method:"OPTIONS",mode:"cors",credentials:h.withCredentials?"include":"omit",headers:h.headers}).pipe(it((()=>Oe)),ft((()=>{throw new Nt({projectId:r})}))),b=ct(y,f).pipe(bt((()=>qn.delete(d))),xn({predicate:e=>"welcome"===e.type}));return qn.set(d,b),b}}const qn=new Map;class $n{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return On(this.#a,this.#c,"PUT",e,t)}edit(e,t){return On(this.#a,this.#c,"PATCH",e,t)}delete(e){return On(this.#a,this.#c,"DELETE",e)}list(){return rn(this.#a,this.#c,{uri:"/datasets",tag:null})}}class Tn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return rr("dataset",this.#a.config()),et(On(this.#a,this.#c,"PUT",e,t))}edit(e,t){return rr("dataset",this.#a.config()),et(On(this.#a,this.#c,"PATCH",e,t))}delete(e){return rr("dataset",this.#a.config()),et(On(this.#a,this.#c,"DELETE",e))}list(){return rr("dataset",this.#a.config()),et(rn(this.#a,this.#c,{uri:"/datasets",tag:null}))}}function On(e,t,r,n,o){return rr("dataset",e.config()),Gt(n),rn(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class jn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){rr("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return rn(this.#a,this.#c,{uri:t})}getById(e){return rr("projects",this.#a.config()),rn(this.#a,this.#c,{uri:`/projects/${e}`})}}class An{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){rr("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return et(rn(this.#a,this.#c,{uri:t}))}getById(e){return rr("projects",this.#a.config()),et(rn(this.#a,this.#c,{uri:`/projects/${e}`}))}}const Pn=((e,t=21)=>((e,t,r)=>{let n=(2<<Math.log(e.length-1)/Math.LN2)-1,o=-~(1.6*n*t/e.length);return(s=t)=>{let i="";for(;;){let t=r(o),a=0|o;for(;a--;)if(i+=e[t[a]&n]||"",i.length===s)return i}}})(e,t,Pt))("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),Dn=(e,t)=>t?Ot(e,t):function(e){if(Tt(e)){const t=At(e);return St+t}return $t(e)?e:St+e}(e);function kn(e,{releaseId:t,publishedId:r,document:n}){if(r&&n._id){const e=Dn(r,t);return((e,t)=>{if(t._id&&t._id!==e)throw new Error(`The provided document ID (\`${t._id}\`) does not match the generated version ID (\`${e}\`)`)})(e,n),e}if(n._id){const r=$t(n._id),o=Tt(n._id);if(!r&&!o)throw new Error(`\`${e}()\` requires a document with an \`_id\` that is a version or draft ID`);if(t){if(r)throw new Error(`\`${e}()\` was called with a document ID (\`${n._id}\`) that is a draft ID, but a release ID (\`${t}\`) was also provided.`);const o=jt(n._id);if(o!==t)throw new Error(`\`${e}()\` was called with a document ID (\`${n._id}\`) that is a version ID, but the release ID (\`${t}\`) does not match the document's version ID (\`${o}\`).`)}return n._id}if(r)return Dn(r,t);throw new Error(`\`${e}()\` requires either a publishedId or a document with an \`_id\``)}const Fn=(e,t)=>{const[r,n,o]=((e,t)=>{if("object"==typeof e&&null!==e&&("releaseId"in e||"metadata"in e)){const{releaseId:r=Pn(),metadata:n={}}=e;return[r,n,t]}return[Pn(),{},e]})(e,t);return{action:{actionType:"sanity.action.release.create",releaseId:r,metadata:{...n,releaseType:n.releaseType||"undecided"}},options:o}};class Mn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Mr(this.#a,this.#c,`_.releases.${e}`,t)}create(e,t){const{action:r,options:n}=Fn(e,t),{releaseId:o,metadata:s}=r;return Yr(this.#a,this.#c,r,n).pipe(rt((e=>({...e,releaseId:o,metadata:s}))))}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return Yr(this.#a,this.#c,n,r)}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return Yr(this.#a,this.#c,r,t)}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return Yr(this.#a,this.#c,r,t)}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return Yr(this.#a,this.#c,r,t)}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return Yr(this.#a,this.#c,n,r)}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return Yr(this.#a,this.#c,r,t)}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return Yr(this.#a,this.#c,r,t)}fetchDocuments({releaseId:e},t){return Nr(this.#a,this.#c,e,t)}}class Un{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return et(Mr(this.#a,this.#c,`_.releases.${e}`,t))}async create(e,t){const{action:r,options:n}=Fn(e,t),{releaseId:o,metadata:s}=r;return{...await et(Yr(this.#a,this.#c,r,n)),releaseId:o,metadata:s}}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return et(Yr(this.#a,this.#c,n,r))}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return et(Yr(this.#a,this.#c,n,r))}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return et(Yr(this.#a,this.#c,r,t))}fetchDocuments({releaseId:e},t){return et(Nr(this.#a,this.#c,e,t))}}class Nn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return rn(this.#a,this.#c,{uri:`/users/${e}`})}}class zn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return et(rn(this.#a,this.#c,{uri:`/users/${e}`}))}}class Ln{assets;datasets;live;projects;users;agent;releases;#u;#c;listen=_n;constructor(e,t=dr){this.config(t),this.#c=e,this.assets=new pn(this,this.#c),this.datasets=new $n(this,this.#c),this.live=new Sn(this),this.projects=new jn(this,this.#c),this.users=new Nn(this,this.#c),this.agent={action:new hn(this,this.#c)},this.releases=new Mn(this,this.#c)}clone(){return new Ln(this.#c,this.config())}config(e){if(void 0===e)return{...this.#u};if(this.#u&&!1===this.#u.allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.#u=yr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Ln(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Fr(this,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){return Mr(this,this.#c,e,t)}getDocuments(e,t){return Ur(this,this.#c,e,t)}create(e,t){return Xr(this,this.#c,e,"create",t)}createIfNotExists(e,t){return zr(this,this.#c,e,t)}createOrReplace(e,t){return Lr(this,this.#c,e,t)}createVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("createVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o},i=t||At(e._id);return Hr(this,this.#c,s,i,n)}delete(e,t){return Vr(this,this.#c,e,t)}discardVersion({releaseId:e,publishedId:t},r,n){const o=Dn(t,e);return Br(this,this.#c,o,r,n)}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return Wr(this,this.#c,s,n)}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ot(t,e);return Jr(this,this.#c,n,t,r)}mutate(e,t){return Gr(this,this.#c,e,t)}patch(e,t){return new Sr(e,t,this)}transaction(e){return new jr(e,this)}action(e,t){return Yr(this,this.#c,e,t)}request(e){return rn(this,this.#c,e)}getUrl(e,t){return on(this,e,t)}getDataUrl(e,t){return nn(this,e,t)}}class Hn{assets;datasets;live;projects;users;agent;releases;observable;#u;#c;listen=_n;constructor(e,t=dr){this.config(t),this.#c=e,this.assets=new fn(this,this.#c),this.datasets=new Tn(this,this.#c),this.live=new Sn(this),this.projects=new An(this,this.#c),this.users=new zn(this,this.#c),this.agent={action:new dn(this,this.#c)},this.releases=new Un(this,this.#c),this.observable=new Ln(e,t)}clone(){return new Hn(this.#c,this.config())}config(e){if(void 0===e)return{...this.#u};if(this.#u&&!1===this.#u.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),this.#u=yr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Hn(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return et(Fr(this,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){return et(Mr(this,this.#c,e,t))}getDocuments(e,t){return et(Ur(this,this.#c,e,t))}create(e,t){return et(Xr(this,this.#c,e,"create",t))}createIfNotExists(e,t){return et(zr(this,this.#c,e,t))}createOrReplace(e,t){return et(Lr(this,this.#c,e,t))}createVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("createVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o},i=t||At(e._id);return tt(Hr(this,this.#c,s,i,n))}delete(e,t){return et(Vr(this,this.#c,e,t))}discardVersion({releaseId:e,publishedId:t},r,n){const o=Dn(t,e);return et(Br(this,this.#c,o,r,n))}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=kn("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return tt(Wr(this,this.#c,s,n))}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ot(t,e);return et(Jr(this,this.#c,n,t,r))}mutate(e,t){return et(Gr(this,this.#c,e,t))}patch(e,t){return new qr(e,t,this)}transaction(e){return new Or(e,this)}action(e,t){return et(Yr(this,this.#c,e,t))}request(e){return et(rn(this,this.#c,e))}dataRequest(e,t,r){return et(Qr(this,this.#c,e,t,r))}getUrl(e,t){return on(this,e,t)}getDataUrl(e,t){return nn(this,e,t)}}const Vn=(Qn=Hn,{requester:Ht(Yn=[]),createClient:e=>{const t=Ht(Yn);return new Qn(((r,n)=>(n||t)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...r})),e)}}),Bn=Vn.requester,Wn=Vn.createClient,Jn=(Gn=Wn,function(e){return hr(),Gn(e)});var Gn,Yn,Qn;const Xn=/_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?Xn.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 Zn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},eo={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function to(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=>eo[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=>eo[e]));t.push(e)}return t}function ro(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 no(e,t){if(!t?.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Zn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Zn[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 oo(e){return"object"==typeof e&&null!==e}function so(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(oo(e)){const o=e._key;if("string"==typeof o)return so(e,t,r.concat({_key:o,_index:n}))}return so(e,t,r.concat(n))}));if(oo(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=so(e.children,t,r.concat("children")):"span"===e._type&&(n.text=so(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,so(n,t,r.concat(e))])))}return t(e,r)}function io(e,t,r){return so(e,((e,n)=>{if("string"!=typeof e)return e;const o=no(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],c=t.paths[s.source.path],u=to(i),l=to(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const ao=".",co=`drafts${ao}`,uo=`versions${ao}`;function lo(e){return e.startsWith(co)}function ho(e){return e.startsWith(uo)}function po(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:c}=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 u="default"===r?void 0:r,l="default"===n?void 0:n,h=function(e){return ho(e)?e.split(ao).slice(2).join(ao):lo(e)?e.slice(co.length):e}(o),d=Array.isArray(i)?Kn(ro(i)):i,p=new URLSearchParams({baseUrl:t,id:h,type:s,path:d});if(u&&p.set("workspace",u),l&&p.set("tool",l),a&&p.set("projectId",a),c&&p.set("dataset",c),function(e){return!lo(e)&&!ho(e)}(o))p.set("perspective","published");else if(ho(o)){const e=function(e){if(!ho(e))return;const[t,r,...n]=e.split(ao);return r}(o);p.set("perspective",e)}const f=["/"===t?"":t];u&&f.push(u);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),f.push("intent","edit",`${y.join(";")}?${p}`),f.join("/")}const fo=({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("_")||o.endsWith("Id"))||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||bo(e)||bo(t)||"string"==typeof o&&yo.has(o))},yo=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","textTheme","unit","url","username","variant","website"]);function bo(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function go(e,t,r){const{filter:n,logger:o,enabled:s}=r;if(!s){const n="config.enabled must be true, don't call this function otherwise";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}if(!t)return o?.error?.("[@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 o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const i={encoded:[],skipped:[]},a=io(e,t,(({sourcePath:e,sourceDocument:t,resultPath:s,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:s,filterDefault:fo,sourceDocument:t,value:a}):fo({sourcePath:e,resultPath:s,value:a})))return o&&i.skipped.push({path:vo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&i.encoded.push({path:vo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length});const{baseUrl:c,workspace:u,tool:l}=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(!c)return a;const{_id:h,_type:d,_projectId:p,_dataset:f}=t;return Et(a,{origin:"sanity.io",href:po({baseUrl:c,workspace:u,tool:l,id:h,type:d,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:p}})},!1)}));if(o){const e=i.skipped.length,t=i.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${i.encoded.length}, skipped: ${i.skipped.length}`)),i.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(i.encoded)),i.skipped.length>0){const e=new Set;for(const{path:t}of i.skipped)e.add(t.replace(Xn,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function vo(e){return Kn(ro(e))}var mo=Object.freeze({__proto__:null,stegaEncodeSourceMap:go}),wo=Object.freeze({__proto__:null,encodeIntoResult:io,stegaEncodeSourceMap:go,stegaEncodeSourceMap$1:mo});function Co(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Eo,Io,_o,xo={exports:{}},Ro=xo.exports;
2
2
  /** @license
3
3
  * eventsource.js
4
4
  * Available under MIT License (MIT)