@sanity/client 5.2.0 → 5.2.1

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.
@@ -11,4 +11,4 @@ function F(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,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=$&&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="",V=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(V===P&&c==="\n".charCodeAt(0))V=D;else if(V===P&&(V=D),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(V!==D){V===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(V===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=""}V=c==="\r".charCodeAt(0)?P:D}else V===D&&(J=a,V=q),V===q?c===":".charCodeAt(0)&&(G=a+1,V=N):V===N&&(V=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,V=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 $=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 V,J=c;null==s||null!=c&&"withCredentials"in c.prototype||(J=B),V=function(e){e.EventSourcePolyfill=B,e.NativeEventSource=c,e.EventSource=J}(t),void 0!==V&&(e.exports=V)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:i:globalThis)}({get exports(){return Ce},set exports(e){Ce=e}},Ce);var Ee=Ce.EventSourcePolyfill;class Te extends Error{constructor(e){const t=Oe(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class xe extends Error{constructor(e){const t=Oe(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function Oe(e){const t=e.body,n={response:e,statusCode:e.statusCode,responseBody:_e(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 _e(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Se={onResponse:e=>{if(e.statusCode>=500)throw new xe(e);if(e.statusCode>=400)throw new Te(e);return e}},je={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};const Ae="X-Sanity-Project-ID";var ke=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[Ae]=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})};function Fe(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 Re=["image","file"],Ie=["before","after","replace"],Me=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")},Pe=e=>{if(-1===Re.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(Re.join(", ")))},De=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},qe=(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'))},Ne=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));qe(e,t._id)},He=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},We=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};var ze,Ue,Le=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)},Be=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},$e=(e,t,n)=>(Be(e,t,"read from private field"),n?n.call(e):t.get(e)),Ve=(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)},Je=(e,t,n,r)=>(Be(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Ge{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 De("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===Ie.indexOf(e)){const e=Ie.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{...Fe(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 De(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 Xe=class extends Ge{constructor(e,t,n){super(e,t),Ve(this,ze,void 0),Je(this,ze,n)}clone(){return new Xe(this.selection,{...this.operations},$e(this,ze))}commit(e){if(!$e(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 $e(this,ze).mutate({patch:this.serialize()},n)}};let Ye=Xe;ze=new WeakMap;const Ke=class extends Ge{constructor(e,t,n){super(e,t),Ve(this,Ue,void 0),Je(this,Ue,n)}clone(){return new Ke(this.selection,{...this.operations},$e(this,Ue))}commit(e){if(!$e(this,Ue))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 $e(this,Ue).mutate({patch:this.serialize()},n)}};let Ze=Ke;Ue=new WeakMap;var Qe,et,tt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},nt=(e,t,n)=>(tt(e,t,"read from private field"),n?n.call(e):t.get(e)),rt=(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)},ot=(e,t,n,r)=>(tt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const st={returnDocuments:!1};class it{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 De("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return De(t,e),Ne(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return De(t,e),Ne(t,e),this._add({[t]:e})}delete(e){return qe("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 at=class extends it{constructor(e,t,n){super(e,n),rt(this,Qe,void 0),ot(this,Qe,t)}clone(){return new at([...this.operations],nt(this,Qe),this.trxId)}commit(e){if(!nt(this,Qe))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return nt(this,Qe).mutate(this.serialize(),Object.assign({transactionId:this.trxId},st,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof Ze)return this._add({patch:e.serialize()});if(n){const n=t(new Ze(e,{},nt(this,Qe)));if(!(n instanceof Ze))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;Qe=new WeakMap;const ut=class extends it{constructor(e,t,n){super(e,n),rt(this,et,void 0),ot(this,et,t)}clone(){return new ut([...this.operations],nt(this,et),this.trxId)}commit(e){if(!nt(this,et))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return nt(this,et).mutate(this.serialize(),Object.assign({transactionId:this.trxId},st,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,{},nt(this,et)));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 lt=ut;et=new WeakMap;const ht=(e,t)=>!1===e?void 0:void 0===e?t:e,dt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:ht(e.returnDocuments,!0),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation}},ft=e=>"response"===e.type,pt=e=>e.body,yt=(e,t)=>e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null)),gt=11264;function vt(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 xt(e,t,"query",{query:n,params:r},o).pipe(we(s))}function mt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return _t(e,t,{uri:jt(e,"doc",n),json:!0,tag:r.tag}).pipe(be(ft),we((e=>e.body.documents&&e.body.documents[0])))}function wt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return _t(e,t,{uri:jt(e,"doc",n.join(",")),json:!0,tag:r.tag}).pipe(be(ft),we((e=>{const t=yt(e.body.documents||[],(e=>e._id));return n.map((e=>t[e]||null))})))}function bt(e,t,n,r){return Ne("createIfNotExists",n),Ot(e,t,n,"createIfNotExists",r)}function Ct(e,t,n,r){return Ne("createOrReplace",n),Ot(e,t,n,"createOrReplace",r)}function Et(e,t,n,r){return xt(e,t,"mutate",{mutations:[{delete:Fe(n)}]},r)}function Tt(e,t,n,r){const o=n instanceof Ze||n instanceof Ye||n instanceof ct||n instanceof lt?n.serialize():n;return xt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:r&&r.transactionId},r)}function xt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===n,i="query"===n,a=s?"":Le(r),c=!s&&a.length<gt,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p}=o;return _t(e,t,{method:c?"GET":"POST",uri:jt(e,n,u),json:!0,body:c?void 0:r,query:s&&dt(o),timeout:h,headers:p,token:d,tag:f,canUseCdn:i,signal:o.signal}).pipe(be(ft),we(pt),we((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 Ot(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return xt(e,t,"mutate",{mutations:[{[r]:n}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function _t(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:We(a),...n.query});const c=ke(o,Object.assign({},n,{url:At(e,r,i)})),u=new de((e=>t(c,o.requester).subscribe(e)));return n.signal?u.pipe((l=n.signal,e=>new de((t=>{const n=()=>t.error(function(e){var t,n;if(kt)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 St(e,t,n){return _t(e,t,n).pipe(be((e=>"response"===e.type)),we((e=>e.body)))}function jt(e,t,n){const r=e.config(),o=He(r),s="/".concat(t,"/").concat(o),i=n?"".concat(s,"/").concat(n):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function At(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 kt=Boolean(globalThis.DOMException);var Ft,Rt,It,Mt,Pt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Dt=(e,t,n)=>(Pt(e,t,"read from private field"),n?n.call(e):t.get(e)),qt=(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)=>(Pt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Ht{constructor(e,t){qt(this,Ft,void 0),qt(this,Rt,void 0),Nt(this,Ft,e),Nt(this,Rt,t)}upload(e,t,n){return zt(Dt(this,Ft),Dt(this,Rt),e,t,n)}}Ft=new WeakMap,Rt=new WeakMap;class Wt{constructor(e,t){qt(this,It,void 0),qt(this,Mt,void 0),Nt(this,It,e),Nt(this,Mt,t)}upload(e,t,n){return me(zt(Dt(this,It),Dt(this,Mt),e,t,n).pipe(be((e=>"response"===e.type)),we((e=>e.body.document))))}}function zt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Pe(n);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=He(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),_t(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})}It=new WeakMap,Mt=new WeakMap;const Ut="https://www.sanity.io/help/";function Lt(e){return Ut+e}const Bt=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)})),$t=Bt(["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(Lt("js-client-cdn-configuration")," "),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),Vt=Bt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(Lt("js-client-browser-token")," for more information and how to hide this warning.")]),Jt=Bt(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(Lt("js-client-api-version"))]),Gt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},Xt=["localhost","127.0.0.1","0.0.0.0"],Yt=(e,t)=>{const n=Object.assign({},t,e);n.apiVersion||Jt();const r=Object.assign({},Gt,n),o=r.useProjectHostname;if("undefined"==typeof Promise){const e=Lt("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!==Xt.indexOf(e))(window.location.hostname);s&&i&&r.token&&!0!==r.ignoreBrowserTokenWarning?Vt():void 0===r.useCdn&&$t(),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&&Me(r.dataset),"requestTagPrefix"in r&&(r.requestTagPrefix=r.requestTagPrefix?We(r.requestTagPrefix).replace(/\.+$/,""):void 0),r.apiVersion="".concat(r.apiVersion).replace(/^v/,""),r.isDefaultApi=r.apiHost===Gt.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 Kt=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((n,r)=>(n[r]=void 0===e[r]?t[r]:e[r],n)),{}),Zt=(e,t)=>t.reduce(((t,n)=>(void 0===e[n]||(t[n]=e[n]),t)),{});const Qt=14800,en=Ee,tn=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],nn={includeResult:!0};function rn(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={...Kt(n,nn),tag:a},u=Zt(c,tn),l=Le({query:e,params:t,options:{tag:a,...u}}),h="".concat(r).concat(jt(this,"listen",l));if(h.length>Qt)return new de((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 de((e=>{let t,n=u(),r=!1;function o(){r||(f&&e.next({type:"reconnect"}),r||n.readyState===en.CLOSED&&(c(),clearTimeout(t),t=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=on(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=on(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 en(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 on(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var sn,an,cn,un,ln=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},hn=(e,t,n)=>(ln(e,t,"read from private field"),n?n.call(e):t.get(e)),dn=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},fn=(e,t,n,r)=>(ln(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class pn{constructor(e,t){dn(this,sn,void 0),dn(this,an,void 0),fn(this,sn,e),fn(this,an,t)}create(e,t){return gn(hn(this,sn),hn(this,an),"PUT",e,t)}edit(e,t){return gn(hn(this,sn),hn(this,an),"PATCH",e,t)}delete(e){return gn(hn(this,sn),hn(this,an),"DELETE",e)}list(){return St(hn(this,sn),hn(this,an),{uri:"/datasets"})}}sn=new WeakMap,an=new WeakMap;class yn{constructor(e,t){dn(this,cn,void 0),dn(this,un,void 0),fn(this,cn,e),fn(this,un,t)}create(e,t){return me(gn(hn(this,cn),hn(this,un),"PUT",e,t))}edit(e,t){return me(gn(hn(this,cn),hn(this,un),"PATCH",e,t))}delete(e){return me(gn(hn(this,cn),hn(this,un),"DELETE",e))}list(){return me(St(hn(this,cn),hn(this,un),{uri:"/datasets"}))}}function gn(e,t,n,r,o){return Me(r),St(e,t,{method:n,uri:"/datasets/".concat(r),body:o})}cn=new WeakMap,un=new WeakMap;var vn,mn,wn,bn,Cn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},En=(e,t,n)=>(Cn(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)},xn=(e,t,n,r)=>(Cn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class On{constructor(e,t){Tn(this,vn,void 0),Tn(this,mn,void 0),xn(this,vn,e),xn(this,mn,t)}list(){return St(En(this,vn),En(this,mn),{uri:"/projects"})}getById(e){return St(En(this,vn),En(this,mn),{uri:"/projects/".concat(e)})}}vn=new WeakMap,mn=new WeakMap;class _n{constructor(e,t){Tn(this,wn,void 0),Tn(this,bn,void 0),xn(this,wn,e),xn(this,bn,t)}list(){return me(St(En(this,wn),En(this,bn),{uri:"/projects"}))}getById(e){return me(St(En(this,wn),En(this,bn),{uri:"/projects/".concat(e)}))}}wn=new WeakMap,bn=new WeakMap;var Sn,jn,An,kn,Fn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Rn=(e,t,n)=>(Fn(e,t,"read from private field"),n?n.call(e):t.get(e)),In=(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)},Mn=(e,t,n,r)=>(Fn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Pn{constructor(e,t){In(this,Sn,void 0),In(this,jn,void 0),Mn(this,Sn,e),Mn(this,jn,t)}getById(e){return St(Rn(this,Sn),Rn(this,jn),{uri:"/users/".concat(e)})}}Sn=new WeakMap,jn=new WeakMap;class Dn{constructor(e,t){In(this,An,void 0),In(this,kn,void 0),Mn(this,An,e),Mn(this,kn,t)}getById(e){return me(St(Rn(this,An),Rn(this,kn),{uri:"/users/".concat(e)}))}}An=new WeakMap,kn=new WeakMap;var qn,Nn,Hn,Wn,zn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Un=(e,t,n)=>(zn(e,t,"read from private field"),n?n.call(e):t.get(e)),Ln=(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)},Bn=(e,t,n,r)=>(zn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const $n=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;Ln(this,qn,void 0),Ln(this,Nn,void 0),this.listen=rn,this.config(t),Bn(this,Nn,e),this.assets=new Ht(this,Un(this,Nn)),this.datasets=new pn(this,Un(this,Nn)),this.projects=new On(this,Un(this,Nn)),this.users=new Pn(this,Un(this,Nn))}clone(){return new $n(Un(this,Nn),this.config())}config(e){if(void 0===e)return{...Un(this,qn)};if(Un(this,qn)&&!1===Un(this,qn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Bn(this,qn,Yt(e,Un(this,qn)||{})),this}withConfig(e){return new $n(Un(this,Nn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return vt(this,Un(this,Nn),e,t,n)}getDocument(e,t){return mt(this,Un(this,Nn),e,t)}getDocuments(e,t){return wt(this,Un(this,Nn),e,t)}create(e,t){return Ot(this,Un(this,Nn),e,"create",t)}createIfNotExists(e,t){return bt(this,Un(this,Nn),e,t)}createOrReplace(e,t){return Ct(this,Un(this,Nn),e,t)}delete(e,t){return Et(this,Un(this,Nn),e,t)}mutate(e,t){return Tt(this,Un(this,Nn),e,t)}patch(e,t){return new Ye(e,t,this)}transaction(e){return new lt(e,this)}request(e){return St(this,Un(this,Nn),e)}getUrl(e,t){return At(this,e,t)}getDataUrl(e,t){return jt(this,e,t)}};let Vn=$n;qn=new WeakMap,Nn=new WeakMap;const Jn=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;Ln(this,Hn,void 0),Ln(this,Wn,void 0),this.listen=rn,this.config(t),Bn(this,Wn,e),this.assets=new Wt(this,Un(this,Wn)),this.datasets=new yn(this,Un(this,Wn)),this.projects=new _n(this,Un(this,Wn)),this.users=new Dn(this,Un(this,Wn)),this.observable=new Vn(e,t)}clone(){return new Jn(Un(this,Wn),this.config())}config(e){if(void 0===e)return{...Un(this,Hn)};if(Un(this,Hn)&&!1===Un(this,Hn).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),Bn(this,Hn,Yt(e,Un(this,Hn)||{})),this}withConfig(e){return new Jn(Un(this,Wn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return me(vt(this,Un(this,Wn),e,t,n))}getDocument(e,t){return me(mt(this,Un(this,Wn),e,t))}getDocuments(e,t){return me(wt(this,Un(this,Wn),e,t))}create(e,t){return me(Ot(this,Un(this,Wn),e,"create",t))}createIfNotExists(e,t){return me(bt(this,Un(this,Wn),e,t))}createOrReplace(e,t){return me(Ct(this,Un(this,Wn),e,t))}delete(e,t){return me(Et(this,Un(this,Wn),e,t))}mutate(e,t){return me(Tt(this,Un(this,Wn),e,t))}patch(e,t){return new Ze(e,t,this)}transaction(e){return new ct(e,this)}request(e){return me(St(this,Un(this,Wn),e))}dataRequest(e,t,n){return me(xt(this,Un(this,Wn),e,t,n))}getUrl(e,t){return At(this,e,t)}getDataUrl(e,t){return jt(this,e,t)}};let Gn=Jn;Hn=new WeakMap,Wn=new WeakMap;const Xn=function(e){const t=O([...e,je,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"))}},Se,N({implementation:de})]);function n(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:t)({maxRedirects:0,...e})}return n.defaultRequester=t,n}([]),Yn=Xn.defaultRequester;e.BasePatch=Ge,e.BaseTransaction=it,e.ClientError=Te,e.ObservablePatch=Ye,e.ObservableSanityClient=Vn,e.ObservableTransaction=lt,e.Patch=Ze,e.SanityClient=Gn,e.ServerError=xe,e.Transaction=ct,e.createClient=e=>new Gn(Xn,e),e.default=function(){throw new TypeError("The default export of @sanity/client has been deprecated. Use the named export `createClient` instead")},e.requester=Yn,Object.defineProperty(e,"__esModule",{value:!0})}));
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=$&&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="",V=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(V===P&&c==="\n".charCodeAt(0))V=D;else if(V===P&&(V=D),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(V!==D){V===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(V===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=""}V=c==="\r".charCodeAt(0)?P:D}else V===D&&(J=a,V=q),V===q?c===":".charCodeAt(0)&&(G=a+1,V=N):V===N&&(V=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,V=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 $=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 V,J=c;null==s||null!=c&&"withCredentials"in c.prototype||(J=B),V=function(e){e.EventSourcePolyfill=B,e.NativeEventSource=c,e.EventSource=J}(t),void 0!==V&&(e.exports=V)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:i:globalThis)}({get exports(){return Ce},set exports(e){Ce=e}},Ce);var Ee=Ce.EventSourcePolyfill;class Te extends Error{constructor(e){const t=Oe(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class xe extends Error{constructor(e){const t=Oe(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function Oe(e){const t=e.body,n={response:e,statusCode:e.statusCode,responseBody:_e(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 _e(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Se={onResponse:e=>{if(e.statusCode>=500)throw new xe(e);if(e.statusCode>=400)throw new Te(e);return e}},je={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};const Ae="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 Fe=["image","file"],Re=["before","after","replace"],Ie=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")},Me=e=>{if(-1===Fe.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(Fe.join(", ")))},Pe=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},De=(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'))},qe=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));De(e,t._id)},Ne=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},He=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},We=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 ze,Ue,Le=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Be=(e,t,n)=>(Le(e,t,"read from private field"),n?n.call(e):t.get(e)),$e=(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)=>(Le(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Je{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 Pe("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===Re.indexOf(e)){const e=Re.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 Pe(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 Ge=class extends Je{constructor(e,t,n){super(e,t),$e(this,ze,void 0),Ve(this,ze,n)}clone(){return new Ge(this.selection,{...this.operations},Be(this,ze))}commit(e){if(!Be(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 Be(this,ze).mutate({patch:this.serialize()},n)}};let Xe=Ge;ze=new WeakMap;const Ye=class extends Je{constructor(e,t,n){super(e,t),$e(this,Ue,void 0),Ve(this,Ue,n)}clone(){return new Ye(this.selection,{...this.operations},Be(this,Ue))}commit(e){if(!Be(this,Ue))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 Be(this,Ue).mutate({patch:this.serialize()},n)}};let Ke=Ye;Ue=new WeakMap;var Ze,Qe,et=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},tt=(e,t,n)=>(et(e,t,"read from private field"),n?n.call(e):t.get(e)),nt=(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)},rt=(e,t,n,r)=>(et(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const ot={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 Pe("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Pe(t,e),qe(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Pe(t,e),qe(t,e),this._add({[t]:e})}delete(e){return De("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 it=class extends st{constructor(e,t,n){super(e,n),nt(this,Ze,void 0),rt(this,Ze,t)}clone(){return new it([...this.operations],tt(this,Ze),this.trxId)}commit(e){if(!tt(this,Ze))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return tt(this,Ze).mutate(this.serialize(),Object.assign({transactionId:this.trxId},ot,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof Ke)return this._add({patch:e.serialize()});if(n){const n=t(new Ke(e,{},tt(this,Ze)));if(!(n instanceof Ke))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=it;Ze=new WeakMap;const ct=class extends st{constructor(e,t,n){super(e,n),nt(this,Qe,void 0),rt(this,Qe,t)}clone(){return new ct([...this.operations],tt(this,Qe),this.trxId)}commit(e){if(!tt(this,Qe))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return tt(this,Qe).mutate(this.serialize(),Object.assign({transactionId:this.trxId},ot,e||{}))}patch(e,t){const n="function"==typeof t;if("string"!=typeof e&&e instanceof Xe)return this._add({patch:e.serialize()});if(n){const n=t(new Xe(e,{},tt(this,Qe)));if(!(n instanceof Xe))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 ut=ct;Qe=new WeakMap;const lt=(e,t)=>!1===e?void 0:void 0===e?t:e,ht=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:lt(e.returnDocuments,!0),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation}},dt=e=>"response"===e.type,ft=e=>e.body,pt=(e,t)=>e.reduce(((e,n)=>(e[t(n)]=n,e)),Object.create(null)),yt=11264;function gt(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 Tt(e,t,"query",{query:n,params:r},o).pipe(we(s))}function vt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ot(e,t,{uri:St(e,"doc",n),json:!0,tag:r.tag}).pipe(be(dt),we((e=>e.body.documents&&e.body.documents[0])))}function mt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ot(e,t,{uri:St(e,"doc",n.join(",")),json:!0,tag:r.tag}).pipe(be(dt),we((e=>{const t=pt(e.body.documents||[],(e=>e._id));return n.map((e=>t[e]||null))})))}function wt(e,t,n,r){return qe("createIfNotExists",n),xt(e,t,n,"createIfNotExists",r)}function bt(e,t,n,r){return qe("createOrReplace",n),xt(e,t,n,"createOrReplace",r)}function Ct(e,t,n,r){return Tt(e,t,"mutate",{mutations:[{delete:ke(n)}]},r)}function Et(e,t,n,r){const o=n instanceof Ke||n instanceof Xe||n instanceof at||n instanceof ut?n.serialize():n;return Tt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:r&&r.transactionId},r)}function Tt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===n,i="query"===n,a=s?"":We(r),c=!s&&a.length<yt,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p}=o;return Ot(e,t,{method:c?"GET":"POST",uri:St(e,n,u),json:!0,body:c?void 0:r,query:s&&ht(o),timeout:h,headers:p,token:d,tag:f,canUseCdn:i,signal:o.signal}).pipe(be(dt),we(ft),we((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 xt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return Tt(e,t,"mutate",{mutations:[{[r]:n}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function Ot(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:He(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[Ae]=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:jt(e,r,i)})),u=new de((e=>t(c,o.requester).subscribe(e)));return n.signal?u.pipe((l=n.signal,e=>new de((t=>{const n=()=>t.error(function(e){var t,n;if(At)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 _t(e,t,n){return Ot(e,t,n).pipe(be((e=>"response"===e.type)),we((e=>e.body)))}function St(e,t,n){const r=e.config(),o=Ne(r),s="/".concat(t,"/").concat(o),i=n?"".concat(s,"/").concat(n):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function jt(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 At=Boolean(globalThis.DOMException);var kt,Ft,Rt,It,Mt=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Pt=(e,t,n)=>(Mt(e,t,"read from private field"),n?n.call(e):t.get(e)),Dt=(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)},qt=(e,t,n,r)=>(Mt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Nt{constructor(e,t){Dt(this,kt,void 0),Dt(this,Ft,void 0),qt(this,kt,e),qt(this,Ft,t)}upload(e,t,n){return Wt(Pt(this,kt),Pt(this,Ft),e,t,n)}}kt=new WeakMap,Ft=new WeakMap;class Ht{constructor(e,t){Dt(this,Rt,void 0),Dt(this,It,void 0),qt(this,Rt,e),qt(this,It,t)}upload(e,t,n){return me(Wt(Pt(this,Rt),Pt(this,It),e,t,n).pipe(be((e=>"response"===e.type)),we((e=>e.body.document))))}}function Wt(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Me(n);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=Ne(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),Ot(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})}Rt=new WeakMap,It=new WeakMap;const zt="https://www.sanity.io/help/";function Ut(e){return zt+e}const Lt=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)})),Bt=Lt(["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(Ut("js-client-cdn-configuration")," "),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),$t=Lt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(Ut("js-client-browser-token")," for more information and how to hide this warning.")]),Vt=Lt(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(Ut("js-client-api-version"))]),Jt=Lt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]),Gt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},Xt=["localhost","127.0.0.1","0.0.0.0"],Yt=(e,t)=>{const n=Object.assign({},t,e);n.apiVersion||Vt();const r=Object.assign({},Gt,n),o=r.useProjectHostname;if("undefined"==typeof Promise){const e=Ut("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!==Xt.indexOf(e))(window.location.hostname);s&&i&&r.token&&!0!==r.ignoreBrowserTokenWarning?$t():void 0===r.useCdn&&Bt(),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&&Ie(r.dataset),"requestTagPrefix"in r&&(r.requestTagPrefix=r.requestTagPrefix?He(r.requestTagPrefix).replace(/\.+$/,""):void 0),r.apiVersion="".concat(r.apiVersion).replace(/^v/,""),r.isDefaultApi=r.apiHost===Gt.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 Kt=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((n,r)=>(n[r]=void 0===e[r]?t[r]:e[r],n)),{});const Zt=(e,t)=>t.reduce(((t,n)=>(void 0===e[n]||(t[n]=e[n]),t)),{}),Qt=14800,en=Ee,tn=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],nn={includeResult:!0};function rn(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={...Kt(n,nn),tag:a},u=Zt(c,tn),l=We({query:e,params:t,options:{tag:a,...u}}),h="".concat(r).concat(St(this,"listen",l));if(h.length>Qt)return new de((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 de((e=>{let t,n=u(),r=!1;function o(){r||(f&&e.next({type:"reconnect"}),r||n.readyState===en.CLOSED&&(c(),clearTimeout(t),t=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=on(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=on(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 en(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 on(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var sn,an,cn,un,ln=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},hn=(e,t,n)=>(ln(e,t,"read from private field"),n?n.call(e):t.get(e)),dn=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},fn=(e,t,n,r)=>(ln(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class pn{constructor(e,t){dn(this,sn,void 0),dn(this,an,void 0),fn(this,sn,e),fn(this,an,t)}create(e,t){return gn(hn(this,sn),hn(this,an),"PUT",e,t)}edit(e,t){return gn(hn(this,sn),hn(this,an),"PATCH",e,t)}delete(e){return gn(hn(this,sn),hn(this,an),"DELETE",e)}list(){return _t(hn(this,sn),hn(this,an),{uri:"/datasets"})}}sn=new WeakMap,an=new WeakMap;class yn{constructor(e,t){dn(this,cn,void 0),dn(this,un,void 0),fn(this,cn,e),fn(this,un,t)}create(e,t){return me(gn(hn(this,cn),hn(this,un),"PUT",e,t))}edit(e,t){return me(gn(hn(this,cn),hn(this,un),"PATCH",e,t))}delete(e){return me(gn(hn(this,cn),hn(this,un),"DELETE",e))}list(){return me(_t(hn(this,cn),hn(this,un),{uri:"/datasets"}))}}function gn(e,t,n,r,o){return Ie(r),_t(e,t,{method:n,uri:"/datasets/".concat(r),body:o})}cn=new WeakMap,un=new WeakMap;var vn,mn,wn,bn,Cn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},En=(e,t,n)=>(Cn(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)},xn=(e,t,n,r)=>(Cn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class On{constructor(e,t){Tn(this,vn,void 0),Tn(this,mn,void 0),xn(this,vn,e),xn(this,mn,t)}list(){return _t(En(this,vn),En(this,mn),{uri:"/projects"})}getById(e){return _t(En(this,vn),En(this,mn),{uri:"/projects/".concat(e)})}}vn=new WeakMap,mn=new WeakMap;class _n{constructor(e,t){Tn(this,wn,void 0),Tn(this,bn,void 0),xn(this,wn,e),xn(this,bn,t)}list(){return me(_t(En(this,wn),En(this,bn),{uri:"/projects"}))}getById(e){return me(_t(En(this,wn),En(this,bn),{uri:"/projects/".concat(e)}))}}wn=new WeakMap,bn=new WeakMap;var Sn,jn,An,kn,Fn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Rn=(e,t,n)=>(Fn(e,t,"read from private field"),n?n.call(e):t.get(e)),In=(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)},Mn=(e,t,n,r)=>(Fn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);class Pn{constructor(e,t){In(this,Sn,void 0),In(this,jn,void 0),Mn(this,Sn,e),Mn(this,jn,t)}getById(e){return _t(Rn(this,Sn),Rn(this,jn),{uri:"/users/".concat(e)})}}Sn=new WeakMap,jn=new WeakMap;class Dn{constructor(e,t){In(this,An,void 0),In(this,kn,void 0),Mn(this,An,e),Mn(this,kn,t)}getById(e){return me(_t(Rn(this,An),Rn(this,kn),{uri:"/users/".concat(e)}))}}An=new WeakMap,kn=new WeakMap;var qn,Nn,Hn,Wn,zn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Un=(e,t,n)=>(zn(e,t,"read from private field"),n?n.call(e):t.get(e)),Ln=(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)},Bn=(e,t,n,r)=>(zn(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);const $n=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;Ln(this,qn,void 0),Ln(this,Nn,void 0),this.listen=rn,this.config(t),Bn(this,Nn,e),this.assets=new Nt(this,Un(this,Nn)),this.datasets=new pn(this,Un(this,Nn)),this.projects=new On(this,Un(this,Nn)),this.users=new Pn(this,Un(this,Nn))}clone(){return new $n(Un(this,Nn),this.config())}config(e){if(void 0===e)return{...Un(this,qn)};if(Un(this,qn)&&!1===Un(this,qn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Bn(this,qn,Yt(e,Un(this,qn)||{})),this}withConfig(e){return new $n(Un(this,Nn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return gt(this,Un(this,Nn),e,t,n)}getDocument(e,t){return vt(this,Un(this,Nn),e,t)}getDocuments(e,t){return mt(this,Un(this,Nn),e,t)}create(e,t){return xt(this,Un(this,Nn),e,"create",t)}createIfNotExists(e,t){return wt(this,Un(this,Nn),e,t)}createOrReplace(e,t){return bt(this,Un(this,Nn),e,t)}delete(e,t){return Ct(this,Un(this,Nn),e,t)}mutate(e,t){return Et(this,Un(this,Nn),e,t)}patch(e,t){return new Xe(e,t,this)}transaction(e){return new ut(e,this)}request(e){return _t(this,Un(this,Nn),e)}getUrl(e,t){return jt(this,e,t)}getDataUrl(e,t){return St(this,e,t)}};let Vn=$n;qn=new WeakMap,Nn=new WeakMap;const Jn=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;Ln(this,Hn,void 0),Ln(this,Wn,void 0),this.listen=rn,this.config(t),Bn(this,Wn,e),this.assets=new Ht(this,Un(this,Wn)),this.datasets=new yn(this,Un(this,Wn)),this.projects=new _n(this,Un(this,Wn)),this.users=new Dn(this,Un(this,Wn)),this.observable=new Vn(e,t)}clone(){return new Jn(Un(this,Wn),this.config())}config(e){if(void 0===e)return{...Un(this,Hn)};if(Un(this,Hn)&&!1===Un(this,Hn).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),Bn(this,Hn,Yt(e,Un(this,Hn)||{})),this}withConfig(e){return new Jn(Un(this,Wn),{...this.config(),...e})}fetch(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return me(gt(this,Un(this,Wn),e,t,n))}getDocument(e,t){return me(vt(this,Un(this,Wn),e,t))}getDocuments(e,t){return me(mt(this,Un(this,Wn),e,t))}create(e,t){return me(xt(this,Un(this,Wn),e,"create",t))}createIfNotExists(e,t){return me(wt(this,Un(this,Wn),e,t))}createOrReplace(e,t){return me(bt(this,Un(this,Wn),e,t))}delete(e,t){return me(Ct(this,Un(this,Wn),e,t))}mutate(e,t){return me(Et(this,Un(this,Wn),e,t))}patch(e,t){return new Ke(e,t,this)}transaction(e){return new at(e,this)}request(e){return me(_t(this,Un(this,Wn),e))}dataRequest(e,t,n){return me(Tt(this,Un(this,Wn),e,t,n))}getUrl(e,t){return jt(this,e,t)}getDataUrl(e,t){return St(this,e,t)}};let Gn=Jn;Hn=new WeakMap,Wn=new WeakMap;const Xn=function(e){const t=O([...e,je,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"))}},Se,N({implementation:de})]);function n(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:t)({maxRedirects:0,...e})}return n.defaultRequester=t,n}([]),Yn=Xn.defaultRequester;e.BasePatch=Je,e.BaseTransaction=st,e.ClientError=Te,e.ObservablePatch=Xe,e.ObservableSanityClient=Vn,e.ObservableTransaction=ut,e.Patch=Ke,e.SanityClient=Gn,e.ServerError=xe,e.Transaction=at,e.createClient=e=>new Gn(Xn,e),e.default=function(e){return Jt(),new Gn(Xn,e)},e.requester=Yn,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1,9 +0,0 @@
1
- /**
2
- * @public
3
- * @deprecated Use the named export `createClient` instead of the `default` export
4
- */
5
- export function migrationNotice() {
6
- throw new TypeError(
7
- 'The default export of @sanity/client has been deprecated. Use the named export `createClient` instead'
8
- )
9
- }