@sanity/client 0.0.0-dev.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/LICENSE +21 -0
- package/README.md +1225 -0
- package/dist/index.browser.cjs +1760 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.js +1737 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +1769 -0
- package/dist/index.cjs.js +16 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2234 -0
- package/dist/index.js +1746 -0
- package/dist/index.js.map +1 -0
- package/package.json +127 -0
- package/src/SanityClient.ts +1253 -0
- package/src/assets/AssetsClient.ts +191 -0
- package/src/config.ts +96 -0
- package/src/data/dataMethods.ts +416 -0
- package/src/data/encodeQueryString.ts +29 -0
- package/src/data/listen.ts +196 -0
- package/src/data/patch.ts +345 -0
- package/src/data/transaction.ts +358 -0
- package/src/datasets/DatasetsClient.ts +115 -0
- package/src/generateHelpUrl.ts +5 -0
- package/src/http/browserMiddleware.ts +1 -0
- package/src/http/errors.ts +68 -0
- package/src/http/nodeMiddleware.ts +11 -0
- package/src/http/request.ts +48 -0
- package/src/http/requestOptions.ts +33 -0
- package/src/index.browser.ts +28 -0
- package/src/index.ts +28 -0
- package/src/projects/ProjectsClient.ts +61 -0
- package/src/types.ts +575 -0
- package/src/users/UsersClient.ts +55 -0
- package/src/util/defaults.ts +10 -0
- package/src/util/getSelection.ts +21 -0
- package/src/util/once.ts +14 -0
- package/src/util/pick.ts +11 -0
- package/src/validators.ts +78 -0
- package/src/warnings.ts +30 -0
- package/umd/.gitkeep +1 -0
- package/umd/sanityClient.js +4840 -0
- package/umd/sanityClient.min.js +14 -0
|
@@ -0,0 +1,14 @@
|
|
|
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},u=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;n++){if(o=(0,e[t][n])(o,...i),r&&!o)break}return o};const l=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const r=[],o=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[n],validateOptions:[s]});function i(e){const n=l.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=u(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 h=r("onReturn",n,i);return h===n&&n.request.publish(i),h}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 h.forEach((t=>{e[t]&&o[t].push(e[t])})),r.push(e),i},i.clone=function(){return d(r,t)},e.forEach(i.use),i}var f,p,y,g,v,m=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},w=(e,t,n)=>(m(e,t,"read from private field"),n?n.call(e):t.get(e)),b=(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)},C=(e,t,n,r)=>(m(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);f=new WeakMap,p=new WeakMap,y=new WeakMap,g=new WeakMap,v=new WeakMap;const E="function"==typeof XMLHttpRequest?"xhr":"fetch",T="xhr"===E?XMLHttpRequest:class{constructor(){this.readyState=0,b(this,f,void 0),b(this,p,void 0),b(this,y,void 0),b(this,g,{}),b(this,v,void 0)}open(e,t,n){C(this,f,e),C(this,p,t),C(this,y,""),this.readyState=1,this.onreadystatechange(),C(this,v,void 0)}abort(){w(this,v)&&w(this,v).abort()}getAllResponseHeaders(){return w(this,y)}setRequestHeader(e,t){w(this,g)[e]=t}send(e){const t="arraybuffer"!==this.responseType,n={method:w(this,f),headers:w(this,g),signal:null,body:e};"function"==typeof AbortController&&(C(this,v,new AbortController),n.signal=w(this,v).signal),"undefined"!=typeof document&&(n.credentials=this.withCredentials?"include":"omit"),fetch(w(this,p),n).then((e=>(e.headers.forEach(((e,t)=>{C(this,y,w(this,y)+"".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 x=(e,t)=>{const n=e.options,r=e.applyMiddleware("finalizeOptions",n),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:E,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new T;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:E,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)}};const O=function(){return d(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],arguments.length>1&&void 0!==arguments[1]?arguments[1]:x)};var _,S,j={};function A(){if(S)return _;S=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 _=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 k=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=A(),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
|
+
/*!
|
|
3
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
function F(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=k(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}({get exports(){return j},set exports(e){j=e}},j);const R="undefined"==typeof Buffer?()=>!1:e=>Buffer.isBuffer(e),I=["boolean","string","number"];function M(){return{processOptions:e=>{const t=e.body;if(!t)return e;var n,r,o;return!("function"==typeof t.pipe)&&!R(t)&&(-1!==I.indexOf(typeof t)||Array.isArray(t)||!1!==F(n=t)&&(void 0===(r=n.constructor)||!1!==F(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 P(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 D;D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var q=D;function N(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||q.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(t,n)=>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(n),()=>t.abort.publish())))}}class H{constructor(e){this.__CANCEL__=!0,this.message=e}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const W=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 H(e),t(this.reason))}))}};W.source=()=>{let e;return{token:new W((t=>{e=t})),cancel:e}};var z=function(e,t){return z=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])},z(e,t)};function U(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}z(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function L(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 B(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 V(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 $(e){return"function"==typeof e}function J(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var G=J((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function X(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Y=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=L(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if($(c))try{c()}catch(e){o=e instanceof G?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=L(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{Z(d)}catch(e){o=null!=o?o:[],e instanceof G?o=V(V([],B(o)),B(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 G(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Z(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)&&X(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&X(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function K(e){return e instanceof Y||e&&"closed"in e&&$(e.remove)&&$(e.add)&&$(e.unsubscribe)}function Z(e){$(e)?e():e.unsubscribe()}Y.EMPTY;var Q={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ee={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=ee.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,V([e,t],B(n))):setTimeout.apply(void 0,V([e,t],B(n)))},clearTimeout:function(e){var t=ee.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function te(){}var ne=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,K(t)&&t.add(n)):n.destination=ce,n}return U(t,e),t.create=function(e,t,n){return new ie(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}(Y),re=Function.prototype.bind;function oe(e,t){return re.call(e,t)}var se=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){ae(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ae(e)}else ae(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ae(e)}},e}(),ie=function(e){function t(t,n,r){var o,s,i=e.call(this)||this;$(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:i&&Q.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&oe(t.next,s),error:t.error&&oe(t.error,s),complete:t.complete&&oe(t.complete,s)}):o=t;return i.destination=new se(o),i}return U(t,e),t}(ne);function ae(e){var t;t=e,ee.setTimeout((function(){throw t}))}var ce={closed:!0,next:te,error:function(e){throw e},complete:te},ue="function"==typeof Symbol&&Symbol.observable||"@@observable";function le(e){return e}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 ne||function(e){return e&&$(e.next)&&$(e.error)&&$(e.complete)}(r)&&K(r)?e:new ie(e,t,n);return 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 ie({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[ue]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(0===(e=t).length?le:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(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:Q.Promise)&&void 0!==t?t:Promise}function fe(e){return function(t){if(function(e){return $(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 U(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}(ne),ge=J((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
|
+
/** @license
|
|
10
|
+
* eventsource.js
|
|
11
|
+
* Available under MIT License (MIT)
|
|
12
|
+
* https://github.com/Yaffle/EventSource/
|
|
13
|
+
*/
|
|
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=0,I=1,M=2,P=-1,D=0,q=1,N=2,H=3,W=/^text\/event\-stream(;.*)?$/i,z=function(e,t){var n=null==e?t:parseInt(e,10);return n!=n&&(n=t),U(n)},U=function(e){return Math.min(Math.max(e,1e3),18e6)},L=function(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){_(e)}};function B(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=U(1e3),l=z(n.heartbeatTimeout,45e3),h="",d=u,f=!1,p=0,y=n.headers||{},g=n.Transport,v=V&&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="",B="",$=D,J=0,G=0,X=function(t,n,r,o){if(T===R)if(200===t&&null!=r&&W.test(r)){T=I,f=Date.now(),d=u,e.readyState=I;var s=new A("open",{status:t,statusText:n,headers:o});e.dispatchEvent(s),L(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.",Z();s=new A("error",{status:t,statusText:n,headers:o});e.dispatchEvent(s),L(e,e.onerror,s),console.error(i)}},Y=function(t){if(T===I){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?B:"")+t.slice(0,n+1);B=(-1===n?B:"")+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($===P&&c==="\n".charCodeAt(0))$=D;else if($===P&&($=D),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if($!==D){$===q&&(G=a+1);var y=i.slice(J,G-1),g=i.slice(G+(G<a&&i.charCodeAt(G)===" ".charCodeAt(0)?1:0),a);"data"===y?(O+="\n",O+=g):"id"===y?_=g:"event"===y?S=g:"retry"===y?(u=z(g,u),d=u):"heartbeatTimeout"===y&&(l=z(g,l),0!==C&&(o(C),C=r((function(){Q()}),l)))}if($===D){if(""!==O){h=_,""===S&&(S="message");var v=new j(S,{data:O.slice(1),lastEventId:_});if(e.dispatchEvent(v),"open"===S?L(e,e.onopen,v):"message"===S?L(e,e.onmessage,v):"error"===S&&L(e,e.onerror,v),T===M)return}O="",S=""}$=c==="\r".charCodeAt(0)?P:D}else $===D&&(J=a,$=q),$===q?c===":".charCodeAt(0)&&(G=a+1,$=N):$===N&&($=H)}}},K=function(t){if(T===I||T===R){T=F,0!==C&&(o(C),C=0),C=r((function(){Q()}),d),d=U(Math.min(16*u,2*d)),e.readyState=R;var n=new k("error",{error:t});e.dispatchEvent(n),L(e,e.onerror,n),null!=t&&console.error(t)}},Z=function(){T=M,null!=b&&(b.abort(),b=void 0),0!==C&&(o(C),C=0),e.readyState=M},Q=function(){if(C=0,T===F){f=!1,p=0,C=r((function(){Q()}),l),T=R,O="",S="",_=h,B="",J=0,G=0,$=D;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,X,Y,K,n,s,i)}catch(e){throw Z(),e}}else if(f||null==b){var d=Math.max((f||Date.now())+l-Date.now(),1);f=!1,C=r((function(){Q()}),d)}else K(new Error("No activity within "+l+" milliseconds. "+(T===R?"No response received.":p+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=R,e.withCredentials=a,e.headers=y,e._close=Z,Q()}(this,e,t)}var V=null!=h&&null!=d&&"body"in d.prototype;B.prototype=Object.create(O.prototype),B.prototype.CONNECTING=R,B.prototype.OPEN=I,B.prototype.CLOSED=M,B.prototype.close=function(){this._close()},B.CONNECTING=R,B.OPEN=I,B.CLOSED=M,B.prototype.withCredentials=void 0;var $,J=c;null==s||null!=c&&"withCredentials"in c.prototype||(J=B),$=function(e){e.EventSourcePolyfill=B,e.NativeEventSource=c,e.EventSource=J}(t),void 0!==$&&(e.exports=$)}("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},He=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)};var We,ze,Ue=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Le=(e,t,n)=>(Ue(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)},Ve=(e,t,n,r)=>(Ue(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class $e{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 $e{constructor(e,t,n){super(e,t),Be(this,We,void 0),Ve(this,We,n)}clone(){return new Je(this.selection,{...this.operations},Le(this,We))}commit(e){if(!Le(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 Le(this,We).mutate({patch:this.serialize()},n)}};let Ge=Je;We=new WeakMap;const Xe=class extends $e{constructor(e,t,n){super(e,t),Be(this,ze,void 0),Ve(this,ze,n)}clone(){return new Xe(this.selection,{...this.operations},Le(this,ze))}commit(e){if(!Le(this,ze))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 Le(this,ze).mutate({patch:this.serialize()},n)}};let Ye=Xe;ze=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)),pt=11264;function yt(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 Et(e,t,"query",{query:n,params:r},o).pipe(me(s))}function gt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return xt(e,t,{uri:_t(e,"doc",n),json:!0,tag:r.tag}).pipe(we(ht),me((e=>e.body.documents&&e.body.documents[0])))}function vt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return xt(e,t,{uri:_t(e,"doc",n.join(",")),json:!0,tag:r.tag}).pipe(we(ht),me((e=>{const t=ft(e.body.documents||[],(e=>e._id));return n.map((e=>t[e]||null))})))}function mt(e,t,n,r){return De("createIfNotExists",n),Tt(e,t,n,"createIfNotExists",r)}function wt(e,t,n,r){return De("createOrReplace",n),Tt(e,t,n,"createOrReplace",r)}function bt(e,t,n,r){return Et(e,t,"mutate",{mutations:[{delete:Ae(n)}]},r)}function Ct(e,t,n,r){const o=n instanceof Ye||n instanceof Ge||n instanceof it||n instanceof ct?n.serialize():n;return Et(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:r&&r.transactionId},r)}function Et(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===n,i="query"===n,a=s?"":He(r),c=!s&&a.length<pt,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p}=o;return xt(e,t,{method:c?"GET":"POST",uri:_t(e,n,u),json:!0,body:c?void 0:r,query:s&<(o),timeout:h,headers:p,token:d,tag:f,canUseCdn:i,signal:o.signal}).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 Tt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return Et(e,t,"mutate",{mutations:[{[r]:n}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function xt(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}),o.unstable_overlayDrafts&&("X"!==o.apiVersion&&console.error("You need to set `apiVersion` to `X` to use `unstable_overlayDrafts"),n.query={overlayDrafts:!0,...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:St(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(jt)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 Ot(e,t,n){return xt(e,t,n).pipe(we((e=>"response"===e.type)),me((e=>e.body)))}function _t(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 St(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:r,cdnUrl:o}=e.config();return"".concat(n?o:r,"/").concat(t.replace(/^\//,""))}const jt=Boolean(globalThis.DOMException);var At,kt,Ft,Rt,It=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Mt=(e,t,n)=>(It(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(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)},Dt=(e,t,n,r)=>(It(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class qt{constructor(e,t){Pt(this,At,void 0),Pt(this,kt,void 0),Dt(this,At,e),Dt(this,kt,t)}upload(e,t,n){return Ht(Mt(this,At),Mt(this,kt),e,t,n)}}At=new WeakMap,kt=new WeakMap;class Nt{constructor(e,t){Pt(this,Ft,void 0),Pt(this,Rt,void 0),Dt(this,Ft,e),Dt(this,Rt,t)}upload(e,t,n){return ve(Ht(Mt(this,Ft),Mt(this,Rt),e,t,n).pipe(we((e=>"response"===e.type)),me((e=>e.body.document))))}}function Ht(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=function(e,t){if("undefined"==typeof window||!(t instanceof window.File))return e;return Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(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),xt(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})}Ft=new WeakMap,Rt=new WeakMap;const Wt="https://www.sanity.io/help/";function zt(e){return Wt+e}const Ut=e=>function(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=Ut(["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(zt("js-client-cdn-configuration")," "),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),Bt=Ut(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(zt("js-client-browser-token")," for more information and how to hide this warning.")]),Vt=Ut(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(zt("js-client-api-version"))]),$t=Ut(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]),Jt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},Gt=["localhost","127.0.0.1","0.0.0.0"],Xt=(e,t)=>{const n=Object.assign({},t,e);n.apiVersion||Vt();const r=Object.assign({},Jt,n),o=r.useProjectHostname;if("undefined"==typeof Promise){const e=zt("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!==Gt.indexOf(e))(window.location.hostname);s&&i&&r.token&&!0!==r.ignoreBrowserTokenWarning?Bt():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===Jt.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 Yt=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((n,r)=>(n[r]=void 0===e[r]?t[r]:e[r],n)),{});const Kt=(e,t)=>t.reduce(((t,n)=>(void 0===e[n]||(t[n]=e[n]),t)),{}),Zt=14800,Qt=Ce,en=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],tn={includeResult:!0};function nn(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={...Yt(n,tn),tag:a},u=Kt(c,en),l=He({query:e,params:t,options:{tag:a,...u}}),h="".concat(r).concat(_t(this,"listen",l));if(h.length>Zt)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===Qt.CLOSED&&(c(),clearTimeout(t),t=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=rn(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))}(t))}function i(t){const n=rn(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 Qt(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 rn(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var on,sn,an,cn,un=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},ln=(e,t,n)=>(un(e,t,"read from private field"),n?n.call(e):t.get(e)),hn=(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)},dn=(e,t,n,r)=>(un(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class fn{constructor(e,t){hn(this,on,void 0),hn(this,sn,void 0),dn(this,on,e),dn(this,sn,t)}create(e,t){return yn(ln(this,on),ln(this,sn),"PUT",e,t)}edit(e,t){return yn(ln(this,on),ln(this,sn),"PATCH",e,t)}delete(e){return yn(ln(this,on),ln(this,sn),"DELETE",e)}list(){return Ot(ln(this,on),ln(this,sn),{uri:"/datasets"})}}on=new WeakMap,sn=new WeakMap;class pn{constructor(e,t){hn(this,an,void 0),hn(this,cn,void 0),dn(this,an,e),dn(this,cn,t)}create(e,t){return ve(yn(ln(this,an),ln(this,cn),"PUT",e,t))}edit(e,t){return ve(yn(ln(this,an),ln(this,cn),"PATCH",e,t))}delete(e){return ve(yn(ln(this,an),ln(this,cn),"DELETE",e))}list(){return ve(Ot(ln(this,an),ln(this,cn),{uri:"/datasets"}))}}function yn(e,t,n,r,o){return Re(r),Ot(e,t,{method:n,uri:"/datasets/".concat(r),body:o})}an=new WeakMap,cn=new WeakMap;var gn,vn,mn,wn,bn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Cn=(e,t,n)=>(bn(e,t,"read from private field"),n?n.call(e):t.get(e)),En=(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)},Tn=(e,t,n,r)=>(bn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class xn{constructor(e,t){En(this,gn,void 0),En(this,vn,void 0),Tn(this,gn,e),Tn(this,vn,t)}list(){return Ot(Cn(this,gn),Cn(this,vn),{uri:"/projects"})}getById(e){return Ot(Cn(this,gn),Cn(this,vn),{uri:"/projects/".concat(e)})}}gn=new WeakMap,vn=new WeakMap;class On{constructor(e,t){En(this,mn,void 0),En(this,wn,void 0),Tn(this,mn,e),Tn(this,wn,t)}list(){return ve(Ot(Cn(this,mn),Cn(this,wn),{uri:"/projects"}))}getById(e){return ve(Ot(Cn(this,mn),Cn(this,wn),{uri:"/projects/".concat(e)}))}}mn=new WeakMap,wn=new WeakMap;var _n,Sn,jn,An,kn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Fn=(e,t,n)=>(kn(e,t,"read from private field"),n?n.call(e):t.get(e)),Rn=(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)},In=(e,t,n,r)=>(kn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Mn{constructor(e,t){Rn(this,_n,void 0),Rn(this,Sn,void 0),In(this,_n,e),In(this,Sn,t)}getById(e){return Ot(Fn(this,_n),Fn(this,Sn),{uri:"/users/".concat(e)})}}_n=new WeakMap,Sn=new WeakMap;class Pn{constructor(e,t){Rn(this,jn,void 0),Rn(this,An,void 0),In(this,jn,e),In(this,An,t)}getById(e){return ve(Ot(Fn(this,jn),Fn(this,An),{uri:"/users/".concat(e)}))}}jn=new WeakMap,An=new WeakMap;var Dn,qn,Nn,Hn,Wn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},zn=(e,t,n)=>(Wn(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)=>(Wn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const Bn=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;Un(this,Dn,void 0),Un(this,qn,void 0),this.listen=nn,this.config(t),Ln(this,qn,e),this.assets=new qt(this,zn(this,qn)),this.datasets=new fn(this,zn(this,qn)),this.projects=new xn(this,zn(this,qn)),this.users=new Mn(this,zn(this,qn))}clone(){return new Bn(zn(this,qn),this.config())}config(e){if(void 0===e)return{...zn(this,Dn)};if(zn(this,Dn)&&!1===zn(this,Dn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Ln(this,Dn,Xt(e,zn(this,Dn)||{})),this}withConfig(e){return new Bn(zn(this,qn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return yt(this,zn(this,qn),e,t,n)}getDocument(e,t){return gt(this,zn(this,qn),e,t)}getDocuments(e,t){return vt(this,zn(this,qn),e,t)}create(e,t){return Tt(this,zn(this,qn),e,"create",t)}createIfNotExists(e,t){return mt(this,zn(this,qn),e,t)}createOrReplace(e,t){return wt(this,zn(this,qn),e,t)}delete(e,t){return bt(this,zn(this,qn),e,t)}mutate(e,t){return Ct(this,zn(this,qn),e,t)}patch(e,t){return new Ge(e,t,this)}transaction(e){return new ct(e,this)}request(e){return Ot(this,zn(this,qn),e)}getUrl(e,t){return St(this,e,t)}getDataUrl(e,t){return _t(this,e,t)}};let Vn=Bn;Dn=new WeakMap,qn=new WeakMap;const $n=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jt;Un(this,Nn,void 0),Un(this,Hn,void 0),this.listen=nn,this.config(t),Ln(this,Hn,e),this.assets=new Nt(this,zn(this,Hn)),this.datasets=new pn(this,zn(this,Hn)),this.projects=new On(this,zn(this,Hn)),this.users=new Pn(this,zn(this,Hn)),this.observable=new Vn(e,t)}clone(){return new $n(zn(this,Hn),this.config())}config(e){if(void 0===e)return{...zn(this,Nn)};if(zn(this,Nn)&&!1===zn(this,Nn).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),Ln(this,Nn,Xt(e,zn(this,Nn)||{})),this}withConfig(e){return new $n(zn(this,Hn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ve(yt(this,zn(this,Hn),e,t,n))}getDocument(e,t){return ve(gt(this,zn(this,Hn),e,t))}getDocuments(e,t){return ve(vt(this,zn(this,Hn),e,t))}create(e,t){return ve(Tt(this,zn(this,Hn),e,"create",t))}createIfNotExists(e,t){return ve(mt(this,zn(this,Hn),e,t))}createOrReplace(e,t){return ve(wt(this,zn(this,Hn),e,t))}delete(e,t){return ve(bt(this,zn(this,Hn),e,t))}mutate(e,t){return ve(Ct(this,zn(this,Hn),e,t))}patch(e,t){return new Ye(e,t,this)}transaction(e){return new it(e,this)}request(e){return ve(Ot(this,zn(this,Hn),e))}dataRequest(e,t,n){return ve(Et(this,zn(this,Hn),e,t,n))}getUrl(e,t){return St(this,e,t)}getDataUrl(e,t){return _t(this,e,t)}};let Jn=$n;Nn=new WeakMap,Hn=new WeakMap;const Gn=function(e){const t=O([...e,Se,M(),P(),{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,N({implementation:he})]);function n(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:t)({maxRedirects:0,...e})}return n.defaultRequester=t,n}([]),Xn=Gn.defaultRequester;e.BasePatch=$e,e.BaseTransaction=ot,e.ClientError=Ee,e.ObservablePatch=Ge,e.ObservableSanityClient=Vn,e.ObservableTransaction=ct,e.Patch=Ye,e.SanityClient=Jn,e.ServerError=Te,e.Transaction=it,e.createClient=e=>new Jn(Gn,e),e.default=function(e){return $t(),new Jn(Gn,e)},e.requester=Xn,Object.defineProperty(e,"__esModule",{value:!0})}));
|