@sanity/client 7.1.0-views.0 → 7.1.0-views.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/README.md +810 -40
- package/dist/_chunks-cjs/config.cjs +14 -0
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-cjs/dataMethods.cjs +197 -32
- package/dist/_chunks-cjs/dataMethods.cjs.map +1 -1
- package/dist/_chunks-cjs/isRecord.cjs +6 -0
- package/dist/_chunks-cjs/isRecord.cjs.map +1 -0
- package/dist/_chunks-cjs/resolveEditInfo.cjs +3 -5
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaClean.cjs +4 -0
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +2 -5
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/config.js +15 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/_chunks-es/dataMethods.js +200 -33
- package/dist/_chunks-es/dataMethods.js.map +1 -1
- package/dist/_chunks-es/isRecord.js +7 -0
- package/dist/_chunks-es/isRecord.js.map +1 -0
- package/dist/_chunks-es/resolveEditInfo.js +1 -3
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaClean.js +4 -0
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -4
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/index.browser.cjs +1019 -59
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1950 -149
- package/dist/index.browser.d.ts +1950 -149
- package/dist/index.browser.js +1021 -60
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +825 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1950 -149
- package/dist/index.d.ts +1950 -149
- package/dist/index.js +826 -31
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1950 -149
- package/dist/stega.browser.d.ts +1950 -149
- package/dist/stega.d.cts +1950 -149
- package/dist/stega.d.ts +1950 -149
- package/dist/views.cjs +21 -5
- package/dist/views.cjs.map +1 -1
- package/dist/views.d.cts +54 -36
- package/dist/views.d.ts +54 -36
- package/dist/views.js +22 -5
- package/dist/views.js.map +1 -1
- package/package.json +2 -1
- package/src/SanityClient.ts +652 -12
- package/src/agent/actions/AgentActionsClient.ts +29 -2
- package/src/agent/actions/commonTypes.ts +57 -17
- package/src/agent/actions/generate.ts +36 -2
- package/src/agent/actions/patch.ts +136 -0
- package/src/agent/actions/prompt.ts +145 -0
- package/src/agent/actions/transform.ts +105 -7
- package/src/agent/actions/translate.ts +5 -2
- package/src/config.ts +3 -1
- package/src/csm/walkMap.ts +1 -1
- package/src/data/dataMethods.ts +170 -12
- package/src/data/encodeQueryString.ts +1 -1
- package/src/data/eventsource.ts +16 -7
- package/src/data/listen.ts +10 -4
- package/src/data/live.ts +13 -5
- package/src/datasets/DatasetsClient.ts +4 -1
- package/src/defineCreateClient.ts +7 -1
- package/src/http/errors.ts +92 -27
- package/src/http/request.ts +3 -3
- package/src/http/requestOptions.ts +4 -0
- package/src/projects/ProjectsClient.ts +6 -2
- package/src/releases/ReleasesClient.ts +693 -0
- package/src/releases/createRelease.ts +53 -0
- package/src/types.ts +293 -10
- package/src/users/UsersClient.ts +7 -3
- package/src/util/codeFrame.ts +174 -0
- package/src/util/createVersionId.ts +79 -0
- package/src/{csm → util}/isRecord.ts +1 -1
- package/src/validators.ts +23 -1
- package/src/views/index.ts +65 -15
- package/umd/sanityClient.js +1067 -61
- package/umd/sanityClient.min.js +2 -2
package/umd/sanityClient.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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=s(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 s=new URLSearchParams;for(const e of o.split("&")){const[t,r]=e.split("=");t&&s.append(i(t),i(r||""))}return{url:n,searchParams:s}}(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 i=n.toString();i&&(t.url=`${e}?${i}`)}}return t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t};function i(e){return decodeURIComponent(e.replace(/\+/g," "))}function s(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?s(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 f(e,t){const r=[],n=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[o],validateOptions:[c]});function i(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 i=r;for(let r=0;r<e[t].length&&(i=(0,e[t][r])(i,...n),!o||i);r++);return i})(n),i=o("processOptions",e);o("validateOptions",i);const s={options:i,channels:r,applyMiddleware:o};let a;const c=r.request.subscribe((e=>{a=t(e,((t,n)=>((e,t,n)=>{let i=e,s=t;if(!i)try{s=o("onResponse",t,n)}catch(e){s=null,i=e}i=i&&o("onError",i,n),i?r.error.publish(i):s&&r.response.publish(s)})(t,n,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=o("onReturn",r,s);return u===r&&r.request.publish(s),u}return i.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),i},i.clone=()=>f(r,t),e.forEach(i.use),i}var p,d,y=u(function(){if(d)return p;d=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 i=n[o],s=i.indexOf(":"),a=e(i.slice(0,s)).toLowerCase(),c=e(i.slice(s+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 g=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#i={};#s;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.#i=e,this.#s=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#i,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#s&&(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 v="function"==typeof XMLHttpRequest?"xhr":"fetch",b="xhr"===v?XMLHttpRequest:g,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},i=e.applyMiddleware("interceptRequest",void 0,{adapter:v,context:e});if(i){const e=setTimeout(t,0,null,i);return{abort:()=>clearTimeout(e)}}let s=new b;s instanceof g&&"object"==typeof n.fetch&&s.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,h=!1;if(s.onerror=e=>{d(s instanceof g?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)`:""}`))},s.ontimeout=e=>{d(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},s.onabort=()=>{p(!0),u=!0},s.onreadystatechange=()=>{c&&(p(),o.socket=setTimeout((()=>f("ESOCKETTIMEDOUT")),c.socket)),!u&&4===s.readyState&&0!==s.status&&function(){if(!(u||l||h)){if(0===s.status)return void d(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:s.response||(""===s.responseType||"text"===s.responseType?s.responseText:""),url:n.url,method:n.method,headers:y(s.getAllResponseHeaders()),statusCode:s.status,statusMessage:s.statusText})}}()},s.open(n.method,n.url,!0),s.withCredentials=!!n.withCredentials,a&&s.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&s.setRequestHeader(e,a[e]);return n.rawBody&&(s.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:v,request:s,context:e}),s.send(n.body||null),c&&(o.connect=setTimeout((()=>f("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,s&&s.abort()}};function f(t){h=!0,s.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||s.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function d(e){if(l)return;p(!0),l=!0,s=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)=>f(e,t);var C,E,x,_,S,R={exports:{}};S||(S=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=(_?x:(_=1,x=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}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!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=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,i=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,i=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,i++,r=i}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 i(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return C=function(s,a){a=a||{};var c,u,l=typeof s;if("string"===l&&s.length>0)return function(i){if(!((i=String(i)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(s){var a=parseFloat(s[1]);switch((s[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}}}}(s);if("number"===l&&isFinite(s))return a.long?(c=s,(u=Math.abs(c))>=n?i(c,u,n,"day"):u>=r?i(c,u,r,"hour"):u>=t?i(c,u,t,"minute"):u>=e?i(c,u,e,"second"):c+" ms"):function(o){var i=Math.abs(o);return i>=n?Math.round(o/n)+"d":i>=r?Math.round(o/r)+"h":i>=t?Math.round(o/t)+"m":i>=e?Math.round(o/e)+"s":o+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}(),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 O=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function $(e){return"[object Object]"===Object.prototype.toString.call(e)}const q=["boolean","string","number"];function j(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||O(t)||-1===q.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===$(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===$(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 T(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 A={};typeof globalThis<"u"?A=globalThis:typeof window<"u"?A=window:typeof global<"u"?A=global:typeof self<"u"&&(A=self);var I=A;function P(e={}){const t=e.implementation||I.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 k=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function D(e){return 100*Math.pow(2,e)+100*Math.random()}const F=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||D,n=e.shouldRetry;return{onError:(e,o)=>{const i=o.options,s=i.maxRetries||t,a=i.retryDelay||r,c=i.shouldRetry||n,u=i.attemptNumber||0;if(null!==(l=i.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,i)||u>=s)return e;var l;const h=Object.assign({},o,{options:Object.assign({},i,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(h)),a(u)),null}}})({shouldRetry:k,...e});F.shouldRetry=k;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,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(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(s,a)}c((n=n.apply(e,t||[])).next())}))}function z(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,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,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function B(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;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 W(e){return this instanceof W?(this.v=e,this):new W(e)}function J(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.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 W?Promise.resolve(e.value.v).then(c,u):l(i[0][2],e)}(o[e](t))}catch(e){l(i[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function V(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 i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=L(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.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 f=h.value;try{te(f)}catch(e){o=null!=o?o:[],e instanceof Q?o=B(B([],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,B([e,t],H(r)))};function oe(e){ne((function(){throw e}))}function ie(){}function se(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,i=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,i.destination=new ce(o),i}return U(t,e),t}(ae);function le(e){oe(e)}var he={closed:!0,next:ie,error:function(e){throw e},complete:ie},fe="function"==typeof Symbol&&Symbol.observable||"@@observable";function pe(e){return e}function de(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,i=(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 se((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},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=ge(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[fe]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return de(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ge(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 ge(e){var t;return null!==(t=null!=e?e:re.Promise)&&void 0!==t?t:Promise}function ve(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 be(e,t,r,n,o){return new me(e,t,r,n,o)}var me=function(e){function t(t,r,n,o,i,s){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,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;se((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=L(t.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(e)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;se((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;se((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,i=r.observers;return n||o?Z:(this.currentObservers=null,i.push(e),new K((function(){t.currentObservers=null,X(i,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),xe={now:function(){return(xe.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=xe);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,i=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(o.push(t),!i&&o.push(s.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,i=(o?1:2)*t;if(t<1/0&&i<n.length&&n.splice(0,n.length-i),!o){for(var s=r.now(),a=0,c=1;c<n.length&&n[c]<=s;c+=2)a=c;a&&n.splice(0,a+1)}},t}(Ce),Se=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,B([e,t],H(r)))},Oe=function(e){return clearInterval(e)},$e=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&&Oe(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}(Se),qe=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=xe.now,e}(),je=new(function(e){function t(t,r){void 0===r&&(r=qe.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}(qe))($e),Te=new ye((function(e){return e.complete()}));function Ae(e){return e[e.length-1]}function Ie(e){return(t=Ae(e))&&G(t.schedule)?e.pop():void 0;var t}var Pe=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function ke(e){return G(null==e?void 0:e.then)}function De(e){return G(e[fe])}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 J(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,W(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,W(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,W(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(De(e))return o=e,new ye((function(e){var t=o[fe]();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(ke(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 Be(e);if(Ne(e))return t=e,new ye((function(e){var r,n;try{for(var o=L(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Le(e))return Be(ze(e))}var t,r,n,o;throw Me(e)}function Be(e){return new ye((function(t){(function(e,t){var r,n,o,i;return N(this,void 0,void 0,(function(){var s,a;return z(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=V(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(s=n.value,t.next(s),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&&(i=r.return)?[4,i.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 We(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var i=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(i),!o)return i}function Je(e,t){return void 0===t&&(t=0),ve((function(r,n){r.subscribe(be(n,(function(r){return We(n,e,(function(){return n.next(r)}),t)}),(function(){return We(n,e,(function(){return n.complete()}),t)}),(function(r){return We(n,e,(function(){return n.error(r)}),t)})))}))}function Ve(e,t){return void 0===t&&(t=0),ve((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){We(r,t,(function(){var n=e[Symbol.asyncIterator]();We(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(De(e))return function(e,t){return He(e).pipe(Ve(t),Je(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(ke(e))return function(e,t){return He(e).pipe(Ve(t),Je(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 We(r,t,(function(){n=e[Ue](),We(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,Ie(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 ve((function(r,n){var o=0;r.subscribe(be(n,(function(r){n.next(e.call(t,r,o++))})))}))}var rt=Array.isArray;function nt(e){return tt((function(t){return function(e,t){return rt(t)?e.apply(void 0,B([],H(t))):e(t)}(e,t)}))}function ot(e,t,r){t()}function it(e,t,r){return void 0===r&&(r=1/0),G(t)?it((function(r,n){return tt((function(e,o){return t(r,e,n,o)}))(He(e(r,n)))}),r):("number"==typeof t&&(r=t),ve((function(t,n){return function(e,t,r,n,o,i,s){var a=[],c=0,u=0,l=!1,h=function(){!l||a.length||c||t.complete()},f=function(e){c++;var o=!1;He(r(e,u++)).subscribe(be(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(),s||f(e);h()}catch(e){t.error(e)}var e})))};return e.subscribe(be(t,(function(e){return c<n?f(e):a.push(e)}),(function(){l=!0,h()}))),function(){}}(t,n,e,r)})))}function st(e){return void 0===e&&(e=1/0),it(pe,e)}function at(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return st(1)(Qe(e,Ie(e)))}function ct(e){return new ye((function(t){He(e()).subscribe(t)}))}function ut(e,t,r){return void 0===r&&(r=je),new ye((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?1e3-r.now():e;o<0&&(o=0);var i=0;return r.schedule((function(){t.closed||(t.next(i++),t.complete())}),o)}))}function lt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Ie(e),n=function(e,t){return"number"==typeof Ae(e)?e.pop():t}(e,1/0),o=e;return o.length?1===o.length?He(o[0]):st(n)(Qe(o,r)):Te}var ht=Array.isArray;function ft(e,t){return ve((function(r,n){var o=0;r.subscribe(be(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function pt(e){return ve((function(t,r){var n,o=null,i=!1;o=t.subscribe(be(r,void 0,void 0,(function(s){n=He(e(s,pt(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):i=!0}))),i&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function dt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return G(Ae(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return de(e)}(dt.apply(void 0,B([],H(e))),nt(r)):ve((function(t,r){var n,o,i;(n=B([t],H(function(e){return 1===e.length&&ht(e[0])?e[0]:e}(e))),void 0===i&&(i=pe),function(e){ot(0,(function(){for(var t=n.length,r=new Array(t),s=t,a=t,c=function(t){ot(0,(function(){var c=Qe(n[t],o),u=!1;c.subscribe(be(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(i(r.slice()))}),(function(){--s||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function yt(e){return ve((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,i=e.resetOnComplete,s=void 0===i||i,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,i,a=0,u=!1,l=!1,h=function(){null==n||n.unsubscribe(),n=void 0},f=function(){h(),t=i=void 0,u=l=!1},p=function(){var e=t;f(),null==e||e.unsubscribe()};return ve((function(e,d){a++,l||u||h();var y=i=null!=i?i:r();d.add((function(){0!==--a||l||u||(n=vt(p,c))})),y.subscribe(d),!t&&a>0&&(t=new ue({next:function(e){return y.next(e)},error:function(e){l=!0,h(),n=vt(f,o,e),y.error(e)},complete:function(){u=!0,h(),n=vt(f,s),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,B([],H(r)))).subscribe(o)}}else e()}var bt={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},mt={0:8203,1:8204,2:8205,3:65279},wt=new Array(4).fill(String.fromCodePoint(mt[0])).join("");function Ct(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`${wt}${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(mt[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(mt).map((e=>e.reverse()))),Object.fromEntries(Object.entries(bt).map((e=>e.reverse())));var Et=`${Object.values(bt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,xt=new RegExp(`[${Et}]{4,}`,"gu");function _t(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(xt,""),encoded:(null==(t=e.match(xt))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}class St extends Error{response;statusCode=400;responseBody;details;constructor(e){const t=Ot(e);super(t.message),Object.assign(this,t)}}class Rt extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=Ot(e);super(t.message),Object.assign(this,t)}}function Ot(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:qt(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return $t(e)&&$t(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return $t(e)&&$t(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 $t(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function qt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class jt 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 Tt={onResponse:e=>{if(e.statusCode>=500)throw new Rt(e);if(e.statusCode>=400)throw new St(e);return e}};function At(){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 It(e){return w([F({shouldRetry:Pt}),...e,At(),j(),T(),{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"))}},Tt,P({implementation:ye})])}function Pt(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"),i=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!i)||F.shouldRetry(e,t,r)}function kt(e){return"https://www.sanity.io/help/"+e}const Dt=["image","file"],Ft=["before","after","replace"],Mt=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")},Ut=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},Nt=(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`)},zt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);Nt(e,t._id)},Lt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ht=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},Bt=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":case"view":return;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}},Wt=(e,t)=>{if(t["~experimental_resource"])throw new Error(`\`${e}\` does not support resource-based operations`)};const Jt=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Vt=Jt(["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"]),Gt=Jt(["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."]),Yt=Jt(["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."]),Qt=Jt(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),Xt=Jt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${kt("js-client-browser-token")} for more information and how to hide this warning.`]),Kt=Jt(["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`."]),Zt=Jt(["Using the Sanity client without specifying an API version is deprecated.",`See ${kt("js-client-api-version")}`]),er=Jt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),tr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},rr=["localhost","127.0.0.1","0.0.0.0"];function nr(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 or=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||tr.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Zt();const n={...tr,...r},o=n.useProjectHostname&&!n["~experimental_resource"];if(typeof Promise>"u"){const e=kt("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"]&&Bt(n),typeof n.perspective<"u"&&nr(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 i=typeof window<"u"&&window.location&&window.location.hostname,s=i&&(e=>-1!==rr.indexOf(e))(window.location.hostname),a=!!n.token;n.withCredentials&&a&&(Kt(),n.withCredentials=!1),i&&s&&a&&!0!==n.ignoreBrowserTokenWarning?Xt():typeof n.useCdn>"u"&&Gt(),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&&Mt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Ht(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===tr.apiHost,!0===n.useCdn&&n.withCredentials&&Vt(),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?"https://apicdn.sanity.io":n.apiCdnHost||n.apiHost).split("://",2),f=h[0],p=h[1];return o?(n.url=`${u}://${n.projectId}.${l}/v${n.apiVersion}`,n.cdnUrl=`${f}://${n.projectId}.${p}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=`${f}://${p}/v${n.apiVersion}`),n};class ir extends Error{name="ConnectionFailedError"}class sr extends Error{name="DisconnectError";reason;constructor(e,t,r={}){super(e,r),this.reason=t}}class ar extends Error{name="ChannelError";data;constructor(e,t){super(e),this.data=t}}class cr extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class ur extends Error{name="MessageParseError"}const lr=["channelError","disconnect"];function hr(e,t){return ct((()=>{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 i(t){if("data"in t){const[e,n]=fr(t);r.error(e?new ur("Unable to parse EventSource error message",{cause:n}):new cr((n?.data).message,n))}else e.readyState===e.CLOSED?r.error(new ir("EventSource connection failed")):o&&r.next({type:"reconnect"})}function s(){r.next({type:"open"})}function a(e){const[t,n]=fr(e);var o;t?r.error(new ur("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 sr(`Server disconnected client: ${n.data?.reason||"unknown error"}`)):r.error(new ar((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",i),n&&e.addEventListener("open",s);const c=[...new Set([...lr,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return c.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",i),n&&e.removeEventListener("open",s),c.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function fr(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,...pr(t)?{}:{data:t}}]}catch(e){return[e,null]}}function pr(e){for(const t in e)return!1;return!0}function dr(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 yr{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 Ut("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===Ft.indexOf(e)){const e=Ft.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,i=typeof r>"u"||-1===r?-1:Math.max(0,t+r),s=`${e}[${o}:${o<0&&i>=0?"":i}]`;return this.insert("replace",s,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...dr(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return Ut(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 gr extends yr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new gr(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 vr extends yr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new vr(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 br={returnDocuments:!1};class mr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return Ut("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Ut(t,e),zt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Ut(t,e),zt(t,e),this._add({[t]:e})}delete(e){return Nt("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 wr extends mr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new wr([...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},br,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 vr)return this._add({patch:e.serialize()});if(r){const r=t(new vr(e,{},this.#a));if(!(r instanceof vr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new vr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class Cr extends mr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Cr([...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},br,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof gr)return this._add({patch:e.serialize()});if(r){const r=t(new gr(e,{},this.#a));if(!(r instanceof gr))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 Er=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:i,returnQuery:s,...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===s&&n.append("returnQuery","false"),!1===i&&n.append("includeMutations","false"),`?${n}`},xr=(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},_r=e=>"response"===e.type,Sr=e=>e.body;function Rr(e,t,r,n,o={},i={}){const s="stega"in i?{...r||{},..."boolean"==typeof i.stega?{enabled:i.stega}:i.stega||{}}:r,a=s.enabled?_t(o):o,c=!1===i.filterResponse?e=>e:e=>e.result,{cache:u,next:l,...h}={useAbortSignal:typeof i.signal<"u",resultSourceMap:s.enabled?"withKeyArraySelector":i.resultSourceMap,...i,returnQuery:!1===i.filterResponse&&!1!==i.returnQuery},f=Pr(e,t,"query",{query:n,params:a},typeof u<"u"||typeof l<"u"?{...h,fetch:{cache:u,next:l}}:h);return s.enabled?f.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return dt.apply(void 0,B([],H(e)))}(Qe(Promise.resolve().then((function(){return Xn})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),tt((([e,t])=>{const r=t(e.result,e.resultSourceMap,s);return c({...e,result:r})}))):f.pipe(tt(c))}function Or(e,t,r,n={}){return Ur(e,t,{uri:zr(e,"doc",r),json:!0,tag:n.tag,signal:n.signal}).pipe(ft(_r),tt((e=>e.body.documents&&e.body.documents[0])))}function $r(e,t,r,n={}){return Ur(e,t,{uri:zr(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(ft(_r),tt((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 qr(e,t,r,n){return zt("createIfNotExists",r),kr(e,t,r,"createIfNotExists",n)}function jr(e,t,r,n){return zt("createOrReplace",r),kr(e,t,r,"createOrReplace",n)}function Tr(e,t,r,n){return Pr(e,t,"mutate",{mutations:[{delete:dr(r)}]},n)}function Ar(e,t,r,n){let o;o=r instanceof vr||r instanceof gr?{patch:r.serialize()}:r instanceof wr||r instanceof Cr?r.serialize():r;return Pr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function Ir(e,t,r,n){return Pr(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 Pr(e,t,r,n,o={}){const i="mutate"===r,s="actions"===r,a="query"===r,c=i||s?"":Er(n),u=!i&&!s&&c.length<11264,l=u?c:"",h=o.returnFirst,{timeout:f,token:p,tag:d,headers:y,returnQuery:g,lastLiveEventId:v,cacheMode:b}=o;return Ur(e,t,{method:u?"GET":"POST",uri:zr(e,r,l),json:!0,body:u?void 0:n,query:i&&xr(o),timeout:f,headers:y,token:p,tag:d,returnQuery:g,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(v)?v[0]:v,cacheMode:b,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(ft(_r),tt(Sr),tt((e=>{if(!i)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 kr(e,t,r,n,o={}){return Pr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}const Dr=e=>void 0!==e.dataset&&void 0!==e.projectId||void 0!==e["~experimental_resource"],Fr=(e,t)=>Dr(e)&&t.startsWith(zr(e,"query")),Mr=(e,t)=>t.startsWith("/data/")||Fr(e,t)||((e,t)=>Dr(e)&&t.startsWith(zr(e,"mutate")))(e,t)||((e,t)=>Dr(e)&&t.startsWith(zr(e,"doc","")))(e,t)||((e,t)=>Dr(e)&&t.startsWith(zr(e,"listen")))(e,t)||((e,t)=>Dr(e)&&t.startsWith(zr(e,"history","")))(e,t)||((e,t)=>Dr(e)&&t.startsWith(zr(e,"views")))(e,t);function Ur(e,t,r){const n=r.url||r.uri,o=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&Mr(e,n):r.canUseCdn;let i=(r.useCdn??e.useCdn)&&o;const s=r.tag&&e.requestTagPrefix?[e.requestTagPrefix,r.tag].join("."):r.tag||e.requestTagPrefix;if(s&&null!==r.tag&&(r.query={tag:Ht(s),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&Fr(e,n)){const t=r.resultSourceMap??e.resultSourceMap;void 0!==t&&!1!==t&&(r.query={resultSourceMap:t,...r.query});const n=r.perspective||e.perspective;typeof n<"u"&&("previewDrafts"===n&&Qt(),nr(n),r.query={perspective:Array.isArray(n)?n.join(","):n,...r.query},(Array.isArray(n)&&n.length>0||"previewDrafts"===n||"drafts"===n)&&i&&(i=!1,Yt())),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 a=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),i=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof i>"u"?3e5:i,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})}(e,Object.assign({},r,{url:Lr(e,n,i)})),c=new ye((r=>t(a,e.requester).subscribe(r)));return r.signal?c.pipe((u=r.signal,e=>new ye((t=>{const r=()=>t.error(function(e){if(Hr)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}(u));if(u&&u.aborted)return void r();const n=e.subscribe(t);return u.addEventListener("abort",r),()=>{u.removeEventListener("abort",r),n.unsubscribe()}})))):c;var u}function Nr(e,t,r){return Ur(e,t,r).pipe(ft((e=>"response"===e.type)),tt((e=>e.body)))}function zr(e,t,r){if(e["~experimental_resource"]){Bt(e);return`${Br(e)}/${void 0!==r?`${t}/${r}`:t}`.replace(/\/($|\?)/,"$1")}const n=`/${t}/${Lt(e)}`;return`/data${void 0!==r?`${n}/${r}`:n}`.replace(/\/($|\?)/,"$1")}function Lr(e,t,r=!1,n={}){const{url:o,cdnUrl:i}=e;return`${r?i:o}/${t.replace(/^\//,"")}`}const Hr=!!globalThis.DOMException;const Br=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}`;case"view":return`/views/${r}`;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}};function Wr(e,t,r){const n=Lt(e.config());return Nr(e.config(),t,{method:"POST",uri:`/agent/action/generate/${n}`,body:r})}function Jr(e,t,r){const n=Lt(e.config());return Nr(e.config(),t,{method:"POST",uri:`/agent/action/transform/${n}`,body:r})}function Vr(e,t,r){const n=Lt(e.config());return Nr(e.config(),t,{method:"POST",uri:`/agent/action/translate/${n}`,body:r})}class Gr{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return Wr(this.#a,this.#c,e)}transform(e){return Jr(this.#a,this.#c,e)}translate(e){return Vr(this.#a,this.#c,e)}}class Yr{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return et(Wr(this.#a,this.#c,e))}transform(e){return et(Jr(this.#a,this.#c,e))}translate(e){return et(Vr(this.#a,this.#c,e))}}class Qr{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return Kr(this.#a,this.#c,e,t,r)}}class Xr{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return et(Kr(this.#a,this.#c,e,t,r).pipe(ft((e=>"response"===e.type)),tt((e=>e.body.document))))}}function Kr(e,t,r,n,o={}){(e=>{if(-1===Dt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${Dt.join(", ")}`)})(r);let i=o.extract||void 0;i&&!i.length&&(i=["none"]);const s=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:f,filename:p,source:d}=a,y={label:u,title:l,description:h,filename:p,meta:i,creditLine:f};return d&&(y.sourceId=d.id,y.sourceName=d.name,y.sourceUrl=d.url),Ur(s,t,{tag:c,method:"POST",timeout:a.timeout||0,uri:Zr(s,r),headers:a.contentType?{"Content-Type":a.contentType}:{},query:y,body:n})}function Zr(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}`;case"view":throw new Error("Assets are not supported for views.");default:throw new Error(`Unsupported resource type: ${t.toString()}`)}}return`assets/${r}/${Lt(e)}`}const en=ct((()=>Promise.resolve().then((function(){return ao})))).pipe(tt((({default:e})=>e)),(nn=1,gt({connector:function(){return new _e(nn,tn,rn)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})));var tn,rn,nn;function on(){return function(e){return e.pipe(pt(((e,t)=>e instanceof ir?at(Xe({type:"reconnect"}),ut(1e3).pipe(it((()=>t)))):Ke((()=>e)))))}}const sn=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","tag"],an={includeResult:!0};function cn(e,t,r={}){const{url:n,token:o,withCredentials:i,requestTagPrefix:s}=this.config(),a=r.tag&&s?[s,r.tag].join("."):r.tag,c={...(f=r,p=an,Object.keys(p).concat(Object.keys(f)).reduce(((e,t)=>(e[t]=typeof f[t]>"u"?p[t]:f[t],e)),{})),tag:a},u=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(c,sn),l=Er({query:e,params:t,options:{tag:a,...u}}),h=`${n}${zr(this.config(),"listen",l)}`;var f,p;if(h.length>14800)return Ke((()=>new Error("Query too large for listener")));const d=c.events?c.events:["mutation"],y={};return i&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),hr((()=>(typeof EventSource>"u"||y.headers?en:Xe(EventSource)).pipe(tt((e=>new e(h,y))))),d).pipe(on(),ft((e=>d.includes(e.type))),tt((e=>({type:e.type,..."data"in e?e.data:{}}))))}function un(e,t){return function(e){return t=>{let r,n=!1;const{predicate:o,...i}=e,s=t.pipe((l=G(a=t=>{e.predicate(t)&&(n=!0,r=t)})||c||u?{next:a,error:c,complete:u}:a)?ve((function(e,t){var r;null===(r=l.subscribe)||void 0===r||r.call(l);var n=!0;e.subscribe(be(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,yt((()=>{n=!1,r=void 0})),gt(i));var a,c,u,l;return lt(s,new ye((e=>{n&&e.next(r),e.complete()})))}}("function"==typeof e?{predicate:e,...t}:e)}const ln="2021-03-25";class hn{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t}={}){Wt("live",this.#a.config());const{projectId:r,apiVersion:n,token:o,withCredentials:i,requestTagPrefix:s}=this.#a.config(),a=n.replace(/^v/,"");if("X"!==a&&a<ln)throw new Error(`The live events API requires API version ${ln} or later. The current API version is ${a}. Please update your API version to use this feature.`);if(e&&!o&&!i)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=zr(this.#a.config(),"live/events"),u=new URL(this.#a.getUrl(c,!1)),l=t&&s?[s,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&&i&&(h.withCredentials=!0);const f=`${u.href}::${JSON.stringify(h)}`,p=fn.get(f);if(p)return p;const d=hr((()=>(typeof EventSource>"u"||h.headers?en:Xe(EventSource)).pipe(tt((e=>new e(u.href,h))))),["message","restart","welcome","reconnect","goaway"]).pipe(on(),tt((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((()=>Te)),pt((()=>{throw new jt({projectId:r})}))),g=at(y,d).pipe(yt((()=>fn.delete(f))),un({predicate:e=>"welcome"===e.type}));return fn.set(f,g),g}}const fn=new Map;class pn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return yn(this.#a,this.#c,"PUT",e,t)}edit(e,t){return yn(this.#a,this.#c,"PATCH",e,t)}delete(e){return yn(this.#a,this.#c,"DELETE",e)}list(){return Nr(this.#a.config(),this.#c,{uri:"/datasets",tag:null})}}class dn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return Wt("dataset",this.#a.config()),et(yn(this.#a,this.#c,"PUT",e,t))}edit(e,t){return Wt("dataset",this.#a.config()),et(yn(this.#a,this.#c,"PATCH",e,t))}delete(e){return Wt("dataset",this.#a.config()),et(yn(this.#a,this.#c,"DELETE",e))}list(){return Wt("dataset",this.#a.config()),et(Nr(this.#a.config(),this.#c,{uri:"/datasets",tag:null}))}}function yn(e,t,r,n,o){return Wt("dataset",e.config()),Mt(n),Nr(e.config(),t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class gn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){Wt("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return Nr(this.#a.config(),this.#c,{uri:t})}getById(e){return Wt("projects",this.#a.config()),Nr(this.#a.config(),this.#c,{uri:`/projects/${e}`})}}class vn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){Wt("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return et(Nr(this.#a.config(),this.#c,{uri:t}))}getById(e){return Wt("projects",this.#a.config()),et(Nr(this.#a.config(),this.#c,{uri:`/projects/${e}`}))}}class bn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return Nr(this.#a.config(),this.#c,{uri:`/users/${e}`})}}class mn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return et(Nr(this.#a.config(),this.#c,{uri:`/users/${e}`}))}}class wn{assets;datasets;live;projects;users;agent;#u;#c;listen=cn;constructor(e,t=tr){this.config(t),this.#c=e,this.assets=new Qr(this,this.#c),this.datasets=new pn(this,this.#c),this.live=new hn(this),this.projects=new gn(this,this.#c),this.users=new bn(this,this.#c),this.agent={action:new Gr(this,this.#c)}}clone(){return new wn(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=or(e,this.#u||{}),this}withConfig(e){const t=this.config();return new wn(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Rr(this.#u,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){return Or(this.#u,this.#c,e,t)}getDocuments(e,t){return $r(this.#u,this.#c,e,t)}create(e,t){return kr(this.#u,this.#c,e,"create",t)}createIfNotExists(e,t){return qr(this.#u,this.#c,e,t)}createOrReplace(e,t){return jr(this.#u,this.#c,e,t)}delete(e,t){return Tr(this.#u,this.#c,e,t)}mutate(e,t){return Ar(this.#u,this.#c,e,t)}patch(e,t){return new gr(e,t,this)}transaction(e){return new Cr(e,this)}action(e,t){return Ir(this.#u,this.#c,e,t)}request(e){return Nr(this.#u,this.#c,e)}getUrl(e,t){return Lr(this.#u,e,t)}getDataUrl(e,t){return zr(this.#u,e,t)}}class Cn{assets;datasets;live;projects;users;agent;observable;#u;#c;listen=cn;constructor(e,t=tr){this.config(t),this.#c=e,this.assets=new Xr(this,this.#c),this.datasets=new dn(this,this.#c),this.live=new hn(this),this.projects=new vn(this,this.#c),this.users=new mn(this,this.#c),this.agent={action:new Yr(this,this.#c)},this.observable=new wn(e,t)}clone(){return new Cn(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=or(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Cn(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return et(Rr(this.#u,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){return et(Or(this.#u,this.#c,e,t))}getDocuments(e,t){return et($r(this.#u,this.#c,e,t))}create(e,t){return et(kr(this.#u,this.#c,e,"create",t))}createIfNotExists(e,t){return et(qr(this.#u,this.#c,e,t))}createOrReplace(e,t){return et(jr(this.#u,this.#c,e,t))}delete(e,t){return et(Tr(this.#u,this.#c,e,t))}mutate(e,t){return et(Ar(this.#u,this.#c,e,t))}patch(e,t){return new vr(e,t,this)}transaction(e){return new wr(e,this)}action(e,t){return et(Ir(this.#u,this.#c,e,t))}request(e){return et(Nr(this.#u,this.#c,e))}dataRequest(e,t,r){return et(Pr(this.#u,this.#c,e,t,r))}getUrl(e,t){return Lr(this.#u,e,t)}getDataUrl(e,t){return zr(this.#u,e,t)}}const En=($n=Cn,{requester:It(On=[]),createClient:e=>{const t=It(On);return new $n(((r,n)=>(n||t)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...r})),e)}}),xn=En.requester,_n=En.createClient,Sn=(Rn=_n,function(e){return er(),Rn(e)});var Rn,On,$n;const qn=/_key\s*==\s*['"](.*)['"]/;function jn(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?qn.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 Tn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},An={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function In(e){const t=[],r=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;let n;for(;null!==(n=r.exec(e));)if(void 0===n[1])if(void 0===n[2])if(void 0===n[3]);else{const e=n[3].replace(/\\(\\')/g,(e=>An[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=>An[e]));t.push(e)}return t}function Pn(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 kn(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=>Tn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Tn[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,i]=n[0];return{mapping:i,matchedPath:o,pathSuffix:r.substring(o.length)}}function Dn(e){return"object"==typeof e&&null!==e}function Fn(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(Dn(e)){const o=e._key;if("string"==typeof o)return Fn(e,t,r.concat({_key:o,_index:n}))}return Fn(e,t,r.concat(n))}));if(Dn(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=Fn(e.children,t,r.concat("children")):"span"===e._type&&(n.text=Fn(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,Fn(n,t,r.concat(e))])))}return t(e,r)}function Mn(e,t,r){return Fn(e,((e,n)=>{if("string"!=typeof e)return e;const o=kn(n,t);if(!o)return e;const{mapping:i,matchedPath:s}=o;if("value"!==i.type||"documentValue"!==i.source.type)return e;const a=t.documents[i.source.document],c=t.paths[i.source.path],u=In(s),l=In(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Un=".",Nn=`drafts${Un}`,zn=`versions${Un}`;function Ln(e){return e.startsWith(Nn)}function Hn(e){return e.startsWith(zn)}function Bn(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:i,path:s,projectId:a,dataset:c}=e;if(!t)throw new Error("baseUrl is required");if(!s)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 Hn(e)?e.split(Un).slice(2).join(Un):Ln(e)?e.slice(Nn.length):e}(o),f=Array.isArray(s)?jn(Pn(s)):s,p=new URLSearchParams({baseUrl:t,id:h,type:i,path:f});if(u&&p.set("workspace",u),l&&p.set("tool",l),a&&p.set("projectId",a),c&&p.set("dataset",c),function(e){return!Ln(e)&&!Hn(e)}(o))p.set("perspective","published");else if(Hn(o)){const e=function(e){if(!Hn(e))return;const[t,r,...n]=e.split(Un);return r}(o);p.set("perspective",e)}const d=["/"===t?"":t];u&&d.push(u);const y=["mode=presentation",`id=${h}`,`type=${i}`,`path=${encodeURIComponent(f)}`];return l&&y.push(`tool=${l}`),d.push("intent","edit",`${y.join(";")}?${p}`),d.join("/")}const Wn=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(r))return!1;var n;const o=e.at(-1);return!("slug"===e.at(-2)&&"current"===o||"string"==typeof o&&(o.startsWith("_")||o.endsWith("Id"))||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||Vn(e)||Vn(t)||"string"==typeof o&&Jn.has(o))},Jn=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 Vn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function Gn(e,t,r){const{filter:n,logger:o,enabled:i}=r;if(!i){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 s={encoded:[],skipped:[]},a=Mn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:i,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:i,filterDefault:Wn,sourceDocument:t,value:a}):Wn({sourcePath:e,resultPath:i,value:a})))return o&&s.skipped.push({path:Yn(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&s.encoded.push({path:Yn(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:f,_projectId:p,_dataset:d}=t;return Ct(a,{origin:"sanity.io",href:Bn({baseUrl:c,workspace:u,tool:l,id:h,type:f,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:d,projectId:p}})},!1)}));if(o){const e=s.skipped.length,t=s.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${s.encoded.length}, skipped: ${s.skipped.length}`)),s.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(s.encoded)),s.skipped.length>0){const e=new Set;for(const{path:t}of s.skipped)e.add(t.replace(qn,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function Yn(e){return jn(Pn(e))}var Qn=Object.freeze({__proto__:null,stegaEncodeSourceMap:Gn}),Xn=Object.freeze({__proto__:null,encodeIntoResult:Mn,stegaEncodeSourceMap:Gn,stegaEncodeSourceMap$1:Qn});function Kn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zn,eo,to,ro={exports:{}},no=ro.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=s(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 s=new URLSearchParams;for(const e of o.split("&")){const[t,r]=e.split("=");t&&s.append(i(t),i(r||""))}return{url:n,searchParams:s}}(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 i=n.toString();i&&(t.url=`${e}?${i}`)}}return t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t};function i(e){return decodeURIComponent(e.replace(/\+/g," "))}function s(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?s(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 i(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 i=r;for(let r=0;r<e[t].length&&(i=(0,e[t][r])(i,...n),!o||i);r++);return i})(n),i=o("processOptions",e);o("validateOptions",i);const s={options:i,channels:r,applyMiddleware:o};let a;const c=r.request.subscribe((e=>{a=t(e,((t,n)=>((e,t,n)=>{let i=e,s=t;if(!i)try{s=o("onResponse",t,n)}catch(e){s=null,i=e}i=i&&o("onError",i,n),i?r.error.publish(i):s&&r.response.publish(s)})(t,n,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=o("onReturn",r,s);return u===r&&r.request.publish(s),u}return i.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),i},i.clone=()=>d(r,t),e.forEach(i.use),i}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 i=n[o],s=i.indexOf(":"),a=e(i.slice(0,s)).toLowerCase(),c=e(i.slice(s+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 g=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#i={};#s;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.#i=e,this.#s=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#i,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#s&&(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 b="function"==typeof XMLHttpRequest?"xhr":"fetch",v="xhr"===b?XMLHttpRequest:g,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},i=e.applyMiddleware("interceptRequest",void 0,{adapter:b,context:e});if(i){const e=setTimeout(t,0,null,i);return{abort:()=>clearTimeout(e)}}let s=new v;s instanceof g&&"object"==typeof n.fetch&&s.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,h=!1;if(s.onerror=e=>{f(s instanceof g?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)`:""}`))},s.ontimeout=e=>{f(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},s.onabort=()=>{p(!0),u=!0},s.onreadystatechange=()=>{c&&(p(),o.socket=setTimeout((()=>d("ESOCKETTIMEDOUT")),c.socket)),!u&&4===s.readyState&&0!==s.status&&function(){if(!(u||l||h)){if(0===s.status)return void f(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:s.response||(""===s.responseType||"text"===s.responseType?s.responseText:""),url:n.url,method:n.method,headers:y(s.getAllResponseHeaders()),statusCode:s.status,statusMessage:s.statusText})}}()},s.open(n.method,n.url,!0),s.withCredentials=!!n.withCredentials,a&&s.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&s.setRequestHeader(e,a[e]);return n.rawBody&&(s.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:b,request:s,context:e}),s.send(n.body||null),c&&(o.connect=setTimeout((()=>d("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,s&&s.abort()}};function d(t){h=!0,s.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||s.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function f(e){if(l)return;p(!0),l=!0,s=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,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}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!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=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,i=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,i=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,i++,r=i}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 i(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return C=function(s,a){a=a||{};var c,u,l=typeof s;if("string"===l&&s.length>0)return function(i){if(!((i=String(i)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(s){var a=parseFloat(s[1]);switch((s[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}}}}(s);if("number"===l&&isFinite(s))return a.long?(c=s,(u=Math.abs(c))>=n?i(c,u,n,"day"):u>=r?i(c,u,r,"hour"):u>=t?i(c,u,t,"minute"):u>=e?i(c,u,e,"second"):c+" ms"):function(o){var i=Math.abs(o);return i>=n?Math.round(o/n)+"d":i>=r?Math.round(o/r)+"h":i>=t?Math.round(o/t)+"m":i>=e?Math.round(o/e)+"s":o+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}(),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 $=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function q(e){return"[object Object]"===Object.prototype.toString.call(e)}const S=["boolean","string","number"];function T(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||$(t)||-1===S.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 i=o.options,s=i.maxRetries||t,a=i.retryDelay||r,c=i.shouldRetry||n,u=i.attemptNumber||0;if(null!==(l=i.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,i)||u>=s)return e;var l;const h=Object.assign({},o,{options:Object.assign({},i,{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,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(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(s,a)}c((n=n.apply(e,t||[])).next())}))}function L(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function z(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,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function V(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;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||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.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(i[0][2],e)}(o[e](t))}catch(e){l(i[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function G(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=z(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 J(e){return"function"==typeof e}function Q(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 Y=Q((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 i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=z(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.remove(this);var c=this.initialTeardown;if(J(c))try{c()}catch(e){o=e instanceof Y?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=z(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{te(d)}catch(e){o=null!=o?o:[],e instanceof Y?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 Y(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&&J(e.remove)&&J(e.add)&&J(e.unsubscribe)}function te(e){J(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 ie(){}function se(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,i=e.call(this)||this;return o=J(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,i.destination=new ce(o),i}return U(t,e),t}(ae);function le(e){oe(e)}var he={closed:!0,next:ie,error:function(e){throw e},complete:ie},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,i=(n=e)&&n instanceof ae||function(e){return e&&J(e.next)&&J(e.error)&&J(e.complete)}(n)&&ee(n)?e:new ue(e,t,r);return se((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},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=ge(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=ge(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 ge(e){var t;return null!==(t=null!=e?e:re.Promise)&&void 0!==t?t:Promise}function be(e){return function(t){if(function(e){return J(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,i,s){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,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=Q((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;se((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=z(t.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(e)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;se((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;se((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,i=r.observers;return n||o?Z:(this.currentObservers=null,i.push(e),new K((function(){t.currentObservers=null,X(i,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,i=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(o.push(t),!i&&o.push(s.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,i=(o?1:2)*t;if(t<1/0&&i<n.length&&n.splice(0,n.length-i),!o){for(var s=r.now(),a=0,c=1;c<n.length&&n[c]<=s;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)))},$e=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&&$e(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),Se=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=Se.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}(Se))(qe),Oe=new ye((function(e){return e.complete()}));function je(e){return e[e.length-1]}function Ae(e){return(t=je(e))&&J(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 J(null==e?void 0:e.then)}function ke(e){return J(e[de])}function Fe(e){return Symbol.asyncIterator&&J(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 J(null==e?void 0:e[Ue])}function Le(e){return W(this,arguments,(function(){var t,r,n;return L(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 ze(e){return J(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(J(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=z(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(ze(e))return Ve(Le(e))}var t,r,n,o;throw Me(e)}function Ve(e){return new ye((function(t){(function(e,t){var r,n,o,i;return N(this,void 0,void 0,(function(){var s,a;return L(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=G(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(s=n.value,t.next(s),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&&(i=r.return)?[4,i.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 i=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(i),!o)return i}function We(e,t){return void 0===t&&(t=0),be((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 Ge(e,t){return void 0===t&&(t=0),be((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function Je(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 Qe(e,t){if(null!=e){if(ke(e))return function(e,t){return He(e).pipe(Ge(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(Ge(t),We(t))}(e,t);if(Fe(e))return Je(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 J(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(ze(e))return function(e,t){return Je(Le(e),t)}(e,t)}throw Me(e)}function Ye(e,t){return t?Qe(e,t):He(e)}function Xe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ye(e,Ae(e))}function Ke(e,t){var r=J(e)?e:function(){return e};return new ye((function(e){return e.error(r())}))}var Ze=Q((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 be((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 it(e,t,r){t()}function st(e,t,r){return void 0===r&&(r=1/0),J(t)?st((function(r,n){return rt((function(e,o){return t(r,e,n,o)}))(He(e(r,n)))}),r):("number"==typeof t&&(r=t),be((function(t,n){return function(e,t,r,n,o,i,s){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(),s||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),st(pe,e)}function ct(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return at(1)(Ye(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 i=0;return r.schedule((function(){t.closed||(t.next(i++),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)(Ye(o,r)):Oe}var dt=Array.isArray;function pt(e,t){return be((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 be((function(t,r){var n,o=null,i=!1;o=t.subscribe(ve(r,void 0,void 0,(function(s){n=He(e(s,ft(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):i=!0}))),i&&(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 J(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)):be((function(t,r){var n,o,i;(n=V([t],H(function(e){return 1===e.length&&dt(e[0])?e[0]:e}(e))),void 0===i&&(i=pe),function(e){it(0,(function(){for(var t=n.length,r=new Array(t),s=t,a=t,c=function(t){it(0,(function(){var c=Ye(n[t],o),u=!1;c.subscribe(ve(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(i(r.slice()))}),(function(){--s||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function gt(e){return be((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}function bt(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,i=e.resetOnComplete,s=void 0===i||i,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,i,a=0,u=!1,l=!1,h=function(){null==n||n.unsubscribe(),n=void 0},d=function(){h(),t=i=void 0,u=l=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return be((function(e,f){a++,l||u||h();var y=i=null!=i?i: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,s),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()}function mt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var wt={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},Ct={0:8203,1:8204,2:8205,3:65279},Et=new Array(4).fill(String.fromCodePoint(Ct[0])).join("");function It(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`${Et}${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(Ct[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Ct).map((e=>e.reverse()))),Object.fromEntries(Object.entries(wt).map((e=>e.reverse())));var _t=`${Object.values(wt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,xt=new RegExp(`[${_t}]{4,}`,"gu");function Rt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(xt,""),encoded:(null==(t=e.match(xt))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}const $t=".",qt=`drafts${$t}`,St=`versions${$t}`;function Tt(e){return e.startsWith(qt)}function Ot(e){return e.startsWith(St)}function jt(e,t){if("drafts"===t||"published"===t)throw new Error('Version can not be "published" or "drafts"');return`${St}${t}${$t}${Pt(e)}`}function At(e){if(!Ot(e))return;const[t,r,...n]=e.split($t);return r}function Pt(e){return Ot(e)?e.split($t).slice(2).join($t):Tt(e)?e.slice(qt.length):e}const Dt=/\r\n|[\n\r\u2028\u2029]/;function kt(e,t,r){const n=e.split(Dt),o={start:Ft(t.start,n),end:t.end?Ft(t.end,n):void 0},{start:i,end:s,markerLines:a}=function(e,t){const r={...e.start},n={...r,...e.end},o=2,i=3,s=r.line??-1,a=r.column??0,c=n.line,u=n.column;let l=Math.max(s-(o+1),0),h=Math.min(t.length,c+i);-1===s&&(l=0),-1===c&&(h=t.length);const d=c-s,p={};if(d)for(let e=0;e<=d;e++){const r=e+s;if(a)if(0===e){const e=t[r-1].length;p[r]=[a,e-a+1]}else if(e===d)p[r]=[0,u];else{const n=t[r-e].length;p[r]=[0,n]}else p[r]=!0}else p[s]=a===u?!a||[a,0]:[a,u-a];return{start:l,end:h,markerLines:p}}(o,n),c=`${s}`.length;return e.split(Dt,s).slice(i,s).map(((e,t)=>{const n=i+1+t,o=` ${` ${n}`.slice(-c)} |`,s=a[n],u=!a[n+1];if(!s)return` ${o}${e.length>0?` ${e}`:""}`;let l="";if(Array.isArray(s)){const t=e.slice(0,Math.max(s[0]-1,0)).replace(/[^\t]/g," "),n=s[1]||1;l=["\n ",o.replace(/\d/g," ")," ",t,"^".repeat(n)].join(""),u&&r&&(l+=" "+r)}return[">",o,e.length>0?` ${e}`:"",l].join("")})).join("\n")}function Ft(e,t){let r=0;for(let n=0;n<t.length;n++){const o=t[n].length+1;if(r+o>e)return{line:n+1,column:e-r};r+=o}return{line:t.length,column:t[t.length-1]?.length??0}}class Mt extends Error{response;statusCode=400;responseBody;details;constructor(e,t){const r=Nt(e,t);super(r.message),Object.assign(this,r)}}class Ut extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=Nt(e);super(t.message),Object.assign(this,t)}}function Nt(e,t){const r=e.body,n={response:e,statusCode:e.statusCode,responseBody:Vt(r,e),message:"",details:void 0};if(!mt(r))return n.message=Ht(e,r),n;const o=r.error;if("string"==typeof o&&"string"==typeof r.message)return n.message=`${o} - ${r.message}`,n;if("object"!=typeof o||null===o)return"string"==typeof o?n.message=o:"string"==typeof r.message?n.message=r.message:n.message=Ht(e,r),n;if(function(e){return"type"in e&&"mutationError"===e.type&&"description"in e&&"string"==typeof e.description}(o)||function(e){return"type"in e&&"actionError"===e.type&&"description"in e&&"string"==typeof e.description}(o)){const e=o.items||[],t=e.slice(0,5).map((e=>e.error?.description)).filter(Boolean);let i=t.length?`:\n- ${t.join("\n- ")}`:"";return e.length>5&&(i+=`\n...and ${e.length-5} more`),n.message=`${o.description}${i}`,n.details=r.error,n}if(Lt(o)){const e=t?.options?.query?.tag;return n.message=zt(o,e),n.details=r.error,n}return"description"in o&&"string"==typeof o.description?(n.message=o.description,n.details=o,n):(n.message=Ht(e,r),n)}function Lt(e){return mt(e)&&"queryParseError"===e.type&&"string"==typeof e.query&&"number"==typeof e.start&&"number"==typeof e.end}function zt(e,t){const{query:r,start:n,end:o,description:i}=e;if(!r||typeof n>"u")return`GROQ query parse error: ${i}`;const s=t?`\n\nTag: ${t}`:"";return`GROQ query parse error:\n${kt(r,{start:n,end:o},i)}${s}`}function Ht(e,t){const r="string"==typeof t?` (${o=t,i=100,o.length>i?`${o.slice(0,i)}…`:o})`:"",n=e.statusMessage?` ${e.statusMessage}`:"";var o,i;return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${n}${r}`}function Vt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class Bt 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 Wt={onResponse:(e,t)=>{if(e.statusCode>=500)throw new Ut(e);if(e.statusCode>=400)throw new Mt(e,t);return e}};function Gt(){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 Jt(e){return w([F({shouldRetry:Qt}),...e,Gt(),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"))}},Wt,P({implementation:ye})])}function Qt(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"),i=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!i)||F.shouldRetry(e,t,r)}function Yt(e){return"https://www.sanity.io/help/"+e}const Xt=["image","file"],Kt=["before","after","replace"],Zt=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")},er=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},tr=(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`)},rr=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);tr(e,t._id)},nr=(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)},or=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},ir=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},sr=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":case"view":return;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}},ar=(e,t)=>{if(t["~experimental_resource"])throw new Error(`\`${e}\` does not support resource-based operations`)};var cr=(e=>(e.Dataset="dataset",e.View="view",e))(cr||{});const ur=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),lr=ur(["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"]),hr=ur(["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."]),dr=ur(["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."]),pr=ur(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),fr=ur(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Yt("js-client-browser-token")} for more information and how to hide this warning.`]),yr=ur(["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`."]),gr=ur(["Using the Sanity client without specifying an API version is deprecated.",`See ${Yt("js-client-api-version")}`]),br=ur(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),vr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},mr=["localhost","127.0.0.1","0.0.0.0"];function wr(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 Cr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||vr.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||gr();const n={...vr,...r},o=n.useProjectHostname&&!n["~experimental_resource"];if(typeof Promise>"u"){const e=Yt("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"]&&sr(n),typeof n.perspective<"u"&&wr(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 i=typeof window<"u"&&window.location&&window.location.hostname,s=i&&(e=>-1!==mr.indexOf(e))(window.location.hostname),a=!!n.token;n.withCredentials&&a&&(yr(),n.withCredentials=!1),i&&s&&a&&!0!==n.ignoreBrowserTokenWarning?fr():typeof n.useCdn>"u"&&hr(),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&&Zt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?ir(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===vr.apiHost,!0===n.useCdn&&n.withCredentials&&lr(),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?"https://apicdn.sanity.io":n.apiCdnHost||n.apiHost).split("://",2),d=h[0],p=h[1];return o?(n.url=`${u}://${n.projectId}.${l}/v${n.apiVersion}`,n.cdnUrl=`${d}://${n.projectId}.${p}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=`${d}://${p}/v${n.apiVersion}`),n};class Er extends Error{name="ConnectionFailedError"}class Ir extends Error{name="DisconnectError";reason;constructor(e,t,r={}){super(e,r),this.reason=t}}class _r extends Error{name="ChannelError";data;constructor(e,t){super(e),this.data=t}}class xr extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class Rr extends Error{name="MessageParseError"}const $r=["channelError","disconnect"];function qr(e,t){return ut((()=>{const t=e();return(r=t)&&(r instanceof ye||J(r.lift)&&J(r.subscribe))?t:Xe(t);var r})).pipe(st((e=>function(e,t){return new ye((r=>{const n=t.includes("open"),o=t.includes("reconnect");function i(t){if("data"in t){const[e,n]=Sr(t);r.error(e?new Rr("Unable to parse EventSource error message",{cause:n}):new xr((n?.data).message,n))}else e.readyState===e.CLOSED?r.error(new Er("EventSource connection failed")):o&&r.next({type:"reconnect"})}function s(){r.next({type:"open"})}function a(t){const[n,o]=Sr(t);if(n)r.error(new Rr("Unable to parse EventSource message",{cause:n}));else if("channelError"!==t.type)"disconnect"!==t.type?r.next({type:t.type,id:t.lastEventId,...o.data?{data:o.data}:{}}):r.error(new Ir(`Server disconnected client: ${o.data?.reason||"unknown error"}`));else{const t=new URL(e.url).searchParams.get("tag");r.error(new _r(function(e,t){const r=e.error;return r?Lt(r)?zt(r,t):r.description?r.description:"string"==typeof r?r:JSON.stringify(r,null,2):e.message||"Unknown listener error"}(o?.data,t),o.data))}}e.addEventListener("error",i),n&&e.addEventListener("open",s);const c=[...new Set([...$r,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return c.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",i),n&&e.removeEventListener("open",s),c.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function Sr(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,...Tr(t)?{}:{data:t}}]}catch(e){return[e,null]}}function Tr(e){for(const t in e)return!1;return!0}function Or(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 jr{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 er("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===Kt.indexOf(e)){const e=Kt.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,i=typeof r>"u"||-1===r?-1:Math.max(0,t+r),s=`${e}[${o}:${o<0&&i>=0?"":i}]`;return this.insert("replace",s,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...Or(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return er(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 Ar extends jr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new Ar(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 Pr extends jr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new Pr(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 Dr={returnDocuments:!1};class kr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return er("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return er(t,e),rr(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return er(t,e),rr(t,e),this._add({[t]:e})}delete(e){return tr("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 Fr extends kr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Fr([...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},Dr,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 Pr)return this._add({patch:e.serialize()});if(r){const r=t(new Pr(e,{},this.#a));if(!(r instanceof Pr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new Pr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class Mr extends kr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Mr([...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},Dr,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Ar)return this._add({patch:e.serialize()});if(r){const r=t(new Ar(e,{},this.#a));if(!(r instanceof Ar))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 Ur=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:i,returnQuery:s,...a}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))void 0!==r&&n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(a))t&&n.append(e,`${t}`);return!1===s&&n.append("returnQuery","false"),!1===i&&n.append("includeMutations","false"),`?${n}`},Nr=(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},Lr=e=>"response"===e.type,zr=e=>e.body;function Hr(e,t,r,n,o={},i={}){const s="stega"in i?{...r||{},..."boolean"==typeof i.stega?{enabled:i.stega}:i.stega||{}}:r,a=s.enabled?Rt(o):o,c=!1===i.filterResponse?e=>e:e=>e.result,{cache:u,next:l,useEmulate:h,connections:d,...p}={useAbortSignal:typeof i.signal<"u",resultSourceMap:s.enabled?"withKeyArraySelector":i.resultSourceMap,useEmulate:!1,connections:void 0,...i,returnQuery:!1===i.filterResponse&&!1!==i.returnQuery},f=rn(e,t,h?"emulate":"query",h?{query:n,params:a,connections:d}:{query:n,params:a},typeof u<"u"||typeof l<"u"?{...p,fetch:{cache:u,next:l}}:p);return s.enabled?f.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yt.apply(void 0,V([],H(e)))}(Ye(Promise.resolve().then((function(){return $o})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),rt((([e,t])=>{const r=t(e.result,e.resultSourceMap,s);return c({...e,result:r})}))):f.pipe(rt(c))}function Vr(e,t,r,n={}){return un(e,t,{uri:hn(e,"doc",(()=>{if(!n.releaseId)return r;const e=At(r);if(!e){if(Tt(r))throw new Error(`The document ID (\`${r}\`) is a draft, but \`options.releaseId\` is set as \`${n.releaseId}\``);return jt(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(Lr),rt((e=>e.body.documents&&e.body.documents[0])))}function Br(e,t,r,n={}){return un(e,t,{uri:hn(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(pt(Lr),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 Wr(e,t,r,n={}){return rn(e,t,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:r}},n)}function Gr(e,t,r,n){return rr("createIfNotExists",r),nn(e,t,r,"createIfNotExists",n)}function Jr(e,t,r,n){return rr("createOrReplace",r),nn(e,t,r,"createOrReplace",n)}function Qr(e,t,r,n,o){return rr("createVersion",r),nr("createVersion",r),tn(e,t,{actionType:"sanity.action.document.version.create",publishedId:n,document:r},o)}function Yr(e,t,r,n){return rn(e,t,"mutate",{mutations:[{delete:Or(r)}]},n)}function Xr(e,t,r,n=!1,o){return tn(e,t,{actionType:"sanity.action.document.version.discard",versionId:r,purge:n},o)}function Kr(e,t,r,n){return rr("replaceVersion",r),nr("replaceVersion",r),tn(e,t,{actionType:"sanity.action.document.version.replace",document:r},n)}function Zr(e,t,r,n,o){return tn(e,t,{actionType:"sanity.action.document.version.unpublish",versionId:r,publishedId:n},o)}function en(e,t,r,n){let o;o=r instanceof Pr||r instanceof Ar?{patch:r.serialize()}:r instanceof Fr||r instanceof Mr?r.serialize():r;return rn(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function tn(e,t,r,n){return rn(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 rn(e,t,r,n,o={}){const i="mutate"===r,s="actions"===r,a="query"===r,c="emulate"===r,u=i||s||c?"":Ur(n),l=!i&&!s&&!c&&u.length<11264,h=l?u:"",d=o.returnFirst,{timeout:p,token:f,tag:y,headers:g,returnQuery:b,lastLiveEventId:v,cacheMode:m}=o;return un(e,t,{method:l?"GET":"POST",uri:hn(e,r,h),json:!0,body:l?void 0:n,query:i&&Nr(o),timeout:p,headers:g,token:f,tag:y,returnQuery:b,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(v)?v[0]:v,cacheMode:m,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(pt(Lr),rt(zr),rt((e=>{if(!i)return e;const t=e.results||[];if(o.returnDocuments)return d?t[0]&&t[0].document:t.map((e=>e.document));const r=d?"documentId":"documentIds",n=d?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function nn(e,t,r,n,o={}){return rn(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}const on=e=>void 0!==e.dataset&&void 0!==e.projectId||void 0!==e["~experimental_resource"],sn=(e,t)=>on(e)&&t.startsWith(hn(e,"query")),an=(e,t)=>on(e)&&t.startsWith(hn(e,"emulate")),cn=(e,t)=>t.startsWith("/data/")||sn(e,t)||((e,t)=>on(e)&&t.startsWith(hn(e,"mutate")))(e,t)||((e,t)=>on(e)&&t.startsWith(hn(e,"doc","")))(e,t)||((e,t)=>on(e)&&t.startsWith(hn(e,"listen")))(e,t)||((e,t)=>on(e)&&t.startsWith(hn(e,"history","")))(e,t)||((e,t)=>on(e)&&t.startsWith(hn(e,"views")))(e,t)||an(e,t);function un(e,t,r){const n=r.url||r.uri,o=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&cn(e,n):r.canUseCdn;let i=(r.useCdn??e.useCdn)&&o;const s=r.tag&&e.requestTagPrefix?[e.requestTagPrefix,r.tag].join("."):r.tag||e.requestTagPrefix;if(s&&null!==r.tag&&(r.query={tag:ir(s),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&(sn(e,n)||an(e,n))){const t=r.resultSourceMap??e.resultSourceMap;void 0!==t&&!1!==t&&(r.query={resultSourceMap:t,...r.query});const n=r.perspective||e.perspective;typeof n<"u"&&("previewDrafts"===n&&pr(),wr(n),r.query={perspective:Array.isArray(n)?n.join(","):n,...r.query},(Array.isArray(n)&&n.length>0||"previewDrafts"===n||"drafts"===n)&&i&&(i=!1,dr())),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 a=function(e,t={}){const r={};e.headers&&Object.assign(r,e.headers);const 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),i=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof i>"u"?3e5:i,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})}(e,Object.assign({},r,{url:dn(e,n,i)})),c=new ye((r=>t(a,e.requester).subscribe(r)));return r.signal?c.pipe((u=r.signal,e=>new ye((t=>{const r=()=>t.error(function(e){if(pn)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}(u));if(u&&u.aborted)return void r();const n=e.subscribe(t);return u.addEventListener("abort",r),()=>{u.removeEventListener("abort",r),n.unsubscribe()}})))):c;var u}function ln(e,t,r){return un(e,t,r).pipe(pt((e=>"response"===e.type)),rt((e=>e.body)))}function hn(e,t,r){if(e["~experimental_resource"]){sr(e);return`${fn(e)}/${void 0!==r?`${t}/${r}`:t}`.replace(/\/($|\?)/,"$1")}const n=`/${t}/${or(e)}`;return`/data${void 0!==r?`${n}/${r}`:n}`.replace(/\/($|\?)/,"$1")}function dn(e,t,r=!1){const{url:n,cdnUrl:o}=e;return`${r?o:n}/${t.replace(/^\//,"")}`}const pn=!!globalThis.DOMException;const fn=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}`;case"view":return`/views/${r}`;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}};function yn(e,t,r){const n=or(e.config());return ln(e.config(),t,{method:"POST",uri:`/agent/action/generate/${n}`,body:r})}function gn(e,t,r){const n=or(e.config());return ln(e.config(),t,{method:"POST",uri:`/agent/action/transform/${n}`,body:r})}function bn(e,t,r){const n=or(e.config());return ln(e.config(),t,{method:"POST",uri:`/agent/action/translate/${n}`,body:r})}class vn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return yn(this.#a,this.#c,e)}transform(e){return gn(this.#a,this.#c,e)}translate(e){return bn(this.#a,this.#c,e)}}class mn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return et(yn(this.#a,this.#c,e))}transform(e){return et(gn(this.#a,this.#c,e))}translate(e){return et(bn(this.#a,this.#c,e))}prompt(e){return et(function(e,t,r){const n=or(e.config());return ln(e.config(),t,{method:"POST",uri:`/agent/action/prompt/${n}`,body:r})}(this.#a,this.#c,e))}patch(e){return et(function(e,t,r){const n=or(e.config());return ln(e.config(),t,{method:"POST",uri:`/agent/action/patch/${n}`,body:r})}(this.#a,this.#c,e))}}class wn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return En(this.#a,this.#c,e,t,r)}}class Cn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return et(En(this.#a,this.#c,e,t,r).pipe(pt((e=>"response"===e.type)),rt((e=>e.body.document))))}}function En(e,t,r,n,o={}){(e=>{if(-1===Xt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${Xt.join(", ")}`)})(r);let i=o.extract||void 0;i&&!i.length&&(i=["none"]);const s=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:i,creditLine:d};return f&&(y.sourceId=f.id,y.sourceName=f.name,y.sourceUrl=f.url),un(s,t,{tag:c,method:"POST",timeout:a.timeout||0,uri:In(s,r),headers:a.contentType?{"Content-Type":a.contentType}:{},query:y,body:n})}function In(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}`;case"view":throw new Error("Assets are not supported for views.");default:throw new Error(`Unsupported resource type: ${t.toString()}`)}}return`assets/${r}/${or(e)}`}const _n=ut((()=>Promise.resolve().then((function(){return Fo})))).pipe(rt((({default:e})=>e)),($n=1,bt({connector:function(){return new _e($n,xn,Rn)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})));var xn,Rn,$n;function qn(){return function(e){return e.pipe(ft(((e,t)=>e instanceof Er?ct(Xe({type:"reconnect"}),lt(1e3).pipe(st((()=>t)))):Ke((()=>e)))))}}const Sn=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","tag"],Tn={includeResult:!0};function On(e,t,r={}){const{url:n,token:o,withCredentials:i,requestTagPrefix:s,headers:a}=this.config(),c=r.tag&&s?[s,r.tag].join("."):r.tag,u={...(p=r,f=Tn,Object.keys(f).concat(Object.keys(p)).reduce(((e,t)=>(e[t]=typeof p[t]>"u"?f[t]:p[t],e)),{})),tag:c},l=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,Sn),h=Ur({query:e,params:t,options:{tag:c,...l}}),d=`${n}${hn(this.config(),"listen",h)}`;var p,f;if(d.length>14800)return Ke((()=>new Error("Query too large for listener")));const y=u.events?u.events:["mutation"],g={};return i&&(g.withCredentials=!0),(o||a)&&(g.headers={},o&&(g.headers.Authorization=`Bearer ${o}`),a&&Object.assign(g.headers,a)),qr((()=>(typeof EventSource>"u"||g.headers?_n:Xe(EventSource)).pipe(rt((e=>new e(d,g))))),y).pipe(qn(),pt((e=>y.includes(e.type))),rt((e=>({type:e.type,..."data"in e?e.data:{}}))))}function jn(e,t){return function(e){return t=>{let r,n=!1;const{predicate:o,...i}=e,s=t.pipe((l=J(a=t=>{e.predicate(t)&&(n=!0,r=t)})||c||u?{next:a,error:c,complete:u}:a)?be((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,gt((()=>{n=!1,r=void 0})),bt(i));var a,c,u,l;return ht(s,new ye((e=>{n&&e.next(r),e.complete()})))}}("function"==typeof e?{predicate:e,...t}:e)}const An="2021-03-25";class Pn{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t}={}){ar("live",this.#a.config());const{projectId:r,apiVersion:n,token:o,withCredentials:i,requestTagPrefix:s,headers:a}=this.#a.config(),c=n.replace(/^v/,"");if("X"!==c&&c<An)throw new Error(`The live events API requires API version ${An} or later. The current API version is ${c}. Please update your API version to use this feature.`);if(e&&!o&&!i)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 u=hn(this.#a.config(),"live/events"),l=new URL(this.#a.getUrl(u,!1)),h=t&&s?[s,t].join("."):t;h&&l.searchParams.set("tag",h),e&&l.searchParams.set("includeDrafts","true");const d={};e&&i&&(d.withCredentials=!0),(e&&o||a)&&(d.headers={},e&&o&&(d.headers.Authorization=`Bearer ${o}`),a&&Object.assign(d.headers,a));const p=`${l.href}::${JSON.stringify(d)}`,f=Dn.get(p);if(f)return f;const y=qr((()=>(typeof EventSource>"u"||d.headers?_n:Xe(EventSource)).pipe(rt((e=>new e(l.href,d))))),["message","restart","welcome","reconnect","goaway"]).pipe(qn(),rt((e=>{if("message"===e.type){const{data:t,...r}=e;return{...r,tags:t.tags}}return e}))),g=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()}))}(l,{method:"OPTIONS",mode:"cors",credentials:d.withCredentials?"include":"omit",headers:d.headers}).pipe(st((()=>Oe)),ft((()=>{throw new Bt({projectId:r})}))),b=ct(g,y).pipe(gt((()=>Dn.delete(p))),jn({predicate:e=>"welcome"===e.type}));return Dn.set(p,b),b}}const Dn=new Map;class kn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return Mn(this.#a,this.#c,"PUT",e,t)}edit(e,t){return Mn(this.#a,this.#c,"PATCH",e,t)}delete(e){return Mn(this.#a,this.#c,"DELETE",e)}list(){return ln(this.#a.config(),this.#c,{uri:"/datasets",tag:null})}}class Fn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return ar("dataset",this.#a.config()),et(Mn(this.#a,this.#c,"PUT",e,t))}edit(e,t){return ar("dataset",this.#a.config()),et(Mn(this.#a,this.#c,"PATCH",e,t))}delete(e){return ar("dataset",this.#a.config()),et(Mn(this.#a,this.#c,"DELETE",e))}list(){return ar("dataset",this.#a.config()),et(ln(this.#a.config(),this.#c,{uri:"/datasets",tag:null}))}}function Mn(e,t,r,n,o){return ar("dataset",e.config()),Zt(n),ln(e.config(),t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class Un{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){ar("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return ln(this.#a.config(),this.#c,{uri:t})}getById(e){return ar("projects",this.#a.config()),ln(this.#a.config(),this.#c,{uri:`/projects/${e}`})}}class Nn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){ar("projects",this.#a.config());const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return et(ln(this.#a.config(),this.#c,{uri:t}))}getById(e){return ar("projects",this.#a.config()),et(ln(this.#a.config(),this.#c,{uri:`/projects/${e}`}))}}let Ln=e=>crypto.getRandomValues(new Uint8Array(e));const zn=((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(i=t)=>{let s="";for(;;){let t=r(o),a=0|o;for(;a--;)if(s+=e[t[a]&n]||"",s.length===i)return s}}})(e,t,Ln))("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),Hn=(e,t)=>t?jt(e,t):function(e){if(Ot(e)){const t=Pt(e);return qt+t}return Tt(e)?e:qt+e}(e);function Vn(e,{releaseId:t,publishedId:r,document:n}){if(r&&n._id){const e=Hn(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=Tt(n._id),o=Ot(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=At(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 Hn(r,t);throw new Error(`\`${e}()\` requires either a publishedId or a document with an \`_id\``)}const Bn=(e,t)=>{const[r,n,o]=((e,t)=>{if("object"==typeof e&&null!==e&&("releaseId"in e||"metadata"in e)){const{releaseId:r=zn(),metadata:n={}}=e;return[r,n,t]}return[zn(),{},e]})(e,t);return{action:{actionType:"sanity.action.release.create",releaseId:r,metadata:{...n,releaseType:n.releaseType||"undecided"}},options:o}};class Wn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Vr(this.#a.config(),this.#c,`_.releases.${e}`,t)}create(e,t){const{action:r,options:n}=Bn(e,t),{releaseId:o,metadata:i}=r;return tn(this.#a.config(),this.#c,r,n).pipe(rt((e=>({...e,releaseId:o,metadata:i}))))}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return tn(this.#a.config(),this.#c,n,r)}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return tn(this.#a.config(),this.#c,r,t)}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return tn(this.#a.config(),this.#c,r,t)}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return tn(this.#a.config(),this.#c,r,t)}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return tn(this.#a.config(),this.#c,n,r)}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return tn(this.#a.config(),this.#c,r,t)}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return tn(this.#a.config(),this.#c,r,t)}fetchDocuments({releaseId:e},t){return Wr(this.#a.config(),this.#c,e,t)}}class Gn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return et(Vr(this.#a.config(),this.#c,`_.releases.${e}`,t))}async create(e,t){const{action:r,options:n}=Bn(e,t),{releaseId:o,metadata:i}=r;return{...await et(tn(this.#a.config(),this.#c,r,n)),releaseId:o,metadata:i}}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return et(tn(this.#a.config(),this.#c,n,r))}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return et(tn(this.#a.config(),this.#c,r,t))}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return et(tn(this.#a.config(),this.#c,r,t))}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return et(tn(this.#a.config(),this.#c,r,t))}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return et(tn(this.#a.config(),this.#c,n,r))}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return et(tn(this.#a.config(),this.#c,r,t))}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return et(tn(this.#a.config(),this.#c,r,t))}fetchDocuments({releaseId:e},t){return et(Wr(this.#a.config(),this.#c,e,t))}}class Jn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return ln(this.#a.config(),this.#c,{uri:`/users/${e}`})}}class Qn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return et(ln(this.#a.config(),this.#c,{uri:`/users/${e}`}))}}class Yn{assets;datasets;live;projects;users;agent;releases;#u;#c;listen=On;constructor(e,t=vr){this.config(t),this.#c=e,this.assets=new wn(this,this.#c),this.datasets=new kn(this,this.#c),this.live=new Pn(this),this.projects=new Un(this,this.#c),this.users=new Jn(this,this.#c),this.agent={action:new vn(this,this.#c)},this.releases=new Wn(this,this.#c)}clone(){return new Yn(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=Cr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Yn(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Hr(this.#u,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){return Vr(this.#u,this.#c,e,t)}getDocuments(e,t){return Br(this.#u,this.#c,e,t)}create(e,t){return nn(this.#u,this.#c,e,"create",t)}createIfNotExists(e,t){return Gr(this.#u,this.#c,e,t)}createOrReplace(e,t){return Jr(this.#u,this.#c,e,t)}createVersion({document:e,publishedId:t,releaseId:r},n){const o=Vn("createVersion",{document:e,publishedId:t,releaseId:r}),i={...e,_id:o},s=t||Pt(e._id);return Qr(this.config(),this.#c,i,s,n)}delete(e,t){return Yr(this.#u,this.#c,e,t)}discardVersion({releaseId:e,publishedId:t},r,n){const o=Hn(t,e);return Xr(this.config(),this.#c,o,r,n)}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=Vn("replaceVersion",{document:e,publishedId:t,releaseId:r}),i={...e,_id:o};return Kr(this.config(),this.#c,i,n)}unpublishVersion({releaseId:e,publishedId:t},r){const n=jt(t,e);return Zr(this.config(),this.#c,n,t,r)}mutate(e,t){return en(this.#u,this.#c,e,t)}patch(e,t){return new Ar(e,t,this)}transaction(e){return new Mr(e,this)}action(e,t){return tn(this.#u,this.#c,e,t)}request(e){return ln(this.#u,this.#c,e)}getUrl(e,t){return dn(this.#u,e,t)}getDataUrl(e,t){return hn(this.#u,e,t)}}class Xn{assets;datasets;live;projects;users;agent;releases;observable;#u;#c;listen=On;constructor(e,t=vr){this.config(t),this.#c=e,this.assets=new Cn(this,this.#c),this.datasets=new Fn(this,this.#c),this.live=new Pn(this),this.projects=new Nn(this,this.#c),this.users=new Qn(this,this.#c),this.agent={action:new mn(this,this.#c)},this.releases=new Gn(this,this.#c),this.observable=new Yn(e,t)}clone(){return new Xn(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=Cr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Xn(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return et(Hr(this.#u,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){return et(Vr(this.#u,this.#c,e,t))}getDocuments(e,t){return et(Br(this.#u,this.#c,e,t))}create(e,t){return et(nn(this.#u,this.#c,e,"create",t))}createIfNotExists(e,t){return et(Gr(this.#u,this.#c,e,t))}createOrReplace(e,t){return et(Jr(this.#u,this.#c,e,t))}createVersion({document:e,publishedId:t,releaseId:r},n){const o=Vn("createVersion",{document:e,publishedId:t,releaseId:r}),i={...e,_id:o},s=t||Pt(e._id);return tt(Qr(this.config(),this.#c,i,s,n))}delete(e,t){return et(Yr(this.#u,this.#c,e,t))}discardVersion({releaseId:e,publishedId:t},r,n){const o=Hn(t,e);return et(Xr(this.config(),this.#c,o,r,n))}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=Vn("replaceVersion",{document:e,publishedId:t,releaseId:r}),i={...e,_id:o};return tt(Kr(this.config(),this.#c,i,n))}unpublishVersion({releaseId:e,publishedId:t},r){const n=jt(t,e);return et(Zr(this.config(),this.#c,n,t,r))}mutate(e,t){return et(en(this.#u,this.#c,e,t))}patch(e,t){return new Pr(e,t,this)}transaction(e){return new Fr(e,this)}action(e,t){return et(tn(this.#u,this.#c,e,t))}request(e){return et(ln(this.#u,this.#c,e))}dataRequest(e,t,r){return et(rn(this.#u,this.#c,e,t,r))}getUrl(e,t){return dn(this.#u,e,t)}getDataUrl(e,t){return hn(this.#u,e,t)}}const Kn=(oo=Xn,{requester:Jt(no=[]),createClient:e=>{const t=Jt(no);return new oo(((r,n)=>(n||t)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...r})),e)}}),Zn=Kn.requester,eo=Kn.createClient,to=(ro=eo,function(e){return br(),ro(e)});var ro,no,oo;const io=/_key\s*==\s*['"](.*)['"]/;function so(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?io.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 ao={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},co={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function uo(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=>co[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=>co[e]));t.push(e)}return t}function lo(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 ho(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=>ao[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>ao[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,i]=n[0];return{mapping:i,matchedPath:o,pathSuffix:r.substring(o.length)}}function po(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(mt(e)){const o=e._key;if("string"==typeof o)return po(e,t,r.concat({_key:o,_index:n}))}return po(e,t,r.concat(n))}));if(mt(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=po(e.children,t,r.concat("children")):"span"===e._type&&(n.text=po(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,po(n,t,r.concat(e))])))}return t(e,r)}function fo(e,t,r){return po(e,((e,n)=>{if("string"!=typeof e)return e;const o=ho(n,t);if(!o)return e;const{mapping:i,matchedPath:s}=o;if("value"!==i.type||"documentValue"!==i.source.type)return e;const a=t.documents[i.source.document],c=t.paths[i.source.path],u=uo(s),l=uo(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const yo=".",go=`drafts${yo}`,bo=`versions${yo}`;function vo(e){return e.startsWith(go)}function mo(e){return e.startsWith(bo)}function wo(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:i,path:s,projectId:a,dataset:c}=e;if(!t)throw new Error("baseUrl is required");if(!s)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 mo(e)?e.split(yo).slice(2).join(yo):vo(e)?e.slice(go.length):e}(o),d=Array.isArray(s)?so(lo(s)):s,p=new URLSearchParams({baseUrl:t,id:h,type:i,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!vo(e)&&!mo(e)}(o))p.set("perspective","published");else if(mo(o)){const e=function(e){if(!mo(e))return;const[t,r,...n]=e.split(yo);return r}(o);p.set("perspective",e)}const f=["/"===t?"":t];u&&f.push(u);const y=["mode=presentation",`id=${h}`,`type=${i}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),f.push("intent","edit",`${y.join(";")}?${p}`),f.join("/")}const Co=({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))||Io(e)||Io(t)||"string"==typeof o&&Eo.has(o))},Eo=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 Io(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function _o(e,t,r){const{filter:n,logger:o,enabled:i}=r;if(!i){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 s={encoded:[],skipped:[]},a=fo(e,t,(({sourcePath:e,sourceDocument:t,resultPath:i,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:i,filterDefault:Co,sourceDocument:t,value:a}):Co({sourcePath:e,resultPath:i,value:a})))return o&&s.skipped.push({path:xo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&s.encoded.push({path:xo(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 It(a,{origin:"sanity.io",href:wo({baseUrl:c,workspace:u,tool:l,id:h,type:d,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:p}})},!1)}));if(o){const e=s.skipped.length,t=s.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${s.encoded.length}, skipped: ${s.skipped.length}`)),s.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(s.encoded)),s.skipped.length>0){const e=new Set;for(const{path:t}of s.skipped)e.add(t.replace(io,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function xo(e){return so(lo(e))}var Ro=Object.freeze({__proto__:null,stegaEncodeSourceMap:_o}),$o=Object.freeze({__proto__:null,encodeIntoResult:fo,stegaEncodeSourceMap:_o,stegaEncodeSourceMap$1:Ro});function qo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var So,To,Oo,jo={exports:{}},Ao=jo.exports;
|
|
2
2
|
/** @license
|
|
3
3
|
* eventsource.js
|
|
4
4
|
* Available under MIT License (MIT)
|
|
5
5
|
* https://github.com/Yaffle/EventSource/
|
|
6
|
-
*/function oo(){return Zn||(Zn=1,function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,i=r.XMLHttpRequest,s=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,h=r.fetch,f=r.Response,p=r.TextDecoder,d=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===u||"readyState"in u||null!=u.body||(u.readyState="loading",window.addEventListener("load",(function(e){u.readyState="complete"}),!1)),null==i&&null!=a&&(i=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=h;h=function(e,t){var r=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function v(){this.bitsNeeded=0,this.codePoint=0}v.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",i=this.bitsNeeded,s=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==i&&(c<128||c>191||!t(s<<6|63&c,i-6,r(i,s)))&&(i=0,s=n,o+=String.fromCharCode(s)),0===i?(c>=0&&c<=127?(i=0,s=c):c>=192&&c<=223?(i=6,s=31&c):c>=224&&c<=239?(i=12,s=15&c):c>=240&&c<=247?(i=18,s=7&c):(i=0,s=n),0===i||t(s,i,r(i,s))||(i=0,s=n)):(i-=6,s=s<<6|63&c),0===i&&(s<=65535?o+=String.fromCharCode(s):(o+=String.fromCharCode(55296+(s-65535-1>>10)),o+=String.fromCharCode(56320+(s-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=s,o};null!=p&&null!=d&&function(){try{return"test"===(new p).decode((new d).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=v);var b=function(){};function m(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),i=o.shift(),s=o.join(": ");t[w(i)]=s}this._map=t}function E(){}function x(e){this._headers=e}function _(){}function S(){this._listeners=Object.create(null)}function R(e){n((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function $(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function q(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function j(e,t){O.call(this,e),this.error=t.error}m.prototype.open=function(e,t){this._abort(!0);var r=this,s=this._xhr,a=1,c=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,s.onload=b,s.onerror=b,s.onabort=b,s.onprogress=b,s.onreadystatechange=b,s.abort(),0!==c&&(o(c),c=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var u=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in s)e=200,t="OK",n=s.contentType;else try{e=s.status,t=s.statusText,n=s.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=s.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:b}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},f=function(){c=n((function(){f()}),500),3===s.readyState&&l()};"onload"in s&&(s.onload=function(e){h("load",e)}),"onerror"in s&&(s.onerror=function(e){h("error",e)}),"onabort"in s&&(s.onabort=function(e){h("abort",e)}),"onprogress"in s&&(s.onprogress=l),"onreadystatechange"in s&&(s.onreadystatechange=function(e){!function(e){null!=s&&(4===s.readyState?"onload"in s&&"onerror"in s&&"onabort"in s||h(""===s.responseText?"error":"load",e):3===s.readyState?"onprogress"in s||l():2===s.readyState&&u())}(e)}),!("contentType"in s)&&"ontimeout"in i.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),s.open(e,t,!0),"readyState"in s&&(c=n((function(){f()}),0))},m.prototype.abort=function(){this._abort(!1)},m.prototype.getResponseHeader=function(e){return this._contentType},m.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},m.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},m.prototype.send=function(){if("ontimeout"in i.prototype&&("sendAsBinary"in i.prototype||"mozAnon"in i.prototype)||null==u||null==u.readyState||"complete"===u.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=i&&null==i.HEADERS_RECEIVED&&(i.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,s,a){e.open("GET",o);var c=0;for(var u in e.onprogress=function(){var t=e.responseText.slice(c);c+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===i.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),s=e.getAllResponseHeaders();t(r,n,o,new C(s))}},e.withCredentials=s,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},_.prototype.open=function(e,t,r,n,o,i,s){var a=null,c=new y,u=c.signal,f=new p;return h(o,{headers:s,credentials:i?"include":"same-origin",signal:u,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=f.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},S.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){R(e)}}},S.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,i=0;i<n.length;i+=1)n[i]===t&&(o=!0);o||n.push(t)},S.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],i=0;i<n.length;i+=1)n[i]!==t&&o.push(n[i]);0===o.length?delete r[e]:r[e]=o}},$.prototype=Object.create(O.prototype),q.prototype=Object.create(O.prototype),j.prototype=Object.create(O.prototype);var T=-1,A=-1,I=/^text\/event\-stream(;.*)?$/i,P=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),k(r)},k=function(e){return Math.min(Math.max(e,1e3),18e6)},D=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){R(e)}};function F(e,t){S.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),c=r.lastEventIdQueryParameterName||"lastEventId",u=k(1e3),l=P(r.heartbeatTimeout,45e3),h="",f=u,p=!1,d=0,y=r.headers||{},g=r.Transport,v=M&&null==g?void 0:new m(null!=g?new g:null!=i&&"withCredentials"in i.prototype||null==s?new i:new s),b=null!=g&&"string"!=typeof g?new g:null==v?new _:new E,w=void 0,C=0,x=T,S="",R="",O="",F="",U=0,N=0,z=0,L=function(t,r,n,o){if(0===x)if(200===t&&null!=n&&I.test(n)){x=1,p=Date.now(),f=u,e.readyState=1;var i=new q("open",{status:t,statusText:r,headers:o});e.dispatchEvent(i),D(e,e.onopen,i)}else{var s="";200!==t?(r&&(r=r.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",W();i=new q("error",{status:t,statusText:r,headers:o});e.dispatchEvent(i),D(e,e.onerror,i),console.error(s)}},H=function(t){if(1===x){for(var r=-1,i=0;i<t.length;i+=1){(c=t.charCodeAt(i))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=i)}var s=(-1!==r?F:"")+t.slice(0,r+1);F=(-1===r?F:"")+t.slice(r+1),""!==t&&(p=Date.now(),d+=t.length);for(var a=0;a<s.length;a+=1){var c=s.charCodeAt(a);if(U===A&&c==="\n".charCodeAt(0))U=0;else if(U===A&&(U=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==U){1===U&&(z=a+1);var y=s.slice(N,z-1),g=s.slice(z+(z<a&&s.charCodeAt(z)===" ".charCodeAt(0)?1:0),a);"data"===y?(S+="\n",S+=g):"id"===y?R=g:"event"===y?O=g:"retry"===y?(u=P(g,u),f=u):"heartbeatTimeout"===y&&(l=P(g,l),0!==C&&(o(C),C=n((function(){J()}),l)))}if(0===U){if(""!==S){h=R,""===O&&(O="message");var v=new $(O,{data:S.slice(1),lastEventId:R});if(e.dispatchEvent(v),"open"===O?D(e,e.onopen,v):"message"===O?D(e,e.onmessage,v):"error"===O&&D(e,e.onerror,v),2===x)return}S="",O=""}U=c==="\r".charCodeAt(0)?A:0}else 0===U&&(N=a,U=1),1===U?c===":".charCodeAt(0)&&(z=a+1,U=2):2===U&&(U=3)}}},B=function(t){if(1===x||0===x){x=T,0!==C&&(o(C),C=0),C=n((function(){J()}),f),f=k(Math.min(16*u,2*f)),e.readyState=0;var r=new j("error",{error:t});e.dispatchEvent(r),D(e,e.onerror,r),null!=t&&console.error(t)}},W=function(){x=2,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=2},J=function(){if(C=0,x===T){p=!1,d=0,C=n((function(){J()}),l),x=0,S="",O="",R=h,F="",N=0,z=0,U=0;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===c?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(h)}var i=e.withCredentials,s={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(s[u]=a[u]);try{w=b.open(v,L,H,B,r,i,s)}catch(e){throw W(),e}}else if(p||null==w){var f=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){J()}),f)}else B(new Error("No activity within "+l+" milliseconds. "+(0===x?"No response received.":d+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=W,J()}(this,e,t)}var M=null!=h&&null!=f&&"body"in f.prototype;F.prototype=Object.create(S.prototype),F.prototype.CONNECTING=0,F.prototype.OPEN=1,F.prototype.CLOSED=2,F.prototype.close=function(){this._close()},F.CONNECTING=0,F.OPEN=1,F.CLOSED=2,F.prototype.withCredentials=void 0;var U=c;null==i||null!=c&&"withCredentials"in c.prototype||(U=F),function(){var r=function(e){e.EventSourcePolyfill=F,e.NativeEventSource=c,e.EventSource=U}(t);void 0!==r&&(e.exports=r)}()}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:no:globalThis)}(ro,ro.exports)),ro.exports}function io(){return to?eo:(to=1,eo=oo().EventSourcePolyfill)}var so=io(),ao=t({__proto__:null,default:Kn(so)},[so]);e.BasePatch=yr,e.BaseTransaction=mr,e.ChannelError=ar,e.ClientError=St,e.ConnectionFailedError=ir,e.CorsOriginError=jt,e.DisconnectError=sr,e.MessageError=cr,e.MessageParseError=ur,e.ObservablePatch=gr,e.ObservableSanityClient=wn,e.ObservableTransaction=Cr,e.Patch=vr,e.SanityClient=Cn,e.ServerError=Rt,e.Transaction=wr,e.connectEventSource=hr,e.createClient=_n,e.default=Sn,e.requester=xn,e.unstable__adapter=v,e.unstable__environment="browser",e.validateApiPerspective=nr,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
6
|
+
*/function Po(){return So||(So=1,function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,i=r.XMLHttpRequest,s=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,h=r.fetch,d=r.Response,p=r.TextDecoder,f=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===u||"readyState"in u||null!=u.body||(u.readyState="loading",window.addEventListener("load",(function(e){u.readyState="complete"}),!1)),null==i&&null!=a&&(i=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=h;h=function(e,t){var r=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function b(){this.bitsNeeded=0,this.codePoint=0}b.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",i=this.bitsNeeded,s=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==i&&(c<128||c>191||!t(s<<6|63&c,i-6,r(i,s)))&&(i=0,s=n,o+=String.fromCharCode(s)),0===i?(c>=0&&c<=127?(i=0,s=c):c>=192&&c<=223?(i=6,s=31&c):c>=224&&c<=239?(i=12,s=15&c):c>=240&&c<=247?(i=18,s=7&c):(i=0,s=n),0===i||t(s,i,r(i,s))||(i=0,s=n)):(i-=6,s=s<<6|63&c),0===i&&(s<=65535?o+=String.fromCharCode(s):(o+=String.fromCharCode(55296+(s-65535-1>>10)),o+=String.fromCharCode(56320+(s-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=s,o};null!=p&&null!=f&&function(){try{return"test"===(new p).decode((new f).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=b);var v=function(){};function m(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=v}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),i=o.shift(),s=o.join(": ");t[w(i)]=s}this._map=t}function E(){}function I(e){this._headers=e}function _(){}function x(){this._listeners=Object.create(null)}function R(e){n((function(){throw e}),0)}function $(e){this.type=e,this.target=void 0}function q(e,t){$.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function S(e,t){$.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function T(e,t){$.call(this,e),this.error=t.error}m.prototype.open=function(e,t){this._abort(!0);var r=this,s=this._xhr,a=1,c=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,s.onload=v,s.onerror=v,s.onabort=v,s.onprogress=v,s.onreadystatechange=v,s.abort(),0!==c&&(o(c),c=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var u=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in s)e=200,t="OK",n=s.contentType;else try{e=s.status,t=s.statusText,n=s.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=s.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:v}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},d=function(){c=n((function(){d()}),500),3===s.readyState&&l()};"onload"in s&&(s.onload=function(e){h("load",e)}),"onerror"in s&&(s.onerror=function(e){h("error",e)}),"onabort"in s&&(s.onabort=function(e){h("abort",e)}),"onprogress"in s&&(s.onprogress=l),"onreadystatechange"in s&&(s.onreadystatechange=function(e){!function(e){null!=s&&(4===s.readyState?"onload"in s&&"onerror"in s&&"onabort"in s||h(""===s.responseText?"error":"load",e):3===s.readyState?"onprogress"in s||l():2===s.readyState&&u())}(e)}),!("contentType"in s)&&"ontimeout"in i.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),s.open(e,t,!0),"readyState"in s&&(c=n((function(){d()}),0))},m.prototype.abort=function(){this._abort(!1)},m.prototype.getResponseHeader=function(e){return this._contentType},m.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},m.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},m.prototype.send=function(){if("ontimeout"in i.prototype&&("sendAsBinary"in i.prototype||"mozAnon"in i.prototype)||null==u||null==u.readyState||"complete"===u.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=i&&null==i.HEADERS_RECEIVED&&(i.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,s,a){e.open("GET",o);var c=0;for(var u in e.onprogress=function(){var t=e.responseText.slice(c);c+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===i.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),s=e.getAllResponseHeaders();t(r,n,o,new C(s))}},e.withCredentials=s,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},I.prototype.get=function(e){return this._headers.get(e)},_.prototype.open=function(e,t,r,n,o,i,s){var a=null,c=new y,u=c.signal,d=new p;return h(o,{headers:s,credentials:i?"include":"same-origin",signal:u,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new I(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=d.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},x.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){R(e)}}},x.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,i=0;i<n.length;i+=1)n[i]===t&&(o=!0);o||n.push(t)},x.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],i=0;i<n.length;i+=1)n[i]!==t&&o.push(n[i]);0===o.length?delete r[e]:r[e]=o}},q.prototype=Object.create($.prototype),S.prototype=Object.create($.prototype),T.prototype=Object.create($.prototype);var O=-1,j=-1,A=/^text\/event\-stream(;.*)?$/i,P=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),D(r)},D=function(e){return Math.min(Math.max(e,1e3),18e6)},k=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){R(e)}};function F(e,t){x.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),c=r.lastEventIdQueryParameterName||"lastEventId",u=D(1e3),l=P(r.heartbeatTimeout,45e3),h="",d=u,p=!1,f=0,y=r.headers||{},g=r.Transport,b=M&&null==g?void 0:new m(null!=g?new g:null!=i&&"withCredentials"in i.prototype||null==s?new i:new s),v=null!=g&&"string"!=typeof g?new g:null==b?new _:new E,w=void 0,C=0,I=O,x="",R="",$="",F="",U=0,N=0,L=0,z=function(t,r,n,o){if(0===I)if(200===t&&null!=n&&A.test(n)){I=1,p=Date.now(),d=u,e.readyState=1;var i=new S("open",{status:t,statusText:r,headers:o});e.dispatchEvent(i),k(e,e.onopen,i)}else{var s="";200!==t?(r&&(r=r.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",B();i=new S("error",{status:t,statusText:r,headers:o});e.dispatchEvent(i),k(e,e.onerror,i),console.error(s)}},H=function(t){if(1===I){for(var r=-1,i=0;i<t.length;i+=1){(c=t.charCodeAt(i))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=i)}var s=(-1!==r?F:"")+t.slice(0,r+1);F=(-1===r?F:"")+t.slice(r+1),""!==t&&(p=Date.now(),f+=t.length);for(var a=0;a<s.length;a+=1){var c=s.charCodeAt(a);if(U===j&&c==="\n".charCodeAt(0))U=0;else if(U===j&&(U=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==U){1===U&&(L=a+1);var y=s.slice(N,L-1),g=s.slice(L+(L<a&&s.charCodeAt(L)===" ".charCodeAt(0)?1:0),a);"data"===y?(x+="\n",x+=g):"id"===y?R=g:"event"===y?$=g:"retry"===y?(u=P(g,u),d=u):"heartbeatTimeout"===y&&(l=P(g,l),0!==C&&(o(C),C=n((function(){W()}),l)))}if(0===U){if(""!==x){h=R,""===$&&($="message");var b=new q($,{data:x.slice(1),lastEventId:R});if(e.dispatchEvent(b),"open"===$?k(e,e.onopen,b):"message"===$?k(e,e.onmessage,b):"error"===$&&k(e,e.onerror,b),2===I)return}x="",$=""}U=c==="\r".charCodeAt(0)?j:0}else 0===U&&(N=a,U=1),1===U?c===":".charCodeAt(0)&&(L=a+1,U=2):2===U&&(U=3)}}},V=function(t){if(1===I||0===I){I=O,0!==C&&(o(C),C=0),C=n((function(){W()}),d),d=D(Math.min(16*u,2*d)),e.readyState=0;var r=new T("error",{error:t});e.dispatchEvent(r),k(e,e.onerror,r),null!=t&&console.error(t)}},B=function(){I=2,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=2},W=function(){if(C=0,I===O){p=!1,f=0,C=n((function(){W()}),l),I=0,x="",$="",R=h,F="",N=0,L=0,U=0;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===c?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(h)}var i=e.withCredentials,s={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(s[u]=a[u]);try{w=v.open(b,z,H,V,r,i,s)}catch(e){throw B(),e}}else if(p||null==w){var d=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){W()}),d)}else V(new Error("No activity within "+l+" milliseconds. "+(0===I?"No response received.":f+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=B,W()}(this,e,t)}var M=null!=h&&null!=d&&"body"in d.prototype;F.prototype=Object.create(x.prototype),F.prototype.CONNECTING=0,F.prototype.OPEN=1,F.prototype.CLOSED=2,F.prototype.close=function(){this._close()},F.CONNECTING=0,F.OPEN=1,F.CLOSED=2,F.prototype.withCredentials=void 0;var U=c;null==i||null!=c&&"withCredentials"in c.prototype||(U=F),function(){var r=function(e){e.EventSourcePolyfill=F,e.NativeEventSource=c,e.EventSource=U}(t);void 0!==r&&(e.exports=r)}()}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:Ao:globalThis)}(jo,jo.exports)),jo.exports}function Do(){return Oo?To:(Oo=1,To=Po().EventSourcePolyfill)}var ko=Do(),Fo=t({__proto__:null,default:qo(ko)},[ko]);e.BasePatch=jr,e.BaseTransaction=kr,e.ChannelError=_r,e.ClientError=Mt,e.ConnectionFailedError=Er,e.CorsOriginError=Bt,e.DisconnectError=Ir,e.MessageError=xr,e.MessageParseError=Rr,e.ObservablePatch=Ar,e.ObservableSanityClient=Yn,e.ObservableTransaction=Mr,e.Patch=Pr,e.SanityClient=Xn,e.ServerError=Ut,e.Transaction=Fr,e.ViewResourceType=cr,e.connectEventSource=qr,e.createClient=eo,e.default=to,e.formatQueryParseError=zt,e.isQueryParseError=Lt,e.requester=Zn,e.unstable__adapter=b,e.unstable__environment="browser",e.validateApiPerspective=wr,Object.defineProperty(e,"__esModule",{value:!0})}));
|