@returningai/widget-sdk 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/README.md +90 -0
- package/dist/rai-banner.iife.js +3 -0
- package/dist/rai-banner.js +1915 -0
- package/dist/rai-widget.iife.js +3 -1
- package/dist/rai-widget.js +1930 -62
- package/dist/types/BaseWidget.d.ts +10 -0
- package/dist/types/banner/BannerRuntime.d.ts +32 -0
- package/dist/types/banner/api.d.ts +33 -0
- package/dist/types/banner/render.d.ts +12 -0
- package/dist/types/banner/sanitize.d.ts +9 -0
- package/dist/types/banner/session.d.ts +9 -0
- package/dist/types/banner/track.d.ts +7 -0
- package/dist/types/banner/types.d.ts +64 -0
- package/dist/types/banner-index.d.ts +2 -0
- package/dist/types/jsx.d.ts +23 -11
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.6.0] — 2026-06-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`<rai-banner>` — standalone Banner SDK runtime.** A new lightweight custom
|
|
15
|
+
element + IIFE bundle (`dist/rai-banner.iife.js`) that external sites embed to
|
|
16
|
+
render ReturningAI banners. It calls the public eligibility endpoint
|
|
17
|
+
(`POST /v2/api/banner-sdk/eligible`) on the `sdk` surface, renders the returned
|
|
18
|
+
banner (overlay/popup → centered card; inline → into a target selector), and
|
|
19
|
+
fires the signed impression / click / dismiss tracking URLs. No auth, no iframe.
|
|
20
|
+
- Anonymous visitor identity: a per-community UUID persisted in `localStorage`
|
|
21
|
+
(`anonymous_session`), enabling frequency caps and dismiss-memory without PII.
|
|
22
|
+
- Banner HTML is sanitized client-side via DOMPurify (defense-in-depth alongside
|
|
23
|
+
the server-side sanitization).
|
|
24
|
+
- DOM events on the element: `rai-banner-impression`, `rai-banner-click`,
|
|
25
|
+
`rai-banner-dismiss`, `rai-banner-empty`, `rai-banner-error`.
|
|
26
|
+
- New build scripts `build:banner` / `build:banner:min` and a `./banner` package export.
|
|
27
|
+
- **Widgets auto-render eligible banners.** Mounting any widget
|
|
28
|
+
(`<rai-store-widget>`, `<rai-channel-widget>`, …) now calls the eligibility
|
|
29
|
+
endpoint for that widget type and renders a matching banner (if any). The widget
|
|
30
|
+
element emits the same `rai-banner-*` events. Opt out per widget with
|
|
31
|
+
`banner="off"` (or the `no-banner` attribute).
|
|
32
|
+
- `embed-token` / `data-embed-token` attribute on `<rai-banner>` (and its script-tag
|
|
33
|
+
bootstrap) so standalone embeds can serve `domain` / `authenticated` access banners.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- **Banner access model — per-banner Access gate.** Each banner now carries an
|
|
38
|
+
Access type (`public` / `domain` / `authenticated`) that replaces the old
|
|
39
|
+
anonymous / external-identifier toggles. `domain` banners render on the banner's
|
|
40
|
+
own allowed domains (enforced on the request `Origin`) **or** any origin a valid
|
|
41
|
+
embed token's access key authorizes; `authenticated` banners require a valid
|
|
42
|
+
embed token. Widget-mounted banners pass the widget's `embed-token` automatically,
|
|
43
|
+
so `domain` / `authenticated` banners work on widgets with no extra setup.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- **Inline banners no longer need a hand-added mount `<div>`.** When an `inline`
|
|
48
|
+
banner's `targetSelector` is absent (or set but not present on the page),
|
|
49
|
+
`<rai-banner>` now promotes itself to a visible block and renders the banner in
|
|
50
|
+
place. Previously it appended into the host custom element, which defaults to
|
|
51
|
+
`display: inline` with no layout box, so the banner mounted but never showed —
|
|
52
|
+
embedders had to add a `<div id="…">` matching the selector by hand.
|
|
53
|
+
|
|
54
|
+
### Notes
|
|
55
|
+
|
|
56
|
+
- The widget runtime's public API (attributes, globals, existing events) is
|
|
57
|
+
unchanged, but it now makes one eligibility request on mount and bundles
|
|
58
|
+
DOMPurify — so `rai-widget.iife.js` is larger and performs one extra network
|
|
59
|
+
call per widget. Use `banner="off"` to disable.
|
|
60
|
+
- `dompurify` added as a runtime dependency (bundled into both IIFEs).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
10
64
|
## [1.5.0] — 2026-06-03
|
|
11
65
|
|
|
12
66
|
### Added
|
package/README.md
CHANGED
|
@@ -836,3 +836,93 @@ Requires Custom Elements v1 + Shadow DOM v1.
|
|
|
836
836
|
| Chrome | 67 |
|
|
837
837
|
| Firefox | 63 |
|
|
838
838
|
| Safari | 13 |
|
|
839
|
+
|
|
840
|
+
---
|
|
841
|
+
|
|
842
|
+
## Banner SDK (`<rai-banner>`)
|
|
843
|
+
|
|
844
|
+
A separate, lightweight runtime for embedding ReturningAI **banners** on any site —
|
|
845
|
+
no auth, no iframe. Ships as its own bundle, `dist/rai-banner.iife.js` (~13 KB gzip).
|
|
846
|
+
|
|
847
|
+
> **Widgets render banners automatically.** As of 1.6.0, mounting any widget
|
|
848
|
+
> (`<rai-store-widget>`, `<rai-channel-widget>`, …) also renders eligible banners
|
|
849
|
+
> targeted at that widget type — no extra markup, and the widget element emits the
|
|
850
|
+
> same `rai-banner-*` events. Disable per widget with `banner="off"`. The
|
|
851
|
+
> `<rai-banner>` element below is for embedding banners on pages with no widget.
|
|
852
|
+
|
|
853
|
+
### Embed
|
|
854
|
+
|
|
855
|
+
Custom element:
|
|
856
|
+
|
|
857
|
+
```html
|
|
858
|
+
<script src="https://unpkg.com/@returningai/widget-sdk@1.6.0/dist/rai-banner.iife.js"></script>
|
|
859
|
+
<rai-banner community-id="YOUR_COMMUNITY_ID" domain-key="GEN"></rai-banner>
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
Or script-tag bootstrap (auto-creates the element):
|
|
863
|
+
|
|
864
|
+
```html
|
|
865
|
+
<script
|
|
866
|
+
src="https://unpkg.com/@returningai/widget-sdk@1.6.0/dist/rai-banner.iife.js"
|
|
867
|
+
data-rai-banner
|
|
868
|
+
data-community-id="YOUR_COMMUNITY_ID"
|
|
869
|
+
data-domain-key="GEN"
|
|
870
|
+
></script>
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
### Attributes
|
|
874
|
+
|
|
875
|
+
| Attribute | Required | Description |
|
|
876
|
+
| ------------------------------------------ | -------- | ------------------------------------------------------------------- |
|
|
877
|
+
| `community-id` | yes | Community ObjectId |
|
|
878
|
+
| `api-url` | no | Explicit API base (overrides `domain-key`) |
|
|
879
|
+
| `domain-key` | no | `LOCAL` \| `SGTR` \| `STG` \| `GEN` (default `LOCAL`) |
|
|
880
|
+
| `surface` | no | Defaults to `sdk` |
|
|
881
|
+
| `page-path` / `page-hostname` / `page-url` | no | Override page context (default: `window.location`) for page rules |
|
|
882
|
+
| `storage-prefix` | no | localStorage key prefix for the anonymous visitor id |
|
|
883
|
+
| `embed-token` | no\* | SDK embed token (minted from your access id/key, like the widgets). **Required for banners whose Access is `domain` or `authenticated`** — see below |
|
|
884
|
+
|
|
885
|
+
### How it works
|
|
886
|
+
|
|
887
|
+
1. Mints/loads an anonymous visitor UUID in `localStorage` (`anonymous_session`).
|
|
888
|
+
2. Calls `POST {api}/v2/api/banner-sdk/eligible` for the `sdk` surface with page + viewport context.
|
|
889
|
+
3. Renders the returned banner — `overlay`/`popup` placement → a centered card (portaled to `<body>`);
|
|
890
|
+
`inline` → into the configured target selector, or — when that selector isn't on the page —
|
|
891
|
+
in place where the `<rai-banner>` element sits. **No mount `<div>` is required** for any
|
|
892
|
+
placement: overlay/popup float over the page, inline renders where the snippet/element is.
|
|
893
|
+
4. Fires signed impression / click / dismiss tracking URLs (one-time, HMAC-signed, replay-protected server-side).
|
|
894
|
+
5. Banner HTML is sanitized with DOMPurify before injection.
|
|
895
|
+
|
|
896
|
+
**Access types** — each banner has an Access setting (chosen in the dashboard) that decides what the embed must provide:
|
|
897
|
+
|
|
898
|
+
| Banner Access | What the embed needs |
|
|
899
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
900
|
+
| **Open to everyone** | nothing — `community-id` only |
|
|
901
|
+
| **Domain gate** | the page is served from one of the banner's allowed domains (enforced on the request `Origin`), **or** an `embed-token` whose access key authorizes the origin |
|
|
902
|
+
| **SDK auth** | a valid `embed-token` whose access key authorizes the origin (mint it from your access id/key, exactly like widgets) |
|
|
903
|
+
|
|
904
|
+
A live banner whose `surfaces` include `sdk` is required. Widget‑mounted banners pass the widget's `embed-token`
|
|
905
|
+
automatically, so `domain` / `authenticated` banners work on widgets with no extra setup.
|
|
906
|
+
|
|
907
|
+
### Events
|
|
908
|
+
|
|
909
|
+
The element emits bubbling `CustomEvent`s:
|
|
910
|
+
|
|
911
|
+
| Event | Detail |
|
|
912
|
+
| ----------------------- | --------------------------------- |
|
|
913
|
+
| `rai-banner-impression` | `{ bannerId }` |
|
|
914
|
+
| `rai-banner-click` | `{ bannerId }` |
|
|
915
|
+
| `rai-banner-dismiss` | `{ bannerId }` |
|
|
916
|
+
| `rai-banner-empty` | `{ reason }` (no eligible banner) |
|
|
917
|
+
| `rai-banner-error` | `{ error }` |
|
|
918
|
+
|
|
919
|
+
```js
|
|
920
|
+
document.addEventListener('rai-banner-impression', (e) => console.log('shown', e.detail.bannerId))
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
### Build
|
|
924
|
+
|
|
925
|
+
```
|
|
926
|
+
npm run build:banner # dev
|
|
927
|
+
npm run build:banner:min # production (minified)
|
|
928
|
+
```
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var RaiBanner=function(e){"use strict";var t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o)(e,"symbol"!=typeof n?n+"":n,o);
|
|
2
|
+
/*! @license DOMPurify 3.4.9 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.9/LICENSE */
|
|
3
|
+
function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(s=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);s=!0);}catch(u){c=!0,r=u}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const i=Object.entries,a=Object.setPrototypeOf,l=Object.isFrozen,s=Object.getPrototypeOf,c=Object.getOwnPropertyDescriptor;let u=Object.freeze,d=Object.seal,p=Object.create,f="undefined"!=typeof Reflect&&Reflect,m=f.apply,h=f.construct;u||(u=function(e){return e}),d||(d=function(e){return e}),m||(m=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),h||(h=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const g=U(Array.prototype.forEach),y=U(Array.prototype.lastIndexOf),b=U(Array.prototype.pop),T=U(Array.prototype.push),A=U(Array.prototype.splice),S=Array.isArray,x=U(String.prototype.toLowerCase),v=U(String.prototype.toString),w=U(String.prototype.match),E=U(String.prototype.replace),_=U(String.prototype.indexOf),N=U(String.prototype.trim),O=U(Number.prototype.toString),C=U(Boolean.prototype.toString),k="undefined"==typeof BigInt?null:U(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:U(Symbol.prototype.toString),R=U(Object.prototype.hasOwnProperty),I=U(Object.prototype.toString),L=U(RegExp.prototype.test),M=(z=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h(z,t)});var z;function U(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return m(e,t,o)}}function P(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:x;if(a&&a(e,null),!S(t))return e;let o=t.length;for(;o--;){let r=t[o];if("string"==typeof r){const e=n(r);e!==r&&(l(t)||(t[o]=e),r=e)}e[r]=!0}return e}function F(e){for(let t=0;t<e.length;t++){R(e,t)||(e[t]=null)}return e}function H(e){const t=p(null);for(const o of i(e)){var n=r(o,2);const i=n[0],a=n[1];R(e,i)&&(S(a)?t[i]=F(a):a&&"object"==typeof a&&a.constructor===Object?t[i]=H(a):t[i]=a)}return t}function j(e,t){for(;null!==e;){const n=c(e,t);if(n){if(n.get)return U(n.get);if("function"==typeof n.value)return U(n.value)}e=s(e)}return function(){return null}}const B=u(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),W=u(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),G=u(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Y=u(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),q=u(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$=u(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),X=u(["#text"]),K=u(["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"]),V=u(["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"]),Z=u(["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"]),J=u(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Q=d(/{{[\w\W]*|^[\w\W]*}}/g),ee=d(/<%[\w\W]*|^[\w\W]*%>/g),te=d(/\${[\w\W]*/g),ne=d(/^data-[\-\w.\u00B7-\uFFFF]+$/),oe=d(/^aria-[\-\w]+$/),re=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ie=d(/^(?:\w+script|data):/i),ae=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),le=d(/^html$/i),se=d(/^[a-z][.\w]*(-[.\w]+)+$/i),ce=1,ue=3,de=7,pe=8,fe=9,me=11;var he=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const n=t=>e(t);if(n.version="3.4.9",n.removed=[],!t||!t.document||t.document.nodeType!==fe||!t.Element)return n.isSupported=!1,n;let o=t.document;const r=o,a=r.currentScript;t.DocumentFragment;const l=t.HTMLTemplateElement,s=t.Node,c=t.Element,d=t.NodeFilter,f=t.NamedNodeMap;void 0===f&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const m=t.DOMParser,h=t.trustedTypes,z=c.prototype,U=j(z,"cloneNode"),F=j(z,"remove"),he=j(z,"nextSibling"),ge=j(z,"childNodes"),ye=j(z,"parentNode"),be=j(z,"shadowRoot"),Te=j(z,"attributes"),Ae=s&&s.prototype?j(s.prototype,"nodeType"):null,Se=s&&s.prototype?j(s.prototype,"nodeName"):null;if("function"==typeof l){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let xe,ve,we="",Ee=!1,_e=0;const Ne=function(){if(_e>0)throw M('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Oe=function(e){Ne(),_e++;try{return xe.createHTML(e)}finally{_e--}},Ce=function(e){Ne(),_e++;try{return xe.createScriptURL(e)}finally{_e--}},ke=function(){return Ee||(ve=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(i){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(h,a),Ee=!0),ve},De=o,Re=De.implementation,Ie=De.createNodeIterator,Le=De.createDocumentFragment,Me=De.getElementsByTagName,ze=r.importNode;let Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof i&&"function"==typeof ye&&Re&&void 0!==Re.createHTMLDocument;const Pe=Q,Fe=ee,He=te,je=ne,Be=oe,We=ie,Ge=ae,Ye=se;let qe=re,$e=null;const Xe=P({},[...B,...W,...G,...q,...X]);let Ke=null;const Ve=P({},[...K,...V,...Z,...J]);let Ze=Object.seal(p(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Je=null,Qe=null;const et=Object.seal(p(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,nt=!0,ot=!1,rt=!0,it=!1,at=!0,lt=!1,st=!1,ct=!1,ut=!1,dt=!1,pt=!1,ft=!0,mt=!1;const ht="user-content-";let gt=!0,yt=!1,bt={},Tt=null;const At=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let St=null;const xt=P({},["audio","video","img","source","image","track"]);let vt=null;const wt=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Et="http://www.w3.org/1998/Math/MathML",_t="http://www.w3.org/2000/svg",Nt="http://www.w3.org/1999/xhtml";let Ot=Nt,Ct=!1,kt=null;const Dt=P({},[Et,_t,Nt],v);let Rt=P({},["mi","mo","mn","ms","mtext"]),It=P({},["annotation-xml"]);const Lt=P({},["title","style","font","a","script"]);let Mt=null;const zt=["application/xhtml+xml","text/html"];let Ut=null,Pt=null;const Ft=o.createElement("form"),Ht=function(e){return e instanceof RegExp||e instanceof Function},jt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Pt&&Pt===e)return;e&&"object"==typeof e||(e={}),e=H(e),Mt=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ut="application/xhtml+xml"===Mt?v:x,$e=R(e,"ALLOWED_TAGS")&&S(e.ALLOWED_TAGS)?P({},e.ALLOWED_TAGS,Ut):Xe,Ke=R(e,"ALLOWED_ATTR")&&S(e.ALLOWED_ATTR)?P({},e.ALLOWED_ATTR,Ut):Ve,kt=R(e,"ALLOWED_NAMESPACES")&&S(e.ALLOWED_NAMESPACES)?P({},e.ALLOWED_NAMESPACES,v):Dt,vt=R(e,"ADD_URI_SAFE_ATTR")&&S(e.ADD_URI_SAFE_ATTR)?P(H(wt),e.ADD_URI_SAFE_ATTR,Ut):wt,St=R(e,"ADD_DATA_URI_TAGS")&&S(e.ADD_DATA_URI_TAGS)?P(H(xt),e.ADD_DATA_URI_TAGS,Ut):xt,Tt=R(e,"FORBID_CONTENTS")&&S(e.FORBID_CONTENTS)?P({},e.FORBID_CONTENTS,Ut):At,Je=R(e,"FORBID_TAGS")&&S(e.FORBID_TAGS)?P({},e.FORBID_TAGS,Ut):H({}),Qe=R(e,"FORBID_ATTR")&&S(e.FORBID_ATTR)?P({},e.FORBID_ATTR,Ut):H({}),bt=!!R(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?H(e.USE_PROFILES):e.USE_PROFILES),tt=!1!==e.ALLOW_ARIA_ATTR,nt=!1!==e.ALLOW_DATA_ATTR,ot=e.ALLOW_UNKNOWN_PROTOCOLS||!1,rt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,it=e.SAFE_FOR_TEMPLATES||!1,at=!1!==e.SAFE_FOR_XML,lt=e.WHOLE_DOCUMENT||!1,ut=e.RETURN_DOM||!1,dt=e.RETURN_DOM_FRAGMENT||!1,pt=e.RETURN_TRUSTED_TYPE||!1,ct=e.FORCE_BODY||!1,ft=!1!==e.SANITIZE_DOM,mt=e.SANITIZE_NAMED_PROPS||!1,gt=!1!==e.KEEP_CONTENT,yt=e.IN_PLACE||!1,qe=function(e){try{return L(e,""),!0}catch(t){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:re,Ot="string"==typeof e.NAMESPACE?e.NAMESPACE:Nt,Rt=R(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?H(e.MATHML_TEXT_INTEGRATION_POINTS):P({},["mi","mo","mn","ms","mtext"]),It=R(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?H(e.HTML_INTEGRATION_POINTS):P({},["annotation-xml"]);const t=R(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?H(e.CUSTOM_ELEMENT_HANDLING):p(null);if(Ze=p(null),R(t,"tagNameCheck")&&Ht(t.tagNameCheck)&&(Ze.tagNameCheck=t.tagNameCheck),R(t,"attributeNameCheck")&&Ht(t.attributeNameCheck)&&(Ze.attributeNameCheck=t.attributeNameCheck),R(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Ze.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),it&&(nt=!1),dt&&(ut=!0),bt&&($e=P({},X),Ke=p(null),!0===bt.html&&(P($e,B),P(Ke,K)),!0===bt.svg&&(P($e,W),P(Ke,V),P(Ke,J)),!0===bt.svgFilters&&(P($e,G),P(Ke,V),P(Ke,J)),!0===bt.mathMl&&(P($e,q),P(Ke,Z),P(Ke,J))),et.tagCheck=null,et.attributeCheck=null,R(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?et.tagCheck=e.ADD_TAGS:S(e.ADD_TAGS)&&($e===Xe&&($e=H($e)),P($e,e.ADD_TAGS,Ut))),R(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?et.attributeCheck=e.ADD_ATTR:S(e.ADD_ATTR)&&(Ke===Ve&&(Ke=H(Ke)),P(Ke,e.ADD_ATTR,Ut))),R(e,"ADD_URI_SAFE_ATTR")&&S(e.ADD_URI_SAFE_ATTR)&&P(vt,e.ADD_URI_SAFE_ATTR,Ut),R(e,"FORBID_CONTENTS")&&S(e.FORBID_CONTENTS)&&(Tt===At&&(Tt=H(Tt)),P(Tt,e.FORBID_CONTENTS,Ut)),R(e,"ADD_FORBID_CONTENTS")&&S(e.ADD_FORBID_CONTENTS)&&(Tt===At&&(Tt=H(Tt)),P(Tt,e.ADD_FORBID_CONTENTS,Ut)),gt&&($e["#text"]=!0),lt&&P($e,["html","head","body"]),$e.table&&(P($e,["tbody"]),delete Je.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=xe;xe=e.TRUSTED_TYPES_POLICY;try{we=Oe("")}catch(n){throw xe=t,n}}else null===e.TRUSTED_TYPES_POLICY?(xe=void 0,we=""):(void 0===xe&&(xe=ke()),xe&&"string"==typeof we&&(we=Oe("")));(Ue.uponSanitizeElement.length>0||Ue.uponSanitizeAttribute.length>0)&&$e===Xe&&($e=H($e)),Ue.uponSanitizeAttribute.length>0&&Ke===Ve&&(Ke=H(Ke)),u&&u(e),Pt=e},Bt=P({},[...W,...G,...Y]),Wt=P({},[...q,...$]),Gt=function(e){T(n.removed,{element:e});try{ye(e).removeChild(e)}catch(t){if(F(e),!ye(e))throw M("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Yt=function(e){const t=ge?ge(e):e.childNodes;if(t){const e=[];g(t,t=>{T(e,t)}),g(e,e=>{try{F(e)}catch(t){}})}const n=Te?Te(e):null;if(n)for(let r=n.length-1;r>=0;--r){const t=n[r],i=t&&t.name;if("string"==typeof i)try{e.removeAttribute(i)}catch(o){}}},qt=function(e,t){try{T(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(o){T(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ut||dt)try{Gt(t)}catch(o){}else try{t.setAttribute(e,"")}catch(o){}},$t=function(e){const t=Te?Te(e):e.attributes;if(t)for(let o=t.length-1;o>=0;--o){const r=t[o],i=r&&r.name;if("string"==typeof i&&!Ke[Ut(i)])try{e.removeAttribute(i)}catch(n){}}},Xt=function(e){let t=null,n=null;if(ct)e="<remove></remove>"+e;else{const t=w(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Mt&&Ot===Nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=xe?Oe(e):e;if(Ot===Nt)try{t=(new m).parseFromString(r,Mt)}catch(a){}if(!t||!t.documentElement){t=Re.createDocument(Ot,"template",null);try{t.documentElement.innerHTML=Ct?we:r}catch(a){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(o.createTextNode(n),i.childNodes[0]||null),Ot===Nt?Me.call(t,lt?"html":"body")[0]:lt?t.documentElement:i},Kt=function(e){return Ie.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Vt=function(e){var t,n;e.normalize();const o=Ie.call(e.ownerDocument||e,e,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let r=o.nextNode();for(;r;){let e=r.data;g([Pe,Fe,He],t=>{e=E(e,t," ")}),r.data=e,r=o.nextNode()}const i=null!==(t=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"template"))&&void 0!==t?t:[];g(Array.from(i),e=>{Jt(e.content)&&Vt(e.content)})},Zt=function(e){const t=Se?Se(e):null;return"string"==typeof t&&("form"===Ut(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Te(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==Ae(e)||e.childNodes!==ge(e)))},Jt=function(e){if(!Ae||"object"!=typeof e||null===e)return!1;try{return Ae(e)===me}catch(t){return!1}},Qt=function(e){if(!Ae||"object"!=typeof e||null===e)return!1;try{return"number"==typeof Ae(e)}catch(t){return!1}};function en(e,t,o){g(e,e=>{e.call(n,t,o,Pt)})}const tn=function(e){let t=null;if(en(Ue.beforeSanitizeElements,e,null),Zt(e))return Gt(e),!0;const o=Ut(Se?Se(e):e.nodeName);if(en(Ue.uponSanitizeElement,e,{tagName:o,allowedTags:$e}),at&&e.hasChildNodes()&&!Qt(e.firstElementChild)&&L(/<[/\w!]/g,e.innerHTML)&&L(/<[/\w!]/g,e.textContent))return Gt(e),!0;if(at&&e.namespaceURI===Nt&&"style"===o&&Qt(e.firstElementChild))return Gt(e),!0;if(e.nodeType===de)return Gt(e),!0;if(at&&e.nodeType===pe&&L(/<[/\w]/g,e.data))return Gt(e),!0;if(Je[o]||!(et.tagCheck instanceof Function&&et.tagCheck(o))&&!$e[o]){if(!Je[o]&&rn(o)){if(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,o))return!1;if(Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(o))return!1}if(gt&&!Tt[o]){const t=ye(e),n=ge(e);if(n&&t){for(let o=n.length-1;o>=0;--o){const r=yt?n[o]:U(n[o],!0);t.insertBefore(r,he(e))}}}return Gt(e),!0}return((Ae?Ae(e):e.nodeType)!==ce||function(e){let t=ye(e);t&&t.tagName||(t={namespaceURI:Ot,tagName:"template"});const n=x(e.tagName),o=x(t.tagName);return!!kt[e.namespaceURI]&&(e.namespaceURI===_t?t.namespaceURI===Nt?"svg"===n:t.namespaceURI===Et?"svg"===n&&("annotation-xml"===o||Rt[o]):Boolean(Bt[n]):e.namespaceURI===Et?t.namespaceURI===Nt?"math"===n:t.namespaceURI===_t?"math"===n&&It[o]:Boolean(Wt[n]):e.namespaceURI===Nt?!(t.namespaceURI===_t&&!It[o])&&!(t.namespaceURI===Et&&!Rt[o])&&!Wt[n]&&(Lt[n]||!Bt[n]):!("application/xhtml+xml"!==Mt||!kt[e.namespaceURI]))}(e))&&("noscript"!==o&&"noembed"!==o&&"noframes"!==o||!L(/<\/no(script|embed|frames)/i,e.innerHTML))?(it&&e.nodeType===ue&&(t=e.textContent,g([Pe,Fe,He],e=>{t=E(t,e," ")}),e.textContent!==t&&(T(n.removed,{element:e.cloneNode()}),e.textContent=t)),en(Ue.afterSanitizeElements,e,null),!1):(Gt(e),!0)},nn=function(e,t,n){if(Qe[t])return!1;if(ft&&("id"===t||"name"===t)&&(n in o||n in Ft))return!1;const r=Ke[t]||et.attributeCheck instanceof Function&&et.attributeCheck(t,e);if(nt&&!Qe[t]&&L(je,t));else if(tt&&L(Be,t));else if(!r||Qe[t]){if(!(rn(e)&&(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,e)||Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(e))&&(Ze.attributeNameCheck instanceof RegExp&&L(Ze.attributeNameCheck,t)||Ze.attributeNameCheck instanceof Function&&Ze.attributeNameCheck(t,e))||"is"===t&&Ze.allowCustomizedBuiltInElements&&(Ze.tagNameCheck instanceof RegExp&&L(Ze.tagNameCheck,n)||Ze.tagNameCheck instanceof Function&&Ze.tagNameCheck(n))))return!1}else if(vt[t]);else if(L(qe,E(n,Ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==_(n,"data:")||!St[e]){if(ot&&!L(We,E(n,Ge,"")));else if(n)return!1}else;return!0},on=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),rn=function(e){return!on[x(e)]&&L(Ye,e)},an=function(e){en(Ue.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||Zt(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ke,forceKeepAttr:void 0};let r=t.length;for(;r--;){const a=t[r],l=a.name,s=a.namespaceURI,c=a.value,u=Ut(l),d=c;let p="value"===l?d:N(d);if(o.attrName=u,o.attrValue=p,o.keepAttr=!0,o.forceKeepAttr=void 0,en(Ue.uponSanitizeAttribute,e,o),p=o.attrValue,!mt||"id"!==u&&"name"!==u||0===_(p,ht)||(qt(l,e),p=ht+p),at&&L(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,p)){qt(l,e);continue}if("attributename"===u&&w(p,"href")){qt(l,e);continue}if(o.forceKeepAttr)continue;if(!o.keepAttr){qt(l,e);continue}if(!rt&&L(/\/>/i,p)){qt(l,e);continue}it&&g([Pe,Fe,He],e=>{p=E(p,e," ")});const f=Ut(e.nodeName);if(nn(f,u,p)){if(xe&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(s);else switch(h.getAttributeType(f,u)){case"TrustedHTML":p=Oe(p);break;case"TrustedScriptURL":p=Ce(p)}if(p!==d)try{s?e.setAttributeNS(s,l,p):e.setAttribute(l,p),Zt(e)?Gt(e):b(n.removed)}catch(i){qt(l,e)}}else qt(l,e)}en(Ue.afterSanitizeAttributes,e,null)},ln=function(e){let t=null;const n=Kt(e);for(en(Ue.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){en(Ue.uponSanitizeShadowNode,t,null),tn(t),an(t),Jt(t.content)&&ln(t.content);if((Ae?Ae(t):t.nodeType)===ce){const e=be?be(t):t.shadowRoot;Jt(e)&&(sn(e),ln(e))}}en(Ue.afterSanitizeShadowDOM,e,null)},sn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){ln(e.shadow);continue}const n=e.node,o=(Ae?Ae(n):n.nodeType)===ce,r=ge?ge(n):n.childNodes;if(r)for(let i=r.length-1;i>=0;--i)t.push({node:r[i],shadow:null});if(o){const e=Se?Se(n):null;if("string"==typeof e&&"template"===Ut(e)){const e=n.content;Jt(e)&&t.push({node:e,shadow:null})}}if(o){const e=be?be(n):n.shadowRoot;Jt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,i=null,a=null,l=null;if(Ct=!e,Ct&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Qt(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return O(e);case"boolean":return C(e);case"bigint":return k?k(e):"0";case"symbol":return D?D(e):"Symbol()";case"undefined":default:return I(e);case"function":case"object":{if(null===e)return I(e);const t=e,n=j(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:I(e)}return I(e)}}}(e)))throw M("dirty is not a string, aborting");if(!n.isSupported)return e;st||jt(t),n.removed=[];const s=yt&&"string"!=typeof e&&Qt(e);if(s){const t=Se?Se(e):e.nodeName;if("string"==typeof t){const e=Ut(t);if(!$e[e]||Je[e])throw M("root node is forbidden and cannot be sanitized in-place")}if(Zt(e))throw M("root node is clobbered and cannot be sanitized in-place");try{sn(e)}catch(d){throw Yt(e),d}}else if(Qt(e))o=Xt("\x3c!----\x3e"),i=o.ownerDocument.importNode(e,!0),i.nodeType===ce&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i),sn(i);else{if(!ut&&!it&&!lt&&-1===e.indexOf("<"))return xe&&pt?Oe(e):e;if(o=Xt(e),!o)return ut?null:pt?we:""}o&&ct&&Gt(o.firstChild);const c=Kt(s?e:o);try{for(;a=c.nextNode();)tn(a),an(a),Jt(a.content)&&ln(a.content)}catch(d){throw s&&Yt(e),d}if(s)return g(n.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();(Ae?Ae(e):e.nodeType)===ce&&$t(e);const n=ge?ge(e):e.childNodes;if(n)for(let o=n.length-1;o>=0;--o)t.push(n[o])}}(e.element)}),it&&Vt(e),e;if(ut){if(it&&Vt(o),dt)for(l=Le.call(o.ownerDocument);o.firstChild;)l.appendChild(o.firstChild);else l=o;return(Ke.shadowroot||Ke.shadowrootmode)&&(l=ze.call(r,l,!0)),l}let u=lt?o.outerHTML:o.innerHTML;return lt&&$e["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&L(le,o.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+u),it&&g([Pe,Fe,He],e=>{u=E(u,e," ")}),xe&&pt?Oe(u):u},n.setConfig=function(){jt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),st=!0},n.clearConfig=function(){Pt=null,st=!1,xe=ve,we=""},n.isValidAttribute=function(e,t,n){Pt||jt({});const o=Ut(e),r=Ut(t);return nn(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&T(Ue[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=y(Ue[e],t);return-1===n?void 0:A(Ue[e],n,1)[0]}return b(Ue[e])},n.removeHooks=function(e){Ue[e]=[]},n.removeAllHooks=function(){Ue={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function ge(e){const t=[document.documentElement,document.body,...Array.from(document.querySelectorAll(["rai-widget","rai-custom-widget","rai-channel-widget","rai-store-widget","rai-milestone-widget","rai-social-widget","rai-currency-widget","rai-referral-widget",".rai-widget-root",'[data-rai-widget-root="true"]'].join(",")))].filter(Boolean);for(const n of t){const t=getComputedStyle(n).getPropertyValue(e).trim();if(t)return t}}he.addHook("afterSanitizeAttributes",e=>{"A"===e.tagName&&"_blank"===e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer")});const ye=e=>{if(!e)return;if(/^(#|rgb|hsl)/i.test(e))return e;if(/^--[a-z0-9-]+$/i.test(e)){return ge(e)||`var(${e})`}const t=e.match(/^var\((--[a-z0-9-]+)\)$/i);if(t){return ge(t[1])||e}};function be(e,t,n){const o=document.createElement(e);if(Object.assign(o.style,t),n)for(const r of Object.keys(n))o.setAttribute(r,n[r]);return o}function Te(e){return"left"===e||"top"===e?"flex-start":"right"===e||"bottom"===e?"flex-end":"center"}function Ae(e,t){var n;const o=[null==(n=e.cta)?void 0:n.style,e.cta,e.ctaStyle];for(const r of o)for(const e of t){const t=null==r?void 0:r[e];if(t)return t}}function Se(e,t){var n,o,r,i,a,l,s,c,u,d,p,f,m;const h=e.placement||{},g=h.mode||"overlay",y=h.position||"top",b=String(h.zIndex||2147483e3),T=function(e){var t,n;return"image"===e.type&&Boolean((null==(t=e.image)?void 0:t.desktopUrl)||(null==(n=e.image)?void 0:n.mobileUrl))}(e),A=T?"transparent":ye(null==(n=e.style)?void 0:n.backgroundColor)||"#1f2024",S=ye(null==(o=e.style)?void 0:o.color)||"#ffffff",x="overlay"===g||"popup"===g,v=Ae(e,["position"])||"center",w=Te(null==(r=e.image)?void 0:r.horizontalAlignment),E=Te(null==(i=e.image)?void 0:i.verticalAlignment),_=(null==(a=e.image)?void 0:a.horizontalAlignment)||"center",N=(null==(l=e.image)?void 0:l.verticalAlignment)||"center",O=be("div",{boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"12px",lineHeight:"1.35",background:A,color:S,borderRadius:x&&!T?"6px":"0",boxShadow:x&&!T?"0 8px 24px rgba(0,0,0,0.22)":"none",padding:T?"0":x?"12px 24px":"8px 16px",display:"flex",alignItems:T?E:"flex-start",justifyContent:"center",gap:T?"4px":"16px"});if(O.setAttribute("role",x?"dialog":"region"),O.setAttribute("aria-label","community banner"),O.setAttribute("data-renderer-version","sdk-banner-preview-layout"),x)if(Object.assign(O.style,{position:"fixed",left:"50%",width:"fit-content",maxWidth:T?"min(85vw, 700px)":"min(700px, 80vw)",height:"auto",minHeight:T?"0":"80px",maxHeight:"calc(100vh - 300px)",overflowY:"auto",zIndex:b}),T){const e=[];"left"===_?O.style.left="24px":"right"===_?(O.style.left="",O.style.right="24px"):(O.style.left="50%",e.push("-50%")),"top"===N?O.style.top="10px":"bottom"===N?O.style.bottom="24px":(O.style.top="50%",e.push("-50%")),2===e.length?O.style.transform=`translate(${e[0]}, ${e[1]})`:1===e.length&&"center"===_?O.style.transform=`translateX(${e[0]})`:1===e.length?O.style.transform=`translateY(${e[0]})`:O.style.transform=""}else"bottom"===y?(O.style.bottom="24px",O.style.transform="translateX(-50%)"):"center"===y?(O.style.top="50%",O.style.transform="translate(-50%, -50%)"):(O.style.top="10px",O.style.transform="translateX(-50%)");else Object.assign(O.style,{position:"relative",width:"100%",zIndex:b});const C=be("div",{display:"flex",width:T?"auto":"100%",maxWidth:"100%",flexDirection:"column",gap:T?"0":"12px",overflow:"hidden"}),k=be("div",{display:"flex",width:"100%",justifyContent:T?w:"space-between",alignItems:T?E:"flex-start",gap:"12px"}),D=be("div",{width:T?"auto":"100%",maxWidth:"100%",overflow:"hidden",wordBreak:"break-word"}),R=(null==(s=e.image)?void 0:s.desktopUrl)||(null==(c=e.image)?void 0:c.mobileUrl);if(T&&R){const t=null==(u=e.image)?void 0:u.linkUrl,n=null==(d=e.image)?void 0:d.openInNewTab,o=be("img",{display:"block",maxWidth:"100%",maxHeight:"240px",height:"auto",objectFit:"contain",cursor:t?"pointer":"",borderRadius:"rounded"===(null==(p=e.image)?void 0:p.cornerRadius)?"8px":"0"},{src:R,alt:e.title||"banner"});t&&o.addEventListener("click",()=>{n?window.open(t,"_blank","noopener,noreferrer"):window.location.href=t}),D.appendChild(o)}else D.innerHTML=(L=e.text)?he.sanitize(L,{ALLOWED_TAGS:["p","strong","em","u","img","span","div","a","br"],ALLOWED_ATTR:["style","src","class","href","target","alt","width","height"],ADD_ATTR:["target"],ALLOW_DATA_ATTR:!1}):"",(I=D).querySelectorAll("p").forEach(e=>{e.style.margin="0"}),I.querySelectorAll("strong").forEach(e=>{e.style.fontWeight="700"}),I.querySelectorAll("em").forEach(e=>{e.style.fontStyle="italic"}),I.querySelectorAll("u").forEach(e=>{e.style.textDecoration="underline"}),I.querySelectorAll("a").forEach(e=>{e.style.color="#3b82f6",e.style.textDecoration="underline","_blank"===e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer")}),I.querySelectorAll("img").forEach(e=>{e.style.maxWidth="100%",e.style.height="auto"});var I,L,M;if(!T&&(null==(f=e.cta)?void 0:f.enabled)){const n=be("button",{cursor:"pointer",border:"none",borderRadius:"4px",height:"36px",minHeight:"36px",padding:"0 16px",fontSize:"12px",fontWeight:"600",lineHeight:"20px",background:ye(Ae(e,["backgroundColor","buttonColor","aColor"]))||ye(null==(m=e.style)?void 0:m.backgroundColor)||"#2f6df6",color:ye(Ae(e,["textColor","color"]))||"#ffffff",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center"});if(n.type="button",n.textContent=e.cta.label||"CTA Button",n.addEventListener("click",t.onCtaClick),"inline"===v){k.appendChild(D);const e=be("div",{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",flexShrink:"0"});e.appendChild(n),k.appendChild(e),C.appendChild(k)}else{k.appendChild(D),C.appendChild(k);const e=be("div",{display:"flex",width:"100%",justifyContent:(M=v,"left"===M?"flex-start":"right"===M?"flex-end":"center")});e.appendChild(n),C.appendChild(e)}}else k.appendChild(D),C.appendChild(k);O.appendChild(C);const z=be("button",{marginTop:T?"0":"8px",width:"20px",minWidth:"20px",height:"20px",cursor:"pointer",border:"none",borderRadius:"50%",background:"rgba(0,0,0,0.25)",color:S,fontSize:"16px",lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",flexShrink:"0"});return z.type="button",z.setAttribute("aria-label","dismiss banner"),z.innerHTML="×",z.addEventListener("click",t.onDismiss),O.appendChild(z),O}function xe(){try{if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function ve(e){if(e)try{(new Image).src=e}catch{}}const we={LOCAL:"http://localhost:1335",SGTR:"https://api-v2.genesiv.org",STG:"https://staging-api-v2.genesiv.org",GEN:"https://api-v2.returning.ai"};class Ee extends HTMLElement{constructor(){super(...arguments),n(this,"rendered",null),n(this,"impressionFired",!1)}connectedCallback(){this.init()}disconnectedCallback(){this.cleanup()}resolveApiUrl(){const e=this.getAttribute("api-url")||this.getAttribute("data-api-url");if(e)return e.replace(/\/+$/,"");const t=this.getAttribute("domain-key")||this.getAttribute("data-domain-key");return t&&we[t]?we[t]:we.LOCAL}device(){const e=window.innerWidth;return e<640?"mobile":e<1024?"tablet":"desktop"}async init(){var e;try{const t=this.getAttribute("community-id")||this.getAttribute("data-community-id");if(!t)return void console.error('[rai-banner] missing required "community-id" attribute');const n=this.resolveApiUrl(),o=this.getAttribute("storage-prefix")||this.getAttribute("data-storage-prefix")||"returning-ai-widget",r=this.getAttribute("surface")||"sdk",i=function(e,t){const n=`${t}-rai-banner-visitor-${e}`;try{let e=localStorage.getItem(n);return e||(e=xe(),localStorage.setItem(n,e)),e}catch{return xe()}}(t,o),a=this.getAttribute("page-path")||window.location.pathname,l=this.getAttribute("page-hostname")||window.location.hostname,s=this.getAttribute("page-url")||window.location.href,c=this.getAttribute("embed-token")||this.getAttribute("data-embed-token")||void 0,u=await async function(e,t){try{const n=await fetch(`${e}/v2/api/banner-sdk/eligible`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),o=await n.json();return o&&o.meta&&"success"===o.meta.status?o.data||{banner:null}:{banner:null,reason:o&&o.detail||"request_failed"}}catch{return{banner:null,reason:"network_error"}}}(n,{communityId:t,surface:r,embedToken:c,page:{url:s,hostname:l,path:a},viewport:{width:window.innerWidth,height:window.innerHeight,device:this.device()},identifier:{type:"anonymous_session",value:i}}),d=u.banner;if(!d)return void this.dispatch("rai-banner-empty",{reason:u.reason});if("hide"===(null==(e=d.placement)?void 0:e.mobileBehavior)&&"mobile"===this.device())return void this.dispatch("rai-banner-empty",{reason:"hidden_on_mobile"});this.mount(d)}catch(t){this.dispatch("rai-banner-error",{error:null==t?void 0:t.message})}}mount(e){var t,n,o,r,i,a,l;if(!this.isConnected)return;const s=Se(e,{onCtaClick:()=>{var t,n,o;ve(null==(t=e.tracking)?void 0:t.clickUrl),this.dispatch("rai-banner-click",{bannerId:e.id});const r=null==(n=e.cta)?void 0:n.url;r&&((null==(o=e.cta)?void 0:o.openInNewTab)?window.open(r,"_blank","noopener,noreferrer"):window.location.href=r)},onDismiss:()=>{var t;ve(null==(t=e.tracking)?void 0:t.dismissUrl),this.dispatch("rai-banner-dismiss",{bannerId:e.id}),this.cleanup()}});this.rendered=s;if("overlay"===(null==(t=e.placement)?void 0:t.mode)||"popup"===(null==(n=e.placement)?void 0:n.mode))document.body.appendChild(s);else{const t=null==(o=e.placement)?void 0:o.targetSelector,n=t?document.querySelector(t):null;if(n){const t=(null==(r=e.placement)?void 0:r.insertion)||"append";"prepend"===t?n.insertBefore(s,n.firstChild):"before"===t?null==(i=n.parentNode)||i.insertBefore(s,n):"after"===t?null==(a=n.parentNode)||a.insertBefore(s,n.nextSibling):n.appendChild(s)}else this.style.display="block",this.style.width="100%",this.appendChild(s)}this.impressionFired||(this.impressionFired=!0,ve(null==(l=e.tracking)?void 0:l.impressionUrl),this.dispatch("rai-banner-impression",{bannerId:e.id}))}cleanup(){this.rendered&&this.rendered.parentNode&&this.rendered.parentNode.removeChild(this.rendered),this.rendered=null}dispatch(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}}function _e(){var e;const t=((null==(e=document.currentScript)?void 0:e.hasAttribute("data-rai-banner"))?document.currentScript:null)||document.querySelector("script[data-rai-banner]");if(!t)return;if(!t.getAttribute("data-community-id"))return;if(document.querySelector("rai-banner"))return;const n=document.createElement("rai-banner"),o={"data-community-id":"community-id","data-api-url":"api-url","data-domain-key":"domain-key","data-surface":"surface","data-storage-prefix":"storage-prefix","data-page-path":"page-path","data-embed-token":"embed-token"};for(const[r,i]of Object.entries(o)){const e=t.getAttribute(r);e&&n.setAttribute(i,e)}document.body.appendChild(n)}return console.log("[rai-banner] v1.6.0"),"undefined"==typeof customElements||customElements.get("rai-banner")||customElements.define("rai-banner",Ee),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",_e):_e(),e.BannerRuntime=Ee,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|