podchat-browser 11.3.1 → 11.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26736,7 +26736,7 @@ function config (name) {
26736
26736
  },{}],188:[function(require,module,exports){
26737
26737
  window.PodChat = require('./src/chat.js');
26738
26738
 
26739
- },{"./src/chat.js":330}],189:[function(require,module,exports){
26739
+ },{"./src/chat.js":331}],189:[function(require,module,exports){
26740
26740
  Object.defineProperty(exports, "__esModule", { value: true });
26741
26741
  var tslib_1 = require("tslib");
26742
26742
  var core_1 = require("@sentry/core");
@@ -26787,7 +26787,7 @@ var BrowserBackend = /** @class */ (function (_super) {
26787
26787
  }(core_1.BaseBackend));
26788
26788
  exports.BrowserBackend = BrowserBackend;
26789
26789
 
26790
- },{"./eventbuilder":191,"./transports":207,"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],190:[function(require,module,exports){
26790
+ },{"./eventbuilder":191,"./transports":207,"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],190:[function(require,module,exports){
26791
26791
  Object.defineProperty(exports, "__esModule", { value: true });
26792
26792
  var tslib_1 = require("tslib");
26793
26793
  var core_1 = require("@sentry/core");
@@ -26864,7 +26864,7 @@ var BrowserClient = /** @class */ (function (_super) {
26864
26864
  }(core_1.BaseClient));
26865
26865
  exports.BrowserClient = BrowserClient;
26866
26866
 
26867
- },{"./backend":189,"./helpers":193,"./integrations":198,"@sentry/core":213,"@sentry/utils":238,"tslib":312}],191:[function(require,module,exports){
26867
+ },{"./backend":189,"./helpers":193,"./integrations":198,"@sentry/core":213,"@sentry/utils":238,"tslib":313}],191:[function(require,module,exports){
26868
26868
  Object.defineProperty(exports, "__esModule", { value: true });
26869
26869
  var tslib_1 = require("tslib");
26870
26870
  var types_1 = require("@sentry/types");
@@ -26989,7 +26989,7 @@ function eventFromString(input, syntheticException, options) {
26989
26989
  }
26990
26990
  exports.eventFromString = eventFromString;
26991
26991
 
26992
- },{"./parsers":202,"./tracekit":204,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],192:[function(require,module,exports){
26992
+ },{"./parsers":202,"./tracekit":204,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],192:[function(require,module,exports){
26993
26993
  Object.defineProperty(exports, "__esModule", { value: true });
26994
26994
  var types_1 = require("@sentry/types");
26995
26995
  exports.Severity = types_1.Severity;
@@ -27199,7 +27199,7 @@ function injectReportDialog(options) {
27199
27199
  }
27200
27200
  exports.injectReportDialog = injectReportDialog;
27201
27201
 
27202
- },{"@sentry/core":213,"@sentry/utils":238,"tslib":312}],194:[function(require,module,exports){
27202
+ },{"@sentry/core":213,"@sentry/utils":238,"tslib":313}],194:[function(require,module,exports){
27203
27203
  Object.defineProperty(exports, "__esModule", { value: true });
27204
27204
  var tslib_1 = require("tslib");
27205
27205
  tslib_1.__exportStar(require("./exports"), exports);
@@ -27217,7 +27217,7 @@ if (_window.Sentry && _window.Sentry.Integrations) {
27217
27217
  var INTEGRATIONS = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, windowIntegrations), core_1.Integrations), BrowserIntegrations);
27218
27218
  exports.Integrations = INTEGRATIONS;
27219
27219
 
27220
- },{"./exports":192,"./integrations":198,"./transports":207,"@sentry/core":213,"@sentry/utils":238,"tslib":312}],195:[function(require,module,exports){
27220
+ },{"./exports":192,"./integrations":198,"./transports":207,"@sentry/core":213,"@sentry/utils":238,"tslib":313}],195:[function(require,module,exports){
27221
27221
  Object.defineProperty(exports, "__esModule", { value: true });
27222
27222
  var tslib_1 = require("tslib");
27223
27223
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
@@ -27487,7 +27487,7 @@ var Breadcrumbs = /** @class */ (function () {
27487
27487
  }());
27488
27488
  exports.Breadcrumbs = Breadcrumbs;
27489
27489
 
27490
- },{"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],196:[function(require,module,exports){
27490
+ },{"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],196:[function(require,module,exports){
27491
27491
  Object.defineProperty(exports, "__esModule", { value: true });
27492
27492
  /** Deduplication filter */
27493
27493
  var Dedupe = /** @class */ (function () {
@@ -27857,7 +27857,7 @@ var GlobalHandlers = /** @class */ (function () {
27857
27857
  }());
27858
27858
  exports.GlobalHandlers = GlobalHandlers;
27859
27859
 
27860
- },{"../eventbuilder":191,"../helpers":193,"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],198:[function(require,module,exports){
27860
+ },{"../eventbuilder":191,"../helpers":193,"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],198:[function(require,module,exports){
27861
27861
  Object.defineProperty(exports, "__esModule", { value: true });
27862
27862
  var globalhandlers_1 = require("./globalhandlers");
27863
27863
  exports.GlobalHandlers = globalhandlers_1.GlobalHandlers;
@@ -27939,7 +27939,7 @@ var LinkedErrors = /** @class */ (function () {
27939
27939
  }());
27940
27940
  exports.LinkedErrors = LinkedErrors;
27941
27941
 
27942
- },{"../parsers":202,"../tracekit":204,"@sentry/core":213,"@sentry/utils":238,"tslib":312}],200:[function(require,module,exports){
27942
+ },{"../parsers":202,"../tracekit":204,"@sentry/core":213,"@sentry/utils":238,"tslib":313}],200:[function(require,module,exports){
27943
27943
  Object.defineProperty(exports, "__esModule", { value: true });
27944
27944
  var tslib_1 = require("tslib");
27945
27945
  var utils_1 = require("@sentry/utils");
@@ -28171,7 +28171,7 @@ var TryCatch = /** @class */ (function () {
28171
28171
  }());
28172
28172
  exports.TryCatch = TryCatch;
28173
28173
 
28174
- },{"../helpers":193,"@sentry/utils":238,"tslib":312}],201:[function(require,module,exports){
28174
+ },{"../helpers":193,"@sentry/utils":238,"tslib":313}],201:[function(require,module,exports){
28175
28175
  Object.defineProperty(exports, "__esModule", { value: true });
28176
28176
  var tslib_1 = require("tslib");
28177
28177
  var core_1 = require("@sentry/core");
@@ -28215,7 +28215,7 @@ var UserAgent = /** @class */ (function () {
28215
28215
  }());
28216
28216
  exports.UserAgent = UserAgent;
28217
28217
 
28218
- },{"@sentry/core":213,"@sentry/utils":238,"tslib":312}],202:[function(require,module,exports){
28218
+ },{"@sentry/core":213,"@sentry/utils":238,"tslib":313}],202:[function(require,module,exports){
28219
28219
  Object.defineProperty(exports, "__esModule", { value: true });
28220
28220
  var utils_1 = require("@sentry/utils");
28221
28221
  var tracekit_1 = require("./tracekit");
@@ -28540,7 +28540,7 @@ function startSessionTracking() {
28540
28540
  });
28541
28541
  }
28542
28542
 
28543
- },{"./client":190,"./helpers":193,"./integrations":198,"@sentry/core":213,"@sentry/utils":238,"tslib":312}],204:[function(require,module,exports){
28543
+ },{"./client":190,"./helpers":193,"./integrations":198,"@sentry/core":213,"@sentry/utils":238,"tslib":313}],204:[function(require,module,exports){
28544
28544
  /**
28545
28545
  * This was originally forked from https://github.com/occ/TraceKit, but has since been
28546
28546
  * largely modified and is now maintained as part of Sentry JS SDK.
@@ -28771,7 +28771,7 @@ function extractMessage(ex) {
28771
28771
  return message;
28772
28772
  }
28773
28773
 
28774
- },{"tslib":312}],205:[function(require,module,exports){
28774
+ },{"tslib":313}],205:[function(require,module,exports){
28775
28775
  Object.defineProperty(exports, "__esModule", { value: true });
28776
28776
  var tslib_1 = require("tslib");
28777
28777
  var core_1 = require("@sentry/core");
@@ -28898,7 +28898,7 @@ var BaseTransport = /** @class */ (function () {
28898
28898
  }());
28899
28899
  exports.BaseTransport = BaseTransport;
28900
28900
 
28901
- },{"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],206:[function(require,module,exports){
28901
+ },{"@sentry/core":213,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],206:[function(require,module,exports){
28902
28902
  Object.defineProperty(exports, "__esModule", { value: true });
28903
28903
  var tslib_1 = require("tslib");
28904
28904
  var core_1 = require("@sentry/core");
@@ -29044,7 +29044,7 @@ var FetchTransport = /** @class */ (function (_super) {
29044
29044
  }(base_1.BaseTransport));
29045
29045
  exports.FetchTransport = FetchTransport;
29046
29046
 
29047
- },{"./base":205,"@sentry/core":213,"@sentry/utils":238,"tslib":312}],207:[function(require,module,exports){
29047
+ },{"./base":205,"@sentry/core":213,"@sentry/utils":238,"tslib":313}],207:[function(require,module,exports){
29048
29048
  Object.defineProperty(exports, "__esModule", { value: true });
29049
29049
  var base_1 = require("./base");
29050
29050
  exports.BaseTransport = base_1.BaseTransport;
@@ -29117,7 +29117,7 @@ var XHRTransport = /** @class */ (function (_super) {
29117
29117
  }(base_1.BaseTransport));
29118
29118
  exports.XHRTransport = XHRTransport;
29119
29119
 
29120
- },{"./base":205,"@sentry/core":213,"@sentry/utils":238,"tslib":312}],209:[function(require,module,exports){
29120
+ },{"./base":205,"@sentry/core":213,"@sentry/utils":238,"tslib":313}],209:[function(require,module,exports){
29121
29121
  Object.defineProperty(exports, "__esModule", { value: true });
29122
29122
  // TODO: Remove in the next major release and rely only on @sentry/core SDK_VERSION and SdkInfo metadata
29123
29123
  exports.SDK_NAME = 'sentry.javascript.browser';
@@ -29820,7 +29820,7 @@ var BaseClient = /** @class */ (function () {
29820
29820
  }());
29821
29821
  exports.BaseClient = BaseClient;
29822
29822
 
29823
- },{"./integration":214,"@sentry/hub":223,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],213:[function(require,module,exports){
29823
+ },{"./integration":214,"@sentry/hub":223,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],213:[function(require,module,exports){
29824
29824
  Object.defineProperty(exports, "__esModule", { value: true });
29825
29825
  var minimal_1 = require("@sentry/minimal");
29826
29826
  exports.addBreadcrumb = minimal_1.addBreadcrumb;
@@ -29932,7 +29932,7 @@ function setupIntegrations(options) {
29932
29932
  }
29933
29933
  exports.setupIntegrations = setupIntegrations;
29934
29934
 
29935
- },{"@sentry/hub":223,"@sentry/utils":238,"tslib":312}],215:[function(require,module,exports){
29935
+ },{"@sentry/hub":223,"@sentry/utils":238,"tslib":313}],215:[function(require,module,exports){
29936
29936
  Object.defineProperty(exports, "__esModule", { value: true });
29937
29937
  var originalFunctionToString;
29938
29938
  /** Patch toString calls to return proper name for wrapped functions */
@@ -30142,7 +30142,7 @@ var InboundFilters = /** @class */ (function () {
30142
30142
  }());
30143
30143
  exports.InboundFilters = InboundFilters;
30144
30144
 
30145
- },{"@sentry/hub":223,"@sentry/utils":238,"tslib":312}],217:[function(require,module,exports){
30145
+ },{"@sentry/hub":223,"@sentry/utils":238,"tslib":313}],217:[function(require,module,exports){
30146
30146
  Object.defineProperty(exports, "__esModule", { value: true });
30147
30147
  var functiontostring_1 = require("./functiontostring");
30148
30148
  exports.FunctionToString = functiontostring_1.FunctionToString;
@@ -30233,7 +30233,7 @@ function eventToSentryRequest(event, api) {
30233
30233
  }
30234
30234
  exports.eventToSentryRequest = eventToSentryRequest;
30235
30235
 
30236
- },{"tslib":312}],219:[function(require,module,exports){
30236
+ },{"tslib":313}],219:[function(require,module,exports){
30237
30237
  Object.defineProperty(exports, "__esModule", { value: true });
30238
30238
  var hub_1 = require("@sentry/hub");
30239
30239
  var utils_1 = require("@sentry/utils");
@@ -30809,7 +30809,7 @@ function setHubOnCarrier(carrier, hub) {
30809
30809
  }
30810
30810
  exports.setHubOnCarrier = setHubOnCarrier;
30811
30811
 
30812
- },{"./scope":224,"./session":225,"@sentry/types":228,"@sentry/utils":238,"tslib":312}],223:[function(require,module,exports){
30812
+ },{"./scope":224,"./session":225,"@sentry/types":228,"@sentry/utils":238,"tslib":313}],223:[function(require,module,exports){
30813
30813
  Object.defineProperty(exports, "__esModule", { value: true });
30814
30814
  var scope_1 = require("./scope");
30815
30815
  exports.addGlobalEventProcessor = scope_1.addGlobalEventProcessor;
@@ -31274,7 +31274,7 @@ function addGlobalEventProcessor(callback) {
31274
31274
  }
31275
31275
  exports.addGlobalEventProcessor = addGlobalEventProcessor;
31276
31276
 
31277
- },{"@sentry/utils":238,"tslib":312}],225:[function(require,module,exports){
31277
+ },{"@sentry/utils":238,"tslib":313}],225:[function(require,module,exports){
31278
31278
  Object.defineProperty(exports, "__esModule", { value: true });
31279
31279
  var types_1 = require("@sentry/types");
31280
31280
  var utils_1 = require("@sentry/utils");
@@ -31707,7 +31707,7 @@ function startTransaction(context, customSamplingContext) {
31707
31707
  }
31708
31708
  exports.startTransaction = startTransaction;
31709
31709
 
31710
- },{"@sentry/hub":223,"tslib":312}],228:[function(require,module,exports){
31710
+ },{"@sentry/hub":223,"tslib":313}],228:[function(require,module,exports){
31711
31711
  Object.defineProperty(exports, "__esModule", { value: true });
31712
31712
  var loglevel_1 = require("./loglevel");
31713
31713
  exports.LogLevel = loglevel_1.LogLevel;
@@ -32074,7 +32074,7 @@ var Dsn = /** @class */ (function () {
32074
32074
  }());
32075
32075
  exports.Dsn = Dsn;
32076
32076
 
32077
- },{"./error":237,"tslib":312}],237:[function(require,module,exports){
32077
+ },{"./error":237,"tslib":313}],237:[function(require,module,exports){
32078
32078
  Object.defineProperty(exports, "__esModule", { value: true });
32079
32079
  var tslib_1 = require("tslib");
32080
32080
  var polyfill_1 = require("./polyfill");
@@ -32093,7 +32093,7 @@ var SentryError = /** @class */ (function (_super) {
32093
32093
  }(Error));
32094
32094
  exports.SentryError = SentryError;
32095
32095
 
32096
- },{"./polyfill":247,"tslib":312}],238:[function(require,module,exports){
32096
+ },{"./polyfill":247,"tslib":313}],238:[function(require,module,exports){
32097
32097
  Object.defineProperty(exports, "__esModule", { value: true });
32098
32098
  var tslib_1 = require("tslib");
32099
32099
  tslib_1.__exportStar(require("./async"), exports);
@@ -32115,7 +32115,7 @@ tslib_1.__exportStar(require("./supports"), exports);
32115
32115
  tslib_1.__exportStar(require("./syncpromise"), exports);
32116
32116
  tslib_1.__exportStar(require("./time"), exports);
32117
32117
 
32118
- },{"./async":234,"./browser":235,"./dsn":236,"./error":237,"./instrument":239,"./is":240,"./logger":241,"./memo":242,"./misc":243,"./node":244,"./object":245,"./path":246,"./promisebuffer":248,"./stacktrace":249,"./string":250,"./supports":251,"./syncpromise":252,"./time":253,"tslib":312}],239:[function(require,module,exports){
32118
+ },{"./async":234,"./browser":235,"./dsn":236,"./error":237,"./instrument":239,"./is":240,"./logger":241,"./memo":242,"./misc":243,"./node":244,"./object":245,"./path":246,"./promisebuffer":248,"./stacktrace":249,"./string":250,"./supports":251,"./syncpromise":252,"./time":253,"tslib":313}],239:[function(require,module,exports){
32119
32119
  Object.defineProperty(exports, "__esModule", { value: true });
32120
32120
  var tslib_1 = require("tslib");
32121
32121
  var is_1 = require("./is");
@@ -32660,7 +32660,7 @@ function instrumentUnhandledRejection() {
32660
32660
  };
32661
32661
  }
32662
32662
 
32663
- },{"./is":240,"./logger":241,"./misc":243,"./object":245,"./stacktrace":249,"./supports":251,"tslib":312}],240:[function(require,module,exports){
32663
+ },{"./is":240,"./logger":241,"./misc":243,"./object":245,"./stacktrace":249,"./supports":251,"tslib":313}],240:[function(require,module,exports){
32664
32664
  /* eslint-disable @typescript-eslint/no-explicit-any */
32665
32665
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
32666
32666
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -33600,7 +33600,7 @@ function dropUndefinedKeys(val) {
33600
33600
  exports.dropUndefinedKeys = dropUndefinedKeys;
33601
33601
 
33602
33602
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
33603
- },{"./browser":235,"./is":240,"./memo":242,"./stacktrace":249,"./string":250,"tslib":312}],246:[function(require,module,exports){
33603
+ },{"./browser":235,"./is":240,"./memo":242,"./stacktrace":249,"./string":250,"tslib":313}],246:[function(require,module,exports){
33604
33604
  // Slightly modified (no IE8 support, ES6) and transcribed to TypeScript
33605
33605
  // https://raw.githubusercontent.com/calvinmetcalf/rollup-plugin-node-builtins/master/src/es6/path.js
33606
33606
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -45707,6 +45707,1406 @@ return Dexie;
45707
45707
 
45708
45708
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
45709
45709
  },{"timers":186}],289:[function(require,module,exports){
45710
+ /*! @license DOMPurify 2.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.3/LICENSE */
45711
+
45712
+ (function (global, factory) {
45713
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
45714
+ typeof define === 'function' && define.amd ? define(factory) :
45715
+ (global = global || self, global.DOMPurify = factory());
45716
+ }(this, function () { 'use strict';
45717
+
45718
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
45719
+
45720
+ var hasOwnProperty = Object.hasOwnProperty,
45721
+ setPrototypeOf = Object.setPrototypeOf,
45722
+ isFrozen = Object.isFrozen,
45723
+ getPrototypeOf = Object.getPrototypeOf,
45724
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
45725
+ var freeze = Object.freeze,
45726
+ seal = Object.seal,
45727
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
45728
+
45729
+ var _ref = typeof Reflect !== 'undefined' && Reflect,
45730
+ apply = _ref.apply,
45731
+ construct = _ref.construct;
45732
+
45733
+ if (!apply) {
45734
+ apply = function apply(fun, thisValue, args) {
45735
+ return fun.apply(thisValue, args);
45736
+ };
45737
+ }
45738
+
45739
+ if (!freeze) {
45740
+ freeze = function freeze(x) {
45741
+ return x;
45742
+ };
45743
+ }
45744
+
45745
+ if (!seal) {
45746
+ seal = function seal(x) {
45747
+ return x;
45748
+ };
45749
+ }
45750
+
45751
+ if (!construct) {
45752
+ construct = function construct(Func, args) {
45753
+ return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
45754
+ };
45755
+ }
45756
+
45757
+ var arrayForEach = unapply(Array.prototype.forEach);
45758
+ var arrayPop = unapply(Array.prototype.pop);
45759
+ var arrayPush = unapply(Array.prototype.push);
45760
+
45761
+ var stringToLowerCase = unapply(String.prototype.toLowerCase);
45762
+ var stringMatch = unapply(String.prototype.match);
45763
+ var stringReplace = unapply(String.prototype.replace);
45764
+ var stringIndexOf = unapply(String.prototype.indexOf);
45765
+ var stringTrim = unapply(String.prototype.trim);
45766
+
45767
+ var regExpTest = unapply(RegExp.prototype.test);
45768
+
45769
+ var typeErrorCreate = unconstruct(TypeError);
45770
+
45771
+ function unapply(func) {
45772
+ return function (thisArg) {
45773
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
45774
+ args[_key - 1] = arguments[_key];
45775
+ }
45776
+
45777
+ return apply(func, thisArg, args);
45778
+ };
45779
+ }
45780
+
45781
+ function unconstruct(func) {
45782
+ return function () {
45783
+ for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
45784
+ args[_key2] = arguments[_key2];
45785
+ }
45786
+
45787
+ return construct(func, args);
45788
+ };
45789
+ }
45790
+
45791
+ /* Add properties to a lookup table */
45792
+ function addToSet(set, array) {
45793
+ if (setPrototypeOf) {
45794
+ // Make 'in' and truthy checks like Boolean(set.constructor)
45795
+ // independent of any properties defined on Object.prototype.
45796
+ // Prevent prototype setters from intercepting set as a this value.
45797
+ setPrototypeOf(set, null);
45798
+ }
45799
+
45800
+ var l = array.length;
45801
+ while (l--) {
45802
+ var element = array[l];
45803
+ if (typeof element === 'string') {
45804
+ var lcElement = stringToLowerCase(element);
45805
+ if (lcElement !== element) {
45806
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
45807
+ if (!isFrozen(array)) {
45808
+ array[l] = lcElement;
45809
+ }
45810
+
45811
+ element = lcElement;
45812
+ }
45813
+ }
45814
+
45815
+ set[element] = true;
45816
+ }
45817
+
45818
+ return set;
45819
+ }
45820
+
45821
+ /* Shallow clone an object */
45822
+ function clone(object) {
45823
+ var newObject = create(null);
45824
+
45825
+ var property = void 0;
45826
+ for (property in object) {
45827
+ if (apply(hasOwnProperty, object, [property])) {
45828
+ newObject[property] = object[property];
45829
+ }
45830
+ }
45831
+
45832
+ return newObject;
45833
+ }
45834
+
45835
+ /* IE10 doesn't support __lookupGetter__ so lets'
45836
+ * simulate it. It also automatically checks
45837
+ * if the prop is function or getter and behaves
45838
+ * accordingly. */
45839
+ function lookupGetter(object, prop) {
45840
+ while (object !== null) {
45841
+ var desc = getOwnPropertyDescriptor(object, prop);
45842
+ if (desc) {
45843
+ if (desc.get) {
45844
+ return unapply(desc.get);
45845
+ }
45846
+
45847
+ if (typeof desc.value === 'function') {
45848
+ return unapply(desc.value);
45849
+ }
45850
+ }
45851
+
45852
+ object = getPrototypeOf(object);
45853
+ }
45854
+
45855
+ function fallbackValue(element) {
45856
+ console.warn('fallback value for', element);
45857
+ return null;
45858
+ }
45859
+
45860
+ return fallbackValue;
45861
+ }
45862
+
45863
+ var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
45864
+
45865
+ // SVG
45866
+ var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
45867
+
45868
+ var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
45869
+
45870
+ // List of SVG elements that are disallowed by default.
45871
+ // We still need to know them so that we can do namespace
45872
+ // checks properly in case one wants to add them to
45873
+ // allow-list.
45874
+ var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'feimage', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
45875
+
45876
+ var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
45877
+
45878
+ // Similarly to SVG, we want to know all MathML elements,
45879
+ // even those that we disallow by default.
45880
+ var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
45881
+
45882
+ var text = freeze(['#text']);
45883
+
45884
+ var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
45885
+
45886
+ var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
45887
+
45888
+ var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
45889
+
45890
+ var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
45891
+
45892
+ // eslint-disable-next-line unicorn/better-regex
45893
+ var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
45894
+ var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
45895
+ var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
45896
+ var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
45897
+ var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
45898
+ );
45899
+ var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
45900
+ var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
45901
+ );
45902
+
45903
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
45904
+
45905
+ function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
45906
+
45907
+ var getGlobal = function getGlobal() {
45908
+ return typeof window === 'undefined' ? null : window;
45909
+ };
45910
+
45911
+ /**
45912
+ * Creates a no-op policy for internal use only.
45913
+ * Don't export this function outside this module!
45914
+ * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
45915
+ * @param {Document} document The document object (to determine policy name suffix)
45916
+ * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
45917
+ * are not supported).
45918
+ */
45919
+ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
45920
+ if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
45921
+ return null;
45922
+ }
45923
+
45924
+ // Allow the callers to control the unique policy name
45925
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
45926
+ // Policy creation with duplicate names throws in Trusted Types.
45927
+ var suffix = null;
45928
+ var ATTR_NAME = 'data-tt-policy-suffix';
45929
+ if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
45930
+ suffix = document.currentScript.getAttribute(ATTR_NAME);
45931
+ }
45932
+
45933
+ var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
45934
+
45935
+ try {
45936
+ return trustedTypes.createPolicy(policyName, {
45937
+ createHTML: function createHTML(html$$1) {
45938
+ return html$$1;
45939
+ }
45940
+ });
45941
+ } catch (_) {
45942
+ // Policy creation failed (most likely another DOMPurify script has
45943
+ // already run). Skip creating the policy, as this will only cause errors
45944
+ // if TT are enforced.
45945
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
45946
+ return null;
45947
+ }
45948
+ };
45949
+
45950
+ function createDOMPurify() {
45951
+ var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
45952
+
45953
+ var DOMPurify = function DOMPurify(root) {
45954
+ return createDOMPurify(root);
45955
+ };
45956
+
45957
+ /**
45958
+ * Version label, exposed for easier checks
45959
+ * if DOMPurify is up to date or not
45960
+ */
45961
+ DOMPurify.version = '2.3.3';
45962
+
45963
+ /**
45964
+ * Array of elements that DOMPurify removed during sanitation.
45965
+ * Empty if nothing was removed.
45966
+ */
45967
+ DOMPurify.removed = [];
45968
+
45969
+ if (!window || !window.document || window.document.nodeType !== 9) {
45970
+ // Not running in a browser, provide a factory function
45971
+ // so that you can pass your own Window
45972
+ DOMPurify.isSupported = false;
45973
+
45974
+ return DOMPurify;
45975
+ }
45976
+
45977
+ var originalDocument = window.document;
45978
+
45979
+ var document = window.document;
45980
+ var DocumentFragment = window.DocumentFragment,
45981
+ HTMLTemplateElement = window.HTMLTemplateElement,
45982
+ Node = window.Node,
45983
+ Element = window.Element,
45984
+ NodeFilter = window.NodeFilter,
45985
+ _window$NamedNodeMap = window.NamedNodeMap,
45986
+ NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
45987
+ Text = window.Text,
45988
+ Comment = window.Comment,
45989
+ DOMParser = window.DOMParser,
45990
+ trustedTypes = window.trustedTypes;
45991
+
45992
+
45993
+ var ElementPrototype = Element.prototype;
45994
+
45995
+ var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
45996
+ var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
45997
+ var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
45998
+ var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
45999
+
46000
+ // As per issue #47, the web-components registry is inherited by a
46001
+ // new document created via createHTMLDocument. As per the spec
46002
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
46003
+ // a new empty registry is used when creating a template contents owner
46004
+ // document, so we use that as our parent document to ensure nothing
46005
+ // is inherited.
46006
+ if (typeof HTMLTemplateElement === 'function') {
46007
+ var template = document.createElement('template');
46008
+ if (template.content && template.content.ownerDocument) {
46009
+ document = template.content.ownerDocument;
46010
+ }
46011
+ }
46012
+
46013
+ var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
46014
+ var emptyHTML = trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML('') : '';
46015
+
46016
+ var _document = document,
46017
+ implementation = _document.implementation,
46018
+ createNodeIterator = _document.createNodeIterator,
46019
+ createDocumentFragment = _document.createDocumentFragment,
46020
+ getElementsByTagName = _document.getElementsByTagName;
46021
+ var importNode = originalDocument.importNode;
46022
+
46023
+
46024
+ var documentMode = {};
46025
+ try {
46026
+ documentMode = clone(document).documentMode ? document.documentMode : {};
46027
+ } catch (_) {}
46028
+
46029
+ var hooks = {};
46030
+
46031
+ /**
46032
+ * Expose whether this browser supports running the full DOMPurify.
46033
+ */
46034
+ DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
46035
+
46036
+ var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
46037
+ ERB_EXPR$$1 = ERB_EXPR,
46038
+ DATA_ATTR$$1 = DATA_ATTR,
46039
+ ARIA_ATTR$$1 = ARIA_ATTR,
46040
+ IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
46041
+ ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
46042
+ var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
46043
+
46044
+ /**
46045
+ * We consider the elements and attributes below to be safe. Ideally
46046
+ * don't add any new ones but feel free to remove unwanted ones.
46047
+ */
46048
+
46049
+ /* allowed element names */
46050
+
46051
+ var ALLOWED_TAGS = null;
46052
+ var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
46053
+
46054
+ /* Allowed attribute names */
46055
+ var ALLOWED_ATTR = null;
46056
+ var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
46057
+
46058
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
46059
+ var FORBID_TAGS = null;
46060
+
46061
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
46062
+ var FORBID_ATTR = null;
46063
+
46064
+ /* Decide if ARIA attributes are okay */
46065
+ var ALLOW_ARIA_ATTR = true;
46066
+
46067
+ /* Decide if custom data attributes are okay */
46068
+ var ALLOW_DATA_ATTR = true;
46069
+
46070
+ /* Decide if unknown protocols are okay */
46071
+ var ALLOW_UNKNOWN_PROTOCOLS = false;
46072
+
46073
+ /* Output should be safe for common template engines.
46074
+ * This means, DOMPurify removes data attributes, mustaches and ERB
46075
+ */
46076
+ var SAFE_FOR_TEMPLATES = false;
46077
+
46078
+ /* Decide if document with <html>... should be returned */
46079
+ var WHOLE_DOCUMENT = false;
46080
+
46081
+ /* Track whether config is already set on this instance of DOMPurify. */
46082
+ var SET_CONFIG = false;
46083
+
46084
+ /* Decide if all elements (e.g. style, script) must be children of
46085
+ * document.body. By default, browsers might move them to document.head */
46086
+ var FORCE_BODY = false;
46087
+
46088
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
46089
+ * string (or a TrustedHTML object if Trusted Types are supported).
46090
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
46091
+ */
46092
+ var RETURN_DOM = false;
46093
+
46094
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
46095
+ * string (or a TrustedHTML object if Trusted Types are supported) */
46096
+ var RETURN_DOM_FRAGMENT = false;
46097
+
46098
+ /* If `RETURN_DOM` or `RETURN_DOM_FRAGMENT` is enabled, decide if the returned DOM
46099
+ * `Node` is imported into the current `Document`. If this flag is not enabled the
46100
+ * `Node` will belong (its ownerDocument) to a fresh `HTMLDocument`, created by
46101
+ * DOMPurify.
46102
+ *
46103
+ * This defaults to `true` starting DOMPurify 2.2.0. Note that setting it to `false`
46104
+ * might cause XSS from attacks hidden in closed shadowroots in case the browser
46105
+ * supports Declarative Shadow: DOM https://web.dev/declarative-shadow-dom/
46106
+ */
46107
+ var RETURN_DOM_IMPORT = true;
46108
+
46109
+ /* Try to return a Trusted Type object instead of a string, return a string in
46110
+ * case Trusted Types are not supported */
46111
+ var RETURN_TRUSTED_TYPE = false;
46112
+
46113
+ /* Output should be free from DOM clobbering attacks? */
46114
+ var SANITIZE_DOM = true;
46115
+
46116
+ /* Keep element content when removing element? */
46117
+ var KEEP_CONTENT = true;
46118
+
46119
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
46120
+ * of importing it into a new Document and returning a sanitized copy */
46121
+ var IN_PLACE = false;
46122
+
46123
+ /* Allow usage of profiles like html, svg and mathMl */
46124
+ var USE_PROFILES = {};
46125
+
46126
+ /* Tags to ignore content of when KEEP_CONTENT is true */
46127
+ var FORBID_CONTENTS = null;
46128
+ var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
46129
+
46130
+ /* Tags that are safe for data: URIs */
46131
+ var DATA_URI_TAGS = null;
46132
+ var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
46133
+
46134
+ /* Attributes safe for values like "javascript:" */
46135
+ var URI_SAFE_ATTRIBUTES = null;
46136
+ var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
46137
+
46138
+ var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
46139
+ var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
46140
+ var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
46141
+ /* Document namespace */
46142
+ var NAMESPACE = HTML_NAMESPACE;
46143
+ var IS_EMPTY_INPUT = false;
46144
+
46145
+ /* Parsing of strict XHTML documents */
46146
+ var PARSER_MEDIA_TYPE = void 0;
46147
+ var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
46148
+ var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
46149
+ var transformCaseFunc = void 0;
46150
+
46151
+ /* Keep a reference to config to pass to hooks */
46152
+ var CONFIG = null;
46153
+
46154
+ /* Ideally, do not touch anything below this line */
46155
+ /* ______________________________________________ */
46156
+
46157
+ var formElement = document.createElement('form');
46158
+
46159
+ /**
46160
+ * _parseConfig
46161
+ *
46162
+ * @param {Object} cfg optional config literal
46163
+ */
46164
+ // eslint-disable-next-line complexity
46165
+ var _parseConfig = function _parseConfig(cfg) {
46166
+ if (CONFIG && CONFIG === cfg) {
46167
+ return;
46168
+ }
46169
+
46170
+ /* Shield configuration object from tampering */
46171
+ if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
46172
+ cfg = {};
46173
+ }
46174
+
46175
+ /* Shield configuration object from prototype pollution */
46176
+ cfg = clone(cfg);
46177
+
46178
+ /* Set configuration parameters */
46179
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
46180
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
46181
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
46182
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
46183
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
46184
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
46185
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
46186
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
46187
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
46188
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
46189
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
46190
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
46191
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
46192
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
46193
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
46194
+ RETURN_DOM_IMPORT = cfg.RETURN_DOM_IMPORT !== false; // Default true
46195
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
46196
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
46197
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
46198
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
46199
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
46200
+ IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
46201
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
46202
+
46203
+ PARSER_MEDIA_TYPE =
46204
+ // eslint-disable-next-line unicorn/prefer-includes
46205
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
46206
+
46207
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
46208
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
46209
+ return x;
46210
+ } : stringToLowerCase;
46211
+
46212
+ if (SAFE_FOR_TEMPLATES) {
46213
+ ALLOW_DATA_ATTR = false;
46214
+ }
46215
+
46216
+ if (RETURN_DOM_FRAGMENT) {
46217
+ RETURN_DOM = true;
46218
+ }
46219
+
46220
+ /* Parse profile info */
46221
+ if (USE_PROFILES) {
46222
+ ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
46223
+ ALLOWED_ATTR = [];
46224
+ if (USE_PROFILES.html === true) {
46225
+ addToSet(ALLOWED_TAGS, html);
46226
+ addToSet(ALLOWED_ATTR, html$1);
46227
+ }
46228
+
46229
+ if (USE_PROFILES.svg === true) {
46230
+ addToSet(ALLOWED_TAGS, svg);
46231
+ addToSet(ALLOWED_ATTR, svg$1);
46232
+ addToSet(ALLOWED_ATTR, xml);
46233
+ }
46234
+
46235
+ if (USE_PROFILES.svgFilters === true) {
46236
+ addToSet(ALLOWED_TAGS, svgFilters);
46237
+ addToSet(ALLOWED_ATTR, svg$1);
46238
+ addToSet(ALLOWED_ATTR, xml);
46239
+ }
46240
+
46241
+ if (USE_PROFILES.mathMl === true) {
46242
+ addToSet(ALLOWED_TAGS, mathMl);
46243
+ addToSet(ALLOWED_ATTR, mathMl$1);
46244
+ addToSet(ALLOWED_ATTR, xml);
46245
+ }
46246
+ }
46247
+
46248
+ /* Merge configuration parameters */
46249
+ if (cfg.ADD_TAGS) {
46250
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
46251
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
46252
+ }
46253
+
46254
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
46255
+ }
46256
+
46257
+ if (cfg.ADD_ATTR) {
46258
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
46259
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
46260
+ }
46261
+
46262
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
46263
+ }
46264
+
46265
+ if (cfg.ADD_URI_SAFE_ATTR) {
46266
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
46267
+ }
46268
+
46269
+ if (cfg.FORBID_CONTENTS) {
46270
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
46271
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
46272
+ }
46273
+
46274
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
46275
+ }
46276
+
46277
+ /* Add #text in case KEEP_CONTENT is set to true */
46278
+ if (KEEP_CONTENT) {
46279
+ ALLOWED_TAGS['#text'] = true;
46280
+ }
46281
+
46282
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
46283
+ if (WHOLE_DOCUMENT) {
46284
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
46285
+ }
46286
+
46287
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
46288
+ if (ALLOWED_TAGS.table) {
46289
+ addToSet(ALLOWED_TAGS, ['tbody']);
46290
+ delete FORBID_TAGS.tbody;
46291
+ }
46292
+
46293
+ // Prevent further manipulation of configuration.
46294
+ // Not available in IE8, Safari 5, etc.
46295
+ if (freeze) {
46296
+ freeze(cfg);
46297
+ }
46298
+
46299
+ CONFIG = cfg;
46300
+ };
46301
+
46302
+ var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
46303
+
46304
+ var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
46305
+
46306
+ /* Keep track of all possible SVG and MathML tags
46307
+ * so that we can perform the namespace checks
46308
+ * correctly. */
46309
+ var ALL_SVG_TAGS = addToSet({}, svg);
46310
+ addToSet(ALL_SVG_TAGS, svgFilters);
46311
+ addToSet(ALL_SVG_TAGS, svgDisallowed);
46312
+
46313
+ var ALL_MATHML_TAGS = addToSet({}, mathMl);
46314
+ addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
46315
+
46316
+ /**
46317
+ *
46318
+ *
46319
+ * @param {Element} element a DOM element whose namespace is being checked
46320
+ * @returns {boolean} Return false if the element has a
46321
+ * namespace that a spec-compliant parser would never
46322
+ * return. Return true otherwise.
46323
+ */
46324
+ var _checkValidNamespace = function _checkValidNamespace(element) {
46325
+ var parent = getParentNode(element);
46326
+
46327
+ // In JSDOM, if we're inside shadow DOM, then parentNode
46328
+ // can be null. We just simulate parent in this case.
46329
+ if (!parent || !parent.tagName) {
46330
+ parent = {
46331
+ namespaceURI: HTML_NAMESPACE,
46332
+ tagName: 'template'
46333
+ };
46334
+ }
46335
+
46336
+ var tagName = stringToLowerCase(element.tagName);
46337
+ var parentTagName = stringToLowerCase(parent.tagName);
46338
+
46339
+ if (element.namespaceURI === SVG_NAMESPACE) {
46340
+ // The only way to switch from HTML namespace to SVG
46341
+ // is via <svg>. If it happens via any other tag, then
46342
+ // it should be killed.
46343
+ if (parent.namespaceURI === HTML_NAMESPACE) {
46344
+ return tagName === 'svg';
46345
+ }
46346
+
46347
+ // The only way to switch from MathML to SVG is via
46348
+ // svg if parent is either <annotation-xml> or MathML
46349
+ // text integration points.
46350
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
46351
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
46352
+ }
46353
+
46354
+ // We only allow elements that are defined in SVG
46355
+ // spec. All others are disallowed in SVG namespace.
46356
+ return Boolean(ALL_SVG_TAGS[tagName]);
46357
+ }
46358
+
46359
+ if (element.namespaceURI === MATHML_NAMESPACE) {
46360
+ // The only way to switch from HTML namespace to MathML
46361
+ // is via <math>. If it happens via any other tag, then
46362
+ // it should be killed.
46363
+ if (parent.namespaceURI === HTML_NAMESPACE) {
46364
+ return tagName === 'math';
46365
+ }
46366
+
46367
+ // The only way to switch from SVG to MathML is via
46368
+ // <math> and HTML integration points
46369
+ if (parent.namespaceURI === SVG_NAMESPACE) {
46370
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
46371
+ }
46372
+
46373
+ // We only allow elements that are defined in MathML
46374
+ // spec. All others are disallowed in MathML namespace.
46375
+ return Boolean(ALL_MATHML_TAGS[tagName]);
46376
+ }
46377
+
46378
+ if (element.namespaceURI === HTML_NAMESPACE) {
46379
+ // The only way to switch from SVG to HTML is via
46380
+ // HTML integration points, and from MathML to HTML
46381
+ // is via MathML text integration points
46382
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
46383
+ return false;
46384
+ }
46385
+
46386
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
46387
+ return false;
46388
+ }
46389
+
46390
+ // Certain elements are allowed in both SVG and HTML
46391
+ // namespace. We need to specify them explicitly
46392
+ // so that they don't get erronously deleted from
46393
+ // HTML namespace.
46394
+ var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
46395
+
46396
+ // We disallow tags that are specific for MathML
46397
+ // or SVG and should never appear in HTML namespace
46398
+ return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
46399
+ }
46400
+
46401
+ // The code should never reach this place (this means
46402
+ // that the element somehow got namespace that is not
46403
+ // HTML, SVG or MathML). Return false just in case.
46404
+ return false;
46405
+ };
46406
+
46407
+ /**
46408
+ * _forceRemove
46409
+ *
46410
+ * @param {Node} node a DOM node
46411
+ */
46412
+ var _forceRemove = function _forceRemove(node) {
46413
+ arrayPush(DOMPurify.removed, { element: node });
46414
+ try {
46415
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
46416
+ node.parentNode.removeChild(node);
46417
+ } catch (_) {
46418
+ try {
46419
+ node.outerHTML = emptyHTML;
46420
+ } catch (_) {
46421
+ node.remove();
46422
+ }
46423
+ }
46424
+ };
46425
+
46426
+ /**
46427
+ * _removeAttribute
46428
+ *
46429
+ * @param {String} name an Attribute name
46430
+ * @param {Node} node a DOM node
46431
+ */
46432
+ var _removeAttribute = function _removeAttribute(name, node) {
46433
+ try {
46434
+ arrayPush(DOMPurify.removed, {
46435
+ attribute: node.getAttributeNode(name),
46436
+ from: node
46437
+ });
46438
+ } catch (_) {
46439
+ arrayPush(DOMPurify.removed, {
46440
+ attribute: null,
46441
+ from: node
46442
+ });
46443
+ }
46444
+
46445
+ node.removeAttribute(name);
46446
+
46447
+ // We void attribute values for unremovable "is"" attributes
46448
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
46449
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
46450
+ try {
46451
+ _forceRemove(node);
46452
+ } catch (_) {}
46453
+ } else {
46454
+ try {
46455
+ node.setAttribute(name, '');
46456
+ } catch (_) {}
46457
+ }
46458
+ }
46459
+ };
46460
+
46461
+ /**
46462
+ * _initDocument
46463
+ *
46464
+ * @param {String} dirty a string of dirty markup
46465
+ * @return {Document} a DOM, filled with the dirty markup
46466
+ */
46467
+ var _initDocument = function _initDocument(dirty) {
46468
+ /* Create a HTML document */
46469
+ var doc = void 0;
46470
+ var leadingWhitespace = void 0;
46471
+
46472
+ if (FORCE_BODY) {
46473
+ dirty = '<remove></remove>' + dirty;
46474
+ } else {
46475
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
46476
+ var matches = stringMatch(dirty, /^[\r\n\t ]+/);
46477
+ leadingWhitespace = matches && matches[0];
46478
+ }
46479
+
46480
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
46481
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
46482
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
46483
+ }
46484
+
46485
+ var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
46486
+ /*
46487
+ * Use the DOMParser API by default, fallback later if needs be
46488
+ * DOMParser not work for svg when has multiple root element.
46489
+ */
46490
+ if (NAMESPACE === HTML_NAMESPACE) {
46491
+ try {
46492
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
46493
+ } catch (_) {}
46494
+ }
46495
+
46496
+ /* Use createHTMLDocument in case DOMParser is not available */
46497
+ if (!doc || !doc.documentElement) {
46498
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
46499
+ try {
46500
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
46501
+ } catch (_) {
46502
+ // Syntax error if dirtyPayload is invalid xml
46503
+ }
46504
+ }
46505
+
46506
+ var body = doc.body || doc.documentElement;
46507
+
46508
+ if (dirty && leadingWhitespace) {
46509
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
46510
+ }
46511
+
46512
+ /* Work on whole document or just its body */
46513
+ if (NAMESPACE === HTML_NAMESPACE) {
46514
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
46515
+ }
46516
+
46517
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
46518
+ };
46519
+
46520
+ /**
46521
+ * _createIterator
46522
+ *
46523
+ * @param {Document} root document/fragment to create iterator for
46524
+ * @return {Iterator} iterator instance
46525
+ */
46526
+ var _createIterator = function _createIterator(root) {
46527
+ return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
46528
+ };
46529
+
46530
+ /**
46531
+ * _isClobbered
46532
+ *
46533
+ * @param {Node} elm element to check for clobbering attacks
46534
+ * @return {Boolean} true if clobbered, false if safe
46535
+ */
46536
+ var _isClobbered = function _isClobbered(elm) {
46537
+ if (elm instanceof Text || elm instanceof Comment) {
46538
+ return false;
46539
+ }
46540
+
46541
+ if (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function') {
46542
+ return true;
46543
+ }
46544
+
46545
+ return false;
46546
+ };
46547
+
46548
+ /**
46549
+ * _isNode
46550
+ *
46551
+ * @param {Node} obj object to check whether it's a DOM node
46552
+ * @return {Boolean} true is object is a DOM node
46553
+ */
46554
+ var _isNode = function _isNode(object) {
46555
+ return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
46556
+ };
46557
+
46558
+ /**
46559
+ * _executeHook
46560
+ * Execute user configurable hooks
46561
+ *
46562
+ * @param {String} entryPoint Name of the hook's entry point
46563
+ * @param {Node} currentNode node to work on with the hook
46564
+ * @param {Object} data additional hook parameters
46565
+ */
46566
+ var _executeHook = function _executeHook(entryPoint, currentNode, data) {
46567
+ if (!hooks[entryPoint]) {
46568
+ return;
46569
+ }
46570
+
46571
+ arrayForEach(hooks[entryPoint], function (hook) {
46572
+ hook.call(DOMPurify, currentNode, data, CONFIG);
46573
+ });
46574
+ };
46575
+
46576
+ /**
46577
+ * _sanitizeElements
46578
+ *
46579
+ * @protect nodeName
46580
+ * @protect textContent
46581
+ * @protect removeChild
46582
+ *
46583
+ * @param {Node} currentNode to check for permission to exist
46584
+ * @return {Boolean} true if node was killed, false if left alive
46585
+ */
46586
+ var _sanitizeElements = function _sanitizeElements(currentNode) {
46587
+ var content = void 0;
46588
+
46589
+ /* Execute a hook if present */
46590
+ _executeHook('beforeSanitizeElements', currentNode, null);
46591
+
46592
+ /* Check if element is clobbered or can clobber */
46593
+ if (_isClobbered(currentNode)) {
46594
+ _forceRemove(currentNode);
46595
+ return true;
46596
+ }
46597
+
46598
+ /* Check if tagname contains Unicode */
46599
+ if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
46600
+ _forceRemove(currentNode);
46601
+ return true;
46602
+ }
46603
+
46604
+ /* Now let's check the element's type and name */
46605
+ var tagName = transformCaseFunc(currentNode.nodeName);
46606
+
46607
+ /* Execute a hook if present */
46608
+ _executeHook('uponSanitizeElement', currentNode, {
46609
+ tagName: tagName,
46610
+ allowedTags: ALLOWED_TAGS
46611
+ });
46612
+
46613
+ /* Detect mXSS attempts abusing namespace confusion */
46614
+ if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
46615
+ _forceRemove(currentNode);
46616
+ return true;
46617
+ }
46618
+
46619
+ /* Mitigate a problem with templates inside select */
46620
+ if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
46621
+ _forceRemove(currentNode);
46622
+ return true;
46623
+ }
46624
+
46625
+ /* Remove element if anything forbids its presence */
46626
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
46627
+ /* Keep content except for bad-listed elements */
46628
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
46629
+ var parentNode = getParentNode(currentNode) || currentNode.parentNode;
46630
+ var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
46631
+
46632
+ if (childNodes && parentNode) {
46633
+ var childCount = childNodes.length;
46634
+
46635
+ for (var i = childCount - 1; i >= 0; --i) {
46636
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
46637
+ }
46638
+ }
46639
+ }
46640
+
46641
+ _forceRemove(currentNode);
46642
+ return true;
46643
+ }
46644
+
46645
+ /* Check whether element has a valid namespace */
46646
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
46647
+ _forceRemove(currentNode);
46648
+ return true;
46649
+ }
46650
+
46651
+ if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
46652
+ _forceRemove(currentNode);
46653
+ return true;
46654
+ }
46655
+
46656
+ /* Sanitize element content to be template-safe */
46657
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
46658
+ /* Get the element's text content */
46659
+ content = currentNode.textContent;
46660
+ content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
46661
+ content = stringReplace(content, ERB_EXPR$$1, ' ');
46662
+ if (currentNode.textContent !== content) {
46663
+ arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
46664
+ currentNode.textContent = content;
46665
+ }
46666
+ }
46667
+
46668
+ /* Execute a hook if present */
46669
+ _executeHook('afterSanitizeElements', currentNode, null);
46670
+
46671
+ return false;
46672
+ };
46673
+
46674
+ /**
46675
+ * _isValidAttribute
46676
+ *
46677
+ * @param {string} lcTag Lowercase tag name of containing element.
46678
+ * @param {string} lcName Lowercase attribute name.
46679
+ * @param {string} value Attribute value.
46680
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
46681
+ */
46682
+ // eslint-disable-next-line complexity
46683
+ var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
46684
+ /* Make sure attribute cannot clobber */
46685
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
46686
+ return false;
46687
+ }
46688
+
46689
+ /* Allow valid data-* attributes: At least one character after "-"
46690
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
46691
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
46692
+ We don't need to check the value; it's always URI safe. */
46693
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
46694
+ return false;
46695
+
46696
+ /* Check value is safe. First, is attr inert? If so, is safe */
46697
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else {
46698
+ return false;
46699
+ }
46700
+
46701
+ return true;
46702
+ };
46703
+
46704
+ /**
46705
+ * _sanitizeAttributes
46706
+ *
46707
+ * @protect attributes
46708
+ * @protect nodeName
46709
+ * @protect removeAttribute
46710
+ * @protect setAttribute
46711
+ *
46712
+ * @param {Node} currentNode to sanitize
46713
+ */
46714
+ var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
46715
+ var attr = void 0;
46716
+ var value = void 0;
46717
+ var lcName = void 0;
46718
+ var l = void 0;
46719
+ /* Execute a hook if present */
46720
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
46721
+
46722
+ var attributes = currentNode.attributes;
46723
+
46724
+ /* Check if we have attributes; if not we might have a text node */
46725
+
46726
+ if (!attributes) {
46727
+ return;
46728
+ }
46729
+
46730
+ var hookEvent = {
46731
+ attrName: '',
46732
+ attrValue: '',
46733
+ keepAttr: true,
46734
+ allowedAttributes: ALLOWED_ATTR
46735
+ };
46736
+ l = attributes.length;
46737
+
46738
+ /* Go backwards over all attributes; safely remove bad ones */
46739
+ while (l--) {
46740
+ attr = attributes[l];
46741
+ var _attr = attr,
46742
+ name = _attr.name,
46743
+ namespaceURI = _attr.namespaceURI;
46744
+
46745
+ value = stringTrim(attr.value);
46746
+ lcName = transformCaseFunc(name);
46747
+
46748
+ /* Execute a hook if present */
46749
+ hookEvent.attrName = lcName;
46750
+ hookEvent.attrValue = value;
46751
+ hookEvent.keepAttr = true;
46752
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
46753
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
46754
+ value = hookEvent.attrValue;
46755
+ /* Did the hooks approve of the attribute? */
46756
+ if (hookEvent.forceKeepAttr) {
46757
+ continue;
46758
+ }
46759
+
46760
+ /* Remove attribute */
46761
+ _removeAttribute(name, currentNode);
46762
+
46763
+ /* Did the hooks approve of the attribute? */
46764
+ if (!hookEvent.keepAttr) {
46765
+ continue;
46766
+ }
46767
+
46768
+ /* Work around a security issue in jQuery 3.0 */
46769
+ if (regExpTest(/\/>/i, value)) {
46770
+ _removeAttribute(name, currentNode);
46771
+ continue;
46772
+ }
46773
+
46774
+ /* Sanitize attribute content to be template-safe */
46775
+ if (SAFE_FOR_TEMPLATES) {
46776
+ value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
46777
+ value = stringReplace(value, ERB_EXPR$$1, ' ');
46778
+ }
46779
+
46780
+ /* Is `value` valid for this attribute? */
46781
+ var lcTag = transformCaseFunc(currentNode.nodeName);
46782
+ if (!_isValidAttribute(lcTag, lcName, value)) {
46783
+ continue;
46784
+ }
46785
+
46786
+ /* Handle invalid data-* attribute set by try-catching it */
46787
+ try {
46788
+ if (namespaceURI) {
46789
+ currentNode.setAttributeNS(namespaceURI, name, value);
46790
+ } else {
46791
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
46792
+ currentNode.setAttribute(name, value);
46793
+ }
46794
+
46795
+ arrayPop(DOMPurify.removed);
46796
+ } catch (_) {}
46797
+ }
46798
+
46799
+ /* Execute a hook if present */
46800
+ _executeHook('afterSanitizeAttributes', currentNode, null);
46801
+ };
46802
+
46803
+ /**
46804
+ * _sanitizeShadowDOM
46805
+ *
46806
+ * @param {DocumentFragment} fragment to iterate over recursively
46807
+ */
46808
+ var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
46809
+ var shadowNode = void 0;
46810
+ var shadowIterator = _createIterator(fragment);
46811
+
46812
+ /* Execute a hook if present */
46813
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
46814
+
46815
+ while (shadowNode = shadowIterator.nextNode()) {
46816
+ /* Execute a hook if present */
46817
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
46818
+
46819
+ /* Sanitize tags and elements */
46820
+ if (_sanitizeElements(shadowNode)) {
46821
+ continue;
46822
+ }
46823
+
46824
+ /* Deep shadow DOM detected */
46825
+ if (shadowNode.content instanceof DocumentFragment) {
46826
+ _sanitizeShadowDOM(shadowNode.content);
46827
+ }
46828
+
46829
+ /* Check attributes, sanitize if necessary */
46830
+ _sanitizeAttributes(shadowNode);
46831
+ }
46832
+
46833
+ /* Execute a hook if present */
46834
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
46835
+ };
46836
+
46837
+ /**
46838
+ * Sanitize
46839
+ * Public method providing core sanitation functionality
46840
+ *
46841
+ * @param {String|Node} dirty string or DOM node
46842
+ * @param {Object} configuration object
46843
+ */
46844
+ // eslint-disable-next-line complexity
46845
+ DOMPurify.sanitize = function (dirty, cfg) {
46846
+ var body = void 0;
46847
+ var importedNode = void 0;
46848
+ var currentNode = void 0;
46849
+ var oldNode = void 0;
46850
+ var returnNode = void 0;
46851
+ /* Make sure we have a string to sanitize.
46852
+ DO NOT return early, as this will return the wrong type if
46853
+ the user has requested a DOM object rather than a string */
46854
+ IS_EMPTY_INPUT = !dirty;
46855
+ if (IS_EMPTY_INPUT) {
46856
+ dirty = '<!-->';
46857
+ }
46858
+
46859
+ /* Stringify, in case dirty is an object */
46860
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
46861
+ // eslint-disable-next-line no-negated-condition
46862
+ if (typeof dirty.toString !== 'function') {
46863
+ throw typeErrorCreate('toString is not a function');
46864
+ } else {
46865
+ dirty = dirty.toString();
46866
+ if (typeof dirty !== 'string') {
46867
+ throw typeErrorCreate('dirty is not a string, aborting');
46868
+ }
46869
+ }
46870
+ }
46871
+
46872
+ /* Check we can run. Otherwise fall back or ignore */
46873
+ if (!DOMPurify.isSupported) {
46874
+ if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
46875
+ if (typeof dirty === 'string') {
46876
+ return window.toStaticHTML(dirty);
46877
+ }
46878
+
46879
+ if (_isNode(dirty)) {
46880
+ return window.toStaticHTML(dirty.outerHTML);
46881
+ }
46882
+ }
46883
+
46884
+ return dirty;
46885
+ }
46886
+
46887
+ /* Assign config vars */
46888
+ if (!SET_CONFIG) {
46889
+ _parseConfig(cfg);
46890
+ }
46891
+
46892
+ /* Clean up removed elements */
46893
+ DOMPurify.removed = [];
46894
+
46895
+ /* Check if dirty is correctly typed for IN_PLACE */
46896
+ if (typeof dirty === 'string') {
46897
+ IN_PLACE = false;
46898
+ }
46899
+
46900
+ if (IN_PLACE) ; else if (dirty instanceof Node) {
46901
+ /* If dirty is a DOM element, append to an empty document to avoid
46902
+ elements being stripped by the parser */
46903
+ body = _initDocument('<!---->');
46904
+ importedNode = body.ownerDocument.importNode(dirty, true);
46905
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
46906
+ /* Node is already a body, use as is */
46907
+ body = importedNode;
46908
+ } else if (importedNode.nodeName === 'HTML') {
46909
+ body = importedNode;
46910
+ } else {
46911
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
46912
+ body.appendChild(importedNode);
46913
+ }
46914
+ } else {
46915
+ /* Exit directly if we have nothing to do */
46916
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
46917
+ // eslint-disable-next-line unicorn/prefer-includes
46918
+ dirty.indexOf('<') === -1) {
46919
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
46920
+ }
46921
+
46922
+ /* Initialize the document to work on */
46923
+ body = _initDocument(dirty);
46924
+
46925
+ /* Check we have a DOM node from the data */
46926
+ if (!body) {
46927
+ return RETURN_DOM ? null : emptyHTML;
46928
+ }
46929
+ }
46930
+
46931
+ /* Remove first element node (ours) if FORCE_BODY is set */
46932
+ if (body && FORCE_BODY) {
46933
+ _forceRemove(body.firstChild);
46934
+ }
46935
+
46936
+ /* Get node iterator */
46937
+ var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
46938
+
46939
+ /* Now start iterating over the created document */
46940
+ while (currentNode = nodeIterator.nextNode()) {
46941
+ /* Fix IE's strange behavior with manipulated textNodes #89 */
46942
+ if (currentNode.nodeType === 3 && currentNode === oldNode) {
46943
+ continue;
46944
+ }
46945
+
46946
+ /* Sanitize tags and elements */
46947
+ if (_sanitizeElements(currentNode)) {
46948
+ continue;
46949
+ }
46950
+
46951
+ /* Shadow DOM detected, sanitize it */
46952
+ if (currentNode.content instanceof DocumentFragment) {
46953
+ _sanitizeShadowDOM(currentNode.content);
46954
+ }
46955
+
46956
+ /* Check attributes, sanitize if necessary */
46957
+ _sanitizeAttributes(currentNode);
46958
+
46959
+ oldNode = currentNode;
46960
+ }
46961
+
46962
+ oldNode = null;
46963
+
46964
+ /* If we sanitized `dirty` in-place, return it. */
46965
+ if (IN_PLACE) {
46966
+ return dirty;
46967
+ }
46968
+
46969
+ /* Return sanitized string or DOM */
46970
+ if (RETURN_DOM) {
46971
+ if (RETURN_DOM_FRAGMENT) {
46972
+ returnNode = createDocumentFragment.call(body.ownerDocument);
46973
+
46974
+ while (body.firstChild) {
46975
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
46976
+ returnNode.appendChild(body.firstChild);
46977
+ }
46978
+ } else {
46979
+ returnNode = body;
46980
+ }
46981
+
46982
+ if (RETURN_DOM_IMPORT) {
46983
+ /*
46984
+ AdoptNode() is not used because internal state is not reset
46985
+ (e.g. the past names map of a HTMLFormElement), this is safe
46986
+ in theory but we would rather not risk another attack vector.
46987
+ The state that is cloned by importNode() is explicitly defined
46988
+ by the specs.
46989
+ */
46990
+ returnNode = importNode.call(originalDocument, returnNode, true);
46991
+ }
46992
+
46993
+ return returnNode;
46994
+ }
46995
+
46996
+ var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
46997
+
46998
+ /* Sanitize final string template-safe */
46999
+ if (SAFE_FOR_TEMPLATES) {
47000
+ serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
47001
+ serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
47002
+ }
47003
+
47004
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
47005
+ };
47006
+
47007
+ /**
47008
+ * Public method to set the configuration once
47009
+ * setConfig
47010
+ *
47011
+ * @param {Object} cfg configuration object
47012
+ */
47013
+ DOMPurify.setConfig = function (cfg) {
47014
+ _parseConfig(cfg);
47015
+ SET_CONFIG = true;
47016
+ };
47017
+
47018
+ /**
47019
+ * Public method to remove the configuration
47020
+ * clearConfig
47021
+ *
47022
+ */
47023
+ DOMPurify.clearConfig = function () {
47024
+ CONFIG = null;
47025
+ SET_CONFIG = false;
47026
+ };
47027
+
47028
+ /**
47029
+ * Public method to check if an attribute value is valid.
47030
+ * Uses last set config, if any. Otherwise, uses config defaults.
47031
+ * isValidAttribute
47032
+ *
47033
+ * @param {string} tag Tag name of containing element.
47034
+ * @param {string} attr Attribute name.
47035
+ * @param {string} value Attribute value.
47036
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
47037
+ */
47038
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
47039
+ /* Initialize shared config vars if necessary. */
47040
+ if (!CONFIG) {
47041
+ _parseConfig({});
47042
+ }
47043
+
47044
+ var lcTag = transformCaseFunc(tag);
47045
+ var lcName = transformCaseFunc(attr);
47046
+ return _isValidAttribute(lcTag, lcName, value);
47047
+ };
47048
+
47049
+ /**
47050
+ * AddHook
47051
+ * Public method to add DOMPurify hooks
47052
+ *
47053
+ * @param {String} entryPoint entry point for the hook to add
47054
+ * @param {Function} hookFunction function to execute
47055
+ */
47056
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
47057
+ if (typeof hookFunction !== 'function') {
47058
+ return;
47059
+ }
47060
+
47061
+ hooks[entryPoint] = hooks[entryPoint] || [];
47062
+ arrayPush(hooks[entryPoint], hookFunction);
47063
+ };
47064
+
47065
+ /**
47066
+ * RemoveHook
47067
+ * Public method to remove a DOMPurify hook at a given entryPoint
47068
+ * (pops it from the stack of hooks if more are present)
47069
+ *
47070
+ * @param {String} entryPoint entry point for the hook to remove
47071
+ */
47072
+ DOMPurify.removeHook = function (entryPoint) {
47073
+ if (hooks[entryPoint]) {
47074
+ arrayPop(hooks[entryPoint]);
47075
+ }
47076
+ };
47077
+
47078
+ /**
47079
+ * RemoveHooks
47080
+ * Public method to remove all DOMPurify hooks at a given entryPoint
47081
+ *
47082
+ * @param {String} entryPoint entry point for the hooks to remove
47083
+ */
47084
+ DOMPurify.removeHooks = function (entryPoint) {
47085
+ if (hooks[entryPoint]) {
47086
+ hooks[entryPoint] = [];
47087
+ }
47088
+ };
47089
+
47090
+ /**
47091
+ * RemoveAllHooks
47092
+ * Public method to remove all DOMPurify hooks
47093
+ *
47094
+ */
47095
+ DOMPurify.removeAllHooks = function () {
47096
+ hooks = {};
47097
+ };
47098
+
47099
+ return DOMPurify;
47100
+ }
47101
+
47102
+ var purify = createDOMPurify();
47103
+
47104
+ return purify;
47105
+
47106
+ }));
47107
+
47108
+
47109
+ },{}],290:[function(require,module,exports){
45710
47110
  /* jshint node: true */
45711
47111
  'use strict';
45712
47112
 
@@ -45814,7 +47214,7 @@ var freeice = function(opts) {
45814
47214
  };
45815
47215
 
45816
47216
  module.exports = freeice;
45817
- },{"./stun.json":290,"./turn.json":291,"normalice":299}],290:[function(require,module,exports){
47217
+ },{"./stun.json":291,"./turn.json":292,"normalice":300}],291:[function(require,module,exports){
45818
47218
  module.exports=[
45819
47219
  "stun.l.google.com:19302",
45820
47220
  "stun1.l.google.com:19302",
@@ -45831,10 +47231,10 @@ module.exports=[
45831
47231
  "stun.voxgratia.org"
45832
47232
  ]
45833
47233
 
45834
- },{}],291:[function(require,module,exports){
47234
+ },{}],292:[function(require,module,exports){
45835
47235
  module.exports=[]
45836
47236
 
45837
- },{}],292:[function(require,module,exports){
47237
+ },{}],293:[function(require,module,exports){
45838
47238
  var WildEmitter = require('wildemitter');
45839
47239
 
45840
47240
  function getMaxVolume (analyser, fftBins) {
@@ -45979,9 +47379,9 @@ module.exports = function(stream, options) {
45979
47379
  return harker;
45980
47380
  }
45981
47381
 
45982
- },{"wildemitter":328}],293:[function(require,module,exports){
47382
+ },{"wildemitter":329}],294:[function(require,module,exports){
45983
47383
  arguments[4][132][0].apply(exports,arguments)
45984
- },{"dup":132}],294:[function(require,module,exports){
47384
+ },{"dup":132}],295:[function(require,module,exports){
45985
47385
  (function (global){(function (){
45986
47386
  // https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js
45987
47387
 
@@ -46002,10 +47402,10 @@ if (typeof WebSocket !== 'undefined') {
46002
47402
  module.exports = ws
46003
47403
 
46004
47404
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
46005
- },{}],295:[function(require,module,exports){
47405
+ },{}],296:[function(require,module,exports){
46006
47406
  // Does nothing at all.
46007
47407
 
46008
- },{}],296:[function(require,module,exports){
47408
+ },{}],297:[function(require,module,exports){
46009
47409
  /*
46010
47410
  * (C) Copyright 2014-2015 Kurento (http://kurento.org/)
46011
47411
  *
@@ -46926,7 +48326,7 @@ exports.WebRtcPeerSendonly = WebRtcPeerSendonly
46926
48326
  exports.WebRtcPeerSendrecv = WebRtcPeerSendrecv
46927
48327
  exports.hark = harkUtils
46928
48328
 
46929
- },{"events":100,"freeice":289,"hark":292,"inherits":293,"kurento-browser-extensions":295,"merge":298,"sdp-translator":308,"ua-parser-js":313,"uuid/v4":316}],297:[function(require,module,exports){
48329
+ },{"events":100,"freeice":290,"hark":293,"inherits":294,"kurento-browser-extensions":296,"merge":299,"sdp-translator":309,"ua-parser-js":314,"uuid/v4":317}],298:[function(require,module,exports){
46930
48330
  /*
46931
48331
  * (C) Copyright 2014 Kurento (http://kurento.org/)
46932
48332
  *
@@ -46958,7 +48358,7 @@ var WebRtcPeer = require('./WebRtcPeer');
46958
48358
 
46959
48359
  exports.WebRtcPeer = WebRtcPeer;
46960
48360
 
46961
- },{"./WebRtcPeer":296}],298:[function(require,module,exports){
48361
+ },{"./WebRtcPeer":297}],299:[function(require,module,exports){
46962
48362
  /*!
46963
48363
  * @name JavaScript/NodeJS Merge v1.2.1
46964
48364
  * @author yeikos
@@ -47136,7 +48536,7 @@ exports.WebRtcPeer = WebRtcPeer;
47136
48536
  }
47137
48537
 
47138
48538
  })(typeof module === 'object' && module && typeof module.exports === 'object' && module.exports);
47139
- },{}],299:[function(require,module,exports){
48539
+ },{}],300:[function(require,module,exports){
47140
48540
  /**
47141
48541
  # normalice
47142
48542
 
@@ -47198,7 +48598,7 @@ module.exports = function(input) {
47198
48598
  return output;
47199
48599
  };
47200
48600
 
47201
- },{}],300:[function(require,module,exports){
48601
+ },{}],301:[function(require,module,exports){
47202
48602
  (function () {
47203
48603
  /*
47204
48604
  * Async module to handle async messaging
@@ -47911,7 +49311,7 @@ module.exports = function(input) {
47911
49311
  }
47912
49312
  })();
47913
49313
 
47914
- },{"../utility/utility.js":302,"./socket.js":301}],301:[function(require,module,exports){
49314
+ },{"../utility/utility.js":303,"./socket.js":302}],302:[function(require,module,exports){
47915
49315
  (function() {
47916
49316
  /*
47917
49317
  * Socket Module to connect and handle Socket functionalities
@@ -48132,7 +49532,7 @@ module.exports = function(input) {
48132
49532
 
48133
49533
  })();
48134
49534
 
48135
- },{"isomorphic-ws":294}],302:[function(require,module,exports){
49535
+ },{"isomorphic-ws":295}],303:[function(require,module,exports){
48136
49536
  (function (global){(function (){
48137
49537
  (function() {
48138
49538
  /**
@@ -48360,7 +49760,7 @@ module.exports = function(input) {
48360
49760
  })();
48361
49761
 
48362
49762
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
48363
- },{}],303:[function(require,module,exports){
49763
+ },{}],304:[function(require,module,exports){
48364
49764
  var grammar = module.exports = {
48365
49765
  v: [{
48366
49766
  name: 'version',
@@ -48619,7 +50019,7 @@ Object.keys(grammar).forEach(function (key) {
48619
50019
  });
48620
50020
  });
48621
50021
 
48622
- },{}],304:[function(require,module,exports){
50022
+ },{}],305:[function(require,module,exports){
48623
50023
  var parser = require('./parser');
48624
50024
  var writer = require('./writer');
48625
50025
 
@@ -48629,7 +50029,7 @@ exports.parseFmtpConfig = parser.parseFmtpConfig;
48629
50029
  exports.parsePayloads = parser.parsePayloads;
48630
50030
  exports.parseRemoteCandidates = parser.parseRemoteCandidates;
48631
50031
 
48632
- },{"./parser":305,"./writer":306}],305:[function(require,module,exports){
50032
+ },{"./parser":306,"./writer":307}],306:[function(require,module,exports){
48633
50033
  var toIntIfInt = function (v) {
48634
50034
  return String(Number(v)) === v ? Number(v) : v;
48635
50035
  };
@@ -48724,7 +50124,7 @@ exports.parseRemoteCandidates = function (str) {
48724
50124
  return candidates;
48725
50125
  };
48726
50126
 
48727
- },{"./grammar":303}],306:[function(require,module,exports){
50127
+ },{"./grammar":304}],307:[function(require,module,exports){
48728
50128
  var grammar = require('./grammar');
48729
50129
 
48730
50130
  // customized util.format - discards excess arguments and can void middle ones
@@ -48840,7 +50240,7 @@ module.exports = function (session, opts) {
48840
50240
  return sdp.join('\r\n') + '\r\n';
48841
50241
  };
48842
50242
 
48843
- },{"./grammar":303}],307:[function(require,module,exports){
50243
+ },{"./grammar":304}],308:[function(require,module,exports){
48844
50244
  /* Copyright @ 2015 Atlassian Pty Ltd
48845
50245
  *
48846
50246
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -48881,7 +50281,7 @@ module.exports = function arrayEquals(array) {
48881
50281
  };
48882
50282
 
48883
50283
 
48884
- },{}],308:[function(require,module,exports){
50284
+ },{}],309:[function(require,module,exports){
48885
50285
  /* Copyright @ 2015 Atlassian Pty Ltd
48886
50286
  *
48887
50287
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -48899,7 +50299,7 @@ module.exports = function arrayEquals(array) {
48899
50299
 
48900
50300
  exports.Interop = require('./interop');
48901
50301
 
48902
- },{"./interop":309}],309:[function(require,module,exports){
50302
+ },{"./interop":310}],310:[function(require,module,exports){
48903
50303
  /* Copyright @ 2015 Atlassian Pty Ltd
48904
50304
  *
48905
50305
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -49784,7 +51184,7 @@ Interop.prototype.toUnifiedPlan = function(desc) {
49784
51184
  //#endregion
49785
51185
  };
49786
51186
 
49787
- },{"./array-equals":307,"./transform":310}],310:[function(require,module,exports){
51187
+ },{"./array-equals":308,"./transform":311}],311:[function(require,module,exports){
49788
51188
  /* Copyright @ 2015 Atlassian Pty Ltd
49789
51189
  *
49790
51190
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -49898,7 +51298,7 @@ exports.parse = function(sdp) {
49898
51298
  };
49899
51299
 
49900
51300
 
49901
- },{"sdp-transform":304}],311:[function(require,module,exports){
51301
+ },{"sdp-transform":305}],312:[function(require,module,exports){
49902
51302
  /* eslint-env node */
49903
51303
  'use strict';
49904
51304
 
@@ -50659,7 +52059,7 @@ SDPUtils.isValidSDP = function (blob) {
50659
52059
  if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') {
50660
52060
  module.exports = SDPUtils;
50661
52061
  }
50662
- },{}],312:[function(require,module,exports){
52062
+ },{}],313:[function(require,module,exports){
50663
52063
  (function (global){(function (){
50664
52064
  /*! *****************************************************************************
50665
52065
  Copyright (c) Microsoft Corporation.
@@ -50947,7 +52347,7 @@ var __createBinding;
50947
52347
  });
50948
52348
 
50949
52349
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
50950
- },{}],313:[function(require,module,exports){
52350
+ },{}],314:[function(require,module,exports){
50951
52351
  /*!
50952
52352
  * UAParser.js v0.7.24
50953
52353
  * Lightweight JavaScript-based User-Agent string parser
@@ -51886,7 +53286,7 @@ var __createBinding;
51886
53286
 
51887
53287
  })(typeof window === 'object' ? window : this);
51888
53288
 
51889
- },{}],314:[function(require,module,exports){
53289
+ },{}],315:[function(require,module,exports){
51890
53290
  /**
51891
53291
  * Convert array of 16 byte values to UUID string format of the form:
51892
53292
  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
@@ -51914,7 +53314,7 @@ function bytesToUuid(buf, offset) {
51914
53314
 
51915
53315
  module.exports = bytesToUuid;
51916
53316
 
51917
- },{}],315:[function(require,module,exports){
53317
+ },{}],316:[function(require,module,exports){
51918
53318
  // Unique ID creation requires a high quality random # generator. In the
51919
53319
  // browser this is a little complicated due to unknown quality of Math.random()
51920
53320
  // and inconsistent support for the `crypto` API. We do the best we can via
@@ -51950,7 +53350,7 @@ if (getRandomValues) {
51950
53350
  };
51951
53351
  }
51952
53352
 
51953
- },{}],316:[function(require,module,exports){
53353
+ },{}],317:[function(require,module,exports){
51954
53354
  var rng = require('./lib/rng');
51955
53355
  var bytesToUuid = require('./lib/bytesToUuid');
51956
53356
 
@@ -51981,7 +53381,7 @@ function v4(options, buf, offset) {
51981
53381
 
51982
53382
  module.exports = v4;
51983
53383
 
51984
- },{"./lib/bytesToUuid":314,"./lib/rng":315}],317:[function(require,module,exports){
53384
+ },{"./lib/bytesToUuid":315,"./lib/rng":316}],318:[function(require,module,exports){
51985
53385
  /*
51986
53386
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
51987
53387
  *
@@ -52002,7 +53402,7 @@ var _adapter_factory = require('./adapter_factory.js');
52002
53402
  var adapter = (0, _adapter_factory.adapterFactory)({ window: typeof window === 'undefined' ? undefined : window });
52003
53403
  exports.default = adapter;
52004
53404
 
52005
- },{"./adapter_factory.js":318}],318:[function(require,module,exports){
53405
+ },{"./adapter_factory.js":319}],319:[function(require,module,exports){
52006
53406
  'use strict';
52007
53407
 
52008
53408
  Object.defineProperty(exports, "__esModule", {
@@ -52167,7 +53567,7 @@ function adapterFactory() {
52167
53567
 
52168
53568
  // Browser shims.
52169
53569
 
52170
- },{"./chrome/chrome_shim":319,"./common_shim":322,"./firefox/firefox_shim":323,"./safari/safari_shim":326,"./utils":327,"sdp":311}],319:[function(require,module,exports){
53570
+ },{"./chrome/chrome_shim":320,"./common_shim":323,"./firefox/firefox_shim":324,"./safari/safari_shim":327,"./utils":328,"sdp":312}],320:[function(require,module,exports){
52171
53571
  /*
52172
53572
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
52173
53573
  *
@@ -52916,7 +54316,7 @@ function fixNegotiationNeeded(window, browserDetails) {
52916
54316
  });
52917
54317
  }
52918
54318
 
52919
- },{"../utils.js":327,"./getdisplaymedia":320,"./getusermedia":321}],320:[function(require,module,exports){
54319
+ },{"../utils.js":328,"./getdisplaymedia":321,"./getusermedia":322}],321:[function(require,module,exports){
52920
54320
  /*
52921
54321
  * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
52922
54322
  *
@@ -52967,7 +54367,7 @@ function shimGetDisplayMedia(window, getSourceId) {
52967
54367
  };
52968
54368
  }
52969
54369
 
52970
- },{}],321:[function(require,module,exports){
54370
+ },{}],322:[function(require,module,exports){
52971
54371
  /*
52972
54372
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
52973
54373
  *
@@ -53172,7 +54572,7 @@ function shimGetUserMedia(window, browserDetails) {
53172
54572
  }
53173
54573
  }
53174
54574
 
53175
- },{"../utils.js":327}],322:[function(require,module,exports){
54575
+ },{"../utils.js":328}],323:[function(require,module,exports){
53176
54576
  /*
53177
54577
  * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
53178
54578
  *
@@ -53560,7 +54960,7 @@ function shimAddIceCandidateNullOrEmpty(window, browserDetails) {
53560
54960
  };
53561
54961
  }
53562
54962
 
53563
- },{"./utils":327,"sdp":311}],323:[function(require,module,exports){
54963
+ },{"./utils":328,"sdp":312}],324:[function(require,module,exports){
53564
54964
  /*
53565
54965
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
53566
54966
  *
@@ -53895,7 +55295,7 @@ function shimCreateAnswer(window) {
53895
55295
  };
53896
55296
  }
53897
55297
 
53898
- },{"../utils":327,"./getdisplaymedia":324,"./getusermedia":325}],324:[function(require,module,exports){
55298
+ },{"../utils":328,"./getdisplaymedia":325,"./getusermedia":326}],325:[function(require,module,exports){
53899
55299
  /*
53900
55300
  * Copyright (c) 2018 The adapter.js project authors. All Rights Reserved.
53901
55301
  *
@@ -53934,7 +55334,7 @@ function shimGetDisplayMedia(window, preferredMediaSource) {
53934
55334
  };
53935
55335
  }
53936
55336
 
53937
- },{}],325:[function(require,module,exports){
55337
+ },{}],326:[function(require,module,exports){
53938
55338
  /*
53939
55339
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
53940
55340
  *
@@ -54011,7 +55411,7 @@ function shimGetUserMedia(window, browserDetails) {
54011
55411
  }
54012
55412
  }
54013
55413
 
54014
- },{"../utils":327}],326:[function(require,module,exports){
55414
+ },{"../utils":328}],327:[function(require,module,exports){
54015
55415
  /*
54016
55416
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
54017
55417
  *
@@ -54380,7 +55780,7 @@ function shimAudioContext(window) {
54380
55780
  window.AudioContext = window.webkitAudioContext;
54381
55781
  }
54382
55782
 
54383
- },{"../utils":327}],327:[function(require,module,exports){
55783
+ },{"../utils":328}],328:[function(require,module,exports){
54384
55784
  /*
54385
55785
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
54386
55786
  *
@@ -54651,7 +56051,7 @@ function filterStats(result, track, outbound) {
54651
56051
  return filteredResult;
54652
56052
  }
54653
56053
 
54654
- },{}],328:[function(require,module,exports){
56054
+ },{}],329:[function(require,module,exports){
54655
56055
  /*
54656
56056
  WildEmitter.js is a slim little event emitter by @henrikjoreteg largely based
54657
56057
  on @visionmedia's Emitter from UI Kit.
@@ -54808,7 +56208,7 @@ WildEmitter.mixin = function (constructor) {
54808
56208
 
54809
56209
  WildEmitter.mixin(WildEmitter);
54810
56210
 
54811
- },{}],329:[function(require,module,exports){
56211
+ },{}],330:[function(require,module,exports){
54812
56212
  (function () {
54813
56213
  /**
54814
56214
  * Global Variables
@@ -54828,6 +56228,7 @@ WildEmitter.mixin(WildEmitter);
54828
56228
 
54829
56229
 
54830
56230
  var Utility = params.Utility,
56231
+ currentModuleInstance = this,
54831
56232
  Sentry = params.Sentry,
54832
56233
  asyncClient = params.asyncClient,
54833
56234
  chatEvents = params.chatEvents,
@@ -54940,6 +56341,7 @@ WildEmitter.mixin(WildEmitter);
54940
56341
  START_SCREEN_SHARE: 123,
54941
56342
  END_SCREEN_SHARE: 124,
54942
56343
  DELETE_FROM_CALL_HISTORY: 125,
56344
+ DESTINATED_RECORD_CALL: 126,
54943
56345
  MUTUAL_GROUPS: 130,
54944
56346
  CREATE_TAG: 140,
54945
56347
  EDIT_TAG: 141,
@@ -54948,6 +56350,7 @@ WildEmitter.mixin(WildEmitter);
54948
56350
  REMOVE_TAG_PARTICIPANT: 144,
54949
56351
  GET_TAG_LIST: 145,
54950
56352
  DELETE_MESSAGE_THREAD: 151,
56353
+ EXPORT_CHAT: 152,
54951
56354
  ERROR: 999
54952
56355
  },
54953
56356
  inviteeVOidTypes = {
@@ -54999,20 +56402,25 @@ WildEmitter.mixin(WildEmitter);
54999
56402
  currentCallId = null,
55000
56403
  shouldReconnectCallTimeout = null,
55001
56404
  callTopics = {},
56405
+ screenShareState = {
56406
+ started: false,
56407
+ imOwner: false
56408
+ },
55002
56409
  callClientType = {
55003
56410
  WEB: 1,
55004
56411
  ANDROID: 2,
55005
56412
  DESKTOP: 3
55006
56413
  },
55007
56414
  webpeers = {},
56415
+ callUsers = {},
55008
56416
  webpeersMetadata = {},
55009
56417
  callRequestController = {
55010
56418
  callRequestReceived: false,
55011
56419
  callEstablishedInMySide: false,
55012
56420
  iCanAcceptTheCall: function () {
55013
56421
  return callRequestController.callRequestReceived && callRequestController.callEstablishedInMySide;
55014
-
55015
- }
56422
+ },
56423
+ cameraPaused: true
55016
56424
  },
55017
56425
  uiRemoteMedias = {},
55018
56426
  callStopQueue = {
@@ -55246,7 +56654,7 @@ WildEmitter.mixin(WildEmitter);
55246
56654
  },
55247
56655
 
55248
56656
  endCall = function (params, callback) {
55249
- consoleLogging && console.log('endCall called...');
56657
+ consoleLogging && console.log('[SDK][endCall] called...');
55250
56658
 
55251
56659
  var endCallData = {
55252
56660
  chatMessageVOType: chatMessageVOTypes.END_CALL_REQUEST,
@@ -55285,6 +56693,7 @@ WildEmitter.mixin(WildEmitter);
55285
56693
  }
55286
56694
  });
55287
56695
  },
56696
+
55288
56697
  /*
55289
56698
  * Call Functionalities
55290
56699
  */
@@ -55292,25 +56701,36 @@ WildEmitter.mixin(WildEmitter);
55292
56701
  if (callDivId) {
55293
56702
  var callParentDiv,
55294
56703
  callVideo = (typeof params.video === 'boolean') ? params.video : true,
55295
- callMute = (typeof params.mute === 'boolean') ? params.mute : false,
55296
- sendingTopic = params.sendingTopic,
55297
- receiveTopic = params.receiveTopic;
56704
+ callMute = (typeof params.mute === 'boolean') ? params.mute : false;
56705
+ //sendingTopic = params.sendingTopic,
56706
+ //receiveTopic = params.receiveTopic;
56707
+
56708
+ if(params.clientsList && params.clientsList.length) {
56709
+ for(var i in params.clientsList) {
56710
+ callStateController.setupCallParticipant(params.clientsList[i]);
56711
+ //callStateController.callUsers.push(params.clientsList[i]);
56712
+ }
56713
+ }
56714
+
56715
+ callStateController.setupScreenSharingObject(params.screenShare);
55298
56716
 
55299
- callTopics['sendVideoTopic'] = 'Vi-' + sendingTopic;
56717
+ /*callTopics['sendVideoTopic'] = 'Vi-' + sendingTopic;
55300
56718
  callTopics['sendAudioTopic'] = 'Vo-' + sendingTopic;
56719
+ callTopics['screenShare'] = params.screenShare;
55301
56720
  //callTopics['receiveVideoTopic'] = 'Vi-' + receiveTopic;
55302
56721
  //callTopics['receiveAudioTopic'] = 'Vo-' + receiveTopic;
55303
56722
  callTopics['receive'] = [];
55304
56723
  callTopics['receive'].push({
55305
56724
  "VideoTopic": 'Vi-' + receiveTopic,
55306
56725
  "AudioTopic": 'Vo-' + receiveTopic
55307
- });
56726
+ });*/
55308
56727
 
55309
- webpeersMetadata[callTopics['sendVideoTopic']] = {
56728
+ /*webpeersMetadata[callTopics['sendVideoTopic']] = {
55310
56729
  interval: null,
55311
56730
  receivedSdpAnswer: false,
55312
56731
  connectionQualityInterval: null,
55313
56732
  poorConnectionCount: 0,
56733
+ poorConnectionResolvedCount: 0,
55314
56734
  isConnectionPoor: false
55315
56735
  };
55316
56736
  webpeersMetadata[callTopics['sendAudioTopic']] = {
@@ -55318,6 +56738,15 @@ WildEmitter.mixin(WildEmitter);
55318
56738
  receivedSdpAnswer: false,
55319
56739
  connectionQualityInterval: null,
55320
56740
  poorConnectionCount: 0,
56741
+ poorConnectionResolvedCount: 0,
56742
+ isConnectionPoor: false
56743
+ };
56744
+ webpeersMetadata[callTopics['screenShare']] = {
56745
+ interval: null,
56746
+ receivedSdpAnswer: false,
56747
+ connectionQualityInterval: null,
56748
+ poorConnectionCount: 0,
56749
+ poorConnectionResolvedCount: 0,
55321
56750
  isConnectionPoor: false
55322
56751
  };
55323
56752
 
@@ -55330,11 +56759,11 @@ WildEmitter.mixin(WildEmitter);
55330
56759
  interval: null,
55331
56760
  receivedSdpAnswer: false
55332
56761
  };
55333
- }
56762
+ }*/
55334
56763
 
55335
- callParentDiv = document.getElementById(callDivId);
56764
+ //callParentDiv = document.getElementById(callDivId);
55336
56765
 
55337
- // Local Video Tag
56766
+ /*// Local Video Tag
55338
56767
  if (callVideo && !uiRemoteMedias[callTopics['sendVideoTopic']]) {
55339
56768
  uiRemoteMedias[callTopics['sendVideoTopic']] = document.createElement('video');
55340
56769
  var el = uiRemoteMedias[callTopics['sendVideoTopic']];
@@ -55380,10 +56809,11 @@ WildEmitter.mixin(WildEmitter);
55380
56809
  callMute && el.setAttribute('muted', '');
55381
56810
  el.setAttribute('controls', '');
55382
56811
  }
55383
- }
56812
+ }*/
55384
56813
 
55385
- var uiRemoteElements = [];
55386
- for(var i in callTopics['receive']) {
56814
+ callback && callback(generateCallUIList());
56815
+
56816
+ /*for(var i in callTopics['receive']) {
55387
56817
  uiRemoteElements.push(uiRemoteMedias[callTopics['receive'][i]['AudioTopic']])
55388
56818
  callVideo && uiRemoteElements.push(uiRemoteMedias[callTopics['receive'][i]['VideoTopic']])
55389
56819
  }
@@ -55404,18 +56834,19 @@ WildEmitter.mixin(WildEmitter);
55404
56834
  'uiLocalVideo': uiRemoteMedias[callTopics['sendVideoTopic']],
55405
56835
  'uiLocalAudio': uiRemoteMedias[callTopics['sendAudioTopic']],
55406
56836
  uiRemoteElements: uiRemoteElements
55407
- /* 'uiRemoteVideo': uiRemoteMedias[callTopics['receiveVideoTopic']],
55408
- 'uiRemoteAudio': uiRemoteMedias[callTopics['receiveAudioTopic']]*/
56837
+ /!* 'uiRemoteVideo': uiRemoteMedias[callTopics['receiveVideoTopic']],
56838
+ 'uiRemoteAudio': uiRemoteMedias[callTopics['receiveAudioTopic']]*!/
55409
56839
  });
55410
56840
  } else {
55411
56841
  callback && callback({
55412
56842
  'uiLocalVideo': uiRemoteMedias[callTopics['sendVideoTopic']],
55413
56843
  'uiLocalAudio': uiRemoteMedias[callTopics['sendAudioTopic']],
55414
56844
  uiRemoteElements: uiRemoteElements
55415
- /*'uiRemoteVideo': uiRemoteMedias[callTopics['receiveVideoTopic']],
55416
- 'uiRemoteAudio': uiRemoteMedias[callTopics['receiveAudioTopic']]*/
56845
+ /!*'uiRemoteVideo': uiRemoteMedias[callTopics['receiveVideoTopic']],
56846
+ 'uiRemoteAudio': uiRemoteMedias[callTopics['receiveAudioTopic']]*!/
55417
56847
  });
55418
- }
56848
+ }*/
56849
+
55419
56850
 
55420
56851
  callStateController.createSessionInChat(Object.assign(params, {
55421
56852
  callVideo: callVideo,
@@ -55440,6 +56871,26 @@ WildEmitter.mixin(WildEmitter);
55440
56871
  }
55441
56872
  },
55442
56873
 
56874
+ generateCallUIList = function () {
56875
+ var me = chatMessaging.userInfo.Id;
56876
+ var callUIElements = {};
56877
+ for(var i in callUsers) {
56878
+ callUIElements[i] = {
56879
+ container: callUsers[i].htmlElements.container,
56880
+ video: callUsers[i].htmlElements[callUsers[i].videoTopicName],
56881
+ audio: callUsers[i].htmlElements[callUsers[i].audioTopicName]
56882
+ }
56883
+
56884
+ /* callUIElements[i].container = callUsers[i].htmlElements.container;
56885
+ callUIElements[i].video = callUsers[i].htmlElements[callUsers[i].videoTopicName];
56886
+ callUIElements[i].audio = callUsers[i].htmlElements[callUsers[i].audioTopicName];
56887
+ */
56888
+ //callUIElements[i] = callUsers[i].htmlElements;
56889
+ }
56890
+ return {
56891
+ uiElements: callUIElements,
56892
+ };
56893
+ },
55443
56894
 
55444
56895
  /*handleCallSocketOpen = function (params) {
55445
56896
  currentCallParams = params;
@@ -55468,6 +56919,7 @@ WildEmitter.mixin(WildEmitter);
55468
56919
  createSessionInChat: function (params) {
55469
56920
  currentCallParams = params;
55470
56921
  var callController = this;
56922
+ consoleLogging && console.log("createSessionInChat:inside", params);
55471
56923
  sendCallMessage({
55472
56924
  id: 'CREATE_SESSION',
55473
56925
  brokerAddress: params.brokerAddress,
@@ -55494,18 +56946,144 @@ WildEmitter.mixin(WildEmitter);
55494
56946
  */
55495
56947
  startCall: function (params) {
55496
56948
  var callController = this;
55497
- if (params.callVideo) {
55498
- this.startParticipantVideo(callTopics['receive'][0]['VideoTopic'], 'receive');
55499
- setTimeout(function (){
55500
- callController.startMyVideo();
55501
- }, 2000);
56949
+ for(var i in callUsers) {
56950
+ if(i === 'screenShare')
56951
+ continue;
56952
+
56953
+ if(callUsers[i].video) {
56954
+ callController.startParticipantVideo(i);
56955
+ }
56956
+ if(!callUsers[i].mute) {
56957
+ callController.startParticipantAudio(i);
56958
+ }
56959
+ /*if (params.callVideo) {
56960
+ callController.startParticipantVideo(i);
56961
+ }*/
56962
+ /*if(params.callAudio) {
56963
+ callController.startParticipantAudio(i);
56964
+ }*/
55502
56965
  }
55503
- if(params.callAudio) {
55504
- this.startParticipantAudio(callTopics['receive'][0]['AudioTopic'], 'receive');
55505
- setTimeout(function (){
55506
- callController.startMyAudio();
55507
- }, 2000)
56966
+ },
56967
+ setupCallParticipant: function (participant) {
56968
+ var user = participant;
56969
+ user.topicMetaData = {};
56970
+ user.peers = {};
56971
+ if(user.userId === chatMessaging.userInfo.id) {
56972
+ user.direction = 'send';
56973
+ } else {
56974
+ user.direction = 'receive';
55508
56975
  }
56976
+ user.videoTopicName = 'Vi-' + user.topicSend;
56977
+ user.audioTopicName = 'Vo-' + user.topicSend;
56978
+ user.topicMetaData[user.videoTopicName] = {
56979
+ interval: null,
56980
+ receivedSdpAnswer: false,
56981
+ connectionQualityInterval: null,
56982
+ poorConnectionCount: 0,
56983
+ poorConnectionResolvedCount: 0,
56984
+ isConnectionPoor: false
56985
+ };
56986
+ user.topicMetaData[user.audioTopicName] = {
56987
+ interval: null,
56988
+ receivedSdpAnswer: false,
56989
+ connectionQualityInterval: null,
56990
+ poorConnectionCount: 0,
56991
+ poorConnectionResolvedCount: 0,
56992
+ isConnectionPoor: false
56993
+ };
56994
+ callUsers[user.userId] = user;
56995
+ this.appendUserToCallDiv(user.userId, this.generateHTMLElements(user.userId));
56996
+ },
56997
+ setupScreenSharingObject: function (topic) {
56998
+ var obj = {
56999
+ video: true,
57000
+ };
57001
+ obj.topicMetaData = {};
57002
+ obj.peers = {};
57003
+ if(screenShareState.imOwner) {
57004
+ obj.direction = 'send';
57005
+ } else {
57006
+ obj.direction = 'receive'
57007
+ }
57008
+ obj.videoTopicName = topic;
57009
+ obj.topicMetaData[obj.videoTopicName] = {
57010
+ interval: null,
57011
+ receivedSdpAnswer: false,
57012
+ connectionQualityInterval: null,
57013
+ poorConnectionCount: 0,
57014
+ poorConnectionResolvedCount: 0,
57015
+ isConnectionPoor: false
57016
+ };
57017
+ callUsers['screenShare'] = obj;
57018
+ this.generateHTMLElements('screenShare')
57019
+ },
57020
+ appendUserToCallDiv: function (userId) {
57021
+ if(!callDivId) {
57022
+ consoleLogging && console.log('No Call DIV has been declared!');
57023
+ return;
57024
+ }
57025
+ var user = callUsers[userId]
57026
+ var callParentDiv = document.getElementById(callDivId);
57027
+ if(user.video) {
57028
+ console.log("appendUserToCallDiv1", user, document.getElementById("callParticipantWrapper-" + userId), document.getElementById("uiRemoteVideo-" + user.videoTopicName))
57029
+ if(!document.getElementById("callParticipantWrapper-" + userId)) {
57030
+ if (!document.getElementById("uiRemoteVideo-" + user.videoTopicName)) {
57031
+ user.htmlElements.container.appendChild(user.htmlElements[user.videoTopicName])
57032
+ }
57033
+ }
57034
+ else {
57035
+ document.getElementById("callParticipantWrapper-" + userId).append(user.htmlElements[user.videoTopicName])
57036
+ }
57037
+ }
57038
+ if(typeof user.mute !== "undefined" && !user.mute){
57039
+ if(!document.getElementById("callParticipantWrapper-" + userId)) {
57040
+ if(!document.getElementById("uiRemoteAudio-" + user.videoTopicName)) {
57041
+ user.htmlElements.container.appendChild(user.htmlElements[user.audioTopicName])
57042
+ }
57043
+ } else {
57044
+ document.getElementById("callParticipantWrapper-" + userId).append(user.htmlElements[user.audioTopicName])
57045
+ }
57046
+ }
57047
+
57048
+ if(!document.getElementById("callParticipantWrapper-" + userId))
57049
+ callParentDiv.appendChild(user.htmlElements.container);
57050
+ },
57051
+ generateHTMLElements: function (userId) {
57052
+ var user = callUsers[userId]
57053
+ if(!user.htmlElements) {
57054
+ user.htmlElements = {
57055
+ container: document.createElement('div')
57056
+ };
57057
+ var el = user.htmlElements.container;
57058
+ el.setAttribute('id', 'callParticipantWrapper-' + userId);
57059
+ el.classList.add('participant');
57060
+ el.classList.add('wrapper');
57061
+ el.classList.add('user-' + userId);
57062
+ el.classList.add((userId === chatMessaging.userInfo.id ? 'local' : 'remote'));
57063
+ }
57064
+
57065
+ if (user.video && !user.htmlElements[user.videoTopicName]) {
57066
+ user.htmlElements[user.videoTopicName] = document.createElement('video');
57067
+ var el = user.htmlElements[user.videoTopicName];
57068
+ el.setAttribute('id', 'uiRemoteVideo-' + user.videoTopicName);
57069
+ el.setAttribute('class', callVideoTagClassName);
57070
+ el.setAttribute('playsinline', '');
57071
+ el.setAttribute('muted', '');
57072
+ el.setAttribute('width', callVideoMinWidth + 'px');
57073
+ el.setAttribute('height', callVideoMinHeight + 'px');
57074
+ }
57075
+
57076
+ if (typeof user.mute !== 'undefined' && !user.mute && !user.htmlElements[user.audioTopicName]) {
57077
+ user.htmlElements[user.audioTopicName] = document.createElement('audio');
57078
+ var el = user.htmlElements[user.audioTopicName];
57079
+ el.setAttribute('id', 'uiRemoteAudio-' + user.audioTopicName);
57080
+ el.setAttribute('class', callAudioTagClassName);
57081
+ el.setAttribute('autoplay', '');
57082
+ el.setAttribute('muted', '');
57083
+ el.setAttribute('controls', '');
57084
+ }
57085
+
57086
+ return user.htmlElements;
55509
57087
  },
55510
57088
  /**
55511
57089
  * When call started we can add participants
@@ -55531,77 +57109,88 @@ WildEmitter.mixin(WildEmitter);
55531
57109
  return;
55532
57110
  }
55533
57111
  },
55534
- stopMyAudio: function () {
55535
- this.removeTopic(callTopics['sendAudioTopic']);
55536
- },
55537
- startMyAudio: function () {
55538
- this.createTopic(callTopics['sendAudioTopic'], 'audio', 'send');
57112
+ stopParticipantAudio: function (userId) {
57113
+ this.removeTopic(userId, callUsers[userId].peers[userId].audioTopicName);
55539
57114
  },
55540
- stopParticipantAudio: function (topic) {
55541
- this.removeTopic(topic);
57115
+ startParticipantAudio: function (userId) {
57116
+ this.createTopic(userId, callUsers[userId].audioTopicName, 'audio', callUsers[userId].direction);
55542
57117
  },
55543
- startParticipantAudio: function (topic) {
55544
- this.createTopic(topic, 'audio', 'receive');
57118
+ stopParticipantVideo: function (userId) {
57119
+ this.removeTopic(userId, callUsers[userId].peers[userId].videoTopicName);
55545
57120
  },
55546
- stopMyVideo: function () {
55547
- this.removeTopic(callTopics['sendVideoTopic']);
57121
+ startParticipantVideo: function (userId) {
57122
+ this.createTopic(userId, callUsers[userId].videoTopicName, 'video', callUsers[userId].direction);
55548
57123
  },
55549
- startMyVideo: function () {
55550
- this.createTopic(callTopics['sendVideoTopic'], 'video','send');
55551
- },
55552
- stopParticipantVideo: function (topic) {
55553
- this.removeTopic(topic);
55554
- },
55555
- startParticipantVideo: function (topic) {
55556
- this.createTopic(topic, 'video', 'receive');
55557
- },
55558
- createTopic: function (topic, mediaType, direction) {
55559
- var options = this.getSdpOfferOptions(topic, mediaType, direction);
55560
- this.generateTopicPeer(topic, mediaType, direction, options);
55561
- },
55562
- removeTopic: function (topic) {
55563
- for(var i in webpeers) {
55564
- if(i === topic) {
55565
- webpeers[i].dispose();
55566
- webpeers[i] = null;
55567
- }
57124
+ createTopic: function (userId, topic, mediaType, direction, shareScreen) {
57125
+ if(callUsers[userId] && callUsers[userId].peers[topic]) {
57126
+ return;
55568
57127
  }
57128
+ shareScreen = typeof shareScreen !== 'undefined' ? shareScreen : false;
57129
+ this.getSdpOfferOptions(userId, topic, mediaType, direction, shareScreen).then(function (options){
57130
+ callStateController.generateTopicPeer(userId, topic, mediaType, direction, options);
57131
+ });
55569
57132
  },
55570
- getSdpOfferOptions: function (topic, mediaType, direction) {
55571
- var mediaConstraints = {audio: (mediaType === 'audio'), video: (mediaType === 'video')};
55572
- if(direction === 'send') {
55573
- mediaConstraints.video = {
55574
- width: callVideoMinWidth,
55575
- height: callVideoMinHeight,
55576
- framerate: 15
55577
- }
57133
+ removeTopic: function (userId, topic) {
57134
+ if(callUsers[userId].peers[topic]) {
57135
+ callUsers[userId].peers[topic].dispose();
57136
+ this.removeConnectionQualityInterval(userId, topic);
57137
+ callUsers[userId].peers[topic] = null;
55578
57138
  }
55579
- var options = {
55580
- mediaConstraints: mediaConstraints,
55581
- iceTransportPolicy: 'relay',
55582
- onicecandidate: (candidate) => {
55583
- if (webpeersMetadata[topic].interval !== null) {
55584
- clearInterval(webpeersMetadata[topic].interval);
57139
+ },
57140
+ getSdpOfferOptions: function (userId, topic, mediaType, direction, shareScreen) {
57141
+ return new Promise(function (resolve, reject) {
57142
+ var mediaConstraints = {audio: (mediaType === 'audio'), video: (mediaType === 'video')};
57143
+
57144
+ if(direction === 'send' && mediaType === 'video') {
57145
+ mediaConstraints.video = {
57146
+ width: callVideoMinWidth,
57147
+ height: callVideoMinHeight,
57148
+ framerate: 15
55585
57149
  }
55586
- webpeersMetadata[topic].interval = setInterval(function () {
55587
- if (webpeersMetadata[topic].sdpAnswerReceived === true) {
55588
- webpeersMetadata[topic].sdpAnswerReceived = false;
55589
- clearInterval(webpeersMetadata[topic].interval);
55590
- sendCallMessage({
55591
- id: 'ADD_ICE_CANDIDATE',
55592
- topic: topic,
55593
- candidateDto: candidate
55594
- })
57150
+ }
57151
+
57152
+ var options = {
57153
+ mediaConstraints: mediaConstraints,
57154
+ iceTransportPolicy: 'relay',
57155
+ onicecandidate: (candidate) => {
57156
+ if (callUsers[userId].topicMetaData[topic].interval !== null) {
57157
+ clearInterval(callUsers[userId].topicMetaData[topic].interval);
55595
57158
  }
55596
- }, 500, {candidate: candidate});
55597
- },
55598
- configuration: {
55599
- iceServers: this.getTurnServer(currentCallParams)
57159
+ callUsers[userId].topicMetaData[topic].interval = setInterval(function () {
57160
+ if (callUsers[userId].topicMetaData[topic].sdpAnswerReceived === true) {
57161
+ callUsers[userId].topicMetaData[topic].sdpAnswerReceived = false;
57162
+ clearInterval(callUsers[userId].topicMetaData[topic].interval);
57163
+ sendCallMessage({
57164
+ id: 'ADD_ICE_CANDIDATE',
57165
+ topic: topic,
57166
+ candidateDto: candidate
57167
+ })
57168
+ }
57169
+ }, 500, {candidate: candidate});
57170
+ },
57171
+ configuration: {
57172
+ iceServers: callStateController.getTurnServer(currentCallParams)
57173
+ }
57174
+ };
57175
+
57176
+ options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = callUsers[userId].htmlElements[topic];
57177
+
57178
+ if(direction === 'send' && mediaType === 'video' && shareScreen) {
57179
+ navigator.mediaDevices.getDisplayMedia().then(function (result) {
57180
+ options.videoStream = result;
57181
+ options.sendSource = 'screen';
57182
+ // options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = uiRemoteMedias[topic];
57183
+ resolve(options);
57184
+ }).catch(function (error) {
57185
+ console.error("[SDK][navigator.mediaDevices.getDisplayMedia]", error);
57186
+ explainUserMediaError(error, 'video', 'screen');
57187
+ //resolve(options);
57188
+ });
57189
+ } else {
57190
+ resolve(options);
55600
57191
  }
55601
- };
55602
- options[(direction === 'send' ? 'localVideo' : 'remoteVideo')] = uiRemoteMedias[topic];
55603
- consoleLogging && console.log("getSdpOfferOptions:", "topic: ", topic, "mediaType: ", mediaType, "direction: ", direction, "options: ", options)
55604
- return options;
57192
+ consoleLogging && console.log("[SDK][getSdpOfferOptions] ", "topic: ", topic, "mediaType: ", mediaType, "direction: ", direction, "options: ", options);
57193
+ });
55605
57194
  },
55606
57195
  getTurnServer: function (params) {
55607
57196
  if (!!params.turnAddress && params.turnAddress.length > 0) {
@@ -55624,154 +57213,223 @@ WildEmitter.mixin(WildEmitter);
55624
57213
  ];
55625
57214
  }
55626
57215
  },
55627
- watchRTCPeerConnection: function (topic, mediaType, direction) {
55628
- console.log("set callback on webpeers: ", topic, mediaType, direction);
57216
+ checkConnectionQuality: function (userId, topic) {
57217
+ if(!callUsers[userId] || !callUsers[userId].peers[topic] || !callUsers[userId].peers[topic].peerConnection) {
57218
+ callStateController.removeConnectionQualityInterval(userId, topic);
57219
+ return;
57220
+ }
57221
+ callUsers[userId].peers[topic].peerConnection.getStats(null).then(stats => {
57222
+ //console.log(' watchRTCPeerConnection:: window.setInterval then(stats:', stats)
57223
+ //let statsOutput = "";
57224
+ var user = callUsers[userId],
57225
+ userMetadata = user.topicMetaData[topic]
57226
+
57227
+ stats.forEach(report => {
57228
+ if(report && report.type && report.type === 'remote-inbound-rtp') {
57229
+ /*statsOutput += `<h2>Report: ${report.type}</h2>\n<strong>ID:</strong> ${report.id}<br>\n` +
57230
+ `<strong>Timestamp:</strong> ${report.timestamp}<br>\n`;*/
57231
+
57232
+ // Now the statistics for this report; we intentially drop the ones we
57233
+ // sorted to the top above
57234
+ if(!report['roundTripTime'] || report['roundTripTime'] > 1) {
57235
+ if(userMetadata.poorConnectionCount === 10) {
57236
+ chatEvents.fireEvent('callEvents', {
57237
+ type: 'POOR_VIDEO_CONNECTION',
57238
+ subType: 'LONG_TIME',
57239
+ message: 'Poor connection for a long time',
57240
+ metadata: {
57241
+ elementId: "uiRemoteVideo-" + topic,
57242
+ topic: topic
57243
+ }
57244
+ });
57245
+ }
57246
+ if(userMetadata.poorConnectionCount > 3 && !userMetadata.isConnectionPoor) {
57247
+ //alert('Poor connection detected...');
57248
+ consoleLogging && console.log('[SDK][checkConnectionQuality] Poor connection detected...');
57249
+ chatEvents.fireEvent('callEvents', {
57250
+ type: 'POOR_VIDEO_CONNECTION',
57251
+ subType: 'SHORT_TIME',
57252
+ message: 'Poor connection detected',
57253
+ metadata: {
57254
+ elementId: "uiRemoteVideo-" + topic,
57255
+ topic: topic,
57256
+ userId: userId
57257
+ }
57258
+ });
57259
+ userMetadata.isConnectionPoor = true;
57260
+ userMetadata.poorConnectionCount = 0;
57261
+ userMetadata.poorConnectionResolvedCount = 0;
57262
+ } else {
57263
+ callUsers[userId].topicMetaData[topic].poorConnectionCount++;
57264
+ }
57265
+ } else if(report['roundTripTime'] || report['roundTripTime'] < 1) {
57266
+ if(userMetadata.poorConnectionResolvedCount > 3 && userMetadata.isConnectionPoor) {
57267
+ userMetadata.poorConnectionResolvedCount = 0;
57268
+ userMetadata.poorConnectionCount = 0;
57269
+ userMetadata.isConnectionPoor = false;
57270
+ chatEvents.fireEvent('callEvents', {
57271
+ type: 'POOR_VIDEO_CONNECTION_RESOLVED',
57272
+ message: 'Poor connection resolved',
57273
+ metadata: {
57274
+ elementId: "uiRemoteVideo-" + topic,
57275
+ topic: topic
57276
+ }
57277
+ });
57278
+ } else {
57279
+ userMetadata.poorConnectionResolvedCount++;
57280
+ }
57281
+ }
57282
+
57283
+ /*Object.keys(report).forEach(function (statName) {
57284
+ if (statName !== "id" && statName !== "timestamp" && statName !== "type") {
57285
+ statsOutput += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
57286
+ }
57287
+ });*/
57288
+ }
57289
+ });
57290
+
57291
+ //document.querySelector(".stats-box").innerHTML = statsOutput;
57292
+ });
57293
+ },
57294
+ generateTopicPeer: function (userId, topic, mediaType, direction, options) {
57295
+ var WebRtcFunction = direction === 'send' ? 'WebRtcPeerSendonly' : 'WebRtcPeerRecvonly',
57296
+ callController = this,
57297
+ user = callUsers[userId],
57298
+ topicElement = user.htmlElements[topic],
57299
+ topicMetaData = user.topicMetaData[topic];
57300
+
57301
+ callUsers[userId].peers[topic] = new KurentoUtils.WebRtcPeer[WebRtcFunction](options, function (err) {
57302
+ if (err) {
57303
+ console.error("[SDK][start/webRtc " + direction + " " + mediaType + " Peer] Error: " + explainUserMediaError(err, mediaType));
57304
+ return;
57305
+ }
57306
+
57307
+ callController.watchRTCPeerConnection(userId, topic, mediaType, direction);
57308
+
57309
+ if(direction === 'send') {
57310
+ startMedia(topicElement);
57311
+ if(callRequestController.cameraPaused) {
57312
+ currentModuleInstance.pauseCamera();
57313
+ }
57314
+ }
57315
+
57316
+ callUsers[userId].peers[topic].generateOffer((err, sdpOffer) => {
57317
+ if (err) {
57318
+ console.error("[SDK][start/WebRc " + direction + " " + mediaType + " Peer/generateOffer] " + err);
57319
+ return;
57320
+ }
57321
+
57322
+ sdpOffer = callController.setMediaBitrates(sdpOffer);
57323
+ sendCallMessage({
57324
+ id: (direction === 'send' ? 'SEND_SDP_OFFER' : 'RECIVE_SDP_OFFER'),
57325
+ sdpOffer: sdpOffer,
57326
+ useComedia: true,
57327
+ useSrtp: false,
57328
+ topic: topic,
57329
+ mediaType: (mediaType === 'video' ? 2 : 1)
57330
+ });
57331
+ });
57332
+ });
57333
+ },
57334
+ watchRTCPeerConnection: function (userId, topic, mediaType, direction) {
57335
+ consoleLogging && console.log("[SDK][watchRTCPeerConnection] called with: ", userId, topic, mediaType, direction);
57336
+ var callController = this,
57337
+ user = callUsers[userId];
55629
57338
 
55630
- var callController = this;
55631
- webpeers[topic].peerConnection.onconnectionstatechange = function () {
55632
- console.log("on connection state change, ", "peer: ", topic, "peerConnection.connectionState: ", webpeers[topic].peerConnection.connectionState);
55633
- if (webpeers[topic].peerConnection.connectionState === 'disconnected') {
55634
- console.log(topic, 'peerConnection.onconnectionstatechange: disconnected');
57339
+ consoleLogging && console.log("[SDK][watchRTCPeerConnection] called with: ", callUsers, user);
55635
57340
 
55636
- callController.removeConnectionQualityInterval(topic);
57341
+ user.peers[topic].peerConnection.onconnectionstatechange = function () {
57342
+ if(!user || !user.peers || !user.peers[topic]) {
57343
+ return; //avoid log errors
57344
+ }
57345
+ consoleLogging && console.log("[SDK][peerConnection.onconnectionstatechange] ", "peer: ", topic, " peerConnection.connectionState: ", user.peers[topic].peerConnection.connectionState);
57346
+ if (user.peers[topic].peerConnection.connectionState === 'disconnected') {
57347
+ callController.removeConnectionQualityInterval(userId, topic);
55637
57348
  }
55638
57349
 
55639
- if (webpeers[topic].peerConnection.connectionState === "failed") {
57350
+ if (user.peers[topic].peerConnection.connectionState === "failed") {
55640
57351
  chatEvents.fireEvent('callEvents', {
55641
57352
  type: 'CALL_STATUS',
55642
57353
  errorCode: 7000,
55643
57354
  errorMessage: `Call Peer (${topic}) has failed!`,
55644
- errorInfo: webpeers[topic]
57355
+ errorInfo: user.peers[topic]
55645
57356
  });
55646
- setTimeout(function () {
57357
+ // setTimeout(function () {
55647
57358
  if(chatMessaging.chatState) {
55648
- callController.shouldReconnectTopic(topic, mediaType, direction);
57359
+ callController.shouldReconnectTopic(userId, topic, mediaType, direction);
55649
57360
  }
55650
- }, 7000);
57361
+ // }, 7000);
55651
57362
 
55652
- callController.removeConnectionQualityInterval(topic);
57363
+ callController.removeConnectionQualityInterval(userId, topic);
55653
57364
  }
55654
57365
 
55655
- if(webpeers[topic].peerConnection.connectionState === 'connected') {
57366
+ if(user.peers[topic].peerConnection.connectionState === 'connected') {
55656
57367
  if(mediaType === 'video' && direction === 'send') {
55657
- webpeersMetadata[topic]['connectionQualityInterval'] = setInterval(function() {
55658
- callController.checkConnectionQuality(topic, mediaType, direction)
57368
+ user.topicMetaData[topic].connectionQualityInterval = setInterval(function() {
57369
+ callController.checkConnectionQuality(userId, topic, mediaType, direction)
55659
57370
  }, 1000);
55660
57371
  }
55661
57372
  }
55662
57373
  }
55663
57374
 
55664
- webpeers[topic].peerConnection.oniceconnectionstatechange = function () {
55665
- console.log("on ice connection state change: ", topic, webpeers[topic].peerConnection.iceConnectionState);
55666
- if (webpeers[topic].peerConnection.iceConnectionState === 'disconnected') {
55667
- console.log(topic, 'peerConnection.oniceconnectionstatechange disconnected');
57375
+ user.peers[topic].peerConnection.oniceconnectionstatechange = function () {
57376
+ if(!user || !user.peers || !user.peers[topic]) {
57377
+ return; //avoid log errors
57378
+ }
57379
+
57380
+ consoleLogging && console.log("[SDK][oniceconnectionstatechange] ", "peer: ", topic, " peerConnection.connectionState: ", user.peers[topic].peerConnection.iceConnectionState);
57381
+ if (user.peers[topic].peerConnection.iceConnectionState === 'disconnected') {
55668
57382
  chatEvents.fireEvent('callEvents', {
55669
57383
  type: 'CALL_STATUS',
55670
57384
  errorCode: 7000,
55671
57385
  errorMessage: `Call Peer (${topic}) is disconnected!`,
55672
- errorInfo: webpeers[topic]
57386
+ errorInfo: user.peers[topic]
55673
57387
  });
55674
57388
 
55675
- console.log('Internet connection failed, Reconnect your call, topic:', topic);
57389
+ consoleLogging && console.log('[SDK][oniceconnectionstatechange]:[disconnected] Internet connection failed, Reconnect your call, topic:', topic);
55676
57390
  }
55677
57391
 
55678
- if (webpeers[topic].peerConnection.iceConnectionState === "failed") {
57392
+ if (user.peers[topic].peerConnection.iceConnectionState === "failed") {
55679
57393
  chatEvents.fireEvent('callEvents', {
55680
57394
  type: 'CALL_STATUS',
55681
57395
  errorCode: 7000,
55682
57396
  errorMessage: `Call Peer (${topic}) has failed!`,
55683
- errorInfo: webpeers[topic]
57397
+ errorInfo: user.peers[topic]
55684
57398
  });
55685
57399
  if(chatMessaging.chatState) {
55686
- callController.shouldReconnectTopic(topic, mediaType, direction);
55687
- } else {
55688
- setTimeout(function () {
55689
- if(chatMessaging.chatState) {
55690
- callController.shouldReconnectTopic(topic, mediaType, direction);
55691
- }
55692
- }, 7000);
57400
+ callController.shouldReconnectTopic(userId, topic, mediaType, direction);
55693
57401
  }
57402
+ // } else {
57403
+ // setTimeout(function () {
57404
+ // if(chatMessaging.chatState) {
57405
+ // callController.shouldReconnectTopic(userId, topic, mediaType, direction);
57406
+ // }
57407
+ // }, 7000);
57408
+ // }
55694
57409
  }
55695
57410
 
55696
- if (webpeers[topic].peerConnection.iceConnectionState === "connected") {
57411
+ if (user.peers[topic].peerConnection.iceConnectionState === "connected") {
55697
57412
  callRequestController.callEstablishedInMySide = true;
55698
57413
  chatEvents.fireEvent('callEvents', {
55699
57414
  type: 'CALL_STATUS',
55700
57415
  errorCode: 7000,
55701
57416
  errorMessage: `Call Peer (${topic}) has connected!`,
55702
- errorInfo: webpeers[topic]
57417
+ errorInfo: user.peers[topic]
55703
57418
  });
55704
57419
  }
55705
57420
  }
55706
57421
  },
55707
- checkConnectionQuality: function (topic) {
55708
- webpeers[topic].peerConnection.getStats(null).then(stats => {
55709
- //console.log(' watchRTCPeerConnection:: window.setInterval then(stats:', stats)
55710
- //let statsOutput = "";
55711
-
55712
- stats.forEach(report => {
55713
- if(report && report.type && report.type === 'remote-inbound-rtp') {
55714
- /*statsOutput += `<h2>Report: ${report.type}</h2>\n<strong>ID:</strong> ${report.id}<br>\n` +
55715
- `<strong>Timestamp:</strong> ${report.timestamp}<br>\n`;*/
55716
-
55717
- // Now the statistics for this report; we intentially drop the ones we
55718
- // sorted to the top above
55719
- if(!report['roundTripTime'] || report['roundTripTime'] > 1) {
55720
- if(webpeersMetadata[topic].poorConnectionCount > 3 && !webpeersMetadata[topic].isConnectionPoor) {
55721
- //alert('Poor connection detected...');
55722
- consoleLogging && console.log('Poor connection detected...');
55723
- chatEvents.fireEvent('callEvents', {
55724
- type: 'POOR_VIDEO_CONNECTION',
55725
- message: 'Poor connection detected',
55726
- metadata: {
55727
- elementId: "uiRemoteVideo-" + topic,
55728
- topic: topic
55729
- }
55730
- });
55731
- webpeersMetadata[topic].isConnectionPoor = true;
55732
- webpeersMetadata[topic].poorConnectionCount = 0;
55733
- } else {
55734
- webpeersMetadata[topic].poorConnectionCount++;
55735
- }
55736
-
55737
- } else if((report['roundTripTime'] || report['roundTripTime'] < 1) && webpeersMetadata[topic].isConnectionPoor) {
55738
- webpeersMetadata[topic].poorConnectionCount = 0;
55739
- webpeersMetadata[topic].isConnectionPoor = false;
55740
- chatEvents.fireEvent('callEvents', {
55741
- type: 'POOR_VIDEO_CONNECTION_RESOLVED',
55742
- message: 'Poor connection resolved',
55743
- metadata: {
55744
- elementId: "uiRemoteVideo-" + topic,
55745
- topic: topic
55746
- }
55747
- });
55748
- }
55749
-
55750
- /*Object.keys(report).forEach(function (statName) {
55751
- if (statName !== "id" && statName !== "timestamp" && statName !== "type") {
55752
- statsOutput += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
55753
- }
55754
- });*/
55755
- }
55756
- });
55757
-
55758
- //document.querySelector(".stats-box").innerHTML = statsOutput;
55759
- });
55760
- },
55761
- removeConnectionQualityInterval: function (topic) {
55762
- //isConnectionPoor
55763
- webpeersMetadata[topic]['poorConnectionCount'] = 0;
55764
- clearInterval(webpeersMetadata[topic]['connectionQualityInterval']);
55765
- },
55766
- shouldReconnectTopic: function (topic, mediaType, direction) {
55767
- var callController = this;
57422
+ shouldReconnectTopic: function (userId, topic, mediaType, direction) {
57423
+ var callController = this, iceConnectionState = callUsers[userId].peers[topic].peerConnection.iceConnectionState;
55768
57424
  if (currentCallParams && Object.keys(currentCallParams).length) {
55769
- if (webpeers[topic].peerConnection.iceConnectionState != 'connected') {
57425
+ if (callUsers[userId]
57426
+ && callUsers[userId].peers[topic]
57427
+ && iceConnectionState != 'connected') {
55770
57428
  chatEvents.fireEvent('callEvents', {
55771
57429
  type: 'CALL_STATUS',
55772
57430
  errorCode: 7000,
55773
57431
  errorMessage: `Call Peer (${topic}) is not in connected state, Restarting call in progress ...!`,
55774
- errorInfo: webpeers[topic]
57432
+ errorInfo: callUsers[userId].peers[topic]
55775
57433
  });
55776
57434
 
55777
57435
  sendCallMessage({
@@ -55779,18 +57437,11 @@ WildEmitter.mixin(WildEmitter);
55779
57437
  topic: topic
55780
57438
  }, function (result) {
55781
57439
  if (result.done === 'TRUE') {
55782
- //handleCallSocketOpen(currentCallParams);
55783
- /*webpeers[topic].dispose();
55784
- webpeers[topic] = null;*/
55785
- callController.removeTopic(topic);
55786
- callController.createTopic(topic, mediaType, direction);
55787
- //generateAndSendSdpOffers(currentCallParams, [topicName]);
57440
+ callController.removeTopic(userId, topic);
57441
+ callController.createTopic(userId, topic, mediaType, direction, userId === 'screenShare');
55788
57442
  } else if (result.done === 'SKIP') {
55789
- //handleCallSocketOpen(currentCallParams);
55790
- /*webpeers[topic].dispose();
55791
- webpeers[topic] = null;*/
55792
- callController.removeTopic(topic);
55793
- callController.createTopic(topic, mediaType, direction);
57443
+ callController.removeTopic(userId, topic);
57444
+ callController.createTopic(userId, topic, mediaType, direction, userId === 'screenShare');
55794
57445
  //generateAndSendSdpOffers(currentCallParams, [topicName]);
55795
57446
  } else {
55796
57447
  consoleLogging && console.log('STOP topic faced a problem', result);
@@ -55803,487 +57454,194 @@ WildEmitter.mixin(WildEmitter);
55803
57454
  }
55804
57455
  }
55805
57456
  },
55806
- generateTopicPeer: function (topic, mediaType, direction, options) {
55807
- var WebRtcFunction = direction === 'send' ? 'WebRtcPeerSendonly' : 'WebRtcPeerRecvonly',
55808
- callController = this;
57457
+ maybeReconnectAllTopics: function (){
57458
+ if(!callUsers || !Object.keys(callUsers).length || !callRequestController.callEstablishedInMySide)
57459
+ return;
55809
57460
 
55810
- webpeers[topic] = new KurentoUtils.WebRtcPeer[WebRtcFunction](options, function (err) {
55811
- if (err) {
55812
- console.error("[start/webRtc " + direction + " " + mediaType + " Peer] Error: " + explainUserMediaError(err, mediaType));
55813
- return;
57461
+ for(var i in callUsers) {
57462
+ var videoTopic = callUsers[i].videoTopicName, audioTopic = callUsers[i].audioTopicName;
57463
+ if(callUsers[i] && callUsers[i].peers[videoTopic] && callUsers[i].peers[videoTopic].peerConnection.connectionState === 'failed'){
57464
+ this.shouldReconnectTopic(i, videoTopic, 'video', callUsers[i].direction)
55814
57465
  }
55815
-
55816
- callController.watchRTCPeerConnection(topic, mediaType, direction);
55817
-
55818
- if(direction === 'send')
55819
- startMedia(uiRemoteMedias[topic]);
55820
-
55821
- webpeers[topic].generateOffer((err, sdpOffer) => {
55822
- if (err) {
55823
- console.error("[start/WebRc " + direction + " " + mediaType + " Peer/generateOffer] " + err);
55824
- return;
55825
- }
55826
-
55827
- sendCallMessage({
55828
- id: (direction === 'send' ? 'SEND_SDP_OFFER' : 'RECIVE_SDP_OFFER'),
55829
- sdpOffer: sdpOffer,
55830
- useComedia: true,
55831
- useSrtp: false,
55832
- topic: topic,
55833
- mediaType: (mediaType === 'video' ? 2 : 1)
55834
- });
55835
- });
55836
- });
55837
- }
55838
- },
55839
-
55840
- /*
55841
- shouldReconnectCall = function (topic) {
55842
- if (currentCallParams && Object.keys(currentCallParams).length) {
55843
- if (webpeers[topic] && webpeers[topic].peerConnection.iceConnectionState != 'connected') {
55844
-
55845
- chatEvents.fireEvent('callEvents', {
55846
- type: 'CALL_STATUS',
55847
- errorCode: 7000,
55848
- errorMessage: `Call Peer (${topic}) is not in connected state, Restarting call in progress ...!`,
55849
- errorInfo: webpeers[topic]
55850
- });
55851
-
55852
- sendCallMessage({
55853
- id: 'STOP',
55854
- topic: topic
55855
- }, function (result) {
55856
- if (result.done === 'TRUE') {
55857
- //handleCallSocketOpen(currentCallParams);
55858
- /!*webpeers[topic].dispose();
55859
- webpeers[topic] = null;*!/
55860
- generateAndSendSdpOffers(currentCallParams, [topic]);
55861
-
55862
- } else if (result.done === 'SKIP') {
55863
- //handleCallSocketOpen(currentCallParams);
55864
- /!*webpeers[topic].dispose();
55865
- webpeers[topic] = null;*!/
55866
- generateAndSendSdpOffers(currentCallParams, [topic]);
55867
- } else {
55868
- consoleLogging && console.log('STOP topic faced a problem', result);
55869
- endCall({
55870
- callId: currentCallId
57466
+ if(callUsers[i] && callUsers[i].peers[audioTopic] && callUsers[i].peers[audioTopic].peerConnection.connectionState === 'failed'){
57467
+ this.shouldReconnectTopic(i, audioTopic, 'audio', callUsers[i].direction)
57468
+ }
57469
+ }
57470
+ },
57471
+ removeConnectionQualityInterval: function (userId, topic) {
57472
+ callUsers[userId].topicMetaData[topic]['poorConnectionCount'] = 0;
57473
+ clearInterval(callUsers[userId].topicMetaData[topic]['connectionQualityInterval']);
57474
+ },
57475
+ removeStreamFromWebRTC : function (userId, topic) {
57476
+ if(callUsers[userId].htmlElements[topic]){
57477
+ const stream = callUsers[userId].htmlElements[topic].srcObject;
57478
+ if (!!stream) {
57479
+ const tracks = stream.getTracks();
57480
+
57481
+ if (!!tracks) {
57482
+ tracks.forEach(function (track) {
57483
+ track.stop();
55871
57484
  });
55872
- callStop();
55873
57485
  }
55874
- });
55875
- }
55876
- }
55877
- },
55878
-
55879
- generateAndSendSdpOffers = function (params, topics) {
55880
- var turnServers = [];
55881
-
55882
- if (!!params.turnAddress && params.turnAddress.length > 0) {
55883
- var serversTemp = params.turnAddress.split(',');
55884
57486
 
55885
- turnServers = [
55886
- //{"urls": "stun:" + serversTemp[0]},
55887
- {
55888
- "urls": "turn:" + serversTemp[0],
55889
- "username": "mkhorrami",
55890
- "credential": "mkh_123456"
57487
+ callUsers[userId].htmlElements[topic].srcObject = null;
55891
57488
  }
55892
- ];
55893
- } else {
55894
- turnServers = [
55895
- //{"urls": "stun:" + callTurnIp + ":3478"},
55896
- {
55897
- "urls": "turn:" + callTurnIp + ":3478",
55898
- "username": "mkhorrami",
55899
- "credential": "mkh_123456"
55900
- }
55901
- ];
55902
- }
55903
-
55904
- // Video Topics
55905
- if (params.callVideo) {
55906
- if(topics.indexOf(callTopics['receiveVideoTopic']) !== -1) {
55907
- const receiveVideoOptions = {
55908
- remoteVideo: uiRemoteMedias[callTopics['receiveVideoTopic']],
55909
- mediaConstraints: {audio: false, video: true},
55910
- iceTransportPolicy: 'relay',
55911
- onicecandidate: (candidate) => {
55912
- if (webpeersMetadata[callTopics['receiveVideoTopic']].interval !== null) {
55913
- clearInterval(webpeersMetadata[callTopics['receiveVideoTopic']].interval);
55914
- }
55915
- webpeersMetadata[callTopics['receiveVideoTopic']].interval = setInterval(function () {
55916
- if (webpeersMetadata[callTopics['receiveVideoTopic']].sdpAnswerReceived === true) {
55917
- webpeersMetadata[callTopics['receiveVideoTopic']].sdpAnswerReceived = false;
55918
- clearInterval(webpeersMetadata[callTopics['receiveVideoTopic']].interval);
55919
- sendCallMessage({
55920
- id: 'ADD_ICE_CANDIDATE',
55921
- topic: callTopics['receiveVideoTopic'],
55922
- candidateDto: candidate
55923
- })
55924
- }
55925
- }, 500, {candidate: candidate});
55926
- },
55927
- configuration: {
55928
- iceServers: turnServers
55929
- }
55930
- };
55931
-
55932
- webpeers[callTopics['receiveVideoTopic']] = new KurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(receiveVideoOptions, function (err) {
55933
- if (err) {
55934
- console.error("[start/webRtcReceiveVideoPeer] Error: " + explainUserMediaError(err, 'video'));
55935
- return;
55936
- }
55937
-
55938
- watchRTCPeerConnection(callTopics['receiveVideoTopic']);
55939
-
55940
- webpeers[callTopics['receiveVideoTopic']].generateOffer((err, sdpOffer) => {
55941
- if (err) {
55942
- console.error("[start/WebRtcVideoPeerReceiveOnly/generateOffer] " + err);
55943
- return;
55944
- }
55945
57489
 
55946
- sendCallMessage({
55947
- id: 'RECIVE_SDP_OFFER',
55948
- sdpOffer: sdpOffer,
55949
- useComedia: true,
55950
- useSrtp: false,
55951
- topic: callTopics['receiveVideoTopic'],
55952
- mediaType: 2
55953
- });
55954
- });
55955
- });
57490
+ callUsers[userId].htmlElements[topic].remove();
57491
+ delete (callUsers[userId].htmlElements[topic]);
55956
57492
  }
55957
-
55958
- if(topics.indexOf(callTopics['sendVideoTopic']) !== -1) {
55959
- const sendVideoOptions = {
55960
- localVideo: uiRemoteMedias[callTopics['sendVideoTopic']],
55961
- mediaConstraints: {
55962
- audio: false,
55963
- video: {
55964
- width: callVideoMinWidth,
55965
- height: callVideoMinHeight,
55966
- framerate: 15
55967
- }
55968
- },
55969
- iceTransportPolicy: 'relay',
55970
- onicecandidate: (candidate) => {
55971
- if (webpeersMetadata[callTopics['sendVideoTopic']].interval !== null) {
55972
- clearInterval(webpeersMetadata[callTopics['sendVideoTopic']].interval);
55973
- }
55974
- webpeersMetadata[callTopics['sendVideoTopic']].interval = setInterval(function () {
55975
- if (webpeersMetadata[callTopics['sendVideoTopic']].sdpAnswerReceived === true) {
55976
- webpeersMetadata[callTopics['sendVideoTopic']].sdpAnswerReceived = false;
55977
- clearInterval(webpeersMetadata[callTopics['sendVideoTopic']].interval);
55978
- sendCallMessage({
55979
- id: 'ADD_ICE_CANDIDATE',
55980
- topic: callTopics['sendVideoTopic'],
55981
- candidateDto: candidate
55982
- })
55983
- }
55984
- }, 500, {candidate: candidate});
55985
-
55986
- },
55987
- configuration: {
55988
- iceServers: turnServers
55989
- }
55990
- };
55991
-
57493
+ },
57494
+ addScreenShareToCall: function (direction, shareScreen) {
57495
+ if(direction !== callUsers["screenShare"].direction) {
57496
+ callUsers['screenShare'].direction = direction
57497
+ }
57498
+ var callController = this,
57499
+ screenShare = callUsers["screenShare"];
57500
+ if(!screenShare.peers[screenShare.videoTopicName]) {
57501
+ // Local Video Tag
57502
+ if(!screenShare.htmlElements[screenShare.videoTopicName]) {
57503
+ callStateController.generateHTMLElements('screenShare');
57504
+ }
55992
57505
  setTimeout(function () {
55993
- webpeers[callTopics['sendVideoTopic']] = new KurentoUtils.WebRtcPeer.WebRtcPeerSendonly(sendVideoOptions, function (err) {
55994
- if (err) {
55995
- sendCallSocketError("[start/WebRtcVideoPeerSendOnly] Error: " + explainUserMediaError(err, 'video'));
55996
- //callStop();
55997
- return;
55998
- }
55999
-
56000
- watchRTCPeerConnection(callTopics['sendVideoTopic']);
56001
- startMedia(uiRemoteMedias[callTopics['sendVideoTopic']]);
56002
-
56003
- webpeers[callTopics['sendVideoTopic']].generateOffer((err, sdpOffer) => {
56004
- if (err) {
56005
- sendCallSocketError("[start/WebRtcVideoPeerSendOnly/generateOffer] Error: " + err);
56006
- //callStop();
56007
- return;
56008
- }
56009
-
56010
- sendCallMessage({
56011
- id: 'SEND_SDP_OFFER',
56012
- topic: callTopics['sendVideoTopic'],
56013
- sdpOffer: sdpOffer,
56014
- mediaType: 2
56015
- });
56016
- });
56017
- });
56018
- }, 2000);
57506
+ callStateController.appendUserToCallDiv('screenShare');
57507
+ callStateController.createTopic('screenShare', screenShare.videoTopicName, "video", direction, shareScreen);
57508
+ });
57509
+ chatEvents.fireEvent('callEvents', {
57510
+ type: 'CALL_DIVS',
57511
+ result: generateCallUIList()
57512
+ });
57513
+ } else {
57514
+ callStateController.removeTopic('screenShare', screenShare.videoTopicName);
57515
+ callStateController.createTopic('screenShare', screenShare.videoTopicName, "video", direction, shareScreen);
57516
+ startMedia(screenShare.htmlElements[screenShare.videoTopicName])
56019
57517
  }
56020
- }
56021
-
56022
- // Audio Topics
56023
- if (params.callAudio) {
56024
- if(topics.indexOf(callTopics['receiveAudioTopic']) !== -1) {
56025
- const receiveAudioOptions = {
56026
- remoteVideo: uiRemoteMedias[callTopics['receiveAudioTopic']],
56027
- mediaConstraints: {audio: true, video: false},
56028
- iceTransportPolicy: 'relay',
56029
- onicecandidate: (candidate) => {
56030
- if (webpeersMetadata[callTopics['receiveAudioTopic']].interval !== null) {
56031
- clearInterval(webpeersMetadata[callTopics['receiveAudioTopic']].interval);
56032
- }
56033
- webpeersMetadata[callTopics['receiveAudioTopic']].interval = setInterval(function () {
56034
- if (webpeersMetadata[callTopics['receiveAudioTopic']].sdpAnswerReceived === true) {
56035
- webpeersMetadata[callTopics['receiveAudioTopic']].sdpAnswerReceived = false;
56036
- clearInterval(webpeersMetadata[callTopics['receiveAudioTopic']].interval);
56037
- sendCallMessage({
56038
- id: 'ADD_ICE_CANDIDATE',
56039
- topic: callTopics['receiveAudioTopic'],
56040
- candidateDto: candidate,
56041
- })
56042
- }
56043
- }, 500, {candidate: candidate});
56044
- },
56045
- configuration: {
56046
- iceServers: turnServers
56047
- }
56048
- };
56049
-
56050
- webpeers[callTopics['receiveAudioTopic']] = new KurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(receiveAudioOptions, function (err) {
56051
- if (err) {
56052
- console.error("[start/WebRtcAudioPeerReceiveOnly] Error: " + explainUserMediaError(err, 'audio'));
56053
- return;
56054
- }
56055
-
56056
- watchRTCPeerConnection(callTopics['receiveAudioTopic']);
56057
-
56058
- webpeers[callTopics['receiveAudioTopic']].generateOffer((err, sdpOffer) => {
56059
- if (err) {
56060
- console.error("[start/WebRtcAudioPeerReceiveOnly/generateOffer] " + err);
56061
- return;
56062
- }
56063
- sendCallMessage({
56064
- id: 'RECIVE_SDP_OFFER',
56065
- sdpOffer: sdpOffer,
56066
- useComedia: false,
56067
- useSrtp: false,
56068
- mediaType: 1,
56069
- topic: callTopics['receiveAudioTopic']
56070
- });
56071
- });
57518
+ },
57519
+ removeScreenShareFromCall: function (topic) {
57520
+ var callController = this,
57521
+ screenShare = callUsers["screenShare"];
57522
+ if(screenShare.peers[screenShare.videoTopicName]) {
57523
+ // Local Video Tag
57524
+
57525
+ //removeStreamFromWebRTC(callTopics['screenShare']);
57526
+ callStateController.removeStreamFromWebRTC('screenShare', screenShare.videoTopicName)
57527
+ callStateController.removeTopic('screenShare', screenShare.videoTopicName);
57528
+ chatEvents.fireEvent('callEvents', {
57529
+ type: 'CALL_DIVS',
57530
+ result: generateCallUIList()
56072
57531
  });
56073
57532
  }
57533
+ },
57534
+ removeAllCallParticipants: function () {
57535
+ for (var i in callUsers) {
57536
+ var user = callUsers[i];
57537
+ if (user) {
57538
+ if(user.videoTopicName && user.peers[user.videoTopicName]) {
57539
+ callStateController.removeConnectionQualityInterval(i, user.videoTopicName);
57540
+ callStateController.removeStreamFromWebRTC(i, user.videoTopicName);
57541
+ callUsers[i].peers[user.videoTopicName].dispose();
57542
+ delete callUsers[i].peers[user.videoTopicName];
56074
57543
 
56075
- if(topics.indexOf(callTopics['sendAudioTopic']) !== -1) {
56076
- const sendAudioOptions = {
56077
- localVideo: uiRemoteMedias[callTopics['sendAudioTopic']],
56078
- mediaConstraints: {audio: true, video: false},
56079
- iceTransportPolicy: 'relay',
56080
- onicecandidate: (candidate) => {
56081
- if (webpeersMetadata[callTopics['sendAudioTopic']].interval !== null) {
56082
- clearInterval(webpeersMetadata[callTopics['sendAudioTopic']].interval);
56083
- }
56084
- webpeersMetadata[callTopics['sendAudioTopic']].interval = setInterval(function () {
56085
- if (webpeersMetadata[callTopics['sendAudioTopic']].sdpAnswerReceived === true) {
56086
- webpeersMetadata[callTopics['sendAudioTopic']].sdpAnswerReceived = false;
56087
- clearInterval(webpeersMetadata[callTopics['sendAudioTopic']].interval);
56088
- sendCallMessage({
56089
- id: 'ADD_ICE_CANDIDATE',
56090
- topic: callTopics['sendAudioTopic'],
56091
- candidateDto: candidate,
56092
- })
56093
- }
56094
- }, 500, {candidate: candidate});
56095
- },
56096
- configuration: {
56097
- iceServers: turnServers
56098
57544
  }
56099
- };
56100
-
56101
- setTimeout(function () {
56102
- webpeers[callTopics['sendAudioTopic']] = new KurentoUtils.WebRtcPeer.WebRtcPeerSendonly(sendAudioOptions, function (err) {
56103
- if (err) {
56104
- sendCallSocketError("[start/WebRtcAudioPeerSendOnly] Error: " + explainUserMediaError(err, 'audio'));
56105
- //callStop();
56106
- return;
56107
- }
56108
- watchRTCPeerConnection(callTopics['sendAudioTopic']);
56109
- startMedia(uiRemoteMedias[callTopics['sendAudioTopic']]);
56110
-
56111
- webpeers[callTopics['sendAudioTopic']].generateOffer((err, sdpOffer) => {
56112
- if (err) {
56113
- sendCallSocketError("[start/WebRtcAudioPeerSendOnly/generateOffer] Error: " + err);
56114
- //callStop();
56115
- return;
56116
- }
56117
- sendCallMessage({
56118
- id: 'SEND_SDP_OFFER',
56119
- topic: callTopics['sendAudioTopic'],
56120
- sdpOffer: sdpOffer,
56121
- mediaType: 1
56122
- });
56123
- });
56124
- });
56125
- }, 2000);
56126
- }
56127
- }
57545
+ if(user.audioTopicName && user.peers[user.audioTopicName]) {
57546
+ callStateController.removeConnectionQualityInterval(i, user.audioTopicName);
57547
+ callStateController.removeStreamFromWebRTC(i, user.audioTopicName);
56128
57548
 
56129
- /!*setTimeout(function () {
56130
- for (var peer in webpeers) {
56131
- console.log("set callback on webpeers: ", peer);
56132
- if (webpeers[peer]) {
56133
- webpeers[peer].peerConnection.onconnectionstatechange = function () {
56134
- console.log("on connection state change, ", "peer: ", peer, "peerConnection.connectionState: ", webpeers[peer].peerConnection.connectionState);
56135
- if (webpeers[peer].peerConnection.connectionState == 'disconnected') {
56136
- console.log(peer, 'peerConnection.onconnectionstatechange: disconnected');
56137
- }
57549
+ callUsers[i].peers[user.audioTopicName].dispose();
57550
+ delete callUsers[i].peers[user.audioTopicName];
56138
57551
  }
56139
-
56140
- webpeers[peer].peerConnection.oniceconnectionstatechange = function () {
56141
- console.log("on ice connection state change: ", peer, webpeers[peer].peerConnection.connectionState);
56142
- if (webpeers[peer].peerConnection.iceConnectionState == 'disconnected') {
56143
- console.log( peer , '>>>>>>>>>>>>> disconnected');
56144
- chatEvents.fireEvent('callEvents', {
56145
- type: 'CALL_STATUS',
56146
- errorCode: 7000,
56147
- errorMessage: `Call Peer (${peer}) is disconnected!`,
56148
- errorInfo: webpeers[peer]
56149
- });
56150
-
56151
- setTimeout(function () {
56152
- restartMedia(callTopics['sendVideoTopic'])
56153
- }, 2000);
56154
-
56155
- setTimeout(function () {
56156
- restartMedia(callTopics['sendVideoTopic'])
56157
- }, 6000);
56158
-
56159
- alert('Internet connection failed, Reconnect your call');
56160
- /!*shouldReconnectCallTimeout && clearTimeout(shouldReconnectCallTimeout);
56161
- shouldReconnectCallTimeout = setTimeout(function () {
56162
- shouldReconnectCall();
56163
- }, 7000);*!/
56164
- }
56165
-
56166
- if (webpeers[peer].peerConnection.iceConnectionState === "failed") {
56167
- chatEvents.fireEvent('callEvents', {
56168
- type: 'CALL_STATUS',
56169
- errorCode: 7000,
56170
- errorMessage: `Call Peer (${peer}) has failed!`,
56171
- errorInfo: webpeers[peer]
56172
- });
56173
- }
56174
-
56175
- if (webpeers[peer].peerConnection.iceConnectionState === "connected") {
56176
- chatEvents.fireEvent('callEvents', {
56177
- type: 'CALL_STATUS',
56178
- errorCode: 7000,
56179
- errorMessage: `Call Peer (${peer}) has connected!`,
56180
- errorInfo: webpeers[peer]
56181
- });
56182
-
56183
- setTimeout(function () {
56184
- restartMedia(callTopics['sendVideoTopic'])
56185
- }, 2000);
56186
-
56187
- setTimeout(function () {
56188
- restartMedia(callTopics['sendVideoTopic'])
56189
- }, 6000);
57552
+ setTimeout(function (){
57553
+ if(callUsers[i]){
57554
+ callUsers[i].peers = {};
57555
+ callUsers[i].topicMetaData = {};
57556
+ callUsers[i].htmlElements = {};
57557
+ callUsers[i] = null;
56190
57558
  }
56191
- }
57559
+ }, 200);
56192
57560
  }
56193
57561
  }
56194
- }, 6000);*!/
56195
-
56196
- setTimeout(function () {
56197
- restartMedia(callTopics['sendVideoTopic'])
56198
- }, 4000);
56199
- setTimeout(function () {
56200
- restartMedia(callTopics['sendVideoTopic'])
56201
- }, 8000);
56202
- setTimeout(function () {
56203
- restartMedia(callTopics['sendVideoTopic'])
56204
- }, 12000);
56205
- setTimeout(function () {
56206
- restartMedia(callTopics['sendVideoTopic'])
56207
- }, 20000);
56208
- },
57562
+ },
57563
+ removeFromCallUI: function (topic) {
57564
+ var videoElement = 'Vi-' + topic,
57565
+ audioElement = 'Vo-' + topic,
57566
+ userId = this.findUserIdByTopic(videoElement);
56209
57567
 
56210
- watchRTCPeerConnection = function (topic) {
56211
- console.log("set callback on webpeers: ", topic);
56212
- if (webpeers[topic]) {
56213
- webpeers[topic].peerConnection.onconnectionstatechange = function () {
56214
- console.log("on connection state change, ", "peer: ", topic, "peerConnection.connectionState: ", webpeers[topic].peerConnection.connectionState);
56215
- if (webpeers[topic].peerConnection.connectionState == 'disconnected') {
56216
- console.log(topic, 'peerConnection.onconnectionstatechange: disconnected');
56217
- }
57568
+ if (topic.length > 0 && callUsers[userId].htmlElements[videoElement]) {
57569
+ this.removeStreamFromWebRTC(userId,videoElement);
56218
57570
  }
56219
57571
 
56220
- webpeers[topic].peerConnection.oniceconnectionstatechange = function () {
56221
- console.log("on ice connection state change: ", topic, webpeers[topic].peerConnection.iceConnectionState);
56222
- if (webpeers[topic].peerConnection.iceConnectionState == 'disconnected') {
56223
- console.log(topic, 'peerConnection.oniceconnectionstatechange disconnected');
56224
- chatEvents.fireEvent('callEvents', {
56225
- type: 'CALL_STATUS',
56226
- errorCode: 7000,
56227
- errorMessage: `Call Peer (${topic}) is disconnected!`,
56228
- errorInfo: webpeers[topic]
56229
- });
56230
-
56231
- /!*setTimeout(function () {
56232
- restartMedia(callTopics['sendVideoTopic'])
56233
- }, 2000);*!/
56234
-
56235
- /!*setTimeout(function () {
56236
- restartMedia(callTopics['sendVideoTopic'])
56237
- }, 6000);*!/
56238
-
56239
- console.log('Internet connection failed, Reconnect your call, topic:', topic);
56240
- //shouldReconnectCallTimeout && clearTimeout(shouldReconnectCallTimeout);
56241
- /!*shouldReconnectCallTimeout = setTimeout(function () {
56242
- shouldReconnectCall(topic);
56243
- }, 7000);*!/
57572
+ if (topic.length > 0 && callUsers[userId].htmlElements[videoElement]) {
57573
+ this.removeStreamFromWebRTC(userId, audioElement);
57574
+ }
57575
+ },
57576
+ findUserIdByTopic: function (topic) {
57577
+ for(var i in callUsers) {
57578
+ if (callUsers[i].videoTopicName === topic || callUsers[i].audioTopicName === topic) {
57579
+ //peer = callUsers[i].peers[jsonMessage.topic];
57580
+ return i;
56244
57581
  }
57582
+ }
57583
+ },
57584
+ activateParticipantStream: function (userId, mediaType, direction, topicNameKey, sendTopic, mediaKey) {
57585
+ if(callUsers[userId]) {
57586
+ callUsers[userId][mediaKey] = (mediaKey !== 'mute');
57587
+ callUsers[userId][topicNameKey] = (mediaType === 'audio'? 'Vo-': 'Vi-') + sendTopic;
56245
57588
 
56246
- if (webpeers[topic].peerConnection.iceConnectionState === "failed") {
56247
- chatEvents.fireEvent('callEvents', {
56248
- type: 'CALL_STATUS',
56249
- errorCode: 7000,
56250
- errorMessage: `Call Peer (${topic}) has failed!`,
56251
- errorInfo: webpeers[topic]
56252
- });
56253
-
56254
- if(chatMessaging.chatState) {
56255
- shouldReconnectCall(topic);
56256
- } else {
56257
- setTimeout(function () {
56258
- if(chatMessaging.chatState) {
56259
- shouldReconnectCall(topic);
56260
- }
56261
- }, 5000);
56262
- }
57589
+ var user = callUsers[userId];
57590
+ callStateController.appendUserToCallDiv(userId, callStateController.generateHTMLElements(userId));
57591
+ setTimeout(function () {
57592
+ callStateController.createTopic(userId, user[topicNameKey], mediaType, direction);
57593
+ })
57594
+ }
57595
+ },
57596
+ deactivateParticipantStream: function (userId, topicNameKey, mediaKey) {
57597
+ callUsers[userId][mediaKey] = false;
57598
+ var user = callUsers[userId];
57599
+ clearInterval(callUsers[userId].topicMetaData[user[topicNameKey]].interval)
57600
+ callStateController.removeTopic(userId, user[topicNameKey]);
57601
+ callStateController.removeStreamFromWebRTC(userId, user[topicNameKey]);
57602
+ },
57603
+ setMediaBitrates: function (sdp) {
57604
+ return this.setMediaBitrate(this.setMediaBitrate(sdp, "video", 400), "audio", 50);
57605
+ },
57606
+ setMediaBitrate: function (sdp, media, bitrate) {
57607
+ var lines = sdp.split("\n");
57608
+ var line = -1;
57609
+ for (var i = 0; i < lines.length; i++) {
57610
+ if (lines[i].indexOf("m=" + media) === 0) {
57611
+ line = i;
57612
+ break;
56263
57613
  }
57614
+ }
57615
+ if (line === -1) {
57616
+ consoleLogging && console.debug("[SDK][setMediaBitrate] Could not find the m line for", media);
57617
+ return sdp;
57618
+ }
57619
+ consoleLogging && console.debug("[SDK][setMediaBitrate] Found the m line for", media, "at line", line);
56264
57620
 
56265
- if (webpeers[topic].peerConnection.iceConnectionState === "connected") {
56266
- callRequestController.callEstablishedInMySide = true;
56267
- chatEvents.fireEvent('callEvents', {
56268
- type: 'CALL_STATUS',
56269
- errorCode: 7000,
56270
- errorMessage: `Call Peer (${topic}) has connected!`,
56271
- errorInfo: webpeers[topic]
56272
- });
57621
+ // Pass the m line
57622
+ line++;
56273
57623
 
56274
- /!*setTimeout(function () {
56275
- restartMedia(callTopics['sendVideoTopic'])
56276
- }, 2000);*!/
57624
+ // Skip i and c lines
57625
+ /* while (lines[line].indexOf("i=") === 0 || lines[line].indexOf("c=") === 0) {
57626
+ line++;
57627
+ }*/
56277
57628
 
56278
- /!*setTimeout(function () {
56279
- restartMedia(callTopics['sendVideoTopic'])
56280
- }, 6000);*!/
56281
- }
57629
+ // If we're on a b line, replace it
57630
+ if (lines[line].indexOf("b") === 0) {
57631
+ consoleLogging && console.debug("[SDK][setMediaBitrate] Replaced b line at line", line);
57632
+ lines[line] = "b=AS:" + bitrate;
57633
+ return lines.join("\n");
56282
57634
  }
56283
- }
56284
57635
 
57636
+ // Add a new b line
57637
+ consoleLogging && console.debug("[SDK][setMediaBitrate] Adding new b line before line", line);
57638
+ var newLines = lines.slice(0, line);
57639
+ newLines.push("b=AS:" + bitrate + "\r");
57640
+ newLines = newLines.concat(lines.slice(line, lines.length));
57641
+ consoleLogging && console.debug("[SDK][setMediaBitrate] output: ", newLines.join("\n"));
57642
+ return newLines.join("\n")
57643
+ },
56285
57644
  },
56286
- */
56287
57645
 
56288
57646
  sendCallSocketError = function (message) {
56289
57647
  chatEvents.fireEvent('callEvents', {
@@ -56298,7 +57656,7 @@ WildEmitter.mixin(WildEmitter);
56298
57656
  });
56299
57657
  },
56300
57658
 
56301
- explainUserMediaError = function (err, deviceType) {
57659
+ explainUserMediaError = function (err, deviceType, deviceSource) {
56302
57660
  chatEvents.fireEvent('callEvents', {
56303
57661
  type: 'CALL_ERROR',
56304
57662
  code: 7000,
@@ -56335,10 +57693,10 @@ WildEmitter.mixin(WildEmitter);
56335
57693
  chatEvents.fireEvent('callEvents', {
56336
57694
  type: 'CALL_ERROR',
56337
57695
  code: 7000,
56338
- message: (deviceType === 'video' ? 'Webcam' : 'Mice') + " permission has been denied by the user"
57696
+ message: (deviceType === 'video' ? (deviceSource === 'screen'? 'ScreenShare' : 'Webcam') : 'Mice') + " permission has been denied by the user"
56339
57697
  });
56340
- alert((deviceType === 'video' ? 'Webcam' : 'Mice') + " permission has been denied by the user");
56341
- return (deviceType === 'video' ? 'Webcam' : 'Mice') + " permission has been denied by the user";
57698
+ alert((deviceType === 'video' ? (deviceSource === 'screen'? 'ScreenShare' : 'Webcam') : 'Mice') + " permission has been denied by the user");
57699
+ return (deviceType === 'video' ? (deviceSource === 'screen'? 'ScreenShare' : 'Webcam') : 'Mice') + " permission has been denied by the user";
56342
57700
  } else if (n === 'TypeError') {
56343
57701
  chatEvents.fireEvent('callEvents', {
56344
57702
  type: 'CALL_ERROR',
@@ -56363,19 +57721,19 @@ WildEmitter.mixin(WildEmitter);
56363
57721
  },
56364
57722
 
56365
57723
  startMedia = function (media) {
56366
- consoleLogging && console.log("startMedia:: ", media);
57724
+ consoleLogging && console.log("[SDK][startMedia] called with: ", media);
56367
57725
  media.play().catch((err) => {
56368
57726
  if (err.name === 'NotAllowedError') {
56369
57727
  chatEvents.fireEvent('callEvents', {
56370
57728
  type: 'CALL_ERROR',
56371
57729
  code: 7000,
56372
- message: "[start] Browser doesn't allow playing media: " + err
57730
+ message: "[startMedia] Browser doesn't allow playing media: " + err
56373
57731
  });
56374
57732
  } else {
56375
57733
  chatEvents.fireEvent('callEvents', {
56376
57734
  type: 'CALL_ERROR',
56377
57735
  code: 7000,
56378
- message: "[start] Error in media.play(): " + err
57736
+ message: "[startMedia] Error in media.play(): " + err
56379
57737
  });
56380
57738
  }
56381
57739
  });
@@ -56383,9 +57741,9 @@ WildEmitter.mixin(WildEmitter);
56383
57741
 
56384
57742
  restartMedia = function (videoTopicParam) {
56385
57743
  if (currentCallParams && Object.keys(currentCallParams).length) {
56386
- consoleLogging && console.log('Sending Key Frame ...');
57744
+ consoleLogging && console.log('[SDK] Sending Key Frame ...');
56387
57745
 
56388
- var videoTopic = !!videoTopicParam ? videoTopicParam : callTopics['sendVideoTopic'];
57746
+ var videoTopic = !!videoTopicParam ? videoTopicParam : callUsers[chatMessaging.userInfo.id].videoTopicName;//callTopics['sendVideoTopic'];
56389
57747
  let videoElement = document.getElementById(`uiRemoteVideo-${videoTopic}`);
56390
57748
 
56391
57749
  if (videoElement) {
@@ -56439,19 +57797,20 @@ WildEmitter.mixin(WildEmitter);
56439
57797
  },
56440
57798
 
56441
57799
  handleProcessSdpAnswer = function (jsonMessage) {
56442
- let sampleWebRtc = webpeers[jsonMessage.topic];
57800
+ var userId = callStateController.findUserIdByTopic(jsonMessage.topic),
57801
+ peer = callUsers[userId].peers[jsonMessage.topic];
56443
57802
 
56444
- if (sampleWebRtc == null) {
57803
+ if (peer == null) {
56445
57804
  chatEvents.fireEvent('callEvents', {
56446
57805
  type: 'CALL_ERROR',
56447
57806
  code: 7000,
56448
57807
  message: "[handleProcessSdpAnswer] Skip, no WebRTC Peer",
56449
- error: webpeers[jsonMessage.topic]
57808
+ error: peer
56450
57809
  });
56451
57810
  return;
56452
57811
  }
56453
57812
 
56454
- sampleWebRtc.processAnswer(jsonMessage.sdpAnswer, (err) => {
57813
+ peer.processAnswer(jsonMessage.sdpAnswer, (err) => {
56455
57814
  if (err) {
56456
57815
  sendCallSocketError("[handleProcessSdpAnswer] Error: " + err);
56457
57816
 
@@ -56464,26 +57823,29 @@ WildEmitter.mixin(WildEmitter);
56464
57823
  return;
56465
57824
  }
56466
57825
 
56467
- if (webpeersMetadata[jsonMessage.topic].interval !== null) {
56468
- webpeersMetadata[jsonMessage.topic].sdpAnswerReceived = true;
57826
+ if (callUsers[userId].topicMetaData[jsonMessage.topic].interval !== null) {
57827
+ callUsers[userId].topicMetaData[jsonMessage.topic].sdpAnswerReceived = true;
56469
57828
  }
56470
- startMedia(uiRemoteMedias[jsonMessage.topic]);
57829
+ consoleLogging && console.log("[SDK][handleProcessSdpAnswer]", jsonMessage, jsonMessage.topic)
57830
+ startMedia(callUsers[userId].htmlElements[jsonMessage.topic]);
56471
57831
  });
56472
57832
  },
56473
57833
 
56474
57834
  handleAddIceCandidate = function (jsonMessage) {
56475
- let sampleWebRtc = webpeers[jsonMessage.topic];
56476
- if (sampleWebRtc == null) {
57835
+ var userId = callStateController.findUserIdByTopic(jsonMessage.topic);
57836
+
57837
+ let peer = callUsers[userId].peers[jsonMessage.topic];
57838
+ if (peer == null) {
56477
57839
  chatEvents.fireEvent('callEvents', {
56478
57840
  type: 'CALL_ERROR',
56479
57841
  code: 7000,
56480
57842
  message: "[handleAddIceCandidate] Skip, no WebRTC Peer",
56481
- error: JSON.stringify(webpeers[jsonMessage.topic])
57843
+ error: JSON.stringify(peer)
56482
57844
  });
56483
57845
  return;
56484
57846
  }
56485
57847
 
56486
- sampleWebRtc.addIceCandidate(jsonMessage.candidate, (err) => {
57848
+ peer.addIceCandidate(jsonMessage.candidate, (err) => {
56487
57849
  if (err) {
56488
57850
  console.error("[handleAddIceCandidate] " + err);
56489
57851
 
@@ -56522,19 +57884,7 @@ WildEmitter.mixin(WildEmitter);
56522
57884
  },
56523
57885
 
56524
57886
  callStop = function () {
56525
- consoleLogging && console.log('Call is stopping ...');
56526
-
56527
- for (var media in uiRemoteMedias) {
56528
- removeStreamFromWebRTC(media);
56529
- }
56530
-
56531
- for (var i in webpeers) {
56532
- if (webpeers[i]) {
56533
- callStateController.removeConnectionQualityInterval(i);
56534
- webpeers[i].dispose();
56535
- webpeers[i] = null;
56536
- }
56537
- }
57887
+ callStateController.removeAllCallParticipants();
56538
57888
 
56539
57889
  if (callStopQueue.callStarted) {
56540
57890
  sendCallMessage({
@@ -56543,6 +57893,7 @@ WildEmitter.mixin(WildEmitter);
56543
57893
  callStopQueue.callStarted = false;
56544
57894
  }
56545
57895
 
57896
+ callRequestController.cameraPaused = false;
56546
57897
  callRequestController.callEstablishedInMySide = false;
56547
57898
  callRequestController.callRequestReceived = false;
56548
57899
  currentCallParams = {};
@@ -56608,16 +57959,16 @@ WildEmitter.mixin(WildEmitter);
56608
57959
 
56609
57960
  case 'GET_KEY_FRAME':
56610
57961
  setTimeout(function () {
56611
- restartMedia(callTopics['sendVideoTopic']);
57962
+ restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
56612
57963
  }, 2000);
56613
57964
  setTimeout(function () {
56614
- restartMedia(callTopics['sendVideoTopic']);
57965
+ restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
56615
57966
  }, 4000);
56616
57967
  setTimeout(function () {
56617
- restartMedia(callTopics['sendVideoTopic']);
57968
+ restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
56618
57969
  }, 8000);
56619
57970
  setTimeout(function () {
56620
- restartMedia(callTopics['sendVideoTopic']);
57971
+ restartMedia(callUsers[chatMessaging.userInfo.id].videoTopicName);
56621
57972
  }, 12000);
56622
57973
  break;
56623
57974
 
@@ -56658,7 +58009,7 @@ WildEmitter.mixin(WildEmitter);
56658
58009
  break;
56659
58010
 
56660
58011
  default:
56661
- console.warn("[onmessage] Invalid message, id: " + jsonMessage.id, jsonMessage);
58012
+ console.warn("[SDK][onmessage] Invalid message, id: " + jsonMessage.id, jsonMessage);
56662
58013
  if (jsonMessage.match(/NOT CREATE SESSION/g)) {
56663
58014
  if (currentCallParams && Object.keys(currentCallParams)) {
56664
58015
  //handleCallSocketOpen(currentCallParams);
@@ -56670,7 +58021,11 @@ WildEmitter.mixin(WildEmitter);
56670
58021
  };
56671
58022
 
56672
58023
  this.asyncInitialized = function (async) {
56673
- asyncClient = async
58024
+ asyncClient = async;
58025
+
58026
+ asyncClient.on('asyncReady', function (){
58027
+ callStateController.maybeReconnectAllTopics();
58028
+ })
56674
58029
  };
56675
58030
 
56676
58031
  this.handleChatMessages = function(type, chatMessageVOTypes, messageContent, contentCount, threadId, uniqueId) {
@@ -56774,13 +58129,7 @@ WildEmitter.mixin(WildEmitter);
56774
58129
  result: messageContent
56775
58130
  });
56776
58131
 
56777
- for (var peer in webpeers) {
56778
- if (webpeers[peer]) {
56779
- webpeers[peer].dispose();
56780
- delete webpeers[peer];
56781
- }
56782
- }
56783
- webpeers = {};
58132
+ //callStateController.removeAllCallParticipants();
56784
58133
 
56785
58134
  if (typeof messageContent === 'object'
56786
58135
  && messageContent.hasOwnProperty('chatDataDto')
@@ -56793,8 +58142,10 @@ WildEmitter.mixin(WildEmitter);
56793
58142
  mute: messageContent.clientDTO.mute,
56794
58143
  sendingTopic: messageContent.clientDTO.topicSend,
56795
58144
  receiveTopic: messageContent.clientDTO.topicReceive,
58145
+ screenShare: messageContent.chatDataDto.screenShare,
56796
58146
  brokerAddress: messageContent.chatDataDto.brokerAddressWeb,
56797
58147
  turnAddress: messageContent.chatDataDto.turnAddress,
58148
+ clientsList: messageContent.otherClientDtoList
56798
58149
  }, function (callDivs) {
56799
58150
  chatEvents.fireEvent('callEvents', {
56800
58151
  type: 'CALL_DIVS',
@@ -56932,7 +58283,8 @@ WildEmitter.mixin(WildEmitter);
56932
58283
  });
56933
58284
 
56934
58285
  if (!!messageContent[0].sendTopic) {
56935
- removeFromCallUI(messageContent[0].sendTopic);
58286
+ //removeFromCallUI(messageContent[0].sendTopic);
58287
+ callStateController.removeFromCallUI(messageContent[0].sendTopic)
56936
58288
  }
56937
58289
 
56938
58290
  break;
@@ -57003,6 +58355,24 @@ WildEmitter.mixin(WildEmitter);
57003
58355
  case chatMessageVOTypes.MUTE_CALL_PARTICIPANT:
57004
58356
  if (chatMessaging.messagesCallbacks[uniqueId]) {
57005
58357
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58358
+ } else {
58359
+ if(Array.isArray(messageContent)){
58360
+ for(var i in messageContent) {
58361
+ callStateController.deactivateParticipantStream(
58362
+ messageContent[i].userId,
58363
+ 'audioTopicName',
58364
+ 'mute'
58365
+ )
58366
+ /*if(callUsers[messageContent[i].userId]) {
58367
+ callUsers[messageContent[i].userId].mute = true;
58368
+
58369
+ var user = callUsers[messageContent[i].userId];
58370
+ clearInterval(callUsers[messageContent[i].userId].topicMetaData[user.audioTopicName].interval)
58371
+ callStateController.removeTopic(messageContent[i].userId, user.audioTopicName);
58372
+ callStateController.removeStreamFromWebRTC(messageContent[i].userId, user.audioTopicName);
58373
+ }*/
58374
+ }
58375
+ }
57006
58376
  }
57007
58377
 
57008
58378
  chatEvents.fireEvent('callEvents', {
@@ -57018,6 +58388,30 @@ WildEmitter.mixin(WildEmitter);
57018
58388
  case chatMessageVOTypes.UNMUTE_CALL_PARTICIPANT:
57019
58389
  if (chatMessaging.messagesCallbacks[uniqueId]) {
57020
58390
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58391
+ } else {
58392
+ if(Array.isArray(messageContent)) {
58393
+ for(var i in messageContent) {
58394
+ callStateController.activateParticipantStream(
58395
+ messageContent[i].userId,
58396
+ 'audio',
58397
+ 'receive',
58398
+ 'audioTopicName',
58399
+ messageContent[i].sendTopic,
58400
+ 'mute'
58401
+ );
58402
+ /*if(callUsers[messageContent[i].userId]) {
58403
+ callUsers[messageContent[i].userId].mute = false;
58404
+ callUsers[messageContent[i].userId].audioTopicName = 'Vo-' + messageContent[i].sendTopic;
58405
+
58406
+ var user = callUsers[messageContent[i].userId];
58407
+ callStateController.appendUserToCallDiv(messageContent[i].userId, callStateController.generateHTMLElements(messageContent[i].userId));
58408
+ setTimeout(function () {
58409
+ callStateController.createTopic(messageContent[i].userId, user.audioTopicName, 'audio', 'receive');
58410
+
58411
+ })
58412
+ }*/
58413
+ }
58414
+ }
57021
58415
  }
57022
58416
 
57023
58417
  chatEvents.fireEvent('callEvents', {
@@ -57058,8 +58452,38 @@ WildEmitter.mixin(WildEmitter);
57058
58452
  case chatMessageVOTypes.TURN_ON_VIDEO_CALL:
57059
58453
  if (chatMessaging.messagesCallbacks[uniqueId]) {
57060
58454
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58455
+ } else {
58456
+ if(Array.isArray(messageContent)) {
58457
+ for(var i in messageContent) {
58458
+ callStateController.activateParticipantStream(
58459
+ messageContent[i].userId,
58460
+ 'video',
58461
+ 'receive',
58462
+ 'videoTopicName',
58463
+ messageContent[i].sendTopic,
58464
+ 'video'
58465
+ );
58466
+ /*if(callUsers[messageContent[i].userId]) {
58467
+ callUsers[messageContent[i].userId].video = true;
58468
+ callUsers[messageContent[i].userId].videoTopicName = 'Vi-' + messageContent[i].sendTopic;
58469
+
58470
+ var user = callUsers[messageContent[i].userId];
58471
+ callStateController.appendUserToCallDiv(messageContent[i].userId, callStateController.generateHTMLElements(messageContent[i].userId));
58472
+ setTimeout(function () {
58473
+ callStateController.createTopic(messageContent[i].userId, user.videoTopicName, 'video', 'receive');
58474
+ })
58475
+ }*/
58476
+ }
58477
+ }
57061
58478
  }
57062
58479
 
58480
+ setTimeout(function () {
58481
+ chatEvents.fireEvent('callEvents', {
58482
+ type: 'CALL_DIVS',
58483
+ result: generateCallUIList()
58484
+ });
58485
+ })
58486
+
57063
58487
  chatEvents.fireEvent('callEvents', {
57064
58488
  type: 'TURN_ON_VIDEO_CALL',
57065
58489
  result: messageContent
@@ -57073,8 +58497,32 @@ WildEmitter.mixin(WildEmitter);
57073
58497
  case chatMessageVOTypes.TURN_OFF_VIDEO_CALL:
57074
58498
  if (chatMessaging.messagesCallbacks[uniqueId]) {
57075
58499
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58500
+ } else {
58501
+ if(Array.isArray(messageContent)){
58502
+ for(var i in messageContent) {
58503
+ callStateController.deactivateParticipantStream(
58504
+ messageContent[i].userId,
58505
+ 'videoTopicName',
58506
+ 'video'
58507
+ )
58508
+ /* if(callUsers[messageContent[i].userId]) {
58509
+ callUsers[messageContent[i].userId].video = false;
58510
+ var user = callUsers[messageContent[i].userId];
58511
+ clearInterval(callUsers[messageContent[i].userId].topicMetaData[user.videoTopicName].interval)
58512
+ callStateController.removeTopic(messageContent[i].userId, user.videoTopicName);
58513
+ callStateController.removeStreamFromWebRTC(messageContent[i].userId, user.videoTopicName);
58514
+ }*/
58515
+ }
58516
+ }
57076
58517
  }
57077
58518
 
58519
+ setTimeout(function () {
58520
+ chatEvents.fireEvent('callEvents', {
58521
+ type: 'CALL_DIVS',
58522
+ result: generateCallUIList()
58523
+ });
58524
+ })
58525
+
57078
58526
  chatEvents.fireEvent('callEvents', {
57079
58527
  type: 'TURN_OFF_VIDEO_CALL',
57080
58528
  result: messageContent
@@ -57118,8 +58566,20 @@ WildEmitter.mixin(WildEmitter);
57118
58566
  * Type 123 Start Screen Share
57119
58567
  */
57120
58568
  case chatMessageVOTypes.START_SCREEN_SHARE:
58569
+ if(!callRequestController.callEstablishedInMySide)
58570
+ return;
58571
+
58572
+ screenShareState.started = true;
58573
+ if(messageContent.screenOwner.id === chatMessaging.userInfo.id) {
58574
+ screenShareState.imOwner = true;
58575
+ } else {
58576
+ screenShareState.imOwner = false;
58577
+ }
58578
+
57121
58579
  if (chatMessaging.messagesCallbacks[uniqueId]) {
57122
58580
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58581
+ } else if(!screenShareState.imOwner) {
58582
+ callStateController.addScreenShareToCall("receive", false)
57123
58583
  }
57124
58584
 
57125
58585
  chatEvents.fireEvent('callEvents', {
@@ -57133,8 +58593,14 @@ WildEmitter.mixin(WildEmitter);
57133
58593
  * Type 124 End Screen Share
57134
58594
  */
57135
58595
  case chatMessageVOTypes.END_SCREEN_SHARE:
58596
+ screenShareState.imOwner = false;
58597
+ screenShareState.started = false;
58598
+
57136
58599
  if (chatMessaging.messagesCallbacks[uniqueId]) {
57137
58600
  chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58601
+ } else if (!screenShareState.imOwner) {
58602
+ consoleLogging && console.log("[SDK][END_SCREEN_SHARE], im not owner of screen");
58603
+ callStateController.removeScreenShareFromCall();
57138
58604
  }
57139
58605
 
57140
58606
  chatEvents.fireEvent('callEvents', {
@@ -57157,6 +58623,25 @@ WildEmitter.mixin(WildEmitter);
57157
58623
  result: messageContent
57158
58624
  });
57159
58625
 
58626
+ break;
58627
+ /**
58628
+ * Type 126 Destinated Record Call Request
58629
+ */
58630
+ case chatMessageVOTypes.DESTINATED_RECORD_CALL:
58631
+ if(!callRequestController.callEstablishedInMySide)
58632
+ return;
58633
+
58634
+ if (chatMessaging.messagesCallbacks[uniqueId]) {
58635
+ chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
58636
+ }
58637
+
58638
+ chatEvents.fireEvent('callEvents', {
58639
+ type: 'START_RECORDING_CALL',
58640
+ result: messageContent
58641
+ });
58642
+
58643
+ restartMedia(callTopics['sendVideoTopic']);
58644
+
57160
58645
  break;
57161
58646
  }
57162
58647
  }
@@ -57219,6 +58704,7 @@ WildEmitter.mixin(WildEmitter);
57219
58704
  return;
57220
58705
  }
57221
58706
 
58707
+ callRequestController.cameraPaused = (typeof params.cameraPaused === 'boolean') ? params.cameraPaused : false;
57222
58708
  callRequestController.callRequestReceived = true;
57223
58709
  callRequestController.callEstablishedInMySide = true;
57224
58710
 
@@ -57352,6 +58838,8 @@ WildEmitter.mixin(WildEmitter);
57352
58838
 
57353
58839
  content.videoCall = content.video;
57354
58840
 
58841
+ callRequestController.cameraPaused = (typeof params.cameraPaused === 'boolean') ? params.cameraPaused : callRequestController.cameraPaused;
58842
+
57355
58843
  if (params.clientType && typeof params.clientType === 'string' && callClientTypes[params.clientType.toUpperCase()] > 0) {
57356
58844
  content.clientType = callClientTypes[params.clientType.toUpperCase()];
57357
58845
  } else {
@@ -57414,7 +58902,8 @@ WildEmitter.mixin(WildEmitter);
57414
58902
  chatMessageVOType: chatMessageVOTypes.RECORD_CALL,
57415
58903
  typeCode: params.typeCode,
57416
58904
  pushMsgType: 3,
57417
- token: token
58905
+ token: token,
58906
+ content: {}
57418
58907
  };
57419
58908
 
57420
58909
  if (params) {
@@ -57427,6 +58916,13 @@ WildEmitter.mixin(WildEmitter);
57427
58916
  });
57428
58917
  return;
57429
58918
  }
58919
+
58920
+ if(params.destinated === true) {
58921
+ recordCallData.chatMessageVOType = chatMessageVOTypes.DESTINATED_RECORD_CALL;
58922
+ recordCallData.content.recordType = typeof +params.recordType === 'number' ? params.recordType : 1;
58923
+ recordCallData.content.tags = Array.isArray(params.tags) ? params.tags : null;
58924
+ recordCallData.content.threadId = typeof +params.threadId === 'number' ? params.threadId : null;
58925
+ }
57430
58926
  } else {
57431
58927
  chatEvents.fireEvent('error', {
57432
58928
  code: 999,
@@ -57502,8 +58998,26 @@ WildEmitter.mixin(WildEmitter);
57502
58998
  return;
57503
58999
  }
57504
59000
 
59001
+ /*if(screenShareState.started) {
59002
+ chatEvents.fireEvent('error', {
59003
+ code: 999,
59004
+ message: "ScreenShare has already started"
59005
+ });
59006
+ console.log("ScreenShare has already started");
59007
+ return
59008
+ }*/
59009
+
57505
59010
  return chatMessaging.sendMessage(sendData, {
57506
59011
  onResult: function (result) {
59012
+ consoleLogging && console.log("[sdk][startScreenShare][onResult]: ", result);
59013
+ if(!result.hasError) {
59014
+ var direction = 'send', shareScreen = true;
59015
+ if(screenShareState.started && !screenShareState.imOwner) {
59016
+ direction = 'receive';
59017
+ shareScreen = false;
59018
+ }
59019
+ callStateController.addScreenShareToCall(direction, shareScreen);
59020
+ }
57507
59021
  callback && callback(result);
57508
59022
  }
57509
59023
  });
@@ -57535,6 +59049,20 @@ WildEmitter.mixin(WildEmitter);
57535
59049
  return;
57536
59050
  }
57537
59051
 
59052
+ if(!screenShareState.imOwner) {
59053
+ chatEvents.fireEvent('error', {
59054
+ code: 999,
59055
+ message: 'You can not end others screen sharing!'
59056
+ });
59057
+ return;
59058
+ }
59059
+
59060
+ if(!callUsers['screenShare'].peers[callUsers['screenShare'].videoTopicName]) {
59061
+ consoleLogging && console.log('[SDK][endScreenShare] No screenShare connection available');
59062
+ } else {
59063
+ callStateController.removeScreenShareFromCall();
59064
+ }
59065
+
57538
59066
  return chatMessaging.sendMessage(sendData, {
57539
59067
  onResult: function (result) {
57540
59068
  callback && callback(result);
@@ -57854,6 +59382,15 @@ WildEmitter.mixin(WildEmitter);
57854
59382
  sendMessageParams.content = params.userIds;
57855
59383
  }
57856
59384
  }
59385
+ callStateController.deactivateParticipantStream(
59386
+ chatMessaging.userInfo.id,
59387
+ 'audioTopicName',
59388
+ 'mute'
59389
+ )
59390
+ /*
59391
+ callStateController.removeTopic(chatMessaging.userInfo.id, callUsers[chatMessaging.userInfo.id].audioTopicName)
59392
+ callStateController.removeStreamFromWebRTC(chatMessaging.userInfo.id, callUsers[chatMessaging.userInfo.id].audioTopicName)
59393
+ */
57857
59394
 
57858
59395
  return chatMessaging.sendMessage(sendMessageParams, {
57859
59396
  onResult: function (result) {
@@ -57895,6 +59432,26 @@ WildEmitter.mixin(WildEmitter);
57895
59432
  sendMessageParams.content = params.userIds;
57896
59433
  }
57897
59434
  }
59435
+ var myId = chatMessaging.userInfo.id;
59436
+
59437
+ callStateController.activateParticipantStream(
59438
+ myId,
59439
+ 'audio',
59440
+ 'send',
59441
+ 'audioTopicName',
59442
+ callUsers[myId].topicSend,
59443
+ 'mute'
59444
+ );
59445
+ /*if(callUsers[myId]) {
59446
+ callUsers[myId].mute = false;
59447
+ callUsers[myId].audioTopicName = 'Vo-' + callUsers[myId].topicSend;
59448
+
59449
+ var user = callUsers[myId];
59450
+ callStateController.appendUserToCallDiv(myId, callStateController.generateHTMLElements(myId));
59451
+ setTimeout(function () {
59452
+ callStateController.createTopic(myId, user.audioTopicName, 'audio', 'send');
59453
+ })
59454
+ }*/
57898
59455
 
57899
59456
  return chatMessaging.sendMessage(sendMessageParams, {
57900
59457
  onResult: function (result) {
@@ -57908,6 +59465,19 @@ WildEmitter.mixin(WildEmitter);
57908
59465
  // TODO : What is the result?!
57909
59466
  var messageContent = result.result;
57910
59467
  returnData.result = messageContent;
59468
+
59469
+ /*for(var i in result.result) {
59470
+ if(callUsers[result.result[i].userId]) {
59471
+ callUsers[result.result[i].userId].mute = false;
59472
+ callUsers[result.result[i].userId].audioTopicName = 'Vo-' + result.result[i].sendTopic;
59473
+
59474
+ var user = callUsers[result.result[i].userId];
59475
+ callStateController.appendUserToCallDiv(result.result[i].userId, callStateController.generateHTMLElements(result.result[i].userId));
59476
+ setTimeout(function () {
59477
+ callStateController.createTopic(result.result[i].userId, user.audioTopicName, 'audio', 'send');
59478
+ })
59479
+ }
59480
+ }*/
57911
59481
  }
57912
59482
  callback && callback(returnData);
57913
59483
  }
@@ -57942,6 +59512,29 @@ WildEmitter.mixin(WildEmitter);
57942
59512
 
57943
59513
  return chatMessaging.sendMessage(turnOnVideoData, {
57944
59514
  onResult: function (result) {
59515
+ if(!result.hasError && Array.isArray(result.result)) {
59516
+ for(var i in result.result) {
59517
+ callStateController.activateParticipantStream(
59518
+ result.result[i].userId,
59519
+ 'video',
59520
+ 'send',
59521
+ 'videoTopicName',
59522
+ result.result[i].sendTopic,
59523
+ 'video'
59524
+ );
59525
+ /*if(callUsers[result.result[i].userId]) {
59526
+ callUsers[result.result[i].userId].video = true;
59527
+ callUsers[result.result[i].userId].mute = result.result[i].mute;
59528
+ callUsers[result.result[i].userId].videoTopicName = 'Vi-' + result.result[i].sendTopic;
59529
+
59530
+ var user = callUsers[result.result[i].userId];
59531
+ callStateController.appendUserToCallDiv(result.result[i].userId, callStateController.generateHTMLElements(result.result[i].userId));
59532
+ setTimeout(function () {
59533
+ callStateController.createTopic(result.result[i].userId, user.videoTopicName, 'video', 'send');
59534
+ })
59535
+ }*/
59536
+ }
59537
+ }
57945
59538
  callback && callback(result);
57946
59539
  }
57947
59540
  });
@@ -57973,6 +59566,16 @@ WildEmitter.mixin(WildEmitter);
57973
59566
  return;
57974
59567
  }
57975
59568
 
59569
+ callStateController.deactivateParticipantStream(
59570
+ chatMessaging.userInfo.id,
59571
+ 'videoTopicName',
59572
+ 'video'
59573
+ )
59574
+ /*
59575
+ callStateController.removeTopic(chatMessaging.userInfo.id, callUsers[chatMessaging.userInfo.id].videoTopicName)
59576
+ callStateController.removeStreamFromWebRTC(chatMessaging.userInfo.id, callUsers[chatMessaging.userInfo.id].videoTopicName)
59577
+ */
59578
+
57976
59579
  return chatMessaging.sendMessage(turnOffVideoData, {
57977
59580
  onResult: function (result) {
57978
59581
  callback && callback(result);
@@ -57980,6 +59583,53 @@ WildEmitter.mixin(WildEmitter);
57980
59583
  });
57981
59584
  };
57982
59585
 
59586
+ /**
59587
+ * Pauses camera-send without closing its topic
59588
+ * @param params
59589
+ * @param callback
59590
+ */
59591
+ this.pauseCamera = function (params, callback) {
59592
+ var me = callUsers[chatMessaging.userInfo.id];
59593
+
59594
+ if(!Object.keys(callUsers).length || !me.videoTopicName || !me.peers[me.videoTopicName])
59595
+ return;
59596
+
59597
+ me.peers[me.videoTopicName].getLocalStream().getTracks()[0].enabled = false;
59598
+ callback && callback();
59599
+ };
59600
+
59601
+ this.resumeCamera = function (params, callback) {
59602
+ var me = callUsers[chatMessaging.userInfo.id]
59603
+ if(!Object.keys(callUsers).length || !me.videoTopicName || !me.peers[me.videoTopicName])
59604
+ return;
59605
+
59606
+ me.peers[me.videoTopicName].getLocalStream().getTracks()[0].enabled = true;
59607
+ callback && callback();
59608
+ };
59609
+
59610
+ /**
59611
+ * Pauses mice-send without closing its topic
59612
+ * @param params
59613
+ * @param callback
59614
+ */
59615
+ this.pauseMice = function (params, callback) {
59616
+ var me = callUsers[chatMessaging.userInfo.id];
59617
+ if(!Object.keys(callUsers).length || !me.audioTopicName || !me.peers[me.audioTopicName])
59618
+ return;
59619
+
59620
+ me.peers[me.audioTopicName].getLocalStream().getTracks()[0].enabled = false;
59621
+ callback && callback();
59622
+ };
59623
+
59624
+ this.resumeMice = function (params, callback) {
59625
+ var me = callUsers[chatMessaging.userInfo.id];
59626
+ if(!Object.keys(callUsers).length || !me.audioTopicName || !me.peers[me.audioTopicName])
59627
+ return;
59628
+
59629
+ me.peers[me.audioTopicName].getLocalStream().getTracks()[0].enabled = true;
59630
+ callback && callback();
59631
+ };
59632
+
57983
59633
  this.resizeCallVideo = function (params, callback) {
57984
59634
  if (params) {
57985
59635
  if (!!params.width && +params.width > 0) {
@@ -57990,13 +59640,19 @@ WildEmitter.mixin(WildEmitter);
57990
59640
  callVideoMinHeight = +params.height;
57991
59641
  }
57992
59642
 
57993
- webpeers[callTopics['sendVideoTopic']].getLocalStream().getTracks()[0].applyConstraints({
59643
+ if(!callUsers[chatMessaging.userInfo.id]){
59644
+ consoleLogging && console.log("Error in resizeCallVideo(), call not started ");
59645
+ return;
59646
+ }
59647
+
59648
+ var userObject = callUsers[chatMessaging.userInfo.id]
59649
+ userObject.peers[userObject.videoTopicName].getLocalStream().getTracks()[0].applyConstraints({
57994
59650
  "width": callVideoMinWidth,
57995
59651
  "height": callVideoMinHeight
57996
59652
  })
57997
59653
  .then((res) => {
57998
- uiRemoteMedias[callTopics['sendVideoTopic']].style.width = callVideoMinWidth + 'px';
57999
- uiRemoteMedias[callTopics['sendVideoTopic']].style.height = callVideoMinHeight + 'px';
59654
+ userObject.htmlElements[userObject.videoTopicName].style.width = callVideoMinWidth + 'px';
59655
+ userObject.htmlElements[userObject.videoTopicName].style.height = callVideoMinHeight + 'px';
58000
59656
  callback && callback();
58001
59657
  })
58002
59658
  .catch((e) => {
@@ -58029,7 +59685,7 @@ WildEmitter.mixin(WildEmitter);
58029
59685
  }
58030
59686
  })();
58031
59687
 
58032
- },{"kurento-utils":297,"webrtc-adapter":317}],330:[function(require,module,exports){
59688
+ },{"kurento-utils":298,"webrtc-adapter":318}],331:[function(require,module,exports){
58033
59689
  'use strict';
58034
59690
 
58035
59691
  (function () {
@@ -58222,6 +59878,7 @@ WildEmitter.mixin(WildEmitter);
58222
59878
  START_SCREEN_SHARE: 123,
58223
59879
  END_SCREEN_SHARE: 124,
58224
59880
  DELETE_FROM_CALL_HISTORY: 125,
59881
+ DESTINATED_RECORD_CALL: 126,
58225
59882
  MUTUAL_GROUPS: 130,
58226
59883
  CREATE_TAG: 140,
58227
59884
  EDIT_TAG: 141,
@@ -58230,6 +59887,7 @@ WildEmitter.mixin(WildEmitter);
58230
59887
  REMOVE_TAG_PARTICIPANT: 144,
58231
59888
  GET_TAG_LIST: 145,
58232
59889
  DELETE_MESSAGE_THREAD: 151,
59890
+ EXPORT_CHAT: 152,
58233
59891
  ERROR: 999
58234
59892
  },
58235
59893
  inviteeVOidTypes = {
@@ -61279,6 +62937,16 @@ WildEmitter.mixin(WildEmitter);
61279
62937
 
61280
62938
  break;
61281
62939
 
62940
+ /**
62941
+ * Type 152 Gives us a json to export for user
62942
+ */
62943
+ case chatMessageVOTypes.EXPORT_CHAT:
62944
+ if (chatMessaging.messagesCallbacks[uniqueId]) {
62945
+ chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount, uniqueId));
62946
+ }
62947
+
62948
+ break;
62949
+
61282
62950
  /**
61283
62951
  * Type 999 All unknown errors
61284
62952
  */
@@ -66695,9 +68363,6 @@ WildEmitter.mixin(WildEmitter);
66695
68363
  }
66696
68364
  },
66697
68365
 
66698
-
66699
-
66700
-
66701
68366
  /**
66702
68367
  * Delete Cache Database
66703
68368
  *
@@ -67167,6 +68832,8 @@ WildEmitter.mixin(WildEmitter);
67167
68832
  putInChatWaitQueue(params.message, function () {
67168
68833
  callback && callback();
67169
68834
  });
68835
+ } else {
68836
+ callback && callback();
67170
68837
  }
67171
68838
  },
67172
68839
 
@@ -67339,7 +69006,7 @@ WildEmitter.mixin(WildEmitter);
67339
69006
  callbacks: callbacks
67340
69007
  }, function () {
67341
69008
  callback && callback();
67342
- });
69009
+ }, true);
67343
69010
  });
67344
69011
  break;
67345
69012
  }
@@ -69410,7 +71077,7 @@ WildEmitter.mixin(WildEmitter);
69410
71077
  callbacks: callbacks
69411
71078
  }, function () {
69412
71079
  chatSendQueueHandler();
69413
- });
71080
+ }, true);
69414
71081
  };
69415
71082
 
69416
71083
  this.deliver = function (params) {
@@ -71525,6 +73192,157 @@ WildEmitter.mixin(WildEmitter);
71525
73192
  removeRoleFromUser(params, callback);
71526
73193
  };
71527
73194
 
73195
+ function requestExportChat(stackArr, wantedCount, stepCount, offset, sendData) {
73196
+ sendData.content.offset = offset;
73197
+ sendData.content.count = stepCount;
73198
+ return new Promise(function(resolve, reject){
73199
+ return chatMessaging.sendMessage(sendData, {
73200
+ onResult: function (result) {
73201
+ var returnData = {
73202
+ hasError: result.hasError,
73203
+ cache: false,
73204
+ errorMessage: result.errorMessage,
73205
+ errorCode: result.errorCode
73206
+ };
73207
+
73208
+ if (!returnData.hasError) {
73209
+ for(var i in result.result) {
73210
+ stackArr.push(result.result[i]);
73211
+ }
73212
+
73213
+ consoleLogging && console.log("[SDK][exportChat] a step passed...");
73214
+ wantedCount = wantedCount > result.contentCount ? result.contentCount : wantedCount;
73215
+ setTimeout(function () {
73216
+ chatEvents.fireEvent('threadEvents', {
73217
+ type: 'EXPORT_CHAT',
73218
+ subType: 'IN_PROGRESS',
73219
+ threadId: sendData.subjectId,
73220
+ percent: Math.floor((stackArr.length / wantedCount) * 100)
73221
+ });
73222
+
73223
+ if(stackArr.length < wantedCount) {
73224
+ stepCount = wantedCount - stackArr.length < stepCount ? wantedCount - stackArr.length : stepCount;
73225
+ resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData));
73226
+ } else {
73227
+ resolve(stackArr);
73228
+ }
73229
+ });
73230
+ /*returnData.result = result;*/
73231
+ /*var messageContent = result.result,
73232
+ messageLength = messageContent.length,
73233
+ resultData = {
73234
+ participants: formatDataToMakeAssistantHistoryList(messageContent),
73235
+ contentCount: result.contentCount,
73236
+ hasNext: (sendData.content.offset + sendData.content.count < result.contentCount && messageLength > 0),
73237
+ nextOffset: sendData.content.offset * 1 + messageLength * 1
73238
+ };
73239
+
73240
+ returnData.result = resultData;*/
73241
+ } else {
73242
+ consoleLogging && console.log("[SDK][exportChat] Problem in one step... . Rerunning the request.", wantedCount, stepCount, stackArr.length, sendData, result);
73243
+ resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData))
73244
+ }
73245
+ }
73246
+ });
73247
+ })
73248
+ }
73249
+
73250
+ this.exportChat = function (params, callback) {
73251
+ var stackArr = [], wantedCount = 10000, stepCount = 500, offset = 0;
73252
+ var sendData = {
73253
+ chatMessageVOType: chatMessageVOTypes.EXPORT_CHAT,
73254
+ typeCode: params.typeCode,
73255
+ content: {
73256
+ offset: +params.offset > 0 ? +params.offset : offset,
73257
+ count: +params.count > 0 ? +params.count : wantedCount,//config.getHistoryCount,
73258
+ },
73259
+ subjectId: params.threadId
73260
+ };
73261
+
73262
+ if (+params.fromTime > 0 && +params.fromTime < 9999999999999) {
73263
+ sendData.content.fromTime = +params.fromTime;
73264
+ }
73265
+
73266
+ if (+params.toTime > 0 && +params.toTime < 9999999999999) {
73267
+ sendData.content.toTime = +params.toTime;
73268
+ }
73269
+
73270
+ if(+params.wantedCount > 0) {
73271
+ wantedCount = params.wantedCount;
73272
+ }
73273
+
73274
+ if(+params.stepCount > 0) {
73275
+ stepCount = params.stepCount;
73276
+ }
73277
+
73278
+ if(+params.offset > 0) {
73279
+ offset = params.offset;
73280
+ }
73281
+
73282
+ if (params.messageType && typeof params.messageType.toUpperCase() !== 'undefined' && chatMessageTypes[params.messageType.toUpperCase()] > 0) {
73283
+ sendData.content.messageType = chatMessageTypes[params.messageType.toUpperCase()];
73284
+ }
73285
+
73286
+ if(wantedCount < stepCount)
73287
+ stepCount = wantedCount;
73288
+
73289
+ consoleLogging && console.log("[SDK][exportChat] Starting...");
73290
+ requestExportChat(stackArr, wantedCount, stepCount, offset, sendData).then(function (result) {
73291
+ consoleLogging && console.log("[SDK][exportChat] Export done..., Now converting...");
73292
+
73293
+ var exportedFilename = 'export-' + params.threadId + '.csv',
73294
+ responseType = params.responseType !== null ? params.responseType : "blob",
73295
+ autoStartDownload = params.autoStartDownload !== null ? params.autoStartDownload : true
73296
+
73297
+ var blob = new Blob([Utility.convertToCSV(result)], { type: 'text/csv;charset=utf-8;' });
73298
+ chatEvents.fireEvent('threadEvents', {
73299
+ type: 'EXPORT_CHAT',
73300
+ subType: 'DONE',
73301
+ threadId: sendData.subjectId,
73302
+ result: blob
73303
+ });
73304
+
73305
+ /*if (navigator.msSaveBlob) { // IE 10+
73306
+ if(params.autoStartDownload) {
73307
+ navigator.msSaveBlob(blob, exportedFilename);
73308
+ }
73309
+ callback && callback({
73310
+ hasError: false,
73311
+ type: 'blob',
73312
+ result: blob
73313
+ });
73314
+ } else {*/
73315
+ if(responseType === 'link') {
73316
+ var link = document.createElement("a"),
73317
+ url = URL.createObjectURL(blob);
73318
+ //if (link.download !== undefined) { // feature detection
73319
+ // Browsers that support HTML5 download attribute
73320
+ link.setAttribute("href", url);
73321
+ link.setAttribute("download", exportedFilename);
73322
+ if(autoStartDownload) {
73323
+ link.style.visibility = 'hidden';
73324
+ document.body.appendChild(link);
73325
+ link.click();
73326
+ document.body.removeChild(link);
73327
+ }
73328
+ //}
73329
+ callback && callback({
73330
+ hasError: false,
73331
+ type: 'link',
73332
+ result: link
73333
+ });
73334
+ } else {
73335
+ callback && callback({
73336
+ hasError: false,
73337
+ type: 'blob',
73338
+ result: blob
73339
+ });
73340
+ }
73341
+ //}
73342
+ callback = undefined;
73343
+ });
73344
+ }
73345
+
71528
73346
  this.startCall = callModule.startCall;
71529
73347
 
71530
73348
  this.startGroupCall = callModule.startGroupCall;
@@ -71565,6 +73383,14 @@ WildEmitter.mixin(WildEmitter);
71565
73383
 
71566
73384
  this.turnOffVideoCall = callModule.turnOffVideoCall;
71567
73385
 
73386
+ this.pauseCamera = callModule.pauseCamera;
73387
+
73388
+ this.resumeCamera = callModule.resumeCamera;
73389
+
73390
+ this.pauseMice = callModule.pauseMice;
73391
+
73392
+ this.resumeMice = callModule.resumeMice;
73393
+
71568
73394
  this.resizeCallVideo = callModule.resizeCallVideo;
71569
73395
 
71570
73396
  this.restartMedia = callModule.restartMedia;
@@ -71807,7 +73633,7 @@ WildEmitter.mixin(WildEmitter);
71807
73633
  }
71808
73634
  })();
71809
73635
 
71810
- },{"./call.module.js":329,"./events.module.js":331,"./messaging.module.js":332,"./utility/utility.js":333,"@sentry/browser":194,"dexie":288,"podasync-ws-only":300}],331:[function(require,module,exports){
73636
+ },{"./call.module.js":330,"./events.module.js":332,"./messaging.module.js":333,"./utility/utility.js":334,"@sentry/browser":194,"dexie":288,"podasync-ws-only":301}],332:[function(require,module,exports){
71811
73637
  (function () {
71812
73638
  /**
71813
73639
  * Global Variables
@@ -71817,6 +73643,7 @@ WildEmitter.mixin(WildEmitter);
71817
73643
  //if (typeof (require) !== 'undefined' && typeof (exports) !== 'undefined') {} else {}
71818
73644
 
71819
73645
  var Sentry = params.Sentry,
73646
+ currentModuleInstance = this,
71820
73647
  Utility = params.Utility,
71821
73648
  consoleLogging = params.consoleLogging,
71822
73649
  token = params.token,
@@ -71928,11 +73755,12 @@ WildEmitter.mixin(WildEmitter);
71928
73755
  }
71929
73756
  })();
71930
73757
 
71931
- },{}],332:[function(require,module,exports){
73758
+ },{}],333:[function(require,module,exports){
71932
73759
  (function () {
71933
73760
  /**
71934
73761
  * Global Variables
71935
73762
  */
73763
+ var DOMPurify;
71936
73764
 
71937
73765
  /**
71938
73766
  * Communicates with chat server
@@ -71940,7 +73768,11 @@ WildEmitter.mixin(WildEmitter);
71940
73768
  * @constructor
71941
73769
  */
71942
73770
  function ChatMessaging(params) {
71943
- //if (typeof (require) !== 'undefined' && typeof (exports) !== 'undefined') {} else {}
73771
+ if (typeof (require) !== 'undefined' && typeof (exports) !== 'undefined') {
73772
+ DOMPurify = require('dompurify');
73773
+ } else {
73774
+ DOMPurify = window.DOMPurify;
73775
+ }
71944
73776
 
71945
73777
  var currentModuleInstance = this,
71946
73778
  asyncClient = params.asyncClient,
@@ -72043,6 +73875,9 @@ WildEmitter.mixin(WildEmitter);
72043
73875
  messageVO.content = JSON.stringify(params.content);
72044
73876
  } else {
72045
73877
  messageVO.content = params.content;
73878
+ if(DOMPurify.isSupported) {
73879
+ messageVO.content = DOMPurify.sanitize(messageVO.content, {ALLOWED_TAGS: []});
73880
+ }
72046
73881
  }
72047
73882
  }
72048
73883
 
@@ -72232,7 +74067,7 @@ WildEmitter.mixin(WildEmitter);
72232
74067
  }
72233
74068
  })();
72234
74069
 
72235
- },{}],333:[function(require,module,exports){
74070
+ },{"dompurify":289}],334:[function(require,module,exports){
72236
74071
  (function (global){(function (){
72237
74072
  (function() {
72238
74073
 
@@ -72781,6 +74616,31 @@ WildEmitter.mixin(WildEmitter);
72781
74616
  console.log("Error happened at Utility.jsonParser function()", e);
72782
74617
  }
72783
74618
  };
74619
+
74620
+ /**
74621
+ * Export given json to csv
74622
+ *
74623
+ * @param objArray
74624
+ * @return {string}
74625
+ */
74626
+ this.convertToCSV = function(objArray) {
74627
+ var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
74628
+ var str = '';
74629
+
74630
+ for (var i = 0; i < array.length; i++) {
74631
+ var line = '';
74632
+ for (var index in array[i]) {
74633
+ if (line != '') line += ','
74634
+
74635
+ line += index;
74636
+ line += ": " + (typeof array[i][index] !== 'string' ? JSON.stringify(array[i][index]).replaceAll(",", ".") : array[i][index]);
74637
+ }
74638
+
74639
+ str += line + '\r\n';
74640
+ }
74641
+
74642
+ return str;
74643
+ }
72784
74644
  }
72785
74645
 
72786
74646
  if (typeof module !== 'undefined' && typeof module.exports != 'undefined') {