@sanity/client 5.0.0-esm.1 → 5.0.0-esm.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/SanityClient.ts +2 -2
- package/umd/sanityClient.js +1 -1
- package/umd/sanityClient.min.js +1 -1
package/package.json
CHANGED
package/src/SanityClient.ts
CHANGED
|
@@ -675,6 +675,8 @@ export class SanityClient {
|
|
|
675
675
|
listen = _listen
|
|
676
676
|
|
|
677
677
|
constructor(httpRequest: HttpRequest, config: ClientConfig) {
|
|
678
|
+
this.observable = new ObservableSanityClient(httpRequest, config)
|
|
679
|
+
|
|
678
680
|
this.config(config)
|
|
679
681
|
|
|
680
682
|
this.#httpRequest = httpRequest
|
|
@@ -684,8 +686,6 @@ export class SanityClient {
|
|
|
684
686
|
this.datasets = new DatasetsClient(this)
|
|
685
687
|
this.projects = new ProjectsClient(this)
|
|
686
688
|
this.users = new UsersClient(this)
|
|
687
|
-
|
|
688
|
-
this.observable = new ObservableSanityClient(httpRequest, this.config())
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
/**
|
package/umd/sanityClient.js
CHANGED
|
@@ -5378,6 +5378,7 @@
|
|
|
5378
5378
|
__privateAdd(this, _clientConfig2, void 0);
|
|
5379
5379
|
__privateAdd(this, _httpRequest2, void 0);
|
|
5380
5380
|
this.listen = _listen;
|
|
5381
|
+
this.observable = new ObservableSanityClient(httpRequest, config);
|
|
5381
5382
|
this.config(config);
|
|
5382
5383
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
5383
5384
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -5385,7 +5386,6 @@
|
|
|
5385
5386
|
this.datasets = new DatasetsClient(this);
|
|
5386
5387
|
this.projects = new ProjectsClient(this);
|
|
5387
5388
|
this.users = new UsersClient(this);
|
|
5388
|
-
this.observable = new ObservableSanityClient(httpRequest, this.config());
|
|
5389
5389
|
}
|
|
5390
5390
|
clone() {
|
|
5391
5391
|
return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
|
package/umd/sanityClient.min.js
CHANGED
|
@@ -11,4 +11,4 @@ function K(e){return"[object Object]"===Object.prototype.toString.call(e)}!funct
|
|
|
11
11
|
* Available under MIT License (MIT)
|
|
12
12
|
* https://github.com/Yaffle/EventSource/
|
|
13
13
|
*/
|
|
14
|
-
!function(e,n){!function(t){var r=t.setTimeout,o=t.clearTimeout,s=t.XMLHttpRequest,i=t.XDomainRequest,a=t.ActiveXObject,c=t.EventSource,u=t.document,l=t.Promise,h=t.fetch,d=t.Response,p=t.TextDecoder,f=t.TextEncoder,y=t.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 m=h;h=function(e,t){var n=t.signal;return m(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 g(){this.bitsNeeded=0,this.codePoint=0}g.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!=p&&null!=f&&function(){try{return"test"===(new p).decode((new f).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=g);var v=function(){};function w(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=v}function 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 x(e){this._headers=e}function T(){}function O(){this._listeners=Object.create(null)}function _(e){r((function(){throw e}),0)}function j(e){this.type=e,this.target=void 0}function S(e,t){j.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function R(e,t){j.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function A(e,t){j.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=v,i.onerror=v,i.onabort=v,i.onprogress=v,i.onreadystatechange=v,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:v}),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},x.prototype.get=function(e){return this._headers.get(e)},T.prototype.open=function(e,t,n,r,o,s,i){var a=null,c=new y,u=c.signal,d=new p;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 x(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}},S.prototype=Object.create(j.prototype),R.prototype=Object.create(j.prototype),A.prototype=Object.create(j.prototype);var k=-1,I=-1,F=/^text\/event\-stream(;.*)?$/i,q=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 N(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=q(n.heartbeatTimeout,45e3),h="",d=u,p=!1,f=0,y=n.headers||{},m=n.Transport,g=M&&null==m?void 0:new w(null!=m?new m:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),v=null!=m&&"string"!=typeof m?new m:null==g?new T:new E,b=void 0,C=0,x=k,O="",_="",j="",N="",U=0,H=0,z=0,L=function(t,n,r,o){if(0===x)if(200===t&&null!=r&&F.test(r)){x=1,p=Date.now(),d=u,e.readyState=1;var s=new R("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.",B();s=new R("error",{status:t,statusText:n,headers:o});e.dispatchEvent(s),D(e,e.onerror,s),console.error(i)}},W=function(t){if(1===x){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?N:"")+t.slice(0,n+1);N=(-1===n?N:"")+t.slice(n+1),""!==t&&(p=Date.now(),f+=t.length);for(var a=0;a<i.length;a+=1){var c=i.charCodeAt(a);if(U===I&&c==="\n".charCodeAt(0))U=0;else if(U===I&&(U=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==U){1===U&&(z=a+1);var y=i.slice(H,z-1),m=i.slice(z+(z<a&&i.charCodeAt(z)===" ".charCodeAt(0)?1:0),a);"data"===y?(O+="\n",O+=m):"id"===y?_=m:"event"===y?j=m:"retry"===y?(u=q(m,u),d=u):"heartbeatTimeout"===y&&(l=q(m,l),0!==C&&(o(C),C=r((function(){V()}),l)))}if(0===U){if(""!==O){h=_,""===j&&(j="message");var g=new S(j,{data:O.slice(1),lastEventId:_});if(e.dispatchEvent(g),"open"===j?D(e,e.onopen,g):"message"===j?D(e,e.onmessage,g):"error"===j&&D(e,e.onerror,g),2===x)return}O="",j=""}U=c==="\r".charCodeAt(0)?I:0}else 0===U&&(H=a,U=1),1===U?c===":".charCodeAt(0)&&(z=a+1,U=2):2===U&&(U=3)}}},$=function(t){if(1===x||0===x){x=k,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 A("error",{error:t});e.dispatchEvent(n),D(e,e.onerror,n),null!=t&&console.error(t)}},B=function(){x=2,null!=b&&(b.abort(),b=void 0),0!==C&&(o(C),C=0),e.readyState=2},V=function(){if(C=0,x===k){p=!1,f=0,C=r((function(){V()}),l),x=0,O="",j="",_=h,N="",H=0,z=0,U=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=v.open(g,L,W,$,n,s,i)}catch(e){throw B(),e}}else if(p||null==b){var d=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=r((function(){V()}),d)}else $(new Error("No activity within "+l+" milliseconds. "+(0===x?"No response received.":f+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=B,V()}(this,e,t)}var M=null!=h&&null!=d&&"body"in d.prototype;N.prototype=Object.create(O.prototype),N.prototype.CONNECTING=0,N.prototype.OPEN=1,N.prototype.CLOSED=2,N.prototype.close=function(){this._close()},N.CONNECTING=0,N.OPEN=1,N.CLOSED=2,N.prototype.withCredentials=void 0;var U,H=c;null==s||null!=c&&"withCredentials"in c.prototype||(H=N),U=function(e){e.EventSourcePolyfill=N,e.NativeEventSource=c,e.EventSource=H}(n),void 0!==U&&(e.exports=U)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:t:globalThis)}({get exports(){return We},set exports(e){We=e}},We);var $e=We.EventSourcePolyfill;class Be extends Le.BaseError{constructor(e){const t=Xe(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class Ve extends Le.BaseError{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:Je(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 Je(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Ge={onResponse:e=>{if(e.statusCode>=500)throw new Ve(e);if(e.statusCode>=400)throw new Be(e);return e}},Ye={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};const Ze="X-Sanity-Project-ID";function Ke(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 Qe=["image","file"],et=["before","after","replace"],tt=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")},nt=e=>{if(-1===Qe.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(Qe.join(", ")))},rt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},ot=(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'))},st=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));ot(e,t._id)},it=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},at=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},ct=encodeURIComponent;var ut,lt,ht=e=>{let{query:t,params:n={},options:r={}}=e;const{tag:o,...s}=r,i="query=".concat(ct(t)),a=o?"?tag=".concat(ct(o),"&").concat(i):"?".concat(i),c=Object.keys(n).reduce(((e,t)=>"".concat(e,"&").concat(ct("$".concat(t)),"=").concat(ct(JSON.stringify(n[t])))),a);return Object.keys(s).reduce(((e,t)=>r[t]?"".concat(e,"&").concat(ct(t),"=").concat(ct(r[t])):e),c)},dt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},pt=(e,t,n)=>(dt(e,t,"read from private field"),n?n.call(e):t.get(e)),ft=(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)},yt=(e,t,n,r)=>(dt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class mt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}replace(e){return rt("replace",e),this._set("set",{$:e})}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return rt("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===et.indexOf(e)){const e=et.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{...Ke(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 rt(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 gt=class extends mt{constructor(e,t,n){super(e,t),ft(this,ut,void 0),yt(this,ut,n)}clone(){return new gt(this.selection,{...this.operations},pt(this,ut))}commit(e){if(!pt(this,ut))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 pt(this,ut).mutate({patch:this.serialize()},n)}};let vt=gt;ut=new WeakMap;const wt=class extends mt{constructor(e,t,n){super(e,t),ft(this,lt,void 0),yt(this,lt,n)}clone(){return new wt(this.selection,{...this.operations},pt(this,lt))}commit(e){if(!pt(this,lt))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 pt(this,lt).mutate({patch:this.serialize()},n)}};let bt=wt;lt=new WeakMap;var Ct,Et,xt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Tt=(e,t,n)=>(xt(e,t,"read from private field"),n?n.call(e):t.get(e)),Ot=(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)},_t=(e,t,n,r)=>(xt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const jt={returnDocuments:!1};class St{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 rt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return rt(t,e),st(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return rt(t,e),st(t,e),this._add({[t]:e})}delete(e){return ot("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 Rt=class extends St{constructor(e,t,n){super(e,n),Ot(this,Ct,void 0),_t(this,Ct,t)}clone(){return new Rt([...this.operations],Tt(this,Ct),this.trxId)}commit(e){if(!Tt(this,Ct))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Tt(this,Ct).mutate(this.serialize(),Object.assign({transactionId:this.trxId},jt,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof bt)return this._add({patch:e.serialize()});if(n){const n=t(new bt(e,{},Tt(this,Ct)));if(!(n instanceof bt))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 At=Rt;Ct=new WeakMap;const kt=class extends St{constructor(e,t,n){super(e,n),Ot(this,Et,void 0),_t(this,Et,t)}clone(){return new kt([...this.operations],Tt(this,Et),this.trxId)}commit(e){if(!Tt(this,Et))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Tt(this,Et).mutate(this.serialize(),Object.assign({transactionId:this.trxId},jt,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof vt)return this._add({patch:e.serialize()});if(n){const n=t(new vt(e,{},Tt(this,Et)));if(!(n instanceof vt))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=kt;Et=new WeakMap;const Ft=(e,t)=>!1===e?void 0:void 0===e?t:e,qt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:Ft(e.returnDocuments,!0),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation}},Pt=e=>"response"===e.type,Dt=e=>e.body,Nt=(e,t)=>e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null));function Mt(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 Bt(e,t,"query",{query:n,params:r},o).pipe(He(s))}function Ut(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:e.getDataUrl("doc",n),json:!0,tag:r.tag};return Xt(e,t,o).pipe(ze(Pt),He((e=>e.body.documents&&e.body.documents[0])))}function Ht(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:e.getDataUrl("doc",n.join(",")),json:!0,tag:r.tag};return Xt(e,t,o).pipe(ze(Pt),He((e=>{const t=Nt(e.body.documents||[],(e=>e._id));return n.map((e=>t[e]||null))})))}function zt(e,t,n,r){return st("createIfNotExists",n),Vt(e,t,n,"createIfNotExists",r)}function Lt(e,t,n,r){return st("createOrReplace",n),Vt(e,t,n,"createOrReplace",r)}function Wt(e,t,n,r){return Bt(e,t,"mutate",{mutations:[{delete:Ke(n)}]},r)}function $t(e,t,n,r){const o=n instanceof bt||n instanceof vt||n instanceof At||n instanceof It?n.serialize():n;return Bt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:r&&r.transactionId},r)}function Bt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===n,i="query"===n,a=s?"":ht(r),c=!s&&a.length<11264,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:p,headers:f}=o,y=e.getDataUrl(n,u),m={method:c?"GET":"POST",uri:y,json:!0,body:c?void 0:r,query:s&&qt(o),timeout:h,headers:f,token:d,tag:p,canUseCdn:i};return Xt(e,t,m).pipe(ze(Pt),He(Dt),He((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 Vt(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 Bt(e,t,"mutate",{mutations:[s]},i)}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:at(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[Ze]=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:e.getUrl(r,i)}));return new Fe((e=>t(c,o.requester).subscribe(e)))}function Jt(e,t,n){return Xt(e,t,n).pipe(ze((e=>"response"===e.type)),He((e=>e.body)))}var Gt,Yt,Zt,Kt,Qt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},en=(e,t,n)=>(Qt(e,t,"read from private field"),n?n.call(e):t.get(e)),tn=(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)},nn=(e,t,n,r)=>(Qt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class rn{constructor(e,t){tn(this,Gt,void 0),tn(this,Yt,void 0),nn(this,Gt,e),nn(this,Yt,t)}upload(e,t,n){return sn(en(this,Gt),en(this,Yt),e,t,n)}}Gt=new WeakMap,Yt=new WeakMap;class on{constructor(e,t){tn(this,Zt,void 0),tn(this,Kt,void 0),nn(this,Zt,e),nn(this,Kt,t)}upload(e,t,n){return Ue(sn(en(this,Zt),en(this,Kt),e,t,n).pipe(ze((e=>"response"===e.type)),He((e=>e.body.document))))}}function sn(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};nt(n);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=it(e.config()),a="image"===n?"images":"files",c=an(o,r),{tag:u,label:l,title:h,description:d,creditLine:p,filename:f,source:y}=c,m={label:l,title:h,description:d,filename:f,meta:s,creditLine:p};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.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:m,body:r})}function an(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}Zt=new WeakMap,Kt=new WeakMap;var cn,un,ln,hn,dn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},pn=(e,t,n)=>(dn(e,t,"read from private field"),n?n.call(e):t.get(e)),fn=(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)},yn=(e,t,n,r)=>(dn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class mn{constructor(e,t){fn(this,cn,void 0),fn(this,un,void 0),yn(this,cn,e),yn(this,un,t)}getLoginProviders(){return Jt(pn(this,cn),pn(this,un),{uri:"/auth/providers"})}logout(){return Jt(pn(this,cn),pn(this,un),{uri:"/auth/logout",method:"POST"})}}cn=new WeakMap,un=new WeakMap;class gn{constructor(e,t){fn(this,ln,void 0),fn(this,hn,void 0),yn(this,ln,e),yn(this,hn,t)}getLoginProviders(){return Ue(Jt(pn(this,ln),pn(this,hn),{uri:"/auth/providers"}))}logout(){return Ue(Jt(pn(this,ln),pn(this,hn),{uri:"/auth/logout",method:"POST"}))}}ln=new WeakMap,hn=new WeakMap;function vn(e){return"https://docs.sanity.io/help/"+e}const wn=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)})),bn=wn(["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(vn("js-client-cdn-configuration"),"."),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),Cn=wn(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(vn("js-client-browser-token")," for more information and how to hide this warning.")]),En=wn(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(vn("js-client-api-version"))]),xn={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},Tn=["localhost","127.0.0.1","0.0.0.0"],On=(e,t)=>{const n=Object.assign({},t,e);n.apiVersion||En();const r=Object.assign({},xn,n),o=r.useProjectHostname;if("undefined"==typeof Promise){const e=vn("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!==Tn.indexOf(e))(window.location.hostname);s&&i&&r.token&&!0!==r.ignoreBrowserTokenWarning?Cn():void 0===r.useCdn&&bn(),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&&tt(r.dataset),"requestTagPrefix"in r&&(r.requestTagPrefix=r.requestTagPrefix?at(r.requestTagPrefix).replace(/\.+$/,""):void 0),r.apiVersion="".concat(r.apiVersion).replace(/^v/,""),r.isDefaultApi=r.apiHost===xn.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 _n=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((n,r)=>(n[r]=void 0===e[r]?t[r]:e[r],n)),{}),jn=(e,t)=>t.reduce(((t,n)=>(void 0===e[n]||(t[n]=e[n]),t)),{});const Sn=$e,Rn=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],An={includeResult:!0};function kn(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={..._n(n,An),tag:a},u=jn(c,Rn),l=ht({query:e,params:t,options:{tag:a,...u}}),h="".concat(r).concat(this.getDataUrl("listen",l));if(h.length>14800)return new Fe((e=>e.error(new Error("Query too large for listener"))));const d=c.events?c.events:["mutation"],p=-1!==d.indexOf("reconnect"),f={};return(o||s)&&(f.withCredentials=!0),o&&(f.headers={Authorization:"Bearer ".concat(o)}),new Fe((e=>{let t,n=u(),r=!1;function o(){r||(p&&e.next({type:"reconnect"}),r||n.readyState===Sn.CLOSED&&(c(),clearTimeout(t),t=setTimeout(l,100)))}function s(t){e.error(Fn(t))}function i(t){const n=In(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 Sn(h,f);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 In(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}function Fn(e){if(e instanceof Error)return e;const t=In(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 qn,Pn,Dn=(e,t,n)=>(((e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)})(e,t,"access private method"),n);class Nn{constructor(){((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)})(this,qn)}create(e,t){return Dn(this,qn,Pn).call(this,"PUT",e,t)}edit(e,t){return Dn(this,qn,Pn).call(this,"PATCH",e,t)}delete(e){return Dn(this,qn,Pn).call(this,"DELETE",e)}list(){return this.client.request({uri:"/datasets"})}}qn=new WeakSet,Pn=function(e,t,n){return tt(t),this.client.request({method:e,uri:"/datasets/".concat(t),body:n})};class Mn extends Nn{constructor(e){super(),this.client=e}}class Un extends Nn{constructor(e){super(),this.client=e}}class Hn{list(){return this.client.request({uri:"/projects"})}getById(e){return this.client.request({uri:"/projects/".concat(e)})}}class zn extends Hn{constructor(e){super(),this.client=e}}class Ln extends Hn{constructor(e){super(),this.client=e}}class Wn{getById(e){return this.client.request({uri:"/users/".concat(e)})}}class $n extends Wn{constructor(e){super(),this.client=e}}class Bn extends Wn{constructor(e){super(),this.client=e}}var Vn,Xn,Jn,Gn,Yn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Zn=(e,t,n)=>(Yn(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)},Qn=(e,t,n,r)=>(Yn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const er=class{constructor(e,t){Kn(this,Vn,void 0),Kn(this,Xn,void 0),this.config(t),Qn(this,Xn,e),this.assets=new rn(this,Zn(this,Xn)),this.auth=new mn(this,Zn(this,Xn)),this.datasets=new Mn(this),this.projects=new zn(this),this.users=new $n(this)}clone(){return new er(Zn(this,Xn),this.config())}config(e){if(void 0===e)return{...Zn(this,Vn)};if(Zn(this,Vn)&&!1===Zn(this,Vn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Qn(this,Vn,On(e,Zn(this,Vn)||{})),this}withConfig(e){return new er(Zn(this,Xn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Mt(this,Zn(this,Xn),e,t,n)}getDocument(e,t){return Ut(this,Zn(this,Xn),e,t)}getDocuments(e,t){return Ht(this,Zn(this,Xn),e,t)}create(e,t){return Vt(this,Zn(this,Xn),e,"create",t)}createIfNotExists(e,t){return zt(this,Zn(this,Xn),e,t)}createOrReplace(e,t){return Lt(this,Zn(this,Xn),e,t)}delete(e,t){return Wt(this,Zn(this,Xn),e,t)}mutate(e,t){return $t(this,Zn(this,Xn),e,t)}patch(e,t){return new vt(e,t,this)}transaction(e){return new It(e,this)}request(e){return Jt(this,Zn(this,Xn),e)}getUrl(e){const t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?Zn(this,Vn).cdnUrl:Zn(this,Vn).url;return"".concat(t,"/").concat(e.replace(/^\//,""))}getDataUrl(e,t){const n=this.config(),r=it(n),o="/".concat(e,"/").concat(r),s=t?"".concat(o,"/").concat(t):o;return"/data".concat(s).replace(/\/($|\?)/,"$1")}};let tr=er;Vn=new WeakMap,Xn=new WeakMap;const nr=class{constructor(e,t){Kn(this,Jn,void 0),Kn(this,Gn,void 0),this.listen=kn,this.config(t),Qn(this,Gn,e),this.assets=new on(this,Zn(this,Gn)),this.auth=new gn(this,Zn(this,Gn)),this.datasets=new Un(this),this.projects=new Ln(this),this.users=new Bn(this),this.observable=new tr(e,this.config())}clone(){return new nr(Zn(this,Gn),this.config())}config(e){if(void 0===e)return{...Zn(this,Jn)};if(Zn(this,Jn)&&!1===Zn(this,Jn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable.config(e),Qn(this,Jn,On(e,Zn(this,Jn)||{})),this}withConfig(e){return new nr(Zn(this,Gn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Ue(Mt(this,Zn(this,Gn),e,t,n))}getDocument(e,t){return Ue(Ut(this,Zn(this,Gn),e,t))}getDocuments(e,t){return Ue(Ht(this,Zn(this,Gn),e,t))}create(e,t){return Ue(Vt(this,Zn(this,Gn),e,"create",t))}createIfNotExists(e,t){return Ue(zt(this,Zn(this,Gn),e,t))}createOrReplace(e,t){return Ue(Lt(this,Zn(this,Gn),e,t))}delete(e,t){return Ue(Wt(this,Zn(this,Gn),e,t))}mutate(e,t){return Ue($t(this,Zn(this,Gn),e,t))}patch(e,t){return new bt(e,t,this)}transaction(e){return new At(e,this)}request(e){return Ue(Jt(this,Zn(this,Gn),e))}dataRequest(e,t,n){return Ue(Bt(this,Zn(this,Gn),e,t,n))}getUrl(e){const t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?Zn(this,Jn).cdnUrl:Zn(this,Jn).url;return"".concat(t,"/").concat(e.replace(/^\//,""))}getDataUrl(e,t){const n=this.config(),r=it(n),o="/".concat(e,"/").concat(r),s=t?"".concat(o,"/").concat(t):o;return"/data".concat(s).replace(/\/($|\?)/,"$1")}};let rr=nr;Jn=new WeakMap,Gn=new WeakMap;const or=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]:B;return N(e,t)}([...e,Ye,ee(),te(),{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"))}},Ge,oe({implementation:Fe})]);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}([]),sr=or.defaultRequester;e.BasePatch=mt,e.BaseTransaction=St,e.ClientError=Be,e.ObservablePatch=vt,e.ObservableSanityClient=tr,e.ObservableTransaction=It,e.Patch=bt,e.SanityClient=rr,e.ServerError=Ve,e.Transaction=At,e.createClient=function(e){return new rr(or,e)},e.requester=sr}));
|
|
14
|
+
!function(e,n){!function(t){var r=t.setTimeout,o=t.clearTimeout,s=t.XMLHttpRequest,i=t.XDomainRequest,a=t.ActiveXObject,c=t.EventSource,u=t.document,l=t.Promise,h=t.fetch,d=t.Response,p=t.TextDecoder,f=t.TextEncoder,y=t.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 m=h;h=function(e,t){var n=t.signal;return m(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 g(){this.bitsNeeded=0,this.codePoint=0}g.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!=p&&null!=f&&function(){try{return"test"===(new p).decode((new f).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=g);var v=function(){};function w(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=v}function 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 x(e){this._headers=e}function T(){}function O(){this._listeners=Object.create(null)}function _(e){r((function(){throw e}),0)}function j(e){this.type=e,this.target=void 0}function S(e,t){j.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function R(e,t){j.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function A(e,t){j.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=v,i.onerror=v,i.onabort=v,i.onprogress=v,i.onreadystatechange=v,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:v}),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},x.prototype.get=function(e){return this._headers.get(e)},T.prototype.open=function(e,t,n,r,o,s,i){var a=null,c=new y,u=c.signal,d=new p;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 x(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}},S.prototype=Object.create(j.prototype),R.prototype=Object.create(j.prototype),A.prototype=Object.create(j.prototype);var k=-1,I=-1,F=/^text\/event\-stream(;.*)?$/i,q=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 N(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=q(n.heartbeatTimeout,45e3),h="",d=u,p=!1,f=0,y=n.headers||{},m=n.Transport,g=M&&null==m?void 0:new w(null!=m?new m:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),v=null!=m&&"string"!=typeof m?new m:null==g?new T:new E,b=void 0,C=0,x=k,O="",_="",j="",N="",U=0,H=0,z=0,L=function(t,n,r,o){if(0===x)if(200===t&&null!=r&&F.test(r)){x=1,p=Date.now(),d=u,e.readyState=1;var s=new R("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.",B();s=new R("error",{status:t,statusText:n,headers:o});e.dispatchEvent(s),D(e,e.onerror,s),console.error(i)}},W=function(t){if(1===x){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?N:"")+t.slice(0,n+1);N=(-1===n?N:"")+t.slice(n+1),""!==t&&(p=Date.now(),f+=t.length);for(var a=0;a<i.length;a+=1){var c=i.charCodeAt(a);if(U===I&&c==="\n".charCodeAt(0))U=0;else if(U===I&&(U=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==U){1===U&&(z=a+1);var y=i.slice(H,z-1),m=i.slice(z+(z<a&&i.charCodeAt(z)===" ".charCodeAt(0)?1:0),a);"data"===y?(O+="\n",O+=m):"id"===y?_=m:"event"===y?j=m:"retry"===y?(u=q(m,u),d=u):"heartbeatTimeout"===y&&(l=q(m,l),0!==C&&(o(C),C=r((function(){V()}),l)))}if(0===U){if(""!==O){h=_,""===j&&(j="message");var g=new S(j,{data:O.slice(1),lastEventId:_});if(e.dispatchEvent(g),"open"===j?D(e,e.onopen,g):"message"===j?D(e,e.onmessage,g):"error"===j&&D(e,e.onerror,g),2===x)return}O="",j=""}U=c==="\r".charCodeAt(0)?I:0}else 0===U&&(H=a,U=1),1===U?c===":".charCodeAt(0)&&(z=a+1,U=2):2===U&&(U=3)}}},$=function(t){if(1===x||0===x){x=k,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 A("error",{error:t});e.dispatchEvent(n),D(e,e.onerror,n),null!=t&&console.error(t)}},B=function(){x=2,null!=b&&(b.abort(),b=void 0),0!==C&&(o(C),C=0),e.readyState=2},V=function(){if(C=0,x===k){p=!1,f=0,C=r((function(){V()}),l),x=0,O="",j="",_=h,N="",H=0,z=0,U=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=v.open(g,L,W,$,n,s,i)}catch(e){throw B(),e}}else if(p||null==b){var d=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=r((function(){V()}),d)}else $(new Error("No activity within "+l+" milliseconds. "+(0===x?"No response received.":f+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=B,V()}(this,e,t)}var M=null!=h&&null!=d&&"body"in d.prototype;N.prototype=Object.create(O.prototype),N.prototype.CONNECTING=0,N.prototype.OPEN=1,N.prototype.CLOSED=2,N.prototype.close=function(){this._close()},N.CONNECTING=0,N.OPEN=1,N.CLOSED=2,N.prototype.withCredentials=void 0;var U,H=c;null==s||null!=c&&"withCredentials"in c.prototype||(H=N),U=function(e){e.EventSourcePolyfill=N,e.NativeEventSource=c,e.EventSource=H}(n),void 0!==U&&(e.exports=U)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:t:globalThis)}({get exports(){return We},set exports(e){We=e}},We);var $e=We.EventSourcePolyfill;class Be extends Le.BaseError{constructor(e){const t=Xe(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class Ve extends Le.BaseError{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:Je(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 Je(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Ge={onResponse:e=>{if(e.statusCode>=500)throw new Ve(e);if(e.statusCode>=400)throw new Be(e);return e}},Ye={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};const Ze="X-Sanity-Project-ID";function Ke(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 Qe=["image","file"],et=["before","after","replace"],tt=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")},nt=e=>{if(-1===Qe.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(Qe.join(", ")))},rt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},ot=(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'))},st=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));ot(e,t._id)},it=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},at=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},ct=encodeURIComponent;var ut,lt,ht=e=>{let{query:t,params:n={},options:r={}}=e;const{tag:o,...s}=r,i="query=".concat(ct(t)),a=o?"?tag=".concat(ct(o),"&").concat(i):"?".concat(i),c=Object.keys(n).reduce(((e,t)=>"".concat(e,"&").concat(ct("$".concat(t)),"=").concat(ct(JSON.stringify(n[t])))),a);return Object.keys(s).reduce(((e,t)=>r[t]?"".concat(e,"&").concat(ct(t),"=").concat(ct(r[t])):e),c)},dt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},pt=(e,t,n)=>(dt(e,t,"read from private field"),n?n.call(e):t.get(e)),ft=(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)},yt=(e,t,n,r)=>(dt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class mt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}replace(e){return rt("replace",e),this._set("set",{$:e})}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return rt("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===et.indexOf(e)){const e=et.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{...Ke(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 rt(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 gt=class extends mt{constructor(e,t,n){super(e,t),ft(this,ut,void 0),yt(this,ut,n)}clone(){return new gt(this.selection,{...this.operations},pt(this,ut))}commit(e){if(!pt(this,ut))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 pt(this,ut).mutate({patch:this.serialize()},n)}};let vt=gt;ut=new WeakMap;const wt=class extends mt{constructor(e,t,n){super(e,t),ft(this,lt,void 0),yt(this,lt,n)}clone(){return new wt(this.selection,{...this.operations},pt(this,lt))}commit(e){if(!pt(this,lt))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 pt(this,lt).mutate({patch:this.serialize()},n)}};let bt=wt;lt=new WeakMap;var Ct,Et,xt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Tt=(e,t,n)=>(xt(e,t,"read from private field"),n?n.call(e):t.get(e)),Ot=(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)},_t=(e,t,n,r)=>(xt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const jt={returnDocuments:!1};class St{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 rt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return rt(t,e),st(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return rt(t,e),st(t,e),this._add({[t]:e})}delete(e){return ot("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 Rt=class extends St{constructor(e,t,n){super(e,n),Ot(this,Ct,void 0),_t(this,Ct,t)}clone(){return new Rt([...this.operations],Tt(this,Ct),this.trxId)}commit(e){if(!Tt(this,Ct))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Tt(this,Ct).mutate(this.serialize(),Object.assign({transactionId:this.trxId},jt,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof bt)return this._add({patch:e.serialize()});if(n){const n=t(new bt(e,{},Tt(this,Ct)));if(!(n instanceof bt))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 At=Rt;Ct=new WeakMap;const kt=class extends St{constructor(e,t,n){super(e,n),Ot(this,Et,void 0),_t(this,Et,t)}clone(){return new kt([...this.operations],Tt(this,Et),this.trxId)}commit(e){if(!Tt(this,Et))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Tt(this,Et).mutate(this.serialize(),Object.assign({transactionId:this.trxId},jt,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof vt)return this._add({patch:e.serialize()});if(n){const n=t(new vt(e,{},Tt(this,Et)));if(!(n instanceof vt))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=kt;Et=new WeakMap;const Ft=(e,t)=>!1===e?void 0:void 0===e?t:e,qt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:Ft(e.returnDocuments,!0),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation}},Pt=e=>"response"===e.type,Dt=e=>e.body,Nt=(e,t)=>e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null));function Mt(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 Bt(e,t,"query",{query:n,params:r},o).pipe(He(s))}function Ut(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:e.getDataUrl("doc",n),json:!0,tag:r.tag};return Xt(e,t,o).pipe(ze(Pt),He((e=>e.body.documents&&e.body.documents[0])))}function Ht(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={uri:e.getDataUrl("doc",n.join(",")),json:!0,tag:r.tag};return Xt(e,t,o).pipe(ze(Pt),He((e=>{const t=Nt(e.body.documents||[],(e=>e._id));return n.map((e=>t[e]||null))})))}function zt(e,t,n,r){return st("createIfNotExists",n),Vt(e,t,n,"createIfNotExists",r)}function Lt(e,t,n,r){return st("createOrReplace",n),Vt(e,t,n,"createOrReplace",r)}function Wt(e,t,n,r){return Bt(e,t,"mutate",{mutations:[{delete:Ke(n)}]},r)}function $t(e,t,n,r){const o=n instanceof bt||n instanceof vt||n instanceof At||n instanceof It?n.serialize():n;return Bt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:r&&r.transactionId},r)}function Bt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===n,i="query"===n,a=s?"":ht(r),c=!s&&a.length<11264,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:p,headers:f}=o,y=e.getDataUrl(n,u),m={method:c?"GET":"POST",uri:y,json:!0,body:c?void 0:r,query:s&&qt(o),timeout:h,headers:f,token:d,tag:p,canUseCdn:i};return Xt(e,t,m).pipe(ze(Pt),He(Dt),He((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 Vt(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 Bt(e,t,"mutate",{mutations:[s]},i)}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:at(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[Ze]=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:e.getUrl(r,i)}));return new Fe((e=>t(c,o.requester).subscribe(e)))}function Jt(e,t,n){return Xt(e,t,n).pipe(ze((e=>"response"===e.type)),He((e=>e.body)))}var Gt,Yt,Zt,Kt,Qt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},en=(e,t,n)=>(Qt(e,t,"read from private field"),n?n.call(e):t.get(e)),tn=(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)},nn=(e,t,n,r)=>(Qt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class rn{constructor(e,t){tn(this,Gt,void 0),tn(this,Yt,void 0),nn(this,Gt,e),nn(this,Yt,t)}upload(e,t,n){return sn(en(this,Gt),en(this,Yt),e,t,n)}}Gt=new WeakMap,Yt=new WeakMap;class on{constructor(e,t){tn(this,Zt,void 0),tn(this,Kt,void 0),nn(this,Zt,e),nn(this,Kt,t)}upload(e,t,n){return Ue(sn(en(this,Zt),en(this,Kt),e,t,n).pipe(ze((e=>"response"===e.type)),He((e=>e.body.document))))}}function sn(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};nt(n);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=it(e.config()),a="image"===n?"images":"files",c=an(o,r),{tag:u,label:l,title:h,description:d,creditLine:p,filename:f,source:y}=c,m={label:l,title:h,description:d,filename:f,meta:s,creditLine:p};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.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:m,body:r})}function an(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}Zt=new WeakMap,Kt=new WeakMap;var cn,un,ln,hn,dn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},pn=(e,t,n)=>(dn(e,t,"read from private field"),n?n.call(e):t.get(e)),fn=(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)},yn=(e,t,n,r)=>(dn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class mn{constructor(e,t){fn(this,cn,void 0),fn(this,un,void 0),yn(this,cn,e),yn(this,un,t)}getLoginProviders(){return Jt(pn(this,cn),pn(this,un),{uri:"/auth/providers"})}logout(){return Jt(pn(this,cn),pn(this,un),{uri:"/auth/logout",method:"POST"})}}cn=new WeakMap,un=new WeakMap;class gn{constructor(e,t){fn(this,ln,void 0),fn(this,hn,void 0),yn(this,ln,e),yn(this,hn,t)}getLoginProviders(){return Ue(Jt(pn(this,ln),pn(this,hn),{uri:"/auth/providers"}))}logout(){return Ue(Jt(pn(this,ln),pn(this,hn),{uri:"/auth/logout",method:"POST"}))}}ln=new WeakMap,hn=new WeakMap;function vn(e){return"https://docs.sanity.io/help/"+e}const wn=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)})),bn=wn(["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(vn("js-client-cdn-configuration"),"."),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),Cn=wn(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(vn("js-client-browser-token")," for more information and how to hide this warning.")]),En=wn(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(vn("js-client-api-version"))]),xn={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},Tn=["localhost","127.0.0.1","0.0.0.0"],On=(e,t)=>{const n=Object.assign({},t,e);n.apiVersion||En();const r=Object.assign({},xn,n),o=r.useProjectHostname;if("undefined"==typeof Promise){const e=vn("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!==Tn.indexOf(e))(window.location.hostname);s&&i&&r.token&&!0!==r.ignoreBrowserTokenWarning?Cn():void 0===r.useCdn&&bn(),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&&tt(r.dataset),"requestTagPrefix"in r&&(r.requestTagPrefix=r.requestTagPrefix?at(r.requestTagPrefix).replace(/\.+$/,""):void 0),r.apiVersion="".concat(r.apiVersion).replace(/^v/,""),r.isDefaultApi=r.apiHost===xn.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 _n=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((n,r)=>(n[r]=void 0===e[r]?t[r]:e[r],n)),{}),jn=(e,t)=>t.reduce(((t,n)=>(void 0===e[n]||(t[n]=e[n]),t)),{});const Sn=$e,Rn=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],An={includeResult:!0};function kn(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={..._n(n,An),tag:a},u=jn(c,Rn),l=ht({query:e,params:t,options:{tag:a,...u}}),h="".concat(r).concat(this.getDataUrl("listen",l));if(h.length>14800)return new Fe((e=>e.error(new Error("Query too large for listener"))));const d=c.events?c.events:["mutation"],p=-1!==d.indexOf("reconnect"),f={};return(o||s)&&(f.withCredentials=!0),o&&(f.headers={Authorization:"Bearer ".concat(o)}),new Fe((e=>{let t,n=u(),r=!1;function o(){r||(p&&e.next({type:"reconnect"}),r||n.readyState===Sn.CLOSED&&(c(),clearTimeout(t),t=setTimeout(l,100)))}function s(t){e.error(Fn(t))}function i(t){const n=In(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 Sn(h,f);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 In(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}function Fn(e){if(e instanceof Error)return e;const t=In(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 qn,Pn,Dn=(e,t,n)=>(((e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)})(e,t,"access private method"),n);class Nn{constructor(){((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)})(this,qn)}create(e,t){return Dn(this,qn,Pn).call(this,"PUT",e,t)}edit(e,t){return Dn(this,qn,Pn).call(this,"PATCH",e,t)}delete(e){return Dn(this,qn,Pn).call(this,"DELETE",e)}list(){return this.client.request({uri:"/datasets"})}}qn=new WeakSet,Pn=function(e,t,n){return tt(t),this.client.request({method:e,uri:"/datasets/".concat(t),body:n})};class Mn extends Nn{constructor(e){super(),this.client=e}}class Un extends Nn{constructor(e){super(),this.client=e}}class Hn{list(){return this.client.request({uri:"/projects"})}getById(e){return this.client.request({uri:"/projects/".concat(e)})}}class zn extends Hn{constructor(e){super(),this.client=e}}class Ln extends Hn{constructor(e){super(),this.client=e}}class Wn{getById(e){return this.client.request({uri:"/users/".concat(e)})}}class $n extends Wn{constructor(e){super(),this.client=e}}class Bn extends Wn{constructor(e){super(),this.client=e}}var Vn,Xn,Jn,Gn,Yn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Zn=(e,t,n)=>(Yn(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)},Qn=(e,t,n,r)=>(Yn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const er=class{constructor(e,t){Kn(this,Vn,void 0),Kn(this,Xn,void 0),this.config(t),Qn(this,Xn,e),this.assets=new rn(this,Zn(this,Xn)),this.auth=new mn(this,Zn(this,Xn)),this.datasets=new Mn(this),this.projects=new zn(this),this.users=new $n(this)}clone(){return new er(Zn(this,Xn),this.config())}config(e){if(void 0===e)return{...Zn(this,Vn)};if(Zn(this,Vn)&&!1===Zn(this,Vn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Qn(this,Vn,On(e,Zn(this,Vn)||{})),this}withConfig(e){return new er(Zn(this,Xn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Mt(this,Zn(this,Xn),e,t,n)}getDocument(e,t){return Ut(this,Zn(this,Xn),e,t)}getDocuments(e,t){return Ht(this,Zn(this,Xn),e,t)}create(e,t){return Vt(this,Zn(this,Xn),e,"create",t)}createIfNotExists(e,t){return zt(this,Zn(this,Xn),e,t)}createOrReplace(e,t){return Lt(this,Zn(this,Xn),e,t)}delete(e,t){return Wt(this,Zn(this,Xn),e,t)}mutate(e,t){return $t(this,Zn(this,Xn),e,t)}patch(e,t){return new vt(e,t,this)}transaction(e){return new It(e,this)}request(e){return Jt(this,Zn(this,Xn),e)}getUrl(e){const t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?Zn(this,Vn).cdnUrl:Zn(this,Vn).url;return"".concat(t,"/").concat(e.replace(/^\//,""))}getDataUrl(e,t){const n=this.config(),r=it(n),o="/".concat(e,"/").concat(r),s=t?"".concat(o,"/").concat(t):o;return"/data".concat(s).replace(/\/($|\?)/,"$1")}};let tr=er;Vn=new WeakMap,Xn=new WeakMap;const nr=class{constructor(e,t){Kn(this,Jn,void 0),Kn(this,Gn,void 0),this.listen=kn,this.observable=new tr(e,t),this.config(t),Qn(this,Gn,e),this.assets=new on(this,Zn(this,Gn)),this.auth=new gn(this,Zn(this,Gn)),this.datasets=new Un(this),this.projects=new Ln(this),this.users=new Bn(this)}clone(){return new nr(Zn(this,Gn),this.config())}config(e){if(void 0===e)return{...Zn(this,Jn)};if(Zn(this,Jn)&&!1===Zn(this,Jn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable.config(e),Qn(this,Jn,On(e,Zn(this,Jn)||{})),this}withConfig(e){return new nr(Zn(this,Gn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Ue(Mt(this,Zn(this,Gn),e,t,n))}getDocument(e,t){return Ue(Ut(this,Zn(this,Gn),e,t))}getDocuments(e,t){return Ue(Ht(this,Zn(this,Gn),e,t))}create(e,t){return Ue(Vt(this,Zn(this,Gn),e,"create",t))}createIfNotExists(e,t){return Ue(zt(this,Zn(this,Gn),e,t))}createOrReplace(e,t){return Ue(Lt(this,Zn(this,Gn),e,t))}delete(e,t){return Ue(Wt(this,Zn(this,Gn),e,t))}mutate(e,t){return Ue($t(this,Zn(this,Gn),e,t))}patch(e,t){return new bt(e,t,this)}transaction(e){return new At(e,this)}request(e){return Ue(Jt(this,Zn(this,Gn),e))}dataRequest(e,t,n){return Ue(Bt(this,Zn(this,Gn),e,t,n))}getUrl(e){const t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?Zn(this,Jn).cdnUrl:Zn(this,Jn).url;return"".concat(t,"/").concat(e.replace(/^\//,""))}getDataUrl(e,t){const n=this.config(),r=it(n),o="/".concat(e,"/").concat(r),s=t?"".concat(o,"/").concat(t):o;return"/data".concat(s).replace(/\/($|\?)/,"$1")}};let rr=nr;Jn=new WeakMap,Gn=new WeakMap;const or=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]:B;return N(e,t)}([...e,Ye,ee(),te(),{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"))}},Ge,oe({implementation:Fe})]);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}([]),sr=or.defaultRequester;e.BasePatch=mt,e.BaseTransaction=St,e.ClientError=Be,e.ObservablePatch=vt,e.ObservableSanityClient=tr,e.ObservableTransaction=It,e.Patch=bt,e.SanityClient=rr,e.ServerError=Ve,e.Transaction=At,e.createClient=function(e){return new rr(or,e)},e.requester=sr}));
|