@localazy/cdn-client 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/localazy-cdn-client.umd.js +86 -66
- package/dist/browser/localazy-cdn-client.umd.js.map +1 -1
- package/dist/browser/localazy-cdn-client.umd.min.js +3 -3
- package/dist/browser/localazy-cdn-client.umd.min.js.map +1 -1
- package/dist/index.d.ts +22 -24
- package/dist/localazy-cdn-client.js +85 -65
- package/dist/localazy-cdn-client.js.map +1 -1
- package/dist/localazy-cdn-client.min.js +2 -2
- package/dist/localazy-cdn-client.min.js.map +1 -1
- package/dist/node/localazy-cdn-client.cjs +85 -65
- package/dist/node/localazy-cdn-client.cjs.map +1 -1
- package/dist/node/localazy-cdn-client.min.cjs +2 -2
- package/dist/node/localazy-cdn-client.min.cjs.map +1 -1
- package/package.json +11 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("
|
|
2
|
-
/* @localazy/cdn-client@1.1
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("isomorphic-fetch")):"function"==typeof define&&define.amd?define(["exports","isomorphic-fetch"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LocalazyCDN={})}(this,(function(t){"use strict";var e=Object.defineProperty,r=(t,r,n)=>(((t,r,n)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n})(t,"symbol"!=typeof r?r+"":r,n),n);
|
|
2
|
+
/* @localazy/cdn-client@1.2.1
|
|
3
3
|
* (c) 2024 Localazy <team@localazy.com>
|
|
4
4
|
* @license MIT */
|
|
5
|
-
class a{constructor(t){n(this,"context"),this.context=t}async fetchLocale(t){const e={reference:t};if(this.context.cache.has(t))return new Promise((r=>{r({data:this.context.cache.get(t),config:e})}));const r=/\.(json|json5)$/.test(t.metafileFile.file)?"json":"text";return this.context.client.get(t.metafileLocale.uri,{...e,responseType:r})}async fetchMetafile(t){return this.context.client.get(this.context.metafile.params.jsonPath,t)}}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var s="object"==typeof i&&i&&i.Object===Object&&i,c=s,u="object"==typeof self&&self&&self.Object===Object&&self,l=c||u||Function("return this")(),f=l.Symbol,h=f,p=Object.prototype,v=p.hasOwnProperty,d=p.toString,b=h?h.toStringTag:void 0;var y=function(t){var e=v.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var a=d.call(t);return n&&(e?t[b]=r:delete t[b]),a},g=Object.prototype.toString;var m=y,j=function(t){return g.call(t)},w=f?f.toStringTag:void 0;var _=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":w&&w in Object(t)?m(t):j(t)};var x=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},O=_,F=x;var A=function(t){if(!F(t))return!1;var e=O(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};const L=o(A);var M,S=l["__core-js_shared__"],R=(M=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"";var E=function(t){return!!R&&R in t},I=Function.prototype.toString;var U=function(t){if(null!=t){try{return I.call(t)}catch(t){}try{return t+""}catch(t){}}return""},P=A,q=E,z=x,$=U,C=/^\[object .+?Constructor\]$/,T=Function.prototype,B=Object.prototype,k=T.toString,D=B.hasOwnProperty,N=RegExp("^"+k.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var V=function(t){return!(!z(t)||q(t))&&(P(t)?N:C).test($(t))},W=function(t,e){return null==t?void 0:t[e]};var G=function(t,e){var r=W(t,e);return V(r)?r:void 0},H=G(Object,"create"),J=H;var K=function(){this.__data__=J?J(null):{},this.size=0};var Q=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},X=H,Y=Object.prototype.hasOwnProperty;var Z=function(t){var e=this.__data__;if(X){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Y.call(e,t)?e[t]:void 0},tt=H,et=Object.prototype.hasOwnProperty;var rt=H;var nt=K,at=Q,it=Z,ot=function(t){var e=this.__data__;return tt?void 0!==e[t]:et.call(e,t)},st=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=rt&&void 0===e?"__lodash_hash_undefined__":e,this};function ct(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ct.prototype.clear=nt,ct.prototype.delete=at,ct.prototype.get=it,ct.prototype.has=ot,ct.prototype.set=st;var ut=ct;var lt=function(){this.__data__=[],this.size=0};var ft=function(t,e){return t===e||t!=t&&e!=e},ht=ft;var pt=function(t,e){for(var r=t.length;r--;)if(ht(t[r][0],e))return r;return-1},vt=pt,dt=Array.prototype.splice;var bt=pt;var yt=pt;var gt=pt;var mt=lt,jt=function(t){var e=this.__data__,r=vt(e,t);return!(r<0)&&(r==e.length-1?e.pop():dt.call(e,r,1),--this.size,!0)},wt=function(t){var e=this.__data__,r=bt(e,t);return r<0?void 0:e[r][1]},_t=function(t){return yt(this.__data__,t)>-1},xt=function(t,e){var r=this.__data__,n=gt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function Ot(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Ot.prototype.clear=mt,Ot.prototype.delete=jt,Ot.prototype.get=wt,Ot.prototype.has=_t,Ot.prototype.set=xt;var Ft=Ot,At=G(l,"Map"),Lt=ut,Mt=Ft,St=At;var Rt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Et=function(t,e){var r=t.__data__;return Rt(e)?r["string"==typeof e?"string":"hash"]:r.map},It=Et;var Ut=Et;var Pt=Et;var qt=Et;var zt=function(){this.size=0,this.__data__={hash:new Lt,map:new(St||Mt),string:new Lt}},$t=function(t){var e=It(this,t).delete(t);return this.size-=e?1:0,e},Ct=function(t){return Ut(this,t).get(t)},Tt=function(t){return Pt(this,t).has(t)},Bt=function(t,e){var r=qt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function kt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}kt.prototype.clear=zt,kt.prototype.delete=$t,kt.prototype.get=Ct,kt.prototype.has=Tt,kt.prototype.set=Bt;var Dt=kt;var Nt=Dt,Vt=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Wt=function(t){return this.__data__.has(t)};function Gt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Nt;++e<r;)this.add(t[e])}Gt.prototype.add=Gt.prototype.push=Vt,Gt.prototype.has=Wt;var Ht=Gt;var Jt=function(t,e,r,n){for(var a=t.length,i=r+(n?1:-1);n?i--:++i<a;)if(e(t[i],i,t))return i;return-1};var Kt=Jt,Qt=function(t){return t!=t},Xt=function(t,e,r){for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1};var Yt=function(t,e,r){return e==e?Xt(t,e,r):Kt(t,Qt,r)};var Zt=function(t,e){return!!(null==t?0:t.length)&&Yt(t,e,0)>-1};var te=function(t,e,r){for(var n=-1,a=null==t?0:t.length;++n<a;)if(r(e,t[n]))return!0;return!1};var ee=function(t,e){return t.has(e)},re=G(l,"Set");var ne=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},ae=re,ie=function(){},oe=ae&&1/ne(new ae([,-0]))[1]==1/0?function(t){return new ae(t)}:ie,se=Ht,ce=Zt,ue=te,le=ee,fe=oe,he=ne;var pe=function(t,e,r){var n=-1,a=ce,i=t.length,o=!0,s=[],c=s;if(r)o=!1,a=ue;else if(i>=200){var u=e?null:fe(t);if(u)return he(u);o=!1,a=le,c=new se}else c=e?[]:s;t:for(;++n<i;){var l=t[n],f=e?e(l):l;if(l=r||0!==l?l:0,o&&f==f){for(var h=c.length;h--;)if(c[h]===f)continue t;e&&c.push(f),s.push(l)}else a(c,f,r)||(c!==s&&c.push(f),s.push(l))}return s},ve=pe;const de=o((function(t){return t&&t.length?ve(t):[]}));class be{constructor(){n(this,"map"),this.map=new Map}get(t){return this.map.get(t)}has(t){return this.map.has(t)}set(t,e){this.map.set(t,e)}flush(){this.map=new Map}}class ye{constructor(t){n(this,"context"),n(this,"cacheAdapter"),this.context=t,this.cacheAdapter=new be}setIfMissed(t){const{metafileFile:e,metafileLocale:r,data:n}=t,a=this.keyFromMetafile({metafileFile:e,metafileLocale:r});this.cacheAdapter.has(a)||this.cacheAdapter.set(a,n)}has(t){const e=this.keyFromMetafile(t);return this.cacheAdapter.has(e)}get(t){const e=this.keyFromMetafile(t);return this.cacheAdapter.get(e)}flush(){this.cacheAdapter.flush()}keyFromMetafile(t){const{metafileFile:e,metafileLocale:r}=t,n=[...de(e.productFlavors)].sort().join("-");return[this.context.metafile.params.cdnId,e.id,e.file,e.path,e.library,e.module,e.buildType,n,r.locale,r.timestamp.toString()].filter((t=>""!==t)).join("-")}}var ge=Array.isArray;const me=o(ge);var je=function(t){return null!=t&&"object"==typeof t},we=_,_e=ge,xe=je;const Oe=o((function(t){return"string"==typeof t||!_e(t)&&xe(t)&&"[object String]"==we(t)}));class Fe{constructor(t){n(this,"context"),this.context=t}}class Ae extends Fe{constructor(){super(...arguments),n(this,"flush",(()=>{this.context.cache.flush()}))}}var Le=Ft;var Me=Ft,Se=At,Re=Dt;var Ee=Ft,Ie=function(){this.__data__=new Le,this.size=0},Ue=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Pe=function(t){return this.__data__.get(t)},qe=function(t){return this.__data__.has(t)},ze=function(t,e){var r=this.__data__;if(r instanceof Me){var n=r.__data__;if(!Se||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Re(n)}return r.set(t,e),this.size=r.size,this};function $e(t){var e=this.__data__=new Ee(t);this.size=e.size}$e.prototype.clear=Ie,$e.prototype.delete=Ue,$e.prototype.get=Pe,$e.prototype.has=qe,$e.prototype.set=ze;var Ce=$e;var Te=Ht,Be=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1},ke=ee;var De=function(t,e,r,n,a,i){var o=1&r,s=t.length,c=e.length;if(s!=c&&!(o&&c>s))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var f=-1,h=!0,p=2&r?new Te:void 0;for(i.set(t,e),i.set(e,t);++f<s;){var v=t[f],d=e[f];if(n)var b=o?n(d,v,f,e,t,i):n(v,d,f,t,e,i);if(void 0!==b){if(b)continue;h=!1;break}if(p){if(!Be(e,(function(t,e){if(!ke(p,e)&&(v===t||a(v,t,r,n,i)))return p.push(e)}))){h=!1;break}}else if(v!==d&&!a(v,d,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h},Ne=l.Uint8Array;var Ve=Ne,We=ft,Ge=De,He=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r},Je=ne,Ke=f?f.prototype:void 0,Qe=Ke?Ke.valueOf:void 0;var Xe=function(t,e,r,n,a,i,o){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new Ve(t),new Ve(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return We(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var s=He;case"[object Set]":var c=1&n;if(s||(s=Je),t.size!=e.size&&!c)return!1;var u=o.get(t);if(u)return u==e;n|=2,o.set(t,e);var l=Ge(s(t),s(e),n,a,i,o);return o.delete(t),l;case"[object Symbol]":if(Qe)return Qe.call(t)==Qe.call(e)}return!1};var Ye=function(t,e){for(var r=-1,n=e.length,a=t.length;++r<n;)t[a+r]=e[r];return t},Ze=Ye,tr=ge;var er=function(t,e,r){var n=e(t);return tr(t)?n:Ze(n,r(t))};var rr=function(t,e){for(var r=-1,n=null==t?0:t.length,a=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[a++]=o)}return i};var nr=function(){return[]},ar=rr,ir=nr,or=Object.prototype.propertyIsEnumerable,sr=Object.getOwnPropertySymbols,cr=sr?function(t){return null==t?[]:(t=Object(t),ar(sr(t),(function(e){return or.call(t,e)})))}:ir;var ur=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n},lr=_,fr=je;var hr,pr,vr,dr,br,yr,gr,mr,jr=function(t){return fr(t)&&"[object Arguments]"==lr(t)},wr=je,_r=Object.prototype,xr=_r.hasOwnProperty,Or=_r.propertyIsEnumerable,Fr=jr(function(){return arguments}())?jr:function(t){return wr(t)&&xr.call(t,"callee")&&!Or.call(t,"callee")},Ar=Fr,Lr={exports:{}};hr=Lr,vr=l,dr=function(){return!1},br=(pr=Lr.exports)&&!pr.nodeType&&pr,yr=br&&hr&&!hr.nodeType&&hr,gr=yr&&yr.exports===br?vr.Buffer:void 0,mr=(gr?gr.isBuffer:void 0)||dr,hr.exports=mr;var Mr=Lr.exports,Sr=/^(?:0|[1-9]\d*)$/;var Rr=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Sr.test(t))&&t>-1&&t%1==0&&t<e};var Er=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Ir=_,Ur=Er,Pr=je,qr={};qr["[object Float32Array]"]=qr["[object Float64Array]"]=qr["[object Int8Array]"]=qr["[object Int16Array]"]=qr["[object Int32Array]"]=qr["[object Uint8Array]"]=qr["[object Uint8ClampedArray]"]=qr["[object Uint16Array]"]=qr["[object Uint32Array]"]=!0,qr["[object Arguments]"]=qr["[object Array]"]=qr["[object ArrayBuffer]"]=qr["[object Boolean]"]=qr["[object DataView]"]=qr["[object Date]"]=qr["[object Error]"]=qr["[object Function]"]=qr["[object Map]"]=qr["[object Number]"]=qr["[object Object]"]=qr["[object RegExp]"]=qr["[object Set]"]=qr["[object String]"]=qr["[object WeakMap]"]=!1;var zr=function(t){return Pr(t)&&Ur(t.length)&&!!qr[Ir(t)]};var $r=function(t){return function(e){return t(e)}},Cr={exports:{}};!function(t,e){var r=s,n=e&&!e.nodeType&&e,a=n&&t&&!t.nodeType&&t,i=a&&a.exports===n&&r.process,o=function(){try{var t=a&&a.require&&a.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=o}(Cr,Cr.exports);var Tr=Cr.exports,Br=zr,kr=$r,Dr=Tr&&Tr.isTypedArray,Nr=Dr?kr(Dr):Br,Vr=ur,Wr=Ar,Gr=ge,Hr=Mr,Jr=Rr,Kr=Nr,Qr=Object.prototype.hasOwnProperty;var Xr=function(t,e){var r=Gr(t),n=!r&&Wr(t),a=!r&&!n&&Hr(t),i=!r&&!n&&!a&&Kr(t),o=r||n||a||i,s=o?Vr(t.length,String):[],c=s.length;for(var u in t)!e&&!Qr.call(t,u)||o&&("length"==u||a&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Jr(u,c))||s.push(u);return s},Yr=Object.prototype;var Zr=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Yr)};var tn=function(t,e){return function(r){return t(e(r))}},en=tn(Object.keys,Object),rn=Zr,nn=en,an=Object.prototype.hasOwnProperty;var on=A,sn=Er;var cn=function(t){return null!=t&&sn(t.length)&&!on(t)},un=Xr,ln=function(t){if(!rn(t))return nn(t);var e=[];for(var r in Object(t))an.call(t,r)&&"constructor"!=r&&e.push(r);return e},fn=cn;var hn=function(t){return fn(t)?un(t):ln(t)},pn=er,vn=cr,dn=hn;var bn=function(t){return pn(t,dn,vn)},yn=bn,gn=Object.prototype.hasOwnProperty;var mn=function(t,e,r,n,a,i){var o=1&r,s=yn(t),c=s.length;if(c!=yn(e).length&&!o)return!1;for(var u=c;u--;){var l=s[u];if(!(o?l in e:gn.call(e,l)))return!1}var f=i.get(t),h=i.get(e);if(f&&h)return f==e&&h==t;var p=!0;i.set(t,e),i.set(e,t);for(var v=o;++u<c;){var d=t[l=s[u]],b=e[l];if(n)var y=o?n(b,d,l,e,t,i):n(d,b,l,t,e,i);if(!(void 0===y?d===b||a(d,b,r,n,i):y)){p=!1;break}v||(v="constructor"==l)}if(p&&!v){var g=t.constructor,m=e.constructor;g==m||!("constructor"in t)||!("constructor"in e)||"function"==typeof g&&g instanceof g&&"function"==typeof m&&m instanceof m||(p=!1)}return i.delete(t),i.delete(e),p},jn=G(l,"DataView"),wn=At,_n=G(l,"Promise"),xn=re,On=G(l,"WeakMap"),Fn=_,An=U,Ln="[object Map]",Mn="[object Promise]",Sn="[object Set]",Rn="[object WeakMap]",En="[object DataView]",In=An(jn),Un=An(wn),Pn=An(_n),qn=An(xn),zn=An(On),$n=Fn;(jn&&$n(new jn(new ArrayBuffer(1)))!=En||wn&&$n(new wn)!=Ln||_n&&$n(_n.resolve())!=Mn||xn&&$n(new xn)!=Sn||On&&$n(new On)!=Rn)&&($n=function(t){var e=Fn(t),r="[object Object]"==e?t.constructor:void 0,n=r?An(r):"";if(n)switch(n){case In:return En;case Un:return Ln;case Pn:return Mn;case qn:return Sn;case zn:return Rn}return e});var Cn=$n,Tn=Ce,Bn=De,kn=Xe,Dn=mn,Nn=Cn,Vn=ge,Wn=Mr,Gn=Nr,Hn="[object Arguments]",Jn="[object Array]",Kn="[object Object]",Qn=Object.prototype.hasOwnProperty;var Xn=function(t,e,r,n,a,i){var o=Vn(t),s=Vn(e),c=o?Jn:Nn(t),u=s?Jn:Nn(e),l=(c=c==Hn?Kn:c)==Kn,f=(u=u==Hn?Kn:u)==Kn,h=c==u;if(h&&Wn(t)){if(!Wn(e))return!1;o=!0,l=!1}if(h&&!l)return i||(i=new Tn),o||Gn(t)?Bn(t,e,r,n,a,i):kn(t,e,c,r,n,a,i);if(!(1&r)){var p=l&&Qn.call(t,"__wrapped__"),v=f&&Qn.call(e,"__wrapped__");if(p||v){var d=p?t.value():t,b=v?e.value():e;return i||(i=new Tn),a(d,b,r,n,i)}}return!!h&&(i||(i=new Tn),Dn(t,e,r,n,a,i))},Yn=je;var Zn=function t(e,r,n,a,i){return e===r||(null==e||null==r||!Yn(e)&&!Yn(r)?e!=e&&r!=r:Xn(e,r,n,a,t,i))},ta=Ce,ea=Zn;var ra=x;var na=function(t){return t==t&&!ra(t)},aa=na,ia=hn;var oa=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}},sa=function(t,e,r,n){var a=r.length,i=a,o=!n;if(null==t)return!i;for(t=Object(t);a--;){var s=r[a];if(o&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++a<i;){var c=(s=r[a])[0],u=t[c],l=s[1];if(o&&s[2]){if(void 0===u&&!(c in t))return!1}else{var f=new ta;if(n)var h=n(u,l,c,t,e,f);if(!(void 0===h?ea(l,u,3,n,f):h))return!1}}return!0},ca=function(t){for(var e=ia(t),r=e.length;r--;){var n=e[r],a=t[n];e[r]=[n,a,aa(a)]}return e},ua=oa;var la=function(t){var e=ca(t);return 1==e.length&&e[0][2]?ua(e[0][0],e[0][1]):function(r){return r===t||sa(r,t,e)}},fa=_,ha=je;var pa=function(t){return"symbol"==typeof t||ha(t)&&"[object Symbol]"==fa(t)},va=ge,da=pa,ba=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ya=/^\w*$/;var ga=function(t,e){if(va(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!da(t))||(ya.test(t)||!ba.test(t)||null!=e&&t in Object(e))},ma=Dt;function ja(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,a=e?e.apply(this,n):n[0],i=r.cache;if(i.has(a))return i.get(a);var o=t.apply(this,n);return r.cache=i.set(a,o)||i,o};return r.cache=new(ja.Cache||ma),r}ja.Cache=ma;var wa=ja;var _a=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xa=/\\(\\)?/g,Oa=function(t){var e=wa(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(_a,(function(t,r,n,a){e.push(n?a.replace(xa,"$1"):r||t)})),e}));var Fa=function(t,e){for(var r=-1,n=null==t?0:t.length,a=Array(n);++r<n;)a[r]=e(t[r],r,t);return a},Aa=ge,La=pa,Ma=f?f.prototype:void 0,Sa=Ma?Ma.toString:void 0;var Ra=function t(e){if("string"==typeof e)return e;if(Aa(e))return Fa(e,t)+"";if(La(e))return Sa?Sa.call(e):"";var r=e+"";return"0"==r&&1/e==-Infinity?"-0":r},Ea=Ra;var Ia=ge,Ua=ga,Pa=Oa,qa=function(t){return null==t?"":Ea(t)};var za=function(t,e){return Ia(t)?t:Ua(t,e)?[t]:Pa(qa(t))},$a=pa;var Ca=function(t){if("string"==typeof t||$a(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e},Ta=za,Ba=Ca;var ka=function(t,e){for(var r=0,n=(e=Ta(e,t)).length;null!=t&&r<n;)t=t[Ba(e[r++])];return r&&r==n?t:void 0},Da=ka;var Na=za,Va=Ar,Wa=ge,Ga=Rr,Ha=Er,Ja=Ca;var Ka=function(t,e){return null!=t&&e in Object(t)},Qa=function(t,e,r){for(var n=-1,a=(e=Na(e,t)).length,i=!1;++n<a;){var o=Ja(e[n]);if(!(i=null!=t&&r(t,o)))break;t=t[o]}return i||++n!=a?i:!!(a=null==t?0:t.length)&&Ha(a)&&Ga(o,a)&&(Wa(t)||Va(t))};var Xa=Zn,Ya=function(t,e,r){var n=null==t?void 0:Da(t,e);return void 0===n?r:n},Za=function(t,e){return null!=t&&Qa(t,e,Ka)},ti=ga,ei=na,ri=oa,ni=Ca;var ai=ka;var ii=function(t){return function(e){return null==e?void 0:e[t]}},oi=function(t){return function(e){return ai(e,t)}},si=ga,ci=Ca;var ui=la,li=function(t,e){return ti(t)&&ei(e)?ri(ni(t),e):function(r){var n=Ya(r,t);return void 0===n&&n===e?Za(r,t):Xa(e,n,3)}},fi=function(t){return t},hi=ge,pi=function(t){return si(t)?ii(ci(t)):oi(t)};var vi=function(t){return"function"==typeof t?t:null==t?fi:"object"==typeof t?hi(t)?li(t[0],t[1]):ui(t):pi(t)},di=vi,bi=pe;const yi=o((function(t,e){return t&&t.length?bi(t,di(e)):[]}));class gi{constructor(t,e){n(this,"language"),n(this,"region"),n(this,"script"),n(this,"isRtl"),n(this,"name"),n(this,"localizedName"),n(this,"uri"),n(this,"timestamp"),n(this,"baseLocale"),this.language=t.language,this.region=t.region,this.script=t.script,this.isRtl=t.isRtl,this.name=t.name,this.localizedName=t.localizedName,this.uri=t.uri,this.timestamp=t.timestamp,this.baseLocale=e}get locale(){return this.language&&this.region&&this.script?`${this.language}_${this.region}#${this.script}`:this.language&&this.script?`${this.language}#${this.script}`:this.language&&this.region?`${this.language}_${this.region}`:this.language}get isBaseLocale(){return this.locale===this.baseLocale}toCdnLocale(){return{locale:this.locale,isBaseLocale:this.isBaseLocale,language:this.language,region:this.region,script:this.script,isRtl:this.isRtl,name:this.name,localizedName:this.localizedName}}}class mi{constructor(t){n(this,"id"),n(this,"file"),n(this,"path"),n(this,"library"),n(this,"module"),n(this,"buildType"),n(this,"timestamp"),n(this,"productFlavors"),n(this,"locales"),n(this,"baseUrl"),this.id=t.id,this.file=t.file,this.path=t.path,this.library=t.library,this.module=t.module,this.buildType=t.buildType,this.timestamp=t.timestamp,this.productFlavors=t.productFlavors,this.locales=t.locales,this.baseUrl=t.baseUrl}toCdnFile(){return{id:this.id,file:this.file,path:this.path,library:this.library,module:this.module,buildType:this.buildType,productFlavors:this.productFlavors,locales:this.locales.map((t=>({locale:t.locale,isBaseLocale:t.isBaseLocale,uri:`${this.baseUrl}${t.uri}`})))}}}class ji{constructor(t,e){n(this,"projectUrl"),n(this,"baseLocale"),n(this,"locales"),n(this,"timestamp"),n(this,"files"),n(this,"filesMap"),this.projectUrl=t.projectUrl,this.timestamp=t.timestamp,this.files=ji.filesFactory(t.files,t.baseLocale,e),this.filesMap=ji.filesMapFactory(this.files),this.locales=ji.localesFactory(this.files),this.baseLocale=this.locales.find((t=>t.isBaseLocale))}static createEmpty(t){return new ji({projectUrl:"",baseLocale:"",timestamp:0,files:{}},t)}static filesFactory(t,e,r){return Object.keys(t).reduce(((n,a)=>{const i=t[a].locales.map((t=>new gi(t,e)));return n.push(new mi({...t[a],id:a,locales:i,baseUrl:r.baseUrl})),n}),[])}static filesMapFactory(t){return t.reduce(((t,e)=>(t[e.id]=e,t)),{})}static localesFactory(t){const e=t.reduce(((t,e)=>(t.push(...e.locales.map((t=>t.toCdnLocale()))),t)),[]);return yi(e,(t=>t.locale))}}class wi{constructor(t){n(this,"options"),this.options=wi.parseMetafileUrl(t)}get url(){return this.options.url}get baseUrl(){return this.options.baseUrl}get cdnId(){return this.options.cdnId}get jsonPath(){return this.options.jsonPath}static parseMetafileUrl(t){let e;try{e=new URL(t)}catch(t){throw new Error('Invalid param: "options.metafile" cannot be parsed as url.')}const r=e.pathname.match(/^\/(.*?)\/(.*?)\.(v2.json|js|ts)$/);if(null===r||4!==r.length)throw new Error('Invalid param: "options.metafile" contains invalid metafile url.');const n=r[1],a=r[2];return{url:t,baseUrl:e.origin,cdnId:n,jsonPath:`/${n}/${a}.v2.json`}}}class _i{constructor(t){n(this,"params"),n(this,"parsedData"),n(this,"data"),this.params=new wi(t.metafile),this.parsedData=null,this.data=ji.createEmpty(this.params)}setMetafile(t){this.parsedData=t,this.data=new ji(t,this.params)}}class xi{constructor(t){n(this,"context"),this.context=t}createCdnResponse(t){const{responses:e,hasSingleFileResponse:r,hasSingleLocaleResponse:n}=t;return 0===e.length?{}:(this.cacheResponses(e),r&&n?e[0].data:xi.transformResponsesToOutput(t))}cacheResponses(t){t.forEach((t=>{const{metafileFile:e,metafileLocale:r}=xi.extractReference(t);e&&r&&this.context.cache.setIfMissed({metafileFile:e,metafileLocale:r,data:t.data})}))}static transformResponsesToOutput(t){const{responses:e,hasSingleFileResponse:r}=t;return e.reduce(((t,e)=>{const{metafileFile:n,metafileLocale:a}=xi.extractReference(e);return n&&a&&(r?t[a.locale]=e.data:(t[n.id]||(t[n.id]={}),t[n.id][a.locale]=e.data)),t}),{})}static extractReference(t){var e,r;const n=null==(e=t.config.reference)?void 0:e.metafileFile,a=null==(r=t.config.reference)?void 0:r.metafileLocale,{data:i}=t;return{metafileFile:n,metafileLocale:a,data:i}}}class Oi{constructor(t){n(this,"metafile"),n(this,"cdn"),n(this,"client"),n(this,"api"),n(this,"cache"),n(this,"responseFactory"),this.metafile=t.metafileContext,this.cdn=t.cdn,this.client=t.client,this.api=new a(this),this.cache=new ye(this),this.responseFactory=new xi(this)}}var Fi=function(t){return function(e,r,n){for(var a=-1,i=Object(e),o=n(e),s=o.length;s--;){var c=o[t?s:++a];if(!1===r(i[c],c,i))break}return e}}(),Ai=hn;var Li=cn;var Mi=function(t,e){return function(r,n){if(null==r)return r;if(!Li(r))return t(r,n);for(var a=r.length,i=e?a:-1,o=Object(r);(e?i--:++i<a)&&!1!==n(o[i],i,o););return r}}((function(t,e){return t&&Fi(t,e,Ai)}));var Si=rr,Ri=function(t,e){var r=[];return Mi(t,(function(t,n,a){e(t,n,a)&&r.push(t)})),r},Ei=vi,Ii=ge;const Ui=o((function(t,e){return(Ii(t)?Si:Ri)(t,Ei(e))}));var Pi=vi,qi=cn,zi=hn;var $i=function(t){return function(e,r,n){var a=Object(e);if(!qi(e)){var i=Pi(r);e=zi(e),r=function(t){return i(a[t],t,a)}}var o=t(e,r,n);return o>-1?a[i?e[o]:o]:void 0}},Ci=/\s/;var Ti=function(t){for(var e=t.length;e--&&Ci.test(t.charAt(e)););return e},Bi=/^\s+/;var ki=function(t){return t?t.slice(0,Ti(t)+1).replace(Bi,""):t},Di=x,Ni=pa,Vi=/^[-+]0x[0-9a-f]+$/i,Wi=/^0b[01]+$/i,Gi=/^0o[0-7]+$/i,Hi=parseInt;var Ji=function(t){if("number"==typeof t)return t;if(Ni(t))return NaN;if(Di(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Di(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ki(t);var r=Wi.test(t);return r||Gi.test(t)?Hi(t.slice(2),r?2:8):Vi.test(t)?NaN:+t},Ki=1/0;var Qi=function(t){return t?(t=Ji(t))===Ki||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var Xi=Jt,Yi=vi,Zi=function(t){var e=Qi(t),r=e%1;return e==e?r?e-r:e:0},to=Math.max;const eo=o($i((function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var a=null==r?0:Zi(r);return a<0&&(a=to(n+a,0)),Xi(t,Yi(e),a)})));var ro=tn(Object.getPrototypeOf,Object),no=_,ao=ro,io=je,oo=Function.prototype,so=Object.prototype,co=oo.toString,uo=so.hasOwnProperty,lo=co.call(Object);const fo=o((function(t){if(!io(t)||"[object Object]"!=no(t))return!1;var e=ao(t);if(null===e)return!0;var r=uo.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&co.call(r)==lo}));var ho=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},po=G,vo=function(){try{var t=po(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var bo=function(t,e,r){"__proto__"==e&&vo?vo(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r},yo=bo,go=ft,mo=Object.prototype.hasOwnProperty;var jo=function(t,e,r){var n=t[e];mo.call(t,e)&&go(n,r)&&(void 0!==r||e in t)||yo(t,e,r)},wo=jo,_o=bo;var xo=function(t,e,r,n){var a=!r;r||(r={});for(var i=-1,o=e.length;++i<o;){var s=e[i],c=n?n(r[s],t[s],s,r,t):void 0;void 0===c&&(c=t[s]),a?_o(r,s,c):wo(r,s,c)}return r},Oo=xo,Fo=hn;var Ao=function(t,e){return t&&Oo(e,Fo(e),t)};var Lo=x,Mo=Zr,So=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},Ro=Object.prototype.hasOwnProperty;var Eo=Xr,Io=function(t){if(!Lo(t))return So(t);var e=Mo(t),r=[];for(var n in t)("constructor"!=n||!e&&Ro.call(t,n))&&r.push(n);return r},Uo=cn;var Po=function(t){return Uo(t)?Eo(t,!0):Io(t)},qo=xo,zo=Po;var $o=function(t,e){return t&&qo(e,zo(e),t)},Co={exports:{}};!function(t,e){var r=l,n=e&&!e.nodeType&&e,a=n&&t&&!t.nodeType&&t,i=a&&a.exports===n?r.Buffer:void 0,o=i?i.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=o?o(r):new t.constructor(r);return t.copy(n),n}}(Co,Co.exports);var To=Co.exports;var Bo=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e},ko=xo,Do=cr;var No=function(t,e){return ko(t,Do(t),e)},Vo=Ye,Wo=ro,Go=cr,Ho=nr,Jo=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Vo(e,Go(t)),t=Wo(t);return e}:Ho,Ko=xo,Qo=Jo;var Xo=function(t,e){return Ko(t,Qo(t),e)},Yo=er,Zo=Jo,ts=Po;var es=function(t){return Yo(t,ts,Zo)},rs=Object.prototype.hasOwnProperty;var ns=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&rs.call(t,"index")&&(r.index=t.index,r.input=t.input),r},as=Ne;var is=function(t){var e=new t.constructor(t.byteLength);return new as(e).set(new as(t)),e},os=is;var ss=function(t,e){var r=e?os(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)},cs=/\w*$/;var us=function(t){var e=new t.constructor(t.source,cs.exec(t));return e.lastIndex=t.lastIndex,e},ls=f?f.prototype:void 0,fs=ls?ls.valueOf:void 0;var hs=is;var ps=is,vs=ss,ds=us,bs=function(t){return fs?Object(fs.call(t)):{}},ys=function(t,e){var r=e?hs(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};var gs=function(t,e,r){var n=t.constructor;switch(e){case"[object ArrayBuffer]":return ps(t);case"[object Boolean]":case"[object Date]":return new n(+t);case"[object DataView]":return vs(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return ys(t,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(t);case"[object RegExp]":return ds(t);case"[object Symbol]":return bs(t)}},ms=x,js=Object.create,ws=function(){function t(){}return function(e){if(!ms(e))return{};if(js)return js(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),_s=ro,xs=Zr;var Os=function(t){return"function"!=typeof t.constructor||xs(t)?{}:ws(_s(t))},Fs=Cn,As=je;var Ls=function(t){return As(t)&&"[object Map]"==Fs(t)},Ms=$r,Ss=Tr&&Tr.isMap,Rs=Ss?Ms(Ss):Ls,Es=Cn,Is=je;var Us=function(t){return Is(t)&&"[object Set]"==Es(t)},Ps=$r,qs=Tr&&Tr.isSet,zs=qs?Ps(qs):Us,$s=Ce,Cs=ho,Ts=jo,Bs=Ao,ks=$o,Ds=To,Ns=Bo,Vs=No,Ws=Xo,Gs=bn,Hs=es,Js=Cn,Ks=ns,Qs=gs,Xs=Os,Ys=ge,Zs=Mr,tc=Rs,ec=x,rc=zs,nc=hn,ac=Po,ic="[object Arguments]",oc="[object Function]",sc="[object Object]",cc={};cc[ic]=cc["[object Array]"]=cc["[object ArrayBuffer]"]=cc["[object DataView]"]=cc["[object Boolean]"]=cc["[object Date]"]=cc["[object Float32Array]"]=cc["[object Float64Array]"]=cc["[object Int8Array]"]=cc["[object Int16Array]"]=cc["[object Int32Array]"]=cc["[object Map]"]=cc["[object Number]"]=cc[sc]=cc["[object RegExp]"]=cc["[object Set]"]=cc["[object String]"]=cc["[object Symbol]"]=cc["[object Uint8Array]"]=cc["[object Uint8ClampedArray]"]=cc["[object Uint16Array]"]=cc["[object Uint32Array]"]=!0,cc["[object Error]"]=cc[oc]=cc["[object WeakMap]"]=!1;var uc=function t(e,r,n,a,i,o){var s,c=1&r,u=2&r,l=4&r;if(n&&(s=i?n(e,a,i,o):n(e)),void 0!==s)return s;if(!ec(e))return e;var f=Ys(e);if(f){if(s=Ks(e),!c)return Ns(e,s)}else{var h=Js(e),p=h==oc||"[object GeneratorFunction]"==h;if(Zs(e))return Ds(e,c);if(h==sc||h==ic||p&&!i){if(s=u||p?{}:Xs(e),!c)return u?Ws(e,ks(s,e)):Vs(e,Bs(s,e))}else{if(!cc[h])return i?e:{};s=Qs(e,h,c)}}o||(o=new $s);var v=o.get(e);if(v)return v;o.set(e,s),rc(e)?e.forEach((function(a){s.add(t(a,r,n,a,e,o))})):tc(e)&&e.forEach((function(a,i){s.set(i,t(a,r,n,i,e,o))}));var d=f?void 0:(l?u?Hs:Gs:u?ac:nc)(e);return Cs(d||e,(function(a,i){d&&(a=e[i=a]),Ts(s,i,t(a,r,n,i,e,o))})),s},lc=uc,fc=la;const hc=o((function(t){return fc(lc(t,1))})),pc=class t extends Fe{constructor(){super(...arguments),n(this,"list",(()=>t.transformFiles(this.context.metafile.data.files))),n(this,"filter",(e=>{if(!e)throw new Error('Invalid param: missing required "options" parameter.');if(!L(e)&&!fo(e))throw new Error('Invalid param: "options" must be function or object.');const r=t.transformFiles(this.context.metafile.data.files);return L(e)?r.filter(e):Ui(r,hc(e))})),n(this,"find",(e=>{if(!e)throw new Error('Invalid param: missing required "options" parameter.');if(!L(e)&&!fo(e))throw new Error('Invalid param: "options" must be function or object.');const r=t.transformFiles(this.context.metafile.data.files);return L(e)?r.find(e):eo(r,hc(e))})),n(this,"first",(()=>{if(0===this.context.metafile.data.files.length)throw new Error("File is missing in downloaded metafile.");return t.transformFiles(this.context.metafile.data.files)[0]}))}};n(pc,"transformFiles",(t=>t.map((t=>t.toCdnFile()))));let vc=pc;class dc extends Fe{constructor(t){super(t),n(this,"files"),n(this,"locales",(t=>{const{excludeBaseLocale:e}=t||{},{locales:r}=this.context.metafile.data;return e?r.filter((t=>!t.isBaseLocale)):r})),n(this,"refresh",(async t=>{const e=await this.context.api.fetchMetafile(t);this.context.metafile.setMetafile(e.data)})),n(this,"switch",(async(t,e)=>{this.context.metafile.params=new wi(t.metafile),await this.refresh(e)})),this.files=new vc(t)}get projectUrl(){return this.context.metafile.data.projectUrl}get baseLocale(){return this.context.metafile.data.baseLocale}get url(){return this.context.metafile.params.url}}const bc=o((function(t){return void 0===t}));class yc{constructor(t){n(this,"data"),n(this,"context"),this.context=t.context,this.data=t.data||{}}}class gc{constructor(t){n(this,"files"),n(this,"localesMap"),n(this,"hasSingleFileResponse"),n(this,"hasSingleLocaleResponse"),n(this,"context"),this.files=[],this.localesMap=new yc({context:t}),this.hasSingleFileResponse=!1,this.hasSingleLocaleResponse=!1,this.context=t}async execute(){return this.context.responseFactory.createCdnResponse({responses:await Promise.all(this.getPromises()),localesMap:this.localesMap,hasSingleFileResponse:this.hasSingleFileResponse,hasSingleLocaleResponse:this.hasSingleLocaleResponse})}getPromises(){return this.files.reduce(((t,e)=>(this.localesMap.data[e.id]&&t.push(...this.localesMap.data[e.id].map((t=>this.context.api.fetchLocale({metafileFile:e,metafileLocale:t})))),t)),[])}}class mc{constructor(t){n(this,"context"),n(this,"request"),this.context=t,this.request=new gc(this.context)}addFiles(t){if(!(fo(t)||Oe(t)||bc(t)||me(t)))throw new Error('Invalid param: "request.files" must be object, array, string or undefined.');if(me(t)&&t.forEach((t=>{if(!fo(t)&&!Oe(t))throw new Error('Invalid param: array "request.files" must contain objects or strings.')})),Oe(t)){this.request.hasSingleFileResponse=!0;const e=this.context.metafile.data.files.find((e=>e.id===t));if(!(e instanceof mi))throw new Error(`File not found: "${t}".`);this.request.files=[e]}else if(bc(t))this.request.files=[...this.context.metafile.data.files];else if(me(t))this.request.files=t.map((t=>{let e;if(Oe(t)){const r=this.context.metafile.data.files.find((e=>e.id===t));if(bc(r))throw new Error(`File not found: "${t}".`);e=r}else{const r=this.context.metafile.data.files.find((e=>e.id===t.id));if(bc(r))throw new Error(`File not found: "${t.id}".`);e=r}return e}));else if(fo(t)){this.request.hasSingleFileResponse=!0;const e=this.context.metafile.data.files.find((e=>e.id===t.id));if(bc(e))throw new Error(`File not found: "${t.id}".`);this.request.files=[e]}return this}addLocales(t,e){if(!(Oe(t)||bc(t)||me(t)))throw new Error('Invalid param: "request.locales" must be array, string or undefined.');return me(t)&&t.forEach((t=>{if(!Oe(t))throw new Error('Invalid param: array "request.locales" must contain strings.')})),Oe(t)?(this.request.hasSingleLocaleResponse=!0,this.request.files.reduce(((e,r)=>(e.data[r.id]=r.locales.filter((e=>e.locale===t)),e)),this.request.localesMap)):bc(t)?this.request.files.reduce(((t,r)=>(t.data[r.id]=e?r.locales.filter((t=>!t.isBaseLocale)):r.locales,t)),this.request.localesMap):me(t)&&this.request.files.reduce(((e,r)=>(e.data[r.id]=r.locales.filter((e=>t.includes(e.locale))),e)),this.request.localesMap),this}getCdnRequest(){const t=this.request;return this.request=new gc(this.context),t}}class jc{constructor(t,e){n(this,"client"),this.client=jc.clientFactory(t,e)}static clientFactory(t,r){const n={baseURL:t,...r};return e.create(n)}get(t,e){return this.client.get(t,e)}}class wc{constructor(t,e){n(this,"metafile"),n(this,"cache"),n(this,"context"),n(this,"fetch",(async t=>{const{files:e,locales:r,excludeBaseLocale:n}=t||{};return new mc(this.context).addFiles(e).addLocales(r,n).getCdnRequest().execute()}));const r=new _i(t),a=new jc(r.params.baseUrl,e);this.context=new Oi({metafileContext:r,cdn:this,client:a}),this.metafile=new dc(this.context),this.cache=new Ae(this.context)}static async create(t,e){if(!t)throw new Error('Invalid param: missing required "options" parameter.');if(!Oe(t.metafile))throw new Error('Invalid param: "options.metafile" must be string.');const r=new wc(t,e);return await r.metafile.refresh(e),r}}t.Api=a,t.AxiosHttpAdapter=jc,t.CdnBase=Fe,t.CdnCache=Ae,t.CdnClient=wc,t.CdnMetafile=dc,t.CdnMetafileFiles=vc,t.Context=Oi,t.LocalesCache=ye,t.LocalesMap=yc,t.MemoryCacheAdapter=be,t.MetafileContext=_i,t.MetafileData=ji,t.MetafileFile=mi,t.MetafileLocale=gi,t.MetafileParams=wi,t.Request=gc,t.RequestBuilder=mc,t.ResponseFactory=xi,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
|
5
|
+
class n{constructor(t){r(this,"context"),this.context=t}async fetchLocale(t){return this.context.cache.has(t)?new Promise((e=>{e(this.context.cache.get(t))})):this.context.client.get(t.metafileLocale.uri)}async fetchMetafile(){return await this.context.client.get(this.context.metafile.params.jsonPath)}}var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var o="object"==typeof a&&a&&a.Object===Object&&a,s=o,c="object"==typeof self&&self&&self.Object===Object&&self,u=s||c||Function("return this")(),l=u.Symbol,f=l,h=Object.prototype,p=h.hasOwnProperty,v=h.toString,d=f?f.toStringTag:void 0;var b=function(t){var e=p.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var a=v.call(t);return n&&(e?t[d]=r:delete t[d]),a},y=Object.prototype.toString;var g=b,m=function(t){return y.call(t)},j=l?l.toStringTag:void 0;var w=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":j&&j in Object(t)?g(t):m(t)};var _=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},x=w,O=_;var F=function(t){if(!O(t))return!1;var e=x(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e};const A=i(F);var L,M=u["__core-js_shared__"],S=(L=/[^.]+$/.exec(M&&M.keys&&M.keys.IE_PROTO||""))?"Symbol(src)_1."+L:"";var E=function(t){return!!S&&S in t},R=Function.prototype.toString;var U=function(t){if(null!=t){try{return R.call(t)}catch(t){}try{return t+""}catch(t){}}return""},q=F,I=E,P=_,$=U,z=/^\[object .+?Constructor\]$/,C=Function.prototype,B=Object.prototype,T=C.toString,k=B.hasOwnProperty,D=RegExp("^"+T.call(k).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var N=function(t){return!(!P(t)||I(t))&&(q(t)?D:z).test($(t))},V=function(t,e){return null==t?void 0:t[e]};var W=function(t,e){var r=V(t,e);return N(r)?r:void 0},G=W(Object,"create"),H=G;var J=function(){this.__data__=H?H(null):{},this.size=0};var K=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Q=G,X=Object.prototype.hasOwnProperty;var Y=function(t){var e=this.__data__;if(Q){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return X.call(e,t)?e[t]:void 0},Z=G,tt=Object.prototype.hasOwnProperty;var et=G;var rt=J,nt=K,at=Y,it=function(t){var e=this.__data__;return Z?void 0!==e[t]:tt.call(e,t)},ot=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=et&&void 0===e?"__lodash_hash_undefined__":e,this};function st(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}st.prototype.clear=rt,st.prototype.delete=nt,st.prototype.get=at,st.prototype.has=it,st.prototype.set=ot;var ct=st;var ut=function(){this.__data__=[],this.size=0};var lt=function(t,e){return t===e||t!=t&&e!=e},ft=lt;var ht=function(t,e){for(var r=t.length;r--;)if(ft(t[r][0],e))return r;return-1},pt=ht,vt=Array.prototype.splice;var dt=ht;var bt=ht;var yt=ht;var gt=ut,mt=function(t){var e=this.__data__,r=pt(e,t);return!(r<0)&&(r==e.length-1?e.pop():vt.call(e,r,1),--this.size,!0)},jt=function(t){var e=this.__data__,r=dt(e,t);return r<0?void 0:e[r][1]},wt=function(t){return bt(this.__data__,t)>-1},_t=function(t,e){var r=this.__data__,n=yt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function xt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}xt.prototype.clear=gt,xt.prototype.delete=mt,xt.prototype.get=jt,xt.prototype.has=wt,xt.prototype.set=_t;var Ot=xt,Ft=W(u,"Map"),At=ct,Lt=Ot,Mt=Ft;var St=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Et=function(t,e){var r=t.__data__;return St(e)?r["string"==typeof e?"string":"hash"]:r.map},Rt=Et;var Ut=Et;var qt=Et;var It=Et;var Pt=function(){this.size=0,this.__data__={hash:new At,map:new(Mt||Lt),string:new At}},$t=function(t){var e=Rt(this,t).delete(t);return this.size-=e?1:0,e},zt=function(t){return Ut(this,t).get(t)},Ct=function(t){return qt(this,t).has(t)},Bt=function(t,e){var r=It(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Tt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Tt.prototype.clear=Pt,Tt.prototype.delete=$t,Tt.prototype.get=zt,Tt.prototype.has=Ct,Tt.prototype.set=Bt;var kt=Tt;var Dt=kt,Nt=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Vt=function(t){return this.__data__.has(t)};function Wt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Dt;++e<r;)this.add(t[e])}Wt.prototype.add=Wt.prototype.push=Nt,Wt.prototype.has=Vt;var Gt=Wt;var Ht=function(t,e,r,n){for(var a=t.length,i=r+(n?1:-1);n?i--:++i<a;)if(e(t[i],i,t))return i;return-1};var Jt=Ht,Kt=function(t){return t!=t},Qt=function(t,e,r){for(var n=r-1,a=t.length;++n<a;)if(t[n]===e)return n;return-1};var Xt=function(t,e,r){return e==e?Qt(t,e,r):Jt(t,Kt,r)};var Yt=function(t,e){return!!(null==t?0:t.length)&&Xt(t,e,0)>-1};var Zt=function(t,e,r){for(var n=-1,a=null==t?0:t.length;++n<a;)if(r(e,t[n]))return!0;return!1};var te=function(t,e){return t.has(e)},ee=W(u,"Set");var re=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},ne=ee,ae=function(){},ie=ne&&1/re(new ne([,-0]))[1]==1/0?function(t){return new ne(t)}:ae,oe=Gt,se=Yt,ce=Zt,ue=te,le=ie,fe=re;var he=function(t,e,r){var n=-1,a=se,i=t.length,o=!0,s=[],c=s;if(r)o=!1,a=ce;else if(i>=200){var u=e?null:le(t);if(u)return fe(u);o=!1,a=ue,c=new oe}else c=e?[]:s;t:for(;++n<i;){var l=t[n],f=e?e(l):l;if(l=r||0!==l?l:0,o&&f==f){for(var h=c.length;h--;)if(c[h]===f)continue t;e&&c.push(f),s.push(l)}else a(c,f,r)||(c!==s&&c.push(f),s.push(l))}return s},pe=he;const ve=i((function(t){return t&&t.length?pe(t):[]}));class de{constructor(){r(this,"map"),this.map=new Map}get(t){return this.map.get(t)}has(t){return this.map.has(t)}set(t,e){this.map.set(t,e)}flush(){this.map=new Map}}class be{constructor(t){r(this,"context"),r(this,"cacheAdapter"),this.context=t,this.cacheAdapter=new de}setIfMissed(t){const{metafileFile:e,metafileLocale:r,data:n}=t,a=this.keyFromMetafile({metafileFile:e,metafileLocale:r});this.cacheAdapter.has(a)||this.cacheAdapter.set(a,n)}has(t){const e=this.keyFromMetafile(t);return this.cacheAdapter.has(e)}get(t){const e=this.keyFromMetafile(t);return this.cacheAdapter.get(e)}flush(){this.cacheAdapter.flush()}keyFromMetafile(t){const{metafileFile:e,metafileLocale:r}=t,n=[...ve(e.productFlavors)].sort().join("-");return[this.context.metafile.params.cdnId,e.id,e.file,e.path,e.library,e.module,e.buildType,n,r.locale,r.timestamp.toString()].filter((t=>""!==t)).join("-")}}var ye=Array.isArray;const ge=i(ye);var me=function(t){return null!=t&&"object"==typeof t},je=w,we=ye,_e=me;const xe=i((function(t){return"string"==typeof t||!we(t)&&_e(t)&&"[object String]"==je(t)}));class Oe{constructor(t){r(this,"context"),this.context=t}}class Fe extends Oe{constructor(){super(...arguments),r(this,"flush",(()=>{this.context.cache.flush()}))}}var Ae=Ot;var Le=Ot,Me=Ft,Se=kt;var Ee=Ot,Re=function(){this.__data__=new Ae,this.size=0},Ue=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},qe=function(t){return this.__data__.get(t)},Ie=function(t){return this.__data__.has(t)},Pe=function(t,e){var r=this.__data__;if(r instanceof Le){var n=r.__data__;if(!Me||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Se(n)}return r.set(t,e),this.size=r.size,this};function $e(t){var e=this.__data__=new Ee(t);this.size=e.size}$e.prototype.clear=Re,$e.prototype.delete=Ue,$e.prototype.get=qe,$e.prototype.has=Ie,$e.prototype.set=Pe;var ze=$e;var Ce=Gt,Be=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1},Te=te;var ke=function(t,e,r,n,a,i){var o=1&r,s=t.length,c=e.length;if(s!=c&&!(o&&c>s))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var f=-1,h=!0,p=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++f<s;){var v=t[f],d=e[f];if(n)var b=o?n(d,v,f,e,t,i):n(v,d,f,t,e,i);if(void 0!==b){if(b)continue;h=!1;break}if(p){if(!Be(e,(function(t,e){if(!Te(p,e)&&(v===t||a(v,t,r,n,i)))return p.push(e)}))){h=!1;break}}else if(v!==d&&!a(v,d,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h},De=u.Uint8Array;var Ne=De,Ve=lt,We=ke,Ge=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r},He=re,Je=l?l.prototype:void 0,Ke=Je?Je.valueOf:void 0;var Qe=function(t,e,r,n,a,i,o){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new Ne(t),new Ne(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Ve(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var s=Ge;case"[object Set]":var c=1&n;if(s||(s=He),t.size!=e.size&&!c)return!1;var u=o.get(t);if(u)return u==e;n|=2,o.set(t,e);var l=We(s(t),s(e),n,a,i,o);return o.delete(t),l;case"[object Symbol]":if(Ke)return Ke.call(t)==Ke.call(e)}return!1};var Xe=function(t,e){for(var r=-1,n=e.length,a=t.length;++r<n;)t[a+r]=e[r];return t},Ye=Xe,Ze=ye;var tr=function(t,e,r){var n=e(t);return Ze(t)?n:Ye(n,r(t))};var er=function(t,e){for(var r=-1,n=null==t?0:t.length,a=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[a++]=o)}return i};var rr=function(){return[]},nr=er,ar=rr,ir=Object.prototype.propertyIsEnumerable,or=Object.getOwnPropertySymbols,sr=or?function(t){return null==t?[]:(t=Object(t),nr(or(t),(function(e){return ir.call(t,e)})))}:ar;var cr=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n},ur=w,lr=me;var fr,hr,pr,vr,dr,br,yr,gr,mr=function(t){return lr(t)&&"[object Arguments]"==ur(t)},jr=me,wr=Object.prototype,_r=wr.hasOwnProperty,xr=wr.propertyIsEnumerable,Or=mr(function(){return arguments}())?mr:function(t){return jr(t)&&_r.call(t,"callee")&&!xr.call(t,"callee")},Fr=Or,Ar={exports:{}};fr=Ar,pr=u,vr=function(){return!1},dr=(hr=Ar.exports)&&!hr.nodeType&&hr,br=dr&&fr&&!fr.nodeType&&fr,yr=br&&br.exports===dr?pr.Buffer:void 0,gr=(yr?yr.isBuffer:void 0)||vr,fr.exports=gr;var Lr=Ar.exports,Mr=/^(?:0|[1-9]\d*)$/;var Sr=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Mr.test(t))&&t>-1&&t%1==0&&t<e};var Er=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Rr=w,Ur=Er,qr=me,Ir={};Ir["[object Float32Array]"]=Ir["[object Float64Array]"]=Ir["[object Int8Array]"]=Ir["[object Int16Array]"]=Ir["[object Int32Array]"]=Ir["[object Uint8Array]"]=Ir["[object Uint8ClampedArray]"]=Ir["[object Uint16Array]"]=Ir["[object Uint32Array]"]=!0,Ir["[object Arguments]"]=Ir["[object Array]"]=Ir["[object ArrayBuffer]"]=Ir["[object Boolean]"]=Ir["[object DataView]"]=Ir["[object Date]"]=Ir["[object Error]"]=Ir["[object Function]"]=Ir["[object Map]"]=Ir["[object Number]"]=Ir["[object Object]"]=Ir["[object RegExp]"]=Ir["[object Set]"]=Ir["[object String]"]=Ir["[object WeakMap]"]=!1;var Pr=function(t){return qr(t)&&Ur(t.length)&&!!Ir[Rr(t)]};var $r=function(t){return function(e){return t(e)}},zr={exports:{}};!function(t,e){var r=o,n=e&&!e.nodeType&&e,a=n&&t&&!t.nodeType&&t,i=a&&a.exports===n&&r.process,s=function(){try{var t=a&&a.require&&a.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=s}(zr,zr.exports);var Cr=zr.exports,Br=Pr,Tr=$r,kr=Cr&&Cr.isTypedArray,Dr=kr?Tr(kr):Br,Nr=cr,Vr=Fr,Wr=ye,Gr=Lr,Hr=Sr,Jr=Dr,Kr=Object.prototype.hasOwnProperty;var Qr=function(t,e){var r=Wr(t),n=!r&&Vr(t),a=!r&&!n&&Gr(t),i=!r&&!n&&!a&&Jr(t),o=r||n||a||i,s=o?Nr(t.length,String):[],c=s.length;for(var u in t)!e&&!Kr.call(t,u)||o&&("length"==u||a&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Hr(u,c))||s.push(u);return s},Xr=Object.prototype;var Yr=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Xr)};var Zr=function(t,e){return function(r){return t(e(r))}},tn=Zr(Object.keys,Object),en=Yr,rn=tn,nn=Object.prototype.hasOwnProperty;var an=F,on=Er;var sn=function(t){return null!=t&&on(t.length)&&!an(t)},cn=Qr,un=function(t){if(!en(t))return rn(t);var e=[];for(var r in Object(t))nn.call(t,r)&&"constructor"!=r&&e.push(r);return e},ln=sn;var fn=function(t){return ln(t)?cn(t):un(t)},hn=tr,pn=sr,vn=fn;var dn=function(t){return hn(t,vn,pn)},bn=dn,yn=Object.prototype.hasOwnProperty;var gn=function(t,e,r,n,a,i){var o=1&r,s=bn(t),c=s.length;if(c!=bn(e).length&&!o)return!1;for(var u=c;u--;){var l=s[u];if(!(o?l in e:yn.call(e,l)))return!1}var f=i.get(t),h=i.get(e);if(f&&h)return f==e&&h==t;var p=!0;i.set(t,e),i.set(e,t);for(var v=o;++u<c;){var d=t[l=s[u]],b=e[l];if(n)var y=o?n(b,d,l,e,t,i):n(d,b,l,t,e,i);if(!(void 0===y?d===b||a(d,b,r,n,i):y)){p=!1;break}v||(v="constructor"==l)}if(p&&!v){var g=t.constructor,m=e.constructor;g==m||!("constructor"in t)||!("constructor"in e)||"function"==typeof g&&g instanceof g&&"function"==typeof m&&m instanceof m||(p=!1)}return i.delete(t),i.delete(e),p},mn=W(u,"DataView"),jn=Ft,wn=W(u,"Promise"),_n=ee,xn=W(u,"WeakMap"),On=w,Fn=U,An="[object Map]",Ln="[object Promise]",Mn="[object Set]",Sn="[object WeakMap]",En="[object DataView]",Rn=Fn(mn),Un=Fn(jn),qn=Fn(wn),In=Fn(_n),Pn=Fn(xn),$n=On;(mn&&$n(new mn(new ArrayBuffer(1)))!=En||jn&&$n(new jn)!=An||wn&&$n(wn.resolve())!=Ln||_n&&$n(new _n)!=Mn||xn&&$n(new xn)!=Sn)&&($n=function(t){var e=On(t),r="[object Object]"==e?t.constructor:void 0,n=r?Fn(r):"";if(n)switch(n){case Rn:return En;case Un:return An;case qn:return Ln;case In:return Mn;case Pn:return Sn}return e});var zn=$n,Cn=ze,Bn=ke,Tn=Qe,kn=gn,Dn=zn,Nn=ye,Vn=Lr,Wn=Dr,Gn="[object Arguments]",Hn="[object Array]",Jn="[object Object]",Kn=Object.prototype.hasOwnProperty;var Qn=function(t,e,r,n,a,i){var o=Nn(t),s=Nn(e),c=o?Hn:Dn(t),u=s?Hn:Dn(e),l=(c=c==Gn?Jn:c)==Jn,f=(u=u==Gn?Jn:u)==Jn,h=c==u;if(h&&Vn(t)){if(!Vn(e))return!1;o=!0,l=!1}if(h&&!l)return i||(i=new Cn),o||Wn(t)?Bn(t,e,r,n,a,i):Tn(t,e,c,r,n,a,i);if(!(1&r)){var p=l&&Kn.call(t,"__wrapped__"),v=f&&Kn.call(e,"__wrapped__");if(p||v){var d=p?t.value():t,b=v?e.value():e;return i||(i=new Cn),a(d,b,r,n,i)}}return!!h&&(i||(i=new Cn),kn(t,e,r,n,a,i))},Xn=me;var Yn=function t(e,r,n,a,i){return e===r||(null==e||null==r||!Xn(e)&&!Xn(r)?e!=e&&r!=r:Qn(e,r,n,a,t,i))},Zn=ze,ta=Yn;var ea=_;var ra=function(t){return t==t&&!ea(t)},na=ra,aa=fn;var ia=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}},oa=function(t,e,r,n){var a=r.length,i=a,o=!n;if(null==t)return!i;for(t=Object(t);a--;){var s=r[a];if(o&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++a<i;){var c=(s=r[a])[0],u=t[c],l=s[1];if(o&&s[2]){if(void 0===u&&!(c in t))return!1}else{var f=new Zn;if(n)var h=n(u,l,c,t,e,f);if(!(void 0===h?ta(l,u,3,n,f):h))return!1}}return!0},sa=function(t){for(var e=aa(t),r=e.length;r--;){var n=e[r],a=t[n];e[r]=[n,a,na(a)]}return e},ca=ia;var ua=function(t){var e=sa(t);return 1==e.length&&e[0][2]?ca(e[0][0],e[0][1]):function(r){return r===t||oa(r,t,e)}},la=w,fa=me;var ha=function(t){return"symbol"==typeof t||fa(t)&&"[object Symbol]"==la(t)},pa=ye,va=ha,da=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ba=/^\w*$/;var ya=function(t,e){if(pa(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!va(t))||(ba.test(t)||!da.test(t)||null!=e&&t in Object(e))},ga=kt;function ma(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,a=e?e.apply(this,n):n[0],i=r.cache;if(i.has(a))return i.get(a);var o=t.apply(this,n);return r.cache=i.set(a,o)||i,o};return r.cache=new(ma.Cache||ga),r}ma.Cache=ga;var ja=ma;var wa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,_a=/\\(\\)?/g,xa=function(t){var e=ja(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(wa,(function(t,r,n,a){e.push(n?a.replace(_a,"$1"):r||t)})),e}));var Oa=function(t,e){for(var r=-1,n=null==t?0:t.length,a=Array(n);++r<n;)a[r]=e(t[r],r,t);return a},Fa=ye,Aa=ha,La=l?l.prototype:void 0,Ma=La?La.toString:void 0;var Sa=function t(e){if("string"==typeof e)return e;if(Fa(e))return Oa(e,t)+"";if(Aa(e))return Ma?Ma.call(e):"";var r=e+"";return"0"==r&&1/e==-Infinity?"-0":r},Ea=Sa;var Ra=ye,Ua=ya,qa=xa,Ia=function(t){return null==t?"":Ea(t)};var Pa=function(t,e){return Ra(t)?t:Ua(t,e)?[t]:qa(Ia(t))},$a=ha;var za=function(t){if("string"==typeof t||$a(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e},Ca=Pa,Ba=za;var Ta=function(t,e){for(var r=0,n=(e=Ca(e,t)).length;null!=t&&r<n;)t=t[Ba(e[r++])];return r&&r==n?t:void 0},ka=Ta;var Da=Pa,Na=Fr,Va=ye,Wa=Sr,Ga=Er,Ha=za;var Ja=function(t,e){return null!=t&&e in Object(t)},Ka=function(t,e,r){for(var n=-1,a=(e=Da(e,t)).length,i=!1;++n<a;){var o=Ha(e[n]);if(!(i=null!=t&&r(t,o)))break;t=t[o]}return i||++n!=a?i:!!(a=null==t?0:t.length)&&Ga(a)&&Wa(o,a)&&(Va(t)||Na(t))};var Qa=Yn,Xa=function(t,e,r){var n=null==t?void 0:ka(t,e);return void 0===n?r:n},Ya=function(t,e){return null!=t&&Ka(t,e,Ja)},Za=ya,ti=ra,ei=ia,ri=za;var ni=Ta;var ai=function(t){return function(e){return null==e?void 0:e[t]}},ii=function(t){return function(e){return ni(e,t)}},oi=ya,si=za;var ci=ua,ui=function(t,e){return Za(t)&&ti(e)?ei(ri(t),e):function(r){var n=Xa(r,t);return void 0===n&&n===e?Ya(r,t):Qa(e,n,3)}},li=function(t){return t},fi=ye,hi=function(t){return oi(t)?ai(si(t)):ii(t)};var pi=function(t){return"function"==typeof t?t:null==t?li:"object"==typeof t?fi(t)?ui(t[0],t[1]):ci(t):hi(t)},vi=pi,di=he;const bi=i((function(t,e){return t&&t.length?di(t,vi(e)):[]}));class yi{constructor(t,e){r(this,"language"),r(this,"region"),r(this,"script"),r(this,"isRtl"),r(this,"name"),r(this,"localizedName"),r(this,"uri"),r(this,"timestamp"),r(this,"baseLocale"),this.language=t.language,this.region=t.region,this.script=t.script,this.isRtl=t.isRtl,this.name=t.name,this.localizedName=t.localizedName,this.uri=t.uri,this.timestamp=t.timestamp,this.baseLocale=e}get locale(){return this.language&&this.region&&this.script?`${this.language}_${this.region}#${this.script}`:this.language&&this.script?`${this.language}#${this.script}`:this.language&&this.region?`${this.language}_${this.region}`:this.language}get isBaseLocale(){return this.locale===this.baseLocale}toCdnLocale(){return{locale:this.locale,isBaseLocale:this.isBaseLocale,language:this.language,region:this.region,script:this.script,isRtl:this.isRtl,name:this.name,localizedName:this.localizedName}}}class gi{constructor(t){r(this,"id"),r(this,"file"),r(this,"path"),r(this,"library"),r(this,"module"),r(this,"buildType"),r(this,"timestamp"),r(this,"productFlavors"),r(this,"locales"),r(this,"baseUrl"),this.id=t.id,this.file=t.file,this.path=t.path,this.library=t.library,this.module=t.module,this.buildType=t.buildType,this.timestamp=t.timestamp,this.productFlavors=t.productFlavors,this.locales=t.locales,this.baseUrl=t.baseUrl}toCdnFile(){return{id:this.id,file:this.file,path:this.path,library:this.library,module:this.module,buildType:this.buildType,productFlavors:this.productFlavors,locales:this.locales.map((t=>({locale:t.locale,isBaseLocale:t.isBaseLocale,uri:`${this.baseUrl}${t.uri}`})))}}}class mi{constructor(t,e){r(this,"projectUrl"),r(this,"baseLocale"),r(this,"locales"),r(this,"timestamp"),r(this,"files"),r(this,"filesMap"),this.projectUrl=t.projectUrl,this.timestamp=t.timestamp,this.files=mi.filesFactory(t.files,t.baseLocale,e),this.filesMap=mi.filesMapFactory(this.files),this.locales=mi.localesFactory(this.files),this.baseLocale=this.locales.find((t=>t.isBaseLocale))}static createEmpty(t){return new mi({projectUrl:"",baseLocale:"",timestamp:0,files:{}},t)}static filesFactory(t,e,r){return Object.keys(t).reduce(((n,a)=>{const i=t[a].locales.map((t=>new yi(t,e)));return n.push(new gi({...t[a],id:a,locales:i,baseUrl:r.baseUrl})),n}),[])}static filesMapFactory(t){return t.reduce(((t,e)=>(t[e.id]=e,t)),{})}static localesFactory(t){const e=t.reduce(((t,e)=>(t.push(...e.locales.map((t=>t.toCdnLocale()))),t)),[]);return bi(e,(t=>t.locale))}}class ji{constructor(t){r(this,"options"),this.options=ji.parseMetafileUrl(t)}get url(){return this.options.url}get baseUrl(){return this.options.baseUrl}get cdnId(){return this.options.cdnId}get jsonPath(){return this.options.jsonPath}static parseMetafileUrl(t){let e;try{e=new URL(t)}catch(t){throw new Error('Invalid param: "options.metafile" cannot be parsed as url.')}const r=e.pathname.match(/^\/(.*?)\/(.*?)\.(v2.json|js|ts)$/);if(null===r||4!==r.length)throw new Error('Invalid param: "options.metafile" contains invalid metafile url.');const n=r[1],a=r[2];return{url:t,baseUrl:e.origin,cdnId:n,jsonPath:`/${n}/${a}.v2.json`}}}class wi{constructor(t){r(this,"params"),r(this,"parsedData"),r(this,"data"),this.params=new ji(t.metafile),this.parsedData=null,this.data=mi.createEmpty(this.params)}setMetafile(t){this.parsedData=t,this.data=new mi(t,this.params)}}class _i{constructor(t){r(this,"context"),this.context=t}createCdnResponse(t){const{requests:e,responses:r,hasSingleFileResponse:n,hasSingleLocaleResponse:a}=t;return 0===r.length?{}:(this.cacheResponses(e,r),n&&a?r[0]:_i.transformResponses(t))}cacheResponses(t,e){e.forEach(((e,r)=>{const{metafileFile:n,metafileLocale:a}=t[r];n&&a&&this.context.cache.setIfMissed({metafileFile:n,metafileLocale:a,data:e})}))}static transformResponses(t){const{requests:e,responses:r,hasSingleFileResponse:n}=t;return r.reduce(((t,r,a)=>{const{metafileFile:i,metafileLocale:o}=e[a];return i&&o&&(n?t[o.locale]=r:(t[i.id]||(t[i.id]={}),t[i.id][o.locale]=r)),t}),{})}}class xi{constructor(t){r(this,"metafile"),r(this,"cdn"),r(this,"client"),r(this,"api"),r(this,"cache"),r(this,"responseFactory"),this.metafile=t.metafileContext,this.cdn=t.cdn,this.client=t.client,this.api=new n(this),this.cache=new be(this),this.responseFactory=new _i(this)}}var Oi=function(t){return function(e,r,n){for(var a=-1,i=Object(e),o=n(e),s=o.length;s--;){var c=o[t?s:++a];if(!1===r(i[c],c,i))break}return e}}(),Fi=fn;var Ai=sn;var Li=function(t,e){return function(r,n){if(null==r)return r;if(!Ai(r))return t(r,n);for(var a=r.length,i=e?a:-1,o=Object(r);(e?i--:++i<a)&&!1!==n(o[i],i,o););return r}}((function(t,e){return t&&Oi(t,e,Fi)}));var Mi=er,Si=function(t,e){var r=[];return Li(t,(function(t,n,a){e(t,n,a)&&r.push(t)})),r},Ei=pi,Ri=ye;const Ui=i((function(t,e){return(Ri(t)?Mi:Si)(t,Ei(e))}));var qi=pi,Ii=sn,Pi=fn;var $i=function(t){return function(e,r,n){var a=Object(e);if(!Ii(e)){var i=qi(r);e=Pi(e),r=function(t){return i(a[t],t,a)}}var o=t(e,r,n);return o>-1?a[i?e[o]:o]:void 0}},zi=/\s/;var Ci=function(t){for(var e=t.length;e--&&zi.test(t.charAt(e)););return e},Bi=/^\s+/;var Ti=function(t){return t?t.slice(0,Ci(t)+1).replace(Bi,""):t},ki=_,Di=ha,Ni=/^[-+]0x[0-9a-f]+$/i,Vi=/^0b[01]+$/i,Wi=/^0o[0-7]+$/i,Gi=parseInt;var Hi=function(t){if("number"==typeof t)return t;if(Di(t))return NaN;if(ki(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ki(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ti(t);var r=Vi.test(t);return r||Wi.test(t)?Gi(t.slice(2),r?2:8):Ni.test(t)?NaN:+t},Ji=1/0;var Ki=function(t){return t?(t=Hi(t))===Ji||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var Qi=Ht,Xi=pi,Yi=function(t){var e=Ki(t),r=e%1;return e==e?r?e-r:e:0},Zi=Math.max;const to=i($i((function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var a=null==r?0:Yi(r);return a<0&&(a=Zi(n+a,0)),Qi(t,Xi(e),a)})));var eo=Zr(Object.getPrototypeOf,Object),ro=w,no=eo,ao=me,io=Function.prototype,oo=Object.prototype,so=io.toString,co=oo.hasOwnProperty,uo=so.call(Object);const lo=i((function(t){if(!ao(t)||"[object Object]"!=ro(t))return!1;var e=no(t);if(null===e)return!0;var r=co.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&so.call(r)==uo}));var fo=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},ho=W,po=function(){try{var t=ho(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var vo=function(t,e,r){"__proto__"==e&&po?po(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r},bo=vo,yo=lt,go=Object.prototype.hasOwnProperty;var mo=function(t,e,r){var n=t[e];go.call(t,e)&&yo(n,r)&&(void 0!==r||e in t)||bo(t,e,r)},jo=mo,wo=vo;var _o=function(t,e,r,n){var a=!r;r||(r={});for(var i=-1,o=e.length;++i<o;){var s=e[i],c=n?n(r[s],t[s],s,r,t):void 0;void 0===c&&(c=t[s]),a?wo(r,s,c):jo(r,s,c)}return r},xo=_o,Oo=fn;var Fo=function(t,e){return t&&xo(e,Oo(e),t)};var Ao=_,Lo=Yr,Mo=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},So=Object.prototype.hasOwnProperty;var Eo=Qr,Ro=function(t){if(!Ao(t))return Mo(t);var e=Lo(t),r=[];for(var n in t)("constructor"!=n||!e&&So.call(t,n))&&r.push(n);return r},Uo=sn;var qo=function(t){return Uo(t)?Eo(t,!0):Ro(t)},Io=_o,Po=qo;var $o=function(t,e){return t&&Io(e,Po(e),t)},zo={exports:{}};!function(t,e){var r=u,n=e&&!e.nodeType&&e,a=n&&t&&!t.nodeType&&t,i=a&&a.exports===n?r.Buffer:void 0,o=i?i.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=o?o(r):new t.constructor(r);return t.copy(n),n}}(zo,zo.exports);var Co=zo.exports;var Bo=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e},To=_o,ko=sr;var Do=function(t,e){return To(t,ko(t),e)},No=Xe,Vo=eo,Wo=sr,Go=rr,Ho=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)No(e,Wo(t)),t=Vo(t);return e}:Go,Jo=_o,Ko=Ho;var Qo=function(t,e){return Jo(t,Ko(t),e)},Xo=tr,Yo=Ho,Zo=qo;var ts=function(t){return Xo(t,Zo,Yo)},es=Object.prototype.hasOwnProperty;var rs=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&es.call(t,"index")&&(r.index=t.index,r.input=t.input),r},ns=De;var as=function(t){var e=new t.constructor(t.byteLength);return new ns(e).set(new ns(t)),e},is=as;var os=function(t,e){var r=e?is(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)},ss=/\w*$/;var cs=function(t){var e=new t.constructor(t.source,ss.exec(t));return e.lastIndex=t.lastIndex,e},us=l?l.prototype:void 0,ls=us?us.valueOf:void 0;var fs=as;var hs=as,ps=os,vs=cs,ds=function(t){return ls?Object(ls.call(t)):{}},bs=function(t,e){var r=e?fs(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};var ys=function(t,e,r){var n=t.constructor;switch(e){case"[object ArrayBuffer]":return hs(t);case"[object Boolean]":case"[object Date]":return new n(+t);case"[object DataView]":return ps(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return bs(t,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(t);case"[object RegExp]":return vs(t);case"[object Symbol]":return ds(t)}},gs=_,ms=Object.create,js=function(){function t(){}return function(e){if(!gs(e))return{};if(ms)return ms(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ws=eo,_s=Yr;var xs=function(t){return"function"!=typeof t.constructor||_s(t)?{}:js(ws(t))},Os=zn,Fs=me;var As=function(t){return Fs(t)&&"[object Map]"==Os(t)},Ls=$r,Ms=Cr&&Cr.isMap,Ss=Ms?Ls(Ms):As,Es=zn,Rs=me;var Us=function(t){return Rs(t)&&"[object Set]"==Es(t)},qs=$r,Is=Cr&&Cr.isSet,Ps=Is?qs(Is):Us,$s=ze,zs=fo,Cs=mo,Bs=Fo,Ts=$o,ks=Co,Ds=Bo,Ns=Do,Vs=Qo,Ws=dn,Gs=ts,Hs=zn,Js=rs,Ks=ys,Qs=xs,Xs=ye,Ys=Lr,Zs=Ss,tc=_,ec=Ps,rc=fn,nc=qo,ac="[object Arguments]",ic="[object Function]",oc="[object Object]",sc={};sc[ac]=sc["[object Array]"]=sc["[object ArrayBuffer]"]=sc["[object DataView]"]=sc["[object Boolean]"]=sc["[object Date]"]=sc["[object Float32Array]"]=sc["[object Float64Array]"]=sc["[object Int8Array]"]=sc["[object Int16Array]"]=sc["[object Int32Array]"]=sc["[object Map]"]=sc["[object Number]"]=sc[oc]=sc["[object RegExp]"]=sc["[object Set]"]=sc["[object String]"]=sc["[object Symbol]"]=sc["[object Uint8Array]"]=sc["[object Uint8ClampedArray]"]=sc["[object Uint16Array]"]=sc["[object Uint32Array]"]=!0,sc["[object Error]"]=sc[ic]=sc["[object WeakMap]"]=!1;var cc=function t(e,r,n,a,i,o){var s,c=1&r,u=2&r,l=4&r;if(n&&(s=i?n(e,a,i,o):n(e)),void 0!==s)return s;if(!tc(e))return e;var f=Xs(e);if(f){if(s=Js(e),!c)return Ds(e,s)}else{var h=Hs(e),p=h==ic||"[object GeneratorFunction]"==h;if(Ys(e))return ks(e,c);if(h==oc||h==ac||p&&!i){if(s=u||p?{}:Qs(e),!c)return u?Vs(e,Ts(s,e)):Ns(e,Bs(s,e))}else{if(!sc[h])return i?e:{};s=Ks(e,h,c)}}o||(o=new $s);var v=o.get(e);if(v)return v;o.set(e,s),ec(e)?e.forEach((function(a){s.add(t(a,r,n,a,e,o))})):Zs(e)&&e.forEach((function(a,i){s.set(i,t(a,r,n,i,e,o))}));var d=f?void 0:(l?u?Gs:Ws:u?nc:rc)(e);return zs(d||e,(function(a,i){d&&(a=e[i=a]),Cs(s,i,t(a,r,n,i,e,o))})),s},uc=cc,lc=ua;const fc=i((function(t){return lc(uc(t,1))})),hc=class t extends Oe{constructor(){super(...arguments),r(this,"list",(()=>t.transformFiles(this.context.metafile.data.files))),r(this,"filter",(e=>{if(!e)throw new Error('Invalid param: missing required "options" parameter.');if(!A(e)&&!lo(e))throw new Error('Invalid param: "options" must be function or object.');const r=t.transformFiles(this.context.metafile.data.files);return A(e)?r.filter(e):Ui(r,fc(e))})),r(this,"find",(e=>{if(!e)throw new Error('Invalid param: missing required "options" parameter.');if(!A(e)&&!lo(e))throw new Error('Invalid param: "options" must be function or object.');const r=t.transformFiles(this.context.metafile.data.files);return A(e)?r.find(e):to(r,fc(e))})),r(this,"first",(()=>{if(0===this.context.metafile.data.files.length)throw new Error("File is missing in downloaded metafile.");return t.transformFiles(this.context.metafile.data.files)[0]}))}};r(hc,"transformFiles",(t=>t.map((t=>t.toCdnFile()))));let pc=hc;class vc extends Oe{constructor(t){super(t),r(this,"files"),r(this,"locales",(t=>{const{excludeBaseLocale:e}=t||{},{locales:r}=this.context.metafile.data;return e?r.filter((t=>!t.isBaseLocale)):r})),r(this,"refresh",(async()=>{const t=await this.context.api.fetchMetafile();this.context.metafile.setMetafile(t)})),r(this,"switch",(async t=>{this.context.metafile.params=new ji(t.metafile),await this.refresh()})),this.files=new pc(t)}get projectUrl(){return this.context.metafile.data.projectUrl}get baseLocale(){return this.context.metafile.data.baseLocale}get url(){return this.context.metafile.params.url}}const dc=i((function(t){return void 0===t}));class bc{constructor(t){r(this,"data"),r(this,"context"),this.context=t.context,this.data=t.data||{}}}class yc{constructor(t){r(this,"files"),r(this,"localesMap"),r(this,"hasSingleFileResponse"),r(this,"hasSingleLocaleResponse"),r(this,"context"),this.files=[],this.localesMap=new bc({context:t}),this.hasSingleFileResponse=!1,this.hasSingleLocaleResponse=!1,this.context=t}async execute(){const t=this.getPromises(),e=t.map((t=>t[0])),r=t.map((t=>t[1])),n=await Promise.all(e);return this.context.responseFactory.createCdnResponse({requests:r,responses:n,localesMap:this.localesMap,hasSingleFileResponse:this.hasSingleFileResponse,hasSingleLocaleResponse:this.hasSingleLocaleResponse})}getPromises(){return this.files.reduce(((t,e)=>(this.localesMap.data[e.id]&&t.push(...this.localesMap.data[e.id].map((t=>{const r={metafileFile:e,metafileLocale:t};return[this.context.api.fetchLocale(r),r]}))),t)),[])}}class gc{constructor(t){r(this,"context"),r(this,"request"),this.context=t,this.request=new yc(this.context)}addFiles(t){if(!(lo(t)||xe(t)||dc(t)||ge(t)))throw new Error('Invalid param: "request.files" must be object, array, string or undefined.');if(ge(t)&&t.forEach((t=>{if(!lo(t)&&!xe(t))throw new Error('Invalid param: array "request.files" must contain objects or strings.')})),xe(t)){this.request.hasSingleFileResponse=!0;const e=this.context.metafile.data.files.find((e=>e.id===t));if(!(e instanceof gi))throw new Error(`File not found: "${t}".`);this.request.files=[e]}else if(dc(t))this.request.files=[...this.context.metafile.data.files];else if(ge(t))this.request.files=t.map((t=>{let e;if(xe(t)){const r=this.context.metafile.data.files.find((e=>e.id===t));if(dc(r))throw new Error(`File not found: "${t}".`);e=r}else{const r=this.context.metafile.data.files.find((e=>e.id===t.id));if(dc(r))throw new Error(`File not found: "${t.id}".`);e=r}return e}));else if(lo(t)){this.request.hasSingleFileResponse=!0;const e=this.context.metafile.data.files.find((e=>e.id===t.id));if(dc(e))throw new Error(`File not found: "${t.id}".`);this.request.files=[e]}return this}addLocales(t,e){if(!(xe(t)||dc(t)||ge(t)))throw new Error('Invalid param: "request.locales" must be array, string or undefined.');return ge(t)&&t.forEach((t=>{if(!xe(t))throw new Error('Invalid param: array "request.locales" must contain strings.')})),xe(t)?(this.request.hasSingleLocaleResponse=!0,this.request.files.reduce(((e,r)=>(e.data[r.id]=r.locales.filter((e=>e.locale===t)),e)),this.request.localesMap)):dc(t)?this.request.files.reduce(((t,r)=>(t.data[r.id]=e?r.locales.filter((t=>!t.isBaseLocale)):r.locales,t)),this.request.localesMap):ge(t)&&this.request.files.reduce(((e,r)=>(e.data[r.id]=r.locales.filter((e=>t.includes(e.locale))),e)),this.request.localesMap),this}getCdnRequest(){const t=this.request;return this.request=new yc(this.context),t}}class mc{constructor(t){r(this,"baseUrl"),this.baseUrl=t}async get(t){const e=await fetch(`${this.baseUrl}${t}`),r=e.headers.get("content-type")||"",n=["application/json5","application/json"].includes(r);if(e.status>=400)throw new Error(`Request failed with status code ${e.status}`);let a="";if(n)try{a=await e.json()}catch(t){a={}}else try{a=await e.text()}catch(t){a=""}return a}}class jc{constructor(t){r(this,"metafile"),r(this,"cache"),r(this,"context"),r(this,"fetch",(async t=>{const{files:e,locales:r,excludeBaseLocale:n}=t||{};return new gc(this.context).addFiles(e).addLocales(r,n).getCdnRequest().execute()}));const e=new wi(t),n=new mc(e.params.baseUrl);this.context=new xi({metafileContext:e,cdn:this,client:n}),this.metafile=new vc(this.context),this.cache=new Fe(this.context)}static async create(t){if(!t)throw new Error('Invalid param: missing required "options" parameter.');if(!xe(t.metafile))throw new Error('Invalid param: "options.metafile" must be string.');const e=new jc(t);return await e.metafile.refresh(),e}}t.Api=n,t.CdnBase=Oe,t.CdnCache=Fe,t.CdnClient=jc,t.CdnMetafile=vc,t.CdnMetafileFiles=pc,t.Context=xi,t.FetchHttpAdapter=mc,t.LocalesCache=be,t.LocalesMap=bc,t.MemoryCacheAdapter=de,t.MetafileContext=wi,t.MetafileData=mi,t.MetafileFile=gi,t.MetafileLocale=yi,t.MetafileParams=ji,t.Request=yc,t.RequestBuilder=gc,t.ResponseFactory=_i,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
|
6
6
|
//# sourceMappingURL=localazy-cdn-client.umd.min.js.map
|