@bearer/js
Advanced tools
Comparing version 0.96.1 to 0.96.2-next.13
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).bearer=t()}(this,function(){"use strict";class e{constructor(e){this.clientId=e}}const t=t=>new e(t);return t.version="0.96.1",t}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).bearer={})}(this,function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(a,c)}u((r=r.apply(t,e||[])).next())})}function n(t,e,n){var r,o,i,a,c;function u(){var s=Date.now()-a;s<e&&s>=0?r=setTimeout(u,e-s):(r=null,n||(c=t.apply(i,o),i=o=null))}null==e&&(e=100);var s=function(){i=this,o=arguments,a=Date.now();var s=n&&!r;return r||(r=setTimeout(u,e)),s&&(c=t.apply(i,o),i=o=null),c};return s.clear=function(){r&&(clearTimeout(r),r=null)},s.flush=function(){r&&(c=t.apply(i,o),i=o=null,clearTimeout(r),r=null)},s}n.debounce=n;var r=n;const o=(...t)=>{console.debug("bearer:js",...t)};o.extend=((...t)=>o);const i="bearer",a={domObserver:!0,refreshDebounceDelay:200};class c{constructor(t,n){this.clientId=t,this.registeredIntegrations={},this.config=a,this.loadMissingIntegrations=(()=>{const t=function(t,e=/^bearer-/i){return Array.from(t).filter(t=>e.test(t.tagName)).map(t=>t.tagName.toLowerCase())}(document.getElementsByTagName("*")),e=t.filter(t=>!this.registeredIntegration(t));o(this.registeredIntegrations,t,e),this.sendTags(e)}),this.registeredIntegration=(t=>(this.registeredIntegrations[t]=this.registeredIntegrations[t]||document.createElement(t).constructor!==HTMLElement,this.registeredIntegrations[t])),this.initialIntegrationLoading=(()=>{"complete"===document.readyState||"interactive"===document.readyState?this.debounceRefresh():document.addEventListener("DOMContentLoaded",this.debounceRefresh)}),this.registerDomObserver=(()=>{if("MutationObserver"in window){this.disconnectObserver();const t=document.documentElement||document.body,e={childList:!0,subtree:!0};this.observer=new MutationObserver(this.observerCallback),this.observer.observe(t,e)}}),this.observerCallback=(t=>{for(const e of t)"childList"==e.type&&e.addedNodes.length&&this.debounceRefresh()}),this.disconnectObserver=(()=>{this.observer&&(this.observer.disconnect(),delete this.observer)}),this.sendTags=(t=>e(this,void 0,void 0,function*(){if(!t.length)return Promise.resolve(!0);try{const e=yield fetch("https://int.bearer.sh/v1/parse-tags",{headers:{"content-type":"application/json"},body:JSON.stringify({tags:t,clientId:this.clientId}),method:"POST"});if(e.status>299)throw new Error(`Error while fetching integration tag names: ${t}`);return(yield e.json()).map(t=>{document.querySelector(`#${u(t.uuid)}`)||document.body.appendChild(function(t,e){const n=document.createElement("script");n.type="text/javascript",n.async=!0;const r=e.asset.indexOf("?")>-1?"&":"?";return n.src=[e.asset,[`clientId=${t}`].join("&")].join(r),n.id=u(e.uuid),n}(this.clientId,t))}),!0}catch(t){return!1}})),this.config=Object.assign({},n,a),this.debounceRefresh=r(this.loadMissingIntegrations,this.config.refreshDebounceDelay),this.initialIntegrationLoading(),this.config.domObserver&&this.registerDomObserver()}}function u(t){return`${i}-${t}`}var s="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var l,f=(function(t,e){var n=200,r="__lodash_hash_undefined__",o=800,i=16,a=9007199254740991,c="[object Arguments]",u="[object AsyncFunction]",l="[object Function]",f="[object GeneratorFunction]",h="[object Null]",d="[object Object]",p="[object Proxy]",v="[object Undefined]",_=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,b={};b["[object Float32Array]"]=b["[object Float64Array]"]=b["[object Int8Array]"]=b["[object Int16Array]"]=b["[object Int32Array]"]=b["[object Uint8Array]"]=b["[object Uint8ClampedArray]"]=b["[object Uint16Array]"]=b["[object Uint32Array]"]=!0,b[c]=b["[object Array]"]=b["[object ArrayBuffer]"]=b["[object Boolean]"]=b["[object DataView]"]=b["[object Date]"]=b["[object Error]"]=b[l]=b["[object Map]"]=b["[object Number]"]=b[d]=b["[object RegExp]"]=b["[object Set]"]=b["[object String]"]=b["[object WeakMap]"]=!1;var g="object"==typeof s&&s&&s.Object===Object&&s,j="object"==typeof self&&self&&self.Object===Object&&self,m=g||j||Function("return this")(),w=e&&!e.nodeType&&e,O=w&&t&&!t.nodeType&&t,A=O&&O.exports===w,x=A&&g.process,I=function(){try{return x&&x.binding&&x.binding("util")}catch(t){}}(),S=I&&I.isTypedArray;function $(t,e){return"__proto__"==e?void 0:t[e]}var z,E,T,C=Array.prototype,P=Function.prototype,D=Object.prototype,M=m["__core-js_shared__"],F=P.toString,k=D.hasOwnProperty,L=(z=/[^.]+$/.exec(M&&M.keys&&M.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"",R=D.toString,N=F.call(Object),U=RegExp("^"+F.call(k).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),B=A?m.Buffer:void 0,G=m.Symbol,q=m.Uint8Array,H=B?B.allocUnsafe:void 0,J=(E=Object.getPrototypeOf,T=Object,function(t){return E(T(t))}),V=Object.create,W=D.propertyIsEnumerable,K=C.splice,Q=G?G.toStringTag:void 0,X=function(){try{var t=wt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Y=B?B.isBuffer:void 0,Z=Math.max,tt=Date.now,et=wt(m,"Map"),nt=wt(Object,"create"),rt=function(){function t(){}return function(e){if(!Pt(e))return{};if(V)return V(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function ot(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function it(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function at(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function ct(t){var e=this.__data__=new it(t);this.size=e.size}function ut(t,e){var n=$t(t),r=!n&&St(t),o=!n&&!r&&Et(t),i=!n&&!r&&!o&&Mt(t),a=n||r||o||i,c=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],u=c.length;for(var s in t)!e&&!k.call(t,s)||a&&("length"==s||o&&("offset"==s||"parent"==s)||i&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||Ot(s,u))||c.push(s);return c}function st(t,e,n){(void 0===n||It(t[e],n))&&(void 0!==n||e in t)||ht(t,e,n)}function lt(t,e,n){var r=t[e];k.call(t,e)&&It(r,n)&&(void 0!==n||e in t)||ht(t,e,n)}function ft(t,e){for(var n=t.length;n--;)if(It(t[n][0],e))return n;return-1}function ht(t,e,n){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}ot.prototype.clear=function(){this.__data__=nt?nt(null):{},this.size=0},ot.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ot.prototype.get=function(t){var e=this.__data__;if(nt){var n=e[t];return n===r?void 0:n}return k.call(e,t)?e[t]:void 0},ot.prototype.has=function(t){var e=this.__data__;return nt?void 0!==e[t]:k.call(e,t)},ot.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=nt&&void 0===e?r:e,this},it.prototype.clear=function(){this.__data__=[],this.size=0},it.prototype.delete=function(t){var e=this.__data__,n=ft(e,t);return!(n<0||(n==e.length-1?e.pop():K.call(e,n,1),--this.size,0))},it.prototype.get=function(t){var e=this.__data__,n=ft(e,t);return n<0?void 0:e[n][1]},it.prototype.has=function(t){return ft(this.__data__,t)>-1},it.prototype.set=function(t,e){var n=this.__data__,r=ft(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},at.prototype.clear=function(){this.size=0,this.__data__={hash:new ot,map:new(et||it),string:new ot}},at.prototype.delete=function(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e},at.prototype.get=function(t){return mt(this,t).get(t)},at.prototype.has=function(t){return mt(this,t).has(t)},at.prototype.set=function(t,e){var n=mt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},ct.prototype.clear=function(){this.__data__=new it,this.size=0},ct.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ct.prototype.get=function(t){return this.__data__.get(t)},ct.prototype.has=function(t){return this.__data__.has(t)},ct.prototype.set=function(t,e){var r=this.__data__;if(r instanceof it){var o=r.__data__;if(!et||o.length<n-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new at(o)}return r.set(t,e),this.size=r.size,this};var dt,pt=function(t,e,n){for(var r=-1,o=Object(t),i=n(t),a=i.length;a--;){var c=i[dt?a:++r];if(!1===e(o[c],c,o))break}return t};function vt(t){return null==t?void 0===t?v:h:Q&&Q in Object(t)?function(t){var e=k.call(t,Q),n=t[Q];try{t[Q]=void 0;var r=!0}catch(t){}var o=R.call(t);r&&(e?t[Q]=n:delete t[Q]);return o}(t):function(t){return R.call(t)}(t)}function _t(t){return Dt(t)&&vt(t)==c}function yt(t){return!(!Pt(t)||(e=t,L&&L in e))&&(Tt(t)?U:_).test(function(t){if(null!=t){try{return F.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function bt(t){if(!Pt(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=At(t),n=[];for(var r in t)("constructor"!=r||!e&&k.call(t,r))&&n.push(r);return n}function gt(t,e,n,r,o){t!==e&&pt(e,function(i,a){if(Pt(i))o||(o=new ct),function(t,e,n,r,o,i,a){var c=$(t,n),u=$(e,n),s=a.get(u);if(s)return void st(t,n,s);var l=i?i(c,u,n+"",t,e,a):void 0,f=void 0===l;if(f){var h=$t(u),p=!h&&Et(u),v=!h&&!p&&Mt(u);l=u,h||p||v?$t(c)?l=c:Dt(j=c)&&zt(j)?l=function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(c):p?(f=!1,l=function(t,e){if(e)return t.slice();var n=t.length,r=H?H(n):new t.constructor(n);return t.copy(r),r}(u,!0)):v?(f=!1,_=u,y=!0?(b=_.buffer,g=new b.constructor(b.byteLength),new q(g).set(new q(b)),g):_.buffer,l=new _.constructor(y,_.byteOffset,_.length)):l=[]:function(t){if(!Dt(t)||vt(t)!=d)return!1;var e=J(t);if(null===e)return!0;var n=k.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&F.call(n)==N}(u)||St(u)?(l=c,St(c)?l=function(t){return function(t,e,n,r){var o=!n;n||(n={});var i=-1,a=e.length;for(;++i<a;){var c=e[i],u=r?r(n[c],t[c],c,n,t):void 0;void 0===u&&(u=t[c]),o?ht(n,c,u):lt(n,c,u)}return n}(t,Ft(t))}(c):(!Pt(c)||r&&Tt(c))&&(l=function(t){return"function"!=typeof t.constructor||At(t)?{}:rt(J(t))}(u))):f=!1}var _,y,b,g;var j;f&&(a.set(u,l),o(l,u,r,i,a),a.delete(u));st(t,n,l)}(t,e,a,n,gt,r,o);else{var c=r?r($(t,a),i,a+"",t,e,o):void 0;void 0===c&&(c=i),st(t,a,c)}},Ft)}function jt(t,e){return xt(function(t,e,n){return e=Z(void 0===e?t.length-1:e,0),function(){for(var r=arguments,o=-1,i=Z(r.length-e,0),a=Array(i);++o<i;)a[o]=r[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=r[o];return c[e]=n(a),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,c)}}(t,e,Rt),t+"")}function mt(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function wt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return yt(n)?n:void 0}function Ot(t,e){var n=typeof t;return!!(e=null==e?a:e)&&("number"==n||"symbol"!=n&&y.test(t))&&t>-1&&t%1==0&&t<e}function At(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||D)}var xt=function(t){var e=0,n=0;return function(){var r=tt(),a=i-(r-n);if(n=r,a>0){if(++e>=o)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(X?function(t,e){return X(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Rt);function It(t,e){return t===e||t!=t&&e!=e}var St=_t(function(){return arguments}())?_t:function(t){return Dt(t)&&k.call(t,"callee")&&!W.call(t,"callee")},$t=Array.isArray;function zt(t){return null!=t&&Ct(t.length)&&!Tt(t)}var Et=Y||function(){return!1};function Tt(t){if(!Pt(t))return!1;var e=vt(t);return e==l||e==f||e==u||e==p}function Ct(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=a}function Pt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Dt(t){return null!=t&&"object"==typeof t}var Mt=S?function(t){return function(e){return t(e)}}(S):function(t){return Dt(t)&&Ct(t.length)&&!!b[vt(t)]};function Ft(t){return zt(t)?ut(t,!0):bt(t)}var kt,Lt=(kt=function(t,e,n){gt(t,e,n)},jt(function(t,e){var n=-1,r=e.length,o=r>1?e[r-1]:void 0,i=r>2?e[2]:void 0;for(o=kt.length>3&&"function"==typeof o?(r--,o):void 0,i&&function(t,e,n){if(!Pt(n))return!1;var r=typeof e;return!!("number"==r?zt(n)&&Ot(e,n.length):"string"==r&&e in n)&&It(n[e],t)}(e[0],e[1],i)&&(o=r<3?void 0:o,r=1),t=Object(t);++n<r;){var a=e[n];a&&kt(t,a,n,o)}return t}));function Rt(t){return t}t.exports=Lt}(l={exports:{}},l.exports),l.exports),h="Expected a function",d="__lodash_hash_undefined__",p=1/0,v="[object Function]",_="[object GeneratorFunction]",y="[object Symbol]",b=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/,j=/^\./,m=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,w=/\\(\\)?/g,O=/^\[object .+?Constructor\]$/,A="object"==typeof s&&s&&s.Object===Object&&s,x="object"==typeof self&&self&&self.Object===Object&&self,I=A||x||Function("return this")();var S,$=Array.prototype,z=Function.prototype,E=Object.prototype,T=I["__core-js_shared__"],C=(S=/[^.]+$/.exec(T&&T.keys&&T.keys.IE_PROTO||""))?"Symbol(src)_1."+S:"",P=z.toString,D=E.hasOwnProperty,M=E.toString,F=RegExp("^"+P.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),k=I.Symbol,L=$.splice,R=Q(I,"Map"),N=Q(Object,"create"),U=k?k.prototype:void 0,B=U?U.toString:void 0;function G(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function q(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function H(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function J(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function V(t,e){for(var n,r=0,o=(e=function(t,e){if(tt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||nt(t))return!0;return g.test(t)||!b.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:tt(n=e)?n:X(n)).length;null!=t&&r<o;)t=t[Y(e[r++])];return r&&r==o?t:void 0}function W(t){return!(!et(t)||(e=t,C&&C in e))&&(function(t){var e=et(t)?M.call(t):"";return e==v||e==_}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?F:O).test(function(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function K(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function Q(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return W(n)?n:void 0}G.prototype.clear=function(){this.__data__=N?N(null):{}},G.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},G.prototype.get=function(t){var e=this.__data__;if(N){var n=e[t];return n===d?void 0:n}return D.call(e,t)?e[t]:void 0},G.prototype.has=function(t){var e=this.__data__;return N?void 0!==e[t]:D.call(e,t)},G.prototype.set=function(t,e){return this.__data__[t]=N&&void 0===e?d:e,this},q.prototype.clear=function(){this.__data__=[]},q.prototype.delete=function(t){var e=this.__data__,n=J(e,t);return!(n<0||(n==e.length-1?e.pop():L.call(e,n,1),0))},q.prototype.get=function(t){var e=this.__data__,n=J(e,t);return n<0?void 0:e[n][1]},q.prototype.has=function(t){return J(this.__data__,t)>-1},q.prototype.set=function(t,e){var n=this.__data__,r=J(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},H.prototype.clear=function(){this.__data__={hash:new G,map:new(R||q),string:new G}},H.prototype.delete=function(t){return K(this,t).delete(t)},H.prototype.get=function(t){return K(this,t).get(t)},H.prototype.has=function(t){return K(this,t).has(t)},H.prototype.set=function(t,e){return K(this,t).set(t,e),this};var X=Z(function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(nt(t))return B?B.call(t):"";var e=t+"";return"0"==e&&1/t==-p?"-0":e}(e);var n=[];return j.test(t)&&n.push(""),t.replace(m,function(t,e,r,o){n.push(r?o.replace(w,"$1"):e||t)}),n});function Y(t){if("string"==typeof t||nt(t))return t;var e=t+"";return"0"==e&&1/t==-p?"-0":e}function Z(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(h);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var a=t.apply(this,r);return n.cache=i.set(o,a),a};return n.cache=new(Z.Cache||H),n}Z.Cache=H;var tt=Array.isArray;function et(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function nt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&M.call(t)==y}var rt=function(t,e,n){var r=null==t?void 0:V(t,e);return void 0===r?n:r};const ot=o.extend("i18n"),it="en",at="bearer-locale-changed";class ct{constructor(){this._locale=it,this._dictionnary={[it]:{}},this.load=((t,n,{locale:r=this.locale}={})=>e(this,void 0,void 0,function*(){const e=yield n,o=t?{[t]:e}:e;this._dictionnary[r]=f(rt(this._dictionnary,r),o),this.localeChanged()})),this.get=((t,e,n={})=>{const r=[n.locale||this.locale,t,e].filter(t=>t).join(".");return ot("lookup key",r),rt(this._dictionnary,r)})}localeChanged(){document.dispatchEvent(new CustomEvent(at,{detail:{locale:this.locale}}))}set locale(t){this._locale=t,this.localeChanged()}get locale(){return this._locale}}const ut=new ct,st=t=>new c(t);st.version="0.96.2-next.13+c398332a",st.i18n=ut,t.default=st,t.i18n=ct,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=bearer.production.min.js.map |
import bearer from './lib/main'; | ||
export { I18n as i18n } from './lib/i18n'; | ||
export default bearer; |
@@ -1,2 +0,2 @@ | ||
"use strict";class Bearer{constructor(e){this.clientId=e}}const bearer=e=>new Bearer(e);bearer.version="0.96.1",module.exports=bearer; | ||
"use strict";function __awaiter(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,c)}s((n=n.apply(t,e||[])).next())})}function debounce(t,e,r){var n,o,a,i,c;function s(){var u=Date.now()-i;u<e&&u>=0?n=setTimeout(s,e-u):(n=null,r||(c=t.apply(a,o),a=o=null))}null==e&&(e=100);var u=function(){a=this,o=arguments,i=Date.now();var u=r&&!n;return n||(n=setTimeout(s,e)),u&&(c=t.apply(a,o),a=o=null),c};return u.clear=function(){n&&(clearTimeout(n),n=null)},u.flush=function(){n&&(c=t.apply(a,o),a=o=null,clearTimeout(n),n=null)},u}Object.defineProperty(exports,"__esModule",{value:!0}),debounce.debounce=debounce;var debounce_1=debounce;const logger=(...t)=>{console.debug("bearer:js",...t)};logger.extend=((...t)=>logger);const prefix="bearer",DEFAULT_OPTIONS={domObserver:!0,refreshDebounceDelay:200};class Bearer{constructor(t,e){this.clientId=t,this.registeredIntegrations={},this.config=DEFAULT_OPTIONS,this.loadMissingIntegrations=(()=>{const t=findElements(document.getElementsByTagName("*")),e=t.filter(t=>!this.registeredIntegration(t));logger(this.registeredIntegrations,t,e),this.sendTags(e)}),this.registeredIntegration=(t=>(this.registeredIntegrations[t]=this.registeredIntegrations[t]||document.createElement(t).constructor!==HTMLElement,this.registeredIntegrations[t])),this.initialIntegrationLoading=(()=>{"complete"===document.readyState||"interactive"===document.readyState?this.debounceRefresh():document.addEventListener("DOMContentLoaded",this.debounceRefresh)}),this.registerDomObserver=(()=>{if("MutationObserver"in window){this.disconnectObserver();const t=document.documentElement||document.body,e={childList:!0,subtree:!0};this.observer=new MutationObserver(this.observerCallback),this.observer.observe(t,e)}}),this.observerCallback=(t=>{for(const e of t)"childList"==e.type&&e.addedNodes.length&&this.debounceRefresh()}),this.disconnectObserver=(()=>{this.observer&&(this.observer.disconnect(),delete this.observer)}),this.sendTags=(t=>__awaiter(this,void 0,void 0,function*(){if(!t.length)return Promise.resolve(!0);try{const e=yield fetch("https://int.bearer.sh/v1/parse-tags",{headers:{"content-type":"application/json"},body:JSON.stringify({tags:t,clientId:this.clientId}),method:"POST"});if(e.status>299)throw new Error(`Error while fetching integration tag names: ${t}`);return(yield e.json()).map(t=>{document.querySelector(`#${getScriptId(t.uuid)}`)||document.body.appendChild(getScriptDOM(this.clientId,t))}),!0}catch(t){return!1}})),this.config=Object.assign({},e,DEFAULT_OPTIONS),this.debounceRefresh=debounce_1(this.loadMissingIntegrations,this.config.refreshDebounceDelay),this.initialIntegrationLoading(),this.config.domObserver&&this.registerDomObserver()}}function findElements(t,e=/^bearer-/i){return Array.from(t).filter(t=>e.test(t.tagName)).map(t=>t.tagName.toLowerCase())}function getScriptId(t){return`${prefix}-${t}`}function getScriptDOM(t,e){const r=document.createElement("script");r.type="text/javascript",r.async=!0;const n=e.asset.indexOf("?")>-1?"&":"?";return r.src=[e.asset,[`clientId=${t}`].join("&")].join(n),r.id=getScriptId(e.uuid),r}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var lodash_merge=createCommonjsModule(function(t,e){var r=200,n="__lodash_hash_undefined__",o=800,a=16,i=9007199254740991,c="[object Arguments]",s="[object AsyncFunction]",u="[object Function]",l="[object GeneratorFunction]",h="[object Null]",f="[object Object]",p="[object Proxy]",d="[object Undefined]",_=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,v={};v["[object Float32Array]"]=v["[object Float64Array]"]=v["[object Int8Array]"]=v["[object Int16Array]"]=v["[object Int32Array]"]=v["[object Uint8Array]"]=v["[object Uint8ClampedArray]"]=v["[object Uint16Array]"]=v["[object Uint32Array]"]=!0,v[c]=v["[object Array]"]=v["[object ArrayBuffer]"]=v["[object Boolean]"]=v["[object DataView]"]=v["[object Date]"]=v["[object Error]"]=v[u]=v["[object Map]"]=v["[object Number]"]=v[f]=v["[object RegExp]"]=v["[object Set]"]=v["[object String]"]=v["[object WeakMap]"]=!1;var b="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,g="object"==typeof self&&self&&self.Object===Object&&self,m=b||g||Function("return this")(),j=e&&!e.nodeType&&e,O=j&&t&&!t.nodeType&&t,C=O&&O.exports===j,S=C&&b.process,I=function(){try{return S&&S.binding&&S.binding("util")}catch(t){}}(),w=I&&I.isTypedArray;function T(t,e){return"__proto__"==e?void 0:t[e]}var E,D,A,P=Array.prototype,L=Function.prototype,N=Object.prototype,M=m["__core-js_shared__"],x=L.toString,F=N.hasOwnProperty,H=(E=/[^.]+$/.exec(M&&M.keys&&M.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"",z=N.toString,$=x.call(Object),G=RegExp("^"+x.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=C?m.Buffer:void 0,k=m.Symbol,R=m.Uint8Array,K=U?U.allocUnsafe:void 0,B=(D=Object.getPrototypeOf,A=Object,function(t){return D(A(t))}),J=Object.create,q=N.propertyIsEnumerable,V=P.splice,Y=k?k.toStringTag:void 0,X=function(){try{var t=jt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),W=U?U.isBuffer:void 0,Q=Math.max,Z=Date.now,tt=jt(m,"Map"),et=jt(Object,"create"),rt=function(){function t(){}return function(e){if(!Lt(e))return{};if(J)return J(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function nt(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])}}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])}}function at(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])}}function it(t){var e=this.__data__=new ot(t);this.size=e.size}function ct(t,e){var r=Tt(t),n=!r&&wt(t),o=!r&&!n&&Dt(t),a=!r&&!n&&!o&&Mt(t),i=r||n||o||a,c=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],s=c.length;for(var u in t)!e&&!F.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ot(u,s))||c.push(u);return c}function st(t,e,r){(void 0===r||It(t[e],r))&&(void 0!==r||e in t)||ht(t,e,r)}function ut(t,e,r){var n=t[e];F.call(t,e)&&It(n,r)&&(void 0!==r||e in t)||ht(t,e,r)}function lt(t,e){for(var r=t.length;r--;)if(It(t[r][0],e))return r;return-1}function ht(t,e,r){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}nt.prototype.clear=function(){this.__data__=et?et(null):{},this.size=0},nt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},nt.prototype.get=function(t){var e=this.__data__;if(et){var r=e[t];return r===n?void 0:r}return F.call(e,t)?e[t]:void 0},nt.prototype.has=function(t){var e=this.__data__;return et?void 0!==e[t]:F.call(e,t)},nt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=et&&void 0===e?n:e,this},ot.prototype.clear=function(){this.__data__=[],this.size=0},ot.prototype.delete=function(t){var e=this.__data__,r=lt(e,t);return!(r<0||(r==e.length-1?e.pop():V.call(e,r,1),--this.size,0))},ot.prototype.get=function(t){var e=this.__data__,r=lt(e,t);return r<0?void 0:e[r][1]},ot.prototype.has=function(t){return lt(this.__data__,t)>-1},ot.prototype.set=function(t,e){var r=this.__data__,n=lt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},at.prototype.clear=function(){this.size=0,this.__data__={hash:new nt,map:new(tt||ot),string:new nt}},at.prototype.delete=function(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e},at.prototype.get=function(t){return mt(this,t).get(t)},at.prototype.has=function(t){return mt(this,t).has(t)},at.prototype.set=function(t,e){var r=mt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},it.prototype.clear=function(){this.__data__=new ot,this.size=0},it.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},it.prototype.get=function(t){return this.__data__.get(t)},it.prototype.has=function(t){return this.__data__.has(t)},it.prototype.set=function(t,e){var n=this.__data__;if(n instanceof ot){var o=n.__data__;if(!tt||o.length<r-1)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new at(o)}return n.set(t,e),this.size=n.size,this};var ft,pt=function(t,e,r){for(var n=-1,o=Object(t),a=r(t),i=a.length;i--;){var c=a[ft?i:++n];if(!1===e(o[c],c,o))break}return t};function dt(t){return null==t?void 0===t?d:h:Y&&Y in Object(t)?function(t){var e=F.call(t,Y),r=t[Y];try{t[Y]=void 0;var n=!0}catch(t){}var o=z.call(t);n&&(e?t[Y]=r:delete t[Y]);return o}(t):function(t){return z.call(t)}(t)}function _t(t){return Nt(t)&&dt(t)==c}function yt(t){return!(!Lt(t)||(e=t,H&&H in e))&&(At(t)?G:_).test(function(t){if(null!=t){try{return x.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function vt(t){if(!Lt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Ct(t),r=[];for(var n in t)("constructor"!=n||!e&&F.call(t,n))&&r.push(n);return r}function bt(t,e,r,n,o){t!==e&&pt(e,function(a,i){if(Lt(a))o||(o=new it),function(t,e,r,n,o,a,i){var c=T(t,r),s=T(e,r),u=i.get(s);if(u)return void st(t,r,u);var l=a?a(c,s,r+"",t,e,i):void 0,h=void 0===l;if(h){var p=Tt(s),d=!p&&Dt(s),_=!p&&!d&&Mt(s);l=s,p||d||_?Tt(c)?l=c:Nt(m=c)&&Et(m)?l=function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(c):d?(h=!1,l=function(t,e){if(e)return t.slice();var r=t.length,n=K?K(r):new t.constructor(r);return t.copy(n),n}(s,!0)):_?(h=!1,y=s,v=!0?(b=y.buffer,g=new b.constructor(b.byteLength),new R(g).set(new R(b)),g):y.buffer,l=new y.constructor(v,y.byteOffset,y.length)):l=[]:function(t){if(!Nt(t)||dt(t)!=f)return!1;var e=B(t);if(null===e)return!0;var r=F.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&x.call(r)==$}(s)||wt(s)?(l=c,wt(c)?l=function(t){return function(t,e,r,n){var o=!r;r||(r={});var a=-1,i=e.length;for(;++a<i;){var c=e[a],s=n?n(r[c],t[c],c,r,t):void 0;void 0===s&&(s=t[c]),o?ht(r,c,s):ut(r,c,s)}return r}(t,xt(t))}(c):(!Lt(c)||n&&At(c))&&(l=function(t){return"function"!=typeof t.constructor||Ct(t)?{}:rt(B(t))}(s))):h=!1}var y,v,b,g;var m;h&&(i.set(s,l),o(l,s,n,a,i),i.delete(s));st(t,r,l)}(t,e,i,r,bt,n,o);else{var c=n?n(T(t,i),a,i+"",t,e,o):void 0;void 0===c&&(c=a),st(t,i,c)}},xt)}function gt(t,e){return St(function(t,e,r){return e=Q(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,a=Q(n.length-e,0),i=Array(a);++o<a;)i[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(i),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}(t,e,zt),t+"")}function mt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function jt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return yt(r)?r:void 0}function Ot(t,e){var r=typeof t;return!!(e=null==e?i:e)&&("number"==r||"symbol"!=r&&y.test(t))&&t>-1&&t%1==0&&t<e}function Ct(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}var St=function(t){var e=0,r=0;return function(){var n=Z(),i=a-(n-r);if(r=n,i>0){if(++e>=o)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(X?function(t,e){return X(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:zt);function It(t,e){return t===e||t!=t&&e!=e}var wt=_t(function(){return arguments}())?_t:function(t){return Nt(t)&&F.call(t,"callee")&&!q.call(t,"callee")},Tt=Array.isArray;function Et(t){return null!=t&&Pt(t.length)&&!At(t)}var Dt=W||function(){return!1};function At(t){if(!Lt(t))return!1;var e=dt(t);return e==u||e==l||e==s||e==p}function Pt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}function Lt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Nt(t){return null!=t&&"object"==typeof t}var Mt=w?function(t){return function(e){return t(e)}}(w):function(t){return Nt(t)&&Pt(t.length)&&!!v[dt(t)]};function xt(t){return Et(t)?ct(t,!0):vt(t)}var Ft,Ht=(Ft=function(t,e,r){bt(t,e,r)},gt(function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(o=Ft.length>3&&"function"==typeof o?(n--,o):void 0,a&&function(t,e,r){if(!Lt(r))return!1;var n=typeof e;return!!("number"==n?Et(r)&&Ot(e,r.length):"string"==n&&e in r)&&It(r[e],t)}(e[0],e[1],a)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var i=e[r];i&&Ft(t,i,r,o)}return t}));function zt(t){return t}t.exports=Ht}),FUNC_ERROR_TEXT="Expected a function",HASH_UNDEFINED="__lodash_hash_undefined__",INFINITY=1/0,funcTag="[object Function]",genTag="[object GeneratorFunction]",symbolTag="[object Symbol]",reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,reLeadingDot=/^\./,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reEscapeChar=/\\(\\)?/g,reIsHostCtor=/^\[object .+?Constructor\]$/,freeGlobal="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")();function getValue(t,e){return null==t?void 0:t[e]}function isHostObject(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}var arrayProto=Array.prototype,funcProto=Function.prototype,objectProto=Object.prototype,coreJsData=root["__core-js_shared__"],maskSrcKey=function(){var t=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),funcToString=funcProto.toString,hasOwnProperty=objectProto.hasOwnProperty,objectToString=objectProto.toString,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Symbol$1=root.Symbol,splice=arrayProto.splice,Map=getNative(root,"Map"),nativeCreate=getNative(Object,"create"),symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function Hash(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{}}function hashDelete(t){return this.has(t)&&delete this.__data__[t]}function hashGet(t){var e=this.__data__;if(nativeCreate){var r=e[t];return r===HASH_UNDEFINED?void 0:r}return hasOwnProperty.call(e,t)?e[t]:void 0}function hashHas(t){var e=this.__data__;return nativeCreate?void 0!==e[t]:hasOwnProperty.call(e,t)}function hashSet(t,e){return this.__data__[t]=nativeCreate&&void 0===e?HASH_UNDEFINED:e,this}function ListCache(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function listCacheClear(){this.__data__=[]}function listCacheDelete(t){var e=this.__data__,r=assocIndexOf(e,t);return!(r<0)&&(r==e.length-1?e.pop():splice.call(e,r,1),!0)}function listCacheGet(t){var e=this.__data__,r=assocIndexOf(e,t);return r<0?void 0:e[r][1]}function listCacheHas(t){return assocIndexOf(this.__data__,t)>-1}function listCacheSet(t,e){var r=this.__data__,n=assocIndexOf(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}function MapCache(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function mapCacheClear(){this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}function mapCacheDelete(t){return getMapData(this,t).delete(t)}function mapCacheGet(t){return getMapData(this,t).get(t)}function mapCacheHas(t){return getMapData(this,t).has(t)}function mapCacheSet(t,e){return getMapData(this,t).set(t,e),this}function assocIndexOf(t,e){for(var r=t.length;r--;)if(eq(t[r][0],e))return r;return-1}function baseGet(t,e){for(var r=0,n=(e=isKey(e,t)?[e]:castPath(e)).length;null!=t&&r<n;)t=t[toKey(e[r++])];return r&&r==n?t:void 0}function baseIsNative(t){return!(!isObject(t)||isMasked(t))&&(isFunction(t)||isHostObject(t)?reIsNative:reIsHostCtor).test(toSource(t))}function baseToString(t){if("string"==typeof t)return t;if(isSymbol(t))return symbolToString?symbolToString.call(t):"";var e=t+"";return"0"==e&&1/t==-INFINITY?"-0":e}function castPath(t){return isArray(t)?t:stringToPath(t)}function getMapData(t,e){var r=t.__data__;return isKeyable(e)?r["string"==typeof e?"string":"hash"]:r.map}function getNative(t,e){var r=getValue(t,e);return baseIsNative(r)?r:void 0}function isKey(t,e){if(isArray(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!isSymbol(t))||(reIsPlainProp.test(t)||!reIsDeepProp.test(t)||null!=e&&t in Object(e))}function isKeyable(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function isMasked(t){return!!maskSrcKey&&maskSrcKey in t}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet,ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet,MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var stringToPath=memoize(function(t){t=toString(t);var e=[];return reLeadingDot.test(t)&&e.push(""),t.replace(rePropName,function(t,r,n,o){e.push(n?o.replace(reEscapeChar,"$1"):r||t)}),e});function toKey(t){if("string"==typeof t||isSymbol(t))return t;var e=t+"";return"0"==e&&1/t==-INFINITY?"-0":e}function toSource(t){if(null!=t){try{return funcToString.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function memoize(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(FUNC_ERROR_TEXT);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=t.apply(this,n);return r.cache=a.set(o,i),i};return r.cache=new(memoize.Cache||MapCache),r}function eq(t,e){return t===e||t!=t&&e!=e}memoize.Cache=MapCache;var isArray=Array.isArray;function isFunction(t){var e=isObject(t)?objectToString.call(t):"";return e==funcTag||e==genTag}function isObject(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function isObjectLike(t){return!!t&&"object"==typeof t}function isSymbol(t){return"symbol"==typeof t||isObjectLike(t)&&objectToString.call(t)==symbolTag}function toString(t){return null==t?"":baseToString(t)}function get(t,e,r){var n=null==t?void 0:baseGet(t,e);return void 0===n?r:n}var lodash_get=get;const debug=logger.extend("i18n"),DEFAULT_LOCALE="en",LOCALE_CHANGED="bearer-locale-changed";class I18n{constructor(){this._locale=DEFAULT_LOCALE,this._dictionnary={[DEFAULT_LOCALE]:{}},this.load=((t,e,{locale:r=this.locale}={})=>__awaiter(this,void 0,void 0,function*(){const n=yield e,o=t?{[t]:n}:n;this._dictionnary[r]=lodash_merge(lodash_get(this._dictionnary,r),o),this.localeChanged()})),this.get=((t,e,r={})=>{const n=[r.locale||this.locale,t,e].filter(t=>t).join(".");return debug("lookup key",n),lodash_get(this._dictionnary,n)})}localeChanged(){document.dispatchEvent(new CustomEvent(LOCALE_CHANGED,{detail:{locale:this.locale}}))}set locale(t){this._locale=t,this.localeChanged()}get locale(){return this._locale}}const i18n=new I18n,bearer=t=>new Bearer(t);bearer.version="0.96.2-next.13+c398332a",bearer.i18n=i18n,exports.default=bearer,exports.i18n=I18n; | ||
//# sourceMappingURL=index.js.map |
export default class Bearer { | ||
private readonly clientId; | ||
constructor(clientId: string); | ||
readonly clientId: string; | ||
private registeredIntegrations; | ||
private config; | ||
private observer?; | ||
private debounceRefresh; | ||
constructor(clientId: string, options?: Partial<TBearerOptions>); | ||
/** | ||
* Retrieve all dom elements starting by bearer- and ask for assets urls if | ||
*/ | ||
loadMissingIntegrations: () => void; | ||
/** | ||
* check wether if an integration is resgistered | ||
*/ | ||
registeredIntegration: (tagName: string) => boolean; | ||
/** | ||
* load integration asset or wait until dom is loaded | ||
*/ | ||
private initialIntegrationLoading; | ||
/** | ||
* Register a DOM observer so that we can load integration assets only when we need them | ||
*/ | ||
private registerDomObserver; | ||
private observerCallback; | ||
/** | ||
* remove dom observer | ||
*/ | ||
private disconnectObserver; | ||
/** | ||
* retrieve corresponding integration asset url | ||
*/ | ||
sendTags: (tags: string[]) => Promise<boolean>; | ||
} | ||
declare type TBearerOptions = { | ||
domObserver: boolean; | ||
refreshDebounceDelay: number; | ||
}; | ||
/** | ||
* Extract/format element tag names given a regexp | ||
* @param elements | ||
* @param filter | ||
*/ | ||
export declare function findElements(elements: HTMLCollection | NodeListOf<Element>, filter?: RegExp): string[]; | ||
export {}; |
@@ -5,3 +5,4 @@ import Bearer from './bearer'; | ||
version: string; | ||
i18n: import("./i18n").I18n; | ||
}; | ||
export default bearer; |
import bearer from './lib/main'; | ||
export { I18n as i18n } from './lib/i18n'; | ||
export default bearer; |
@@ -1,2 +0,2 @@ | ||
class Bearer{constructor(e){this.clientId=e}}const bearer=e=>new Bearer(e);bearer.version="0.96.1";export default bearer; | ||
function __awaiter(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,c)}s((n=n.apply(t,e||[])).next())})}function debounce(t,e,r){var n,o,a,i,c;function s(){var u=Date.now()-i;u<e&&u>=0?n=setTimeout(s,e-u):(n=null,r||(c=t.apply(a,o),a=o=null))}null==e&&(e=100);var u=function(){a=this,o=arguments,i=Date.now();var u=r&&!n;return n||(n=setTimeout(s,e)),u&&(c=t.apply(a,o),a=o=null),c};return u.clear=function(){n&&(clearTimeout(n),n=null)},u.flush=function(){n&&(c=t.apply(a,o),a=o=null,clearTimeout(n),n=null)},u}debounce.debounce=debounce;var debounce_1=debounce;const logger=(...t)=>{console.debug("bearer:js",...t)};logger.extend=((...t)=>logger);const prefix="bearer",DEFAULT_OPTIONS={domObserver:!0,refreshDebounceDelay:200};class Bearer{constructor(t,e){this.clientId=t,this.registeredIntegrations={},this.config=DEFAULT_OPTIONS,this.loadMissingIntegrations=(()=>{const t=findElements(document.getElementsByTagName("*")),e=t.filter(t=>!this.registeredIntegration(t));logger(this.registeredIntegrations,t,e),this.sendTags(e)}),this.registeredIntegration=(t=>(this.registeredIntegrations[t]=this.registeredIntegrations[t]||document.createElement(t).constructor!==HTMLElement,this.registeredIntegrations[t])),this.initialIntegrationLoading=(()=>{"complete"===document.readyState||"interactive"===document.readyState?this.debounceRefresh():document.addEventListener("DOMContentLoaded",this.debounceRefresh)}),this.registerDomObserver=(()=>{if("MutationObserver"in window){this.disconnectObserver();const t=document.documentElement||document.body,e={childList:!0,subtree:!0};this.observer=new MutationObserver(this.observerCallback),this.observer.observe(t,e)}}),this.observerCallback=(t=>{for(const e of t)"childList"==e.type&&e.addedNodes.length&&this.debounceRefresh()}),this.disconnectObserver=(()=>{this.observer&&(this.observer.disconnect(),delete this.observer)}),this.sendTags=(t=>__awaiter(this,void 0,void 0,function*(){if(!t.length)return Promise.resolve(!0);try{const e=yield fetch("https://int.bearer.sh/v1/parse-tags",{headers:{"content-type":"application/json"},body:JSON.stringify({tags:t,clientId:this.clientId}),method:"POST"});if(e.status>299)throw new Error(`Error while fetching integration tag names: ${t}`);return(yield e.json()).map(t=>{document.querySelector(`#${getScriptId(t.uuid)}`)||document.body.appendChild(getScriptDOM(this.clientId,t))}),!0}catch(t){return!1}})),this.config=Object.assign({},e,DEFAULT_OPTIONS),this.debounceRefresh=debounce_1(this.loadMissingIntegrations,this.config.refreshDebounceDelay),this.initialIntegrationLoading(),this.config.domObserver&&this.registerDomObserver()}}function findElements(t,e=/^bearer-/i){return Array.from(t).filter(t=>e.test(t.tagName)).map(t=>t.tagName.toLowerCase())}function getScriptId(t){return`${prefix}-${t}`}function getScriptDOM(t,e){const r=document.createElement("script");r.type="text/javascript",r.async=!0;const n=e.asset.indexOf("?")>-1?"&":"?";return r.src=[e.asset,[`clientId=${t}`].join("&")].join(n),r.id=getScriptId(e.uuid),r}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var lodash_merge=createCommonjsModule(function(t,e){var r=200,n="__lodash_hash_undefined__",o=800,a=16,i=9007199254740991,c="[object Arguments]",s="[object AsyncFunction]",u="[object Function]",l="[object GeneratorFunction]",h="[object Null]",f="[object Object]",p="[object Proxy]",d="[object Undefined]",_=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,v={};v["[object Float32Array]"]=v["[object Float64Array]"]=v["[object Int8Array]"]=v["[object Int16Array]"]=v["[object Int32Array]"]=v["[object Uint8Array]"]=v["[object Uint8ClampedArray]"]=v["[object Uint16Array]"]=v["[object Uint32Array]"]=!0,v[c]=v["[object Array]"]=v["[object ArrayBuffer]"]=v["[object Boolean]"]=v["[object DataView]"]=v["[object Date]"]=v["[object Error]"]=v[u]=v["[object Map]"]=v["[object Number]"]=v[f]=v["[object RegExp]"]=v["[object Set]"]=v["[object String]"]=v["[object WeakMap]"]=!1;var b="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,g="object"==typeof self&&self&&self.Object===Object&&self,m=b||g||Function("return this")(),j=e&&!e.nodeType&&e,C=j&&t&&!t.nodeType&&t,O=C&&C.exports===j,S=O&&b.process,I=function(){try{return S&&S.binding&&S.binding("util")}catch(t){}}(),w=I&&I.isTypedArray;function T(t,e){return"__proto__"==e?void 0:t[e]}var E,D,A,P=Array.prototype,L=Function.prototype,N=Object.prototype,M=m["__core-js_shared__"],x=L.toString,F=N.hasOwnProperty,H=(E=/[^.]+$/.exec(M&&M.keys&&M.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"",z=N.toString,$=x.call(Object),G=RegExp("^"+x.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=O?m.Buffer:void 0,k=m.Symbol,R=m.Uint8Array,K=U?U.allocUnsafe:void 0,B=(D=Object.getPrototypeOf,A=Object,function(t){return D(A(t))}),J=Object.create,q=N.propertyIsEnumerable,V=P.splice,Y=k?k.toStringTag:void 0,X=function(){try{var t=jt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),W=U?U.isBuffer:void 0,Q=Math.max,Z=Date.now,tt=jt(m,"Map"),et=jt(Object,"create"),rt=function(){function t(){}return function(e){if(!Lt(e))return{};if(J)return J(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function nt(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])}}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])}}function at(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])}}function it(t){var e=this.__data__=new ot(t);this.size=e.size}function ct(t,e){var r=Tt(t),n=!r&&wt(t),o=!r&&!n&&Dt(t),a=!r&&!n&&!o&&Mt(t),i=r||n||o||a,c=i?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],s=c.length;for(var u in t)!e&&!F.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Ct(u,s))||c.push(u);return c}function st(t,e,r){(void 0===r||It(t[e],r))&&(void 0!==r||e in t)||ht(t,e,r)}function ut(t,e,r){var n=t[e];F.call(t,e)&&It(n,r)&&(void 0!==r||e in t)||ht(t,e,r)}function lt(t,e){for(var r=t.length;r--;)if(It(t[r][0],e))return r;return-1}function ht(t,e,r){"__proto__"==e&&X?X(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}nt.prototype.clear=function(){this.__data__=et?et(null):{},this.size=0},nt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},nt.prototype.get=function(t){var e=this.__data__;if(et){var r=e[t];return r===n?void 0:r}return F.call(e,t)?e[t]:void 0},nt.prototype.has=function(t){var e=this.__data__;return et?void 0!==e[t]:F.call(e,t)},nt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=et&&void 0===e?n:e,this},ot.prototype.clear=function(){this.__data__=[],this.size=0},ot.prototype.delete=function(t){var e=this.__data__,r=lt(e,t);return!(r<0||(r==e.length-1?e.pop():V.call(e,r,1),--this.size,0))},ot.prototype.get=function(t){var e=this.__data__,r=lt(e,t);return r<0?void 0:e[r][1]},ot.prototype.has=function(t){return lt(this.__data__,t)>-1},ot.prototype.set=function(t,e){var r=this.__data__,n=lt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},at.prototype.clear=function(){this.size=0,this.__data__={hash:new nt,map:new(tt||ot),string:new nt}},at.prototype.delete=function(t){var e=mt(this,t).delete(t);return this.size-=e?1:0,e},at.prototype.get=function(t){return mt(this,t).get(t)},at.prototype.has=function(t){return mt(this,t).has(t)},at.prototype.set=function(t,e){var r=mt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},it.prototype.clear=function(){this.__data__=new ot,this.size=0},it.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},it.prototype.get=function(t){return this.__data__.get(t)},it.prototype.has=function(t){return this.__data__.has(t)},it.prototype.set=function(t,e){var n=this.__data__;if(n instanceof ot){var o=n.__data__;if(!tt||o.length<r-1)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new at(o)}return n.set(t,e),this.size=n.size,this};var ft,pt=function(t,e,r){for(var n=-1,o=Object(t),a=r(t),i=a.length;i--;){var c=a[ft?i:++n];if(!1===e(o[c],c,o))break}return t};function dt(t){return null==t?void 0===t?d:h:Y&&Y in Object(t)?function(t){var e=F.call(t,Y),r=t[Y];try{t[Y]=void 0;var n=!0}catch(t){}var o=z.call(t);n&&(e?t[Y]=r:delete t[Y]);return o}(t):function(t){return z.call(t)}(t)}function _t(t){return Nt(t)&&dt(t)==c}function yt(t){return!(!Lt(t)||(e=t,H&&H in e))&&(At(t)?G:_).test(function(t){if(null!=t){try{return x.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function vt(t){if(!Lt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Ot(t),r=[];for(var n in t)("constructor"!=n||!e&&F.call(t,n))&&r.push(n);return r}function bt(t,e,r,n,o){t!==e&&pt(e,function(a,i){if(Lt(a))o||(o=new it),function(t,e,r,n,o,a,i){var c=T(t,r),s=T(e,r),u=i.get(s);if(u)return void st(t,r,u);var l=a?a(c,s,r+"",t,e,i):void 0,h=void 0===l;if(h){var p=Tt(s),d=!p&&Dt(s),_=!p&&!d&&Mt(s);l=s,p||d||_?Tt(c)?l=c:Nt(m=c)&&Et(m)?l=function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(c):d?(h=!1,l=function(t,e){if(e)return t.slice();var r=t.length,n=K?K(r):new t.constructor(r);return t.copy(n),n}(s,!0)):_?(h=!1,y=s,v=!0?(b=y.buffer,g=new b.constructor(b.byteLength),new R(g).set(new R(b)),g):y.buffer,l=new y.constructor(v,y.byteOffset,y.length)):l=[]:function(t){if(!Nt(t)||dt(t)!=f)return!1;var e=B(t);if(null===e)return!0;var r=F.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&x.call(r)==$}(s)||wt(s)?(l=c,wt(c)?l=function(t){return function(t,e,r,n){var o=!r;r||(r={});var a=-1,i=e.length;for(;++a<i;){var c=e[a],s=n?n(r[c],t[c],c,r,t):void 0;void 0===s&&(s=t[c]),o?ht(r,c,s):ut(r,c,s)}return r}(t,xt(t))}(c):(!Lt(c)||n&&At(c))&&(l=function(t){return"function"!=typeof t.constructor||Ot(t)?{}:rt(B(t))}(s))):h=!1}var y,v,b,g;var m;h&&(i.set(s,l),o(l,s,n,a,i),i.delete(s));st(t,r,l)}(t,e,i,r,bt,n,o);else{var c=n?n(T(t,i),a,i+"",t,e,o):void 0;void 0===c&&(c=a),st(t,i,c)}},xt)}function gt(t,e){return St(function(t,e,r){return e=Q(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,a=Q(n.length-e,0),i=Array(a);++o<a;)i[o]=n[e+o];o=-1;for(var c=Array(e+1);++o<e;)c[o]=n[o];return c[e]=r(i),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,c)}}(t,e,zt),t+"")}function mt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function jt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return yt(r)?r:void 0}function Ct(t,e){var r=typeof t;return!!(e=null==e?i:e)&&("number"==r||"symbol"!=r&&y.test(t))&&t>-1&&t%1==0&&t<e}function Ot(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||N)}var St=function(t){var e=0,r=0;return function(){var n=Z(),i=a-(n-r);if(r=n,i>0){if(++e>=o)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(X?function(t,e){return X(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:zt);function It(t,e){return t===e||t!=t&&e!=e}var wt=_t(function(){return arguments}())?_t:function(t){return Nt(t)&&F.call(t,"callee")&&!q.call(t,"callee")},Tt=Array.isArray;function Et(t){return null!=t&&Pt(t.length)&&!At(t)}var Dt=W||function(){return!1};function At(t){if(!Lt(t))return!1;var e=dt(t);return e==u||e==l||e==s||e==p}function Pt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}function Lt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Nt(t){return null!=t&&"object"==typeof t}var Mt=w?function(t){return function(e){return t(e)}}(w):function(t){return Nt(t)&&Pt(t.length)&&!!v[dt(t)]};function xt(t){return Et(t)?ct(t,!0):vt(t)}var Ft,Ht=(Ft=function(t,e,r){bt(t,e,r)},gt(function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(o=Ft.length>3&&"function"==typeof o?(n--,o):void 0,a&&function(t,e,r){if(!Lt(r))return!1;var n=typeof e;return!!("number"==n?Et(r)&&Ct(e,r.length):"string"==n&&e in r)&&It(r[e],t)}(e[0],e[1],a)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var i=e[r];i&&Ft(t,i,r,o)}return t}));function zt(t){return t}t.exports=Ht}),FUNC_ERROR_TEXT="Expected a function",HASH_UNDEFINED="__lodash_hash_undefined__",INFINITY=1/0,funcTag="[object Function]",genTag="[object GeneratorFunction]",symbolTag="[object Symbol]",reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/,reLeadingDot=/^\./,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reEscapeChar=/\\(\\)?/g,reIsHostCtor=/^\[object .+?Constructor\]$/,freeGlobal="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")();function getValue(t,e){return null==t?void 0:t[e]}function isHostObject(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}var arrayProto=Array.prototype,funcProto=Function.prototype,objectProto=Object.prototype,coreJsData=root["__core-js_shared__"],maskSrcKey=function(){var t=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),funcToString=funcProto.toString,hasOwnProperty=objectProto.hasOwnProperty,objectToString=objectProto.toString,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Symbol$1=root.Symbol,splice=arrayProto.splice,Map=getNative(root,"Map"),nativeCreate=getNative(Object,"create"),symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function Hash(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{}}function hashDelete(t){return this.has(t)&&delete this.__data__[t]}function hashGet(t){var e=this.__data__;if(nativeCreate){var r=e[t];return r===HASH_UNDEFINED?void 0:r}return hasOwnProperty.call(e,t)?e[t]:void 0}function hashHas(t){var e=this.__data__;return nativeCreate?void 0!==e[t]:hasOwnProperty.call(e,t)}function hashSet(t,e){return this.__data__[t]=nativeCreate&&void 0===e?HASH_UNDEFINED:e,this}function ListCache(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function listCacheClear(){this.__data__=[]}function listCacheDelete(t){var e=this.__data__,r=assocIndexOf(e,t);return!(r<0)&&(r==e.length-1?e.pop():splice.call(e,r,1),!0)}function listCacheGet(t){var e=this.__data__,r=assocIndexOf(e,t);return r<0?void 0:e[r][1]}function listCacheHas(t){return assocIndexOf(this.__data__,t)>-1}function listCacheSet(t,e){var r=this.__data__,n=assocIndexOf(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}function MapCache(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function mapCacheClear(){this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}function mapCacheDelete(t){return getMapData(this,t).delete(t)}function mapCacheGet(t){return getMapData(this,t).get(t)}function mapCacheHas(t){return getMapData(this,t).has(t)}function mapCacheSet(t,e){return getMapData(this,t).set(t,e),this}function assocIndexOf(t,e){for(var r=t.length;r--;)if(eq(t[r][0],e))return r;return-1}function baseGet(t,e){for(var r=0,n=(e=isKey(e,t)?[e]:castPath(e)).length;null!=t&&r<n;)t=t[toKey(e[r++])];return r&&r==n?t:void 0}function baseIsNative(t){return!(!isObject(t)||isMasked(t))&&(isFunction(t)||isHostObject(t)?reIsNative:reIsHostCtor).test(toSource(t))}function baseToString(t){if("string"==typeof t)return t;if(isSymbol(t))return symbolToString?symbolToString.call(t):"";var e=t+"";return"0"==e&&1/t==-INFINITY?"-0":e}function castPath(t){return isArray(t)?t:stringToPath(t)}function getMapData(t,e){var r=t.__data__;return isKeyable(e)?r["string"==typeof e?"string":"hash"]:r.map}function getNative(t,e){var r=getValue(t,e);return baseIsNative(r)?r:void 0}function isKey(t,e){if(isArray(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!isSymbol(t))||(reIsPlainProp.test(t)||!reIsDeepProp.test(t)||null!=e&&t in Object(e))}function isKeyable(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function isMasked(t){return!!maskSrcKey&&maskSrcKey in t}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet,ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet,MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var stringToPath=memoize(function(t){t=toString(t);var e=[];return reLeadingDot.test(t)&&e.push(""),t.replace(rePropName,function(t,r,n,o){e.push(n?o.replace(reEscapeChar,"$1"):r||t)}),e});function toKey(t){if("string"==typeof t||isSymbol(t))return t;var e=t+"";return"0"==e&&1/t==-INFINITY?"-0":e}function toSource(t){if(null!=t){try{return funcToString.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function memoize(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(FUNC_ERROR_TEXT);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=t.apply(this,n);return r.cache=a.set(o,i),i};return r.cache=new(memoize.Cache||MapCache),r}function eq(t,e){return t===e||t!=t&&e!=e}memoize.Cache=MapCache;var isArray=Array.isArray;function isFunction(t){var e=isObject(t)?objectToString.call(t):"";return e==funcTag||e==genTag}function isObject(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function isObjectLike(t){return!!t&&"object"==typeof t}function isSymbol(t){return"symbol"==typeof t||isObjectLike(t)&&objectToString.call(t)==symbolTag}function toString(t){return null==t?"":baseToString(t)}function get(t,e,r){var n=null==t?void 0:baseGet(t,e);return void 0===n?r:n}var lodash_get=get;const debug=logger.extend("i18n"),DEFAULT_LOCALE="en",LOCALE_CHANGED="bearer-locale-changed";class I18n{constructor(){this._locale=DEFAULT_LOCALE,this._dictionnary={[DEFAULT_LOCALE]:{}},this.load=((t,e,{locale:r=this.locale}={})=>__awaiter(this,void 0,void 0,function*(){const n=yield e,o=t?{[t]:n}:n;this._dictionnary[r]=lodash_merge(lodash_get(this._dictionnary,r),o),this.localeChanged()})),this.get=((t,e,r={})=>{const n=[r.locale||this.locale,t,e].filter(t=>t).join(".");return debug("lookup key",n),lodash_get(this._dictionnary,n)})}localeChanged(){document.dispatchEvent(new CustomEvent(LOCALE_CHANGED,{detail:{locale:this.locale}}))}set locale(t){this._locale=t,this.localeChanged()}get locale(){return this._locale}}const i18n=new I18n,bearer=t=>new Bearer(t);bearer.version="0.96.2-next.13+c398332a",bearer.i18n=i18n;export default bearer;export{I18n as i18n}; | ||
//# sourceMappingURL=index.js.map |
export default class Bearer { | ||
private readonly clientId; | ||
constructor(clientId: string); | ||
readonly clientId: string; | ||
private registeredIntegrations; | ||
private config; | ||
private observer?; | ||
private debounceRefresh; | ||
constructor(clientId: string, options?: Partial<TBearerOptions>); | ||
/** | ||
* Retrieve all dom elements starting by bearer- and ask for assets urls if | ||
*/ | ||
loadMissingIntegrations: () => void; | ||
/** | ||
* check wether if an integration is resgistered | ||
*/ | ||
registeredIntegration: (tagName: string) => boolean; | ||
/** | ||
* load integration asset or wait until dom is loaded | ||
*/ | ||
private initialIntegrationLoading; | ||
/** | ||
* Register a DOM observer so that we can load integration assets only when we need them | ||
*/ | ||
private registerDomObserver; | ||
private observerCallback; | ||
/** | ||
* remove dom observer | ||
*/ | ||
private disconnectObserver; | ||
/** | ||
* retrieve corresponding integration asset url | ||
*/ | ||
sendTags: (tags: string[]) => Promise<boolean>; | ||
} | ||
declare type TBearerOptions = { | ||
domObserver: boolean; | ||
refreshDebounceDelay: number; | ||
}; | ||
/** | ||
* Extract/format element tag names given a regexp | ||
* @param elements | ||
* @param filter | ||
*/ | ||
export declare function findElements(elements: HTMLCollection | NodeListOf<Element>, filter?: RegExp): string[]; | ||
export {}; |
@@ -5,3 +5,4 @@ import Bearer from './bearer'; | ||
version: string; | ||
i18n: import("./i18n").I18n; | ||
}; | ||
export default bearer; |
import bearer from './lib/main'; | ||
export { I18n as i18n } from './lib/i18n'; | ||
export default bearer; |
export default class Bearer { | ||
private readonly clientId; | ||
constructor(clientId: string); | ||
readonly clientId: string; | ||
private registeredIntegrations; | ||
private config; | ||
private observer?; | ||
private debounceRefresh; | ||
constructor(clientId: string, options?: Partial<TBearerOptions>); | ||
/** | ||
* Retrieve all dom elements starting by bearer- and ask for assets urls if | ||
*/ | ||
loadMissingIntegrations: () => void; | ||
/** | ||
* check wether if an integration is resgistered | ||
*/ | ||
registeredIntegration: (tagName: string) => boolean; | ||
/** | ||
* load integration asset or wait until dom is loaded | ||
*/ | ||
private initialIntegrationLoading; | ||
/** | ||
* Register a DOM observer so that we can load integration assets only when we need them | ||
*/ | ||
private registerDomObserver; | ||
private observerCallback; | ||
/** | ||
* remove dom observer | ||
*/ | ||
private disconnectObserver; | ||
/** | ||
* retrieve corresponding integration asset url | ||
*/ | ||
sendTags: (tags: string[]) => Promise<boolean>; | ||
} | ||
declare type TBearerOptions = { | ||
domObserver: boolean; | ||
refreshDebounceDelay: number; | ||
}; | ||
/** | ||
* Extract/format element tag names given a regexp | ||
* @param elements | ||
* @param filter | ||
*/ | ||
export declare function findElements(elements: HTMLCollection | NodeListOf<Element>, filter?: RegExp): string[]; | ||
export {}; |
@@ -5,3 +5,4 @@ import Bearer from './bearer'; | ||
version: string; | ||
i18n: import("./i18n").I18n; | ||
}; | ||
export default bearer; |
{ | ||
"name": "@bearer/js", | ||
"version": "0.96.1", | ||
"version": "0.96.2-next.13+c398332a", | ||
"description": "A JavaScript library for working with Bearer integrations", | ||
@@ -16,5 +16,13 @@ "jsdelivr": "lib/bearer.production.min.js", | ||
], | ||
"dependencies": { | ||
"@bearer/logger": "^0.96.2-next.13+c398332a", | ||
"debounce": "^1.2.0", | ||
"jest-fetch-mock": "^2.1.1" | ||
}, | ||
"devDependencies": { | ||
"@bearer/tsconfig": "^0.96.1", | ||
"@bearer/tsconfig": "^0.96.2-next.13+c398332a", | ||
"@types/debounce": "^1.2.0", | ||
"@types/jest": "^23.3.13", | ||
"@types/lodash.get": "^4.4.4", | ||
"@types/lodash.merge": "^4.6.4", | ||
"jest": "^23.6.0", | ||
@@ -37,3 +45,3 @@ "rollup-plugin-commonjs": "^9.2.0", | ||
}, | ||
"gitHead": "04014f4d9725dc044e46ece175597f45bf0d0a40" | ||
"gitHead": "c398332a9a62264a5fa5c5dfe96f991c6c55c365" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
406900
24
466
3
12
5
+ Addeddebounce@^1.2.0
+ Addedjest-fetch-mock@^2.1.1
+ Added@bearer/logger@0.96.2-next.13(transitive)
+ Addedcross-fetch@2.2.6(transitive)
+ Addeddebounce@1.2.1(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedjest-fetch-mock@2.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedpromise-polyfill@7.1.2(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-fetch@2.0.4(transitive)
+ Addedwhatwg-url@5.0.0(transitive)