text: !function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,n){!function(e,r){"function"==typeof define&&define.amd?define([],r):"object"==typeof n?t.exports=r():e.returnExports=r()}(this,function(){function e(i,o){if("function"!=typeof o)throw new Error("Bad callback given: "+o);if(!i)throw new Error("No options given");var s=i.onResponse;if(i="string"==typeof i?{uri:i}:JSON.parse(JSON.stringify(i)),i.onResponse=s,i.verbose&&(e.log=r()),i.url&&(i.uri=i.url,delete i.url),!i.uri&&""!==i.uri)throw new Error("options.uri is a required argument");if("string"!=typeof i.uri)throw new Error("options.uri must be a string");for(var u=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],c=0;c<u.length;c++)if(i[u[c]])throw new Error("options."+u[c]+" is not supported");if(i.callback=o,i.method=i.method||"GET",i.headers=i.headers||{},i.body=i.body||null,i.timeout=i.timeout||e.DEFAULT_TIMEOUT,i.headers.host)throw new Error("Options.headers.host is not supported");i.json&&(i.headers.accept=i.headers.accept||"application/json","GET"!==i.method&&(i.headers["content-type"]="application/json"),"boolean"!=typeof i.json?i.body=JSON.stringify(i.json):"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)));var l=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")};if(i.qs){var f="string"==typeof i.qs?i.qs:l(i.qs);-1!==i.uri.indexOf("?")?i.uri=i.uri+"&"+f:i.uri=i.uri+"?"+f}var d=function(e){var t={};t.boundry="-------------------------------"+Math.floor(1e9*Math.random());var n=[];for(var r in e)e.hasOwnProperty(r)&&n.push("--"+t.boundry+'\nContent-Disposition: form-data; name="'+r+'"\n\n'+e[r]+"\n");return n.push("--"+t.boundry+"--"),t.body=n.join(""),t.length=t.body.length,t.type="multipart/form-data; boundary="+t.boundry,t};if(i.form){if("string"==typeof i.form)throw"form name unsupported";if("POST"===i.method){var h=(i.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(i.headers["content-type"]=h,h){case"application/x-www-form-urlencoded":i.body=l(i.form).replace(/%20/g,"+");break;case"multipart/form-data":var g=d(i.form);i.body=g.body,i.headers["content-type"]=g.type;break;default:throw new Error("unsupported encoding:"+h)}}}return i.onResponse=i.onResponse||n,i.onResponse===!0&&(i.onResponse=o,i.callback=n),!i.headers.authorization&&i.auth&&(i.headers.authorization="Basic "+a(i.auth.username+":"+i.auth.password)),t(i)}function t(t){function n(){f=!0;var n=new Error("ETIMEDOUT");return n.code="ETIMEDOUT",n.duration=t.timeout,e.log.error("Timeout",{id:l._id,milliseconds:t.timeout}),t.callback(n,l)}function r(n){if(f)return e.log.debug("Ignoring timed out state change",{state:l.readyState,id:l.id});if(e.log.debug("State change",{state:l.readyState,id:l.id,timed_out:f}),l.readyState===s.OPENED){e.log.debug("Request started",{id:l.id});for(var r in t.headers)l.setRequestHeader(r,t.headers[r])}else l.readyState===s.HEADERS_RECEIVED?i():l.readyState===s.LOADING?(i(),a()):l.readyState===s.DONE&&(i(),a(),u())}function i(){if(!p.response){if(p.response=!0,e.log.debug("Got response",{id:l.id,status:l.status}),clearTimeout(l.timeoutTimer),l.statusCode=l.status,d&&0==l.statusCode){var n=new Error("CORS request rejected: "+t.uri);return n.cors="rejected",p.loading=!0,p.end=!0,t.callback(n,l)}t.onResponse(null,l)}}function a(){p.loading||(p.loading=!0,e.log.debug("Response body loading",{id:l.id}))}function u(){if(!p.end){if(p.end=!0,e.log.debug("Request done",{id:l.id}),l.body=l.responseText,t.json)try{l.body=JSON.parse(l.responseText)}catch(n){return t.callback(n,l)}t.callback(null,l,l.body)}}var l=new s,f=!1,d=o(t.uri),h="withCredentials"in l;if(c+=1,l.seq_id=c,l.id=c+": "+t.method+" "+t.uri,l._id=l.id,d&&!h){var g=new Error("Browser does not support cross-origin request: "+t.uri);return g.cors="unsupported",t.callback(g,l)}l.timeoutTimer=setTimeout(n,t.timeout);var p={response:!1,loading:!1,end:!1};return l.onreadystatechange=r,l.open(t.method,t.uri,!0),d&&(l.withCredentials=!!t.withCredentials),l.send(t.body),l}function n(){}function r(){var e,t,r={},o=["trace","debug","info","warn","error"];for(t=0;t<o.length;t++)e=o[t],r[e]=n,"undefined"!=typeof console&&console&&console[e]&&(r[e]=i(console,e));return r}function i(e,t){function n(n,r){return"object"==typeof r&&(n+=" "+JSON.stringify(r)),e[t].call(e,n)}return n}function o(e){var t,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{t=location.href}catch(r){t=document.createElement("a"),t.href="",t=t.href}var i=n.exec(t.toLowerCase())||[],o=n.exec(e.toLowerCase()),a=!(!o||o[1]==i[1]&&o[2]==i[2]&&(o[3]||("http:"===o[1]?80:443))==(i[3]||("http:"===i[1]?80:443)));return a}function a(e){var t,n,r,i,o,a,s,u,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l=0,f=0,d="",h=[];if(!e)return e;do t=e.charCodeAt(l++),n=e.charCodeAt(l++),r=e.charCodeAt(l++),u=t<<16|n<<8|r,i=u>>18&63,o=u>>12&63,a=u>>6&63,s=63&u,h[f++]=c.charAt(i)+c.charAt(o)+c.charAt(a)+c.charAt(s);while(l<e.length);switch(d=h.join(""),e.length%3){case 1:d=d.slice(0,-2)+"==";break;case 2:d=d.slice(0,-1)+"="}return d}var s=XMLHttpRequest;if(!s)throw new Error("missing XMLHttpRequest");e.log={trace:n,debug:n,info:n,warn:n,error:n};var u=18e4,c=0;e.withCredentials=!1,e.DEFAULT_TIMEOUT=u,e.defaults=function(t,n){var r=function(e){var n=function(n,r){n="string"==typeof n?{uri:n}:JSON.parse(JSON.stringify(n));for(var i in t)void 0===n[i]&&(n[i]=t[i]);return e(n,r)};return n},i=r(e);return i.get=r(e.get),i.post=r(e.post),i.put=r(e.put),i.head=r(e.head),i};var l=["get","put","post","head"];return l.forEach(function(t){var n=t.toUpperCase(),r=t.toLowerCase();e[r]=function(t){"string"==typeof t?t={method:n,uri:t}:(t=JSON.parse(JSON.stringify(t)),t.method=n);var r=[t].concat(Array.prototype.slice.apply(arguments,[1]));return e.apply(this,r)}}),e.couch=function(t,r){function i(e,t,n){if(e)return r(e,t,n);if((t.statusCode<200||t.statusCode>299)&&n.error){e=new Error("CouchDB error: "+(n.error.reason||n.error.error));for(var i in n)e[i]=n[i];return r(e,t,n)}return r(e,t,n)}"string"==typeof t&&(t={uri:t}),t.json=!0,t.body&&(t.json=t.body),delete t.body,r=r||n;var o=e(t,i);return o},e})},{}],2:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(r=arguments.length,o=new Array(r-1),u=1;r>u;u++)o[u-1]=arguments[u];n.apply(this,o)}else if(a(n)){for(r=arguments.length,o=new Array(r-1),u=1;r>u;u++)o[u-1]=arguments[u];for(c=n.slice(),r=c.length,u=0;r>u;u++)c[u].apply(this,o)}return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned){var n;n=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(n)){for(s=o;s-->0;)if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?i(e._events[t])?1:e._events[t].length:0}},{}],3:[function(e,t,n){function r(){l=!1,s.length?c=s.concat(c):f=-1,c.length&&i()}function i(){if(!l){var e=setTimeout(r);l=!0;for(var t=c.length;t;){for(s=c,c=[];++f<t;)s&&s[f].run();f=-1,t=c.length}s=null,l=!1,clearTimeout(e)}}function o(e,t){this.fun=e,this.array=t}function a(){}var s,u=t.exports={},c=[],l=!1,f=-1;u.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new o(e,t)),1!==c.length||l||setTimeout(i,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=a,u.addListener=a,u.once=a,u.off=a,u.removeListener=a,u.removeAllListeners=a,u.emit=a,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},{}],4:[function(e,t,n){(function(n,r){(function(){"use strict";function i(e){return"function"==typeof e||"object"==typeof e&&null!==e}function o(e){return"function"==typeof e}function a(e){return"object"==typeof e&&null!==e}function s(e){B=e}function u(e){Y=e}function c(){return function(){n.nextTick(g)}}function l(){return function(){J(g)}}function f(){var e=0,t=new W(g),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}function d(){var e=new MessageChannel;return e.port1.onmessage=g,function(){e.port2.postMessage(0)}}function h(){return function(){setTimeout(g,1)}}function g(){for(var e=0;K>e;e+=2){var t=te[e],n=te[e+1];t(n),te[e]=void 0,te[e+1]=void 0}K=0}function p(){try{var t=e,n=t("vertx");return J=n.runOnLoop||n.runOnContext,l()}catch(r){return h()}}function v(){}function y(){return new TypeError("You cannot resolve a promise with itself")}function _(){return new TypeError("A promises callback cannot return that same promise.")}function m(e){try{return e.then}catch(t){return oe.error=t,oe}}function k(e,t,n,r){try{e.call(t,n,r)}catch(i){return i}}function w(e,t,n){Y(function(e){var r=!1,i=k(n,t,function(n){r||(r=!0,t!==n?I(e,n):S(e,n))},function(t){r||(r=!0,j(e,t))},"Settle: "+(e._label||" unknown promise"));!r&&i&&(r=!0,j(e,i))},e)}function b(e,t){t._state===re?S(e,t._result):t._state===ie?j(e,t._result):E(t,void 0,function(t){I(e,t)},function(t){j(e,t)})}function P(e,t){if(t.constructor===e.constructor)b(e,t);else{var n=m(t);n===oe?j(e,oe.error):void 0===n?S(e,t):o(n)?w(e,t,n):S(e,t)}}function I(e,t){e===t?j(e,y()):i(t)?P(e,t):S(e,t)}function T(e){e._onerror&&e._onerror(e._result),O(e)}function S(e,t){e._state===ne&&(e._result=t,e._state=re,0!==e._subscribers.length&&Y(O,e))}function j(e,t){e._state===ne&&(e._state=ie,e._result=t,Y(T,e))}function E(e,t,n,r){var i=e._subscribers,o=i.length;e._onerror=null,i[o]=t,i[o+re]=n,i[o+ie]=r,0===o&&e._state&&Y(O,e)}function O(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r,i,o=e._result,a=0;a<t.length;a+=3)r=t[a],i=t[a+n],r?A(n,r,i,o):i(o);e._subscribers.length=0}}function C(){this.error=null}function R(e,t){try{return e(t)}catch(n){return ae.error=n,ae}}function A(e,t,n,r){var i,a,s,u,c=o(n);if(c){if(i=R(n,r),i===ae?(u=!0,a=i.error,i=null):s=!0,t===i)return void j(t,_())}else i=r,s=!0;t._state!==ne||(c&&s?I(t,i):u?j(t,a):e===re?S(t,i):e===ie&&j(t,i))}function D(e,t){try{t(function(t){I(e,t)},function(t){j(e,t)})}catch(n){j(e,n)}}function L(e,t){var n=this;n._instanceConstructor=e,n.promise=new e(v),n._validateInput(t)?(n._input=t,n.length=t.length,n._remaining=t.length,n._init(),0===n.length?S(n.promise,n._result):(n.length=n.length||0,n._enumerate(),0===n._remaining&&S(n.promise,n._result))):j(n.promise,n._validationError())}function x(e){return new se(this,e).promise}function N(e){function t(e){I(i,e)}function n(e){j(i,e)}var r=this,i=new r(v);if(!H(e))return j(i,new TypeError("You must pass an array to race.")),i;for(var o=e.length,a=0;i._state===ne&&o>a;a++)E(r.resolve(e[a]),void 0,t,n);return i}function q(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var n=new t(v);return I(n,e),n}function M(e){var t=this,n=new t(v);return j(n,e),n}function U(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function $(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function G(e){this._id=de++,this._state=void 0,this._result=void 0,this._subscribers=[],v!==e&&(o(e)||U(),this instanceof G||$(),D(this,e))}function F(){var e;if("undefined"!=typeof r)e=r;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=e.Promise;(!n||"[object Promise]"!==Object.prototype.toString.call(n.resolve())||n.cast)&&(e.Promise=he)}var z;z=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var J,B,V,H=z,K=0,Y=({}.toString,function(e,t){te[K]=e,te[K+1]=t,K+=2,2===K&&(B?B(g):V())}),X="undefined"!=typeof window?window:void 0,Q=X||{},W=Q.MutationObserver||Q.WebKitMutationObserver,Z="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),ee="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,te=new Array(1e3);V=Z?c():W?f():ee?d():void 0===X&&"function"==typeof e?p():h();var ne=void 0,re=1,ie=2,oe=new C,ae=new C;L.prototype._validateInput=function(e){return H(e)},L.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},L.prototype._init=function(){this._result=new Array(this.length)};var se=L;L.prototype._enumerate=function(){for(var e=this,t=e.length,n=e.promise,r=e._input,i=0;n._state===ne&&t>i;i++)e._eachEntry(r[i],i)},L.prototype._eachEntry=function(e,t){var n=this,r=n._instanceConstructor;a(e)?e.constructor===r&&e._state!==ne?(e._onerror=null,n._settledAt(e._state,t,e._result)):n._willSettleAt(r.resolve(e),t):(n._remaining--,n._result[t]=e)},L.prototype._settledAt=function(e,t,n){var r=this,i=r.promise;i._state===ne&&(r._remaining--,e===ie?j(i,n):r._result[t]=n),0===r._remaining&&S(i,r._result)},L.prototype._willSettleAt=function(e,t){var n=this;E(e,void 0,function(e){n._settledAt(re,t,e)},function(e){n._settledAt(ie,t,e)})};var ue=x,ce=N,le=q,fe=M,de=0,he=G;G.all=ue,G.race=ce,G.resolve=le,G.reject=fe,G._setScheduler=s,G._setAsap=u,G._asap=Y,G.prototype={constructor:G,then:function(e,t){var n=this,r=n._state;if(r===re&&!e||r===ie&&!t)return this;var i=new this.constructor(v),o=n._result;if(r){var a=arguments[r-1];Y(function(){A(r,i,a,o)})}else E(n,i,e,t);return i},"catch":function(e){return this.then(null,e)}};var ge=F,pe={Promise:he,polyfill:ge};"function"==typeof define&&define.amd?define(function(){return pe}):"undefined"!=typeof t&&t.exports?t.exports=pe:"undefined"!=typeof this&&(this.ES6Promise=pe),ge()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:3}],5:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("../core/request"),a=e("../core/promise"),s=e("../core/settings"),u=e("../core/core"),c=e("../core/logger"),l=e("./storage"),f=e("../core/user"),d=e("../util/util"),h=new s.Settings,g=null,p="DEFER_REGISTER",v={},y={},_=[],m=function(){function e(t){r(this,e),this._dispatcher=null,this._dispatchIntervalTime=30,this._useEventCaching=!0,this._serviceHost=h.getURL("analytics"),this.logger=new c.Logger({prefix:"Ionic Analytics:"}),this.logger._silence=!0,this.storage=u.IonicPlatform.getStorage(),this.cache=new l.BucketStorage("ionic_analytics"),this._addGlobalPropertyDefaults(),t!==p&&this.register(t)}return i(e,[{key:"_addGlobalPropertyDefaults",value:function(){var e=this;e.setGlobalProperties(function(e,t){t._user=JSON.parse(JSON.stringify(f.User.current())),t._app={app_id:h.get("app_id"),analytics_version:u.IonicPlatform.Version}})}},{key:"_enqueueEvent",value:function(e,t){var n=this;if(v.dryRun)return n.logger.info("event recieved but not sent (dryRun active):"),n.logger.info(e),void n.logger.info(t);n.logger.info("enqueuing event to send later:"),n.logger.info(e),n.logger.info(t),t.keen||(t.keen={}),t.keen.timestamp=(new Date).toISOString();var r=n.cache.get("event_queue")||{};r[e]||(r[e]=[]),r[e].push(t),n.cache.set("event_queue",r)}},{key:"_requestAnalyticsKey",value:function(){var e={method:"GET",json:!0,uri:h.getURL("api")+"/api/v1/app/"+h.get("app_id")+"/keys/write",headers:{Authorization:"basic "+btoa(h.get("app_id")+":"+h.get("api_key"))}};return new o.APIRequest(e)}},{key:"_postEvent",value:function(e,t){var n=this,r={name:[t]};g||n.logger.error("Cannot send events to the analytics server without an Analytics key.");var i={method:"POST",url:n._serviceHost+"/api/v1/events/"+h.get("app_id"),json:r,headers:{Authorization:g}};return new o.APIRequest(i)}},{key:"_postEvents",value:function(e){var t=this;g||t.logger.info("Cannot send events to the analytics server without an Analytics key.");var n={method:"POST",url:t._serviceHost+"/api/v1/events/"+h.get("app_id"),json:e,headers:{Authorization:g}};return new o.APIRequest(n)}},{key:"_dispatchQueue",value:function(){var e=this,t=this.cache.get("event_queue")||{};0!==Object.keys(t).length&&u.IonicPlatform.deviceConnectedToNetwork()&&e.storage.lockedAsyncCall(e.cache.scopedKey("event_dispatch"),function(){return e._postEvents(t)}).then(function(){e.cache.set("event_queue",{}),e.logger.info("sent events"),e.logger.info(t)},function(n){e._handleDispatchError(n,this,t)})}},{key:"_getRequestStatusCode",value:function(e){var t=!1;return e&&e.requestInfo._lastResponse&&e.requestInfo._lastResponse.statusCode&&(t=e.requestInfo._lastResponse.statusCode),t}},{key:"_handleDispatchError",value:function(e,t,n){var r=this,i=this._getRequestStatusCode(t);"last_call_interrupted"===e?r.cache.set("event_queue",{}):i?(r.cache.set("event_queue",{}),r.logger.error("Error sending analytics data: Server responded with error"),r.logger.error(n)):r.logger.error("Error sending analytics data: Failed to connect to analytics server.")}},{key:"_handleRegisterError",value:function(e,t){var n=this._getRequestStatusCode(t),r=" See http://docs.ionic.io/v1.0/docs/io-quick-start";switch(n){case 401:self.logger.error("The api key and app id you provided did not register on the server. "+r);break;case 404:self.logger.error('The app id you provided ("'+h.get("app_id")+'") was not found.'+r);break;default:self.logger.error("Unable to request analytics key."),self.logger.error(e)}}},{key:"register",value:function(e){var t=this,n=new a.DeferredPromise;return this.hasValidSettings?(v=e||{},v.silent?this.logger._silence=!0:this.logger._silence=!1,v.dryRun&&this.logger.info("dryRun mode is active. Analytics will not send any events."),this._requestAnalyticsKey().then(function(e){g=e.payload.write_key,t.logger.info("successfully registered analytics key"),t.dispatchInterval=t.dispatchInterval,n.resolve(!0)},function(e){t._handleRegisterError(e,this),n.reject(!1)}),n.promise):(n.reject(!1),n.promise)}},{key:"setGlobalProperties",value:function(e){var t=this,n=typeof e;switch(n){case"object":for(var r in e)e.hasOwnProperty(r)&&(y[r]=e[r]);break;case"function":_.push(e);break;default:t.logger.error("setGlobalProperties parameter must be an object or function.")}}},{key:"track",value:function(e,t){var n=this;if(!this.hasValidSettings)return!1;t=t?d.deepExtend({},t):{};for(var r in y)y.hasOwnProperty(r)&&void 0===t[r]&&(t[r]=y[r]);for(var i=0;i<_.length;i++){var o=_[i];o.call(null,e,t)}this._useEventCaching?n._enqueueEvent(e,t):v.dryRun?(n.logger.info("dryRun active, will not send event"),n.logger.info(e),n.logger.info(t)):n._postEvent(e,t)}},{key:"unsetGlobalProperty",value:function(e){var t=this,n=typeof e;switch(n){case"string":delete y[e];break;case"function":var r=_.indexOf(e);-1===r&&t.logger.error("The function passed to unsetGlobalProperty was not a global property."),_.splice(r,1);break;default:t.logger.error("unsetGlobalProperty parameter must be a string or function.")}}},{key:"hasValidSettings",get:function(){if(!h.get("app_id")||!h.get("api_key")){var e="A valid app_id and api_key are required before you can utilize analytics properly. See http://docs.ionic.io/v1.0/docs/io-quick-start";return this.logger.info(e),!1}return!0}},{key:"dispatchInterval",set:function(e){var t=this;this._dispatchIntervalTime=e,this._dispatcher&&window.clearInterval(this.dispatcher),e>0?(this._dispatcher=window.setInterval(function(){t._dispatchQueue()},1e3*e),this._useEventCaching=!0):this._useEventCaching=!1},get:function(){return this._dispatchIntervalTime}}]),e}();n.Analytics=m},{"../core/core":15,"../core/logger":19,"../core/promise":20,"../core/request":21,"../core/settings":22,"../core/user":24,"../util/util":34,"./storage":9}],6:[function(e,t,n){"use strict";if("object"==typeof angular&&angular.module){var r=function(e){return["$ionicAnalytics","$ionicGesture",function(t,n){for(var r=["drag","dragstart","dragend","dragleft","dragright","dragup","dragdown","swipe","swipeleft","swiperight","swipeup","swipedown","tap","doubletap","hold","transform","pinch","pinchin","pinchout","rotate"],i=!1,o=0;o<r.length;o++)r[o]===e.toLowerCase()&&(i=!0);return{restrict:"A",link:function(r,o,a){function s(e){var n=r.$eval(a.ionTrackData)||{};c?t.track(c,n):t.trackClick(e.pageX,e.pageY,e.target,{data:n})}var u=e[0].toUpperCase()+e.slice(1),c=a["ionTrack"+u];if(i){var l=n.on(e,s,o);r.$on("$destroy",function(){n.off(l,e,s)})}else o.on(e,s),r.$on("$destroy",function(){o.off(e,s)})}}}]},i=null;angular.module("ionic.service.analytics",["ionic"]).value("IONIC_ANALYTICS_VERSION",Ionic.Analytics.version).factory("$ionicAnalytics",[function(){return i||(i=new Ionic.Analytics("DEFER_REGISTER")),i}]).factory("domSerializer",[function(){return new Ionic.AnalyticSerializers.DOMSerializer}]).run(["$ionicAnalytics","$state",function(e,t){e.setGlobalProperties(function(e,n){n._ui||(n._ui={}),n._ui.active_state=t.current.name})}]),angular.module("ionic.service.analytics").provider("$ionicAutoTrack",[function(){var e={},t=!1;this.disableTracking=function(n){n?e[n]=!0:t=!0},this.$get=[function(){return{isEnabled:function(n){return!t&&!e[n]}}}]}]).run(["$ionicAutoTrack","$ionicAnalytics",function(e,t){e.isEnabled("Load")&&t.track("Load")}]).run(["$ionicAutoTrack","$document","$ionicAnalytics","domSerializer",function(e,t,n,r){e.isEnabled("Tap")&&t.on("click",function(e){var t=e.target.getBoundingClientRect(),i=t.right-t.left,o=t.bottom-t.top,a=(e.pageX-t.left)/i,s=(e.pageY-t.top)/o,u={coordinates:{x:e.pageX,y:e.pageY},target:r.elementSelector(e.target),target_identifier:r.elementName(e.target)};isFinite(a)&&isFinite(s)&&(u.coordinates.x_norm=a,u.coordinates.y_norm=s),n.track("Tap",{_ui:u})})}]).run(["$ionicAutoTrack","$ionicAnalytics","$rootScope",function(e,t,n){e.isEnabled("State Change")&&n.$on("$stateChangeSuccess",function(e,n,r,i,o){t.track("State Change",{from:i.name,to:n.name})})}]).directive("ionTrackClick",r("click")).directive("ionTrackTap",r("tap")).directive("ionTrackDoubletap",r("doubletap")).directive("ionTrackHold",r("hold")).directive("ionTrackRelease",r("release")).directive("ionTrackDrag",r("drag")).directive("ionTrackDragLeft",r("dragleft")).directive("ionTrackDragRight",r("dragright")).directive("ionTrackDragUp",r("dragup")).directive("ionTrackDragDown",r("dragdown")).directive("ionTrackSwipeLeft",r("swipeleft")).directive("ionTrackSwipeRight",r("swiperight")).directive("ionTrackSwipeUp",r("swipeup")).directive("ionTrackSwipeDown",r("swipedown")).directive("ionTrackTransform",r("hold")).directive("ionTrackPinch",r("pinch")).directive("ionTrackPinchIn",r("pinchin")).directive("ionTrackPinchOut",r("pinchout")).directive("ionTrackRotate",r("rotate"))}},{}],7:[function(e,t,n){"use strict";var r=e("./analytics"),i=e("./storage"),o=e("./serializers");window.Ionic=window.Ionic||{},Ionic.Analytics=r.Analytics,Ionic.AnalyticStorage={},Ionic.AnalyticStorage.BucketStorage=i.BucketStorage,Ionic.AnalyticSerializers={},Ionic.AnalyticSerializers.DOMSerializer=o.DOMSerializer},{"./analytics":5,"./serializers":8,"./storage":9}],8:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){r(this,e)}return i(e,[{key:"elementSelector",value:function(e){for(var t=[];"HTML"!==e.tagName;){var n=e.tagName.toLowerCase(),r=e.getAttribute("id");r&&(n+="#"+r);var i=e.className;if(i)for(var o=i.split(" "),a=0;a<o.length;a++){var s=o[a];s&&(n+="."+s)}if(!e.parentNode)return null;var u=Array.prototype.indexOf.call(e.parentNode.children,e);n+=":nth-child("+(u+1)+")",e=e.parentNode,t.push(n)}return t.reverse().join(">")}},{key:"elementName",value:function(e){var t=e.getAttribute("ion-track-name");if(t)return t;var n=e.getAttribute("id");return n?n:null}}]),e}();n.DOMSerializer=o},{}],9:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("../core/settings"),a=e("../core/core"),s=new o.Settings,u=function(){function e(t){r(this,e),this.name=t,this.baseStorage=a.IonicPlatform.getStorage()}return i(e,[{key:"get",value:function(e){return this.baseStorage.retrieveObject(this.scopedKey(e))}},{key:"set",value:function(e,t){return this.baseStorage.storeObject(this.scopedKey(e),t)}},{key:"scopedKey",value:function(e){return this.name+"_"+e+"_"+s.get("app_id")}}]),e}();n.BucketStorage=u},{"../core/core":15,"../core/settings":22}],10:[function(e,t,n){"use strict";if("object"==typeof angular&&angular.module){var r=null;angular.module("ionic.service.auth",[]).factory("$ionicAuth",[function(){return r||(r=Ionic.Auth),r}])}},{}],11:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){v=t,"object"==typeof e&&e.remember?k.store():m.store()}function o(e){var t=[];try{t=e.response.body.error.details}catch(n){}return t}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=e("../core/request"),u=e("../core/promise"),c=e("../core/settings"),l=e("../core/storage"),f=e("../core/user"),d=new c.Settings,h=new l.PlatformLocalStorageStrategy,g=new l.LocalSessionStorageStrategy,p={},v=null,y=d.getURL("platform-api")+"/auth",_={login:function(e){return e?y+"/login/"+e:y+"/login"},signup:function(){return y+"/users"}},m=function(){function e(){r(this,e)}return a(e,null,[{key:"delete",value:function(){g.remove(e.label)}},{key:"store",value:function(){g.set(e.label,v)}},{key:"getRawData",value:function(){return g.get(e.label)||!1}},{key:"label",get:function(){return"ionic_io_auth_"+d.get("app_id")}}]),e}();n.TempTokenContext=m;var k=function(){function e(){r(this,e)}return a(e,null,[{key:"delete",value:function(){h.remove(e.label)}},{key:"store",value:function(){h.set(e.label,v)}},{key:"getRawData",value:function(){return h.get(e.label)||!1}},{key:"label",get:function(){return"ionic_io_auth_"+d.get("app_id")}}]),e}();n.TokenContext=k;var w=function R(e,t,n){r(this,R);var o=new u.DeferredPromise;return window&&window.cordova&&window.cordova.InAppBrowser?new s.APIRequest({uri:_.login(t.provider),method:t.uri_method||"POST",json:{app_id:d.get("app_id"),callback:t.callback_uri||window.location.href,data:n}}).then(function(t){var n=t.payload.data.url,r=window.cordova.InAppBrowser.open(n,"_blank","location=no");r.addEventListener("loadstart",function(t){if("http://auth.ionic.io"===t.url.slice(0,20)){for(var n=t.url.split("#")[0].split("?")[1],a=n.split("&"),s={},u=0;u<a.length;u++){var c=a[u].split("=");s[c[0]]=c[1]}i(e,s.token),r.close(),o.resolve(!0)}})},function(e){o.reject(e)}):o.reject("Missing InAppBrowser plugin"),o.promise},b=function(){function e(){r(this,e)}return a(e,null,[{key:"isAuthenticated",value:function(){var e=k.getRawData(),t=m.getRawData();return t||e?!0:!1}},{key:"login",value:function(e,t,n){var r=new u.DeferredPromise,i=p[e]||!1;if(!i)throw new Error("Authentication class is invalid or missing:"+i);return i.authenticate.apply(i,[t,n]).then(function(){f.User.self().then(function(e){r.resolve(e)},function(e){r.reject(e)})},function(e){r.reject(e)}),r.promise}},{key:"signup",value:function(e){var t=p.basic||!1;if(!t)throw new Error("Authentication class is invalid or missing:"+t);return t.signup.apply(t,[e])}},{key:"logout",value:function(){k["delete"](),m["delete"]()}},{key:"register",value:function(e,t){p[e]||(p[e]=t)}},{key:"getUserToken",value:function(){var e=k.getRawData(),t=m.getRawData(),n=t||e;return n?n:!1;
  }}]),e}();n.Auth=b;var P=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){var n=new u.DeferredPromise;return new s.APIRequest({uri:_.login(),method:"POST",json:{app_id:d.get("app_id"),email:t.email,password:t.password}}).then(function(t){i(e,t.payload.data.token),n.resolve(!0)},function(e){n.reject(e)}),n.promise}},{key:"signup",value:function(e){var t=new u.DeferredPromise,n={app_id:d.get("app_id"),email:e.email,password:e.password};return e.username&&(n.username=e.username),e.image&&(n.image=e.image),e.name&&(n.name=e.name),e.custom&&(n.custom=e.custom),new s.APIRequest({uri:_.signup(),method:"POST",json:n}).then(function(){t.resolve(!0)},function(e){var n=[],r=o(e);if(r instanceof Array)for(var i=0;i<r.length;i++){var a=r[i];"object"==typeof a&&a.error_type&&n.push(a.error_type+"_"+a.parameter)}t.reject({errors:n})}),t.promise}}]),e}(),I=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"custom"},t)}}]),e}(),T=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"twitter"},t)}}]),e}(),S=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"facebook"},t)}}]),e}(),j=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"github"},t)}}]),e}(),E=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"google"},t)}}]),e}(),O=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"instagram"},t)}}]),e}(),C=function(){function e(){r(this,e)}return a(e,null,[{key:"authenticate",value:function(e,t){return new w(e,{provider:"linkedin"},t)}}]),e}();b.register("basic",P),b.register("custom",I),b.register("facebook",S),b.register("github",j),b.register("google",E),b.register("instagram",O),b.register("linkedin",C),b.register("twitter",T)},{"../core/promise":20,"../core/request":21,"../core/settings":22,"../core/storage":23,"../core/user":24}],12:[function(e,t,n){"use strict";var r=e("./auth");window.Ionic=window.Ionic||{},Ionic.Auth=r.Auth},{"./auth":11}],13:[function(e,t,n){"use strict";"object"==typeof angular&&angular.module&&angular.module("ionic.service.core",[]).provider("persistentStorage",function(){return{$get:[function(){var e=Ionic.getService("Storage");return e||(e=new Ionic.IO.Storage,Ionic.addService("Storage",e,!0)),e}]}}).factory("$ionicCoreSettings",[function(){return new Ionic.IO.Settings}]).factory("$ionicUser",[function(){return Ionic.User}]).run([function(){Ionic.io()}])},{}],14:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return s[e]||null}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=e("./logger"),s={},u=function(){function e(t,n){return r(this,e),this.logger=new a.Logger({prefix:"Ionic App:"}),t&&""!==t?n&&""!==n?(s.id=t,s.apiKey=n,this.devPush=null,void(this.gcmKey=null)):(this.logger.info("No api_key was provided"),!1):(this.logger.info("No app_id was provided"),!1)}return o(e,[{key:"toString",value:function(){return"<IonicApp ['"+this.id+"'>"}},{key:"id",get:function(){return i("id")}},{key:"apiKey",get:function(){return i("apiKey")}}]),e}();n.App=u},{"./logger":19}],15:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./events"),a=e("./storage"),s=e("./logger"),u=new o.EventEmitter,c=new a.Storage,l=function(){function e(){r(this,e);var t=this;if(this.logger=new s.Logger({prefix:"Ionic Core:"}),this.logger.info("init"),this._pluginsReady=!1,this.emitter=e.getEmitter(),this._bootstrap(),t.cordovaPlatformUnknown)t.logger.info("attempting to mock plugins"),t._pluginsReady=!0,t.emitter.emit("ionic_core:plugins_ready");else try{document.addEventListener("deviceready",function(){t.logger.info("plugins are ready"),t._pluginsReady=!0,t.emitter.emit("ionic_core:plugins_ready")},!1)}catch(n){t.logger.info("unable to listen for cordova plugins to be ready")}}return i(e,[{key:"_isCordovaAvailable",value:function(){var e=this;if(this.logger.info("searching for cordova.js"),"undefined"!=typeof cordova)return this.logger.info("cordova.js has already been loaded"),!0;for(var t=document.getElementsByTagName("script"),n=t.length,r=0;n>r;r++){var i=t[r].getAttribute("src");if(i){var o=i.split("/"),a=0;try{if(a=o.length,"cordova.js"===o[a-1])return e.logger.info("cordova.js has previously been included."),!0}catch(s){e.logger.info("encountered error while testing for cordova.js presence, "+s.toString())}}}return!1}},{key:"loadCordova",value:function(){var t=this;if(!this._isCordovaAvailable()){var n=document.createElement("script"),r="cordova.js";switch(e.getDeviceTypeByNavigator()){case"android":"file"===window.location.href.substring(0,4)&&(r="file:///android_asset/www/cordova.js");break;case"ipad":case"iphone":try{var i=window.location.search.match(/cordova_js_bootstrap_resource=(.*?)(&|#|$)/i);i&&(r=decodeURI(i[1]))}catch(o){t.logger.info("could not find cordova_js_bootstrap_resource query param"),t.logger.info(o)}break;case"unknown":return t.cordovaPlatformUnknown=!0,!1}n.setAttribute("src",r),document.head.appendChild(n),t.logger.info("injecting cordova.js")}}},{key:"_bootstrap",value:function(){this.loadCordova()}},{key:"onReady",value:function(e){var t=this;this._pluginsReady?e(t):t.emitter.on("ionic_core:plugins_ready",function(){e(t)})}}],[{key:"getEmitter",value:function(){return u}},{key:"getStorage",value:function(){return c}},{key:"getMain",value:function(){return"undefined"!=typeof Ionic&&Ionic.IO&&Ionic.IO.main?Ionic.IO.main:null}},{key:"getDeviceTypeByNavigator",value:function(){var e=navigator.userAgent,t=e.match(/iPad/i);if(t&&"ipad"===t[0].toLowerCase())return"ipad";var n=e.match(/iPhone/i);if(n&&"iphone"===n[0].toLowerCase())return"iphone";var r=e.match(/Android/i);return r&&"android"===r[0].toLowerCase()?"android":"unknown"}},{key:"isAndroidDevice",value:function(){var t=e.getDeviceTypeByNavigator();return"android"===t?!0:!1}},{key:"isIOSDevice",value:function(){var t=e.getDeviceTypeByNavigator();return"iphone"===t||"ipad"===t?!0:!1}},{key:"deviceConnectedToNetwork",value:function(e){if("undefined"==typeof e&&(e=!1),"undefined"==typeof navigator.connection||"undefined"==typeof navigator.connection.type||"undefined"==typeof Connection)return e?!1:!0;switch(navigator.connection.type){case Connection.ETHERNET:case Connection.WIFI:case Connection.CELL_2G:case Connection.CELL_3G:case Connection.CELL_4G:case Connection.CELL:return!0;default:return!1}}},{key:"Version",get:function(){return"0.7.1"}}]),e}();n.IonicPlatform=l},{"./events":18,"./logger":19,"./storage":23}],16:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o={},a=function(){function e(t){r(this,e),this.data={},this.setProperties(t)}return i(e,[{key:"setProperties",value:function(e){if(e instanceof Object)for(var t in e)this.data[t]=e[t]}},{key:"toJSON",value:function(){var e=this.data;return{__Ionic_DataTypeSchema:e.name,value:e.value}}},{key:"isValid",value:function(){return this.data.name&&this.data.value?!0:!1}}]),e}(),s=function(){function e(){r(this,e)}return i(e,null,[{key:"get",value:function(e,t){return o[e]?new o[e](t):!1}},{key:"getMapping",value:function(){return o}},{key:"register",value:function(e,t){o[e]=t}},{key:"Schema",get:function(){return a}}]),e}();n.DataType=s;var u=function(){function e(t){if(r(this,e),this.data=[],t instanceof Array)for(var n in t)this.push(t[n])}return i(e,[{key:"toJSON",value:function(){var e=this.data,t=new a({name:"UniqueArray",value:e});return t.toJSON()}},{key:"push",value:function(e){-1===this.data.indexOf(e)&&this.data.push(e)}},{key:"pull",value:function(e){var t=this.data.indexOf(e);this.data.splice(t,1)}}],[{key:"fromStorage",value:function(t){return new e(t)}}]),e}();n.UniqueArray=u,s.register("UniqueArray",u)},{}],17:[function(e,t,n){"use strict";var r=e("./app"),i=e("./core"),o=e("./events"),a=e("./logger"),s=e("./promise"),u=e("./request"),c=e("./settings"),l=e("./storage"),f=e("./user"),d=e("./data-types");window.Ionic=window.Ionic||{},Ionic.Core=i.IonicPlatform,Ionic.User=f.User,Ionic.DataType=d.DataType,Ionic.DataTypes=d.DataType.getMapping(),Ionic.IO={},Ionic.IO.App=r.App,Ionic.IO.EventEmitter=o.EventEmitter,Ionic.IO.Logger=a.Logger,Ionic.IO.Promise=s.Promise,Ionic.IO.DeferredPromise=s.DeferredPromise,Ionic.IO.Request=u.Request,Ionic.IO.Response=u.Response,Ionic.IO.APIRequest=u.APIRequest,Ionic.IO.APIResponse=u.APIResponse,Ionic.IO.Storage=l.Storage,Ionic.IO.Settings=c.Settings;var h={};Ionic.io=function(){return"undefined"==typeof Ionic.IO.main&&(Ionic.IO.main=new Ionic.Core),Ionic.IO.main},Ionic.getService=function(e){return"undefined"!=typeof h[e]&&h[e]?h[e]:!1},Ionic.addService=function(e,t,n){t&&"undefined"==typeof h[e]?h[e]=t:t&&n&&(h[e]=t)},Ionic.removeService=function(e){"undefined"!=typeof h[e]&&delete h[e]},Ionic.io()},{"./app":14,"./core":15,"./data-types":16,"./events":18,"./logger":19,"./promise":20,"./request":21,"./settings":22,"./storage":23,"./user":24}],18:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("events"),a=function(){function e(){r(this,e),this._emitter=new o}return i(e,[{key:"on",value:function(e,t){return this._emitter.on(e,t)}},{key:"emit",value:function(e,t){return this._emitter.emit(e,t)}}]),e}();n.EventEmitter=a},{events:2}],19:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(t){r(this,e);var n=t||{};this._silence=!1,this._prefix=!1,this._options=n,this._bootstrap()}return i(e,[{key:"_bootstrap",value:function(){this._options.prefix&&(this._prefix=this._options.prefix)}},{key:"info",value:function(e){this._silence||(this._prefix?console.log(this._prefix,e):console.log(e))}},{key:"warn",value:function(e){this._silence||(this._prefix?console.log(this._prefix,e):console.log(e))}},{key:"error",value:function(e){this._prefix?console.error(this._prefix,e):console.error(e)}}]),e}();n.Logger=o},{}],20:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("es6-promise").Promise,a=o;n.Promise=a;var s=function(){function e(){r(this,e);var t=this;this._update=!1,this.promise=new o(function(e,n){t.resolve=e,t.reject=n});var n=this.promise.then;this.promise.then=function(e,r,i){return t._update=i,n.call(t.promise,e,r)}}return i(e,[{key:"notify",value:function(e){this._update&&"function"==typeof this._update&&this._update(e)}}]),e}();n.DeferredPromise=s},{"es6-promise":4}],21:[function(e,t,n){"use strict";function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(e,t,n){for(var r=!0;r;){var i=e,o=t,a=n;s=c=u=void 0,r=!1,null===i&&(i=Function.prototype);var s=Object.getOwnPropertyDescriptor(i,o);if(void 0!==s){if("value"in s)return s.value;var u=s.get;return void 0===u?void 0:u.call(a)}var c=Object.getPrototypeOf(i);if(null===c)return void 0;e=c,t=o,n=a,r=!0}},a=e("./promise"),s=e("../auth/auth"),u=e("browser-request"),c=function h(){i(this,h)};n.Request=c;var l=function g(){i(this,g)};n.Response=l;var f=function(e){function t(){i(this,t),o(Object.getPrototypeOf(t.prototype),"constructor",this).call(this)}return r(t,e),t}(l);n.APIResponse=f;var d=function(e){function t(e){if(i(this,t),o(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),e.headers=e.headers||{},!e.headers.Authorization){var n=s.Auth.getUserToken();n&&(e.headers.Authorization="Bearer "+n)}var r={},c=new a.Promise(function(t,n){u(e,function(e,i,o){if(r._lastError=e,r._lastResponse=i,r._lastResult=o,e)n(e);else if(i.statusCode<200||i.statusCode>=400){var a=new Error("Request Failed with status code of "+i.statusCode);n({response:i,error:a})}else t({response:i,payload:o})})});return c.requestInfo=r,c}return r(t,e),t}(c);n.APIRequest=d},{"../auth/auth":11,"./promise":20,"browser-request":1}],22:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){return r(this,e),this._settings=null,this}return i(e,[{key:"factory",value:function(e,t){return this._settings=t(),this}},{key:"get",value:function(e){return this._settings.get(e)}},{key:"finish",value:function(){return this}}]),e}(),a=(new o).factory("$ionicCoreSettings",function(){"IONIC_SETTINGS_STRING_START";var settings = {"dev_push":false,"app_id":"d7f99c45","api_key":"66787df7baf41fce8d08b2f8c055b2e48e29014fb6dab6ff","gcm_key":"378633166857"}; return { get: function(setting) { if (settings[setting]) { return settings[setting]; } return null; } };"IONIC_SETTINGS_STRING_END"}).finish(),s=function(){function e(){r(this,e),this._locations={api:"https://apps.ionic.io",push:"https://push.ionic.io",analytics:"https://analytics.ionic.io",deploy:"https://apps.ionic.io","platform-api":"https://api.ionic.io"},this._devLocations=this.get("dev_locations"),this._devLocations||(this._devLocations={})}return i(e,[{key:"get",value:function(e){return a.get(e)}},{key:"getURL",value:function(e){return this._devLocations[e]?this._devLocations[e]:this._locations[e]?this._locations[e]:null}}]),e}();n.Settings=s},{}],23:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./promise"),a=function(){function e(){r(this,e)}return i(e,[{key:"get",value:function(e){return window.localStorage.getItem(e)}},{key:"remove",value:function(e){return window.localStorage.removeItem(e)}},{key:"set",value:function(e,t){return window.localStorage.setItem(e,t)}}]),e}();n.PlatformLocalStorageStrategy=a;var s=function(){function e(){r(this,e)}return i(e,[{key:"get",value:function(e){return window.sessionStorage.getItem(e)}},{key:"remove",value:function(e){return window.sessionStorage.removeItem(e)}},{key:"set",value:function(e,t){return window.sessionStorage.setItem(e,t)}}]),e}();n.LocalSessionStorageStrategy=s;var u={},c={},l=function(){function e(){r(this,e),this.strategy=new a}return i(e,[{key:"storeObject",value:function(e,t){var n=JSON.stringify(t);this.strategy.set(e,n),u[e]=t}},{key:"deleteObject",value:function(e){this.strategy.remove(e),delete u[e]}},{key:"retrieveObject",value:function(e){var t=u[e];if(t)return t;var n=this.strategy.get(e);if(null===n)return null;try{return JSON.parse(n)}catch(r){return null}}},{key:"lockedAsyncCall",value:function(e,t){var n=this,r=new o.DeferredPromise;return c[e]?(r.reject("in_progress"),r.promise):"locked"===this.strategy.get(e)?(r.reject("last_call_interrupted"),r.promise.then(null,function(){n.strategy.remove(e)}),r.promise):(c[e]=!0,n.strategy.set(e,"locked"),t().then(function(t){r.resolve(t),delete c[e],n.strategy.remove(e)},function(t){r.reject(t),delete c[e],n.strategy.remove(e)},function(e){r.notify(e)}),r.promise)}}]),e}();n.Storage=l},{"./promise":20}],24:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("../auth/auth"),a=e("./request"),s=e("./promise"),u=e("./settings"),c=e("./storage"),l=e("./logger"),f=e("./data-types.js"),d=null,h=new u.Settings,g=new c.Storage,p=h.getURL("platform-api")+"/auth/users",v={self:function(){return p+"/self"},get:function(e){return p+"/"+e.id},remove:function(e){return p+"/"+e.id},save:function(e){return p+"/"+e.id},passwordReset:function(e){return p+"/"+e.id+"/password-reset"}},y=function(){function e(){r(this,e)}return i(e,null,[{key:"delete",value:function(){g.deleteObject(e.label)}},{key:"store",value:function(){e.getRawData()&&e.storeLegacyData(e.getRawData()),m.current().data.data.__ionic_user_migrated&&g.storeObject(e.label+"_legacy",{__ionic_user_migrated:!0}),g.storeObject(e.label,m.current())}},{key:"storeLegacyData",value:function(t){e.getRawLegacyData()||g.storeObject(e.label+"_legacy",t)}},{key:"getRawData",value:function(){return g.retrieveObject(e.label)||!1}},{key:"getRawLegacyData",value:function(){return g.retrieveObject(e.label+"_legacy")||!1}},{key:"load",value:function(){var t=g.retrieveObject(e.label)||!1;return t?(e.storeLegacyData(t),m.fromContext(t)):!1}},{key:"label",get:function(){return"ionic_io_user_"+h.get("app_id")}}]),e}(),_=function(){function e(t){r(this,e),this.data={},"object"==typeof t&&(this.data=t,this.deserializerDataTypes())}return i(e,[{key:"deserializerDataTypes",value:function(){for(var e in this.data)if("object"==typeof this.data[e]&&this.data[e].__Ionic_DataTypeSchema){var t=this.data[e].__Ionic_DataTypeSchema,n=f.DataType.getMapping();n[t]&&(this.data[e]=n[t].fromStorage(this.data[e].value))}}},{key:"set",value:function(e,t){this.data[e]=t}},{key:"unset",value:function(e){delete this.data[e]}},{key:"get",value:function(e,t){return this.data.hasOwnProperty(e)?this.data[e]:0===t||t===!1?t:t||null}}]),e}(),m=function(){function e(){r(this,e),this.logger=new l.Logger({prefix:"Ionic User:"}),this._blockLoad=!1,this._blockSave=!1,this._blockDelete=!1,this._dirty=!1,this._fresh=!0,this._unset={},this.data=new _}return i(e,[{key:"isDirty",value:function(){return this._dirty}},{key:"isAnonymous",value:function(){return this.id?!1:!0}},{key:"isAuthenticated",value:function(){return this===e.current()?o.Auth.isAuthenticated():!1}},{key:"isFresh",value:function(){return this._fresh}},{key:"isValid",value:function(){return this.id?!0:!1}},{key:"getAPIFormat",value:function(){var e={};for(var t in this.details)e[t]=this.details[t];return e.custom=this.data.data,e}},{key:"getFormat",value:function(e){var t=this,n=null;switch(e){case"api-save":n=t.getAPIFormat()}return n}},{key:"migrate",value:function(){var e=y.getRawLegacyData();if(e.__ionic_user_migrated)return!0;if(e){var t=Ionic.User.current(),n=new _(e.data.data);for(var r in n.data)t.set(r,n.data[r]);t.set("__ionic_user_migrated",!0)}}},{key:"delete",value:function(){var e=this,t=new s.DeferredPromise;return e.isValid()?(e._blockDelete?(e.logger.info("a delete operation is already in progress for "+this+"."),t.reject(!1)):(e._blockDelete=!0,e._delete(),new a.APIRequest({uri:v.remove(this),method:"DELETE",json:!0}).then(function(n){e._blockDelete=!1,e.logger.info("deleted "+e),t.resolve(n)},function(n){e._blockDelete=!1,e.logger.error(n),t.reject(n)})),t.promise):!1}},{key:"_store",value:function(){this===e.current()&&y.store()}},{key:"_delete",value:function(){this===e.current()&&y["delete"]()}},{key:"save",value:function(){var e=this,t=new s.DeferredPromise;return e._blockSave?(e.logger.info("a save operation is already in progress for "+this+"."),t.reject(!1)):(e._blockSave=!0,e._store(),new a.APIRequest({uri:v.save(this),method:"PATCH",json:e.getFormat("api-save")}).then(function(n){e._dirty=!1,e.isFresh()||(e._unset={}),e._fresh=!1,e._blockSave=!1,e.logger.info("saved user"),t.resolve(n)},function(n){e._dirty=!0,e._blockSave=!1,e.logger.error(n),t.reject(n)})),t.promise}},{key:"resetPassword",value:function(){var e=this,t=new s.DeferredPromise;return new a.APIRequest({uri:v.passwordReset(this),method:"POST"}).then(function(n){e.logger.info("password reset for user"),t.resolve(n)},function(n){e.logger.error(n),t.reject(n)}),t.promise}},{key:"toString",value:function(){return"<IonicUser ['"+this.id+"']>"}},{key:"set",value:function(e,t){return delete this._unset[e],this.data.set(e,t)}},{key:"get",value:function(e,t){return this.data.get(e,t)}},{key:"unset",value:function(e){return this._unset[e]=!0,this.data.unset(e)}},{key:"id",set:function(e){return e&&"string"==typeof e&&""!==e?(this._id=e,!0):!1},get:function(){return this._id||null}}],[{key:"current",value:function(t){return t?(d=t,y.store(),d):(d||(d=y.load()),d||(d=new e),d)}},{key:"fromContext",value:function(t){var n=new e;return n.id=t._id,n.data=new _(t.data.data),n.details=t.details||{},n._fresh=t._fresh,n._dirty=t._dirty,n}},{key:"self",value:function(){var t=new s.DeferredPromise,n=new e;return n._blockLoad?(n.logger.info("a load operation is already in progress for "+this+"."),t.reject(!1)):(n._blockLoad=!0,new a.APIRequest({uri:v.self(),method:"GET",json:!0}).then(function(r){n._blockLoad=!1,n.logger.info("loaded user"),n.id=r.payload.data.uuid,n.data=new _(r.payload.data.custom),n.details=r.payload.data.details,n._fresh=!1,e.current(n),t.resolve(n)},function(e){n._blockLoad=!1,n.logger.error(e),t.reject(e)})),t.promise}},{key:"load",value:function(t){var n=new s.DeferredPromise,r=new e;return r.id=t,r._blockLoad?(r.logger.info("a load operation is already in progress for "+this+"."),n.reject(!1)):(r._blockLoad=!0,new a.APIRequest({uri:v.get(r),method:"GET",json:!0}).then(function(e){r._blockLoad=!1,r.logger.info("loaded user"),r.data=new _(e.payload.data.custom),r.details=e.payload.data.details,r._fresh=!1,n.resolve(r)},function(e){r._blockLoad=!1,r.logger.error(e),n.reject(e)})),n.promise}}]),e}();n.User=m},{"../auth/auth":11,"./data-types.js":16,"./logger":19,"./promise":20,"./request":21,"./settings":22,"./storage":23}],25:[function(e,t,n){"use strict";if("object"==typeof angular&&angular.module){var r=null;angular.module("ionic.service.deploy",[]).factory("$ionicDeploy",[function(){return r||(r=new Ionic.Deploy),r}])}},{}],26:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("../core/settings"),a=e("../core/promise"),s=e("../core/logger"),u=e("../core/core"),c=e("../core/events"),l=new o.Settings,f="IONIC_DEPLOY_MISSING_PLUGIN",d=5e3,h=6e4,g=function(){function e(){r(this,e);var t=this;this.logger=new s.Logger({prefix:"Ionic Deploy:"}),this._plugin=!1,this._isReady=!1,this._channelTag="production",this._emitter=new c.EventEmitter,this.logger.info("init"),u.IonicPlatform.getMain().onReady(function(){t.initialize(),t._isReady=!0,t._emitter.emit("ionic_deploy:ready")})}return i(e,[{key:"_getPlugin",value:function(){return this._plugin?this._plugin:"undefined"==typeof IonicDeploy?(this.logger.info("plugin is not installed or has not loaded. Have you run `ionic plugin add ionic-plugin-deploy` yet?"),!1):(this._plugin=IonicDeploy,IonicDeploy)}},{key:"initialize",value:function(){var e=this;this.onReady(function(){e._getPlugin()&&e._plugin.init(l.get("app_id"),l.getURL("platform-api"))})}},{key:"check",value:function(){var e=this,t=new a.DeferredPromise;return this.onReady(function(){e._getPlugin()?e._plugin.check(l.get("app_id"),e._channelTag,function(n){n&&"true"===n?(e.logger.info("an update is available"),t.resolve(!0)):(e.logger.info("no updates available"),t.resolve(!1))},function(n){e.logger.error("encountered an error while checking for updates"),t.reject(n)}):t.reject(f)}),t.promise}},{key:"download",value:function(){var e=this,t=new a.DeferredPromise;return this.onReady(function(){e._getPlugin()?e._plugin.download(l.get("app_id"),function(n){"true"!==n&&"false"!==n?t.notify(n):("true"===n&&e.logger.info("download complete"),t.resolve("true"===n))},function(e){t.reject(e)}):t.reject(f)}),t.promise}},{key:"extract",value:function(){var e=this,t=new a.DeferredPromise;return this.onReady(function(){e._getPlugin()?e._plugin.extract(l.get("app_id"),function(n){"done"!==n?t.notify(n):("true"===n&&e.logger.info("extraction complete"),t.resolve(n))},function(e){t.reject(e)}):t.reject(f)}),t.promise}},{key:"load",value:function(){var e=this;this.onReady(function(){e._getPlugin()&&e._plugin.redirect(l.get("app_id"))})}},{key:"watch",value:function(e){function t(){i.check().then(function(e){e&&n.notify(e)},function(e){i.logger.info("unable to check for updates, ",e)}),this._checkTimeout&&(this._checkTimeout=setTimeout(t.bind(i),r.interval))}var n=new a.DeferredPromise,r=e||{},i=this;return"undefined"==typeof r.initialDelay&&(r.initialDelay=d),"undefined"==typeof r.interval&&(r.interval=h),this._checkTimeout=setTimeout(t.bind(i),r.initialDelay),n.promise}},{key:"unwatch",value:function(){clearTimeout(this._checkTimeout),this._checkTimeout=null}},{key:"info",value:function(){var e=new a.DeferredPromise,t=this;return this.onReady(function(){t._getPlugin()?t._plugin.info(l.get("app_id"),function(t){e.resolve(t)},function(t){e.reject(t)}):e.reject(f)}),e.promise}},{key:"getVersions",value:function(){var e=new a.DeferredPromise,t=this;return this.onReady(function(){t._getPlugin()?t._plugin.getVersions(l.get("app_id"),function(t){e.resolve(t)},function(t){e.reject(t)}):e.reject(f)}),e.promise}},{key:"deleteVersion",value:function(e){var t=new a.DeferredPromise,n=this;return this.onReady(function(){n._getPlugin()?n._plugin.deleteVersion(l.get("app_id"),e,function(e){t.resolve(e)},function(e){t.reject(e)}):t.reject(f)}),t.promise}},{key:"getMetadata",value:function(e){var t=new a.DeferredPromise,n=this;return this.onReady(function(){n._getPlugin()?n._plugin.getMetadata(l.get("app_id"),e,function(e){t.resolve(e.metadata)},function(e){t.reject(e)}):t.reject(f)}),t.promise}},{key:"setChannel",value:function(e){this._channelTag=e}},{key:"update",value:function(e){var t=new a.DeferredPromise,n=this,r=!1;return"undefined"!=typeof e&&(r=e),this.onReady(function(){n._getPlugin()?n.check().then(function(e){if(e===!0){var i=0;n.download().then(function(e){e||t.reject("download error"),n.extract().then(function(e){e||t.reject("extraction error"),r?t.resolve(!0):(t.resolve(!0),n._plugin.redirect(l.get("app_id")))},function(e){t.reject(e)},function(e){var n=i+e/2;t.notify(n)})},function(e){t.reject(e)},function(e){i=e/2,t.notify(i)})}else t.resolve(!1)},function(e){t.reject(e)}):t.reject(f)}),t.promise}},{key:"onReady",value:function(e){var t=this;this._isReady?e(t):t._emitter.on("ionic_deploy:ready",function(){e(t)})}}]),e}();n.Deploy=g},{"../core/core":15,"../core/events":18,"../core/logger":19,"../core/promise":20,"../core/settings":22}],27:[function(e,t,n){"use strict";var r=e("./deploy");window.Ionic=window.Ionic||{},Ionic.Deploy=r.Deploy},{"./deploy":26}],28:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();if("object"==typeof angular&&angular.module){var o=null;angular.module("ionic.service.push",[]).factory("$ionicPushAction",["$state",function(e){var t=function(){function t(){r(this,t)}return i(t,[{key:"notificationNavigation",value:function(t){var n=t.payload.$state||!1,r=t.payload.$stateParams||{};n&&e.go(n,r)}}]),t}();return new t}]).factory("$ionicPush",[function(){return o||(o=new Ionic.Push("DEFER_INIT")),o}]).run(["$ionicPush","$ionicPushAction",function(e,t){e._emitter.on("ionic_push:processNotification",function(e){e=Ionic.PushMessage.fromPluginJSON(e),e&&e.app&&(e.app.asleep===!0||e.app.closed===!0)&&t.notificationNavigation(e)})}])}},{}],29:[function(e,t,n){"use strict";var r=e("./push"),i=e("./push-token"),o=e("./push-message");window.Ionic=window.Ionic||{},Ionic.Push=r.Push,Ionic.PushToken=i.PushToken,Ionic.PushMessage=o.PushMessage},{"./push":33,"./push-message":31,"./push-token":32}],30:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("../core/request"),a=e("../core/settings"),s=e("../core/logger"),u=e("./push-token"),c=new a.Settings,l=function(){function e(){r(this,e),this.logger=new s.Logger({prefix:"Ionic Push (dev):"}),this._serviceHost=c.getURL("platform-api")+"/push",this._token=!1,this._watch=!1}return i(e,[{key:"getDevToken",value:function(){var e="DEV-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)});return this._token=e,this._token}},{key:"init",value:function(e,t){this._push=e,this._emitter=this._push._emitter;var n=this._token,r=this;n||(n=this.getDevToken());var i={method:"POST",uri:this._serviceHost+"/development",json:{token:n}};new o.APIRequest(i).then(function(){var e={registrationId:n};r.logger.info("registered with development push service",n),r._emitter.emit("ionic_push:token",e),"function"==typeof t&&t(new u.PushToken(r._token)),r.watch()},function(e){r.logger.error("error connecting development push service.",e)})}},{key:"checkForNotifications",
  value:function(){if(!this._token)return!1;var e=this,t={method:"GET",uri:e._serviceHost+"/development?token="+e._token,json:!0};new o.APIRequest(t).then(function(t){if(t.payload.data.message){var n={message:t.payload.data.message,title:"DEVELOPMENT PUSH"};e.logger.warn("Ionic Push: Development Push received. Development pushes will not contain payload data."),e._emitter.emit("ionic_push:notification",n)}},function(t){e.logger.error("unable to check for development pushes.",t)})}},{key:"watch",value:function(){this.logger.info("watching for new notifications");var e=this;this._watch||(this._watch=setInterval(function(){e.checkForNotifications()},5e3))}},{key:"halt",value:function(){this._watch&&clearInterval(this._watch)}}]),e}();n.PushDevService=l},{"../core/logger":19,"../core/request":21,"../core/settings":22,"./push-token":32}],31:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){r(this,e),this.asleep=!1,this.closed=!1}return i(e,[{key:"wasAsleep",get:function(){return this.asleep}},{key:"wasClosed",get:function(){return this.closed}}]),e}(),a=function(){function e(t){r(this,e),this._raw=t||{},this._raw.additionalData||(this._raw.additionalData={coldstart:!1,foreground:!0}),this._payload=null,this.app=null,this.text=null,this.title=null,this.count=null,this.sound=null,this.image=null}return i(e,[{key:"processRaw",value:function(){this.text=this._raw.message||null,this.title=this._raw.title||null,this.count=this._raw.count||null,this.sound=this._raw.sound||null,this.image=this._raw.image||null,this.app=new o,this._raw.additionalData.foreground||(this.app.asleep=!0),this._raw.additionalData.coldstart&&(this.app.closed=!0),this._raw.additionalData.payload&&(this._payload=this._raw.additionalData.payload)}},{key:"getRawVersion",value:function(){return this._raw}},{key:"toString",value:function(){return"<PushMessage ['"+this.title+"']>"}},{key:"payload",get:function(){return this._payload||{}}}],[{key:"fromPluginJSON",value:function(t){var n=new e(t);return n.processRaw(),n}}]),e}();n.PushMessage=a},{}],32:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(t){r(this,e),this._token=t||null}return i(e,[{key:"toString",value:function(){var e=this._token||"null";return"<PushToken ['"+e+"']>"}},{key:"token",set:function(e){this._token=e},get:function(){return this._token}}]),e}();n.PushToken=o},{}],33:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("../core/app"),a=e("../core/settings"),s=e("../core/core"),u=e("../core/logger"),c=e("../core/events"),l=e("../core/request"),f=e("../core/promise"),d=e("../core/user"),h=e("./push-token"),g=e("./push-message"),p=e("./push-dev"),v=new a.Settings,y="DEFER_INIT",_=v.getURL("platform-api")+"/push",m={saveToken:function(){return _+"/tokens"},invalidateToken:function(){return _+"/tokens/invalidate"}},k=function(){function e(t){r(this,e),this.logger=new u.Logger({prefix:"Ionic Push:"});var n=new o.App(v.get("app_id"),v.get("api_key"));if(n.devPush=v.get("dev_push"),n.gcmKey=v.get("gcm_key"),!n.id||!n.apiKey)return this.logger.error("no app_id or api_key found. (http://docs.ionic.io/docs/io-install)"),!1;if(s.IonicPlatform.isAndroidDevice()&&!n.devPush&&!n.gcmKey)return this.logger.error("GCM project number not found (http://docs.ionic.io/docs/push-android-setup)"),!1;if(this.app=n,this.registerCallback=!1,this.notificationCallback=!1,this.errorCallback=!1,this._token=!1,this._notification=!1,this._debug=!1,this._isReady=!1,this._tokenReady=!1,this._blockRegistration=!1,this._blockSaveToken=!1,this._registered=!1,this._emitter=new c.EventEmitter,this._plugin=null,t!==y){var i=this;s.IonicPlatform.getMain().onReady(function(){i.init(t)})}}return i(e,[{key:"getStorageToken",value:function(){var e=s.IonicPlatform.getStorage(),t=e.retrieveObject("ionic_io_push_token");return t?new h.PushToken(t.token):null}},{key:"clearStorageToken",value:function(){var e=s.IonicPlatform.getStorage();e.deleteObject("ionic_io_push_token")}},{key:"init",value:function(e){if(this._getPushPlugin(),"undefined"==typeof e&&(e={}),"object"!=typeof e)return this.logger.error("init() requires a valid config object."),!1;var t=this;return e.pluginConfig||(e.pluginConfig={}),s.IonicPlatform.isAndroidDevice()&&(e.pluginConfig.android||(e.pluginConfig.android={}),e.pluginConfig.android.senderId||(e.pluginConfig.android.senderID=t.app.gcmKey)),e.onRegister&&this.setRegisterCallback(e.onRegister),e.onNotification&&this.setNotificationCallback(e.onNotification),e.onError&&this.setErrorCallback(e.onError),this._config=e,this._isReady=!0,this._emitter.emit("ionic_push:ready",{config:this._config}),this}},{key:"saveToken",value:function(e,t){var n=new f.DeferredPromise,r=t||{};e.token&&(e=e.token);var i={token:e,app_id:v.get("app_id")};if(!r.ignore_user){var o=d.User.current();o.isAuthenticated()&&(i.user_id=o.id)}self._blockSaveToken?(self.logger.info("a token save operation is already in progress."),n.reject(!1)):new l.APIRequest({uri:m.saveToken(),method:"POST",json:i}).then(function(t){self._blockSaveToken=!1,self.logger.info("saved push token: "+e),i.user_id&&self.logger.info("added push token to user: "+i.user_id),n.resolve(t)},function(e){self._blockSaveToken=!1,self.logger.error(e),n.reject(e)})}},{key:"register",value:function(e){this.logger.info("register");var t=this;return this._blockRegistration?(t.logger.info("another registration is already in progress."),!1):(this._blockRegistration=!0,void this.onReady(function(){if(t.app.devPush){var n=new p.PushDevService;t._debugCallbackRegistration(),t._callbackRegistration(),n.init(t,e),t._blockRegistration=!1,t._tokenReady=!0}else t._plugin=t._getPushPlugin().init(t._config.pluginConfig),t._plugin.on("registration",function(n){t._blockRegistration=!1,t.token=new h.PushToken(n.registrationId),t._tokenReady=!0,"function"==typeof e&&e(t._token)}),t._debugCallbackRegistration(),t._callbackRegistration();t._registered=!0}))}},{key:"unregister",value:function(){var e=this,t=new f.DeferredPromise,n=null;return s.IonicPlatform.isAndroidDevice()?n="android":s.IonicPlatform.isIOSDevice()&&(n="ios"),n||t.reject("Could not detect the platform, are you on a device?"),e._blockUnregister?(e.logger.info("an unregister operation is already in progress."),t.reject(!1)):(this._plugin&&this._plugin.unregister(function(){},function(){}),new l.APIRequest({uri:m.invalidateToken(),method:"POST",json:{platform:n,token:e.getStorageToken().token}}).then(function(n){e._blockUnregister=!1,e.logger.info("unregistered push token: "+e.getStorageToken().token),e.clearStorageToken(),t.resolve(n)},function(n){e._blockUnregister=!1,e.logger.error(n),t.reject(n)})),t.promise}},{key:"getPayload",value:function(e){return e.payload}},{key:"setRegisterCallback",value:function(e){return"function"!=typeof e?(this.logger.info("setRegisterCallback() requires a valid callback function"),!1):(this.registerCallback=e,!0)}},{key:"setNotificationCallback",value:function(e){return"function"!=typeof e?(this.logger.info("setNotificationCallback() requires a valid callback function"),!1):(this.notificationCallback=e,!0)}},{key:"setErrorCallback",value:function(e){return"function"!=typeof e?(this.logger.info("setErrorCallback() requires a valid callback function"),!1):(this.errorCallback=e,!0)}},{key:"_debugRegistrationCallback",value:function(){function e(e){t.token=new h.PushToken(e.registrationId),t.logger.info("(debug) device token registered: "+t._token)}var t=this;return e}},{key:"_debugNotificationCallback",value:function(){function e(e){t._processNotification(e);var n=g.PushMessage.fromPluginJSON(e);t.logger.info("(debug) notification received: "+n),!t.notificationCallback&&t.app.devPush&&alert(n.text)}var t=this;return e}},{key:"_debugErrorCallback",value:function(){function e(e){t.logger.error("(debug) unexpected error occured."),t.logger.error(e)}var t=this;return e}},{key:"_registerCallback",value:function(){function e(e){return t.token=new h.PushToken(e.registrationId),t.registerCallback?t.registerCallback(t._token):void 0}var t=this;return e}},{key:"_notificationCallback",value:function(){function e(e){t._processNotification(e);var n=g.PushMessage.fromPluginJSON(e);return t.notificationCallback?t.notificationCallback(n):void 0}var t=this;return e}},{key:"_errorCallback",value:function(){function e(e){return t.errorCallback?t.errorCallback(e):void 0}var t=this;return e}},{key:"_debugCallbackRegistration",value:function(){this._config.debug&&(this.app.devPush?this._registered||(this._emitter.on("ionic_push:token",this._debugRegistrationCallback()),this._emitter.on("ionic_push:notification",this._debugNotificationCallback()),this._emitter.on("ionic_push:error",this._debugErrorCallback())):(this._plugin.on("registration",this._debugRegistrationCallback()),this._plugin.on("notification",this._debugNotificationCallback()),this._plugin.on("error",this._debugErrorCallback())))}},{key:"_callbackRegistration",value:function(){this.app.devPush?this._registered||(this._emitter.on("ionic_push:token",this._registerCallback()),this._emitter.on("ionic_push:notification",this._notificationCallback()),this._emitter.on("ionic_push:error",this._errorCallback())):(this._plugin.on("registration",this._registerCallback()),this._plugin.on("notification",this._notificationCallback()),this._plugin.on("error",this._errorCallback()))}},{key:"_processNotification",value:function(e){this._notification=e,this._emitter.emit("ionic_push:processNotification",e)}},{key:"_getPushPlugin",value:function(){var e=this,t=!1;try{t=window.PushNotification}catch(n){e.logger.info("something went wrong looking for the PushNotification plugin")}return e.app.devPush||t||!s.IonicPlatform.isIOSDevice()&&!s.IonicPlatform.isAndroidDevice()||e.logger.error("PushNotification plugin is required. Have you run `ionic plugin add phonegap-plugin-push` ?"),t}},{key:"getPushPlugin",value:function(){return this._plugin}},{key:"onReady",value:function(e){var t=this;this._isReady?e(t):t._emitter.on("ionic_push:ready",function(){e(t)})}},{key:"token",set:function(e){var t=s.IonicPlatform.getStorage();e instanceof h.PushToken&&t.storeObject("ionic_io_push_token",{token:e.token}),this._token=e}}]),e}();n.Push=k},{"../core/app":14,"../core/core":15,"../core/events":18,"../core/logger":19,"../core/promise":20,"../core/request":21,"../core/settings":22,"../core/user":24,"./push-dev":30,"./push-message":31,"./push-token":32}],34:[function(e,t,n){"use strict";function r(e){e=e||{};for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n)for(var i in n)n.hasOwnProperty(i)&&("object"==typeof n[i]?e[i]=r(e[i],n[i]):e[i]=n[i])}return e}Object.defineProperty(n,"__esModule",{value:!0}),n.deepExtend=r},{}]},{},[20,21,18,19,23,22,16,15,24,14,17,13,11,12,10,32,31,30,33,29,28,26,27,25,9,8,5,7,6]);