{"version":3,"names":[],"mappings":"","sources":["firebase-storage.js"],"sourcesContent":["try{webpackJsonp([0],[function(e,t,n){\"use strict\";function r(e){return null!=e}function a(e){return void 0!==e}function o(e){return\"function\"==typeof e}function i(e){return\"object\"===(void 0===e?\"undefined\":h(e))}function u(e){return i(e)&&null!==e}function s(e){return i(e)&&!Array.isArray(e)}function l(e){return\"string\"==typeof e||e instanceof String}function c(e){return\"number\"==typeof e||e instanceof Number}function f(e){return d()&&e instanceof Blob}function d(){return\"undefined\"!=typeof Blob}Object.defineProperty(t,\"__esModule\",{value:!0});var h=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e};t.isDef=r,t.isJustDef=a,t.isFunction=o,t.isObject=i,t.isNonNullObject=u,t.isNonArrayObject=s,t.isString=l,t.isNumber=c,t.isNativeBlob=f,t.isNativeBlobDefined=d},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 a(e){return\"storage/\"+e}function o(){return new C(A.UNKNOWN,\"An unknown error occurred, please check the error payload for server response.\")}function i(e){return new C(A.OBJECT_NOT_FOUND,\"Object '\"+e+\"' does not exist.\")}function u(e){return new C(A.BUCKET_NOT_FOUND,\"Bucket '\"+e+\"' does not exist.\")}function s(e){return new C(A.PROJECT_NOT_FOUND,\"Project '\"+e+\"' does not exist.\")}function l(e){return new C(A.QUOTA_EXCEEDED,\"Quota for bucket '\"+e+\"' exceeded, please view quota on https://firebase.google.com/pricing/.\")}function c(){return new C(A.UNAUTHENTICATED,\"User is not authenticated, please authenticate using Firebase Authentication and try again.\")}function f(e){return new C(A.UNAUTHORIZED,\"User does not have permission to access '\"+e+\"'.\")}function d(){return new C(A.RETRY_LIMIT_EXCEEDED,\"Max retry time for operation exceeded, please try again.\")}function h(e,t,n){return new C(A.INVALID_CHECKSUM,\"Uploaded/downloaded object '\"+e+\"' has checksum '\"+t+\"' which does not match '\"+n+\"'. Please retry the upload/download.\")}function p(){return new C(A.CANCELED,\"User canceled the upload/download.\")}function v(e){return new C(A.INVALID_EVENT_NAME,\"Invalid event name '\"+e+\"'.\")}function _(e){return new C(A.INVALID_URL,\"Invalid URL '\"+e+\"'.\")}function y(e){return new C(A.INVALID_DEFAULT_BUCKET,\"Invalid default bucket '\"+e+\"'.\")}function b(){return new C(A.NO_DEFAULT_BUCKET,\"No default bucket found. Did you set the '\"+N.configOption+\"' property when initializing the app?\")}function m(){return new C(A.CANNOT_SLICE_BLOB,\"Cannot slice blob for upload. Please retry the upload.\")}function k(){return new C(A.SERVER_FILE_WRONG_SIZE,\"Server recorded incorrect upload file size, please retry the upload.\")}function g(){return new C(A.NO_DOWNLOAD_URL,\"The given file does not have any download URLs.\")}function R(e,t,n){return new C(A.INVALID_ARGUMENT,\"Invalid argument in `\"+t+\"` at index \"+e+\": \"+n)}function w(e,t,n,r){var a=void 0,o=void 0;return e===t?(a=e,o=1===e?\"argument\":\"arguments\"):(a=\"between \"+e+\" and \"+t,o=\"arguments\"),new C(A.INVALID_ARGUMENT_COUNT,\"Invalid argument count in `\"+n+\"`: Expected \"+a+\" \"+o+\", received \"+r+\".\")}function S(){return new C(A.APP_DELETED,\"The Firebase app was deleted.\")}function E(e){return new C(A.INVALID_ROOT_OPERATION,\"The operation '\"+e+\"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').\")}function T(e,t){return new C(A.INVALID_FORMAT,\"String does not match format '\"+e+\"': \"+t)}function O(e){throw new C(A.INTERNAL_ERROR,\"Internal error: \"+e)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.Code=t.errors=t.FirebaseStorageError=void 0;var U=function(){function e(e,t){for(var n=0;n>6,128|63&r);else if(55296==(64512&r)){var a=n>18,128|r>>12&63,128|r>>6&63,128|63&r)}else t.push(239,191,189)}else 56320==(64512&r)?t.push(239,191,189):t.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(t)}function u(e){var t=void 0;try{t=decodeURIComponent(e)}catch(e){throw h.invalidFormat(p.DATA_URL,\"Malformed data URL.\")}return i(t)}function s(e,t){switch(e){case p.BASE64:var n=-1!==t.indexOf(\"-\"),r=-1!==t.indexOf(\"_\");if(n||r){var a=n?\"-\":\"_\";throw h.invalidFormat(e,\"Invalid character '\"+a+\"' found: is it base64url encoded?\")}break;case p.BASE64URL:var o=-1!==t.indexOf(\"+\"),i=-1!==t.indexOf(\"/\");if(o||i){var u=o?\"+\":\"/\";throw h.invalidFormat(e,\"Invalid character '\"+u+\"' found: is it base64 encoded?\")}t=t.replace(/-/g,\"+\").replace(/_/g,\"/\")}var s=void 0;try{s=atob(t)}catch(t){throw h.invalidFormat(e,\"Invalid character found\")}for(var l=new Uint8Array(s.length),c=0;c=t.length)&&e.substring(e.length-t.length)===t}Object.defineProperty(t,\"__esModule\",{value:!0}),t.StringData=t.StringFormat=void 0,t.formatValidator=a,t.dataFromString=o,t.utf8Bytes_=i,t.percentEncodedBytes_=u,t.base64Bytes_=s,t.dataURLBytes_=l,t.dataURLContentType_=c;var d=n(1),h=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(d),p=t.StringFormat={RAW:\"raw\",BASE64:\"base64\",BASE64URL:\"base64url\",DATA_URL:\"data_url\"},v=t.StringData=function e(t,n){r(this,e),this.data=t,this.contentType=n||null},_=function e(t){r(this,e),this.base64=!1,this.contentType=null;var n=t.match(/^data:([^,]+)?,/);if(null===n)throw h.invalidFormat(p.DATA_URL,\"Must be formatted 'data:[][;base64],\");var a=n[1]||null;null!=a&&(this.base64=f(a,\";base64\"),this.contentType=this.base64?a.substring(0,a.length-\";base64\".length):a),this.rest=t.substring(t.indexOf(\",\")+1)}},,,function(e,t,n){\"use strict\";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function a(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function o(e,t,n){for(var r=t.length,a=t.length,o=0;o=0))throw\"Expected a number 0 or greater.\"})}function f(e,t){return new m(function(t){if(!(null===t||b.isDef(t)&&t instanceof Object))throw\"Expected an Object.\";void 0!==e&&null!==e&&e(t)},t)}function d(e){return new m(function(e){if(null!==e&&!b.isFunction(e))throw\"Expected a Function.\"},e)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.ArgSpec=void 0,t.validate=o,t.and_=i,t.stringSpec=u,t.uploadDataSpec=s,t.metadataSpec=l,t.nonNegativeNumberSpec=c,t.looseObjectSpec=f,t.nullFunctionSpec=d;var h=n(1),p=r(h),v=n(13),_=r(v),y=n(0),b=r(y),m=t.ArgSpec=function e(t,n){a(this,e);var r=this;this.validator=function(e){r.optional&&!b.isJustDef(e)||t(e)},this.optional=!!n}},function(e,t,n){\"use strict\";function r(e,t){return-1!==e.indexOf(t)}function a(e){return Array.prototype.slice.call(e)}function o(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.contains=r,t.clone=a,t.remove=o},function(e,t,n){\"use strict\";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function a(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function o(e,t){return t}function i(e){return!m.isString(e)||e.length<2?e:(e=e,y.lastComponent(e))}function u(){if(w)return w;var e=[];e.push(new R(\"bucket\")),e.push(new R(\"generation\")),e.push(new R(\"metageneration\")),e.push(new R(\"name\",\"fullPath\",!0));var t=new R(\"name\");t.xform=function(e,t){return i(t)},e.push(t);var n=new R(\"size\");return n.xform=function(e,t){return m.isDef(t)?+t:t},e.push(n),e.push(new R(\"timeCreated\")),e.push(new R(\"updated\")),e.push(new R(\"md5Hash\",null,!0)),e.push(new R(\"cacheControl\",null,!0)),e.push(new R(\"contentDisposition\",null,!0)),e.push(new R(\"contentEncoding\",null,!0)),e.push(new R(\"contentLanguage\",null,!0)),e.push(new R(\"contentType\",null,!0)),e.push(new R(\"metadata\",\"customMetadata\",!0)),e.push(new R(\"downloadTokens\",\"downloadURLs\",!1,function(e,t){if(!(m.isString(t)&&t.length>0))return[];var n=encodeURIComponent;return t.split(\",\").map(function(t){var r=e.bucket,a=e.fullPath,o=\"/b/\"+n(r)+\"/o/\"+n(a);return g.makeDownloadUrl(o)+g.makeQueryString({alt:\"media\",token:t})})})),w=e}function s(e,t){Object.defineProperty(e,\"ref\",{get:function(){var n=e.bucket,r=e.fullPath,a=new v.Location(n,r);return t.makeStorageReference(a)}})}function l(e,t,n){var r={};r.type=\"file\";for(var a=n.length,o=0;o1&&void 0!==arguments[1]?arguments[1]:null;return u.validate(\"put\",[u.uploadDataSpec(),u.metadataSpec(!0)],arguments),this.throwIfRoot_(\"put\"),new S.UploadTask(this,this.authWrapper,this.location,this.mappings(),new s.FbsBlob(e),t)}},{key:\"putString\",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.StringFormat.RAW,n=arguments[2];u.validate(\"putString\",[u.stringSpec(),u.stringSpec(g.formatValidator,!0),u.metadataSpec(!0)],arguments),this.throwIfRoot_(\"putString\");var r=g.dataFromString(t,e),a=v.clone(n);return!w.isDef(a.contentType)&&w.isDef(r.contentType)&&(a.contentType=r.contentType),new S.UploadTask(this,this.authWrapper,this.location,this.mappings(),new s.FbsBlob(r.data,!0),a)}},{key:\"delete\",value:function(){u.validate(\"delete\",[],arguments),this.throwIfRoot_(\"delete\");var e=this;return this.authWrapper.getAuthToken().then(function(t){var n=m.deleteObject(e.authWrapper,e.location);return e.authWrapper.makeRequest(n,t).getPromise()})}},{key:\"getMetadata\",value:function(){u.validate(\"getMetadata\",[],arguments),this.throwIfRoot_(\"getMetadata\");var e=this;return this.authWrapper.getAuthToken().then(function(t){var n=m.getMetadata(e.authWrapper,e.location,e.mappings());return e.authWrapper.makeRequest(n,t).getPromise()})}},{key:\"updateMetadata\",value:function(e){u.validate(\"updateMetadata\",[u.metadataSpec()],arguments),this.throwIfRoot_(\"updateMetadata\");var t=this;return this.authWrapper.getAuthToken().then(function(n){var r=m.updateMetadata(t.authWrapper,t.location,e,t.mappings());return t.authWrapper.makeRequest(r,n).getPromise()})}},{key:\"getDownloadURL\",value:function(){return u.validate(\"getDownloadURL\",[],arguments),this.throwIfRoot_(\"getDownloadURL\"),this.getMetadata().then(function(e){var t=e.downloadURLs[0];if(w.isDef(t))return t;throw c.noDownloadURL()})}},{key:\"throwIfRoot_\",value:function(e){if(\"\"===this.location.path)throw c.invalidRootOperation(e)}},{key:\"parent\",get:function(){var e=y.parent(this.location.path);if(null===e)return null;var t=new f.Location(this.location.bucket,e);return this.newRef(this.authWrapper,t)}},{key:\"root\",get:function(){var e=new f.Location(this.location.bucket,\"\");return this.newRef(this.authWrapper,e)}},{key:\"bucket\",get:function(){return this.location.bucket}},{key:\"fullPath\",get:function(){return this.location.path}},{key:\"name\",get:function(){return y.lastComponent(this.location.path)}},{key:\"storage\",get:function(){return this.authWrapper.service()}}]),e}()},,,,,,function(e,t,n){\"use strict\";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function a(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}Object.defineProperty(t,\"__esModule\",{value:!0}),t.FbsBlob=void 0;var o=function(){function e(e,t){for(var n=0;n0}).join(\"/\");return 0===e.length?n:e+\"/\"+n}function o(e){var t=e.lastIndexOf(\"/\",e.length-2);return-1===t?e:e.slice(t+1)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.parent=r,t.child=a,t.lastComponent=o},function(e,t,n){\"use strict\";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function a(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function o(e){if(!e)throw w.unknown()}function i(e,t){return function(n,r){var a=E.fromResourceString(e,r,t);return o(null!==a),a}}function u(e){return function(t,n){var r=void 0;return r=401===t.getStatus()?w.unauthenticated():402===t.getStatus()?w.quotaExceeded(e.bucket):403===t.getStatus()?w.unauthorized(e.path):n,r.setServerResponseProp(n.serverResponseProp()),r}}function s(e){var t=u(e);return function(n,r){var a=t(n,r);return 404===n.getStatus()&&(a=w.objectNotFound(e.path)),a.setServerResponseProp(r.serverResponseProp()),a}}function l(e,t,n){var r=t.fullServerUrl(),a=I.makeNormalUrl(r),o=e.maxOperationRetryTime(),u=new U.RequestInfo(a,\"GET\",i(e,n),o);return u.errorHandler=s(t),u}function c(e,t,n,r){var a=t.fullServerUrl(),o=I.makeNormalUrl(a),u=E.toResourceString(n,r),l=e.maxOperationRetryTime(),c=new U.RequestInfo(o,\"PATCH\",i(e,r),l);return c.headers={\"Content-Type\":\"application/json; charset=utf-8\"},c.body=u,c.errorHandler=s(t),c}function f(e,t){var n=t.fullServerUrl(),r=I.makeNormalUrl(n),a=e.maxOperationRetryTime(),o=new U.RequestInfo(r,\"DELETE\",function(){},a);return o.successCodes=[200,204],o.errorHandler=s(t),o}function d(e,t){return e&&e.contentType||t&&t.type()||\"application/octet-stream\"}function h(e,t,n){var r=O.clone(n);return r.fullPath=e.path,r.size=t.size(),r.contentType||(r.contentType=d(null,t)),r}function p(e,t,n,r,a){var o=t.bucketOnlyServerUrl(),s={\"X-Goog-Upload-Protocol\":\"multipart\"},l=function(){for(var e=\"\",t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}();s[\"Content-Type\"]=\"multipart/related; boundary=\"+l;var c=h(t,r,a),f=E.toResourceString(c,n),d=\"--\"+l+\"\\r\\nContent-Type: application/json; charset=utf-8\\r\\n\\r\\n\"+f+\"\\r\\n--\"+l+\"\\r\\nContent-Type: \"+c.contentType+\"\\r\\n\\r\\n\",p=g.FbsBlob.getBlob(d,r,\"\\r\\n--\"+l+\"--\");if(null===p)throw w.cannotSliceBlob();var v={name:c.fullPath},_=I.makeUploadUrl(o),y=e.maxUploadRetryTime(),b=new U.RequestInfo(_,\"POST\",i(e,n),y);return b.urlParams=v,b.headers=s,b.body=p.uploadData(),b.errorHandler=u(t),b}function v(e,t){var n=void 0;try{n=e.getResponseHeader(\"X-Goog-Upload-Status\")}catch(e){o(!1)}return o(k.contains(t||[\"active\"],n)),n}function _(e,t,n,r,a){var i=t.bucketOnlyServerUrl(),s=h(t,r,a),l={name:s.fullPath},c=I.makeUploadUrl(i),f={\"X-Goog-Upload-Protocol\":\"resumable\",\"X-Goog-Upload-Command\":\"start\",\"X-Goog-Upload-Header-Content-Length\":r.size(),\"X-Goog-Upload-Header-Content-Type\":s.contentType,\"Content-Type\":\"application/json; charset=utf-8\"},d=E.toResourceString(s,n),p=e.maxUploadRetryTime(),_=new U.RequestInfo(c,\"POST\",function(e){v(e);var t=void 0;try{t=e.getResponseHeader(\"X-Goog-Upload-URL\")}catch(e){o(!1)}return o(C.isString(t)),t},p);return _.urlParams=l,_.headers=f,_.body=d,_.errorHandler=u(t),_}function y(e,t,n,r){var a=e.maxUploadRetryTime(),i=new U.RequestInfo(n,\"POST\",function(e){var t=v(e,[\"active\",\"final\"]),n=void 0;try{n=e.getResponseHeader(\"X-Goog-Upload-Size-Received\")}catch(e){o(!1)}var a=parseInt(n,10);return o(!isNaN(a)),new P(a,r.size(),\"final\"===t)},a);return i.headers={\"X-Goog-Upload-Command\":\"query\"},i.errorHandler=u(t),i}function b(e,t,n,r,a,o,s,l){var c=new P(0,0);if(s?(c.current=s.current,c.total=s.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw w.serverFileWrongSize();var f=c.total-c.current,d=f;a>0&&(d=Math.min(d,a));var h=c.current,p=h+d,_=d===f?\"upload, finalize\":\"upload\",y={\"X-Goog-Upload-Command\":_,\"X-Goog-Upload-Offset\":c.current},b=r.slice(h,p);if(null===b)throw w.cannotSliceBlob();var m=t.maxUploadRetryTime(),k=new U.RequestInfo(n,\"POST\",function(e,n){var a=v(e,[\"active\",\"final\"]),u=c.current+d,s=r.size(),l=void 0;return l=\"final\"===a?i(t,o)(e,n):null,new P(u,s,\"final\"===a,l)},m);return k.headers=y,k.body=b.uploadData(),k.progressCallback=l||null,k.errorHandler=u(e),k}Object.defineProperty(t,\"__esModule\",{value:!0}),t.resumableUploadChunkSize=t.ResumableUploadStatus=void 0,t.handlerCheck=o,t.metadataHandler=i,t.sharedErrorHandler=u,t.objectErrorHandler=s,t.getMetadata=l,t.updateMetadata=c,t.deleteObject=f,t.determineContentType_=d,t.metadataForUpload_=h,t.multipartUpload=p,t.checkResumeHeader_=v,t.createResumableUpload=_,t.getResumableUploadStatus=y,t.continueResumableUpload=b;var m=n(12),k=r(m),g=n(22),R=n(1),w=r(R),S=n(13),E=r(S),T=n(3),O=r(T),U=n(46),N=n(0),C=r(N),A=n(14),I=r(A),P=t.ResumableUploadStatus=function e(t,n,r,o){a(this,e),this.current=t,this.total=n,this.finalized=!!r,this.metadata=o||null};t.resumableUploadChunkSize=262144},function(e,t,n){\"use strict\";Object.defineProperty(t,\"__esModule\",{value:!0});var r=t.ErrorCode=void 0;!function(e){e[e.NO_ERROR=0]=\"NO_ERROR\",e[e.NETWORK_ERROR=1]=\"NETWORK_ERROR\",e[e.ABORT=2]=\"ABORT\"}(r||(t.ErrorCode=r={}))},,,,,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(t,\"__esModule\",{value:!0}),t.XhrIoPool=void 0;var a=function(){function e(e,t){for(var n=0;n1?t-1:0),i=1;i0&&void 0!==arguments[0]&&arguments[0]}}]),e}()},function(e,t,n){\"use strict\";function r(){return\"undefined\"!=typeof BlobBuilder?BlobBuilder:\"undefined\"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function a(){for(var e=r(),t=arguments.length,n=Array(t),a=0;a0&&(e.Authorization=\"Firebase \"+t)}function i(e){var t=\"undefined\"!=typeof firebase?firebase.SDK_VERSION:\"AppManager\";e[\"X-Firebase-Storage-Version\"]=\"webjs/\"+t}function u(e,t,n){var r=R.makeQueryString(e.urlParams),a=e.url+r,u=_.clone(e.headers);return o(u,t),i(u),new E(a,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,n)}Object.defineProperty(t,\"__esModule\",{value:!0}),t.RequestEndStatus=void 0;var s=function(){function e(e,t){for(var n=0;n=500&&e<600||t||n}}]),e}(),T=t.RequestEndStatus=function e(t,n,r){a(this,e),this.wasSuccessCode=t,this.xhr=n,this.canceled=!!r}},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(t,\"__esModule\",{value:!0});t.RequestInfo=function e(t,n,a,o){r(this,e),this.url=t,this.method=n,this.handler=a,this.timeout=o,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}},function(e,t,n){\"use strict\";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function a(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}Object.defineProperty(t,\"__esModule\",{value:!0}),t.RequestMap=void 0;var o=function(){function e(e,t){for(var n=0;n5&&void 0!==arguments[5]?arguments[5]:null;a(this,e),this.transferred_=0,this.needToFetchStatus_=!1,this.needToFetchMetadata_=!1,this.observers_=[],this.error_=null,this.uploadUrl_=null,this.request_=null,this.chunkMultiplier_=1,this.resolve_=null,this.reject_=null,this.ref_=t,this.authWrapper_=n,this.location_=r,this.blob_=u,this.metadata_=l,this.mappings_=o,this.resumable_=this.shouldDoResumable_(this.blob_),this.state_=i.InternalTaskState.RUNNING,this.errorHandler_=function(e){s.request_=null,s.chunkMultiplier_=1,e.codeEquals(_.Code.CANCELED)?(s.needToFetchStatus_=!0,s.completeTransitions_()):(s.error_=e,s.transition_(i.InternalTaskState.ERROR))},this.metadataErrorHandler_=function(e){s.request_=null,e.codeEquals(_.Code.CANCELED)?s.completeTransitions_():(s.error_=e,s.transition_(i.InternalTaskState.ERROR))},this.promise_=b.make(function(e,t){s.resolve_=e,s.reject_=t,s.start_()}),this.promise_.then(null,function(){})}return o(e,[{key:\"makeProgressCallback_\",value:function(){var e=this,t=this.transferred_;return function(n){e.updateProgress_(t+n)}}},{key:\"shouldDoResumable_\",value:function(e){return e.size()>262144}},{key:\"start_\",value:function(){this.state_===i.InternalTaskState.RUNNING&&null===this.request_&&(this.resumable_?null===this.uploadUrl_?this.createResumable_():this.needToFetchStatus_?this.fetchStatus_():this.needToFetchMetadata_?this.fetchMetadata_():this.continueUpload_():this.oneShotUpload_())}},{key:\"resolveToken_\",value:function(e){var t=this;this.authWrapper_.getAuthToken().then(function(n){switch(t.state_){case i.InternalTaskState.RUNNING:e(n);break;case i.InternalTaskState.CANCELING:t.transition_(i.InternalTaskState.CANCELED);break;case i.InternalTaskState.PAUSING:t.transition_(i.InternalTaskState.PAUSED)}})}},{key:\"createResumable_\",value:function(){var e=this;this.resolveToken_(function(t){var n=k.createResumableUpload(e.authWrapper_,e.location_,e.mappings_,e.blob_,e.metadata_),r=e.authWrapper_.makeRequest(n,t);e.request_=r,r.getPromise().then(function(t){e.request_=null,e.uploadUrl_=t,e.needToFetchStatus_=!1,e.completeTransitions_()},e.errorHandler_)})}},{key:\"fetchStatus_\",value:function(){var e=this,t=this.uploadUrl_;this.resolveToken_(function(n){var r=k.getResumableUploadStatus(e.authWrapper_,e.location_,t,e.blob_),a=e.authWrapper_.makeRequest(r,n);e.request_=a,a.getPromise().then(function(t){t=t,e.request_=null,e.updateProgress_(t.current),e.needToFetchStatus_=!1,t.finalized&&(e.needToFetchMetadata_=!0),e.completeTransitions_()},e.errorHandler_)})}},{key:\"continueUpload_\",value:function(){var e=this,t=k.resumableUploadChunkSize*this.chunkMultiplier_,n=new k.ResumableUploadStatus(this.transferred_,this.blob_.size()),r=this.uploadUrl_;this.resolveToken_(function(a){var o=void 0;try{o=k.continueResumableUpload(e.location_,e.authWrapper_,r,e.blob_,t,e.mappings_,n,e.makeProgressCallback_())}catch(t){return e.error_=t,void e.transition_(i.InternalTaskState.ERROR)}var u=e.authWrapper_.makeRequest(o,a);e.request_=u,u.getPromise().then(function(t){e.increaseMultiplier_(),e.request_=null,e.updateProgress_(t.current),t.finalized?(e.metadata_=t.metadata,e.transition_(i.InternalTaskState.SUCCESS)):e.completeTransitions_()},e.errorHandler_)})}},{key:\"increaseMultiplier_\",value:function(){k.resumableUploadChunkSize*this.chunkMultiplier_<33554432&&(this.chunkMultiplier_*=2)}},{key:\"fetchMetadata_\",value:function(){var e=this;this.resolveToken_(function(t){var n=k.getMetadata(e.authWrapper_,e.location_,e.mappings_),r=e.authWrapper_.makeRequest(n,t);e.request_=r,r.getPromise().then(function(t){e.request_=null,e.metadata_=t,e.transition_(i.InternalTaskState.SUCCESS)},e.metadataErrorHandler_)})}},{key:\"oneShotUpload_\",value:function(){var e=this;this.resolveToken_(function(t){var n=k.multipartUpload(e.authWrapper_,e.location_,e.mappings_,e.blob_,e.metadata_),r=e.authWrapper_.makeRequest(n,t);e.request_=r,r.getPromise().then(function(t){e.request_=null,e.metadata_=t,e.updateProgress_(e.blob_.size()),e.transition_(i.InternalTaskState.SUCCESS)},e.errorHandler_)})}},{key:\"updateProgress_\",value:function(e){var t=this.transferred_;this.transferred_=e,this.transferred_!==t&&this.notifyObservers_()}},{key:\"transition_\",value:function(e){if(this.state_!==e)switch(e){case i.InternalTaskState.CANCELING:case i.InternalTaskState.PAUSING:this.state_=e,null!==this.request_&&this.request_.cancel();break;case i.InternalTaskState.RUNNING:var t=this.state_===i.InternalTaskState.PAUSED;this.state_=e,t&&(this.notifyObservers_(),this.start_());break;case i.InternalTaskState.PAUSED:this.state_=e,this.notifyObservers_();break;case i.InternalTaskState.CANCELED:this.error_=_.canceled(),this.state_=e,this.notifyObservers_();break;case i.InternalTaskState.ERROR:case i.InternalTaskState.SUCCESS:this.state_=e,this.notifyObservers_()}}},{key:\"completeTransitions_\",value:function(){switch(this.state_){case i.InternalTaskState.PAUSING:this.transition_(i.InternalTaskState.PAUSED);break;case i.InternalTaskState.CANCELING:this.transition_(i.InternalTaskState.CANCELED);break;case i.InternalTaskState.RUNNING:this.start_()}}},{key:\"on\",value:function(e){function t(e){try{return void l(e)}catch(e){}try{c(e);if(!(R.isJustDef(e.next)||R.isJustDef(e.error)||R.isJustDef(e.complete)))throw\"\"}catch(e){throw u}}function n(e){return function(t,n){null!==e&&f.validate(\"on\",e,arguments);var r=new s.Observer(t,n,o);return h.addObserver_(r),function(){h.removeObserver_(r)}}}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,u=\"Expected a function or an Object with one of `next`, `error`, `complete` properties.\",l=f.nullFunctionSpec(!0).validator,c=f.looseObjectSpec(null,!0).validator,d=[f.stringSpec(function(){if(e!==i.TaskEvent.STATE_CHANGED)throw\"Expected one of the event types: [\"+i.TaskEvent.STATE_CHANGED+\"].\"}),f.looseObjectSpec(t,!0),f.nullFunctionSpec(!0),f.nullFunctionSpec(!0)];f.validate(\"on\",d,arguments);var h=this,p=[f.looseObjectSpec(function(e){if(null===e)throw u;t(e)}),f.nullFunctionSpec(!0),f.nullFunctionSpec(!0)];return R.isJustDef(r)||R.isJustDef(a)||R.isJustDef(o)?n(null)(r,a,o):n(p)}},{key:\"then\",value:function(e,t){return this.promise_.then(e,t)}},{key:\"catch\",value:function(e){return this.then(null,e)}},{key:\"addObserver_\",value:function(e){this.observers_.push(e),this.notifyObserver_(e)}},{key:\"removeObserver_\",value:function(e){h.remove(this.observers_,e)}},{key:\"notifyObservers_\",value:function(){var e=this;this.finishPromise_(),h.clone(this.observers_).forEach(function(t){e.notifyObserver_(t)})}},{key:\"finishPromise_\",value:function(){if(null!==this.resolve_){var e=!0;switch(u.taskStateFromInternalTaskState(this.state_)){case i.TaskState.SUCCESS:(0,p.async)(this.resolve_.bind(null,this.snapshot))();break;case i.TaskState.CANCELED:case i.TaskState.ERROR:var t=this.reject_;(0,p.async)(t.bind(null,this.error_))();break;default:e=!1}e&&(this.resolve_=null,this.reject_=null)}}},{key:\"notifyObserver_\",value:function(e){switch(u.taskStateFromInternalTaskState(this.state_)){case i.TaskState.RUNNING:case i.TaskState.PAUSED:null!==e.next&&(0,p.async)(e.next.bind(e,this.snapshot))();break;case i.TaskState.SUCCESS:null!==e.complete&&(0,p.async)(e.complete.bind(e))();break;case i.TaskState.CANCELED:case i.TaskState.ERROR:null!==e.error&&(0,p.async)(e.error.bind(e,this.error_))();break;default:null!==e.error&&(0,p.async)(e.error.bind(e,this.error_))()}}},{key:\"resume\",value:function(){f.validate(\"resume\",[],arguments);var e=this.state_===i.InternalTaskState.PAUSED||this.state_===i.InternalTaskState.PAUSING;return e&&this.transition_(i.InternalTaskState.RUNNING),e}},{key:\"pause\",value:function(){f.validate(\"pause\",[],arguments);var e=this.state_===i.InternalTaskState.RUNNING;return e&&this.transition_(i.InternalTaskState.PAUSING),e}},{key:\"cancel\",value:function(){f.validate(\"cancel\",[],arguments);var e=this.state_===i.InternalTaskState.RUNNING||this.state_===i.InternalTaskState.PAUSING;return e&&this.transition_(i.InternalTaskState.CANCELING),e}},{key:\"snapshot\",get:function(){var e=u.taskStateFromInternalTaskState(this.state_);return new l.UploadTaskSnapshot(this.transferred_,this.blob_.size(),e,this.metadata_,this,this.ref_)}}]),e}()},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(t,\"__esModule\",{value:!0});var a=function(){function e(e,t){for(var n=0;n