@returningai/widget-sdk 1.5.0 → 1.6.0

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.
@@ -2183,7 +2183,7 @@ var lottie_light = { exports: {} };
2183
2183
  }
2184
2184
  }
2185
2185
  }
2186
- function freeze() {
2186
+ function freeze2() {
2187
2187
  _isFrozen = true;
2188
2188
  }
2189
2189
  function unfreeze() {
@@ -2220,7 +2220,7 @@ var lottie_light = { exports: {} };
2220
2220
  moduleOb.resize = resize;
2221
2221
  moduleOb.goToAndStop = goToAndStop;
2222
2222
  moduleOb.destroy = destroy;
2223
- moduleOb.freeze = freeze;
2223
+ moduleOb.freeze = freeze2;
2224
2224
  moduleOb.unfreeze = unfreeze;
2225
2225
  moduleOb.setVolume = setVolume;
2226
2226
  moduleOb.mute = mute;
@@ -2382,17 +2382,17 @@ var lottie_light = { exports: {} };
2382
2382
  };
2383
2383
  }();
2384
2384
  var bezierLengthPool = function() {
2385
- function create() {
2385
+ function create2() {
2386
2386
  return {
2387
2387
  addedLength: 0,
2388
2388
  percents: createTypedArray("float32", getDefaultCurveSegments()),
2389
2389
  lengths: createTypedArray("float32", getDefaultCurveSegments())
2390
2390
  };
2391
2391
  }
2392
- return poolFactory(8, create);
2392
+ return poolFactory(8, create2);
2393
2393
  }();
2394
2394
  var segmentsLengthPool = function() {
2395
- function create() {
2395
+ function create2() {
2396
2396
  return {
2397
2397
  lengths: [],
2398
2398
  totalLength: 0
@@ -2406,7 +2406,7 @@ var lottie_light = { exports: {} };
2406
2406
  }
2407
2407
  element.lengths.length = 0;
2408
2408
  }
2409
- return poolFactory(8, create, release);
2409
+ return poolFactory(8, create2, release);
2410
2410
  }();
2411
2411
  function bezFunction() {
2412
2412
  var math = Math;
@@ -3108,10 +3108,10 @@ var lottie_light = { exports: {} };
3108
3108
  }
3109
3109
  };
3110
3110
  var pointPool = function() {
3111
- function create() {
3111
+ function create2() {
3112
3112
  return createTypedArray("float32", 2);
3113
3113
  }
3114
- return poolFactory(8, create);
3114
+ return poolFactory(8, create2);
3115
3115
  }();
3116
3116
  function ShapePath() {
3117
3117
  this.c = false;
@@ -3199,7 +3199,7 @@ var lottie_light = { exports: {} };
3199
3199
  return this._length;
3200
3200
  };
3201
3201
  var shapePool = function() {
3202
- function create() {
3202
+ function create2() {
3203
3203
  return new ShapePath();
3204
3204
  }
3205
3205
  function release(shapePath) {
@@ -3216,7 +3216,7 @@ var lottie_light = { exports: {} };
3216
3216
  shapePath._length = 0;
3217
3217
  shapePath.c = false;
3218
3218
  }
3219
- function clone(shape) {
3219
+ function clone2(shape) {
3220
3220
  var cloned = factory.newElement();
3221
3221
  var i;
3222
3222
  var len = shape._length === void 0 ? shape.v.length : shape._length;
@@ -3227,8 +3227,8 @@ var lottie_light = { exports: {} };
3227
3227
  }
3228
3228
  return cloned;
3229
3229
  }
3230
- var factory = poolFactory(4, create, release);
3231
- factory.clone = clone;
3230
+ var factory = poolFactory(4, create2, release);
3231
+ factory.clone = clone2;
3232
3232
  return factory;
3233
3233
  }();
3234
3234
  function ShapeCollection() {
@@ -3946,7 +3946,7 @@ var lottie_light = { exports: {} };
3946
3946
  }
3947
3947
  return true;
3948
3948
  }
3949
- function clone(matr) {
3949
+ function clone2(matr) {
3950
3950
  var i;
3951
3951
  for (i = 0; i < 16; i += 1) {
3952
3952
  matr.props[i] = this.props[i];
@@ -4098,7 +4098,7 @@ var lottie_light = { exports: {} };
4098
4098
  this.applyToPointStringified = applyToPointStringified;
4099
4099
  this.toCSS = toCSS;
4100
4100
  this.to2dCSS = to2dCSS;
4101
- this.clone = clone;
4101
+ this.clone = clone2;
4102
4102
  this.cloneFromProps = cloneFromProps;
4103
4103
  this.equals = equals;
4104
4104
  this.inversePoints = inversePoints;
@@ -5910,12 +5910,12 @@ var lottie_light = { exports: {} };
5910
5910
  tCanvasHelper.font = fontProps.style + " " + fontProps.weight + " 100px " + fontData.fFamily;
5911
5911
  helper = tCanvasHelper;
5912
5912
  }
5913
- function measure(text) {
5913
+ function measure(text2) {
5914
5914
  if (engine === "svg") {
5915
- helper.textContent = text;
5915
+ helper.textContent = text2;
5916
5916
  return helper.getComputedTextLength();
5917
5917
  }
5918
- return helper.measureText(text).width;
5918
+ return helper.measureText(text2).width;
5919
5919
  }
5920
5920
  return {
5921
5921
  measureText: measure
@@ -6112,22 +6112,22 @@ var lottie_light = { exports: {} };
6112
6112
  function isCombinedCharacter(_char3) {
6113
6113
  return combinedCharacters.indexOf(_char3) !== -1;
6114
6114
  }
6115
- function isRegionalFlag(text, index2) {
6116
- var codePoint = getCodePoint(text.substr(index2, 2));
6115
+ function isRegionalFlag(text2, index2) {
6116
+ var codePoint = getCodePoint(text2.substr(index2, 2));
6117
6117
  if (codePoint !== BLACK_FLAG_CODE_POINT) {
6118
6118
  return false;
6119
6119
  }
6120
6120
  var count = 0;
6121
6121
  index2 += 2;
6122
6122
  while (count < 5) {
6123
- codePoint = getCodePoint(text.substr(index2, 2));
6123
+ codePoint = getCodePoint(text2.substr(index2, 2));
6124
6124
  if (codePoint < A_TAG_CODE_POINT || codePoint > Z_TAG_CODE_POINT) {
6125
6125
  return false;
6126
6126
  }
6127
6127
  count += 1;
6128
6128
  index2 += 2;
6129
6129
  }
6130
- return getCodePoint(text.substr(index2, 2)) === CANCEL_TAG_CODE_POINT;
6130
+ return getCodePoint(text2.substr(index2, 2)) === CANCEL_TAG_CODE_POINT;
6131
6131
  }
6132
6132
  function setIsLoaded() {
6133
6133
  this.isLoaded = true;
@@ -8532,10 +8532,10 @@ var lottie_light = { exports: {} };
8532
8532
  }
8533
8533
  return this.data.d.k[this.keysIndex].s;
8534
8534
  };
8535
- TextProperty.prototype.buildFinalText = function(text) {
8535
+ TextProperty.prototype.buildFinalText = function(text2) {
8536
8536
  var charactersArray = [];
8537
8537
  var i = 0;
8538
- var len = text.length;
8538
+ var len = text2.length;
8539
8539
  var charCode;
8540
8540
  var secondCharCode;
8541
8541
  var shouldCombine = false;
@@ -8544,28 +8544,28 @@ var lottie_light = { exports: {} };
8544
8544
  while (i < len) {
8545
8545
  shouldCombine = shouldCombineNext;
8546
8546
  shouldCombineNext = false;
8547
- charCode = text.charCodeAt(i);
8548
- currentChars = text.charAt(i);
8547
+ charCode = text2.charCodeAt(i);
8548
+ currentChars = text2.charAt(i);
8549
8549
  if (FontManager.isCombinedCharacter(charCode)) {
8550
8550
  shouldCombine = true;
8551
8551
  } else if (charCode >= 55296 && charCode <= 56319) {
8552
- if (FontManager.isRegionalFlag(text, i)) {
8553
- currentChars = text.substr(i, 14);
8552
+ if (FontManager.isRegionalFlag(text2, i)) {
8553
+ currentChars = text2.substr(i, 14);
8554
8554
  } else {
8555
- secondCharCode = text.charCodeAt(i + 1);
8555
+ secondCharCode = text2.charCodeAt(i + 1);
8556
8556
  if (secondCharCode >= 56320 && secondCharCode <= 57343) {
8557
8557
  if (FontManager.isModifier(charCode, secondCharCode)) {
8558
- currentChars = text.substr(i, 2);
8558
+ currentChars = text2.substr(i, 2);
8559
8559
  shouldCombine = true;
8560
- } else if (FontManager.isFlagEmoji(text.substr(i, 4))) {
8561
- currentChars = text.substr(i, 4);
8560
+ } else if (FontManager.isFlagEmoji(text2.substr(i, 4))) {
8561
+ currentChars = text2.substr(i, 4);
8562
8562
  } else {
8563
- currentChars = text.substr(i, 2);
8563
+ currentChars = text2.substr(i, 2);
8564
8564
  }
8565
8565
  }
8566
8566
  }
8567
8567
  } else if (charCode > 56319) {
8568
- secondCharCode = text.charCodeAt(i + 1);
8568
+ secondCharCode = text2.charCodeAt(i + 1);
8569
8569
  if (FontManager.isVariationSelector(charCode)) {
8570
8570
  shouldCombine = true;
8571
8571
  }
@@ -10884,6 +10884,1758 @@ class WidgetCallbackRegistry {
10884
10884
  return { ...this.registeredCallbacks };
10885
10885
  }
10886
10886
  }
10887
+ async function fetchEligibleBanner(apiUrl, request) {
10888
+ try {
10889
+ const res = await fetch(`${apiUrl}/v2/api/banner-sdk/eligible`, {
10890
+ method: "POST",
10891
+ headers: { "Content-Type": "application/json" },
10892
+ body: JSON.stringify(request)
10893
+ });
10894
+ const json = await res.json();
10895
+ if (json && json.meta && json.meta.status === "success") {
10896
+ return json.data || { banner: null };
10897
+ }
10898
+ return { banner: null, reason: json && json.detail || "request_failed" };
10899
+ } catch {
10900
+ return { banner: null, reason: "network_error" };
10901
+ }
10902
+ }
10903
+ /*! @license DOMPurify 3.4.9 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.9/LICENSE */
10904
+ function _arrayLikeToArray(r, a) {
10905
+ (null == a || a > r.length) && (a = r.length);
10906
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10907
+ return n;
10908
+ }
10909
+ function _arrayWithHoles(r) {
10910
+ if (Array.isArray(r)) return r;
10911
+ }
10912
+ function _iterableToArrayLimit(r, l) {
10913
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
10914
+ if (null != t) {
10915
+ var e, n, i, u, a = [], f = true, o = false;
10916
+ try {
10917
+ if (i = (t = t.call(r)).next, 0 === l) ;
10918
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
10919
+ } catch (r2) {
10920
+ o = true, n = r2;
10921
+ } finally {
10922
+ try {
10923
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
10924
+ } finally {
10925
+ if (o) throw n;
10926
+ }
10927
+ }
10928
+ return a;
10929
+ }
10930
+ }
10931
+ function _nonIterableRest() {
10932
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10933
+ }
10934
+ function _slicedToArray(r, e) {
10935
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
10936
+ }
10937
+ function _unsupportedIterableToArray(r, a) {
10938
+ if (r) {
10939
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
10940
+ var t = {}.toString.call(r).slice(8, -1);
10941
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
10942
+ }
10943
+ }
10944
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
10945
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
10946
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
10947
+ if (!freeze) {
10948
+ freeze = function freeze2(x) {
10949
+ return x;
10950
+ };
10951
+ }
10952
+ if (!seal) {
10953
+ seal = function seal2(x) {
10954
+ return x;
10955
+ };
10956
+ }
10957
+ if (!apply) {
10958
+ apply = function apply2(func, thisArg) {
10959
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
10960
+ args[_key - 2] = arguments[_key];
10961
+ }
10962
+ return func.apply(thisArg, args);
10963
+ };
10964
+ }
10965
+ if (!construct) {
10966
+ construct = function construct2(Func) {
10967
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
10968
+ args[_key2 - 1] = arguments[_key2];
10969
+ }
10970
+ return new Func(...args);
10971
+ };
10972
+ }
10973
+ const arrayForEach = unapply(Array.prototype.forEach);
10974
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
10975
+ const arrayPop = unapply(Array.prototype.pop);
10976
+ const arrayPush = unapply(Array.prototype.push);
10977
+ const arraySplice = unapply(Array.prototype.splice);
10978
+ const arrayIsArray = Array.isArray;
10979
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
10980
+ const stringToString = unapply(String.prototype.toString);
10981
+ const stringMatch = unapply(String.prototype.match);
10982
+ const stringReplace = unapply(String.prototype.replace);
10983
+ const stringIndexOf = unapply(String.prototype.indexOf);
10984
+ const stringTrim = unapply(String.prototype.trim);
10985
+ const numberToString = unapply(Number.prototype.toString);
10986
+ const booleanToString = unapply(Boolean.prototype.toString);
10987
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
10988
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
10989
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
10990
+ const objectToString = unapply(Object.prototype.toString);
10991
+ const regExpTest = unapply(RegExp.prototype.test);
10992
+ const typeErrorCreate = unconstruct(TypeError);
10993
+ function unapply(func) {
10994
+ return function(thisArg) {
10995
+ if (thisArg instanceof RegExp) {
10996
+ thisArg.lastIndex = 0;
10997
+ }
10998
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
10999
+ args[_key3 - 1] = arguments[_key3];
11000
+ }
11001
+ return apply(func, thisArg, args);
11002
+ };
11003
+ }
11004
+ function unconstruct(Func) {
11005
+ return function() {
11006
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
11007
+ args[_key4] = arguments[_key4];
11008
+ }
11009
+ return construct(Func, args);
11010
+ };
11011
+ }
11012
+ function addToSet(set, array) {
11013
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
11014
+ if (setPrototypeOf) {
11015
+ setPrototypeOf(set, null);
11016
+ }
11017
+ if (!arrayIsArray(array)) {
11018
+ return set;
11019
+ }
11020
+ let l = array.length;
11021
+ while (l--) {
11022
+ let element = array[l];
11023
+ if (typeof element === "string") {
11024
+ const lcElement = transformCaseFunc(element);
11025
+ if (lcElement !== element) {
11026
+ if (!isFrozen(array)) {
11027
+ array[l] = lcElement;
11028
+ }
11029
+ element = lcElement;
11030
+ }
11031
+ }
11032
+ set[element] = true;
11033
+ }
11034
+ return set;
11035
+ }
11036
+ function cleanArray(array) {
11037
+ for (let index = 0; index < array.length; index++) {
11038
+ const isPropertyExist = objectHasOwnProperty(array, index);
11039
+ if (!isPropertyExist) {
11040
+ array[index] = null;
11041
+ }
11042
+ }
11043
+ return array;
11044
+ }
11045
+ function clone(object) {
11046
+ const newObject = create(null);
11047
+ for (const _ref2 of entries(object)) {
11048
+ var _ref3 = _slicedToArray(_ref2, 2);
11049
+ const property = _ref3[0];
11050
+ const value = _ref3[1];
11051
+ const isPropertyExist = objectHasOwnProperty(object, property);
11052
+ if (isPropertyExist) {
11053
+ if (arrayIsArray(value)) {
11054
+ newObject[property] = cleanArray(value);
11055
+ } else if (value && typeof value === "object" && value.constructor === Object) {
11056
+ newObject[property] = clone(value);
11057
+ } else {
11058
+ newObject[property] = value;
11059
+ }
11060
+ }
11061
+ }
11062
+ return newObject;
11063
+ }
11064
+ function stringifyValue(value) {
11065
+ switch (typeof value) {
11066
+ case "string": {
11067
+ return value;
11068
+ }
11069
+ case "number": {
11070
+ return numberToString(value);
11071
+ }
11072
+ case "boolean": {
11073
+ return booleanToString(value);
11074
+ }
11075
+ case "bigint": {
11076
+ return bigintToString ? bigintToString(value) : "0";
11077
+ }
11078
+ case "symbol": {
11079
+ return symbolToString ? symbolToString(value) : "Symbol()";
11080
+ }
11081
+ case "undefined": {
11082
+ return objectToString(value);
11083
+ }
11084
+ case "function":
11085
+ case "object": {
11086
+ if (value === null) {
11087
+ return objectToString(value);
11088
+ }
11089
+ const valueAsRecord = value;
11090
+ const valueToString = lookupGetter(valueAsRecord, "toString");
11091
+ if (typeof valueToString === "function") {
11092
+ const stringified = valueToString(valueAsRecord);
11093
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
11094
+ }
11095
+ return objectToString(value);
11096
+ }
11097
+ default: {
11098
+ return objectToString(value);
11099
+ }
11100
+ }
11101
+ }
11102
+ function lookupGetter(object, prop) {
11103
+ while (object !== null) {
11104
+ const desc = getOwnPropertyDescriptor(object, prop);
11105
+ if (desc) {
11106
+ if (desc.get) {
11107
+ return unapply(desc.get);
11108
+ }
11109
+ if (typeof desc.value === "function") {
11110
+ return unapply(desc.value);
11111
+ }
11112
+ }
11113
+ object = getPrototypeOf(object);
11114
+ }
11115
+ function fallbackValue() {
11116
+ return null;
11117
+ }
11118
+ return fallbackValue;
11119
+ }
11120
+ function isRegex(value) {
11121
+ try {
11122
+ regExpTest(value, "");
11123
+ return true;
11124
+ } catch (_unused) {
11125
+ return false;
11126
+ }
11127
+ }
11128
+ const html$1 = 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", "search", "section", "select", "shadow", "slot", "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"]);
11129
+ const svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
11130
+ const svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
11131
+ const svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "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"]);
11132
+ const mathMl$1 = 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", "mprescripts"]);
11133
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
11134
+ const text = freeze(["#text"]);
11135
+ const html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
11136
+ const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "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", "exponent", "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", "intercept", "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", "mask-type", "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", "slope", "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", "tablevalues", "targetx", "targety", "transform", "transform-origin", "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"]);
11137
+ const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "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"]);
11138
+ const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
11139
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
11140
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
11141
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
11142
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
11143
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
11144
+ const IS_ALLOWED_URI = seal(
11145
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
11146
+ // eslint-disable-line no-useless-escape
11147
+ );
11148
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
11149
+ const ATTR_WHITESPACE = seal(
11150
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
11151
+ // eslint-disable-line no-control-regex
11152
+ );
11153
+ const DOCTYPE_NAME = seal(/^html$/i);
11154
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
11155
+ const NODE_TYPE = {
11156
+ element: 1,
11157
+ attribute: 2,
11158
+ text: 3,
11159
+ cdataSection: 4,
11160
+ entityReference: 5,
11161
+ // Deprecated
11162
+ entityNode: 6,
11163
+ // Deprecated
11164
+ progressingInstruction: 7,
11165
+ comment: 8,
11166
+ document: 9,
11167
+ documentType: 10,
11168
+ documentFragment: 11,
11169
+ notation: 12
11170
+ // Deprecated
11171
+ };
11172
+ const getGlobal = function getGlobal2() {
11173
+ return typeof window === "undefined" ? null : window;
11174
+ };
11175
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
11176
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
11177
+ return null;
11178
+ }
11179
+ let suffix = null;
11180
+ const ATTR_NAME = "data-tt-policy-suffix";
11181
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
11182
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
11183
+ }
11184
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
11185
+ try {
11186
+ return trustedTypes.createPolicy(policyName, {
11187
+ createHTML(html2) {
11188
+ return html2;
11189
+ },
11190
+ createScriptURL(scriptUrl) {
11191
+ return scriptUrl;
11192
+ }
11193
+ });
11194
+ } catch (_) {
11195
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
11196
+ return null;
11197
+ }
11198
+ };
11199
+ const _createHooksMap = function _createHooksMap2() {
11200
+ return {
11201
+ afterSanitizeAttributes: [],
11202
+ afterSanitizeElements: [],
11203
+ afterSanitizeShadowDOM: [],
11204
+ beforeSanitizeAttributes: [],
11205
+ beforeSanitizeElements: [],
11206
+ beforeSanitizeShadowDOM: [],
11207
+ uponSanitizeAttribute: [],
11208
+ uponSanitizeElement: [],
11209
+ uponSanitizeShadowNode: []
11210
+ };
11211
+ };
11212
+ function createDOMPurify() {
11213
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
11214
+ const DOMPurify = (root) => createDOMPurify(root);
11215
+ DOMPurify.version = "3.4.9";
11216
+ DOMPurify.removed = [];
11217
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
11218
+ DOMPurify.isSupported = false;
11219
+ return DOMPurify;
11220
+ }
11221
+ let document2 = window2.document;
11222
+ const originalDocument = document2;
11223
+ const currentScript = originalDocument.currentScript;
11224
+ window2.DocumentFragment;
11225
+ const HTMLTemplateElement = window2.HTMLTemplateElement, Node = window2.Node, Element = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap;
11226
+ _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap;
11227
+ window2.HTMLFormElement;
11228
+ const DOMParser2 = window2.DOMParser, trustedTypes = window2.trustedTypes;
11229
+ const ElementPrototype = Element.prototype;
11230
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
11231
+ const remove = lookupGetter(ElementPrototype, "remove");
11232
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
11233
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
11234
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
11235
+ const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
11236
+ const getAttributes = lookupGetter(ElementPrototype, "attributes");
11237
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
11238
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
11239
+ if (typeof HTMLTemplateElement === "function") {
11240
+ const template = document2.createElement("template");
11241
+ if (template.content && template.content.ownerDocument) {
11242
+ document2 = template.content.ownerDocument;
11243
+ }
11244
+ }
11245
+ let trustedTypesPolicy;
11246
+ let emptyHTML = "";
11247
+ let defaultTrustedTypesPolicy;
11248
+ let defaultTrustedTypesPolicyResolved = false;
11249
+ let IN_TRUSTED_TYPES_POLICY = 0;
11250
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy2() {
11251
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
11252
+ throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
11253
+ }
11254
+ };
11255
+ const _createTrustedHTML = function _createTrustedHTML2(html2) {
11256
+ _assertNotInTrustedTypesPolicy();
11257
+ IN_TRUSTED_TYPES_POLICY++;
11258
+ try {
11259
+ return trustedTypesPolicy.createHTML(html2);
11260
+ } finally {
11261
+ IN_TRUSTED_TYPES_POLICY--;
11262
+ }
11263
+ };
11264
+ const _createTrustedScriptURL = function _createTrustedScriptURL2(scriptUrl) {
11265
+ _assertNotInTrustedTypesPolicy();
11266
+ IN_TRUSTED_TYPES_POLICY++;
11267
+ try {
11268
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
11269
+ } finally {
11270
+ IN_TRUSTED_TYPES_POLICY--;
11271
+ }
11272
+ };
11273
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy2() {
11274
+ if (!defaultTrustedTypesPolicyResolved) {
11275
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
11276
+ defaultTrustedTypesPolicyResolved = true;
11277
+ }
11278
+ return defaultTrustedTypesPolicy;
11279
+ };
11280
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
11281
+ const importNode = originalDocument.importNode;
11282
+ let hooks = _createHooksMap();
11283
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
11284
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
11285
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
11286
+ let ALLOWED_TAGS = null;
11287
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
11288
+ let ALLOWED_ATTR = null;
11289
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
11290
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
11291
+ tagNameCheck: {
11292
+ writable: true,
11293
+ configurable: false,
11294
+ enumerable: true,
11295
+ value: null
11296
+ },
11297
+ attributeNameCheck: {
11298
+ writable: true,
11299
+ configurable: false,
11300
+ enumerable: true,
11301
+ value: null
11302
+ },
11303
+ allowCustomizedBuiltInElements: {
11304
+ writable: true,
11305
+ configurable: false,
11306
+ enumerable: true,
11307
+ value: false
11308
+ }
11309
+ }));
11310
+ let FORBID_TAGS = null;
11311
+ let FORBID_ATTR = null;
11312
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
11313
+ tagCheck: {
11314
+ writable: true,
11315
+ configurable: false,
11316
+ enumerable: true,
11317
+ value: null
11318
+ },
11319
+ attributeCheck: {
11320
+ writable: true,
11321
+ configurable: false,
11322
+ enumerable: true,
11323
+ value: null
11324
+ }
11325
+ }));
11326
+ let ALLOW_ARIA_ATTR = true;
11327
+ let ALLOW_DATA_ATTR = true;
11328
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
11329
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
11330
+ let SAFE_FOR_TEMPLATES = false;
11331
+ let SAFE_FOR_XML = true;
11332
+ let WHOLE_DOCUMENT = false;
11333
+ let SET_CONFIG = false;
11334
+ let FORCE_BODY = false;
11335
+ let RETURN_DOM = false;
11336
+ let RETURN_DOM_FRAGMENT = false;
11337
+ let RETURN_TRUSTED_TYPE = false;
11338
+ let SANITIZE_DOM = true;
11339
+ let SANITIZE_NAMED_PROPS = false;
11340
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
11341
+ let KEEP_CONTENT = true;
11342
+ let IN_PLACE = false;
11343
+ let USE_PROFILES = {};
11344
+ let FORBID_CONTENTS = null;
11345
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, [
11346
+ "annotation-xml",
11347
+ "audio",
11348
+ "colgroup",
11349
+ "desc",
11350
+ "foreignobject",
11351
+ "head",
11352
+ "iframe",
11353
+ "math",
11354
+ "mi",
11355
+ "mn",
11356
+ "mo",
11357
+ "ms",
11358
+ "mtext",
11359
+ "noembed",
11360
+ "noframes",
11361
+ "noscript",
11362
+ "plaintext",
11363
+ "script",
11364
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
11365
+ // the UA (customizable <select>) — including any on* handlers — and the
11366
+ // engine re-mirrors synchronously whenever a removal changes which
11367
+ // option/selectedcontent is current, even inside DOMPurify's inert
11368
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
11369
+ // mirror target ahead of the walk, which the engine refills, looping
11370
+ // forever (DoS) and amplifying output. Dropping its content on removal
11371
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
11372
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
11373
+ "selectedcontent",
11374
+ "style",
11375
+ "svg",
11376
+ "template",
11377
+ "thead",
11378
+ "title",
11379
+ "video",
11380
+ "xmp"
11381
+ ]);
11382
+ let DATA_URI_TAGS = null;
11383
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
11384
+ let URI_SAFE_ATTRIBUTES = null;
11385
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
11386
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
11387
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
11388
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
11389
+ let NAMESPACE = HTML_NAMESPACE;
11390
+ let IS_EMPTY_INPUT = false;
11391
+ let ALLOWED_NAMESPACES = null;
11392
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
11393
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
11394
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
11395
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
11396
+ let PARSER_MEDIA_TYPE = null;
11397
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
11398
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
11399
+ let transformCaseFunc = null;
11400
+ let CONFIG = null;
11401
+ const formElement = document2.createElement("form");
11402
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
11403
+ return testValue instanceof RegExp || testValue instanceof Function;
11404
+ };
11405
+ const _parseConfig = function _parseConfig2() {
11406
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
11407
+ if (CONFIG && CONFIG === cfg) {
11408
+ return;
11409
+ }
11410
+ if (!cfg || typeof cfg !== "object") {
11411
+ cfg = {};
11412
+ }
11413
+ cfg = clone(cfg);
11414
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
11415
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
11416
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
11417
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
11418
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
11419
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
11420
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
11421
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
11422
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
11423
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
11424
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
11425
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
11426
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
11427
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
11428
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
11429
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
11430
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
11431
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
11432
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
11433
+ RETURN_DOM = cfg.RETURN_DOM || false;
11434
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
11435
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
11436
+ FORCE_BODY = cfg.FORCE_BODY || false;
11437
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
11438
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
11439
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
11440
+ IN_PLACE = cfg.IN_PLACE || false;
11441
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
11442
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
11443
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
11444
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ["annotation-xml"]);
11445
+ const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
11446
+ CUSTOM_ELEMENT_HANDLING = create(null);
11447
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
11448
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
11449
+ }
11450
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
11451
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
11452
+ }
11453
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
11454
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
11455
+ }
11456
+ if (SAFE_FOR_TEMPLATES) {
11457
+ ALLOW_DATA_ATTR = false;
11458
+ }
11459
+ if (RETURN_DOM_FRAGMENT) {
11460
+ RETURN_DOM = true;
11461
+ }
11462
+ if (USE_PROFILES) {
11463
+ ALLOWED_TAGS = addToSet({}, text);
11464
+ ALLOWED_ATTR = create(null);
11465
+ if (USE_PROFILES.html === true) {
11466
+ addToSet(ALLOWED_TAGS, html$1);
11467
+ addToSet(ALLOWED_ATTR, html);
11468
+ }
11469
+ if (USE_PROFILES.svg === true) {
11470
+ addToSet(ALLOWED_TAGS, svg$1);
11471
+ addToSet(ALLOWED_ATTR, svg);
11472
+ addToSet(ALLOWED_ATTR, xml);
11473
+ }
11474
+ if (USE_PROFILES.svgFilters === true) {
11475
+ addToSet(ALLOWED_TAGS, svgFilters);
11476
+ addToSet(ALLOWED_ATTR, svg);
11477
+ addToSet(ALLOWED_ATTR, xml);
11478
+ }
11479
+ if (USE_PROFILES.mathMl === true) {
11480
+ addToSet(ALLOWED_TAGS, mathMl$1);
11481
+ addToSet(ALLOWED_ATTR, mathMl);
11482
+ addToSet(ALLOWED_ATTR, xml);
11483
+ }
11484
+ }
11485
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
11486
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
11487
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
11488
+ if (typeof cfg.ADD_TAGS === "function") {
11489
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
11490
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
11491
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
11492
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
11493
+ }
11494
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
11495
+ }
11496
+ }
11497
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
11498
+ if (typeof cfg.ADD_ATTR === "function") {
11499
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
11500
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
11501
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
11502
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
11503
+ }
11504
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
11505
+ }
11506
+ }
11507
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
11508
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
11509
+ }
11510
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
11511
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
11512
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
11513
+ }
11514
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
11515
+ }
11516
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
11517
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
11518
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
11519
+ }
11520
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
11521
+ }
11522
+ if (KEEP_CONTENT) {
11523
+ ALLOWED_TAGS["#text"] = true;
11524
+ }
11525
+ if (WHOLE_DOCUMENT) {
11526
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
11527
+ }
11528
+ if (ALLOWED_TAGS.table) {
11529
+ addToSet(ALLOWED_TAGS, ["tbody"]);
11530
+ delete FORBID_TAGS.tbody;
11531
+ }
11532
+ if (cfg.TRUSTED_TYPES_POLICY) {
11533
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
11534
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
11535
+ }
11536
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
11537
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
11538
+ }
11539
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
11540
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
11541
+ try {
11542
+ emptyHTML = _createTrustedHTML("");
11543
+ } catch (error) {
11544
+ trustedTypesPolicy = previousTrustedTypesPolicy;
11545
+ throw error;
11546
+ }
11547
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
11548
+ trustedTypesPolicy = void 0;
11549
+ emptyHTML = "";
11550
+ } else {
11551
+ if (trustedTypesPolicy === void 0) {
11552
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
11553
+ }
11554
+ if (trustedTypesPolicy && typeof emptyHTML === "string") {
11555
+ emptyHTML = _createTrustedHTML("");
11556
+ }
11557
+ }
11558
+ if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
11559
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
11560
+ }
11561
+ if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
11562
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
11563
+ }
11564
+ if (freeze) {
11565
+ freeze(cfg);
11566
+ }
11567
+ CONFIG = cfg;
11568
+ };
11569
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
11570
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
11571
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
11572
+ let parent = getParentNode(element);
11573
+ if (!parent || !parent.tagName) {
11574
+ parent = {
11575
+ namespaceURI: NAMESPACE,
11576
+ tagName: "template"
11577
+ };
11578
+ }
11579
+ const tagName = stringToLowerCase(element.tagName);
11580
+ const parentTagName = stringToLowerCase(parent.tagName);
11581
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
11582
+ return false;
11583
+ }
11584
+ if (element.namespaceURI === SVG_NAMESPACE) {
11585
+ if (parent.namespaceURI === HTML_NAMESPACE) {
11586
+ return tagName === "svg";
11587
+ }
11588
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
11589
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
11590
+ }
11591
+ return Boolean(ALL_SVG_TAGS[tagName]);
11592
+ }
11593
+ if (element.namespaceURI === MATHML_NAMESPACE) {
11594
+ if (parent.namespaceURI === HTML_NAMESPACE) {
11595
+ return tagName === "math";
11596
+ }
11597
+ if (parent.namespaceURI === SVG_NAMESPACE) {
11598
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
11599
+ }
11600
+ return Boolean(ALL_MATHML_TAGS[tagName]);
11601
+ }
11602
+ if (element.namespaceURI === HTML_NAMESPACE) {
11603
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
11604
+ return false;
11605
+ }
11606
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
11607
+ return false;
11608
+ }
11609
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
11610
+ }
11611
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
11612
+ return true;
11613
+ }
11614
+ return false;
11615
+ };
11616
+ const _forceRemove = function _forceRemove2(node) {
11617
+ arrayPush(DOMPurify.removed, {
11618
+ element: node
11619
+ });
11620
+ try {
11621
+ getParentNode(node).removeChild(node);
11622
+ } catch (_) {
11623
+ remove(node);
11624
+ if (!getParentNode(node)) {
11625
+ throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
11626
+ }
11627
+ }
11628
+ };
11629
+ const _neutralizeRoot = function _neutralizeRoot2(root) {
11630
+ const childNodes = getChildNodes ? getChildNodes(root) : root.childNodes;
11631
+ if (childNodes) {
11632
+ const snapshot = [];
11633
+ arrayForEach(childNodes, (child) => {
11634
+ arrayPush(snapshot, child);
11635
+ });
11636
+ arrayForEach(snapshot, (child) => {
11637
+ try {
11638
+ remove(child);
11639
+ } catch (_) {
11640
+ }
11641
+ });
11642
+ }
11643
+ const attributes = getAttributes ? getAttributes(root) : null;
11644
+ if (attributes) {
11645
+ for (let i = attributes.length - 1; i >= 0; --i) {
11646
+ const attribute = attributes[i];
11647
+ const name = attribute && attribute.name;
11648
+ if (typeof name === "string") {
11649
+ try {
11650
+ root.removeAttribute(name);
11651
+ } catch (_) {
11652
+ }
11653
+ }
11654
+ }
11655
+ }
11656
+ };
11657
+ const _removeAttribute = function _removeAttribute2(name, element) {
11658
+ try {
11659
+ arrayPush(DOMPurify.removed, {
11660
+ attribute: element.getAttributeNode(name),
11661
+ from: element
11662
+ });
11663
+ } catch (_) {
11664
+ arrayPush(DOMPurify.removed, {
11665
+ attribute: null,
11666
+ from: element
11667
+ });
11668
+ }
11669
+ element.removeAttribute(name);
11670
+ if (name === "is") {
11671
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
11672
+ try {
11673
+ _forceRemove(element);
11674
+ } catch (_) {
11675
+ }
11676
+ } else {
11677
+ try {
11678
+ element.setAttribute(name, "");
11679
+ } catch (_) {
11680
+ }
11681
+ }
11682
+ }
11683
+ };
11684
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
11685
+ const attributes = getAttributes ? getAttributes(element) : element.attributes;
11686
+ if (!attributes) {
11687
+ return;
11688
+ }
11689
+ for (let i = attributes.length - 1; i >= 0; --i) {
11690
+ const attribute = attributes[i];
11691
+ const name = attribute && attribute.name;
11692
+ if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) {
11693
+ continue;
11694
+ }
11695
+ try {
11696
+ element.removeAttribute(name);
11697
+ } catch (_) {
11698
+ }
11699
+ }
11700
+ };
11701
+ const _neutralizeSubtree = function _neutralizeSubtree2(root) {
11702
+ const stack = [root];
11703
+ while (stack.length > 0) {
11704
+ const node = stack.pop();
11705
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
11706
+ if (nodeType === NODE_TYPE.element) {
11707
+ _stripDisallowedAttributes(node);
11708
+ }
11709
+ const childNodes = getChildNodes ? getChildNodes(node) : node.childNodes;
11710
+ if (childNodes) {
11711
+ for (let i = childNodes.length - 1; i >= 0; --i) {
11712
+ stack.push(childNodes[i]);
11713
+ }
11714
+ }
11715
+ }
11716
+ };
11717
+ const _initDocument = function _initDocument2(dirty) {
11718
+ let doc = null;
11719
+ let leadingWhitespace = null;
11720
+ if (FORCE_BODY) {
11721
+ dirty = "<remove></remove>" + dirty;
11722
+ } else {
11723
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
11724
+ leadingWhitespace = matches && matches[0];
11725
+ }
11726
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
11727
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
11728
+ }
11729
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
11730
+ if (NAMESPACE === HTML_NAMESPACE) {
11731
+ try {
11732
+ doc = new DOMParser2().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
11733
+ } catch (_) {
11734
+ }
11735
+ }
11736
+ if (!doc || !doc.documentElement) {
11737
+ doc = implementation.createDocument(NAMESPACE, "template", null);
11738
+ try {
11739
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
11740
+ } catch (_) {
11741
+ }
11742
+ }
11743
+ const body = doc.body || doc.documentElement;
11744
+ if (dirty && leadingWhitespace) {
11745
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
11746
+ }
11747
+ if (NAMESPACE === HTML_NAMESPACE) {
11748
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
11749
+ }
11750
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
11751
+ };
11752
+ const _createNodeIterator = function _createNodeIterator2(root) {
11753
+ return createNodeIterator.call(
11754
+ root.ownerDocument || root,
11755
+ root,
11756
+ // eslint-disable-next-line no-bitwise
11757
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
11758
+ null
11759
+ );
11760
+ };
11761
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
11762
+ var _node$querySelectorAl, _node$querySelectorAl2;
11763
+ node.normalize();
11764
+ const walker = createNodeIterator.call(
11765
+ node.ownerDocument || node,
11766
+ node,
11767
+ // eslint-disable-next-line no-bitwise
11768
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION,
11769
+ null
11770
+ );
11771
+ let currentNode = walker.nextNode();
11772
+ while (currentNode) {
11773
+ let data = currentNode.data;
11774
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
11775
+ data = stringReplace(data, expr, " ");
11776
+ });
11777
+ currentNode.data = data;
11778
+ currentNode = walker.nextNode();
11779
+ }
11780
+ const templates = (_node$querySelectorAl = (_node$querySelectorAl2 = node.querySelectorAll) === null || _node$querySelectorAl2 === void 0 ? void 0 : _node$querySelectorAl2.call(node, "template")) !== null && _node$querySelectorAl !== void 0 ? _node$querySelectorAl : [];
11781
+ arrayForEach(Array.from(templates), (tmpl) => {
11782
+ if (_isDocumentFragment(tmpl.content)) {
11783
+ _scrubTemplateExpressions2(tmpl.content);
11784
+ }
11785
+ });
11786
+ };
11787
+ const _isClobbered = function _isClobbered2(element) {
11788
+ const realTagName = getNodeName ? getNodeName(element) : null;
11789
+ if (typeof realTagName !== "string") {
11790
+ return false;
11791
+ }
11792
+ if (transformCaseFunc(realTagName) !== "form") {
11793
+ return false;
11794
+ }
11795
+ return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || // Realm-safe NamedNodeMap detection: equality against the cached
11796
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
11797
+ // makes the direct read diverge from the cached read; a clean form
11798
+ // (same-realm OR foreign-realm) has both reads pointing at the same
11799
+ // canonical NamedNodeMap.
11800
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
11801
+ // returns the integer 1 for any Element regardless of realm; direct
11802
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
11803
+ // the named child element. Cheap addition — nodeType is read from
11804
+ // an internal slot, no serialization cost — and removes a residual
11805
+ // clobbering surface used by several mXSS / PI / comment branches
11806
+ // in _sanitizeElements that compare currentNode.nodeType directly.
11807
+ element.nodeType !== getNodeType(element) || // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
11808
+ // "childNodes" shadows the prototype getter. Direct reads of
11809
+ // form.childNodes from a clobbered form return the named child
11810
+ // instead of the real NodeList, so any walk that reads it directly
11811
+ // skips the form's real children. Compare the direct read to the
11812
+ // cached Node.prototype getter — when the form's named-property
11813
+ // getter intercepts the read, the two values differ and we flag
11814
+ // the form. This catches every clobbering child type (input,
11815
+ // select, etc.) regardless of whether the named child happens to
11816
+ // carry a numeric .length, which a typeof-based probe would miss
11817
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
11818
+ element.childNodes !== getChildNodes(element);
11819
+ };
11820
+ const _isDocumentFragment = function _isDocumentFragment2(value) {
11821
+ if (!getNodeType || typeof value !== "object" || value === null) {
11822
+ return false;
11823
+ }
11824
+ try {
11825
+ return getNodeType(value) === NODE_TYPE.documentFragment;
11826
+ } catch (_) {
11827
+ return false;
11828
+ }
11829
+ };
11830
+ const _isNode = function _isNode2(value) {
11831
+ if (!getNodeType || typeof value !== "object" || value === null) {
11832
+ return false;
11833
+ }
11834
+ try {
11835
+ return typeof getNodeType(value) === "number";
11836
+ } catch (_) {
11837
+ return false;
11838
+ }
11839
+ };
11840
+ function _executeHooks(hooks2, currentNode, data) {
11841
+ arrayForEach(hooks2, (hook) => {
11842
+ hook.call(DOMPurify, currentNode, data, CONFIG);
11843
+ });
11844
+ }
11845
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
11846
+ let content = null;
11847
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
11848
+ if (_isClobbered(currentNode)) {
11849
+ _forceRemove(currentNode);
11850
+ return true;
11851
+ }
11852
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
11853
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
11854
+ tagName,
11855
+ allowedTags: ALLOWED_TAGS
11856
+ });
11857
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
11858
+ _forceRemove(currentNode);
11859
+ return true;
11860
+ }
11861
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
11862
+ _forceRemove(currentNode);
11863
+ return true;
11864
+ }
11865
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
11866
+ _forceRemove(currentNode);
11867
+ return true;
11868
+ }
11869
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
11870
+ _forceRemove(currentNode);
11871
+ return true;
11872
+ }
11873
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
11874
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
11875
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
11876
+ return false;
11877
+ }
11878
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
11879
+ return false;
11880
+ }
11881
+ }
11882
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
11883
+ const parentNode = getParentNode(currentNode);
11884
+ const childNodes = getChildNodes(currentNode);
11885
+ if (childNodes && parentNode) {
11886
+ const childCount = childNodes.length;
11887
+ for (let i = childCount - 1; i >= 0; --i) {
11888
+ const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
11889
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
11890
+ }
11891
+ }
11892
+ }
11893
+ _forceRemove(currentNode);
11894
+ return true;
11895
+ }
11896
+ const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
11897
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
11898
+ _forceRemove(currentNode);
11899
+ return true;
11900
+ }
11901
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
11902
+ _forceRemove(currentNode);
11903
+ return true;
11904
+ }
11905
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
11906
+ content = currentNode.textContent;
11907
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
11908
+ content = stringReplace(content, expr, " ");
11909
+ });
11910
+ if (currentNode.textContent !== content) {
11911
+ arrayPush(DOMPurify.removed, {
11912
+ element: currentNode.cloneNode()
11913
+ });
11914
+ currentNode.textContent = content;
11915
+ }
11916
+ }
11917
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
11918
+ return false;
11919
+ };
11920
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
11921
+ if (FORBID_ATTR[lcName]) {
11922
+ return false;
11923
+ }
11924
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
11925
+ return false;
11926
+ }
11927
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
11928
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
11929
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
11930
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
11931
+ if (
11932
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
11933
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
11934
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
11935
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
11936
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
11937
+ lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
11938
+ ) ;
11939
+ else {
11940
+ return false;
11941
+ }
11942
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
11943
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
11944
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
11945
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
11946
+ else if (value) {
11947
+ return false;
11948
+ } else ;
11949
+ return true;
11950
+ };
11951
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
11952
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
11953
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
11954
+ };
11955
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
11956
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
11957
+ const attributes = currentNode.attributes;
11958
+ if (!attributes || _isClobbered(currentNode)) {
11959
+ return;
11960
+ }
11961
+ const hookEvent = {
11962
+ attrName: "",
11963
+ attrValue: "",
11964
+ keepAttr: true,
11965
+ allowedAttributes: ALLOWED_ATTR,
11966
+ forceKeepAttr: void 0
11967
+ };
11968
+ let l = attributes.length;
11969
+ while (l--) {
11970
+ const attr = attributes[l];
11971
+ const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
11972
+ const lcName = transformCaseFunc(name);
11973
+ const initValue = attrValue;
11974
+ let value = name === "value" ? initValue : stringTrim(initValue);
11975
+ hookEvent.attrName = lcName;
11976
+ hookEvent.attrValue = value;
11977
+ hookEvent.keepAttr = true;
11978
+ hookEvent.forceKeepAttr = void 0;
11979
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
11980
+ value = hookEvent.attrValue;
11981
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
11982
+ _removeAttribute(name, currentNode);
11983
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
11984
+ }
11985
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
11986
+ _removeAttribute(name, currentNode);
11987
+ continue;
11988
+ }
11989
+ if (lcName === "attributename" && stringMatch(value, "href")) {
11990
+ _removeAttribute(name, currentNode);
11991
+ continue;
11992
+ }
11993
+ if (hookEvent.forceKeepAttr) {
11994
+ continue;
11995
+ }
11996
+ if (!hookEvent.keepAttr) {
11997
+ _removeAttribute(name, currentNode);
11998
+ continue;
11999
+ }
12000
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
12001
+ _removeAttribute(name, currentNode);
12002
+ continue;
12003
+ }
12004
+ if (SAFE_FOR_TEMPLATES) {
12005
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
12006
+ value = stringReplace(value, expr, " ");
12007
+ });
12008
+ }
12009
+ const lcTag = transformCaseFunc(currentNode.nodeName);
12010
+ if (!_isValidAttribute(lcTag, lcName, value)) {
12011
+ _removeAttribute(name, currentNode);
12012
+ continue;
12013
+ }
12014
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
12015
+ if (namespaceURI) ;
12016
+ else {
12017
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
12018
+ case "TrustedHTML": {
12019
+ value = _createTrustedHTML(value);
12020
+ break;
12021
+ }
12022
+ case "TrustedScriptURL": {
12023
+ value = _createTrustedScriptURL(value);
12024
+ break;
12025
+ }
12026
+ }
12027
+ }
12028
+ }
12029
+ if (value !== initValue) {
12030
+ try {
12031
+ if (namespaceURI) {
12032
+ currentNode.setAttributeNS(namespaceURI, name, value);
12033
+ } else {
12034
+ currentNode.setAttribute(name, value);
12035
+ }
12036
+ if (_isClobbered(currentNode)) {
12037
+ _forceRemove(currentNode);
12038
+ } else {
12039
+ arrayPop(DOMPurify.removed);
12040
+ }
12041
+ } catch (_) {
12042
+ _removeAttribute(name, currentNode);
12043
+ }
12044
+ }
12045
+ }
12046
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
12047
+ };
12048
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
12049
+ let shadowNode = null;
12050
+ const shadowIterator = _createNodeIterator(fragment);
12051
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
12052
+ while (shadowNode = shadowIterator.nextNode()) {
12053
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
12054
+ _sanitizeElements(shadowNode);
12055
+ _sanitizeAttributes(shadowNode);
12056
+ if (_isDocumentFragment(shadowNode.content)) {
12057
+ _sanitizeShadowDOM2(shadowNode.content);
12058
+ }
12059
+ const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
12060
+ if (shadowNodeType === NODE_TYPE.element) {
12061
+ const innerSr = getShadowRoot ? getShadowRoot(shadowNode) : shadowNode.shadowRoot;
12062
+ if (_isDocumentFragment(innerSr)) {
12063
+ _sanitizeAttachedShadowRoots(innerSr);
12064
+ _sanitizeShadowDOM2(innerSr);
12065
+ }
12066
+ }
12067
+ }
12068
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
12069
+ };
12070
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots2(root) {
12071
+ const stack = [{
12072
+ node: root,
12073
+ shadow: null
12074
+ }];
12075
+ while (stack.length > 0) {
12076
+ const item = stack.pop();
12077
+ if (item.shadow) {
12078
+ _sanitizeShadowDOM2(item.shadow);
12079
+ continue;
12080
+ }
12081
+ const node = item.node;
12082
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
12083
+ const isElement = nodeType === NODE_TYPE.element;
12084
+ const childNodes = getChildNodes ? getChildNodes(node) : node.childNodes;
12085
+ if (childNodes) {
12086
+ for (let i = childNodes.length - 1; i >= 0; --i) {
12087
+ stack.push({
12088
+ node: childNodes[i],
12089
+ shadow: null
12090
+ });
12091
+ }
12092
+ }
12093
+ if (isElement) {
12094
+ const rootName = getNodeName ? getNodeName(node) : null;
12095
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
12096
+ const content = node.content;
12097
+ if (_isDocumentFragment(content)) {
12098
+ stack.push({
12099
+ node: content,
12100
+ shadow: null
12101
+ });
12102
+ }
12103
+ }
12104
+ }
12105
+ if (isElement) {
12106
+ const sr = getShadowRoot ? getShadowRoot(node) : node.shadowRoot;
12107
+ if (_isDocumentFragment(sr)) {
12108
+ stack.push({
12109
+ node: null,
12110
+ shadow: sr
12111
+ }, {
12112
+ node: sr,
12113
+ shadow: null
12114
+ });
12115
+ }
12116
+ }
12117
+ }
12118
+ };
12119
+ DOMPurify.sanitize = function(dirty) {
12120
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
12121
+ let body = null;
12122
+ let importedNode = null;
12123
+ let currentNode = null;
12124
+ let returnNode = null;
12125
+ IS_EMPTY_INPUT = !dirty;
12126
+ if (IS_EMPTY_INPUT) {
12127
+ dirty = "<!-->";
12128
+ }
12129
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
12130
+ dirty = stringifyValue(dirty);
12131
+ if (typeof dirty !== "string") {
12132
+ throw typeErrorCreate("dirty is not a string, aborting");
12133
+ }
12134
+ }
12135
+ if (!DOMPurify.isSupported) {
12136
+ return dirty;
12137
+ }
12138
+ if (!SET_CONFIG) {
12139
+ _parseConfig(cfg);
12140
+ }
12141
+ DOMPurify.removed = [];
12142
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
12143
+ if (inPlace) {
12144
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
12145
+ if (typeof nn === "string") {
12146
+ const tagName = transformCaseFunc(nn);
12147
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
12148
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
12149
+ }
12150
+ }
12151
+ if (_isClobbered(dirty)) {
12152
+ throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
12153
+ }
12154
+ try {
12155
+ _sanitizeAttachedShadowRoots(dirty);
12156
+ } catch (error) {
12157
+ _neutralizeRoot(dirty);
12158
+ throw error;
12159
+ }
12160
+ } else if (_isNode(dirty)) {
12161
+ body = _initDocument("<!---->");
12162
+ importedNode = body.ownerDocument.importNode(dirty, true);
12163
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
12164
+ body = importedNode;
12165
+ } else if (importedNode.nodeName === "HTML") {
12166
+ body = importedNode;
12167
+ } else {
12168
+ body.appendChild(importedNode);
12169
+ }
12170
+ _sanitizeAttachedShadowRoots(importedNode);
12171
+ } else {
12172
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
12173
+ dirty.indexOf("<") === -1) {
12174
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
12175
+ }
12176
+ body = _initDocument(dirty);
12177
+ if (!body) {
12178
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
12179
+ }
12180
+ }
12181
+ if (body && FORCE_BODY) {
12182
+ _forceRemove(body.firstChild);
12183
+ }
12184
+ const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
12185
+ try {
12186
+ while (currentNode = nodeIterator.nextNode()) {
12187
+ _sanitizeElements(currentNode);
12188
+ _sanitizeAttributes(currentNode);
12189
+ if (_isDocumentFragment(currentNode.content)) {
12190
+ _sanitizeShadowDOM2(currentNode.content);
12191
+ }
12192
+ }
12193
+ } catch (error) {
12194
+ if (inPlace) {
12195
+ _neutralizeRoot(dirty);
12196
+ }
12197
+ throw error;
12198
+ }
12199
+ if (inPlace) {
12200
+ arrayForEach(DOMPurify.removed, (entry) => {
12201
+ if (entry.element) {
12202
+ _neutralizeSubtree(entry.element);
12203
+ }
12204
+ });
12205
+ if (SAFE_FOR_TEMPLATES) {
12206
+ _scrubTemplateExpressions2(dirty);
12207
+ }
12208
+ return dirty;
12209
+ }
12210
+ if (RETURN_DOM) {
12211
+ if (SAFE_FOR_TEMPLATES) {
12212
+ _scrubTemplateExpressions2(body);
12213
+ }
12214
+ if (RETURN_DOM_FRAGMENT) {
12215
+ returnNode = createDocumentFragment.call(body.ownerDocument);
12216
+ while (body.firstChild) {
12217
+ returnNode.appendChild(body.firstChild);
12218
+ }
12219
+ } else {
12220
+ returnNode = body;
12221
+ }
12222
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
12223
+ returnNode = importNode.call(originalDocument, returnNode, true);
12224
+ }
12225
+ return returnNode;
12226
+ }
12227
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
12228
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
12229
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
12230
+ }
12231
+ if (SAFE_FOR_TEMPLATES) {
12232
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
12233
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
12234
+ });
12235
+ }
12236
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
12237
+ };
12238
+ DOMPurify.setConfig = function() {
12239
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
12240
+ _parseConfig(cfg);
12241
+ SET_CONFIG = true;
12242
+ };
12243
+ DOMPurify.clearConfig = function() {
12244
+ CONFIG = null;
12245
+ SET_CONFIG = false;
12246
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
12247
+ emptyHTML = "";
12248
+ };
12249
+ DOMPurify.isValidAttribute = function(tag, attr, value) {
12250
+ if (!CONFIG) {
12251
+ _parseConfig({});
12252
+ }
12253
+ const lcTag = transformCaseFunc(tag);
12254
+ const lcName = transformCaseFunc(attr);
12255
+ return _isValidAttribute(lcTag, lcName, value);
12256
+ };
12257
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
12258
+ if (typeof hookFunction !== "function") {
12259
+ return;
12260
+ }
12261
+ arrayPush(hooks[entryPoint], hookFunction);
12262
+ };
12263
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
12264
+ if (hookFunction !== void 0) {
12265
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
12266
+ return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
12267
+ }
12268
+ return arrayPop(hooks[entryPoint]);
12269
+ };
12270
+ DOMPurify.removeHooks = function(entryPoint) {
12271
+ hooks[entryPoint] = [];
12272
+ };
12273
+ DOMPurify.removeAllHooks = function() {
12274
+ hooks = _createHooksMap();
12275
+ };
12276
+ return DOMPurify;
12277
+ }
12278
+ var purify = createDOMPurify();
12279
+ purify.addHook("afterSanitizeAttributes", (node) => {
12280
+ if (node.tagName === "A" && node.getAttribute("target") === "_blank") {
12281
+ node.setAttribute("rel", "noopener noreferrer");
12282
+ }
12283
+ });
12284
+ function sanitizeBannerHtml(html2) {
12285
+ if (!html2) return "";
12286
+ return purify.sanitize(html2, {
12287
+ ALLOWED_TAGS: ["p", "strong", "em", "u", "img", "span", "div", "a", "br"],
12288
+ ALLOWED_ATTR: ["style", "src", "class", "href", "target", "alt", "width", "height"],
12289
+ ADD_ATTR: ["target"],
12290
+ ALLOW_DATA_ATTR: false
12291
+ });
12292
+ }
12293
+ function resolveCssToken(token) {
12294
+ const candidates = [
12295
+ document.documentElement,
12296
+ document.body,
12297
+ ...Array.from(
12298
+ document.querySelectorAll(
12299
+ [
12300
+ "rai-widget",
12301
+ "rai-custom-widget",
12302
+ "rai-channel-widget",
12303
+ "rai-store-widget",
12304
+ "rai-milestone-widget",
12305
+ "rai-social-widget",
12306
+ "rai-currency-widget",
12307
+ "rai-referral-widget",
12308
+ ".rai-widget-root",
12309
+ '[data-rai-widget-root="true"]'
12310
+ ].join(",")
12311
+ )
12312
+ )
12313
+ ].filter(Boolean);
12314
+ for (const node of candidates) {
12315
+ const value = getComputedStyle(node).getPropertyValue(token).trim();
12316
+ if (value) return value;
12317
+ }
12318
+ return void 0;
12319
+ }
12320
+ const safeColor = (v) => {
12321
+ if (!v) return void 0;
12322
+ if (/^(#|rgb|hsl)/i.test(v)) return v;
12323
+ if (/^--[a-z0-9-]+$/i.test(v)) {
12324
+ const resolved = resolveCssToken(v);
12325
+ return resolved || `var(${v})`;
12326
+ }
12327
+ const varMatch = v.match(/^var\((--[a-z0-9-]+)\)$/i);
12328
+ if (varMatch) {
12329
+ const token = varMatch[1];
12330
+ const resolved = resolveCssToken(token);
12331
+ return resolved || v;
12332
+ }
12333
+ return void 0;
12334
+ };
12335
+ function el(tag, styles, attrs) {
12336
+ const node = document.createElement(tag);
12337
+ Object.assign(node.style, styles);
12338
+ if (attrs) {
12339
+ for (const k of Object.keys(attrs)) node.setAttribute(k, attrs[k]);
12340
+ }
12341
+ return node;
12342
+ }
12343
+ function ctaAlign(pos) {
12344
+ if (pos === "left") return "flex-start";
12345
+ if (pos === "right") return "flex-end";
12346
+ return "center";
12347
+ }
12348
+ function isImageBanner(banner) {
12349
+ var _a, _b;
12350
+ return banner.type === "image" && Boolean(((_a = banner.image) == null ? void 0 : _a.desktopUrl) || ((_b = banner.image) == null ? void 0 : _b.mobileUrl));
12351
+ }
12352
+ function imageAlign(pos) {
12353
+ if (pos === "left" || pos === "top") return "flex-start";
12354
+ if (pos === "right" || pos === "bottom") return "flex-end";
12355
+ return "center";
12356
+ }
12357
+ function getCtaStyleValue(banner, keys) {
12358
+ var _a;
12359
+ const sources = [(_a = banner.cta) == null ? void 0 : _a.style, banner.cta, banner.ctaStyle];
12360
+ for (const source of sources) {
12361
+ for (const key of keys) {
12362
+ const value = source == null ? void 0 : source[key];
12363
+ if (value) return value;
12364
+ }
12365
+ }
12366
+ return void 0;
12367
+ }
12368
+ function styleRichText(container) {
12369
+ container.querySelectorAll("p").forEach((p) => {
12370
+ p.style.margin = "0";
12371
+ });
12372
+ container.querySelectorAll("strong").forEach((strong) => {
12373
+ strong.style.fontWeight = "700";
12374
+ });
12375
+ container.querySelectorAll("em").forEach((em) => {
12376
+ em.style.fontStyle = "italic";
12377
+ });
12378
+ container.querySelectorAll("u").forEach((u) => {
12379
+ u.style.textDecoration = "underline";
12380
+ });
12381
+ container.querySelectorAll("a").forEach((a) => {
12382
+ a.style.color = "#3b82f6";
12383
+ a.style.textDecoration = "underline";
12384
+ if (a.getAttribute("target") === "_blank") {
12385
+ a.setAttribute("rel", "noopener noreferrer");
12386
+ }
12387
+ });
12388
+ container.querySelectorAll("img").forEach((img) => {
12389
+ img.style.maxWidth = "100%";
12390
+ img.style.height = "auto";
12391
+ });
12392
+ }
12393
+ function renderBanner(banner, handlers) {
12394
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
12395
+ const placement = banner.placement || {};
12396
+ const mode = placement.mode || "overlay";
12397
+ const position = placement.position || "top";
12398
+ const zIndex = String(placement.zIndex || 2147483e3);
12399
+ const imageBanner = isImageBanner(banner);
12400
+ const bg = imageBanner ? "transparent" : safeColor((_a = banner.style) == null ? void 0 : _a.backgroundColor) || "#1f2024";
12401
+ const color = safeColor((_b = banner.style) == null ? void 0 : _b.color) || "#ffffff";
12402
+ const isCard = mode === "overlay" || mode === "popup";
12403
+ const ctaPosition = getCtaStyleValue(banner, ["position"]) || "center";
12404
+ const imageHorizontal = imageAlign((_c = banner.image) == null ? void 0 : _c.horizontalAlignment);
12405
+ const imageVertical = imageAlign((_d = banner.image) == null ? void 0 : _d.verticalAlignment);
12406
+ const imageHorizontalPosition = ((_e = banner.image) == null ? void 0 : _e.horizontalAlignment) || "center";
12407
+ const imageVerticalPosition = ((_f = banner.image) == null ? void 0 : _f.verticalAlignment) || "center";
12408
+ const root = el("div", {
12409
+ boxSizing: "border-box",
12410
+ fontFamily: "Roboto, sans-serif",
12411
+ fontSize: "12px",
12412
+ lineHeight: "1.35",
12413
+ background: bg,
12414
+ color,
12415
+ borderRadius: isCard && !imageBanner ? "6px" : "0",
12416
+ boxShadow: isCard && !imageBanner ? "0 8px 24px rgba(0,0,0,0.22)" : "none",
12417
+ padding: imageBanner ? "0" : isCard ? "12px 24px" : "8px 16px",
12418
+ display: "flex",
12419
+ alignItems: imageBanner ? imageVertical : "flex-start",
12420
+ justifyContent: "center",
12421
+ gap: imageBanner ? "4px" : "16px"
12422
+ });
12423
+ root.setAttribute("role", isCard ? "dialog" : "region");
12424
+ root.setAttribute("aria-label", "community banner");
12425
+ root.setAttribute("data-renderer-version", "sdk-banner-preview-layout");
12426
+ if (isCard) {
12427
+ Object.assign(root.style, {
12428
+ position: "fixed",
12429
+ left: "50%",
12430
+ width: imageBanner ? "fit-content" : "fit-content",
12431
+ maxWidth: imageBanner ? "min(85vw, 700px)" : "min(700px, 80vw)",
12432
+ height: "auto",
12433
+ minHeight: imageBanner ? "0" : "80px",
12434
+ maxHeight: "calc(100vh - 300px)",
12435
+ overflowY: "auto",
12436
+ zIndex
12437
+ });
12438
+ if (imageBanner) {
12439
+ const translate = [];
12440
+ if (imageHorizontalPosition === "left") {
12441
+ root.style.left = "24px";
12442
+ } else if (imageHorizontalPosition === "right") {
12443
+ root.style.left = "";
12444
+ root.style.right = "24px";
12445
+ } else {
12446
+ root.style.left = "50%";
12447
+ translate.push("-50%");
12448
+ }
12449
+ if (imageVerticalPosition === "top") {
12450
+ root.style.top = "10px";
12451
+ } else if (imageVerticalPosition === "bottom") {
12452
+ root.style.bottom = "24px";
12453
+ } else {
12454
+ root.style.top = "50%";
12455
+ translate.push("-50%");
12456
+ }
12457
+ if (translate.length === 2) root.style.transform = `translate(${translate[0]}, ${translate[1]})`;
12458
+ else if (translate.length === 1 && imageHorizontalPosition === "center") root.style.transform = `translateX(${translate[0]})`;
12459
+ else if (translate.length === 1) root.style.transform = `translateY(${translate[0]})`;
12460
+ else root.style.transform = "";
12461
+ } else if (position === "bottom") {
12462
+ root.style.bottom = "24px";
12463
+ root.style.transform = "translateX(-50%)";
12464
+ } else if (position === "center") {
12465
+ root.style.top = "50%";
12466
+ root.style.transform = "translate(-50%, -50%)";
12467
+ } else {
12468
+ root.style.top = "10px";
12469
+ root.style.transform = "translateX(-50%)";
12470
+ }
12471
+ } else {
12472
+ Object.assign(root.style, { position: "relative", width: "100%", zIndex });
12473
+ }
12474
+ const contentWrap = el("div", {
12475
+ display: "flex",
12476
+ width: imageBanner ? "auto" : "100%",
12477
+ maxWidth: "100%",
12478
+ flexDirection: "column",
12479
+ gap: imageBanner ? "0" : "12px",
12480
+ overflow: "hidden"
12481
+ });
12482
+ const contentRow = el("div", {
12483
+ display: "flex",
12484
+ width: "100%",
12485
+ justifyContent: imageBanner ? imageHorizontal : "space-between",
12486
+ alignItems: imageBanner ? imageVertical : "flex-start",
12487
+ gap: "12px"
12488
+ });
12489
+ const content = el("div", {
12490
+ width: imageBanner ? "auto" : "100%",
12491
+ maxWidth: "100%",
12492
+ overflow: "hidden",
12493
+ wordBreak: "break-word"
12494
+ });
12495
+ const imageUrl = ((_g = banner.image) == null ? void 0 : _g.desktopUrl) || ((_h = banner.image) == null ? void 0 : _h.mobileUrl);
12496
+ if (imageBanner && imageUrl) {
12497
+ const imageLinkUrl = (_i = banner.image) == null ? void 0 : _i.linkUrl;
12498
+ const imageOpenInNewTab = (_j = banner.image) == null ? void 0 : _j.openInNewTab;
12499
+ const img = el(
12500
+ "img",
12501
+ {
12502
+ display: "block",
12503
+ maxWidth: "100%",
12504
+ maxHeight: "240px",
12505
+ height: "auto",
12506
+ objectFit: "contain",
12507
+ cursor: imageLinkUrl ? "pointer" : "",
12508
+ borderRadius: ((_k = banner.image) == null ? void 0 : _k.cornerRadius) === "rounded" ? "8px" : "0"
12509
+ },
12510
+ { src: imageUrl, alt: banner.title || "banner" }
12511
+ );
12512
+ if (imageLinkUrl) {
12513
+ img.addEventListener("click", () => {
12514
+ if (imageOpenInNewTab) {
12515
+ window.open(imageLinkUrl, "_blank", "noopener,noreferrer");
12516
+ } else {
12517
+ window.location.href = imageLinkUrl;
12518
+ }
12519
+ });
12520
+ }
12521
+ content.appendChild(img);
12522
+ } else {
12523
+ content.innerHTML = sanitizeBannerHtml(banner.text);
12524
+ styleRichText(content);
12525
+ }
12526
+ if (!imageBanner && ((_l = banner.cta) == null ? void 0 : _l.enabled)) {
12527
+ const ctaBg = safeColor(
12528
+ getCtaStyleValue(banner, ["backgroundColor", "buttonColor", "aColor"])
12529
+ ) || safeColor((_m = banner.style) == null ? void 0 : _m.backgroundColor) || "#2f6df6";
12530
+ const ctaColor = safeColor(getCtaStyleValue(banner, ["textColor", "color"])) || "#ffffff";
12531
+ const btn = el("button", {
12532
+ cursor: "pointer",
12533
+ border: "none",
12534
+ borderRadius: "4px",
12535
+ height: "36px",
12536
+ minHeight: "36px",
12537
+ padding: "0 16px",
12538
+ fontSize: "12px",
12539
+ fontWeight: "600",
12540
+ lineHeight: "20px",
12541
+ background: ctaBg,
12542
+ color: ctaColor,
12543
+ boxSizing: "border-box",
12544
+ display: "inline-flex",
12545
+ alignItems: "center",
12546
+ justifyContent: "center"
12547
+ });
12548
+ btn.type = "button";
12549
+ btn.textContent = banner.cta.label || "CTA Button";
12550
+ btn.addEventListener("click", handlers.onCtaClick);
12551
+ if (ctaPosition === "inline") {
12552
+ contentRow.appendChild(content);
12553
+ const inlineWrap = el("div", {
12554
+ display: "flex",
12555
+ flexDirection: "column",
12556
+ alignItems: "flex-end",
12557
+ justifyContent: "center",
12558
+ flexShrink: "0"
12559
+ });
12560
+ inlineWrap.appendChild(btn);
12561
+ contentRow.appendChild(inlineWrap);
12562
+ contentWrap.appendChild(contentRow);
12563
+ } else {
12564
+ contentRow.appendChild(content);
12565
+ contentWrap.appendChild(contentRow);
12566
+ const wrap = el("div", {
12567
+ display: "flex",
12568
+ width: "100%",
12569
+ justifyContent: ctaAlign(ctaPosition)
12570
+ });
12571
+ wrap.appendChild(btn);
12572
+ contentWrap.appendChild(wrap);
12573
+ }
12574
+ } else {
12575
+ contentRow.appendChild(content);
12576
+ contentWrap.appendChild(contentRow);
12577
+ }
12578
+ root.appendChild(contentWrap);
12579
+ const close = el("button", {
12580
+ marginTop: imageBanner ? "0" : "8px",
12581
+ width: "20px",
12582
+ minWidth: "20px",
12583
+ height: "20px",
12584
+ cursor: "pointer",
12585
+ border: "none",
12586
+ borderRadius: "50%",
12587
+ background: "rgba(0,0,0,0.25)",
12588
+ color,
12589
+ fontSize: "16px",
12590
+ lineHeight: "1",
12591
+ display: "flex",
12592
+ alignItems: "center",
12593
+ justifyContent: "center",
12594
+ padding: "0",
12595
+ flexShrink: "0"
12596
+ });
12597
+ close.type = "button";
12598
+ close.setAttribute("aria-label", "dismiss banner");
12599
+ close.innerHTML = "&times;";
12600
+ close.addEventListener("click", handlers.onDismiss);
12601
+ root.appendChild(close);
12602
+ return root;
12603
+ }
12604
+ const VISITOR_KEY = "rai-banner-visitor";
12605
+ function uuid() {
12606
+ try {
12607
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
12608
+ return crypto.randomUUID();
12609
+ }
12610
+ } catch {
12611
+ }
12612
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
12613
+ const r = Math.random() * 16 | 0;
12614
+ const v = c === "x" ? r : r & 3 | 8;
12615
+ return v.toString(16);
12616
+ });
12617
+ }
12618
+ function getOrCreateVisitorId(communityId, storagePrefix) {
12619
+ const key = `${storagePrefix}-${VISITOR_KEY}-${communityId}`;
12620
+ try {
12621
+ let id = localStorage.getItem(key);
12622
+ if (!id) {
12623
+ id = uuid();
12624
+ localStorage.setItem(key, id);
12625
+ }
12626
+ return id;
12627
+ } catch {
12628
+ return uuid();
12629
+ }
12630
+ }
12631
+ function fireTracking(url) {
12632
+ if (!url) return;
12633
+ try {
12634
+ const img = new Image();
12635
+ img.src = url;
12636
+ } catch {
12637
+ }
12638
+ }
10887
12639
  const widgetCSS = ':host{display:block;position:relative;width:100%;height:100%}.rai-loader{position:absolute;top:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.75rem;width:100%;height:100%;background:var(--background-5, var(--rai-loader-bg, #ffffff));border-radius:8px;z-index:10;transition:opacity .3s ease-out;font-family:var(--rai-loader-font, "Roboto", system-ui, -apple-system, sans-serif)}.rai-loader.fade-out{opacity:0;pointer-events:none}.rai-loader-text{margin:.5rem 0 0;font-size:1.125rem;line-height:1.75rem;font-weight:400;letter-spacing:normal;color:var(--accent-1, var(--rai-accent, #000000));text-align:center}@media (min-width: 768px){.rai-loader-text{font-size:1.5rem;line-height:2rem}}.rai-error{display:none;position:absolute;top:0;left:0;width:100%;height:100%;align-items:center;justify-content:center;flex-direction:column;gap:12px;background:var(--rai-error-bg, #1a1a1a);border-radius:8px;padding:24px;box-sizing:border-box;text-align:center;color:var(--rai-error-text, #9ca3af);font-family:system-ui,-apple-system,sans-serif;z-index:10}.rai-error.visible{display:flex}iframe{display:block;border:none;opacity:0;transition:opacity .3s ease-in}iframe.loaded{opacity:1}.rai-lottie-loader{width:100px;height:100px}.rai-lottie-loader svg{width:100%!important;height:100%!important}.rai-lottie-spinner{width:32px;height:32px;margin:34px auto;border:3px solid var(--rai-text4, #6b7280);border-top-color:var(--rai-accent, #000000);border-radius:50%;animation:rai-spin .7s linear infinite}@keyframes rai-spin{to{transform:rotate(360deg)}}.rai-sdk-loader{position:relative;width:75px;height:100px}.rai-sdk-loader__bar{position:absolute;bottom:0;width:10px;height:50%;background:var(--rai-accent, #000000);transform-origin:center bottom;box-shadow:1px 1px #0003}.rai-sdk-loader__bar:nth-child(1){left:0;transform:scaleY(.2);animation:rai-sdk-barUp1 4s infinite}.rai-sdk-loader__bar:nth-child(2){left:15px;transform:scaleY(.4);animation:rai-sdk-barUp2 4s infinite}.rai-sdk-loader__bar:nth-child(3){left:30px;transform:scaleY(.6);animation:rai-sdk-barUp3 4s infinite}.rai-sdk-loader__bar:nth-child(4){left:45px;transform:scaleY(.8);animation:rai-sdk-barUp4 4s infinite}.rai-sdk-loader__bar:nth-child(5){left:60px;transform:scale(1);animation:rai-sdk-barUp5 4s infinite}.rai-sdk-loader__ball{position:absolute;bottom:10px;left:0;width:10px;height:10px;background:var(--rai-accent, #000000);border-radius:50%;animation:rai-sdk-ball 4s infinite}@keyframes rai-sdk-ball{0%{transform:translate(0)}5%{transform:translate(8px,-14px)}10%{transform:translate(15px,-10px)}17%{transform:translate(23px,-24px)}20%{transform:translate(30px,-20px)}27%{transform:translate(38px,-34px)}30%{transform:translate(45px,-30px)}37%{transform:translate(53px,-44px)}40%{transform:translate(60px,-40px)}50%{transform:translate(60px)}57%{transform:translate(53px,-14px)}60%{transform:translate(45px,-10px)}67%{transform:translate(37px,-24px)}70%{transform:translate(30px,-20px)}77%{transform:translate(22px,-34px)}80%{transform:translate(15px,-30px)}87%{transform:translate(7px,-44px)}90%{transform:translateY(-40px)}to{transform:translate(0)}}@keyframes rai-sdk-barUp1{0%{transform:scaleY(.2)}40%{transform:scaleY(.2)}50%{transform:scale(1)}90%{transform:scale(1)}to{transform:scaleY(.2)}}@keyframes rai-sdk-barUp2{0%{transform:scaleY(.4)}40%{transform:scaleY(.4)}50%{transform:scaleY(.8)}90%{transform:scaleY(.8)}to{transform:scaleY(.4)}}@keyframes rai-sdk-barUp3{0%{transform:scaleY(.6)}to{transform:scaleY(.6)}}@keyframes rai-sdk-barUp4{0%{transform:scaleY(.8)}40%{transform:scaleY(.8)}50%{transform:scaleY(.4)}90%{transform:scaleY(.4)}to{transform:scaleY(.8)}}@keyframes rai-sdk-barUp5{0%{transform:scale(1)}40%{transform:scale(1)}50%{transform:scaleY(.2)}90%{transform:scaleY(.2)}to{transform:scale(1)}}#loading-square{width:75px;aspect-ratio:1;display:flex;color:var(--rai-accent, #000000);background:linear-gradient(currentColor 0 0) right / 51% 100%,linear-gradient(currentColor 0 0) bottom / 100% 51%;background-repeat:no-repeat;animation:l16-0 2s infinite linear .25s}#loading-square>div{width:50%;height:50%;background:currentColor;animation:l16-1 .5s infinite linear}@keyframes l16-0{0%,12.49%{transform:rotate(0)}12.5%,37.49%{transform:rotate(90deg)}37.5%,62.49%{transform:rotate(180deg)}62.5%,87.49%{transform:rotate(270deg)}87.5%,to{transform:rotate(360deg)}}@keyframes l16-1{0%{transform:perspective(80px) rotate3d(-1,-1,0,0)}80%,to{transform:perspective(80px) rotate3d(-1,-1,0,-180deg)}}#loading-circle{width:75px;aspect-ratio:1;display:grid;grid:50%/50%;color:var(--rai-accent, #000000);border-radius:50%;--_g: no-repeat linear-gradient(currentColor 0 0);background:var(--_g),var(--_g),var(--_g);background-size:50.1% 50.1%;animation:l9-0 1.5s infinite steps(1) alternate,l9-0-0 3s infinite steps(1) alternate}#loading-circle>div{background:var(--rai-text4, #6b7280);border-top-left-radius:100px;transform:perspective(150px) rotateY(0) rotateX(0);transform-origin:bottom right;animation:l9-1 1.5s infinite linear alternate}@keyframes l9-0{0%{background-position:0 100%,100% 100%,100% 0}33%{background-position:100% 100%,100% 100%,100% 0}66%{background-position:100% 0,100% 0,100% 0}}@keyframes l9-0-0{0%{transform:scaleX(1) rotate(0)}50%{transform:scaleX(-1) rotate(-90deg)}}@keyframes l9-1{16.5%{transform:perspective(150px) rotateX(-90deg) rotateY(0) rotateX(0);filter:grayscale(.8)}33%{transform:perspective(150px) rotateX(-180deg) rotateY(0) rotateX(0)}66%{transform:perspective(150px) rotateX(-180deg) rotateY(-180deg) rotateX(0)}to{transform:perspective(150px) rotateX(-180deg) rotateY(-180deg) rotateX(-180deg);filter:grayscale(.8)}}.rai-custom-error{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.tiptap strong.tw-font-bold,.tiptap b.tw-font-bold{font-weight:700}.tiptap em.tw-font-italic,.tiptap i.tw-font-italic{font-style:italic}.tiptap a.tiptap-rich-text-link{color:#3b82f6;text-decoration:underline;position:relative;display:inline-block;width:fit-content}.tiptap a.tiptap-rich-text-link:hover{color:#3b82f6cc;text-decoration:none}.tiptap a.tiptap-rich-text-link:not([title=""]):before{content:attr(title);position:absolute;top:-2rem;left:50%;transform:translate(-50%);white-space:nowrap;border-radius:.25rem;background-color:#000;padding:.25rem .5rem;color:#fff;opacity:0;transition:opacity .2s;pointer-events:none}.tiptap a.tiptap-rich-text-link:not([title=""]):hover:before{opacity:1}.tiptap p[style*="text-align: left"]{text-align:left}.tiptap p[style*="text-align: center"]{text-align:center}.tiptap p[style*="text-align: right"]{text-align:right}.tiptap p[style*="text-align: justify"]{text-align:justify}.tiptap u{text-decoration:underline}.tiptap.ProseMirror{background-color:transparent;height:fit-content!important;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:0;width:100%;overflow-y:auto}.tiptap{line-height:1.6;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}.tiptap p{margin:.5em 0}.tiptap p:first-child{margin-top:0}.tiptap p:last-child{margin-bottom:0}.tiptap img{max-width:100%;height:auto;display:block}.tiptap p[style*="text-align: left"] img{margin-left:0;margin-right:auto}.tiptap p[style*="text-align: center"] img{margin-left:auto;margin-right:auto}.tiptap p[style*="text-align: right"] img{margin-left:auto;margin-right:0}.rai-retry-btn{padding:8px 20px;border:none;border-radius:6px;background:var(--rai-accent, #000000);color:var(--rai-error-bg, #ffffff);font-size:14px;font-family:system-ui,-apple-system,sans-serif;cursor:pointer}.rai-retry-btn:hover{opacity:.85}';
