@sanity/client 7.23.2 → 7.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +26 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +26 -0
- package/dist/index.browser.d.ts +26 -0
- package/dist/index.browser.js +26 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +26 -0
- package/dist/stega.browser.d.ts +26 -0
- package/dist/stega.d.cts +26 -0
- package/dist/stega.d.ts +26 -0
- package/package.json +1 -1
- package/src/data/dataMethods.ts +40 -0
- package/src/types.ts +26 -0
- package/umd/sanityClient.js +26 -1
- 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";const t=!(typeof navigator>"u")&&"ReactNative"===navigator.product,r={timeout:t?6e4:12e4},n=function(e){const n={...r,..."string"==typeof e?{url:e}:e};if(n.timeout=s(n.timeout),n.query){const{url:e,searchParams:r}=function(e){const r=e.indexOf("?");if(-1===r)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,r),s=e.slice(r+1);if(!t)return{url:n,searchParams:new URLSearchParams(s)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const i=new URLSearchParams;for(const e of s.split("&")){const[t,r]=e.split("=");t&&i.append(o(t),o(r||""))}return{url:n,searchParams:i}}(n.url);for(const[t,o]of Object.entries(n.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)r.append(t,e);else r.append(t,o);const s=r.toString();s&&(n.url=`${e}?${s}`)}}return n.method=n.body&&!n.method?"POST":(n.method||"GET").toUpperCase(),n};function o(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(r.timeout):{connect:t,socket:t}}const i=/^https?:\/\//i,a=function(e){if(!i.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const u=["request","response","progress","error","abort"],l=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const r=[],o=l.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[n],validateOptions:[a]});function s(e){const r="object"==typeof e&&e.callSiteStack?e.callSiteStack:void 0,n=r?void 0:new Error,s=u.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)),{}),i=(e=>function(t,r,...n){const o="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...n),!o||s);r++);return s})(o),a=i("processOptions",e);i("validateOptions",a);const c={options:a,channels:s,applyMiddleware:i};let l;const d=s.request.subscribe((e=>{l=t(e,((t,o)=>((e,t,o)=>{let a=e,c=t;if(!a)try{c=i("onResponse",t,o)}catch(e){c=null,a=e}if(a=a&&i("onError",a,o),a){if(a instanceof Error){const e=r?.stack||n?.stack;if("string"==typeof e){const t=e.split("\n").slice(r?1:2);t.length>0&&(a.stack+="\n"+t.join("\n"))}}s.error.publish(a)}else c&&s.response.publish(c)})(t,o,e)))}));s.abort.subscribe((()=>{d(),l&&l.abort()}));const h=i("onReturn",s,c);return h===s&&s.request.publish(c),h}return s.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&o.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 l.forEach((t=>{e[t]&&o[t].push(e[t])})),r.push(e),s},s.clone=()=>d(r,t),e.forEach(s.use),s}var h,p,f=c(function(){if(p)return h;p=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")},t=function(e){return"[object Array]"===Object.prototype.toString.call(e)};return h=function(r){if(!r)return{};for(var n=Object.create(null),o=e(r).split("\n"),s=0;s<o.length;s++){var i=o[s],a=i.indexOf(":"),c=e(i.slice(0,a)).toLowerCase(),u=e(i.slice(a+1));typeof n[c]>"u"?n[c]=u:t(n[c])?n[c].push(u):n[c]=[n[c],u]}return n}}());let y=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#s={};#i;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#n[e]=t}setInit(e,t=!0){this.#s=e,this.#i=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#s,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#i&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}};const g="function"==typeof XMLHttpRequest?"xhr":"fetch",m="xhr"===g?XMLHttpRequest:y,b=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:g,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new m;i instanceof y&&"object"==typeof n.fetch&&i.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,d=!1;if(i.onerror=e=>{b(i instanceof y?e instanceof Error?e:new Error(`Request error while attempting to reach ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.ontimeout=e=>{b(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.onabort=()=>{p(!0),u=!0},i.onreadystatechange=function(){c&&(p(),o.socket=setTimeout((()=>h("ESOCKETTIMEDOUT")),c.socket)),!u&&i&&4===i.readyState&&0!==i.status&&function(){if(!(u||l||d)){if(0===i.status)return void b(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:i.response||(""===i.responseType||"text"===i.responseType?i.responseText:""),url:n.url,method:n.method,headers:f(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}}()},i.open(n.method,n.url,!0),i.withCredentials=!!n.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return n.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:g,request:i,context:e}),i.send(n.body||null),c&&(o.connect=setTimeout((()=>h("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,i&&i.abort()}};function h(t){d=!0,i.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function p(e){(e||u||i&&i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function b(e){if(l)return;p(!0),l=!0,i=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},v=(e=[],t=b)=>d(e,t);var w,C,E,I,R,x={exports:{}};R||(R=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")||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?E:(I=1,E=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,o=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,s=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").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(C)return w;C=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return w=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(s){if(!((s=String(s)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=r?s(c,u,r,"hour"):u>=t?s(c,u,t,"minute"):u>=e?s(c,u,e,"second"):c+" ms"):function(o){var s=Math.abs(o);return s>=n?Math.round(o/n)+"d":s>=r?Math.round(o/r)+"h":s>=t?Math.round(o/t)+"m":s>=e?Math.round(o/e)+"s":o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(x,x.exports));const _=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function q(e){return"[object Object]"===Object.prototype.toString.call(e)}const $=["boolean","string","number"];function S(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||_(t)||-1===$.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===q(r)||!1===r.hasOwnProperty("isPrototypeOf"))}(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function 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 O={};typeof globalThis<"u"?O=globalThis:typeof window<"u"?O=window:typeof global<"u"?O=global:typeof self<"u"&&(O=self);var j=O;function A(e={}){const t=e.implementation||j.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 P=(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 D=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||k,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,c=s.shouldRetry||n,u=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,s)||u>=i)return e;var l;const d=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(d)),a(u)),null}}})({shouldRetry:P,...e});D.shouldRetry=P;var F=function(e,t){return F=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])},F(e,t)};function M(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}F(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function U(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function N(e,t){var r,n,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function L(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function z(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function H(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function V(e){return this instanceof V?(this.v=e,this):new V(e)}function W(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof V?Promise.resolve(e.value.v).then(c,u):l(s[0][2],e)}(o[e](t))}catch(e){l(s[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function B(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 J(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=J((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 Y(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var X=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=L(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(G(c))try{c()}catch(e){o=e instanceof Q?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=L(u),d=l.next();!d.done;d=l.next()){var h=d.value;try{ee(h)}catch(e){o=null!=o?o:[],e instanceof Q?o=H(H([],z(o)),z(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{d&&!d.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)ee(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)&&Y(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&Y(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),K=X.EMPTY;function Z(e){return e instanceof X||e&&"closed"in e&&G(e.remove)&&G(e.add)&&G(e.unsubscribe)}function ee(e){G(e)?e():e.unsubscribe()}var te={Promise:void 0},re=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,H([e,t],z(r)))};function ne(e){re((function(){throw e}))}function oe(){}function se(e){e()}var ie=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Z(t)&&t.add(r)):r.destination=le,r}return M(t,e),t.create=function(e,t,r){return new ce(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}(X),ae=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){ue(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ue(e)}else ue(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ue(e)}},e}(),ce=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=G(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new ae(o),s}return M(t,e),t}(ie);function ue(e){ne(e)}var le={closed:!0,next:oe,error:function(e){throw e},complete:oe},de="function"==typeof Symbol&&Symbol.observable||"@@observable";function he(e){return e}function pe(e){return 0===e.length?he:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var fe=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof ie||function(e){return e&&G(e.next)&&G(e.error)&&G(e.complete)}(n)&&Z(n)?e:new ce(e,t,r);return se((function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=ye(t))((function(t,n){var o=new ce({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 pe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ye(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 ye(e){var t;return null!==(t=null!=e?e:te.Promise)&&void 0!==t?t:Promise}function ge(e){return function(t){if(function(e){return G(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function me(e,t,r,n,o){return new be(e,t,r,n,o)}var be=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return M(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}(ie),ve=J((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),we=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 M(t,e),t.prototype.lift=function(e){var t=new Ce(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new ve},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),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;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,s=r.observers;return n||o?K:(this.currentObservers=null,s.push(e),new X((function(){t.currentObservers=null,Y(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new fe;return e.source=this,e},t.create=function(e,t){return new Ce(e,t)},t}(fe),Ce=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return M(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:K},t}(we),Ee={now:function(){return(Ee.delegate||Date).now()},delegate:void 0},Ie=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Ee);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 M(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,i=r._timestampProvider,a=r._windowTime;n||(o.push(t),!s&&o.push(i.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,s=(o?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!o){for(var i=r.now(),a=0,c=1;c<n.length&&n[c]<=i;c+=2)a=c;a&&n.splice(0,a+1)}},t}(we),Re=function(e){function t(t,r){return e.call(this)||this}return M(t,e),t.prototype.schedule=function(e,t){return this},t}(X),xe=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,H([e,t],z(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 M(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),xe(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,Y(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Re),$e=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Ee.now,e}(),Se=new(function(e){function t(t,r){void 0===r&&(r=$e.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return M(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}($e))(qe),Te=new fe((function(e){return e.complete()}));function Oe(e){return e[e.length-1]}function je(e){return(t=Oe(e))&&G(t.schedule)?e.pop():void 0;var t}var Ae=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function Pe(e){return G(null==e?void 0:e.then)}function ke(e){return G(e[de])}function De(e){return Symbol.asyncIterator&&G(null==e?void 0:e[Symbol.asyncIterator])}function Fe(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 Me="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ue(e){return G(null==e?void 0:e[Me])}function Ne(e){return W(this,arguments,(function(){var t,r,n;return N(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,V(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,V(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,V(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 ze(e){if(e instanceof fe)return e;if(null!=e){if(ke(e))return o=e,new fe((function(e){var t=o[de]();if(G(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Ae(e))return n=e,new fe((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(Pe(e))return r=e,new fe((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,ne)}));if(De(e))return He(e);if(Ue(e))return t=e,new fe((function(e){var r,n;try{for(var o=L(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Le(e))return He(Ne(e))}var t,r,n,o;throw Fe(e)}function He(e){return new fe((function(t){(function(e,t){var r,n,o,s;return U(this,void 0,void 0,(function(){var i,a;return N(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=B(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Ve(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),ge((function(r,n){r.subscribe(me(n,(function(r){return Ve(n,e,(function(){return n.next(r)}),t)}),(function(){return Ve(n,e,(function(){return n.complete()}),t)}),(function(r){return Ve(n,e,(function(){return n.error(r)}),t)})))}))}function Be(e,t){return void 0===t&&(t=0),ge((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function Ge(e,t){if(!e)throw new Error("Iterable cannot be null");return new fe((function(r){Ve(r,t,(function(){var n=e[Symbol.asyncIterator]();Ve(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function Je(e,t){if(null!=e){if(ke(e))return function(e,t){return ze(e).pipe(Be(t),We(t))}(e,t);if(Ae(e))return function(e,t){return new fe((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(Pe(e))return function(e,t){return ze(e).pipe(Be(t),We(t))}(e,t);if(De(e))return Ge(e,t);if(Ue(e))return function(e,t){return new fe((function(r){var n;return Ve(r,t,(function(){n=e[Me](),Ve(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(Ne(e),t)}(e,t)}throw Fe(e)}function Qe(e,t){return t?Je(e,t):ze(e)}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qe(e,je(e))}function Xe(e,t){var r=G(e)?e:function(){return e};return new fe((function(e){return e.error(r())}))}var Ke=J((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ze(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 Ke)}})}))}function et(e,t){return new Promise((function(t,r){var n=new ce({next:function(e){t(e),n.unsubscribe()},error:r,complete:function(){r(new Ke)}});e.subscribe(n)}))}function tt(e,t){return ge((function(r,n){var o=0;r.subscribe(me(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,H([],z(t))):e(t)}(e,t)}))}function ot(e,t,r){t()}function st(e,t,r){return void 0===r&&(r=1/0),G(t)?st((function(r,n){return tt((function(e,o){return t(r,e,n,o)}))(ze(e(r,n)))}),r):("number"==typeof t&&(r=t),ge((function(t,n){return function(e,t,r,n,o,s,i){var a=[],c=0,u=0,l=!1,d=function(){!l||a.length||c||t.complete()},h=function(e){c++;var o=!1;ze(r(e,u++)).subscribe(me(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{for(c--;a.length&&c<n;)e=void 0,e=a.shift(),i||h(e);d()}catch(e){t.error(e)}var e})))};return e.subscribe(me(t,(function(e){return c<n?h(e):a.push(e)}),(function(){l=!0,d()}))),function(){}}(t,n,e,r)})))}function it(e){return void 0===e&&(e=1/0),st(he,e)}function at(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return it(1)(Qe(e,je(e)))}function ct(e){return new fe((function(t){ze(e()).subscribe(t)}))}function ut(e,t,r){return void 0===r&&(r=Se),new fe((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?+e-r.now():e;o<0&&(o=0);var s=0;return r.schedule((function(){t.closed||(t.next(s++),t.complete())}),o)}))}function lt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=je(e),n=function(e,t){return"number"==typeof Oe(e)?e.pop():t}(e,1/0),o=e;return o.length?1===o.length?ze(o[0]):it(n)(Qe(o,r)):Te}var dt=Array.isArray;function ht(e,t){return ge((function(r,n){var o=0;r.subscribe(me(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function pt(e){return ge((function(t,r){var n,o=null,s=!1;o=t.subscribe(me(r,void 0,void 0,(function(i){n=ze(e(i,pt(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):s=!0}))),s&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function ft(e,t){return ge(function(e,t,r){return function(n,o){var s=r,i=t,a=0;n.subscribe(me(o,(function(t){var r=a++;i=s?e(i,t,r):(s=!0,t)}),(function(){s&&o.next(i),o.complete()})))}}(e,t,arguments.length>=2))}function yt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return G(Oe(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pe(e)}(yt.apply(void 0,H([],z(e))),nt(r)):ge((function(t,r){var n,o,s;(n=H([t],z(function(e){return 1===e.length&&dt(e[0])?e[0]:e}(e))),void 0===s&&(s=he),function(e){ot(0,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,c=function(t){ot(0,(function(){var c=Qe(n[t],o),u=!1;c.subscribe(me(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function gt(e){return ge((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}function mt(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new we}:t,n=e.resetOnError,o=void 0===n||n,s=e.resetOnComplete,i=void 0===s||s,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,s,a=0,u=!1,l=!1,d=function(){null==n||n.unsubscribe(),n=void 0},h=function(){d(),t=s=void 0,u=l=!1},p=function(){var e=t;h(),null==e||e.unsubscribe()};return ge((function(e,f){a++,l||u||d();var y=s=null!=s?s:r();f.add((function(){0!==--a||l||u||(n=bt(p,c))})),y.subscribe(f),!t&&a>0&&(t=new ce({next:function(e){return y.next(e)},error:function(e){l=!0,d(),n=bt(h,o,e),y.error(e)},complete:function(){u=!0,d(),n=bt(h,i),y.complete()}}),ze(e).subscribe(t))}))(e)}}function bt(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 ce({next:function(){o.unsubscribe(),e()}});return ze(t.apply(void 0,H([],z(r)))).subscribe(o)}}else e()}function vt(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=8203,Et=8204,It=8205,Rt=65279,xt={0:String.fromCodePoint(Ct),1:String.fromCodePoint(Et),2:String.fromCodePoint(It),3:String.fromCodePoint(Rt)},_t=new Array(4).fill(String.fromCodePoint(Ct)).join("");function qt(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),r=(new TextEncoder).encode(t),n="";for(let e=0;e<r.length;e++){let t=r[e];n+=xt[t>>6&3]+xt[t>>4&3]+xt[t>>2&3]+xt[3&t]}return _t+n}(t)}`}Object.fromEntries(Object.entries(xt).map((e=>[e[1],+e[0]]))),Object.fromEntries(Object.entries(wt).map((e=>e.reverse())));var $t=`${Object.values(wt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,St=new RegExp(`[${$t}]{4,}`,"gu");function Tt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(St,""),encoded:(null==(t=e.match(St))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}const Ot=".",jt=`drafts${Ot}`,At=`versions${Ot}`;function Pt(e){return e.startsWith(jt)}function kt(e){return e.startsWith(At)}function Dt(e){if(kt(e)){const t=Ut(e);return jt+t}return Pt(e)?e:jt+e}function Ft(e,t){if("drafts"===t||"published"===t)throw new Error('Version can not be "published" or "drafts"');return`${At}${t}${Ot}${Ut(e)}`}function Mt(e){if(!kt(e))return;const[t,r]=e.split(Ot);return r}function Ut(e){return kt(e)?e.split(Ot).slice(2).join(Ot):Pt(e)?e.slice(jt.length):e}let Nt=e=>crypto.getRandomValues(new Uint8Array(e));const Lt=/\r\n|[\n\r\u2028\u2029]/;function zt(e,t,r){const n=e.split(Lt),o={start:Ht(t.start,n),end:t.end?Ht(t.end,n):void 0},{start:s,end:i,markerLines:a}=function(e,t){const r={...e.start},n={...r,...e.end},o=2,s=3,i=r.line??-1,a=r.column??0,c=n.line,u=n.column;let l=Math.max(i-(o+1),0),d=Math.min(t.length,c+s);-1===i&&(l=0),-1===c&&(d=t.length);const h=c-i,p={};if(h)for(let e=0;e<=h;e++){const r=e+i;if(a)if(0===e){const e=t[r-1].length;p[r]=[a,e-a+1]}else if(e===h)p[r]=[0,u];else{const n=t[r-e].length;p[r]=[0,n]}else p[r]=!0}else p[i]=a===u?!a||[a,0]:[a,u-a];return{start:l,end:d,markerLines:p}}(o,n),c=`${i}`.length;return e.split(Lt,i).slice(s,i).map(((e,t)=>{const n=s+1+t,o=` ${` ${n}`.slice(-c)} |`,i=a[n],u=!a[n+1];if(!i)return` ${o}${e.length>0?` ${e}`:""}`;let l="";if(Array.isArray(i)){const t=e.slice(0,Math.max(i[0]-1,0)).replace(/[^\t]/g," "),n=i[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 Ht(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 Vt extends Error{response;statusCode=400;responseBody;traceId;details;constructor(e,t){const r=Bt(e,t);super(r.message),Object.assign(this,r)}}class Wt extends Error{response;statusCode=500;responseBody;traceId;details;constructor(e){const t=Bt(e);super(t.message),Object.assign(this,t)}}function Bt(e,t){const r=e.body,n={response:e,statusCode:e.statusCode,responseBody:Xt(r,e),traceId:Yt(e),message:"",details:void 0};if(!vt(r))return n.message=`${Qt(e,r)}${Kt(n.traceId)}`,n;const o=r.error;if("string"==typeof o&&"string"==typeof r.message)return n.message=`${o} - ${r.message}${Kt(n.traceId)}`,n;if("object"!=typeof o||null===o)return"string"==typeof o?n.message=`${o}${Kt(n.traceId)}`:"string"==typeof r.message?n.message=`${r.message}${Kt(n.traceId)}`:n.message=`${Qt(e,r)}${Kt(n.traceId)}`,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 s=t.length?`:\n- ${t.join("\n- ")}`:"";return e.length>5&&(s+=`\n...and ${e.length-5} more`),n.message=`${o.description}${Kt(n.traceId)}${s}`,n.details=r.error,n}if(Gt(o)){const e=t?.options?.query?.tag;return n.message=Jt(o,e,n.traceId),n.details=r.error,n}return"description"in o&&"string"==typeof o.description?(n.message=`${o.description}${Kt(n.traceId)}`,n.details=o,n):(n.message=`${Qt(e,r)}${Kt(n.traceId)}`,n)}function Gt(e){return vt(e)&&"queryParseError"===e.type&&"string"==typeof e.query&&"number"==typeof e.start&&"number"==typeof e.end}function Jt(e,t,r){const{query:n,start:o,end:s,description:i}=e,a=r?`\n(traceId: ${r})`:"";if(!n||typeof o>"u")return`GROQ query parse error: ${i}${a}`;const c=t?`\n\nTag: ${t}`:"";return`GROQ query parse error:\n${zt(n,{start:o,end:s},i)}${c}${a}`}function Qt(e,t){const r="string"==typeof t?` (${o=t,s=100,o.length>s?`${o.slice(0,s)}…`:o})`:"",n=e.statusMessage?` ${e.statusMessage}`:"";var o,s;return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${n}${r}`}function Yt(e){const t=e?.headers?.traceparent;if(t)return t.split("-")[1]}function Xt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}function Kt(e){return e?` (traceId: ${e})`:""}class Zt extends Error{projectId;addOriginUrl;constructor({projectId:e,credentials:t}={}){if(super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e,e&&typeof location<"u"){const r=new URL(`https://sanity.io/manage/project/${e}/api`),{origin:n}=location;r.searchParams.set("cors","add"),r.searchParams.set("origin",n),t&&r.searchParams.set("credentials",""),this.addOriginUrl=r,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${r}`}else this.message=e?`The current origin is not allowed to connect to the Live Content API. Change your configuration here: https://sanity.io/manage/project/${e}/api`:"The current origin is not allowed to connect to the Live Content API."}}const er={onResponse:(e,t)=>{if(e.statusCode>=500)throw new Wt(e);if(e.statusCode>=400)throw new Vt(e,t);return e}};function tr(e={}){const t={},r=t=>void 0!==e.ignoreWarnings&&(Array.isArray(e.ignoreWarnings)?e.ignoreWarnings:[e.ignoreWarnings]).some((e=>"string"==typeof e?t.includes(e):e instanceof RegExp&&e.test(t)));return{onResponse:e=>{const n=e.headers["x-sanity-warning"],o=Array.isArray(n)?n:[n];for(const e of o)!e||t[e]||r(e)||(t[e]=!0,console.warn(e));return e}}}function rr(e,t={}){return v([D({shouldRetry:nr}),...e,tr(t),S(),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"))}},er,A({implementation:fe})])}function nr(e,t,r){if(0===r.maxRetries)return!1;const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||D.shouldRetry(e,t,r)}function or(e){return"https://www.sanity.io/help/"+e}const sr=["image","file"],ir=["before","after","replace"],ar=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")},cr=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},ur=(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`)},lr=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);ur(e,t._id)},dr=(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)},hr=e=>{if(e.dataset)return e.dataset;const t=e.resource;if(t&&"dataset"===t.type){const e=t.id.split(".");if(2!==e.length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return e[1]}throw new Error("`dataset` must be provided to perform queries")},pr=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},fr=e=>{const t=e.resource;if(!t)throw new Error("`resource` must be provided to perform resource queries");const{type:r,id:n}=t;switch(r){case"dataset":if(2!==n.split(".").length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return;case"dashboard":case"media-library":case"canvas":return;default:throw new Error(`Unsupported resource type: ${r.toString()}`)}},yr=(e,t)=>{if(t.resource)throw new Error(`\`${e}\` does not support resource-based operations`)};const gr=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),mr=gr(["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"]),br=gr(["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."]),vr=gr(["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."]),wr=gr(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),Cr=gr(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${or("js-client-browser-token")} for more information and how to hide this warning.`]),Er=gr(["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`."]),Ir=gr(["Using the Sanity client without specifying an API version is deprecated.",`See ${or("js-client-api-version")}`]),Rr=gr(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),xr=gr(["You have called `createVersion()` with a defined `document`. The recommended approach is to provide a `baseId` and `releaseId` instead."]),_r=gr(["The `~experimental_resource` configuration property has been renamed to `resource`.","Please update your client configuration to use `resource` instead. Support for `~experimental_resource` will be removed in a future version."]),qr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},$r=["localhost","127.0.0.1","0.0.0.0"];function Sr(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 Tr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||qr.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Ir();const n={...qr,...r};n["~experimental_resource"]&&!n.resource&&(_r(),n.resource=n["~experimental_resource"]);const o=n.resource,s=n.useProjectHostname&&!o;if(typeof Promise>"u"){const e=or("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${e}`)}if(s&&!n.projectId)throw new Error("Configuration must contain `projectId`");if(o&&fr(n),typeof n.perspective<"u"&&Sr(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,a=i&&(e=>-1!==$r.indexOf(e))(window.location.hostname),c=!!n.token;n.withCredentials&&c&&(Er(),n.withCredentials=!1),i&&a&&c&&!0!==n.ignoreBrowserTokenWarning?Cr():typeof n.useCdn>"u"&&br(),s&&(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&&ar(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?pr(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===qr.apiHost,!0===n.useCdn&&n.withCredentials&&mr(),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 u=n.apiHost.split("://",2),l=u[0],d=u[1],h=n.isDefaultApi?"apicdn.sanity.io":d;return s?(n.url=`${l}://${n.projectId}.${d}/v${n.apiVersion}`,n.cdnUrl=`${l}://${n.projectId}.${h}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n};class Or extends Error{name="ConnectionFailedError";status;constructor(e,t={}){const{status:r,...n}=t;super(e,n),this.status=r}}class jr 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 Pr extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class kr extends Error{name="MessageParseError"}const Dr=["channelError","disconnect"];function Fr(e,t){return ct((()=>{const t=e();return(r=t)&&(r instanceof fe||G(r.lift)&&G(r.subscribe))?t:Ye(t);var r})).pipe(st((e=>function(e,t){return new fe((r=>{const n=t.includes("open"),o=t.includes("reconnect");function s(t){if("data"in t){const[e,n]=Mr(t);return void r.error(e?new kr("Unable to parse EventSource error message",{cause:n}):new Pr((n?.data).message,n))}const n=t.status,s="number"==typeof n?n:void 0;void 0===s?e.readyState===e.CLOSED?r.error(new Or("EventSource connection failed")):o&&r.next({type:"reconnect"}):r.error(new Or("EventSource connection failed",{status:s}))}function i(){r.next({type:"open"})}function a(t){const[n,o]=Mr(t);if(n)r.error(new kr("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 jr(`Server disconnected client: ${o.data?.reason||"unknown error"}`));else{const t=new URL(e.url).searchParams.get("tag");r.error(new Ar(function(e,t){const r=e.error;return r?Gt(r)?Jt(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",s),n&&e.addEventListener("open",i);const c=[...new Set([...Dr,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return c.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",s),n&&e.removeEventListener("open",i),c.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function Mr(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,...Ur(t)?{}:{data:t}}]}catch(e){return[e,null]}}function Ur(e){for(const t in e)return!1;return!0}function Nr(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 Lr{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 cr("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===ir.indexOf(e)){const e=ir.map((e=>`"${e}"`)).join(", ");throw new Error(`${n} takes an "at"-argument which is one of: ${e}`)}if("string"!=typeof t)throw new Error(`${n} takes a "selector"-argument which must be a string`);if(!Array.isArray(r))throw new Error(`${n} takes an "items"-argument which must be an array`)})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after",`${e}[-1]`,t)}prepend(e,t){return this.insert("before",`${e}[0]`,t)}splice(e,t,r,n){const o=t<0?t-1:t,s=typeof r>"u"||-1===r?-1:Math.max(0,t+r),i=`${e}[${o}:${o<0&&s>=0?"":s}]`;return this.insert("replace",i,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...Nr(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return cr(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 zr extends Lr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new zr(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 Hr extends Lr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new Hr(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 Vr={returnDocuments:!1};class Wr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return cr("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return cr(t,e),lr(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return cr(t,e),lr(t,e),this._add({[t]:e})}delete(e){return ur("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 Br extends Wr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Br([...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},Vr,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 Hr)return this._add({patch:e.serialize()});if(r){const r=t(new Hr(e,{},this.#a));if(!(r instanceof Hr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new Hr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class Gr extends Wr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Gr([...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},Vr,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof zr)return this._add({patch:e.serialize()});if(r){const r=t(new zr(e,{},this.#a));if(!(r instanceof zr))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 Jr=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:s,returnQuery:i,...a}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))void 0!==r&&n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(a))t&&n.append(e,`${t}`);return!1===i&&n.append("returnQuery","false"),!1===s&&n.append("includeMutations","false"),`?${n}`},Qr=(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},Yr=e=>"response"===e.type,Xr=e=>e.body;function Kr(e,t,r,n,o={},s={}){const i="stega"in s?{...r||{},..."boolean"==typeof s.stega?{enabled:s.stega}:s.stega||{}}:r,a=i.enabled?Tt(o):o,c=!1===s.filterResponse?e=>e:e=>e.result,{cache:u,next:l,...d}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},h=fn(e,t,"query",{query:n,params:a},typeof u<"u"||typeof l<"u"?{...d,fetch:{cache:u,next:l}}:d);return i.enabled?h.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yt.apply(void 0,H([],z(e)))}(Qe(Promise.resolve().then((function(){return Ho})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),tt((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return c({...e,result:r})}))):h.pipe(tt(c))}function Zr(e,t,r,n={}){return vn(e,t,{uri:Cn(e,"doc",(()=>{if(!n.releaseId)return r;const e=Mt(r);if(!e){if(Pt(r))throw new Error(`The document ID (\`${r}\`) is a draft, but \`options.releaseId\` is set as \`${n.releaseId}\``);return Ft(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,query:void 0!==n.includeAllVersions?{includeAllVersions:n.includeAllVersions}:void 0}).pipe(ht(Yr),tt((e=>{const t=e.body.documents;return t?n.includeAllVersions?t:t[0]:n.includeAllVersions?[]:void 0})))}function en(e,t,r,n={}){return vn(e,t,{uri:Cn(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(ht(Yr),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 tn(e,t,r,n={}){if(0===r.length)return Ye(new Set);const o=[];for(let e=0;e<r.length;e+=100)o.push(r.slice(e,e+100));return Qe(o).pipe((s=r=>vn(e,t,{uri:Cn(e,"doc",r.map(encodeURIComponent).join(",")),tag:n.tag,signal:n.signal,query:{excludeContent:!0}}).pipe(ht(Yr),tt((e=>{const t=new Set;for(const r of e.body.omitted||[])"existence"===r.reason&&t.add(r.id);return new Set(r.filter((e=>!t.has(e))))}))),G(i)?st(s,i,1):st(s,1)),ft(((e,t)=>{for(const r of t)e.add(r);return e}),new Set));var s,i}function rn(e,t,r,n={}){return fn(e,t,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:r}},n)}function nn(e,t,r,n){return lr("createIfNotExists",r),yn(e,t,r,"createIfNotExists",n)}function on(e,t,r,n){return lr("createOrReplace",r),yn(e,t,r,"createOrReplace",n)}function sn(e,t,r,n,o){return lr("createVersion",r),dr("createVersion",r),xr(),pn(e,t,{actionType:"sanity.action.document.version.create",publishedId:n,document:r},o)}function an(e,t,r,n,o,s,i){if(!n)throw new Error("`createVersion()` requires `baseId` when no `document` is provided");if(!r)throw new Error("`createVersion()` requires `publishedId` when `baseId` is provided");ur("createVersion",n),ur("createVersion",r);return pn(e,t,{actionType:"sanity.action.document.version.create",publishedId:r,baseId:n,versionId:o?Ft(r,o):Dt(r),ifBaseRevisionId:s},i)}function cn(e,t,r,n){return fn(e,t,"mutate",{mutations:[{delete:Nr(r)}]},n)}function un(e,t,r,n=!1,o){return pn(e,t,{actionType:"sanity.action.document.version.discard",versionId:r,purge:n},o)}function ln(e,t,r,n){return lr("replaceVersion",r),dr("replaceVersion",r),pn(e,t,{actionType:"sanity.action.document.version.replace",document:r},n)}function dn(e,t,r,n,o){return pn(e,t,{actionType:"sanity.action.document.version.unpublish",versionId:r,publishedId:n},o)}function hn(e,t,r,n){let o;o=r instanceof Hr||r instanceof zr?{patch:r.serialize()}:r instanceof Br||r instanceof Gr?r.serialize():r;return fn(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function pn(e,t,r,n){return fn(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 fn(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,c=s||i?"":Jr(n),u=!s&&!i&&c.length<11264,l=u?c:"",d=o.returnFirst,{timeout:h,token:p,tag:f,headers:y,returnQuery:g,lastLiveEventId:m,cacheMode:b}=o;return vn(e,t,{method:u?"GET":"POST",uri:Cn(e,r,l),json:!0,body:u?void 0:n,query:s&&Qr(o),timeout:h,headers:y,token:p,tag:f,returnQuery:g,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(m)?m[0]:m,cacheMode:b,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(ht(Yr),tt(Xr),tt((e=>{if(!s)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 yn(e,t,r,n,o={}){return fn(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}const gn=e=>{const t=e.config();return void 0!==t.dataset&&void 0!==t.projectId||void 0!==t.resource},mn=(e,t)=>gn(e)&&t.startsWith(Cn(e,"query")),bn=(e,t)=>t.startsWith("/data/")||mn(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"mutate")))(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"doc","")))(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"listen")))(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"history","")))(e,t);function vn(e,t,r){const n=new Error,o=r.url||r.uri,s=e.config(),i=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&bn(e,o):r.canUseCdn;let a=(r.useCdn??s.useCdn)&&i;const c=r.tag&&s.requestTagPrefix?[s.requestTagPrefix,r.tag].join("."):r.tag||s.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:pr(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&mn(e,o)){const e=r.resultSourceMap??s.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||s.perspective;typeof t<"u"&&("previewDrafts"===t&&wr(),Sr(t),r.query={perspective:Array.isArray(t)?t.join(","):t,...r.query},(Array.isArray(t)&&t.length>0||"previewDrafts"===t||"drafts"===t)&&a&&(a=!1,vr())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query}),a&&"noStale"==r.cacheMode&&(r.query={cacheMode:"noStale",...r.query})}const u=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),s=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof s>"u"?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(s,Object.assign({},r,{url:En(e,o,a),callSiteStack:n})),l=new fe((e=>t(u,s.requester).subscribe(e)));return r.signal?l.pipe((d=r.signal,e=>new fe((t=>{const r=()=>t.error(function(e){if(In)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}(d));if(d&&d.aborted)return void r();const n=e.subscribe(t);return d.addEventListener("abort",r),()=>{d.removeEventListener("abort",r),n.unsubscribe()}})))):l;var d}function wn(e,t,r){return vn(e,t,r).pipe(ht((e=>"response"===e.type)),tt((e=>e.body)))}function Cn(e,t,r){const n=e.config();if(n.resource){fr(n);return`${Rn(n)}/${void 0!==r?`${t}/${r}`:t}`.replace(/\/($|\?)/,"$1")}const o=`/${t}/${hr(n)}`;return`/data${void 0!==r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function En(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const In=!!globalThis.DOMException;const Rn=e=>{const t=e.resource;if(!t)throw new Error("`resource` must be provided to perform resource queries");const{type:r,id:n}=t;switch(r){case"dataset":{const e=n.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/${n}`;case"media-library":return`/media-libraries/${n}`;case"dashboard":return`/dashboards/${n}`;default:throw new Error(`Unsupported resource type: ${r.toString()}`)}};function xn(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/generate/${n}`,body:r})}function _n(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/transform/${n}`,body:r})}function qn(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/translate/${n}`,body:r})}class $n{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return xn(this.#a,this.#c,e)}transform(e){return _n(this.#a,this.#c,e)}translate(e){return qn(this.#a,this.#c,e)}}class Sn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return Ze(xn(this.#a,this.#c,e))}transform(e){return Ze(_n(this.#a,this.#c,e))}translate(e){return Ze(qn(this.#a,this.#c,e))}prompt(e){return Ze(function(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/prompt/${n}`,body:r})}(this.#a,this.#c,e))}patch(e){return Ze(function(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/patch/${n}`,body:r})}(this.#a,this.#c,e))}}class Tn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return jn(this.#a,this.#c,e,t,r)}}class On{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return Ze(jn(this.#a,this.#c,e,t,r).pipe(ht((e=>"response"===e.type)),tt((e=>e.body.document))))}}function jn(e,t,r,n,o={}){(e=>{if(-1===sr.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${sr.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=e.config(),a=function(e,t){return typeof File>"u"||!(t instanceof File)?e:Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:c,label:u,title:l,description:d,creditLine:h,filename:p,source:f}=a,y="media-library"===i.resource?.type,g=y?{title:l,filename:p}:{label:u,title:l,description:d,filename:p,meta:s,creditLine:h};return f&&!y&&(g.sourceId=f.id,g.sourceName=f.name,g.sourceUrl=f.url),vn(e,t,{tag:c,method:"POST",timeout:a.timeout||0,uri:An(i,r),headers:a.contentType?{"Content-Type":a.contentType}:{},query:g,body:n})}function An(e,t){const r="image"===t?"images":"files",n=e.resource;if(n){const{type:e,id:t}=n;switch(e){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/${t}/assets/${r}`;case"media-library":return`/media-libraries/${t}/upload`;case"dashboard":return`/dashboards/${t}/assets/${r}`;default:throw new Error(`Unsupported resource type: ${e.toString()}`)}}return`assets/${r}/${hr(e)}`}const Pn=ct((()=>Promise.resolve().then((function(){return Zo})))).pipe(tt((({default:e})=>e)),(Mn=1,mt({connector:function(){return new Ie(Mn,Dn,Fn)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1}))),kn=new Set([408,429]);var Dn,Fn,Mn;function Un(){return function(e){return e.pipe(pt(((e,t)=>e instanceof Or&&("number"!=typeof e.status||e.status<400||e.status>=500||kn.has(e.status))?at(Ye({type:"reconnect"}),ut(1e3).pipe(st((()=>t)))):Xe((()=>e)))))}}const Nn=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","enableResume","tag"],Ln={includeResult:!0};function zn(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i,headers:a}=this.config(),c=r.tag&&i?[i,r.tag].join("."):r.tag,u={...(h=r,p=Ln,Object.keys(p).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?p[t]:h[t],e)),{})),tag:c},l=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,Nn),d=`${n}${Cn(this,"listen",Jr({query:e,params:t,options:{tag:c,...l}}))}`;var h,p;if(d.length>14800)return Xe((()=>new Error("Query too large for listener")));const f=u.events?u.events:["mutation"],y={};return s&&(y.withCredentials=!0),(o||a)&&(y.headers={},o&&(y.headers.Authorization=`Bearer ${o}`),a&&Object.assign(y.headers,a)),Fr((()=>(typeof EventSource>"u"||y.headers?Pn:Ye(EventSource)).pipe(tt((e=>new e(d,y))))),f).pipe(Un(),ht((e=>f.includes(e.type))),tt((e=>({type:e.type,..."data"in e?e.data:{}}))))}function Hn(e,t){return function(e){return t=>{let r,n=!1;const{predicate:o,...s}=e,i=t.pipe((l=G(a=t=>{e.predicate(t)&&(n=!0,r=t)})||c||u?{next:a,error:c,complete:u}:a)?ge((function(e,t){var r;null===(r=l.subscribe)||void 0===r||r.call(l);var n=!0;e.subscribe(me(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)})))})):he,gt((()=>{n=!1,r=void 0})),mt(s));var a,c,u,l;return lt(i,new fe((e=>{n&&e.next(r),e.complete()})))}}("function"==typeof e?{predicate:e,...t}:e)}const Vn="2021-03-25";class Wn{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t,waitFor:r}={}){const{projectId:n,apiVersion:o,token:s,withCredentials:i,requestTagPrefix:a,headers:c}=this.#a.config(),u=o.replace(/^v/,"");if("X"!==u&&u<Vn)throw new Error(`The live events API requires API version ${Vn} or later. The current API version is ${u}. Please update your API version to use this feature.`);if(e&&!s&&!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 l=Cn(this.#a,"live/events"),d=new URL(this.#a.getUrl(l,!1)),h=t&&a?[a,t].join("."):t;h&&d.searchParams.set("tag",h),e&&d.searchParams.set("includeDrafts","true"),r&&d.searchParams.set("waitFor",r);const p={};e&&i&&(p.withCredentials=!0),(e&&s||c)&&(p.headers={},e&&s&&(p.headers.Authorization=`Bearer ${s}`),c&&Object.assign(p.headers,c));const f=`${d.href}::${JSON.stringify(p)}`,y=Bn.get(f);if(y)return y;const g=Fr((()=>(typeof EventSource>"u"||p.headers?Pn:Ye(EventSource)).pipe(tt((e=>new e(d.href,p))))),["message","restart","welcome","reconnect","goaway"]),m=function(e,t,r){return new fe((n=>{const o=new AbortController,{signal:s}=o;return fetch(e,{method:"GET",mode:"cors",credentials:"omit",signal:s}).then((e=>{if(!s.aborted&&e.ok)return e.json()})).then((e=>{if(!s.aborted){if(r&&!1===e?.result?.withCredentials)return void n.error(new Zt({projectId:t,credentials:!0}));if(!1===e?.result?.allowed)return void n.error(new Zt({projectId:t,credentials:r}));n.next(),n.complete()}})).catch((()=>{s.aborted||n.closed||(n.next(),n.complete())})),()=>o.abort()}))}(new URL(this.#a.getUrl("/check/cors",!1)),n,!0===p.withCredentials),b=g.pipe(Un(),st((e=>"reconnect"===e.type?m.pipe(st((()=>Ye(e)))):Ye(e))),pt((e=>e instanceof Zt?Xe((()=>e)):m.pipe(st((()=>{throw e}))))),tt((e=>{if("message"===e.type){const{data:t,...r}=e;return{...r,tags:t.tags}}return e}))).pipe(gt((()=>Bn.delete(f))),Hn({predicate:e=>"welcome"===e.type}));return Bn.set(f,b),b}}const Bn=new Map;class Gn{#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(){yr("dataset",this.#a.config());const e=this.#a.config(),t=e.projectId;let r="/datasets";return!1===e.useProjectHostname&&(r=`/projects/${t}/datasets`),wn(this.#a,this.#c,{uri:r,tag:null})}getEmbeddingsSettings(e){return yr("dataset",this.#a.config()),ar(e),wn(this.#a,this.#c,{uri:Qn(this.#a,e),tag:null})}editEmbeddingsSettings(e,t){return yr("dataset",this.#a.config()),ar(e),wn(this.#a,this.#c,{method:"PUT",uri:Qn(this.#a,e),body:t,tag:null})}}class Jn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return yr("dataset",this.#a.config()),Ze(Yn(this.#a,this.#c,"PUT",e,t))}edit(e,t){return yr("dataset",this.#a.config()),Ze(Yn(this.#a,this.#c,"PATCH",e,t))}delete(e){return yr("dataset",this.#a.config()),Ze(Yn(this.#a,this.#c,"DELETE",e))}list(){yr("dataset",this.#a.config());const e=this.#a.config(),t=e.projectId;let r="/datasets";return!1===e.useProjectHostname&&(r=`/projects/${t}/datasets`),Ze(wn(this.#a,this.#c,{uri:r,tag:null}))}getEmbeddingsSettings(e){return yr("dataset",this.#a.config()),ar(e),Ze(wn(this.#a,this.#c,{uri:Qn(this.#a,e),tag:null}))}editEmbeddingsSettings(e,t){return yr("dataset",this.#a.config()),ar(e),Ze(wn(this.#a,this.#c,{method:"PUT",uri:Qn(this.#a,e),body:t,tag:null}))}}function Qn(e,t){const r=e.config();return!1===r.useProjectHostname?`/projects/${r.projectId}/datasets/${t}/settings/embeddings`:`/datasets/${t}/settings/embeddings`}function Yn(e,t,r,n,o){return yr("dataset",e.config()),ar(n),wn(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class Xn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getPlaybackInfo(e,t={}){const r=this.#a.config(),n=(r.resource||r["~experimental_resource"])?.id,{instanceId:o,libraryId:s}=function(e){const t=function(e){return"object"==typeof e&&"_ref"in e}(e)?e._ref:e,r=Zn.exec(t);if(r){const[,e,t]=r;return{libraryId:e,instanceId:t}}if("string"==typeof e&&e.startsWith("video-"))return{instanceId:e};throw new Error(`Invalid video asset instance identifier "${t}": must be a valid video instance id or a Global Dataset Reference (GDR) to the video asset in the Media Library`)}(e),i=s||n;if(!i)throw new Error("Could not determine Media Library ID - you need to provide a valid Media Library ID in the client config or a Media Library GDR");const a=function(e,t){return`/media-libraries/${t}/video/${e}/playback-info`}(o,i),c=function(e){const t={};if(e.transformations){const{thumbnail:r,animated:n,storyboard:o}=e.transformations;r&&(r.width&&(t.thumbnailWidth=r.width),r.height&&(t.thumbnailHeight=r.height),void 0!==r.time&&(t.thumbnailTime=r.time),r.fit&&(t.thumbnailFit=r.fit),r.format&&(t.thumbnailFormat=r.format)),n&&(n.width&&(t.animatedWidth=n.width),n.height&&(t.animatedHeight=n.height),void 0!==n.start&&(t.animatedStart=n.start),void 0!==n.end&&(t.animatedEnd=n.end),n.fps&&(t.animatedFps=n.fps),n.format&&(t.animatedFormat=n.format)),o&&o.format&&(t.storyboardFormat=o.format)}return e.expiration&&(t.expiration=e.expiration),t}(t);return wn(this.#a,this.#c,{method:"GET",uri:a,query:c})}}class Kn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getPlaybackInfo(e,t={}){return Ze(new Xn(this.#a.observable,this.#c).getPlaybackInfo(e,t))}}const Zn=/^media-library:(ml[^:]+):([^:]+)$/;class eo{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){const t={};return!1===e?.includeMembers&&(t.includeMembers="false"),!1===e?.includeFeatures&&(t.includeFeatures="false"),e?.organizationId&&(t.organizationId=e.organizationId),e?.onlyExplicitMembership&&(t.onlyExplicitMembership="true"),wn(this.#a,this.#c,{uri:"/projects",query:t})}getById(e){return wn(this.#a,this.#c,{uri:`/projects/${e}`})}}class to{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){const t={};return!1===e?.includeMembers&&(t.includeMembers="false"),!1===e?.includeFeatures&&(t.includeFeatures="false"),e?.organizationId&&(t.organizationId=e.organizationId),e?.onlyExplicitMembership&&(t.onlyExplicitMembership="true"),Ze(wn(this.#a,this.#c,{uri:"/projects",query:t}))}getById(e){return Ze(wn(this.#a,this.#c,{uri:`/projects/${e}`}))}}const ro=((e,t=21)=>((e,t,r)=>{let n=(2<<Math.log(e.length-1)/Math.LN2)-1,o=-~(1.6*n*t/e.length);return(s=t)=>{let i="";for(;;){let t=r(o),a=0|o;for(;a--;)if(i+=e[t[a]&n]||"",i.length===s)return i}}})(e,t,Nt))("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),no=(e,t)=>t?Ft(e,t):Dt(e);function oo(e,{releaseId:t,publishedId:r,document:n}){if(r&&n._id){const e=no(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=Pt(n._id),o=kt(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=Mt(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 no(r,t);throw new Error(`\`${e}()\` requires either a publishedId or a document with an \`_id\``)}const so=(e,t)=>{const[r,n,o]=((e,t)=>{if("object"==typeof e&&null!==e&&("releaseId"in e||"metadata"in e)){const{releaseId:r=ro(),metadata:n={}}=e;return[r,n,t]}return[ro(),{},e]})(e,t);return{action:{actionType:"sanity.action.release.create",releaseId:r,metadata:{...n,releaseType:n.releaseType||"undecided"}},options:o}};class io{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Zr(this.#a,this.#c,`_.releases.${e}`,t)}create(e,t){const{action:r,options:n}=so(e,t),{releaseId:o,metadata:s}=r;return pn(this.#a,this.#c,r,n).pipe(tt((e=>({...e,releaseId:o,metadata:s}))))}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return pn(this.#a,this.#c,n,r)}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return pn(this.#a,this.#c,r,t)}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return pn(this.#a,this.#c,r,t)}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return pn(this.#a,this.#c,r,t)}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return pn(this.#a,this.#c,n,r)}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return pn(this.#a,this.#c,r,t)}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return pn(this.#a,this.#c,r,t)}fetchDocuments({releaseId:e},t){return rn(this.#a,this.#c,e,t)}}class ao{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Ze(Zr(this.#a,this.#c,`_.releases.${e}`,t))}async create(e,t){const{action:r,options:n}=so(e,t),{releaseId:o,metadata:s}=r;return{...await Ze(pn(this.#a,this.#c,r,n)),releaseId:o,metadata:s}}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return Ze(pn(this.#a,this.#c,n,r))}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return Ze(pn(this.#a,this.#c,n,r))}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}fetchDocuments({releaseId:e},t){return Ze(rn(this.#a,this.#c,e,t))}}class co{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return wn(this.#a,this.#c,{uri:`/users/${e}`})}}class uo{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return Ze(wn(this.#a,this.#c,{uri:`/users/${e}`}))}}class lo{assets;datasets;live;mediaLibrary;projects;users;agent;releases;#u;#l;#c;listen=zn;constructor(e,t=qr){this.config(t),this.#l=e;const r=t._requestHandler;this.#c=r?(()=>{let n;return(o,s)=>{const i=o;return n||(n=new ho(e,{...t,_requestHandler:void 0})),r(i,(t=>e(t,s)),n)}})():e,this.assets=new Tn(this,this.#c),this.datasets=new Gn(this,this.#c),this.live=new Wn(this),this.mediaLibrary={video:new Xn(this,this.#c)},this.projects=new eo(this,this.#c),this.users=new co(this,this.#c),this.agent={action:new $n(this,this.#c)},this.releases=new io(this,this.#c)}clone(){return new lo(this.#l,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=Tr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new lo(this.#l,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Kr(this,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){if(!0===t?.includeAllVersions)return Zr(this,this.#c,e,{...t,includeAllVersions:!0});const r={signal:t?.signal,tag:t?.tag,releaseId:t?.releaseId,...t&&"includeAllVersions"in t?{includeAllVersions:!1}:{}};return Zr(this,this.#c,e,r)}getDocuments(e,t){return en(this,this.#c,e,t)}documentsExists(e,t){return tn(this,this.#c,e,t)}create(e,t){return yn(this,this.#c,e,"create",t)}createIfNotExists(e,t){return nn(this,this.#c,e,t)}createOrReplace(e,t){return on(this,this.#c,e,t)}createVersion({document:e,publishedId:t,releaseId:r,baseId:n,ifBaseRevisionId:o},s){if(!e)return an(this,this.#c,t,n,r,o,s);const i=oo("createVersion",{document:e,publishedId:t,releaseId:r}),a={...e,_id:i},c=t||Ut(e._id);return sn(this,this.#c,a,c,s)}delete(e,t){return cn(this,this.#c,e,t)}discardVersion({releaseId:e,publishedId:t},r,n){const o=no(t,e);return un(this,this.#c,o,r,n)}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=oo("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return ln(this,this.#c,s,n)}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ft(t,e);return dn(this,this.#c,n,t,r)}mutate(e,t){return hn(this,this.#c,e,t)}patch(e,t){return new zr(e,t,this)}transaction(e){return new Gr(e,this)}action(e,t){return pn(this,this.#c,e,t)}request(e){return wn(this,this.#c,e)}getUrl(e,t){return En(this,e,t)}getDataUrl(e,t){return Cn(this,e,t)}}class ho{assets;datasets;live;mediaLibrary;projects;users;agent;releases;observable;#u;#l;#c;listen=zn;constructor(e,t=qr){this.config(t),this.#l=e;const r=t._requestHandler;this.#c=r?(()=>{let n;return(o,s)=>{const i=o;return n||(n=new ho(e,{...t,_requestHandler:void 0})),r(i,(t=>e(t,s)),n)}})():e,this.assets=new On(this,this.#c),this.datasets=new Jn(this,this.#c),this.live=new Wn(this),this.mediaLibrary={video:new Kn(this,this.#c)},this.projects=new to(this,this.#c),this.users=new uo(this,this.#c),this.agent={action:new Sn(this,this.#c)},this.releases=new ao(this,this.#c),this.observable=new lo(e,t)}clone(){return new ho(this.#l,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=Tr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new ho(this.#l,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Ze(Kr(this,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){if(!0===t?.includeAllVersions)return Ze(Zr(this,this.#c,e,{...t,includeAllVersions:!0}));const r={signal:t?.signal,tag:t?.tag,releaseId:t?.releaseId,...t&&"includeAllVersions"in t?{includeAllVersions:!1}:{}};return Ze(Zr(this,this.#c,e,r))}getDocuments(e,t){return Ze(en(this,this.#c,e,t))}documentsExists(e,t){return Ze(tn(this,this.#c,e,t))}create(e,t){return Ze(yn(this,this.#c,e,"create",t))}createIfNotExists(e,t){return Ze(nn(this,this.#c,e,t))}createOrReplace(e,t){return Ze(on(this,this.#c,e,t))}createVersion({document:e,publishedId:t,releaseId:r,baseId:n,ifBaseRevisionId:o},s){if(!e)return et(an(this,this.#c,t,n,r,o,s));const i=oo("createVersion",{document:e,publishedId:t,releaseId:r}),a={...e,_id:i},c=t||Ut(e._id);return et(sn(this,this.#c,a,c,s))}delete(e,t){return Ze(cn(this,this.#c,e,t))}discardVersion({releaseId:e,publishedId:t},r,n){const o=no(t,e);return Ze(un(this,this.#c,o,r,n))}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=oo("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return et(ln(this,this.#c,s,n))}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ft(t,e);return Ze(dn(this,this.#c,n,t,r))}mutate(e,t){return Ze(hn(this,this.#c,e,t))}patch(e,t){return new Hr(e,t,this)}transaction(e){return new Br(e,this)}action(e,t){return Ze(pn(this,this.#c,e,t))}request(e){return Ze(wn(this,this.#c,e))}dataRequest(e,t,r){return Ze(fn(this,this.#c,e,t,r))}getUrl(e,t){return En(this,e,t)}getDataUrl(e,t){return Cn(this,e,t)}}const po=(vo=ho,{requester:rr(bo=[]),createClient:e=>{const t=rr(bo,{ignoreWarnings:e.ignoreWarnings});return new vo(((r,n)=>(n||t)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,lineage:e.lineage,...r})),e)}}),fo=po.requester,yo=po.createClient,go=(mo=yo,function(e){return Rr(),mo(e)});var mo,bo,vo;const wo=/_key\s*==\s*['"](.*)['"]/;function Co(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?wo.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 Eo={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},Io={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function Ro(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=>Io[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=>Io[e]));t.push(e)}return t}function xo(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 _o(e){return 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)}`)}))}function qo(e,t){if(!t?.mappings)return;const r=`$${_o(e).map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Eo[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Eo[e]))}')]`:`[${e._index}]`)).join("")}`;if(void 0!==t.mappings[r])return{mapping:t.mappings[r],matchedPath:r,pathSuffix:""};const n=function(e){return e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Eo[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Eo[e]))}')]`:`[${e._index}]`))}(_o(e));for(let e=n.length-1;e>=0;e--){const o=`$${n.slice(0,e).join("")}`,s=t.mappings[o];if(s){return{mapping:s,matchedPath:o,pathSuffix:r.substring(o.length)}}}}function $o(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(vt(e)){const o=e._key;if("string"==typeof o)return $o(e,t,r.concat({_key:o,_index:n}))}return $o(e,t,r.concat(n))}));if(vt(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=$o(e.children,t,r.concat("children")):"span"===e._type&&(n.text=$o(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,$o(n,t,r.concat(e))])))}return t(e,r)}function So(e,t,r){return $o(e,((e,n)=>{if("string"!=typeof e)return e;const o=qo(n,t);if(!o)return e;const{mapping:s,matchedPath:i}=o;if("value"!==s.type||"documentValue"!==s.source.type)return e;const a=t.documents[s.source.document],c=t.paths[s.source.path],u=Ro(i),l=Ro(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const To=".",Oo=`drafts${To}`,jo=`versions${To}`;function Ao(e){return e.startsWith(Oo)}function Po(e){return e.startsWith(jo)}function ko(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:c}=e;if(!t)throw new Error("baseUrl is required");if(!i)throw new Error("path is required");if(!o)throw new Error("id is required");if("/"!==t&&t.endsWith("/"))throw new Error("baseUrl must not end with a slash");const u="default"===r?void 0:r,l="default"===n?void 0:n,d=function(e){return Po(e)?e.split(To).slice(2).join(To):Ao(e)?e.slice(Oo.length):e}(o),h=Array.isArray(i)?Co(xo(i)):i,p=new URLSearchParams({baseUrl:t,id:d,type:s,path:h});if(u&&p.set("workspace",u),l&&p.set("tool",l),a&&p.set("projectId",a),c&&p.set("dataset",c),function(e){return!Ao(e)&&!Po(e)}(o))p.set("perspective","published");else if(Po(o)){const e=function(e){if(!Po(e))return;const[t,r]=e.split(To);return r}(o);p.set("perspective",e)}const f=["/"===t?"":t];u&&f.push(u);const y=["mode=presentation",`id=${d}`,`type=${s}`,`path=${encodeURIComponent(h)}`];return l&&y.push(`tool=${l}`),f.push("intent","edit",`${y.join(";")}?${p}`),f.join("/")}const Do=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{const{protocol:t}=new URL(e,e.startsWith("/")?"https://acme.com":void 0);return Mo.has(t)||t.startsWith("web+")}catch{return!1}}(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))||Uo(e)||Uo(t)||"string"==typeof o&&Fo.has(o))},Fo=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"]);const Mo=new Set(["app:","data:","discord:","file:","ftp:","ftps:","geo:","http:","https:","imap:","javascript:","magnet:","mailto:","maps:","ms-excel:","ms-powerpoint:","ms-word:","slack:","sms:","spotify:","steam:","teams:","tel:","vscode:","zoom:"]);function Uo(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function No(e,t,r){const{filter:n,logger:o,enabled:s}=r;if(!s){const n="config.enabled must be true, don't call this function otherwise";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}if(!t)return o?.error?.("[@sanity/client]: Missing Content Source Map from response body",{result:e,resultSourceMap:t,config:r}),e;if(!r.studioUrl){const n="config.studioUrl must be defined";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const i={encoded:[],skipped:[]},a=So(e,t,(({sourcePath:e,sourceDocument:t,resultPath:s,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:s,filterDefault:Do,sourceDocument:t,value:a}):Do({sourcePath:e,resultPath:s,value:a})))return o&&i.skipped.push({path:Lo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&i.encoded.push({path:Lo(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:d,_type:h,_projectId:p,_dataset:f}=t;return qt(a,{origin:"sanity.io",href:ko({baseUrl:c,workspace:u,tool:l,id:d,type:h,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:p}})},!1)}));if(o){const e=i.skipped.length,t=i.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${i.encoded.length}, skipped: ${i.skipped.length}`)),i.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(i.encoded)),i.skipped.length>0){const e=new Set;for(const{path:t}of i.skipped)e.add(t.replace(wo,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function Lo(e){return Co(xo(e))}var zo=Object.freeze({__proto__:null,stegaEncodeSourceMap:No}),Ho=Object.freeze({__proto__:null,encodeIntoResult:So,stegaEncodeSourceMap:No,stegaEncodeSourceMap$1:zo});function Vo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wo,Bo,Go,Jo={exports:{}},Qo=Jo.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";const t=!(typeof navigator>"u")&&"ReactNative"===navigator.product,r={timeout:t?6e4:12e4},n=function(e){const n={...r,..."string"==typeof e?{url:e}:e};if(n.timeout=s(n.timeout),n.query){const{url:e,searchParams:r}=function(e){const r=e.indexOf("?");if(-1===r)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,r),s=e.slice(r+1);if(!t)return{url:n,searchParams:new URLSearchParams(s)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const i=new URLSearchParams;for(const e of s.split("&")){const[t,r]=e.split("=");t&&i.append(o(t),o(r||""))}return{url:n,searchParams:i}}(n.url);for(const[t,o]of Object.entries(n.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)r.append(t,e);else r.append(t,o);const s=r.toString();s&&(n.url=`${e}?${s}`)}}return n.method=n.body&&!n.method?"POST":(n.method||"GET").toUpperCase(),n};function o(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(r.timeout):{connect:t,socket:t}}const i=/^https?:\/\//i,a=function(e){if(!i.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const u=["request","response","progress","error","abort"],l=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const r=[],o=l.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[n],validateOptions:[a]});function s(e){const r="object"==typeof e&&e.callSiteStack?e.callSiteStack:void 0,n=r?void 0:new Error,s=u.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)),{}),i=(e=>function(t,r,...n){const o="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...n),!o||s);r++);return s})(o),a=i("processOptions",e);i("validateOptions",a);const c={options:a,channels:s,applyMiddleware:i};let l;const d=s.request.subscribe((e=>{l=t(e,((t,o)=>((e,t,o)=>{let a=e,c=t;if(!a)try{c=i("onResponse",t,o)}catch(e){c=null,a=e}if(a=a&&i("onError",a,o),a){if(a instanceof Error){const e=r?.stack||n?.stack;if("string"==typeof e){const t=e.split("\n").slice(r?1:2);t.length>0&&(a.stack+="\n"+t.join("\n"))}}s.error.publish(a)}else c&&s.response.publish(c)})(t,o,e)))}));s.abort.subscribe((()=>{d(),l&&l.abort()}));const h=i("onReturn",s,c);return h===s&&s.request.publish(c),h}return s.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&o.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 l.forEach((t=>{e[t]&&o[t].push(e[t])})),r.push(e),s},s.clone=()=>d(r,t),e.forEach(s.use),s}var h,p,f=c(function(){if(p)return h;p=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")},t=function(e){return"[object Array]"===Object.prototype.toString.call(e)};return h=function(r){if(!r)return{};for(var n=Object.create(null),o=e(r).split("\n"),s=0;s<o.length;s++){var i=o[s],a=i.indexOf(":"),c=e(i.slice(0,a)).toLowerCase(),u=e(i.slice(a+1));typeof n[c]>"u"?n[c]=u:t(n[c])?n[c].push(u):n[c]=[n[c],u]}return n}}());let y=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#s={};#i;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#n[e]=t}setInit(e,t=!0){this.#s=e,this.#i=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#s,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#i&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}};const g="function"==typeof XMLHttpRequest?"xhr":"fetch",m="xhr"===g?XMLHttpRequest:y,b=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:g,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new m;i instanceof y&&"object"==typeof n.fetch&&i.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,d=!1;if(i.onerror=e=>{b(i instanceof y?e instanceof Error?e:new Error(`Request error while attempting to reach ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.ontimeout=e=>{b(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.onabort=()=>{p(!0),u=!0},i.onreadystatechange=function(){c&&(p(),o.socket=setTimeout((()=>h("ESOCKETTIMEDOUT")),c.socket)),!u&&i&&4===i.readyState&&0!==i.status&&function(){if(!(u||l||d)){if(0===i.status)return void b(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:i.response||(""===i.responseType||"text"===i.responseType?i.responseText:""),url:n.url,method:n.method,headers:f(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}}()},i.open(n.method,n.url,!0),i.withCredentials=!!n.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return n.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:g,request:i,context:e}),i.send(n.body||null),c&&(o.connect=setTimeout((()=>h("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,i&&i.abort()}};function h(t){d=!0,i.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function p(e){(e||u||i&&i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function b(e){if(l)return;p(!0),l=!0,i=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},v=(e=[],t=b)=>d(e,t);var w,C,E,I,R,q={exports:{}};R||(R=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")||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?E:(I=1,E=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,o=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,s=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").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(C)return w;C=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return w=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(s){if(!((s=String(s)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=r?s(c,u,r,"hour"):u>=t?s(c,u,t,"minute"):u>=e?s(c,u,e,"second"):c+" ms"):function(o){var s=Math.abs(o);return s>=n?Math.round(o/n)+"d":s>=r?Math.round(o/r)+"h":s>=t?Math.round(o/t)+"m":s>=e?Math.round(o/e)+"s":o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(q,q.exports));const x=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function _(e){return"[object Object]"===Object.prototype.toString.call(e)}const $=["boolean","string","number"];function S(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||x(t)||-1===$.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 O={};typeof globalThis<"u"?O=globalThis:typeof window<"u"?O=window:typeof global<"u"?O=global:typeof self<"u"&&(O=self);var j=O;function A(e={}){const t=e.implementation||j.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 P=(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 D=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||k,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,c=s.shouldRetry||n,u=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,s)||u>=i)return e;var l;const d=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(d)),a(u)),null}}})({shouldRetry:P,...e});D.shouldRetry=P;var F=function(e,t){return F=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])},F(e,t)};function M(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}F(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function U(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function N(e,t){var r,n,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function L(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function z(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function H(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function V(e){return this instanceof V?(this.v=e,this):new V(e)}function W(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof V?Promise.resolve(e.value.v).then(c,u):l(s[0][2],e)}(o[e](t))}catch(e){l(s[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function B(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 J(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=J((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 Y(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var X=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=L(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(G(c))try{c()}catch(e){o=e instanceof Q?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=L(u),d=l.next();!d.done;d=l.next()){var h=d.value;try{ee(h)}catch(e){o=null!=o?o:[],e instanceof Q?o=H(H([],z(o)),z(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{d&&!d.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)ee(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)&&Y(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&Y(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),K=X.EMPTY;function Z(e){return e instanceof X||e&&"closed"in e&&G(e.remove)&&G(e.add)&&G(e.unsubscribe)}function ee(e){G(e)?e():e.unsubscribe()}var te={Promise:void 0},re=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,H([e,t],z(r)))};function ne(e){re((function(){throw e}))}function oe(){}function se(e){e()}var ie=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Z(t)&&t.add(r)):r.destination=le,r}return M(t,e),t.create=function(e,t,r){return new ce(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}(X),ae=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){ue(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ue(e)}else ue(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ue(e)}},e}(),ce=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=G(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new ae(o),s}return M(t,e),t}(ie);function ue(e){ne(e)}var le={closed:!0,next:oe,error:function(e){throw e},complete:oe},de="function"==typeof Symbol&&Symbol.observable||"@@observable";function he(e){return e}function pe(e){return 0===e.length?he:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var fe=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof ie||function(e){return e&&G(e.next)&&G(e.error)&&G(e.complete)}(n)&&Z(n)?e:new ce(e,t,r);return se((function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=ye(t))((function(t,n){var o=new ce({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 pe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ye(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 ye(e){var t;return null!==(t=null!=e?e:te.Promise)&&void 0!==t?t:Promise}function ge(e){return function(t){if(function(e){return G(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function me(e,t,r,n,o){return new be(e,t,r,n,o)}var be=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return M(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}(ie),ve=J((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),we=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 M(t,e),t.prototype.lift=function(e){var t=new Ce(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new ve},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),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;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,s=r.observers;return n||o?K:(this.currentObservers=null,s.push(e),new X((function(){t.currentObservers=null,Y(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new fe;return e.source=this,e},t.create=function(e,t){return new Ce(e,t)},t}(fe),Ce=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return M(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:K},t}(we),Ee={now:function(){return(Ee.delegate||Date).now()},delegate:void 0},Ie=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Ee);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 M(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,i=r._timestampProvider,a=r._windowTime;n||(o.push(t),!s&&o.push(i.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,s=(o?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!o){for(var i=r.now(),a=0,c=1;c<n.length&&n[c]<=i;c+=2)a=c;a&&n.splice(0,a+1)}},t}(we),Re=function(e){function t(t,r){return e.call(this)||this}return M(t,e),t.prototype.schedule=function(e,t){return this},t}(X),qe=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,H([e,t],z(r)))},xe=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 M(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),qe(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&&xe(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,Y(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Re),$e=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Ee.now,e}(),Se=new(function(e){function t(t,r){void 0===r&&(r=$e.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return M(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}($e))(_e),Te=new fe((function(e){return e.complete()}));function Oe(e){return e[e.length-1]}function je(e){return(t=Oe(e))&&G(t.schedule)?e.pop():void 0;var t}var Ae=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function Pe(e){return G(null==e?void 0:e.then)}function ke(e){return G(e[de])}function De(e){return Symbol.asyncIterator&&G(null==e?void 0:e[Symbol.asyncIterator])}function Fe(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 Me="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ue(e){return G(null==e?void 0:e[Me])}function Ne(e){return W(this,arguments,(function(){var t,r,n;return N(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,V(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,V(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,V(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 ze(e){if(e instanceof fe)return e;if(null!=e){if(ke(e))return o=e,new fe((function(e){var t=o[de]();if(G(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Ae(e))return n=e,new fe((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(Pe(e))return r=e,new fe((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,ne)}));if(De(e))return He(e);if(Ue(e))return t=e,new fe((function(e){var r,n;try{for(var o=L(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Le(e))return He(Ne(e))}var t,r,n,o;throw Fe(e)}function He(e){return new fe((function(t){(function(e,t){var r,n,o,s;return U(this,void 0,void 0,(function(){var i,a;return N(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=B(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Ve(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),ge((function(r,n){r.subscribe(me(n,(function(r){return Ve(n,e,(function(){return n.next(r)}),t)}),(function(){return Ve(n,e,(function(){return n.complete()}),t)}),(function(r){return Ve(n,e,(function(){return n.error(r)}),t)})))}))}function Be(e,t){return void 0===t&&(t=0),ge((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function Ge(e,t){if(!e)throw new Error("Iterable cannot be null");return new fe((function(r){Ve(r,t,(function(){var n=e[Symbol.asyncIterator]();Ve(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function Je(e,t){if(null!=e){if(ke(e))return function(e,t){return ze(e).pipe(Be(t),We(t))}(e,t);if(Ae(e))return function(e,t){return new fe((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(Pe(e))return function(e,t){return ze(e).pipe(Be(t),We(t))}(e,t);if(De(e))return Ge(e,t);if(Ue(e))return function(e,t){return new fe((function(r){var n;return Ve(r,t,(function(){n=e[Me](),Ve(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(Ne(e),t)}(e,t)}throw Fe(e)}function Qe(e,t){return t?Je(e,t):ze(e)}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qe(e,je(e))}function Xe(e,t){var r=G(e)?e:function(){return e};return new fe((function(e){return e.error(r())}))}var Ke=J((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ze(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 Ke)}})}))}function et(e,t){return new Promise((function(t,r){var n=new ce({next:function(e){t(e),n.unsubscribe()},error:r,complete:function(){r(new Ke)}});e.subscribe(n)}))}function tt(e,t){return ge((function(r,n){var o=0;r.subscribe(me(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,H([],z(t))):e(t)}(e,t)}))}function ot(e,t,r){t()}function st(e,t,r){return void 0===r&&(r=1/0),G(t)?st((function(r,n){return tt((function(e,o){return t(r,e,n,o)}))(ze(e(r,n)))}),r):("number"==typeof t&&(r=t),ge((function(t,n){return function(e,t,r,n,o,s,i){var a=[],c=0,u=0,l=!1,d=function(){!l||a.length||c||t.complete()},h=function(e){c++;var o=!1;ze(r(e,u++)).subscribe(me(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{for(c--;a.length&&c<n;)e=void 0,e=a.shift(),i||h(e);d()}catch(e){t.error(e)}var e})))};return e.subscribe(me(t,(function(e){return c<n?h(e):a.push(e)}),(function(){l=!0,d()}))),function(){}}(t,n,e,r)})))}function it(e){return void 0===e&&(e=1/0),st(he,e)}function at(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return it(1)(Qe(e,je(e)))}function ct(e){return new fe((function(t){ze(e()).subscribe(t)}))}function ut(e,t,r){return void 0===r&&(r=Se),new fe((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?+e-r.now():e;o<0&&(o=0);var s=0;return r.schedule((function(){t.closed||(t.next(s++),t.complete())}),o)}))}function lt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=je(e),n=function(e,t){return"number"==typeof Oe(e)?e.pop():t}(e,1/0),o=e;return o.length?1===o.length?ze(o[0]):it(n)(Qe(o,r)):Te}var dt=Array.isArray;function ht(e,t){return ge((function(r,n){var o=0;r.subscribe(me(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function pt(e){return ge((function(t,r){var n,o=null,s=!1;o=t.subscribe(me(r,void 0,void 0,(function(i){n=ze(e(i,pt(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):s=!0}))),s&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function ft(e,t){return ge(function(e,t,r){return function(n,o){var s=r,i=t,a=0;n.subscribe(me(o,(function(t){var r=a++;i=s?e(i,t,r):(s=!0,t)}),(function(){s&&o.next(i),o.complete()})))}}(e,t,arguments.length>=2))}function yt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return G(Oe(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pe(e)}(yt.apply(void 0,H([],z(e))),nt(r)):ge((function(t,r){var n,o,s;(n=H([t],z(function(e){return 1===e.length&&dt(e[0])?e[0]:e}(e))),void 0===s&&(s=he),function(e){ot(0,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,c=function(t){ot(0,(function(){var c=Qe(n[t],o),u=!1;c.subscribe(me(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function gt(e){return ge((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}function mt(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new we}:t,n=e.resetOnError,o=void 0===n||n,s=e.resetOnComplete,i=void 0===s||s,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,s,a=0,u=!1,l=!1,d=function(){null==n||n.unsubscribe(),n=void 0},h=function(){d(),t=s=void 0,u=l=!1},p=function(){var e=t;h(),null==e||e.unsubscribe()};return ge((function(e,f){a++,l||u||d();var y=s=null!=s?s:r();f.add((function(){0!==--a||l||u||(n=bt(p,c))})),y.subscribe(f),!t&&a>0&&(t=new ce({next:function(e){return y.next(e)},error:function(e){l=!0,d(),n=bt(h,o,e),y.error(e)},complete:function(){u=!0,d(),n=bt(h,i),y.complete()}}),ze(e).subscribe(t))}))(e)}}function bt(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 ce({next:function(){o.unsubscribe(),e()}});return ze(t.apply(void 0,H([],z(r)))).subscribe(o)}}else e()}function vt(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=8203,Et=8204,It=8205,Rt=65279,qt={0:String.fromCodePoint(Ct),1:String.fromCodePoint(Et),2:String.fromCodePoint(It),3:String.fromCodePoint(Rt)},xt=new Array(4).fill(String.fromCodePoint(Ct)).join("");function _t(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),r=(new TextEncoder).encode(t),n="";for(let e=0;e<r.length;e++){let t=r[e];n+=qt[t>>6&3]+qt[t>>4&3]+qt[t>>2&3]+qt[3&t]}return xt+n}(t)}`}Object.fromEntries(Object.entries(qt).map((e=>[e[1],+e[0]]))),Object.fromEntries(Object.entries(wt).map((e=>e.reverse())));var $t=`${Object.values(wt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,St=new RegExp(`[${$t}]{4,}`,"gu");function Tt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(St,""),encoded:(null==(t=e.match(St))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}const Ot=".",jt=`drafts${Ot}`,At=`versions${Ot}`;function Pt(e){return e.startsWith(jt)}function kt(e){return e.startsWith(At)}function Dt(e){if(kt(e)){const t=Ut(e);return jt+t}return Pt(e)?e:jt+e}function Ft(e,t){if("drafts"===t||"published"===t)throw new Error('Version can not be "published" or "drafts"');return`${At}${t}${Ot}${Ut(e)}`}function Mt(e){if(!kt(e))return;const[t,r]=e.split(Ot);return r}function Ut(e){return kt(e)?e.split(Ot).slice(2).join(Ot):Pt(e)?e.slice(jt.length):e}let Nt=e=>crypto.getRandomValues(new Uint8Array(e));const Lt=/\r\n|[\n\r\u2028\u2029]/;function zt(e,t,r){const n=e.split(Lt),o={start:Ht(t.start,n),end:t.end?Ht(t.end,n):void 0},{start:s,end:i,markerLines:a}=function(e,t){const r={...e.start},n={...r,...e.end},o=2,s=3,i=r.line??-1,a=r.column??0,c=n.line,u=n.column;let l=Math.max(i-(o+1),0),d=Math.min(t.length,c+s);-1===i&&(l=0),-1===c&&(d=t.length);const h=c-i,p={};if(h)for(let e=0;e<=h;e++){const r=e+i;if(a)if(0===e){const e=t[r-1].length;p[r]=[a,e-a+1]}else if(e===h)p[r]=[0,u];else{const n=t[r-e].length;p[r]=[0,n]}else p[r]=!0}else p[i]=a===u?!a||[a,0]:[a,u-a];return{start:l,end:d,markerLines:p}}(o,n),c=`${i}`.length;return e.split(Lt,i).slice(s,i).map(((e,t)=>{const n=s+1+t,o=` ${` ${n}`.slice(-c)} |`,i=a[n],u=!a[n+1];if(!i)return` ${o}${e.length>0?` ${e}`:""}`;let l="";if(Array.isArray(i)){const t=e.slice(0,Math.max(i[0]-1,0)).replace(/[^\t]/g," "),n=i[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 Ht(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 Vt extends Error{response;statusCode=400;responseBody;traceId;details;constructor(e,t){const r=Bt(e,t);super(r.message),Object.assign(this,r)}}class Wt extends Error{response;statusCode=500;responseBody;traceId;details;constructor(e){const t=Bt(e);super(t.message),Object.assign(this,t)}}function Bt(e,t){const r=e.body,n={response:e,statusCode:e.statusCode,responseBody:Xt(r,e),traceId:Yt(e),message:"",details:void 0};if(!vt(r))return n.message=`${Qt(e,r)}${Kt(n.traceId)}`,n;const o=r.error;if("string"==typeof o&&"string"==typeof r.message)return n.message=`${o} - ${r.message}${Kt(n.traceId)}`,n;if("object"!=typeof o||null===o)return"string"==typeof o?n.message=`${o}${Kt(n.traceId)}`:"string"==typeof r.message?n.message=`${r.message}${Kt(n.traceId)}`:n.message=`${Qt(e,r)}${Kt(n.traceId)}`,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 s=t.length?`:\n- ${t.join("\n- ")}`:"";return e.length>5&&(s+=`\n...and ${e.length-5} more`),n.message=`${o.description}${Kt(n.traceId)}${s}`,n.details=r.error,n}if(Gt(o)){const e=t?.options?.query?.tag;return n.message=Jt(o,e,n.traceId),n.details=r.error,n}return"description"in o&&"string"==typeof o.description?(n.message=`${o.description}${Kt(n.traceId)}`,n.details=o,n):(n.message=`${Qt(e,r)}${Kt(n.traceId)}`,n)}function Gt(e){return vt(e)&&"queryParseError"===e.type&&"string"==typeof e.query&&"number"==typeof e.start&&"number"==typeof e.end}function Jt(e,t,r){const{query:n,start:o,end:s,description:i}=e,a=r?`\n(traceId: ${r})`:"";if(!n||typeof o>"u")return`GROQ query parse error: ${i}${a}`;const c=t?`\n\nTag: ${t}`:"";return`GROQ query parse error:\n${zt(n,{start:o,end:s},i)}${c}${a}`}function Qt(e,t){const r="string"==typeof t?` (${o=t,s=100,o.length>s?`${o.slice(0,s)}…`:o})`:"",n=e.statusMessage?` ${e.statusMessage}`:"";var o,s;return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${n}${r}`}function Yt(e){const t=e?.headers?.traceparent;if(t)return t.split("-")[1]}function Xt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}function Kt(e){return e?` (traceId: ${e})`:""}class Zt extends Error{projectId;addOriginUrl;constructor({projectId:e,credentials:t}={}){if(super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e,e&&typeof location<"u"){const r=new URL(`https://sanity.io/manage/project/${e}/api`),{origin:n}=location;r.searchParams.set("cors","add"),r.searchParams.set("origin",n),t&&r.searchParams.set("credentials",""),this.addOriginUrl=r,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${r}`}else this.message=e?`The current origin is not allowed to connect to the Live Content API. Change your configuration here: https://sanity.io/manage/project/${e}/api`:"The current origin is not allowed to connect to the Live Content API."}}const er={onResponse:(e,t)=>{if(e.statusCode>=500)throw new Wt(e);if(e.statusCode>=400)throw new Vt(e,t);return e}};function tr(e={}){const t={},r=t=>void 0!==e.ignoreWarnings&&(Array.isArray(e.ignoreWarnings)?e.ignoreWarnings:[e.ignoreWarnings]).some((e=>"string"==typeof e?t.includes(e):e instanceof RegExp&&e.test(t)));return{onResponse:e=>{const n=e.headers["x-sanity-warning"],o=Array.isArray(n)?n:[n];for(const e of o)!e||t[e]||r(e)||(t[e]=!0,console.warn(e));return e}}}function rr(e,t={}){return v([D({shouldRetry:nr}),...e,tr(t),S(),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"))}},er,A({implementation:fe})])}function nr(e,t,r){if(0===r.maxRetries)return!1;const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||D.shouldRetry(e,t,r)}function or(e){return"https://www.sanity.io/help/"+e}const sr=["image","file"],ir=["before","after","replace"],ar=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")},cr=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},ur=(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`)},lr=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);ur(e,t._id)},dr=(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)},hr=e=>{if(e.dataset)return e.dataset;const t=e.resource;if(t&&"dataset"===t.type){const e=t.id.split(".");if(2!==e.length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return e[1]}throw new Error("`dataset` must be provided to perform queries")},pr=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},fr=e=>{const t=e.resource;if(!t)throw new Error("`resource` must be provided to perform resource queries");const{type:r,id:n}=t;switch(r){case"dataset":if(2!==n.split(".").length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return;case"dashboard":case"media-library":case"canvas":return;default:throw new Error(`Unsupported resource type: ${r.toString()}`)}},yr=(e,t)=>{if(t.resource)throw new Error(`\`${e}\` does not support resource-based operations`)};const gr=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),mr=gr(["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"]),br=gr(["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."]),vr=gr(["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."]),wr=gr(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),Cr=gr(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${or("js-client-browser-token")} for more information and how to hide this warning.`]),Er=gr(["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`."]),Ir=gr(["Using the Sanity client without specifying an API version is deprecated.",`See ${or("js-client-api-version")}`]),Rr=gr(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),qr=gr(["You have called `createVersion()` with a defined `document`. The recommended approach is to provide a `baseId` and `releaseId` instead."]),xr=gr(["The `~experimental_resource` configuration property has been renamed to `resource`.","Please update your client configuration to use `resource` instead. Support for `~experimental_resource` will be removed in a future version."]),_r={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},$r=["localhost","127.0.0.1","0.0.0.0"];function Sr(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 Tr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||_r.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Ir();const n={..._r,...r};n["~experimental_resource"]&&!n.resource&&(xr(),n.resource=n["~experimental_resource"]);const o=n.resource,s=n.useProjectHostname&&!o;if(typeof Promise>"u"){const e=or("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${e}`)}if(s&&!n.projectId)throw new Error("Configuration must contain `projectId`");if(o&&fr(n),typeof n.perspective<"u"&&Sr(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,a=i&&(e=>-1!==$r.indexOf(e))(window.location.hostname),c=!!n.token;n.withCredentials&&c&&(Er(),n.withCredentials=!1),i&&a&&c&&!0!==n.ignoreBrowserTokenWarning?Cr():typeof n.useCdn>"u"&&br(),s&&(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&&ar(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?pr(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===_r.apiHost,!0===n.useCdn&&n.withCredentials&&mr(),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 u=n.apiHost.split("://",2),l=u[0],d=u[1],h=n.isDefaultApi?"apicdn.sanity.io":d;return s?(n.url=`${l}://${n.projectId}.${d}/v${n.apiVersion}`,n.cdnUrl=`${l}://${n.projectId}.${h}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n};class Or extends Error{name="ConnectionFailedError";status;constructor(e,t={}){const{status:r,...n}=t;super(e,n),this.status=r}}class jr 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 Pr extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class kr extends Error{name="MessageParseError"}const Dr=["channelError","disconnect"];function Fr(e,t){return ct((()=>{const t=e();return(r=t)&&(r instanceof fe||G(r.lift)&&G(r.subscribe))?t:Ye(t);var r})).pipe(st((e=>function(e,t){return new fe((r=>{const n=t.includes("open"),o=t.includes("reconnect");function s(t){if("data"in t){const[e,n]=Mr(t);return void r.error(e?new kr("Unable to parse EventSource error message",{cause:n}):new Pr((n?.data).message,n))}const n=t.status,s="number"==typeof n?n:void 0;void 0===s?e.readyState===e.CLOSED?r.error(new Or("EventSource connection failed")):o&&r.next({type:"reconnect"}):r.error(new Or("EventSource connection failed",{status:s}))}function i(){r.next({type:"open"})}function a(t){const[n,o]=Mr(t);if(n)r.error(new kr("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 jr(`Server disconnected client: ${o.data?.reason||"unknown error"}`));else{const t=new URL(e.url).searchParams.get("tag");r.error(new Ar(function(e,t){const r=e.error;return r?Gt(r)?Jt(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",s),n&&e.addEventListener("open",i);const c=[...new Set([...Dr,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return c.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",s),n&&e.removeEventListener("open",i),c.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function Mr(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,...Ur(t)?{}:{data:t}}]}catch(e){return[e,null]}}function Ur(e){for(const t in e)return!1;return!0}function Nr(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 Lr{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 cr("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===ir.indexOf(e)){const e=ir.map((e=>`"${e}"`)).join(", ");throw new Error(`${n} takes an "at"-argument which is one of: ${e}`)}if("string"!=typeof t)throw new Error(`${n} takes a "selector"-argument which must be a string`);if(!Array.isArray(r))throw new Error(`${n} takes an "items"-argument which must be an array`)})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after",`${e}[-1]`,t)}prepend(e,t){return this.insert("before",`${e}[0]`,t)}splice(e,t,r,n){const o=t<0?t-1:t,s=typeof r>"u"||-1===r?-1:Math.max(0,t+r),i=`${e}[${o}:${o<0&&s>=0?"":s}]`;return this.insert("replace",i,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...Nr(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return cr(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 zr extends Lr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new zr(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 Hr extends Lr{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new Hr(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 Vr={returnDocuments:!1};class Wr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return cr("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return cr(t,e),lr(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return cr(t,e),lr(t,e),this._add({[t]:e})}delete(e){return ur("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 Br extends Wr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Br([...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},Vr,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 Hr)return this._add({patch:e.serialize()});if(r){const r=t(new Hr(e,{},this.#a));if(!(r instanceof Hr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new Hr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class Gr extends Wr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new Gr([...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},Vr,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof zr)return this._add({patch:e.serialize()});if(r){const r=t(new zr(e,{},this.#a));if(!(r instanceof zr))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 Jr=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:s,returnQuery:i,...a}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))void 0!==r&&n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(a))t&&n.append(e,`${t}`);return!1===i&&n.append("returnQuery","false"),!1===s&&n.append("includeMutations","false"),`?${n}`},Qr=(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},Yr=e=>"response"===e.type,Xr=e=>e.body;function Kr(e,t,r,n,o={},s={}){const i="stega"in s?{...r||{},..."boolean"==typeof s.stega?{enabled:s.stega}:s.stega||{}}:r,a=i.enabled?Tt(o):o,c=!1===s.filterResponse?e=>e:e=>e.result,{cache:u,next:l,...d}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},h=fn(e,t,"query",{query:n,params:a},typeof u<"u"||typeof l<"u"?{...d,fetch:{cache:u,next:l}}:d);return i.enabled?h.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yt.apply(void 0,H([],z(e)))}(Qe(Promise.resolve().then((function(){return Ho})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),tt((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return c({...e,result:r})}))):h.pipe(tt(c))}function Zr(e,t,r,n={}){return vn(e,t,{uri:Cn(e,"doc",(()=>{if(!n.releaseId)return r;const e=Mt(r);if(!e){if(Pt(r))throw new Error(`The document ID (\`${r}\`) is a draft, but \`options.releaseId\` is set as \`${n.releaseId}\``);return Ft(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,query:void 0!==n.includeAllVersions?{includeAllVersions:n.includeAllVersions}:void 0}).pipe(ht(Yr),tt((e=>{const t=e.body.documents;return t?n.includeAllVersions?t:t[0]:n.includeAllVersions?[]:void 0})))}function en(e,t,r,n={}){return vn(e,t,{uri:Cn(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(ht(Yr),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 tn(e,t,r,n={}){if(0===r.length)return Ye(new Set);const o=[];for(let e=0;e<r.length;e+=100)o.push(r.slice(e,e+100));return Qe(o).pipe((s=r=>vn(e,t,{uri:Cn(e,"doc",r.map(encodeURIComponent).join(",")),tag:n.tag,signal:n.signal,query:{excludeContent:!0}}).pipe(ht(Yr),tt((e=>{const t=new Set;for(const r of e.body.omitted||[])"existence"===r.reason&&t.add(r.id);return new Set(r.filter((e=>!t.has(e))))}))),G(i)?st(s,i,1):st(s,1)),ft(((e,t)=>{for(const r of t)e.add(r);return e}),new Set));var s,i}function rn(e,t,r,n={}){return fn(e,t,"query",{query:"*[sanity::partOfRelease($releaseId)]",params:{releaseId:r}},n)}function nn(e,t,r,n){return lr("createIfNotExists",r),yn(e,t,r,"createIfNotExists",n)}function on(e,t,r,n){return lr("createOrReplace",r),yn(e,t,r,"createOrReplace",n)}function sn(e,t,r,n,o){return lr("createVersion",r),dr("createVersion",r),qr(),pn(e,t,{actionType:"sanity.action.document.version.create",publishedId:n,document:r},o)}function an(e,t,r,n,o,s,i){if(!n)throw new Error("`createVersion()` requires `baseId` when no `document` is provided");if(!r)throw new Error("`createVersion()` requires `publishedId` when `baseId` is provided");ur("createVersion",n),ur("createVersion",r);return pn(e,t,{actionType:"sanity.action.document.version.create",publishedId:r,baseId:n,versionId:o?Ft(r,o):Dt(r),ifBaseRevisionId:s},i)}function cn(e,t,r,n){return fn(e,t,"mutate",{mutations:[{delete:Nr(r)}]},n)}function un(e,t,r,n=!1,o){return pn(e,t,{actionType:"sanity.action.document.version.discard",versionId:r,purge:n},o)}function ln(e,t,r,n){return lr("replaceVersion",r),dr("replaceVersion",r),pn(e,t,{actionType:"sanity.action.document.version.replace",document:r},n)}function dn(e,t,r,n,o){return pn(e,t,{actionType:"sanity.action.document.version.unpublish",versionId:r,publishedId:n},o)}function hn(e,t,r,n){let o;o=r instanceof Hr||r instanceof zr?{patch:r.serialize()}:r instanceof Br||r instanceof Gr?r.serialize():r;return fn(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function pn(e,t,r,n){return fn(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 fn(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,c=s||i?"":Jr(n),u=!s&&!i&&c.length<11264,l=u?c:"",d=o.returnFirst,{timeout:h,token:p,tag:f,headers:y,returnQuery:g,lastLiveEventId:m,cacheMode:b}=o;return vn(e,t,{method:u?"GET":"POST",uri:Cn(e,r,l),json:!0,body:u?void 0:n,query:s&&Qr(o),timeout:h,headers:y,token:p,tag:f,returnQuery:g,perspective:o.perspective,variant:o.variant,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(m)?m[0]:m,cacheMode:b,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(ht(Yr),tt(Xr),tt((e=>{if(!s)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 yn(e,t,r,n,o={}){return fn(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}const gn=e=>{const t=e.config();return void 0!==t.dataset&&void 0!==t.projectId||void 0!==t.resource},mn=(e,t)=>gn(e)&&t.startsWith(Cn(e,"query")),bn=(e,t)=>t.startsWith("/data/")||mn(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"mutate")))(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"doc","")))(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"listen")))(e,t)||((e,t)=>gn(e)&&t.startsWith(Cn(e,"history","")))(e,t);function vn(e,t,r){const n=new Error,o=r.url||r.uri,s=e.config(),i=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&bn(e,o):r.canUseCdn;let a=(r.useCdn??s.useCdn)&&i;const c=r.tag&&s.requestTagPrefix?[s.requestTagPrefix,r.tag].join("."):r.tag||s.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:pr(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&mn(e,o)){const e=r.resultSourceMap??s.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||s.perspective;typeof t<"u"&&("previewDrafts"===t&&wr(),Sr(t),r.query={perspective:Array.isArray(t)?t.join(","):t,...r.query},(Array.isArray(t)&&t.length>0||"previewDrafts"===t||"drafts"===t)&&a&&(a=!1,vr()));const n=r.variant||s.variant;if(typeof n<"u"&&("string"==typeof n&&(r.query={variant:n,...r.query}),"object"==typeof n)){const e=Object.entries(n),t=(u=e,u.map((([e,t])=>["variantCondition",`${e}:${t}`]))).slice(0,1);if(e.length>1){const t=new Intl.ListFormat("en");console.warn(`The Sanity client's beta \`variant\` option currently only supports one condition. Dropped: ${t.format(e.slice(1).map((([e])=>JSON.stringify(e))))}.`)}r.query={...Object.fromEntries(t),...r.query}}r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query}),a&&"noStale"==r.cacheMode&&(r.query={cacheMode:"noStale",...r.query})}var u;const l=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),s=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof s>"u"?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(s,Object.assign({},r,{url:En(e,o,a),callSiteStack:n})),d=new fe((e=>t(l,s.requester).subscribe(e)));return r.signal?d.pipe((h=r.signal,e=>new fe((t=>{const r=()=>t.error(function(e){if(In)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}(h));if(h&&h.aborted)return void r();const n=e.subscribe(t);return h.addEventListener("abort",r),()=>{h.removeEventListener("abort",r),n.unsubscribe()}})))):d;var h}function wn(e,t,r){return vn(e,t,r).pipe(ht((e=>"response"===e.type)),tt((e=>e.body)))}function Cn(e,t,r){const n=e.config();if(n.resource){fr(n);return`${Rn(n)}/${void 0!==r?`${t}/${r}`:t}`.replace(/\/($|\?)/,"$1")}const o=`/${t}/${hr(n)}`;return`/data${void 0!==r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function En(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const In=!!globalThis.DOMException;const Rn=e=>{const t=e.resource;if(!t)throw new Error("`resource` must be provided to perform resource queries");const{type:r,id:n}=t;switch(r){case"dataset":{const e=n.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/${n}`;case"media-library":return`/media-libraries/${n}`;case"dashboard":return`/dashboards/${n}`;default:throw new Error(`Unsupported resource type: ${r.toString()}`)}};function qn(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/generate/${n}`,body:r})}function xn(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/transform/${n}`,body:r})}function _n(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/translate/${n}`,body:r})}class $n{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return qn(this.#a,this.#c,e)}transform(e){return xn(this.#a,this.#c,e)}translate(e){return _n(this.#a,this.#c,e)}}class Sn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}generate(e){return Ze(qn(this.#a,this.#c,e))}transform(e){return Ze(xn(this.#a,this.#c,e))}translate(e){return Ze(_n(this.#a,this.#c,e))}prompt(e){return Ze(function(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/prompt/${n}`,body:r})}(this.#a,this.#c,e))}patch(e){return Ze(function(e,t,r){const n=hr(e.config());return wn(e,t,{method:"POST",uri:`/agent/action/patch/${n}`,body:r})}(this.#a,this.#c,e))}}class Tn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return jn(this.#a,this.#c,e,t,r)}}class On{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return Ze(jn(this.#a,this.#c,e,t,r).pipe(ht((e=>"response"===e.type)),tt((e=>e.body.document))))}}function jn(e,t,r,n,o={}){(e=>{if(-1===sr.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${sr.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=e.config(),a=function(e,t){return typeof File>"u"||!(t instanceof File)?e:Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:c,label:u,title:l,description:d,creditLine:h,filename:p,source:f}=a,y="media-library"===i.resource?.type,g=y?{title:l,filename:p}:{label:u,title:l,description:d,filename:p,meta:s,creditLine:h};return f&&!y&&(g.sourceId=f.id,g.sourceName=f.name,g.sourceUrl=f.url),vn(e,t,{tag:c,method:"POST",timeout:a.timeout||0,uri:An(i,r),headers:a.contentType?{"Content-Type":a.contentType}:{},query:g,body:n})}function An(e,t){const r="image"===t?"images":"files",n=e.resource;if(n){const{type:e,id:t}=n;switch(e){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/${t}/assets/${r}`;case"media-library":return`/media-libraries/${t}/upload`;case"dashboard":return`/dashboards/${t}/assets/${r}`;default:throw new Error(`Unsupported resource type: ${e.toString()}`)}}return`assets/${r}/${hr(e)}`}const Pn=ct((()=>Promise.resolve().then((function(){return Zo})))).pipe(tt((({default:e})=>e)),(Mn=1,mt({connector:function(){return new Ie(Mn,Dn,Fn)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1}))),kn=new Set([408,429]);var Dn,Fn,Mn;function Un(){return function(e){return e.pipe(pt(((e,t)=>e instanceof Or&&("number"!=typeof e.status||e.status<400||e.status>=500||kn.has(e.status))?at(Ye({type:"reconnect"}),ut(1e3).pipe(st((()=>t)))):Xe((()=>e)))))}}const Nn=["includePreviousRevision","includeResult","includeMutations","includeAllVersions","visibility","effectFormat","enableResume","tag"],Ln={includeResult:!0};function zn(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i,headers:a}=this.config(),c=r.tag&&i?[i,r.tag].join("."):r.tag,u={...(h=r,p=Ln,Object.keys(p).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?p[t]:h[t],e)),{})),tag:c},l=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,Nn),d=`${n}${Cn(this,"listen",Jr({query:e,params:t,options:{tag:c,...l}}))}`;var h,p;if(d.length>14800)return Xe((()=>new Error("Query too large for listener")));const f=u.events?u.events:["mutation"],y={};return s&&(y.withCredentials=!0),(o||a)&&(y.headers={},o&&(y.headers.Authorization=`Bearer ${o}`),a&&Object.assign(y.headers,a)),Fr((()=>(typeof EventSource>"u"||y.headers?Pn:Ye(EventSource)).pipe(tt((e=>new e(d,y))))),f).pipe(Un(),ht((e=>f.includes(e.type))),tt((e=>({type:e.type,..."data"in e?e.data:{}}))))}function Hn(e,t){return function(e){return t=>{let r,n=!1;const{predicate:o,...s}=e,i=t.pipe((l=G(a=t=>{e.predicate(t)&&(n=!0,r=t)})||c||u?{next:a,error:c,complete:u}:a)?ge((function(e,t){var r;null===(r=l.subscribe)||void 0===r||r.call(l);var n=!0;e.subscribe(me(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)})))})):he,gt((()=>{n=!1,r=void 0})),mt(s));var a,c,u,l;return lt(i,new fe((e=>{n&&e.next(r),e.complete()})))}}("function"==typeof e?{predicate:e,...t}:e)}const Vn="2021-03-25";class Wn{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t,waitFor:r}={}){const{projectId:n,apiVersion:o,token:s,withCredentials:i,requestTagPrefix:a,headers:c}=this.#a.config(),u=o.replace(/^v/,"");if("X"!==u&&u<Vn)throw new Error(`The live events API requires API version ${Vn} or later. The current API version is ${u}. Please update your API version to use this feature.`);if(e&&!s&&!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 l=Cn(this.#a,"live/events"),d=new URL(this.#a.getUrl(l,!1)),h=t&&a?[a,t].join("."):t;h&&d.searchParams.set("tag",h),e&&d.searchParams.set("includeDrafts","true"),r&&d.searchParams.set("waitFor",r);const p={};e&&i&&(p.withCredentials=!0),(e&&s||c)&&(p.headers={},e&&s&&(p.headers.Authorization=`Bearer ${s}`),c&&Object.assign(p.headers,c));const f=`${d.href}::${JSON.stringify(p)}`,y=Bn.get(f);if(y)return y;const g=Fr((()=>(typeof EventSource>"u"||p.headers?Pn:Ye(EventSource)).pipe(tt((e=>new e(d.href,p))))),["message","restart","welcome","reconnect","goaway"]),m=function(e,t,r){return new fe((n=>{const o=new AbortController,{signal:s}=o;return fetch(e,{method:"GET",mode:"cors",credentials:"omit",signal:s}).then((e=>{if(!s.aborted&&e.ok)return e.json()})).then((e=>{if(!s.aborted){if(r&&!1===e?.result?.withCredentials)return void n.error(new Zt({projectId:t,credentials:!0}));if(!1===e?.result?.allowed)return void n.error(new Zt({projectId:t,credentials:r}));n.next(),n.complete()}})).catch((()=>{s.aborted||n.closed||(n.next(),n.complete())})),()=>o.abort()}))}(new URL(this.#a.getUrl("/check/cors",!1)),n,!0===p.withCredentials),b=g.pipe(Un(),st((e=>"reconnect"===e.type?m.pipe(st((()=>Ye(e)))):Ye(e))),pt((e=>e instanceof Zt?Xe((()=>e)):m.pipe(st((()=>{throw e}))))),tt((e=>{if("message"===e.type){const{data:t,...r}=e;return{...r,tags:t.tags}}return e}))).pipe(gt((()=>Bn.delete(f))),Hn({predicate:e=>"welcome"===e.type}));return Bn.set(f,b),b}}const Bn=new Map;class Gn{#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(){yr("dataset",this.#a.config());const e=this.#a.config(),t=e.projectId;let r="/datasets";return!1===e.useProjectHostname&&(r=`/projects/${t}/datasets`),wn(this.#a,this.#c,{uri:r,tag:null})}getEmbeddingsSettings(e){return yr("dataset",this.#a.config()),ar(e),wn(this.#a,this.#c,{uri:Qn(this.#a,e),tag:null})}editEmbeddingsSettings(e,t){return yr("dataset",this.#a.config()),ar(e),wn(this.#a,this.#c,{method:"PUT",uri:Qn(this.#a,e),body:t,tag:null})}}class Jn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return yr("dataset",this.#a.config()),Ze(Yn(this.#a,this.#c,"PUT",e,t))}edit(e,t){return yr("dataset",this.#a.config()),Ze(Yn(this.#a,this.#c,"PATCH",e,t))}delete(e){return yr("dataset",this.#a.config()),Ze(Yn(this.#a,this.#c,"DELETE",e))}list(){yr("dataset",this.#a.config());const e=this.#a.config(),t=e.projectId;let r="/datasets";return!1===e.useProjectHostname&&(r=`/projects/${t}/datasets`),Ze(wn(this.#a,this.#c,{uri:r,tag:null}))}getEmbeddingsSettings(e){return yr("dataset",this.#a.config()),ar(e),Ze(wn(this.#a,this.#c,{uri:Qn(this.#a,e),tag:null}))}editEmbeddingsSettings(e,t){return yr("dataset",this.#a.config()),ar(e),Ze(wn(this.#a,this.#c,{method:"PUT",uri:Qn(this.#a,e),body:t,tag:null}))}}function Qn(e,t){const r=e.config();return!1===r.useProjectHostname?`/projects/${r.projectId}/datasets/${t}/settings/embeddings`:`/datasets/${t}/settings/embeddings`}function Yn(e,t,r,n,o){return yr("dataset",e.config()),ar(n),wn(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class Xn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getPlaybackInfo(e,t={}){const r=this.#a.config(),n=(r.resource||r["~experimental_resource"])?.id,{instanceId:o,libraryId:s}=function(e){const t=function(e){return"object"==typeof e&&"_ref"in e}(e)?e._ref:e,r=Zn.exec(t);if(r){const[,e,t]=r;return{libraryId:e,instanceId:t}}if("string"==typeof e&&e.startsWith("video-"))return{instanceId:e};throw new Error(`Invalid video asset instance identifier "${t}": must be a valid video instance id or a Global Dataset Reference (GDR) to the video asset in the Media Library`)}(e),i=s||n;if(!i)throw new Error("Could not determine Media Library ID - you need to provide a valid Media Library ID in the client config or a Media Library GDR");const a=function(e,t){return`/media-libraries/${t}/video/${e}/playback-info`}(o,i),c=function(e){const t={};if(e.transformations){const{thumbnail:r,animated:n,storyboard:o}=e.transformations;r&&(r.width&&(t.thumbnailWidth=r.width),r.height&&(t.thumbnailHeight=r.height),void 0!==r.time&&(t.thumbnailTime=r.time),r.fit&&(t.thumbnailFit=r.fit),r.format&&(t.thumbnailFormat=r.format)),n&&(n.width&&(t.animatedWidth=n.width),n.height&&(t.animatedHeight=n.height),void 0!==n.start&&(t.animatedStart=n.start),void 0!==n.end&&(t.animatedEnd=n.end),n.fps&&(t.animatedFps=n.fps),n.format&&(t.animatedFormat=n.format)),o&&o.format&&(t.storyboardFormat=o.format)}return e.expiration&&(t.expiration=e.expiration),t}(t);return wn(this.#a,this.#c,{method:"GET",uri:a,query:c})}}class Kn{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getPlaybackInfo(e,t={}){return Ze(new Xn(this.#a.observable,this.#c).getPlaybackInfo(e,t))}}const Zn=/^media-library:(ml[^:]+):([^:]+)$/;class eo{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){const t={};return!1===e?.includeMembers&&(t.includeMembers="false"),!1===e?.includeFeatures&&(t.includeFeatures="false"),e?.organizationId&&(t.organizationId=e.organizationId),e?.onlyExplicitMembership&&(t.onlyExplicitMembership="true"),wn(this.#a,this.#c,{uri:"/projects",query:t})}getById(e){return wn(this.#a,this.#c,{uri:`/projects/${e}`})}}class to{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){const t={};return!1===e?.includeMembers&&(t.includeMembers="false"),!1===e?.includeFeatures&&(t.includeFeatures="false"),e?.organizationId&&(t.organizationId=e.organizationId),e?.onlyExplicitMembership&&(t.onlyExplicitMembership="true"),Ze(wn(this.#a,this.#c,{uri:"/projects",query:t}))}getById(e){return Ze(wn(this.#a,this.#c,{uri:`/projects/${e}`}))}}const ro=((e,t=21)=>((e,t,r)=>{let n=(2<<Math.log(e.length-1)/Math.LN2)-1,o=-~(1.6*n*t/e.length);return(s=t)=>{let i="";for(;;){let t=r(o),a=0|o;for(;a--;)if(i+=e[t[a]&n]||"",i.length===s)return i}}})(e,t,Nt))("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",8),no=(e,t)=>t?Ft(e,t):Dt(e);function oo(e,{releaseId:t,publishedId:r,document:n}){if(r&&n._id){const e=no(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=Pt(n._id),o=kt(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=Mt(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 no(r,t);throw new Error(`\`${e}()\` requires either a publishedId or a document with an \`_id\``)}const so=(e,t)=>{const[r,n,o]=((e,t)=>{if("object"==typeof e&&null!==e&&("releaseId"in e||"metadata"in e)){const{releaseId:r=ro(),metadata:n={}}=e;return[r,n,t]}return[ro(),{},e]})(e,t);return{action:{actionType:"sanity.action.release.create",releaseId:r,metadata:{...n,releaseType:n.releaseType||"undecided"}},options:o}};class io{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Zr(this.#a,this.#c,`_.releases.${e}`,t)}create(e,t){const{action:r,options:n}=so(e,t),{releaseId:o,metadata:s}=r;return pn(this.#a,this.#c,r,n).pipe(tt((e=>({...e,releaseId:o,metadata:s}))))}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return pn(this.#a,this.#c,n,r)}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return pn(this.#a,this.#c,r,t)}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return pn(this.#a,this.#c,r,t)}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return pn(this.#a,this.#c,r,t)}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return pn(this.#a,this.#c,n,r)}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return pn(this.#a,this.#c,r,t)}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return pn(this.#a,this.#c,r,t)}fetchDocuments({releaseId:e},t){return rn(this.#a,this.#c,e,t)}}class ao{#a;#c;constructor(e,t){this.#a=e,this.#c=t}get({releaseId:e},t){return Ze(Zr(this.#a,this.#c,`_.releases.${e}`,t))}async create(e,t){const{action:r,options:n}=so(e,t),{releaseId:o,metadata:s}=r;return{...await Ze(pn(this.#a,this.#c,r,n)),releaseId:o,metadata:s}}edit({releaseId:e,patch:t},r){const n={actionType:"sanity.action.release.edit",releaseId:e,patch:t};return Ze(pn(this.#a,this.#c,n,r))}publish({releaseId:e},t){const r={actionType:"sanity.action.release.publish",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}archive({releaseId:e},t){const r={actionType:"sanity.action.release.archive",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}unarchive({releaseId:e},t){const r={actionType:"sanity.action.release.unarchive",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}schedule({releaseId:e,publishAt:t},r){const n={actionType:"sanity.action.release.schedule",releaseId:e,publishAt:t};return Ze(pn(this.#a,this.#c,n,r))}unschedule({releaseId:e},t){const r={actionType:"sanity.action.release.unschedule",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}delete({releaseId:e},t){const r={actionType:"sanity.action.release.delete",releaseId:e};return Ze(pn(this.#a,this.#c,r,t))}fetchDocuments({releaseId:e},t){return Ze(rn(this.#a,this.#c,e,t))}}class co{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return wn(this.#a,this.#c,{uri:`/users/${e}`})}}class uo{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return Ze(wn(this.#a,this.#c,{uri:`/users/${e}`}))}}class lo{assets;datasets;live;mediaLibrary;projects;users;agent;releases;#u;#l;#c;listen=zn;constructor(e,t=_r){this.config(t),this.#l=e;const r=t._requestHandler;this.#c=r?(()=>{let n;return(o,s)=>{const i=o;return n||(n=new ho(e,{...t,_requestHandler:void 0})),r(i,(t=>e(t,s)),n)}})():e,this.assets=new Tn(this,this.#c),this.datasets=new Gn(this,this.#c),this.live=new Wn(this),this.mediaLibrary={video:new Xn(this,this.#c)},this.projects=new eo(this,this.#c),this.users=new co(this,this.#c),this.agent={action:new $n(this,this.#c)},this.releases=new io(this,this.#c)}clone(){return new lo(this.#l,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=Tr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new lo(this.#l,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Kr(this,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){if(!0===t?.includeAllVersions)return Zr(this,this.#c,e,{...t,includeAllVersions:!0});const r={signal:t?.signal,tag:t?.tag,releaseId:t?.releaseId,...t&&"includeAllVersions"in t?{includeAllVersions:!1}:{}};return Zr(this,this.#c,e,r)}getDocuments(e,t){return en(this,this.#c,e,t)}documentsExists(e,t){return tn(this,this.#c,e,t)}create(e,t){return yn(this,this.#c,e,"create",t)}createIfNotExists(e,t){return nn(this,this.#c,e,t)}createOrReplace(e,t){return on(this,this.#c,e,t)}createVersion({document:e,publishedId:t,releaseId:r,baseId:n,ifBaseRevisionId:o},s){if(!e)return an(this,this.#c,t,n,r,o,s);const i=oo("createVersion",{document:e,publishedId:t,releaseId:r}),a={...e,_id:i},c=t||Ut(e._id);return sn(this,this.#c,a,c,s)}delete(e,t){return cn(this,this.#c,e,t)}discardVersion({releaseId:e,publishedId:t},r,n){const o=no(t,e);return un(this,this.#c,o,r,n)}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=oo("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return ln(this,this.#c,s,n)}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ft(t,e);return dn(this,this.#c,n,t,r)}mutate(e,t){return hn(this,this.#c,e,t)}patch(e,t){return new zr(e,t,this)}transaction(e){return new Gr(e,this)}action(e,t){return pn(this,this.#c,e,t)}request(e){return wn(this,this.#c,e)}getUrl(e,t){return En(this,e,t)}getDataUrl(e,t){return Cn(this,e,t)}}class ho{assets;datasets;live;mediaLibrary;projects;users;agent;releases;observable;#u;#l;#c;listen=zn;constructor(e,t=_r){this.config(t),this.#l=e;const r=t._requestHandler;this.#c=r?(()=>{let n;return(o,s)=>{const i=o;return n||(n=new ho(e,{...t,_requestHandler:void 0})),r(i,(t=>e(t,s)),n)}})():e,this.assets=new On(this,this.#c),this.datasets=new Jn(this,this.#c),this.live=new Wn(this),this.mediaLibrary={video:new Kn(this,this.#c)},this.projects=new to(this,this.#c),this.users=new uo(this,this.#c),this.agent={action:new Sn(this,this.#c)},this.releases=new ao(this,this.#c),this.observable=new lo(e,t)}clone(){return new ho(this.#l,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=Tr(e,this.#u||{}),this}withConfig(e){const t=this.config();return new ho(this.#l,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Ze(Kr(this,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){if(!0===t?.includeAllVersions)return Ze(Zr(this,this.#c,e,{...t,includeAllVersions:!0}));const r={signal:t?.signal,tag:t?.tag,releaseId:t?.releaseId,...t&&"includeAllVersions"in t?{includeAllVersions:!1}:{}};return Ze(Zr(this,this.#c,e,r))}getDocuments(e,t){return Ze(en(this,this.#c,e,t))}documentsExists(e,t){return Ze(tn(this,this.#c,e,t))}create(e,t){return Ze(yn(this,this.#c,e,"create",t))}createIfNotExists(e,t){return Ze(nn(this,this.#c,e,t))}createOrReplace(e,t){return Ze(on(this,this.#c,e,t))}createVersion({document:e,publishedId:t,releaseId:r,baseId:n,ifBaseRevisionId:o},s){if(!e)return et(an(this,this.#c,t,n,r,o,s));const i=oo("createVersion",{document:e,publishedId:t,releaseId:r}),a={...e,_id:i},c=t||Ut(e._id);return et(sn(this,this.#c,a,c,s))}delete(e,t){return Ze(cn(this,this.#c,e,t))}discardVersion({releaseId:e,publishedId:t},r,n){const o=no(t,e);return Ze(un(this,this.#c,o,r,n))}replaceVersion({document:e,publishedId:t,releaseId:r},n){const o=oo("replaceVersion",{document:e,publishedId:t,releaseId:r}),s={...e,_id:o};return et(ln(this,this.#c,s,n))}unpublishVersion({releaseId:e,publishedId:t},r){const n=Ft(t,e);return Ze(dn(this,this.#c,n,t,r))}mutate(e,t){return Ze(hn(this,this.#c,e,t))}patch(e,t){return new Hr(e,t,this)}transaction(e){return new Br(e,this)}action(e,t){return Ze(pn(this,this.#c,e,t))}request(e){return Ze(wn(this,this.#c,e))}dataRequest(e,t,r){return Ze(fn(this,this.#c,e,t,r))}getUrl(e,t){return En(this,e,t)}getDataUrl(e,t){return Cn(this,e,t)}}const po=(vo=ho,{requester:rr(bo=[]),createClient:e=>{const t=rr(bo,{ignoreWarnings:e.ignoreWarnings});return new vo(((r,n)=>(n||t)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,lineage:e.lineage,...r})),e)}}),fo=po.requester,yo=po.createClient,go=(mo=yo,function(e){return Rr(),mo(e)});var mo,bo,vo;const wo=/_key\s*==\s*['"](.*)['"]/;function Co(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?wo.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 Eo={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},Io={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function Ro(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=>Io[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=>Io[e]));t.push(e)}return t}function qo(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 xo(e){return 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)}`)}))}function _o(e,t){if(!t?.mappings)return;const r=`$${xo(e).map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Eo[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Eo[e]))}')]`:`[${e._index}]`)).join("")}`;if(void 0!==t.mappings[r])return{mapping:t.mappings[r],matchedPath:r,pathSuffix:""};const n=function(e){return e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Eo[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Eo[e]))}')]`:`[${e._index}]`))}(xo(e));for(let e=n.length-1;e>=0;e--){const o=`$${n.slice(0,e).join("")}`,s=t.mappings[o];if(s){return{mapping:s,matchedPath:o,pathSuffix:r.substring(o.length)}}}}function $o(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(vt(e)){const o=e._key;if("string"==typeof o)return $o(e,t,r.concat({_key:o,_index:n}))}return $o(e,t,r.concat(n))}));if(vt(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=$o(e.children,t,r.concat("children")):"span"===e._type&&(n.text=$o(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,$o(n,t,r.concat(e))])))}return t(e,r)}function So(e,t,r){return $o(e,((e,n)=>{if("string"!=typeof e)return e;const o=_o(n,t);if(!o)return e;const{mapping:s,matchedPath:i}=o;if("value"!==s.type||"documentValue"!==s.source.type)return e;const a=t.documents[s.source.document],c=t.paths[s.source.path],u=Ro(i),l=Ro(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const To=".",Oo=`drafts${To}`,jo=`versions${To}`;function Ao(e){return e.startsWith(Oo)}function Po(e){return e.startsWith(jo)}function ko(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:c}=e;if(!t)throw new Error("baseUrl is required");if(!i)throw new Error("path is required");if(!o)throw new Error("id is required");if("/"!==t&&t.endsWith("/"))throw new Error("baseUrl must not end with a slash");const u="default"===r?void 0:r,l="default"===n?void 0:n,d=function(e){return Po(e)?e.split(To).slice(2).join(To):Ao(e)?e.slice(Oo.length):e}(o),h=Array.isArray(i)?Co(qo(i)):i,p=new URLSearchParams({baseUrl:t,id:d,type:s,path:h});if(u&&p.set("workspace",u),l&&p.set("tool",l),a&&p.set("projectId",a),c&&p.set("dataset",c),function(e){return!Ao(e)&&!Po(e)}(o))p.set("perspective","published");else if(Po(o)){const e=function(e){if(!Po(e))return;const[t,r]=e.split(To);return r}(o);p.set("perspective",e)}const f=["/"===t?"":t];u&&f.push(u);const y=["mode=presentation",`id=${d}`,`type=${s}`,`path=${encodeURIComponent(h)}`];return l&&y.push(`tool=${l}`),f.push("intent","edit",`${y.join(";")}?${p}`),f.join("/")}const Do=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{const{protocol:t}=new URL(e,e.startsWith("/")?"https://acme.com":void 0);return Mo.has(t)||t.startsWith("web+")}catch{return!1}}(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))||Uo(e)||Uo(t)||"string"==typeof o&&Fo.has(o))},Fo=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"]);const Mo=new Set(["app:","data:","discord:","file:","ftp:","ftps:","geo:","http:","https:","imap:","javascript:","magnet:","mailto:","maps:","ms-excel:","ms-powerpoint:","ms-word:","slack:","sms:","spotify:","steam:","teams:","tel:","vscode:","zoom:"]);function Uo(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function No(e,t,r){const{filter:n,logger:o,enabled:s}=r;if(!s){const n="config.enabled must be true, don't call this function otherwise";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}if(!t)return o?.error?.("[@sanity/client]: Missing Content Source Map from response body",{result:e,resultSourceMap:t,config:r}),e;if(!r.studioUrl){const n="config.studioUrl must be defined";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const i={encoded:[],skipped:[]},a=So(e,t,(({sourcePath:e,sourceDocument:t,resultPath:s,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:s,filterDefault:Do,sourceDocument:t,value:a}):Do({sourcePath:e,resultPath:s,value:a})))return o&&i.skipped.push({path:Lo(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&i.encoded.push({path:Lo(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:d,_type:h,_projectId:p,_dataset:f}=t;return _t(a,{origin:"sanity.io",href:ko({baseUrl:c,workspace:u,tool:l,id:d,type:h,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:p}})},!1)}));if(o){const e=i.skipped.length,t=i.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${i.encoded.length}, skipped: ${i.skipped.length}`)),i.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(i.encoded)),i.skipped.length>0){const e=new Set;for(const{path:t}of i.skipped)e.add(t.replace(wo,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function Lo(e){return Co(qo(e))}var zo=Object.freeze({__proto__:null,stegaEncodeSourceMap:No}),Ho=Object.freeze({__proto__:null,encodeIntoResult:So,stegaEncodeSourceMap:No,stegaEncodeSourceMap$1:zo});function Vo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wo,Bo,Go,Jo={exports:{}},Qo=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 Yo(){return Wo||(Wo=1,function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,d=r.fetch,h=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==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=d;d=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 m(){this.bitsNeeded=0,this.codePoint=0}m.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==s&&(c<128||c>191||!t(i<<6|63&c,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(c>=0&&c<=127?(s=0,i=c):c>=192&&c<=223?(s=6,i=31&c):c>=224&&c<=239?(s=12,i=15&c):c>=240&&c<=247?(s=18,i=7&c):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&c),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=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=m);var b=function(){};function v(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function I(e){this._headers=e}function R(){}function x(){this._listeners=Object.create(null)}function _(e){n((function(){throw e}),0)}function q(e){this.type=e,this.target=void 0}function $(e,t){q.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function S(e,t){q.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function T(e,t){q.call(this,e),this.error=t.error}v.prototype.open=function(e,t){this._abort(!0);var r=this,i=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,i.onload=b,i.onerror=b,i.onabort=b,i.onprogress=b,i.onreadystatechange=b,i.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 i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},d=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()}},h=function(){c=n((function(){h()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){d("load",e)}),"onerror"in i&&(i.onerror=function(e){d("error",e)}),"onabort"in i&&(i.onabort=function(e){d("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||d(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&u())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(c=n((function(){h()}),0))},v.prototype.abort=function(){this._abort(!1)},v.prototype.getResponseHeader=function(e){return this._contentType},v.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},v.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},v.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==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!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var 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===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},I.prototype.get=function(e){return this._headers.get(e)},R.prototype.open=function(e,t,r,n,o,s,i){var a=null,c=new y,u=c.signal,h=new p;return d(o,{headers:i,credentials:s?"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=h.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){_(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,s=0;s<n.length;s+=1)n[s]===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=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},$.prototype=Object.create(q.prototype),S.prototype=Object.create(q.prototype),T.prototype=Object.create(q.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),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){_(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=k(1e3),l=P(r.heartbeatTimeout,45e3),d="",h=u,p=!1,f=0,y=r.headers||{},g=r.Transport,m=M&&null==g?void 0:new v(null!=g?new g:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),b=null!=g&&"string"!=typeof g?new g:null==m?new R:new E,w=void 0,C=0,I=O,x="",_="",q="",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(),h=u,e.readyState=1;var s=new S("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),D(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",W();s=new S("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),D(e,e.onerror,s),console.error(i)}},H=function(t){if(1===I){for(var r=-1,s=0;s<t.length;s+=1){(c=t.charCodeAt(s))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=s)}var i=(-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<i.length;a+=1){var c=i.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=i.slice(N,L-1),g=i.slice(L+(L<a&&i.charCodeAt(L)===" ".charCodeAt(0)?1:0),a);"data"===y?(x+="\n",x+=g):"id"===y?_=g:"event"===y?q=g:"retry"===y?(u=P(g,u),h=u):"heartbeatTimeout"===y&&(l=P(g,l),0!==C&&(o(C),C=n((function(){B()}),l)))}if(0===U){if(""!==x){d=_,""===q&&(q="message");var m=new $(q,{data:x.slice(1),lastEventId:_});if(e.dispatchEvent(m),"open"===q?D(e,e.onopen,m):"message"===q?D(e,e.onmessage,m):"error"===q&&D(e,e.onerror,m),2===I)return}x="",q=""}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(){B()}),h),h=k(Math.min(16*u,2*h)),e.readyState=0;var r=new T("error",{error:t});e.dispatchEvent(r),D(e,e.onerror,r),null!=t&&console.error(t)}},W=function(){I=2,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=2},B=function(){if(C=0,I===O){p=!1,f=0,C=n((function(){B()}),l),I=0,x="",q="",_=d,F="",N=0,L=0,U=0;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==d){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(d)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(i[u]=a[u]);try{w=b.open(m,z,H,V,r,s,i)}catch(e){throw W(),e}}else if(p||null==w){var h=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){B()}),h)}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=W,B()}(this,e,t)}var M=null!=d&&null!=h&&"body"in h.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==s||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:Qo:globalThis)}(Jo,Jo.exports)),Jo.exports}function Xo(){return Go?Bo:(Go=1,Bo=Yo().EventSourcePolyfill)}var Ko=Vo(Xo()),Zo=Object.freeze({__proto__:null,default:Ko});e.BasePatch=Lr,e.BaseTransaction=Wr,e.ChannelError=Ar,e.ClientError=Vt,e.ConnectionFailedError=Or,e.CorsOriginError=Zt,e.DisconnectError=jr,e.EXPERIMENTAL_API_WARNING="This is an experimental API version",e.MessageError=Pr,e.MessageParseError=kr,e.ObservablePatch=zr,e.ObservableSanityClient=lo,e.ObservableTransaction=Gr,e.Patch=Hr,e.SanityClient=ho,e.ServerError=Wt,e.Transaction=Br,e.connectEventSource=Fr,e.createClient=yo,e.default=go,e.formatQueryParseError=Jt,e.isHttpError=function(e){if(!vt(e))return!1;const t=e.response;return!("number"!=typeof e.statusCode||"string"!=typeof e.message||!vt(t)||typeof t.body>"u"||"string"!=typeof t.url||"string"!=typeof t.method||"object"!=typeof t.headers||"number"!=typeof t.statusCode)},e.isQueryParseError=Gt,e.requester=fo,e.unstable__adapter=g,e.unstable__environment="browser",e.validateApiPerspective=Sr,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
6
|
+
*/function Yo(){return Wo||(Wo=1,function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,d=r.fetch,h=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==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=d;d=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 m(){this.bitsNeeded=0,this.codePoint=0}m.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==s&&(c<128||c>191||!t(i<<6|63&c,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(c>=0&&c<=127?(s=0,i=c):c>=192&&c<=223?(s=6,i=31&c):c>=224&&c<=239?(s=12,i=15&c):c>=240&&c<=247?(s=18,i=7&c):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&c),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=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=m);var b=function(){};function v(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function I(e){this._headers=e}function R(){}function q(){this._listeners=Object.create(null)}function x(e){n((function(){throw e}),0)}function _(e){this.type=e,this.target=void 0}function $(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}v.prototype.open=function(e,t){this._abort(!0);var r=this,i=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,i.onload=b,i.onerror=b,i.onabort=b,i.onprogress=b,i.onreadystatechange=b,i.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 i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},d=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()}},h=function(){c=n((function(){h()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){d("load",e)}),"onerror"in i&&(i.onerror=function(e){d("error",e)}),"onabort"in i&&(i.onabort=function(e){d("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||d(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&u())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(c=n((function(){h()}),0))},v.prototype.abort=function(){this._abort(!1)},v.prototype.getResponseHeader=function(e){return this._contentType},v.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},v.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},v.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==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!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var 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===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},I.prototype.get=function(e){return this._headers.get(e)},R.prototype.open=function(e,t,r,n,o,s,i){var a=null,c=new y,u=c.signal,h=new p;return d(o,{headers:i,credentials:s?"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=h.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()}}},q.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){x(e)}}},q.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},q.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},$.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),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){x(e)}};function F(e,t){q.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),d="",h=u,p=!1,f=0,y=r.headers||{},g=r.Transport,m=M&&null==g?void 0:new v(null!=g?new g:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),b=null!=g&&"string"!=typeof g?new g:null==m?new R:new E,w=void 0,C=0,I=O,q="",x="",_="",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(),h=u,e.readyState=1;var s=new S("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),D(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",W();s=new S("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),D(e,e.onerror,s),console.error(i)}},H=function(t){if(1===I){for(var r=-1,s=0;s<t.length;s+=1){(c=t.charCodeAt(s))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=s)}var i=(-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<i.length;a+=1){var c=i.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=i.slice(N,L-1),g=i.slice(L+(L<a&&i.charCodeAt(L)===" ".charCodeAt(0)?1:0),a);"data"===y?(q+="\n",q+=g):"id"===y?x=g:"event"===y?_=g:"retry"===y?(u=P(g,u),h=u):"heartbeatTimeout"===y&&(l=P(g,l),0!==C&&(o(C),C=n((function(){B()}),l)))}if(0===U){if(""!==q){d=x,""===_&&(_="message");var m=new $(_,{data:q.slice(1),lastEventId:x});if(e.dispatchEvent(m),"open"===_?D(e,e.onopen,m):"message"===_?D(e,e.onmessage,m):"error"===_&&D(e,e.onerror,m),2===I)return}q="",_=""}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(){B()}),h),h=k(Math.min(16*u,2*h)),e.readyState=0;var r=new T("error",{error:t});e.dispatchEvent(r),D(e,e.onerror,r),null!=t&&console.error(t)}},W=function(){I=2,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=2},B=function(){if(C=0,I===O){p=!1,f=0,C=n((function(){B()}),l),I=0,q="",_="",x=d,F="",N=0,L=0,U=0;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==d){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(d)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(i[u]=a[u]);try{w=b.open(m,z,H,V,r,s,i)}catch(e){throw W(),e}}else if(p||null==w){var h=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){B()}),h)}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=W,B()}(this,e,t)}var M=null!=d&&null!=h&&"body"in h.prototype;F.prototype=Object.create(q.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==s||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:Qo:globalThis)}(Jo,Jo.exports)),Jo.exports}function Xo(){return Go?Bo:(Go=1,Bo=Yo().EventSourcePolyfill)}var Ko=Vo(Xo()),Zo=Object.freeze({__proto__:null,default:Ko});e.BasePatch=Lr,e.BaseTransaction=Wr,e.ChannelError=Ar,e.ClientError=Vt,e.ConnectionFailedError=Or,e.CorsOriginError=Zt,e.DisconnectError=jr,e.EXPERIMENTAL_API_WARNING="This is an experimental API version",e.MessageError=Pr,e.MessageParseError=kr,e.ObservablePatch=zr,e.ObservableSanityClient=lo,e.ObservableTransaction=Gr,e.Patch=Hr,e.SanityClient=ho,e.ServerError=Wt,e.Transaction=Br,e.connectEventSource=Fr,e.createClient=yo,e.default=go,e.formatQueryParseError=Jt,e.isHttpError=function(e){if(!vt(e))return!1;const t=e.response;return!("number"!=typeof e.statusCode||"string"!=typeof e.message||!vt(t)||typeof t.body>"u"||"string"!=typeof t.url||"string"!=typeof t.method||"object"!=typeof t.headers||"number"!=typeof t.statusCode)},e.isQueryParseError=Gt,e.requester=fo,e.unstable__adapter=g,e.unstable__environment="browser",e.validateApiPerspective=Sr,Object.defineProperty(e,"__esModule",{value:!0})}));
|