├── .gitignore ├── .netlify └── state.json ├── netlify.toml ├── functions └── submission-created.js ├── package.json ├── src └── index.html ├── README.md └── lambda └── submission-created.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build/* 3 | lambda -------------------------------------------------------------------------------- /.netlify/state.json: -------------------------------------------------------------------------------- 1 | { 2 | "siteId": "c31bbb90-02c0-49d9-aae2-027af5a040ee" 3 | } -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "yarn build" 3 | functions = "lambda" # netlify-lambda reads this 4 | publish = "build" -------------------------------------------------------------------------------- /functions/submission-created.js: -------------------------------------------------------------------------------- 1 | const sanityClient = require('@sanity/client') 2 | const { uuid } = require('@sanity/uuid') 3 | const client = sanityClient({ 4 | projectId: 'zv292tg5', 5 | dataset: 'production', 6 | token: process.env.SANITY_TOKEN 7 | }) 8 | 9 | exports.handler = async function (event, context, callback) { 10 | const { payload } = JSON.parse(event.body) 11 | const result = await client.create({ 12 | _id: `submission.${uuid()}` 13 | _type: 'submission.form', ...payload }) 14 | callback(null, { 15 | statusCode: 200 16 | }) 17 | } 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "netlify-form-sanity", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "dependencies": { 7 | "@sanity/client": "^0.140.0", 8 | "@sanity/uuid": "^3.0.1" 9 | }, 10 | "devDependencies": { 11 | "netlify-cli": "^2.6.4", 12 | "netlify-lambda": "^1.3.0" 13 | }, 14 | "scripts": { 15 | "start": "netlify-lambda serve functions", 16 | "build": "cp src/index.html build/index.html && netlify-lambda build functions", 17 | "test": "echo \"Error: no test specified\" && exit 1" 18 | }, 19 | "keywords": [], 20 | "author": "", 21 | "license": "ISC" 22 | } 23 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | How to use Netlify Form and Functions to submit data to Sanity.io 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |
17 |

How to use Netlify Form and Functions to submit data to Sanity.io

18 |
19 |
20 | 23 |
24 |
25 | 28 |
29 |
30 | 31 |
32 | 36 |
37 |
38 |
39 | 42 |
43 |
44 | 45 |
46 |
47 |
48 |
49 |
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to use Netlify Forms and Functions to submit data to Sanity.io 2 | 3 | This is a simple example of how you can use Forms and Functions in [Netlify](https://netlify.com) to submit data to your Sanity.io project. 4 | 5 | ![Demonstration of Netlify form via Functions to Sanity Studio](https://cdn.sanity.io/images/3do82whm/production/1728e9c2e1a25edbbb914e53edff8ded40ed2567-1642x1056.gif) 6 | 7 | ## How to use 8 | 9 | 1. Fork or clone this repo 10 | 2. Run `yarn` or `npm install` 11 | 3. Change the `projectId` and the `dataset` configuration in `/lambda/submission-created.js` to your Sanity.io project`s 12 | 4. Commit and push the changes to your GitHub repo 13 | 5. Connect Netlify to that repo, and add a environment variable in Netlify called `SANITY_TOKEN` 14 | 6. Go to your Settings -> API in your project at [manage.sanity.io](https://manage.sanity.io), and add a token with `write` rights. 15 | 7. Paste this token as the value for `SANITY_TOKEN` (be careful with where you store this token!) 16 | 8. Submissions will be stored with `_id` on [a path](https://www.sanity.io/docs/ids): `"submission."`, and will not be available through the public API without a token with `read` rights. 17 | 9. If you want to view the submissions in the Studio, you can add the following schema to your project: 18 | 19 | ```js 20 | /* 21 | * Doesn't cover all the data fields. 22 | * Remove or set readOnly to `false` if you want to be able 23 | * to edit the responses in the Studio 24 | */ 25 | 26 | export default { 27 | name: 'submission.form', 28 | type: 'document', 29 | title: 'Form submission', 30 | readOnly: true, 31 | fields: [ 32 | { 33 | name: 'title', 34 | type: 'string', 35 | title: 'Title' 36 | }, 37 | { 38 | name: 'number', 39 | type: 'number', 40 | title: 'Number' 41 | }, 42 | { 43 | name: 'created_at', 44 | type: 'datetime', 45 | title: 'Created at' 46 | }, 47 | { 48 | name: 'data', 49 | type: 'object', 50 | title: 'Data', 51 | fields: [ 52 | { 53 | name: 'email', 54 | type: 'email', 55 | title: 'Email' 56 | }, 57 | { 58 | name: 'name', 59 | type: 'string', 60 | title: 'Name' 61 | }, 62 | { 63 | name: 'message', 64 | type: 'text', 65 | title: 'Message' 66 | }, 67 | { 68 | name: 'role', 69 | type: 'array', 70 | title: 'Role', 71 | of: [{ type: 'string' }] 72 | } 73 | ] 74 | } 75 | ] 76 | } 77 | 78 | ``` 79 | -------------------------------------------------------------------------------- /lambda/submission-created.js: -------------------------------------------------------------------------------- 1 | !function(e,t){for(var r in t)e[r]=t[r]}(exports,function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=44)}([function(e,t,r){"use strict"; 2 | /* 3 | object-assign 4 | (c) Sindre Sorhus 5 | @license MIT 6 | */var n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,s,a=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=e,this.operations=i({},t),this.client=r}i(f.prototype,{clone:function(){return new f(this.selection,i({},this.operations),this.client)},merge:function(e){u("merge",e);var t=(new Error).stack.toString().split("\n").filter(function(e){return e.trim()}).slice(2);return console.warn('The "merge" patch has been deprecated and will be removed in the future\n'.concat(t.join("\n"))),this._assign("merge",o(this.operations.merge||{},e))},set:function(e){return this._assign("set",e)},diffMatchPatch:function(e){return u("diffMatchPatch",e),this._assign("diffMatchPatch",e)},unset:function(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=i({},this.operations,{unset:e}),this},setIfMissing:function(e){return this._assign("setIfMissing",e)},replace:function(e){return u("replace",e),this._set("set",{$:e})},inc:function(e){return this._assign("inc",e)},dec:function(e){return this._assign("dec",e)},insert:function(e,t,r){var o;return c(e,t,r),this._assign("insert",(n(o={},e,t),n(o,"items",r),o))},append:function(e,t){return this.insert("after","".concat(e,"[-1]"),t)},prepend:function(e,t){return this.insert("before","".concat(e,"[0]"),t)},splice:function(e,t,r,n){var o=t<0?t-1:t,i=void 0===r||-1===r?-1:Math.max(0,t+r),s=o<0&&i>=0?"":i,a="".concat(e,"[").concat(o,":").concat(s,"]");return this.insert("replace",a,n||[])},ifRevisionId:function(e){return this.operations.ifRevisionID=e,this},serialize:function(){return i(s(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");var t="string"==typeof this.selection,r=i({returnFirst:t,returnDocuments:!0},e);return this.client.mutate({patch:this.serialize()},r)},reset:function(){return this.operations={},this},_set:function(e,t){return this._assign(e,t,!1)},_assign:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return u(e,t),this.operations=i({},this.operations,n({},e,i({},r&&this.operations[e]||{},t))),this}}),e.exports=f},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("https")},function(e,t){e.exports=require("http")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=function(e){return"function"==typeof e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(12),o=r(19);t.empty={closed:!0,next:function(e){},error:function(e){if(n.config.useDeprecatedSynchronousErrorHandling)throw e;o.hostReportError(e)},complete:function(){}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hostReportError=function(e){setTimeout(function(){throw e})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorObject={e:{}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rxSubscriber="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),t.$$rxSubscriber=t.rxSubscriber},function(e,t,r){"use strict";e.exports=function(e){if("string"==typeof e||Array.isArray(e))return{id:e};if(e&&e.query)return{query:e.query};var t=["* Document ID ()","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(t))}},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=r(0),i=r(3),s=r(13),a={returnDocuments:!1};function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;this.trxId=r,this.operations=e,this.client=t}o(u.prototype,{clone:function(){return new u(this.operations.slice(0),this.client,this.trxId)},create:function(e){return i.validateObject("create",e),this._add({create:e})},createIfNotExists:function(e){var t="createIfNotExists";return i.validateObject(t,e),i.requireDocumentId(t,e),this._add(n({},t,e))},createOrReplace:function(e){var t="createOrReplace";return i.validateObject(t,e),i.requireDocumentId(t,e),this._add(n({},t,e))},delete:function(e){return i.validateDocumentId("delete",e),this._add({delete:{id:e}})},patch:function(e,t){var r="function"==typeof t;if(e instanceof s)return this._add({patch:e.serialize()});if(r){var n=t(new s(e,{},this.client));if(!(n instanceof s))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:n.serialize()})}return this._add({patch:o({id:e},t)})},transactionId:function(e){return e?(this.trxId=e,this):this.trxId},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(e){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),o({transactionId:this.trxId},a,e||{}))},reset:function(){return this.operations=[],this},_add:function(e){return this.operations.push(e),this}}),e.exports=u},function(e,t,r){"use strict";var n=encodeURIComponent;e.exports=function(e){var t=e.query,r=e.params,o=void 0===r?{}:r,i=e.options,s=void 0===i?{}:i,a="?query=".concat(n(t)),u=Object.keys(o).reduce(function(e,t){return"".concat(e,"&").concat(n("$".concat(t)),"=").concat(n(JSON.stringify(o[t])))},a);return Object.keys(s).reduce(function(e,t){return s[t]?"".concat(e,"&").concat(n(t),"=").concat(n(s[t])):e},u)}},function(e,t,r){e.exports=r(57)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(58),o=r(59),i=r(60),s=r(27),a=r(12),u=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n=this.operator,i=o.toSubscriber(e,t,r);if(n?n.call(i,this.source):i.add(this.source||a.config.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),a.config.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){a.config.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),n.canReportError(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=c(t))(function(t,n){var o;o=r.subscribe(function(t){try{e(t)}catch(e){n(e),o&&o.unsubscribe()}},n,t)})},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[i.observable]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*o;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===c&&!1===isNaN(e))return t.long?a(u=e,i,"day")||a(u,o,"hour")||a(u,n,"minute")||a(u,r,"second")||u+" ms":function(e){if(e>=i)return Math.round(e/i)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t){e.exports=require("tty")},function(e,t,r){var n=r(9);"disable"===process.env.READABLE_STREAM&&n?(e.exports=n,(t=e.exports=n.Readable).Readable=n.Readable,t.Writable=n.Writable,t.Duplex=n.Duplex,t.Transform=n.Transform,t.PassThrough=n.PassThrough,t.Stream=n):((t=e.exports=r(36)).Stream=n||t,t.Readable=t,t.Writable=r(39),t.Duplex=r(5),t.Transform=r(41),t.PassThrough=r(109))},function(e,t,r){"use strict";var n=r(10);e.exports=m;var o,i=r(104);m.ReadableState=g;r(29).EventEmitter;var s=function(e,t){return e.listeners(t).length},a=r(37),u=r(11).Buffer,c=global.Uint8Array||function(){};var f=r(6);f.inherits=r(4);var l=r(1),p=void 0;p=l&&l.debuglog?l.debuglog("stream"):function(){};var d,h=r(107),b=r(38);f.inherits(m,a);var y=["error","close","destroy","pause","resume"];function g(e,t){e=e||{};var n=t instanceof(o=o||r(5));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,s=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=r(40).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function m(e){if(o=o||r(5),!(this instanceof m))return new m(e);this._readableState=new g(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function v(e,t,r,n,o){var i,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,O(e)}(e,s)):(o||(i=function(e,t){var r;n=t,u.isBuffer(n)||n instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(s,t)),i?e.emit("error",i):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):S(e,s)):w(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=_?e=_:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function O(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?n.nextTick(C,e):C(e))}function C(e){p("emit readable"),e.emit("readable"),T(e)}function S(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;ei.length?i.length:e;if(s===i.length?o+=i:o+=i.slice(0,e),0===(e-=s)){s===i.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(s));break}++n}return t.length-=n,o}(e,t):function(e,t){var r=u.allocUnsafe(e),n=t.head,o=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var i=n.data,s=e>i.length?i.length:e;if(i.copy(r,r.length-e,0,s),0===(e-=s)){s===i.length?(++o,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(s));break}++o}return t.length-=o,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function P(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,n.nextTick(I,t,e))}function I(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function A(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?P(this):O(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&P(this),null;var n,o=t.needReadable;return p("need readable",o),(0===t.length||t.length-e0?k(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&P(this)),null!==n&&this.emit("data",n),n},m.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,t);var a=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?c:m;function u(t,n){p("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),e.removeListener("close",y),e.removeListener("finish",g),e.removeListener("drain",f),e.removeListener("error",b),e.removeListener("unpipe",u),r.removeListener("end",c),r.removeListener("end",m),r.removeListener("data",h),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function c(){p("onend"),e.end()}o.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",u);var f=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,T(e))}}(r);e.on("drain",f);var l=!1;var d=!1;function h(t){p("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==A(o.pipes,e))&&!l&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function b(t){p("onerror",t),m(),e.removeListener("error",b),0===s(e,"error")&&e.emit("error",t)}function y(){e.removeListener("finish",g),m()}function g(){p("onfinish"),e.removeListener("close",y),m()}function m(){p("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?i(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",b),e.once("close",y),e.once("finish",g),e.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),e},m.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1?setImmediate:n.nextTick;y.WritableState=b;var a=r(6);a.inherits=r(4);var u={deprecate:r(108)},c=r(37),f=r(11).Buffer,l=global.Uint8Array||function(){};var p,d=r(38);function h(){}function b(e,t){i=i||r(5),e=e||{};var a=t instanceof i;this.objectMode=!!e.objectMode,a&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var u=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=u||0===u?u:a&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",o)):(i(o),e._writableState.errorEmitted=!0,e.emit("error",o),E(e,t))}(e,r,o,t,i);else{var a=w(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||v(e,r),o?s(m,e,r,a,i):m(e,r,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function y(e){if(i=i||r(5),!(p.call(y,this)||this instanceof i))return new y(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),c.call(this)}function g(e,t,r,n,o,i,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function m(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),E(e,t)}function v(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,g(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(g(e,t,!1,t.objectMode?1:c.length,c,f,l),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function w(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function _(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function E(e,t){var r=w(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,n.nextTick(_,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}a.inherits(y,c),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:u.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===y&&(e&&e._writableState instanceof b)}})):p=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,r){var o,i=this._writableState,s=!1,a=!i.objectMode&&(o=e,f.isBuffer(o)||o instanceof l);return a&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=h),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),n.nextTick(t,r)}(this,r):(a||function(e,t,r,o){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),n.nextTick(o,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,o,i){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,r));return t}(t,n,o);n!==s&&(r=!0,o="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,r){var o=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||o.finished||function(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,o,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=d.destroy,y.prototype._undestroy=d.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}},function(e,t,r){"use strict";var n=r(11).Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=f,this.end=l,t=3;break;default:return this.write=p,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return o>0&&(e.lastNeed=o-1),o;if(--n=0)return o>0&&(e.lastNeed=o-2),o;if(--n=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";e.exports=s;var n=r(5),o=r(6);function i(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length=u?i-u:0,Date.now()>=c&&h(!1),n(null,e)},function(e){h(!0),e()}),y=function(e){i=e,d.length=i,d.remaining=i-d.transferred,b.emit("length",i)};return b.setLength=y,b.on("pipe",function(e){if("number"!=typeof i)return e.readable&&!e.writable&&e.headers?y(parseInt(e.headers["content-length"]||0)):"number"==typeof e.length?y(e.length):void e.on("response",function(e){if(e&&e.headers&&"gzip"!==e.headers["content-encoding"])return e.headers["content-length"]?y(parseInt(e.headers["content-length"])):void 0})}),a&&b.resume(),r&&b.on("progress",r),b.progress=function(){return d.speed=l(0),d.eta=Math.round(d.remaining/d.speed),d},b}},function(e,t,r){var n;function o(e){function r(){if(r.enabled){var e=r,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;for(var s=new Array(arguments.length),a=0;a0&&void 0!==arguments[0]?arguments[0]:g;if(!(this instanceof v))return new v(e);if(this.config(e),this.assets=new l(this),this.datasets=new c(this),this.projects=new f(this),this.users=new p(this),this.auth=new d(this),this.clientConfig.isPromiseAPI){var t=n({},this.clientConfig,{isPromiseAPI:!1});this.observable=new v(t)}}n(v.prototype,u),n(v.prototype,{clone:function(){return new v(this.config())},config:function(e){if(void 0===e)return n({},this.clientConfig);if(this.observable){var t=n({},e,{isPromiseAPI:!1});this.observable.config(t)}return this.clientConfig=m(e,this.clientConfig||{}),this},getUrl:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.clientConfig.cdnUrl:this.clientConfig.url;return"".concat(t,"/").concat(e.replace(/^\//,""))},isPromiseAPI:function(){return this.clientConfig.isPromiseAPI},_requestObservable:function(e){var t=e.url||e.uri,r=this.clientConfig.useCdn&&["GET","HEAD"].indexOf(e.method||"GET")>=0&&0===t.indexOf("/data/");return h(function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};return{returnIds:!0,returnDocuments:(e=r.returnDocuments,t=!0,!1===e?void 0:void 0===e?t:e),visibility:r.visibility||"sync"}},h=function(e){return"response"===e.type},b=function(e){return e.body},y=function(e){return e.toPromise()};e.exports={listen:p,getDataUrl:function(e,t){var r=this.clientConfig,n=r.gradientMode?r.namespace:a.hasDataset(r),o="/".concat(e,"/").concat(n),i=t?"".concat(o,"/").concat(t):o;return(this.clientConfig.gradientMode?i:"/data".concat(i)).replace(/\/($|\?)/,"$1")},fetch:function(e,t){var r=!1===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).filterResponse?function(e){return e}:function(e){return e.result},n=this._dataRequest("query",{query:e,params:t}).pipe(s(r));return this.isPromiseAPI()?y(n):n},getDocument:function(e){var t={uri:this.getDataUrl("doc",e),json:!0},r=this._requestObservable(t).pipe(i(h),s(function(e){return e.body.documents&&e.body.documents[0]}));return this.isPromiseAPI()?y(r):r},create:function(e,t){return this._create(e,"create",t)},createIfNotExists:function(e,t){return a.requireDocumentId("createIfNotExists",e),this._create(e,"createIfNotExists",t)},createOrReplace:function(e,t){return a.requireDocumentId("createOrReplace",e),this._create(e,"createOrReplace",t)},patch:function(e,t){return new l(e,t,this)},delete:function(e,t){return this.dataRequest("mutate",{mutations:[{delete:u(e)}]},t)},mutate:function(e,t){var r=e instanceof l||e instanceof f?e.serialize():e,n=Array.isArray(r)?r:[r],o=t&&t.transactionId;return this.dataRequest("mutate",{mutations:n,transactionId:o},t)},transaction:function(e){return new f(e,this)},dataRequest:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._dataRequest(e,t,r);return this.isPromiseAPI()?y(n):n},_dataRequest:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o="mutate"===e,a=!o&&c(t),u=!o&&a.length<11264,f=u?a:"",l=r.returnFirst,p={method:u?"GET":"POST",uri:this.getDataUrl(e,f),json:!0,body:u?void 0:t,query:o&&d(r)};return this._requestObservable(p).pipe(i(h),s(b),s(function(e){if(!o)return e;var t=e.results||[];if(r.returnDocuments)return l?t[0]&&t[0].document:t.map(function(e){return e.document});var i=l?"documentId":"documentIds",s=l?t[0]&&t[0].id:t.map(function(e){return e.id});return n({transactionId:e.transactionId,results:t},i,s)}))},_create:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n({},t,e),s=o({returnFirst:!0,returnDocuments:!0},r);return this.dataRequest("mutate",{mutations:[i]},s)}}},function(e,t,r){"use strict";var n=r(0),o=r(25),i=r(69),s=r(74),a=r(75),u=r(24),c=r(30),f=r(31),l=["Using token with listeners is not supported in browsers. ","For more info, see ".concat(c("js-client-listener-tokens-browser"),".")],p=f(function(){return console.warn(l.join(" "))}),d=Boolean("undefined"!=typeof window&&window.EventSource),h=d?window.EventSource:i,b=["includePreviousRevision","includeResult"],y={includeResult:!0};function g(e){try{var t=e.data&&JSON.parse(e.data)||{};return n({type:e.type},t)}catch(e){return e}}e.exports=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=a(r,y),i=s(n,b),c=u({query:e,params:t,options:i}),f=this.clientConfig,l=f.url,m=f.token,v=f.withCredentials,w="".concat(l).concat(this.getDataUrl("listen",c)),_=n.events?n.events:["mutation"],E=-1!==_.indexOf("reconnect");m&&d&&p();var O={};return(m||v)&&(O.withCredentials=!0),m&&(O.headers={Authorization:"Bearer ".concat(m)}),new o(function(e){var t,r=c(),n=!1;function o(){n||(E&&e.next({type:"reconnect"}),n||r.readyState===h.CLOSED&&(u(),clearTimeout(t),t=setTimeout(f,100)))}function i(t){e.error(function(e){if(e instanceof Error)return e;var t=g(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 s(t){var r=g(t);return r instanceof Error?e.error(r):e.next(r)}function a(t){n=!0,u(),e.complete()}function u(){r.removeEventListener("error",o,!1),r.removeEventListener("channelError",i,!1),r.removeEventListener("disconnect",a,!1),_.forEach(function(e){return r.removeEventListener(e,s,!1)}),r.close()}function c(){var e=new h(w,O);return e.addEventListener("error",o,!1),e.addEventListener("channelError",i,!1),e.addEventListener("disconnect",a,!1),_.forEach(function(t){return e.addEventListener(t,s,!1)}),e}function f(){r=c()}return function(){n=!0,u()}})}},function(e,t,r){"use strict";var n=r(26).Observable,o=r(0),i=r(8).map,s=r(7).filter,a=r(62).reduce;function u(){n.apply(this,arguments)}function c(e,t){var r=!1;return function(){return r||(r=!0,console.warn(new Error("Calling observable.".concat(e,"(...) is deprecated. Please use observable.pipe(").concat(e,"(...)) instead")))),this.pipe(t.apply(this,arguments))}}u.prototype=Object.create(o(Object.create(null),n.prototype)),Object.defineProperty(u.prototype,"constructor",{value:u,enumerable:!1,writable:!0,configurable:!0}),u.prototype.lift=function(e){var t=new u;return t.source=this,t.operator=e,t},u.prototype.map=c("map",i),u.prototype.filter=c("filter",s),u.prototype.reduce=c("filter",a),e.exports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);t.canReportError=function(e){for(;e;){var t=e,r=t.closed,o=t.destination,i=t.isStopped;if(r||i)return!1;e=o&&o instanceof n.Subscriber?o:null}return!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(21),i=r(18);t.toSubscriber=function(e,t,r){if(e){if(e instanceof n.Subscriber)return e;if(e[o.rxSubscriber])return e[o.rxSubscriber]()}return e||t||r?new n.Subscriber(e,t,r):new n.Subscriber(i.empty)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.observable="function"==typeof Symbol&&Symbol.observable||"@@observable"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noop=function(){}},function(e,t,r){t.reduce=r(63).reduce},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(64),o=r(65),i=r(68),s=r(27);t.reduce=function(e,t){return arguments.length>=2?function(r){return s.pipe(n.scan(e,t),o.takeLast(1),i.defaultIfEmpty(t))(r)}:function(t){return s.pipe(n.scan(function(t,r,n){return e(t,r,n+1)}),o.takeLast(1))(t)}}},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=r(2);t.scan=function(e,t){var r=!1;return arguments.length>=2&&(r=!0),function(n){return n.lift(new s(e,t,r))}};var s=function(){function e(e,t,r){void 0===r&&(r=!1),this.accumulator=e,this.seed=t,this.hasSeed=r}return e.prototype.call=function(e,t){return t.subscribe(new a(e,this.accumulator,this.seed,this.hasSeed))},e}(),a=function(e){function t(t,r,n,o){var i=e.call(this,t)||this;return i.accumulator=r,i._seed=n,i.hasSeed=o,i.index=0,i}return o(t,e),Object.defineProperty(t.prototype,"seed",{get:function(){return this._seed},set:function(e){this.hasSeed=!0,this._seed=e},enumerable:!0,configurable:!0}),t.prototype._next=function(e){if(this.hasSeed)return this._tryNext(e);this.seed=e,this.destination.next(e)},t.prototype._tryNext=function(e){var t,r=this.index++;try{t=this.accumulator(this.seed,e,r)}catch(e){this.destination.error(e)}this.seed=t,this.destination.next(t)},t}(i.Subscriber)},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),s=r(66),a=r(67);t.takeLast=function(e){return function(t){return 0===e?a.empty():t.lift(new u(e))}};var u=function(){function e(e){if(this.total=e,this.total<0)throw new s.ArgumentOutOfRangeError}return e.prototype.call=function(e,t){return t.subscribe(new c(e,this.total))},e}(),c=function(e){function t(t,r){var n=e.call(this,t)||this;return n.total=r,n.ring=new Array,n.count=0,n}return o(t,e),t.prototype._next=function(e){var t=this.ring,r=this.total,n=this.count++;t.length0)for(var r=this.count>=this.total?this.total:this.count,n=this.ring,o=0;o0&&(n=n.slice(t))})})).on("error",function(e){m(e.message)}),i.setNoDelay&&i.setNoDelay(!0),i.end()}function S(){u.listeners(arguments[0]).length>0&&u.emit.apply(u,arguments)}function x(t,r,o,i){if(0===i){if(_.length>0){var s=E||"message";S(s,new g(s,{data:_.slice(0,-1),lastEventId:v,origin:n(e)})),_=""}E=void 0}else if(o>0){var a=o<0,c=0,f=t.slice(r,r+(a?i:o)).toString();r+=c=a?i:t[r+o+1]!==p?o+1:o+2;var l=i-c,d=t.slice(r,r+l).toString();if("data"===f)_+=d+"\n";else if("event"===f)E=d;else if("id"===f)v=d;else if("retry"===f){var h=parseInt(d,10);Number.isNaN(h)||(u.reconnectInterval=h)}}}C(),this._close=function(){r!==b.CLOSED&&(r=b.CLOSED,i.abort&&i.abort(),i.xhr&&i.xhr.abort&&i.xhr.abort())}}function y(e,t){if(Object.defineProperty(this,"type",{writable:!1,value:e,enumerable:!0}),t)for(var r in t)t.hasOwnProperty(r)&&Object.defineProperty(this,r,{writable:!1,value:t[r],enumerable:!0})}function g(e,t){for(var r in Object.defineProperty(this,"type",{writable:!1,value:e,enumerable:!0}),t)t.hasOwnProperty(r)&&Object.defineProperty(this,r,{writable:!1,value:t[r],enumerable:!0})}e.exports=b,u.inherits(b,i.EventEmitter),b.prototype.constructor=b,["open","error","message"].forEach(function(e){Object.defineProperty(b.prototype,"on"+e,{get:function(){var t=this.listeners(e)[0];return t?t._listener?t._listener:t:void 0},set:function(t){this.removeAllListeners(e),this.addEventListener(e,t)}})}),Object.defineProperty(b,"CONNECTING",{enumerable:!0,value:0}),Object.defineProperty(b,"OPEN",{enumerable:!0,value:1}),Object.defineProperty(b,"CLOSED",{enumerable:!0,value:2}),b.prototype.CONNECTING=0,b.prototype.OPEN=1,b.prototype.CLOSED=2,b.prototype.close=function(){this._close()},b.prototype.addEventListener=function(e,t){"function"==typeof t&&(t._listener=t,this.on(e,t))},b.prototype.dispatchEvent=function(e){if(!e.type)throw new Error("UNSPECIFIED_EVENT_TYPE_ERR");this.emit(e.type,e.detail)},b.prototype.removeEventListener=function(e,t){"function"==typeof t&&(t._listener=void 0,this.removeListener(e,t))}},function(e,t,r){"use strict";var n=r(28);function o(e){return"string"==typeof e&&(e=n(e)),e.protocol&&e.hostname?(e.protocol+"//"+e.host).toLowerCase():"null"}o.same=function(e,t){return o(e)===o(t)},e.exports=o},function(e,t,r){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t,r){"use strict";var n,o=Object.prototype.hasOwnProperty;function i(e){return decodeURIComponent(e.replace(/\+/g," "))}t.stringify=function(e,t){t=t||"";var r,i,s=[];for(i in"string"!=typeof t&&(t="?"),e)o.call(e,i)&&((r=e[i])||null!==r&&r!==n&&!isNaN(r)||(r=""),s.push(encodeURIComponent(i)+"="+encodeURIComponent(r)));return s.length?t+s.join("&"):""},t.parse=function(e){for(var t,r=/([^=?&]+)=?([^&]*)/g,n={};t=r.exec(e);){var o=i(t[1]),s=i(t[2]);o in n||(n[o]=s)}return n}},function(e,t,r){"use strict";e.exports=function(e,t){return t.reduce(function(t,r){return void 0===e[r]?t:(t[r]=e[r],t)},{})}},function(e,t,r){"use strict";e.exports=function(e,t){return Object.keys(t).concat(Object.keys(e)).reduce(function(r,n){return r[n]=void 0===e[n]?t[n]:e[n],r},{})}},function(e,t,r){"use strict";var n=r(0),o=r(3);function i(e){this.request=e.request.bind(e)}n(i.prototype,{create:function(e,t){return this._modify("PUT",e,t)},edit:function(e,t){return this._modify("PATCH",e,t)},delete:function(e){return this._modify("DELETE",e)},list:function(){return this.request({uri:"/datasets"})},_modify:function(e,t,r){return o.dataset(t),this.request({method:e,uri:"/datasets/".concat(t),body:r})}}),e.exports=i},function(e,t,r){"use strict";function n(e){this.client=e}r(0)(n.prototype,{list:function(){return this.client.request({uri:"/projects"})},getById:function(e){return this.client.request({uri:"/projects/".concat(e)})}}),e.exports=n},function(e,t,r){"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=r(0),i=r(8).map,s=r(7).filter,a=r(79),u=r(3);function c(e){this.client=e}o(c.prototype,{upload:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u.validateAssetType(e);var n=r.extract||void 0;n&&!n.length&&(n=["none"]);var a=u.hasDataset(this.client.clientConfig),c="image"===e?"images":"files",f=function(e,t){return"undefined"!=typeof window&&t instanceof window.File?o({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e):e}(r,t),l={label:f.label,filename:f.filename,meta:n},p=this.client._requestObservable({method:"POST",timeout:f.timeout||0,uri:"/assets/".concat(c,"/").concat(a),headers:f.contentType?{"Content-Type":f.contentType}:{},query:l,body:t});return this.client.isPromiseAPI()?p.pipe(s(function(e){return"response"===e.type}),i(function(e){return t=e.body,r=t.document,Object.defineProperty(r,"document",{enumerable:!1,get:function(){return console.warn("The promise returned from client.asset.upload(...) now resolves with the asset document"),r}}),r;var t,r})).toPromise():p},delete:function(e,t){console.warn("client.assets.delete() is deprecated, please use client.delete()");var r=t||"";return/^(image|file)-/.test(r)?e._id&&(r=e._id):r="".concat(e,"-").concat(r),u.hasDataset(this.client.clientConfig),this.client.delete(r)},getImageUrl:function(e,t){var r=e._ref||e;if("string"!=typeof r)throw new Error("getImageUrl() needs either an object with a _ref, or a string with an asset document ID");if(!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(r))throw new Error('Unsupported asset ID "'.concat(r,'". URL generation only works for auto-generated IDs.'));var o=n(r.split("-"),4),i=o[1],s=o[2],c=o[3];u.hasDataset(this.client.clientConfig);var f=this.client.clientConfig,l=f.projectId,p=f.dataset,d=t?a(t):"";return"https://cdn.sanity.io/images/".concat(l,"/").concat(p,"/").concat(i,"-").concat(s,".").concat(c).concat(d)}}),e.exports=c},function(e,t,r){"use strict";e.exports=function(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(e[r])));return t.length>0?"?".concat(t.join("&")):""}},function(e,t,r){"use strict";function n(e){this.client=e}r(0)(n.prototype,{getById:function(e){return this.client.request({uri:"/users/".concat(e)})}}),e.exports=n},function(e,t,r){"use strict";function n(e){this.client=e}r(0)(n.prototype,{getLoginProviders:function(){return this.client.request({uri:"/auth/providers"})},logout:function(){return this.client.request({uri:"/auth/logout",method:"POST"})}}),e.exports=n},function(e,t,r){"use strict";var n=r(83),o=r(0),i=r(117),s=r(119),a=r(122),u=r(123),c=r(25),f=r(125),l=f.ClientError,p=f.ServerError,d={onResponse:function(e){if(e.statusCode>=500)throw new p(e);if(e.statusCode>=400)throw new l(e);return e}},h=n(r(127).concat([s(),a(),u(),d,i({implementation:c})]));function b(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:h)(o({maxRedirects:0},e))}b.defaultRequester=h,b.ClientError=l,b.ServerError=p,e.exports=b},function(e,t,r){e.exports=r(84)},function(e,t,r){"use strict";const n=r(85),o=r(86),i=r(87),s=r(88),a=r(89),u=["request","response","progress","error","abort"],c=["processOptions","validateOptions","interceptRequest","onRequest","onResponse","onError","onReturn","onHeaders"];e.exports=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const r=[],f=c.reduce((e,t)=>(e[t]=e[t]||[],e),{processOptions:[i],validateOptions:[s]});function l(e){const t=u.reduce((e,t)=>(e[t]=n(),e),{}),r=o(f),i=r("processOptions",e);r("validateOptions",i);const s={options:i,channels:t,applyMiddleware:r};let c=null;const l=t.request.subscribe(e=>{c=a(e,(n,o)=>(function(e,n,o){let i=e,s=n;if(!i)try{s=r("onResponse",n,o)}catch(e){s=null,i=e}(i=i&&r("onError",i,o))?t.error.publish(i):s&&t.response.publish(s)})(n,o,e))});t.abort.subscribe(()=>{l(),c&&c.abort()});const p=r("onReturn",t,s);return p===t&&t.request.publish(s),p}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&f.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return c.forEach(t=>{e[t]&&f[t].push(e[t])}),r.push(e),l},l.clone=function(){return e(r)},t.forEach(l.use),l}},function(e,t){e.exports=function(){var e=[];return{subscribe:function(t){return e.push(t),function(){var r=e.indexOf(t);r>-1&&e.splice(r,1)}},publish:function(){for(var t=0;t{return function(t,r){for(var n=arguments.length,o=Array(n>2?n-2:0),i=2;it.apply(void 0,[e].concat(o)),r)}})},function(e,t,r){"use strict";const n=r(0),o=r(28),i="undefined"!=typeof navigator&&"ReactNative"===navigator.product,s=Object.prototype.hasOwnProperty,a={timeout:i?6e4:12e4};function u(e){const t=[];for(const t in e)s.call(e,t)&&r(t,e[t]);return t.length?t.join("&"):"";function r(e,n){Array.isArray(n)?n.forEach(t=>r(e,t)):t.push([e,n].map(encodeURIComponent).join("="))}}e.exports=(e=>{const t="string"==typeof e?n({url:e},a):n({},a,e),r=o(t.url,{},!0);return t.timeout=function e(t){if(!1===t||0===t)return!1;if(t.connect||t.socket)return t;const r=Number(t);if(isNaN(r))return e(a.timeout);return{connect:r,socket:r}}(t.timeout),t.query&&(r.query=n({},r.query,function(e){const t={};for(const r in e)void 0!==e[r]&&(t[r]=e[r]);return t}(t.query))),t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t.url=r.toString(u),t})},function(e,t,r){"use strict";const n=/^https?:\/\//i;e.exports=(e=>{if(!n.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)})},function(e,t,r){"use strict";e.exports=r(90)},function(e,t,r){"use strict";const n=r(14),o=r(16),i=r(15),s=r(91),a=r(92),u=r(100),c=r(101),f=r(102),l=r(0),p=r(42),d=r(114);e.exports=((e,t)=>{const r=e.options,h=l({},n.parse(r.url)),b=c(r.body)?"stream":typeof r.body;if("undefined"!==b&&"stream"!==b&&"string"!==b&&!Buffer.isBuffer(r.body))throw new Error(`Request body must be a string, buffer or stream, got ${b}`);const y={};r.bodySize?y["Content-Length"]=r.bodySize:r.body&&Buffer.isBuffer(r.body)&&(y["Content-Length"]=r.body.length);let g=!1;const m=(e,r)=>!g&&t(e,r);e.channels.abort.subscribe(()=>{g=!0});const v=l(h,{method:r.method,headers:l({},r.headers,y)}),w=e.applyMiddleware("interceptRequest",void 0,{adapter:"node",context:e});if(w){const e=setImmediate(m,null,w);return{abort:()=>clearImmediate(e)}}let _="https:"===h.protocol?i:o;0!==r.maxRedirects&&(_="https:"===h.protocol?a.https:a.http,v.maxRedirects=r.maxRedirects||5);const E=_.request(v,t=>{const n="HEAD"!==v.method?d(t):t,o=e.applyMiddleware("onHeaders",n,{headers:t.headers,adapter:"node",context:e});s(o,(e,o)=>{if(e)return m(e);const i=r.rawBody?o:o.toString(),s=((e,t,r,n)=>({body:n,url:t,method:r,headers:e.headers,statusCode:e.statusCode,statusMessage:e.statusMessage}))(n,t.responseUrl||r.url,v.method,i);return m(null,s)})});r.timeout&&u(E,r.timeout),E.once("error",m);var O=function(e){if(!e.body)return{};const t=c(e.body),r=e.bodySize||(t?null:Buffer.byteLength(e.body));if(!r)return t?{bodyStream:e.body}:{};const n=p({time:16,length:r});return{bodyStream:(t?e.body:f(e.body)).pipe(n),progress:n}}(r);const C=O.bodyStream,S=O.progress;return e.applyMiddleware("onRequest",{options:r,adapter:"node",request:E,context:e,progress:S}),C?C.pipe(E):E.end(r.body),{abort:()=>E.abort()}})},function(e,t){e.exports=function(e,t){var r=[];e.on("data",function(e){r.push(e)}),e.once("end",function(){t&&t(null,Buffer.concat(r)),t=null}),e.once("error",function(e){t&&t(e),t=null})}},function(e,t,r){var n=r(14),o=n.URL,i=r(16),s=r(15),a=r(93),u=r(9).Writable,c=r(94)("follow-redirects"),f={GET:!0,HEAD:!0,OPTIONS:!0,TRACE:!0},l=Object.create(null);function p(e,t){u.call(this),e.headers=e.headers||{},this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e.host&&(e.hostname||(e.hostname=e.host),delete e.host),t&&this.on("response",t);var r=this;if(this._onNativeResponse=function(e){r._processResponse(e)},!e.pathname&&e.path){var n=e.path.indexOf("?");n<0?e.pathname=e.path:(e.pathname=e.path.substring(0,n),e.search=e.path.substring(n))}this._performRequest()}function d(e){var t={maxRedirects:21,maxBodyLength:10485760},r={};return Object.keys(e).forEach(function(i){var s=i+":",u=r[s]=e[i],f=t[i]=Object.create(u);f.request=function(e,i,u){if("string"==typeof e){var f=e;try{e=b(new o(f))}catch(t){e=n.parse(f)}}else o&&e instanceof o?e=b(e):(u=i,i=e,e={protocol:s});return"function"==typeof i&&(u=i,i=null),(i=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,i)).nativeProtocols=r,a.equal(i.protocol,s,"protocol mismatch"),c("options",i),new p(i,u)},f.get=function(e,t,r){var n=f.request(e,t,r);return n.end(),n}}),t}function h(){}function b(e){var t={protocol:e.protocol,hostname:e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:e.pathname+e.search,href:e.href};return""!==e.port&&(t.port=Number(e.port)),t}["abort","aborted","error","socket","timeout"].forEach(function(e){l[e]=function(t){this._redirectable.emit(e,t)}}),p.prototype=Object.create(u.prototype),p.prototype.write=function(e,t,r){if(this._ending)throw new Error("write after end");if(!("string"==typeof e||"object"==typeof e&&"length"in e))throw new Error("data should be a string, Buffer or Uint8Array");"function"==typeof t&&(r=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,r)):(this.emit("error",new Error("Request body larger than maxBodyLength limit")),this.abort()):r&&r()},p.prototype.end=function(e,t,r){if("function"==typeof e?(r=e,e=t=null):"function"==typeof t&&(r=t,t=null),e){var n=this,o=this._currentRequest;this.write(e,t,function(){n._ended=!0,o.end(null,null,r)}),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,r)},p.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},p.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},["abort","flushHeaders","getHeader","setNoDelay","setSocketKeepAlive","setTimeout"].forEach(function(e){p.prototype[e]=function(t,r){return this._currentRequest[e](t,r)}}),["aborted","connection","socket"].forEach(function(e){Object.defineProperty(p.prototype,e,{get:function(){return this._currentRequest[e]}})}),p.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(t){if(this._options.agents){var r=e.substr(0,e.length-1);this._options.agent=this._options.agents[r]}var o=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var i in this._currentUrl=n.format(this._options),o._redirectable=this,l)i&&o.on(i,l[i]);if(this._isRedirect){var s=0,a=this,u=this._requestBodyBuffers;!function e(t){if(o===a._currentRequest)if(t)a.emit("error",t);else if(s=300&&e.statusCode<400){if(this._currentRequest.removeAllListeners(),this._currentRequest.on("error",h),this._currentRequest.abort(),++this._redirectCount>this._options.maxRedirects)return void this.emit("error",new Error("Max redirects exceeded."));var r,o=this._options.headers;if(307!==e.statusCode&&!(this._options.method in f))for(r in this._options.method="GET",this._requestBodyBuffers=[],o)/^content-/i.test(r)&&delete o[r];if(!this._isRedirect)for(r in o)/^host$/i.test(r)&&delete o[r];var i=n.resolve(this._currentUrl,t);c("redirecting to",i),Object.assign(this._options,n.parse(i)),this._isRedirect=!0,this._performRequest(),e.destroy()}else e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),this._requestBodyBuffers=[]},e.exports=d({http:i,https:s}),e.exports.wrap=d},function(e,t){e.exports=require("assert")},function(e,t,r){"undefined"==typeof process||"renderer"===process.type?e.exports=r(95):e.exports=r(96)},function(e,t,r){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=r(32)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())},function(e,t,r){var n=r(34),o=r(1);(t=e.exports=r(32)).init=function(e){e.inspectOpts={};for(var r=Object.keys(t.inspectOpts),n=0;n=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}function s(){return process.env.DEBUG}t.inspectOpts=Object.keys(process.env).filter(function(e){return/^debug_/i.test(e)}).reduce(function(e,t){var r=t.substring(6).toLowerCase().replace(/_([a-z])/g,function(e,t){return t.toUpperCase()}),n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e},{}),t.formatters.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map(function(e){return e.trim()}).join(" ")},t.formatters.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)},t.enable(s())},function(e,t,r){"use strict";const n=r(98),o=r(99),i=process.env;let s;function a(e){return function(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}(function(e){if(!1===s)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(e&&!e.isTTY&&!0!==s)return 0;const t=s?1:0;if("win32"===process.platform){const e=n.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in i)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in i)||"codeship"===i.CI_NAME?1:t;if("TEAMCITY_VERSION"in i)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0;if("truecolor"===i.COLORTERM)return 3;if("TERM_PROGRAM"in i){const e=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(i.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)?1:"COLORTERM"in i?1:(i.TERM,t)}(e))}o("no-color")||o("no-colors")||o("color=false")?s=!1:(o("color")||o("colors")||o("color=true")||o("color=always"))&&(s=!0),"FORCE_COLOR"in i&&(s=0===i.FORCE_COLOR.length||0!==parseInt(i.FORCE_COLOR,10)),e.exports={supportsColor:a,stdout:a(process.stdout),stderr:a(process.stderr)}},function(e,t){e.exports=require("os")},function(e,t,r){"use strict";e.exports=((e,t)=>{t=t||process.argv;const r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return-1!==n&&(-1===o||n{let t,r;function i(n){const i=!(t=o(e=n)?e:null)&&e[Symbol.iterator]&&"string"!=typeof e&&!Buffer.isBuffer(e);r=i?e[Symbol.iterator]():null}return Array.isArray(e)&&(e=e.slice()),i(e),n(function n(o,s){if(t)return void t.then(i).then(()=>n.call(this,o,s),s);if(r){const e=r.next();return void setImmediate(s,null,e.done?null:e.value)}if(0===e.length)return void setImmediate(s,null,null);const a=e.slice(0,o);e=e.slice(o),setImmediate(s,null,a)})}),e.exports.obj=(e=>{let t,r;function i(n){t=o(e=n)?e:null,r=!t&&e[Symbol.iterator]?e[Symbol.iterator]():null}return Array.isArray(e)&&(e=e.slice()),i(e),n.obj(function n(o,s){if(t)t.then(i).then(()=>n.call(this,o,s),s);else if(r){const e=r.next();setImmediate(s,null,e.done?null:e.value)}else this.push(e),setImmediate(s,null,null)})})},function(e,t,r){var n=r(35).Readable,o=r(4);e.exports=s,s.ctor=a,s.obj=function(e,t){("function"==typeof e||Array.isArray(e))&&(t=e,e={});return(e=c(e)).objectMode=!0,e.highWaterMark=16,s(e,t)};var i=a();function s(e,t){("object"!=typeof e||Array.isArray(e))&&(t=e,e={});var r,n=new i(e);return n._from=Array.isArray(t)?(r=(r=t).slice(),function(e,t){var n=null,o=r.length?r.shift():null;o instanceof Error&&(n=o,o=null),t(n,o)}):t||u,n}function a(e,t){function r(t){if(!(this instanceof r))return new r(t);this._reading=!1,this._callback=function(e,t){if(o.destroyed)return;if(e)return o.destroy(e);if(null===t)return o.push(null);o._reading=!1,o.push(t)&&o._read(i)},this.destroyed=!1,n.call(this,t||e);var o=this,i=this._readableState.highWaterMark}return"function"==typeof e&&(t=e,e={}),e=c(e),o(r,n),r.prototype._from=t||u,r.prototype._read=function(e){this._reading||this.destroyed||(this._reading=!0,this._from(e,this._callback))},r.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;process.nextTick(function(){e&&t.emit("error",e),t.emit("close")})}},r}function u(){}function c(e){return e=e||{}}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){e.exports=require("buffer")},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t,r){"use strict";var n=r(11).Buffer,o=r(1);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,o,i=n.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=i,o=a,t.copy(r,o),a+=s.data.length,s=s.next;return i},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t,r){e.exports=r(1).deprecate},function(e,t,r){"use strict";e.exports=i;var n=r(41),o=r(6);function i(e){if(!(this instanceof i))return new i(e);n.call(this,e)}o.inherits=r(4),o.inherits(i,n),i.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){"use strict";e.exports=(e=>e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch)},function(e,t,r){var n=r(35).Transform,o=r(1).inherits,i=r(112);function s(e){n.call(this,e),this._destroyed=!1}function a(e,t,r){r(null,e)}function u(e){return function(t,r,n){return"function"==typeof t&&(n=r,r=t,t={}),"function"!=typeof r&&(r=a),"function"!=typeof n&&(n=null),e(t,r,n)}}o(s,n),s.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var t=this;process.nextTick(function(){e&&t.emit("error",e),t.emit("close")})}},e.exports=u(function(e,t,r){var n=new s(e);return n._transform=t,r&&(n._flush=r),n}),e.exports.ctor=u(function(e,t,r){function n(t){if(!(this instanceof n))return new n(t);this.options=i(e,t),s.call(this,this.options)}return o(n,s),n.prototype._transform=t,r&&(n.prototype._flush=r),n}),e.exports.obj=u(function(e,t,r){var n=new s(i({objectMode:!0,highWaterMark:16},e));return n._transform=t,r&&(n._flush=r),n})},function(e,t){e.exports=function(){for(var e={},t=0;tt&&(s=t),i=r;s--;)o===t&&(o=0),n[o]=n[0===o?t-1:o-1],o++;e&&(n[o-1]+=e);var a=n[o-1],u=n.length{if(-1===["gzip","deflate"].indexOf(e.headers["content-encoding"]))return e;const t=o.createUnzip(),r=new n;return i(e,r),t.on("error",e=>{"Z_BUF_ERROR"!==e.code?r.emit("error",e):r.end()}),e.pipe(t).pipe(r),r})},function(e,t){e.exports=require("zlib")},function(e,t,r){"use strict";const n=["destroy","setTimeout","socket","headers","trailers","rawHeaders","statusCode","httpVersion","httpVersionMinor","httpVersionMajor","rawTrailers","statusMessage"];e.exports=((e,t)=>{const r=new Set(Object.keys(e).concat(n));for(const n of r)n in t||(t[n]="function"==typeof e[n]?e[n].bind(e):e[n])})},function(e,t,r){"use strict";var n=r(118),o=r(0);e.exports=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||n.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:function(t,r){return new e(function(e){return t.error.subscribe(function(t){return e.error(t)}),t.progress.subscribe(function(t){return e.next(o({type:"progress"},t))}),t.response.subscribe(function(t){e.next(o({type:"response"},t)),e.complete()}),t.request.publish(r),function(){return t.abort.publish()}})}}}},function(e,t,r){"use strict";"undefined"!=typeof window?e.exports=window:"undefined"!=typeof global?e.exports=global:"undefined"!=typeof self?e.exports=self:e.exports={}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(0),i=r(120),s=["boolean","string","number"];e.exports=function(){return{processOptions:function(e){var t,r=e.body;return r&&!("function"==typeof r.pipe)&&!((t=r).constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t))&&(-1!==s.indexOf(void 0===r?"undefined":n(r))||Array.isArray(r)||i(r))?o({},e,{body:JSON.stringify(e.body),headers:o({},e.headers,{"Content-Type":"application/json"})}):e}}}},function(e,t,r){"use strict"; 7 | /*! 8 | * is-plain-object 9 | * 10 | * Copyright (c) 2014-2017, Jon Schlinkert. 11 | * Released under the MIT License. 12 | */var n=r(121);function o(e){return!0===n(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,r;return!1!==o(e)&&("function"==typeof(t=e.constructor)&&(!1!==o(r=t.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},function(e,t,r){"use strict"; 13 | /*! 14 | * isobject 15 | * 16 | * Copyright (c) 2014-2017, Jon Schlinkert. 17 | * Released under the MIT License. 18 | */e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},function(e,t,r){"use strict";var n=r(0);function o(e){try{return JSON.parse(e)}catch(e){throw e.message="Failed to parsed response body as JSON: "+e.message,e}}e.exports=function(e){return{onResponse:function(t){var r=t.headers["content-type"]||"",i=e&&e.force||-1!==r.indexOf("application/json");return t.body&&r&&i?n({},t,{body:o(t.body)}):t},processOptions:function(e){return n({},e,{headers:n({Accept:"application/json"},e.headers)})}}}},function(e,t,r){"use strict";e.exports=r(124)},function(e,t,r){"use strict";var n=r(42);function o(e){return function(t){return{stage:e,percent:t.percentage,total:t.length,loaded:t.transferred,lengthComputable:!(0===t.length&&0===t.percentage)}}}e.exports=function(){return{onHeaders:function(e,t){var r=n({time:16}),i=o("download"),s=e.headers["content-length"],a=s&&Number(s);return!isNaN(a)&&a>0&&r.setLength(a),r.on("progress",function(e){return t.context.channels.progress.publish(i(e))}),e.pipe(r)},onRequest:function(e){if(e.progress){var t=o("upload");e.progress.on("progress",function(r){return e.context.channels.progress.publish(t(r))})}}}}},function(e,t,r){"use strict";var n=r(126),o=r(0);function i(e){var t=a(e);i.super.call(this,t.message),o(this,t)}function s(e){var t=a(e);s.super.call(this,t.message),o(this,t)}function a(e){var t=e.body,r={response:e,statusCode:e.statusCode,responseBody:u(t,e)};return t.error&&t.message?(r.message="".concat(t.error," - ").concat(t.message),r):t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){var t=e.statusMessage?" ".concat(e.statusMessage):"";return"".concat(e.method,"-request to ").concat(e.url," resulted in HTTP ").concat(e.statusCode).concat(t)}(e),r)}function u(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}n(i),n(s),t.ClientError=i,t.ServerError=s},function(e,t,r){"use strict";var n="undefined"!=typeof Reflect?Reflect.construct:void 0,o=Object.defineProperty,i=Error.captureStackTrace;function s(e){void 0!==e&&o(this,"message",{configurable:!0,value:e,writable:!0});var t=this.constructor.name;void 0!==t&&t!==this.name&&o(this,"name",{configurable:!0,value:t,writable:!0}),i(this,this.constructor)}void 0===i&&(i=function(e){var t=new Error;o(e,"stack",{configurable:!0,get:function(){var e=t.stack;return o(this,"stack",{configurable:!0,value:e,writable:!0}),e},set:function(t){o(e,"stack",{configurable:!0,value:t,writable:!0})}})}),s.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:s,writable:!0}});var a=function(){function e(e,t){return o(e,"name",{configurable:!0,value:t})}try{var t=function(){};if(e(t,"foo"),"foo"===t.name)return e}catch(e){}}();(e.exports=function(e,t){if(null==t||t===Error)t=s;else if("function"!=typeof t)throw new TypeError("super_ should be a function");var r;if("string"==typeof e)r=e,e=void 0!==n?function(){return n(t,arguments,this.constructor)}:function(){t.apply(this,arguments)},void 0!==a&&(a(e,r),r=void 0);else if("function"!=typeof e)throw new TypeError("constructor should be either a string or a function");e.super_=e.super=t;var o={constructor:{configurable:!0,value:e,writable:!0}};return void 0!==r&&(o.name={configurable:!0,value:r,writable:!0}),e.prototype=Object.create(t.prototype,o),e}).BaseError=s},function(e,t,r){"use strict";var n=r(128),o=r(131),i=r(137),s=r(138),a=[o({verbose:!0,namespace:"sanity:client"}),i({"User-Agent":"".concat(s.name," ").concat(s.version)}),n({maxRetries:3})];e.exports=a},function(e,t,r){"use strict";const n=r(0),o=r(129),i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.maxRetries||5,r=e.retryDelay||s,i=e.shouldRetry||o;return{onError:(e,o)=>{const s=o.options,a=s.maxRetries||t,u=s.shouldRetry||i,c=s.attemptNumber||0;if((e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe)(s.body))return e;if(!u(e,c,s)||c>=a)return e;const f=n({},o,{options:n({},s,{attemptNumber:c+1})});return setTimeout(()=>o.channels.request.publish(f),r(c)),null}}};function s(e){return 100*Math.pow(2,e)+100*Math.random()}i.shouldRetry=o,e.exports=i},function(e,t,r){"use strict";const n=r(130);e.exports=((e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&((!e.response||!e.response.statusCode)&&n(e)))},function(e,t,r){"use strict";var n=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ESOCKETTIMEDOUT","ECONNREFUSED","EPIPE"],o=["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"];e.exports=function(e){return!e||!e.code||(-1!==n.indexOf(e.code)||-1===o.indexOf(e.code))}},function(e,t,r){"use strict";const n=r(132),o=["Cookie","Authorization"],i=Object.prototype.hasOwnProperty;e.exports=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.verbose,r=e.namespace||"get-it",s=n(r),a=e.log||s,u=a===s&&!n.enabled(r);let c=0;return{processOptions:e=>(e.requestId=e.requestId||++c,e),onRequest:r=>{if(u||!r)return r;const n=r.options;if(a("[%s] HTTP %s %s",n.requestId,n.method,n.url),t&&n.body&&"string"==typeof n.body&&a("[%s] Request body: %s",n.requestId,n.body),t&&n.headers){const t=!1===e.redactSensitiveHeaders?n.headers:((e,t)=>{const r={};for(const n in e)i.call(e,n)&&(r[n]=t.indexOf(n)>-1?"":e[n]);return r})(n.headers,o);a("[%s] Request headers: %s",n.requestId,JSON.stringify(t,null,2))}return r},onResponse:(e,r)=>{if(u||!e)return e;const n=r.options.requestId;return a("[%s] Response code: %s %s",n,e.statusCode,e.statusMessage),t&&e.body&&a("[%s] Response body: %s",n,function(e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?function(e){try{const t="string"==typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch(t){return e}}(e.body):e.body}(e)),e},onError:(e,t)=>{const r=t.options.requestId;return e?(a("[%s] ERROR: %s",r,e.message),e):(a("[%s] Error encountered, but handled by an earlier middleware",r),e)}}}},function(e,t,r){"undefined"!=typeof process&&"renderer"===process.type?e.exports=r(133):e.exports=r(134)},function(e,t,r){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=r(43)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())},function(e,t,r){var n=r(34),o=r(1);(t=e.exports=r(43)).init=function(e){e.inspectOpts={};for(var r=Object.keys(t.inspectOpts),n=0;n1&&void 0!==arguments[1]?arguments[1]:{};return{processOptions:r=>{const o=r.headers||{};return r.headers=t.override?n({},o,e):n({},e,o),r}}}},function(e){e.exports={name:"@sanity/client",version:"0.140.0",description:"Client for retrieving data from Sanity",main:"lib/sanityClient.js",umd:"umd/sanityClient.min.js",unpkg:"umd/sanityClient.min.js",scripts:{analyze:"NODE_ENV=production BROWSERIFY_ENV=build DEBUG='' browserify --full-paths -t envify -g uglifyify lib/sanityClient.js --standalone=SanityClient | discify --open",browserify:"NODE_ENV=production BROWSERIFY_ENV=build DEBUG='' browserify -t envify -g uglifyify lib/sanityClient.js -o umd/sanityClient.js --standalone=SanityClient",build:"npm run browserify && npm run minify && npm run size",size:"node -r @babel/register src/scripts/print-bundle-size",clean:"rimraf lib coverage .nyc_output umd/*.js",coverage:"DEBUG=sanity NODE_ENV=test nyc --reporter=html --reporter=lcov --reporter=text npm test",minify:"terser -c -m -- umd/sanityClient.js > umd/sanityClient.min.js",prepublishOnly:"npm run build",test:"NODE_ENV=test tape -r @babel/register test/*.test.js"},browser:{"./src/http/nodeMiddleware.js":"./src/http/browserMiddleware.js","./lib/http/nodeMiddleware.js":"./lib/http/browserMiddleware.js"},dependencies:{"@sanity/eventsource":"0.140.0","@sanity/generate-help-url":"0.140.0","@sanity/observable":"0.140.0","deep-assign":"^2.0.0","get-it":"^4.0.1","make-error":"^1.3.0","object-assign":"^4.1.1"},devDependencies:{boxen:"^1.3.0",browserify:"^14.3.0",chalk:"^2.3.0",disc:"^1.3.2",envify:"^4.0.0","gzip-size":"^3.0.0","hard-rejection":"^1.0.0",nock:"^9.0.5",nyc:"^11.0.3","pretty-bytes":"^4.0.2",rimraf:"^2.6.2","sse-channel":"^2.0.6",tape:"^4.8.0",terser:"^3.10.11",uglifyify:"^5.0.1"},repository:{type:"git",url:"git+https://github.com/sanity-io/sanity.git"},keywords:["sanity","cms","headless","realtime","content","client","fetch","api","gradient"],author:"Sanity.io ",license:"MIT",bugs:{url:"https://github.com/sanity-io/sanity/issues"},homepage:"https://www.sanity.io/",nyc:{include:["src/**/*.js"],require:["@babel/register"],sourceMap:!1,instrument:!1},gitHead:"230394c89b3d2adf36a922fe9dc189bb955122ce"}},function(e,t,r){"use strict";e.exports=function(e){var t={};return e.token&&(t.Authorization="Bearer ".concat(e.token)),!e.useProjectHostname&&e.projectId&&(t["X-Sanity-Project-ID"]=e.projectId),{headers:t,timeout:"timeout"in e?e.timeout:3e4,json:!0,withCredentials:Boolean(e.token||e.withCredentials)}}},function(e,t,r){"use strict";var n=r(30),o=r(0),i=r(3),s=r(31),a={apiHost:"https://api.sanity.io",useProjectHostname:!0,gradientMode:!1,isPromiseAPI:!0},u=["localhost","127.0.0.1","0.0.0.0"],c=function(e){return s(function(){return console.warn(e.join(" "))})},f=c(["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(n("js-client-cdn-configuration"),"."),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),l=c(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(n("js-client-browser-token")," for more information and how to hide this warning.")]),p=c(["You have set `useCdn` to `true` while also specifying a token. This is usually not what you","want. The CDN cannot be used with an authorization token, since private data cannot be cached.","See ".concat(n("js-client-usecdn-token")," for more information.")]);t.defaultConfig=a,t.initConfig=function(e,t){var r=o({},a,t,e),s=r.gradientMode,c=!s&&r.useProjectHostname;if("undefined"==typeof Promise){var d=n("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(d))}if(s&&!r.namespace)throw new Error("Configuration must contain `namespace` when running in gradient mode");if(c&&!r.projectId)throw new Error("Configuration must contain `projectId`");var h="undefined"!=typeof window&&window.location&&window.location.hostname,b=h&&function(e){return-1!==u.indexOf(e)}(window.location.hostname);if(h&&b&&r.token&&!0!==r.ignoreBrowserTokenWarning?l():(!h||b)&&r.useCdn&&r.token?p():void 0===r.useCdn&&f(),c&&i.projectId(r.projectId),!s&&r.dataset&&i.dataset(r.dataset,r.gradientMode),r.isDefaultApi=r.apiHost===a.apiHost,r.useCdn=Boolean(r.useCdn)&&!r.token&&!r.withCredentials,r.gradientMode)r.url=r.apiHost,r.cdnUrl=r.apiHost;else{var y=r.apiHost.split("://",2),g=y[0],m=y[1],v=r.isDefaultApi?"apicdn.sanity.io":m;r.useProjectHostname?(r.url="".concat(g,"://").concat(r.projectId,".").concat(m,"/v1"),r.cdnUrl="".concat(g,"://").concat(r.projectId,".").concat(v,"/v1")):(r.url="".concat(r.apiHost,"/v1"),r.cdnUrl=r.url)}return r}}])); --------------------------------------------------------------------------------