@returningai/widget-sdk 1.7.2 → 1.8.1
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.
- package/CHANGELOG.md +45 -0
- package/README.md +49 -9
- package/dist/rai-banner.iife.js +3 -3
- package/dist/rai-banner.js +268 -144
- package/dist/rai-widget.iife.js +3 -3
- package/dist/rai-widget.js +827 -265
- package/dist/types/BaseWidget.d.ts +6 -4
- package/dist/types/core/bundle-runtime-cache.d.ts +6 -0
- package/dist/types/core/bundle-token-sync.d.ts +7 -0
- package/dist/types/core/host-callback.d.ts +49 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +65 -10
- package/package.json +5 -4
package/dist/rai-widget.js
CHANGED
|
@@ -6,7 +6,7 @@ function getDefaultExportFromCjs(x) {
|
|
|
6
6
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
7
7
|
}
|
|
8
8
|
var lottie_light = { exports: {} };
|
|
9
|
-
(function(module, exports
|
|
9
|
+
(function(module, exports) {
|
|
10
10
|
typeof document !== "undefined" && typeof navigator !== "undefined" && function(global2, factory) {
|
|
11
11
|
module.exports = factory();
|
|
12
12
|
}(commonjsGlobal, function() {
|
|
@@ -4231,7 +4231,7 @@ var lottie_light = { exports: {} };
|
|
|
4231
4231
|
}
|
|
4232
4232
|
var readyStateCheckInterval = setInterval(checkReady, 100);
|
|
4233
4233
|
try {
|
|
4234
|
-
if (!((false ? "undefined" : _typeof(exports
|
|
4234
|
+
if (!((false ? "undefined" : _typeof(exports)) === "object" && true) && true) {
|
|
4235
4235
|
window.bodymovin = lottie2;
|
|
4236
4236
|
}
|
|
4237
4237
|
} catch (err) {
|
|
@@ -10351,7 +10351,7 @@ async function fetchEligibleBanner(apiUrl, request) {
|
|
|
10351
10351
|
return { banner: null, reason: "network_error" };
|
|
10352
10352
|
}
|
|
10353
10353
|
}
|
|
10354
|
-
/*! @license DOMPurify 3.4.
|
|
10354
|
+
/*! @license DOMPurify 3.4.12 | (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.12/LICENSE */
|
|
10355
10355
|
function _arrayLikeToArray(r, a) {
|
|
10356
10356
|
(null == a || a > r.length) && (a = r.length);
|
|
10357
10357
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -10584,7 +10584,7 @@ const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mgly
|
|
|
10584
10584
|
const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
10585
10585
|
const text = freeze(["#text"]);
|
|
10586
10586
|
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"]);
|
|
10587
|
-
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"]);
|
|
10587
|
+
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", "dominant-baseline", "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-orientation", "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"]);
|
|
10588
10588
|
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"]);
|
|
10589
10589
|
const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
10590
10590
|
const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
@@ -10603,6 +10603,10 @@ const ATTR_WHITESPACE = seal(
|
|
|
10603
10603
|
);
|
|
10604
10604
|
const DOCTYPE_NAME = seal(/^html$/i);
|
|
10605
10605
|
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
10606
|
+
const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
10607
|
+
const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
10608
|
+
const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
10609
|
+
const SELF_CLOSING_TAG = seal(/\/>/i);
|
|
10606
10610
|
const NODE_TYPE = {
|
|
10607
10611
|
element: 1,
|
|
10608
10612
|
attribute: 2,
|
|
@@ -10612,7 +10616,7 @@ const NODE_TYPE = {
|
|
|
10612
10616
|
// Deprecated
|
|
10613
10617
|
entityNode: 6,
|
|
10614
10618
|
// Deprecated
|
|
10615
|
-
|
|
10619
|
+
processingInstruction: 7,
|
|
10616
10620
|
comment: 8,
|
|
10617
10621
|
document: 9,
|
|
10618
10622
|
documentType: 10,
|
|
@@ -10660,10 +10664,13 @@ const _createHooksMap = function _createHooksMap2() {
|
|
|
10660
10664
|
uponSanitizeShadowNode: []
|
|
10661
10665
|
};
|
|
10662
10666
|
};
|
|
10667
|
+
const _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
|
|
10668
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
10669
|
+
};
|
|
10663
10670
|
function createDOMPurify() {
|
|
10664
10671
|
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
10665
10672
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
10666
|
-
DOMPurify.version = "3.4.
|
|
10673
|
+
DOMPurify.version = "3.4.12";
|
|
10667
10674
|
DOMPurify.removed = [];
|
|
10668
10675
|
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
10669
10676
|
DOMPurify.isSupported = false;
|
|
@@ -10782,6 +10789,8 @@ function createDOMPurify() {
|
|
|
10782
10789
|
let SAFE_FOR_XML = true;
|
|
10783
10790
|
let WHOLE_DOCUMENT = false;
|
|
10784
10791
|
let SET_CONFIG = false;
|
|
10792
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
10793
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
10785
10794
|
let FORCE_BODY = false;
|
|
10786
10795
|
let RETURN_DOM = false;
|
|
10787
10796
|
let RETURN_DOM_FRAGMENT = false;
|
|
@@ -10841,8 +10850,10 @@ function createDOMPurify() {
|
|
|
10841
10850
|
let IS_EMPTY_INPUT = false;
|
|
10842
10851
|
let ALLOWED_NAMESPACES = null;
|
|
10843
10852
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
10844
|
-
|
|
10845
|
-
let
|
|
10853
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
|
|
10854
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
10855
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
|
|
10856
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
10846
10857
|
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
10847
10858
|
let PARSER_MEDIA_TYPE = null;
|
|
10848
10859
|
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
@@ -10865,14 +10876,32 @@ function createDOMPurify() {
|
|
|
10865
10876
|
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
10866
10877
|
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
10867
10878
|
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
10868
|
-
ALLOWED_TAGS =
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10879
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
|
|
10880
|
+
transform: transformCaseFunc
|
|
10881
|
+
});
|
|
10882
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
|
|
10883
|
+
transform: transformCaseFunc
|
|
10884
|
+
});
|
|
10885
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
|
|
10886
|
+
transform: stringToString
|
|
10887
|
+
});
|
|
10888
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
10889
|
+
transform: transformCaseFunc,
|
|
10890
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
10891
|
+
});
|
|
10892
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
10893
|
+
transform: transformCaseFunc,
|
|
10894
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
10895
|
+
});
|
|
10896
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
|
|
10897
|
+
transform: transformCaseFunc
|
|
10898
|
+
});
|
|
10899
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
|
|
10900
|
+
transform: transformCaseFunc
|
|
10901
|
+
});
|
|
10902
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
|
|
10903
|
+
transform: transformCaseFunc
|
|
10904
|
+
});
|
|
10876
10905
|
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
10877
10906
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
10878
10907
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
@@ -10891,8 +10920,8 @@ function createDOMPurify() {
|
|
|
10891
10920
|
IN_PLACE = cfg.IN_PLACE || false;
|
|
10892
10921
|
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
10893
10922
|
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
10894
|
-
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({},
|
|
10895
|
-
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({},
|
|
10923
|
+
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({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
10924
|
+
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
10896
10925
|
const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
|
|
10897
10926
|
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
10898
10927
|
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
@@ -10904,6 +10933,7 @@ function createDOMPurify() {
|
|
|
10904
10933
|
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
|
|
10905
10934
|
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
10906
10935
|
}
|
|
10936
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
10907
10937
|
if (SAFE_FOR_TEMPLATES) {
|
|
10908
10938
|
ALLOW_DATA_ATTR = false;
|
|
10909
10939
|
}
|
|
@@ -11006,12 +11036,6 @@ function createDOMPurify() {
|
|
|
11006
11036
|
emptyHTML = _createTrustedHTML("");
|
|
11007
11037
|
}
|
|
11008
11038
|
}
|
|
11009
|
-
if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
11010
|
-
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
11011
|
-
}
|
|
11012
|
-
if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
11013
|
-
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
11014
|
-
}
|
|
11015
11039
|
if (freeze) {
|
|
11016
11040
|
freeze(cfg);
|
|
11017
11041
|
}
|
|
@@ -11019,6 +11043,33 @@ function createDOMPurify() {
|
|
|
11019
11043
|
};
|
|
11020
11044
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
11021
11045
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
11046
|
+
const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
|
|
11047
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
11048
|
+
return tagName === "svg";
|
|
11049
|
+
}
|
|
11050
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
11051
|
+
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
11052
|
+
}
|
|
11053
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
11054
|
+
};
|
|
11055
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
|
|
11056
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
11057
|
+
return tagName === "math";
|
|
11058
|
+
}
|
|
11059
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
11060
|
+
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
11061
|
+
}
|
|
11062
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
11063
|
+
};
|
|
11064
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
|
|
11065
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
11066
|
+
return false;
|
|
11067
|
+
}
|
|
11068
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
11069
|
+
return false;
|
|
11070
|
+
}
|
|
11071
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
11072
|
+
};
|
|
11022
11073
|
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
11023
11074
|
let parent = getParentNode(element);
|
|
11024
11075
|
if (!parent || !parent.tagName) {
|
|
@@ -11033,31 +11084,13 @@ function createDOMPurify() {
|
|
|
11033
11084
|
return false;
|
|
11034
11085
|
}
|
|
11035
11086
|
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
11036
|
-
|
|
11037
|
-
return tagName === "svg";
|
|
11038
|
-
}
|
|
11039
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
11040
|
-
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
11041
|
-
}
|
|
11042
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
11087
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
11043
11088
|
}
|
|
11044
11089
|
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
11045
|
-
|
|
11046
|
-
return tagName === "math";
|
|
11047
|
-
}
|
|
11048
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
11049
|
-
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
11050
|
-
}
|
|
11051
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
11090
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
11052
11091
|
}
|
|
11053
11092
|
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
11054
|
-
|
|
11055
|
-
return false;
|
|
11056
|
-
}
|
|
11057
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
11058
|
-
return false;
|
|
11059
|
-
}
|
|
11060
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
11093
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
11061
11094
|
}
|
|
11062
11095
|
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
11063
11096
|
return true;
|
|
@@ -11078,7 +11111,8 @@ function createDOMPurify() {
|
|
|
11078
11111
|
}
|
|
11079
11112
|
};
|
|
11080
11113
|
const _neutralizeRoot = function _neutralizeRoot2(root) {
|
|
11081
|
-
|
|
11114
|
+
_neutralizeSubtree(root);
|
|
11115
|
+
const childNodes = getChildNodes(root);
|
|
11082
11116
|
if (childNodes) {
|
|
11083
11117
|
const snapshot = [];
|
|
11084
11118
|
arrayForEach(childNodes, (child) => {
|
|
@@ -11091,7 +11125,7 @@ function createDOMPurify() {
|
|
|
11091
11125
|
}
|
|
11092
11126
|
});
|
|
11093
11127
|
}
|
|
11094
|
-
const attributes = getAttributes
|
|
11128
|
+
const attributes = getAttributes(root);
|
|
11095
11129
|
if (attributes) {
|
|
11096
11130
|
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
11097
11131
|
const attribute = attributes[i];
|
|
@@ -11133,7 +11167,7 @@ function createDOMPurify() {
|
|
|
11133
11167
|
}
|
|
11134
11168
|
};
|
|
11135
11169
|
const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
|
|
11136
|
-
const attributes = getAttributes
|
|
11170
|
+
const attributes = getAttributes(element);
|
|
11137
11171
|
if (!attributes) {
|
|
11138
11172
|
return;
|
|
11139
11173
|
}
|
|
@@ -11157,7 +11191,43 @@ function createDOMPurify() {
|
|
|
11157
11191
|
if (nodeType === NODE_TYPE.element) {
|
|
11158
11192
|
_stripDisallowedAttributes(node);
|
|
11159
11193
|
}
|
|
11160
|
-
const childNodes = getChildNodes
|
|
11194
|
+
const childNodes = getChildNodes(node);
|
|
11195
|
+
if (childNodes) {
|
|
11196
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
11197
|
+
stack.push(childNodes[i]);
|
|
11198
|
+
}
|
|
11199
|
+
}
|
|
11200
|
+
}
|
|
11201
|
+
};
|
|
11202
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
|
|
11203
|
+
if (!SAFE_FOR_XML) {
|
|
11204
|
+
return;
|
|
11205
|
+
}
|
|
11206
|
+
const stack = [root];
|
|
11207
|
+
while (stack.length > 0) {
|
|
11208
|
+
const node = stack.pop();
|
|
11209
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
11210
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
11211
|
+
try {
|
|
11212
|
+
remove(node);
|
|
11213
|
+
} catch (_) {
|
|
11214
|
+
}
|
|
11215
|
+
continue;
|
|
11216
|
+
}
|
|
11217
|
+
if (nodeType === NODE_TYPE.element) {
|
|
11218
|
+
const element = node;
|
|
11219
|
+
const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
|
|
11220
|
+
try {
|
|
11221
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) {
|
|
11222
|
+
element.removeAttribute("patchsrc");
|
|
11223
|
+
}
|
|
11224
|
+
if (element.hasAttribute && element.hasAttribute("for") && lcTag !== "label" && lcTag !== "output") {
|
|
11225
|
+
element.removeAttribute("for");
|
|
11226
|
+
}
|
|
11227
|
+
} catch (_) {
|
|
11228
|
+
}
|
|
11229
|
+
}
|
|
11230
|
+
const childNodes = getChildNodes(node);
|
|
11161
11231
|
if (childNodes) {
|
|
11162
11232
|
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
11163
11233
|
stack.push(childNodes[i]);
|
|
@@ -11209,8 +11279,14 @@ function createDOMPurify() {
|
|
|
11209
11279
|
null
|
|
11210
11280
|
);
|
|
11211
11281
|
};
|
|
11282
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
|
|
11283
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
11284
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
11285
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
11286
|
+
return value;
|
|
11287
|
+
};
|
|
11212
11288
|
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
11213
|
-
var _node$querySelectorAl
|
|
11289
|
+
var _node$querySelectorAl;
|
|
11214
11290
|
node.normalize();
|
|
11215
11291
|
const walker = createNodeIterator.call(
|
|
11216
11292
|
node.ownerDocument || node,
|
|
@@ -11221,19 +11297,17 @@ function createDOMPurify() {
|
|
|
11221
11297
|
);
|
|
11222
11298
|
let currentNode = walker.nextNode();
|
|
11223
11299
|
while (currentNode) {
|
|
11224
|
-
|
|
11225
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
|
|
11226
|
-
data = stringReplace(data, expr, " ");
|
|
11227
|
-
});
|
|
11228
|
-
currentNode.data = data;
|
|
11300
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
11229
11301
|
currentNode = walker.nextNode();
|
|
11230
11302
|
}
|
|
11231
|
-
const templates = (_node$querySelectorAl =
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11303
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
11304
|
+
if (templates) {
|
|
11305
|
+
arrayForEach(templates, (tmpl) => {
|
|
11306
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
11307
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
11308
|
+
}
|
|
11309
|
+
});
|
|
11310
|
+
}
|
|
11237
11311
|
};
|
|
11238
11312
|
const _isClobbered = function _isClobbered2(element) {
|
|
11239
11313
|
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
@@ -11289,13 +11363,56 @@ function createDOMPurify() {
|
|
|
11289
11363
|
}
|
|
11290
11364
|
};
|
|
11291
11365
|
function _executeHooks(hooks2, currentNode, data) {
|
|
11366
|
+
if (hooks2.length === 0) {
|
|
11367
|
+
return;
|
|
11368
|
+
}
|
|
11292
11369
|
arrayForEach(hooks2, (hook) => {
|
|
11293
11370
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
11294
11371
|
});
|
|
11295
11372
|
}
|
|
11296
|
-
const
|
|
11297
|
-
|
|
11373
|
+
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
11374
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
11375
|
+
return true;
|
|
11376
|
+
}
|
|
11377
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
|
|
11378
|
+
return true;
|
|
11379
|
+
}
|
|
11380
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
11381
|
+
return true;
|
|
11382
|
+
}
|
|
11383
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
11384
|
+
return true;
|
|
11385
|
+
}
|
|
11386
|
+
return false;
|
|
11387
|
+
};
|
|
11388
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName) {
|
|
11389
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
11390
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
11391
|
+
return false;
|
|
11392
|
+
}
|
|
11393
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
11394
|
+
return false;
|
|
11395
|
+
}
|
|
11396
|
+
}
|
|
11397
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
11398
|
+
const parentNode = getParentNode(currentNode);
|
|
11399
|
+
const childNodes = getChildNodes(currentNode);
|
|
11400
|
+
if (childNodes && parentNode) {
|
|
11401
|
+
const childCount = childNodes.length;
|
|
11402
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
11403
|
+
const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
|
|
11404
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
11405
|
+
}
|
|
11406
|
+
}
|
|
11407
|
+
}
|
|
11408
|
+
_forceRemove(currentNode);
|
|
11409
|
+
return true;
|
|
11410
|
+
};
|
|
11411
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
11298
11412
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
11413
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
11414
|
+
return true;
|
|
11415
|
+
}
|
|
11299
11416
|
if (_isClobbered(currentNode)) {
|
|
11300
11417
|
_forceRemove(currentNode);
|
|
11301
11418
|
return true;
|
|
@@ -11305,59 +11422,31 @@ function createDOMPurify() {
|
|
|
11305
11422
|
tagName,
|
|
11306
11423
|
allowedTags: ALLOWED_TAGS
|
|
11307
11424
|
});
|
|
11308
|
-
if (
|
|
11309
|
-
_forceRemove(currentNode);
|
|
11425
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
11310
11426
|
return true;
|
|
11311
11427
|
}
|
|
11312
|
-
if (
|
|
11313
|
-
_forceRemove(currentNode);
|
|
11314
|
-
return true;
|
|
11315
|
-
}
|
|
11316
|
-
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
11317
|
-
_forceRemove(currentNode);
|
|
11318
|
-
return true;
|
|
11319
|
-
}
|
|
11320
|
-
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
11428
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
11321
11429
|
_forceRemove(currentNode);
|
|
11322
11430
|
return true;
|
|
11323
11431
|
}
|
|
11324
11432
|
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
}
|
|
11329
|
-
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
11330
|
-
return false;
|
|
11331
|
-
}
|
|
11332
|
-
}
|
|
11333
|
-
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
11334
|
-
const parentNode = getParentNode(currentNode);
|
|
11335
|
-
const childNodes = getChildNodes(currentNode);
|
|
11336
|
-
if (childNodes && parentNode) {
|
|
11337
|
-
const childCount = childNodes.length;
|
|
11338
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
11339
|
-
const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
|
|
11340
|
-
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
11341
|
-
}
|
|
11342
|
-
}
|
|
11433
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName);
|
|
11434
|
+
if (removed === false) {
|
|
11435
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
11343
11436
|
}
|
|
11344
|
-
|
|
11345
|
-
return true;
|
|
11437
|
+
return removed;
|
|
11346
11438
|
}
|
|
11347
11439
|
const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
|
|
11348
11440
|
if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
11349
11441
|
_forceRemove(currentNode);
|
|
11350
11442
|
return true;
|
|
11351
11443
|
}
|
|
11352
|
-
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(
|
|
11444
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
11353
11445
|
_forceRemove(currentNode);
|
|
11354
11446
|
return true;
|
|
11355
11447
|
}
|
|
11356
11448
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
11357
|
-
content = currentNode.textContent;
|
|
11358
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
|
|
11359
|
-
content = stringReplace(content, expr, " ");
|
|
11360
|
-
});
|
|
11449
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
11361
11450
|
if (currentNode.textContent !== content) {
|
|
11362
11451
|
arrayPush(DOMPurify.removed, {
|
|
11363
11452
|
element: currentNode.cloneNode()
|
|
@@ -11372,13 +11461,19 @@ function createDOMPurify() {
|
|
|
11372
11461
|
if (FORBID_ATTR[lcName]) {
|
|
11373
11462
|
return false;
|
|
11374
11463
|
}
|
|
11464
|
+
if (SAFE_FOR_XML && lcName === "patchsrc") {
|
|
11465
|
+
return false;
|
|
11466
|
+
}
|
|
11467
|
+
if (SAFE_FOR_XML && lcName === "for" && lcTag !== "label" && lcTag !== "output") {
|
|
11468
|
+
return false;
|
|
11469
|
+
}
|
|
11375
11470
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
|
|
11376
11471
|
return false;
|
|
11377
11472
|
}
|
|
11378
11473
|
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
11379
|
-
if (ALLOW_DATA_ATTR &&
|
|
11474
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ;
|
|
11380
11475
|
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
|
|
11381
|
-
else if (!nameIsPermitted
|
|
11476
|
+
else if (!nameIsPermitted) {
|
|
11382
11477
|
if (
|
|
11383
11478
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
11384
11479
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -11403,6 +11498,35 @@ function createDOMPurify() {
|
|
|
11403
11498
|
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
11404
11499
|
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
11405
11500
|
};
|
|
11501
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
|
|
11502
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) {
|
|
11503
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
11504
|
+
case "TrustedHTML": {
|
|
11505
|
+
return _createTrustedHTML(value);
|
|
11506
|
+
}
|
|
11507
|
+
case "TrustedScriptURL": {
|
|
11508
|
+
return _createTrustedScriptURL(value);
|
|
11509
|
+
}
|
|
11510
|
+
}
|
|
11511
|
+
}
|
|
11512
|
+
return value;
|
|
11513
|
+
};
|
|
11514
|
+
const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
|
|
11515
|
+
try {
|
|
11516
|
+
if (namespaceURI) {
|
|
11517
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
11518
|
+
} else {
|
|
11519
|
+
currentNode.setAttribute(name, value);
|
|
11520
|
+
}
|
|
11521
|
+
if (_isClobbered(currentNode)) {
|
|
11522
|
+
_forceRemove(currentNode);
|
|
11523
|
+
} else {
|
|
11524
|
+
arrayPop(DOMPurify.removed);
|
|
11525
|
+
}
|
|
11526
|
+
} catch (_) {
|
|
11527
|
+
_removeAttribute(name, currentNode);
|
|
11528
|
+
}
|
|
11529
|
+
};
|
|
11406
11530
|
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
11407
11531
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
11408
11532
|
const attributes = currentNode.attributes;
|
|
@@ -11417,6 +11541,7 @@ function createDOMPurify() {
|
|
|
11417
11541
|
forceKeepAttr: void 0
|
|
11418
11542
|
};
|
|
11419
11543
|
let l = attributes.length;
|
|
11544
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
11420
11545
|
while (l--) {
|
|
11421
11546
|
const attr = attributes[l];
|
|
11422
11547
|
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
@@ -11448,50 +11573,20 @@ function createDOMPurify() {
|
|
|
11448
11573
|
_removeAttribute(name, currentNode);
|
|
11449
11574
|
continue;
|
|
11450
11575
|
}
|
|
11451
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(
|
|
11576
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
11452
11577
|
_removeAttribute(name, currentNode);
|
|
11453
11578
|
continue;
|
|
11454
11579
|
}
|
|
11455
11580
|
if (SAFE_FOR_TEMPLATES) {
|
|
11456
|
-
|
|
11457
|
-
value = stringReplace(value, expr, " ");
|
|
11458
|
-
});
|
|
11581
|
+
value = _stripTemplateExpressions(value);
|
|
11459
11582
|
}
|
|
11460
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
11461
11583
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
11462
11584
|
_removeAttribute(name, currentNode);
|
|
11463
11585
|
continue;
|
|
11464
11586
|
}
|
|
11465
|
-
|
|
11466
|
-
if (namespaceURI) ;
|
|
11467
|
-
else {
|
|
11468
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
11469
|
-
case "TrustedHTML": {
|
|
11470
|
-
value = _createTrustedHTML(value);
|
|
11471
|
-
break;
|
|
11472
|
-
}
|
|
11473
|
-
case "TrustedScriptURL": {
|
|
11474
|
-
value = _createTrustedScriptURL(value);
|
|
11475
|
-
break;
|
|
11476
|
-
}
|
|
11477
|
-
}
|
|
11478
|
-
}
|
|
11479
|
-
}
|
|
11587
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
11480
11588
|
if (value !== initValue) {
|
|
11481
|
-
|
|
11482
|
-
if (namespaceURI) {
|
|
11483
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
11484
|
-
} else {
|
|
11485
|
-
currentNode.setAttribute(name, value);
|
|
11486
|
-
}
|
|
11487
|
-
if (_isClobbered(currentNode)) {
|
|
11488
|
-
_forceRemove(currentNode);
|
|
11489
|
-
} else {
|
|
11490
|
-
arrayPop(DOMPurify.removed);
|
|
11491
|
-
}
|
|
11492
|
-
} catch (_) {
|
|
11493
|
-
_removeAttribute(name, currentNode);
|
|
11494
|
-
}
|
|
11589
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
11495
11590
|
}
|
|
11496
11591
|
}
|
|
11497
11592
|
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
@@ -11502,14 +11597,14 @@ function createDOMPurify() {
|
|
|
11502
11597
|
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
11503
11598
|
while (shadowNode = shadowIterator.nextNode()) {
|
|
11504
11599
|
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
11505
|
-
_sanitizeElements(shadowNode);
|
|
11600
|
+
_sanitizeElements(shadowNode, fragment);
|
|
11506
11601
|
_sanitizeAttributes(shadowNode);
|
|
11507
11602
|
if (_isDocumentFragment(shadowNode.content)) {
|
|
11508
11603
|
_sanitizeShadowDOM2(shadowNode.content);
|
|
11509
11604
|
}
|
|
11510
11605
|
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
11511
11606
|
if (shadowNodeType === NODE_TYPE.element) {
|
|
11512
|
-
const innerSr = getShadowRoot
|
|
11607
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
11513
11608
|
if (_isDocumentFragment(innerSr)) {
|
|
11514
11609
|
_sanitizeAttachedShadowRoots(innerSr);
|
|
11515
11610
|
_sanitizeShadowDOM2(innerSr);
|
|
@@ -11532,7 +11627,7 @@ function createDOMPurify() {
|
|
|
11532
11627
|
const node = item.node;
|
|
11533
11628
|
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
11534
11629
|
const isElement = nodeType === NODE_TYPE.element;
|
|
11535
|
-
const childNodes = getChildNodes
|
|
11630
|
+
const childNodes = getChildNodes(node);
|
|
11536
11631
|
if (childNodes) {
|
|
11537
11632
|
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
11538
11633
|
stack.push({
|
|
@@ -11554,7 +11649,7 @@ function createDOMPurify() {
|
|
|
11554
11649
|
}
|
|
11555
11650
|
}
|
|
11556
11651
|
if (isElement) {
|
|
11557
|
-
const sr = getShadowRoot
|
|
11652
|
+
const sr = getShadowRoot(node);
|
|
11558
11653
|
if (_isDocumentFragment(sr)) {
|
|
11559
11654
|
stack.push({
|
|
11560
11655
|
node: null,
|
|
@@ -11586,20 +11681,32 @@ function createDOMPurify() {
|
|
|
11586
11681
|
if (!DOMPurify.isSupported) {
|
|
11587
11682
|
return dirty;
|
|
11588
11683
|
}
|
|
11589
|
-
if (
|
|
11684
|
+
if (SET_CONFIG) {
|
|
11685
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
11686
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
11687
|
+
} else {
|
|
11590
11688
|
_parseConfig(cfg);
|
|
11591
11689
|
}
|
|
11690
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
11691
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
11692
|
+
}
|
|
11693
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
11694
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
11695
|
+
}
|
|
11592
11696
|
DOMPurify.removed = [];
|
|
11593
11697
|
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
11594
11698
|
if (inPlace) {
|
|
11699
|
+
_neutralizePatchLinkage(dirty);
|
|
11595
11700
|
const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
11596
11701
|
if (typeof nn === "string") {
|
|
11597
11702
|
const tagName = transformCaseFunc(nn);
|
|
11598
11703
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
11704
|
+
_neutralizeRoot(dirty);
|
|
11599
11705
|
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
11600
11706
|
}
|
|
11601
11707
|
}
|
|
11602
11708
|
if (_isClobbered(dirty)) {
|
|
11709
|
+
_neutralizeRoot(dirty);
|
|
11603
11710
|
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
11604
11711
|
}
|
|
11605
11712
|
try {
|
|
@@ -11632,10 +11739,11 @@ function createDOMPurify() {
|
|
|
11632
11739
|
if (body && FORCE_BODY) {
|
|
11633
11740
|
_forceRemove(body.firstChild);
|
|
11634
11741
|
}
|
|
11635
|
-
const
|
|
11742
|
+
const walkRoot = inPlace ? dirty : body;
|
|
11743
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
11636
11744
|
try {
|
|
11637
11745
|
while (currentNode = nodeIterator.nextNode()) {
|
|
11638
|
-
_sanitizeElements(currentNode);
|
|
11746
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
11639
11747
|
_sanitizeAttributes(currentNode);
|
|
11640
11748
|
if (_isDocumentFragment(currentNode.content)) {
|
|
11641
11749
|
_sanitizeShadowDOM2(currentNode.content);
|
|
@@ -11644,6 +11752,11 @@ function createDOMPurify() {
|
|
|
11644
11752
|
} catch (error) {
|
|
11645
11753
|
if (inPlace) {
|
|
11646
11754
|
_neutralizeRoot(dirty);
|
|
11755
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
11756
|
+
if (entry.element) {
|
|
11757
|
+
_neutralizeSubtree(entry.element);
|
|
11758
|
+
}
|
|
11759
|
+
});
|
|
11647
11760
|
}
|
|
11648
11761
|
throw error;
|
|
11649
11762
|
}
|
|
@@ -11680,9 +11793,7 @@ function createDOMPurify() {
|
|
|
11680
11793
|
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
11681
11794
|
}
|
|
11682
11795
|
if (SAFE_FOR_TEMPLATES) {
|
|
11683
|
-
|
|
11684
|
-
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
11685
|
-
});
|
|
11796
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
11686
11797
|
}
|
|
11687
11798
|
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
11688
11799
|
};
|
|
@@ -11690,10 +11801,14 @@ function createDOMPurify() {
|
|
|
11690
11801
|
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
11691
11802
|
_parseConfig(cfg);
|
|
11692
11803
|
SET_CONFIG = true;
|
|
11804
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
11805
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
11693
11806
|
};
|
|
11694
11807
|
DOMPurify.clearConfig = function() {
|
|
11695
11808
|
CONFIG = null;
|
|
11696
11809
|
SET_CONFIG = false;
|
|
11810
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
11811
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
11697
11812
|
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
11698
11813
|
emptyHTML = "";
|
|
11699
11814
|
};
|
|
@@ -11709,9 +11824,15 @@ function createDOMPurify() {
|
|
|
11709
11824
|
if (typeof hookFunction !== "function") {
|
|
11710
11825
|
return;
|
|
11711
11826
|
}
|
|
11827
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
11828
|
+
return;
|
|
11829
|
+
}
|
|
11712
11830
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
11713
11831
|
};
|
|
11714
11832
|
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
11833
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
11834
|
+
return void 0;
|
|
11835
|
+
}
|
|
11715
11836
|
if (hookFunction !== void 0) {
|
|
11716
11837
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
11717
11838
|
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -11719,6 +11840,9 @@ function createDOMPurify() {
|
|
|
11719
11840
|
return arrayPop(hooks[entryPoint]);
|
|
11720
11841
|
};
|
|
11721
11842
|
DOMPurify.removeHooks = function(entryPoint) {
|
|
11843
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
11844
|
+
return;
|
|
11845
|
+
}
|
|
11722
11846
|
hooks[entryPoint] = [];
|
|
11723
11847
|
};
|
|
11724
11848
|
DOMPurify.removeAllHooks = function() {
|
|
@@ -12223,6 +12347,9 @@ function setTokens(config, state, data, onRefreshScheduled) {
|
|
|
12223
12347
|
state.accessToken = data.accessToken;
|
|
12224
12348
|
state.refreshToken = data.refreshToken;
|
|
12225
12349
|
state.tokenFamily = data.tokenFamily ?? null;
|
|
12350
|
+
if (data.widgetData && typeof data.widgetData === "object" && !Array.isArray(data.widgetData)) {
|
|
12351
|
+
state.widgetData = data.widgetData;
|
|
12352
|
+
}
|
|
12226
12353
|
const now = Date.now();
|
|
12227
12354
|
state.accessTokenExpiry = now + data.accessTokenTTL * 1e3;
|
|
12228
12355
|
state.refreshTokenExpiry = now + data.refreshTokenTTL * 1e3;
|
|
@@ -12441,6 +12568,9 @@ function applyErrorSettingsToState(state, data) {
|
|
|
12441
12568
|
if (data.loadingAnimation) {
|
|
12442
12569
|
state.loadingAnimation = data.loadingAnimation;
|
|
12443
12570
|
}
|
|
12571
|
+
if (data.loadingSettings) {
|
|
12572
|
+
state.loadingSettings = data.loadingSettings;
|
|
12573
|
+
}
|
|
12444
12574
|
if (data.themePalette) {
|
|
12445
12575
|
state.themePalette = data.themePalette;
|
|
12446
12576
|
}
|
|
@@ -12495,6 +12625,7 @@ function clearState(state) {
|
|
|
12495
12625
|
state.isRefreshing = false;
|
|
12496
12626
|
state.refreshPromise = null;
|
|
12497
12627
|
state.lastAuthError = null;
|
|
12628
|
+
state.widgetData = null;
|
|
12498
12629
|
if (state.refreshTimer) {
|
|
12499
12630
|
clearTimeout(state.refreshTimer);
|
|
12500
12631
|
state.refreshTimer = null;
|
|
@@ -12575,6 +12706,20 @@ async function waitForBundleMountReadiness(mountResult, firstPaint, timeoutMs =
|
|
|
12575
12706
|
);
|
|
12576
12707
|
return "deep-ready";
|
|
12577
12708
|
}
|
|
12709
|
+
function createBundleRuntimeWarmer({
|
|
12710
|
+
preloadScript: preloadScript2,
|
|
12711
|
+
baseUrl
|
|
12712
|
+
}) {
|
|
12713
|
+
const preloadPromises = /* @__PURE__ */ new Map();
|
|
12714
|
+
return function warmBundleRuntime2(globalName, bundleUrl) {
|
|
12715
|
+
const normalizedUrl = normalizeBundleUrl(bundleUrl, baseUrl());
|
|
12716
|
+
if (preloadPromises.has(normalizedUrl)) return;
|
|
12717
|
+
const preloadPromise = preloadScript2(normalizedUrl).catch(() => {
|
|
12718
|
+
preloadPromises.delete(normalizedUrl);
|
|
12719
|
+
});
|
|
12720
|
+
preloadPromises.set(normalizedUrl, preloadPromise);
|
|
12721
|
+
};
|
|
12722
|
+
}
|
|
12578
12723
|
function isWidgetBundleRuntime(value) {
|
|
12579
12724
|
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.mount === "function";
|
|
12580
12725
|
}
|
|
@@ -12641,14 +12786,46 @@ function appendScript(url) {
|
|
|
12641
12786
|
document.head.appendChild(script);
|
|
12642
12787
|
});
|
|
12643
12788
|
}
|
|
12789
|
+
function preloadScript(url) {
|
|
12790
|
+
return new Promise((resolve, reject) => {
|
|
12791
|
+
const link = document.createElement("link");
|
|
12792
|
+
link.rel = "preload";
|
|
12793
|
+
link.as = "script";
|
|
12794
|
+
link.href = url;
|
|
12795
|
+
link.onload = () => resolve();
|
|
12796
|
+
link.onerror = () => reject(new Error(`Failed to preload ${url}`));
|
|
12797
|
+
document.head.appendChild(link);
|
|
12798
|
+
});
|
|
12799
|
+
}
|
|
12644
12800
|
const loadBrowserBundleRuntime = createBundleRuntimeLoader({
|
|
12645
12801
|
loadScript: appendScript,
|
|
12646
12802
|
readGlobal: (globalName) => window[globalName],
|
|
12647
12803
|
baseUrl: () => document.baseURI
|
|
12648
12804
|
});
|
|
12805
|
+
const warmBrowserBundleRuntime = createBundleRuntimeWarmer({
|
|
12806
|
+
preloadScript,
|
|
12807
|
+
baseUrl: () => document.baseURI
|
|
12808
|
+
});
|
|
12809
|
+
function warmBundleRuntime(globalName, bundleUrl) {
|
|
12810
|
+
warmBrowserBundleRuntime(globalName, bundleUrl);
|
|
12811
|
+
}
|
|
12649
12812
|
function getOrLoadBundleRuntime(globalName, bundleUrl) {
|
|
12650
12813
|
return loadBrowserBundleRuntime(globalName, bundleUrl);
|
|
12651
12814
|
}
|
|
12815
|
+
const BUNDLE_AUTH_TOKEN_CHANGE_EVENT = "authtoken-change";
|
|
12816
|
+
function syncBundleAccessToken(config, state, runtime = window) {
|
|
12817
|
+
if (!config.bundleUrl || !state.accessToken) return false;
|
|
12818
|
+
runtime.guest_token = state.accessToken;
|
|
12819
|
+
runtime.dispatchEvent(
|
|
12820
|
+
new CustomEvent(BUNDLE_AUTH_TOKEN_CHANGE_EVENT, {
|
|
12821
|
+
detail: {
|
|
12822
|
+
token: state.accessToken,
|
|
12823
|
+
widgetId: config.widgetId
|
|
12824
|
+
}
|
|
12825
|
+
})
|
|
12826
|
+
);
|
|
12827
|
+
return true;
|
|
12828
|
+
}
|
|
12652
12829
|
function assertCallbackName(callbackName) {
|
|
12653
12830
|
if (!callbackName || typeof callbackName !== "string") {
|
|
12654
12831
|
throw new TypeError("ReturningAI callback name must be a non-empty string");
|
|
@@ -12693,23 +12870,194 @@ const STORE_CALLBACK_FIELD_OPTIONS_CALLBACK_NAME = "callbackFieldOptions";
|
|
|
12693
12870
|
const STORE_CALLBACK_FIELD_OPTIONS_TIMEOUT_MS = 15e3;
|
|
12694
12871
|
const STORE_PURCHASE_SUCCESS_SCOPE = "store.purchase_success";
|
|
12695
12872
|
const STORE_PURCHASE_SUCCESS_CALLBACK_NAME = "storePurchaseSuccess";
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12873
|
+
const MILESTONE_CTA_CLICK_SCOPE = "milestone.cta_click";
|
|
12874
|
+
const MILESTONE_CTA_CLICK_CALLBACK_NAME = "milestoneCtaClick";
|
|
12875
|
+
const MILESTONE_CTA_CLICK_EVENT = "milestone_cta_clicked";
|
|
12876
|
+
function isRecord(value) {
|
|
12877
|
+
return typeof value === "object" && value !== null;
|
|
12878
|
+
}
|
|
12879
|
+
function isStringRecord(value) {
|
|
12880
|
+
return isRecord(value) && Object.values(value).every((item) => typeof item === "string");
|
|
12881
|
+
}
|
|
12882
|
+
function readEmbedTokenUserIdentifiers(embedToken) {
|
|
12883
|
+
if (!embedToken) return null;
|
|
12884
|
+
const encodedPayload = embedToken.split(".")[1];
|
|
12885
|
+
if (!encodedPayload) return null;
|
|
12886
|
+
try {
|
|
12887
|
+
const normalizedPayload = encodedPayload.replace(/-/g, "+").replace(/_/g, "/");
|
|
12888
|
+
const paddedPayload = normalizedPayload.padEnd(
|
|
12889
|
+
Math.ceil(normalizedPayload.length / 4) * 4,
|
|
12890
|
+
"="
|
|
12891
|
+
);
|
|
12892
|
+
const bytes = Uint8Array.from(atob(paddedPayload), (character) => character.charCodeAt(0));
|
|
12893
|
+
const claims = JSON.parse(new TextDecoder().decode(bytes));
|
|
12894
|
+
if (!isRecord(claims) || !isStringRecord(claims.userIdentifiers)) return null;
|
|
12895
|
+
return { ...claims.userIdentifiers };
|
|
12896
|
+
} catch {
|
|
12897
|
+
return null;
|
|
12898
|
+
}
|
|
12899
|
+
}
|
|
12900
|
+
function resolveHostUserIdentifiers(config) {
|
|
12901
|
+
return readEmbedTokenUserIdentifiers(config.embedToken) ?? { ...config.userIdentifiers };
|
|
12902
|
+
}
|
|
12903
|
+
function hasCallbackContract(payload, callbackName, scope) {
|
|
12904
|
+
return isRecord(payload) && payload.callbackName === callbackName && payload.scope === scope;
|
|
12905
|
+
}
|
|
12906
|
+
function isMilestoneCtaClickPayload(payload) {
|
|
12907
|
+
if (!hasCallbackContract(
|
|
12908
|
+
payload,
|
|
12909
|
+
MILESTONE_CTA_CLICK_CALLBACK_NAME,
|
|
12910
|
+
MILESTONE_CTA_CLICK_SCOPE
|
|
12911
|
+
)) return false;
|
|
12912
|
+
const context = payload.context;
|
|
12913
|
+
if (!isRecord(context)) return false;
|
|
12914
|
+
const community = context.community;
|
|
12915
|
+
const milestone = context.milestone;
|
|
12916
|
+
const stage = context.stage;
|
|
12917
|
+
const button = context.button;
|
|
12918
|
+
const user = context.user;
|
|
12919
|
+
return context.event === MILESTONE_CTA_CLICK_EVENT && isRecord(community) && typeof community.id === "string" && community.id.length > 0 && (community.name === void 0 || community.name === null || typeof community.name === "string") && isRecord(milestone) && typeof milestone.id === "string" && milestone.id.length > 0 && typeof milestone.name === "string" && milestone.name.length > 0 && isRecord(stage) && typeof stage.id === "string" && stage.id.length > 0 && typeof stage.name === "string" && stage.name.length > 0 && isRecord(button) && typeof button.name === "string" && button.name.length > 0 && isRecord(user) && isStringRecord(user.identifiers) && typeof context.clickedAt === "string" && context.clickedAt.length > 0 && !Number.isNaN(Date.parse(context.clickedAt));
|
|
12920
|
+
}
|
|
12921
|
+
function enrichHostCallbackPayload(payload, userIdentifiers) {
|
|
12922
|
+
if (!userIdentifiers || Object.keys(userIdentifiers).length === 0) return payload;
|
|
12923
|
+
if (!isRecord(payload)) return payload;
|
|
12924
|
+
const context = payload.context;
|
|
12925
|
+
if (!isRecord(context)) return payload;
|
|
12926
|
+
const user = context.user;
|
|
12927
|
+
if (!isRecord(user)) return payload;
|
|
12928
|
+
return {
|
|
12929
|
+
...payload,
|
|
12930
|
+
context: {
|
|
12931
|
+
...context,
|
|
12932
|
+
user: {
|
|
12933
|
+
...user,
|
|
12934
|
+
identifiers: { ...userIdentifiers }
|
|
12935
|
+
}
|
|
12936
|
+
}
|
|
12937
|
+
};
|
|
12699
12938
|
}
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12939
|
+
const HOST_CALLBACK_DEFINITIONS = {
|
|
12940
|
+
[STORE_CALLBACK_FIELD_OPTIONS_CALLBACK_NAME]: {
|
|
12941
|
+
callbackName: STORE_CALLBACK_FIELD_OPTIONS_CALLBACK_NAME,
|
|
12942
|
+
scope: STORE_CALLBACK_FIELD_OPTIONS_SCOPE,
|
|
12943
|
+
sourceWidgetType: "store",
|
|
12944
|
+
allowedHostWidgetTypes: ["store", "custom"],
|
|
12945
|
+
completionMode: "result",
|
|
12946
|
+
missingHandler: "reject",
|
|
12947
|
+
legacyActions: ["store:host-callback"],
|
|
12948
|
+
validatePayload: (payload) => hasCallbackContract(
|
|
12949
|
+
payload,
|
|
12950
|
+
STORE_CALLBACK_FIELD_OPTIONS_CALLBACK_NAME,
|
|
12951
|
+
STORE_CALLBACK_FIELD_OPTIONS_SCOPE
|
|
12952
|
+
)
|
|
12953
|
+
},
|
|
12954
|
+
[STORE_PURCHASE_SUCCESS_CALLBACK_NAME]: {
|
|
12955
|
+
callbackName: STORE_PURCHASE_SUCCESS_CALLBACK_NAME,
|
|
12956
|
+
scope: STORE_PURCHASE_SUCCESS_SCOPE,
|
|
12957
|
+
sourceWidgetType: "store",
|
|
12958
|
+
allowedHostWidgetTypes: ["store", "custom"],
|
|
12959
|
+
completionMode: "acknowledged",
|
|
12960
|
+
missingHandler: "reject",
|
|
12961
|
+
legacyActions: ["store:host-callback"],
|
|
12962
|
+
validatePayload: (payload) => hasCallbackContract(
|
|
12963
|
+
payload,
|
|
12964
|
+
STORE_PURCHASE_SUCCESS_CALLBACK_NAME,
|
|
12965
|
+
STORE_PURCHASE_SUCCESS_SCOPE
|
|
12966
|
+
)
|
|
12967
|
+
},
|
|
12968
|
+
[MILESTONE_CTA_CLICK_CALLBACK_NAME]: {
|
|
12969
|
+
callbackName: MILESTONE_CTA_CLICK_CALLBACK_NAME,
|
|
12970
|
+
scope: MILESTONE_CTA_CLICK_SCOPE,
|
|
12971
|
+
sourceWidgetType: "milestone",
|
|
12972
|
+
allowedHostWidgetTypes: ["milestone", "custom"],
|
|
12973
|
+
completionMode: "detached",
|
|
12974
|
+
missingHandler: "ignore",
|
|
12975
|
+
legacyActions: [],
|
|
12976
|
+
validatePayload: isMilestoneCtaClickPayload
|
|
12703
12977
|
}
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12978
|
+
};
|
|
12979
|
+
function createInvocationId() {
|
|
12980
|
+
return `host_callback_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
12981
|
+
}
|
|
12982
|
+
function observe(observer, event) {
|
|
12983
|
+
if (!observer) return;
|
|
12707
12984
|
try {
|
|
12708
|
-
|
|
12985
|
+
observer(event);
|
|
12709
12986
|
} catch {
|
|
12710
|
-
throw new Error("Host callback failed");
|
|
12711
12987
|
}
|
|
12712
|
-
|
|
12988
|
+
}
|
|
12989
|
+
function getHostCallbackDefinition(callbackName, payload) {
|
|
12990
|
+
const definition = HOST_CALLBACK_DEFINITIONS[callbackName];
|
|
12991
|
+
return (definition == null ? void 0 : definition.validatePayload(payload)) ? definition : void 0;
|
|
12992
|
+
}
|
|
12993
|
+
function isHostCallbackMessageSupported(definition, action, sourceWidgetType, hostWidgetType) {
|
|
12994
|
+
const actionSupported = action === "widget:host-callback" || definition.legacyActions.includes(action);
|
|
12995
|
+
return actionSupported && sourceWidgetType === definition.sourceWidgetType && definition.allowedHostWidgetTypes.includes(hostWidgetType);
|
|
12996
|
+
}
|
|
12997
|
+
function dispatchHostCallback(input) {
|
|
12998
|
+
const definition = getHostCallbackDefinition(input.callbackName, input.payload);
|
|
12999
|
+
if (!definition || !definition.allowedHostWidgetTypes.includes(input.hostWidgetType)) {
|
|
13000
|
+
throw new Error("Host callback is not supported for this widget");
|
|
13001
|
+
}
|
|
13002
|
+
const invocationId = input.invocationId || createInvocationId();
|
|
13003
|
+
const eventBase = {
|
|
13004
|
+
invocationId,
|
|
13005
|
+
callbackName: definition.callbackName,
|
|
13006
|
+
scope: definition.scope,
|
|
13007
|
+
sourceWidgetType: definition.sourceWidgetType,
|
|
13008
|
+
hostWidgetType: input.hostWidgetType,
|
|
13009
|
+
completionMode: definition.completionMode,
|
|
13010
|
+
transport: input.transport
|
|
13011
|
+
};
|
|
13012
|
+
observe(input.observer, { type: "callback.received", ...eventBase });
|
|
13013
|
+
const callback = input.callbacks[definition.callbackName];
|
|
13014
|
+
if (!callback) {
|
|
13015
|
+
observe(input.observer, { type: "callback.handler_missing", ...eventBase });
|
|
13016
|
+
if (definition.missingHandler === "ignore") return;
|
|
13017
|
+
return Promise.reject(new Error("Host callback is not registered"));
|
|
13018
|
+
}
|
|
13019
|
+
observe(input.observer, { type: "callback.handler_started", ...eventBase });
|
|
13020
|
+
let result;
|
|
13021
|
+
try {
|
|
13022
|
+
result = callback(input.payload);
|
|
13023
|
+
} catch (error) {
|
|
13024
|
+
observe(input.observer, {
|
|
13025
|
+
type: "callback.handler_rejected",
|
|
13026
|
+
...eventBase,
|
|
13027
|
+
error
|
|
13028
|
+
});
|
|
13029
|
+
if (definition.completionMode === "detached") return;
|
|
13030
|
+
return Promise.reject(new Error("Host callback failed"));
|
|
13031
|
+
}
|
|
13032
|
+
if (definition.completionMode === "detached") {
|
|
13033
|
+
if (result && typeof result.then === "function") {
|
|
13034
|
+
void Promise.resolve(result).then(
|
|
13035
|
+
() => observe(input.observer, { type: "callback.handler_resolved", ...eventBase }),
|
|
13036
|
+
(error) => observe(input.observer, {
|
|
13037
|
+
type: "callback.handler_rejected",
|
|
13038
|
+
...eventBase,
|
|
13039
|
+
error
|
|
13040
|
+
})
|
|
13041
|
+
);
|
|
13042
|
+
} else {
|
|
13043
|
+
observe(input.observer, { type: "callback.handler_resolved", ...eventBase });
|
|
13044
|
+
}
|
|
13045
|
+
return;
|
|
13046
|
+
}
|
|
13047
|
+
return Promise.resolve(result).then(
|
|
13048
|
+
(value) => {
|
|
13049
|
+
observe(input.observer, { type: "callback.handler_resolved", ...eventBase });
|
|
13050
|
+
return definition.completionMode === "result" ? value : void 0;
|
|
13051
|
+
},
|
|
13052
|
+
(error) => {
|
|
13053
|
+
observe(input.observer, {
|
|
13054
|
+
type: "callback.handler_rejected",
|
|
13055
|
+
...eventBase,
|
|
13056
|
+
error
|
|
13057
|
+
});
|
|
13058
|
+
throw new Error("Host callback failed");
|
|
13059
|
+
}
|
|
13060
|
+
);
|
|
12713
13061
|
}
|
|
12714
13062
|
function debounce(fn, wait) {
|
|
12715
13063
|
let timer = null;
|
|
@@ -12801,52 +13149,58 @@ function setupMessageListener(config, state, _shadow, iframe, onRefreshScheduled
|
|
|
12801
13149
|
}
|
|
12802
13150
|
case "RETURNINGAI_WIDGET_ACTION": {
|
|
12803
13151
|
if (event.source !== iframe.contentWindow) break;
|
|
12804
|
-
const
|
|
12805
|
-
if (
|
|
12806
|
-
if (
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
13152
|
+
const actionMessage = event.data;
|
|
13153
|
+
if (actionMessage.widgetId !== void 0 && actionMessage.widgetId !== config.widgetId) break;
|
|
13154
|
+
if (actionMessage.containerId !== void 0 && actionMessage.containerId !== config.container) break;
|
|
13155
|
+
const callbackPayload = enrichHostCallbackPayload(
|
|
13156
|
+
actionMessage.payload,
|
|
13157
|
+
resolveHostUserIdentifiers(config)
|
|
13158
|
+
);
|
|
13159
|
+
const definition = getHostCallbackDefinition(
|
|
13160
|
+
actionMessage.callbackName,
|
|
13161
|
+
callbackPayload
|
|
13162
|
+
);
|
|
13163
|
+
if (!definition) break;
|
|
13164
|
+
if (!isHostCallbackMessageSupported(
|
|
13165
|
+
definition,
|
|
13166
|
+
actionMessage.action,
|
|
13167
|
+
actionMessage.widgetType,
|
|
13168
|
+
config.widgetType
|
|
13169
|
+
)) break;
|
|
12811
13170
|
const respond = (result) => {
|
|
12812
13171
|
var _a2;
|
|
12813
13172
|
(_a2 = iframe.contentWindow) == null ? void 0 : _a2.postMessage(result, config.widgetDomain);
|
|
12814
13173
|
};
|
|
12815
|
-
const
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
});
|
|
12825
|
-
break;
|
|
12826
|
-
}
|
|
13174
|
+
const dispatchResult = dispatchHostCallback({
|
|
13175
|
+
callbacks: (getCallbacks == null ? void 0 : getCallbacks()) ?? {},
|
|
13176
|
+
callbackName: actionMessage.callbackName,
|
|
13177
|
+
payload: callbackPayload,
|
|
13178
|
+
hostWidgetType: config.widgetType,
|
|
13179
|
+
invocationId: actionMessage.requestId,
|
|
13180
|
+
transport: "iframe"
|
|
13181
|
+
});
|
|
13182
|
+
if (!dispatchResult) break;
|
|
12827
13183
|
try {
|
|
12828
|
-
const value = await
|
|
12829
|
-
callbacks,
|
|
12830
|
-
message.callbackName,
|
|
12831
|
-
message.payload
|
|
12832
|
-
);
|
|
13184
|
+
const value = await dispatchResult;
|
|
12833
13185
|
const result = {
|
|
12834
13186
|
type: "RETURNINGAI_WIDGET_ACTION_RESULT",
|
|
12835
|
-
requestId:
|
|
12836
|
-
action: "store:host-callback",
|
|
13187
|
+
requestId: actionMessage.requestId,
|
|
13188
|
+
action: actionMessage.action === "widget:host-callback" ? "widget:host-callback" : "store:host-callback",
|
|
12837
13189
|
ok: true,
|
|
12838
13190
|
status: "success",
|
|
12839
|
-
...value !== void 0 ? { value } : {}
|
|
13191
|
+
...definition.completionMode === "result" && value !== void 0 ? { value } : {}
|
|
12840
13192
|
};
|
|
12841
13193
|
respond(result);
|
|
12842
|
-
} catch {
|
|
13194
|
+
} catch (error) {
|
|
12843
13195
|
respond({
|
|
12844
13196
|
type: "RETURNINGAI_WIDGET_ACTION_RESULT",
|
|
12845
|
-
requestId:
|
|
12846
|
-
action: "store:host-callback",
|
|
13197
|
+
requestId: actionMessage.requestId,
|
|
13198
|
+
action: actionMessage.action === "widget:host-callback" ? "widget:host-callback" : "store:host-callback",
|
|
12847
13199
|
ok: false,
|
|
12848
13200
|
status: "failed",
|
|
12849
|
-
error: {
|
|
13201
|
+
error: {
|
|
13202
|
+
message: error instanceof Error && error.message === "Host callback is not registered" ? error.message : "Host callback failed"
|
|
13203
|
+
}
|
|
12850
13204
|
});
|
|
12851
13205
|
}
|
|
12852
13206
|
break;
|
|
@@ -12859,7 +13213,7 @@ function setupMessageListener(config, state, _shadow, iframe, onRefreshScheduled
|
|
|
12859
13213
|
heightSetter.cancel();
|
|
12860
13214
|
};
|
|
12861
13215
|
}
|
|
12862
|
-
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}';
|
|
13216
|
+
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(--rai-loading-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-pending-settings{visibility:hidden}.rai-loader-text{margin:.5rem 0 0;font-family:var(--rai-loading-text-font, var(--rai-loader-font, "Roboto", system-ui, -apple-system, sans-serif));font-size:var(--rai-loading-text-size, 1.125rem);line-height:1.75rem;font-weight:var(--rai-loading-text-weight, 400);font-style:var(--rai-loading-text-style, normal);text-decoration:var(--rai-loading-text-decoration, none);letter-spacing:normal;color:var(--rai-loading-text-color, var(--accent-1, var(--rai-accent, #000000)));text-align:center}@media (min-width: 768px){.rai-loader-text{font-size:var(--rai-loading-text-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}';
|
|
12863
13217
|
const DEFINED_ATTRS = /* @__PURE__ */ new Set([
|
|
12864
13218
|
"community-id",
|
|
12865
13219
|
"channel-id",
|
|
@@ -12967,17 +13321,88 @@ function resolveWidgetServerUrl(domainKey) {
|
|
|
12967
13321
|
function resolveV2ApiUrl(domainKey) {
|
|
12968
13322
|
return DOMAIN_KEY_TO_V2_API_URL[domainKey] || DOMAIN_KEY_TO_V2_API_URL.PROD;
|
|
12969
13323
|
}
|
|
12970
|
-
const
|
|
13324
|
+
const loadedGoogleFontFamilies = /* @__PURE__ */ new Set();
|
|
13325
|
+
const LOCAL_OR_SYSTEM_FONT_FAMILIES = /* @__PURE__ */ new Set([
|
|
13326
|
+
"aeonik",
|
|
13327
|
+
"courier",
|
|
13328
|
+
"courier new",
|
|
13329
|
+
"monaco",
|
|
13330
|
+
"monospace",
|
|
13331
|
+
"sans-serif",
|
|
13332
|
+
"serif",
|
|
13333
|
+
"system-ui"
|
|
13334
|
+
]);
|
|
13335
|
+
const SERIF_FONT_FAMILIES = /* @__PURE__ */ new Set(["lora", "playfair display", "prata"]);
|
|
13336
|
+
const GOOGLE_FONT_VARIANTS = ":ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,700";
|
|
13337
|
+
function normalizeFontFamily(family) {
|
|
13338
|
+
return family.trim() === "Noto" ? "Noto Sans" : family.trim();
|
|
13339
|
+
}
|
|
13340
|
+
function getFontStack(family) {
|
|
13341
|
+
const normalizedFamily = normalizeFontFamily(family);
|
|
13342
|
+
const normalizedKey = normalizedFamily.toLowerCase();
|
|
13343
|
+
switch (normalizedKey) {
|
|
13344
|
+
case "monospace":
|
|
13345
|
+
return "monospace";
|
|
13346
|
+
case "courier":
|
|
13347
|
+
case "courier new":
|
|
13348
|
+
return '"Courier New", Courier, monospace';
|
|
13349
|
+
case "monaco":
|
|
13350
|
+
return "Monaco, Menlo, Consolas, monospace";
|
|
13351
|
+
case "system-ui":
|
|
13352
|
+
return "system-ui, -apple-system, sans-serif";
|
|
13353
|
+
case "sans-serif":
|
|
13354
|
+
case "serif":
|
|
13355
|
+
return normalizedKey;
|
|
13356
|
+
default:
|
|
13357
|
+
return `'${normalizedFamily.replace(/[\\']/g, "\\\\$&")}', ${SERIF_FONT_FAMILIES.has(normalizedKey) ? "Georgia, 'Times New Roman', serif" : "system-ui, -apple-system, sans-serif"}`;
|
|
13358
|
+
}
|
|
13359
|
+
}
|
|
13360
|
+
function ensureGoogleFontPreconnect() {
|
|
13361
|
+
if (!document.getElementById("rai-fonts-preconnect")) {
|
|
13362
|
+
const link = document.createElement("link");
|
|
13363
|
+
link.id = "rai-fonts-preconnect";
|
|
13364
|
+
link.rel = "preconnect";
|
|
13365
|
+
link.href = "https://fonts.googleapis.com";
|
|
13366
|
+
document.head.appendChild(link);
|
|
13367
|
+
}
|
|
13368
|
+
if (!document.getElementById("rai-fonts-static-preconnect")) {
|
|
13369
|
+
const link = document.createElement("link");
|
|
13370
|
+
link.id = "rai-fonts-static-preconnect";
|
|
13371
|
+
link.rel = "preconnect";
|
|
13372
|
+
link.href = "https://fonts.gstatic.com";
|
|
13373
|
+
link.crossOrigin = "anonymous";
|
|
13374
|
+
document.head.appendChild(link);
|
|
13375
|
+
}
|
|
13376
|
+
}
|
|
12971
13377
|
function ensureGoogleFontLoaded(family) {
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
13378
|
+
const normalizedFamily = normalizeFontFamily(family);
|
|
13379
|
+
const fontKey = normalizedFamily.toLowerCase();
|
|
13380
|
+
if (!normalizedFamily || LOCAL_OR_SYSTEM_FONT_FAMILIES.has(fontKey)) {
|
|
13381
|
+
return;
|
|
13382
|
+
}
|
|
13383
|
+
if (loadedGoogleFontFamilies.has(fontKey)) return;
|
|
13384
|
+
ensureGoogleFontPreconnect();
|
|
13385
|
+
const linkId = `rai-font-${normalizedFamily.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
|
|
13386
|
+
const fontUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
13387
|
+
normalizedFamily
|
|
13388
|
+
)}${GOOGLE_FONT_VARIANTS}&display=swap`;
|
|
13389
|
+
let link = document.getElementById(linkId);
|
|
13390
|
+
if (link && link.href !== fontUrl) {
|
|
13391
|
+
link.remove();
|
|
13392
|
+
link = null;
|
|
13393
|
+
}
|
|
13394
|
+
if (!link) {
|
|
13395
|
+
link = document.createElement("link");
|
|
13396
|
+
link.id = linkId;
|
|
13397
|
+
link.rel = "stylesheet";
|
|
13398
|
+
link.href = fontUrl;
|
|
13399
|
+
document.head.appendChild(link);
|
|
13400
|
+
}
|
|
13401
|
+
loadedGoogleFontFamilies.add(fontKey);
|
|
13402
|
+
link.onerror = () => {
|
|
13403
|
+
loadedGoogleFontFamilies.delete(fontKey);
|
|
13404
|
+
link == null ? void 0 : link.remove();
|
|
13405
|
+
};
|
|
12981
13406
|
}
|
|
12982
13407
|
const DANGEROUS_ELEMENTS = ["script", "iframe", "object", "embed"];
|
|
12983
13408
|
const URL_ATTRS = ["src", "href", "xlink:href"];
|
|
@@ -13140,10 +13565,12 @@ function createInitialState() {
|
|
|
13140
13565
|
refreshPromise: null,
|
|
13141
13566
|
errorSettings: null,
|
|
13142
13567
|
loadingAnimation: null,
|
|
13568
|
+
loadingSettings: null,
|
|
13143
13569
|
themePalette: null,
|
|
13144
13570
|
font: null,
|
|
13145
13571
|
defaultColorSchema: null,
|
|
13146
|
-
lastAuthError: null
|
|
13572
|
+
lastAuthError: null,
|
|
13573
|
+
widgetData: null
|
|
13147
13574
|
};
|
|
13148
13575
|
}
|
|
13149
13576
|
class BaseWidget extends HTMLElement {
|
|
@@ -13164,6 +13591,7 @@ class BaseWidget extends HTMLElement {
|
|
|
13164
13591
|
__publicField(this, "hasAttemptedInit", false);
|
|
13165
13592
|
__publicField(this, "initGeneration", 0);
|
|
13166
13593
|
__publicField(this, "lottieInstances", []);
|
|
13594
|
+
__publicField(this, "renderedLoaderAnimationKey", null);
|
|
13167
13595
|
__publicField(this, "callbackRegistry", new WidgetCallbackRegistry());
|
|
13168
13596
|
__publicField(this, "bannerNode", null);
|
|
13169
13597
|
__publicField(this, "releaseAutoThemeDisableLease");
|
|
@@ -13289,6 +13717,7 @@ class BaseWidget extends HTMLElement {
|
|
|
13289
13717
|
applyFirstPaintColors() {
|
|
13290
13718
|
var _a;
|
|
13291
13719
|
const cached = loadErrorSettingsFromStorage(this.config);
|
|
13720
|
+
if (cached) applyErrorSettingsToState(this.state, cached);
|
|
13292
13721
|
if (!this.config.themeExplicit) {
|
|
13293
13722
|
const cachedDefault = cached == null ? void 0 : cached.defaultColorSchema;
|
|
13294
13723
|
if (cachedDefault === "light" || cachedDefault === "dark") {
|
|
@@ -13301,6 +13730,7 @@ class BaseWidget extends HTMLElement {
|
|
|
13301
13730
|
const cachedFont = typeof (cached == null ? void 0 : cached.font) === "string" ? cached.font : void 0;
|
|
13302
13731
|
const font = cachedFont || this.config.firstPaintFont;
|
|
13303
13732
|
if (font) this.applyFont(font);
|
|
13733
|
+
this.applyLoadingSettings();
|
|
13304
13734
|
if (cachedPalette) return;
|
|
13305
13735
|
const hints = this.config.firstPaintColors;
|
|
13306
13736
|
if (hints == null ? void 0 : hints.bg) this.style.setProperty("--background-5", hints.bg);
|
|
@@ -13308,11 +13738,10 @@ class BaseWidget extends HTMLElement {
|
|
|
13308
13738
|
if (hints == null ? void 0 : hints.accent) this.style.setProperty("--accent-1", hints.accent);
|
|
13309
13739
|
}
|
|
13310
13740
|
applyFont(font) {
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
);
|
|
13315
|
-
ensureGoogleFontLoaded(font);
|
|
13741
|
+
const normalizedFont = normalizeFontFamily(font);
|
|
13742
|
+
this.style.setProperty("--rai-loader-font", getFontStack(normalizedFont));
|
|
13743
|
+
this.style.setProperty("--font-family", normalizedFont);
|
|
13744
|
+
ensureGoogleFontLoaded(normalizedFont);
|
|
13316
13745
|
}
|
|
13317
13746
|
applyPalette(palette) {
|
|
13318
13747
|
Object.entries(palette).forEach(([key, value]) => {
|
|
@@ -13321,14 +13750,91 @@ class BaseWidget extends HTMLElement {
|
|
|
13321
13750
|
}
|
|
13322
13751
|
});
|
|
13323
13752
|
}
|
|
13753
|
+
applyLoadingSettings(loadingSettings = this.state.loadingSettings) {
|
|
13754
|
+
var _a, _b;
|
|
13755
|
+
const loadingText = loadingSettings == null ? void 0 : loadingSettings.loadingText;
|
|
13756
|
+
const colorMode = this.config.theme === "dark" ? "dark" : "light";
|
|
13757
|
+
const backgroundColor = ((_a = loadingSettings == null ? void 0 : loadingSettings.backgroundColors) == null ? void 0 : _a[colorMode]) ?? (loadingSettings == null ? void 0 : loadingSettings.backgroundColor);
|
|
13758
|
+
if (backgroundColor && backgroundColor !== "var(--background-5)") {
|
|
13759
|
+
this.style.setProperty("--rai-loading-background", backgroundColor);
|
|
13760
|
+
} else {
|
|
13761
|
+
this.style.removeProperty("--rai-loading-background");
|
|
13762
|
+
}
|
|
13763
|
+
const textEl = (_b = this.loaderEl) == null ? void 0 : _b.querySelector(".rai-loader-text");
|
|
13764
|
+
if (!loadingText) {
|
|
13765
|
+
this.style.removeProperty("--rai-loading-text-color");
|
|
13766
|
+
this.style.removeProperty("--rai-loading-text-font");
|
|
13767
|
+
this.style.removeProperty("--rai-loading-text-size");
|
|
13768
|
+
this.style.removeProperty("--rai-loading-text-weight");
|
|
13769
|
+
this.style.removeProperty("--rai-loading-text-style");
|
|
13770
|
+
this.style.removeProperty("--rai-loading-text-decoration");
|
|
13771
|
+
if (textEl) {
|
|
13772
|
+
textEl.textContent = this.config.loadingText;
|
|
13773
|
+
textEl.hidden = false;
|
|
13774
|
+
}
|
|
13775
|
+
return;
|
|
13776
|
+
}
|
|
13777
|
+
if (loadingText.color) {
|
|
13778
|
+
this.style.setProperty("--rai-loading-text-color", loadingText.color);
|
|
13779
|
+
}
|
|
13780
|
+
if (loadingText.fontFamily) {
|
|
13781
|
+
this.style.setProperty(
|
|
13782
|
+
"--rai-loading-text-font",
|
|
13783
|
+
getFontStack(loadingText.fontFamily)
|
|
13784
|
+
);
|
|
13785
|
+
ensureGoogleFontLoaded(loadingText.fontFamily);
|
|
13786
|
+
}
|
|
13787
|
+
if (Number.isFinite(loadingText.fontSizePx) && loadingText.fontSizePx > 0) {
|
|
13788
|
+
this.style.setProperty(
|
|
13789
|
+
"--rai-loading-text-size",
|
|
13790
|
+
`${loadingText.fontSizePx}px`
|
|
13791
|
+
);
|
|
13792
|
+
}
|
|
13793
|
+
this.style.setProperty(
|
|
13794
|
+
"--rai-loading-text-weight",
|
|
13795
|
+
loadingText.bold ? "700" : "400"
|
|
13796
|
+
);
|
|
13797
|
+
this.style.setProperty(
|
|
13798
|
+
"--rai-loading-text-style",
|
|
13799
|
+
loadingText.italic ? "italic" : "normal"
|
|
13800
|
+
);
|
|
13801
|
+
this.style.setProperty(
|
|
13802
|
+
"--rai-loading-text-decoration",
|
|
13803
|
+
loadingText.underline ? "underline" : "none"
|
|
13804
|
+
);
|
|
13805
|
+
if (textEl) {
|
|
13806
|
+
textEl.textContent = loadingText.text;
|
|
13807
|
+
textEl.hidden = !loadingText.enabled;
|
|
13808
|
+
}
|
|
13809
|
+
}
|
|
13810
|
+
getLoadingAnimationRenderKey() {
|
|
13811
|
+
var _a, _b, _c;
|
|
13812
|
+
const animation = this.state.loadingAnimation;
|
|
13813
|
+
const theme = this.config.theme === "dark" ? "dark" : "light";
|
|
13814
|
+
const custom = (animation == null ? void 0 : animation.type) === "custom" ? ((_a = animation.custom) == null ? void 0 : _a[theme]) || ((_b = animation.custom) == null ? void 0 : _b.light) || ((_c = animation.custom) == null ? void 0 : _c.dark) : void 0;
|
|
13815
|
+
return JSON.stringify({
|
|
13816
|
+
theme,
|
|
13817
|
+
type: (animation == null ? void 0 : animation.type) ?? null,
|
|
13818
|
+
preset: (animation == null ? void 0 : animation.preset) ?? null,
|
|
13819
|
+
custom: custom ? {
|
|
13820
|
+
type: custom.type ?? null,
|
|
13821
|
+
html: custom.html ?? null,
|
|
13822
|
+
lottie: custom.lottie ?? null
|
|
13823
|
+
} : null
|
|
13824
|
+
});
|
|
13825
|
+
}
|
|
13324
13826
|
renderShell() {
|
|
13325
13827
|
this.loaderEl = document.createElement("div");
|
|
13326
13828
|
this.loaderEl.className = "rai-loader";
|
|
13829
|
+
if (this.config.widgetType === "custom" && !loadErrorSettingsFromStorage(this.config)) {
|
|
13830
|
+
this.loaderEl.classList.add("rai-loader-pending-settings");
|
|
13831
|
+
}
|
|
13327
13832
|
const textEl = document.createElement("h1");
|
|
13328
13833
|
textEl.className = "rai-loader-text";
|
|
13329
13834
|
textEl.textContent = this.config.loadingText;
|
|
13330
13835
|
this.loaderEl.appendChild(textEl);
|
|
13331
13836
|
this.shadow.appendChild(this.loaderEl);
|
|
13837
|
+
this.applyLoadingSettings();
|
|
13332
13838
|
this.fetchAndRenderLoader();
|
|
13333
13839
|
this.errorEl = document.createElement("div");
|
|
13334
13840
|
this.errorEl.className = "rai-error";
|
|
@@ -13359,11 +13865,21 @@ class BaseWidget extends HTMLElement {
|
|
|
13359
13865
|
const cached = loadErrorSettingsFromStorage(this.config);
|
|
13360
13866
|
if (cached) {
|
|
13361
13867
|
applyErrorSettingsToState(this.state, cached);
|
|
13868
|
+
this.applyLoadingSettings();
|
|
13362
13869
|
this.renderLoaderAnimation();
|
|
13363
|
-
fetchErrorSettings(this.config, this.state, { skipCache: true }).
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13870
|
+
void fetchErrorSettings(this.config, this.state, { skipCache: true }).then(() => {
|
|
13871
|
+
var _a2;
|
|
13872
|
+
if (!this.loaderEl) return;
|
|
13873
|
+
const theme2 = this.config.theme === "dark" ? "dark" : "light";
|
|
13874
|
+
const palette2 = (_a2 = this.state.themePalette) == null ? void 0 : _a2[theme2];
|
|
13875
|
+
if (palette2) this.applyPalette(palette2);
|
|
13876
|
+
if (this.state.font) this.applyFont(this.state.font);
|
|
13877
|
+
this.applyLoadingSettings();
|
|
13878
|
+
if (this.renderedLoaderAnimationKey !== this.getLoadingAnimationRenderKey()) {
|
|
13879
|
+
this.renderLoaderAnimation();
|
|
13880
|
+
}
|
|
13881
|
+
}).catch(() => {
|
|
13882
|
+
});
|
|
13367
13883
|
return;
|
|
13368
13884
|
}
|
|
13369
13885
|
try {
|
|
@@ -13378,7 +13894,9 @@ class BaseWidget extends HTMLElement {
|
|
|
13378
13894
|
const palette = (_a = this.state.themePalette) == null ? void 0 : _a[theme];
|
|
13379
13895
|
if (palette) this.applyPalette(palette);
|
|
13380
13896
|
if (this.state.font) this.applyFont(this.state.font);
|
|
13897
|
+
this.applyLoadingSettings();
|
|
13381
13898
|
this.renderLoaderAnimation();
|
|
13899
|
+
this.loaderEl.classList.remove("rai-loader-pending-settings");
|
|
13382
13900
|
}
|
|
13383
13901
|
/**
|
|
13384
13902
|
* Append the loading animation above the text. Removes any previous
|
|
@@ -13387,6 +13905,7 @@ class BaseWidget extends HTMLElement {
|
|
|
13387
13905
|
*/
|
|
13388
13906
|
renderLoaderAnimation() {
|
|
13389
13907
|
if (!this.loaderEl) return;
|
|
13908
|
+
this.renderedLoaderAnimationKey = this.getLoadingAnimationRenderKey();
|
|
13390
13909
|
this.clearLottieInstances();
|
|
13391
13910
|
const existing = this.loaderEl.querySelector(".rai-loader-anim");
|
|
13392
13911
|
if (existing) existing.remove();
|
|
@@ -13467,8 +13986,13 @@ class BaseWidget extends HTMLElement {
|
|
|
13467
13986
|
hideLoader() {
|
|
13468
13987
|
if (!this.loaderEl) return;
|
|
13469
13988
|
const loader = this.loaderEl;
|
|
13989
|
+
const lottieInstances = this.lottieInstances;
|
|
13990
|
+
this.lottieInstances = [];
|
|
13470
13991
|
loader.classList.add("fade-out");
|
|
13471
|
-
setTimeout(() =>
|
|
13992
|
+
setTimeout(() => {
|
|
13993
|
+
loader.remove();
|
|
13994
|
+
lottieInstances.forEach((instance) => instance.destroy());
|
|
13995
|
+
}, 300);
|
|
13472
13996
|
this.loaderEl = null;
|
|
13473
13997
|
}
|
|
13474
13998
|
/**
|
|
@@ -13676,8 +14200,21 @@ class BaseWidget extends HTMLElement {
|
|
|
13676
14200
|
this.showError();
|
|
13677
14201
|
return;
|
|
13678
14202
|
}
|
|
13679
|
-
|
|
13680
|
-
|
|
14203
|
+
if (this.config.bundleUrl) {
|
|
14204
|
+
this.prepareBundleRuntimeEnvironment();
|
|
14205
|
+
warmBundleRuntime(
|
|
14206
|
+
WIDGET_GLOBALS[this.config.widgetType],
|
|
14207
|
+
this.config.bundleUrl
|
|
14208
|
+
);
|
|
14209
|
+
}
|
|
14210
|
+
const errorSettingsPromise = fetchErrorSettings(this.config, this.state);
|
|
14211
|
+
const finishStartup = async (authentication) => {
|
|
14212
|
+
const [authenticated] = await Promise.all([
|
|
14213
|
+
authentication,
|
|
14214
|
+
errorSettingsPromise
|
|
14215
|
+
]);
|
|
14216
|
+
return authenticated;
|
|
14217
|
+
};
|
|
13681
14218
|
const launchWidget = () => {
|
|
13682
14219
|
var _a;
|
|
13683
14220
|
if (!this.isCurrentInit(initId)) return;
|
|
@@ -13703,10 +14240,12 @@ class BaseWidget extends HTMLElement {
|
|
|
13703
14240
|
}
|
|
13704
14241
|
};
|
|
13705
14242
|
if (this.config.authUrl) {
|
|
13706
|
-
const authed2 = await
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
14243
|
+
const authed2 = await finishStartup(
|
|
14244
|
+
authenticateViaProxy(
|
|
14245
|
+
this.config,
|
|
14246
|
+
this.state,
|
|
14247
|
+
() => this.scheduleRefresh()
|
|
14248
|
+
)
|
|
13710
14249
|
);
|
|
13711
14250
|
if (!this.isCurrentInit(initId)) return;
|
|
13712
14251
|
if (authed2) {
|
|
@@ -13720,10 +14259,12 @@ class BaseWidget extends HTMLElement {
|
|
|
13720
14259
|
if (this.config.embedToken) {
|
|
13721
14260
|
clearState(this.state);
|
|
13722
14261
|
clearStorage(this.config);
|
|
13723
|
-
const authed2 = await
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
14262
|
+
const authed2 = await finishStartup(
|
|
14263
|
+
authenticateServerless(
|
|
14264
|
+
this.config,
|
|
14265
|
+
this.state,
|
|
14266
|
+
() => this.scheduleRefresh()
|
|
14267
|
+
)
|
|
13727
14268
|
);
|
|
13728
14269
|
if (!this.isCurrentInit(initId)) return;
|
|
13729
14270
|
if (authed2) {
|
|
@@ -13736,10 +14277,12 @@ class BaseWidget extends HTMLElement {
|
|
|
13736
14277
|
}
|
|
13737
14278
|
const hasStored = loadFromStorage(this.config, this.state);
|
|
13738
14279
|
if (hasStored) {
|
|
13739
|
-
const refreshed = await
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
14280
|
+
const refreshed = await finishStartup(
|
|
14281
|
+
refreshAccessToken(
|
|
14282
|
+
this.config,
|
|
14283
|
+
this.state,
|
|
14284
|
+
() => this.scheduleRefresh()
|
|
14285
|
+
)
|
|
13743
14286
|
);
|
|
13744
14287
|
if (!this.isCurrentInit(initId)) return;
|
|
13745
14288
|
if (!refreshed) {
|
|
@@ -13751,10 +14294,12 @@ class BaseWidget extends HTMLElement {
|
|
|
13751
14294
|
launchWidget();
|
|
13752
14295
|
return;
|
|
13753
14296
|
}
|
|
13754
|
-
const authed = await
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
14297
|
+
const authed = await finishStartup(
|
|
14298
|
+
authenticateServerless(
|
|
14299
|
+
this.config,
|
|
14300
|
+
this.state,
|
|
14301
|
+
() => this.scheduleRefresh()
|
|
14302
|
+
)
|
|
13758
14303
|
);
|
|
13759
14304
|
if (!this.isCurrentInit(initId)) return;
|
|
13760
14305
|
if (authed) {
|
|
@@ -13823,33 +14368,35 @@ class BaseWidget extends HTMLElement {
|
|
|
13823
14368
|
);
|
|
13824
14369
|
}
|
|
13825
14370
|
// ── Bundle mode (no-iframe) ──────────────────────────────────────────
|
|
14371
|
+
prepareBundleRuntimeEnvironment() {
|
|
14372
|
+
const bundleApiUrl = this.config.v2ApiUrl || resolveV2ApiUrl(this.config.domainKey);
|
|
14373
|
+
const runtimeWindow = window;
|
|
14374
|
+
if (!runtimeWindow.DomainKey) {
|
|
14375
|
+
runtimeWindow.DomainKey = toInternalDomainKey(this.config.domainKey);
|
|
14376
|
+
}
|
|
14377
|
+
if (!runtimeWindow.api_url) {
|
|
14378
|
+
runtimeWindow.api_url = bundleApiUrl;
|
|
14379
|
+
}
|
|
14380
|
+
runtimeWindow.__IS_WIDGET__ = true;
|
|
14381
|
+
const colorMode = this.config.theme === "dark" ? "dark" : "light";
|
|
14382
|
+
const defaultThemeName = colorMode === "dark" ? "dark-knight" : "white-smoke";
|
|
14383
|
+
document.documentElement.setAttribute("data-theme", defaultThemeName);
|
|
14384
|
+
runtimeWindow.currentTheme = colorMode;
|
|
14385
|
+
runtimeWindow.__FORCE_COLOR_MODE__ = colorMode;
|
|
14386
|
+
runtimeWindow.__WIDGET_STORAGE_KEY__ = `color-schema-${this.config.widgetType}-${this.config.widgetId}`;
|
|
14387
|
+
return { bundleApiUrl, colorMode };
|
|
14388
|
+
}
|
|
13826
14389
|
async mountWidget(initId) {
|
|
13827
14390
|
var _a;
|
|
13828
14391
|
let container = null;
|
|
13829
14392
|
try {
|
|
13830
14393
|
this.teardownMountedWidget();
|
|
14394
|
+
const autoHeight = this.config.height.trim().toLowerCase() === "auto";
|
|
13831
14395
|
if (this.config.widgetType === "custom") {
|
|
13832
14396
|
this.releaseAutoThemeDisableLease = acquireAutoThemeDisableLease();
|
|
13833
14397
|
}
|
|
13834
|
-
const bundleApiUrl = this.
|
|
13835
|
-
|
|
13836
|
-
if (!w.DomainKey) {
|
|
13837
|
-
w.DomainKey = toInternalDomainKey(this.config.domainKey);
|
|
13838
|
-
}
|
|
13839
|
-
if (!w.api_url) {
|
|
13840
|
-
w.api_url = bundleApiUrl;
|
|
13841
|
-
}
|
|
13842
|
-
window.__IS_WIDGET__ = true;
|
|
13843
|
-
window.guest_token = this.state.accessToken;
|
|
13844
|
-
const colorMode = this.config.theme === "dark" ? "dark" : "light";
|
|
13845
|
-
const defaultThemeName = colorMode === "dark" ? "dark-knight" : "white-smoke";
|
|
13846
|
-
document.documentElement.setAttribute("data-theme", defaultThemeName);
|
|
13847
|
-
window.currentTheme = colorMode;
|
|
13848
|
-
window.__FORCE_COLOR_MODE__ = colorMode;
|
|
13849
|
-
window.__WIDGET_STORAGE_KEY__ = `color-schema-${this.config.widgetType}-${this.config.widgetId}`;
|
|
13850
|
-
if (this.state.loadingAnimation) {
|
|
13851
|
-
window.loadingAnimation = this.state.loadingAnimation;
|
|
13852
|
-
}
|
|
14398
|
+
const { bundleApiUrl, colorMode } = this.prepareBundleRuntimeEnvironment();
|
|
14399
|
+
syncBundleAccessToken(this.config, this.state);
|
|
13853
14400
|
const globalName = WIDGET_GLOBALS[this.config.widgetType];
|
|
13854
14401
|
const widgetGlobal = await getOrLoadBundleRuntime(
|
|
13855
14402
|
globalName,
|
|
@@ -13860,10 +14407,15 @@ class BaseWidget extends HTMLElement {
|
|
|
13860
14407
|
const hideNestedBundleUntilReady = this.config.widgetType === "custom";
|
|
13861
14408
|
container.className = "rai-widget-root";
|
|
13862
14409
|
container.setAttribute("data-rai-widget-root", "true");
|
|
14410
|
+
container.__raiWidgetRuntime = {
|
|
14411
|
+
colorMode,
|
|
14412
|
+
loadingAnimation: this.state.loadingAnimation,
|
|
14413
|
+
loadingSettings: this.state.loadingSettings
|
|
14414
|
+
};
|
|
13863
14415
|
container.style.cssText = [
|
|
13864
14416
|
"position: relative",
|
|
13865
14417
|
"width: 100%",
|
|
13866
|
-
|
|
14418
|
+
`height: ${autoHeight ? "auto" : "100%"}`,
|
|
13867
14419
|
"color: var(--text-1)",
|
|
13868
14420
|
"background: transparent",
|
|
13869
14421
|
"font-family: var(--rai-loader-font, 'Roboto', system-ui, -apple-system, sans-serif)",
|
|
@@ -13899,18 +14451,27 @@ class BaseWidget extends HTMLElement {
|
|
|
13899
14451
|
// injected by SSR for the explicit `/open-widget` route.
|
|
13900
14452
|
isOpenWidget: !this.state.accessToken,
|
|
13901
14453
|
defaultColorSchema: this.config.widgetType === "custom" && !this.config.themeExplicit ? null : colorMode,
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
14454
|
+
// Bundle loading screens are rendered beneath an instance-scoped
|
|
14455
|
+
// provider. Do not put these values on window: pages can mount several
|
|
14456
|
+
// widget types at once.
|
|
14457
|
+
colorMode,
|
|
14458
|
+
loadingAnimation: this.state.loadingAnimation,
|
|
14459
|
+
loadingSettings: this.state.loadingSettings,
|
|
14460
|
+
widgetData: this.config.widgetType === "custom" ? this.state.widgetData || void 0 : void 0,
|
|
14461
|
+
// Auto-height embeds delegate vertical sizing and scrolling to the
|
|
14462
|
+
// host page. Bundle consumers use this explicit contract instead of
|
|
14463
|
+
// inferring the SDK host element from their rendered DOM.
|
|
14464
|
+
autoHeight,
|
|
14465
|
+
requestHostCallback: (callbackName, payload) => dispatchHostCallback({
|
|
14466
|
+
callbacks: this.readRuntimeCallbacks(),
|
|
14467
|
+
callbackName,
|
|
14468
|
+
payload: enrichHostCallbackPayload(
|
|
14469
|
+
payload,
|
|
14470
|
+
resolveHostUserIdentifiers(this.config)
|
|
14471
|
+
),
|
|
14472
|
+
hostWidgetType: this.config.widgetType,
|
|
14473
|
+
transport: "bundle"
|
|
14474
|
+
})
|
|
13914
14475
|
});
|
|
13915
14476
|
await waitForBundleMountReadiness(mountResult, firstPaint);
|
|
13916
14477
|
if (!this.isCurrentInit(initId) || !container.isConnected) {
|
|
@@ -13939,9 +14500,7 @@ class BaseWidget extends HTMLElement {
|
|
|
13939
14500
|
const pushToken = () => {
|
|
13940
14501
|
if (this.state.iframe)
|
|
13941
14502
|
sendTokenToWidget(this.config, this.state, this.state.iframe);
|
|
13942
|
-
|
|
13943
|
-
window.guest_token = this.state.accessToken;
|
|
13944
|
-
}
|
|
14503
|
+
syncBundleAccessToken(this.config, this.state);
|
|
13945
14504
|
};
|
|
13946
14505
|
const doRefresh = async () => {
|
|
13947
14506
|
if (this.config.authUrl) {
|
|
@@ -14115,7 +14674,7 @@ class CustomWidget extends BaseWidget {
|
|
|
14115
14674
|
}
|
|
14116
14675
|
}
|
|
14117
14676
|
}
|
|
14118
|
-
console.log(`[rai-widget] v${"1.
|
|
14677
|
+
console.log(`[rai-widget] v${"1.8.1"}`);
|
|
14119
14678
|
class StoreWidgetCompat extends StoreWidget {
|
|
14120
14679
|
}
|
|
14121
14680
|
const WIDGET_REGISTRY = [
|
|
@@ -14179,7 +14738,7 @@ function exposePublicApi() {
|
|
|
14179
14738
|
})();
|
|
14180
14739
|
const widget = container == null ? void 0 : container.querySelector(ALL_WIDGET_SELECTOR);
|
|
14181
14740
|
window.ReturningAIWidget = {
|
|
14182
|
-
version: "1.
|
|
14741
|
+
version: "1.8.1",
|
|
14183
14742
|
reload: () => (widget == null ? void 0 : widget.reload()) ?? Promise.resolve(),
|
|
14184
14743
|
logout: () => (widget == null ? void 0 : widget.logoutPublic()) ?? Promise.resolve(),
|
|
14185
14744
|
isAuthenticated: () => (widget == null ? void 0 : widget.isAuthenticated()) ?? false,
|
|
@@ -14195,6 +14754,9 @@ export {
|
|
|
14195
14754
|
ChannelWidget,
|
|
14196
14755
|
CurrencyWidget,
|
|
14197
14756
|
CustomWidget,
|
|
14757
|
+
MILESTONE_CTA_CLICK_CALLBACK_NAME,
|
|
14758
|
+
MILESTONE_CTA_CLICK_EVENT,
|
|
14759
|
+
MILESTONE_CTA_CLICK_SCOPE,
|
|
14198
14760
|
MilestoneWidget,
|
|
14199
14761
|
ReferralWidget,
|
|
14200
14762
|
STORE_CALLBACK_FIELD_OPTIONS_CALLBACK_NAME,
|