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.
 */
/**
 * @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 c extends t{constructor(t,n){super(a(t),`Firebase Storage: ${n} (${a(t)})`),this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,c.prototype)}_codeEquals(t){return a(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 a(t){return"storage/"+t}function l(){return new c("unknown","An unknown error occurred, please check the error payload for server response.")}function h(t){return new c("invalid-argument",t)}function f(){return new c("app-deleted","The Firebase app was deleted.")}function d(t,n){return new c("invalid-format","String does not match format '"+t+"': "+n)}function w(t){throw new c("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 p{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=p.makeFromUrl(t,n)}catch(n){return new p(t,"")}if(""===e.path)return e;throw new c("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?://${"firebasestorage.googleapis.com"===n?"(?: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 p(i[r.indices.bucket],t),r.postModify(e);break}}if(null==e)throw function(t){return new c("invalid-url","Invalid URL '"+t+"'.")}(t);return e}}class g{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 b(t){return"string"==typeof t||t instanceof String}function m(t){return y()&&t instanceof Blob}function y(){return"undefined"!=typeof Blob}function v(t,n,e,r){if(r<n)throw h(`Invalid value for '${t}'. Expected ${n} or greater.`);if(r>e)throw h(`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 R(t,n,e){let r=n;return null==e&&(r=`https://${n}`),`${e}://${r}/v0${t}`}function k(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 U;!function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"}(U||(U={}));
/**
 * @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 T{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=l();t.serverResponse=i.getErrorText(),r(this.errorCallback_?this.errorCallback_(i,t):t)}else r(n.canceled?this.appDelete_?f():new c("canceled","User canceled the upload/download."):new c("retry-limit-exceeded","Max retry time for operation exceeded, please try again."))};this.canceled_?t(0,new x(!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 x(!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()===U.NO_ERROR,i=e.getStatus();if(!n||this.isRetryStatusCode_(i)){const n=e.getErrorCode()===U.ABORT;return void t(!1,new x(!1,null,n))}const s=-1!==this.successCodes_.indexOf(i);t(!0,new x(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 x{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 A(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function _(...t){const n=A();if(void 0!==n){const e=new n;for(let n=0;n<t.length;n++)e.append(t[n]);return e.getBlob()}if(y())return new Blob(t);throw new c("unsupported-environment","This browser doesn't seem to support creating Blobs")}class B{constructor(t,n){this.data=t,this.contentType=n||null}}function C(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 S(t,n){switch(t){case"base64":{const e=-1!==n.indexOf("-"),r=-1!==n.indexOf("_");if(e||r)throw d(t,"Invalid character '"+(e?"-":"_")+"' found: is it base64url encoded?");break}case"base64url":{const e=-1!==n.indexOf("+"),r=-1!==n.indexOf("/");if(e||r)throw d(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 d(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 ${constructor(t){this.base64=!1,this.contentType=null;const n=t.match(/^data:([^,]+)?,/);if(null===n)throw d("data_url","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 I{constructor(t,n){let e=0,r="";m(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(m(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 I(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 I(e,!0)}}static getBlob(...t){if(y()){const n=t.map((t=>t instanceof I?t.data_:t));return new I(_.apply(null,n))}{const n=t.map((t=>b(t)?function(t,n){switch(t){case"raw":return new B(C(n));case"base64":case"base64url":return new B(S(t,n));case"data_url":return new B(function(t){const n=new $(t);return n.base64?S("base64",n.rest):function(t){let n;try{n=decodeURIComponent(t)}catch(t){throw d("data_url","Malformed data URL.")}return C(n)}(n.rest)}(n),new $(n).contentType)}throw l()}("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 I(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 O(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 E(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 P(t,n){return n}class j{constructor(t,n,e,r){this.server=t,this.local=n||t,this.writable=!!e,this.xform=r||P}}let M=null;function F(){if(M)return M;const t=[];t.push(new j("bucket")),t.push(new j("generation")),t.push(new j("metageneration")),t.push(new j("name","fullPath",!0));const n=new j("name");n.xform=function(t,n){return function(t){return!b(t)||t.length<2?t:E(t)}(n)},t.push(n);const e=new j("size");return e.xform=function(t,n){return void 0!==n?Number(n):n},t.push(e),t.push(new j("timeCreated")),t.push(new j("updated")),t.push(new j("md5Hash",null,!0)),t.push(new j("cacheControl",null,!0)),t.push(new j("contentDisposition",null,!0)),t.push(new j("contentEncoding",null,!0)),t.push(new j("contentLanguage",null,!0)),t.push(new j("contentType",null,!0)),t.push(new j("metadata","customMetadata",!0)),M=t,M}function L(t,n,e){const r=O(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 p(t.bucket,t.fullPath);return n._makeStorageReference(e)}})}(r,t),r}(t,r,e)}class z{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 N(t){if(!t)throw l()}function q(t){return function(n,e){let r;return r=401===n.getStatus()?n.getErrorText().includes("Firebase App Check token is invalid")?new c("unauthorized-app","This app does not have permission to access Firebase Storage on this project."):new c("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===n.getStatus()?new c("quota-exceeded","Quota for bucket '"+t.bucket+"' exceeded, please view quota on https://firebase.google.com/pricing/."):403===n.getStatus()?new c("unauthorized","User does not have permission to access '"+t.path+"'."):e,r.serverResponse=e.serverResponse,r}}class D extends class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=U.NO_ERROR,this.sendPromise_=new Promise((t=>{this.xhr_.addEventListener("abort",(()=>{this.errorCode_=U.ABORT,t()})),this.xhr_.addEventListener("error",(()=>{this.errorCode_=U.NETWORK_ERROR,t()})),this.xhr_.addEventListener("load",(()=>{t()}))}))}send(t,n,e,r){if(this.sent_)throw w("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 w("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw w("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}}getResponse(){if(!this.sent_)throw w("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw w("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)}}{initXhr(){this.xhr_.responseType="text"}}function W(){return new D}
/**
 * @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 H{constructor(t,n){this._service=t,this._location=n instanceof p?n:p.makeFromUrl(n,t.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(t,n){return new H(t,n)}get root(){const t=new p(this._location.bucket,"");return this._newRef(this._service,t)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return E(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 p(this._location.bucket,t);return new H(this._service,n)}_throwIfRoot(t){if(""===this._location.path)throw function(t){return new c("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 K(t){t._throwIfRoot("getDownloadURL");const n=function(t,n,e){const r=R(n.fullServerUrl(),t.host,t._protocol),i=t.maxOperationRetryTime,s=new z(r,"GET",function(t,n){return function(e,r){const i=L(t,r,n);return N(null!==i),function(t,n,e,r){const i=O(n);if(null===i)return null;if(!b(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 R("/b/"+o(t.bucket)+"/o/"+o(i),e,r)+k({alt:"media",token:n})}))[0]}(i,r,t.host,t._protocol)}}(t,e),i);return s.errorHandler=function(t){const n=q(t);return function(e,r){let i=n(e,r);return 404===e.getStatus()&&(i=new c("object-not-found","Object '"+t.path+"' does not exist.")),i.serverResponse=r.serverResponse,i}}(n),s}(t.storage,t._location,F());return t.storage.makeRequestWithTokens(n,W).then((t=>{if(null===t)throw new c("no-download-url","The given file does not have any download URLs.");return t}))}function X(t,n){if(t instanceof J){const e=t;if(null==e._bucket)throw new c("no-default-bucket","No default bucket found. Did you set the 'storageBucket' property when initializing the app?");const r=new H(e,e._bucket);return null!=n?X(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 p(t._location.bucket,e);return new H(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 Z(t,n){if(n&&/^[A-Za-z]+:\/\//.test(n)){if(t instanceof J)return new H(t,n);throw h("To use ref(service, url), the first argument must be a Storage instance.")}return X(t,n)}function G(t,n){const e=null==n?void 0:n.storageBucket;return null==e?null:p.makeFromBucketSpec(e,t)}class J{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="firebasestorage.googleapis.com",this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?p.makeFromBucketSpec(r,this._host):G(this._host,this.app.options)}get host(){return this._host}set host(t){this._host=t,this._bucket=null!=this._url?p.makeFromBucketSpec(this._url,t):G(t,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(t){v("time",0,Number.POSITIVE_INFINITY,t),this._maxUploadRetryTime=t}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(t){v("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 H(this,t)}_makeRequest(t,n,e,r){if(this._deleted)return new g(f());{const i=function(t,n,e,r,i,s){const o=k(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 T(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 Q="@firebase/storage";function V(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 a=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),l=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)}(a,e),h=I.getBlob("--"+u+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+l+"\r\n--"+u+"\r\nContent-Type: "+a.contentType+"\r\n\r\n",r,"\r\n--"+u+"--");if(null===h)throw new c("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.");const f={name:a.fullPath},d=R(s,t.host,t._protocol),w=t.maxUploadRetryTime,p=new z(d,"POST",function(t,n){return function(e,r){const i=L(t,r,n);return N(null!==i),i}}(t,e),w);return p.urlParams=f,p.headers=o,p.body=h.uploadData(),p.errorHandler=q(n),p}(t.storage,t._location,F(),new I(n,!0),e);return t.storage.makeRequestWithTokens(r,W).then((n=>({metadata:n,ref:t})))}(t=e(t),n,r)}function Y(t){return K(t=e(t))}function tt(t,n){return Z(t=e(t),n)}function nt(t=n(),i){return t=e(t),r(t,"storage").getImmediate({identifier:i})}i(new s("storage",(function(t,{instanceIdentifier:n}){const e=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal"),i=t.getProvider("app-check-internal");return new J(e,r,i,n,u)}),"PUBLIC").setMultipleInstances(!0)),o(Q,"0.9.9",""),o(Q,"0.9.9","esm2017");export{Y as a,nt as g,tt as r,V as u}