import{F as t,g as n,a as e,_ as r,b as i,C as s,r as o,S as u}from"./p-18355b65.js";
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */const c="firebasestorage.googleapis.com",a="storageBucket";
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class l extends t{constructor(t,n){super(h(t),`Firebase Storage: ${n} (${h(t)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,l.prototype)}_codeEquals(t){return h(t)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(t){this.customData.serverResponse=t,this.message=this.customData.serverResponse?`${this._baseMessage}\n${this.customData.serverResponse}`:this._baseMessage}}function h(t){return"storage/"+t}function f(){return new l("unknown","An unknown error occurred, please check the error payload for server response.")}function d(t){return new l("invalid-argument",t)}function w(){return new l("app-deleted","The Firebase app was deleted.")}function p(t,n){return new l("invalid-format","String does not match format '"+t+"': "+n)}function g(t){throw new l("internal-error","Internal error: "+t)}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class m{constructor(t,n){this.bucket=t,this.path_=n}get path(){return this.path_}get isRoot(){return 0===this.path.length}fullServerUrl(){const t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(t,n){let e;try{e=m.makeFromUrl(t,n)}catch(n){return new m(t,"")}if(""===e.path)return e;throw new l("invalid-default-bucket","Invalid default bucket '"+t+"'.")}static makeFromUrl(t,n){let e=null;const r="([A-Za-z0-9.\\-_]+)",i=new RegExp("^gs://"+r+"(/(.*))?$","i");function s(t){t.path_=decodeURIComponent(t.path)}const o=n.replace(/[.]/g,"\\."),u=[{regex:i,indices:{bucket:1,path:3},postModify:function(t){"/"===t.path.charAt(t.path.length-1)&&(t.path_=t.path_.slice(0,-1))}},{regex:new RegExp(`^https?://${o}/v[A-Za-z0-9_]+/b/${r}/o(/([^?#]*).*)?$`,"i"),indices:{bucket:1,path:3},postModify:s},{regex:new RegExp(`^https?://${n===c?"(?:storage.googleapis.com|storage.cloud.google.com)":n}/${r}/([^?#]*)`,"i"),indices:{bucket:1,path:2},postModify:s}];for(let n=0;n<u.length;n++){const r=u[n],i=r.regex.exec(t);if(i){let t=i[r.indices.path];t||(t=""),e=new m(i[r.indices.bucket],t),r.postModify(e);break}}if(null==e)throw function(t){return new l("invalid-url","Invalid URL '"+t+"'.")}(t);return e}}class b{constructor(t){this.promise_=Promise.reject(t)}getPromise(){return this.promise_}cancel(t=!1){}}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function y(t){return"string"==typeof t||t instanceof String}function v(t){return R()&&t instanceof Blob}function R(){return"undefined"!=typeof Blob}function k(t,n,e,r){if(r<n)throw d(`Invalid value for '${t}'. Expected ${n} or greater.`);if(r>e)throw d(`Invalid value for '${t}'. Expected ${e} or less.`)}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function U(t,n,e){let r=n;return null==e&&(r=`https://${n}`),`${e}://${r}/v0${t}`}function T(t){const n=encodeURIComponent;let e="?";for(const r in t)t.hasOwnProperty(r)&&(e=e+(n(r)+"=")+n(t[r])+"&");return e=e.slice(0,-1),e}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var x;!function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"}(x||(x={}));
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class A{constructor(t,n,e,r,i,s,o,u,c,a,l){this.url_=t,this.method_=n,this.headers_=e,this.body_=r,this.successCodes_=i,this.additionalRetryCodes_=s,this.callback_=o,this.errorCallback_=u,this.timeout_=c,this.progressCallback_=a,this.connectionFactory_=l,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise(((t,n)=>{this.resolve_=t,this.reject_=n,this.start_()}))}start_(){const t=(t,n)=>{const e=this.resolve_,r=this.reject_,i=n.connection;if(n.wasSuccessCode)try{const t=this.callback_(i,i.getResponse());void 0!==t?e(t):e()}catch(t){r(t)}else if(null!==i){const t=f();t.serverResponse=i.getErrorText(),r(this.errorCallback_?this.errorCallback_(i,t):t)}else r(n.canceled?this.appDelete_?w():new l("canceled","User canceled the upload/download."):new l("retry-limit-exceeded","Max retry time for operation exceeded, please try again."))};this.canceled_?t(0,new B(!1,null,!0)):this.backoffId_=function(t,n,e){let r=1,i=null,s=null,o=!1,u=0;function c(){return 2===u}let a=!1;function l(...t){a||(a=!0,n.apply(null,t))}function h(n){i=setTimeout((()=>{i=null,t(d,c())}),n)}function f(){s&&clearTimeout(s)}function d(t,...n){if(a)return void f();if(t)return f(),void l.call(null,t,...n);if(c()||o)return f(),void l.call(null,t,...n);let e;r<64&&(r*=2),1===u?(u=2,e=0):e=1e3*(r+Math.random()),h(e)}let w=!1;function p(t){w||(w=!0,f(),a||(null!==i?(t||(u=2),clearTimeout(i),h(0)):t||(u=1)))}return h(0),s=setTimeout((()=>{o=!0,p(!0)}),e),p}(((t,n)=>{if(n)return void t(!1,new B(!1,null,!0));const e=this.connectionFactory_();this.pendingConnection_=e;const r=t=>{null!==this.progressCallback_&&this.progressCallback_(t.loaded,t.lengthComputable?t.total:-1)};null!==this.progressCallback_&&e.addUploadProgressListener(r),e.send(this.url_,this.method_,this.body_,this.headers_).then((()=>{null!==this.progressCallback_&&e.removeUploadProgressListener(r),this.pendingConnection_=null;const n=e.getErrorCode()===x.NO_ERROR,i=e.getStatus();if(!n||this.isRetryStatusCode_(i)){const n=e.getErrorCode()===x.ABORT;return void t(!1,new B(!1,null,n))}const s=-1!==this.successCodes_.indexOf(i);t(!0,new B(s,e))}))}),t,this.timeout_)}getPromise(){return this.promise_}cancel(t){this.canceled_=!0,this.appDelete_=t||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingConnection_&&this.pendingConnection_.abort()}isRetryStatusCode_(t){const n=t>=500&&t<600,e=-1!==[408,429].indexOf(t),r=-1!==this.additionalRetryCodes_.indexOf(t);return n||e||r}}class B{constructor(t,n,e){this.wasSuccessCode=t,this.connection=n,this.canceled=!!e}}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function _(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function C(...t){const n=_();if(void 0!==n){const e=new n;for(let n=0;n<t.length;n++)e.append(t[n]);return e.getBlob()}if(R())return new Blob(t);throw new l("unsupported-environment","This browser doesn't seem to support creating Blobs")}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const S="base64",$="base64url",I="data_url";class O{constructor(t,n){this.data=t,this.contentType=n||null}}function E(t){const n=[];for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);r<=127?n.push(r):r<=2047?n.push(192|r>>6,128|63&r):55296==(64512&r)?e<t.length-1&&56320==(64512&t.charCodeAt(e+1))?(r=65536|(1023&r)<<10|1023&t.charCodeAt(++e),n.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)):n.push(239,191,189):56320==(64512&r)?n.push(239,191,189):n.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(n)}function P(t,n){switch(t){case S:{const e=-1!==n.indexOf("-"),r=-1!==n.indexOf("_");if(e||r)throw p(t,"Invalid character '"+(e?"-":"_")+"' found: is it base64url encoded?");break}case $:{const e=-1!==n.indexOf("+"),r=-1!==n.indexOf("/");if(e||r)throw p(t,"Invalid character '"+(e?"+":"/")+"' found: is it base64 encoded?");n=n.replace(/-/g,"+").replace(/_/g,"/");break}}let e;try{e=atob(n)}catch(n){throw p(t,"Invalid character found")}const r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}class j{constructor(t){this.base64=!1,this.contentType=null;const n=t.match(/^data:([^,]+)?,/);if(null===n)throw p(I,"Must be formatted 'data:[<mediatype>][;base64],<data>");const e=n[1]||null;var r,i;
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */null!=e&&(this.base64=(r=e).length>=(i=";base64").length&&r.substring(r.length-i.length)===i,this.contentType=this.base64?e.substring(0,e.length-";base64".length):e),this.rest=t.substring(t.indexOf(",")+1)}}class M{constructor(t,n){let e=0,r="";v(t)?(this.data_=t,e=t.size,r=t.type):t instanceof ArrayBuffer?(n?this.data_=new Uint8Array(t):(this.data_=new Uint8Array(t.byteLength),this.data_.set(new Uint8Array(t))),e=this.data_.length):t instanceof Uint8Array&&(n?this.data_=t:(this.data_=new Uint8Array(t.length),this.data_.set(t)),e=t.length),this.size_=e,this.type_=r}size(){return this.size_}type(){return this.type_}slice(t,n){if(v(this.data_)){const s=(r=t,i=n,(e=this.data_).webkitSlice?e.webkitSlice(r,i):e.mozSlice?e.mozSlice(r,i):e.slice?e.slice(r,i):null);return null===s?null:new M(s)}var e,r,i;
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */{const e=new Uint8Array(this.data_.buffer,t,n-t);return new M(e,!0)}}static getBlob(...t){if(R()){const n=t.map((t=>t instanceof M?t.data_:t));return new M(C.apply(null,n))}{const n=t.map((t=>y(t)?function(t,n){switch(t){case"raw":return new O(E(n));case S:case $:return new O(P(t,n));case I:return new O(function(t){const n=new j(t);return n.base64?P(S,n.rest):function(t){let n;try{n=decodeURIComponent(t)}catch(t){throw p(I,"Malformed data URL.")}return E(n)}(n.rest)}(n),new j(n).contentType)}throw f()}("raw",t).data:t.data_));let e=0;n.forEach((t=>{e+=t.byteLength}));const r=new Uint8Array(e);let i=0;return n.forEach((t=>{for(let n=0;n<t.length;n++)r[i++]=t[n]})),new M(r,!0)}}uploadData(){return this.data_}}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function F(t){let n;try{n=JSON.parse(t)}catch(t){return null}return"object"!=typeof(e=n)||Array.isArray(e)?null:n;var e}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function L(t){const n=t.lastIndexOf("/",t.length-2);return-1===n?t:t.slice(n+1)}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function z(t,n){return n}class N{constructor(t,n,e,r){this.server=t,this.local=n||t,this.writable=!!e,this.xform=r||z}}let q=null;function D(){if(q)return q;const t=[];t.push(new N("bucket")),t.push(new N("generation")),t.push(new N("metageneration")),t.push(new N("name","fullPath",!0));const n=new N("name");n.xform=function(t,n){return function(t){return!y(t)||t.length<2?t:L(t)}(n)},t.push(n);const e=new N("size");return e.xform=function(t,n){return void 0!==n?Number(n):n},t.push(e),t.push(new N("timeCreated")),t.push(new N("updated")),t.push(new N("md5Hash",null,!0)),t.push(new N("cacheControl",null,!0)),t.push(new N("contentDisposition",null,!0)),t.push(new N("contentEncoding",null,!0)),t.push(new N("contentLanguage",null,!0)),t.push(new N("contentType",null,!0)),t.push(new N("metadata","customMetadata",!0)),q=t,q}function W(t,n,e){const r=F(n);return null===r?null:function(t,n,e){const r={type:"file"},i=e.length;for(let t=0;t<i;t++){const i=e[t];r[i.local]=i.xform(r,n[i.server])}return function(t,n){Object.defineProperty(t,"ref",{get:function(){const e=new m(t.bucket,t.fullPath);return n._makeStorageReference(e)}})}(r,t),r}(t,r,e)}class H{constructor(t,n,e,r){this.url=t,this.method=n,this.handler=e,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */function K(t){if(!t)throw f()}function X(t){return function(n,e){let r;return r=401===n.getStatus()?n.getErrorText().includes("Firebase App Check token is invalid")?new l("unauthorized-app","This app does not have permission to access Firebase Storage on this project."):new l("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===n.getStatus()?new l("quota-exceeded","Quota for bucket '"+t.bucket+"' exceeded, please view quota on https://firebase.google.com/pricing/."):403===n.getStatus()?new l("unauthorized","User does not have permission to access '"+t.path+"'."):e,r.serverResponse=e.serverResponse,r}}class Z{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=x.NO_ERROR,this.sendPromise_=new Promise((t=>{this.xhr_.addEventListener("abort",(()=>{this.errorCode_=x.ABORT,t()})),this.xhr_.addEventListener("error",(()=>{this.errorCode_=x.NETWORK_ERROR,t()})),this.xhr_.addEventListener("load",(()=>{t()}))}))}send(t,n,e,r){if(this.sent_)throw g("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(n,t,!0),void 0!==r)for(const t in r)r.hasOwnProperty(t)&&this.xhr_.setRequestHeader(t,r[t].toString());return void 0!==e?this.xhr_.send(e):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw g("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw g("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}}getResponse(){if(!this.sent_)throw g("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw g("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(t){return this.xhr_.getResponseHeader(t)}addUploadProgressListener(t){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",t)}removeUploadProgressListener(t){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",t)}}class G extends Z{initXhr(){this.xhr_.responseType="text"}}function J(){return new G}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class Q{constructor(t,n){this._service=t,this._location=n instanceof m?n:m.makeFromUrl(n,t.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(t,n){return new Q(t,n)}get root(){const t=new m(this._location.bucket,"");return this._newRef(this._service,t)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return L(this._location.path)}get storage(){return this._service}get parent(){const t=function(t){if(0===t.length)return null;const n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n)}(this._location.path);if(null===t)return null;const n=new m(this._location.bucket,t);return new Q(this._service,n)}_throwIfRoot(t){if(""===this._location.path)throw function(t){return new l("invalid-root-operation","The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}(t)}}function V(t){t._throwIfRoot("getDownloadURL");const n=function(t,n,e){const r=U(n.fullServerUrl(),t.host,t._protocol),i=t.maxOperationRetryTime,s=new H(r,"GET",function(t,n){return function(e,r){const i=W(t,r,n);return K(null!==i),function(t,n,e,r){const i=F(n);if(null===i)return null;if(!y(i.downloadTokens))return null;const s=i.downloadTokens;if(0===s.length)return null;const o=encodeURIComponent;return s.split(",").map((n=>{const i=t.fullPath;return U("/b/"+o(t.bucket)+"/o/"+o(i),e,r)+T({alt:"media",token:n})}))[0]}(i,r,t.host,t._protocol)}}(t,e),i);return s.errorHandler=function(t){const n=X(t);return function(e,r){let i=n(e,r);return 404===e.getStatus()&&(i=new l("object-not-found","Object '"+t.path+"' does not exist.")),i.serverResponse=r.serverResponse,i}}(n),s}(t.storage,t._location,D());return t.storage.makeRequestWithTokens(n,J).then((t=>{if(null===t)throw new l("no-download-url","The given file does not have any download URLs.");return t}))}function Y(t,n){if(t instanceof et){const e=t;if(null==e._bucket)throw new l("no-default-bucket","No default bucket found. Did you set the '"+a+"' property when initializing the app?");const r=new Q(e,e._bucket);return null!=n?Y(r,n):r}return void 0!==n?function(t,n){const e=function(t,n){const e=n.split("/").filter((t=>t.length>0)).join("/");return 0===t.length?e:t+"/"+e}(t._location.path,n),r=new m(t._location.bucket,e);return new Q(t.storage,r)}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */(t,n):t}function tt(t,n){if(n&&/^[A-Za-z]+:\/\//.test(n)){if(t instanceof et)return new Q(t,n);throw d("To use ref(service, url), the first argument must be a Storage instance.")}return Y(t,n)}function nt(t,n){const e=null==n?void 0:n[a];return null==e?null:m.makeFromBucketSpec(e,t)}class et{constructor(t,n,e,r,i){this.app=t,this._authProvider=n,this._appCheckProvider=e,this._url=r,this._firebaseVersion=i,this._bucket=null,this._host=c,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?m.makeFromBucketSpec(r,this._host):nt(this._host,this.app.options)}get host(){return this._host}set host(t){this._host=t,this._bucket=null!=this._url?m.makeFromBucketSpec(this._url,t):nt(t,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(t){k("time",0,Number.POSITIVE_INFINITY,t),this._maxUploadRetryTime=t}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(t){k("time",0,Number.POSITIVE_INFINITY,t),this._maxOperationRetryTime=t}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const t=this._authProvider.getImmediate({optional:!0});if(t){const n=await t.getToken();if(null!==n)return n.accessToken}return null}async _getAppCheckToken(){const t=this._appCheckProvider.getImmediate({optional:!0});return t?(await t.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach((t=>t.cancel())),this._requests.clear()),Promise.resolve()}_makeStorageReference(t){return new Q(this,t)}_makeRequest(t,n,e,r){if(this._deleted)return new b(w());{const i=function(t,n,e,r,i,s){const o=T(t.urlParams),u=t.url+o,c=Object.assign({},t.headers);return function(t,n){n&&(t["X-Firebase-GMPID"]=n)}(c,n),function(t,n){null!==n&&n.length>0&&(t.Authorization="Firebase "+n)}(c,e),function(t,n){t["X-Firebase-Storage-Version"]="webjs/"+(null!=n?n:"AppManager")}(c,s),function(t,n){null!==n&&(t["X-Firebase-AppCheck"]=n)}(c,r),new A(u,t.method,c,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,i)}(t,this._appId,e,r,n,this._firebaseVersion);return this._requests.add(i),i.getPromise().then((()=>this._requests.delete(i)),(()=>this._requests.delete(i))),i}}async makeRequestWithTokens(t,n){const[e,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(t,n,e,r).getPromise()}}const rt="@firebase/storage",it="0.9.9",st="storage";function ot(t,n,r){return function(t,n,e){t._throwIfRoot("uploadBytes");const r=function(t,n,e,r,i){const s=n.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":"multipart"},u=function(){let t="";for(let n=0;n<2;n++)t+=Math.random().toString().slice(2);return t}();o["Content-Type"]="multipart/related; boundary="+u;const c=function(t,n,e){const r=Object.assign({},e);return r.fullPath=t.path,r.size=n.size(),r.contentType||(r.contentType=function(t,n){return n&&n.type()||"application/octet-stream"}(0,n)),r}(n,r,i),a=function(t,n){const e={},r=n.length;for(let i=0;i<r;i++){const r=n[i];r.writable&&(e[r.server]=t[r.local])}return JSON.stringify(e)}(c,e),h=M.getBlob("--"+u+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+a+"\r\n--"+u+"\r\nContent-Type: "+c.contentType+"\r\n\r\n",r,"\r\n--"+u+"--");if(null===h)throw new l("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.");const f={name:c.fullPath},d=U(s,t.host,t._protocol),w=t.maxUploadRetryTime,p=new H(d,"POST",function(t,n){return function(e,r){const i=W(t,r,n);return K(null!==i),i}}(t,e),w);return p.urlParams=f,p.headers=o,p.body=h.uploadData(),p.errorHandler=X(n),p}(t.storage,t._location,D(),new M(n,!0),e);return t.storage.makeRequestWithTokens(r,J).then((n=>({metadata:n,ref:t})))}(t=e(t),n,r)}function ut(t){return V(t=e(t))}function ct(t,n){return tt(t=e(t),n)}function at(t=n(),i){return t=e(t),r(t,st).getImmediate({identifier:i})}i(new s(st,(function(t,{instanceIdentifier:n}){const e=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal"),i=t.getProvider("app-check-internal");return new et(e,r,i,n,u)}),"PUBLIC").setMultipleInstances(!0)),o(rt,it,""),o(rt,it,"esm2017");export{ut as a,at as g,ct as r,ot as u}