@sanity/client 5.0.0-esm.9 → 5.1.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/README.md +186 -65
- package/dist/index.browser.cjs +117 -164
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +117 -165
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +118 -165
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +59 -58
- package/dist/index.js +118 -166
- package/dist/index.js.map +1 -1
- package/package.json +23 -24
- package/src/SanityClient.ts +23 -25
- package/src/assets/AssetsClient.ts +29 -5
- package/src/data/dataMethods.ts +54 -4
- package/src/data/encodeQueryString.ts +15 -14
- package/src/data/listen.ts +4 -4
- package/src/data/patch.ts +1 -13
- package/src/datasets/DatasetsClient.ts +1 -1
- package/src/generateHelpUrl.ts +1 -1
- package/src/http/errors.ts +3 -5
- package/src/http/request.ts +1 -1
- package/src/index.browser.ts +2 -0
- package/src/index.ts +2 -0
- package/src/migrationNotice.ts +9 -0
- package/src/projects/ProjectsClient.ts +1 -1
- package/src/types.ts +1 -0
- package/src/users/UsersClient.ts +1 -1
- package/src/warnings.ts +1 -1
- package/umd/sanityClient.js +146 -416
- package/umd/sanityClient.min.js +3 -3
- package/src/auth/AuthClient.ts +0 -67
package/umd/sanityClient.min.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SanityClient={})}(this,(function(t){"use strict";const e={timeout:"undefined"!=typeof navigator&&"ReactNative"===navigator.product?6e4:12e4};function r(t){const r="string"==typeof t?Object.assign({url:t},e):Object.assign({},e,t),o=new URL(r.url,"http://localhost");if(r.timeout=n(r.timeout),r.query)for(const[t,e]of Object.entries(r.query))if(void 0!==e)if(Array.isArray(e))for(const r of e)o.searchParams.append(t,r);else o.searchParams.append(t,e);return r.method=r.body&&!r.method?"POST":(r.method||"GET").toUpperCase(),r.url="http://localhost"===o.origin?"".concat(o.pathname,"?").concat(o.searchParams):o.toString(),r}function n(t){if(!1===t||0===t)return!1;if(t.connect||t.socket)return t;const r=Number(t);return isNaN(r)?n(e.timeout):{connect:r,socket:r}}const o=/^https?:\/\//i;function i(t){if(!o.test(t.url))throw new Error('"'.concat(t.url,'" is not a valid URL'))}var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=function(t){return t.replace(/^\s+|\s+$/g,"")},c=function(t){if(!t)return{};for(var e,r={},n=a(t).split("\n"),o=0;o<n.length;o++){var i=n[o],s=i.indexOf(":"),c=a(i.slice(0,s)).toLowerCase(),u=a(i.slice(s+1));void 0===r[c]?r[c]=u:(e=r[c],"[object Array]"===Object.prototype.toString.call(e)?r[c].push(u):r[c]=[r[c],u])}return r};const u=["request","response","progress","error","abort"],l=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function h(t,e){const n=[],o=l.reduce(((t,e)=>(t[e]=t[e]||[],t)),{processOptions:[r],validateOptions:[i]});function s(t){const r=u.reduce(((t,e)=>(t[e]=function(){const t=Object.create(null);let e=0;return{publish:function(e){for(const r in t)t[r](e)},subscribe:function(r){const n=e++;return t[n]=r,function(){delete t[n]}}}}(),t)),{}),n=(t=>function(e,r){const n="onError"===e;let o=r;for(var i=arguments.length,s=new Array(i>2?i-2:0),a=2;a<i;a++)s[a-2]=arguments[a];for(let r=0;r<t[e].length&&(o=(0,t[e][r])(o,...s),!n||o);r++);return o})(o),i=n("processOptions",t);n("validateOptions",i);const s={options:i,channels:r,applyMiddleware:n};let a=null;const c=r.request.subscribe((t=>{a=e(t,((e,o)=>function(t,e,o){let i=t,s=e;if(!i)try{s=n("onResponse",e,o)}catch(t){s=null,i=t}i=i&&n("onError",i,o),i?r.error.publish(i):s&&r.response.publish(s)}(e,o,t)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const l=n("onReturn",r,s);return l===r&&r.request.publish(s),l}return s.use=function(t){if(!t)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof t)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(t.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((e=>{t[e]&&o[e].push(t[e])})),n.push(t),s},s.clone=function(){return h(n,e)},t.forEach(s.use),s}var d,f,p,y,g,v=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},m=(t,e,r)=>(v(t,e,"read from private field"),r?r.call(t):e.get(t)),w=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},b=(t,e,r,n)=>(v(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);d=new WeakMap,f=new WeakMap,p=new WeakMap,y=new WeakMap,g=new WeakMap;const C="function"==typeof XMLHttpRequest?"xhr":"fetch",E="xhr"===C?XMLHttpRequest:class{constructor(){this.readyState=0,w(this,d,void 0),w(this,f,void 0),w(this,p,void 0),w(this,y,{}),w(this,g,void 0)}open(t,e,r){b(this,d,t),b(this,f,e),b(this,p,""),this.readyState=1,this.onreadystatechange(),b(this,g,void 0)}abort(){m(this,g)&&m(this,g).abort()}getAllResponseHeaders(){return m(this,p)}setRequestHeader(t,e){m(this,y)[t]=e}send(t){const e="arraybuffer"!==this.responseType,r={method:m(this,d),headers:m(this,y),signal:null,body:t};"function"==typeof AbortController&&(b(this,g,new AbortController),r.signal=m(this,g).signal),"undefined"!=typeof document&&(r.credentials=this.withCredentials?"include":"omit"),fetch(m(this,f),r).then((t=>(t.headers.forEach(((t,e)=>{b(this,p,m(this,p)+"".concat(e,": ").concat(t,"\r\n"))})),this.status=t.status,this.statusText=t.statusText,this.readyState=3,e?t.text():t.arrayBuffer()))).then((t=>{"string"==typeof t?this.responseText=t:this.response=t,this.readyState=4,this.onreadystatechange()})).catch((t=>{var e;"AbortError"!==t.name?null==(e=this.onerror)||e.call(this,t):this.onabort()}))}};var T=(t,e)=>{const r=t.options,n=t.applyMiddleware("finalizeOptions",r),o={},i=t.applyMiddleware("interceptRequest",void 0,{adapter:C,context:t});if(i){const t=setTimeout(e,0,null,i);return{abort:()=>clearTimeout(t)}}let s=new E;const a=n.headers,u=n.timeout;let l=!1,h=!1,d=!1;if(s.onerror=y,s.ontimeout=y,s.onabort=()=>{p(!0),l=!0},s.onreadystatechange=()=>{!function(){if(!u)return;p(),o.socket=setTimeout((()=>f("ESOCKETTIMEDOUT")),u.socket)}(),l||4!==s.readyState||0!==s.status&&function(){if(l||h||d)return;if(0===s.status)return void y(new Error("Unknown XHR error"));p(),h=!0,e(null,{body:s.response||s.responseText,url:n.url,method:n.method,headers:c(s.getAllResponseHeaders()),statusCode:s.status,statusMessage:s.statusText})}()},s.open(n.method,n.url,!0),s.withCredentials=!!n.withCredentials,a&&s.setRequestHeader)for(const t in a)a.hasOwnProperty(t)&&s.setRequestHeader(t,a[t]);return n.rawBody&&(s.responseType="arraybuffer"),t.applyMiddleware("onRequest",{options:n,adapter:C,request:s,context:t}),s.send(n.body||null),u&&(o.connect=setTimeout((()=>f("ETIMEDOUT")),u.connect)),{abort:function(){l=!0,s&&s.abort()}};function f(e){d=!0,s.abort();const r=new Error("ESOCKETTIMEDOUT"===e?"Socket timed out on request to ".concat(n.url):"Connection timed out on request to ".concat(n.url));r.code=e,t.channels.error.publish(r)}function p(t){(t||l||s.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function y(t){if(h)return;p(!0),h=!0,s=null;const r=t||new Error("Network error while attempting to reach ".concat(n.url));r.isNetworkError=!0,r.request=n,e(r)}};var x,O,_={};function S(){if(O)return x;O=1;var t=1e3,e=60*t,r=60*e,n=24*r,o=7*n,i=365.25*n;function s(t,e,r,n){var o=e>=1.5*r;return Math.round(t/r)+" "+n+(o?"s":"")}return x=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\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(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*e;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=n)return s(o,i,n,"day");if(i>=r)return s(o,i,r,"hour");if(i>=e)return s(o,i,e,"minute");if(i>=t)return s(o,i,t,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=n)return Math.round(o/n)+"d";if(i>=r)return Math.round(o/r)+"h";if(i>=e)return Math.round(o/e)+"m";if(i>=t)return Math.round(o/t)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var j=function(t){function e(t){let n,o,i,s=null;function a(...t){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=e.formatters[o];if("function"==typeof i){const e=t[s];n=i.call(r,e),t.splice(s,1),s--}return n})),e.formatArgs.call(r,t);(r.log||e.log).apply(r,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=r,a.destroy=e.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==e.namespaces&&(o=e.namespaces,i=e.enabled(t)),i),set:t=>{s=t}}),"function"==typeof e.init&&e.init(a),a}function r(t,r){const n=e(this.namespace+(void 0===r?":":r)+t);return n.log=this.log,n}function n(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names.map(n),...e.skips.map(n).map((t=>"-"+t))].join(",");return e.enable(""),t},e.enable=function(t){let r;e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=("string"==typeof t?t:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(t=n[r].replace(/\*/g,".*?"))[0]?e.skips.push(new RegExp("^"+t.slice(1)+"$")):e.names.push(new RegExp("^"+t+"$")))},e.enabled=function(t){if("*"===t[t.length-1])return!0;let r,n;for(r=0,n=e.skips.length;r<n;r++)if(e.skips[r].test(t))return!1;for(r=0,n=e.names.length;r<n;r++)if(e.names[r].test(t))return!0;return!1},e.humanize=S(),e.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(t).forEach((r=>{e[r]=t[r]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return e.colors[Math.abs(r)%e.colors.length]},e.enable(e.load()),e};!function(t,e){e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{"%%"!==t&&(n++,"%c"===t&&(o=n))})),e.splice(o,0,r)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem("debug")}catch(t){}!t&&"undefined"!=typeof process&&"env"in process&&(t=process.env.DEBUG);return t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})(),e.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"],e.log=console.debug||console.log||(()=>{}),t.exports=j(e);const{formatters:r}=t.exports;r.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}({get exports(){return _},set exports(t){_=t}},_);var k=Error.captureStackTrace||function(t){var e=new Error;Object.defineProperty(t,"stack",{configurable:!0,get:function(){var t=e.stack;return Object.defineProperty(this,"stack",{value:t}),t}})};
|
|
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={timeout:"undefined"!=typeof navigator&&"ReactNative"===navigator.product?6e4:12e4};function n(e){const n="string"==typeof e?Object.assign({url:e},t):Object.assign({},t,e),o=new URL(n.url,"http://localhost");if(n.timeout=r(n.timeout),n.query)for(const[e,t]of Object.entries(n.query))if(void 0!==t)if(Array.isArray(t))for(const n of t)o.searchParams.append(e,n);else o.searchParams.append(e,t);return n.method=n.body&&!n.method?"POST":(n.method||"GET").toUpperCase(),n.url="http://localhost"===o.origin?"".concat(o.pathname,"?").concat(o.searchParams):o.toString(),n}function r(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const n=Number(e);return isNaN(n)?r(t.timeout):{connect:n,socket:n}}const o=/^https?:\/\//i;function s(e){if(!o.test(e.url))throw new Error('"'.concat(e.url,'" is not a valid URL'))}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=function(e){return e.replace(/^\s+|\s+$/g,"")},c=function(e){if(!e)return{};for(var t,n={},r=a(e).split("\n"),o=0;o<r.length;o++){var s=r[o],i=s.indexOf(":"),c=a(s.slice(0,i)).toLowerCase(),u=a(s.slice(i+1));void 0===n[c]?n[c]=u:(t=n[c],"[object Array]"===Object.prototype.toString.call(t)?n[c].push(u):n[c]=[n[c],u])}return n};const u=["request","response","progress","error","abort"],l=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function h(e,t){const r=[],o=l.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[n],validateOptions:[s]});function i(e){const n=u.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const n in e)e[n](t)},subscribe:function(n){const r=t++;return e[r]=n,function(){delete e[r]}}}}(),e)),{}),r=(e=>function(t,n){const r="onError"===t;let o=n;for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];for(let n=0;n<e[t].length&&(o=(0,e[t][n])(o,...i),!r||o);n++);return o})(o),s=r("processOptions",e);r("validateOptions",s);const i={options:s,channels:n,applyMiddleware:r};let a=null;const c=n.request.subscribe((e=>{a=t(e,((t,o)=>function(e,t,o){let s=e,i=t;if(!s)try{i=r("onResponse",t,o)}catch(e){i=null,s=e}s=s&&r("onError",s,o),s?n.error.publish(s):i&&n.response.publish(i)}(t,o,e)))}));n.abort.subscribe((()=>{c(),a&&a.abort()}));const l=r("onReturn",n,i);return l===n&&n.request.publish(i),l}return i.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&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),i},i.clone=function(){return h(r,t)},e.forEach(i.use),i}var d,f,p,y,g,v=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},m=(e,t,n)=>(v(e,t,"read from private field"),n?n.call(e):t.get(e)),w=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},b=(e,t,n,r)=>(v(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);d=new WeakMap,f=new WeakMap,p=new WeakMap,y=new WeakMap,g=new WeakMap;const C="function"==typeof XMLHttpRequest?"xhr":"fetch",E="xhr"===C?XMLHttpRequest:class{constructor(){this.readyState=0,w(this,d,void 0),w(this,f,void 0),w(this,p,void 0),w(this,y,{}),w(this,g,void 0)}open(e,t,n){b(this,d,e),b(this,f,t),b(this,p,""),this.readyState=1,this.onreadystatechange(),b(this,g,void 0)}abort(){m(this,g)&&m(this,g).abort()}getAllResponseHeaders(){return m(this,p)}setRequestHeader(e,t){m(this,y)[e]=t}send(e){const t="arraybuffer"!==this.responseType,n={method:m(this,d),headers:m(this,y),signal:null,body:e};"function"==typeof AbortController&&(b(this,g,new AbortController),n.signal=m(this,g).signal),"undefined"!=typeof document&&(n.credentials=this.withCredentials?"include":"omit"),fetch(m(this,f),n).then((e=>(e.headers.forEach(((e,t)=>{b(this,p,m(this,p)+"".concat(t,": ").concat(e,"\r\n"))})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange()})).catch((e=>{var t;"AbortError"!==e.name?null==(t=this.onerror)||t.call(this,e):this.onabort()}))}};var T=(e,t)=>{const n=e.options,r=e.applyMiddleware("finalizeOptions",n),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:C,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new E;const a=r.headers,u=r.timeout;let l=!1,h=!1,d=!1;if(i.onerror=y,i.ontimeout=y,i.onabort=()=>{p(!0),l=!0},i.onreadystatechange=()=>{!function(){if(!u)return;p(),o.socket=setTimeout((()=>f("ESOCKETTIMEDOUT")),u.socket)}(),l||4!==i.readyState||0!==i.status&&function(){if(l||h||d)return;if(0===i.status)return void y(new Error("Unknown XHR error"));p(),h=!0,t(null,{body:i.response||i.responseText,url:r.url,method:r.method,headers:c(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}()},i.open(r.method,r.url,!0),i.withCredentials=!!r.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return r.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:r,adapter:C,request:i,context:e}),i.send(r.body||null),u&&(o.connect=setTimeout((()=>f("ETIMEDOUT")),u.connect)),{abort:function(){l=!0,i&&i.abort()}};function f(t){d=!0,i.abort();const n=new Error("ESOCKETTIMEDOUT"===t?"Socket timed out on request to ".concat(r.url):"Connection timed out on request to ".concat(r.url));n.code=t,e.channels.error.publish(n)}function p(e){(e||l||i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function y(e){if(h)return;p(!0),h=!0,i=null;const n=e||new Error("Network error while attempting to reach ".concat(r.url));n.isNetworkError=!0,n.request=r,t(n)}};var x,O,_={};function S(){if(O)return x;O=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,s=365.25*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return x=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(i){if((i=String(i)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var s=Math.abs(o);if(s>=r)return i(o,s,r,"day");if(s>=n)return i(o,s,n,"hour");if(s>=t)return i(o,s,t,"minute");if(s>=e)return i(o,s,e,"second");return o+" ms"}(a):function(o){var s=Math.abs(o);if(s>=r)return Math.round(o/r)+"d";if(s>=n)return Math.round(o/n)+"h";if(s>=t)return Math.round(o/t)+"m";if(s>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var j=function(e){function t(e){let r,o,s,i=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),s=o-(r||o);n.diff=s,n.prev=r,n.curr=o,r=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,((r,o)=>{if("%%"===r)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];r=s.call(n,t),e.splice(i,1),i--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,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 n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=S(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};
|
|
2
2
|
/*!
|
|
3
3
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
6
|
* Released under the MIT License.
|
|
7
7
|
*/
|
|
8
|
-
function A(t){return"[object Object]"===Object.prototype.toString.call(t)}!function(t,e){if("string"!=typeof t)throw new TypeError("Expected className to be a string");if(/[^0-9a-zA-Z_$]/.test(t))throw new Error("className contains invalid characters");e=e||function(t){this.message=t};var r,n,o=function(){Object.defineProperty(this,"name",{configurable:!0,value:t,writable:!0}),k(this,this.constructor),e.apply(this,arguments)};r=o,n=Error,r.super_=n,r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}})}("HttpError",(function(t,e){const r=t.url.length>400?"".concat(t.url.slice(0,399),"…"):t.url;let n="".concat(t.method,"-request to ").concat(r," resulted in ");n+="HTTP ".concat(t.statusCode," ").concat(t.statusMessage),this.message=n.trim(),this.response=t,this.request=e.options}));const F=["boolean","string","number"];function R(){return{processOptions:t=>{const e=t.body;if(!e)return t;var r,n,o,i;return!("function"==typeof e.pipe)&&!((i=e).constructor&&"function"==typeof i.constructor.isBuffer&&i.constructor.isBuffer(i))&&(-1!==F.indexOf(typeof e)||Array.isArray(e)||!1!==A(r=e)&&(void 0===(n=r.constructor)||!1!==A(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))?Object.assign({},t,{body:JSON.stringify(t.body),headers:Object.assign({},t.headers,{"Content-Type":"application/json"})}):t}}}function P(t){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=t&&t.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:e(r.body)}):r},processOptions:t=>Object.assign({},t,{headers:Object.assign({Accept:"application/json"},t.headers)})};function e(t){try{return JSON.parse(t)}catch(t){throw t.message="Failed to parsed response body as JSON: ".concat(t.message),t}}}let I;I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var M=I;function q(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.implementation||M.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(t,r)=>new e((e=>(t.error.subscribe((t=>e.error(t))),t.progress.subscribe((t=>e.next(Object.assign({type:"progress"},t)))),t.response.subscribe((t=>{e.next(Object.assign({type:"response"},t)),e.complete()})),t.request.publish(r),()=>t.abort.publish())))}}class D{constructor(t){this.__CANCEL__=!0,this.message=t}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const N=class{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e=null;this.promise=new Promise((t=>{e=t})),t((t=>{this.reason||(this.reason=new D(t),e(this.reason))}))}};N.source=()=>{let t;return{token:new N((e=>{t=e})),cancel:t}};var W=function(t,e){return W=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},W(t,e)};function H(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}W(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function z(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function U(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function B(t){return"function"==typeof t}function $(t){var e=t((function(t){Error.call(t),t.stack=(new Error).stack}));return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var V=$((function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}}));function J(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var G=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var e;return t.prototype.unsubscribe=function(){var t,e,r,n,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=z(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}else i.remove(this);var c=this.initialTeardown;if(B(c))try{c()}catch(t){o=t instanceof V?t.errors:[t]}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{Y(d)}catch(t){o=null!=o?o:[],t instanceof V?o=U(U([],L(o)),L(t.errors)):o.push(t)}}}catch(t){r={error:t}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new V(o)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Y(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&J(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&J(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=((e=new t).closed=!0,e),t}();function X(t){return t instanceof G||t&&"closed"in t&&B(t.remove)&&B(t.add)&&B(t.unsubscribe)}function Y(t){B(t)?t():t.unsubscribe()}G.EMPTY;var K={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Z={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=Z.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,U([t,e],L(r))):setTimeout.apply(void 0,U([t,e],L(r)))},clearTimeout:function(t){var e=Z.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Q(){}var tt=null;var et=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,X(e)&&e.add(r)):r.destination=at,r}return H(e,t),e.create=function(t,e,r){return new it(t,e,r)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(G),rt=Function.prototype.bind;function nt(t,e){return rt.call(t,e)}var ot=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){st(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){st(t)}else st(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){st(t)}},t}(),it=function(t){function e(e,r,n){var o,i,s=t.call(this)||this;B(e)||!e?o={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:s&&K.useDeprecatedNextContext?((i=Object.create(e)).unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&nt(e.next,i),error:e.error&&nt(e.error,i),complete:e.complete&&nt(e.complete,i)}):o=e;return s.destination=new ot(o),s}return H(e,t),e}(et);function st(t){var e;e=t,Z.setTimeout((function(){throw e}))}var at={closed:!0,next:Q,error:function(t){throw t},complete:Q},ct="function"==typeof Symbol&&Symbol.observable||"@@observable";function ut(t){return t}function lt(t){return 0===t.length?ut:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var ht=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n,o=this,i=(n=t)&&n instanceof et||function(t){return t&&B(t.next)&&B(t.error)&&B(t.complete)}(n)&&X(n)?t:new it(t,e,r);return function(t){if(K.useDeprecatedSynchronousErrorHandling){var e=!tt;if(e&&(tt={errorThrown:!1,error:null}),t(),e){var r=tt,n=r.errorThrown,o=r.error;if(tt=null,n)throw o}}else t()}((function(){var t=o,e=t.operator,r=t.source;i.add(e?e.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=dt(e))((function(e,n){var o=new it({next:function(e){try{t(e)}catch(t){n(t),o.unsubscribe()}},error:n,complete:e});r.subscribe(o)}))},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[ct]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=dt(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function dt(t){var e;return null!==(e=null!=t?t:K.Promise)&&void 0!==e?e:Promise}function ft(t){return function(e){if(function(t){return B(null==t?void 0:t.lift)}(e))return e.lift((function(e){try{return t(e,this)}catch(t){this.error(t)}}));throw new TypeError("Unable to lift unknown Observable type")}}function pt(t,e,r,n,o){return new yt(t,e,r,n,o)}var yt=function(t){function e(e,r,n,o,i,s){var a=t.call(this,e)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,a._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=o?function(t){try{o(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return H(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(et),gt=$((function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}}));function vt(t,e){var r="object"==typeof e;return new Promise((function(n,o){var i,s=!1;t.subscribe({next:function(t){i=t,s=!0},error:o,complete:function(){s?n(i):r?n(e.defaultValue):o(new gt)}})}))}function mt(t,e){return ft((function(r,n){var o=0;r.subscribe(pt(n,(function(r){n.next(t.call(e,r,o++))})))}))}function wt(t,e){return ft((function(r,n){var o=0;r.subscribe(pt(n,(function(r){return t.call(e,r,o++)&&n.next(r)})))}))}var bt={};!function(t,e){var r="undefined"!=typeof Reflect?Reflect.construct:void 0,n=Object.defineProperty,o=Error.captureStackTrace;function i(t){void 0!==t&&n(this,"message",{configurable:!0,value:t,writable:!0});var e=this.constructor.name;void 0!==e&&e!==this.name&&n(this,"name",{configurable:!0,value:e,writable:!0}),o(this,this.constructor)}void 0===o&&(o=function(t){var e=new Error;n(t,"stack",{configurable:!0,get:function(){var t=e.stack;return n(this,"stack",{configurable:!0,value:t,writable:!0}),t},set:function(e){n(t,"stack",{configurable:!0,value:e,writable:!0})}})}),i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function t(t,e){return n(t,"name",{configurable:!0,value:e})}try{var e=function(){};if(t(e,"foo"),"foo"===e.name)return t}catch(t){}}();e=t.exports=function(t,e){if(null==e||e===Error)e=i;else if("function"!=typeof e)throw new TypeError("super_ should be a function");var n;if("string"==typeof t)n=t,t=void 0!==r?function(){return r(e,arguments,this.constructor)}:function(){e.apply(this,arguments)},void 0!==s&&(s(t,n),n=void 0);else if("function"!=typeof t)throw new TypeError("constructor should be either a string or a function");t.super_=t.super=e;var o={constructor:{configurable:!0,value:t,writable:!0}};return void 0!==n&&(o.name={configurable:!0,value:n,writable:!0}),t.prototype=Object.create(e.prototype,o),t},e.BaseError=i}({get exports(){return bt},set exports(t){bt=t}},bt);var Ct={};
|
|
8
|
+
function A(e){return"[object Object]"===Object.prototype.toString.call(e)}!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 n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),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=j(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}({get exports(){return _},set exports(e){_=e}},_);const k="undefined"==typeof Buffer?()=>!1:e=>Buffer.isBuffer(e),F=["boolean","string","number"];function R(){return{processOptions:e=>{const t=e.body;if(!t)return e;var n,r,o;return!("function"==typeof t.pipe)&&!k(t)&&(-1!==F.indexOf(typeof t)||Array.isArray(t)||!1!==A(n=t)&&(void 0===(r=n.constructor)||!1!==A(o=r.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))?Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})}):e}}}function I(e){return{onResponse:n=>{const r=n.headers["content-type"]||"",o=e&&e.force||-1!==r.indexOf("application/json");return n.body&&r&&o?Object.assign({},n,{body:t(n.body)}):n},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: ".concat(e.message),e}}}let M;M="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var P=M;function D(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.implementation||P.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,n)=>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(n),()=>e.abort.publish())))}}class q{constructor(e){this.__CANCEL__=!0,this.message=e}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const N=class{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new q(e),t(this.reason))}))}};N.source=()=>{let e;return{token:new N((t=>{e=t})),cancel:e}};var H=function(e,t){return H=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},H(e,t)};function W(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}H(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function z(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function U(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function B(e){return"function"==typeof e}function $(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}var V=$((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 J(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var G=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,n,r,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(B(c))try{c()}catch(e){o=e instanceof V?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{Y(d)}catch(e){o=null!=o?o:[],e instanceof V?o=U(U([],L(o)),L(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}}if(o)throw new V(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Y(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).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)&&J(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&J(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function X(e){return e instanceof G||e&&"closed"in e&&B(e.remove)&&B(e.add)&&B(e.unsubscribe)}function Y(e){B(e)?e():e.unsubscribe()}G.EMPTY;var K={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Z={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=Z.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,U([e,t],L(n))):setTimeout.apply(void 0,U([e,t],L(n)))},clearTimeout:function(e){var t=Z.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function Q(){}var ee=null;var te=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,X(t)&&t.add(n)):n.destination=ae,n}return W(t,e),t.create=function(e,t,n){return new se(e,t,n)},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}(G),ne=Function.prototype.bind;function re(e,t){return ne.call(e,t)}var oe=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){ie(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ie(e)}else ie(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ie(e)}},e}(),se=function(e){function t(t,n,r){var o,s,i=e.call(this)||this;B(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:i&&K.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&re(t.next,s),error:t.error&&re(t.error,s),complete:t.complete&&re(t.complete,s)}):o=t;return i.destination=new oe(o),i}return W(t,e),t}(te);function ie(e){var t;t=e,Z.setTimeout((function(){throw t}))}var ae={closed:!0,next:Q,error:function(e){throw e},complete:Q},ce="function"==typeof Symbol&&Symbol.observable||"@@observable";function ue(e){return e}function le(e){return 0===e.length?ue:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var he=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,s=(r=e)&&r instanceof te||function(e){return e&&B(e.next)&&B(e.error)&&B(e.complete)}(r)&&X(r)?e:new se(e,t,n);return function(e){if(K.useDeprecatedSynchronousErrorHandling){var t=!ee;if(t&&(ee={errorThrown:!1,error:null}),e(),t){var n=ee,r=n.errorThrown,o=n.error;if(ee=null,r)throw o}}else e()}((function(){var e=o,t=e.operator,n=e.source;s.add(t?t.call(s,n):n?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 n=this;return new(t=de(t))((function(t,r){var o=new se({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[ce]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return le(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=de(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function de(e){var t;return null!==(t=null!=e?e:K.Promise)&&void 0!==t?t:Promise}function fe(e){return function(t){if(function(e){return B(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 pe(e,t,n,r,o){return new ye(e,t,n,r,o)}var ye=function(e){function t(t,n,r,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=n?function(e){try{n(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=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return W(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(te),ge=$((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function ve(e,t){var n="object"==typeof t;return new Promise((function(r,o){var s,i=!1;e.subscribe({next:function(e){s=e,i=!0},error:o,complete:function(){i?r(s):n?r(t.defaultValue):o(new ge)}})}))}function me(e,t){return fe((function(n,r){var o=0;n.subscribe(pe(r,(function(n){r.next(e.call(t,n,o++))})))}))}function we(e,t){return fe((function(n,r){var o=0;n.subscribe(pe(r,(function(n){return e.call(t,n,o++)&&r.next(n)})))}))}var be={};
|
|
9
9
|
/** @license
|
|
10
10
|
* eventsource.js
|
|
11
11
|
* Available under MIT License (MIT)
|
|
12
12
|
* https://github.com/Yaffle/EventSource/
|
|
13
13
|
*/
|
|
14
|
-
!function(t,e){!function(r){var n=r.setTimeout,o=r.clearTimeout,i=r.XMLHttpRequest,s=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,h=r.fetch,d=r.Response,f=r.TextDecoder,p=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(t){u.readyState="complete"}),!1)),null==i&&null!=a&&(i=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(t){function e(){}return e.prototype=t,new e}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=h;h=function(t,e){var r=e.signal;return g(t,{headers:e.headers,credentials:e.credentials,cache:e.cache}).then((function(t){var e=t.body.getReader();return r._reader=e,r._aborted&&r._reader.cancel(),{status:t.status,statusText:t.statusText,headers:t.headers,body:{getReader:function(){return e}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function v(){this.bitsNeeded=0,this.codePoint=0}v.prototype.decode=function(t){function e(t,e,r){if(1===r)return t>=128>>e&&t<<e<=2047;if(2===r)return t>=2048>>e&&t<<e<=55295||t>=57344>>e&&t<<e<=65535;if(3===r)return t>=65536>>e&&t<<e<=1114111;throw new Error}function r(t,e){if(6===t)return e>>6>15?3:e>31?2:1;if(12===t)return e>15?3:2;if(18===t)return 3;throw new Error}for(var n=65533,o="",i=this.bitsNeeded,s=this.codePoint,a=0;a<t.length;a+=1){var c=t[a];0!==i&&(c<128||c>191||!e(s<<6|63&c,i-6,r(i,s)))&&(i=0,s=n,o+=String.fromCharCode(s)),0===i?(c>=0&&c<=127?(i=0,s=c):c>=192&&c<=223?(i=6,s=31&c):c>=224&&c<=239?(i=12,s=15&c):c>=240&&c<=247?(i=18,s=7&c):(i=0,s=n),0===i||e(s,i,r(i,s))||(i=0,s=n)):(i-=6,s=s<<6|63&c),0===i&&(s<=65535?o+=String.fromCharCode(s):(o+=String.fromCharCode(55296+(s-65535-1>>10)),o+=String.fromCharCode(56320+(s-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=s,o};null!=f&&null!=p&&function(){try{return"test"===(new f).decode((new p).encode("test"),{stream:!0})}catch(t){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+t)}return!1}()||(f=v);var m=function(){};function w(t){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=m,this.onload=m,this.onerror=m,this.onreadystatechange=m,this._contentType="",this._xhr=t,this._sendTimeout=0,this._abort=m}function b(t){return t.replace(/[A-Z]/g,(function(t){return String.fromCharCode(t.charCodeAt(0)+32)}))}function C(t){for(var e=Object.create(null),r=t.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),i=o.shift(),s=o.join(": ");e[b(i)]=s}this._map=e}function E(){}function T(t){this._headers=t}function x(){}function O(){this._listeners=Object.create(null)}function _(t){n((function(){throw t}),0)}function S(t){this.type=t,this.target=void 0}function j(t,e){S.call(this,t),this.data=e.data,this.lastEventId=e.lastEventId}function k(t,e){S.call(this,t),this.status=e.status,this.statusText=e.statusText,this.headers=e.headers}function A(t,e){S.call(this,t),this.error=e.error}w.prototype.open=function(t,e){this._abort(!0);var r=this,s=this._xhr,a=1,c=0;this._abort=function(t){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,s.onload=m,s.onerror=m,s.onabort=m,s.onprogress=m,s.onreadystatechange=m,s.abort(),0!==c&&(o(c),c=0),t||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var u=function(){if(1===a){var t=0,e="",n=void 0;if("contentType"in s)t=200,e="OK",n=s.contentType;else try{t=s.status,e=s.statusText,n=s.getResponseHeader("Content-Type")}catch(r){t=0,e="",n=void 0}0!==t&&(a=2,r.readyState=2,r.status=t,r.statusText=e,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var t="";try{t=s.responseText}catch(t){}r.readyState=3,r.responseText=t,r.onprogress()}},h=function(t,e){if(null!=e&&null!=e.preventDefault||(e={preventDefault:m}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),r.readyState=4,"load"===t)r.onload(e);else if("error"===t)r.onerror(e);else{if("abort"!==t)throw new TypeError;r.onabort(e)}r.onreadystatechange()}},d=function(){c=n((function(){d()}),500),3===s.readyState&&l()};"onload"in s&&(s.onload=function(t){h("load",t)}),"onerror"in s&&(s.onerror=function(t){h("error",t)}),"onabort"in s&&(s.onabort=function(t){h("abort",t)}),"onprogress"in s&&(s.onprogress=l),"onreadystatechange"in s&&(s.onreadystatechange=function(t){!function(t){null!=s&&(4===s.readyState?"onload"in s&&"onerror"in s&&"onabort"in s||h(""===s.responseText?"error":"load",t):3===s.readyState?"onprogress"in s||l():2===s.readyState&&u())}(t)}),!("contentType"in s)&&"ontimeout"in i.prototype||(e+=(-1===e.indexOf("?")?"?":"&")+"padding=true"),s.open(t,e,!0),"readyState"in s&&(c=n((function(){d()}),0))},w.prototype.abort=function(){this._abort(!1)},w.prototype.getResponseHeader=function(t){return this._contentType},w.prototype.setRequestHeader=function(t,e){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(t,e)},w.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},w.prototype.send=function(){if("ontimeout"in i.prototype&&("sendAsBinary"in i.prototype||"mozAnon"in i.prototype)||null==u||null==u.readyState||"complete"===u.readyState){var t=this._xhr;"withCredentials"in t&&(t.withCredentials=this.withCredentials);try{t.send(void 0)}catch(t){throw t}}else{var e=this;e._sendTimeout=n((function(){e._sendTimeout=0,e.send()}),4)}},C.prototype.get=function(t){return this._map[b(t)]},null!=i&&null==i.HEADERS_RECEIVED&&(i.HEADERS_RECEIVED=2),E.prototype.open=function(t,e,r,n,o,s,a){t.open("GET",o);var c=0;for(var u in t.onprogress=function(){var e=t.responseText.slice(c);c+=e.length,r(e)},t.onerror=function(t){t.preventDefault(),n(new Error("NetworkError"))},t.onload=function(){n(null)},t.onabort=function(){n(null)},t.onreadystatechange=function(){if(t.readyState===i.HEADERS_RECEIVED){var r=t.status,n=t.statusText,o=t.getResponseHeader("Content-Type"),s=t.getAllResponseHeaders();e(r,n,o,new C(s))}},t.withCredentials=s,a)Object.prototype.hasOwnProperty.call(a,u)&&t.setRequestHeader(u,a[u]);return t.send(),t},T.prototype.get=function(t){return this._headers.get(t)},x.prototype.open=function(t,e,r,n,o,i,s){var a=null,c=new y,u=c.signal,d=new f;return h(o,{headers:s,credentials:i?"include":"same-origin",signal:u,cache:"no-store"}).then((function(t){return a=t.body.getReader(),e(t.status,t.statusText,t.headers.get("Content-Type"),new T(t.headers)),new l((function(t,e){var n=function(){a.read().then((function(e){if(e.done)t(void 0);else{var o=d.decode(e.value,{stream:!0});r(o),n()}})).catch((function(t){e(t)}))};n()}))})).catch((function(t){return"AbortError"===t.name?void 0:t})).then((function(t){n(t)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},O.prototype.dispatchEvent=function(t){t.target=this;var e=this._listeners[t.type];if(null!=e)for(var r=e.length,n=0;n<r;n+=1){var o=e[n];try{"function"==typeof o.handleEvent?o.handleEvent(t):o.call(this,t)}catch(t){_(t)}}},O.prototype.addEventListener=function(t,e){t=String(t);var r=this._listeners,n=r[t];null==n&&(n=[],r[t]=n);for(var o=!1,i=0;i<n.length;i+=1)n[i]===e&&(o=!0);o||n.push(e)},O.prototype.removeEventListener=function(t,e){t=String(t);var r=this._listeners,n=r[t];if(null!=n){for(var o=[],i=0;i<n.length;i+=1)n[i]!==e&&o.push(n[i]);0===o.length?delete r[t]:r[t]=o}},j.prototype=Object.create(S.prototype),k.prototype=Object.create(S.prototype),A.prototype=Object.create(S.prototype);var F=-1,R=-1,P=/^text\/event\-stream(;.*)?$/i,I=function(t,e){var r=null==t?e:parseInt(t,10);return r!=r&&(r=e),M(r)},M=function(t){return Math.min(Math.max(t,1e3),18e6)},q=function(t,e,r){try{"function"==typeof e&&e.call(t,r)}catch(t){_(t)}};function D(t,e){O.call(this),e=e||{},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(t,e,r){e=String(e);var a=Boolean(r.withCredentials),c=r.lastEventIdQueryParameterName||"lastEventId",u=M(1e3),l=I(r.heartbeatTimeout,45e3),h="",d=u,f=!1,p=0,y=r.headers||{},g=r.Transport,v=N&&null==g?void 0:new w(null!=g?new g:null!=i&&"withCredentials"in i.prototype||null==s?new i:new s),m=null!=g&&"string"!=typeof g?new g:null==v?new x:new E,b=void 0,C=0,T=F,O="",_="",S="",D="",W=0,H=0,z=0,L=function(e,r,n,o){if(0===T)if(200===e&&null!=n&&P.test(n)){T=1,f=Date.now(),d=u,t.readyState=1;var i=new k("open",{status:e,statusText:r,headers:o});t.dispatchEvent(i),q(t,t.onopen,i)}else{var s="";200!==e?(r&&(r=r.replace(/\s+/g," ")),s="EventSource's response has a status "+e+" "+r+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",$();i=new k("error",{status:e,statusText:r,headers:o});t.dispatchEvent(i),q(t,t.onerror,i),console.error(s)}},U=function(e){if(1===T){for(var r=-1,i=0;i<e.length;i+=1){(c=e.charCodeAt(i))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=i)}var s=(-1!==r?D:"")+e.slice(0,r+1);D=(-1===r?D:"")+e.slice(r+1),""!==e&&(f=Date.now(),p+=e.length);for(var a=0;a<s.length;a+=1){var c=s.charCodeAt(a);if(W===R&&c==="\n".charCodeAt(0))W=0;else if(W===R&&(W=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==W){1===W&&(z=a+1);var y=s.slice(H,z-1),g=s.slice(z+(z<a&&s.charCodeAt(z)===" ".charCodeAt(0)?1:0),a);"data"===y?(O+="\n",O+=g):"id"===y?_=g:"event"===y?S=g:"retry"===y?(u=I(g,u),d=u):"heartbeatTimeout"===y&&(l=I(g,l),0!==C&&(o(C),C=n((function(){V()}),l)))}if(0===W){if(""!==O){h=_,""===S&&(S="message");var v=new j(S,{data:O.slice(1),lastEventId:_});if(t.dispatchEvent(v),"open"===S?q(t,t.onopen,v):"message"===S?q(t,t.onmessage,v):"error"===S&&q(t,t.onerror,v),2===T)return}O="",S=""}W=c==="\r".charCodeAt(0)?R:0}else 0===W&&(H=a,W=1),1===W?c===":".charCodeAt(0)&&(z=a+1,W=2):2===W&&(W=3)}}},B=function(e){if(1===T||0===T){T=F,0!==C&&(o(C),C=0),C=n((function(){V()}),d),d=M(Math.min(16*u,2*d)),t.readyState=0;var r=new A("error",{error:e});t.dispatchEvent(r),q(t,t.onerror,r),null!=e&&console.error(e)}},$=function(){T=2,null!=b&&(b.abort(),b=void 0),0!==C&&(o(C),C=0),t.readyState=2},V=function(){if(C=0,T===F){f=!1,p=0,C=n((function(){V()}),l),T=0,O="",S="",_=h,D="",H=0,z=0,W=0;var r=e;if("data:"!==e.slice(0,5)&&"blob:"!==e.slice(0,5)&&""!==h){var o=e.indexOf("?");r=-1===o?e:e.slice(0,o+1)+e.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(t,e){return e===c?"":t})),r+=(-1===e.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(h)}var i=t.withCredentials,s={Accept:"text/event-stream"},a=t.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(s[u]=a[u]);try{b=m.open(v,L,U,B,r,i,s)}catch(t){throw $(),t}}else if(f||null==b){var d=Math.max((f||Date.now())+l-Date.now(),1);f=!1,C=n((function(){V()}),d)}else B(new Error("No activity within "+l+" milliseconds. "+(0===T?"No response received.":p+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};t.url=e,t.readyState=0,t.withCredentials=a,t.headers=y,t._close=$,V()}(this,t,e)}var N=null!=h&&null!=d&&"body"in d.prototype;D.prototype=Object.create(O.prototype),D.prototype.CONNECTING=0,D.prototype.OPEN=1,D.prototype.CLOSED=2,D.prototype.close=function(){this._close()},D.CONNECTING=0,D.OPEN=1,D.CLOSED=2,D.prototype.withCredentials=void 0;var W,H=c;null==i||null!=c&&"withCredentials"in c.prototype||(H=D),W=function(t){t.EventSourcePolyfill=D,t.NativeEventSource=c,t.EventSource=H}(e),void 0!==W&&(t.exports=W)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:s:globalThis)}({get exports(){return Ct},set exports(t){Ct=t}},Ct);var Et=Ct.EventSourcePolyfill;class Tt extends bt.BaseError{constructor(t){const e=Ot(t);super(e.message),this.statusCode=400,Object.assign(this,e)}}class xt extends bt.BaseError{constructor(t){const e=Ot(t);super(e.message),this.statusCode=500,Object.assign(this,e)}}function Ot(t){const e=t.body,r={response:t,statusCode:t.statusCode,responseBody:_t(e,t),message:"",details:void 0};return e.error&&e.message?(r.message="".concat(e.error," - ").concat(e.message),r):e.error&&e.error.description?(r.message=e.error.description,r.details=e.error,r):(r.message=e.error||e.message||function(t){const e=t.statusMessage?" ".concat(t.statusMessage):"";return"".concat(t.method,"-request to ").concat(t.url," resulted in HTTP ").concat(t.statusCode).concat(e)}(t),r)}function _t(t,e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(t,null,2):t}const St={onResponse:t=>{if(t.statusCode>=500)throw new xt(t);if(t.statusCode>=400)throw new Tt(t);return t}},jt={onResponse:t=>{const e=t.headers["x-sanity-warning"];return(Array.isArray(e)?e:[e]).filter(Boolean).forEach((t=>console.warn(t))),t}};const kt="X-Sanity-Project-ID";function At(t){if("string"==typeof t||Array.isArray(t))return{id:t};if("object"==typeof t&&null!==t&&"query"in t&&"string"==typeof t.query)return"params"in t&&"object"==typeof t.params&&null!==t.params?{query:t.query,params:t.params}:{query:t.query};const e=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(e))}const Ft=["image","file"],Rt=["before","after","replace"],Pt=t=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},It=t=>{if(-1===Ft.indexOf(t))throw new Error("Invalid asset type: ".concat(t,". Must be one of ").concat(Ft.join(", ")))},Mt=(t,e)=>{if(null===e||"object"!=typeof e||Array.isArray(e))throw new Error("".concat(t,"() takes an object of properties"))},qt=(t,e)=>{if("string"!=typeof e||!/^[a-z0-9_.-]+$/i.test(e))throw new Error("".concat(t,'(): "').concat(e,'" is not a valid document ID'))},Dt=(t,e)=>{if(!e._id)throw new Error("".concat(t,'() requires that the document contains an ID ("_id" property)'));qt(t,e._id)},Nt=t=>{if(!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset||""},Wt=t=>{if("string"!=typeof t||!/^[a-z0-9._-]{1,75}$/i.test(t))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return t},Ht=encodeURIComponent;var zt,Lt,Ut=t=>{let{query:e,params:r={},options:n={}}=t;const{tag:o,...i}=n,s="query=".concat(Ht(e)),a=o?"?tag=".concat(Ht(o),"&").concat(s):"?".concat(s),c=Object.keys(r).reduce(((t,e)=>"".concat(t,"&").concat(Ht("$".concat(e)),"=").concat(Ht(JSON.stringify(r[e])))),a);return Object.keys(i).reduce(((t,e)=>n[e]?"".concat(t,"&").concat(Ht(e),"=").concat(Ht(n[e])):t),c)},Bt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},$t=(t,e,r)=>(Bt(t,e,"read from private field"),r?r.call(t):e.get(t)),Vt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Jt=(t,e,r,n)=>(Bt(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);class Gt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=t,this.operations=e}replace(t){return Mt("replace",t),this._set("set",{$:t})}set(t){return this._assign("set",t)}setIfMissing(t){return this._assign("setIfMissing",t)}diffMatchPatch(t){return Mt("diffMatchPatch",t),this._assign("diffMatchPatch",t)}unset(t){if(!Array.isArray(t))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:t}),this}inc(t){return this._assign("inc",t)}dec(t){return this._assign("dec",t)}insert(t,e,r){return((t,e,r)=>{const n="insert(at, selector, items)";if(-1===Rt.indexOf(t)){const t=Rt.map((t=>'"'.concat(t,'"'))).join(", ");throw new Error("".concat(n,' takes an "at"-argument which is one of: ').concat(t))}if("string"!=typeof e)throw new Error("".concat(n,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(n,' takes an "items"-argument which must be an array'))})(t,e,r),this._assign("insert",{[t]:e,items:r})}append(t,e){return this.insert("after","".concat(t,"[-1]"),e)}prepend(t,e){return this.insert("before","".concat(t,"[0]"),e)}splice(t,e,r,n){const o=e<0?e-1:e,i=void 0===r||-1===r?-1:Math.max(0,e+r),s=o<0&&i>=0?"":i,a="".concat(t,"[").concat(o,":").concat(s,"]");return this.insert("replace",a,n||[])}ifRevisionId(t){return this.operations.ifRevisionID=t,this}serialize(){return{...At(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(t,e){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Mt(t,e),this.operations=Object.assign({},this.operations,{[t]:Object.assign({},r&&this.operations[t]||{},e)}),this}_set(t,e){return this._assign(t,e,!1)}}const Xt=class extends Gt{constructor(t,e,r){super(t,e),Vt(this,zt,void 0),Jt(this,zt,r)}clone(){return new Xt(this.selection,{...this.operations},$t(this,zt))}commit(t){if(!$t(this,zt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const e="string"==typeof this.selection,r=Object.assign({returnFirst:e,returnDocuments:!0},t);return $t(this,zt).mutate({patch:this.serialize()},r)}};let Yt=Xt;zt=new WeakMap;const Kt=class extends Gt{constructor(t,e,r){super(t,e),Vt(this,Lt,void 0),Jt(this,Lt,r)}clone(){return new Kt(this.selection,{...this.operations},$t(this,Lt))}commit(t){if(!$t(this,Lt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const e="string"==typeof this.selection,r=Object.assign({returnFirst:e,returnDocuments:!0},t);return $t(this,Lt).mutate({patch:this.serialize()},r)}};let Zt=Kt;Lt=new WeakMap;var Qt,te,ee=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},re=(t,e,r)=>(ee(t,e,"read from private field"),r?r.call(t):e.get(t)),ne=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},oe=(t,e,r,n)=>(ee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);const ie={returnDocuments:!1};class se{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;this.operations=t,this.trxId=e}create(t){return Mt("create",t),this._add({create:t})}createIfNotExists(t){const e="createIfNotExists";return Mt(e,t),Dt(e,t),this._add({[e]:t})}createOrReplace(t){const e="createOrReplace";return Mt(e,t),Dt(e,t),this._add({[e]:t})}delete(t){return qt("delete",t),this._add({delete:{id:t}})}transactionId(t){return t?(this.trxId=t,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(t){return this.operations.push(t),this}}const ae=class extends se{constructor(t,e,r){super(t,r),ne(this,Qt,void 0),oe(this,Qt,e)}clone(){return new ae([...this.operations],re(this,Qt),this.trxId)}commit(t){if(!re(this,Qt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return re(this,Qt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},ie,t||{}))}patch(t,e){const r="function"==typeof e;if("string"!=typeof t&&t instanceof Zt)return this._add({patch:t.serialize()});if(r){const r=e(new Zt(t,{},re(this,Qt)));if(!(r instanceof Zt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:t,...e}})}};let ce=ae;Qt=new WeakMap;const ue=class extends se{constructor(t,e,r){super(t,r),ne(this,te,void 0),oe(this,te,e)}clone(){return new ue([...this.operations],re(this,te),this.trxId)}commit(t){if(!re(this,te))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return re(this,te).mutate(this.serialize(),Object.assign({transactionId:this.trxId},ie,t||{}))}patch(t,e){const r="function"==typeof e;if("string"!=typeof t&&t instanceof Yt)return this._add({patch:t.serialize()});if(r){const r=e(new Yt(t,{},re(this,te)));if(!(r instanceof Yt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:t,...e}})}};let le=ue;te=new WeakMap;const he=(t,e)=>!1===t?void 0:void 0===t?e:t,de=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:t.dryRun,returnIds:!0,returnDocuments:he(t.returnDocuments,!0),visibility:t.visibility||"sync",autoGenerateArrayKeys:t.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:t.skipCrossDatasetReferenceValidation}},fe=t=>"response"===t.type,pe=t=>t.body,ye=(t,e)=>t.reduce(((t,r)=>(t[e(r)]=r,t)),Object.create(null));function ge(t,e,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const i=!1===o.filterResponse?t=>t:t=>t.result;return Te(t,e,"query",{query:r,params:n},o).pipe(mt(i))}function ve(t,e,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:Se(t,"doc",r),json:!0,tag:n.tag};return Oe(t,e,o).pipe(wt(fe),mt((t=>t.body.documents&&t.body.documents[0])))}function me(t,e,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:Se(t,"doc",r.join(",")),json:!0,tag:n.tag};return Oe(t,e,o).pipe(wt(fe),mt((t=>{const e=ye(t.body.documents||[],(t=>t._id));return r.map((t=>e[t]||null))})))}function we(t,e,r,n){return Dt("createIfNotExists",r),xe(t,e,r,"createIfNotExists",n)}function be(t,e,r,n){return Dt("createOrReplace",r),xe(t,e,r,"createOrReplace",n)}function Ce(t,e,r,n){return Te(t,e,"mutate",{mutations:[{delete:At(r)}]},n)}function Ee(t,e,r,n){const o=r instanceof Zt||r instanceof Yt||r instanceof ce||r instanceof le?r.serialize():r;return Te(t,e,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId},n)}function Te(t,e,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const i="mutate"===r,s="query"===r,a=i?"":Ut(n),c=!i&&a.length<11264,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p}=o,y=Se(t,r,u),g={method:c?"GET":"POST",uri:y,json:!0,body:c?void 0:n,query:i&&de(o),timeout:h,headers:p,token:d,tag:f,canUseCdn:s};return Oe(t,e,g).pipe(wt(fe),mt(pe),mt((t=>{if(!i)return t;const e=t.results||[];if(o.returnDocuments)return l?e[0]&&e[0].document:e.map((t=>t.document));const r=l?"documentId":"documentIds",n=l?e[0]&&e[0].id:e.map((t=>t.id));return{transactionId:t.transactionId,results:e,[r]:n}})))}function xe(t,e,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const i={[n]:r},s=Object.assign({returnFirst:!0,returnDocuments:!0},o);return Te(t,e,"mutate",{mutations:[i]},s)}function Oe(t,e,r){const n=r.url||r.uri,o=t.config(),i=void 0===r.canUseCdn?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===n.indexOf("/data/"):r.canUseCdn,s=o.useCdn&&i,a=r.tag&&o.requestTagPrefix?[o.requestTagPrefix,r.tag].join("."):r.tag||o.requestTagPrefix;a&&(r.query={tag:Wt(a),...r.query});const c=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},n=e.token||t.token;n&&(r.Authorization="Bearer ".concat(n)),e.useGlobalApi||t.useProjectHostname||!t.projectId||(r[kt]=t.projectId);const o=Boolean(void 0===e.withCredentials?t.token||t.withCredentials:e.withCredentials),i=void 0===e.timeout?t.timeout:e.timeout;return Object.assign({},e,{headers:Object.assign({},r,e.headers||{}),timeout:void 0===i?3e5:i,proxy:e.proxy||t.proxy,json:!0,withCredentials:o})}(o,Object.assign({},r,{url:je(t,n,s)}));return new ht((t=>e(c,o.requester).subscribe(t)))}function _e(t,e,r){return Oe(t,e,r).pipe(wt((t=>"response"===t.type)),mt((t=>t.body)))}function Se(t,e,r){const n=t.config(),o=Nt(n),i="/".concat(e,"/").concat(o),s=r?"".concat(i,"/").concat(r):i;return"/data".concat(s).replace(/\/($|\?)/,"$1")}function je(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:n,cdnUrl:o}=t.config(),i=r?o:n;return"".concat(i,"/").concat(e.replace(/^\//,""))}var ke,Ae,Fe,Re,Pe=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Ie=(t,e,r)=>(Pe(t,e,"read from private field"),r?r.call(t):e.get(t)),Me=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Pe(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);class De{constructor(t,e){Me(this,ke,void 0),Me(this,Ae,void 0),qe(this,ke,t),qe(this,Ae,e)}upload(t,e,r){return We(Ie(this,ke),Ie(this,Ae),t,e,r)}}ke=new WeakMap,Ae=new WeakMap;class Ne{constructor(t,e){Me(this,Fe,void 0),Me(this,Re,void 0),qe(this,Fe,t),qe(this,Re,e)}upload(t,e,r){return vt(We(Ie(this,Fe),Ie(this,Re),t,e,r).pipe(wt((t=>"response"===t.type)),mt((t=>t.body.document))))}}function We(t,e,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};It(r);let i=o.extract||void 0;i&&!i.length&&(i=["none"]);const s=Nt(t.config()),a="image"===r?"images":"files",c=He(o,n),{tag:u,label:l,title:h,description:d,creditLine:f,filename:p,source:y}=c,g={label:l,title:h,description:d,filename:p,meta:i,creditLine:f};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),Oe(t,e,{tag:u,method:"POST",timeout:c.timeout||0,uri:"/assets/".concat(a,"/").concat(s),headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:n})}function He(t,e){return"undefined"!=typeof window&&e instanceof window.File?Object.assign({filename:!1===t.preserveFilename?void 0:e.name,contentType:e.type},t):t}Fe=new WeakMap,Re=new WeakMap;var ze,Le,Ue,Be,$e=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Ve=(t,e,r)=>($e(t,e,"read from private field"),r?r.call(t):e.get(t)),Je=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Ge=(t,e,r,n)=>($e(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);class Xe{constructor(t,e){Je(this,ze,void 0),Je(this,Le,void 0),Ge(this,ze,t),Ge(this,Le,e)}getLoginProviders(){return _e(Ve(this,ze),Ve(this,Le),{uri:"/auth/providers"})}logout(){return _e(Ve(this,ze),Ve(this,Le),{uri:"/auth/logout",method:"POST"})}}ze=new WeakMap,Le=new WeakMap;class Ye{constructor(t,e){Je(this,Ue,void 0),Je(this,Be,void 0),Ge(this,Ue,t),Ge(this,Be,e)}getLoginProviders(){return vt(_e(Ve(this,Ue),Ve(this,Be),{uri:"/auth/providers"}))}logout(){return vt(_e(Ve(this,Ue),Ve(this,Be),{uri:"/auth/logout",method:"POST"}))}}Ue=new WeakMap,Be=new WeakMap;function Ke(t){return"https://docs.sanity.io/help/"+t}const Ze=t=>(t=>{let e,r=!1;return function(){return r||(e=t(...arguments),r=!0),e}})((function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return console.warn(t.join(" "),...r)})),Qe=Ze(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and","cheaper. Think about it! For more info, see ".concat(Ke("js-client-cdn-configuration"),"."),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),tr=Ze(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(Ke("js-client-browser-token")," for more information and how to hide this warning.")]),er=Ze(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(Ke("js-client-api-version"))]),rr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},nr=["localhost","127.0.0.1","0.0.0.0"],or=(t,e)=>{const r=Object.assign({},e,t);r.apiVersion||er();const n=Object.assign({},rr,r),o=n.useProjectHostname;if("undefined"==typeof Promise){const t=Ke("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(t))}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");const i="undefined"!=typeof window&&window.location&&window.location.hostname,s=i&&(t=>-1!==nr.indexOf(t))(window.location.hostname);i&&s&&n.token&&!0!==n.ignoreBrowserTokenWarning?tr():void 0===n.useCdn&&Qe(),o&&(t=>{if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&Pt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Wt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion="".concat(n.apiVersion).replace(/^v/,""),n.isDefaultApi=n.apiHost===rr.apiHost,n.useCdn=Boolean(n.useCdn)&&!n.withCredentials,function(t){if("1"===t||"X"===t)return;const e=new Date(t);if(!(/^\d{4}-\d{2}-\d{2}$/.test(t)&&e instanceof Date&&e.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),c=a[0],u=a[1],l=n.isDefaultApi?"apicdn.sanity.io":u;return n.useProjectHostname?(n.url="".concat(c,"://").concat(n.projectId,".").concat(u,"/v").concat(n.apiVersion),n.cdnUrl="".concat(c,"://").concat(n.projectId,".").concat(l,"/v").concat(n.apiVersion)):(n.url="".concat(n.apiHost,"/v").concat(n.apiVersion),n.cdnUrl=n.url),n};var ir=(t,e)=>Object.keys(e).concat(Object.keys(t)).reduce(((r,n)=>(r[n]=void 0===t[n]?e[n]:t[n],r)),{}),sr=(t,e)=>e.reduce(((e,r)=>(void 0===t[r]||(e[r]=t[r]),e)),{});const ar=Et,cr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],ur={includeResult:!0};function lr(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{url:n,token:o,withCredentials:i,requestTagPrefix:s}=this.config(),a=r.tag&&s?[s,r.tag].join("."):r.tag,c={...ir(r,ur),tag:a},u=sr(c,cr),l=Ut({query:t,params:e,options:{tag:a,...u}}),h="".concat(n).concat(Se(this,"listen",l));if(h.length>14800)return new ht((t=>t.error(new Error("Query too large for listener"))));const d=c.events?c.events:["mutation"],f=-1!==d.indexOf("reconnect"),p={};return(o||i)&&(p.withCredentials=!0),o&&(p.headers={Authorization:"Bearer ".concat(o)}),new ht((t=>{let e,r=u(),n=!1;function o(){n||(f&&t.next({type:"reconnect"}),n||r.readyState===ar.CLOSED&&(c(),clearTimeout(e),e=setTimeout(l,100)))}function i(e){t.error(dr(e))}function s(e){const r=hr(e);return r instanceof Error?t.error(r):t.next(r)}function a(){n=!0,c(),t.complete()}function c(){r.removeEventListener("error",o,!1),r.removeEventListener("channelError",i,!1),r.removeEventListener("disconnect",a,!1),d.forEach((t=>r.removeEventListener(t,s,!1))),r.close()}function u(){const t=new ar(h,p);return t.addEventListener("error",o,!1),t.addEventListener("channelError",i,!1),t.addEventListener("disconnect",a,!1),d.forEach((e=>t.addEventListener(e,s,!1))),t}function l(){r=u()}return function(){n=!0,c()}}))}function hr(t){try{const e=t.data&&JSON.parse(t.data)||{};return Object.assign({type:t.type},e)}catch(t){return t}}function dr(t){if(t instanceof Error)return t;const e=hr(t);return e instanceof Error?e:new Error(function(t){if(!t.error)return t.message||"Unknown listener error";if(t.error.description)return t.error.description;return"string"==typeof t.error?t.error:JSON.stringify(t.error,null,2)}(e))}var fr,pr,yr,gr,vr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},mr=(t,e,r)=>(vr(t,e,"read from private field"),r?r.call(t):e.get(t)),wr=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},br=(t,e,r,n)=>(vr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);class Cr{constructor(t,e){wr(this,fr,void 0),wr(this,pr,void 0),br(this,fr,t),br(this,pr,e)}create(t,e){return Tr(mr(this,fr),mr(this,pr),"PUT",t,e)}edit(t,e){return Tr(mr(this,fr),mr(this,pr),"PATCH",t,e)}delete(t){return Tr(mr(this,fr),mr(this,pr),"DELETE",t)}list(){return _e(mr(this,fr),mr(this,pr),{uri:"/datasets"})}}fr=new WeakMap,pr=new WeakMap;class Er{constructor(t,e){wr(this,yr,void 0),wr(this,gr,void 0),br(this,yr,t),br(this,gr,e)}create(t,e){return vt(Tr(mr(this,yr),mr(this,gr),"PUT",t,e))}edit(t,e){return vt(Tr(mr(this,yr),mr(this,gr),"PATCH",t,e))}delete(t){return vt(Tr(mr(this,yr),mr(this,gr),"DELETE",t))}list(){return vt(_e(mr(this,yr),mr(this,gr),{uri:"/datasets"}))}}function Tr(t,e,r,n,o){return Pt(n),_e(t,e,{method:r,uri:"/datasets/".concat(n),body:o})}yr=new WeakMap,gr=new WeakMap;var xr,Or,_r,Sr,jr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},kr=(t,e,r)=>(jr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ar=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Fr=(t,e,r,n)=>(jr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);class Rr{constructor(t,e){Ar(this,xr,void 0),Ar(this,Or,void 0),Fr(this,xr,t),Fr(this,Or,e)}list(){return _e(kr(this,xr),kr(this,Or),{uri:"/projects"})}getById(t){return _e(kr(this,xr),kr(this,Or),{uri:"/projects/".concat(t)})}}xr=new WeakMap,Or=new WeakMap;class Pr{constructor(t,e){Ar(this,_r,void 0),Ar(this,Sr,void 0),Fr(this,_r,t),Fr(this,Sr,e)}list(){return vt(_e(kr(this,_r),kr(this,Sr),{uri:"/projects"}))}getById(t){return vt(_e(kr(this,_r),kr(this,Sr),{uri:"/projects/".concat(t)}))}}_r=new WeakMap,Sr=new WeakMap;var Ir,Mr,qr,Dr,Nr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Wr=(t,e,r)=>(Nr(t,e,"read from private field"),r?r.call(t):e.get(t)),Hr=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},zr=(t,e,r,n)=>(Nr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);class Lr{constructor(t,e){Hr(this,Ir,void 0),Hr(this,Mr,void 0),zr(this,Ir,t),zr(this,Mr,e)}getById(t){return _e(Wr(this,Ir),Wr(this,Mr),{uri:"/users/".concat(t)})}}Ir=new WeakMap,Mr=new WeakMap;class Ur{constructor(t,e){Hr(this,qr,void 0),Hr(this,Dr,void 0),zr(this,qr,t),zr(this,Dr,e)}getById(t){return vt(_e(Wr(this,qr),Wr(this,Dr),{uri:"/users/".concat(t)}))}}qr=new WeakMap,Dr=new WeakMap;var Br,$r,Vr,Jr,Gr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},Xr=(t,e,r)=>(Gr(t,e,"read from private field"),r?r.call(t):e.get(t)),Yr=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Kr=(t,e,r,n)=>(Gr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);const Zr=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rr;Yr(this,Br,void 0),Yr(this,$r,void 0),this.config(e),Kr(this,$r,t),this.assets=new De(this,Xr(this,$r)),this.auth=new Xe(this,Xr(this,$r)),this.datasets=new Cr(this,Xr(this,$r)),this.projects=new Rr(this,Xr(this,$r)),this.users=new Lr(this,Xr(this,$r))}clone(){return new Zr(Xr(this,$r),this.config())}config(t){if(void 0===t)return{...Xr(this,Br)};if(Xr(this,Br)&&!1===Xr(this,Br).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Kr(this,Br,or(t,Xr(this,Br)||{})),this}withConfig(t){return new Zr(Xr(this,$r),{...this.config(),...t})}fetch(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ge(this,Xr(this,$r),t,e,r)}getDocument(t,e){return ve(this,Xr(this,$r),t,e)}getDocuments(t,e){return me(this,Xr(this,$r),t,e)}create(t,e){return xe(this,Xr(this,$r),t,"create",e)}createIfNotExists(t,e){return we(this,Xr(this,$r),t,e)}createOrReplace(t,e){return be(this,Xr(this,$r),t,e)}delete(t,e){return Ce(this,Xr(this,$r),t,e)}mutate(t,e){return Ee(this,Xr(this,$r),t,e)}patch(t,e){return new Yt(t,e,this)}transaction(t){return new le(t,this)}request(t){return _e(this,Xr(this,$r),t)}};let Qr=Zr;Br=new WeakMap,$r=new WeakMap;const tn=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:rr;Yr(this,Vr,void 0),Yr(this,Jr,void 0),this.listen=lr,this.config(e),Kr(this,Jr,t),this.assets=new Ne(this,Xr(this,Jr)),this.auth=new Ye(this,Xr(this,Jr)),this.datasets=new Er(this,Xr(this,Jr)),this.projects=new Pr(this,Xr(this,Jr)),this.users=new Ur(this,Xr(this,Jr)),this.observable=new Qr(t,e)}clone(){return new tn(Xr(this,Jr),this.config())}config(t){if(void 0===t)return{...Xr(this,Vr)};if(Xr(this,Vr)&&!1===Xr(this,Vr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(t),Kr(this,Vr,or(t,Xr(this,Vr)||{})),this}withConfig(t){return new tn(Xr(this,Jr),{...this.config(),...t})}fetch(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return vt(ge(this,Xr(this,Jr),t,e,r))}getDocument(t,e){return vt(ve(this,Xr(this,Jr),t,e))}getDocuments(t,e){return vt(me(this,Xr(this,Jr),t,e))}create(t,e){return vt(xe(this,Xr(this,Jr),t,"create",e))}createIfNotExists(t,e){return vt(we(this,Xr(this,Jr),t,e))}createOrReplace(t,e){return vt(be(this,Xr(this,Jr),t,e))}delete(t,e){return vt(Ce(this,Xr(this,Jr),t,e))}mutate(t,e){return vt(Ee(this,Xr(this,Jr),t,e))}patch(t,e){return new Zt(t,e,this)}transaction(t){return new ce(t,this)}request(t){return vt(_e(this,Xr(this,Jr),t))}dataRequest(t,e,r){return vt(Te(this,Xr(this,Jr),t,e,r))}};let en=tn;Vr=new WeakMap,Jr=new WeakMap;const rn=function(t){const e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;return h(t,e)}([...t,jt,R(),P(),{onRequest:t=>{if("xhr"!==t.adapter)return;const e=t.request,r=t.context;function n(t){return e=>{const n=e.lengthComputable?e.loaded/e.total*100:-1;r.channels.progress.publish({stage:t,percent:n,total:e.total,loaded:e.loaded,lengthComputable:e.lengthComputable})}}"upload"in e&&"onprogress"in e.upload&&(e.upload.onprogress=n("upload")),"onprogress"in e&&(e.onprogress=n("download"))}},St,q({implementation:ht})]);function r(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return r({maxRedirects:0,...t})}return r.defaultRequester=e,r}([]),nn=rn.defaultRequester;t.BasePatch=Gt,t.BaseTransaction=se,t.ClientError=Tt,t.ObservablePatch=Yt,t.ObservableSanityClient=Qr,t.ObservableTransaction=le,t.Patch=Zt,t.SanityClient=en,t.ServerError=xt,t.Transaction=ce,t.createClient=t=>new en(rn,t),t.requester=nn}));
|
|
14
|
+
!function(e,t){!function(n){var r=n.setTimeout,o=n.clearTimeout,s=n.XMLHttpRequest,i=n.XDomainRequest,a=n.ActiveXObject,c=n.EventSource,u=n.document,l=n.Promise,h=n.fetch,d=n.Response,f=n.TextDecoder,p=n.TextEncoder,y=n.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=h;h=function(e,t){var n=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return n._reader=t,n._aborted&&n._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function v(){this.bitsNeeded=0,this.codePoint=0}v.prototype.decode=function(e){function t(e,t,n){if(1===n)return e>=128>>t&&e<<t<=2047;if(2===n)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===n)return e>=65536>>t&&e<<t<=1114111;throw new Error}function n(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 r=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,n(s,i)))&&(s=0,i=r,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=r),0===s||t(i,s,n(s,i))||(s=0,i=r)):(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!=f&&null!=p&&function(){try{return"test"===(new f).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(f=v);var m=function(){};function w(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=m,this.onload=m,this.onerror=m,this.onreadystatechange=m,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=m}function b(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),n=e.split("\r\n"),r=0;r<n.length;r+=1){var o=n[r].split(": "),s=o.shift(),i=o.join(": ");t[b(s)]=i}this._map=t}function E(){}function T(e){this._headers=e}function x(){}function O(){this._listeners=Object.create(null)}function _(e){r((function(){throw e}),0)}function S(e){this.type=e,this.target=void 0}function j(e,t){S.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function A(e,t){S.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function k(e,t){S.call(this,e),this.error=t.error}w.prototype.open=function(e,t){this._abort(!0);var n=this,i=this._xhr,a=1,c=0;this._abort=function(e){0!==n._sendTimeout&&(o(n._sendTimeout),n._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=m,i.onerror=m,i.onabort=m,i.onprogress=m,i.onreadystatechange=m,i.abort(),0!==c&&(o(c),c=0),e||(n.readyState=4,n.onabort(null),n.onreadystatechange())),a=0};var u=function(){if(1===a){var e=0,t="",r=void 0;if("contentType"in i)e=200,t="OK",r=i.contentType;else try{e=i.status,t=i.statusText,r=i.getResponseHeader("Content-Type")}catch(n){e=0,t="",r=void 0}0!==e&&(a=2,n.readyState=2,n.status=e,n.statusText=t,n._contentType=r,n.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}n.readyState=3,n.responseText=e,n.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:m}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),n.readyState=4,"load"===e)n.onload(t);else if("error"===e)n.onerror(t);else{if("abort"!==e)throw new TypeError;n.onabort(t)}n.onreadystatechange()}},d=function(){c=r((function(){d()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){h("load",e)}),"onerror"in i&&(i.onerror=function(e){h("error",e)}),"onabort"in i&&(i.onabort=function(e){h("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||h(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&u())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(c=r((function(){d()}),0))},w.prototype.abort=function(){this._abort(!1)},w.prototype.getResponseHeader=function(e){return this._contentType},w.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},w.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},w.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=r((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[b(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,n,r,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,n(t)},e.onerror=function(e){e.preventDefault(),r(new Error("NetworkError"))},e.onload=function(){r(null)},e.onabort=function(){r(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var n=e.status,r=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(n,r,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},T.prototype.get=function(e){return this._headers.get(e)},x.prototype.open=function(e,t,n,r,o,s,i){var a=null,c=new y,u=c.signal,d=new f;return h(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 T(e.headers)),new l((function(e,t){var r=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=d.decode(t.value,{stream:!0});n(o),r()}})).catch((function(e){t(e)}))};r()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){r(e)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},O.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var n=t.length,r=0;r<n;r+=1){var o=t[r];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){_(e)}}},O.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];null==r&&(r=[],n[e]=r);for(var o=!1,s=0;s<r.length;s+=1)r[s]===t&&(o=!0);o||r.push(t)},O.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(null!=r){for(var o=[],s=0;s<r.length;s+=1)r[s]!==t&&o.push(r[s]);0===o.length?delete n[e]:n[e]=o}},j.prototype=Object.create(S.prototype),A.prototype=Object.create(S.prototype),k.prototype=Object.create(S.prototype);var F=-1,R=-1,I=/^text\/event\-stream(;.*)?$/i,M=function(e,t){var n=null==e?t:parseInt(e,10);return n!=n&&(n=t),P(n)},P=function(e){return Math.min(Math.max(e,1e3),18e6)},D=function(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){_(e)}};function q(e,t){O.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,n){t=String(t);var a=Boolean(n.withCredentials),c=n.lastEventIdQueryParameterName||"lastEventId",u=P(1e3),l=M(n.heartbeatTimeout,45e3),h="",d=u,f=!1,p=0,y=n.headers||{},g=n.Transport,v=N&&null==g?void 0:new w(null!=g?new g:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),m=null!=g&&"string"!=typeof g?new g:null==v?new x:new E,b=void 0,C=0,T=F,O="",_="",S="",q="",H=0,W=0,z=0,L=function(t,n,r,o){if(0===T)if(200===t&&null!=r&&I.test(r)){T=1,f=Date.now(),d=u,e.readyState=1;var s=new A("open",{status:t,statusText:n,headers:o});e.dispatchEvent(s),D(e,e.onopen,s)}else{var i="";200!==t?(n&&(n=n.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+n+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==r?"-":r.replace(/\s+/g," "))+". Aborting the connection.",$();s=new A("error",{status:t,statusText:n,headers:o});e.dispatchEvent(s),D(e,e.onerror,s),console.error(i)}},U=function(t){if(1===T){for(var n=-1,s=0;s<t.length;s+=1){(c=t.charCodeAt(s))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(n=s)}var i=(-1!==n?q:"")+t.slice(0,n+1);q=(-1===n?q:"")+t.slice(n+1),""!==t&&(f=Date.now(),p+=t.length);for(var a=0;a<i.length;a+=1){var c=i.charCodeAt(a);if(H===R&&c==="\n".charCodeAt(0))H=0;else if(H===R&&(H=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==H){1===H&&(z=a+1);var y=i.slice(W,z-1),g=i.slice(z+(z<a&&i.charCodeAt(z)===" ".charCodeAt(0)?1:0),a);"data"===y?(O+="\n",O+=g):"id"===y?_=g:"event"===y?S=g:"retry"===y?(u=M(g,u),d=u):"heartbeatTimeout"===y&&(l=M(g,l),0!==C&&(o(C),C=r((function(){V()}),l)))}if(0===H){if(""!==O){h=_,""===S&&(S="message");var v=new j(S,{data:O.slice(1),lastEventId:_});if(e.dispatchEvent(v),"open"===S?D(e,e.onopen,v):"message"===S?D(e,e.onmessage,v):"error"===S&&D(e,e.onerror,v),2===T)return}O="",S=""}H=c==="\r".charCodeAt(0)?R:0}else 0===H&&(W=a,H=1),1===H?c===":".charCodeAt(0)&&(z=a+1,H=2):2===H&&(H=3)}}},B=function(t){if(1===T||0===T){T=F,0!==C&&(o(C),C=0),C=r((function(){V()}),d),d=P(Math.min(16*u,2*d)),e.readyState=0;var n=new k("error",{error:t});e.dispatchEvent(n),D(e,e.onerror,n),null!=t&&console.error(t)}},$=function(){T=2,null!=b&&(b.abort(),b=void 0),0!==C&&(o(C),C=0),e.readyState=2},V=function(){if(C=0,T===F){f=!1,p=0,C=r((function(){V()}),l),T=0,O="",S="",_=h,q="",W=0,z=0,H=0;var n=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");n=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===c?"":e})),n+=(-1===t.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(h)}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{b=m.open(v,L,U,B,n,s,i)}catch(e){throw $(),e}}else if(f||null==b){var d=Math.max((f||Date.now())+l-Date.now(),1);f=!1,C=r((function(){V()}),d)}else B(new Error("No activity within "+l+" milliseconds. "+(0===T?"No response received.":p+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=$,V()}(this,e,t)}var N=null!=h&&null!=d&&"body"in d.prototype;q.prototype=Object.create(O.prototype),q.prototype.CONNECTING=0,q.prototype.OPEN=1,q.prototype.CLOSED=2,q.prototype.close=function(){this._close()},q.CONNECTING=0,q.OPEN=1,q.CLOSED=2,q.prototype.withCredentials=void 0;var H,W=c;null==s||null!=c&&"withCredentials"in c.prototype||(W=q),H=function(e){e.EventSourcePolyfill=q,e.NativeEventSource=c,e.EventSource=W}(t),void 0!==H&&(e.exports=H)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:i:globalThis)}({get exports(){return be},set exports(e){be=e}},be);var Ce=be.EventSourcePolyfill;class Ee extends Error{constructor(e){const t=xe(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class Te extends Error{constructor(e){const t=xe(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function xe(e){const t=e.body,n={response:e,statusCode:e.statusCode,responseBody:Oe(t,e),message:"",details:void 0};return t.error&&t.message?(n.message="".concat(t.error," - ").concat(t.message),n):t.error&&t.error.description?(n.message=t.error.description,n.details=t.error,n):(n.message=t.error||t.message||function(e){const t=e.statusMessage?" ".concat(e.statusMessage):"";return"".concat(e.method,"-request to ").concat(e.url," resulted in HTTP ").concat(e.statusCode).concat(t)}(e),n)}function Oe(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const _e={onResponse:e=>{if(e.statusCode>=500)throw new Te(e);if(e.statusCode>=400)throw new Ee(e);return e}},Se={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};const je="X-Sanity-Project-ID";function Ae(e){if("string"==typeof e||Array.isArray(e))return{id: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".concat(t))}const ke=["image","file"],Fe=["before","after","replace"],Re=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")},Ie=e=>{if(-1===ke.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(ke.join(", ")))},Me=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},Pe=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_.-]+$/i.test(t))throw new Error("".concat(e,'(): "').concat(t,'" is not a valid document ID'))},De=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));Pe(e,t._id)},qe=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ne=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};var He,We,ze=e=>{let{query:t,params:n={},options:r={}}=e;const o=new URLSearchParams,{tag:s,...i}=r;s&&o.set("tag",s),o.set("query",t);for(const[e,t]of Object.entries(n))o.set("$".concat(e),JSON.stringify(t));for(const[e,t]of Object.entries(i))t&&o.set(e,"".concat(t));return"?".concat(o)},Le=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ue=(e,t,n)=>(Le(e,t,"read from private field"),n?n.call(e):t.get(e)),Be=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},$e=(e,t,n,r)=>(Le(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Ve{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Me("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,n){return((e,t,n)=>{const r="insert(at, selector, items)";if(-1===Fe.indexOf(e)){const e=Fe.map((e=>'"'.concat(e,'"'))).join(", ");throw new Error("".concat(r,' takes an "at"-argument which is one of: ').concat(e))}if("string"!=typeof t)throw new Error("".concat(r,' takes a "selector"-argument which must be a string'));if(!Array.isArray(n))throw new Error("".concat(r,' takes an "items"-argument which must be an array'))})(e,t,n),this._assign("insert",{[e]:t,items:n})}append(e,t){return this.insert("after","".concat(e,"[-1]"),t)}prepend(e,t){return this.insert("before","".concat(e,"[0]"),t)}splice(e,t,n,r){const o=t<0?t-1:t,s=void 0===n||-1===n?-1:Math.max(0,t+n),i=o<0&&s>=0?"":s,a="".concat(e,"[").concat(o,":").concat(i,"]");return this.insert("replace",a,r||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...Ae(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Me(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},n&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}const Je=class extends Ve{constructor(e,t,n){super(e,t),Be(this,He,void 0),$e(this,He,n)}clone(){return new Je(this.selection,{...this.operations},Ue(this,He))}commit(e){if(!Ue(this,He))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,n=Object.assign({returnFirst:t,returnDocuments:!0},e);return Ue(this,He).mutate({patch:this.serialize()},n)}};let Ge=Je;He=new WeakMap;const Xe=class extends Ve{constructor(e,t,n){super(e,t),Be(this,We,void 0),$e(this,We,n)}clone(){return new Xe(this.selection,{...this.operations},Ue(this,We))}commit(e){if(!Ue(this,We))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,n=Object.assign({returnFirst:t,returnDocuments:!0},e);return Ue(this,We).mutate({patch:this.serialize()},n)}};let Ye=Xe;We=new WeakMap;var Ke,Ze,Qe=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},et=(e,t,n)=>(Qe(e,t,"read from private field"),n?n.call(e):t.get(e)),tt=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},nt=(e,t,n,r)=>(Qe(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const rt={returnDocuments:!1};class ot{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;this.operations=e,this.trxId=t}create(e){return Me("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Me(t,e),De(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Me(t,e),De(t,e),this._add({[t]:e})}delete(e){return Pe("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}}const st=class extends ot{constructor(e,t,n){super(e,n),tt(this,Ke,void 0),nt(this,Ke,t)}clone(){return new st([...this.operations],et(this,Ke),this.trxId)}commit(e){if(!et(this,Ke))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return et(this,Ke).mutate(this.serialize(),Object.assign({transactionId:this.trxId},rt,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof Ye)return this._add({patch:e.serialize()});if(n){const n=t(new Ye(e,{},et(this,Ke)));if(!(n instanceof Ye))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:n.serialize()})}return this._add({patch:{id:e,...t}})}};let it=st;Ke=new WeakMap;const at=class extends ot{constructor(e,t,n){super(e,n),tt(this,Ze,void 0),nt(this,Ze,t)}clone(){return new at([...this.operations],et(this,Ze),this.trxId)}commit(e){if(!et(this,Ze))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return et(this,Ze).mutate(this.serialize(),Object.assign({transactionId:this.trxId},rt,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof Ge)return this._add({patch:e.serialize()});if(n){const n=t(new Ge(e,{},et(this,Ze)));if(!(n instanceof Ge))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:n.serialize()})}return this._add({patch:{id:e,...t}})}};let ct=at;Ze=new WeakMap;const ut=(e,t)=>!1===e?void 0:void 0===e?t:e,lt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:ut(e.returnDocuments,!0),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation}},ht=e=>"response"===e.type,dt=e=>e.body,ft=(e,t)=>e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null));function pt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=!1===o.filterResponse?e=>e:e=>e.result;return Ct(e,t,"query",{query:n,params:r},o).pipe(me(s))}function yt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:Ot(e,"doc",n),json:!0,tag:r.tag};return Tt(e,t,o).pipe(we(ht),me((e=>e.body.documents&&e.body.documents[0])))}function gt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:Ot(e,"doc",n.join(",")),json:!0,tag:r.tag};return Tt(e,t,o).pipe(we(ht),me((e=>{const t=ft(e.body.documents||[],(e=>e._id));return n.map((e=>t[e]||null))})))}function vt(e,t,n,r){return De("createIfNotExists",n),Et(e,t,n,"createIfNotExists",r)}function mt(e,t,n,r){return De("createOrReplace",n),Et(e,t,n,"createOrReplace",r)}function wt(e,t,n,r){return Ct(e,t,"mutate",{mutations:[{delete:Ae(n)}]},r)}function bt(e,t,n,r){const o=n instanceof Ye||n instanceof Ge||n instanceof it||n instanceof ct?n.serialize():n;return Ct(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:r&&r.transactionId},r)}function Ct(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===n,i="query"===n,a=s?"":ze(r),c=!s&&a.length<11264,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p}=o,y=Ot(e,n,u),g={method:c?"GET":"POST",uri:y,json:!0,body:c?void 0:r,query:s&<(o),timeout:h,headers:p,token:d,tag:f,canUseCdn:i,signal:o.signal};return Tt(e,t,g).pipe(we(ht),me(dt),me((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const n=l?"documentId":"documentIds",r=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[n]:r}})))}function Et(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s={[r]:n},i=Object.assign({returnFirst:!0,returnDocuments:!0},o);return Ct(e,t,"mutate",{mutations:[s]},i)}function Tt(e,t,n){const r=n.url||n.uri,o=e.config(),s=void 0===n.canUseCdn?["GET","HEAD"].indexOf(n.method||"GET")>=0&&0===r.indexOf("/data/"):n.canUseCdn,i=o.useCdn&&s,a=n.tag&&o.requestTagPrefix?[o.requestTagPrefix,n.tag].join("."):n.tag||o.requestTagPrefix;a&&(n.query={tag:Ne(a),...n.query});const c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={},r=t.token||e.token;r&&(n.Authorization="Bearer ".concat(r)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(n[je]=e.projectId);const o=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),s=void 0===t.timeout?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},n,t.headers||{}),timeout:void 0===s?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o})}(o,Object.assign({},n,{url:_t(e,r,i)})),u=new he((e=>t(c,o.requester).subscribe(e)));return n.signal?u.pipe((l=n.signal,e=>new he((t=>{const n=()=>t.error(function(e){var t,n;if(St)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const r=new Error(null!=(n=null==e?void 0:e.reason)?n:"The operation was aborted.");return r.name="AbortError",r}(l));if(l&&l.aborted)return void n();const r=e.subscribe(t);return l.addEventListener("abort",n),()=>{l.removeEventListener("abort",n),r.unsubscribe()}})))):u;var l}function xt(e,t,n){return Tt(e,t,n).pipe(we((e=>"response"===e.type)),me((e=>e.body)))}function Ot(e,t,n){const r=e.config(),o=qe(r),s="/".concat(t,"/").concat(o),i=n?"".concat(s,"/").concat(n):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function _t(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:r,cdnUrl:o}=e.config(),s=n?o:r;return"".concat(s,"/").concat(t.replace(/^\//,""))}const St=Boolean(globalThis.DOMException);var jt,At,kt,Ft,Rt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},It=(e,t,n)=>(Rt(e,t,"read from private field"),n?n.call(e):t.get(e)),Mt=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Pt=(e,t,n,r)=>(Rt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Dt{constructor(e,t){Mt(this,jt,void 0),Mt(this,At,void 0),Pt(this,jt,e),Pt(this,At,t)}upload(e,t,n){return Nt(It(this,jt),It(this,At),e,t,n)}}jt=new WeakMap,At=new WeakMap;class qt{constructor(e,t){Mt(this,kt,void 0),Mt(this,Ft,void 0),Pt(this,kt,e),Pt(this,Ft,t)}upload(e,t,n){return ve(Nt(It(this,kt),It(this,Ft),e,t,n).pipe(we((e=>"response"===e.type)),me((e=>e.body.document))))}}function Nt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Ie(n);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=qe(e.config()),a="image"===n?"images":"files",c=Ht(o,r),{tag:u,label:l,title:h,description:d,creditLine:f,filename:p,source:y}=c,g={label:l,title:h,description:d,filename:p,meta:s,creditLine:f};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),Tt(e,t,{tag:u,method:"POST",timeout:c.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:r})}function Ht(e,t){return"undefined"!=typeof window&&t instanceof window.File?Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e):e}kt=new WeakMap,Ft=new WeakMap;function Wt(e){return"https://www.sanity.io/help/"+e}const zt=e=>(e=>{let t,n=!1;return function(){return n||(t=e(...arguments),n=!0),t}})((function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return console.warn(e.join(" "),...n)})),Lt=zt(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and","cheaper. Think about it! For more info, see ".concat(Wt("js-client-cdn-configuration")," "),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),Ut=zt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(Wt("js-client-browser-token")," for more information and how to hide this warning.")]),Bt=zt(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(Wt("js-client-api-version"))]),$t={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},Vt=["localhost","127.0.0.1","0.0.0.0"],Jt=(e,t)=>{const n=Object.assign({},t,e);n.apiVersion||Bt();const r=Object.assign({},$t,n),o=r.useProjectHostname;if("undefined"==typeof Promise){const e=Wt("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(e))}if(o&&!r.projectId)throw new Error("Configuration must contain `projectId`");const s="undefined"!=typeof window&&window.location&&window.location.hostname,i=s&&(e=>-1!==Vt.indexOf(e))(window.location.hostname);s&&i&&r.token&&!0!==r.ignoreBrowserTokenWarning?Ut():void 0===r.useCdn&&Lt(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(r.projectId),r.dataset&&Re(r.dataset),"requestTagPrefix"in r&&(r.requestTagPrefix=r.requestTagPrefix?Ne(r.requestTagPrefix).replace(/\.+$/,""):void 0),r.apiVersion="".concat(r.apiVersion).replace(/^v/,""),r.isDefaultApi=r.apiHost===$t.apiHost,r.useCdn=Boolean(r.useCdn)&&!r.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`")}(r.apiVersion);const a=r.apiHost.split("://",2),c=a[0],u=a[1],l=r.isDefaultApi?"apicdn.sanity.io":u;return r.useProjectHostname?(r.url="".concat(c,"://").concat(r.projectId,".").concat(u,"/v").concat(r.apiVersion),r.cdnUrl="".concat(c,"://").concat(r.projectId,".").concat(l,"/v").concat(r.apiVersion)):(r.url="".concat(r.apiHost,"/v").concat(r.apiVersion),r.cdnUrl=r.url),r};var Gt=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((n,r)=>(n[r]=void 0===e[r]?t[r]:e[r],n)),{}),Xt=(e,t)=>t.reduce(((t,n)=>(void 0===e[n]||(t[n]=e[n]),t)),{});const Yt=Ce,Kt=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Zt={includeResult:!0};function Qt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{url:r,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=n.tag&&i?[i,n.tag].join("."):n.tag,c={...Gt(n,Zt),tag:a},u=Xt(c,Kt),l=ze({query:e,params:t,options:{tag:a,...u}}),h="".concat(r).concat(Ot(this,"listen",l));if(h.length>14800)return new he((e=>e.error(new Error("Query too large for listener"))));const d=c.events?c.events:["mutation"],f=-1!==d.indexOf("reconnect"),p={};return(o||s)&&(p.withCredentials=!0),o&&(p.headers={Authorization:"Bearer ".concat(o)}),new he((e=>{let t,n=u(),r=!1;function o(){r||(f&&e.next({type:"reconnect"}),r||n.readyState===Yt.CLOSED&&(c(),clearTimeout(t),t=setTimeout(l,100)))}function s(t){e.error(tn(t))}function i(t){const n=en(t);return n instanceof Error?e.error(n):e.next(n)}function a(){r=!0,c(),e.complete()}function c(){n.removeEventListener("error",o,!1),n.removeEventListener("channelError",s,!1),n.removeEventListener("disconnect",a,!1),d.forEach((e=>n.removeEventListener(e,i,!1))),n.close()}function u(){const e=new Yt(h,p);return e.addEventListener("error",o,!1),e.addEventListener("channelError",s,!1),e.addEventListener("disconnect",a,!1),d.forEach((t=>e.addEventListener(t,i,!1))),e}function l(){n=u()}return function(){r=!0,c()}}))}function en(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}function tn(e){if(e instanceof Error)return e;const t=en(e);return t instanceof Error?t:new Error(function(e){if(!e.error)return e.message||"Unknown listener error";if(e.error.description)return e.error.description;return"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2)}(t))}var nn,rn,on,sn,an=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},cn=(e,t,n)=>(an(e,t,"read from private field"),n?n.call(e):t.get(e)),un=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ln=(e,t,n,r)=>(an(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class hn{constructor(e,t){un(this,nn,void 0),un(this,rn,void 0),ln(this,nn,e),ln(this,rn,t)}create(e,t){return fn(cn(this,nn),cn(this,rn),"PUT",e,t)}edit(e,t){return fn(cn(this,nn),cn(this,rn),"PATCH",e,t)}delete(e){return fn(cn(this,nn),cn(this,rn),"DELETE",e)}list(){return xt(cn(this,nn),cn(this,rn),{uri:"/datasets"})}}nn=new WeakMap,rn=new WeakMap;class dn{constructor(e,t){un(this,on,void 0),un(this,sn,void 0),ln(this,on,e),ln(this,sn,t)}create(e,t){return ve(fn(cn(this,on),cn(this,sn),"PUT",e,t))}edit(e,t){return ve(fn(cn(this,on),cn(this,sn),"PATCH",e,t))}delete(e){return ve(fn(cn(this,on),cn(this,sn),"DELETE",e))}list(){return ve(xt(cn(this,on),cn(this,sn),{uri:"/datasets"}))}}function fn(e,t,n,r,o){return Re(r),xt(e,t,{method:n,uri:"/datasets/".concat(r),body:o})}on=new WeakMap,sn=new WeakMap;var pn,yn,gn,vn,mn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},wn=(e,t,n)=>(mn(e,t,"read from private field"),n?n.call(e):t.get(e)),bn=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Cn=(e,t,n,r)=>(mn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class En{constructor(e,t){bn(this,pn,void 0),bn(this,yn,void 0),Cn(this,pn,e),Cn(this,yn,t)}list(){return xt(wn(this,pn),wn(this,yn),{uri:"/projects"})}getById(e){return xt(wn(this,pn),wn(this,yn),{uri:"/projects/".concat(e)})}}pn=new WeakMap,yn=new WeakMap;class Tn{constructor(e,t){bn(this,gn,void 0),bn(this,vn,void 0),Cn(this,gn,e),Cn(this,vn,t)}list(){return ve(xt(wn(this,gn),wn(this,vn),{uri:"/projects"}))}getById(e){return ve(xt(wn(this,gn),wn(this,vn),{uri:"/projects/".concat(e)}))}}gn=new WeakMap,vn=new WeakMap;var xn,On,_n,Sn,jn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},An=(e,t,n)=>(jn(e,t,"read from private field"),n?n.call(e):t.get(e)),kn=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Fn=(e,t,n,r)=>(jn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Rn{constructor(e,t){kn(this,xn,void 0),kn(this,On,void 0),Fn(this,xn,e),Fn(this,On,t)}getById(e){return xt(An(this,xn),An(this,On),{uri:"/users/".concat(e)})}}xn=new WeakMap,On=new WeakMap;class In{constructor(e,t){kn(this,_n,void 0),kn(this,Sn,void 0),Fn(this,_n,e),Fn(this,Sn,t)}getById(e){return ve(xt(An(this,_n),An(this,Sn),{uri:"/users/".concat(e)}))}}_n=new WeakMap,Sn=new WeakMap;var Mn,Pn,Dn,qn,Nn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Hn=(e,t,n)=>(Nn(e,t,"read from private field"),n?n.call(e):t.get(e)),Wn=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},zn=(e,t,n,r)=>(Nn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const Ln=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$t;Wn(this,Mn,void 0),Wn(this,Pn,void 0),this.listen=Qt,this.config(t),zn(this,Pn,e),this.assets=new Dt(this,Hn(this,Pn)),this.datasets=new hn(this,Hn(this,Pn)),this.projects=new En(this,Hn(this,Pn)),this.users=new Rn(this,Hn(this,Pn))}clone(){return new Ln(Hn(this,Pn),this.config())}config(e){if(void 0===e)return{...Hn(this,Mn)};if(Hn(this,Mn)&&!1===Hn(this,Mn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return zn(this,Mn,Jt(e,Hn(this,Mn)||{})),this}withConfig(e){return new Ln(Hn(this,Pn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return pt(this,Hn(this,Pn),e,t,n)}getDocument(e,t){return yt(this,Hn(this,Pn),e,t)}getDocuments(e,t){return gt(this,Hn(this,Pn),e,t)}create(e,t){return Et(this,Hn(this,Pn),e,"create",t)}createIfNotExists(e,t){return vt(this,Hn(this,Pn),e,t)}createOrReplace(e,t){return mt(this,Hn(this,Pn),e,t)}delete(e,t){return wt(this,Hn(this,Pn),e,t)}mutate(e,t){return bt(this,Hn(this,Pn),e,t)}patch(e,t){return new Ge(e,t,this)}transaction(e){return new ct(e,this)}request(e){return xt(this,Hn(this,Pn),e)}};let Un=Ln;Mn=new WeakMap,Pn=new WeakMap;const Bn=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$t;Wn(this,Dn,void 0),Wn(this,qn,void 0),this.listen=Qt,this.config(t),zn(this,qn,e),this.assets=new qt(this,Hn(this,qn)),this.datasets=new dn(this,Hn(this,qn)),this.projects=new Tn(this,Hn(this,qn)),this.users=new In(this,Hn(this,qn)),this.observable=new Un(e,t)}clone(){return new Bn(Hn(this,qn),this.config())}config(e){if(void 0===e)return{...Hn(this,Dn)};if(Hn(this,Dn)&&!1===Hn(this,Dn).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),zn(this,Dn,Jt(e,Hn(this,Dn)||{})),this}withConfig(e){return new Bn(Hn(this,qn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ve(pt(this,Hn(this,qn),e,t,n))}getDocument(e,t){return ve(yt(this,Hn(this,qn),e,t))}getDocuments(e,t){return ve(gt(this,Hn(this,qn),e,t))}create(e,t){return ve(Et(this,Hn(this,qn),e,"create",t))}createIfNotExists(e,t){return ve(vt(this,Hn(this,qn),e,t))}createOrReplace(e,t){return ve(mt(this,Hn(this,qn),e,t))}delete(e,t){return ve(wt(this,Hn(this,qn),e,t))}mutate(e,t){return ve(bt(this,Hn(this,qn),e,t))}patch(e,t){return new Ye(e,t,this)}transaction(e){return new it(e,this)}request(e){return ve(xt(this,Hn(this,qn),e))}dataRequest(e,t,n){return ve(Ct(this,Hn(this,qn),e,t,n))}};let $n=Bn;Dn=new WeakMap,qn=new WeakMap;const Vn=function(e){const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;return h(e,t)}([...e,Se,R(),I(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,n=e.context;function r(e){return t=>{const r=t.lengthComputable?t.loaded/t.total*100:-1;n.channels.progress.publish({stage:e,percent:r,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=r("upload")),"onprogress"in t&&(t.onprogress=r("download"))}},_e,D({implementation:he})]);function n(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return n({maxRedirects:0,...e})}return n.defaultRequester=t,n}([]),Jn=Vn.defaultRequester;e.BasePatch=Ve,e.BaseTransaction=ot,e.ClientError=Ee,e.ObservablePatch=Ge,e.ObservableSanityClient=Un,e.ObservableTransaction=ct,e.Patch=Ye,e.SanityClient=$n,e.ServerError=Te,e.Transaction=it,e.createClient=e=>new $n(Vn,e),e.default=function(){throw new TypeError("The default export of @sanity/client has been deprecated. Use the named export `createClient` instead")},e.requester=Jn,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/src/auth/AuthClient.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {type Observable, lastValueFrom} from 'rxjs'
|
|
2
|
-
|
|
3
|
-
import {_request} from '../data/dataMethods'
|
|
4
|
-
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
|
-
import type {AuthProviderResponse, HttpRequest} from '../types'
|
|
6
|
-
|
|
7
|
-
/** @internal */
|
|
8
|
-
export class ObservableAuthClient {
|
|
9
|
-
#client: ObservableSanityClient
|
|
10
|
-
#httpRequest: HttpRequest
|
|
11
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {
|
|
12
|
-
this.#client = client
|
|
13
|
-
this.#httpRequest = httpRequest
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Fetch available login providers
|
|
18
|
-
*/
|
|
19
|
-
getLoginProviders(): Observable<AuthProviderResponse> {
|
|
20
|
-
return _request<AuthProviderResponse>(this.#client, this.#httpRequest, {
|
|
21
|
-
uri: '/auth/providers',
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Revoke the configured session/token
|
|
27
|
-
*/
|
|
28
|
-
logout(): Observable<void> {
|
|
29
|
-
return _request<void>(this.#client, this.#httpRequest, {
|
|
30
|
-
uri: '/auth/logout',
|
|
31
|
-
method: 'POST',
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @internal */
|
|
37
|
-
export class AuthClient {
|
|
38
|
-
#client: SanityClient
|
|
39
|
-
#httpRequest: HttpRequest
|
|
40
|
-
constructor(client: SanityClient, httpRequest: HttpRequest) {
|
|
41
|
-
this.#client = client
|
|
42
|
-
this.#httpRequest = httpRequest
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Fetch available login providers
|
|
47
|
-
*/
|
|
48
|
-
getLoginProviders(): Promise<AuthProviderResponse> {
|
|
49
|
-
return lastValueFrom(
|
|
50
|
-
_request<AuthProviderResponse>(this.#client, this.#httpRequest, {
|
|
51
|
-
uri: '/auth/providers',
|
|
52
|
-
})
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Revoke the configured session/token
|
|
58
|
-
*/
|
|
59
|
-
logout(): Promise<void> {
|
|
60
|
-
return lastValueFrom(
|
|
61
|
-
_request<void>(this.#client, this.#httpRequest, {
|
|
62
|
-
uri: '/auth/logout',
|
|
63
|
-
method: 'POST',
|
|
64
|
-
})
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
}
|