webcom
Version:
Webcom library
18 lines • 44.5 kB
JavaScript
/*!
* Webcom. Build realtime apps. Share and sync data instantly between your clients
*
* Module name: Webcom
* Version: 3.8.0
* Created: 2025-06-26T13:38:09.952Z
*
* Copyright (C) <2015-2025> Orange
*
* This software is confidential and proprietary information of Orange.
* You shall not disclose such Confidential Information and shall use it only in
* accordance with the terms of the agreement you entered into.
* Unauthorized copying of this file, via any medium is strictly prohibited.
*
* If you are Orange employee you shall use this software in accordance with
* the Orange Source Charter (http://opensource.itn.ftgroup/index.php/Orange_Source_Charter)
*/
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,(()=>(()=>{"use strict";var t={730:(t,e)=>{var n,r={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};r.bitArray={bitSlice:function(t,e,n){return t=r.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===n?t:r.bitArray.clamp(t,n-e)},extract:function(t,e,n){var r=Math.floor(-e-n&31);return(-32&(e+n-1^e)?t[e/32|0]<<32-r^t[e/32+1|0]>>>r:t[e/32|0]>>>r)&(1<<n)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var n=t[t.length-1],i=r.bitArray.getPartial(n);return 32===i?t.concat(e):r.bitArray._shiftRight(e,i,0|n,t.slice(0,t.length-1))},bitLength:function(t){var e,n=t.length;return 0===n?0:(e=t[n-1],32*(n-1)+r.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length<e)return t;var n=(t=t.slice(0,Math.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=r.bitArray.partial(e,t[n-1]&2147483648>>e-1,1)),t},partial:function(t,e,n){return 32===t?e:(n?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(r.bitArray.bitLength(t)!==r.bitArray.bitLength(e))return!1;var n,i=0;for(n=0;n<t.length;n++)i|=t[n]^e[n];return 0===i},_shiftRight:function(t,e,n,i){var o,a,s;for(void 0===i&&(i=[]);e>=32;e-=32)i.push(n),n=0;if(0===e)return i.concat(t);for(o=0;o<t.length;o++)i.push(n|t[o]>>>e),n=t[o]<<32-e;return a=t.length?t[t.length-1]:0,s=r.bitArray.getPartial(a),i.push(r.bitArray.partial(e+s&31,e+s>32?n:i.pop(),1)),i},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,n;for(e=0;e<t.length;++e)n=t[e],t[e]=n>>>24|n>>>8&65280|(65280&n)<<8|n<<24;return t}},r.codec.utf8String={fromBits:function(t){var e,n,i="",o=r.bitArray.bitLength(t);for(e=0;e<o/8;e++)0==(3&e)&&(n=t[e/4]),i+=String.fromCharCode(n>>>8>>>8>>>8),n<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,n=[],i=0;for(e=0;e<t.length;e++)i=i<<8|t.charCodeAt(e),3==(3&e)&&(n.push(i),i=0);return 3&e&&n.push(r.bitArray.partial(8*(3&e),i)),n}},r.codec.base64={_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,n){var i,o="",a=0,s=r.codec.base64._chars,u=0,c=r.bitArray.bitLength(t);for(n&&(s=s.substr(0,62)+"-_"),i=0;6*o.length<c;)o+=s.charAt((u^t[i]>>>a)>>>26),a<6?(u=t[i]<<6-a,a+=26,i++):(u<<=6,a-=6);for(;3&o.length&&!e;)o+="=";return o},toBits:function(t,e){t=t.replace(/\s|=/g,"");var n,i,o=[],a=0,s=r.codec.base64._chars,u=0;for(e&&(s=s.substr(0,62)+"-_"),n=0;n<t.length;n++){if((i=s.indexOf(t.charAt(n)))<0)throw new r.exception.invalid("this isn't base64!");a>26?(a-=26,o.push(u^i>>>a),u=i<<32-a):u^=i<<32-(a+=6)}return 56&a&&o.push(r.bitArray.partial(56&a,u,1)),o}},r.codec.base64url={fromBits:function(t){return r.codec.base64.fromBits(t,1,1)},toBits:function(t){return r.codec.base64.toBits(t,1)}},r.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},r.hash.sha256.hash=function(t){return(new r.hash.sha256).update(t).finalize()},r.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=r.codec.utf8String.toBits(t));var e,n=this._buffer=r.bitArray.concat(this._buffer,t),i=this._length,o=this._length=i+r.bitArray.bitLength(t);if(o>9007199254740991)throw new r.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var a=new Uint32Array(n),s=0;for(e=512+i-(512+i&511);e<=o;e+=512)this._block(a.subarray(16*s,16*(s+1))),s+=1;n.splice(0,16*s)}else for(e=512+i-(512+i&511);e<=o;e+=512)this._block(n.splice(0,16));return this},finalize:function(){var t,e=this._buffer,n=this._h;for(t=(e=r.bitArray.concat(e,[r.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),n},_init:[],_key:[],_precompute:function(){var t,e,n=0,r=2;function i(t){return 4294967296*(t-Math.floor(t))|0}for(;n<64;r++){for(e=!0,t=2;t*t<=r;t++)if(r%t==0){e=!1;break}e&&(n<8&&(this._init[n]=i(Math.pow(r,.5))),this._key[n]=i(Math.pow(r,1/3)),n++)}},_block:function(t){var e,n,r,i,o=this._h,a=this._key,s=o[0],u=o[1],c=o[2],h=o[3],f=o[4],l=o[5],d=o[6],p=o[7];for(e=0;e<64;e++)e<16?n=t[e]:(r=t[e+1&15],i=t[e+14&15],n=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+t[15&e]+t[e+9&15]|0),n=n+p+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(d^f&(l^d))+a[e],p=d,d=l,l=f,f=h+n|0,h=c,c=u,s=n+((u=s)&c^h&(u^c))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+u|0,o[2]=o[2]+c|0,o[3]=o[3]+h|0,o[4]=o[4]+f|0,o[5]=o[5]+l|0,o[6]=o[6]+d|0,o[7]=o[7]+p|0}},r.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},r.hash.sha1.hash=function(t){return(new r.hash.sha1).update(t).finalize()},r.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=r.codec.utf8String.toBits(t));var e,n=this._buffer=r.bitArray.concat(this._buffer,t),i=this._length,o=this._length=i+r.bitArray.bitLength(t);if(o>9007199254740991)throw new r.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var a=new Uint32Array(n),s=0;for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=o;e+=this.blockSize)this._block(a.subarray(16*s,16*(s+1))),s+=1;n.splice(0,16*s)}else for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=o;e+=this.blockSize)this._block(n.splice(0,16));return this},finalize:function(){var t,e=this._buffer,n=this._h;for(t=(e=r.bitArray.concat(e,[r.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),n},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,n,r){return t<=19?e&n|~e&r:t<=39?e^n^r:t<=59?e&n|e&r|n&r:t<=79?e^n^r:void 0},_S:function(t,e){return e<<t|e>>>32-t},_block:function(t){var e,n,r,i,o,a,s,u,c=this._h;if("undefined"!=typeof Uint32Array){u=Array(80);for(var h=0;h<16;h++)u[h]=t[h]}else u=t;for(r=c[0],i=c[1],o=c[2],a=c[3],s=c[4],e=0;e<=79;e++)e>=16&&(u[e]=this._S(1,u[e-3]^u[e-8]^u[e-14]^u[e-16])),n=this._S(5,r)+this._f(e,i,o,a)+s+u[e]+this._key[Math.floor(e/20)]|0,s=a,a=o,o=this._S(30,i),i=r,r=n;c[0]=c[0]+r|0,c[1]=c[1]+i|0,c[2]=c[2]+o|0,c[3]=c[3]+a|0,c[4]=c[4]+s|0}},t.exports&&(t.exports=r),void 0===(n=function(){return r}.apply(e,[]))||(t.exports=n)}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};return(()=>{n.d(r,{default:()=>Jt});var t=function(){if("undefined"!=typeof globalThis)return globalThis;return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:Function("return this")()}();function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function s(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(t,e)||s(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function h(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||s(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var f=t.WebcomDependencies||{},l={};function d(t,e,n){Object.defineProperty(l,t,{enumerable:!0,get:e,set:n})}var p="browser",v="mobile/",g="".concat(v,"android"),y="".concat(v,"iOS"),b={browser:"b"};b[g]="a",b[y]="i",b.node="n";var m,_=!0,w="device",k=f.device;if(!k){var A=t.window;A&&A.location?A.location.href.indexOf("webview.datasync.orange.com")<0?S(p):S(g):S(y)}function S(t){k=t,_=t===p,0===t.indexOf(v),m=(b[t]||"")+"3.8.0"}function O(t){return"string"==typeof t}function P(t){return"function"==typeof t}function R(t){return"object"===c(t)}d(w,(function(){return k}),(function(t){return S(t)}));var E="Webcom internal error";function I(t,e){t||C(E,e)}var j={values:[]};function x(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];Object.assign(j,{method:t,args:e||[],checkers:r})}var C=function(t,e){var n;throw new Error("".concat((n="").concat.apply(n,h(t)),": ").concat(e))};function T(t,e){if(!j.method){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];x.apply(void 0,[t,e].concat(r))}var o=j.method,a=j.args,s=j.checkers,u=j.values;Object.assign(j,{method:void 0,args:void 0,checkers:void 0,values:[]}),a.length>s.length&&C(o,"too many arguments, ".concat(a.length," instead of ").concat(s.length)),s.forEach((function(t,e){return H(t,a[e],o,(function(t){return"argument #".concat(e+1," ").concat(t)}))})),u.forEach((function(t){var e=t.name,n=t.value;return H(t.checker,n,o,(function(t){return"".concat(e," ").concat(t)}))}))}function H(t,e,n,r){var i=t(e);i&&C(n,r(i))}function L(t){return function(e){return D("undefined")(e)&&t&&t(e)}}var N=function(t){return void 0===t?"is missing":""};function U(t){return function(e){return!(e instanceof t)&&"must be an instance of ".concat(t.name)}}function D(t){return function(e){return c(e)!==t&&"must be a ".concat(t)}}var F=D("undefined"),W=D("string"),M=D("function"),q=D("boolean"),z=B(Number.isFinite,"must be a finite number"),J=D("object");function K(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(t){return e.every((function(e){return e(t)}))&&"either ".concat(e.map((function(e){return e(t)})).join(" or "))}}function B(t,e){return function(n){return!t(n)&&(e||"is not valid")}}B((function(t){return"number"==typeof t&&Math.floor(t)===t}),"must be an integer");function G(t,e){return B((function(e){return t.test(e)}),e)}var V="console",Q=f.console,X=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=function(t){return R(t)?JSON.stringify(t):(t||"undefined").toString()};if(O(t)){var o=0;return[t=t.replace(/%(.)/g,(function(t,e){switch(e){case"%":return"%";case"s":case"o":case"O":return i(n[o++]);case"d":case"i":case"f":return n[o++];default:return t}}))].concat(h(n.slice(o).map(i))).join(" ")}return[t].concat(n).map(i).join(" ")};function Y(t,e,n,r,i){if(!n||!r||!i){var o=e,a=function(t){return function(e){return o("[".concat(t,"] ").concat(e))}};n=n||a("INFO"),r=r||a("WARN"),i=i||a("ERR!"),e=a("LOG ")}return{log:function(){return e.call(t,X.apply(void 0,arguments))},info:function(){return n.call(t,X.apply(void 0,arguments))},warn:function(){return r.call(t,X.apply(void 0,arguments))},error:function(){return i.call(t,X.apply(void 0,arguments))}}}if(P(Q))Q=Y(t,Q);else if(R(Q)&&Q){var $=Q,Z=$.log,tt=$.info,et=$.warn,nt=$.error;Q=Y(Q,Z,tt,et,nt)}else{Q=Y(t.console,t.console.log,t.console.info,t.console.warn,t.console.error)}d(V,(function(){return Q}),(function(t){return Q=t}));var rt="setTimeout",it=f.setTimeout;it||(it=t.setTimeout),d(rt,(function(){return it}),(function(t){return it=t})),t.setTimeout||(t.setTimeout=it),t.setImmediate||(t.setImmediate=it);var ot="clearTimeout",at=f.clearTimeout;at||(at=t.clearTimeout),d(ot,(function(){return at}),(function(t){return at=t})),t.clearTimeout||(t.clearTimeout=at),t.clearImmediate||(t.clearImmediate=at);var st="setInterval",ut=f.setInterval;ut||(ut=t.setInterval),d(st,(function(){return ut}),(function(t){return ut=t}));var ct="clearInterval",ht=f.clearInterval;ht||(ht=t.clearInterval),d(ct,(function(){return ht}),(function(t){return ht=t}));var ft=Function.prototype;var lt={};function dt(t,e){var n=t.length;return n>=e?t.substring(0,e):t+gt.substring(0,e-n)}function pt(t){return t.map((function(t){return P(t)?t():t}))}var vt=function(){function t(n,r,i,o){e(this,t),this._fqdn=n,this._prefix=r;var a=n.join(".");this._count=void 0===lt[a]?lt[a]=0:++lt[a],this.displayTimestamp=i,this.setPrefixWidth(o||8),this._log=this._emitLog.bind(this,Q.log),this._info=this._emitLog.bind(this,Q.info),this._warn=this._emitLog.bind(this,Q.warn),this._error=this._emitLog.bind(this,Q.error),this._enabled=!0}return o(t,[{key:"fqdn",get:function(){return this._fqdn}},{key:"_emitLog",value:function(t,e){var n=this.displayTimestamp?[(new Date).toISOString()]:[];n.push(this._displayedPrefix);for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];O(e)?(n.push(e),e=n.join(" "),t.apply(void 0,[e].concat(h(pt(i))))):t.apply(void 0,n.concat(h(pt([e].concat(i)))))}},{key:"setPrefixWidth",value:function(t){this._displayedPrefix="".concat(dt(this._prefix,t)," #").concat(dt(this._count.toString(),3))}},{key:"setLevel",value:function(t){this._enabled=t>=0,this.log=t>=Tt.LOG?this._log:ft,this.info=t>=Tt.INFO?this._info:ft,this.warn=t>=Tt.WARN?this._warn:ft,this.error=t>=Tt.ERROR?this._error:ft}},{key:"updateLevel",value:function(t){this._enabled&&this.setLevel(t)}}]),t}(),gt=" ",yt=!1,bt=15,mt=[],_t={},wt={},kt={},At="_leaf_";function St(t){return t?t.split("."):[]}function Ot(t){return{disabledDepth:Et(t,kt),enabledDepth:Et(t,wt)}}function Pt(t,e,n,r){for(var i=0;i<t.length;){var o=t[i++];e.hasOwnProperty(o)||(e[o]={}),e=e[o]}r&&Object.keys(e).forEach((function(t){return delete e[t]})),e._leaf_=n}function Rt(t,e){for(var n=0;n<t.length;){var r=t[n++];if(!e.hasOwnProperty(r))return;e=e[r]}delete e._leaf_}function Et(t,e){var n=-1,r=0;do{e.hasOwnProperty(At)&&(n=r)}while(r<t.length&&(e=e[t[r++]]));return n}function It(t,e){Object.entries(t||{}).forEach((function(t){var n=u(t,2),r=n[0],i=n[1];r===At?e(i):It(i,e)}))}function jt(t,e){for(var n=[],r=0;e&&r<t.length;)e=e[t[r++]];return It(e,(function(t){return n.push(t)})),n}function xt(t){yt=t,mt.forEach((function(t){return t.displayTimestamp=yt}))}var Ct="LogManager",Tt=function(){function t(){e(this,t)}return o(t,null,[{key:"enable",value:function(e){T([Ct,".enable"],arguments,L(W));var n=St(e),r=Ot(n),i=r.enabledDepth,o=r.disabledDepth;i<=o&&(o<0&&t.disable(),Pt(n,wt,!0,!0),Rt(n,kt),jt(n,_t).forEach((function(t){return t.setLevel(Lt)})))}},{key:"disable",value:function(t){T([Ct,".disable"],arguments,L(W));var e=St(t),n=Ot(e),r=n.enabledDepth,i=n.disabledDepth;i<=r&&(Pt(e,kt,!0,!0),Rt(e,wt),jt(e,_t).forEach((function(t){return t.setLevel(-1)})))}},{key:"showTimestamp",value:function(){T([Ct,".showTimestamp"],arguments),xt(!0)}},{key:"hideTimestamp",value:function(){T([Ct,".hideTimestamp"],arguments),xt(!1)}},{key:"setPrefixWidth",value:function(t){T([Ct,".setPrefixWidth"],arguments,z),t<0?t=0:t>gt.length&&(t=gt.length),bt=t,mt.forEach((function(t){return t.setPrefixWidth(bt)}))}},{key:"level",get:function(){return Lt},set:function(t){T([Ct,".level"],arguments,z),t>-1&&t!==Lt&&(mt.forEach((function(e){return e.updateLevel(t)})),Lt=t)}},{key:"LOG",get:function(){return 4}},{key:"INFO",get:function(){return 3}},{key:"WARN",get:function(){return 2}},{key:"ERROR",get:function(){return 1}},{key:"NONE",get:function(){return 0}},{key:"debugOnCallback",value:function(t){var e=t&&t.toUpperCase();return function(t,n){return Q.log("********** UPDATE ".concat(e||t.ref().pathString()," **********"),t.toString(),n?"[<<".concat(n,"]"):"")}}},{key:"debugOnCompletionCallback",value:function(t,e){var n=t&&t.toUpperCase();return function(t){return t?Q.log("********** REVOKED ".concat(n," **********"),t):Q.log("********** COMPLETED ".concat(n," **********")),e}}},{key:"debugOnCallbackWithCancel",value:function(e){var n=e&&e.toUpperCase();return[t.debugOnCallback(e),function(t){return Q.log.apply(Q,["********** COMPLETE ".concat(n," **********")].concat(h(t?["FAILED:",t.code,t.message]:["cancelled"])))}]}}]),t}();function Ht(t,e){var n=St(t),r=new vt(n,e||n[n.length-1],yt,bt);return function(t){var e=t.fqdn;Pt(e,_t,t),mt.push(t);var n=Ot(e),r=n.disabledDepth,i=n.enabledDepth;t.setLevel(i>=r?Lt:-1)}(r),r}var Lt=Tt.INFO,Nt="WebcomApp",Ut=function(){function t(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(this,t),T(["new ",Nt],arguments,G(/^[a-z0-9](?:[-a-z0-9]{0,38}[a-z0-9])?$/),L(K(J,W))),this._logger=Ht("api.WebcomApp",Nt),this._services={},this.appId=n,this.config={},O(r)&&(r=Object.keys(Wt).reduce((function(t,e){return t[e]={baseUrl:r},t}),{})),this._fillConfig(r),this._logger.log("Initialized %s with options %s",n,JSON.stringify(this.config))}return o(t,[{key:"dispose",value:function(){T([Nt,"#dispose"],arguments),Object.values(this._services).forEach((function(t){return t._dispose()})),this._services={}}},{key:"_fillConfig",value:function(t){Dt.call(this,t,Wt)}},{key:"toString",value:function(){return"".concat(this.appId,"{").concat(Object.keys(this._services).join(","),"}")}}]),t}();function Dt(t,e){var n=this;!function t(e,r,i,o){var a=function(t){return"".concat(Nt,".Configuration.").concat(o.concat(t).join("."))};r=Object.assign({},r),Object.entries(i).forEach((function(i){var s=u(i,2),c=s[0],h=s[1];if(h instanceof Object&&!(h instanceof Array))e[c]=e[c]||{},t(e[c],r[c]||{},h,o.concat(c));else{var f=r[c],l=h[1]||function(t){return t};try{e[c]=l(void 0===f?void 0===e[c]?h.length?h[0]:h:e[c]:f)}catch(t){var d=a(c);void 0===t.value?C(d,t.message):(n._logger.warn("%s: %s",d,t.message),e[c]=t.value)}}delete r[c]})),Object.keys(r).forEach((function(t){return n._logger.warn("%s: unknown config key",a(t))}))}(this.config,t,e,[])}function Ft(t,e,n){return"".concat(n.key,":").concat(e,":").concat(function(t,e){var n=e.baseUrl;return"/".concat(n.protocol.slice(0,-1),"/").concat(n.host,"/").concat(t.appId,"/")}(t,n))}var Wt={},Mt="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",qt=Mt.length;var zt="Webcom",Jt=function(){function t(){e(this,t),this._init.apply(this,arguments)}return o(t,[{key:"_init",value:function(){C(["new ",zt],"this static class cannot be instantiated")}}],[{key:"SDK_VERSION",get:function(){return"3.8.0"}},{key:"Log",get:function(){return Tt}},{key:"App",value:function(t,e){return new Ut(t,e)}},{key:"getUniqueKeyDate",value:function(t){return new Date(function(t){for(var e=t.substring(0,8),n=0,r=0;r<8;++r)n=n*qt+Mt.indexOf(e[r]);return n}(t))}},{key:"dependencies",get:function(){return l}}]),t}(),Kt=Ht("api.Webcom",zt);function Bt(t){"http:"===t.protocol&&_&&"https:"===window.location.protocol&&this._logger.warn("Insecure access to a Webcom service from a secure page. Please setup your service with an https protocol.")}var Gt=new RegExp("^(?:([^:]+:)//)?(?:[^/@]+@)?([^/:]+(?::\\d+)?)(?:/.*)?$"),Vt="io.datasync.orange.com";function Qt(t,e){return function(n){var r=t(n);if(r)throw new Error(r);return e?e(n):n}}function Xt(t,e,n,r){return $t(t,e,{value:n},r)}function Yt(t,e,n,r){return $t(t,e,{get:n},r)}function $t(t,e,n,r){return Object.defineProperty(t,e,Object.assign(n,{enumerable:r,configurable:!0}))}var Zt="some",te="required",ee="none",ne=function(){function t(n,r){e(this,t),I(n===Zt||n===te||n===ee,"Wrong state value for a new State object: expecting 'some', 'required' or 'none'."),this.state=n,I(n!==Zt||r&&r.webcomAuthToken,"Missing details or webcomAuthToken for a new 'some' State"),this.details=r}return o(t,[{key:"isUnauthenticated",value:function(){return this.state===ee}},{key:"isAuthenticated",value:function(){return this.state===Zt}},{key:"isRequired",value:function(){return this.state===te}},{key:"isSameAs",value:function(t){return this.state===t.state&&(this.state!==Zt||this.details.webcomAuthToken===t.details.webcomAuthToken)}}]),t}(),re=new ne(ee),ie=(new ne(te),function(t){return new ne(Zt,t)});var oe,ae="Authentication";function se(t){switch(T([zt,".avatarURL"],arguments,J),t&&t.provider){case"facebook":return"https://graph.facebook.com/".concat(t.providerUid,"/picture?type=large");case"github":return t.providerProfile.avatar_url;case"gitlab":case"google":return t.providerProfile.picture}}function ue(t){var e=t.code||"UNKNOWN_ERROR",n=t.message||JSON.stringify(t),r=new Error("".concat(e,"[").concat(n,"]"));return r.code=e,r}Wt.Authentication={from:[void 0,Qt(L(U(Ut)))],baseUrl:[null,function(e){if(e&&(t.URL&&e instanceof URL||e.href&&e.protocol&&e.host))return e;var n=e?Gt.exec(e):[Vt,void 0,Vt];if(n){var r=u(n,3),i=r[0],o=r[1],a=r[2];return o||(i="".concat(o="https:","//").concat(i)),{href:i,protocol:o,host:a}}throw new Error("cannot parse base URL: ".concat(e))}],storage:[void 0,Qt(L(K(W,M)))],initialState:[void 0,function(t){return t&&JSON.parse(t)}],key:[void 0,Qt(F,(function(){return"auth"}))]},function(t,e,n,r){Yt(t.prototype,e,n,r)}(Ut,"authentication",(function(){var t=this._services.Authentication;if(!t){var e=this.config.Authentication.from;t=e?e.authentication:oe(this),this._services.Authentication=t}return t}));var ce=function(){function t(){e(this,t),this.cache_={}}return o(t,[{key:"length",get:function(){return Object.keys(this.cache_).length}},{key:"key",value:function(t){var e=Object.keys(this.cache_);return 0<=t&&t<e.length?e[t]:null}},{key:"getItem",value:function(t){return this.cache_.hasOwnProperty(t)?this.cache_[t]:null}},{key:"setItem",value:function(t,e){this.cache_[t]=e}},{key:"removeItem",value:function(t){delete this.cache_[t]}},{key:"clear",value:function(){this.cache_={}}}]),t}(),he="localStorage",fe=f.localStorage;fe||(fe=t.localStorage||new ce),d(he,(function(){return fe}),(function(t){return fe=t}));var le="sessionStorage",de=f.sessionStorage;function pe(t){return"webcom:"+t}de||(de=t.sessionStorage||null),d(le,(function(){return de}),(function(t){return de=t}));var ve=o((function t(n,r){e(this,t);var i=n();if(i){var o=pe("sentinel");i.setItem(o,""),i.removeItem(o)}function a(){return n()||C("JSONStorage","the ".concat(r," implementation could not be found!"))}this.set=function(t,e){if(null===e)a().removeItem(pe(t));else{var n=JSON.stringify(e);a().setItem(pe(t),"string"==typeof n?n:"null")}},this.get=function(t){var e=a().getItem(pe(t));return e&&JSON.parse(e)},this.remove=function(t){a().removeItem(pe(t))}})),ge=new ve((function(){return fe}),"localStorage"),ye=new ve((function(){return de}),"sessionStorage"),be=n(730),me=n.n(be);function _e(t){return decodeURIComponent(t.replace(/\+/g," "))}function we(){var t=2147483648;return Math.floor(Math.random()*t).toString(36)+Math.abs(Math.floor(Math.random()*t)^Date.now()).toString(36)}function ke(t){var e={};return t.replace(/^[^?]*\?/,"").split("&").forEach((function(t){var n=t.indexOf("=");if(n<0)e[_e(t)]=!0;else{var r=_e(t.substring(0,n));e[r]=_e(t.substring(n+1))}})),e}function Ae(t){if(!t)return"";var e=[];return Object.entries(t).forEach((function(t){var n=u(t,2),r=n[0],i=n[1];null!=i&&(R(i)&&(i=JSON.stringify(i)),e.push(encodeURIComponent(r)+"="+encodeURIComponent(i)))})),e.join("&")}function Se(t,e){var n=t.indexOf("?"),r=e?(n<0?"?":"&")+Ae(e):"",i=t.indexOf("#");return i<0?t+r:t.substring(0,i)+r+t.substring(i)}function Oe(t,e){return Oe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Oe(t,e)}function Pe(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function Re(t,e,n){return Re=Pe()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&Oe(i,n.prototype),i},Re.apply(null,arguments)}var Ee="XMLHttpRequest",Ie=f.XMLHttpRequest;Ie||(void 0===(Ie=t.XMLHttpRequest)||function(){if(_&&"Microsoft Internet Explorer"===window.navigator.appName){var t=window.navigator.userAgent.match(/MSIE (\d+[.\d]*)/);return t&&t.length>1&&parseFloat(t[1])<10}return!1}())&&C(E,"XMLHttpRequest not found"),d(Ee,(function(){return Ie}),(function(t){return Ie=t}));var je=Ht("network.HttpRequest","HttpRequest"),xe="application/x-www-form-urlencoded",Ce="application/json",Te="Content-Type",He="PUT",Le="PATCH",Ne="POST",Ue="DELETE",De="GET",Fe=o((function t(n,r){e(this,t),this.name=n,this.value=r})),We="HttpRequest",Me=function(){function t(n,r){e(this,t);for(var i=arguments.length,o=new Array(i>2?i-2:0),a=2;a<i;a++)o[a-2]=arguments[a];this.url=Se([r].concat(h(o.filter((function(t){return t&&t.length})).map((function(t){return encodeURIComponent(t)})))).join("/"),{c:m}),this.method=n.toUpperCase(),this.headers={Accept:"application/json, text/plain"}}return o(t,[{key:"addQueryParameters",value:function(t){return this.url=Se(this.url,t),this}},{key:"addJson",value:function(t){return this.contentType=Ce,this.data=t,this}},{key:"addForm",value:function(t){return this.contentType=xe,this.data=t,this}},{key:"addHeader",value:function(t){return T([We,"#addHeader"],arguments,L(U(Fe))),t&&(this.headers[t.name]=t.value),this}},{key:"readResponseHeaders",value:function(){return this.readHeaders=!0,this}},{key:"send",value:function(){var t=this;return new Promise((function(e,n){var r=null;void 0!==t.data&&[Ne,He,Le].indexOf(t.method)>=0&&((r=t.contentType===xe?Ae(t.data):t.contentType===Ce?JSON.stringify(t.data):t.data)?t.headers[Te]=t.contentType:delete t.headers[Te]),je.log("==> ".concat(t.method," ").concat(t.url)),Object.keys(t.headers).forEach((function(e){return je.log(" > HEADER ".concat(e,": ").concat(t.headers[e]))})),r&&je.log(" > DATA: ".concat(r)),t._open(r,e,(function(t){je.log("<== ERROR: ".concat(JSON.stringify(t))),n(ue(t))}))}))}},{key:"_open",value:function(t,e,n){var r=this,i=new Ie,o="RESPONSE_PAYLOAD_ERROR";i.onreadystatechange=function(){if(4===i.readyState){var t=i.responseText,a=i.status;if(a>=500)n({code:o,message:"HTTP status ".concat(a)});else try{var s=t.length?JSON.parse(t):{};if(a>=400)n(s.error||s);else if(a>=200&&a<300||304===a){var u={body:s},c=u.body.error||null;c?n(R(c)?c:{code:u.body.status,message:c}):(r.readHeaders&&(u.headers=function(t){var e=t.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};return e.forEach((function(t){var e=t.indexOf(": "),r=t.substring(0,e).toLowerCase();n[r]=t.substring(e+2)})),n}(i)),je.log("<== ".concat(JSON.stringify(u))),e(u))}else n({code:o,message:"HTTP status ".concat(a)})}catch(t){n({code:o,message:"invalid response payload, not a Json content type"})}}},i.open(this.method,this.url,!0),Object.entries(this.headers).forEach((function(t){var e=u(t,2),n=e[0],r=e[1];return i.setRequestHeader(n,r)})),i.send(t)}}]),t}();function qe(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Re(Me,[De,t].concat(n))}function ze(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Re(Me,[He,t].concat(n))}function Je(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Re(Me,[Ne,t].concat(n))}function Ke(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Re(Me,[Ue,t].concat(n))}function Be(t){if(t)return new Fe("Authorization","Bearer ".concat(t))}var Ge=new(function(){function t(n){e(this,t),Xt(this,"name",n),this.counters_={}}return o(t,[{key:"attach",value:function(t){this.counters_=t.counters_}},{key:"incrementCounter",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.counters_[t]=(this.counters_[t]||0)+e}},{key:"get",value:function(){return Object.assign({},this.counters_)}}]),t}())("deprecated");function Ve(t,e,n,r){r=r&&r.concat(": ")||"",n=n?"use ".concat(n," instead"):"it should no longer be used",t.warn("".concat(r).concat(e," is deprecated, ").concat(n,".")),Ge.incrementCounter(e)}Xt(Tt,"showDeprecations",(function(){T([Ct,"showDeprecations"],arguments),Qe=Ve})),Xt(Tt,"hideDeprecations",(function(){T([Ct,"hideDeprecations"],arguments),Qe=ft}));var Qe=Ve;Xt(Jt,"Authentication",{avatarURL:se}),Yt(Jt,"avatarURL",(function(){return Qe(Kt,"Webcom.avatarURL","Webcom.Authentication.avatarURL"),se}));var Xe={code:"USER_DENIED",message:"The user aborted authentication"},Ye={facebook:{height:650,width:680},google:{height:460,width:490},github:{height:760,width:340},gitlab:{height:710,width:800},orange:{height:700,width:1e3},mobileconnectOFR:{height:540,width:700}},$e={menubar:0,location:0,resizable:0,scrollbars:1,status:0,dialog:1,width:700,height:375};function Ze(t,e){var n=t.config.Authentication;return O(n.storage)?n.storage:Ft(t,"state",n)+e}function tn(t,e,n){it((function(){return t(e,n)}))}function en(){return _&&(ye.get(this._oauthSessionKey)||ge.get(this._oauthSessionKey))}var nn=function(){function t(n){e(this,t),this._logger=Ht("api.Authentication",ae),this._logger.log("Initializing with options ".concat(JSON.stringify(n.config.Authentication))),this._app=n,this._init(n)}return o(t,[{key:"_init",value:function(t){var e=t.config.Authentication;Bt.call(this,e.baseUrl);var n=this._logger._count;this._currentState=function(t){try{return new ne(t.state,t.details)}catch(t){return re}}(function(t,e){var n=t.config.Authentication;return n.initialState||(P(n.storage)?{}:ge.get(Ze(t,e)))}(t,n)),this._authStateSetter=function(t,e){var n=t.config.Authentication;if(P(n.storage))return function(t){return n.storage(JSON.stringify(t))};var r=Ze(t,e);return function(t){return t&&!t.isUnauthenticated()?ge.set(r,t):ge.remove(r)}}(t,n),this._oauthSessionKey=Ft(t,"ongoing",e)+n,this.isAuthContextual=!1,this._firstSubscriptions=[],this._lastSubscriptions=[],this._authRoute="".concat(e.baseUrl.href,"/auth/v2/").concat(t.appId),this._resumeAuthState(),this._logger.log("Initialized for appId %s",t.appId)}},{key:"_dispose",value:function(){}},{key:"currentState",get:function(){return this._currentState},set:function(t){this._currentState.isSameAs(t)||(this._currentState=function(t){if(t.isAuthenticated()){var e=Object.assign({},t.details);return delete e.extra,ie(e)}return t}(t),this._authStateSetter(this._currentState),this._notifyErrorOrAuthStateChanged(null,t))}},{key:"_resumeAuthState",value:function(){var t=this;if(_)if("popup"===ge.get(this._oauthSessionKey))document.body.style.display="none",ge.set(this._oauthSessionKey,ke(location.search).__wcsession),window.close();else{var e=ye.get(this._oauthSessionKey);if(e){var n=ke(location.search).__wcsession;if(n)return void(this._oauthSessionPromise=this.resumeSession(n,e).finally((function(){delete t._oauthSessionPromise,ye.remove(t._oauthSessionKey)})).catch(ft));ye.remove(this._oauthSessionKey)}}this._logger.info("Authentication state resumed: %s",this.currentState.state),this._logger.log("Authentication details are: %o",this.currentState.details)}},{key:"getAccountDetails",value:function(){var t=[ae,"#removeIdentity"];try{T(t,arguments);var e=this._getCurrentAuthenticationDetails(t);return this._httpGet("accounts",e.uid).addHeader(Be(e.webcomAuthToken)).send().then((function(t){for(var e={},n=0,r=Object.entries(t.body);n<r.length;n++){var i=u(r[n],2),o=i[0],a=i[1];switch(o){case"providers":for(var s={},c=0,h=Object.entries(a);c<h.length;c++){var f=u(h[c],2),l=f[0],d=f[1];s[l]=Object.keys(d)}e.identities=s;break;case"createdOn":e[o]=new Date(a);break;default:e[o]=a}}return e}))}catch(t){return Promise.reject(t)}}},{key:"subscribe",value:function(t,e){return T([ae,"#subscribe"],arguments,M,L(q)),e?this._firstSubscriptions.push(t):this._lastSubscriptions.push(t),en.call(this)?this._logger.log("Notification not sent, because an OAuth authentication is ongoing."):tn(t,null,this.currentState),t}},{key:"unsubscribe",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;T([ae,"#unsubscribe"],arguments,L(M),L(q));var n=this._firstSubscriptions.length+this._lastSubscriptions.length,r=function(e){return t&&t!==e};return!1!==e&&(this._firstSubscriptions=this._firstSubscriptions.filter(r)),!0!==e&&(this._lastSubscriptions=this._lastSubscriptions.filter(r)),n-this._firstSubscriptions.length-this._lastSubscriptions.length}},{key:"_notifyErrorOrAuthStateChanged",value:function(t,e){this._firstSubscriptions.concat(this._lastSubscriptions).forEach((function(n){return tn(n,t,e)}))}},{key:"authenticationRevoked",value:function(t,e){T([ae,"#authenticationRevoked"],arguments,U(ne),W);var n=new Error("Authentication was revoked by the server: ".concat(e));n.code="AUTH_REVOKED",this._notifyErrorOrAuthStateChanged(n,null),this.currentState=t}},{key:"resumeSession",value:function(t,e){return T("AuthenticationImpl#resumeSession",arguments,W,W),this._logger.info("fetching authentication state from an ongoing OAuth2 session..."),Je(this._authRoute,"session").addJson({sessionKey:t,requestKey:e}).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}},{key:"_extendHttpRequest",value:function(t){var e=this,n=t;return n.addAuthContext=function(){var n=e._contextAuthToken();return n?t.addHeader(Be(n)):t},n}},{key:"_httpGet",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(qe.apply(void 0,[this._authRoute].concat(e)))}},{key:"_httpPost",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(Je.apply(void 0,[this._authRoute].concat(e)))}},{key:"_httpPut",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(ze.apply(void 0,[this._authRoute].concat(e)))}},{key:"_httpDelete",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._extendHttpRequest(Ke.apply(void 0,[this._authRoute].concat(e)))}},{key:"_updateStateFromHttpResponse",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(t){return t};return function(n){var r=e(n).body,i=r.token,o=r.user;if(i)return o.webcomAuthToken=i,t.currentState=ie(o),new Promise((function(t){return it((function(){return t(o)}))}));throw ue({code:"UNEXPECTED_RESPONSE",message:"the 'token' property is missing."})}}},{key:"_notifyErrorFromHttpResponse",value:function(t){throw this._notifyErrorOrAuthStateChanged(t,null),t}},{key:"useCurrentContextForNextAuthOperation",value:function(){T([ae,"#useCurrentContextForNextAuthOperation"],arguments),this.isAuthContextual=!0}},{key:"useNewContextForNextAuthOperation",value:function(){T([ae,"#useNewContextForNextAuthOperation"],arguments),this.isAuthContextual=!1}},{key:"_contextAuthToken",value:function(){var t=this.isAuthContextual?this.currentState.details:null;return this.isAuthContextual=!1,t&&t.webcomAuthToken}},{key:"signInWithToken",value:function(t){try{return T([ae,"#signInWithToken"],arguments,W),this._httpGet("decode").addHeader(Be(t)).send().then(this._updateStateFromHttpResponse((function(e){var n=e.body;return{body:{token:t,user:n.data}}})),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signInAsGuest",value:function(){try{return T([ae,"#signInAsGuest"],arguments),this._httpPost("anonymous","signin").addAuthContext().send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signInWithCredentials",value:function(t,e){try{return T([ae,"#signInWithCredentials"],arguments,W,J),this._httpPost(t,"signin").addAuthContext().addJson(e).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"sendOtp",value:function(t,e,n){try{return T([ae,"#sendOtp"],arguments,W,W,L(J)),this._httpPost(t,"otps").addQueryParameters(n).addJson(e).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"signInWithCustomProvider",value:function(t,e){try{return T([ae,"#signInWithCustomProvider"],arguments,W,W),this._httpPost("custom.".concat(t),"signin").addAuthContext().addForm({token:e}).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signInWithOAuth",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{T([ae,"#signInWithOAuth"],arguments,W,L(J)),e.mode=e.mode||"popup";var n=e.mode;return"code"===n?this._loginViaOAuthCode(t,e):this._loginViaOAuth(t,e)}catch(t){return Promise.reject(t)}}},{key:"signInWithWassup",value:function(t){try{return T([ae,"#signInWithWassup"],arguments,J),this._httpPost("wassup","signin").addAuthContext().addForm(t).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"signOut",value:function(){try{return T([ae,"#signOut"],arguments),this.currentState=re,new Promise((function(t){return it((function(){return t()}))}))}catch(t){return Promise.reject(t)}}},{key:"_loginViaOAuthCode",value:function(t,e){return e.code&&e.state||this._logger.warn("authWithOAuth(): options.code or options.state is missing!"),this._httpGet(t,"callback").addQueryParameters(e).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}},{key:"_loginViaOAuth",value:function(t,e){if(en.call(this))return this._oauthSessionPromise||Promise.reject(ue({code:"ONGOING_OAUTH",message:"An OAuth authentication is already ongoing"}));var n=!_||"redirect"===e.mode||_&&(window.navigator.userAgent.match(/CriOS|Twitter for iPhone|FBAN\/FBIOS|Windows Phone/)||window.navigator.standalone);e.token=this._contextAuthToken(),e.mode="redirect",!e.to&&_&&(e.to=location.href.replace(/[?&]__wcsession=[^&]+/,"")),!e.from&&_&&(e.from=we()+we()+we()+we());var r,i,o=e.from;e.from=(r=o,i=!0,me().codec.base64.fromBits(me().hash.sha256.hash(r),!1,i)),e.pm="2";var a=e.popupFeatures||{};delete e.popupFeatures;var s=Se("".concat(this._authRoute,"/").concat(t,"/signin"),e);if(!n)return this._oauthLoginViaPopup(t,a,s,o);try{return _&&(ye.set(this._oauthSessionKey,o),document.location=s),Promise.resolve(s)}catch(t){return Promise.reject(t)}}},{key:"_oauthLoginViaPopup",value:function(t,e,n,r){var i=this,o=Object.assign({},$e,Ye[t],e),a=o.target||"_blank";delete o.target;var s=window.open(n,a,Object.entries(o).map((function(t){var e=u(t,2),n=e[0],r=e[1];return"".concat(n,"=").concat(r)})).join(","));return new Promise((function(t,e){if(s){ge.set(i._oauthSessionKey,"popup");var o=function(){s.close(),ge.remove(i._oauthSessionKey)};window.addEventListener("beforeunload",o);var a=ut((function(){if(s.closed){ht(a),window.removeEventListener("beforeunload",o);var n=ge.get(i._oauthSessionKey);o(),"popup"===n?e(ue(Xe)):t(i.resumeSession(n,r))}}),250)}else e(ue(function(t){return{code:"POPUP_FAILED",message:"Could not open popup at ".concat(t)}}(n)))}))}},{key:"addIdentity",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{return T([ae,"#addIdentity"],arguments,W,J,L(J)),this._httpPost(t,"identities").addAuthContext().addQueryParameters(n).addJson(e).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"removeIdentity",value:function(){var t=[ae,"#removeIdentity"];try{T(t,arguments);var e=this._getCurrentAuthenticationDetails(t);return this._httpDelete(e.provider,"identities",e.providerUid).addHeader(Be(e.webcomAuthToken)).send().then((function(){}))}catch(t){return Promise.reject(t)}}},{key:"removeAccount",value:function(){var t=[ae,"#removeAccount"];try{T(t,arguments);var e=this._getCurrentAuthenticationDetails(t);return this._httpDelete("accounts",e.uid).addHeader(Be(e.webcomAuthToken)).send().then((function(){}))}catch(t){return Promise.reject(t)}}},{key:"verifyIdentity",value:function(t,e,n){try{return T([ae,"#verifyIdentity"],arguments,W,W,J),n.auth&&(n.challenge=n.auth.verificationPending,delete n.auth),this._httpPost(t,"identities",e,"verify").addAuthContext().addJson(n).send().then(this._updateStateFromHttpResponse(),this._notifyErrorFromHttpResponse.bind(this))}catch(t){return Promise.reject(t)}}},{key:"updateIdentityProfile",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=[ae,"#updateIdentityProfile"];try{T(n,arguments,N,L(W));var r=this._getCurrentAuthenticationDetails(n);return this._httpPut(r.provider,"identities",r.providerUid,"providerProfile",e).addHeader(Be(r.webcomAuthToken)).addJson(t).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"_getCurrentAuthenticationDetails",value:function(t){var e;if(!this.currentState.isAuthenticated())throw ue({code:"AUTH_MISSING",message:"".concat((e="").concat.apply(e,h(t))," failed: needs to be authenticated")});return this.currentState.details}},{key:"updatePassword",value:function(t,e,n){try{return T([ae,"#updatePassword"],arguments,W,W,W),this._httpPut("password","identities",t,"password").addForm({password:e,newPassword:n}).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"sendPasswordResetCode",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{return T([ae,"#sendPasswordResetCode"],arguments,W,W,L(J)),this._httpPost(t,"identities",e,"reset").addQueryParameters(n).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}},{key:"sendVerificationCode",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{return T([ae,"#sendVerificationCode"],arguments,W,W,L(J)),this._httpPost(t,"identities",e,"sendVerification").addQueryParameters(n).send().then((function(t){return t.body}))}catch(t){return Promise.reject(t)}}}]),t}();oe=function(t){return new nn(t)},t.Webcom=Jt})(),r=r.default})()));