forked from parse-community/ParseReact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse-react.min.js
25 lines (25 loc) · 25.7 KB
/
parse-react.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
* Parse + React
* v0.1.3
*
* Copyright (c) 2015, Parse, LLC. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
* form for use in connection with the web services and APIs provided by Parse.
*
* As with any software that integrates with the Parse platform, your use of
* this software is subject to the Parse Terms of Service
* [https://www.parse.com/about/terms]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.ParseReact=e()}}(function(){return function e(t,r,n){function a(i,o){if(!r[i]){if(!t[i]){var u="function"==typeof require&&require;if(!o&&u)return u(i,!0);if(s)return s(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[i]={exports:{}};t[i][0].call(l.exports,function(e){var r=t[i][1][e];return a(r?r:e)},l,l.exports,e,t,r,n)}return r[i].exports}for(var s="function"==typeof require&&require,i=0;i<n.length;i++)a(n[i]);return a}({1:[function(e,t){"use strict";var r=e("./LocalSubscriptions"),n=e("./ParsePatches");n.applyPatches(),t.exports={currentUser:r.currentUser,Mixin:e("./Mixin"),Mutation:e("./Mutation")}},{"./LocalSubscriptions":4,"./Mixin":5,"./Mutation":6,"./ParsePatches":9}],2:[function(e,t){"use strict";var r=e("./Id"),n=function(e,t){if(!(e instanceof r))throw new TypeError("Cannot create a Delta with an invalid target Id");if(this.id=e,this.map={},"DESTROY"===t)this.map="DESTROY";else for(var n in t)"objectId"!==n&&(this.map[n]=t[n])};n.prototype={merge:function(e){if(!(e instanceof n))throw new TypeError("Only Deltas can be merged");if(this.id.toString()!==e.id.toString())throw new Error("Only Deltas for the same Object can be merged");if("DESTROY"===e.map&&(this.map="DESTROY"),"DESTROY"!==this.map){for(var t in e.map)this.map[t]=e.map[t];return this}}},t.exports=n},{"./Id":3}],3:[function(e,t){"use strict";var r=function(e,t){this.className=e,this.objectId=t};r.fromString=function(e){var t=e.split(":");if(2!==t.length)throw new TypeError("Cannot create Id object from this string");return new r(t[0],t[1])},r.prototype={toString:function(){return this.className+":"+this.objectId}},t.exports=r},{}],4:[function(e,t){"use strict";var r=e("./flatten"),n=e("./Id"),a=e("./ObjectStore"),s=e("./StubParse"),i=[],o={subscribe:function(e,t){var i=this;if(e._registerLocalQuery(t,"currentUser"),s.User.current()){var o=new n("_User",s.User.current().id);return a.getLatest(o)||a.storeObject(r(s.User.current())),a.getLatest(o)}return s.Storage.async&&s.User._currentAsync().then(function(e){null!==e&&i.triggerUpdate()}),null},addSubscriber:function(e,t){i.push({name:t,component:e})},removeSubscriber:function(e,t){for(var r=0;r<i.length;r++)if(i[r].name===t&&i[r].component===e)return void i.splice(r,1)},update:function(e){var t=s.User.current();for(var r in e)"id"!==r&&"objectId"!==r&&"className"!==r&&"sessionToken"!==r&&"createdAt"!==r&&"updatedAt"!==r&&t.set(r,e[r]);s.User._saveCurrentUser(t),this.triggerUpdate()},triggerUpdate:function(){if(s.Storage.async)return s.User._currentAsync().then(function(){for(var e=0;e<i.length;e++)i[e].component.forceUpdate()});for(var e=0;e<i.length;e++)i[e].component.forceUpdate()}},u={currentUser:o};t.exports=u},{"./Id":3,"./ObjectStore":8,"./StubParse":11,"./flatten":16}],5:[function(e,t){"use strict";var r=e("./LocalSubscriptions"),n=e("./StubParse"),a=e("./SubscriptionManager"),s=e("./QueryTools").queryHash,i=e("./warning"),o={componentWillMount:function(){if(this._lastQueryHash={},this._outstandingQueries={},this._localQueries={},this._queryErrors={},this.data=this.data||{},!this.observe)throw new Error("Components using ParseReact.Mixin must declare an observe() method.");this._subscribeObservables(this.props,this.state)},componentWillUnmount:function(){this._revokeQueries()},componentWillUpdate:function(e,t){this._subscribeObservables(e,t)},pendingQueries:function(){var e=[];for(var t in this._outstandingQueries)this._outstandingQueries[t]&&e.push(t);return e},queryErrors:function(){if(Object.keys(this._queryErrors).length<1)return null;var e={};for(var t in this._queryErrors)e[t]=this._queryErrors[t];return e},refreshQueries:function(e){var t,r={};if("undefined"==typeof e)for(t in this._lastQueryHash)r[t]=this._lastQueryHash[t];else if("string"==typeof e)r[e]=this._lastQueryHash[e];else{if(!Array.isArray(e))throw new TypeError("refreshQueries must receive a query name or an array of query names");for(var n=0;n<e.length;n++)this._lastQueryHash[e[n]]?r[e[n]]=this._lastQueryHash[e[n]]:i("Cannot refresh unknown query name: "+e[n])}for(t in r){var s=r[t],o=a.getSubscription(s);o.pending||o.issueQuery()}},_subscribeObservables:function(e,t){var r=this.observe(e,t);if("object"!=typeof r)return void i("observe() must return an object map");for(var n in r)this.data[n]=r[n].subscribe(this,n)},_registerQuery:function(e,t,r){if(!(t instanceof n.Query))return void i("Query function "+e+" did not return a valid Parse Query object. Make sure you are returning the Query, and not fetching it yourself.");var o=s(t);(o!==this._lastQueryHash[e]||r)&&(this._lastQueryHash[e]&&o!==this._lastQueryHash[e]&&a.unsubscribeQuery(this._lastQueryHash[e],this._receiveQueryResults),this._queryErrors[e]&&delete this._queryErrors[e],this._lastQueryHash[e]=o,this._outstandingQueries[e]=!0,a.subscribeQuery(this._receiveQueryResults,e,t,o))},_registerLocalQuery:function(e,t){this._localQueries[e]!==t&&(r[this._localQueries[e]]&&r[this._localQueries[e]].removeSubscriber(this,e),r[t].addSubscriber(this,e)),this._localQueries[e]=t},_receiveQueryResults:function(e,t){Array.isArray(t)?this.data[e]=t:t.error&&(this._queryErrors[e]=t.error),this._outstandingQueries[e]=!1,this.pendingQueries().length||this.forceUpdate()},_revokeQueries:function(){var e;for(e in this._lastQueryHash)a.unsubscribeQuery(this._lastQueryHash[e],this._receiveQueryResults);for(e in this._localQueries)r[this._localQueries[e]].removeSubscriber(this,e)}};t.exports=o},{"./LocalSubscriptions":4,"./QueryTools":10,"./StubParse":11,"./SubscriptionManager":13,"./warning":17}],6:[function(e,t){"use strict";function r(e){if(e instanceof s)return e;if(e.className&&e.objectId)return new s(e.className,e.objectId);throw new TypeError("Argument must be a plain Parse Object with a className and objectId")}function n(e){if(!e||"string"!=typeof e||"objectId"===e||"createdAt"===e||"updatedAt"===e)throw new TypeError("Invalid column name for mutation: "+e)}function a(e){e.hasOwnProperty("objectId")&&(u("Ignoring reserved field: objectId"),delete e.objectId),e.hasOwnProperty("className")&&(u("Ignoring reserved field: className"),delete e.className),e.hasOwnProperty("createdAt")&&(u("Ignoring reserved field: createdAt"),delete e.createdAt),e.hasOwnProperty("updatedAt")&&(u("Ignoring reserved field: updatedAt"),delete e.updatedAt)}var s=e("./Id"),i=e("./Delta"),o=e("./UpdateChannel"),u=e("./warning"),c={dispatch:function(){}},l=function(e,t,r){this.action=e,this.target=t,this.data=r};l.prototype={dispatch:function(e){return o.issueMutation(this,e||{})},applyTo:function(e){var t=this;switch(this.action){case"SET":for(var r in this.data)e[r]=this.data[r];break;case"UNSET":delete e[this.data];break;case"INCREMENT":isNaN(e[this.data.column])?e[this.data.column]=this.data.delta:e[this.data.column]+=this.data.delta;break;case"ADD":e[this.data.column]=Array.isArray(e[this.data.column])?e[this.data.column].concat(this.data.value):this.data.value.concat([]);break;case"ADDUNIQUE":Array.isArray(e[this.data.column])?this.data.value.map(function(r){e[t.data.column].indexOf(r)<0&&e[t.data.column].push(r)}):e[this.data.column]=this.data.value.concat([]);break;case"REMOVE":if(!Array.isArray(e[this.data.column])||e[this.data.column].length<1)break;this.data.value.map(function(r){var n=e[t.data.column].indexOf(r);n>-1&&e[t.data.column].splice(n,1)})}},generateDelta:function(e){if("DESTROY"===this.action)return new i(this.target,"DESTROY");var t={};"UNSET"===this.action&&(t[this.data]={unset:!0});var r,n=this.target;if("CREATE"===this.action||"SET"===this.action){for(r in this.data)t[r]={set:this.data[r]};"CREATE"===this.action&&(n=new s(this.target,e.objectId))}for(r in e)"objectId"!==r&&(t[r]={set:e[r]}),"createdAt"===r&&(t.updatedAt={set:new Date(e.createdAt)});return new i(n,t)}},t.exports={Create:function(e,t){return t=t||{},a(t),new l("CREATE",e,t)},Destroy:function(e){return new l("DESTROY",r(e),null)},Set:function(e,t){return t&&Object.keys(t).length?(a(t),new l("SET",r(e),t)):(u("Performing a Set mutation with no changes: dispatching thiswill do nothing."),c)},Unset:function(e,t){return n(t),new l("UNSET",r(e),t)},Increment:function(e,t,a){if(n(t),"undefined"!=typeof a&&isNaN(a))throw new TypeError("Cannot increment by a non-numeric amount");var s={column:t,delta:"undefined"==typeof a?1:a};return new l("INCREMENT",r(e),s)},Add:function(e,t,a){n(t);var s={column:t,value:Array.isArray(a)?a:[a]};return new l("ADD",r(e),s)},AddUnique:function(e,t,a){n(t);var s={column:t,value:Array.isArray(a)?a:[a]};return new l("ADDUNIQUE",r(e),s)},Remove:function(e,t,a){n(t);var s={column:t,value:Array.isArray(a)?a:[a]};return new l("REMOVE",r(e),s)},AddRelation:function(e,t,a){n(t);var s=Array.isArray(a)?a:[a],i={column:t,targets:s.map(r)};return new l("ADDRELATION",r(e),i)},RemoveRelation:function(e,t,a){n(t);var s=Array.isArray(a)?a:[a],i={column:t,targets:s.map(r)};return new l("REMOVERELATION",r(e),i)}}},{"./Delta":2,"./Id":3,"./UpdateChannel":14,"./warning":17}],7:[function(e,t){"use strict";function r(e,t){if(t||(t=[]),t.indexOf(e)>-1)throw new Error("Tried to encode circular reference");if(Array.isArray(e))return t=t.concat([e]),e.map(function(e){return r(e,t)});if("[object Date]"===o.call(e))return{__type:"Date",iso:e.toJSON()};if(e instanceof s||e instanceof i.Object){var n=e instanceof s?e.objectId:e.id;if("undefined"==typeof n)throw new Error("Tried to save a pointer to an unsaved Parse Object");return{__type:"Pointer",className:e.className,objectId:n}}if(e instanceof i.GeoPoint)return e.toJSON();if(e instanceof i.File){if(!e.url())throw new Error("Tried to save a reference to an unsaved file");return{__type:"File",name:e.name(),url:e.url()}}if("object"==typeof e){if(e.objectId&&e.className)return{__type:"Pointer",className:e.className,objectId:e.objectId};t=t.concat(e);var a={};for(var u in e)a[u]=r(e[u],t);return a}return e}function n(e){return i._request(e).then(function(e){return e.createdAt&&(e.createdAt=new Date(e.createdAt)),e.updatedAt&&(e.updatedAt=new Date(e.updatedAt)),i.Promise.as(e)})}function a(e,t,a){var s;switch(e){case"CREATE":return n({method:"POST",route:"classes",className:t,data:r(a)});case"DESTROY":return n({method:"DELETE",route:"classes",className:t.className,objectId:t.objectId});case"SET":return n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:r(a)});case"UNSET":return s={},s[a]={__op:"Delete"},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s});case"INCREMENT":return s={},s[a.column]={__op:"Increment",amount:a.delta},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s});case"ADD":return s={},s[a.column]={__op:"Add",objects:r(a.value)},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s});case"ADDUNIQUE":return s={},s[a.column]={__op:"AddUnique",objects:r(a.value)},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s});case"REMOVE":return s={},s[a.column]={__op:"Remove",objects:r(a.value)},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s});case"ADDRELATION":return s={},s[a.column]={__op:"AddRelation",objects:r(a.targets)},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s});case"REMOVERELATION":return s={},s[a.column]={__op:"RemoveRelation",objects:r(a.targets)},n({method:"PUT",route:"classes",className:t.className,objectId:t.objectId,data:s})}throw new TypeError("Invalid Mutation action: "+e)}var s=e("./Id"),i=e("./StubParse"),o=Object.prototype.toString,u={execute:a};t.exports=u},{"./Id":3,"./StubParse":11}],8:[function(e,t){"use strict";function r(e){if(!(e.id instanceof p))throw new Error("Cannot store an object without an Id");return v[e.id]={data:e,queries:{}},e.id}function n(e){if(!(e instanceof p))throw new TypeError("Argument must be a valid object Id");if(!v[e])return[];var t=Object.keys(v[e].queries);return delete v[e],t}function a(e,t){if(v[e])v[e].queries[t]=!0;else if(g[e])g[e][t]=!0;else{var r={};r[t]=!0,g[e]=r}}function s(e,t){v[e]?delete v[e].queries[t]:g[e]&&(delete g[e][t],Object.keys(g[e]).length<1&&delete g[e])}function i(e){return v[e]?Object.keys(v[e].queries):g[e]?Object.keys(g[e]):[]}function o(e,t,r){var n=S++,a={payloadId:n,date:r||new Date,mutation:t};return m[e]?m[e].push(a):m[e]=[a],n}function u(e){m[e]=[]}function c(e,t,r){var n,a=m[e];for(n=0;n<a.length;n++)if(a[n].payloadId===t){delete a[n].mutation,a[n].delta=r;break}if(n>=a.length)throw new Error("Optimistic Mutation completed, but was not found in the pending stack.");var s=Object.keys(r.map);if(n+1<a.length&&a[n+1].delta&&(r.merge(a[n+1].delta),a.splice(n+1,1)),n>0&&a[n-1].delta&&(a[n-1].delta.merge(r),a.splice(n,1)),a[0].delta){var i=l(a.shift().delta);return i.id=e,i}return{id:e,latest:h(r.id),fields:s}}function l(e){var t=e.id;if("DESTROY"===e.map&&v[t])return delete v[t],{id:t,latest:null};var r,n={},a=v[t]&&v[t].data,s=[];if(a)for(r in a)n[r]=a[r];else n.id=t,n.objectId=t.objectId,n.className=t.className,s.push("objectId");for(r in e.map){s.push(r);var i=e.map[r];i.hasOwnProperty("unset")?delete n[r]:i.hasOwnProperty("set")&&(n[r]=i.set)}return a?v[t].data=n:v[t]={data:n,queries:{}},{id:t,latest:n,fields:s}}function f(e,t){var n=y(t);Array.isArray(e)||(e=[e]);var s,i;if(t._order)for(i={},s=0;s<t._order.length;s++){var o=t._order[s];"-"===o[0]&&(o=o.substring(1)),i[o]=!0}var u=[];for(s=0;s<e.length;s++){var c=b(e[s]),l=r(c),f=l;if(i){var d={};for(var h in i)d[h]=c[h];f={id:l,ordering:d}}u.push(f),a(c.id,n)}return u}function d(e){Array.isArray(e)||(e=[e]);for(var t=[],r=0;r<e.length;r++){var n=h(e[r]),a={};for(var s in n)a[s]=n[s];Object.freeze(a),t.push(a)}return t}function h(e){if(m[e]&&m[e].length>0){var t,r,n={};if("CREATE"===m[e][0].mutation.action){t=m[e][0].mutation;var a=t.data;for(r in a)n[r]=a[r];return n.id=e instanceof p?e:new p(t.target,e),n.className=t.target,n.createdAt=n.updatedAt=m[e][0].date,n}if(v[e]){var s=v[e].data;for(r in s)n[r]=s[r]}for(var i=0;i<m[e].length;i++){if(t=m[e][i].mutation,"DESTROY"===t.action)return null;t.applyTo(n),n.updatedAt=m[e][i].date}return n}return v[e]?v[e].data:null}var b=e("./flatten"),p=e("./Id"),y=e("./QueryTools").queryHash,v={},g={},m={},S=0,j={storeObject:r,removeObject:n,addSubscriber:a,removeSubscriber:s,fetchSubscribers:i,stackMutation:o,destroyMutationStack:u,resolveMutation:c,commitDelta:l,storeQueryResults:f,getDataForIds:d,getLatest:h};t.exports=j},{"./Id":3,"./QueryTools":10,"./flatten":16}],9:[function(e,t){"use strict";var r=e("./flatten"),n=e("./LocalSubscriptions"),a=e("./StubParse"),s=a.User.prototype.signUp,i=a.User.prototype.logIn,o=a.User.prototype._linkWith,u=a.User.logOut,c={toPlainObject:function(){return r(this)},subscribe:function(e,t){return e._registerQuery(t,this),e.data[t]||[]},signUp:function(e,t){return s.call(this,e,t).then(function(){n.currentUser.triggerUpdate()})},logIn:function(e){return i.call(this,e).then(function(){n.currentUser.triggerUpdate()})},_linkWith:function(e,t){return o.call(this,e,t).then(function(){n.currentUser.triggerUpdate()})},logOut:function(){var e=u();return n.currentUser.triggerUpdate(),e}},l={applyPatches:function(){a.Object.prototype.toPlainObject||(a.Object.prototype.toPlainObject=c.toPlainObject),a.Query.prototype.subscribe||(a.Query.prototype.subscribe=c.subscribe),a.User.prototype.signUp=c.signUp,a.User.prototype.logIn=c.logIn,a.User.prototype._linkWith=c._linkWith,a.User.logOut=c.logOut}};t.exports=l},{"./LocalSubscriptions":4,"./StubParse":11,"./flatten":16}],10:[function(e,t){"use strict";function r(e){if(!e.hasOwnProperty("$or"))return e;for(var t=[],r=0;r<e.$or.length;r++)t=t.concat(e.$or[r]);return t}function n(e){if("object"!=typeof e)return"string"==typeof e?'"'+e.replace(/\|/g,"%|")+'"':e;if(Array.isArray(e)){var t=e.map(n);return t.sort(),"["+t.join(",")+"]"}var r=[],a=Object.keys(e);a.sort();for(var s=0;s<a.length;s++)r.push(n(a[s])+":"+n(e[a[s]]));return"{"+r.join(",")+"}"}function a(e){if(!(e instanceof l.Query))throw new TypeError("Only a Parse Query can be hashed");var t,a,s=r(e._where||{}),i=[];if(Array.isArray(s)){var o={};for(a=0;a<s.length;a++){var u={},c=Object.keys(s[a]);c.sort();for(var f=0;f<c.length;f++)u[c[f]]=s[a][c[f]],o[c[f]]=!0;i.push(u)}t=Object.keys(o),t.sort()}else for(t=Object.keys(s),t.sort(),a=0;a<t.length;a++)i.push(s[t[a]]);var d=[t.join(","),n(i),n(e._include||[]),n(e._order||[]),e._limit,e._skip];return e.className+":"+d.join("|")}function s(e){var t=e.indexOf(":"),r=e.substring(0,t),n=e.indexOf("|"),a=e.substring(t+1,n),s=a.split(",");return{className:r,keys:s.length?s:[""]}}function i(e,t){if(t instanceof l.Query){var r=e.id instanceof c?e.id.className:e.className;return r!==t.className?!1:i(e,t._where)}for(var n in t)if(!o(e,n,t[n]))return!1;return!0}function o(e,t,r){var n;if("$or"===t){for(n=0;n<r.length;n++)if(i(e,r[n]))return!0;return!1}if("$relatedTo"===t)return!1;if("object"!=typeof r)return Array.isArray(e[t])?e[t].indexOf(r)>-1:e[t]===r;var a;if(r.__type){if("Pointer"===r.__type)return r.className===e[t].className&&r.objectId===e[t].objectId;if(a=l._decode(t,r),Array.isArray(e[t])){for(n=0;n<e[t].length;n++)if(u(e[t][n],a))return!0;return!1}return u(e[t],a)}for(var s in r)switch(a=r[s],a.__type&&(a=l._decode(t,a)),s){case"$lt":if(e[t]>=a)return!1;break;case"$lte":if(e[t]>a)return!1;break;case"$gt":if(e[t]<=a)return!1;break;case"$gte":if(e[t]<a)return!1;break;case"$ne":if(u(e[t],a))return!1;break;case"$in":if(a.indexOf(e[t])<0)return!1;break;case"$nin":if(a.indexOf(e[t])>-1)return!1;break;case"$all":for(n=0;n<a.length;n++)if(e[t].indexOf(a[n])<0)return!1;break;case"$exists":if("undefined"==typeof e[t])return!1;break;case"$regex":if("object"==typeof a)return a.test(e[t]);for(var o="",c=-2,f=a.indexOf("\\Q");f>-1;)o+=a.substring(c+2,f),c=a.indexOf("\\E",f),c>-1&&(o+=a.substring(f+2,c).replace(/\\\\\\\\E/g,"\\E").replace(/\W/g,"\\$&")),f=a.indexOf("\\Q",c);o+=a.substring(Math.max(f,c+2));var d=new RegExp(o,r.$options||"");if(!d.test(e[t]))return!1;break;case"$options":break;case"$select":return!1;case"$dontSelect":return!1;default:return!1}return!0}var u=e("./equalObjects"),c=e("./Id"),l=e("./StubParse");t.exports={queryHash:a,keysFromHash:s,matchesQuery:i}},{"./Id":3,"./StubParse":11,"./equalObjects":15}],11:[function(e,t){"use strict";if("undefined"==typeof Parse){if("function"!=typeof require)throw new Error("Parse + React: Parse is not defined.");t.exports=require("parse").Parse}else t.exports=Parse},{}],12:[function(e,t){"use strict";function r(e){return e.id}function n(e,t,r){for(var n=0;n<e.length;n++){var a=e[n],s=1;if("-"===a[0]&&(a=a.substring(1),s=-1),t[a]<r[a])return-1*s;if(t[a]>r[a])return s}return 0}var a=e("./Id"),s=e("./ObjectStore"),i=function(e){this.originalQuery=e,this.pending=!1,this.subscribers=[],this.resultSet=[]};i.prototype={addSubscriber:function(e,t){for(var r=0;r<this.subscribers.length;r++)if(this.subscribers[r].callback===e)return;this.subscribers.push({callback:e,name:t}),this.pending||this.issueQuery()},removeSubscriber:function(e){for(var t=0;t<this.subscribers.length;t++)if(this.subscribers[t].callback===e)return this.subscribers.splice(t,1),this.subscribers.length;return this.subscribers.length},issueQuery:function(){var e=this;this.pending=!0,this.originalQuery.find().then(function(t){e.pending=!1,e.resultSet=s.storeQueryResults(t,e.originalQuery),e.pushData()},function(t){e.pending=!1,e.pushData({error:t})})},addResult:function(e,t){if(this.originalQuery._order){if(this.originalQuery._skip)return;for(var r=0,a=this.originalQuery._order;r<this.resultSet.length;){var s=n(a,e,this.resultSet[r].ordering);if(!(s>0))break;r++}for(var i={},o=0;o<a.length;o++){var u=a[o];"-"===u[0]&&(u=u.substring(1)),i[u]=e[u]}this.resultSet.splice(r,0,{id:e.id,ordering:i})}else this.resultSet.push(e.id);t||this.pushData()},removeResult:function(e,t){for(var r=e.toString(),n=0;n<this.resultSet.length;n++){var s=this.resultSet[n];if(s instanceof a||(s=s.id),s.toString()===r)return this.resultSet.splice(n,1),void(t||this.pushData())}},pushData:function(e){var t=e,n=this.resultSet;if(this.originalQuery.limit>-1&&(n=n.slice(0,this.originalQuery.limit)),!n[0]||n[0]instanceof a||(n=n.map(r)),"undefined"==typeof e){var i=this.resultSet;!i[0]||i[0]instanceof a||(i=i.map(r)),t=s.getDataForIds(i)}for(var o=0;o<this.subscribers.length;o++)this.subscribers[o].callback(this.subscribers[o].name,t)}},t.exports=i},{"./Id":3,"./ObjectStore":8}],13:[function(e,t){"use strict";function r(e,t,r,n){n||(n=c(r));var a=f[n];a||(a=new l(r),f[n]=a,s(r,n)),a.addSubscriber(e,t)}function n(e,t){var r=f[e];if(r&&r.removeSubscriber(t)<1){delete f[e];var n=u(e),a=d[n.className];if(!a)return;for(var s=0;s<n.keys.length;s++)delete a[n.keys[s]][e]}}function a(e){return f[e]||null}function s(e,t){var r=u(t).keys;r.length<1&&(r=[""]);var n=d[e.className];n||(n=d[e.className]={});for(var a=0;a<r.length;a++)n[r[a]]||(n[r[a]]={}),n[r[a]][t]=!0}function i(e,t){var r=d[e];if(!r)return[];var n={};t=t.concat("");for(var a=0;a<t.length;a++)if(r[t[a]])for(var s in r[t[a]])n[s]=!0;return Object.keys(n)}var o=e("./QueryTools"),u=o.keysFromHash,c=o.queryHash,l=e("./Subscription"),f={},d={},h={subscribeQuery:r,unsubscribeQuery:n,getSubscription:a,queriesForFields:i};t.exports=h},{"./QueryTools":10,"./Subscription":12}],14:[function(e,t){"use strict";function r(e,t){var r,i;if(!t.waitForServer){var l,h,b=[];"CREATE"===e.action?(i=new s(e.target,"local-"+d++),r=u.stackMutation(i,e),h=u.getLatest(i),l={id:i,latest:h,fields:Object.keys(h)}):(r=u.stackMutation(e.target,e),b=u.fetchSubscribers(e.target),"DESTROY"===e.action?l={id:e.target,latest:null,fields:[]}:(h=u.getLatest(e.target),l={id:e.target,latest:h,fields:Object.keys(h)})),n(b,l)}var p=new c.Promise;return o.execute(e.action,e.target,e.data).then(function(a){var s,o,c=e.generateDelta(a);if(t.waitForServer)o=u.fetchSubscribers(e.target),s=u.commitDelta(c),p.resolve(n(o,s));else{var l="CREATE"===e.action?i:e.target;o=u.fetchSubscribers(l),s=u.resolveMutation(l,r,c),p.resolve(n(o,s))}},function(s){if(!t.waitForServer){var o;if("CREATE"===e.action){o=u.fetchSubscribers(i);for(var c=0;c<o.length;c++){var l=f.getSubscription(o[c]);l.removeResult(i)}u.destroyMutationStack(i)}else{var d=new a(e.target,{});o=u.fetchSubscribers(e.target);var h=u.resolveMutation(e.target,r,d);n(o,h)}}p.reject(s)}),p}function n(e,t){var r,n;if(null===t.latest){for(r=0;r<e.length;r++){if(n=f.getSubscription(e[r]),!n)throw new Error("Object is attached to a nonexistant subscription");n.removeResult(t.id)}return null}var a={};for(r=0;r<e.length;r++)a[e[r]]=!0,n=f.getSubscription(e[r]),l.matchesQuery(t.latest,n.originalQuery)?t.id.toString()!==t.latest.id.toString()?(n.removeResult(t.id,!0),u.removeSubscriber(t.id,e[r]),n.addResult(t.latest),u.addSubscriber(t.latest.id,e[r])):n.pushData():(n.removeResult(t.id),u.removeSubscriber(t.id,e[r]));var s=f.queriesForFields(t.latest.id.className,t.fields);for(r=0;r<s.length;r++)a[s[r]]||(n=f.getSubscription(s[r]),l.matchesQuery(t.latest,n.originalQuery)&&(n.addResult(t.latest),u.addSubscriber(t.latest.id,s[r])));if("_User"===t.latest.id.className){var o=c.User.current();o&&t.latest.id.objectId===o.id&&i.currentUser.update(t.latest)}return t.latest}var a=e("./Delta"),s=e("./Id"),i=e("./LocalSubscriptions"),o=e("./MutationExecutor"),u=e("./ObjectStore"),c=e("./StubParse"),l=e("./QueryTools"),f=e("./SubscriptionManager"),d=0;t.exports={issueMutation:r}},{"./Delta":2,"./Id":3,"./LocalSubscriptions":4,"./MutationExecutor":7,"./ObjectStore":8,"./QueryTools":10,"./StubParse":11,"./SubscriptionManager":13}],15:[function(e,t){"use strict";function r(e,t){if(typeof e!=typeof t)return!1;if("object"!=typeof e)return e===t;if(e===t)return!0;if("[object Date]"===n.call(e))return"[object Date]"===n.call(t)?+e===+t:!1;if(Array.isArray(e)){if(Array.isArray(t)){if(e.length!==t.length)return!1;for(var a=0;a<e.length;a++)if(!r(e[a],t[a]))return!1;return!0}return!1}if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var s in e)if(!r(e[s],t[s]))return!1;return!0}var n=Object.prototype.toString;t.exports=r},{}],16:[function(e,t){"use strict";function r(e,t){var i=function(e){return r(e,t)};if(Array.isArray(e))return e.map(i);if(!(e instanceof a.Object))return s("Attempted to flatten something that is not a Parse Object"),e;Array.isArray(t)||(t=[]),t.push(e);var o={id:new n(e.className,e.id),className:e.className,objectId:e.id};e.createdAt&&(o.createdAt=e.createdAt),e.updatedAt&&(o.updatedAt=e.updatedAt);for(var u in e.attributes){var c=e.attributes[u];if(c instanceof a.Object){if(t.indexOf(c)>-1)throw new Error("Cannot flatten circular reference");o[u]=r(c,t)}else o[u]=Array.isArray(c)?c.map(i):c}return o}var n=e("./Id"),a=e("./StubParse"),s=e("./warning");t.exports=r},{"./Id":3,"./StubParse":11,"./warning":17}],17:[function(e,t){"use strict";t.exports=function(){}},{}]},{},[1])(1)});