/*! * webchat.js v3.1.0 * https://github.com/Cognigy/WebchatWidget/tree/v3.1.0 * https://github.com/Cognigy/WebchatWidget/tree/v3.1.0/OSS_LICENSES.txt */(()=>{var e,t,n={1510:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shouldForceWebsockets=void 0;const r=(0,n(8809).detect)();t.shouldForceWebsockets=()=>{switch(r.name){case"ie":case"ios":case"ios-webview":case"crios":case"safari":case"chrome":case"chromium-webview":case"node":return console.log('[SocketClient] Enabling "forceWebsockets" by default for compatibility with this environment.'),!0;default:return!0}}},2166:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function o(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.SocketClient=void 0;const a=n(8657),i=n(5325),o=n(4845),s=n(1510);class l extends a.EventEmitter{static createDefaultSocketOptions(){return{channel:"socket-client",userId:`user-${(0,o.v4)()}`,sessionId:`session-${(0,o.v4)()}`,testMode:!1,expiresIn:null,forceWebsockets:!1,disableWebsockets:!1,interval:1e4,passthroughIP:null,reconnection:!0,reconnectionLimit:5,enableInnerSocketHandshake:!1,resetFlow:!1}}static completeSocketOptions(e={}){const t=Object.assign(Object.assign({},l.createDefaultSocketOptions()),e);return e.forceWebsockets||e.disableWebsockets||(t.forceWebsockets=(0,s.shouldForceWebsockets)()),t}constructor(e,t,n){super(),this.messageBuffer=[],this.socketUrl=e,this.socketURLToken=t,this.socketOptions=l.completeSocketOptions(n),this.reconnectCounter=0,this.updateLastUsed()}resetReconnectionCounter(){this.reconnectCounter=0}registerReconnectionAttempt(){this.reconnectCounter++,console.log("[SocketClient] Trying to reconnect"),this.shouldStopReconnecting()&&(console.log("[SocketClient] Reconnection attempts limit reached. Giving up."),this.emit("socket/error",{type:"RECONNECTION_LIMIT"}))}shouldStopReconnecting(){const{reconnectionLimit:e}=this.socketOptions;return 0!==e&&e<=this.reconnectCounter}flushMessageBuffer(){if(this.messageBuffer.length>0)if(this.connected){console.log("[SocketClient] Starting to send your buffered messages...");for(let e of this.messageBuffer)this.sendMessage(e.text,e.data);console.log(`[SocketClient] Finished sending ${this.messageBuffer.length} buffered messages.`),this.messageBuffer=[]}else console.log("[SocketClient] Could not send your buffered messages because we are not connected")}setupReconnectInterval(){this.socketReconnectInterval||(this.socketReconnectInterval=setInterval((()=>r(this,void 0,void 0,(function*(){if(!this.connected&&!this.shouldStopReconnecting()){this.registerReconnectionAttempt();try{const e=!0;yield this.connect(e),console.log("[SocketClient] Successfully reconnected.")}catch(e){console.error(`[SocketClient] Failed to reconnect, error was: ${JSON.stringify(e)}`)}}}))),this.socketOptions.interval))}updateLastUsed(){this.lastUsed=Date.now()}get connected(){return!!this.socket&&this.socket.connected}get expired(){return null!==this.socketOptions.expiresIn&&Date.now()-this.lastUsed>this.socketOptions.expiresIn}connect(e=!1){return r(this,void 0,void 0,(function*(){const e=new URL(this.socketUrl),t={path:e.pathname&&"/"!==e.pathname?e.pathname+"/socket.io":null,reconnection:!1,upgrade:!0,transports:["polling","websocket"],autoConnect:!1};this.socketOptions.forceWebsockets?t.transports=["websocket"]:this.socketOptions.disableWebsockets&&(t.transports=["polling"],t.upgrade=!1),this.socketOptions.enableInnerSocketHandshake?t.query={handshake:"true"}:t.query={sessionId:encodeURIComponent(this.socketOptions.sessionId),urlToken:encodeURIComponent(this.socketURLToken),userId:encodeURIComponent(this.socketOptions.userId),testMode:encodeURIComponent(this.socketOptions.testMode?"true":"false")};const n=(0,i.io)(e.origin,t);return["connect","connect_error","connect_timeout","error","disconnect","reconnect","reconnect_attempt","reconnecting","reconnect_error","reconnect_failed","ping","pong"].forEach((e=>{n.on(e,(t=>{this.emit(`socket/${e}`,t)}))})),n.on("exception",(e=>this.emit("exception",e))),n.on("typingStatus",(e=>this.emit("typingStatus",e))),n.on("finalPing",(e=>this.emit("finalPing",e))),n.on("output",(e=>{if(e&&"error"===e.type)return this.emit("error",e.data.error);if(e&&"output"===e.type){let t=e.data;this.emit("output",t)}e&&"finalPing"===e.type&&this.emit("finalPing",e.data)})),yield new Promise(((e,t)=>{n.on("connect_error",(()=>t(new Error("[SocketClient] Error connecting")))),n.on("connect_timeout",(()=>t(new Error("[SocketClient] Error connecting")))),this.socketOptions.enableInnerSocketHandshake&&n.on("handshake",(t=>{const{userId:n,sessionId:r,testMode:a}=this.socketOptions,i={userId:n,sessionId:r,urlToken:this.socketURLToken,testMode:a};console.log("[SocketClient] completing session handshake"),t(i),e()})),n.on("connect",(()=>{this.socket=n,this.flushMessageBuffer(),this.socketOptions.reconnection&&this.setupReconnectInterval(),this.socketOptions.enableInnerSocketHandshake||e()})),n.connect()})),console.log("[SocketClient] connection established"),this}))}switchSession(e){return r(this,void 0,void 0,(function*(){return this.disconnect(),this.socketOptions.sessionId=e||`session-${(0,o.v4)()}`,this.reconnectCounter=0,this.updateLastUsed(),yield this.connect(),console.log("[SocketClient] switched session"),this}))}disconnect(){return clearInterval(this.socketReconnectInterval),this.socketReconnectInterval=null,this.socket&&(this.socket.disconnect(),this.socket=null),this}sendMessage(e,t){return this.connected?(this.resetReconnectionCounter(),this.updateLastUsed(),this.socket.emit("processInput",{URLToken:this.socketURLToken,userId:this.socketOptions.userId,sessionId:this.socketOptions.sessionId,channel:this.socketOptions.channel,source:"device",passthroughIP:this.socketOptions.passthroughIP,resetFlow:!!this.socketOptions.resetFlow,text:e,data:t})):(this.messageBuffer.push({text:e,data:t}),console.log("[SocketClient] Unable to directly send your message since we are not connected. Your message will be buffered and sent later on.")),this}}t.SocketClient=l},2715:(e,t)=>{var n; /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,a,i){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(r)for(var s=0;s0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),a&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=a):u[4]="".concat(a)),t.push(u))}},t}},3051:e=>{"use strict";e.exports=function(e){return e[1]}},1636:(e,t)=>{ /*! * Converts CSS stylesheets between left-to-right and right-to-left. * https://github.com/cssjanus/cssjanus * * Copyright 2008 Google Inc. * Copyright 2010 Trevor Parscal */ var n;function r(e,t){var n=[],r=0;function a(e){return n.push(e),t}function i(){return n[r++]}return{tokenize:function(t){return t.replace(e,a)},detokenize:function(e){return e.replace(new RegExp("("+t+")","g"),i)}}}n=new function(){var e="`TMP`",t="[^\\u0020-\\u007e]",n="(?:[0-9]*\\.[0-9]+|[0-9]+)",a="direction\\s*:\\s*",i="['\"]?\\s*",o="(^|[^a-zA-Z])",s="\\/\\*\\!?\\s*@noflip\\s*\\*\\/",l="(?:(?:(?:\\\\[0-9a-f]{1,6})(?:\\r\\n|\\s)?)|\\\\[^\\r\\n\\f0-9a-f])",d="(?:[_a-z0-9-]|"+t+"|"+l+")",u=n+"(?:\\s*(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)|"+("-?"+("(?:[_a-z]|"+t+"|"+l+")")+d+"*")+")?",c="((?:-?"+u+")|(?:inherit|auto))",p="(#?"+d+"+|(?:rgba?|hsla?)\\([ \\d.,%-]+\\))",h="(?:[!#$%&*-~]|"+t+"|"+l+")*?",m="(?![a-zA-Z])",f="(?!("+d+"|\\r?\\n|\\s|#|\\:|\\.|\\,|\\+|>|\\(|\\)|\\[|\\]|=|\\*=|~=|\\^=|'[^']*'])*?{)",g="(?!"+h+i+"\\))",y="(?="+h+i+"\\))",A="(\\s*(?:!important\\s*)?[;}])",v=new RegExp("`TMP`","g"),w=new RegExp("\\/\\*[^*]*\\*+([^\\/*][^*]*\\*+)*\\/","gi"),_=new RegExp("("+s+f+"[^;}]+;?)","gi"),b=new RegExp("("+s+"[^\\}]*?})","gi"),M=new RegExp("("+a+")ltr","gi"),k=new RegExp("("+a+")rtl","gi"),L=new RegExp(o+"(left)"+m+g+f,"gi"),D=new RegExp(o+"(right)"+m+g+f,"gi"),Y=new RegExp(o+"(left)"+y,"gi"),E=new RegExp(o+"(right)"+y,"gi"),C=new RegExp(o+"(ltr)"+y,"gi"),S=new RegExp(o+"(rtl)"+y,"gi"),T=new RegExp(o+"([ns]?)e-resize","gi"),x=new RegExp(o+"([ns]?)w-resize","gi"),P=new RegExp("((?:margin|padding|border-width)\\s*:\\s*)"+c+"(\\s+)"+c+"(\\s+)"+c+"(\\s+)"+c+A,"gi"),I=new RegExp("((?:-color|border-style)\\s*:\\s*)"+p+"(\\s+)"+p+"(\\s+)"+p+"(\\s+)"+p+A,"gi"),B=new RegExp("(background(?:-position)?\\s*:\\s*(?:[^:;}\\s]+\\s+)*?)("+u+")","gi"),O=new RegExp("(background-position-x\\s*:\\s*)(-?"+n+"%)","gi"),V=new RegExp("(border-radius\\s*:\\s*)"+c+"(?:(?:\\s+"+c+")(?:\\s+"+c+")?(?:\\s+"+c+")?)?(?:(?:(?:\\s*\\/\\s*)"+c+")(?:\\s+"+c+")?(?:\\s+"+c+")?(?:\\s+"+c+")?)?"+A,"gi"),j=new RegExp("(box-shadow\\s*:\\s*(?:inset\\s*)?)"+c,"gi"),R=new RegExp("(text-shadow\\s*:\\s*)"+c+"(\\s*)"+p,"gi"),H=new RegExp("(text-shadow\\s*:\\s*)"+p+"(\\s*)"+c,"gi"),F=new RegExp("(text-shadow\\s*:\\s*)"+c,"gi"),N=new RegExp("(transform\\s*:[^;}]*)(translateX\\s*\\(\\s*)"+c+"(\\s*\\))","gi"),q=new RegExp("(transform\\s*:[^;}]*)(translate\\s*\\(\\s*)"+c+"((?:\\s*,\\s*"+c+"){0,2}\\s*\\))","gi");function G(e,t,n){var r,a;return"%"===n.slice(-1)&&(-1!==(r=n.indexOf("."))?(a=n.length-r-2,n=(n=100-parseFloat(n)).toFixed(a)+"%"):n=100-parseFloat(n)+"%"),t+n}function W(e){switch(e.length){case 4:e=[e[1],e[0],e[3],e[2]];break;case 3:e=[e[1],e[0],e[1],e[2]];break;case 2:e=[e[1],e[0]];break;case 1:e=[e[0]]}return e.join(" ")}function z(e,t){var n=[].slice.call(arguments),r=n.slice(2,6).filter((function(e){return e})),a=n.slice(6,10).filter((function(e){return e})),i=n[10]||"";return t+(a.length?W(r)+" / "+W(a):W(r))+i}function U(e){return 0===parseFloat(e)?e:"-"===e[0]?e.slice(1):"-"+e}function Q(e,t,n){return t+U(n)}function Z(e,t,n,r,a){return t+n+U(r)+a}function J(e,t,n,r,a){return t+n+r+U(a)}return{transform:function(t,n){var a=new r(_,"`NOFLIP_SINGLE`"),i=new r(b,"`NOFLIP_CLASS`"),o=new r(w,"`COMMENT`");return t=o.tokenize(i.tokenize(a.tokenize(t.replace("`","%60")))),n.transformDirInUrl&&(t=t.replace(C,"$1"+e).replace(S,"$1ltr").replace(v,"rtl")),n.transformEdgeInUrl&&(t=t.replace(Y,"$1"+e).replace(E,"$1left").replace(v,"right")),t=t.replace(M,"$1"+e).replace(k,"$1ltr").replace(v,"rtl").replace(L,"$1"+e).replace(D,"$1left").replace(v,"right").replace(T,"$1$2"+e).replace(x,"$1$2e-resize").replace(v,"w-resize").replace(V,z).replace(j,Q).replace(R,J).replace(H,J).replace(F,Q).replace(N,Z).replace(q,Z).replace(P,"$1$2$3$8$5$6$7$4$9").replace(I,"$1$2$3$8$5$6$7$4$9").replace(B,G).replace(O,G),t=a.detokenize(i.detokenize(o.detokenize(t)))}}},e.exports?t.transform=function(e,t,r){var a;return"object"==typeof t?a=t:(a={},"boolean"==typeof t&&(a.transformDirInUrl=t),"boolean"==typeof r&&(a.transformEdgeInUrl=r)),n.transform(e,a)}:"undefined"!=typeof window&&(window.cssjanus=n)},7947:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))})),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(7238)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},7238:(e,t,n)=>{e.exports=function(e){function t(e){let n,a,i,o=null;function s(...e){if(!s.enabled)return;const r=s,a=Number(new Date),i=a-(n||a);r.diff=i,r.prev=n,r.curr=a,n=a,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,a)=>{if("%%"===n)return"%";o++;const i=t.formatters[a];if("function"==typeof i){const t=e[o];n=i.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=r,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(a!==t.namespaces&&(a=t.namespaces,i=t.enabled(e)),i),set:e=>{o=e}}),"function"==typeof t.init&&t.init(s),s}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function a(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(a),...t.skips.map(a).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?n-1:0),a=1;a/gm),J=g(/\${[\w\W]*}/gm),K=g(/^data-[\-\w.\u00B7-\uFFFF]/),X=g(/^aria-[\-\w]+$/),$=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ee=g(/^(?:\w+script|data):/i),te=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ne=g(/^html$/i),re=g(/^[a-z][.\w]*(-[.\w]+)+$/i),ae=function(){return"undefined"==typeof window?null:window},ie=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,a="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(a)&&(r=n.currentScript.getAttribute(a));var i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML:function(e){return e},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function oe(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ae(),n=function(e){return oe(e)};if(n.version="2.4.9",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,i=t.document,o=t.DocumentFragment,s=t.HTMLTemplateElement,l=t.Node,d=t.Element,u=t.NodeFilter,c=t.NamedNodeMap,p=void 0===c?t.NamedNodeMap||t.MozNamedAttrMap:c,h=t.HTMLFormElement,m=t.DOMParser,g=t.trustedTypes,y=d.prototype,A=O(y,"cloneNode"),v=O(y,"nextSibling"),w=O(y,"childNodes"),x=O(y,"parentNode");if("function"==typeof s){var P=i.createElement("template");P.content&&P.content.ownerDocument&&(i=P.content.ownerDocument)}var se=ie(g,r),le=se?se.createHTML(""):"",de=i,ue=de.implementation,ce=de.createNodeIterator,pe=de.createDocumentFragment,he=de.getElementsByTagName,me=r.importNode,fe={};try{fe=B(i).documentMode?i.documentMode:{}}catch(e){}var ge={};n.isSupported="function"==typeof x&&ue&&void 0!==ue.createHTMLDocument&&9!==fe;var ye,Ae,ve=Q,we=Z,_e=J,be=K,Me=X,ke=ee,Le=te,De=re,Ye=$,Ee=null,Ce=I({},[].concat(a(V),a(j),a(R),a(F),a(q))),Se=null,Te=I({},[].concat(a(G),a(W),a(z),a(U))),xe=Object.seal(Object.create(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}})),Pe=null,Ie=null,Be=!0,Oe=!0,Ve=!1,je=!0,Re=!1,He=!1,Fe=!1,Ne=!1,qe=!1,Ge=!1,We=!1,ze=!0,Ue=!1,Qe="user-content-",Ze=!0,Je=!1,Ke={},Xe=null,$e=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),et=null,tt=I({},["audio","video","img","source","image","track"]),nt=null,rt=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),at="http://www.w3.org/1998/Math/MathML",it="http://www.w3.org/2000/svg",ot="http://www.w3.org/1999/xhtml",st=ot,lt=!1,dt=null,ut=I({},[at,it,ot],L),ct=["application/xhtml+xml","text/html"],pt="text/html",ht=null,mt=i.createElement("form"),ft=function(e){return e instanceof RegExp||e instanceof Function},gt=function(t){ht&&ht===t||(t&&"object"===e(t)||(t={}),t=B(t),ye=ye=-1===ct.indexOf(t.PARSER_MEDIA_TYPE)?pt:t.PARSER_MEDIA_TYPE,Ae="application/xhtml+xml"===ye?L:k,Ee="ALLOWED_TAGS"in t?I({},t.ALLOWED_TAGS,Ae):Ce,Se="ALLOWED_ATTR"in t?I({},t.ALLOWED_ATTR,Ae):Te,dt="ALLOWED_NAMESPACES"in t?I({},t.ALLOWED_NAMESPACES,L):ut,nt="ADD_URI_SAFE_ATTR"in t?I(B(rt),t.ADD_URI_SAFE_ATTR,Ae):rt,et="ADD_DATA_URI_TAGS"in t?I(B(tt),t.ADD_DATA_URI_TAGS,Ae):tt,Xe="FORBID_CONTENTS"in t?I({},t.FORBID_CONTENTS,Ae):$e,Pe="FORBID_TAGS"in t?I({},t.FORBID_TAGS,Ae):{},Ie="FORBID_ATTR"in t?I({},t.FORBID_ATTR,Ae):{},Ke="USE_PROFILES"in t&&t.USE_PROFILES,Be=!1!==t.ALLOW_ARIA_ATTR,Oe=!1!==t.ALLOW_DATA_ATTR,Ve=t.ALLOW_UNKNOWN_PROTOCOLS||!1,je=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Re=t.SAFE_FOR_TEMPLATES||!1,He=t.WHOLE_DOCUMENT||!1,qe=t.RETURN_DOM||!1,Ge=t.RETURN_DOM_FRAGMENT||!1,We=t.RETURN_TRUSTED_TYPE||!1,Ne=t.FORCE_BODY||!1,ze=!1!==t.SANITIZE_DOM,Ue=t.SANITIZE_NAMED_PROPS||!1,Ze=!1!==t.KEEP_CONTENT,Je=t.IN_PLACE||!1,Ye=t.ALLOWED_URI_REGEXP||Ye,st=t.NAMESPACE||ot,xe=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&ft(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(xe.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&ft(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(xe.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(xe.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Re&&(Oe=!1),Ge&&(qe=!0),Ke&&(Ee=I({},a(q)),Se=[],!0===Ke.html&&(I(Ee,V),I(Se,G)),!0===Ke.svg&&(I(Ee,j),I(Se,W),I(Se,U)),!0===Ke.svgFilters&&(I(Ee,R),I(Se,W),I(Se,U)),!0===Ke.mathMl&&(I(Ee,F),I(Se,z),I(Se,U))),t.ADD_TAGS&&(Ee===Ce&&(Ee=B(Ee)),I(Ee,t.ADD_TAGS,Ae)),t.ADD_ATTR&&(Se===Te&&(Se=B(Se)),I(Se,t.ADD_ATTR,Ae)),t.ADD_URI_SAFE_ATTR&&I(nt,t.ADD_URI_SAFE_ATTR,Ae),t.FORBID_CONTENTS&&(Xe===$e&&(Xe=B(Xe)),I(Xe,t.FORBID_CONTENTS,Ae)),Ze&&(Ee["#text"]=!0),He&&I(Ee,["html","head","body"]),Ee.table&&(I(Ee,["tbody"]),delete Pe.tbody),f&&f(t),ht=t)},yt=I({},["mi","mo","mn","ms","mtext"]),At=I({},["foreignobject","desc","title","annotation-xml"]),vt=I({},["title","style","font","a","script"]),wt=I({},j);I(wt,R),I(wt,H);var _t=I({},F);I(_t,N);var bt=function(e){var t=x(e);t&&t.tagName||(t={namespaceURI:st,tagName:"template"});var n=k(e.tagName),r=k(t.tagName);return!!dt[e.namespaceURI]&&(e.namespaceURI===it?t.namespaceURI===ot?"svg"===n:t.namespaceURI===at?"svg"===n&&("annotation-xml"===r||yt[r]):Boolean(wt[n]):e.namespaceURI===at?t.namespaceURI===ot?"math"===n:t.namespaceURI===it?"math"===n&&At[r]:Boolean(_t[n]):e.namespaceURI===ot?!(t.namespaceURI===it&&!At[r])&&!(t.namespaceURI===at&&!yt[r])&&!_t[n]&&(vt[n]||!wt[n]):!("application/xhtml+xml"!==ye||!dt[e.namespaceURI]))},Mt=function(e){M(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=le}catch(t){e.remove()}}},kt=function(e,t){try{M(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){M(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Se[e])if(qe||Ge)try{Mt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Lt=function(e){var t,n;if(Ne)e=""+e;else{var r=D(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===ye&&st===ot&&(e=''+e+"");var a=se?se.createHTML(e):e;if(st===ot)try{t=(new m).parseFromString(a,ye)}catch(e){}if(!t||!t.documentElement){t=ue.createDocument(st,"template",null);try{t.documentElement.innerHTML=lt?le:a}catch(e){}}var o=t.body||t.documentElement;return e&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),st===ot?he.call(t,He?"html":"body")[0]:He?t.documentElement:o},Dt=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null,!1)},Yt=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Et=function(t){return"object"===e(l)?t instanceof l:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Ct=function(e,t,r){ge[e]&&_(ge[e],(function(e){e.call(n,t,r,ht)}))},St=function(e){var t;if(Ct("beforeSanitizeElements",e,null),Yt(e))return Mt(e),!0;if(S(/[\u0080-\uFFFF]/,e.nodeName))return Mt(e),!0;var r=Ae(e.nodeName);if(Ct("uponSanitizeElement",e,{tagName:r,allowedTags:Ee}),e.hasChildNodes()&&!Et(e.firstElementChild)&&(!Et(e.content)||!Et(e.content.firstElementChild))&&S(/<[/\w]/g,e.innerHTML)&&S(/<[/\w]/g,e.textContent))return Mt(e),!0;if("select"===r&&S(/