import{F as t,d as n,g as e,e as r,_ as s,C as i,r as o,S as u}from"./p-464104f5.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";const l="storageBucket";const a=2*60*1e3;const f=10*60*1e3;
/**
 * @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 h extends t{constructor(t,n){super(d(t),`Firebase Storage: ${n} (${d(t)})`);this.customData={serverResponse:null};this._baseMessage=this.message;Object.setPrototypeOf(this,h.prototype)}_codeEquals(t){return d(t)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(t){this.customData.serverResponse=t;if(this.customData.serverResponse){this.message=`${this._baseMessage}\n${this.customData.serverResponse}`}else{this.message=this._baseMessage}}}function d(t){return"storage/"+t}function w(){const t="An unknown error occurred, please check the error payload for "+"server response.";return new h("unknown",t)}function p(t){return new h("object-not-found","Object '"+t+"' does not exist.")}function g(t){return new h("quota-exceeded","Quota for bucket '"+t+"' exceeded, please view quota on "+"https://firebase.google.com/pricing/.")}function m(){const t="User is not authenticated, please authenticate using Firebase "+"Authentication and try again.";return new h("unauthenticated",t)}function b(){return new h("unauthorized-app","This app does not have permission to access Firebase Storage on this project.")}function y(t){return new h("unauthorized","User does not have permission to access '"+t+"'.")}function R(){return new h("retry-limit-exceeded","Max retry time for operation exceeded, please try again.")}function v(){return new h("canceled","User canceled the upload/download.")}function U(t){return new h("invalid-url","Invalid URL '"+t+"'.")}function k(t){return new h("invalid-default-bucket","Invalid default bucket '"+t+"'.")}function T(){return new h("no-default-bucket","No default bucket "+"found. Did you set the '"+l+"' property when initializing the app?")}function A(){return new h("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.")}function x(){return new h("no-download-url","The given file does not have any download URLs.")}function B(t){return new h("invalid-argument",t)}function $(){return new h("app-deleted","The Firebase app was deleted.")}function S(t){return new h("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').")}function _(t,n){return new h("invalid-format","String does not match format '"+t+"': "+n)}function C(t){throw new h("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 E{constructor(t,n){this.bucket=t;this.path_=n}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)}bucketOnlyServerUrl(){const t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o"}static makeFromBucketSpec(t,n){let e;try{e=E.makeFromUrl(t,n)}catch(n){return new E(t,"")}if(e.path===""){return e}else{throw k(t)}}static makeFromUrl(t,n){let e=null;const r="([A-Za-z0-9.\\-_]+)";function s(t){if(t.path.charAt(t.path.length-1)==="/"){t.path_=t.path_.slice(0,-1)}}const i="(/(.*))?$";const o=new RegExp("^gs://"+r+i,"i");const u={bucket:1,path:3};function l(t){t.path_=decodeURIComponent(t.path)}const a="v[A-Za-z0-9_]+";const f=n.replace(/[.]/g,"\\.");const h="(/([^?#]*).*)?$";const d=new RegExp(`^https?://${f}/${a}/b/${r}/o${h}`,"i");const w={bucket:1,path:3};const p=n===c?"(?:storage.googleapis.com|storage.cloud.google.com)":n;const g="([^?#]*)";const m=new RegExp(`^https?://${p}/${r}/${g}`,"i");const b={bucket:1,path:2};const y=[{regex:o,indices:u,postModify:s},{regex:d,indices:w,postModify:l},{regex:m,indices:b,postModify:l}];for(let n=0;n<y.length;n++){const r=y[n];const s=r.regex.exec(t);if(s){const t=s[r.indices.bucket];let n=s[r.indices.path];if(!n){n=""}e=new E(t,n);r.postModify(e);break}}if(e==null){throw U(t)}return e}}class I{constructor(t){this.promise_=Promise.reject(t)}getPromise(){return this.promise_}cancel(t=false){}}
/**
 * @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,n,e){let r=1;let s=null;let i=null;let o=false;let u=0;function c(){return u===2}let l=false;function a(...t){if(!l){l=true;n.apply(null,t)}}function f(n){s=setTimeout((()=>{s=null;t(d,c())}),n)}function h(){if(i){clearTimeout(i)}}function d(t,...n){if(l){h();return}if(t){h();a.call(null,t,...n);return}const e=c()||o;if(e){h();a.call(null,t,...n);return}if(r<64){r*=2}let s;if(u===1){u=2;s=0}else{s=(r+Math.random())*1e3}f(s)}let w=false;function p(t){if(w){return}w=true;h();if(l){return}if(s!==null){if(!t){u=2}clearTimeout(s);f(0)}else{if(!t){u=1}}}f(0);i=setTimeout((()=>{o=true;p(true)}),e);return p}function P(t){t(false)}
/**
 * @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 j(t){return t!==void 0}function L(t){return typeof t==="object"&&!Array.isArray(t)}function M(t){return typeof t==="string"||t instanceof String}function F(t){return z()&&t instanceof Blob}function z(){return typeof Blob!=="undefined"}function N(t,n,e,r){if(r<n){throw B(`Invalid value for '${t}'. Expected ${n} or greater.`)}if(r>e){throw B(`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 q(t,n,e){let r=n;if(e==null){r=`https://${n}`}return`${e}://${r}/v0${t}`}function D(t){const n=encodeURIComponent;let e="?";for(const r in t){if(t.hasOwnProperty(r)){const s=n(r)+"="+n(t[r]);e=e+s+"&"}}e=e.slice(0,-1);return 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 W;(function(t){t[t["NO_ERROR"]=0]="NO_ERROR";t[t["NETWORK_ERROR"]=1]="NETWORK_ERROR";t[t["ABORT"]=2]="ABORT"})(W||(W={}));
/**
 * @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 H{constructor(t,n,e,r,s,i,o,u,c,l,a){this.url_=t;this.method_=n;this.headers_=e;this.body_=r;this.successCodes_=s;this.additionalRetryCodes_=i;this.callback_=o;this.errorCallback_=u;this.timeout_=c;this.progressCallback_=l;this.connectionFactory_=a;this.pendingConnection_=null;this.backoffId_=null;this.canceled_=false;this.appDelete_=false;this.promise_=new Promise(((t,n)=>{this.resolve_=t;this.reject_=n;this.start_()}))}start_(){const t=(t,n)=>{if(n){t(false,new K(false,null,true));return}const e=this.connectionFactory_();this.pendingConnection_=e;const r=t=>{const n=t.loaded;const e=t.lengthComputable?t.total:-1;if(this.progressCallback_!==null){this.progressCallback_(n,e)}};if(this.progressCallback_!==null){e.addUploadProgressListener(r)}e.send(this.url_,this.method_,this.body_,this.headers_).then((()=>{if(this.progressCallback_!==null){e.removeUploadProgressListener(r)}this.pendingConnection_=null;const n=e.getErrorCode()===W.NO_ERROR;const s=e.getStatus();if(!n||this.isRetryStatusCode_(s)){const n=e.getErrorCode()===W.ABORT;t(false,new K(false,null,n));return}const i=this.successCodes_.indexOf(s)!==-1;t(true,new K(i,e))}))};const n=(t,n)=>{const e=this.resolve_;const r=this.reject_;const s=n.connection;if(n.wasSuccessCode){try{const t=this.callback_(s,s.getResponse());if(j(t)){e(t)}else{e()}}catch(t){r(t)}}else{if(s!==null){const t=w();t.serverResponse=s.getErrorText();if(this.errorCallback_){r(this.errorCallback_(s,t))}else{r(t)}}else{if(n.canceled){const t=this.appDelete_?$():v();r(t)}else{const t=R();r(t)}}}};if(this.canceled_){n(false,new K(false,null,true))}else{this.backoffId_=O(t,n,this.timeout_)}}getPromise(){return this.promise_}cancel(t){this.canceled_=true;this.appDelete_=t||false;if(this.backoffId_!==null){P(this.backoffId_)}if(this.pendingConnection_!==null){this.pendingConnection_.abort()}}isRetryStatusCode_(t){const n=t>=500&&t<600;const e=[408,429];const r=e.indexOf(t)!==-1;const s=this.additionalRetryCodes_.indexOf(t)!==-1;return n||r||s}}class K{constructor(t,n,e){this.wasSuccessCode=t;this.connection=n;this.canceled=!!e}}function X(t,n){if(n!==null&&n.length>0){t["Authorization"]="Firebase "+n}}function Z(t,n){t["X-Firebase-Storage-Version"]="webjs/"+(n!==null&&n!==void 0?n:"AppManager")}function G(t,n){if(n){t["X-Firebase-GMPID"]=n}}function J(t,n){if(n!==null){t["X-Firebase-AppCheck"]=n}}function Q(t,n,e,r,s,i){const o=D(t.urlParams);const u=t.url+o;const c=Object.assign({},t.headers);G(c,n);X(c,e);Z(c,i);J(c,r);return new H(u,t.method,c,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,s)}
/**
 * @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 V(){if(typeof BlobBuilder!=="undefined"){return BlobBuilder}else if(typeof WebKitBlobBuilder!=="undefined"){return WebKitBlobBuilder}else{return undefined}}function Y(...t){const n=V();if(n!==undefined){const e=new n;for(let n=0;n<t.length;n++){e.append(t[n])}return e.getBlob()}else{if(z()){return new Blob(t)}else{throw new h("unsupported-environment","This browser doesn't seem to support creating Blobs")}}}function tt(t,n,e){if(t.webkitSlice){return t.webkitSlice(n,e)}else if(t.mozSlice){return t.mozSlice(n,e)}else if(t.slice){return t.slice(n,e)}return null}
/**
 * @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.
 */function nt(t){return atob(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.
 */const et={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class rt{constructor(t,n){this.data=t;this.contentType=n||null}}function st(t,n){switch(t){case et.RAW:return new rt(it(n));case et.BASE64:case et.BASE64URL:return new rt(ut(t,n));case et.DATA_URL:return new rt(lt(n),at(n))}throw w()}function it(t){const n=[];for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);if(r<=127){n.push(r)}else{if(r<=2047){n.push(192|r>>6,128|r&63)}else{if((r&64512)===55296){const s=e<t.length-1&&(t.charCodeAt(e+1)&64512)===56320;if(!s){n.push(239,191,189)}else{const s=r;const i=t.charCodeAt(++e);r=65536|(s&1023)<<10|i&1023;n.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}}else{if((r&64512)===56320){n.push(239,191,189)}else{n.push(224|r>>12,128|r>>6&63,128|r&63)}}}}}return new Uint8Array(n)}function ot(t){let n;try{n=decodeURIComponent(t)}catch(t){throw _(et.DATA_URL,"Malformed data URL.")}return it(n)}function ut(t,n){switch(t){case et.BASE64:{const e=n.indexOf("-")!==-1;const r=n.indexOf("_")!==-1;if(e||r){const n=e?"-":"_";throw _(t,"Invalid character '"+n+"' found: is it base64url encoded?")}break}case et.BASE64URL:{const e=n.indexOf("+")!==-1;const r=n.indexOf("/")!==-1;if(e||r){const n=e?"+":"/";throw _(t,"Invalid character '"+n+"' found: is it base64 encoded?")}n=n.replace(/-/g,"+").replace(/_/g,"/");break}}let e;try{e=nt(n)}catch(n){throw _(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 ct{constructor(t){this.base64=false;this.contentType=null;const n=t.match(/^data:([^,]+)?,/);if(n===null){throw _(et.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>")}const e=n[1]||null;if(e!=null){this.base64=ft(e,";base64");this.contentType=this.base64?e.substring(0,e.length-";base64".length):e}this.rest=t.substring(t.indexOf(",")+1)}}function lt(t){const n=new ct(t);if(n.base64){return ut(et.BASE64,n.rest)}else{return ot(n.rest)}}function at(t){const n=new ct(t);return n.contentType}function ft(t,n){const e=t.length>=n.length;if(!e){return false}return t.substring(t.length-n.length)===n}
/**
 * @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 ht{constructor(t,n){let e=0;let r="";if(F(t)){this.data_=t;e=t.size;r=t.type}else if(t instanceof ArrayBuffer){if(n){this.data_=new Uint8Array(t)}else{this.data_=new Uint8Array(t.byteLength);this.data_.set(new Uint8Array(t))}e=this.data_.length}else if(t instanceof Uint8Array){if(n){this.data_=t}else{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(F(this.data_)){const e=this.data_;const r=tt(e,t,n);if(r===null){return null}return new ht(r)}else{const e=new Uint8Array(this.data_.buffer,t,n-t);return new ht(e,true)}}static getBlob(...t){if(z()){const n=t.map((t=>{if(t instanceof ht){return t.data_}else{return t}}));return new ht(Y.apply(null,n))}else{const n=t.map((t=>{if(M(t)){return st(et.RAW,t).data}else{return t.data_}}));let e=0;n.forEach((t=>{e+=t.byteLength}));const r=new Uint8Array(e);let s=0;n.forEach((t=>{for(let n=0;n<t.length;n++){r[s++]=t[n]}}));return new ht(r,true)}}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 dt(t){let n;try{n=JSON.parse(t)}catch(t){return null}if(L(n)){return n}else{return null}}
/**
 * @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 wt(t){if(t.length===0){return null}const n=t.lastIndexOf("/");if(n===-1){return""}const e=t.slice(0,n);return e}function pt(t,n){const e=n.split("/").filter((t=>t.length>0)).join("/");if(t.length===0){return e}else{return t+"/"+e}}function gt(t){const n=t.lastIndexOf("/",t.length-2);if(n===-1){return t}else{return 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 mt(t,n){return n}class bt{constructor(t,n,e,r){this.server=t;this.local=n||t;this.writable=!!e;this.xform=r||mt}}let yt=null;function Rt(t){if(!M(t)||t.length<2){return t}else{return gt(t)}}function vt(){if(yt){return yt}const t=[];t.push(new bt("bucket"));t.push(new bt("generation"));t.push(new bt("metageneration"));t.push(new bt("name","fullPath",true));function n(t,n){return Rt(n)}const e=new bt("name");e.xform=n;t.push(e);function r(t,n){if(n!==undefined){return Number(n)}else{return n}}const s=new bt("size");s.xform=r;t.push(s);t.push(new bt("timeCreated"));t.push(new bt("updated"));t.push(new bt("md5Hash",null,true));t.push(new bt("cacheControl",null,true));t.push(new bt("contentDisposition",null,true));t.push(new bt("contentEncoding",null,true));t.push(new bt("contentLanguage",null,true));t.push(new bt("contentType",null,true));t.push(new bt("metadata","customMetadata",true));yt=t;return yt}function Ut(t,n){function e(){const e=t["bucket"];const r=t["fullPath"];const s=new E(e,r);return n._makeStorageReference(s)}Object.defineProperty(t,"ref",{get:e})}function kt(t,n,e){const r={};r["type"]="file";const s=e.length;for(let t=0;t<s;t++){const s=e[t];r[s.local]=s.xform(r,n[s.server])}Ut(r,t);return r}function Tt(t,n,e){const r=dt(n);if(r===null){return null}const s=r;return kt(t,s,e)}function At(t,n,e,r){const s=dt(n);if(s===null){return null}if(!M(s["downloadTokens"])){return null}const i=s["downloadTokens"];if(i.length===0){return null}const o=encodeURIComponent;const u=i.split(",");const c=u.map((n=>{const s=t["bucket"];const i=t["fullPath"];const u="/b/"+o(s)+"/o/"+o(i);const c=q(u,e,r);const l=D({alt:"media",token:n});return c+l}));return c[0]}function xt(t,n){const e={};const r=n.length;for(let s=0;s<r;s++){const r=n[s];if(r.writable){e[r.server]=t[r.local]}}return JSON.stringify(e)}class Bt{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 $t(t){if(!t){throw w()}}function St(t,n){function e(e,r){const s=Tt(t,r,n);$t(s!==null);return s}return e}function _t(t,n){function e(e,r){const s=Tt(t,r,n);$t(s!==null);return At(s,r,t.host,t._protocol)}return e}function Ct(t){function n(n,e){let r;if(n.getStatus()===401){if(n.getErrorText().includes("Firebase App Check token is invalid")){r=b()}else{r=m()}}else{if(n.getStatus()===402){r=g(t.bucket)}else{if(n.getStatus()===403){r=y(t.path)}else{r=e}}}r.serverResponse=e.serverResponse;return r}return n}function Et(t){const n=Ct(t);function e(e,r){let s=n(e,r);if(e.getStatus()===404){s=p(t.path)}s.serverResponse=r.serverResponse;return s}return e}function It(t,n,e){const r=n.fullServerUrl();const s=q(r,t.host,t._protocol);const i="GET";const o=t.maxOperationRetryTime;const u=new Bt(s,i,_t(t,e),o);u.errorHandler=Et(n);return u}function Ot(t,n){return t&&t["contentType"]||n&&n.type()||"application/octet-stream"}function Pt(t,n,e){const r=Object.assign({},e);r["fullPath"]=t.path;r["size"]=n.size();if(!r["contentType"]){r["contentType"]=Ot(null,n)}return r}function jt(t,n,e,r,s){const i=n.bucketOnlyServerUrl();const o={"X-Goog-Upload-Protocol":"multipart"};function u(){let t="";for(let n=0;n<2;n++){t=t+Math.random().toString().slice(2)}return t}const c=u();o["Content-Type"]="multipart/related; boundary="+c;const l=Pt(n,r,s);const a=xt(l,e);const f="--"+c+"\r\n"+"Content-Type: application/json; charset=utf-8\r\n\r\n"+a+"\r\n--"+c+"\r\n"+"Content-Type: "+l["contentType"]+"\r\n\r\n";const h="\r\n--"+c+"--";const d=ht.getBlob(f,r,h);if(d===null){throw A()}const w={name:l["fullPath"]};const p=q(i,t.host,t._protocol);const g="POST";const m=t.maxUploadRetryTime;const b=new Bt(p,g,St(t,e),m);b.urlParams=w;b.headers=o;b.body=d.uploadData();b.errorHandler=Ct(n);return b}class Lt{constructor(){this.sent_=false;this.xhr_=new XMLHttpRequest;this.initXhr();this.errorCode_=W.NO_ERROR;this.sendPromise_=new Promise((t=>{this.xhr_.addEventListener("abort",(()=>{this.errorCode_=W.ABORT;t()}));this.xhr_.addEventListener("error",(()=>{this.errorCode_=W.NETWORK_ERROR;t()}));this.xhr_.addEventListener("load",(()=>{t()}))}))}send(t,n,e,r){if(this.sent_){throw C("cannot .send() more than once")}this.sent_=true;this.xhr_.open(n,t,true);if(r!==undefined){for(const t in r){if(r.hasOwnProperty(t)){this.xhr_.setRequestHeader(t,r[t].toString())}}}if(e!==undefined){this.xhr_.send(e)}else{this.xhr_.send()}return this.sendPromise_}getErrorCode(){if(!this.sent_){throw C("cannot .getErrorCode() before sending")}return this.errorCode_}getStatus(){if(!this.sent_){throw C("cannot .getStatus() before sending")}try{return this.xhr_.status}catch(t){return-1}}getResponse(){if(!this.sent_){throw C("cannot .getResponse() before sending")}return this.xhr_.response}getErrorText(){if(!this.sent_){throw C("cannot .getErrorText() before sending")}return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(t){return this.xhr_.getResponseHeader(t)}addUploadProgressListener(t){if(this.xhr_.upload!=null){this.xhr_.upload.addEventListener("progress",t)}}removeUploadProgressListener(t){if(this.xhr_.upload!=null){this.xhr_.upload.removeEventListener("progress",t)}}}class Mt extends Lt{initXhr(){this.xhr_.responseType="text"}}function Ft(){return new Mt}
/**
 * @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 zt{constructor(t,n){this._service=t;if(n instanceof E){this._location=n}else{this._location=E.makeFromUrl(n,t.host)}}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(t,n){return new zt(t,n)}get root(){const t=new E(this._location.bucket,"");return this._newRef(this._service,t)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return gt(this._location.path)}get storage(){return this._service}get parent(){const t=wt(this._location.path);if(t===null){return null}const n=new E(this._location.bucket,t);return new zt(this._service,n)}_throwIfRoot(t){if(this._location.path===""){throw S(t)}}}function Nt(t,n,e){t._throwIfRoot("uploadBytes");const r=jt(t.storage,t._location,vt(),new ht(n,true),e);return t.storage.makeRequestWithTokens(r,Ft).then((n=>({metadata:n,ref:t})))}function qt(t){t._throwIfRoot("getDownloadURL");const n=It(t.storage,t._location,vt());return t.storage.makeRequestWithTokens(n,Ft).then((t=>{if(t===null){throw x()}return t}))}function Dt(t,n){const e=pt(t._location.path,n);const r=new E(t._location.bucket,e);return new zt(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.
 */function Wt(t){return/^[A-Za-z]+:\/\//.test(t)}function Ht(t,n){return new zt(t,n)}function Kt(t,n){if(t instanceof Gt){const e=t;if(e._bucket==null){throw T()}const r=new zt(e,e._bucket);if(n!=null){return Kt(r,n)}else{return r}}else{if(n!==undefined){return Dt(t,n)}else{return t}}}function Xt(t,n){if(n&&Wt(n)){if(t instanceof Gt){return Ht(t,n)}else{throw B("To use ref(service, url), the first argument must be a Storage instance.")}}else{return Kt(t,n)}}function Zt(t,n){const e=n===null||n===void 0?void 0:n[l];if(e==null){return null}return E.makeFromBucketSpec(e,t)}class Gt{constructor(t,n,e,r,s){this.app=t;this._authProvider=n;this._appCheckProvider=e;this._url=r;this._firebaseVersion=s;this._bucket=null;this._host=c;this._protocol="https";this._appId=null;this._deleted=false;this._maxOperationRetryTime=a;this._maxUploadRetryTime=f;this._requests=new Set;if(r!=null){this._bucket=E.makeFromBucketSpec(r,this._host)}else{this._bucket=Zt(this._host,this.app.options)}}get host(){return this._host}set host(t){this._host=t;if(this._url!=null){this._bucket=E.makeFromBucketSpec(this._url,t)}else{this._bucket=Zt(t,this.app.options)}}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(t){N("time",0,Number.POSITIVE_INFINITY,t);this._maxUploadRetryTime=t}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(t){N("time",0,Number.POSITIVE_INFINITY,t);this._maxOperationRetryTime=t}async _getAuthToken(){if(this._overrideAuthToken){return this._overrideAuthToken}const t=this._authProvider.getImmediate({optional:true});if(t){const n=await t.getToken();if(n!==null){return n.accessToken}}return null}async _getAppCheckToken(){const t=this._appCheckProvider.getImmediate({optional:true});if(t){const n=await t.getToken();return n.token}return null}_delete(){if(!this._deleted){this._deleted=true;this._requests.forEach((t=>t.cancel()));this._requests.clear()}return Promise.resolve()}_makeStorageReference(t){return new zt(this,t)}_makeRequest(t,n,e,r){if(!this._deleted){const s=Q(t,this._appId,e,r,n,this._firebaseVersion);this._requests.add(s);s.getPromise().then((()=>this._requests.delete(s)),(()=>this._requests.delete(s)));return s}else{return new I($())}}async makeRequestWithTokens(t,n){const[e,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(t,n,e,r).getPromise()}}const Jt="@firebase/storage";const Qt="0.9.5";
/**
 * @license
 * Copyright 2020 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 Vt="storage";function Yt(t,n,r){t=e(t);return Nt(t,n,r)}function tn(t){t=e(t);return qt(t)}function nn(t,n){t=e(t);return Xt(t,n)}function en(t=n(),s){t=e(t);const i=r(t,Vt);const o=i.getImmediate({identifier:s});return o}function rn(t,{instanceIdentifier:n}){const e=t.getProvider("app").getImmediate();const r=t.getProvider("auth-internal");const s=t.getProvider("app-check-internal");return new Gt(e,r,s,n,u)}function sn(){s(new i(Vt,rn,"PUBLIC").setMultipleInstances(true));o(Jt,Qt,"");o(Jt,Qt,"esm2017")}sn();export{tn as a,en as g,nn as r,Yt as u};
//# sourceMappingURL=p-76cf0b45.js.map