UNPKG

@sanity/client

Version:

Client for retrieving, creating and patching data from Sanity.io

1 lines 104 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}const r=!(typeof navigator>"u")&&"ReactNative"===navigator.product,n={timeout:r?6e4:12e4},o=function(e){const t={...n,..."string"==typeof e?{url:e}:e};if(t.timeout=i(t.timeout),t.query){const{url:e,searchParams:n}=function(e){const t=e.indexOf("?");if(-1===t)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,t),o=e.slice(t+1);if(!r)return{url:n,searchParams:new URLSearchParams(o)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const i=new URLSearchParams;for(const e of o.split("&")){const[t,r]=e.split("=");t&&i.append(s(t),s(r||""))}return{url:n,searchParams:i}}(t.url);for(const[r,o]of Object.entries(t.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)n.append(r,e);else n.append(r,o);const s=n.toString();s&&(t.url=`${e}?${s}`)}}return t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t};function s(e){return decodeURIComponent(e.replace(/\+/g," "))}function i(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?i(n.timeout):{connect:t,socket:t}}const a=/^https?:\/\//i,c=function(e){if(!a.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const l=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const r=[],n=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[o],validateOptions:[c]});function s(e){const r=l.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),o=(e=>function(t,r,...n){const o="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...n),!o||s);r++);return s})(n),s=o("processOptions",e);o("validateOptions",s);const i={options:s,channels:r,applyMiddleware:o};let a;const c=r.request.subscribe((e=>{a=t(e,((t,n)=>((e,t,n)=>{let s=e,i=t;if(!s)try{i=o("onResponse",t,n)}catch(e){i=null,s=e}s=s&&o("onError",s,n),s?r.error.publish(s):i&&r.response.publish(i)})(t,n,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=o("onReturn",r,i);return u===r&&r.request.publish(i),u}return s.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&n.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return h.forEach((t=>{e[t]&&n[t].push(e[t])})),r.push(e),s},s.clone=()=>d(r,t),e.forEach(s.use),s}var p,f,y=u(function(){if(f)return p;f=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return p=function(t){if(!t)return{};for(var r={},n=e(t).split("\n"),o=0;o<n.length;o++){var s=n[o],i=s.indexOf(":"),a=e(s.slice(0,i)).toLowerCase(),c=e(s.slice(i+1));typeof r[a]>"u"?r[a]=c:(u=r[a],"[object Array]"===Object.prototype.toString.call(u)?r[a].push(c):r[a]=[r[a],c])}var u;return r}}());let g=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 b="function"==typeof XMLHttpRequest?"xhr":"fetch",v="xhr"===b?XMLHttpRequest:g,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:b,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new v;i instanceof g&&"object"==typeof n.fetch&&i.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,h=!1;if(i.onerror=e=>{f(i instanceof g?e instanceof Error?e:new Error(`Request error while attempting to reach is ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.ontimeout=e=>{f(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.onabort=()=>{p(!0),u=!0},i.onreadystatechange=function(){c&&(p(),o.socket=setTimeout((()=>d("ESOCKETTIMEDOUT")),c.socket)),!u&&i&&4===i.readyState&&0!==i.status&&function(){if(!(u||l||h)){if(0===i.status)return void f(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:i.response||(""===i.responseType||"text"===i.responseType?i.responseText:""),url:n.url,method:n.method,headers:y(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}}()},i.open(n.method,n.url,!0),i.withCredentials=!!n.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return n.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:b,request:i,context:e}),i.send(n.body||null),c&&(o.connect=setTimeout((()=>d("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,i&&i.abort()}};function d(t){h=!0,i.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function p(e){(e||u||i&&i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function f(e){if(l)return;p(!0),l=!0,i=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},w=(e=[],t=m)=>d(e,t);var C,E,I,_,x,R={exports:{}};x||(x=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if(typeof window<"u"&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(_?I:(_=1,I=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,o=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,s=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=function(){if(E)return C;E=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return C=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(s){if(!((s=String(s)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=r?s(c,u,r,"hour"):u>=t?s(c,u,t,"minute"):u>=e?s(c,u,e,"second"):c+" ms"):function(o){var s=Math.abs(o);return s>=n?Math.round(o/n)+"d":s>=r?Math.round(o/r)+"h":s>=t?Math.round(o/t)+"m":s>=e?Math.round(o/e)+"s":o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(R,R.exports));const q=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function $(e){return"[object Object]"===Object.prototype.toString.call(e)}const S=["boolean","string","number"];function T(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||q(t)||-1===S.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 O(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let j={};typeof globalThis<"u"?j=globalThis:typeof window<"u"?j=window:typeof global<"u"?j=global:typeof self<"u"&&(j=self);var A=j;function P(e={}){const t=e.implementation||A.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,r)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(r),()=>e.abort.publish())))}}var D=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function k(e){return 100*Math.pow(2,e)+100*Math.random()}const F=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||k,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,c=s.shouldRetry||n,u=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,s)||u>=i)return e;var l;const h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(h)),a(u)),null}}})({shouldRetry:D,...e});F.shouldRetry=D;var M=function(e,t){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},M(e,t)};function U(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}M(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function N(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function L(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 z(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function H(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function V(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function B(e){return this instanceof B?(this.v=e,this):new B(e)}function W(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof B?Promise.resolve(e.value.v).then(c,u):l(s[0][2],e)}(o[e](t))}catch(e){l(s[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function G(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=z(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function J(e){return"function"==typeof e}function Q(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var Y=Q((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function X(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var K=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=z(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(J(c))try{c()}catch(e){o=e instanceof Y?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=z(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{te(d)}catch(e){o=null!=o?o:[],e instanceof Y?o=V(V([],H(o)),H(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new Y(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)te(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&X(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&X(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),Z=K.EMPTY;function ee(e){return e instanceof K||e&&"closed"in e&&J(e.remove)&&J(e.add)&&J(e.unsubscribe)}function te(e){J(e)?e():e.unsubscribe()}var re={Promise:void 0},ne=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,V([e,t],H(r)))};function oe(e){ne((function(){throw e}))}function se(){}function ie(e){e()}var ae=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ee(t)&&t.add(r)):r.destination=he,r}return U(t,e),t.create=function(e,t,r){return new ue(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(K),ce=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){le(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){le(e)}else le(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){le(e)}},e}(),ue=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=J(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new ce(o),s}return U(t,e),t}(ae);function le(e){oe(e)}var he={closed:!0,next:se,error:function(e){throw e},complete:se},de="function"==typeof Symbol&&Symbol.observable||"@@observable";function pe(e){return e}function fe(e){return 0===e.length?pe:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ye=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof ae||function(e){return e&&J(e.next)&&J(e.error)&&J(e.complete)}(n)&&ee(n)?e:new ue(e,t,r);return ie((function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=ge(t))((function(t,n){var o=new ue({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[de]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ge(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function ge(e){var t;return null!==(t=null!=e?e:re.Promise)&&void 0!==t?t:Promise}function be(e){return function(t){if(function(e){return J(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function ve(e,t,r,n,o){return new me(e,t,r,n,o)}var me=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return U(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(ae),we=Q((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Ce=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return U(t,e),t.prototype.lift=function(e){var t=new Ee(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new we},t.prototype.next=function(e){var t=this;ie((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=z(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;ie((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;ie((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,s=r.observers;return n||o?Z:(this.currentObservers=null,s.push(e),new K((function(){t.currentObservers=null,X(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new ye;return e.source=this,e},t.create=function(e,t){return new Ee(e,t)},t}(ye),Ee=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return U(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:Z},t}(Ce),Ie={now:function(){return(Ie.delegate||Date).now()},delegate:void 0},_e=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Ie);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=r,o._timestampProvider=n,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,r),o}return U(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,i=r._timestampProvider,a=r._windowTime;n||(o.push(t),!s&&o.push(i.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,s=(o?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!o){for(var i=r.now(),a=0,c=1;c<n.length&&n[c]<=i;c+=2)a=c;a&&n.splice(0,a+1)}},t}(Ce),xe=function(e){function t(t,r){return e.call(this)||this}return U(t,e),t.prototype.schedule=function(e,t){return this},t}(K),Re=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,V([e,t],H(r)))},qe=function(e){return clearInterval(e)},$e=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return U(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,o=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(o,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),Re(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&qe(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,X(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(xe),Se=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Ie.now,e}(),Te=new(function(e){function t(t,r){void 0===r&&(r=Se.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return U(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(Se))($e),Oe=new ye((function(e){return e.complete()}));function je(e){return e[e.length-1]}function Ae(e){return(t=je(e))&&J(t.schedule)?e.pop():void 0;var t}var Pe=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function De(e){return J(null==e?void 0:e.then)}function ke(e){return J(e[de])}function Fe(e){return Symbol.asyncIterator&&J(null==e?void 0:e[Symbol.asyncIterator])}function Me(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Ue="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ne(e){return J(null==e?void 0:e[Ue])}function Le(e){return W(this,arguments,(function(){var t,r,n;return L(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,B(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,B(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,B(n)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function ze(e){return J(null==e?void 0:e.getReader)}function He(e){if(e instanceof ye)return e;if(null!=e){if(ke(e))return o=e,new ye((function(e){var t=o[de]();if(J(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Pe(e))return n=e,new ye((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(De(e))return r=e,new ye((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,oe)}));if(Fe(e))return Ve(e);if(Ne(e))return t=e,new ye((function(e){var r,n;try{for(var o=z(t),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(ze(e))return Ve(Le(e))}var t,r,n,o;throw Me(e)}function Ve(e){return new ye((function(t){(function(e,t){var r,n,o,s;return N(this,void 0,void 0,(function(){var i,a;return L(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=G(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Be(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),be((function(r,n){r.subscribe(ve(n,(function(r){return Be(n,e,(function(){return n.next(r)}),t)}),(function(){return Be(n,e,(function(){return n.complete()}),t)}),(function(r){return Be(n,e,(function(){return n.error(r)}),t)})))}))}function Ge(e,t){return void 0===t&&(t=0),be((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function Je(e,t){if(!e)throw new Error("Iterable cannot be null");return new ye((function(r){Be(r,t,(function(){var n=e[Symbol.asyncIterator]();Be(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function Qe(e,t){if(null!=e){if(ke(e))return function(e,t){return He(e).pipe(Ge(t),We(t))}(e,t);if(Pe(e))return function(e,t){return new ye((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(De(e))return function(e,t){return He(e).pipe(Ge(t),We(t))}(e,t);if(Fe(e))return Je(e,t);if(Ne(e))return function(e,t){return new ye((function(r){var n;return Be(r,t,(function(){n=e[Ue](),Be(r,t,(function(){var e,t,o;try{t=(e=n.next()).value,o=e.done}catch(e){return void r.error(e)}o?r.complete():r.next(t)}),0,!0)})),function(){return J(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(ze(e))return function(e,t){return Je(Le(e),t)}(e,t)}throw Me(e)}function Ye(e,t){return t?Qe(e,t):He(e)}function Xe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ye(e,Ae(e))}function Ke(e,t){var r=J(e)?e:function(){return e};return new ye((function(e){return e.error(r())}))}var Ze=Q((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function et(e,t){return new Promise((function(t,r){var n,o=!1;e.subscribe({next:function(e){n=e,o=!0},error:r,complete:function(){o?t(n):r(new Ze)}})}))}function tt(e,t){return new Promise((function(t,r){var n=new ue({next:function(e){t(e),n.unsubscribe()},error:r,complete:function(){r(new Ze)}});e.subscribe(n)}))}function rt(e,t){return be((function(r,n){var o=0;r.subscribe(ve(n,(function(r){n.next(e.call(t,r,o++))})))}))}var nt=Array.isArray;function ot(e){return rt((function(t){return function(e,t){return nt(t)?e.apply(void 0,V([],H(t))):e(t)}(e,t)}))}function st(e,t,r){t()}function it(e,t,r){return void 0===r&&(r=1/0),J(t)?it((function(r,n){return rt((function(e,o){return t(r,e,n,o)}))(He(e(r,n)))}),r):("number"==typeof t&&(r=t),be((function(t,n){return function(e,t,r,n,o,s,i){var a=[],c=0,u=0,l=!1,h=function(){!l||a.length||c||t.complete()},d=function(e){c++;var o=!1;He(r(e,u++)).subscribe(ve(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{for(c--;a.length&&c<n;)e=void 0,e=a.shift(),i||d(e);h()}catch(e){t.error(e)}var e})))};return e.subscribe(ve(t,(function(e){return c<n?d(e):a.push(e)}),(function(){l=!0,h()}))),function(){}}(t,n,e,r)})))}function at(e){return void 0===e&&(e=1/0),it(pe,e)}function ct(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return at(1)(Ye(e,Ae(e)))}function ut(e){return new ye((function(t){He(e()).subscribe(t)}))}function lt(e,t,r){return void 0===r&&(r=Te),new ye((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?1e3-r.now():e;o<0&&(o=0);var s=0;return r.schedule((function(){t.closed||(t.next(s++),t.complete())}),o)}))}function ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Ae(e),n=function(e,t){return"number"==typeof je(e)?e.pop():t}(e,1/0),o=e;return o.length?1===o.length?He(o[0]):at(n)(Ye(o,r)):Oe}var dt=Array.isArray;function pt(e,t){return be((function(r,n){var o=0;r.subscribe(ve(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function ft(e){return be((function(t,r){var n,o=null,s=!1;o=t.subscribe(ve(r,void 0,void 0,(function(i){n=He(e(i,ft(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):s=!0}))),s&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function yt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return J(je(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fe(e)}(yt.apply(void 0,V([],H(e))),ot(r)):be((function(t,r){var n,o,s;(n=V([t],H(function(e){return 1===e.length&&dt(e[0])?e[0]:e}(e))),void 0===s&&(s=pe),function(e){st(0,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,c=function(t){st(0,(function(){var c=Ye(n[t],o),u=!1;c.subscribe(ve(e,(function(n){r[t]=n,u||(u=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}))},u=0;u<t;u++)c(u)}))})(r)}))}function gt(e){return be((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}function bt(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new Ce}:t,n=e.resetOnError,o=void 0===n||n,s=e.resetOnComplete,i=void 0===s||s,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,s,a=0,u=!1,l=!1,h=function(){null==n||n.unsubscribe(),n=void 0},d=function(){h(),t=s=void 0,u=l=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return be((function(e,f){a++,l||u||h();var y=s=null!=s?s:r();f.add((function(){0!==--a||l||u||(n=vt(p,c))})),y.subscribe(f),!t&&a>0&&(t=new ue({next:function(e){return y.next(e)},error:function(e){l=!0,h(),n=vt(d,o,e),y.error(e)},complete:function(){u=!0,h(),n=vt(d,i),y.complete()}}),He(e).subscribe(t))}))(e)}}function vt(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var o=new ue({next:function(){o.unsubscribe(),e()}});return He(t.apply(void 0,V([],H(r)))).subscribe(o)}}else e()}function mt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var wt={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},Ct={0:8203,1:8204,2:8205,3:65279},Et=new Array(4).fill(String.fromCodePoint(Ct[0])).join("");function It(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!(!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e)||!Date.parse(e))}(e)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(e))?e:`${e}${function(e){let t=JSON.stringify(e);return`${Et}${Array.from(t).map((e=>{let r=e.charCodeAt(0);if(r>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${t} on character ${e} (${r})`);return Array.from(r.toString(4).padStart(4,"0")).map((e=>String.fromCodePoint(Ct[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Ct).map((e=>e.reverse()))),Object.fromEntries(Object.entries(wt).map((e=>e.reverse())));var _t=`${Object.values(wt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,xt=new RegExp(`[${_t}]{4,}`,"gu");function Rt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(xt,""),encoded:(null==(t=e.match(xt))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}const qt=".",$t=`drafts${qt}`,St=`versions${qt}`;function Tt(e){return e.startsWith($t)}function Ot(e){return e.startsWith(St)}function jt(e,t){if("drafts"===t||"published"===t)throw new Error('Version can not be "published" or "drafts"');return`${St}${t}${qt}${Pt(e)}`}function At(e){if(!Ot(e))return;const[t,r,...n]=e.split(qt);return r}function Pt(e){return Ot(e)?e.split(qt).slice(2).join(qt):Tt(e)?e.slice($t.length):e}let Dt=e=>crypto.getRandomValues(new Uint8Array(e));const kt=/\r\n|[\n\r\u2028\u2029]/;function Ft(e,t,r){const n=e.split(kt),o={start:Mt(t.start,n),end:t.end?Mt(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),h=Math.min(t.length,c+s);-1===i&&(l=0),-1===c&&(h=t.length);const d=c-i,p={};if(d)for(let e=0;e<=d;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===d)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:h,markerLines:p}}(o,n),c=`${i}`.length;return e.split(kt,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 Mt(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 Ut extends Error{response;statusCode=400;responseBody;details;constructor(e,t){const r=Lt(e,t);super(r.message),Object.assign(this,r)}}class Nt extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=Lt(e);super(t.message),Object.assign(this,t)}}function Lt(e,t){const r=e.body,n={response:e,statusCode:e.statusCode,responseBody:Bt(r,e),message:"",details:void 0};if(!mt(r))return n.message=Vt(e,r),n;const o=r.error;if("string"==typeof o&&"string"==typeof r.message)return n.message=`${o} - ${r.message}`,n;if("object"!=typeof o||null===o)return"string"==typeof o?n.message=o:"string"==typeof r.message?n.message=r.message:n.message=Vt(e,r),n;if(function(e){return"type"in e&&"mutationError"===e.type&&"description"in e&&"string"==typeof e.description}(o)||function(e){return"type"in e&&"actionError"===e.type&&"description"in e&&"string"==typeof e.description}(o)){const e=o.items||[],t=e.slice(0,5).map((e=>e.error?.description)).filter(Boolean);let s=t.length?`:\n- ${t.join("\n- ")}`:"";return e.length>5&&(s+=`\n...and ${e.length-5} more`),n.message=`${o.description}${s}`,n.details=r.error,n}if(zt(o)){const e=t?.options?.query?.tag;return n.message=Ht(o,e),n.details=r.error,n}return"description"in o&&"string"==typeof o.description?(n.message=o.description,n.details=o,n):(n.message=Vt(e,r),n)}function zt(e){return mt(e)&&"queryParseError"===e.type&&"string"==typeof e.query&&"number"==typeof e.start&&"number"==typeof e.end}function Ht(e,t){const{query:r,start:n,end:o,description:s}=e;if(!r||typeof n>"u")return`GROQ query parse error: ${s}`;const i=t?`\n\nTag: ${t}`:"";return`GROQ query parse error:\n${Ft(r,{start:n,end:o},s)}${i}`}function Vt(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 Bt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class Wt extends Error{projectId;addOriginUrl;constructor({projectId:e}){super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e;const t=new URL(`https://sanity.io/manage/project/${e}/api`);if(typeof location<"u"){const{origin:e}=location;t.searchParams.set("cors","add"),t.searchParams.set("origin",e),this.addOriginUrl=t,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${t}`}else this.message=`The current origin is not allowed to connect to the Live Content API. Change your configuration here: ${t}`}}const Gt={onResponse:(e,t)=>{if(e.statusCode>=500)throw new Nt(e);if(e.statusCode>=400)throw new Ut(e,t);return e}};function Jt(){const e={};return{onResponse:t=>{const r=t.headers["x-sanity-warning"],n=Array.isArray(r)?r:[r];for(const t of n)!t||e[t]||(e[t]=!0,console.warn(t));return t}}}function Qt(e){return w([F({shouldRetry:Yt}),...e,Jt(),T(),O(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},Gt,P({implementation:ye})])}function Yt(e,t,r){if(0===r.maxRetries)return!1;const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||F.shouldRetry(e,t,r)}function Xt(e){return"https://www.sanity.io/help/"+e}const Kt=["image","file"],Zt=["before","after","replace"],er=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")},tr=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},rr=(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`)},nr=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);rr(e,t._id)},or=(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)},sr=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},ir=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e},ar=e=>{if(!e["~experimental_resource"])throw new Error("`resource` must be provided to perform resource queries");const{type:t,id:r}=e["~experimental_resource"];switch(t){case"dataset":if(2!==r.split(".").length)throw new Error('Dataset resource ID must be in the format "project.dataset"');return;case"dashboard":case"media-library":case"canvas":return;default:throw new Error(`Unsupported resource type: ${t.toString()}`)}},cr=(e,t)=>{if(t["~experimental_resource"])throw new Error(`\`${e}\` does not support resource-based operations`)};const ur=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),lr=ur(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),hr=ur(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),dr=ur(["The Sanity client is configured with the `perspective` set to `drafts` or `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),pr=ur(["The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"]),fr=ur(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Xt("js-client-browser-token")} for more information and how to hide this warning.`]),yr=ur(["You have configured Sanity client to use a token, but also provided `withCredentials: true`.","This is no longer supported - only token will be used - remove `withCredentials: true`."]),gr=ur(["Using the Sanity client without specifying an API version is deprecated.",`See ${Xt("js-client-api-version")}`]),br=ur(["The