1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DHWs = factory());
- }(this, (function () { 'use strict';
-
- var account = {
-
- loginClient() {
- this.loginEnd = false;
- this.loginStartTime = Date.now();
- const config = this.config;
- let { appName, appId, browser: { name, version, platform } } = config;
-
- if (!appName) {
- this.loginEnd = true;
- return false;
- }
- const params = {
- appName,
- params: {
- browser: name,
- version,
- platform
- },
- appId
- };
- this.postMessage('register', params);
- },
-
- logoutClient() {
- console.log("注销客户端");
- const config = this.config;
- const { appName, appId } = config;
- this.postMessage('unregister', {
- appName,
- appId
- });
- this.config.appName = '';
- },
- };
-
-
- function detectZoom() {
- var ratio = 0, screen = window.screen, ua = navigator.userAgent.toLowerCase();
- if (window.devicePixelRatio !== undefined) {
- ratio = window.devicePixelRatio;
- }
- else if (~ua.indexOf('msie')) {
- if (screen['deviceXDPI'] && screen['logicalXDPI']) {
- ratio = screen['deviceXDPI'] / screen['logicalXDPI'];
- }
- }
- else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
- ratio = window.outerWidth / window.innerWidth;
- }
- if (ratio) {
- ratio = Math.round(ratio * 100);
- }
- return ratio;
- }
-
- function hasScrollbarY() {
- return (getDocument().body.scrollHeight >
- (window.innerHeight || getDocument().documentElement.clientHeight));
- }
-
- function hasScrollbarX() {
- return (getDocument().body.scrollWidth >
- (window.innerWidth || getDocument().documentElement.clientWidth));
- }
-
- function getScrollbarWidth() {
- var scrollDiv = getDocument().createElement('div');
- scrollDiv.style.cssText =
- 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
- getDocument().body.appendChild(scrollDiv);
- var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
- getDocument().body.removeChild(scrollDiv);
- return scrollbarWidth;
- }
-
- function getScrollInfo() {
- let ratio = detectZoom();
- let scrollX = window.pageXOffset;
- let scrollY = window.pageYOffset;
- var hasscrollbary = hasScrollbarY();
- var hasscrollbarx = hasScrollbarX();
- var scrollbarWidth = getScrollbarWidth();
- let scrollXH = hasscrollbarx ? scrollbarWidth : 0;
- let scrollYW = hasscrollbary ? scrollbarWidth : 0;
- return { ratio, scrollX, scrollY, scrollXH, scrollYW };
- }
-
- function checkDomExit(domId, log = true) {
- let defaultDomInfo = {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- };
- const domTarget = getDocument().getElementById(domId);
- if (!domTarget) {
- log && console.log(`ws-can not find dom by id ${domId}`);
- return defaultDomInfo;
- }
- const domInfo = (domTarget.getClientRects() && domTarget.getClientRects()[0]);
- if (!domInfo) {
- log && console.warn(`ws-can not find domInfo by id ${domId}, please check dom exited`);
- return defaultDomInfo;
- }
- return domInfo;
- }
-
- function isIframe() {
- return self.frameElement && self.frameElement.tagName == "IFRAME";
- }
-
- function getDocument() {
- let _document = window.document;
-
- if (isIframe()) {
-
- if (top['$nav']) {
-
- const iframe = top['$nav'].getIframeByPath();
- if (iframe) {
- _document = iframe.contentWindow.document;
- }
- else {
- throw new Error('can not find document in iframe by @psi/navigator');
- }
- }
- else {
-
- throw new Error('not support in iframe that without @psi/navigator');
- }
- }
- return _document;
- }
-
- function getDomById(domId) {
- console.log('ws-getDomById', domId);
- const domInfo = checkDomExit(domId);
- const width = domInfo.width;
- const height = domInfo.height;
- let x = domInfo.x;
- let y = domInfo.y;
- if (isIframe()) {
- console.log('dom in iframe');
- if (top['$nav']) {
-
- const iframe = top['$nav'].getIframeByPath();
- if (iframe) {
- let iframeRect = iframe.getClientRects();
- if (iframeRect && iframeRect[0]) {
- x += iframeRect[0].x;
- y += iframeRect[0].y;
- }
- throw new Error('can not find document in iframe by @psi/navigator');
- }
- throw new Error('can not find document in iframe by @psi/navigator');
- }
- else {
-
- throw new Error('not support in iframe that without @psi/navigator');
- }
- }
- return {
- width,
- height,
- x,
- y
- };
- }
- var control = {
-
- browserInfo() {
- const config = this.config;
- const { loginIp, userCode } = config;
- const { browser: { name, version, platform } } = config;
- this.postMessage('browserInfo', {
- loginIp,
- userCode,
- params: {
- browser: name,
- version,
- platform
- }
- });
- },
-
- webVisibilityChange() {
- const config = this.config;
-
- const { appName, appId } = config;
- this.postMessage('webVisibilityChange', {
- appName,
- appId,
- params: {
- hidden: getDocument().hidden
- }
- });
- },
-
- trusteSite(http) {
- console.log('ws-trusteSite-http', http);
- const config = this.config;
- const { loginIp, userCode } = config;
- this.postMessage('trusteSite', {
- loginIp,
- userCode,
- params: {
- trusteSite: http
- }
- });
- },
-
- setDownloadPath(path) {
- const config = this.config;
- const { loginIp, userCode } = config;
- return this.postMessage('setDownloadPath', {
- loginIp,
- userCode,
- params: {
- downloadPath: path
- }
- });
- },
-
- downloadVideo(downloads, visible) {
- const config = this.config;
- const { loginIp, userCode } = config;
- return this.postMessage('downloadVideo', {
- loginIp,
- userCode,
- params: {
- array: downloads,
- visible: visible
- }
- });
- },
-
- createCtrl(widgets) {
- console.log('ws-createCtrl', widgets);
- const _this = this;
- const config = this.config;
-
- const { appName, appId } = config;
- let widgetParams = [];
- if (widgets.length === 0) {
- console.error('param widget must has a ctrlCode.');
- return false;
- }
- widgets.forEach(item => {
- if (_this.ids.includes(item.ctrlCode)) {
- _this.destroyCtrl([item.ctrlCode]);
- }
- let widgetParam = {};
- const { ctrlType, ctrlCode, ctrlProperty, visible, cutList, domId } = item;
- getDocument().getElementById(domId);
-
-
-
-
- let domInfo = getDomById(domId);
- let scrollInfo = getScrollInfo();
-
-
- widgetParam['ctrlType'] = ctrlType;
- widgetParam['visible'] = visible;
- widgetParam['ctrlCode'] = ctrlCode;
- widgetParam['ctrlProperty'] = ctrlProperty;
-
- widgetParam['posX'] = domInfo.x;
- widgetParam['posY'] = domInfo.y;
- widgetParam['width'] = domInfo.width;
- widgetParam['height'] = domInfo.height;
- widgetParam['ratio'] = scrollInfo.ratio;
- widgetParam['scrollX'] = scrollInfo.scrollX;
- widgetParam['scrollY'] = scrollInfo.scrollY;
- widgetParam['scrollXH'] = scrollInfo.scrollXH;
- widgetParam['scrollYW'] = scrollInfo.scrollYW;
-
- widgetParam['domId'] = domId;
-
- widgetParams.push(widgetParam);
- _this.ctrls.push(widgetParam);
- _this.ids.push(ctrlCode);
- });
- return this.postMessage('createCtrl', {
-
-
-
- appName,
- appId,
- params: {
- array: widgetParams
- }
- });
- },
-
- setCtrlVisible(ctrls) {
- const _this = this;
- const config = this.config;
-
- const { appName, appId } = config;
- let ctrlParams = [];
- if (ctrls.length === 0) {
- return false;
- }
- ctrls.forEach(item => {
- const ctrlParam = {};
- if (!_this.ids.includes(item.ctrlCode)) {
- return false;
- }
- const ctrl = _this.ctrls.find((ctrl) => {
- return ctrl.ctrlCode === item.ctrlCode;
- });
- ctrl['visible'] = item.visible;
- ctrlParam['ctrlCode'] = item.ctrlCode;
- ctrlParam['visible'] = item.visible;
- ctrlParams.push(ctrlParam);
- });
- return this.postMessage('setCtrlVisible', {
- appName,
- appId,
- params: {
- array: ctrlParams
- }
- });
- },
-
- setCtrlPos(positions) {
- const _this = this;
- const config = this.config;
-
- const { appName, appId } = config;
- let widgetParams = [];
- if (positions.length === 0) {
- throw new Error('setCtrlPos must has a Id.');
- }
- positions.forEach(item => {
- if (!_this.ids.includes(item.ctrlCode)) {
- throw new Error(`widget by id:${item.ctrlCode} has not been created.`);
- }
- const ctrl = _this.ctrls.find((ctrl) => {
- return ctrl.ctrlCode === item.ctrlCode;
- });
- if (!ctrl) {
- throw new Error(`can not find ctrl by id:${item.ctrlCode}.`);
- }
-
- let propList = ['posX', 'posY', 'width', 'height', 'ratio', 'scrollX', 'scrollY', 'scrollXH', 'scrollYW', 'cutList'];
-
- function setProp(ctrl, item, prop) {
- item.hasOwnProperty(prop) ? ctrl[prop] = item[prop] : '';
- }
- propList.forEach(e => {
- setProp(ctrl, item, e);
- });
- const widgetParam = ctrl;
- widgetParams.push(widgetParam);
- });
- return this.postMessage('setCtrlPos', {
- appName,
- appId,
- params: {
- array: widgetParams
- }
- });
- },
-
- reLocatedPosition(ctrlCode) {
- let _ctrlList = [];
- if (ctrlCode && ctrlCode.length > 0) {
- this.ctrls.forEach(e => {
- if (ctrlCode.includes(e.ctrlCode)) {
- _ctrlList.push(e);
- }
- });
- }
- let _needLocationList = _ctrlList.length > 0 ? _ctrlList : this.ctrls;
- if (_needLocationList.length === 0)
- return false;
- let exitParams = _needLocationList.filter(e => {
- return (e.domId && checkDomExit(e.domId, false));
- });
- let params = exitParams.map(e => {
- let domInfo = getDomById(e.domId);
- let scrollInfo = getScrollInfo();
- let ctrlCode = e.ctrlCode;
- let cutList = e.cutList;
- let posX = domInfo.x;
- let posY = domInfo.y;
- let width = domInfo.width;
- let height = domInfo.height;
- let ratio = scrollInfo.ratio;
- let scrollX = scrollInfo.scrollX;
- let scrollY = scrollInfo.scrollY;
- let scrollXH = scrollInfo.scrollXH;
- let scrollYW = scrollInfo.scrollYW;
- return { ctrlCode, cutList, posX, posY, width, height, ratio, scrollX, scrollY, scrollXH, scrollYW };
- });
- if (params.length) {
- return this.setCtrlPos(params);
- }
- else {
- return new Promise((resolve) => { resolve(true); });
- }
- },
-
- destroyCtrl(ids) {
- if (ids.length === 0) {
- return false;
- }
- const _this = this;
- const config = this.config;
-
- const { appName, appId } = config;
- const _ids = [...ids];
-
- const params = ids.map(item => {
- return { ctrlCode: item };
- });
- _ids.forEach(id => {
-
-
-
- for (var i = 0; i < _this.ctrls.length; i++) {
- if (_this.ctrls[i].ctrlCode === id) {
- _this.ctrls.splice(i, 1);
- _this.ids.splice(i, 1);
- }
- }
- });
- return this.postMessage('destroyCtrl', {
- appName,
- appId,
- params: {
- array: params
- }
- });
- },
-
- openCtrlPreview(obj) {
- const config = this.config;
- const { loginIp, userCode } = config;
- if (!obj.ctrlCode || !this.ids.includes(obj.ctrlCode)) {
- throw new Error(`widget by id:${obj.ctrlCode} has not been created.`);
- }
- if (obj.channelIds.length === 0) {
- return false;
- }
- const arr = obj.channelIds.map((i) => {
- return { channelId: i };
- });
- return this.postMessage('openCtrlPreview', {
- loginIp,
- userCode,
- params: {
- array: [
- {
- ctrlCode: obj.ctrlCode,
- array: arr
- }
- ]
- }
- });
- },
-
- openCtrlRecord(arr) {
- const config = this.config;
- var obj = arr[0];
- if (!obj.ctrlCode || !this.ids.includes(obj.ctrlCode)) {
- throw new Error(`widget by id:${obj.ctrlCode} has not been created.`);
- }
- const { loginIp, userCode } = config;
- return this.postMessage('openCtrlRecord', {
- loginIp,
- userCode,
- params: {
- array: arr
- }
- });
- },
-
- closeCtrlVideo(arr) {
- const config = this.config;
- const { loginIp, userCode } = config;
- const arrParams = arr.map(item => {
- return { ctrlCode: item };
- });
- return this.postMessage('closeCtrlVideo', {
- loginIp,
- userCode,
- params: {
- array: arrParams
- }
- });
- },
-
- openVideo(arr) {
- const config = this.config;
- const { userCode, loginIp } = config;
- let params = {};
- if (Array.isArray(arr)) {
- let _arr = arr.map(i => {
- return { channelId: i };
- });
- params = { array: _arr };
- }
- else {
- params = arr;
- }
- return this.postMessage('openVideo', {
- loginIp,
- userCode,
- params: params
- });
- },
-
- openRecord(arr) {
- const config = this.config;
- const { userCode, loginIp } = config;
- let params = {};
- if (Array.isArray(arr)) {
- params = { array: arr };
- }
- else {
- params = arr;
- }
- return this.postMessage('openRecord', {
- loginIp,
- userCode,
- params: params
- });
- },
-
- openMixedModeDialog(menuCode, array, toolBarFucList = [0, 1, 2]) {
- const config = this.config;
- const { userCode, loginIp } = config;
- let params = {
- destinationCode: menuCode,
- toolBarFucList: toolBarFucList,
- array: array
- };
- return this.postMessage('openMixedModeDialog', {
- loginIp,
- userCode,
- params: params
- });
- },
-
- PictureEnhance(url, value, type = 1) {
- const config = this.config;
- const { userCode, loginIp } = config;
- const params = {
- loginIp,
- userCode,
- params: {
- array: [{ type: `${type}`, degree: `${value}`, url }]
- }
- };
- return this.postMessage('PictureEnhance', params);
- }
- };
- var transparent = {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- transparent(method, params) {
- return this.postMessage(method, params);
- }
- };
-
- var wsActions = {
- account,
- control,
- transparent
-
- };
- var defaultMessageEvents = {
-
- getVersionResult(data) {
- this.getVersionEnd = true;
- this.currentDssVersion = data;
- if (this.onlineDssVersion !== '') {
- this.compareVersion();
- }
- },
-
- goToSearchPic(data) {
- console.log('ws-goToSearchPic', data);
- if (data && data.params && data.params.array && Array.isArray(data.params.array)) {
- let menuCode = data.params.destinationCode;
- let param = {};
- param[menuCode] = data.params.array[0];
- if (frames[`nav-frame-${menuCode}`]) {
- frames[`nav-frame-${menuCode}`].$nav.push({
- code: menuCode,
- params: param
- });
- }
- else {
- window && window['$nav'] && window['$nav'].push({
- code: menuCode,
- params: param
- });
- }
- }
- else {
- this.Vue.prototype.$Message.info('未查询到数据');
- }
- },
-
- loginState(data) {
- console.log("登录成功");
- if (data) {
- this.isLoginSuccess = data;
-
- this.loginEnd = true;
- if (typeof this.callback.loginResult === 'function') {
- this.callback.loginResult.call(this, this.isLoginSuccess);
- }
- }
- else {
- this.loginFailCount++;
- if (this.loginFailCount < this.reLoginCount + 1) {
- this.loginClient();
- }
- else {
-
- this.loginEnd = true;
-
- this.loginFailCount = 0;
- this.isLoginSuccess = data;
- if (typeof this.callback.loginResult === 'function') {
- this.callback.loginResult.call(this, this.isLoginSuccess);
- }
- }
- }
- },
- registerState(data) {
- console.log("注册成功");
- if (data) {
- this.isLoginSuccess = data;
-
- this.loginEnd = true;
- if (typeof this.callback.registerResult === 'function') {
- this.callback.registerResult.call(this, this.isLoginSuccess);
- }
- }
- else {
- this.loginFailCount++;
- if (this.loginFailCount < this.reLoginCount + 1) {
- this.loginClient();
- }
- else {
-
- this.loginEnd = true;
-
- this.loginFailCount = 0;
- this.isLoginSuccess = data;
- if (typeof this.callback.registerResult === 'function') {
- this.callback.registerResult.call(this, this.isLoginSuccess);
- }
- }
- }
- },
-
- createCtrlResult(data) {
-
- let _data = data;
- let failIds = [];
- _data.forEach(e => {
- if (e.result !== 0) {
- failIds.push(e.ctrlCode);
- }
- });
- this.ids.forEach((e, i) => {
- if (failIds.indexOf(e) !== -1) {
- this.ids.splice(i, 1);
- this.ctrls.splice(i, 1);
- }
- });
- },
-
- destroyCtrlResult(data) {
-
-
- console.log(data);
- }
- };
-
- var dealEventData = {
- registerState: registerState,
- loginState: loginState,
- getVersionResult: getVersionResult,
-
- createCtrlResult: createCtrlResult
- };
- function registerState(data) {
- return data.params.registerResult === 0;
- }
- function loginState(data) {
- return data.params.loginResult === 0;
- }
- function getVersionResult(data) {
- return data.params.version + '';
- }
-
-
- function createCtrlResult(data) {
- return data.params.array;
- }
-
-
- var extendStatics = function(d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- function __extends(d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
- function __values(o) {
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
- if (m) return m.call(o);
- return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- }
- function __read(o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- }
- function __spread() {
- for (var ar = [], i = 0; i < arguments.length; i++)
- ar = ar.concat(__read(arguments[i]));
- return ar;
- }
- var Event = (function () {
- function Event(type, target) {
- this.target = target;
- this.type = type;
- }
- return Event;
- }());
- var ErrorEvent = (function (_super) {
- __extends(ErrorEvent, _super);
- function ErrorEvent(error, target) {
- var _this = _super.call(this, 'error', target) || this;
- _this.message = error.message;
- _this.error = error;
- return _this;
- }
- return ErrorEvent;
- }(Event));
- var CloseEvent = (function (_super) {
- __extends(CloseEvent, _super);
- function CloseEvent(code, reason, target) {
- if (code === void 0) { code = 1000; }
- if (reason === void 0) { reason = ''; }
- var _this = _super.call(this, 'close', target) || this;
- _this.wasClean = true;
- _this.code = code;
- _this.reason = reason;
- return _this;
- }
- return CloseEvent;
- }(Event));
-
- var getGlobalWebSocket = function () {
- if (typeof WebSocket !== 'undefined') {
-
- return WebSocket;
- }
- };
-
- var isWebSocket = function (w) { return typeof w !== 'undefined' && !!w && w.CLOSING === 2; };
- var DEFAULT = {
- maxReconnectionDelay: 10000,
- minReconnectionDelay: 1000 + Math.random() * 4000,
- minUptime: 5000,
- reconnectionDelayGrowFactor: 1.3,
- connectionTimeout: 4000,
- maxRetries: Infinity,
- maxEnqueuedMessages: Infinity,
- startClosed: false,
- debug: false,
- };
- var ReconnectingWebSocket = (function () {
- function ReconnectingWebSocket(url, protocols, options) {
- var _this = this;
- if (options === void 0) { options = {}; }
- this._listeners = {
- error: [],
- message: [],
- open: [],
- close: [],
- };
- this._retryCount = -1;
- this._shouldReconnect = true;
- this._connectLock = false;
- this._binaryType = 'blob';
- this._closeCalled = false;
- this._messageQueue = [];
-
- this.onclose = null;
-
- this.onerror = null;
-
- this.onmessage = null;
-
- this.onopen = null;
- this._handleOpen = function (event) {
- _this._debug('open event');
- var _a = _this._options.minUptime, minUptime = _a === void 0 ? DEFAULT.minUptime : _a;
- clearTimeout(_this._connectTimeout);
- _this._uptimeTimeout = setTimeout(function () { return _this._acceptOpen(); }, minUptime);
- _this._ws.binaryType = _this._binaryType;
-
- _this._messageQueue.forEach(function (message) { return _this._ws.send(message); });
- _this._messageQueue = [];
- if (_this.onopen) {
- _this.onopen(event);
- }
- _this._listeners.open.forEach(function (listener) { return _this._callEventListener(event, listener); });
- };
- this._handleMessage = function (event) {
- _this._debug('message event');
- if (_this.onmessage) {
- _this.onmessage(event);
- }
- _this._listeners.message.forEach(function (listener) { return _this._callEventListener(event, listener); });
- };
- this._handleError = function (event) {
- _this._debug('error event', event.message);
- _this._disconnect(undefined, event.message === 'TIMEOUT' ? 'timeout' : undefined);
- if (_this.onerror) {
- _this.onerror(event);
- }
- _this._debug('exec error listeners');
- _this._listeners.error.forEach(function (listener) { return _this._callEventListener(event, listener); });
- _this._connect();
- };
- this._handleClose = function (event) {
- _this._debug('close event');
- _this._clearTimeouts();
- if (_this._shouldReconnect) {
- _this._connect();
- }
- if (_this.onclose) {
- _this.onclose(event);
- }
- _this._listeners.close.forEach(function (listener) { return _this._callEventListener(event, listener); });
- };
- this._url = url;
- this._protocols = protocols;
- this._options = options;
- if (this._options.startClosed) {
- this._shouldReconnect = false;
- }
- this._connect();
- }
- Object.defineProperty(ReconnectingWebSocket, "CONNECTING", {
- get: function () {
- return 0;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket, "OPEN", {
- get: function () {
- return 1;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket, "CLOSING", {
- get: function () {
- return 2;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket, "CLOSED", {
- get: function () {
- return 3;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "CONNECTING", {
- get: function () {
- return ReconnectingWebSocket.CONNECTING;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "OPEN", {
- get: function () {
- return ReconnectingWebSocket.OPEN;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "CLOSING", {
- get: function () {
- return ReconnectingWebSocket.CLOSING;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "CLOSED", {
- get: function () {
- return ReconnectingWebSocket.CLOSED;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "binaryType", {
- get: function () {
- return this._ws ? this._ws.binaryType : this._binaryType;
- },
- set: function (value) {
- this._binaryType = value;
- if (this._ws) {
- this._ws.binaryType = value;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "retryCount", {
-
- get: function () {
- return Math.max(this._retryCount, 0);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "bufferedAmount", {
-
- get: function () {
- var bytes = this._messageQueue.reduce(function (acc, message) {
- if (typeof message === 'string') {
- acc += message.length;
- }
- else if (message instanceof Blob) {
- acc += message.size;
- }
- else {
- acc += message.byteLength;
- }
- return acc;
- }, 0);
- return bytes + (this._ws ? this._ws.bufferedAmount : 0);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "extensions", {
-
- get: function () {
- return this._ws ? this._ws.extensions : '';
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "protocol", {
-
- get: function () {
- return this._ws ? this._ws.protocol : '';
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "readyState", {
-
- get: function () {
- if (this._ws) {
- return this._ws.readyState;
- }
- return this._options.startClosed
- ? ReconnectingWebSocket.CLOSED
- : ReconnectingWebSocket.CONNECTING;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ReconnectingWebSocket.prototype, "url", {
-
- get: function () {
- return this._ws ? this._ws.url : '';
- },
- enumerable: true,
- configurable: true
- });
-
- ReconnectingWebSocket.prototype.close = function (code, reason) {
- if (code === void 0) { code = 1000; }
- this._closeCalled = true;
- this._shouldReconnect = false;
- this._clearTimeouts();
- if (!this._ws) {
- this._debug('close enqueued: no ws instance');
- return;
- }
- if (this._ws.readyState === this.CLOSED) {
- this._debug('close: already closed');
- return;
- }
- this._ws.close(code, reason);
- };
-
- ReconnectingWebSocket.prototype.reconnect = function (code, reason) {
- this._shouldReconnect = true;
- this._closeCalled = false;
- this._retryCount = -1;
- if (!this._ws || this._ws.readyState === this.CLOSED) {
- this._connect();
- }
- else {
- this._disconnect(code, reason);
- this._connect();
- }
- };
-
- ReconnectingWebSocket.prototype.send = function (data) {
- if (this._ws && this._ws.readyState === this.OPEN) {
- this._debug('send', data);
- this._ws.send(data);
- }
- else {
- var _a = this._options.maxEnqueuedMessages, maxEnqueuedMessages = _a === void 0 ? DEFAULT.maxEnqueuedMessages : _a;
- if (this._messageQueue.length < maxEnqueuedMessages) {
- this._debug('enqueue', data);
- this._messageQueue.push(data);
- }
- }
- };
-
- ReconnectingWebSocket.prototype.addEventListener = function (type, listener) {
- if (this._listeners[type]) {
-
- this._listeners[type].push(listener);
- }
- };
- ReconnectingWebSocket.prototype.dispatchEvent = function (event) {
- var e_1, _a;
- var listeners = this._listeners[event.type];
- if (listeners) {
- try {
- for (var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()) {
- var listener = listeners_1_1.value;
- this._callEventListener(event, listener);
- }
- }
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
- finally {
- try {
- if (listeners_1_1 && !listeners_1_1.done && (_a = listeners_1.return)) _a.call(listeners_1);
- }
- finally { if (e_1) throw e_1.error; }
- }
- }
- return true;
- };
-
- ReconnectingWebSocket.prototype.removeEventListener = function (type, listener) {
- if (this._listeners[type]) {
-
- this._listeners[type] = this._listeners[type].filter(function (l) { return l !== listener; });
- }
- };
- ReconnectingWebSocket.prototype._debug = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- if (this._options.debug) {
-
-
- console.log.apply(console, __spread(['RWS>'], args));
- }
- };
- ReconnectingWebSocket.prototype._getNextDelay = function () {
- var _a = this._options, _b = _a.reconnectionDelayGrowFactor, reconnectionDelayGrowFactor = _b === void 0 ? DEFAULT.reconnectionDelayGrowFactor : _b, _c = _a.minReconnectionDelay, minReconnectionDelay = _c === void 0 ? DEFAULT.minReconnectionDelay : _c, _d = _a.maxReconnectionDelay, maxReconnectionDelay = _d === void 0 ? DEFAULT.maxReconnectionDelay : _d;
- var delay = 0;
- if (this._retryCount > 0) {
- delay =
- minReconnectionDelay * Math.pow(reconnectionDelayGrowFactor, this._retryCount - 1);
- if (delay > maxReconnectionDelay) {
- delay = maxReconnectionDelay;
- }
- }
- this._debug('next delay', delay);
- return delay;
- };
- ReconnectingWebSocket.prototype._wait = function () {
- var _this = this;
- return new Promise(function (resolve) {
- setTimeout(resolve, _this._getNextDelay());
- });
- };
- ReconnectingWebSocket.prototype._getNextUrl = function (urlProvider) {
- if (typeof urlProvider === 'string') {
- return Promise.resolve(urlProvider);
- }
- if (typeof urlProvider === 'function') {
- var url = urlProvider();
- if (typeof url === 'string') {
- return Promise.resolve(url);
- }
- if (!!url.then) {
- return url;
- }
- }
- throw Error('Invalid URL');
- };
- ReconnectingWebSocket.prototype._connect = function () {
- var _this = this;
- if (this._connectLock || !this._shouldReconnect) {
- return;
- }
- this._connectLock = true;
- var _a = this._options, _b = _a.maxRetries, maxRetries = _b === void 0 ? DEFAULT.maxRetries : _b, _c = _a.connectionTimeout, connectionTimeout = _c === void 0 ? DEFAULT.connectionTimeout : _c, _d = _a.WebSocket, WebSocket = _d === void 0 ? getGlobalWebSocket() : _d;
- if (this._retryCount >= maxRetries) {
- this._debug('max retries reached', this._retryCount, '>=', maxRetries);
- return;
- }
- this._retryCount++;
- this._debug('connect', this._retryCount);
- this._removeListeners();
- if (!isWebSocket(WebSocket)) {
- throw Error('No valid WebSocket class provided');
- }
- this._wait()
- .then(function () { return _this._getNextUrl(_this._url); })
- .then(function (url) {
-
- if (_this._closeCalled) {
- return;
- }
- _this._debug('connect', { url: url, protocols: _this._protocols });
- _this._ws = _this._protocols
- ? new WebSocket(url, _this._protocols)
- : new WebSocket(url);
- _this._ws.onerror = function (e) {
- window.postMessage({method: "connectResult", success: false}, "*")
- }
- _this._ws.binaryType = _this._binaryType;
- _this._connectLock = false;
- _this._addListeners();
- _this._connectTimeout = setTimeout(function () { return _this._handleTimeout(); }, connectionTimeout);
- });
- };
- ReconnectingWebSocket.prototype._handleTimeout = function () {
- this._debug('timeout event');
- this._handleError(new ErrorEvent(Error('TIMEOUT'), this));
- };
- ReconnectingWebSocket.prototype._disconnect = function (code, reason) {
- if (code === void 0) { code = 1000; }
- this._clearTimeouts();
- if (!this._ws) {
- return;
- }
- this._removeListeners();
- try {
- this._ws.close(code, reason);
- this._handleClose(new CloseEvent(code, reason, this));
- }
- catch (error) {
-
- }
- };
- ReconnectingWebSocket.prototype._acceptOpen = function () {
- this._debug('accept open');
- this._retryCount = 0;
- };
- ReconnectingWebSocket.prototype._callEventListener = function (event, listener) {
- if ('handleEvent' in listener) {
-
- listener.handleEvent(event);
- }
- else {
-
- listener(event);
- }
- };
- ReconnectingWebSocket.prototype._removeListeners = function () {
- if (!this._ws) {
- return;
- }
- this._debug('removeListeners');
- this._ws.removeEventListener('open', this._handleOpen);
- this._ws.removeEventListener('close', this._handleClose);
- this._ws.removeEventListener('message', this._handleMessage);
-
- this._ws.removeEventListener('error', this._handleError);
- };
- ReconnectingWebSocket.prototype._addListeners = function () {
- if (!this._ws) {
- return;
- }
- this._debug('addListeners');
- this._ws.addEventListener('open', this._handleOpen);
- this._ws.addEventListener('close', this._handleClose);
- this._ws.addEventListener('message', this._handleMessage);
-
- this._ws.addEventListener('error', this._handleError);
- };
- ReconnectingWebSocket.prototype._clearTimeouts = function () {
- clearTimeout(this._connectTimeout);
- clearTimeout(this._uptimeTimeout);
- };
- return ReconnectingWebSocket;
- }());
- var reconnectingWebsocketCjs = ReconnectingWebSocket;
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
- function unwrapExports (x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
- }
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
- var es5 = createCommonjsModule(function (module, exports) {
- !function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n});},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return "NT";case"XP":return "XP";case"NT 5.0":return "2000";case"NT 5.1":return "XP";case"NT 5.2":return "2003";case"NT 6.0":return "Vista";case"NT 6.1":return "7";case"NT 6.2":return "8";case"NT 6.3":return "8.1";case"NT 10.0":return "10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return "Leopard";case 6:return "Snow Leopard";case 7:return "Lion";case 8:return "Mountain Lion";case 9:return "Mavericks";case 10:return "Yosemite";case 11:return "El Capitan";case 12:return "Sierra";case 13:return "High Sierra";case 14:return "Mojave";case 15:return "Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),o=Math.max(i,s),a=0,u=e.map([t,r],(function(t){var r=o-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(a=o-Math.min(i,s)),o-=1;o>=a;){if(u[0][o]>u[1][o])return 1;if(u[0][o]===u[1][o]){if(o===a)return 0;o-=1;}else if(u[0][o]<u[1][o])return -1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var a=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t];}));};for(t=0,r=s.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default;},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0;t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"};t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"};t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"};t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"};t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}var a=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&o(t.prototype,r),n&&o(t,n),e}();t.default=a,e.exports=t.default;},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=u(r(92)),i=u(r(93)),s=u(r(94)),o=u(r(95)),a=u(r(17));function u(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse();}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var o=e[t];"string"==typeof o?(i[t]=o,s+=1):"object"==typeof o&&(r[t]=o,n+=1);})),n>0){var o=Object.keys(r),u=a.default.find(o,(function(e){return t.isOS(e)}));if(u){var d=this.satisfies(r[u]);if(void 0!==d)return d}var c=a.default.find(o,(function(e){return t.isPlatform(e)}));if(c){var f=this.satisfies(r[c]);if(void 0!==f)return f}}if(s>0){var l=Object.keys(i),h=a.default.find(l,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return ">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e){return this.isBrowser(e)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default;},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n};var s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return {name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default;},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var o=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return {name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return {name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?) Version\//],describe:function(e){var t=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return {name:s.OS_MAP.iOS,version:t}}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return {name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return {name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return {name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return {name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default;},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var o=[{test:[/googlebot/i],describe:function(){return {type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?) Version\//],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return {type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "blackberry"===e.getBrowserName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return "bada"===e.getBrowserName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "windows phone"===e.getBrowserName()},describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return "android"===e.getOSName(!0)&&t>=3},describe:function(){return {type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return "android"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "macos"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return "windows"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return "linux"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return "playstation 4"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.tv}}},{test:function(e){return "roku"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default;},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var o=[{test:function(e){return "microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return {name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return {name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return {name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=o,e.exports=t.default;}})}));
- });
- var Bowser = unwrapExports(es5);
- es5.bowser;
-
- const browser = Bowser.getParser(window.navigator.userAgent);
- class Ws {
- constructor({ url = 'ws://localhost', port = '1234', publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbEpPpxpLJft4W9YZj8bRh2bYYZshBEsKOlxgyn11rlEyTasjBSZRV9aj33tvQ2T55izH0fWl+dL/dLZChawFrlGDcH8JuWge2xYMgII9mggcYa0UiQ7pLXJ9ivXZ/cOY3HzrRQdR7dGTSNn3Z0Ctbns6mLgvlA2r3qMNs/8wHBwIDAQAB', reConnectCount = 3, reLoginCount = 0, loginIp = location.hostname, appName = "", loginPort = location.port, userName = '', userPwd = '', token = '', callback = {
- connectResult: null,
- loginResult: null
- }, isKeepConnect = true, detectDssVersion = true, messageEvents = {} }) {
-
- this.isConnectSuccessQt = false;
-
- this.isLoginSuccess = false;
-
- this.messageEvents = {};
-
- this.reConnectCount = 3;
-
- this.connectFailCount = 0;
-
- this.connectEnd = true;
-
- this.connectStartTime = 0;
-
- this.connectTimeOut = 30 * 1000;
-
- this.loginEnd = true;
-
- this.loginStartTime = 0;
-
- this.loginTimeOut = 60 * 1000;
-
- this.reLoginCount = 0;
-
- this.loginFailCount = 0;
-
- this.config = {
- browser: {}
- };
-
- this.userCode = 0;
-
- this.appId = 0;
-
- this.detectDssVersion = true;
-
- this.currentDssVersion = '';
-
-
-
-
-
-
-
- this.onlineDssVersion = '';
-
- this.onlineDssVersionAfterfix = '/data/VSL/DSSEnterpriseClient/LightWeightVersion.txt';
-
- this.onlineDssAfterfix = '/data/VSL/DSSEnterpriseClient/DSS_LightWeight_Client.zip';
-
- this.isKeepConnect = true;
-
- this.ids = [];
-
- this.ctrls = [];
-
- this.heartBeatTimer = null;
-
- this.handlers = {};
- this.url = url;
- this.port = port;
- this.userCode = new Date().valueOf();
- this.appId = new Date().valueOf();
- this.webSocket = null;
- this.reConnectCount = reConnectCount;
- this.reLoginCount = reLoginCount;
- this.publicKey = publicKey;
- this.loginIp = loginIp;
- this.appName = appName;
- this.loginPort = loginPort;
- this.userName = userName;
- this.userPwd = userPwd;
- this.token = token;
- this.callback = callback;
- this.isKeepConnect = isKeepConnect;
- this.detectDssVersion = detectDssVersion;
- this.messageEvents = messageEvents || {};
- this.connectFailCount = this.connectFailCount;
-
- this.ids = [];
- this.ctrls = [];
-
- this.isConnectSuccessQt = false;
-
- this.isLoginSuccess = false;
- this.heartBeatTimer = null;
-
- this.handlers = {};
-
- this.listerns = new Map();
-
- const defaultActions = [];
- Object.keys(wsActions).forEach(item => {
- if (hasKey(wsActions, item)) {
- defaultActions.push(wsActions[item]);
- }
- });
-
- usePlugin(defaultActions);
-
- this.messageEvents = Object.assign(this.messageEvents, defaultMessageEvents);
- Object.keys(this.messageEvents).forEach(item => {
- this.addEventListener(item, this.messageEvents[item].bind(this));
- });
-
- this.initConfig();
-
-
-
-
-
-
-
-
-
-
- }
-
- static getInstance(options) {
- if (!top['$ws']) {
- if (!this._instance) {
- this._instance = new Ws(options || {});
- top['$ws'] = this._instance;
- }
- }
- else {
- this._instance = top['$ws'];
-
-
-
-
-
-
-
-
-
-
- }
- return this._instance;
- }
-
- on(eventType, callback) {
- this.listerns.set(eventType, callback);
- }
-
- off(eventType) {
- delete this.listerns[eventType];
- }
-
- addEventListener(eventType, handler) {
-
- if (!(eventType in this.handlers)) {
- this.handlers[eventType] = [];
- }
-
- this.handlers[eventType].push(handler);
- }
-
- dispatchEvent(eventType, ...params) {
-
- if (!(eventType in this.handlers)) {
- return new Error('未注册该事件');
- }
-
- this.handlers[eventType].forEach(handler => {
- handler(...params);
- });
- }
-
- removeEventListener(eventType, handler) {
-
- if (!(eventType in this.handlers)) {
- return new Error('无效事件');
- }
- if (!handler) {
-
- delete this.handlers[eventType];
- }
- else {
- const idx = this.handlers[eventType].findIndex(ele => ele === handler);
-
- if (idx === -1) {
- return new Error('无该绑定事件');
- }
-
- this.handlers[eventType].splice(idx, 1);
- if (this.handlers[eventType].length === 0) {
- delete this.handlers[eventType];
- }
- }
- }
-
- postMessage(method, data) {
- console.log('sendMessageToClient', method, data);
- const { webSocket } = this;
- data.method = method;
-
-
- let filterList = ['register', 'unregister', 'browserInfo', 'trusteSite'];
- if (filterList.includes(method)) {
- webSocket.send(JSON.stringify(data));
-
-
-
-
-
-
- return Promise.resolve(true);
- }
- return new Promise((resolve, reject) => {
- this.keeper().then(res => {
- if (res) {
-
-
-
- webSocket.send(JSON.stringify(data));
- resolve(true);
- }
- else {
- reject(false);
- }
- }).catch(e => {
- console.error('ws-error in keeper');
- });
- });
- }
-
- initConfig() {
-
- if (this.token && this.token.split('_')[0]) {
- this.userName = this.token.split('_')[0];
- }
- this.config = {
- userName: this.userName,
- userCode: this.userCode,
- appId: this.appId,
- loginPort: this.loginPort,
- loginIp: this.loginIp,
- userPwd: this.userPwd,
- token: this.token,
- appName: this.appName,
- port: this.port
- };
-
- const browserInfo = {
- name: '',
- version: '',
- platform: ''
- };
- browserInfo.name = browser.getBrowserName().toLowerCase();
- browserInfo.version = browser.getBrowser().version.toLowerCase();
- browserInfo.platform =
- browser._ua.indexOf('Win64') >= 0 || browser._ua.indexOf('Wow64') >= 0
- ? 'win64'
- : 'win32';
- this.config['browser'] = browserInfo;
- }
-
- connectSocket(config) {
- this.connectFailCount = 0;
- this.connectEnd = false;
- this.connectStartTime = Date.now();
- let { port } = config;
- let url = this.url + ":" + port;
-
- this.webSocket = new reconnectingWebsocketCjs(url, '', {
- maxRetries: this.reConnectCount
- });
-
- this.removeEvents();
-
- this.addEvents();
- return this.detectConnectQt();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- detectConnectQt() {
- let _this = this;
- return new Promise((resolve, reject) => {
- if (!_this.connectEnd) {
-
-
-
-
-
- let _interval = setInterval(() => {
- if (_this.connectEnd) {
- clearInterval(_interval);
- resolve(_this.isConnectSuccessQt);
- }
- }, 50);
- }
- else {
- resolve(_this.isConnectSuccessQt);
- }
- });
- }
-
- detectLoginClient() {
- let _this = this;
- return new Promise((resolve, reject) => {
- console.log(this.loginEnd, "this.loginEnd");
- if (!this.loginEnd) {
- let _interval = setInterval(() => {
- if (_this.loginEnd) {
- clearInterval(_interval);
- resolve(_this.isLoginSuccess);
- }
- }, 50);
- }
- else {
- resolve(_this.isLoginSuccess);
- }
- });
- }
-
- keepConnect() {
- return new Promise((resolve, reject) => {
-
- this.detectConnectQt().then((connectStatus) => {
-
- if (connectStatus) {
- resolve(true);
- }
- else {
-
-
-
-
-
-
-
-
-
-
- this.Vue.prototype.$Message.info("请先连接客户端");
- }
- });
- });
- }
-
- keeper() {
- return new Promise((resolve, reject) => {
-
- this.detectConnectQt().then((connectStatus) => {
-
- if (connectStatus) {
- this.detectLoginClient().then((loginStatus) => {
-
- if (loginStatus) {
- resolve(true);
- }
- else {
-
-
- console.log(507);
- this.loginClient();
-
- this.detectLoginClient().then((reLoginStatus) => {
- if (reLoginStatus) {
- resolve(true);
- }
- else {
- console.log(`ws-in-keeper-reLogin-fail`);
- reject(false);
- }
- });
- }
- });
- }
- else {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.Vue.prototype.$Message.info("请先连接客户端");
- }
- });
- });
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- compareVersion() {
- if (this.currentDssVersion && this.onlineDssVersion && Number(this.onlineDssVersion) > Number(this.currentDssVersion)) {
- this.dispatchEvent('updateDss');
-
-
-
-
-
-
-
-
-
-
- }
- }
-
- downloadClient() {
- var agent = navigator.userAgent.toLowerCase();
- let type = '64';
- if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
- type = '32';
- }
- else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
- type = '64';
- }
- let downUrl = location.origin + '/data/VSL/DSSEnterpriseClient/DSS_LightWeight_Client';
- type === '32' ? downUrl = downUrl + '32.zip' : downUrl = downUrl + '.zip';
- window.open(downUrl);
- }
-
- register(config) {
- console.log('ws-login-start');
- this.loginFailCount = 0;
-
- let { userName, token } = config;
-
- if (token && token.split('_')[0]) {
- userName = token.split('_')[0];
- }
- if (this.config['userName'] && (userName !== this.config['userName'])) {
- this.userCode = new Date().valueOf();
- this.appId = new Date().valueOf();
- }
- this.userName = userName;
- this.initConfig();
- Object.assign(this.config, config);
- this.detectConnectQt().then((res) => {
- if (res) {
-
- console.log('ws-login-start-this.isLoginSuccess', this.isLoginSuccess);
-
-
-
-
- console.log(637);
- this.loginClient();
-
-
- }
- else {
-
-
-
-
-
-
-
-
-
-
-
-
- this.Vue.prototype.$Message.info("请先连接客户端");
- }
- });
- }
-
- unregister() {
-
- this.logoutClient();
-
-
-
- this.ids = [];
- this.ctrls = [];
- this.isLoginSuccess = false;
- if (typeof this.callback.loginResult === 'function') {
- this.callback.loginResult.call(this, this.isLoginSuccess);
- }
- }
-
- addEvents() {
- const webSocket = this.webSocket;
- webSocket.addEventListener('open', this.onOpen.bind(this));
- webSocket.addEventListener('message', this.onMessage.bind(this));
- webSocket.addEventListener('error', this.onError.bind(this));
- window.addEventListener('resize', this.reLocatedPosition.bind(this));
- window.addEventListener('scroll', this.reLocatedPosition.bind(this));
- window.addEventListener('visibilitychange', this.webVisibilityChange.bind(this));
- window.addEventListener('onunload', this.closeBrowser.bind(this));
- }
-
- removeEvents() {
- const webSocket = this.webSocket;
- webSocket.removeEventListener('open', this.onOpen);
- webSocket.removeEventListener('message', this.onMessage);
- webSocket.removeEventListener('error', this.onError);
- window.removeEventListener('resize', this.reLocatedPosition);
- window.removeEventListener('scroll', this.reLocatedPosition);
- window.removeEventListener('visibilitychange', this.webVisibilityChange);
- window.removeEventListener('onunload', this.closeBrowser);
- }
-
- onOpen() {
- console.log('ws-onOpen');
-
-
-
-
- this.isConnectSuccessQt = true;
- this.dispatchEvent('connectStateChange', true);
- this.connectEnd = true;
- if (typeof this.callback.connectResult === 'function') {
- this.callback.connectResult.call(this, this.isConnectSuccessQt);
- }
-
-
-
- }
-
- onMessage(event) {
- try {
- const data = JSON.parse(event.data);
- const { method } = data;
- console.log('receiveMessageFromClient', method, event);
- const callback = this.listerns.get(method);
-
- let dealDataRes = dealEventData[method] ? dealEventData[method](data) : data;
- this.dispatchEvent(method, dealDataRes);
-
-
-
-
-
-
-
-
-
-
-
-
-
- callback && callback(data);
- }
- catch (e) {
-
- console.log('ws-error-客户端返回的消息不是Json数据', e);
- }
- }
-
- onError() {
- this.ctrls = [];
- this.ids = [];
- this.isConnectSuccessQt = false;
-
- this.connectFailCount++;
- this.dispatchEvent('connectStateChange', false);
- if (this.connectFailCount === this.reConnectCount + 1) {
- this.connectEnd = true;
- this.isKeepConnect && this.keepConnect();
- if (typeof this.callback.connectResult === 'function') {
- this.callback.connectResult.call(this, this.isConnectSuccessQt);
- }
- }
- }
-
- isOpen() {
- if (!this.webSocket)
- return false;
- return this.webSocket.readyState === 1;
- }
-
-
-
-
-
-
-
-
-
- closeBrowser() {
- this.unregister();
-
- var timestamp = new Date().getTime();
- while ((new Date().getTime() - timestamp) < 100) { }
- }
- }
-
- Ws._instance = null;
-
- function hasKey(obj, key) {
- return key in obj;
- }
-
- function usePlugin(actions) {
- actions.forEach((plugin) => {
- Object.getOwnPropertyNames(plugin).forEach(prop => {
- Ws.prototype[prop] = plugin[prop];
- });
- });
- }
- return Ws;
- })));
|