10888
12640
  const DEFINED_ATTRS = /* @__PURE__ */ new Set([
10889
12641
  "community-id",
@@ -11015,26 +12767,26 @@ function ensureGoogleFontLoaded(family) {
11015
12767
  }
11016
12768
  const DANGEROUS_ELEMENTS = ["script", "iframe", "object", "embed"];
11017
12769
  const URL_ATTRS = ["src", "href", "xlink:href"];
11018
- function sanitizeLoaderHtml(html) {
11019
- const doc = new DOMParser().parseFromString(html, "text/html");
11020
- doc.body.querySelectorAll(DANGEROUS_ELEMENTS.join(",")).forEach((el) => el.remove());
11021
- doc.body.querySelectorAll("*").forEach((el) => {
11022
- Array.from(el.attributes).forEach((attr) => {
12770
+ function sanitizeLoaderHtml(html2) {
12771
+ const doc = new DOMParser().parseFromString(html2, "text/html");
12772
+ doc.body.querySelectorAll(DANGEROUS_ELEMENTS.join(",")).forEach((el2) => el2.remove());
12773
+ doc.body.querySelectorAll("*").forEach((el2) => {
12774
+ Array.from(el2.attributes).forEach((attr) => {
11023
12775
  const name = attr.name.toLowerCase();
11024
12776
  if (name.startsWith("on")) {
11025
- el.removeAttribute(attr.name);
12777
+ el2.removeAttribute(attr.name);
11026
12778
  return;
11027
12779
  }
11028
12780
  if (URL_ATTRS.includes(name)) {
11029
12781
  const val = attr.value.trim().toLowerCase();
11030
- if (val.startsWith("javascript:")) el.removeAttribute(attr.name);
12782
+ if (val.startsWith("javascript:")) el2.removeAttribute(attr.name);
11031
12783
  }
11032
12784
  });
11033
12785
  });
11034
12786
  return doc.body.innerHTML;
11035
12787
  }
11036
- function readConfig(el, existingId) {
11037
- const get = (name) => el.getAttribute(name) ?? el.getAttribute(`data-${name}`) ?? "";
12788
+ function readConfig(el2, existingId) {
12789
+ const get = (name) => el2.getAttribute(name) ?? el2.getAttribute(`data-${name}`) ?? "";
11038
12790
  const num = (name, def) => {
11039
12791
  const v = parseInt(get(name), 10);
11040
12792
  return Number.isFinite(v) && v >= 0 ? v : def;
@@ -11048,7 +12800,7 @@ function readConfig(el, existingId) {
11048
12800
  if (channelId && !/^[a-zA-Z0-9_\-=]{8,}$/.test(channelId)) {
11049
12801
  throw new Error(`[rai-widget] Invalid channel-id: "${channelId}"`);
11050
12802
  }
11051
- const widgetType = get("widget-type") || TAG_TO_TYPE[el.tagName] || "store";
12803
+ const widgetType = get("widget-type") || TAG_TO_TYPE[el2.tagName] || "store";
11052
12804
  let widgetId;
11053
12805
  if (usesExplicitIds) {
11054
12806
  if (widgetType === "store") {
@@ -11082,7 +12834,7 @@ function readConfig(el, existingId) {
11082
12834
  const domainKey = normalizeDomainKey(get("domain-key")) || inferDomainKeyFromUrl(explicitApiUrl) || inferDomainKeyFromUrl(explicitV2ApiUrl) || "PROD";
11083
12835
  const container = get("container") || get("data-container") || `returning-ai-widget-${widgetId}`;
11084
12836
  const userIdentifiers = {};
11085
- Array.from(el.attributes).forEach((attr) => {
12837
+ Array.from(el2.attributes).forEach((attr) => {
11086
12838
  const name = attr.name.toLowerCase();
11087
12839
  if (!name.startsWith("data-")) return;
11088
12840
  const bare = name.slice(5);
@@ -11142,9 +12894,9 @@ function readConfig(el, existingId) {
11142
12894
  // matches React WidgetLoadingPage default
11143
12895
  firstPaintColors: (() => {
11144
12896
  const bg = get("bg") || void 0;
11145
- const text = get("text") || void 0;
12897
+ const text2 = get("text") || void 0;
11146
12898
  const accent = get("accent") || void 0;
11147
- return bg || text || accent ? { bg, text, accent } : void 0;
12899
+ return bg || text2 || accent ? { bg, text: text2, accent } : void 0;
11148
12900
  })(),
11149
12901
  firstPaintFont: get("font") || void 0
11150
12902
  };
@@ -11196,6 +12948,7 @@ class BaseWidget extends HTMLElement {
11196
12948
  __publicField(this, "initGeneration", 0);
11197
12949
  __publicField(this, "lottieInstances", []);
11198
12950
  __publicField(this, "callbackRegistry", new WidgetCallbackRegistry());
12951
+ __publicField(this, "bannerNode", null);
11199
12952
  this.shadow = this.attachShadow({ mode: "closed" });
11200
12953
  }
11201
12954
  static get observedAttributes() {
@@ -11229,8 +12982,8 @@ class BaseWidget extends HTMLElement {
11229
12982
  if (this.hasAttribute("eager")) {
11230
12983
  this.init();
11231
12984
  } else {
11232
- this.intersectionObserver = new IntersectionObserver((entries) => {
11233
- if (entries[0].isIntersecting) {
12985
+ this.intersectionObserver = new IntersectionObserver((entries2) => {
12986
+ if (entries2[0].isIntersecting) {
11234
12987
  this.intersectionObserver.disconnect();
11235
12988
  this.intersectionObserver = void 0;
11236
12989
  this.init();
@@ -11246,6 +12999,7 @@ class BaseWidget extends HTMLElement {
11246
12999
  (_c = this.identityAttributeObserver) == null ? void 0 : _c.disconnect();
11247
13000
  this.teardownMountedWidget();
11248
13001
  this.clearLottieInstances();
13002
+ this.removeBanner();
11249
13003
  clearState(this.state);
11250
13004
  }
11251
13005
  attributeChangedCallback(name, oldValue, newValue) {
@@ -11479,18 +13233,18 @@ class BaseWidget extends HTMLElement {
11479
13233
  }
11480
13234
  createPresetLoader(preset) {
11481
13235
  if (preset === "square") {
11482
- const el = document.createElement("div");
11483
- el.id = "loading-square";
13236
+ const el2 = document.createElement("div");
13237
+ el2.id = "loading-square";
11484
13238
  const inner = document.createElement("div");
11485
- el.appendChild(inner);
11486
- return el;
13239
+ el2.appendChild(inner);
13240
+ return el2;
11487
13241
  }
11488
13242
  if (preset === "circle") {
11489
- const el = document.createElement("div");
11490
- el.id = "loading-circle";
13243
+ const el2 = document.createElement("div");
13244
+ el2.id = "loading-circle";
11491
13245
  const inner = document.createElement("div");
11492
- el.appendChild(inner);
11493
- return el;
13246
+ el2.appendChild(inner);
13247
+ return el2;
11494
13248
  }
11495
13249
  return this.createDefaultLoader();
11496
13250
  }
@@ -11599,6 +13353,102 @@ class BaseWidget extends HTMLElement {
11599
13353
  errorContainer.appendChild(modal);
11600
13354
  this.shadow.appendChild(errorContainer);
11601
13355
  }
13356
+ // ── Banner SDK auto-integration ────────────────────────────────────────
13357
+ resolveBannerApiUrl() {
13358
+ if (this.config.v2ApiUrl) return this.config.v2ApiUrl.replace(/\/+$/, "");
13359
+ switch (this.config.domainKey) {
13360
+ case "SGTR":
13361
+ return "https://api-v2.genesiv.org";
13362
+ case "STG":
13363
+ return "https://staging-api-v2.genesiv.org";
13364
+ case "LOCAL":
13365
+ return "http://localhost:1335";
13366
+ default:
13367
+ return "https://api-v2.returning.ai";
13368
+ }
13369
+ }
13370
+ removeBanner() {
13371
+ var _a;
13372
+ if ((_a = this.bannerNode) == null ? void 0 : _a.parentNode) this.bannerNode.parentNode.removeChild(this.bannerNode);
13373
+ this.bannerNode = null;
13374
+ }
13375
+ /**
13376
+ * After the widget mounts, fetch + render any eligible sdk-surface banner
13377
+ * targeted at this widget type. Core widgets send their communityId + type;
13378
+ * custom widgets send the decoded widget id so the server resolves the precise
13379
+ * sub-type + community. Best-effort: never throws into the host page.
13380
+ */
13381
+ async mountBannerForWidget() {
13382
+ var _a, _b;
13383
+ try {
13384
+ if (this.bannerNode) return;
13385
+ if (this.getAttribute("banner") === "off" || this.hasAttribute("no-banner")) return;
13386
+ const apiUrl = this.resolveBannerApiUrl();
13387
+ const isCustom = this.config.widgetType === "custom";
13388
+ let communityId;
13389
+ let widgetId;
13390
+ if (isCustom) {
13391
+ const isObjectId = (v) => /^[a-f0-9]{24}$/i.test(v);
13392
+ let decoded = "";
13393
+ try {
13394
+ decoded = atob(this.config.communityId);
13395
+ } catch {
13396
+ decoded = "";
13397
+ }
13398
+ if (isObjectId(decoded)) widgetId = decoded;
13399
+ else if (isObjectId(this.config.communityId)) widgetId = this.config.communityId;
13400
+ if (!widgetId) return;
13401
+ } else {
13402
+ communityId = this.config.communityId;
13403
+ }
13404
+ const sessionKey = this.config.communityId || widgetId || "rai";
13405
+ const visitorId = getOrCreateVisitorId(sessionKey, this.config.storagePrefix);
13406
+ const w = window.innerWidth;
13407
+ const device = w < 640 ? "mobile" : w < 1024 ? "tablet" : "desktop";
13408
+ const result = await fetchEligibleBanner(apiUrl, {
13409
+ communityId,
13410
+ surface: "sdk",
13411
+ widgetType: this.config.widgetType,
13412
+ widgetId,
13413
+ // Pass the embed token the widget authed with, so `access: 'domain' |
13414
+ // 'authenticated'` banners can be served/gated via its access key origins.
13415
+ embedToken: this.config.embedToken,
13416
+ page: {
13417
+ url: window.location.href,
13418
+ hostname: window.location.hostname,
13419
+ path: window.location.pathname
13420
+ },
13421
+ viewport: { width: window.innerWidth, height: window.innerHeight, device },
13422
+ identifier: { type: "anonymous_session", value: visitorId }
13423
+ });
13424
+ if (!this.isConnected) return;
13425
+ const banner = result.banner;
13426
+ if (!banner) return;
13427
+ if (((_a = banner.placement) == null ? void 0 : _a.mobileBehavior) === "hide" && device === "mobile") return;
13428
+ const node = renderBanner(banner, {
13429
+ onCtaClick: () => {
13430
+ var _a2, _b2, _c;
13431
+ fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.clickUrl);
13432
+ this.emit("rai-banner-click", { bannerId: banner.id });
13433
+ const url = (_b2 = banner.cta) == null ? void 0 : _b2.url;
13434
+ if (!url) return;
13435
+ if ((_c = banner.cta) == null ? void 0 : _c.openInNewTab) window.open(url, "_blank", "noopener,noreferrer");
13436
+ else window.location.href = url;
13437
+ },
13438
+ onDismiss: () => {
13439
+ var _a2;
13440
+ fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.dismissUrl);
13441
+ this.emit("rai-banner-dismiss", { bannerId: banner.id });
13442
+ this.removeBanner();
13443
+ }
13444
+ });
13445
+ this.bannerNode = node;
13446
+ document.body.appendChild(node);
13447
+ fireTracking((_b = banner.tracking) == null ? void 0 : _b.impressionUrl);
13448
+ this.emit("rai-banner-impression", { bannerId: banner.id });
13449
+ } catch {
13450
+ }
13451
+ }
11602
13452
  // ── Initialization ─────────────────────────────────────────────────────
11603
13453
  async init() {
11604
13454
  const initId = ++this.initGeneration;
@@ -11613,7 +13463,20 @@ class BaseWidget extends HTMLElement {
11613
13463
  var _a;
11614
13464
  if (!this.isCurrentInit(initId)) return;
11615
13465
  (_a = this.errorEl) == null ? void 0 : _a.classList.remove("visible");
11616
- this.shadow.querySelectorAll(".rai-custom-error").forEach((el) => el.remove());
13466
+ this.shadow.querySelectorAll(".rai-custom-error").forEach((el2) => el2.remove());
13467
+ let bannerGated = false;
13468
+ let bannerGateTimer = 0;
13469
+ const mountBannerOnce = () => {
13470
+ if (bannerGated) return;
13471
+ bannerGated = true;
13472
+ window.clearTimeout(bannerGateTimer);
13473
+ this.removeEventListener("rai-mounted", mountBannerOnce);
13474
+ this.removeEventListener("rai-ready", mountBannerOnce);
13475
+ void this.mountBannerForWidget();
13476
+ };
13477
+ this.addEventListener("rai-mounted", mountBannerOnce);
13478
+ this.addEventListener("rai-ready", mountBannerOnce);
13479
+ bannerGateTimer = window.setTimeout(mountBannerOnce, 2500);
11617
13480
  if (this.config.bundleUrl) {
11618
13481
  this.mountWidget();
11619
13482
  } else {
@@ -11695,9 +13558,9 @@ class BaseWidget extends HTMLElement {
11695
13558
  this.state.syncTimer = null;
11696
13559
  }
11697
13560
  this.state.iframe = null;
11698
- this.shadow.querySelectorAll("iframe").forEach((el) => el.remove());
13561
+ this.shadow.querySelectorAll("iframe").forEach((el2) => el2.remove());
11699
13562
  this.querySelectorAll('[data-rai-widget-root="true"]').forEach(
11700
- (el) => el.remove()
13563
+ (el2) => el2.remove()
11701
13564
  );
11702
13565
  }
11703
13566
  createIframe() {
@@ -11739,6 +13602,7 @@ class BaseWidget extends HTMLElement {
11739
13602
  }
11740
13603
  // ── Bundle mode (no-iframe) ──────────────────────────────────────────
11741
13604
  async mountWidget() {
13605
+ var _a;
11742
13606
  try {
11743
13607
  this.teardownMountedWidget();
11744
13608
  const bundleApiUrl = this.config.v2ApiUrl || resolveV2ApiUrl(this.config.domainKey);
@@ -11760,8 +13624,10 @@ class BaseWidget extends HTMLElement {
11760
13624
  if (this.state.loadingAnimation) {
11761
13625
  window.loadingAnimation = this.state.loadingAnimation;
11762
13626
  }
11763
- await loadScript(this.config.bundleUrl);
11764
13627
  const globalName = WIDGET_GLOBALS[this.config.widgetType];
13628
+ if (!((_a = window[globalName]) == null ? void 0 : _a.mount)) {
13629
+ await loadScript(this.config.bundleUrl);
13630
+ }
11765
13631
  const widgetGlobal = window[globalName];
11766
13632
  if (!(widgetGlobal == null ? void 0 : widgetGlobal.mount)) {
11767
13633
  throw new Error(
@@ -11866,6 +13732,7 @@ class BaseWidget extends HTMLElement {
11866
13732
  async logoutAndClear() {
11867
13733
  await logout(this.config, this.state);
11868
13734
  this.teardownMountedWidget();
13735
+ this.removeBanner();
11869
13736
  this.emit("rai-logout");
11870
13737
  }
11871
13738
  // ── Public API ────────────────────────────────────────────────────────
@@ -11879,6 +13746,7 @@ class BaseWidget extends HTMLElement {
11879
13746
  clearStorage(previousConfig);
11880
13747
  clearStorage(this.config);
11881
13748
  this.teardownMountedWidget();
13749
+ this.removeBanner();
11882
13750
  clearState(this.state);
11883
13751
  await this.init();
11884
13752
  }
@@ -12000,7 +13868,7 @@ class CustomWidget extends BaseWidget {
12000
13868
  }
12001
13869
  }
12002
13870
  }
12003
- console.log(`[rai-widget] v${"1.5.0"}`);
13871
+ console.log(`[rai-widget] v${"1.6.0"}`);
12004
13872
  class StoreWidgetCompat extends StoreWidget {
12005
13873
  }
12006
13874
  const WIDGET_REGISTRY = [
@@ -12064,7 +13932,7 @@ function exposePublicApi() {
12064
13932
  })();
12065
13933
  const widget = container == null ? void 0 : container.querySelector(ALL_WIDGET_SELECTOR);
12066
13934
  window.ReturningAIWidget = {
12067
- version: "1.5.0",
13935
+ version: "1.6.0",
12068
13936
  reload: () => (widget == null ? void 0 : widget.reload()) ?? Promise.resolve(),
12069
13937
  logout: () => (widget == null ? void 0 : widget.logoutPublic()) ?? Promise.resolve(),
12070
13938
  isAuthenticated: () => (widget == null ? void 0 : widget.isAuthenticated()) ?? false,