@v-tilt/browser 1.12.0 → 1.13.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/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.chat.js +2 -0
- package/dist/array.chat.js.map +1 -0
- package/dist/array.chat.no-external.js +2 -0
- package/dist/array.chat.no-external.js.map +1 -0
- package/dist/array.full.chat.js +2 -0
- package/dist/array.full.chat.js.map +1 -0
- package/dist/array.full.chat.no-external.js +2 -0
- package/dist/array.full.chat.no-external.js.map +1 -0
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +2 -0
- package/dist/array.full.no-external.js.map +1 -0
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/entrypoints/all-external-dependencies.d.ts +10 -3
- package/dist/entrypoints/array.chat.d.ts +10 -0
- package/dist/entrypoints/array.chat.no-external.d.ts +6 -0
- package/dist/entrypoints/array.full.chat.d.ts +13 -0
- package/dist/entrypoints/array.full.chat.no-external.d.ts +7 -0
- package/dist/entrypoints/array.full.d.ts +5 -9
- package/dist/entrypoints/array.full.no-external.d.ts +12 -0
- package/dist/entrypoints/module.chat.es.d.ts +7 -0
- package/dist/entrypoints/module.full.chat.es.d.ts +12 -0
- package/dist/entrypoints/module.full.es.d.ts +12 -0
- package/dist/entrypoints/module.no-external.es.d.ts +1 -0
- package/dist/extensions/chat/bubble-drag.d.ts +20 -5
- package/dist/extensions/chat/chat-wrapper.d.ts +8 -2
- package/dist/extensions/chat/chat.d.ts +21 -221
- package/dist/extensions/chat/controller/__tests__/fakes/ably-realtime-fake.d.ts +84 -0
- package/dist/extensions/chat/controller/ably-client.d.ts +160 -0
- package/dist/extensions/chat/controller/ably-handlers.d.ts +95 -0
- package/dist/extensions/chat/controller/ably-token.d.ts +67 -0
- package/dist/extensions/chat/controller/chat-controller.d.ts +194 -0
- package/dist/extensions/chat/controller/message-delivery-status.d.ts +6 -0
- package/dist/extensions/chat/controller/message-order.d.ts +12 -0
- package/dist/extensions/chat/controller/message-stream.d.ts +49 -0
- package/dist/extensions/chat/lib/bubble-offset.d.ts +18 -0
- package/dist/extensions/chat/lib/merge-chat-config.d.ts +3 -0
- package/dist/extensions/chat/normalize-send-content.d.ts +2 -0
- package/dist/extensions/chat/outbox/message-delivery.d.ts +17 -0
- package/dist/extensions/chat/outbox/message-outbox.d.ts +57 -0
- package/dist/extensions/chat/store/chat-store.d.ts +122 -0
- package/dist/extensions/chat/types.d.ts +1 -19
- package/dist/extensions/chat/ui/ChannelItem.d.ts +12 -0
- package/dist/extensions/chat/ui/ChannelListView.d.ts +14 -0
- package/dist/extensions/chat/ui/ChatBubble.d.ts +14 -0
- package/dist/extensions/chat/ui/ChatHeader.d.ts +13 -0
- package/dist/extensions/chat/ui/ChatPanel.d.ts +14 -0
- package/dist/extensions/chat/ui/ChatRoot.d.ts +31 -0
- package/dist/extensions/chat/ui/ClosedBanner.d.ts +7 -0
- package/dist/extensions/chat/ui/ConnectionBanner.d.ts +32 -0
- package/dist/extensions/chat/ui/ConversationView.d.ts +14 -0
- package/dist/extensions/chat/ui/MessageBubble.d.ts +25 -0
- package/dist/extensions/chat/ui/MessageInput.d.ts +14 -0
- package/dist/extensions/chat/ui/MessageList.d.ts +19 -0
- package/dist/extensions/chat/ui/NewMessagesPill.d.ts +13 -0
- package/dist/extensions/chat/ui/Skeletons.d.ts +14 -0
- package/dist/extensions/chat/ui/TypingBubble.d.ts +23 -0
- package/dist/extensions/chat/ui/TypingIndicator.d.ts +12 -0
- package/dist/extensions/chat/ui/WidgetSlot.d.ts +20 -0
- package/dist/extensions/chat/ui/hooks/use-auto-mark-read.d.ts +18 -0
- package/dist/extensions/chat/ui/hooks/use-scroll-preservation.d.ts +33 -0
- package/dist/extensions/chat/ui/icons.d.ts +18 -0
- package/dist/extensions/chat/ui/message-render.d.ts +18 -0
- package/dist/extensions/chat/ui/shadow-styles.d.ts +13 -0
- package/dist/extensions/chat/ui/utils/mobile-body-scroll-lock.d.ts +14 -0
- package/dist/extensions/chat/widget-registry.d.ts +21 -5
- package/dist/extensions/chat/widgets/collect-email.d.ts +4 -2
- package/dist/extensions/chat/widgets/escalate-to-human.d.ts +2 -1
- package/dist/external-scripts-loader.js +1 -1
- package/dist/external-scripts-loader.js.map +1 -1
- package/dist/feature.d.ts +1 -0
- package/dist/lib/merge-vtilt-config.d.ts +9 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.chat.d.ts +1788 -0
- package/dist/module.chat.js +2 -0
- package/dist/module.chat.js.map +1 -0
- package/dist/module.d.ts +48 -3
- package/dist/module.full.chat.d.ts +1792 -0
- package/dist/module.full.chat.js +2 -0
- package/dist/module.full.chat.js.map +1 -0
- package/dist/module.full.d.ts +1793 -0
- package/dist/module.full.js +2 -0
- package/dist/module.full.js.map +1 -0
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +48 -3
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/snippet-stub-methods.d.ts +14 -0
- package/dist/utils/globals.d.ts +53 -27
- package/dist/utils/index.d.ts +8 -0
- package/dist/vtilt.d.ts +6 -1
- package/dist/web-vitals.js.map +1 -1
- package/package.json +4 -1
- package/dist/extensions/chat/chat-styles.d.ts +0 -27
- package/dist/extensions/chat/message-content-styles.d.ts +0 -1
- package/dist/extensions/chat/message-html.d.ts +0 -6
- package/dist/extensions/chat/message-markdown.d.ts +0 -8
- package/dist/extensions/ga4-proxy.d.ts +0 -59
- package/dist/utils/type-utils.d.ts +0 -4
- package/dist/web-vitals.d.ts +0 -81
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(){"use strict";function t(t,e,i,n,r,s,o){try{var a=t[s](o),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(n,r)}function e(e){return function(){var i=this,n=arguments;return new Promise(function(r,s){var o=e.apply(i,n);function a(e){t(o,r,s,a,l,"next",e)}function l(e){t(o,r,s,a,l,"throw",e)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)({}).hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},i.apply(null,arguments)}function n(t,e){if(null==t)return{};var i={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;i[n]=t[n]}return i}var r,s=["inputs"],o=["inputId"],a=["inputs"],l=["inputId"],h=["type"],u=Object.defineProperty,c=(t,e,i)=>((t,e,i)=>e in t?u(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),d=Object.defineProperty,v=(t,e,i)=>((t,e,i)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),f=(t=>(t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment",t))(f||{}),p={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},m={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},g={};function b(t){if(g[t])return g[t];var e=globalThis[t],i=e.prototype,n=t in p?p[t]:void 0,r=Boolean(n&&n.every(t=>{var e,n;return Boolean(null==(n=null==(e=Object.getOwnPropertyDescriptor(i,t))?void 0:e.get)?void 0:n.toString().includes("[native code]"))})),s=t in m?m[t]:void 0,o=Boolean(s&&s.every(t=>{var e;return"function"==typeof i[t]&&(null==(e=i[t])?void 0:e.toString().includes("[native code]"))}));if(r&&o&&!globalThis.Zone)return g[t]=e.prototype,e.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var l=a.contentWindow;if(!l)return e.prototype;var h=l[t].prototype;return document.body.removeChild(a),h?g[t]=h:i}catch(t){return i}}var y={};function w(t,e,i){var n,r=t+"."+String(i);if(y[r])return y[r].call(e);var s=b(t),o=null==(n=Object.getOwnPropertyDescriptor(s,i))?void 0:n.get;return o?(y[r]=o,o.call(e)):e[i]}var k={};function x(t,e,i){var n=t+"."+String(i);if(k[n])return k[n].bind(e);var r=b(t)[i];return"function"!=typeof r?e[i]:(k[n]=r,r.bind(e))}var S={ownerDocument:function(t){return w("Node",t,"ownerDocument")},childNodes:function(t){return w("Node",t,"childNodes")},parentNode:function(t){return w("Node",t,"parentNode")},parentElement:function(t){return w("Node",t,"parentElement")},textContent:function(t){return w("Node",t,"textContent")},contains:function(t,e){return x("Node",t,"contains")(e)},getRootNode:function(t){return x("Node",t,"getRootNode")()},host:function(t){return t&&"host"in t?w("ShadowRoot",t,"host"):null},styleSheets:function(t){return t.styleSheets},shadowRoot:function(t){return t&&"shadowRoot"in t?w("Element",t,"shadowRoot"):null},querySelector:function(t,e){return w("Element",t,"querySelector")(e)},querySelectorAll:function(t,e){return w("Element",t,"querySelectorAll")(e)},mutationObserver:function(){return b("MutationObserver").constructor},patch:function(t,e,i){try{if(!(e in t))return()=>{};var n=t[e],r=i(n);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:n}})),t[e]=r,()=>{t[e]=n}}catch(t){return()=>{}}}};function C(t){return t.nodeType===t.ELEMENT_NODE}function _(t){var e=t&&"host"in t&&"mode"in t&&S.host(t)||null;return Boolean(e&&"shadowRoot"in e&&S.shadowRoot(e)===t)}function I(t){return"[object ShadowRoot]"===Object.prototype.toString.call(t)}function A(t){try{var e=t.rules||t.cssRules;if(!e)return null;var i=t.href;!i&&t.ownerNode&&(i=t.ownerNode.baseURI);var n=Array.from(e,t=>T(t,i)).join("");return(r=n).includes(" background-clip: text;")&&!r.includes(" -webkit-background-clip: text;")&&(r=r.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),r}catch(t){return null}var r}function T(t,e){if(function(t){return"styleSheet"in t}(t)){var i;try{i=A(t.styleSheet)||function(t){var{cssText:e}=t;if(e.split('"').length<3)return e;var i=["@import","url("+JSON.stringify(t.href)+")"];return""===t.layerName?i.push("layer"):t.layerName&&i.push("layer("+t.layerName+")"),t.supportsText&&i.push("supports("+t.supportsText+")"),t.media.length&&i.push(t.media.mediaText),i.join(" ")+";"}(t)}catch(e){i=t.cssText}return t.styleSheet.href?L(i,t.styleSheet.href):i}var n,r=t.cssText;return function(t){return"selectorText"in t}(t)&&t.selectorText.includes(":")&&(n=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,r=r.replace(n,"$1\\$2")),e?L(r,e):r}class E{constructor(){v(this,"idNodeMap",new Map),v(this,"nodeMetaMap",new WeakMap)}getId(t){var e;if(!t)return-1;var i=null==(e=this.getMeta(t))?void 0:e.id;return null!=i?i:-1}getNode(t){return this.idNodeMap.get(t)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(t){return this.nodeMetaMap.get(t)||null}removeNodeFromMap(t){var e=this.getId(t);this.idNodeMap.delete(e),t.childNodes&&t.childNodes.forEach(t=>this.removeNodeFromMap(t))}has(t){return this.idNodeMap.has(t)}hasNode(t){return this.nodeMetaMap.has(t)}add(t,e){var i=e.id;this.idNodeMap.set(i,t),this.nodeMetaMap.set(t,e)}replace(t,e){var i=this.getNode(t);if(i){var n=this.nodeMetaMap.get(i);n&&this.nodeMetaMap.set(e,n)}this.idNodeMap.set(t,e)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function M(t){var{element:e,maskInputOptions:i,tagName:n,type:r,value:s,maskInputFn:o}=t,a=s||"",l=r&&O(r);return(i[n.toLowerCase()]||l&&i[l])&&(a=o?o(a,e):"*".repeat(a.length)),a}function O(t){return t.toLowerCase()}var R="__rrweb_original__";function N(t){var e=t.type;return t.hasAttribute("data-rr-is-password")?"password":e?O(e):null}function P(t,e){var i,n;try{n=new URL(t,null!=e?e:window.location.href)}catch(t){return null}var r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(i=null==r?void 0:r[1])&&void 0!==i?i:null}var B=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,D=/^(?:[a-z+]+:)?\/\//i,j=/^www\..*/i,U=/^(data:)([^,]*),(.*)/i;function L(t,e){return(t||"").replace(B,(t,i,n,r,s,o)=>{var a,l=n||s||o,h=i||r||"";if(!l)return t;if(D.test(l)||j.test(l))return"url("+h+l+h+")";if(U.test(l))return"url("+h+l+h+")";if("/"===l[0])return"url("+h+(((a=e).indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)+h+")";var u=e.split("/"),c=l.split("/");for(var d of(u.pop(),c))"."!==d&&(".."===d?u.pop():u.push(d));return"url("+h+u.join("/")+h+")"})}function F(t,e){return void 0===e&&(e=!1),e?t.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):t.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function z(t,e){return function(t,e,i){void 0===i&&(i=!1);var n=Array.from(e.childNodes),r=[],s=0;if(n.length>1&&t&&"string"==typeof t)for(var o=F(t,i),a=o.length/t.length,l=1;l<n.length;l++)if(n[l].textContent&&"string"==typeof n[l].textContent){for(var h=F(n[l].textContent,i),u=3;u<h.length&&(h[u].match(/[a-zA-Z0-9]/)||-1!==h.indexOf(h.substring(0,u),1));u++);for(;u<h.length;u++){var c=h.substring(0,u),d=o.split(c),v=-1;if(2===d.length)v=d[0].length;else if(d.length>2&&""===d[0]&&""!==n[l-1].textContent)v=o.indexOf(c,1);else if(1===d.length){if(c=c.substring(0,c.length-1),(d=o.split(c)).length<=1)return r.push(t),r;u=101}else u===h.length-1&&(v=o.indexOf(c));if(d.length>=2&&u>100){var f=n[l-1].textContent;if(f&&"string"==typeof f){var p=F(f).length;v=o.indexOf(c,p)}-1===v&&(v=d[0].length)}if(-1!==v){for(var m=Math.floor(v/a);m>0&&m<t.length;){if((s+=1)>50*n.length)return r.push(t),r;var g=F(t.substring(0,m),i);if(g.length===v){r.push(t.substring(0,m)),t=t.substring(m),o=o.substring(v);break}g.length<v?m+=Math.max(1,Math.floor((v-g.length)/a)):m-=Math.max(1,Math.floor((g.length-v)*a))}break}}}return r.push(t),r}(t,e).join("/* rr_split */")}var W,V,H=1,q=new RegExp("[^a-z0-9-_:]");function J(){return H++}var G=/^[^ \t\n\r\u000c]+/,Z=/^[, \t\n\r\u000c]+/;var Y=new WeakMap;function K(t,e){return e&&""!==e.trim()?Q(t,e):e}function X(t){return Boolean("svg"===t.tagName||t.ownerSVGElement)}function Q(t,e){var i=Y.get(t);if(i||(i=t.createElement("a"),Y.set(t,i)),e){if(e.startsWith("blob:")||e.startsWith("data:"))return e}else e="";return i.setAttribute("href",e),i.href}function tt(t,e,i,n){return n?"src"===i||"href"===i&&("use"!==e||"#"!==n[0])||"xlink:href"===i&&"#"!==n[0]||"background"===i&&["table","td","th"].includes(e)?K(t,n):"srcset"===i?function(t,e){if(""===e.trim())return e;var i=0;function n(t){var n,r=t.exec(e.substring(i));return r?(n=r[0],i+=n.length,n):""}for(var r=[];n(Z),!(i>=e.length);){var s=n(G);if(","===s.slice(-1))s=K(t,s.substring(0,s.length-1)),r.push(s);else{var o="";s=K(t,s);for(var a=!1;;){var l=e.charAt(i);if(""===l){r.push((s+o).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){i+=1,r.push((s+o).trim());break}"("===l&&(a=!0)}o+=l,i+=1}}}return r.join(", ")}(t,n):"style"===i?L(n,Q(t)):"object"===e&&"data"===i?K(t,n):n:n}function et(t,e,i){return["video","audio"].includes(t)&&"autoplay"===e}function it(t,e,i){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return!!i&&it(S.parentNode(t),e,i);for(var n=t.classList.length;n--;){var r=t.classList[n];if(e.test(r))return!0}return!!i&&it(S.parentNode(t),e,i)}function nt(t,e,i,n){var r;if(C(t)){if(r=t,!S.childNodes(r).length)return!1}else{if(null===S.parentElement(t))return!1;r=S.parentElement(t)}try{if("string"==typeof e){if(n){if(r.closest("."+e))return!0}else if(r.classList.contains(e))return!0}else if(it(r,e,n))return!0;if(i)if(n){if(r.closest(i))return!0}else if(r.matches(i))return!0}catch(t){}return!1}function rt(t,e){var{doc:i,mirror:n,blockClass:r,blockSelector:s,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:h,maskInputFn:u,dataURLOptions:c={},inlineImages:d,recordCanvas:v,keepIframeSrcFn:p,newlyAddedElement:m=!1,cssCaptured:g=!1}=e,b=function(t,e){if(!e.hasNode(t))return;var i=e.getId(t);return 1===i?void 0:i}(i,n);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:f.Document,childNodes:[],compatMode:t.compatMode}:{type:f.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:f.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:b};case t.ELEMENT_NODE:return function(t,e){for(var i,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:o,maskInputOptions:a={},maskInputFn:l,dataURLOptions:h={},inlineImages:u,recordCanvas:c,keepIframeSrcFn:d,newlyAddedElement:v=!1,rootId:p}=e,m=function(t,e,i){try{if("string"==typeof e){if(t.classList.contains(e))return!0}else for(var n=t.classList.length;n--;){var r=t.classList[n];if(e.test(r))return!0}if(i)return t.matches(i)}catch(t){}return!1}(t,r,s),g=function(t){if(t instanceof HTMLFormElement)return"form";var e=O(t.tagName);return q.test(e)?"div":e}(t),b={},y=t.attributes.length,w=0;w<y;w++){var k=t.attributes[w];et(g,k.name,k.value)||(b[k.name]=tt(n,g,O(k.name),k.value))}if("link"===g&&o){var x=Array.from(n.styleSheets).find(e=>e.href===t.href),S=null;x&&(S=A(x)),S&&(delete b.rel,delete b.href,b._cssText=S)}if("style"===g&&t.sheet){var C=A(t.sheet);C&&(t.childNodes.length>1&&(C=z(C,t)),b._cssText=C)}if(["input","textarea","select"].includes(g)){var _=t.value,I=t.checked;"radio"!==b.type&&"checkbox"!==b.type&&"submit"!==b.type&&"button"!==b.type&&_?b.value=M({element:t,type:N(t),tagName:g,value:_,maskInputOptions:a,maskInputFn:l}):I&&(b.checked=I)}"option"===g&&(t.selected&&!a.select?b.selected=!0:delete b.selected);"dialog"===g&&t.open&&(b.rr_open_mode=t.matches("dialog:modal")?"modal":"non-modal");if("canvas"===g&&c)if("2d"===t.__context)(function(t){var e=t.getContext("2d");if(!e)return!0;for(var i=0;i<t.width;i+=50)for(var n=0;n<t.height;n+=50){var r=e.getImageData,s=R in r?r[R]:r;if(new Uint32Array(s.call(e,i,n,Math.min(50,t.width-i),Math.min(50,t.height-n)).data.buffer).some(t=>0!==t))return!1}return!0})(t)||(b.rr_dataURL=t.toDataURL(h.type,h.quality));else if(!("__context"in t)){var T=t.toDataURL(h.type,h.quality),E=n.createElement("canvas");E.width=t.width,E.height=t.height,T!==E.toDataURL(h.type,h.quality)&&(b.rr_dataURL=T)}if("img"===g&&u){W||(W=n.createElement("canvas"),V=W.getContext("2d"));var P=t,B=P.currentSrc||P.getAttribute("src")||"<unknown-src>",D=P.crossOrigin,j=()=>{P.removeEventListener("load",j);try{W.width=P.naturalWidth,W.height=P.naturalHeight,V.drawImage(P,0,0),b.rr_dataURL=W.toDataURL(h.type,h.quality)}catch(t){if("anonymous"!==P.crossOrigin)return P.crossOrigin="anonymous",void(P.complete&&0!==P.naturalWidth?j():P.addEventListener("load",j));console.warn("Cannot inline img src="+B+"! Error: "+t)}"anonymous"===P.crossOrigin&&(D?b.crossOrigin=D:P.removeAttribute("crossorigin"))};P.complete&&0!==P.naturalWidth?j():P.addEventListener("load",j)}if(["audio","video"].includes(g)){var U=b;U.rr_mediaState=t.paused?"paused":"played",U.rr_mediaCurrentTime=t.currentTime,U.rr_mediaPlaybackRate=t.playbackRate,U.rr_mediaMuted=t.muted,U.rr_mediaLoop=t.loop,U.rr_mediaVolume=t.volume}v||(t.scrollLeft&&(b.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(b.rr_scrollTop=t.scrollTop));if(m){var{width:L,height:F}=t.getBoundingClientRect();b={class:b.class,rr_width:L+"px",rr_height:F+"px"}}"iframe"!==g||d(b.src)||(t.contentDocument||(b.rr_src=b.src),delete b.src);try{customElements.get(g)&&(i=!0)}catch(t){}return{type:f.Element,tagName:g,attributes:b,childNodes:[],isSVG:X(t)||void 0,needBlock:m,rootId:p,isCustom:i}}(t,{doc:i,blockClass:r,blockSelector:s,inlineStylesheet:a,maskInputOptions:l,maskInputFn:u,dataURLOptions:c,inlineImages:d,recordCanvas:v,keepIframeSrcFn:p,newlyAddedElement:m,rootId:b});case t.TEXT_NODE:return function(t,e){var{needsMask:i,maskTextFn:n,rootId:r,cssCaptured:s}=e,o=S.parentNode(t),a=o&&o.tagName,l="",h="STYLE"===a||void 0,u="SCRIPT"===a||void 0;u?l="SCRIPT_PLACEHOLDER":s||(l=S.textContent(t),h&&l&&(l=L(l,Q(e.doc))));!h&&!u&&l&&i&&(l=n?n(l,S.parentElement(t)):l.replace(/[\S]/g,"*"));return{type:f.Text,textContent:l||"",rootId:r}}(t,{doc:i,needsMask:o,maskTextFn:h,rootId:b,cssCaptured:g});case t.CDATA_SECTION_NODE:return{type:f.CDATA,textContent:"",rootId:b};case t.COMMENT_NODE:return{type:f.Comment,textContent:S.textContent(t)||"",rootId:b};default:return!1}}function st(t){return null==t?"":t.toLowerCase()}function ot(t){return!0===t||"all"===t?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===t,headMetaDescKeywords:"all"===t,headTitleMutations:"all"===t}:t||{}}function at(t,e){var{doc:i,mirror:n,blockClass:r,blockSelector:s,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:h=!0,maskInputOptions:u={},maskTextFn:c,maskInputFn:d,slimDOMOptions:v,dataURLOptions:p={},inlineImages:m=!1,recordCanvas:g=!1,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:w=5e3,onStylesheetLoad:k,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:A=()=>!1,newlyAddedElement:T=!1,cssCaptured:E=!1}=e,{needsMask:M}=e,{preserveWhiteSpace:O=!0}=e;M||(M=nt(t,o,a,void 0===M));var R,N=rt(t,{doc:i,mirror:n,blockClass:r,blockSelector:s,needsMask:M,inlineStylesheet:h,maskInputOptions:u,maskTextFn:c,maskInputFn:d,dataURLOptions:p,inlineImages:m,recordCanvas:g,keepIframeSrcFn:A,newlyAddedElement:T,cssCaptured:E});if(!N)return console.warn(t,"not serialized"),null;R=n.hasNode(t)?n.getId(t):function(t,e){if(e.comment&&t.type===f.Comment)return!0;if(t.type===f.Element){if(e.script&&("script"===t.tagName||"link"===t.tagName&&("preload"===t.attributes.rel&&"script"===t.attributes.as||"modulepreload"===t.attributes.rel)||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&"js"===P(t.attributes.href)))return!0;if(e.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(st(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===st(t.attributes.name)||"icon"===st(t.attributes.rel)||"apple-touch-icon"===st(t.attributes.rel)||"shortcut icon"===st(t.attributes.rel))))return!0;if("meta"===t.tagName){if(e.headMetaDescKeywords&&st(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(st(t.attributes.property).match(/^(og|twitter|fb):/)||st(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===st(t.attributes.name)))return!0;if(e.headMetaRobots&&("robots"===st(t.attributes.name)||"googlebot"===st(t.attributes.name)||"bingbot"===st(t.attributes.name)))return!0;if(e.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(e.headMetaAuthorship&&("author"===st(t.attributes.name)||"generator"===st(t.attributes.name)||"framework"===st(t.attributes.name)||"publisher"===st(t.attributes.name)||"progid"===st(t.attributes.name)||st(t.attributes.property).match(/^article:/)||st(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&("google-site-verification"===st(t.attributes.name)||"yandex-verification"===st(t.attributes.name)||"csrf-token"===st(t.attributes.name)||"p:domain_verify"===st(t.attributes.name)||"verify-v1"===st(t.attributes.name)||"verification"===st(t.attributes.name)||"shopify-checkout-api-token"===st(t.attributes.name)))return!0}}return!1}(N,v)||!O&&N.type===f.Text&&!N.textContent.replace(/^\s+|\s+$/gm,"").length?-2:J();var B=Object.assign(N,{id:R});if(n.add(t,B),-2===R)return null;b&&b(t);var D=!l;if(B.type===f.Element){D=D&&!B.needBlock,delete B.needBlock;var j=S.shadowRoot(t);j&&I(j)&&(B.isShadowHost=!0)}if((B.type===f.Document||B.type===f.Element)&&D){v.headWhitespace&&B.type===f.Element&&"head"===B.tagName&&(O=!1);var U={doc:i,mirror:n,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:h,maskInputOptions:u,maskTextFn:c,maskInputFn:d,slimDOMOptions:v,dataURLOptions:p,inlineImages:m,recordCanvas:g,preserveWhiteSpace:O,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:k,stylesheetLoadTimeout:x,keepIframeSrcFn:A,cssCaptured:!1};if(B.type===f.Element&&"textarea"===B.tagName&&void 0!==B.attributes.value);else for(var L of(B.type===f.Element&&void 0!==B.attributes._cssText&&"string"==typeof B.attributes._cssText&&(U.cssCaptured=!0),Array.from(S.childNodes(t)))){var F=at(L,U);F&&B.childNodes.push(F)}var z=null;if(C(t)&&(z=S.shadowRoot(t)))for(var W of Array.from(S.childNodes(z))){var V=at(W,U);V&&(I(z)&&(V.isShadow=!0),B.childNodes.push(V))}}var H=S.parentNode(t);return H&&_(H)&&I(H)&&(B.isShadow=!0),B.type===f.Element&&"iframe"===B.tagName&&function(t,e,i){var n=t.contentWindow;if(n){var r,s=!1;try{r=n.document.readyState}catch(t){return}if("complete"===r){var o="about:blank";if(n.location.href!==o||t.src===o||""===t.src)return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}else{var a=setTimeout(()=>{s||(e(),s=!0)},i);t.addEventListener("load",()=>{clearTimeout(a),s=!0,e()})}}}(t,()=>{var e=t.contentDocument;if(e&&y){var i=at(e,{doc:e,mirror:n,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:h,maskInputOptions:u,maskTextFn:c,maskInputFn:d,slimDOMOptions:v,dataURLOptions:p,inlineImages:m,recordCanvas:g,preserveWhiteSpace:O,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:k,stylesheetLoadTimeout:x,keepIframeSrcFn:A});i&&y(t,i)}},w),B.type===f.Element&&"link"===B.tagName&&"string"==typeof B.attributes.rel&&("stylesheet"===B.attributes.rel||"preload"===B.attributes.rel&&"string"==typeof B.attributes.href&&"css"===P(B.attributes.href))&&function(t,e,i){var n,r=!1;try{n=t.sheet}catch(t){return}if(!n){var s=setTimeout(()=>{r||(e(),r=!0)},i);t.addEventListener("load",()=>{clearTimeout(s),r=!0,e()})}}(t,()=>{if(k){var e=at(t,{doc:i,mirror:n,blockClass:r,blockSelector:s,needsMask:M,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:h,maskInputOptions:u,maskTextFn:c,maskInputFn:d,slimDOMOptions:v,dataURLOptions:p,inlineImages:m,recordCanvas:g,preserveWhiteSpace:O,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:w,onStylesheetLoad:k,stylesheetLoadTimeout:x,keepIframeSrcFn:A});e&&k(t,e)}},x),B}function lt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ht(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),i}var ut={exports:{}},ct=String,dt=function(){return{isColorSupported:!1,reset:ct,bold:ct,dim:ct,italic:ct,underline:ct,inverse:ct,hidden:ct,strikethrough:ct,black:ct,red:ct,green:ct,yellow:ct,blue:ct,magenta:ct,cyan:ct,white:ct,gray:ct,bgBlack:ct,bgRed:ct,bgGreen:ct,bgYellow:ct,bgBlue:ct,bgMagenta:ct,bgCyan:ct,bgWhite:ct}};ut.exports=dt(),ut.exports.createColors=dt;var vt=ut.exports,ft=ht(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),pt=vt,mt=ft,gt=class t extends Error{constructor(e,i,n,r,s,o){super(e),this.name="CssSyntaxError",this.reason=e,s&&(this.file=s),r&&(this.source=r),o&&(this.plugin=o),void 0!==i&&void 0!==n&&("number"==typeof i?(this.line=i,this.column=n):(this.line=i.line,this.column=i.column,this.endLine=n.line,this.endColumn=n.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,t)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(t){if(!this.source)return"";var e=this.source;null==t&&(t=pt.isColorSupported),mt&&t&&(e=mt(e));var i,n,r=e.split(/\r?\n/),s=Math.max(this.line-3,0),o=Math.min(this.line+2,r.length),a=String(o).length;if(t){var{bold:l,gray:h,red:u}=pt.createColors(!0);i=t=>l(u(t)),n=t=>h(t)}else i=n=t=>t;return r.slice(s,o).map((t,e)=>{var r=s+1+e,o=" "+(" "+r).slice(-a)+" | ";if(r===this.line){var l=n(o.replace(/\d/g," "))+t.slice(0,this.column-1).replace(/[^\t]/g," ");return i(">")+n(o)+t+"\n "+l+i("^")}return" "+n(o)+t}).join("\n")}toString(){var t=this.showSourceCode();return t&&(t="\n\n"+t+"\n"),this.name+": "+this.message+t}},bt=gt;gt.default=gt;var yt={};yt.isClean=Symbol("isClean"),yt.my=Symbol("my");var wt={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var kt=class{constructor(t){this.builder=t}atrule(t,e){var i="@"+t.name,n=t.params?this.rawValue(t,"params"):"";if(void 0!==t.raws.afterName?i+=t.raws.afterName:n&&(i+=" "),t.nodes)this.block(t,i+n);else{var r=(t.raws.between||"")+(e?";":"");this.builder(i+n+r,t)}}beforeAfter(t,e){var i;i="decl"===t.type?this.raw(t,null,"beforeDecl"):"comment"===t.type?this.raw(t,null,"beforeComment"):"before"===e?this.raw(t,null,"beforeRule"):this.raw(t,null,"beforeClose");for(var n=t.parent,r=0;n&&"root"!==n.type;)r+=1,n=n.parent;if(i.includes("\n")){var s=this.raw(t,null,"indent");if(s.length)for(var o=0;o<r;o++)i+=s}return i}block(t,e){var i,n=this.raw(t,"between","beforeOpen");this.builder(e+n+"{",t,"start"),t.nodes&&t.nodes.length?(this.body(t),i=this.raw(t,"after")):i=this.raw(t,"after","emptyBody"),i&&this.builder(i),this.builder("}",t,"end")}body(t){for(var e=t.nodes.length-1;e>0&&"comment"===t.nodes[e].type;)e-=1;for(var i=this.raw(t,"semicolon"),n=0;n<t.nodes.length;n++){var r=t.nodes[n],s=this.raw(r,"before");s&&this.builder(s),this.stringify(r,e!==n||i)}}comment(t){var e=this.raw(t,"left","commentLeft"),i=this.raw(t,"right","commentRight");this.builder("/*"+e+t.text+i+"*/",t)}decl(t,e){var i=this.raw(t,"between","colon"),n=t.prop+i+this.rawValue(t,"value");t.important&&(n+=t.raws.important||" !important"),e&&(n+=";"),this.builder(n,t)}document(t){this.body(t)}raw(t,e,i){var n;if(i||(i=e),e&&void 0!==(n=t.raws[e]))return n;var r=t.parent;if("before"===i){if(!r||"root"===r.type&&r.first===t)return"";if(r&&"document"===r.type)return""}if(!r)return wt[i];var s=t.root();if(s.rawCache||(s.rawCache={}),void 0!==s.rawCache[i])return s.rawCache[i];if("before"===i||"after"===i)return this.beforeAfter(t,i);var o,a="raw"+((o=i)[0].toUpperCase()+o.slice(1));return this[a]?n=this[a](s,t):s.walk(t=>{if(void 0!==(n=t.raws[e]))return!1}),void 0===n&&(n=wt[i]),s.rawCache[i]=n,n}rawBeforeClose(t){var e;return t.walk(t=>{if(t.nodes&&t.nodes.length>0&&void 0!==t.raws.after)return(e=t.raws.after).includes("\n")&&(e=e.replace(/[^\n]+$/,"")),!1}),e&&(e=e.replace(/\S/g,"")),e}rawBeforeComment(t,e){var i;return t.walkComments(t=>{if(void 0!==t.raws.before)return(i=t.raws.before).includes("\n")&&(i=i.replace(/[^\n]+$/,"")),!1}),void 0===i?i=this.raw(e,null,"beforeDecl"):i&&(i=i.replace(/\S/g,"")),i}rawBeforeDecl(t,e){var i;return t.walkDecls(t=>{if(void 0!==t.raws.before)return(i=t.raws.before).includes("\n")&&(i=i.replace(/[^\n]+$/,"")),!1}),void 0===i?i=this.raw(e,null,"beforeRule"):i&&(i=i.replace(/\S/g,"")),i}rawBeforeOpen(t){var e;return t.walk(t=>{if("decl"!==t.type&&void 0!==(e=t.raws.between))return!1}),e}rawBeforeRule(t){var e;return t.walk(i=>{if(i.nodes&&(i.parent!==t||t.first!==i)&&void 0!==i.raws.before)return(e=i.raws.before).includes("\n")&&(e=e.replace(/[^\n]+$/,"")),!1}),e&&(e=e.replace(/\S/g,"")),e}rawColon(t){var e;return t.walkDecls(t=>{if(void 0!==t.raws.between)return e=t.raws.between.replace(/[^\s:]/g,""),!1}),e}rawEmptyBody(t){var e;return t.walk(t=>{if(t.nodes&&0===t.nodes.length&&void 0!==(e=t.raws.after))return!1}),e}rawIndent(t){return t.raws.indent?t.raws.indent:(t.walk(i=>{var n=i.parent;if(n&&n!==t&&n.parent&&n.parent===t&&void 0!==i.raws.before){var r=i.raws.before.split("\n");return e=(e=r[r.length-1]).replace(/\S/g,""),!1}}),e);var e}rawSemicolon(t){var e;return t.walk(t=>{if(t.nodes&&t.nodes.length&&"decl"===t.last.type&&void 0!==(e=t.raws.semicolon))return!1}),e}rawValue(t,e){var i=t[e],n=t.raws[e];return n&&n.value===i?n.raw:i}root(t){this.body(t),t.raws.after&&this.builder(t.raws.after)}rule(t){this.block(t,this.rawValue(t,"selector")),t.raws.ownSemicolon&&this.builder(t.raws.ownSemicolon,t,"end")}stringify(t,e){if(!this[t.type])throw new Error("Unknown AST node type "+t.type+". Maybe you need to change PostCSS stringifier.");this[t.type](t,e)}},xt=kt;kt.default=kt;var St=xt;function Ct(t,e){new St(e).stringify(t)}var _t=Ct;Ct.default=Ct;var{isClean:It,my:At}=yt,Tt=bt,Et=xt,Mt=_t;function Ot(t,e){var i=new t.constructor;for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&"proxyCache"!==n){var r=t[n],s=typeof r;"parent"===n&&"object"===s?e&&(i[n]=e):"source"===n?i[n]=r:Array.isArray(r)?i[n]=r.map(t=>Ot(t,i)):("object"===s&&null!==r&&(r=Ot(r)),i[n]=r)}return i}var Rt=class{constructor(t){for(var e in void 0===t&&(t={}),this.raws={},this[It]=!1,this[At]=!0,t)if("nodes"===e)for(var i of(this.nodes=[],t[e]))"function"==typeof i.clone?this.append(i.clone()):this.append(i);else this[e]=t[e]}addToError(t){if(t.postcssNode=this,t.stack&&this.source&&/\n\s{4}at /.test(t.stack)){var e=this.source;t.stack=t.stack.replace(/\n\s{4}at /,"$&"+e.input.from+":"+e.start.line+":"+e.start.column+"$&")}return t}after(t){return this.parent.insertAfter(this,t),this}assign(t){for(var e in void 0===t&&(t={}),t)this[e]=t[e];return this}before(t){return this.parent.insertBefore(this,t),this}cleanRaws(t){delete this.raws.before,delete this.raws.after,t||delete this.raws.between}clone(t){void 0===t&&(t={});var e=Ot(this);for(var i in t)e[i]=t[i];return e}cloneAfter(t){void 0===t&&(t={});var e=this.clone(t);return this.parent.insertAfter(this,e),e}cloneBefore(t){void 0===t&&(t={});var e=this.clone(t);return this.parent.insertBefore(this,e),e}error(t,e){if(void 0===e&&(e={}),this.source){var{end:i,start:n}=this.rangeBy(e);return this.source.input.error(t,{column:n.column,line:n.line},{column:i.column,line:i.line},e)}return new Tt(t)}getProxyProcessor(){return{get:(t,e)=>"proxyOf"===e?t:"root"===e?()=>t.root().toProxy():t[e],set:(t,e,i)=>(t[e]===i||(t[e]=i,"prop"!==e&&"value"!==e&&"name"!==e&&"params"!==e&&"important"!==e&&"text"!==e||t.markDirty()),!0)}}markDirty(){if(this[It]){this[It]=!1;for(var t=this;t=t.parent;)t[It]=!1}}next(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t+1]}}positionBy(t,e){var i=this.source.start;if(t.index)i=this.positionInside(t.index,e);else if(t.word){var n=(e=this.toString()).indexOf(t.word);-1!==n&&(i=this.positionInside(n,e))}return i}positionInside(t,e){for(var i=e||this.toString(),n=this.source.start.column,r=this.source.start.line,s=0;s<t;s++)"\n"===i[s]?(n=1,r+=1):n+=1;return{column:n,line:r}}prev(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t-1]}}rangeBy(t){var e={column:this.source.start.column,line:this.source.start.line},i=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:e.column+1,line:e.line};if(t.word){var n=this.toString(),r=n.indexOf(t.word);-1!==r&&(e=this.positionInside(r,n),i=this.positionInside(r+t.word.length,n))}else t.start?e={column:t.start.column,line:t.start.line}:t.index&&(e=this.positionInside(t.index)),t.end?i={column:t.end.column,line:t.end.line}:"number"==typeof t.endIndex?i=this.positionInside(t.endIndex):t.index&&(i=this.positionInside(t.index+1));return(i.line<e.line||i.line===e.line&&i.column<=e.column)&&(i={column:e.column+1,line:e.line}),{end:i,start:e}}raw(t,e){return(new Et).raw(this,t,e)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(){if(this.parent){for(var t=this,e=!1,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];for(var s of n)s===this?e=!0:e?(this.parent.insertAfter(t,s),t=s):this.parent.insertBefore(t,s);e||this.remove()}return this}root(){for(var t=this;t.parent&&"document"!==t.parent.type;)t=t.parent;return t}toJSON(t,e){var i={},n=null==e;e=e||new Map;var r=0;for(var s in this)if(Object.prototype.hasOwnProperty.call(this,s)&&"parent"!==s&&"proxyCache"!==s){var o=this[s];if(Array.isArray(o))i[s]=o.map(t=>"object"==typeof t&&t.toJSON?t.toJSON(null,e):t);else if("object"==typeof o&&o.toJSON)i[s]=o.toJSON(null,e);else if("source"===s){var a=e.get(o.input);null==a&&(a=r,e.set(o.input,r),r++),i[s]={end:o.end,inputId:a,start:o.start}}else i[s]=o}return n&&(i.inputs=[...e.keys()].map(t=>t.toJSON())),i}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(t){void 0===t&&(t=Mt),t.stringify&&(t=t.stringify);var e="";return t(this,t=>{e+=t}),e}warn(t,e,i){var n={node:this};for(var r in i)n[r]=i[r];return t.warn(e,n)}get proxyOf(){return this}},Nt=Rt;Rt.default=Rt;var Pt=Nt,Bt=class extends Pt{constructor(t){t&&void 0!==t.value&&"string"!=typeof t.value&&(t=i({},t,{value:String(t.value)})),super(t),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Dt=Bt;Bt.default=Bt;var jt={nanoid:function(t){void 0===t&&(t=21);for(var e="",i=t;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e}},{SourceMapConsumer:Ut,SourceMapGenerator:Lt}=ft,{existsSync:Ft,readFileSync:zt}=ft,{dirname:Wt,join:$t}=ft;var Vt=class{constructor(t,e){if(!1!==e.map){this.loadAnnotation(t),this.inline=this.startWith(this.annotation,"data:");var i=e.map?e.map.prev:void 0,n=this.loadMap(e.from,i);!this.mapFile&&e.from&&(this.mapFile=e.from),this.mapFile&&(this.root=Wt(this.mapFile)),n&&(this.text=n)}}consumer(){return this.consumerCache||(this.consumerCache=new Ut(this.text)),this.consumerCache}decodeInline(t){var e;if(/^data:application\/json;charset=utf-?8,/.test(t)||/^data:application\/json,/.test(t))return decodeURIComponent(t.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(t)||/^data:application\/json;base64,/.test(t))return e=t.substr(RegExp.lastMatch.length),Buffer?Buffer.from(e,"base64").toString():window.atob(e);var i=t.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+i)}getAnnotationURL(t){return t.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(t){return"object"==typeof t&&("string"==typeof t.mappings||"string"==typeof t._mappings||Array.isArray(t.sections))}loadAnnotation(t){var e=t.match(/\/\*\s*# sourceMappingURL=/gm);if(e){var i=t.lastIndexOf(e.pop()),n=t.indexOf("*/",i);i>-1&&n>-1&&(this.annotation=this.getAnnotationURL(t.substring(i,n)))}}loadFile(t){if(this.root=Wt(t),Ft(t))return this.mapFile=t,zt(t,"utf-8").toString().trim()}loadMap(t,e){if(!1===e)return!1;if(e){if("string"==typeof e)return e;if("function"!=typeof e){if(e instanceof Ut)return Lt.fromSourceMap(e).toString();if(e instanceof Lt)return e.toString();if(this.isMap(e))return JSON.stringify(e);throw new Error("Unsupported previous source map format: "+e.toString())}var i=e(t);if(i){var n=this.loadFile(i);if(!n)throw new Error("Unable to load previous source map: "+i.toString());return n}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var r=this.annotation;return t&&(r=$t(Wt(t),r)),this.loadFile(r)}}}startWith(t,e){return!!t&&t.substr(0,e.length)===e}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Ht=Vt;Vt.default=Vt;var{SourceMapConsumer:qt,SourceMapGenerator:Jt}=ft,{fileURLToPath:Gt,pathToFileURL:Zt}=ft,{isAbsolute:Yt,resolve:Kt}=ft,{nanoid:Xt}=jt,Qt=ft,te=bt,ee=Ht,ie=Symbol("fromOffsetCache"),ne=Boolean(qt&&Jt),re=Boolean(Kt&&Yt),se=class{constructor(t,e){if(void 0===e&&(e={}),null==t||"object"==typeof t&&!t.toString)throw new Error("PostCSS received "+t+" instead of CSS string");if(this.css=t.toString(),"\ufeff"===this.css[0]||""===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,e.from&&(!re||/^\w+:\/\//.test(e.from)||Yt(e.from)?this.file=e.from:this.file=Kt(e.from)),re&&ne){var i=new ee(this.css,e);if(i.text){this.map=i;var n=i.consumer().file;!this.file&&n&&(this.file=this.mapResolve(n))}}this.file||(this.id="<input css "+Xt(6)+">"),this.map&&(this.map.file=this.from)}error(t,e,i,n){var r,s,o;if(void 0===n&&(n={}),e&&"object"==typeof e){var a=e,l=i;if("number"==typeof a.offset){var h=this.fromOffset(a.offset);e=h.line,i=h.col}else e=a.line,i=a.column;if("number"==typeof l.offset){var u=this.fromOffset(l.offset);s=u.line,o=u.col}else s=l.line,o=l.column}else if(!i){var c=this.fromOffset(e);e=c.line,i=c.col}var d=this.origin(e,i,s,o);return(r=d?new te(t,void 0===d.endLine?d.line:{column:d.column,line:d.line},void 0===d.endLine?d.column:{column:d.endColumn,line:d.endLine},d.source,d.file,n.plugin):new te(t,void 0===s?e:{column:i,line:e},void 0===s?i:{column:o,line:s},this.css,this.file,n.plugin)).input={column:i,endColumn:o,endLine:s,line:e,source:this.css},this.file&&(Zt&&(r.input.url=Zt(this.file).toString()),r.input.file=this.file),r}fromOffset(t){var e;if(this[ie])e=this[ie];else{var i=this.css.split("\n");e=new Array(i.length);for(var n=0,r=0,s=i.length;r<s;r++)e[r]=n,n+=i[r].length+1;this[ie]=e}var o=0;if(t>=e[e.length-1])o=e.length-1;else for(var a,l=e.length-2;o<l;)if(t<e[a=o+(l-o>>1)])l=a-1;else{if(!(t>=e[a+1])){o=a;break}o=a+1}return{col:t-e[o]+1,line:o+1}}mapResolve(t){return/^\w+:\/\//.test(t)?t:Kt(this.map.consumer().sourceRoot||this.map.root||".",t)}origin(t,e,i,n){if(!this.map)return!1;var r,s,o=this.map.consumer(),a=o.originalPositionFor({column:e,line:t});if(!a.source)return!1;"number"==typeof i&&(r=o.originalPositionFor({column:n,line:i})),s=Yt(a.source)?Zt(a.source):new URL(a.source,this.map.consumer().sourceRoot||Zt(this.map.mapFile));var l={column:a.column,endColumn:r&&r.column,endLine:r&&r.line,line:a.line,url:s.toString()};if("file:"===s.protocol){if(!Gt)throw new Error("file: protocol is not available in this PostCSS build");l.file=Gt(s)}var h=o.sourceContentFor(a.source);return h&&(l.source=h),l}toJSON(){var t={};for(var e of["hasBOM","css","file","id"])null!=this[e]&&(t[e]=this[e]);return this.map&&(t.map=i({},this.map),t.map.consumerCache&&(t.map.consumerCache=void 0)),t}get from(){return this.file||this.id}},oe=se;se.default=se,Qt&&Qt.registerInput&&Qt.registerInput(se);var{SourceMapConsumer:ae,SourceMapGenerator:le}=ft,{dirname:he,relative:ue,resolve:ce,sep:de}=ft,{pathToFileURL:ve}=ft,fe=oe,pe=Boolean(ae&&le),me=Boolean(he&&ce&&ue&&de),ge=class{constructor(t,e,i,n){this.stringify=t,this.mapOpts=i.map||{},this.root=e,this.opts=i,this.css=n,this.originalCSS=n,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}addAnnotation(){var t;t=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";var e="\n";this.css.includes("\r\n")&&(e="\r\n"),this.css+=e+"/*# sourceMappingURL="+t+" */"}applyPrevMaps(){for(var t of this.previous()){var e=this.toUrl(this.path(t.file)),i=t.root||he(t.file),n=void 0;!1===this.mapOpts.sourcesContent?(n=new ae(t.text)).sourcesContent&&(n.sourcesContent=null):n=t.consumer(),this.map.applySourceMap(n,e,this.toUrl(this.path(i)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root)for(var t,e=this.root.nodes.length-1;e>=0;e--)"comment"===(t=this.root.nodes[e]).type&&0===t.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(e);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),me&&pe&&this.isMap())return this.generateMap();var t="";return this.stringify(this.root,e=>{t+=e}),[t]}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){var t=this.previous()[0].consumer();t.file=this.outputFile(),this.map=le.fromSourceMap(t,{ignoreInvalidMapping:!0})}else this.map=new le({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new le({file:this.outputFile(),ignoreInvalidMapping:!0});var t,e,i=1,n=1,r="<no source>",s={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(o,a,l)=>{if(this.css+=o,a&&"end"!==l&&(s.generated.line=i,s.generated.column=n-1,a.source&&a.source.start?(s.source=this.sourcePath(a),s.original.line=a.source.start.line,s.original.column=a.source.start.column-1,this.map.addMapping(s)):(s.source=r,s.original.line=1,s.original.column=0,this.map.addMapping(s))),(t=o.match(/\n/g))?(i+=t.length,e=o.lastIndexOf("\n"),n=o.length-e):n+=o.length,a&&"start"!==l){var h=a.parent||{raws:{}};("decl"===a.type||"atrule"===a.type&&!a.nodes)&&a===h.last&&!h.raws.semicolon||(a.source&&a.source.end?(s.source=this.sourcePath(a),s.original.line=a.source.end.line,s.original.column=a.source.end.column-1,s.generated.line=i,s.generated.column=n-2,this.map.addMapping(s)):(s.source=r,s.original.line=1,s.original.column=0,s.generated.line=i,s.generated.column=n-1,this.map.addMapping(s)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(t=>t.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;var t=this.mapOpts.annotation;return(void 0===t||!0===t)&&(!this.previous().length||this.previous().some(t=>t.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(t=>t.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(t){if(this.mapOpts.absolute)return t;if(60===t.charCodeAt(0))return t;if(/^\w+:\/\//.test(t))return t;var e=this.memoizedPaths.get(t);if(e)return e;var i=this.opts.to?he(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(i=he(ce(i,this.mapOpts.annotation)));var n=ue(i,t);return this.memoizedPaths.set(t,n),n}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(t=>{if(t.source&&t.source.input.map){var e=t.source.input.map;this.previousMaps.includes(e)||this.previousMaps.push(e)}});else{var t=new fe(this.originalCSS,this.opts);t.map&&this.previousMaps.push(t.map)}return this.previousMaps}setSourcesContent(){var t={};if(this.root)this.root.walk(e=>{if(e.source){var i=e.source.input.from;if(i&&!t[i]){t[i]=!0;var n=this.usesFileUrls?this.toFileUrl(i):this.toUrl(this.path(i));this.map.setSourceContent(n,e.source.input.css)}}});else if(this.css){var e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(t){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(t.source.input.from):this.toUrl(this.path(t.source.input.from))}toBase64(t){return Buffer?Buffer.from(t).toString("base64"):window.btoa(unescape(encodeURIComponent(t)))}toFileUrl(t){var e=this.memoizedFileURLs.get(t);if(e)return e;if(ve){var i=ve(t).toString();return this.memoizedFileURLs.set(t,i),i}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(t){var e=this.memoizedURLs.get(t);if(e)return e;"\\"===de&&(t=t.replace(/\\/g,"/"));var i=encodeURI(t).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(t,i),i}},be=Nt,ye=class extends be{constructor(t){super(t),this.type="comment"}},we=ye;ye.default=ye;var ke,xe,Se,Ce,{isClean:_e,my:Ie}=yt,Ae=Dt,Te=we,Ee=Nt;function Me(t){return t.map(t=>(t.nodes&&(t.nodes=Me(t.nodes)),delete t.source,t))}function Oe(t){if(t[_e]=!1,t.proxyOf.nodes)for(var e of t.proxyOf.nodes)Oe(e)}var Re=class t extends Ee{append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var n of e){var r=this.normalize(n,this.last);for(var s of r)this.proxyOf.nodes.push(s)}return this.markDirty(),this}cleanRaws(t){if(super.cleanRaws(t),this.nodes)for(var e of this.nodes)e.cleanRaws(t)}each(t){if(this.proxyOf.nodes){for(var e,i,n=this.getIterator();this.indexes[n]<this.proxyOf.nodes.length&&(e=this.indexes[n],!1!==(i=t(this.proxyOf.nodes[e],e)));)this.indexes[n]+=1;return delete this.indexes[n],i}}every(t){return this.nodes.every(t)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var t=this.lastEach;return this.indexes[t]=0,t}getProxyProcessor(){return{get:(t,e)=>"proxyOf"===e?t:t[e]?"each"===e||"string"==typeof e&&e.startsWith("walk")?function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return t[e](...n.map(t=>"function"==typeof t?(e,i)=>t(e.toProxy(),i):t))}:"every"===e||"some"===e?i=>t[e](function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return i(t.toProxy(),...n)}):"root"===e?()=>t.root().toProxy():"nodes"===e?t.nodes.map(t=>t.toProxy()):"first"===e||"last"===e?t[e].toProxy():t[e]:t[e],set:(t,e,i)=>(t[e]===i||(t[e]=i,"name"!==e&&"params"!==e&&"selector"!==e||t.markDirty()),!0)}}index(t){return"number"==typeof t?t:(t.proxyOf&&(t=t.proxyOf),this.proxyOf.nodes.indexOf(t))}insertAfter(t,e){var i,n=this.index(t),r=this.normalize(e,this.proxyOf.nodes[n]).reverse();for(var s of(n=this.index(t),r))this.proxyOf.nodes.splice(n+1,0,s);for(var o in this.indexes)n<(i=this.indexes[o])&&(this.indexes[o]=i+r.length);return this.markDirty(),this}insertBefore(t,e){var i,n=this.index(t),r=0===n&&"prepend",s=this.normalize(e,this.proxyOf.nodes[n],r).reverse();for(var o of(n=this.index(t),s))this.proxyOf.nodes.splice(n,0,o);for(var a in this.indexes)n<=(i=this.indexes[a])&&(this.indexes[a]=i+s.length);return this.markDirty(),this}normalize(e,i){if("string"==typeof e)e=Me(ke(e).nodes);else if(void 0===e)e=[];else if(Array.isArray(e))for(var n of e=e.slice(0))n.parent&&n.parent.removeChild(n,"ignore");else if("root"===e.type&&"document"!==this.type)for(var r of e=e.nodes.slice(0))r.parent&&r.parent.removeChild(r,"ignore");else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error("Value field is missed in node creation");"string"!=typeof e.value&&(e.value=String(e.value)),e=[new Ae(e)]}else if(e.selector)e=[new xe(e)];else if(e.name)e=[new Se(e)];else{if(!e.text)throw new Error("Unknown node type in node creation");e=[new Te(e)]}var s=e.map(e=>(e[Ie]||t.rebuild(e),(e=e.proxyOf).parent&&e.parent.removeChild(e),e[_e]&&Oe(e),void 0===e.raws.before&&i&&void 0!==i.raws.before&&(e.raws.before=i.raws.before.replace(/\S/g,"")),e.parent=this.proxyOf,e));return s}prepend(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var n of e=e.reverse()){var r=this.normalize(n,this.first,"prepend").reverse();for(var s of r)this.proxyOf.nodes.unshift(s);for(var o in this.indexes)this.indexes[o]=this.indexes[o]+r.length}return this.markDirty(),this}push(t){return t.parent=this,this.proxyOf.nodes.push(t),this}removeAll(){for(var t of this.proxyOf.nodes)t.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(t){var e;for(var i in t=this.index(t),this.proxyOf.nodes[t].parent=void 0,this.proxyOf.nodes.splice(t,1),this.indexes)(e=this.indexes[i])>=t&&(this.indexes[i]=e-1);return this.markDirty(),this}replaceValues(t,e,i){return i||(i=e,e={}),this.walkDecls(n=>{e.props&&!e.props.includes(n.prop)||e.fast&&!n.value.includes(e.fast)||(n.value=n.value.replace(t,i))}),this.markDirty(),this}some(t){return this.nodes.some(t)}walk(t){return this.each((e,i)=>{var n;try{n=t(e,i)}catch(t){throw e.addToError(t)}return!1!==n&&e.walk&&(n=e.walk(t)),n})}walkAtRules(t,e){return e?t instanceof RegExp?this.walk((i,n)=>{if("atrule"===i.type&&t.test(i.name))return e(i,n)}):this.walk((i,n)=>{if("atrule"===i.type&&i.name===t)return e(i,n)}):(e=t,this.walk((t,i)=>{if("atrule"===t.type)return e(t,i)}))}walkComments(t){return this.walk((e,i)=>{if("comment"===e.type)return t(e,i)})}walkDecls(t,e){return e?t instanceof RegExp?this.walk((i,n)=>{if("decl"===i.type&&t.test(i.prop))return e(i,n)}):this.walk((i,n)=>{if("decl"===i.type&&i.prop===t)return e(i,n)}):(e=t,this.walk((t,i)=>{if("decl"===t.type)return e(t,i)}))}walkRules(t,e){return e?t instanceof RegExp?this.walk((i,n)=>{if("rule"===i.type&&t.test(i.selector))return e(i,n)}):this.walk((i,n)=>{if("rule"===i.type&&i.selector===t)return e(i,n)}):(e=t,this.walk((t,i)=>{if("rule"===t.type)return e(t,i)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};Re.registerParse=t=>{ke=t},Re.registerRule=t=>{xe=t},Re.registerAtRule=t=>{Se=t},Re.registerRoot=t=>{Ce=t};var Ne=Re;Re.default=Re,Re.rebuild=t=>{"atrule"===t.type?Object.setPrototypeOf(t,Se.prototype):"rule"===t.type?Object.setPrototypeOf(t,xe.prototype):"decl"===t.type?Object.setPrototypeOf(t,Ae.prototype):"comment"===t.type?Object.setPrototypeOf(t,Te.prototype):"root"===t.type&&Object.setPrototypeOf(t,Ce.prototype),t[Ie]=!0,t.nodes&&t.nodes.forEach(t=>{Re.rebuild(t)})};var Pe,Be,De=Ne,je=class extends De{constructor(t){super(i({type:"document"},t)),this.nodes||(this.nodes=[])}toResult(t){return void 0===t&&(t={}),new Pe(new Be,this,t).stringify()}};je.registerLazyResult=t=>{Pe=t},je.registerProcessor=t=>{Be=t};var Ue=je;je.default=je;var Le={},Fe=function(t){Le[t]||(Le[t]=!0,"undefined"!=typeof console&&console.warn&&console.warn(t))},ze=class{constructor(t,e){if(void 0===e&&(e={}),this.type="warning",this.text=t,e.node&&e.node.source){var i=e.node.rangeBy(e);this.line=i.start.line,this.column=i.start.column,this.endLine=i.end.line,this.endColumn=i.end.column}for(var n in e)this[n]=e[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},We=ze;ze.default=ze;var $e=We,Ve=class{constructor(t,e,i){this.processor=t,this.messages=[],this.root=e,this.opts=i,this.css=void 0,this.map=void 0}toString(){return this.css}warn(t,e){void 0===e&&(e={}),e.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(e.plugin=this.lastPlugin.postcssPlugin);var i=new $e(t,e);return this.messages.push(i),i}warnings(){return this.messages.filter(t=>"warning"===t.type)}get content(){return this.css}},He=Ve;Ve.default=Ve;var qe="'".charCodeAt(0),Je='"'.charCodeAt(0),Ge="\\".charCodeAt(0),Ze="/".charCodeAt(0),Ye="\n".charCodeAt(0),Ke=" ".charCodeAt(0),Xe="\f".charCodeAt(0),Qe="\t".charCodeAt(0),ti="\r".charCodeAt(0),ei="[".charCodeAt(0),ii="]".charCodeAt(0),ni="(".charCodeAt(0),ri=")".charCodeAt(0),si="{".charCodeAt(0),oi="}".charCodeAt(0),ai=";".charCodeAt(0),li="*".charCodeAt(0),hi=":".charCodeAt(0),ui="@".charCodeAt(0),ci=/[\t\n\f\r "#'()/;[\\\]{}]/g,di=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,vi=/.[\r\n"'(/\\]/,fi=/[\da-f]/i,pi=Ne,mi=class extends pi{constructor(t){super(t),this.type="atrule"}append(){return this.proxyOf.nodes||(this.nodes=[]),super.append(...arguments)}prepend(){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...arguments)}},gi=mi;mi.default=mi,pi.registerAtRule(mi);var bi,yi,wi=Ne,ki=class extends wi{constructor(t){super(t),this.type="root",this.nodes||(this.nodes=[])}normalize(t,e,i){var n=super.normalize(t);if(e)if("prepend"===i)this.nodes.length>1?e.raws.before=this.nodes[1].raws.before:delete e.raws.before;else if(this.first!==e)for(var r of n)r.raws.before=e.raws.before;return n}removeChild(t,e){var i=this.index(t);return!e&&0===i&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[i].raws.before),super.removeChild(t)}toResult(t){return void 0===t&&(t={}),new bi(new yi,this,t).stringify()}};ki.registerLazyResult=t=>{bi=t},ki.registerProcessor=t=>{yi=t};var xi=ki;ki.default=ki,wi.registerRoot(ki);var Si={comma:t=>Si.split(t,[","],!0),space:t=>Si.split(t,[" ","\n","\t"]),split(t,e,i){var n=[],r="",s=!1,o=0,a=!1,l="",h=!1;for(var u of t)h?h=!1:"\\"===u?h=!0:a?u===l&&(a=!1):'"'===u||"'"===u?(a=!0,l=u):"("===u?o+=1:")"===u?o>0&&(o-=1):0===o&&e.includes(u)&&(s=!0),s?(""!==r&&n.push(r.trim()),r="",s=!1):r+=u;return(i||""!==r)&&n.push(r.trim()),n}},Ci=Si;Si.default=Si;var _i=Ne,Ii=Ci,Ai=class extends _i{constructor(t){super(t),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return Ii.comma(this.selector)}set selectors(t){var e=this.selector?this.selector.match(/,\s*/):null,i=e?e[0]:","+this.raw("between","beforeOpen");this.selector=t.join(i)}},Ti=Ai;Ai.default=Ai,_i.registerRule(Ai);var Ei=Dt,Mi=function(t,e){void 0===e&&(e={});var i,n,r,s,o,a,l,h,u,c,d=t.css.valueOf(),v=e.ignoreErrors,f=d.length,p=0,m=[],g=[];function b(e){throw t.error("Unclosed "+e,p)}return{back:function(t){g.push(t)},endOfFile:function(){return 0===g.length&&p>=f},nextToken:function(t){if(g.length)return g.pop();if(!(p>=f)){var e=!!t&&t.ignoreUnclosed;switch(i=d.charCodeAt(p)){case Ye:case Ke:case Qe:case ti:case Xe:n=p;do{n+=1,i=d.charCodeAt(n)}while(i===Ke||i===Ye||i===Qe||i===ti||i===Xe);c=["space",d.slice(p,n)],p=n-1;break;case ei:case ii:case si:case oi:case hi:case ai:case ri:var y=String.fromCharCode(i);c=[y,y,p];break;case ni:if(h=m.length?m.pop()[1]:"",u=d.charCodeAt(p+1),"url"===h&&u!==qe&&u!==Je&&u!==Ke&&u!==Ye&&u!==Qe&&u!==Xe&&u!==ti){n=p;do{if(a=!1,-1===(n=d.indexOf(")",n+1))){if(v||e){n=p;break}b("bracket")}for(l=n;d.charCodeAt(l-1)===Ge;)l-=1,a=!a}while(a);c=["brackets",d.slice(p,n+1),p,n],p=n}else n=d.indexOf(")",p+1),s=d.slice(p,n+1),-1===n||vi.test(s)?c=["(","(",p]:(c=["brackets",s,p,n],p=n);break;case qe:case Je:r=i===qe?"'":'"',n=p;do{if(a=!1,-1===(n=d.indexOf(r,n+1))){if(v||e){n=p+1;break}b("string")}for(l=n;d.charCodeAt(l-1)===Ge;)l-=1,a=!a}while(a);c=["string",d.slice(p,n+1),p,n],p=n;break;case ui:ci.lastIndex=p+1,ci.test(d),n=0===ci.lastIndex?d.length-1:ci.lastIndex-2,c=["at-word",d.slice(p,n+1),p,n],p=n;break;case Ge:for(n=p,o=!0;d.charCodeAt(n+1)===Ge;)n+=1,o=!o;if(i=d.charCodeAt(n+1),o&&i!==Ze&&i!==Ke&&i!==Ye&&i!==Qe&&i!==ti&&i!==Xe&&(n+=1,fi.test(d.charAt(n)))){for(;fi.test(d.charAt(n+1));)n+=1;d.charCodeAt(n+1)===Ke&&(n+=1)}c=["word",d.slice(p,n+1),p,n],p=n;break;default:i===Ze&&d.charCodeAt(p+1)===li?(0===(n=d.indexOf("*/",p+2)+1)&&(v||e?n=d.length:b("comment")),c=["comment",d.slice(p,n+1),p,n],p=n):(di.lastIndex=p+1,di.test(d),n=0===di.lastIndex?d.length-1:di.lastIndex-2,c=["word",d.slice(p,n+1),p,n],m.push(c),p=n)}return p++,c}},position:function(){return p}}},Oi=we,Ri=gi,Ni=xi,Pi=Ti,Bi={empty:!0,space:!0};var Di=class{constructor(t){this.input=t,this.root=new Ni,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:t,start:{column:1,line:1,offset:0}}}atrule(t){var e,i,n,r=new Ri;r.name=t[1].slice(1),""===r.name&&this.unnamedAtrule(r,t),this.init(r,t[2]);for(var s=!1,o=!1,a=[],l=[];!this.tokenizer.endOfFile();){if("("===(e=(t=this.tokenizer.nextToken())[0])||"["===e?l.push("("===e?")":"]"):"{"===e&&l.length>0?l.push("}"):e===l[l.length-1]&&l.pop(),0===l.length){if(";"===e){r.source.end=this.getPosition(t[2]),r.source.end.offset++,this.semicolon=!0;break}if("{"===e){o=!0;break}if("}"===e){if(a.length>0){for(i=a[n=a.length-1];i&&"space"===i[0];)i=a[--n];i&&(r.source.end=this.getPosition(i[3]||i[2]),r.source.end.offset++)}this.end(t);break}a.push(t)}else a.push(t);if(this.tokenizer.endOfFile()){s=!0;break}}r.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(r.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(r,"params",a),s&&(t=a[a.length-1],r.source.end=this.getPosition(t[3]||t[2]),r.source.end.offset++,this.spaces=r.raws.between,r.raws.between="")):(r.raws.afterName="",r.params=""),o&&(r.nodes=[],this.current=r)}checkMissedSemicolon(t){var e=this.colon(t);if(!1!==e){for(var i,n=0,r=e-1;r>=0&&("space"===(i=t[r])[0]||2!==(n+=1));r--);throw this.input.error("Missed semicolon","word"===i[0]?i[3]+1:i[2])}}colon(t){var e,i,n,r=0;for(var[s,o]of t.entries()){if("("===(i=(e=o)[0])&&(r+=1),")"===i&&(r-=1),0===r&&":"===i){if(n){if("word"===n[0]&&"progid"===n[1])continue;return s}this.doubleColon(e)}n=e}return!1}comment(t){var e=new Oi;this.init(e,t[2]),e.source.end=this.getPosition(t[3]||t[2]),e.source.end.offset++;var i=t[1].slice(2,-2);if(/^\s*$/.test(i))e.text="",e.raws.left=i,e.raws.right="";else{var n=i.match(/^(\s*)([^]*\S)(\s*)$/);e.text=n[2],e.raws.left=n[1],e.raws.right=n[3]}}createTokenizer(){this.tokenizer=Mi(this.input)}decl(t,e){var i=new Ei;this.init(i,t[0][2]);var n,r=t[t.length-1];for(";"===r[0]&&(this.semicolon=!0,t.pop()),i.source.end=this.getPosition(r[3]||r[2]||function(t){for(var e=t.length-1;e>=0;e--){var i=t[e],n=i[3]||i[2];if(n)return n}}(t)),i.source.end.offset++;"word"!==t[0][0];)1===t.length&&this.unknownWord(t),i.raws.before+=t.shift()[1];for(i.source.start=this.getPosition(t[0][2]),i.prop="";t.length;){var s=t[0][0];if(":"===s||"space"===s||"comment"===s)break;i.prop+=t.shift()[1]}for(i.raws.between="";t.length;){if(":"===(n=t.shift())[0]){i.raws.between+=n[1];break}"word"===n[0]&&/\w/.test(n[1])&&this.unknownWord([n]),i.raws.between+=n[1]}"_"!==i.prop[0]&&"*"!==i.prop[0]||(i.raws.before+=i.prop[0],i.prop=i.prop.slice(1));for(var o,a=[];t.length&&("space"===(o=t[0][0])||"comment"===o);)a.push(t.shift());this.precheckMissedSemicolon(t);for(var l=t.length-1;l>=0;l--){if("!important"===(n=t[l])[1].toLowerCase()){i.important=!0;var h=this.stringFrom(t,l);" !important"!==(h=this.spacesFromEnd(t)+h)&&(i.raws.important=h);break}if("important"===n[1].toLowerCase()){for(var u=t.slice(0),c="",d=l;d>0;d--){var v=u[d][0];if(0===c.trim().indexOf("!")&&"space"!==v)break;c=u.pop()[1]+c}0===c.trim().indexOf("!")&&(i.important=!0,i.raws.important=c,t=u)}if("space"!==n[0]&&"comment"!==n[0])break}var f=t.some(t=>"space"!==t[0]&&"comment"!==t[0]);f&&(i.raws.between+=a.map(t=>t[1]).join(""),a=[]),this.raw(i,"value",a.concat(t),e),i.value.includes(":")&&!e&&this.checkMissedSemicolon(t)}doubleColon(t){throw this.input.error("Double colon",{offset:t[2]},{offset:t[2]+t[1].length})}emptyRule(t){var e=new Pi;this.init(e,t[2]),e.selector="",e.raws.between="",this.current=e}end(t){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(t[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(t)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(t){if(this.spaces+=t[1],this.current.nodes){var e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(t){var e=this.input.fromOffset(t);return{column:e.col,line:e.line,offset:t}}init(t,e){this.current.push(t),t.source={input:this.input,start:this.getPosition(e)},t.raws.before=this.spaces,this.spaces="","comment"!==t.type&&(this.semicolon=!1)}other(t){for(var e=!1,i=null,n=!1,r=null,s=[],o=t[1].startsWith("--"),a=[],l=t;l;){if(i=l[0],a.push(l),"("===i||"["===i)r||(r=l),s.push("("===i?")":"]");else if(o&&n&&"{"===i)r||(r=l),s.push("}");else if(0===s.length){if(";"===i){if(n)return void this.decl(a,o);break}if("{"===i)return void this.rule(a);if("}"===i){this.tokenizer.back(a.pop()),e=!0;break}":"===i&&(n=!0)}else i===s[s.length-1]&&(s.pop(),0===s.length&&(r=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(e=!0),s.length>0&&this.unclosedBracket(r),e&&n){if(!o)for(;a.length&&("space"===(l=a[a.length-1][0])||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,o)}else this.unknownWord(a)}parse(){for(var t;!this.tokenizer.endOfFile();)switch((t=this.tokenizer.nextToken())[0]){case"space":this.spaces+=t[1];break;case";":this.freeSemicolon(t);break;case"}":this.end(t);break;case"comment":this.comment(t);break;case"at-word":this.atrule(t);break;case"{":this.emptyRule(t);break;default:this.other(t)}this.endFile()}precheckMissedSemicolon(){}raw(t,e,i,n){for(var r,s,o,a,l=i.length,h="",u=!0,c=0;c<l;c+=1)"space"!==(s=(r=i[c])[0])||c!==l-1||n?"comment"===s?(a=i[c-1]?i[c-1][0]:"empty",o=i[c+1]?i[c+1][0]:"empty",Bi[a]||Bi[o]||","===h.slice(-1)?u=!1:h+=r[1]):h+=r[1]:u=!1;if(!u){var d=i.reduce((t,e)=>t+e[1],"");t.raws[e]={raw:d,value:h}}t[e]=h}rule(t){t.pop();var e=new Pi;this.init(e,t[0][2]),e.raws.between=this.spacesAndCommentsFromEnd(t),this.raw(e,"selector",t),this.current=e}spacesAndCommentsFromEnd(t){for(var e,i="";t.length&&("space"===(e=t[t.length-1][0])||"comment"===e);)i=t.pop()[1]+i;return i}spacesAndCommentsFromStart(t){for(var e,i="";t.length&&("space"===(e=t[0][0])||"comment"===e);)i+=t.shift()[1];return i}spacesFromEnd(t){for(var e="";t.length&&"space"===t[t.length-1][0];)e=t.pop()[1]+e;return e}stringFrom(t,e){for(var i="",n=e;n<t.length;n++)i+=t[n][1];return t.splice(e,t.length-e),i}unclosedBlock(){var t=this.current.source.start;throw this.input.error("Unclosed block",t.line,t.column)}unclosedBracket(t){throw this.input.error("Unclosed bracket",{offset:t[2]},{offset:t[2]+1})}unexpectedClose(t){throw this.input.error("Unexpected }",{offset:t[2]},{offset:t[2]+1})}unknownWord(t){throw this.input.error("Unknown word",{offset:t[0][2]},{offset:t[0][2]+t[0][1].length})}unnamedAtrule(t,e){throw this.input.error("At-rule without name",{offset:e[2]},{offset:e[2]+e[1].length})}},ji=Ne,Ui=Di,Li=oe;function Fi(t,e){var i=new Li(t,e),n=new Ui(i);try{n.parse()}catch(t){throw"production"!==process.env.NODE_ENV&&"CssSyntaxError"===t.name&&e&&e.from&&(/\.scss$/i.test(e.from)?t.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.sass/i.test(e.from)?t.message+="\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser":/\.less$/i.test(e.from)&&(t.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),t}return n.root}var zi=Fi;Fi.default=Fi,ji.registerParse(Fi);var{isClean:Wi,my:$i}=yt,Vi=ge,Hi=_t,qi=Ne,Ji=Ue,Gi=Fe,Zi=He,Yi=zi,Ki=xi,Xi={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Qi={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},tn={Once:!0,postcssPlugin:!0,prepare:!0};function en(t){return"object"==typeof t&&"function"==typeof t.then}function nn(t){var e=!1,i=Xi[t.type];return"decl"===t.type?e=t.prop.toLowerCase():"atrule"===t.type&&(e=t.name.toLowerCase()),e&&t.append?[i,i+"-"+e,0,i+"Exit",i+"Exit-"+e]:e?[i,i+"-"+e,i+"Exit",i+"Exit-"+e]:t.append?[i,0,i+"Exit"]:[i,i+"Exit"]}function rn(t){return{eventIndex:0,events:"document"===t.type?["Document",0,"DocumentExit"]:"root"===t.type?["Root",0,"RootExit"]:nn(t),iterator:0,node:t,visitorIndex:0,visitors:[]}}function sn(t){return t[Wi]=!1,t.nodes&&t.nodes.forEach(t=>sn(t)),t}var on={},an=class t{constructor(e,n,r){var s;if(this.stringified=!1,this.processed=!1,"object"!=typeof n||null===n||"root"!==n.type&&"document"!==n.type)if(n instanceof t||n instanceof Zi)s=sn(n.root),n.map&&(void 0===r.map&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=n.map);else{var o=Yi;r.syntax&&(o=r.syntax.parse),r.parser&&(o=r.parser),o.parse&&(o=o.parse);try{s=o(n,r)}catch(t){this.processed=!0,this.error=t}s&&!s[$i]&&qi.rebuild(s)}else s=sn(n);this.result=new Zi(e,s,r),this.helpers=i({},on,{postcss:on,result:this.result}),this.plugins=this.processor.plugins.map(t=>"object"==typeof t&&t.prepare?i({},t,t.prepare(this.result)):t)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(t,e){var i=this.result.lastPlugin;try{if(e&&e.addToError(t),this.error=t,"CssSyntaxError"!==t.name||t.plugin){if(i.postcssVersion&&"production"!==process.env.NODE_ENV){var n=i.postcssPlugin,r=i.postcssVersion,s=this.result.processor.version,o=r.split("."),a=s.split(".");(o[0]!==a[0]||parseInt(o[1])>parseInt(a[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+s+", but "+n+" uses "+r+". Perhaps this is the source of the error below.")}}else t.plugin=i.postcssPlugin,t.setMessage()}catch(t){console&&console.error&&console.error(t)}return t}prepareVisitors(){this.listeners={};var t=(t,e,i)=>{this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push([t,i])};for(var e of this.plugins)if("object"==typeof e)for(var i in e){if(!Qi[i]&&/^[A-Z]/.test(i))throw new Error("Unknown event "+i+" in "+e.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!tn[i])if("object"==typeof e[i])for(var n in e[i])t(e,"*"===n?i:i+"-"+n.toLowerCase(),e[i][n]);else"function"==typeof e[i]&&t(e,i,e[i])}this.hasListener=Object.keys(this.listeners).length>0}runAsync(){var t=this;return e(function*(){t.plugin=0;for(var e=0;e<t.plugins.length;e++){var i=t.plugins[e],n=t.runOnRoot(i);if(en(n))try{yield n}catch(e){throw t.handleError(e)}}if(t.prepareVisitors(),t.hasListener){for(var r=t.result.root;!r[Wi];){r[Wi]=!0;for(var s=[rn(r)];s.length>0;){var o=t.visitTick(s);if(en(o))try{yield o}catch(e){var a=s[s.length-1].node;throw t.handleError(e,a)}}}if(t.listeners.OnceExit){var l=function*(e){t.result.lastPlugin=h;try{if("document"===r.type){var i=r.nodes.map(i=>e(i,t.helpers));yield Promise.all(i)}else yield e(r,t.helpers)}catch(e){throw t.handleError(e)}};for(var[h,u]of t.listeners.OnceExit)yield*l(u)}}return t.processed=!0,t.stringify()})()}runOnRoot(t){this.result.lastPlugin=t;try{if("object"==typeof t&&t.Once){if("document"===this.result.root.type){var e=this.result.root.nodes.map(e=>t.Once(e,this.helpers));return en(e[0])?Promise.all(e):e}return t.Once(this.result.root,this.helpers)}if("function"==typeof t)return t(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var t=this.result.opts,e=Hi;t.syntax&&(e=t.syntax.stringify),t.stringifier&&(e=t.stringifier),e.stringify&&(e=e.stringify);var i=new Vi(e,this.result.root,this.result.opts).generate();return this.result.css=i[0],this.result.map=i[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(var t of this.plugins){if(en(this.runOnRoot(t)))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var e=this.result.root;!e[Wi];)e[Wi]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(var i of e.nodes)this.visitSync(this.listeners.OnceExit,i);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(t,e){return"production"!==process.env.NODE_ENV&&("from"in this.opts||Gi("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,e)}toString(){return this.css}visitSync(t,e){for(var[i,n]of t){this.result.lastPlugin=i;var r=void 0;try{r=n(e,this.helpers)}catch(t){throw this.handleError(t,e.proxyOf)}if("root"!==e.type&&"document"!==e.type&&!e.parent)return!0;if(en(r))throw this.getAsyncError()}}visitTick(t){var e=t[t.length-1],{node:i,visitors:n}=e;if("root"===i.type||"document"===i.type||i.parent){if(n.length>0&&e.visitorIndex<n.length){var[r,s]=n[e.visitorIndex];e.visitorIndex+=1,e.visitorIndex===n.length&&(e.visitors=[],e.visitorIndex=0),this.result.lastPlugin=r;try{return s(i.toProxy(),this.helpers)}catch(t){throw this.handleError(t,i)}}if(0!==e.iterator){for(var o,a=e.iterator;o=i.nodes[i.indexes[a]];)if(i.indexes[a]+=1,!o[Wi])return o[Wi]=!0,void t.push(rn(o));e.iterator=0,delete i.indexes[a]}for(var l=e.events;e.eventIndex<l.length;){var h=l[e.eventIndex];if(e.eventIndex+=1,0===h)return void(i.nodes&&i.nodes.length&&(i[Wi]=!0,e.iterator=i.getIterator()));if(this.listeners[h])return void(e.visitors=this.listeners[h])}t.pop()}else t.pop()}walkSync(t){t[Wi]=!0;var e=nn(t);for(var i of e)if(0===i)t.nodes&&t.each(t=>{t[Wi]||this.walkSync(t)});else{var n=this.listeners[i];if(n&&this.visitSync(n,t.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};an.registerPostcss=t=>{on=t};var ln=an;an.default=an,Ki.registerLazyResult(an),Ji.registerLazyResult(an);var hn=ge,un=_t,cn=Fe,dn=zi,vn=He,fn=class{constructor(t,e,i){var n;e=e.toString(),this.stringified=!1,this._processor=t,this._css=e,this._opts=i,this._map=void 0;var r=un;this.result=new vn(this._processor,n,this._opts),this.result.css=e;var s=this;Object.defineProperty(this.result,"root",{get:()=>s.root});var o=new hn(r,n,this._opts,e);if(o.isMap()){var[a,l]=o.generate();a&&(this.result.css=a),l&&(this.result.map=l)}else o.clearAnnotation(),this.result.css=o.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}sync(){if(this.error)throw this.error;return this.result}then(t,e){return"production"!==process.env.NODE_ENV&&("from"in this._opts||cn("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,e)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;var t,e=dn;try{t=e(this._css,this._opts)}catch(t){this.error=t}if(this.error)throw this.error;return this._root=t,t}get[Symbol.toStringTag](){return"NoWorkResult"}},pn=fn;fn.default=fn;var mn=pn,gn=ln,bn=Ue,yn=xi,wn=class{constructor(t){void 0===t&&(t=[]),this.version="8.4.38",this.plugins=this.normalize(t)}normalize(t){var e=[];for(var i of t)if(!0===i.postcss?i=i():i.postcss&&(i=i.postcss),"object"==typeof i&&Array.isArray(i.plugins))e=e.concat(i.plugins);else if("object"==typeof i&&i.postcssPlugin)e.push(i);else if("function"==typeof i)e.push(i);else{if("object"!=typeof i||!i.parse&&!i.stringify)throw new Error(i+" is not a PostCSS plugin");if("production"!==process.env.NODE_ENV)throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.")}return e}process(t,e){return void 0===e&&(e={}),this.plugins.length||e.parser||e.stringifier||e.syntax?new gn(this,t,e):new mn(this,t,e)}use(t){return this.plugins=this.plugins.concat(this.normalize([t])),this}},kn=wn;wn.default=wn,yn.registerProcessor(wn),bn.registerProcessor(wn);var xn=Dt,Sn=Ht,Cn=we,_n=gi,In=oe,An=xi,Tn=Ti;function En(t,e){if(Array.isArray(t))return t.map(t=>En(t));var{inputs:r}=t,a=n(t,s);if(r)for(var l of(e=[],r)){var h=i({},l,{__proto__:In.prototype});h.map&&(h.map=i({},h.map,{__proto__:Sn.prototype})),e.push(h)}if(a.nodes&&(a.nodes=t.nodes.map(t=>En(t,e))),a.source){var u=a.source,{inputId:c}=u,d=n(u,o);a.source=d,null!=c&&(a.source.input=e[c])}if("root"===a.type)return new An(a);if("decl"===a.type)return new xn(a);if("rule"===a.type)return new Tn(a);if("comment"===a.type)return new Cn(a);if("atrule"===a.type)return new _n(a);throw new Error("Unknown node type: "+t.type)}var Mn=En;En.default=En;var On=bt,Rn=Dt,Nn=ln,Pn=Ne,Bn=kn,Dn=_t,jn=Mn,Un=Ue,Ln=We,Fn=we,zn=gi,Wn=He,$n=oe,Vn=zi,Hn=Ci,qn=Ti,Jn=xi,Gn=Nt;function Zn(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new Bn(e)}Zn.plugin=function(t,e){var i,n=!1;function r(){console&&console.warn&&!n&&(n=!0,console.warn(t+": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(t+": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226"));var i=e(...arguments);return i.postcssPlugin=t,i.postcssVersion=(new Bn).version,i}return Object.defineProperty(r,"postcss",{get:()=>(i||(i=r()),i)}),r.process=function(t,e,i){return Zn([r(i)]).process(t,e)},r},Zn.stringify=Dn,Zn.parse=Vn,Zn.fromJSON=jn,Zn.list=Hn,Zn.comment=t=>new Fn(t),Zn.atRule=t=>new zn(t),Zn.decl=t=>new Rn(t),Zn.rule=t=>new qn(t),Zn.root=t=>new Jn(t),Zn.document=t=>new Un(t),Zn.CssSyntaxError=On,Zn.Declaration=Rn,Zn.Container=Pn,Zn.Processor=Bn,Zn.Document=Un,Zn.Comment=Fn,Zn.Warning=Ln,Zn.AtRule=zn,Zn.Result=Wn,Zn.Input=$n,Zn.Rule=qn,Zn.Root=Jn,Zn.Node=Gn,Nn.registerPostcss(Zn);var Yn=Zn;Zn.default=Zn;var Kn=lt(Yn);Kn.stringify,Kn.fromJSON,Kn.plugin,Kn.parse,Kn.list,Kn.document,Kn.comment,Kn.atRule,Kn.rule,Kn.decl,Kn.root,Kn.CssSyntaxError,Kn.Declaration,Kn.Container,Kn.Processor,Kn.Document,Kn.Comment,Kn.Warning,Kn.AtRule,Kn.Result,Kn.Input,Kn.Rule,Kn.Root,Kn.Node;var Xn=Object.defineProperty,Qn=(t,e,i)=>((t,e,i)=>e in t?Xn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);function tr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function er(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),i}var ir={exports:{}},nr=String,rr=function(){return{isColorSupported:!1,reset:nr,bold:nr,dim:nr,italic:nr,underline:nr,inverse:nr,hidden:nr,strikethrough:nr,black:nr,red:nr,green:nr,yellow:nr,blue:nr,magenta:nr,cyan:nr,white:nr,gray:nr,bgBlack:nr,bgRed:nr,bgGreen:nr,bgYellow:nr,bgBlue:nr,bgMagenta:nr,bgCyan:nr,bgWhite:nr}};ir.exports=rr(),ir.exports.createColors=rr;var sr=ir.exports,or=er(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),ar=sr,lr=or,hr=class t extends Error{constructor(e,i,n,r,s,o){super(e),this.name="CssSyntaxError",this.reason=e,s&&(this.file=s),r&&(this.source=r),o&&(this.plugin=o),void 0!==i&&void 0!==n&&("number"==typeof i?(this.line=i,this.column=n):(this.line=i.line,this.column=i.column,this.endLine=n.line,this.endColumn=n.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,t)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(t){if(!this.source)return"";var e=this.source;null==t&&(t=ar.isColorSupported),lr&&t&&(e=lr(e));var i,n,r=e.split(/\r?\n/),s=Math.max(this.line-3,0),o=Math.min(this.line+2,r.length),a=String(o).length;if(t){var{bold:l,gray:h,red:u}=ar.createColors(!0);i=t=>l(u(t)),n=t=>h(t)}else i=n=t=>t;return r.slice(s,o).map((t,e)=>{var r=s+1+e,o=" "+(" "+r).slice(-a)+" | ";if(r===this.line){var l=n(o.replace(/\d/g," "))+t.slice(0,this.column-1).replace(/[^\t]/g," ");return i(">")+n(o)+t+"\n "+l+i("^")}return" "+n(o)+t}).join("\n")}toString(){var t=this.showSourceCode();return t&&(t="\n\n"+t+"\n"),this.name+": "+this.message+t}},ur=hr;hr.default=hr;var cr={};cr.isClean=Symbol("isClean"),cr.my=Symbol("my");var dr={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var vr=class{constructor(t){this.builder=t}atrule(t,e){var i="@"+t.name,n=t.params?this.rawValue(t,"params"):"";if(void 0!==t.raws.afterName?i+=t.raws.afterName:n&&(i+=" "),t.nodes)this.block(t,i+n);else{var r=(t.raws.between||"")+(e?";":"");this.builder(i+n+r,t)}}beforeAfter(t,e){var i;i="decl"===t.type?this.raw(t,null,"beforeDecl"):"comment"===t.type?this.raw(t,null,"beforeComment"):"before"===e?this.raw(t,null,"beforeRule"):this.raw(t,null,"beforeClose");for(var n=t.parent,r=0;n&&"root"!==n.type;)r+=1,n=n.parent;if(i.includes("\n")){var s=this.raw(t,null,"indent");if(s.length)for(var o=0;o<r;o++)i+=s}return i}block(t,e){var i,n=this.raw(t,"between","beforeOpen");this.builder(e+n+"{",t,"start"),t.nodes&&t.nodes.length?(this.body(t),i=this.raw(t,"after")):i=this.raw(t,"after","emptyBody"),i&&this.builder(i),this.builder("}",t,"end")}body(t){for(var e=t.nodes.length-1;e>0&&"comment"===t.nodes[e].type;)e-=1;for(var i=this.raw(t,"semicolon"),n=0;n<t.nodes.length;n++){var r=t.nodes[n],s=this.raw(r,"before");s&&this.builder(s),this.stringify(r,e!==n||i)}}comment(t){var e=this.raw(t,"left","commentLeft"),i=this.raw(t,"right","commentRight");this.builder("/*"+e+t.text+i+"*/",t)}decl(t,e){var i=this.raw(t,"between","colon"),n=t.prop+i+this.rawValue(t,"value");t.important&&(n+=t.raws.important||" !important"),e&&(n+=";"),this.builder(n,t)}document(t){this.body(t)}raw(t,e,i){var n;if(i||(i=e),e&&void 0!==(n=t.raws[e]))return n;var r=t.parent;if("before"===i){if(!r||"root"===r.type&&r.first===t)return"";if(r&&"document"===r.type)return""}if(!r)return dr[i];var s=t.root();if(s.rawCache||(s.rawCache={}),void 0!==s.rawCache[i])return s.rawCache[i];if("before"===i||"after"===i)return this.beforeAfter(t,i);var o,a="raw"+((o=i)[0].toUpperCase()+o.slice(1));return this[a]?n=this[a](s,t):s.walk(t=>{if(void 0!==(n=t.raws[e]))return!1}),void 0===n&&(n=dr[i]),s.rawCache[i]=n,n}rawBeforeClose(t){var e;return t.walk(t=>{if(t.nodes&&t.nodes.length>0&&void 0!==t.raws.after)return(e=t.raws.after).includes("\n")&&(e=e.replace(/[^\n]+$/,"")),!1}),e&&(e=e.replace(/\S/g,"")),e}rawBeforeComment(t,e){var i;return t.walkComments(t=>{if(void 0!==t.raws.before)return(i=t.raws.before).includes("\n")&&(i=i.replace(/[^\n]+$/,"")),!1}),void 0===i?i=this.raw(e,null,"beforeDecl"):i&&(i=i.replace(/\S/g,"")),i}rawBeforeDecl(t,e){var i;return t.walkDecls(t=>{if(void 0!==t.raws.before)return(i=t.raws.before).includes("\n")&&(i=i.replace(/[^\n]+$/,"")),!1}),void 0===i?i=this.raw(e,null,"beforeRule"):i&&(i=i.replace(/\S/g,"")),i}rawBeforeOpen(t){var e;return t.walk(t=>{if("decl"!==t.type&&void 0!==(e=t.raws.between))return!1}),e}rawBeforeRule(t){var e;return t.walk(i=>{if(i.nodes&&(i.parent!==t||t.first!==i)&&void 0!==i.raws.before)return(e=i.raws.before).includes("\n")&&(e=e.replace(/[^\n]+$/,"")),!1}),e&&(e=e.replace(/\S/g,"")),e}rawColon(t){var e;return t.walkDecls(t=>{if(void 0!==t.raws.between)return e=t.raws.between.replace(/[^\s:]/g,""),!1}),e}rawEmptyBody(t){var e;return t.walk(t=>{if(t.nodes&&0===t.nodes.length&&void 0!==(e=t.raws.after))return!1}),e}rawIndent(t){return t.raws.indent?t.raws.indent:(t.walk(i=>{var n=i.parent;if(n&&n!==t&&n.parent&&n.parent===t&&void 0!==i.raws.before){var r=i.raws.before.split("\n");return e=(e=r[r.length-1]).replace(/\S/g,""),!1}}),e);var e}rawSemicolon(t){var e;return t.walk(t=>{if(t.nodes&&t.nodes.length&&"decl"===t.last.type&&void 0!==(e=t.raws.semicolon))return!1}),e}rawValue(t,e){var i=t[e],n=t.raws[e];return n&&n.value===i?n.raw:i}root(t){this.body(t),t.raws.after&&this.builder(t.raws.after)}rule(t){this.block(t,this.rawValue(t,"selector")),t.raws.ownSemicolon&&this.builder(t.raws.ownSemicolon,t,"end")}stringify(t,e){if(!this[t.type])throw new Error("Unknown AST node type "+t.type+". Maybe you need to change PostCSS stringifier.");this[t.type](t,e)}},fr=vr;vr.default=vr;var pr=fr;function mr(t,e){new pr(e).stringify(t)}var gr=mr;mr.default=mr;var{isClean:br,my:yr}=cr,wr=ur,kr=fr,xr=gr;function Sr(t,e){var i=new t.constructor;for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&"proxyCache"!==n){var r=t[n],s=typeof r;"parent"===n&&"object"===s?e&&(i[n]=e):"source"===n?i[n]=r:Array.isArray(r)?i[n]=r.map(t=>Sr(t,i)):("object"===s&&null!==r&&(r=Sr(r)),i[n]=r)}return i}var Cr=class{constructor(t){for(var e in void 0===t&&(t={}),this.raws={},this[br]=!1,this[yr]=!0,t)if("nodes"===e)for(var i of(this.nodes=[],t[e]))"function"==typeof i.clone?this.append(i.clone()):this.append(i);else this[e]=t[e]}addToError(t){if(t.postcssNode=this,t.stack&&this.source&&/\n\s{4}at /.test(t.stack)){var e=this.source;t.stack=t.stack.replace(/\n\s{4}at /,"$&"+e.input.from+":"+e.start.line+":"+e.start.column+"$&")}return t}after(t){return this.parent.insertAfter(this,t),this}assign(t){for(var e in void 0===t&&(t={}),t)this[e]=t[e];return this}before(t){return this.parent.insertBefore(this,t),this}cleanRaws(t){delete this.raws.before,delete this.raws.after,t||delete this.raws.between}clone(t){void 0===t&&(t={});var e=Sr(this);for(var i in t)e[i]=t[i];return e}cloneAfter(t){void 0===t&&(t={});var e=this.clone(t);return this.parent.insertAfter(this,e),e}cloneBefore(t){void 0===t&&(t={});var e=this.clone(t);return this.parent.insertBefore(this,e),e}error(t,e){if(void 0===e&&(e={}),this.source){var{end:i,start:n}=this.rangeBy(e);return this.source.input.error(t,{column:n.column,line:n.line},{column:i.column,line:i.line},e)}return new wr(t)}getProxyProcessor(){return{get:(t,e)=>"proxyOf"===e?t:"root"===e?()=>t.root().toProxy():t[e],set:(t,e,i)=>(t[e]===i||(t[e]=i,"prop"!==e&&"value"!==e&&"name"!==e&&"params"!==e&&"important"!==e&&"text"!==e||t.markDirty()),!0)}}markDirty(){if(this[br]){this[br]=!1;for(var t=this;t=t.parent;)t[br]=!1}}next(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t+1]}}positionBy(t,e){var i=this.source.start;if(t.index)i=this.positionInside(t.index,e);else if(t.word){var n=(e=this.toString()).indexOf(t.word);-1!==n&&(i=this.positionInside(n,e))}return i}positionInside(t,e){for(var i=e||this.toString(),n=this.source.start.column,r=this.source.start.line,s=0;s<t;s++)"\n"===i[s]?(n=1,r+=1):n+=1;return{column:n,line:r}}prev(){if(this.parent){var t=this.parent.index(this);return this.parent.nodes[t-1]}}rangeBy(t){var e={column:this.source.start.column,line:this.source.start.line},i=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:e.column+1,line:e.line};if(t.word){var n=this.toString(),r=n.indexOf(t.word);-1!==r&&(e=this.positionInside(r,n),i=this.positionInside(r+t.word.length,n))}else t.start?e={column:t.start.column,line:t.start.line}:t.index&&(e=this.positionInside(t.index)),t.end?i={column:t.end.column,line:t.end.line}:"number"==typeof t.endIndex?i=this.positionInside(t.endIndex):t.index&&(i=this.positionInside(t.index+1));return(i.line<e.line||i.line===e.line&&i.column<=e.column)&&(i={column:e.column+1,line:e.line}),{end:i,start:e}}raw(t,e){return(new kr).raw(this,t,e)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(){if(this.parent){for(var t=this,e=!1,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];for(var s of n)s===this?e=!0:e?(this.parent.insertAfter(t,s),t=s):this.parent.insertBefore(t,s);e||this.remove()}return this}root(){for(var t=this;t.parent&&"document"!==t.parent.type;)t=t.parent;return t}toJSON(t,e){var i={},n=null==e;e=e||new Map;var r=0;for(var s in this)if(Object.prototype.hasOwnProperty.call(this,s)&&"parent"!==s&&"proxyCache"!==s){var o=this[s];if(Array.isArray(o))i[s]=o.map(t=>"object"==typeof t&&t.toJSON?t.toJSON(null,e):t);else if("object"==typeof o&&o.toJSON)i[s]=o.toJSON(null,e);else if("source"===s){var a=e.get(o.input);null==a&&(a=r,e.set(o.input,r),r++),i[s]={end:o.end,inputId:a,start:o.start}}else i[s]=o}return n&&(i.inputs=[...e.keys()].map(t=>t.toJSON())),i}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(t){void 0===t&&(t=xr),t.stringify&&(t=t.stringify);var e="";return t(this,t=>{e+=t}),e}warn(t,e,i){var n={node:this};for(var r in i)n[r]=i[r];return t.warn(e,n)}get proxyOf(){return this}},_r=Cr;Cr.default=Cr;var Ir=_r,Ar=class extends Ir{constructor(t){t&&void 0!==t.value&&"string"!=typeof t.value&&(t=i({},t,{value:String(t.value)})),super(t),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Tr=Ar;Ar.default=Ar;var Er={nanoid:function(t){void 0===t&&(t=21);for(var e="",i=t;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e}},{SourceMapConsumer:Mr,SourceMapGenerator:Or}=or,{existsSync:Rr,readFileSync:Nr}=or,{dirname:Pr,join:Br}=or;var Dr=class{constructor(t,e){if(!1!==e.map){this.loadAnnotation(t),this.inline=this.startWith(this.annotation,"data:");var i=e.map?e.map.prev:void 0,n=this.loadMap(e.from,i);!this.mapFile&&e.from&&(this.mapFile=e.from),this.mapFile&&(this.root=Pr(this.mapFile)),n&&(this.text=n)}}consumer(){return this.consumerCache||(this.consumerCache=new Mr(this.text)),this.consumerCache}decodeInline(t){var e;if(/^data:application\/json;charset=utf-?8,/.test(t)||/^data:application\/json,/.test(t))return decodeURIComponent(t.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(t)||/^data:application\/json;base64,/.test(t))return e=t.substr(RegExp.lastMatch.length),Buffer?Buffer.from(e,"base64").toString():window.atob(e);var i=t.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+i)}getAnnotationURL(t){return t.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(t){return"object"==typeof t&&("string"==typeof t.mappings||"string"==typeof t._mappings||Array.isArray(t.sections))}loadAnnotation(t){var e=t.match(/\/\*\s*# sourceMappingURL=/gm);if(e){var i=t.lastIndexOf(e.pop()),n=t.indexOf("*/",i);i>-1&&n>-1&&(this.annotation=this.getAnnotationURL(t.substring(i,n)))}}loadFile(t){if(this.root=Pr(t),Rr(t))return this.mapFile=t,Nr(t,"utf-8").toString().trim()}loadMap(t,e){if(!1===e)return!1;if(e){if("string"==typeof e)return e;if("function"!=typeof e){if(e instanceof Mr)return Or.fromSourceMap(e).toString();if(e instanceof Or)return e.toString();if(this.isMap(e))return JSON.stringify(e);throw new Error("Unsupported previous source map format: "+e.toString())}var i=e(t);if(i){var n=this.loadFile(i);if(!n)throw new Error("Unable to load previous source map: "+i.toString());return n}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var r=this.annotation;return t&&(r=Br(Pr(t),r)),this.loadFile(r)}}}startWith(t,e){return!!t&&t.substr(0,e.length)===e}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},jr=Dr;Dr.default=Dr;var{SourceMapConsumer:Ur,SourceMapGenerator:Lr}=or,{fileURLToPath:Fr,pathToFileURL:zr}=or,{isAbsolute:Wr,resolve:$r}=or,{nanoid:Vr}=Er,Hr=or,qr=ur,Jr=jr,Gr=Symbol("fromOffsetCache"),Zr=Boolean(Ur&&Lr),Yr=Boolean($r&&Wr),Kr=class{constructor(t,e){if(void 0===e&&(e={}),null==t||"object"==typeof t&&!t.toString)throw new Error("PostCSS received "+t+" instead of CSS string");if(this.css=t.toString(),"\ufeff"===this.css[0]||""===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,e.from&&(!Yr||/^\w+:\/\//.test(e.from)||Wr(e.from)?this.file=e.from:this.file=$r(e.from)),Yr&&Zr){var i=new Jr(this.css,e);if(i.text){this.map=i;var n=i.consumer().file;!this.file&&n&&(this.file=this.mapResolve(n))}}this.file||(this.id="<input css "+Vr(6)+">"),this.map&&(this.map.file=this.from)}error(t,e,i,n){var r,s,o;if(void 0===n&&(n={}),e&&"object"==typeof e){var a=e,l=i;if("number"==typeof a.offset){var h=this.fromOffset(a.offset);e=h.line,i=h.col}else e=a.line,i=a.column;if("number"==typeof l.offset){var u=this.fromOffset(l.offset);s=u.line,o=u.col}else s=l.line,o=l.column}else if(!i){var c=this.fromOffset(e);e=c.line,i=c.col}var d=this.origin(e,i,s,o);return(r=d?new qr(t,void 0===d.endLine?d.line:{column:d.column,line:d.line},void 0===d.endLine?d.column:{column:d.endColumn,line:d.endLine},d.source,d.file,n.plugin):new qr(t,void 0===s?e:{column:i,line:e},void 0===s?i:{column:o,line:s},this.css,this.file,n.plugin)).input={column:i,endColumn:o,endLine:s,line:e,source:this.css},this.file&&(zr&&(r.input.url=zr(this.file).toString()),r.input.file=this.file),r}fromOffset(t){var e;if(this[Gr])e=this[Gr];else{var i=this.css.split("\n");e=new Array(i.length);for(var n=0,r=0,s=i.length;r<s;r++)e[r]=n,n+=i[r].length+1;this[Gr]=e}var o=0;if(t>=e[e.length-1])o=e.length-1;else for(var a,l=e.length-2;o<l;)if(t<e[a=o+(l-o>>1)])l=a-1;else{if(!(t>=e[a+1])){o=a;break}o=a+1}return{col:t-e[o]+1,line:o+1}}mapResolve(t){return/^\w+:\/\//.test(t)?t:$r(this.map.consumer().sourceRoot||this.map.root||".",t)}origin(t,e,i,n){if(!this.map)return!1;var r,s,o=this.map.consumer(),a=o.originalPositionFor({column:e,line:t});if(!a.source)return!1;"number"==typeof i&&(r=o.originalPositionFor({column:n,line:i})),s=Wr(a.source)?zr(a.source):new URL(a.source,this.map.consumer().sourceRoot||zr(this.map.mapFile));var l={column:a.column,endColumn:r&&r.column,endLine:r&&r.line,line:a.line,url:s.toString()};if("file:"===s.protocol){if(!Fr)throw new Error("file: protocol is not available in this PostCSS build");l.file=Fr(s)}var h=o.sourceContentFor(a.source);return h&&(l.source=h),l}toJSON(){var t={};for(var e of["hasBOM","css","file","id"])null!=this[e]&&(t[e]=this[e]);return this.map&&(t.map=i({},this.map),t.map.consumerCache&&(t.map.consumerCache=void 0)),t}get from(){return this.file||this.id}},Xr=Kr;Kr.default=Kr,Hr&&Hr.registerInput&&Hr.registerInput(Kr);var{SourceMapConsumer:Qr,SourceMapGenerator:ts}=or,{dirname:es,relative:is,resolve:ns,sep:rs}=or,{pathToFileURL:ss}=or,os=Xr,as=Boolean(Qr&&ts),ls=Boolean(es&&ns&&is&&rs),hs=class{constructor(t,e,i,n){this.stringify=t,this.mapOpts=i.map||{},this.root=e,this.opts=i,this.css=n,this.originalCSS=n,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}addAnnotation(){var t;t=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";var e="\n";this.css.includes("\r\n")&&(e="\r\n"),this.css+=e+"/*# sourceMappingURL="+t+" */"}applyPrevMaps(){for(var t of this.previous()){var e=this.toUrl(this.path(t.file)),i=t.root||es(t.file),n=void 0;!1===this.mapOpts.sourcesContent?(n=new Qr(t.text)).sourcesContent&&(n.sourcesContent=null):n=t.consumer(),this.map.applySourceMap(n,e,this.toUrl(this.path(i)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root)for(var t,e=this.root.nodes.length-1;e>=0;e--)"comment"===(t=this.root.nodes[e]).type&&0===t.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(e);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),ls&&as&&this.isMap())return this.generateMap();var t="";return this.stringify(this.root,e=>{t+=e}),[t]}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){var t=this.previous()[0].consumer();t.file=this.outputFile(),this.map=ts.fromSourceMap(t,{ignoreInvalidMapping:!0})}else this.map=new ts({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new ts({file:this.outputFile(),ignoreInvalidMapping:!0});var t,e,i=1,n=1,r="<no source>",s={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,(o,a,l)=>{if(this.css+=o,a&&"end"!==l&&(s.generated.line=i,s.generated.column=n-1,a.source&&a.source.start?(s.source=this.sourcePath(a),s.original.line=a.source.start.line,s.original.column=a.source.start.column-1,this.map.addMapping(s)):(s.source=r,s.original.line=1,s.original.column=0,this.map.addMapping(s))),(t=o.match(/\n/g))?(i+=t.length,e=o.lastIndexOf("\n"),n=o.length-e):n+=o.length,a&&"start"!==l){var h=a.parent||{raws:{}};("decl"===a.type||"atrule"===a.type&&!a.nodes)&&a===h.last&&!h.raws.semicolon||(a.source&&a.source.end?(s.source=this.sourcePath(a),s.original.line=a.source.end.line,s.original.column=a.source.end.column-1,s.generated.line=i,s.generated.column=n-2,this.map.addMapping(s)):(s.source=r,s.original.line=1,s.original.column=0,s.generated.line=i,s.generated.column=n-1,this.map.addMapping(s)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(t=>t.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;var t=this.mapOpts.annotation;return(void 0===t||!0===t)&&(!this.previous().length||this.previous().some(t=>t.inline))}isMap(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0}isSourcesContent(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(t=>t.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(t){if(this.mapOpts.absolute)return t;if(60===t.charCodeAt(0))return t;if(/^\w+:\/\//.test(t))return t;var e=this.memoizedPaths.get(t);if(e)return e;var i=this.opts.to?es(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(i=es(ns(i,this.mapOpts.annotation)));var n=is(i,t);return this.memoizedPaths.set(t,n),n}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(t=>{if(t.source&&t.source.input.map){var e=t.source.input.map;this.previousMaps.includes(e)||this.previousMaps.push(e)}});else{var t=new os(this.originalCSS,this.opts);t.map&&this.previousMaps.push(t.map)}return this.previousMaps}setSourcesContent(){var t={};if(this.root)this.root.walk(e=>{if(e.source){var i=e.source.input.from;if(i&&!t[i]){t[i]=!0;var n=this.usesFileUrls?this.toFileUrl(i):this.toUrl(this.path(i));this.map.setSourceContent(n,e.source.input.css)}}});else if(this.css){var e=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(e,this.css)}}sourcePath(t){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(t.source.input.from):this.toUrl(this.path(t.source.input.from))}toBase64(t){return Buffer?Buffer.from(t).toString("base64"):window.btoa(unescape(encodeURIComponent(t)))}toFileUrl(t){var e=this.memoizedFileURLs.get(t);if(e)return e;if(ss){var i=ss(t).toString();return this.memoizedFileURLs.set(t,i),i}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(t){var e=this.memoizedURLs.get(t);if(e)return e;"\\"===rs&&(t=t.replace(/\\/g,"/"));var i=encodeURI(t).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(t,i),i}},us=_r,cs=class extends us{constructor(t){super(t),this.type="comment"}},ds=cs;cs.default=cs;var vs,fs,ps,ms,{isClean:gs,my:bs}=cr,ys=Tr,ws=ds,ks=_r;function xs(t){return t.map(t=>(t.nodes&&(t.nodes=xs(t.nodes)),delete t.source,t))}function Ss(t){if(t[gs]=!1,t.proxyOf.nodes)for(var e of t.proxyOf.nodes)Ss(e)}var Cs=class t extends ks{append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var n of e){var r=this.normalize(n,this.last);for(var s of r)this.proxyOf.nodes.push(s)}return this.markDirty(),this}cleanRaws(t){if(super.cleanRaws(t),this.nodes)for(var e of this.nodes)e.cleanRaws(t)}each(t){if(this.proxyOf.nodes){for(var e,i,n=this.getIterator();this.indexes[n]<this.proxyOf.nodes.length&&(e=this.indexes[n],!1!==(i=t(this.proxyOf.nodes[e],e)));)this.indexes[n]+=1;return delete this.indexes[n],i}}every(t){return this.nodes.every(t)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var t=this.lastEach;return this.indexes[t]=0,t}getProxyProcessor(){return{get:(t,e)=>"proxyOf"===e?t:t[e]?"each"===e||"string"==typeof e&&e.startsWith("walk")?function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return t[e](...n.map(t=>"function"==typeof t?(e,i)=>t(e.toProxy(),i):t))}:"every"===e||"some"===e?i=>t[e](function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return i(t.toProxy(),...n)}):"root"===e?()=>t.root().toProxy():"nodes"===e?t.nodes.map(t=>t.toProxy()):"first"===e||"last"===e?t[e].toProxy():t[e]:t[e],set:(t,e,i)=>(t[e]===i||(t[e]=i,"name"!==e&&"params"!==e&&"selector"!==e||t.markDirty()),!0)}}index(t){return"number"==typeof t?t:(t.proxyOf&&(t=t.proxyOf),this.proxyOf.nodes.indexOf(t))}insertAfter(t,e){var i,n=this.index(t),r=this.normalize(e,this.proxyOf.nodes[n]).reverse();for(var s of(n=this.index(t),r))this.proxyOf.nodes.splice(n+1,0,s);for(var o in this.indexes)n<(i=this.indexes[o])&&(this.indexes[o]=i+r.length);return this.markDirty(),this}insertBefore(t,e){var i,n=this.index(t),r=0===n&&"prepend",s=this.normalize(e,this.proxyOf.nodes[n],r).reverse();for(var o of(n=this.index(t),s))this.proxyOf.nodes.splice(n,0,o);for(var a in this.indexes)n<=(i=this.indexes[a])&&(this.indexes[a]=i+s.length);return this.markDirty(),this}normalize(e,i){if("string"==typeof e)e=xs(vs(e).nodes);else if(void 0===e)e=[];else if(Array.isArray(e))for(var n of e=e.slice(0))n.parent&&n.parent.removeChild(n,"ignore");else if("root"===e.type&&"document"!==this.type)for(var r of e=e.nodes.slice(0))r.parent&&r.parent.removeChild(r,"ignore");else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error("Value field is missed in node creation");"string"!=typeof e.value&&(e.value=String(e.value)),e=[new ys(e)]}else if(e.selector)e=[new fs(e)];else if(e.name)e=[new ps(e)];else{if(!e.text)throw new Error("Unknown node type in node creation");e=[new ws(e)]}var s=e.map(e=>(e[bs]||t.rebuild(e),(e=e.proxyOf).parent&&e.parent.removeChild(e),e[gs]&&Ss(e),void 0===e.raws.before&&i&&void 0!==i.raws.before&&(e.raws.before=i.raws.before.replace(/\S/g,"")),e.parent=this.proxyOf,e));return s}prepend(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var n of e=e.reverse()){var r=this.normalize(n,this.first,"prepend").reverse();for(var s of r)this.proxyOf.nodes.unshift(s);for(var o in this.indexes)this.indexes[o]=this.indexes[o]+r.length}return this.markDirty(),this}push(t){return t.parent=this,this.proxyOf.nodes.push(t),this}removeAll(){for(var t of this.proxyOf.nodes)t.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(t){var e;for(var i in t=this.index(t),this.proxyOf.nodes[t].parent=void 0,this.proxyOf.nodes.splice(t,1),this.indexes)(e=this.indexes[i])>=t&&(this.indexes[i]=e-1);return this.markDirty(),this}replaceValues(t,e,i){return i||(i=e,e={}),this.walkDecls(n=>{e.props&&!e.props.includes(n.prop)||e.fast&&!n.value.includes(e.fast)||(n.value=n.value.replace(t,i))}),this.markDirty(),this}some(t){return this.nodes.some(t)}walk(t){return this.each((e,i)=>{var n;try{n=t(e,i)}catch(t){throw e.addToError(t)}return!1!==n&&e.walk&&(n=e.walk(t)),n})}walkAtRules(t,e){return e?t instanceof RegExp?this.walk((i,n)=>{if("atrule"===i.type&&t.test(i.name))return e(i,n)}):this.walk((i,n)=>{if("atrule"===i.type&&i.name===t)return e(i,n)}):(e=t,this.walk((t,i)=>{if("atrule"===t.type)return e(t,i)}))}walkComments(t){return this.walk((e,i)=>{if("comment"===e.type)return t(e,i)})}walkDecls(t,e){return e?t instanceof RegExp?this.walk((i,n)=>{if("decl"===i.type&&t.test(i.prop))return e(i,n)}):this.walk((i,n)=>{if("decl"===i.type&&i.prop===t)return e(i,n)}):(e=t,this.walk((t,i)=>{if("decl"===t.type)return e(t,i)}))}walkRules(t,e){return e?t instanceof RegExp?this.walk((i,n)=>{if("rule"===i.type&&t.test(i.selector))return e(i,n)}):this.walk((i,n)=>{if("rule"===i.type&&i.selector===t)return e(i,n)}):(e=t,this.walk((t,i)=>{if("rule"===t.type)return e(t,i)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};Cs.registerParse=t=>{vs=t},Cs.registerRule=t=>{fs=t},Cs.registerAtRule=t=>{ps=t},Cs.registerRoot=t=>{ms=t};var _s=Cs;Cs.default=Cs,Cs.rebuild=t=>{"atrule"===t.type?Object.setPrototypeOf(t,ps.prototype):"rule"===t.type?Object.setPrototypeOf(t,fs.prototype):"decl"===t.type?Object.setPrototypeOf(t,ys.prototype):"comment"===t.type?Object.setPrototypeOf(t,ws.prototype):"root"===t.type&&Object.setPrototypeOf(t,ms.prototype),t[bs]=!0,t.nodes&&t.nodes.forEach(t=>{Cs.rebuild(t)})};var Is,As,Ts=_s,Es=class extends Ts{constructor(t){super(i({type:"document"},t)),this.nodes||(this.nodes=[])}toResult(t){return void 0===t&&(t={}),new Is(new As,this,t).stringify()}};Es.registerLazyResult=t=>{Is=t},Es.registerProcessor=t=>{As=t};var Ms=Es;Es.default=Es;var Os={},Rs=function(t){Os[t]||(Os[t]=!0,"undefined"!=typeof console&&console.warn&&console.warn(t))},Ns=class{constructor(t,e){if(void 0===e&&(e={}),this.type="warning",this.text=t,e.node&&e.node.source){var i=e.node.rangeBy(e);this.line=i.start.line,this.column=i.start.column,this.endLine=i.end.line,this.endColumn=i.end.column}for(var n in e)this[n]=e[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},Ps=Ns;Ns.default=Ns;var Bs=Ps,Ds=class{constructor(t,e,i){this.processor=t,this.messages=[],this.root=e,this.opts=i,this.css=void 0,this.map=void 0}toString(){return this.css}warn(t,e){void 0===e&&(e={}),e.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(e.plugin=this.lastPlugin.postcssPlugin);var i=new Bs(t,e);return this.messages.push(i),i}warnings(){return this.messages.filter(t=>"warning"===t.type)}get content(){return this.css}},js=Ds;Ds.default=Ds;var Us="'".charCodeAt(0),Ls='"'.charCodeAt(0),Fs="\\".charCodeAt(0),zs="/".charCodeAt(0),Ws="\n".charCodeAt(0),$s=" ".charCodeAt(0),Vs="\f".charCodeAt(0),Hs="\t".charCodeAt(0),qs="\r".charCodeAt(0),Js="[".charCodeAt(0),Gs="]".charCodeAt(0),Zs="(".charCodeAt(0),Ys=")".charCodeAt(0),Ks="{".charCodeAt(0),Xs="}".charCodeAt(0),Qs=";".charCodeAt(0),to="*".charCodeAt(0),eo=":".charCodeAt(0),io="@".charCodeAt(0),no=/[\t\n\f\r "#'()/;[\\\]{}]/g,ro=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,so=/.[\r\n"'(/\\]/,oo=/[\da-f]/i,ao=_s,lo=class extends ao{constructor(t){super(t),this.type="atrule"}append(){return this.proxyOf.nodes||(this.nodes=[]),super.append(...arguments)}prepend(){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...arguments)}},ho=lo;lo.default=lo,ao.registerAtRule(lo);var uo,co,vo=_s,fo=class extends vo{constructor(t){super(t),this.type="root",this.nodes||(this.nodes=[])}normalize(t,e,i){var n=super.normalize(t);if(e)if("prepend"===i)this.nodes.length>1?e.raws.before=this.nodes[1].raws.before:delete e.raws.before;else if(this.first!==e)for(var r of n)r.raws.before=e.raws.before;return n}removeChild(t,e){var i=this.index(t);return!e&&0===i&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[i].raws.before),super.removeChild(t)}toResult(t){return void 0===t&&(t={}),new uo(new co,this,t).stringify()}};fo.registerLazyResult=t=>{uo=t},fo.registerProcessor=t=>{co=t};var po=fo;fo.default=fo,vo.registerRoot(fo);var mo={comma:t=>mo.split(t,[","],!0),space:t=>mo.split(t,[" ","\n","\t"]),split(t,e,i){var n=[],r="",s=!1,o=0,a=!1,l="",h=!1;for(var u of t)h?h=!1:"\\"===u?h=!0:a?u===l&&(a=!1):'"'===u||"'"===u?(a=!0,l=u):"("===u?o+=1:")"===u?o>0&&(o-=1):0===o&&e.includes(u)&&(s=!0),s?(""!==r&&n.push(r.trim()),r="",s=!1):r+=u;return(i||""!==r)&&n.push(r.trim()),n}},go=mo;mo.default=mo;var bo=_s,yo=go,wo=class extends bo{constructor(t){super(t),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return yo.comma(this.selector)}set selectors(t){var e=this.selector?this.selector.match(/,\s*/):null,i=e?e[0]:","+this.raw("between","beforeOpen");this.selector=t.join(i)}},ko=wo;wo.default=wo,bo.registerRule(wo);var xo=Tr,So=function(t,e){void 0===e&&(e={});var i,n,r,s,o,a,l,h,u,c,d=t.css.valueOf(),v=e.ignoreErrors,f=d.length,p=0,m=[],g=[];function b(e){throw t.error("Unclosed "+e,p)}return{back:function(t){g.push(t)},endOfFile:function(){return 0===g.length&&p>=f},nextToken:function(t){if(g.length)return g.pop();if(!(p>=f)){var e=!!t&&t.ignoreUnclosed;switch(i=d.charCodeAt(p)){case Ws:case $s:case Hs:case qs:case Vs:n=p;do{n+=1,i=d.charCodeAt(n)}while(i===$s||i===Ws||i===Hs||i===qs||i===Vs);c=["space",d.slice(p,n)],p=n-1;break;case Js:case Gs:case Ks:case Xs:case eo:case Qs:case Ys:var y=String.fromCharCode(i);c=[y,y,p];break;case Zs:if(h=m.length?m.pop()[1]:"",u=d.charCodeAt(p+1),"url"===h&&u!==Us&&u!==Ls&&u!==$s&&u!==Ws&&u!==Hs&&u!==Vs&&u!==qs){n=p;do{if(a=!1,-1===(n=d.indexOf(")",n+1))){if(v||e){n=p;break}b("bracket")}for(l=n;d.charCodeAt(l-1)===Fs;)l-=1,a=!a}while(a);c=["brackets",d.slice(p,n+1),p,n],p=n}else n=d.indexOf(")",p+1),s=d.slice(p,n+1),-1===n||so.test(s)?c=["(","(",p]:(c=["brackets",s,p,n],p=n);break;case Us:case Ls:r=i===Us?"'":'"',n=p;do{if(a=!1,-1===(n=d.indexOf(r,n+1))){if(v||e){n=p+1;break}b("string")}for(l=n;d.charCodeAt(l-1)===Fs;)l-=1,a=!a}while(a);c=["string",d.slice(p,n+1),p,n],p=n;break;case io:no.lastIndex=p+1,no.test(d),n=0===no.lastIndex?d.length-1:no.lastIndex-2,c=["at-word",d.slice(p,n+1),p,n],p=n;break;case Fs:for(n=p,o=!0;d.charCodeAt(n+1)===Fs;)n+=1,o=!o;if(i=d.charCodeAt(n+1),o&&i!==zs&&i!==$s&&i!==Ws&&i!==Hs&&i!==qs&&i!==Vs&&(n+=1,oo.test(d.charAt(n)))){for(;oo.test(d.charAt(n+1));)n+=1;d.charCodeAt(n+1)===$s&&(n+=1)}c=["word",d.slice(p,n+1),p,n],p=n;break;default:i===zs&&d.charCodeAt(p+1)===to?(0===(n=d.indexOf("*/",p+2)+1)&&(v||e?n=d.length:b("comment")),c=["comment",d.slice(p,n+1),p,n],p=n):(ro.lastIndex=p+1,ro.test(d),n=0===ro.lastIndex?d.length-1:ro.lastIndex-2,c=["word",d.slice(p,n+1),p,n],m.push(c),p=n)}return p++,c}},position:function(){return p}}},Co=ds,_o=ho,Io=po,Ao=ko,To={empty:!0,space:!0};var Eo=class{constructor(t){this.input=t,this.root=new Io,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:t,start:{column:1,line:1,offset:0}}}atrule(t){var e,i,n,r=new _o;r.name=t[1].slice(1),""===r.name&&this.unnamedAtrule(r,t),this.init(r,t[2]);for(var s=!1,o=!1,a=[],l=[];!this.tokenizer.endOfFile();){if("("===(e=(t=this.tokenizer.nextToken())[0])||"["===e?l.push("("===e?")":"]"):"{"===e&&l.length>0?l.push("}"):e===l[l.length-1]&&l.pop(),0===l.length){if(";"===e){r.source.end=this.getPosition(t[2]),r.source.end.offset++,this.semicolon=!0;break}if("{"===e){o=!0;break}if("}"===e){if(a.length>0){for(i=a[n=a.length-1];i&&"space"===i[0];)i=a[--n];i&&(r.source.end=this.getPosition(i[3]||i[2]),r.source.end.offset++)}this.end(t);break}a.push(t)}else a.push(t);if(this.tokenizer.endOfFile()){s=!0;break}}r.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(r.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(r,"params",a),s&&(t=a[a.length-1],r.source.end=this.getPosition(t[3]||t[2]),r.source.end.offset++,this.spaces=r.raws.between,r.raws.between="")):(r.raws.afterName="",r.params=""),o&&(r.nodes=[],this.current=r)}checkMissedSemicolon(t){var e=this.colon(t);if(!1!==e){for(var i,n=0,r=e-1;r>=0&&("space"===(i=t[r])[0]||2!==(n+=1));r--);throw this.input.error("Missed semicolon","word"===i[0]?i[3]+1:i[2])}}colon(t){var e,i,n,r=0;for(var[s,o]of t.entries()){if("("===(i=(e=o)[0])&&(r+=1),")"===i&&(r-=1),0===r&&":"===i){if(n){if("word"===n[0]&&"progid"===n[1])continue;return s}this.doubleColon(e)}n=e}return!1}comment(t){var e=new Co;this.init(e,t[2]),e.source.end=this.getPosition(t[3]||t[2]),e.source.end.offset++;var i=t[1].slice(2,-2);if(/^\s*$/.test(i))e.text="",e.raws.left=i,e.raws.right="";else{var n=i.match(/^(\s*)([^]*\S)(\s*)$/);e.text=n[2],e.raws.left=n[1],e.raws.right=n[3]}}createTokenizer(){this.tokenizer=So(this.input)}decl(t,e){var i=new xo;this.init(i,t[0][2]);var n,r=t[t.length-1];for(";"===r[0]&&(this.semicolon=!0,t.pop()),i.source.end=this.getPosition(r[3]||r[2]||function(t){for(var e=t.length-1;e>=0;e--){var i=t[e],n=i[3]||i[2];if(n)return n}}(t)),i.source.end.offset++;"word"!==t[0][0];)1===t.length&&this.unknownWord(t),i.raws.before+=t.shift()[1];for(i.source.start=this.getPosition(t[0][2]),i.prop="";t.length;){var s=t[0][0];if(":"===s||"space"===s||"comment"===s)break;i.prop+=t.shift()[1]}for(i.raws.between="";t.length;){if(":"===(n=t.shift())[0]){i.raws.between+=n[1];break}"word"===n[0]&&/\w/.test(n[1])&&this.unknownWord([n]),i.raws.between+=n[1]}"_"!==i.prop[0]&&"*"!==i.prop[0]||(i.raws.before+=i.prop[0],i.prop=i.prop.slice(1));for(var o,a=[];t.length&&("space"===(o=t[0][0])||"comment"===o);)a.push(t.shift());this.precheckMissedSemicolon(t);for(var l=t.length-1;l>=0;l--){if("!important"===(n=t[l])[1].toLowerCase()){i.important=!0;var h=this.stringFrom(t,l);" !important"!==(h=this.spacesFromEnd(t)+h)&&(i.raws.important=h);break}if("important"===n[1].toLowerCase()){for(var u=t.slice(0),c="",d=l;d>0;d--){var v=u[d][0];if(0===c.trim().indexOf("!")&&"space"!==v)break;c=u.pop()[1]+c}0===c.trim().indexOf("!")&&(i.important=!0,i.raws.important=c,t=u)}if("space"!==n[0]&&"comment"!==n[0])break}var f=t.some(t=>"space"!==t[0]&&"comment"!==t[0]);f&&(i.raws.between+=a.map(t=>t[1]).join(""),a=[]),this.raw(i,"value",a.concat(t),e),i.value.includes(":")&&!e&&this.checkMissedSemicolon(t)}doubleColon(t){throw this.input.error("Double colon",{offset:t[2]},{offset:t[2]+t[1].length})}emptyRule(t){var e=new Ao;this.init(e,t[2]),e.selector="",e.raws.between="",this.current=e}end(t){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(t[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(t)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(t){if(this.spaces+=t[1],this.current.nodes){var e=this.current.nodes[this.current.nodes.length-1];e&&"rule"===e.type&&!e.raws.ownSemicolon&&(e.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(t){var e=this.input.fromOffset(t);return{column:e.col,line:e.line,offset:t}}init(t,e){this.current.push(t),t.source={input:this.input,start:this.getPosition(e)},t.raws.before=this.spaces,this.spaces="","comment"!==t.type&&(this.semicolon=!1)}other(t){for(var e=!1,i=null,n=!1,r=null,s=[],o=t[1].startsWith("--"),a=[],l=t;l;){if(i=l[0],a.push(l),"("===i||"["===i)r||(r=l),s.push("("===i?")":"]");else if(o&&n&&"{"===i)r||(r=l),s.push("}");else if(0===s.length){if(";"===i){if(n)return void this.decl(a,o);break}if("{"===i)return void this.rule(a);if("}"===i){this.tokenizer.back(a.pop()),e=!0;break}":"===i&&(n=!0)}else i===s[s.length-1]&&(s.pop(),0===s.length&&(r=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(e=!0),s.length>0&&this.unclosedBracket(r),e&&n){if(!o)for(;a.length&&("space"===(l=a[a.length-1][0])||"comment"===l);)this.tokenizer.back(a.pop());this.decl(a,o)}else this.unknownWord(a)}parse(){for(var t;!this.tokenizer.endOfFile();)switch((t=this.tokenizer.nextToken())[0]){case"space":this.spaces+=t[1];break;case";":this.freeSemicolon(t);break;case"}":this.end(t);break;case"comment":this.comment(t);break;case"at-word":this.atrule(t);break;case"{":this.emptyRule(t);break;default:this.other(t)}this.endFile()}precheckMissedSemicolon(){}raw(t,e,i,n){for(var r,s,o,a,l=i.length,h="",u=!0,c=0;c<l;c+=1)"space"!==(s=(r=i[c])[0])||c!==l-1||n?"comment"===s?(a=i[c-1]?i[c-1][0]:"empty",o=i[c+1]?i[c+1][0]:"empty",To[a]||To[o]||","===h.slice(-1)?u=!1:h+=r[1]):h+=r[1]:u=!1;if(!u){var d=i.reduce((t,e)=>t+e[1],"");t.raws[e]={raw:d,value:h}}t[e]=h}rule(t){t.pop();var e=new Ao;this.init(e,t[0][2]),e.raws.between=this.spacesAndCommentsFromEnd(t),this.raw(e,"selector",t),this.current=e}spacesAndCommentsFromEnd(t){for(var e,i="";t.length&&("space"===(e=t[t.length-1][0])||"comment"===e);)i=t.pop()[1]+i;return i}spacesAndCommentsFromStart(t){for(var e,i="";t.length&&("space"===(e=t[0][0])||"comment"===e);)i+=t.shift()[1];return i}spacesFromEnd(t){for(var e="";t.length&&"space"===t[t.length-1][0];)e=t.pop()[1]+e;return e}stringFrom(t,e){for(var i="",n=e;n<t.length;n++)i+=t[n][1];return t.splice(e,t.length-e),i}unclosedBlock(){var t=this.current.source.start;throw this.input.error("Unclosed block",t.line,t.column)}unclosedBracket(t){throw this.input.error("Unclosed bracket",{offset:t[2]},{offset:t[2]+1})}unexpectedClose(t){throw this.input.error("Unexpected }",{offset:t[2]},{offset:t[2]+1})}unknownWord(t){throw this.input.error("Unknown word",{offset:t[0][2]},{offset:t[0][2]+t[0][1].length})}unnamedAtrule(t,e){throw this.input.error("At-rule without name",{offset:e[2]},{offset:e[2]+e[1].length})}},Mo=_s,Oo=Eo,Ro=Xr;function No(t,e){var i=new Ro(t,e),n=new Oo(i);try{n.parse()}catch(t){throw"production"!==process.env.NODE_ENV&&"CssSyntaxError"===t.name&&e&&e.from&&(/\.scss$/i.test(e.from)?t.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.sass/i.test(e.from)?t.message+="\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser":/\.less$/i.test(e.from)&&(t.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),t}return n.root}var Po=No;No.default=No,Mo.registerParse(No);var{isClean:Bo,my:Do}=cr,jo=hs,Uo=gr,Lo=_s,Fo=Ms,zo=Rs,Wo=js,$o=Po,Vo=po,Ho={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},qo={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Jo={Once:!0,postcssPlugin:!0,prepare:!0};function Go(t){return"object"==typeof t&&"function"==typeof t.then}function Zo(t){var e=!1,i=Ho[t.type];return"decl"===t.type?e=t.prop.toLowerCase():"atrule"===t.type&&(e=t.name.toLowerCase()),e&&t.append?[i,i+"-"+e,0,i+"Exit",i+"Exit-"+e]:e?[i,i+"-"+e,i+"Exit",i+"Exit-"+e]:t.append?[i,0,i+"Exit"]:[i,i+"Exit"]}function Yo(t){return{eventIndex:0,events:"document"===t.type?["Document",0,"DocumentExit"]:"root"===t.type?["Root",0,"RootExit"]:Zo(t),iterator:0,node:t,visitorIndex:0,visitors:[]}}function Ko(t){return t[Bo]=!1,t.nodes&&t.nodes.forEach(t=>Ko(t)),t}var Xo={},Qo=class t{constructor(e,n,r){var s;if(this.stringified=!1,this.processed=!1,"object"!=typeof n||null===n||"root"!==n.type&&"document"!==n.type)if(n instanceof t||n instanceof Wo)s=Ko(n.root),n.map&&(void 0===r.map&&(r.map={}),r.map.inline||(r.map.inline=!1),r.map.prev=n.map);else{var o=$o;r.syntax&&(o=r.syntax.parse),r.parser&&(o=r.parser),o.parse&&(o=o.parse);try{s=o(n,r)}catch(t){this.processed=!0,this.error=t}s&&!s[Do]&&Lo.rebuild(s)}else s=Ko(n);this.result=new Wo(e,s,r),this.helpers=i({},Xo,{postcss:Xo,result:this.result}),this.plugins=this.processor.plugins.map(t=>"object"==typeof t&&t.prepare?i({},t,t.prepare(this.result)):t)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(t,e){var i=this.result.lastPlugin;try{if(e&&e.addToError(t),this.error=t,"CssSyntaxError"!==t.name||t.plugin){if(i.postcssVersion&&"production"!==process.env.NODE_ENV){var n=i.postcssPlugin,r=i.postcssVersion,s=this.result.processor.version,o=r.split("."),a=s.split(".");(o[0]!==a[0]||parseInt(o[1])>parseInt(a[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+s+", but "+n+" uses "+r+". Perhaps this is the source of the error below.")}}else t.plugin=i.postcssPlugin,t.setMessage()}catch(t){console&&console.error&&console.error(t)}return t}prepareVisitors(){this.listeners={};var t=(t,e,i)=>{this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push([t,i])};for(var e of this.plugins)if("object"==typeof e)for(var i in e){if(!qo[i]&&/^[A-Z]/.test(i))throw new Error("Unknown event "+i+" in "+e.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!Jo[i])if("object"==typeof e[i])for(var n in e[i])t(e,"*"===n?i:i+"-"+n.toLowerCase(),e[i][n]);else"function"==typeof e[i]&&t(e,i,e[i])}this.hasListener=Object.keys(this.listeners).length>0}runAsync(){var t=this;return e(function*(){t.plugin=0;for(var e=0;e<t.plugins.length;e++){var i=t.plugins[e],n=t.runOnRoot(i);if(Go(n))try{yield n}catch(e){throw t.handleError(e)}}if(t.prepareVisitors(),t.hasListener){for(var r=t.result.root;!r[Bo];){r[Bo]=!0;for(var s=[Yo(r)];s.length>0;){var o=t.visitTick(s);if(Go(o))try{yield o}catch(e){var a=s[s.length-1].node;throw t.handleError(e,a)}}}if(t.listeners.OnceExit){var l=function*(e){t.result.lastPlugin=h;try{if("document"===r.type){var i=r.nodes.map(i=>e(i,t.helpers));yield Promise.all(i)}else yield e(r,t.helpers)}catch(e){throw t.handleError(e)}};for(var[h,u]of t.listeners.OnceExit)yield*l(u)}}return t.processed=!0,t.stringify()})()}runOnRoot(t){this.result.lastPlugin=t;try{if("object"==typeof t&&t.Once){if("document"===this.result.root.type){var e=this.result.root.nodes.map(e=>t.Once(e,this.helpers));return Go(e[0])?Promise.all(e):e}return t.Once(this.result.root,this.helpers)}if("function"==typeof t)return t(this.result.root,this.result)}catch(t){throw this.handleError(t)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var t=this.result.opts,e=Uo;t.syntax&&(e=t.syntax.stringify),t.stringifier&&(e=t.stringifier),e.stringify&&(e=e.stringify);var i=new jo(e,this.result.root,this.result.opts).generate();return this.result.css=i[0],this.result.map=i[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(var t of this.plugins){if(Go(this.runOnRoot(t)))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var e=this.result.root;!e[Bo];)e[Bo]=!0,this.walkSync(e);if(this.listeners.OnceExit)if("document"===e.type)for(var i of e.nodes)this.visitSync(this.listeners.OnceExit,i);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(t,e){return"production"!==process.env.NODE_ENV&&("from"in this.opts||zo("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,e)}toString(){return this.css}visitSync(t,e){for(var[i,n]of t){this.result.lastPlugin=i;var r=void 0;try{r=n(e,this.helpers)}catch(t){throw this.handleError(t,e.proxyOf)}if("root"!==e.type&&"document"!==e.type&&!e.parent)return!0;if(Go(r))throw this.getAsyncError()}}visitTick(t){var e=t[t.length-1],{node:i,visitors:n}=e;if("root"===i.type||"document"===i.type||i.parent){if(n.length>0&&e.visitorIndex<n.length){var[r,s]=n[e.visitorIndex];e.visitorIndex+=1,e.visitorIndex===n.length&&(e.visitors=[],e.visitorIndex=0),this.result.lastPlugin=r;try{return s(i.toProxy(),this.helpers)}catch(t){throw this.handleError(t,i)}}if(0!==e.iterator){for(var o,a=e.iterator;o=i.nodes[i.indexes[a]];)if(i.indexes[a]+=1,!o[Bo])return o[Bo]=!0,void t.push(Yo(o));e.iterator=0,delete i.indexes[a]}for(var l=e.events;e.eventIndex<l.length;){var h=l[e.eventIndex];if(e.eventIndex+=1,0===h)return void(i.nodes&&i.nodes.length&&(i[Bo]=!0,e.iterator=i.getIterator()));if(this.listeners[h])return void(e.visitors=this.listeners[h])}t.pop()}else t.pop()}walkSync(t){t[Bo]=!0;var e=Zo(t);for(var i of e)if(0===i)t.nodes&&t.each(t=>{t[Bo]||this.walkSync(t)});else{var n=this.listeners[i];if(n&&this.visitSync(n,t.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};Qo.registerPostcss=t=>{Xo=t};var ta=Qo;Qo.default=Qo,Vo.registerLazyResult(Qo),Fo.registerLazyResult(Qo);var ea=hs,ia=gr,na=Rs,ra=Po,sa=js,oa=class{constructor(t,e,i){var n;e=e.toString(),this.stringified=!1,this._processor=t,this._css=e,this._opts=i,this._map=void 0;var r=ia;this.result=new sa(this._processor,n,this._opts),this.result.css=e;var s=this;Object.defineProperty(this.result,"root",{get:()=>s.root});var o=new ea(r,n,this._opts,e);if(o.isMap()){var[a,l]=o.generate();a&&(this.result.css=a),l&&(this.result.map=l)}else o.clearAnnotation(),this.result.css=o.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}sync(){if(this.error)throw this.error;return this.result}then(t,e){return"production"!==process.env.NODE_ENV&&("from"in this._opts||na("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,e)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;var t,e=ra;try{t=e(this._css,this._opts)}catch(t){this.error=t}if(this.error)throw this.error;return this._root=t,t}get[Symbol.toStringTag](){return"NoWorkResult"}},aa=oa;oa.default=oa;var la=aa,ha=ta,ua=Ms,ca=po,da=class{constructor(t){void 0===t&&(t=[]),this.version="8.4.38",this.plugins=this.normalize(t)}normalize(t){var e=[];for(var i of t)if(!0===i.postcss?i=i():i.postcss&&(i=i.postcss),"object"==typeof i&&Array.isArray(i.plugins))e=e.concat(i.plugins);else if("object"==typeof i&&i.postcssPlugin)e.push(i);else if("function"==typeof i)e.push(i);else{if("object"!=typeof i||!i.parse&&!i.stringify)throw new Error(i+" is not a PostCSS plugin");if("production"!==process.env.NODE_ENV)throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.")}return e}process(t,e){return void 0===e&&(e={}),this.plugins.length||e.parser||e.stringifier||e.syntax?new ha(this,t,e):new la(this,t,e)}use(t){return this.plugins=this.plugins.concat(this.normalize([t])),this}},va=da;da.default=da,ca.registerProcessor(da),ua.registerProcessor(da);var fa=Tr,pa=jr,ma=ds,ga=ho,ba=Xr,ya=po,wa=ko;function ka(t,e){if(Array.isArray(t))return t.map(t=>ka(t));var{inputs:r}=t,s=n(t,a);if(r)for(var o of(e=[],r)){var h=i({},o,{__proto__:ba.prototype});h.map&&(h.map=i({},h.map,{__proto__:pa.prototype})),e.push(h)}if(s.nodes&&(s.nodes=t.nodes.map(t=>ka(t,e))),s.source){var u=s.source,{inputId:c}=u,d=n(u,l);s.source=d,null!=c&&(s.source.input=e[c])}if("root"===s.type)return new ya(s);if("decl"===s.type)return new fa(s);if("rule"===s.type)return new wa(s);if("comment"===s.type)return new ma(s);if("atrule"===s.type)return new ga(s);throw new Error("Unknown node type: "+t.type)}var xa=ka;ka.default=ka;var Sa=ur,Ca=Tr,_a=ta,Ia=_s,Aa=va,Ta=gr,Ea=xa,Ma=Ms,Oa=Ps,Ra=ds,Na=ho,Pa=js,Ba=Xr,Da=Po,ja=go,Ua=ko,La=po,Fa=_r;function za(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),new Aa(e)}za.plugin=function(t,e){var i,n=!1;function r(){console&&console.warn&&!n&&(n=!0,console.warn(t+": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(t+": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226"));var i=e(...arguments);return i.postcssPlugin=t,i.postcssVersion=(new Aa).version,i}return Object.defineProperty(r,"postcss",{get:()=>(i||(i=r()),i)}),r.process=function(t,e,i){return za([r(i)]).process(t,e)},r},za.stringify=Ta,za.parse=Da,za.fromJSON=Ea,za.list=ja,za.comment=t=>new Ra(t),za.atRule=t=>new Na(t),za.decl=t=>new Ca(t),za.rule=t=>new Ua(t),za.root=t=>new La(t),za.document=t=>new Ma(t),za.CssSyntaxError=Sa,za.Declaration=Ca,za.Container=Ia,za.Processor=Aa,za.Document=Ma,za.Comment=Ra,za.Warning=Oa,za.AtRule=Na,za.Result=Pa,za.Input=Ba,za.Rule=Ua,za.Root=La,za.Node=Fa,_a.registerPostcss(za);var Wa=za;za.default=za;var $a=tr(Wa);$a.stringify,$a.fromJSON,$a.plugin,$a.parse,$a.list,$a.document,$a.comment,$a.atRule,$a.rule,$a.decl,$a.root,$a.CssSyntaxError,$a.Declaration,$a.Container,$a.Processor,$a.Document,$a.Comment,$a.Warning,$a.AtRule,$a.Result,$a.Input,$a.Rule,$a.Root,$a.Node;class Va{constructor(){Qn(this,"parentElement",null),Qn(this,"parentNode",null),Qn(this,"ownerDocument"),Qn(this,"firstChild",null),Qn(this,"lastChild",null),Qn(this,"previousSibling",null),Qn(this,"nextSibling",null),Qn(this,"ELEMENT_NODE",1),Qn(this,"TEXT_NODE",3),Qn(this,"nodeType"),Qn(this,"nodeName"),Qn(this,"RRNodeType")}get childNodes(){for(var t=[],e=this.firstChild;e;)t.push(e),e=e.nextSibling;return t}contains(t){if(!(t instanceof Va))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,e){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}var Ha={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},qa={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ja={};function Ga(t){if(Ja[t])return Ja[t];var e=globalThis[t],i=e.prototype,n=t in Ha?Ha[t]:void 0,r=Boolean(n&&n.every(t=>{var e,n;return Boolean(null==(n=null==(e=Object.getOwnPropertyDescriptor(i,t))?void 0:e.get)?void 0:n.toString().includes("[native code]"))})),s=t in qa?qa[t]:void 0,o=Boolean(s&&s.every(t=>{var e;return"function"==typeof i[t]&&(null==(e=i[t])?void 0:e.toString().includes("[native code]"))}));if(r&&o&&!globalThis.Zone)return Ja[t]=e.prototype,e.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var l=a.contentWindow;if(!l)return e.prototype;var h=l[t].prototype;return document.body.removeChild(a),h?Ja[t]=h:i}catch(t){return i}}var Za={};function Ya(t,e,i){var n,r=t+"."+String(i);if(Za[r])return Za[r].call(e);var s=Ga(t),o=null==(n=Object.getOwnPropertyDescriptor(s,i))?void 0:n.get;return o?(Za[r]=o,o.call(e)):e[i]}var Ka={};function Xa(t,e,i){var n=t+"."+String(i);if(Ka[n])return Ka[n].bind(e);var r=Ga(t)[i];return"function"!=typeof r?e[i]:(Ka[n]=r,r.bind(e))}function Qa(){return Ga("MutationObserver").constructor}function tl(t,e,i){try{if(!(e in t))return()=>{};var n=t[e],r=i(n);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:n}})),t[e]=r,()=>{t[e]=n}}catch(t){return()=>{}}}var el={ownerDocument:function(t){return Ya("Node",t,"ownerDocument")},childNodes:function(t){return Ya("Node",t,"childNodes")},parentNode:function(t){return Ya("Node",t,"parentNode")},parentElement:function(t){return Ya("Node",t,"parentElement")},textContent:function(t){return Ya("Node",t,"textContent")},contains:function(t,e){return Xa("Node",t,"contains")(e)},getRootNode:function(t){return Xa("Node",t,"getRootNode")()},host:function(t){return t&&"host"in t?Ya("ShadowRoot",t,"host"):null},styleSheets:function(t){return t.styleSheets},shadowRoot:function(t){return t&&"shadowRoot"in t?Ya("Element",t,"shadowRoot"):null},querySelector:function(t,e){return Ya("Element",t,"querySelector")(e)},querySelectorAll:function(t,e){return Ya("Element",t,"querySelectorAll")(e)},mutationObserver:Qa,patch:tl};function il(t,e,i){void 0===i&&(i=document);var n={capture:!0,passive:!0};return i.addEventListener(t,e,n),()=>i.removeEventListener(t,e,n)}var nl="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",rl={map:{},getId:()=>(console.error(nl),-1),getNode:()=>(console.error(nl),null),removeNodeFromMap(){console.error(nl)},has:()=>(console.error(nl),!1),reset(){console.error(nl)}};function sl(t,e,i){void 0===i&&(i={});var n=null,r=0;return function(){for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];var l=Date.now();r||!1!==i.leading||(r=l);var h=e-(l-r),u=this;h<=0||h>e?(n&&(clearTimeout(n),n=null),r=l,t.apply(u,o)):n||!1===i.trailing||(n=setTimeout(()=>{r=!1===i.leading?0:Date.now(),n=null,t.apply(u,o)},h))}}function ol(t,e,i,n,r){void 0===r&&(r=window);var s=r.Object.getOwnPropertyDescriptor(t,e);return r.Object.defineProperty(t,e,n?i:{set(t){setTimeout(()=>{i.set.call(this,t)},0),s&&s.set&&s.set.call(this,t)}}),()=>ol(t,e,s||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(rl=new Proxy(rl,{get:(t,e,i)=>("map"===e&&console.error(nl),Reflect.get(t,e,i))}));var al=Date.now;function ll(t){var e,i,n,r,s=t.document;return{left:s.scrollingElement?s.scrollingElement.scrollLeft:void 0!==t.pageXOffset?t.pageXOffset:s.documentElement.scrollLeft||(null==s?void 0:s.body)&&(null==(e=el.parentElement(s.body))?void 0:e.scrollLeft)||(null==(i=null==s?void 0:s.body)?void 0:i.scrollLeft)||0,top:s.scrollingElement?s.scrollingElement.scrollTop:void 0!==t.pageYOffset?t.pageYOffset:(null==s?void 0:s.documentElement.scrollTop)||(null==s?void 0:s.body)&&(null==(n=el.parentElement(s.body))?void 0:n.scrollTop)||(null==(r=null==s?void 0:s.body)?void 0:r.scrollTop)||0}}function hl(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ul(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function cl(t){return t?t.nodeType===t.ELEMENT_NODE?t:el.parentElement(t):null}function dl(t,e,i,n){if(!t)return!1;var r=cl(t);if(!r)return!1;try{if("string"==typeof e){if(r.classList.contains(e))return!0;if(n&&null!==r.closest("."+e))return!0}else if(it(r,e,n))return!0}catch(t){}if(i){if(r.matches(i))return!0;if(n&&null!==r.closest(i))return!0}return!1}function vl(t,e,i){return!("TITLE"!==t.tagName||!i.headTitleMutations)||-2===e.getId(t)}function fl(t,e){if(_(t))return!1;var i=e.getId(t);if(!e.has(i))return!0;var n=el.parentNode(t);return(!n||n.nodeType!==t.DOCUMENT_NODE)&&(!n||fl(n,e))}function pl(t){return Boolean(t.changedTouches)}function ml(t,e){return Boolean("IFRAME"===t.nodeName&&e.getMeta(t))}function gl(t,e){return Boolean("LINK"===t.nodeName&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&"stylesheet"===t.getAttribute("rel")&&e.getMeta(t))}function bl(t){return!!t&&(t instanceof Va&&"shadowRoot"in t?Boolean(t.shadowRoot):Boolean(el.shadowRoot(t)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(al=()=>(new Date).getTime());class yl{constructor(){c(this,"id",1),c(this,"styleIDMap",new WeakMap),c(this,"idStyleMap",new Map)}getId(t){var e;return null!==(e=this.styleIDMap.get(t))&&void 0!==e?e:-1}has(t){return this.styleIDMap.has(t)}add(t,e){return this.has(t)?this.getId(t):(i=void 0===e?this.id++:e,this.styleIDMap.set(t,i),this.idStyleMap.set(i,t),i);var i}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function wl(t){var e,i=null;return"getRootNode"in t&&(null==(e=el.getRootNode(t))?void 0:e.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&el.host(el.getRootNode(t))&&(i=el.host(el.getRootNode(t))),i}function kl(t){var e=el.ownerDocument(t);if(!e)return!1;var i=function(t){for(var e,i=t;e=wl(i);)i=e;return i}(t);return el.contains(e,i)}function xl(t){var e=el.ownerDocument(t);return!!e&&(el.contains(e,t)||kl(t))}var Sl=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Sl||{}),Cl=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(Cl||{}),_l=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(_l||{}),Il=(t=>(t[t.Mouse=0]="Mouse",t[t.Pen=1]="Pen",t[t.Touch=2]="Touch",t))(Il||{}),Al=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(Al||{}),Tl=(t=>(t[t.Play=0]="Play",t[t.Pause=1]="Pause",t[t.Seeked=2]="Seeked",t[t.VolumeChange=3]="VolumeChange",t[t.RateChange=4]="RateChange",t))(Tl||{}),El=(t=>(t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment",t))(El||{});function Ml(t){return"__ln"in t}class Ol{constructor(){c(this,"length",0),c(this,"head",null),c(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");for(var e=this.head,i=0;i<t;i++)e=(null==e?void 0:e.next)||null;return e}addNode(t){var e={value:t,previous:null,next:null};if(t.__ln=e,t.previousSibling&&Ml(t.previousSibling)){var i=t.previousSibling.__ln.next;e.next=i,e.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=e,i&&(i.previous=e)}else if(t.nextSibling&&Ml(t.nextSibling)&&t.nextSibling.__ln.previous){var n=t.nextSibling.__ln.previous;e.previous=n,e.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=e,n&&(n.next=e)}else this.head&&(this.head.previous=e),e.next=this.head,this.head=e;null===e.next&&(this.tail=e),this.length++}removeNode(t){var e=t.__ln;this.head&&(e.previous?(e.previous.next=e.next,e.next?e.next.previous=e.previous:this.tail=e.previous):(this.head=e.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}var Rl,Nl=(t,e)=>t+"@"+e;class Pl{constructor(){c(this,"frozen",!1),c(this,"locked",!1),c(this,"texts",[]),c(this,"attributes",[]),c(this,"attributeMap",new WeakMap),c(this,"removes",[]),c(this,"mapRemoves",[]),c(this,"movedMap",{}),c(this,"addedSet",new Set),c(this,"movedSet",new Set),c(this,"droppedSet",new Set),c(this,"removesSubTreeCache",new Set),c(this,"mutationCb"),c(this,"blockClass"),c(this,"blockSelector"),c(this,"maskTextClass"),c(this,"maskTextSelector"),c(this,"inlineStylesheet"),c(this,"maskInputOptions"),c(this,"maskTextFn"),c(this,"maskInputFn"),c(this,"keepIframeSrcFn"),c(this,"recordCanvas"),c(this,"inlineImages"),c(this,"slimDOMOptions"),c(this,"dataURLOptions"),c(this,"doc"),c(this,"mirror"),c(this,"iframeManager"),c(this,"stylesheetManager"),c(this,"shadowDomManager"),c(this,"canvasManager"),c(this,"processedNodeManager"),c(this,"unattachedDoc"),c(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),c(this,"emit",()=>{if(!this.frozen&&!this.locked){for(var t=[],e=new Set,i=new Ol,n=t=>{for(var e=t,i=-2;-2===i;)i=(e=e&&e.nextSibling)&&this.mirror.getId(e);return i},r=r=>{var s=el.parentNode(r);if(s&&xl(r)){var o=!1;if(r.nodeType===Node.TEXT_NODE){var a=s.tagName;if("TEXTAREA"===a)return;"STYLE"===a&&this.addedSet.has(s)&&(o=!0)}var l=_(s)?this.mirror.getId(wl(r)):this.mirror.getId(s),h=n(r);if(-1===l||-1===h)return i.addNode(r);var u=at(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:t=>{ml(t,this.mirror)&&this.iframeManager.addIframe(t),gl(t,this.mirror)&&this.stylesheetManager.trackLinkElement(t),bl(r)&&this.shadowDomManager.addShadowRoot(el.shadowRoot(r),this.doc)},onIframeLoad:(t,e)=>{this.iframeManager.attachIframe(t,e),this.shadowDomManager.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{this.stylesheetManager.attachLinkElement(t,e)},cssCaptured:o});u&&(t.push({parentId:l,nextId:h,node:u}),e.add(u.id))}};this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(var s of this.movedSet)Dl(this.removesSubTreeCache,s,this.mirror)&&!this.movedSet.has(el.parentNode(s))||r(s);for(var o of this.addedSet)jl(this.droppedSet,o)||Dl(this.removesSubTreeCache,o,this.mirror)?jl(this.movedSet,o)?r(o):this.droppedSet.add(o):r(o);for(var a=null;i.length;){var l=null;if(a){var h=this.mirror.getId(el.parentNode(a.value)),u=n(a.value);-1!==h&&-1!==u&&(l=a)}if(!l)for(var c=i.tail;c;){var d=c;if(c=c.previous,d){var v=this.mirror.getId(el.parentNode(d.value));if(-1===n(d.value))continue;if(-1!==v){l=d;break}var f=d.value,p=el.parentNode(f);if(p&&p.nodeType===Node.DOCUMENT_FRAGMENT_NODE){var m=el.host(p);if(-1!==this.mirror.getId(m)){l=d;break}}}}if(!l){for(;i.head;)i.removeNode(i.head.value);break}a=l.previous,i.removeNode(l.value),r(l.value)}var g={texts:this.texts.map(t=>{var e=t.node,i=el.parentNode(e);return i&&"TEXTAREA"===i.tagName&&this.genTextAreaValueMutation(i),{id:this.mirror.getId(e),value:t.value}}).filter(t=>!e.has(t.id)).filter(t=>this.mirror.has(t.id)),attributes:this.attributes.map(t=>{var{attributes:e}=t;if("string"==typeof e.style){var i=JSON.stringify(t.styleDiff),n=JSON.stringify(t._unchangedStyles);i.length<e.style.length&&(i+n).split("var(").length===e.style.split("var(").length&&(e.style=t.styleDiff)}return{id:this.mirror.getId(t.node),attributes:e}}).filter(t=>!e.has(t.id)).filter(t=>this.mirror.has(t.id)),removes:this.removes,adds:t};(g.texts.length||g.attributes.length||g.removes.length||g.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},this.mutationCb(g))}}),c(this,"genTextAreaValueMutation",t=>{var e=this.attributeMap.get(t);e||(e={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(e),this.attributeMap.set(t,e));var i=Array.from(el.childNodes(t),t=>el.textContent(t)||"").join("");e.attributes.value=M({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:N(t),value:i,maskInputFn:this.maskInputFn})}),c(this,"processMutation",t=>{if(!vl(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":var e=el.textContent(t.target);dl(t.target,this.blockClass,this.blockSelector,!1)||e===t.oldValue||this.texts.push({value:nt(t.target,this.maskTextClass,this.maskTextSelector,!0)&&e?this.maskTextFn?this.maskTextFn(e,cl(t.target)):e.replace(/[\S]/g,"*"):e,node:t.target});break;case"attributes":var i=t.target,n=t.attributeName,r=t.target.getAttribute(n);if("value"===n){var s=N(i);r=M({element:i,maskInputOptions:this.maskInputOptions,tagName:i.tagName,type:s,value:r,maskInputFn:this.maskInputFn})}if(dl(t.target,this.blockClass,this.blockSelector,!1)||r===t.oldValue)return;var o=this.attributeMap.get(t.target);if("IFRAME"===i.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(i.contentDocument)return;n="rr_src"}if(o||(o={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(t.target,o)),"type"===n&&"INPUT"===i.tagName&&"password"===(t.oldValue||"").toLowerCase()&&i.setAttribute("data-rr-is-password","true"),!et(i.tagName,n))if(o.attributes[n]=tt(this.doc,O(i.tagName),O(n),r),"style"===n){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(t){this.unattachedDoc=this.doc}var a=this.unattachedDoc.createElement("span");for(var l of(t.oldValue&&a.setAttribute("style",t.oldValue),Array.from(i.style))){var h=i.style.getPropertyValue(l),u=i.style.getPropertyPriority(l);h!==a.style.getPropertyValue(l)||u!==a.style.getPropertyPriority(l)?o.styleDiff[l]=""===u?h:[h,u]:o._unchangedStyles[l]=[h,u]}for(var c of Array.from(a.style))""===i.style.getPropertyValue(c)&&(o.styleDiff[c]=!1)}else"open"===n&&"DIALOG"===i.tagName&&(i.matches("dialog:modal")?o.attributes.rr_open_mode="modal":o.attributes.rr_open_mode="non-modal");break;case"childList":if(dl(t.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===t.target.tagName)return void this.genTextAreaValueMutation(t.target);t.addedNodes.forEach(e=>this.genAdds(e,t.target)),t.removedNodes.forEach(e=>{var i=this.mirror.getId(e),n=_(t.target)?this.mirror.getId(el.host(t.target)):this.mirror.getId(t.target);dl(t.target,this.blockClass,this.blockSelector,!1)||vl(e,this.mirror,this.slimDOMOptions)||!function(t,e){return-1!==e.getId(t)}(e,this.mirror)||(this.addedSet.has(e)?(Bl(this.addedSet,e),this.droppedSet.add(e)):this.addedSet.has(t.target)&&-1===i||fl(t.target,this.mirror)||(this.movedSet.has(e)&&this.movedMap[Nl(i,n)]?Bl(this.movedSet,e):(this.removes.push({parentId:n,id:i,isShadow:!(!_(t.target)||!I(t.target))||void 0}),function(t,e){var i=[t];for(;i.length;){var n=i.pop();e.has(n)||(e.add(n),el.childNodes(n).forEach(t=>i.push(t)))}}(e,this.removesSubTreeCache))),this.mapRemoves.push(e))})}}),c(this,"genAdds",(t,e)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!this.addedSet.has(t)&&!this.movedSet.has(t)){if(this.mirror.hasNode(t)){if(vl(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);var i=null;e&&this.mirror.hasNode(e)&&(i=this.mirror.getId(e)),i&&-1!==i&&(this.movedMap[Nl(this.mirror.getId(t),i)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);dl(t,this.blockClass,this.blockSelector,!1)||(el.childNodes(t).forEach(t=>this.genAdds(t)),bl(t)&&el.childNodes(el.shadowRoot(t)).forEach(e=>{this.processedNodeManager.add(e,this),this.genAdds(e,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(e=>{this[e]=t[e]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Bl(t,e){t.delete(e),el.childNodes(e).forEach(e=>Bl(t,e))}function Dl(t,e,i){return 0!==t.size&&function(t,e){var i=el.parentNode(e);return!!i&&t.has(i)}(t,e)}function jl(t,e){return 0!==t.size&&Ul(t,e)}function Ul(t,e){var i=el.parentNode(e);return!!i&&(!!t.has(i)||Ul(t,i))}var Ll=t=>{if(!Rl)return t;return function(){try{return t(...arguments)}catch(t){if(Rl&&!0===Rl(t))return;throw t}}},Fl=[];function zl(t){try{if("composedPath"in t){var e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0]}catch(t){}return t&&t.target}function Wl(t,e){var i=new Pl;Fl.push(i),i.init(t);var n=new(Qa())(Ll(i.processMutations.bind(i)));return n.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n}function $l(t){var{mouseInteractionCb:e,doc:n,mirror:r,blockClass:s,blockSelector:o,sampling:a}=t;if(!1===a.mouseInteraction)return()=>{};var l=!0===a.mouseInteraction||void 0===a.mouseInteraction?{}:a.mouseInteraction,h=[],u=null;return Object.keys(_l).filter(t=>Number.isNaN(Number(t))&&!t.endsWith("_Departed")&&!1!==l[t]).forEach(t=>{var a=O(t),l=(t=>n=>{var a=zl(n);if(!dl(a,s,o,!0)){var l=null,h=t;if("pointerType"in n){switch(n.pointerType){case"mouse":l=Il.Mouse;break;case"touch":l=Il.Touch;break;case"pen":l=Il.Pen}l===Il.Touch?_l[t]===_l.MouseDown?h="TouchStart":_l[t]===_l.MouseUp&&(h="TouchEnd"):Il.Pen}else pl(n)&&(l=Il.Touch);null!==l?(u=l,(h.startsWith("Touch")&&l===Il.Touch||h.startsWith("Mouse")&&l===Il.Mouse)&&(l=null)):_l[t]===_l.Click&&(l=u,u=null);var c=pl(n)?n.changedTouches[0]:n;if(c){var d=r.getId(a),{clientX:v,clientY:f}=c;Ll(e)(i({type:_l[h],id:d,x:v,y:f},null!==l&&{pointerType:l}))}}})(t);if(window.PointerEvent)switch(_l[t]){case _l.MouseDown:case _l.MouseUp:a=a.replace("mouse","pointer");break;case _l.TouchStart:case _l.TouchEnd:return}h.push(il(a,l,n))}),Ll(()=>{h.forEach(t=>t())})}function Vl(t){var{scrollCb:e,doc:i,mirror:n,blockClass:r,blockSelector:s,sampling:o}=t;return il("scroll",Ll(sl(Ll(t=>{var o=zl(t);if(o&&!dl(o,r,s,!0)){var a=n.getId(o);if(o===i&&i.defaultView){var l=ll(i.defaultView);e({id:a,x:l.left,y:l.top})}else e({id:a,x:o.scrollLeft,y:o.scrollTop})}}),o.scroll||100)),i)}var Hl=["INPUT","TEXTAREA","SELECT"],ql=new WeakMap;function Jl(t){return function(t,e){if(Kl("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Kl("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Kl("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Kl("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){var i=Array.from(t.parentRule.cssRules).indexOf(t);e.unshift(i)}else if(t.parentStyleSheet){var n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);e.unshift(n)}return e}(t,[])}function Gl(t,e,i){var n,r;return t?(t.ownerNode?n=e.getId(t.ownerNode):r=i.getId(t),{styleId:r,id:n}):{}}function Zl(t,e){var i,n,r,{mirror:s,stylesheetManager:o}=t,a=null;a="#document"===e.nodeName?s.getId(e):s.getId(el.host(e));var l="#document"===e.nodeName?null==(i=e.defaultView)?void 0:i.Document:null==(r=null==(n=e.ownerDocument)?void 0:n.defaultView)?void 0:r.ShadowRoot,h=(null==l?void 0:l.prototype)?Object.getOwnPropertyDescriptor(null==l?void 0:l.prototype,"adoptedStyleSheets"):void 0;return null!==a&&-1!==a&&l&&h?(Object.defineProperty(e,"adoptedStyleSheets",{configurable:h.configurable,enumerable:h.enumerable,get(){var t;return null==(t=h.get)?void 0:t.call(this)},set(t){var e,i=null==(e=h.set)?void 0:e.call(this,t);if(null!==a&&-1!==a)try{o.adoptStyleSheets(t,a)}catch(t){}return i}}),Ll(()=>{Object.defineProperty(e,"adoptedStyleSheets",{configurable:h.configurable,enumerable:h.enumerable,get:h.get,set:h.set})})):()=>{}}function Yl(t,e){void 0===e&&(e={});var n,r=t.doc.defaultView;if(!r)return()=>{};!function(t,e){var{mutationCb:i,mousemoveCb:n,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:h,styleDeclarationCb:u,canvasMutationCb:c,fontCb:d,selectionCb:v,customElementCb:f}=t;t.mutationCb=function(){e.mutation&&e.mutation(...arguments),i(...arguments)},t.mousemoveCb=function(){e.mousemove&&e.mousemove(...arguments),n(...arguments)},t.mouseInteractionCb=function(){e.mouseInteraction&&e.mouseInteraction(...arguments),r(...arguments)},t.scrollCb=function(){e.scroll&&e.scroll(...arguments),s(...arguments)},t.viewportResizeCb=function(){e.viewportResize&&e.viewportResize(...arguments),o(...arguments)},t.inputCb=function(){e.input&&e.input(...arguments),a(...arguments)},t.mediaInteractionCb=function(){e.mediaInteaction&&e.mediaInteaction(...arguments),l(...arguments)},t.styleSheetRuleCb=function(){e.styleSheetRule&&e.styleSheetRule(...arguments),h(...arguments)},t.styleDeclarationCb=function(){e.styleDeclaration&&e.styleDeclaration(...arguments),u(...arguments)},t.canvasMutationCb=function(){e.canvasMutation&&e.canvasMutation(...arguments),c(...arguments)},t.fontCb=function(){e.font&&e.font(...arguments),d(...arguments)},t.selectionCb=function(){e.selection&&e.selection(...arguments),v(...arguments)},t.customElementCb=function(){e.customElement&&e.customElement(...arguments),f(...arguments)}}(t,e),t.recordDOM&&(n=Wl(t,t.doc));var s=function(t){var{mousemoveCb:e,sampling:i,doc:n,mirror:r}=t;if(!1===i.mousemove)return()=>{};var s,o="number"==typeof i.mousemove?i.mousemove:50,a="number"==typeof i.mousemoveCallback?i.mousemoveCallback:500,l=[],h=sl(Ll(t=>{var i=Date.now()-s;e(l.map(t=>(t.timeOffset-=i,t)),t),l=[],s=null}),a),u=Ll(sl(Ll(t=>{var e=zl(t),{clientX:i,clientY:n}=pl(t)?t.changedTouches[0]:t;s||(s=al()),l.push({x:i,y:n,id:r.getId(e),timeOffset:al()-s}),h("undefined"!=typeof DragEvent&&t instanceof DragEvent?Cl.Drag:t instanceof MouseEvent?Cl.MouseMove:Cl.TouchMove)}),o,{trailing:!1})),c=[il("mousemove",u,n),il("touchmove",u,n),il("drag",u,n)];return Ll(()=>{c.forEach(t=>t())})}(t),o=$l(t),a=Vl(t),l=function(t,e){var{viewportResizeCb:i}=t,{win:n}=e,r=-1,s=-1;return il("resize",Ll(sl(Ll(()=>{var t=hl(),e=ul();r===t&&s===e||(i({width:Number(e),height:Number(t)}),r=t,s=e)}),200)),n)}(t,{win:r}),h=function(t){var{inputCb:e,doc:n,mirror:r,blockClass:s,blockSelector:o,ignoreClass:a,ignoreSelector:l,maskInputOptions:h,maskInputFn:u,sampling:c,userTriggeredOnInput:d}=t;function v(t){var e=zl(t),i=t.isTrusted,r=e&&e.tagName;if(e&&"OPTION"===r&&(e=el.parentElement(e)),e&&r&&!(Hl.indexOf(r)<0)&&!dl(e,s,o,!0)&&!(e.classList.contains(a)||l&&e.matches(l))){var c=e.value,v=!1,p=N(e)||"";"radio"===p||"checkbox"===p?v=e.checked:(h[r.toLowerCase()]||h[p])&&(c=M({element:e,maskInputOptions:h,tagName:r,type:p,value:c,maskInputFn:u})),f(e,d?{text:c,isChecked:v,userTriggered:i}:{text:c,isChecked:v});var m=e.name;"radio"===p&&m&&v&&n.querySelectorAll('input[type="radio"][name="'+m+'"]').forEach(t=>{if(t!==e){var i=t.value;f(t,d?{text:i,isChecked:!v,userTriggered:!1}:{text:i,isChecked:!v})}})}}function f(t,n){var s=ql.get(t);if(!s||s.text!==n.text||s.isChecked!==n.isChecked){ql.set(t,n);var o=r.getId(t);Ll(e)(i({},n,{id:o}))}}var p=("last"===c.input?["change"]:["input","change"]).map(t=>il(t,Ll(v),n)),m=n.defaultView;if(!m)return()=>{p.forEach(t=>t())};var g=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),b=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&p.push(...b.map(t=>ol(t[0],t[1],{set(){Ll(v)({target:this,isTrusted:!1})}},!1,m))),Ll(()=>{p.forEach(t=>t())})}(t),u=function(t){var{mediaInteractionCb:e,blockClass:i,blockSelector:n,mirror:r,sampling:s,doc:o}=t,a=Ll(t=>sl(Ll(s=>{var o=zl(s);if(o&&!dl(o,i,n,!0)){var{currentTime:a,volume:l,muted:h,playbackRate:u,loop:c}=o;e({type:t,id:r.getId(o),currentTime:a,volume:l,muted:h,playbackRate:u,loop:c})}}),s.media||500)),l=[il("play",a(Tl.Play),o),il("pause",a(Tl.Pause),o),il("seeked",a(Tl.Seeked),o),il("volumechange",a(Tl.VolumeChange),o),il("ratechange",a(Tl.RateChange),o)];return Ll(()=>{l.forEach(t=>t())})}(t),c=()=>{},d=()=>{},v=()=>{},f=()=>{};t.recordDOM&&(c=function(t,e){var{styleSheetRuleCb:i,mirror:n,stylesheetManager:r}=t,{win:s}=e;if(!s.CSSStyleSheet||!s.CSSStyleSheet.prototype)return()=>{};var o=s.CSSStyleSheet.prototype.insertRule;s.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Ll((t,e,s)=>{var[o,a]=s,{id:l,styleId:h}=Gl(e,n,r.styleMirror);return(l&&-1!==l||h&&-1!==h)&&i({id:l,styleId:h,adds:[{rule:o,index:a}]}),t.apply(e,s)})}),s.CSSStyleSheet.prototype.addRule=function(t,e,i){void 0===i&&(i=this.cssRules.length);var n=t+" { "+e+" }";return s.CSSStyleSheet.prototype.insertRule.apply(this,[n,i])};var a,l,h=s.CSSStyleSheet.prototype.deleteRule;s.CSSStyleSheet.prototype.deleteRule=new Proxy(h,{apply:Ll((t,e,s)=>{var[o]=s,{id:a,styleId:l}=Gl(e,n,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&i({id:a,styleId:l,removes:[{index:o}]}),t.apply(e,s)})}),s.CSSStyleSheet.prototype.removeRule=function(t){return s.CSSStyleSheet.prototype.deleteRule.apply(this,[t])},s.CSSStyleSheet.prototype.replace&&(a=s.CSSStyleSheet.prototype.replace,s.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:Ll((t,e,s)=>{var[o]=s,{id:a,styleId:l}=Gl(e,n,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&i({id:a,styleId:l,replace:o}),t.apply(e,s)})})),s.CSSStyleSheet.prototype.replaceSync&&(l=s.CSSStyleSheet.prototype.replaceSync,s.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:Ll((t,e,s)=>{var[o]=s,{id:a,styleId:l}=Gl(e,n,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&i({id:a,styleId:l,replaceSync:o}),t.apply(e,s)})}));var u={};Xl("CSSGroupingRule")?u.CSSGroupingRule=s.CSSGroupingRule:(Xl("CSSMediaRule")&&(u.CSSMediaRule=s.CSSMediaRule),Xl("CSSConditionRule")&&(u.CSSConditionRule=s.CSSConditionRule),Xl("CSSSupportsRule")&&(u.CSSSupportsRule=s.CSSSupportsRule));var c={};return Object.entries(u).forEach(t=>{var[e,s]=t;c[e]={insertRule:s.prototype.insertRule,deleteRule:s.prototype.deleteRule},s.prototype.insertRule=new Proxy(c[e].insertRule,{apply:Ll((t,e,s)=>{var[o,a]=s,{id:l,styleId:h}=Gl(e.parentStyleSheet,n,r.styleMirror);return(l&&-1!==l||h&&-1!==h)&&i({id:l,styleId:h,adds:[{rule:o,index:[...Jl(e),a||0]}]}),t.apply(e,s)})}),s.prototype.deleteRule=new Proxy(c[e].deleteRule,{apply:Ll((t,e,s)=>{var[o]=s,{id:a,styleId:l}=Gl(e.parentStyleSheet,n,r.styleMirror);return(a&&-1!==a||l&&-1!==l)&&i({id:a,styleId:l,removes:[{index:[...Jl(e),o]}]}),t.apply(e,s)})})}),Ll(()=>{s.CSSStyleSheet.prototype.insertRule=o,s.CSSStyleSheet.prototype.deleteRule=h,a&&(s.CSSStyleSheet.prototype.replace=a),l&&(s.CSSStyleSheet.prototype.replaceSync=l),Object.entries(u).forEach(t=>{var[e,i]=t;i.prototype.insertRule=c[e].insertRule,i.prototype.deleteRule=c[e].deleteRule})})}(t,{win:r}),d=Zl(t,t.doc),v=function(t,e){var{styleDeclarationCb:i,mirror:n,ignoreCSSAttributes:r,stylesheetManager:s}=t,{win:o}=e,a=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(a,{apply:Ll((t,e,o)=>{var l,[h,u,c]=o;if(r.has(h))return a.apply(e,[h,u,c]);var{id:d,styleId:v}=Gl(null==(l=e.parentRule)?void 0:l.parentStyleSheet,n,s.styleMirror);return(d&&-1!==d||v&&-1!==v)&&i({id:d,styleId:v,set:{property:h,value:u,priority:c},index:Jl(e.parentRule)}),t.apply(e,o)})});var l=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(l,{apply:Ll((t,e,o)=>{var a,[h]=o;if(r.has(h))return l.apply(e,[h]);var{id:u,styleId:c}=Gl(null==(a=e.parentRule)?void 0:a.parentStyleSheet,n,s.styleMirror);return(u&&-1!==u||c&&-1!==c)&&i({id:u,styleId:c,remove:{property:h},index:Jl(e.parentRule)}),t.apply(e,o)})}),Ll(()=>{o.CSSStyleDeclaration.prototype.setProperty=a,o.CSSStyleDeclaration.prototype.removeProperty=l})}(t,{win:r}),t.collectFonts&&(f=function(t){var{fontCb:e,doc:i}=t,n=i.defaultView;if(!n)return()=>{};var r=[],s=new WeakMap,o=n.FontFace;n.FontFace=function(t,e,i){var n=new o(t,e,i);return s.set(n,{family:t,buffer:"string"!=typeof e,descriptors:i,fontSource:"string"==typeof e?e:JSON.stringify(Array.from(new Uint8Array(e)))}),n};var a=tl(i.fonts,"add",function(t){return function(i){return setTimeout(Ll(()=>{var t=s.get(i);t&&(e(t),s.delete(i))}),0),t.apply(this,[i])}});return r.push(()=>{n.FontFace=o}),r.push(a),Ll(()=>{r.forEach(t=>t())})}(t)));var p=function(t){var{doc:e,mirror:i,blockClass:n,blockSelector:r,selectionCb:s}=t,o=!0,a=Ll(()=>{var t=e.getSelection();if(!(!t||o&&(null==t?void 0:t.isCollapsed))){o=t.isCollapsed||!1;for(var a=[],l=t.rangeCount||0,h=0;h<l;h++){var u=t.getRangeAt(h),{startContainer:c,startOffset:d,endContainer:v,endOffset:f}=u;dl(c,n,r,!0)||dl(v,n,r,!0)||a.push({start:i.getId(c),startOffset:d,end:i.getId(v),endOffset:f})}s({ranges:a})}});return a(),il("selectionchange",a)}(t),m=function(t){var{doc:e,customElementCb:i}=t,n=e.defaultView;return n&&n.customElements?tl(n.customElements,"define",function(t){return function(e,n,r){try{i({define:{name:e}})}catch(t){console.warn("Custom element callback failed for "+e)}return t.apply(this,[e,n,r])}}):()=>{}}(t),g=[];for(var b of t.plugins)g.push(b.observer(b.callback,r,b.options));return Ll(()=>{Fl.forEach(t=>t.reset()),null==n||n.disconnect(),s(),o(),a(),l(),h(),u(),c(),d(),v(),f(),p(),m(),g.forEach(t=>t())})}function Kl(t){return void 0!==window[t]}function Xl(t){return Boolean(void 0!==window[t]&&window[t].prototype&&"insertRule"in window[t].prototype&&"deleteRule"in window[t].prototype)}class Ql{constructor(t){c(this,"iframeIdToRemoteIdMap",new WeakMap),c(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,e,i,n){var r=i||this.getIdToRemoteIdMap(t),s=n||this.getRemoteIdToIdMap(t),o=r.get(e);return o||(o=this.generateIdFn(),r.set(e,o),s.set(o,e)),o}getIds(t,e){var i=this.getIdToRemoteIdMap(t),n=this.getRemoteIdToIdMap(t);return e.map(e=>this.getId(t,e,i,n))}getRemoteId(t,e,i){var n=i||this.getRemoteIdToIdMap(t);if("number"!=typeof e)return e;var r=n.get(e);return r||-1}getRemoteIds(t,e){var i=this.getRemoteIdToIdMap(t);return e.map(e=>this.getRemoteId(t,e,i))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){var e=this.iframeIdToRemoteIdMap.get(t);return e||(e=new Map,this.iframeIdToRemoteIdMap.set(t,e)),e}getRemoteIdToIdMap(t){var e=this.iframeRemoteIdToIdMap.get(t);return e||(e=new Map,this.iframeRemoteIdToIdMap.set(t,e)),e}}class th{constructor(t){c(this,"iframes",new WeakMap),c(this,"crossOriginIframeMap",new WeakMap),c(this,"crossOriginIframeMirror",new Ql(J)),c(this,"crossOriginIframeStyleMirror"),c(this,"crossOriginIframeRootIdMap",new WeakMap),c(this,"mirror"),c(this,"mutationCb"),c(this,"wrappedEmit"),c(this,"loadListener"),c(this,"stylesheetManager"),c(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ql(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,e){var i,n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(i=t.contentWindow)||i.addEventListener("message",this.handleMessage.bind(this))),null==(n=this.loadListener)||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){var e=t;if("rrweb"===e.data.type&&e.origin===e.data.origin&&t.source){var i=this.crossOriginIframeMap.get(t.source);if(i){var n=this.transformCrossOriginEvent(i,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}}transformCrossOriginEvent(t,e){var i;switch(e.type){case Sl.FullSnapshot:this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(e.data.node,t);var n=e.data.node.id;return this.crossOriginIframeRootIdMap.set(t,n),this.patchRootIdOnNode(e.data.node,n),{timestamp:e.timestamp,type:Sl.IncrementalSnapshot,data:{source:Cl.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:e.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Sl.Meta:case Sl.Load:case Sl.DomContentLoaded:return!1;case Sl.Plugin:return e;case Sl.Custom:return this.replaceIds(e.data.payload,t,["id","parentId","previousId","nextId"]),e;case Sl.IncrementalSnapshot:switch(e.data.source){case Cl.Mutation:return e.data.adds.forEach(e=>{this.replaceIds(e,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(e.node,t);var i=this.crossOriginIframeRootIdMap.get(t);i&&this.patchRootIdOnNode(e.node,i)}),e.data.removes.forEach(e=>{this.replaceIds(e,t,["parentId","id"])}),e.data.attributes.forEach(e=>{this.replaceIds(e,t,["id"])}),e.data.texts.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Cl.Drag:case Cl.TouchMove:case Cl.MouseMove:return e.data.positions.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Cl.ViewportResize:return!1;case Cl.MediaInteraction:case Cl.MouseInteraction:case Cl.Scroll:case Cl.CanvasMutation:case Cl.Input:return this.replaceIds(e.data,t,["id"]),e;case Cl.StyleSheetRule:case Cl.StyleDeclaration:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleId"]),e;case Cl.Font:return e;case Cl.Selection:return e.data.ranges.forEach(e=>{this.replaceIds(e,t,["start","end"])}),e;case Cl.AdoptedStyleSheet:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleIds"]),null==(i=e.data.styles)||i.forEach(e=>{this.replaceStyleIds(e,t,["styleId"])}),e}}return!1}replace(t,e,i,n){for(var r of n)(Array.isArray(e[r])||"number"==typeof e[r])&&(Array.isArray(e[r])?e[r]=t.getIds(i,e[r]):e[r]=t.getId(i,e[r]));return e}replaceIds(t,e,i){return this.replace(this.crossOriginIframeMirror,t,e,i)}replaceStyleIds(t,e,i){return this.replace(this.crossOriginIframeStyleMirror,t,e,i)}replaceIdOnNode(t,e){this.replaceIds(t,e,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(t=>{this.replaceIdOnNode(t,e)})}patchRootIdOnNode(t,e){t.type===El.Document||t.rootId||(t.rootId=e),"childNodes"in t&&t.childNodes.forEach(t=>{this.patchRootIdOnNode(t,e)})}}class eh{constructor(t){c(this,"shadowDoms",new WeakSet),c(this,"mutationCb"),c(this,"scrollCb"),c(this,"bypassOptions"),c(this,"mirror"),c(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,e){if(I(t)&&!this.shadowDoms.has(t)){this.shadowDoms.add(t);var n=Wl(i({},this.bypassOptions,{doc:e,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(Vl(i({},this.bypassOptions,{scrollCb:this.scrollCb,doc:t,mirror:this.mirror}))),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(el.host(t))),this.restoreHandlers.push(Zl({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}}observeAttachShadow(t){t.contentWindow&&t.contentDocument&&this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,e){var i=this;this.restoreHandlers.push(tl(t.prototype,"attachShadow",function(t){return function(n){var r=t.call(this,n),s=el.shadowRoot(this);return s&&xl(this)&&i.addShadowRoot(s,e),r}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var ih="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nh="undefined"==typeof Uint8Array?[]:new Uint8Array(256),rh=0;rh<64;rh++)nh[ih.charCodeAt(rh)]=rh;var sh=new Map;var oh=(t,e,i)=>{if(t&&(hh(t,e)||"object"==typeof t)){var n=function(t,e){var i=sh.get(t);return i||(i=new Map,sh.set(t,i)),i.has(e)||i.set(e,[]),i.get(e)}(i,t.constructor.name),r=n.indexOf(t);return-1===r&&(r=n.length,n.push(t)),r}};function ah(t,e,i){if(t instanceof Array)return t.map(t=>ah(t,e,i));if(null===t)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer)return{rr_type:t.constructor.name,base64:function(t){var e,i=new Uint8Array(t),n=i.length,r="";for(e=0;e<n;e+=3)r+=ih[i[e]>>2],r+=ih[(3&i[e])<<4|i[e+1]>>4],r+=ih[(15&i[e+1])<<2|i[e+2]>>6],r+=ih[63&i[e+2]];return n%3==2?r=r.substring(0,r.length-1)+"=":n%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(t)};if(t instanceof DataView)return{rr_type:t.constructor.name,args:[ah(t.buffer,e,i),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){var n=t.constructor.name,{src:r}=t;return{rr_type:n,src:r}}if(t instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:t.toDataURL()}}return t instanceof ImageData?{rr_type:t.constructor.name,args:[ah(t.data,e,i),t.width,t.height]}:hh(t,e)||"object"==typeof t?{rr_type:t.constructor.name,index:oh(t,e,i)}:t}var lh=(t,e,i)=>t.map(t=>ah(t,e,i)),hh=(t,e)=>{var i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(t=>"function"==typeof e[t]);return Boolean(i.find(i=>t instanceof e[i]))};function uh(t,e,i,n){var r=[];try{var s=tl(t.HTMLCanvasElement.prototype,"getContext",function(t){return function(r){for(var s=arguments.length,o=new Array(s>1?s-1:0),a=1;a<s;a++)o[a-1]=arguments[a];if(!dl(this,e,i,!0)){var l=function(t){return"experimental-webgl"===t?"webgl":t}(r);if("__context"in this||(this.__context=l),n&&["webgl","webgl2"].includes(l))if(o[0]&&"object"==typeof o[0]){var h=o[0];h.preserveDrawingBuffer||(h.preserveDrawingBuffer=!0)}else o.splice(0,1,{preserveDrawingBuffer:!0})}return t.apply(this,[r,...o])}});r.push(s)}catch(t){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{r.forEach(t=>t())}}function ch(t,e,i,n,r,s){var o=[],a=Object.getOwnPropertyNames(t),l=function(a){if(["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(a))return 0;try{if("function"!=typeof t[a])return 0;var l=tl(t,a,function(t){return function(){for(var o=arguments.length,l=new Array(o),h=0;h<o;h++)l[h]=arguments[h];var u=t.apply(this,l);if(oh(u,s,this),"tagName"in this.canvas&&!dl(this.canvas,n,r,!0)){var c=lh(l,s,this),d={type:e,property:a,args:c};i(this.canvas,d)}return u}});o.push(l)}catch(n){var h=ol(t,a,{set(t){i(this.canvas,{type:e,property:a,args:[t],setter:!0})}});o.push(h)}};for(var h of a)l(h);return o}var dh,vh,fh,ph,mh="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",gh="undefined"!=typeof window&&window.Blob&&new Blob([(dh=mh,Uint8Array.from(atob(dh),t=>t.charCodeAt(0)))],{type:"text/javascript;charset=utf-8"});function bh(t){var e;try{if(!(e=gh&&(window.URL||window.webkitURL).createObjectURL(gh)))throw"";var i=new Worker(e,{name:null==t?void 0:t.name});return i.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),i}catch(e){return new Worker("data:text/javascript;base64,"+mh,{name:null==t?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}class yh{constructor(t){c(this,"pendingCanvasMutations",new Map),c(this,"rafStamps",{latestId:0,invokeId:null}),c(this,"mirror"),c(this,"mutationCb"),c(this,"resetObservers"),c(this,"frozen",!1),c(this,"locked",!1),c(this,"processMutation",(t,e)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(t)||this.pendingCanvasMutations.set(t,[]),this.pendingCanvasMutations.get(t).push(e)});var{sampling:e="all",win:i,blockClass:n,blockSelector:r,recordCanvas:s,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,s&&"all"===e&&this.initCanvasMutationObserver(i,n,r),s&&"number"==typeof e&&this.initCanvasFPSObserver(e,i,n,r,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,i,n,r,s){var o=this,a=uh(i,n,r,!0),l=new Map,h=new bh;h.onmessage=t=>{var{id:e}=t.data;if(l.set(e,!1),"base64"in t.data){var{base64:i,type:n,width:r,height:s}=t.data;this.mutationCb({id:e,type:Al["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:i}],type:n}]},0,0]}]})}};var u,c=1e3/t,d=0,v=t=>{var a;d&&t-d<c?u=requestAnimationFrame(v):(d=t,(a=[],i.document.querySelectorAll("canvas").forEach(t=>{dl(t,n,r,!0)||a.push(t)}),a).forEach(function(){var t=e(function*(t){var e,i=o.mirror.getId(t);if(!l.get(i)&&0!==t.width&&0!==t.height){if(l.set(i,!0),["webgl","webgl2"].includes(t.__context)){var n=t.getContext(t.__context);!1===(null==(e=null==n?void 0:n.getContextAttributes())?void 0:e.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}var r=yield createImageBitmap(t);h.postMessage({id:i,bitmap:r,width:t.width,height:t.height,dataURLOptions:s.dataURLOptions},[r])}});return function(e){return t.apply(this,arguments)}}()),u=requestAnimationFrame(v))};u=requestAnimationFrame(v),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,e,i){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();var n=uh(t,e,i,!1),r=function(t,e,i,n){var r=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype),o=function(s){try{if("function"!=typeof e.CanvasRenderingContext2D.prototype[s])return 1;var o=tl(e.CanvasRenderingContext2D.prototype,s,function(r){return function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return dl(this.canvas,i,n,!0)||setTimeout(()=>{var i=lh(a,e,this);t(this.canvas,{type:Al["2D"],property:s,args:i})},0),r.apply(this,a)}});r.push(o)}catch(i){var a=ol(e.CanvasRenderingContext2D.prototype,s,{set(e){t(this.canvas,{type:Al["2D"],property:s,args:[e],setter:!0})}});r.push(a)}};for(var a of s)o(a);return()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,i),s=function(t,e,i,n){var r=[];return r.push(...ch(e.WebGLRenderingContext.prototype,Al.WebGL,t,i,n,e)),void 0!==e.WebGL2RenderingContext&&r.push(...ch(e.WebGL2RenderingContext.prototype,Al.WebGL2,t,i,n,e)),()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,i);this.resetObservers=()=>{n(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){var t=e=>{this.rafStamps.latestId=e,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,e)=>{var i=this.mirror.getId(e);this.flushPendingCanvasMutationFor(e,i)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,e){if(!this.frozen&&!this.locked){var i=this.pendingCanvasMutations.get(t);if(i&&-1!==e){var r=i.map(t=>n(t,h)),{type:s}=i[0];this.mutationCb({id:e,type:s,commands:r}),this.pendingCanvasMutations.delete(t)}}}}class wh{constructor(t){c(this,"trackedLinkElements",new WeakSet),c(this,"mutationCb"),c(this,"adoptedStyleSheetCb"),c(this,"styleMirror",new yl),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,e){"_cssText"in e.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:e.id,attributes:e.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,e){var i=this;if(0!==t.length){var n={id:e,styleIds:[]},r=[],s=function(t){var e;i.styleMirror.has(t)?e=i.styleMirror.getId(t):(e=i.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,i)=>({rule:T(e,t.href),index:i}))})),n.styleIds.push(e)};for(var o of t)s(o);r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class kh{constructor(){c(this,"nodeMap",new WeakMap),c(this,"active",!1)}inOtherBuffer(t,e){var i=this.nodeMap.get(t);return i&&Array.from(i).some(t=>t!==e)}add(t,e){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(e))}destroy(){}}var xh=!1;try{if(2!==Array.from([1],t=>2*t)[0]){var Sh=document.createElement("iframe");document.body.appendChild(Sh),Array.from=(null==(r=Sh.contentWindow)?void 0:r.Array.from)||Array.from,document.body.removeChild(Sh)}}catch(t){console.debug("Unable to override Array.from",t)}var Ch,_h,Ih=new E;function Ah(t){void 0===t&&(t={});var{emit:e,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:s="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:l=null,maskTextClass:h="rr-mask",maskTextSelector:u=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:v,slimDOMOptions:f,maskInputFn:p,maskTextFn:m,hooks:g,packFn:b,sampling:y={},dataURLOptions:w={},mousemoveWait:k,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:C=!1,recordAfter:_=("DOMContentLoaded"===t.recordAfter?t.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:A=!1,inlineImages:T=!1,plugins:M,keepIframeSrcFn:O=()=>!1,ignoreCSSAttributes:R=new Set([]),errorHandler:N}=t;Rl=N;var P=!C||window.parent===window,B=!1;if(!P)try{window.parent.document&&(B=!1)}catch(t){B=!0}if(P&&!e)throw new Error("emit function is required");if(!P&&!B)return()=>{};void 0!==k&&void 0===y.mousemove&&(y.mousemove=k),Ih.reset();var D,j=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==v?v:{password:!0},U=ot(f);!function(t){void 0===t&&(t=window),"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();var L=0,F=t=>{for(var e of M||[])e.eventProcessor&&(t=e.eventProcessor(t));return b&&!B&&(t=b(t)),t};vh=(t,i)=>{var s,o=t;if(o.timestamp=al(),!(null==(s=Fl[0])?void 0:s.isFrozen())||o.type===Sl.FullSnapshot||o.type===Sl.IncrementalSnapshot&&o.data.source===Cl.Mutation||Fl.forEach(t=>t.unfreeze()),P)null==e||e(F(o),i);else if(B){var a={type:"rrweb",event:F(o),origin:window.location.origin,isCheckout:i};window.parent.postMessage(a,"*")}if(o.type===Sl.FullSnapshot)D=o,L=0;else if(o.type===Sl.IncrementalSnapshot){if(o.data.source===Cl.Mutation&&o.data.isAttachIframe)return;L++;var l=r&&L>=r,h=n&&o.timestamp-D.timestamp>n;(l||h)&&fh(!0)}};var z=t=>{vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.Mutation},t)})},W=t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.Scroll},t)}),V=t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.CanvasMutation},t)}),H=new wh({mutationCb:z,adoptedStyleSheetCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.AdoptedStyleSheet},t)})}),q=new th({mirror:Ih,mutationCb:z,stylesheetManager:H,recordCrossOriginIframes:C,wrappedEmit:vh});for(var J of M||[])J.getMirror&&J.getMirror({nodeMirror:Ih,crossOriginIframeMirror:q.crossOriginIframeMirror,crossOriginIframeStyleMirror:q.crossOriginIframeStyleMirror});var G=new kh;ph=new yh({recordCanvas:S,mutationCb:V,win:window,blockClass:s,blockSelector:o,mirror:Ih,sampling:y.canvas,dataURLOptions:w});var Z=new eh({mutationCb:z,scrollCb:W,bypassOptions:{blockClass:s,blockSelector:o,maskTextClass:h,maskTextSelector:u,inlineStylesheet:c,maskInputOptions:j,dataURLOptions:w,maskTextFn:m,maskInputFn:p,recordCanvas:S,inlineImages:T,sampling:y,slimDOMOptions:U,iframeManager:q,stylesheetManager:H,canvasManager:ph,keepIframeSrcFn:O,processedNodeManager:G},mirror:Ih});fh=function(t){if(void 0===t&&(t=!1),x){vh({type:Sl.Meta,data:{href:window.location.href,width:ul(),height:hl()}},t),H.reset(),Z.init(),Fl.forEach(t=>t.lock());var e=function(t,e){var{mirror:i=new E,blockClass:n="rr-block",blockSelector:r=null,maskTextClass:s="rr-mask",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:h=!1,maskAllInputs:u=!1,maskTextFn:c,maskInputFn:d,slimDOM:v=!1,dataURLOptions:f,preserveWhiteSpace:p,onSerialize:m,onIframeLoad:g,iframeLoadTimeout:b,onStylesheetLoad:y,stylesheetLoadTimeout:w,keepIframeSrcFn:k=()=>!1}=e||{};return at(t,{doc:t,mirror:i,blockClass:n,blockSelector:r,maskTextClass:s,maskTextSelector:o,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===u?{password:!0}:u,maskTextFn:c,maskInputFn:d,slimDOMOptions:ot(v),dataURLOptions:f,inlineImages:l,recordCanvas:h,preserveWhiteSpace:p,onSerialize:m,onIframeLoad:g,iframeLoadTimeout:b,onStylesheetLoad:y,stylesheetLoadTimeout:w,keepIframeSrcFn:k,newlyAddedElement:!1})}(document,{mirror:Ih,blockClass:s,blockSelector:o,maskTextClass:h,maskTextSelector:u,inlineStylesheet:c,maskAllInputs:j,maskTextFn:m,maskInputFn:p,slimDOM:U,dataURLOptions:w,recordCanvas:S,inlineImages:T,onSerialize:t=>{ml(t,Ih)&&q.addIframe(t),gl(t,Ih)&&H.trackLinkElement(t),bl(t)&&Z.addShadowRoot(el.shadowRoot(t),document)},onIframeLoad:(t,e)=>{q.attachIframe(t,e),Z.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{H.attachLinkElement(t,e)},keepIframeSrcFn:O});if(!e)return console.warn("Failed to snapshot the document");vh({type:Sl.FullSnapshot,data:{node:e,initialOffset:ll(window)}},t),Fl.forEach(t=>t.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&H.adoptStyleSheets(document.adoptedStyleSheets,Ih.getId(document))}};try{var Y=[],K=t=>{var e;return Ll(Yl)({mutationCb:z,mousemoveCb:(t,e)=>vh({type:Sl.IncrementalSnapshot,data:{source:e,positions:t}}),mouseInteractionCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.MouseInteraction},t)}),scrollCb:W,viewportResizeCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.ViewportResize},t)}),inputCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.Input},t)}),mediaInteractionCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.MediaInteraction},t)}),styleSheetRuleCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.StyleSheetRule},t)}),styleDeclarationCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.StyleDeclaration},t)}),canvasMutationCb:V,fontCb:t=>vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.Font},t)}),selectionCb:t=>{vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.Selection},t)})},customElementCb:t=>{vh({type:Sl.IncrementalSnapshot,data:i({source:Cl.CustomElement},t)})},blockClass:s,ignoreClass:a,ignoreSelector:l,maskTextClass:h,maskTextSelector:u,maskInputOptions:j,inlineStylesheet:c,sampling:y,recordDOM:x,recordCanvas:S,inlineImages:T,userTriggeredOnInput:I,collectFonts:A,doc:t,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:O,blockSelector:o,slimDOMOptions:U,dataURLOptions:w,mirror:Ih,iframeManager:q,stylesheetManager:H,shadowDomManager:Z,processedNodeManager:G,canvasManager:ph,ignoreCSSAttributes:R,plugins:(null==(e=null==M?void 0:M.filter(t=>t.observer))?void 0:e.map(t=>({observer:t.observer,options:t.options,callback:e=>vh({type:Sl.Plugin,data:{plugin:t.name,payload:e}})})))||[]},g)};q.addLoadListener(t=>{try{Y.push(K(t.contentDocument))}catch(t){console.warn(t)}});var X=()=>{fh(),Y.push(K(document)),xh=!0};return["interactive","complete"].includes(document.readyState)?X():(Y.push(il("DOMContentLoaded",()=>{vh({type:Sl.DomContentLoaded,data:{}}),"DOMContentLoaded"===_&&X()})),Y.push(il("load",()=>{vh({type:Sl.Load,data:{}}),"load"===_&&X()},window))),()=>{Y.forEach(t=>{try{t()}catch(t){String(t).toLowerCase().includes("cross-origin")||console.warn(t)}}),G.destroy(),xh=!1,Rl=void 0}}catch(t){console.warn(t)}}Ah.addCustomEvent=(t,e)=>{if(!xh)throw new Error("please add custom event after start recording");vh({type:Sl.Custom,data:{tag:t,payload:e}})},Ah.freezePage=()=>{Fl.forEach(t=>t.freeze())},Ah.takeFullSnapshot=t=>{if(!xh)throw new Error("please take full snapshot after start recording");fh(t)},Ah.mirror=Ih,(_h=Ch||(Ch={}))[_h.NotStarted=0]="NotStarted",_h[_h.Running=1]="Running",_h[_h.Stopped=2]="Stopped";var Th=Object.defineProperty,Eh=(t,e,i)=>((t,e,i)=>e in t?Th(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);class Mh{constructor(t){Eh(this,"fileName"),Eh(this,"functionName"),Eh(this,"lineNumber"),Eh(this,"columnNumber"),this.fileName=t.fileName||"",this.functionName=t.functionName||"",this.lineNumber=t.lineNumber,this.columnNumber=t.columnNumber}toString(){var t=this.lineNumber||"",e=this.columnNumber||"";return this.functionName?this.functionName+" ("+this.fileName+":"+t+":"+e+")":this.fileName+":"+t+":"+e}}var Oh=/(^|@)\S+:\d+/,Rh=/^\s*at .*(\S+:\d+|\(native\))/m,Nh=/^(eval@)?(\[native code])?$/,Ph={parse:function(t){return t?void 0!==t.stacktrace||void 0!==t["opera#sourceloc"]?this.parseOpera(t):t.stack&&t.stack.match(Rh)?this.parseV8OrIE(t):t.stack?this.parseFFOrSafari(t):(console.warn("[console-record-plugin]: Failed to parse error object:",t),[]):[]},extractLocation:function(t){if(-1===t.indexOf(":"))return[t];var e=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(t.replace(/[()]/g,""));if(!e)throw new Error("Cannot parse given url: "+t);return[e[1],e[2]||void 0,e[3]||void 0]},parseV8OrIE:function(t){return t.stack.split("\n").filter(function(t){return!!t.match(Rh)},this).map(function(t){t.indexOf("(eval ")>-1&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var e=t.replace(/^\s+/,"").replace(/\(eval code/g,"("),i=e.match(/ (\((.+):(\d+):(\d+)\)$)/),n=(e=i?e.replace(i[0],""):e).split(/\s+/).slice(1),r=this.extractLocation(i?i[1]:n.pop()),s=n.join(" ")||void 0,o=["eval","<anonymous>"].indexOf(r[0])>-1?void 0:r[0];return new Mh({functionName:s,fileName:o,lineNumber:r[1],columnNumber:r[2]})},this)},parseFFOrSafari:function(t){return t.stack.split("\n").filter(function(t){return!t.match(Nh)},this).map(function(t){if(t.indexOf(" > eval")>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===t.indexOf("@")&&-1===t.indexOf(":"))return new Mh({functionName:t});var e=/((.*".+"[^@]*)?[^@]*)(?:@)/,i=t.match(e),n=i&&i[1]?i[1]:void 0,r=this.extractLocation(t.replace(e,""));return new Mh({functionName:n,fileName:r[0],lineNumber:r[1],columnNumber:r[2]})},this)},parseOpera:function(t){return!t.stacktrace||t.message.indexOf("\n")>-1&&t.message.split("\n").length>t.stacktrace.split("\n").length?this.parseOpera9(t):t.stack?this.parseOpera11(t):this.parseOpera10(t)},parseOpera9:function(t){for(var e=/Line (\d+).*script (?:in )?(\S+)/i,i=t.message.split("\n"),n=[],r=2,s=i.length;r<s;r+=2){var o=e.exec(i[r]);o&&n.push(new Mh({fileName:o[2],lineNumber:parseFloat(o[1])}))}return n},parseOpera10:function(t){for(var e=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=t.stacktrace.split("\n"),n=[],r=0,s=i.length;r<s;r+=2){var o=e.exec(i[r]);o&&n.push(new Mh({functionName:o[3]||void 0,fileName:o[2],lineNumber:parseFloat(o[1])}))}return n},parseOpera11:function(t){return t.stack.split("\n").filter(function(t){return!!t.match(Oh)&&!t.match(/^Error created at/)},this).map(function(t){var e=t.split("@"),i=this.extractLocation(e.pop()),n=(e.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Mh({functionName:n,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)}};function Bh(t){if(!t||!t.outerHTML)return"";for(var e="";t.parentElement;){var i=t.localName;if(!i)break;i=i.toLowerCase();var n=t.parentElement,r=[];if(n.children&&n.children.length>0)for(var s=0;s<n.children.length;s++){var o=n.children[s];o.localName&&o.localName.toLowerCase&&o.localName.toLowerCase()===i&&r.push(o)}r.length>1&&(i+=":eq("+r.indexOf(t)+")"),e=i+(e?">"+e:""),t=n}return e}function Dh(t){return"[object Object]"===Object.prototype.toString.call(t)}function jh(t,e){if(0===e)return!0;var i=Object.keys(t);for(var n of i)if(Dh(t[n])&&jh(t[n],e-1))return!0;return!1}function Uh(t,e){var i={numOfKeysLimit:50,depthOfLimit:4};Object.assign(i,e);var n=[],r=[];return JSON.stringify(t,function(t,e){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?r.splice(s,1/0,t):r.push(t),~n.indexOf(e)&&(e=n[0]===e?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(e)).join(".")+"]")}else n.push(e);if(null===e)return e;if(void 0===e)return"undefined";if(function(t){if(Dh(t)&&Object.keys(t).length>i.numOfKeysLimit)return!0;if("function"==typeof t)return!0;if(Dh(t)&&jh(t,i.depthOfLimit))return!0;return!1}(e))return function(t){var e=t.toString();i.stringLengthLimit&&e.length>i.stringLengthLimit&&(e=e.slice(0,i.stringLengthLimit)+"...");return e}(e);if("bigint"==typeof e)return e.toString()+"n";if(e instanceof Event){var o={};for(var a in e){var l=e[a];Array.isArray(l)?o[a]=Bh(l.length?l[0]:null):o[a]=l}return o}return e instanceof Node?e instanceof HTMLElement?e?e.outerHTML:"":e.nodeName:e instanceof Error?e.stack?e.stack+"\nEnd of stack for Error object":e.name+": "+e.message:e})}var Lh={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function Fh(t,e,i){var n,r=i?Object.assign({},Lh,i):Lh,s=r.logger;if(!s)return()=>{};n="string"==typeof s?e[s]:s;var o=0,a=!1,l=[];if(r.level.includes("error")){var h=e=>{var i=e.message,n=e.error,s=Ph.parse(n).map(t=>t.toString()),o=[Uh(i,r.stringifyOptions)];t({level:"error",trace:s,payload:o})};e.addEventListener("error",h),l.push(()=>{e.removeEventListener("error",h)});var u=e=>{var i,n;e.reason instanceof Error?n=[Uh("Uncaught (in promise) "+(i=e.reason).name+": "+i.message,r.stringifyOptions)]:(i=new Error,n=[Uh("Uncaught (in promise)",r.stringifyOptions),Uh(e.reason,r.stringifyOptions)]);var s=Ph.parse(i).map(t=>t.toString());t({level:"error",trace:s,payload:n})};e.addEventListener("unhandledrejection",u),l.push(()=>{e.removeEventListener("unhandledrejection",u)})}for(var c of r.level)l.push(d(n,c));return()=>{l.forEach(t=>t())};function d(e,i){var n=this;return e[i]?function(t,e,i){try{if(!(e in t))return()=>{};var n=t[e],r=i(n);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:n}})),t[e]=r,()=>{t[e]=n}}catch(t){return()=>{}}}(e,i,e=>function(){for(var s=arguments.length,l=new Array(s),h=0;h<s;h++)l[h]=arguments[h];if(e.apply(n,l),!("assert"===i&&l[0]||a)){a=!0;try{var u=Ph.parse(new Error).map(t=>t.toString()).splice(1),c=("assert"===i?l.slice(1):l).map(t=>Uh(t,r.stringifyOptions));++o<r.lengthThreshold?t({level:i,trace:u,payload:c}):o===r.lengthThreshold&&t({level:"warn",trace:[],payload:[Uh("The number of log records reached the threshold.")]})}catch(t){e("rrweb logger error:",t,...l)}finally{a=!1}}}):()=>{}}}var zh="undefined"!=typeof window?window:void 0,Wh="undefined"!=typeof globalThis?globalThis:zh,$h=null==Wh?void 0:Wh.navigator,Vh=null==Wh?void 0:Wh.document,Hh=null==Wh?void 0:Wh.location,qh=null==Wh?void 0:Wh.fetch;zh&&Vh&&Vh.createElement,null==Wh||Wh.XMLHttpRequest,null==Wh||Wh.AbortController;var Jh=null==$h?void 0:$h.userAgent,Gh=null!=zh?zh:{},Zh=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Zh||{}),Yh=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(Yh||{});function Kh(t){return"string"==typeof t}function Xh(t){return void 0===t}function Qh(t){return null==t}function tu(t){return Array.isArray(t)}function eu(t){return"function"==typeof t}var iu={none:0,error:1,warn:2,info:3,debug:4},nu="[vTilt]",ru=new Set(["none","error","warn","info","debug"]);function su(){return"undefined"!=typeof console}function ou(t){var e=t.length>0&&"string"==typeof t[0]?t[0]:"",i=e?t.slice(1):t;return[e?nu+":"+e:nu,...i]}var au="warn",lu=!1;var hu=null;function uu(){return hu||(hu={setLevel(t,e){void 0===e&&(e=!1),au=t,e&&(lu=!0)},setLevelFromRemote(t){lu||t&&ru.has(t)&&(au=t)},getLevel:()=>au,isLockedByInit:()=>lu,debug(){if(!(iu[au]<iu.debug)&&su()){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];console.log(...ou(e))}},info(){if(!(iu[au]<iu.info)&&su()){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];console.log(...ou(e))}},warn(){if(!(iu[au]<iu.warn)&&su()){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];console.warn(...ou(e))}},error(){if(!(iu[au]<iu.error)&&su()){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];console.error(...ou(e))}}}),hu}function cu(t,e){void 0===e&&(e=!0);var i=void 0!==t.log_level||!!t.debug,n=function(t){return t.log_level&&ru.has(t.log_level)?t.log_level:t.debug?"debug":"warn"}(t);return uu().setLevel(n,e&&i),n}function du(t,e){try{return t()}catch(t){return e}}var vu="x-api-key";function fu(t,e,i){void 0===i&&(i={});var{api_host:n,token:r}=t,s=""+(n?n.replace(/\/+$/gm,""):"")+e;if(i.includeTokenQuery&&r){var o=s.includes("?")?"&":"?";s=""+s+o+"token="+r}return s}function pu(t){return t.token?{[vu]:t.token}:{}}class mu{constructor(){this.k=new Map,this.C=new Map}on(t,e){return this.k.has(t)||this.k.set(t,new Set),this.k.get(t).add(e),()=>{var i;null===(i=this.k.get(t))||void 0===i||i.delete(e)}}once(t,e){return this.C.has(t)||this.C.set(t,new Set),this.C.get(t).add(e),()=>{var i;null===(i=this.C.get(t))||void 0===i||i.delete(e)}}emit(t,e){var i,n;null===(i=this.k.get(t))||void 0===i||i.forEach(i=>{try{i(e)}catch(e){uu().error("emitter",'error in event listener for "'+t+'":',e)}});var r=this.C.get(t);r&&(r.forEach(i=>{try{i(e)}catch(e){uu().error("emitter",'error in once listener for "'+t+'":',e)}}),this.C.delete(t)),null===(n=this.k.get("*"))||void 0===n||n.forEach(i=>{try{i({event:t,payload:e})}catch(t){uu().error("emitter","error in wildcard listener:",t)}})}off(t){t?(this.k.delete(t),this.C.delete(t)):(this.k.clear(),this.C.clear())}listenerCount(t){var e,i,n,r;return(null!==(i=null===(e=this.k.get(t))||void 0===e?void 0:e.size)&&void 0!==i?i:0)+(null!==(r=null===(n=this.C.get(t))||void 0===n?void 0:n.size)&&void 0!==r?r:0)}hasListeners(t){return this.listenerCount(t)>0}}var gu="sdk:initialized",bu="sdk:config_updated",yu="sdk:remote_config_loaded",wu="consent:updated",ku="event:captured",xu="recording:started",Su="recording:stopped",Cu=0,_u=!1,Iu=!1;function Au(t){(Cu+=1)<2||(_u=!0,Iu||(Iu=!0,uu().warn(t,"vTilt network requests are being cancelled before reaching the server (likely an ad blocker, privacy extension, or DNS-level filter). Further retries and snapshots have been suspended for this page. Route SDK traffic through your own domain to avoid this — see https://www.vtilt.com/docs/browser/reverse-proxy.")))}function Tu(){Cu=0}function Eu(){return _u}var Mu="23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ou(t){for(var e=(2<<31-Math.clz32(57))-1,i=Math.ceil(1.6*e*t/57),n="";n.length<t;)for(var r=crypto.getRandomValues(new Uint8Array(i)),s=0;s<i&&n.length<t;s++){var o=r[s]&e;o<57&&(n+=Mu[o])}return n}var Ru=1048576;function Nu(t,e,i){if(t)if(Array.isArray(t))t.forEach((t,n)=>{e.call(i,t,n)});else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(i,t[n],n)}function Pu(t,e,i,n){var{capture:r=!1,passive:s=!0}=null!=n?n:{};null==t||t.addEventListener(e,i,{capture:r,passive:s})}function Bu(t,e){if(!e)return t;for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}function Du(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];for(var r of i)for(var s of r)t.push(s);return t}function ju(t){var e={};for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=t[i];null!=n&&""!==n&&(e[i]=n)}return e}var Uu=[".sr-only",".visually-hidden",".w-condition-invisible",'[class*="w-condition-invisible"]','[class*="condition-invisible"]','input[type="hidden"]'].join(", ");function Lu(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var r=function(){for(var t=new Set,e=[],i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];for(var s of n)if(s)for(var o of s.split(",")){var a=o.trim();a&&!t.has(a)&&(t.add(a),e.push(a))}return e}(...t?[]:[Uu],...i);return r.length>0?r.join(", "):void 0}var Fu=[Yh.MouseMove,Yh.MouseInteraction,Yh.Scroll,Yh.ViewportResize,Yh.Input,Yh.TouchMove,Yh.MediaInteraction,Yh.Drag];function zu(t){try{return new Blob([JSON.stringify(t)]).size}catch(e){return 2*JSON.stringify(t).length}}function Wu(t,e){if(void 0===e&&(e=6606028.8),t.size>=e&&t.data.length>1){var i=Math.floor(t.data.length/2),n=t.data.slice(0,i),r=t.data.slice(i);return[...Wu({size:zu(n),data:n,sessionId:t.sessionId,windowId:t.windowId}),...Wu({size:zu(r),data:r,sessionId:t.sessionId,windowId:t.windowId})]}return[t]}function $u(t){return t.type===Zh.Custom&&"sessionIdle"===t.data.tag}function Vu(t){return 3===t.type&&Fu.includes(t.data.source)}function Hu(t,e,i,n,r){return t<e||t>i?(uu().warn("replay",n+" must be between "+e+" and "+i+". Using default: "+r),r):t}var qu=Uint8Array,Ju=Uint16Array,Gu=Int32Array,Zu=new qu([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Yu=new qu([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ku=new qu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xu=function(t,e){for(var i=new Ju(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];var r=new Gu(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},Qu=Xu(Zu,2),tc=Qu.b,ec=Qu.r;tc[28]=258,ec[258]=28;for(var ic=Xu(Yu,0).r,nc=new Ju(32768),rc=0;rc<32768;++rc){var sc=(43690&rc)>>1|(21845&rc)<<1;sc=(61680&(sc=(52428&sc)>>2|(13107&sc)<<2))>>4|(3855&sc)<<4,nc[rc]=((65280&sc)>>8|(255&sc)<<8)>>1}var oc=function(t,e,i){for(var n=t.length,r=0,s=new Ju(e);r<n;++r)t[r]&&++s[t[r]-1];var o,a=new Ju(e);for(r=1;r<e;++r)a[r]=a[r-1]+s[r-1]<<1;if(i){o=new Ju(1<<e);var l=15-e;for(r=0;r<n;++r)if(t[r])for(var h=r<<4|t[r],u=e-t[r],c=a[t[r]-1]++<<u,d=c|(1<<u)-1;c<=d;++c)o[nc[c]>>l]=h}else for(o=new Ju(n),r=0;r<n;++r)t[r]&&(o[r]=nc[a[t[r]-1]++]>>15-t[r]);return o},ac=new qu(288);for(rc=0;rc<144;++rc)ac[rc]=8;for(rc=144;rc<256;++rc)ac[rc]=9;for(rc=256;rc<280;++rc)ac[rc]=7;for(rc=280;rc<288;++rc)ac[rc]=8;var lc=new qu(32);for(rc=0;rc<32;++rc)lc[rc]=5;var hc=oc(ac,9,0),uc=oc(lc,5,0),cc=function(t){return(t+7)/8|0},dc=function(t,e,i){return(null==i||i>t.length)&&(i=t.length),new qu(t.subarray(e,i))},vc=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8},fc=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8,t[n+2]|=i>>16},pc=function(t,e){for(var i=[],n=0;n<t.length;++n)t[n]&&i.push({s:n,f:t[n]});var r=i.length,s=i.slice();if(!r)return{t:xc,l:0};if(1==r){var o=new qu(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(t,e){return t.f-e.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],h=0,u=1,c=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[h].f<i[c].f?h++:c++],l=i[h!=u&&i[h].f<i[c].f?h++:c++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var d=s[0].s;for(n=1;n<r;++n)s[n].s>d&&(d=s[n].s);var v=new Ju(d+1),f=mc(i[u-1],v,0);if(f>e){n=0;var p=0,m=f-e,g=1<<m;for(s.sort(function(t,e){return v[e.s]-v[t.s]||t.f-e.f});n<r;++n){var b=s[n].s;if(!(v[b]>e))break;p+=g-(1<<f-v[b]),v[b]=e}for(p>>=m;p>0;){var y=s[n].s;v[y]<e?p-=1<<e-v[y]++-1:++n}for(;n>=0&&p;--n){var w=s[n].s;v[w]==e&&(--v[w],++p)}f=e}return{t:new qu(v),l:f}},mc=function(t,e,i){return-1==t.s?Math.max(mc(t.l,e,i+1),mc(t.r,e,i+1)):e[t.s]=i},gc=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Ju(++e),n=0,r=t[0],s=1,o=function(t){i[n++]=t},a=1;a<=e;++a)if(t[a]==r&&a!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=t[a]}return{c:i.subarray(0,n),n:e}},bc=function(t,e){for(var i=0,n=0;n<e.length;++n)i+=t[n]*e[n];return i},yc=function(t,e,i){var n=i.length,r=cc(e+2);t[r]=255&n,t[r+1]=n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s<n;++s)t[r+s+4]=i[s];return 8*(r+4+n)},wc=function(t,e,i,n,r,s,o,a,l,h,u){vc(e,u++,i),++r[256];for(var c=pc(r,15),d=c.t,v=c.l,f=pc(s,15),p=f.t,m=f.l,g=gc(d),b=g.c,y=g.n,w=gc(p),k=w.c,x=w.n,S=new Ju(19),C=0;C<b.length;++C)++S[31&b[C]];for(C=0;C<k.length;++C)++S[31&k[C]];for(var _=pc(S,7),I=_.t,A=_.l,T=19;T>4&&!I[Ku[T-1]];--T);var E,M,O,R,N=h+5<<3,P=bc(r,ac)+bc(s,lc)+o,B=bc(r,d)+bc(s,p)+o+14+3*T+bc(S,I)+2*S[16]+3*S[17]+7*S[18];if(l>=0&&N<=P&&N<=B)return yc(e,u,t.subarray(l,l+h));if(vc(e,u,1+(B<P)),u+=2,B<P){E=oc(d,v,0),M=d,O=oc(p,m,0),R=p;var D=oc(I,A,0);vc(e,u,y-257),vc(e,u+5,x-1),vc(e,u+10,T-4),u+=14;for(C=0;C<T;++C)vc(e,u+3*C,I[Ku[C]]);u+=3*T;for(var j=[b,k],U=0;U<2;++U){var L=j[U];for(C=0;C<L.length;++C){var F=31&L[C];vc(e,u,D[F]),u+=I[F],F>15&&(vc(e,u,L[C]>>5&127),u+=L[C]>>12)}}}else E=hc,M=ac,O=uc,R=lc;for(C=0;C<a;++C){var z=n[C];if(z>255){fc(e,u,E[(F=z>>18&31)+257]),u+=M[F+257],F>7&&(vc(e,u,z>>23&31),u+=Zu[F]);var W=31&z;fc(e,u,O[W]),u+=R[W],W>3&&(fc(e,u,z>>5&8191),u+=Yu[W])}else fc(e,u,E[z]),u+=M[z]}return fc(e,u,E[256]),u+M[256]},kc=new Gu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xc=new qu(0),Sc=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),Cc=function(t,e,i,n,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),o=new qu(s.length+t.length);o.set(s),o.set(t,s.length),t=o,r.w=s.length}return function(t,e,i,n,r,s){var o=s.z||t.length,a=new qu(n+o+5*(1+Math.ceil(o/7e3))+r),l=a.subarray(n,a.length-r),h=s.l,u=7&(s.r||0);if(e){u&&(l[0]=s.r>>3);for(var c=kc[e-1],d=c>>13,v=8191&c,f=(1<<i)-1,p=s.p||new Ju(32768),m=s.h||new Ju(f+1),g=Math.ceil(i/3),b=2*g,y=function(e){return(t[e]^t[e+1]<<g^t[e+2]<<b)&f},w=new Gu(25e3),k=new Ju(288),x=new Ju(32),S=0,C=0,_=s.i||0,I=0,A=s.w||0,T=0;_+2<o;++_){var E=y(_),M=32767&_,O=m[E];if(p[M]=O,m[E]=M,A<=_){var R=o-_;if((S>7e3||I>24576)&&(R>423||!h)){u=wc(t,l,0,w,k,x,C,I,T,_-T,u),I=S=C=0,T=_;for(var N=0;N<286;++N)k[N]=0;for(N=0;N<30;++N)x[N]=0}var P=2,B=0,D=v,j=M-O&32767;if(R>2&&E==y(_-j))for(var U=Math.min(d,R)-1,L=Math.min(32767,_),F=Math.min(258,R);j<=L&&--D&&M!=O;){if(t[_+P]==t[_+P-j]){for(var z=0;z<F&&t[_+z]==t[_+z-j];++z);if(z>P){if(P=z,B=j,z>U)break;var W=Math.min(j,z-2),V=0;for(N=0;N<W;++N){var H=_-j+N&32767,q=H-p[H]&32767;q>V&&(V=q,O=H)}}}j+=(M=O)-(O=p[M])&32767}if(B){w[I++]=268435456|ec[P]<<18|ic[B];var J=31&ec[P],G=31&ic[B];C+=Zu[J]+Yu[G],++k[257+J],++x[G],A=_+P,++S}else w[I++]=t[_],++k[t[_]]}}for(_=Math.max(_,A);_<o;++_)w[I++]=t[_],++k[t[_]];u=wc(t,l,h,w,k,x,C,I,T,_-T,u),h||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=m,s.p=p,s.i=_,s.w=A)}else{for(_=s.w||0;_<o+h;_+=65535){var Z=_+65535;Z>=o&&(l[u/8|0]=h,Z=o),u=yc(l,u+1,t.subarray(_,Z))}s.i=o}return dc(a,0,n+cc(u)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,i,n,r)},_c=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function Ic(t,e){e||(e={});var i=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n<e.length;++n)i=Sc[255&i^e[n]]^i>>>8;t=i},d:function(){return~t}}}(),n=t.length;i.p(t);var r=Cc(t,e,function(t){return 10+(t.filename?t.filename.length+1:0)}(e),8),s=r.length;return function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&_c(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var n=0;n<=i.length;++n)t[n+10]=i.charCodeAt(n)}}(r,e),_c(r,s-8,i.d()),_c(r,s-4,n),r}var Ac="undefined"!=typeof TextEncoder&&new TextEncoder,Tc="undefined"!=typeof TextDecoder&&new TextDecoder;try{Tc.decode(xc,{stream:!0})}catch(t){}function Ec(t,e){if(Ac)return Ac.encode(t);for(var i=t.length,n=new qu(t.length+(t.length>>1)),r=0,s=function(t){n[r++]=t},o=0;o<i;++o){if(r+5>n.length){var a=new qu(r+8+(i-o<<1));a.set(n),n=a}var l=t.charCodeAt(o);l<128||e?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return dc(n,0,r)}function Mc(t){if("undefined"==typeof btoa)throw new Error("btoa is not available in this environment");for(var e="",i=0;i<t.length;i+=32768){var n=Math.min(i+32768,t.length),r=t.subarray(i,n);e+=String.fromCharCode.apply(null,r)}return btoa(e)}var Oc="replay";function Rc(){var t,e;return null===(e=null===(t=null==Gh?void 0:Gh.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===e?void 0:e.record}function Nc(t,e){var i=t.includes("?")?"&":"?";return""+t+i+"compression="+e}function Pc(t){return{rrwebMethod:t,enqueuedAt:Date.now(),attempt:1}}class Bc{constructor(t,e){void 0===e&&(e={}),this.I="/api/s",this.A=!1,this.T="unknown",this.M=Date.now(),this.O="",this.R="",this.P=[],this.B=()=>{this.D()},this.j=()=>{this.D()},this.L=()=>{this.F("browser offline",{})},this.$=()=>{this.F("browser online",{})},this.V=()=>{if(null==Vh?void 0:Vh.visibilityState){var t="window "+Vh.visibilityState;this.F(t,{}),"hidden"===Vh.visibilityState&&this.D()}},this._instance=t,this.H=e,this.q=this.J()}get isStarted(){return this.A}get started(){return this.A}get sessionId(){return this.O}get status(){return this.A?!0===this.T?"paused":"active":"disabled"}start(t){this.G()?(this.Y(t),zh&&(Pu(zh,"beforeunload",this.B),Pu(zh,"pagehide",this.j),Pu(zh,"offline",this.L),Pu(zh,"online",this.$),Pu(zh,"visibilitychange",this.V))):this.stop()}stop(){this.A&&this.K&&(this.K(),this.K=void 0,this.A=!1,zh&&(zh.removeEventListener("beforeunload",this.B),zh.removeEventListener("pagehide",this.j),zh.removeEventListener("offline",this.L),zh.removeEventListener("online",this.$),zh.removeEventListener("visibilitychange",this.V)),this.D(),this.J(),this.X&&clearInterval(this.X),uu().info(Oc,"stopped"))}stopRecording(){this.stop()}addCustomEvent(t,e){return this.F(t,e)}takeFullSnapshot(){return this.tt()}log(t,e){void 0===e&&(e="log"),this.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:e,trace:[],payload:[JSON.stringify(t)]}},timestamp:Date.now()})}updateConfig(t){this.H=i({},this.H,t)}G(){return!!this.H.enabled&&!!zh}Y(t){var e;if(void 0!==Object.assign&&void 0!==Array.from&&!this.A){this.A=!0;var i=this._instance.getSessionId();this.O=i||this.et(),this.R=(null===(e=this._instance.sessionManager)||void 0===e?void 0:e.getWindowId())||this.et(),Rc()?this.it():this.nt(()=>{this.it()}),uu().info(Oc,"starting"),t&&this.rt(t)}}nt(t){var e,i=null===(e=Gh.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;i?i(this._instance,"recorder",e=>{e?uu().error(Oc,"could not load recorder:",e):t()}):uu().error(Oc,"loadExternalDependency not available; make sure external-scripts-loader is initialized")}it(){var t,e,n=Rc();if(n){var r={blockClass:this.H.blockClass||"vt-no-capture",ignoreClass:this.H.ignoreClass||"vt-ignore-input",maskTextClass:this.H.maskTextClass||"vt-mask",maskTextSelector:this.H.maskTextSelector,maskTextFn:void 0,maskAllInputs:null===(t=this.H.maskAllInputs)||void 0===t||t,maskInputOptions:i({password:!0},this.H.maskInputOptions),maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},s=this.st();s.enabled&&(r.recordCanvas=!0,r.sampling={canvas:s.fps},r.dataURLOptions={type:"image/webp",quality:s.quality});var o=this.ot();o&&(r.maskAllInputs=null===(e=o.maskAllInputs)||void 0===e||e,r.maskTextSelector=o.maskTextSelector),r.blockSelector=Lu(this.H.skipDefaultInvisibleBlocking,this.H.blockSelector,null==o?void 0:o.blockSelector);var a=this.lt();this.K=n(i({emit:t=>{this.onRRwebEmit(t)},plugins:a},r)),this.M=Date.now(),this.T="boolean"==typeof this.T?this.T:"unknown",this.F("$session_options",{sessionRecordingOptions:r,activePlugins:a.map(t=>null==t?void 0:t.name)})}else uu().error(Oc,"onScriptLoaded was called but rrwebRecord is not available")}lt(){var t,e,i=[];if(this.H.captureConsole)try{var n=null===(e=null===(t=Gh.__VTiltExtensions__)||void 0===t?void 0:t.rrwebPlugins)||void 0===e?void 0:e.getRecordConsolePlugin;n&&i.push(n())}catch(t){uu().warn(Oc,"failed to load console plugin",t)}return i}onRRwebEmit(t){if(this.ht(),t&&"object"==typeof t){if(t.type===Zh.Meta){var e=t.data;this.ut=e.href}if(function(t){return t.type===Zh.Custom&&"recording paused"===t.data.tag}(t)||$u(t));else if(!0===this.T&&!Vu(t))return;t.type===Zh.FullSnapshot&&this.ct();var n=function(t){if(t.type!==Zh.Plugin||"rrweb/console@1"!==t.data.plugin)return t;var e=t.data.payload;if(!(null==e?void 0:e.payload))return t;var n=e.payload.map(t=>"string"==typeof t&&t.length>1e3?t.substring(0,1e3)+"... [truncated]":t);return i({},t,{data:i({},t.data,{payload:i({},e,{payload:n})})})}(t);if(this.dt(n),!0!==this.T||$u(n)){var r={$snapshot_bytes:zu(n),$snapshot_data:n,$session_id:this.O,$window_id:this.R};"disabled"!==this.status?this.ft(r):this.J()}}}ht(){if(0!==this.P.length){var t=[...this.P];this.P=[],t.forEach(t=>{Date.now()-t.enqueuedAt<=2e3&&this.gt(t)})}}dt(t){var e,i=Vu(t);if(!i&&!this.T){var n=t.timestamp-this.M,r=this.H.sessionIdleThresholdMs||3e5;n>r&&(this.T=!0,this.X&&clearInterval(this.X),this.F("sessionIdle",{eventTimestamp:t.timestamp,lastActivityTimestamp:this.M,threshold:r,bufferLength:this.q.data.length,bufferSize:this.q.size}),this.bt())}var s=!1;if(i&&(this.M=t.timestamp,this.T)){var o="unknown"===this.T;this.T=!1,o||(this.F("sessionNoLongerIdle",{reason:"user activity",type:t.type}),s=!0)}if(!this.T){var a=this._instance.getSessionId();this.O&&a&&a!==this.O?(this.D(),this.J(),this.O=a,this.R=(null===(e=this._instance.sessionManager)||void 0===e?void 0:e.getWindowId())||this.et(),this.q.sessionId=this.O,this.q.windowId=this.R,this.ct(),this.tt(),this.rt("session_id_changed")):s&&(this.ct(),this.tt())}}J(){return this.q={size:0,data:[],sessionId:this.O,windowId:this.R},this.q}bt(){return this.yt&&(clearTimeout(this.yt),this.yt=void 0),"paused"===this.status||"disabled"===this.status?(this.yt=setTimeout(()=>{this.bt()},2e3),this.q):(this.wt(),this.J())}D(){this.yt&&(clearTimeout(this.yt),this.yt=void 0),this.wt()}wt(){this.q.data.length>0&&Wu(this.q).forEach(t=>{this.kt({$snapshot_bytes:t.size,$snapshot_data:t.data,$session_id:t.sessionId,$window_id:t.windowId})})}ft(t){var e,i=2+((null===(e=this.q)||void 0===e?void 0:e.data.length)||0),n=t.$snapshot_bytes;!this.T&&(this.q.size+n+i>943718.4||this.q.sessionId!==this.O)&&(this.q=this.bt()),this.q.size+=n,this.q.data.push(t.$snapshot_data),this.yt||this.T||(this.yt=setTimeout(()=>{this.bt()},2e3))}kt(t){var e=this._instance.getConfig(),i=e.token||"";if(i){if(!Eu()){var n=!1!==this.H.compressEvents,r={token:i,distinct_id:this._instance.getDistinctId()||this._instance.getAnonymousId()||"",$session_id:this.O,$window_id:this.R,$snapshot_data:t.$snapshot_data,$snapshot_bytes:t.$snapshot_bytes,$lib:"web",$lib_version:this._instance.version||"unknown",timestamp:Date.now()};this.xt(e,i,r,n)}}else uu().warn(Oc,"missing token, cannot send snapshot")}xt(t,e,i,n){var r=JSON.stringify(i),s=i.$snapshot_data,o=Array.isArray(s)&&s.some(t=>2===(null==t?void 0:t.type));if(r.length>61440||o){var a=fu(t,this.I);this.St(a,e,r,n)}else{var l=fu(t,this.I,{includeTokenQuery:!0});this.Ct(l,e,r,n)}}St(t,e,i,n){if(n&&void 0!==zh)try{var r=Ic(Ec(i));if(r.length>0){var s=new Blob([r],{type:"application/octet-stream"});if(s.size>0){var o=Nc(t,"gzip-js");return void this._t(o,e,s,"application/octet-stream")}}}catch(t){uu().warn(Oc,"compression failed, sending uncompressed")}var a=new Blob([i],{type:"application/json"});this._t(t,e,a,"application/json")}Ct(t,e,i,n){if(n&&void 0!==zh)try{var r=Ic(Ec(i));if(r.length>0){var s=Mc(r);if(s.length>0&&s.length<=61440){var o=Nc(t,"base64"),a=new Blob([s],{type:"text/plain"});if("undefined"!=typeof navigator&&navigator.sendBeacon&&navigator.sendBeacon(o,a))return;return void this._t(o,"",a,"text/plain")}}}catch(t){uu().warn(Oc,"compression failed, sending uncompressed")}var l=new Blob([i],{type:"application/json"});"undefined"!=typeof navigator&&navigator.sendBeacon&&navigator.sendBeacon(t,l)||this._t(t,"",l,"application/json")}_t(t,e,i,n,r){void 0===r&&(r=0);var s=i.size<6e4,o={"Content-Type":n};e&&(o[vu]=e),fetch(t,{method:"POST",body:i,headers:o,keepalive:s}).then(s=>{if(!s.ok)return s.status>=400&&s.status<500?(Tu(),void uu().warn(Oc,"snapshot rejected by server ("+s.status+"), not retrying")):void this.It(t,e,i,n,r);Tu()}).catch(()=>{Au(Oc),this.It(t,e,i,n,r)})}It(t,e,i,n,r){if(r>=5)uu().error(Oc,"failed to send snapshot after 5 retries, giving up");else if(!Eu()){var s=3e3*Math.pow(2,r),o=Math.min(s,3e4),a=(Math.random()-.5)*o,l=Math.ceil(o+a);uu().warn(Oc,"snapshot send failed, retrying in "+Math.round(l/1e3)+"s (attempt "+(r+1)+"/5)"),setTimeout(()=>{this._t(t,e,i,n,r+1)},l)}}ct(){if(this.X&&clearInterval(this.X),!0!==this.T){var t=this.H.fullSnapshotIntervalMs||3e5;this.X=setInterval(()=>{this.tt()},t)}}gt(t){try{return t.rrwebMethod(),!0}catch(e){return this.P.length<10?this.P.push({enqueuedAt:t.enqueuedAt||Date.now(),attempt:t.attempt+1,rrwebMethod:t.rrwebMethod}):uu().warn(Oc,"could not emit queued rrweb event",e,t),!1}}F(t,e){return this.gt(Pc(()=>Rc().addCustomEvent(t,e)))}tt(){return this.gt(Pc(()=>Rc().takeFullSnapshot()))}st(){var t,e,i,n=this.H.captureCanvas,r=null!==(t=null==n?void 0:n.recordCanvas)&&void 0!==t&&t,s=null!==(e=null==n?void 0:n.canvasFps)&&void 0!==e?e:4,o=null!==(i=null==n?void 0:n.canvasQuality)&&void 0!==i?i:.4;return{enabled:r,fps:Hu(s,0,12,"canvas recording fps",4),quality:Hu(o,0,1,"canvas recording quality",.4)}}ot(){var t,e=this.H.masking;if(e)return{maskAllInputs:null===(t=e.maskAllInputs)||void 0===t||t,maskTextSelector:e.maskTextSelector,blockSelector:e.blockSelector}}et(){return Math.random().toString(36).substring(2,15)}rt(t,e){uu().info(Oc,t.replace(/_/g," "),e),"recording_initialized"!==t&&"session_id_changed"!==t&&this.F(t,e)}}Gh.__VTiltExtensions__=Gh.__VTiltExtensions__||{},Gh.__VTiltExtensions__.rrweb={record:Ah,version:"v2"},Gh.__VTiltExtensions__.rrwebPlugins={getRecordConsolePlugin:t=>({name:"rrweb/console@1",observer:Fh,options:t})},Gh.__VTiltExtensions__.initSessionRecording=function(t,e){return new Bc(t,e)};var Dc,jc=-1,Uc=function(t){addEventListener("pageshow",function(e){e.persisted&&(jc=e.timeStamp,t(e))},!0)},Lc=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},Fc=function(){var t=Lc();return t&&t.activationStart||0},zc=function(t,e){var i=Lc(),n="navigate";return jc>=0?n="back-forward-cache":i&&(document.prerendering||Fc()>0?n="prerender":document.wasDiscarded?n="restore":i.type&&(n=i.type.replace(/_/g,"-"))),{name:t,value:void 0===e?-1:e,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},Wc=function(t,e,i){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var n=new PerformanceObserver(function(t){Promise.resolve().then(function(){e(t.getEntries())})});return n.observe(Object.assign({type:t,buffered:!0},i||{})),n}}catch(t){}},$c=function(t,e,i,n){var r,s;return function(o){e.value>=0&&(o||n)&&((s=e.value-(r||0))||void 0===r)&&(r=e.value,e.delta=s,e.rating=function(t,e){return t>e[1]?"poor":t>e[0]?"needs-improvement":"good"}(e.value,i),t(e))}},Vc=function(t){requestAnimationFrame(function(){return requestAnimationFrame(function(){return t()})})},Hc=function(t){var e=function(e){"pagehide"!==e.type&&"hidden"!==document.visibilityState||t(e)};addEventListener("visibilitychange",e,!0),addEventListener("pagehide",e,!0)},qc=function(t){var e=!1;return function(i){e||(t(i),e=!0)}},Jc=-1,Gc=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Zc=function(t){"hidden"===document.visibilityState&&Jc>-1&&(Jc="visibilitychange"===t.type?t.timeStamp:0,Kc())},Yc=function(){addEventListener("visibilitychange",Zc,!0),addEventListener("prerenderingchange",Zc,!0)},Kc=function(){removeEventListener("visibilitychange",Zc,!0),removeEventListener("prerenderingchange",Zc,!0)},Xc=function(){return Jc<0&&(Jc=Gc(),Yc(),Uc(function(){setTimeout(function(){Jc=Gc(),Yc()},0)})),{get firstHiddenTime(){return Jc}}},Qc=function(t){document.prerendering?addEventListener("prerenderingchange",function(){return t()},!0):t()},td=[1800,3e3],ed=function(t,e){e=e||{},Qc(function(){var i,n=Xc(),r=zc("FCP"),s=Wc("paint",function(t){t.forEach(function(t){"first-contentful-paint"===t.name&&(s.disconnect(),t.startTime<n.firstHiddenTime&&(r.value=Math.max(t.startTime-Fc(),0),r.entries.push(t),i(!0)))})});s&&(i=$c(t,r,td,e.reportAllChanges),Uc(function(n){r=zc("FCP"),i=$c(t,r,td,e.reportAllChanges),Vc(function(){r.value=performance.now()-n.timeStamp,i(!0)})}))})},id=[.1,.25],nd=0,rd=1/0,sd=0,od=function(t){t.forEach(function(t){t.interactionId&&(rd=Math.min(rd,t.interactionId),sd=Math.max(sd,t.interactionId),nd=sd?(sd-rd)/7+1:0)})},ad=function(){return Dc?nd:performance.interactionCount||0},ld=[200,500],hd=0,ud=function(){return ad()-hd},cd=[],dd={},vd=function(t){var e=cd[cd.length-1],i=dd[t.interactionId];if(i||cd.length<10||t.duration>e.latency){if(i)i.entries.push(t),i.latency=Math.max(i.latency,t.duration);else{var n={id:t.interactionId,latency:t.duration,entries:[t]};dd[n.id]=n,cd.push(n)}cd.sort(function(t,e){return e.latency-t.latency}),cd.splice(10).forEach(function(t){delete dd[t.id]})}},fd=[2500,4e3],pd={},md=[800,1800],gd=function t(e){document.prerendering?Qc(function(){return t(e)}):"complete"!==document.readyState?addEventListener("load",function(){return t(e)},!0):setTimeout(e,0)},bd={onLCP:function(t,e){e=e||{},Qc(function(){var i,n=Xc(),r=zc("LCP"),s=function(t){var e=t[t.length-1];e&&e.startTime<n.firstHiddenTime&&(r.value=Math.max(e.startTime-Fc(),0),r.entries=[e],i())},o=Wc("largest-contentful-paint",s);if(o){i=$c(t,r,fd,e.reportAllChanges);var a=qc(function(){pd[r.id]||(s(o.takeRecords()),o.disconnect(),pd[r.id]=!0,i(!0))});["keydown","click"].forEach(function(t){addEventListener(t,function(){return setTimeout(a,0)},!0)}),Hc(a),Uc(function(n){r=zc("LCP"),i=$c(t,r,fd,e.reportAllChanges),Vc(function(){r.value=performance.now()-n.timeStamp,pd[r.id]=!0,i(!0)})})}})},onCLS:function(t,e){e=e||{},ed(qc(function(){var i,n=zc("CLS",0),r=0,s=[],o=function(t){t.forEach(function(t){if(!t.hadRecentInput){var e=s[0],i=s[s.length-1];r&&t.startTime-i.startTime<1e3&&t.startTime-e.startTime<5e3?(r+=t.value,s.push(t)):(r=t.value,s=[t])}}),r>n.value&&(n.value=r,n.entries=s,i())},a=Wc("layout-shift",o);a&&(i=$c(t,n,id,e.reportAllChanges),Hc(function(){o(a.takeRecords()),i(!0)}),Uc(function(){r=0,n=zc("CLS",0),i=$c(t,n,id,e.reportAllChanges),Vc(function(){return i()})}),setTimeout(i,0))}))},onFCP:ed,onINP:function(t,e){e=e||{},Qc(function(){var i;"interactionCount"in performance||Dc||(Dc=Wc("event",od,{type:"event",buffered:!0,durationThreshold:0}));var n,r=zc("INP"),s=function(t){t.forEach(function(t){t.interactionId&&vd(t),"first-input"===t.entryType&&!cd.some(function(e){return e.entries.some(function(e){return t.duration===e.duration&&t.startTime===e.startTime})})&&vd(t)});var e,i=(e=Math.min(cd.length-1,Math.floor(ud()/50)),cd[e]);i&&i.latency!==r.value&&(r.value=i.latency,r.entries=i.entries,n())},o=Wc("event",s,{durationThreshold:null!==(i=e.durationThreshold)&&void 0!==i?i:40});n=$c(t,r,ld,e.reportAllChanges),o&&("PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&o.observe({type:"first-input",buffered:!0}),Hc(function(){s(o.takeRecords()),r.value<0&&ud()>0&&(r.value=0,r.entries=[]),n(!0)}),Uc(function(){cd=[],hd=ad(),r=zc("INP"),n=$c(t,r,ld,e.reportAllChanges)}))})},onTTFB:function(t,e){e=e||{};var i=zc("TTFB"),n=$c(t,i,md,e.reportAllChanges);gd(function(){var r=Lc();if(r){var s=r.responseStart;if(s<=0||s>performance.now())return;i.value=Math.max(s-Fc(),0),i.entries=[r],n(!0),Uc(function(){i=zc("TTFB",0),(n=$c(t,i,md,e.reportAllChanges))(!0)})}})}};Gh.__VTiltExtensions__=Gh.__VTiltExtensions__||{},Gh.__VTiltExtensions__.webVitalsCallbacks=bd;var yd="/api/chat/widget/channels",wd=t=>"/api/chat/widget/channels/"+t+"/messages",kd=t=>"/api/chat/widget/channels/"+t+"/read",xd="/api/chat/token/widget";function Sd(t,e,i){return Cd.apply(this,arguments)}function Cd(){return(Cd=e(function*(t,e,n){void 0===n&&(n={});var r=t.getConfig(),s=fu(r,e);try{var o=yield fetch(s,i({},n,{headers:i({"Content-Type":"application/json"},pu(r),n.headers)}));if(!o.ok)throw new Error("API error: "+o.status);return yield o.json()}catch(t){return uu().error("chat","API request failed:",t),null}})).apply(this,arguments)}var _d="rich_format",Id="markdown",Ad=/^[a-zA-Z0-9_-]{1,64}$/;function Td(t){return"user"===t.sender_type?function(t){var e;return"html"===t.content_type||(null===(e=t.metadata)||void 0===e?void 0:e[_d])===Id}(t):"ai"===t.sender_type||"agent"===t.sender_type}function Ed(t,e){var i,n=function(t){return"string"==typeof t?{raw:t,format:"text"}:"markdown"in t?{raw:t.markdown,format:"markdown"}:"html"in t?{raw:t.html,format:"html"}:"text"in t?{raw:t.text,format:"text"}:null}(t);if(!n)return null;var r="string"==typeof t?null!==(i=null==e?void 0:e.format)&&void 0!==i?i:"text":n.format,s=n.raw.trim();if(!s)return null;var o={};if(null==e?void 0:e.source){var a=function(t){var e=t.trim();if(Ad.test(e))return e}(e.source);a&&(o.message_source=a)}return"html"===r?{content:s,content_type:"html",metadata:o}:"markdown"===r?(o[_d]=Id,{content:s,content_type:"text",metadata:o}):{content:s,content_type:"text",metadata:o}}var Md="$channel_message";class Od{constructor(){this.At=new Map}register(t){this.At.has(t.type)||this.At.set(t.type,t)}get(t){return this.At.get(t)}getAll(){return Array.from(this.At.values())}getToolDefinitions(){var t={};for(var e of this.At.values())t[e.type]={description:e.toolDescription,parameters:e.parameters};return t}}var Rd,Nd,Pd,Bd,Dd,jd,Ud,Ld,Fd,zd,Wd,$d,Vd,Hd,qd,Jd={},Gd=[],Zd=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Yd=Array.isArray;function Kd(t,e){for(var i in e)t[i]=e[i];return t}function Xd(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Qd(t,e,i){var n,r,s,o={};for(s in e)"key"==s?n=e[s]:"ref"==s?r=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?Rd.call(arguments,2):i),"function"==typeof t&&null!=t.defaultProps)for(s in t.defaultProps)void 0===o[s]&&(o[s]=t.defaultProps[s]);return tv(t,o,n,r,null)}function tv(t,e,i,n,r){var s={type:t,props:e,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==r?++Pd:r,__i:-1,__u:0};return null==r&&null!=Nd.vnode&&Nd.vnode(s),s}function ev(t){return t.children}function iv(t,e){this.props=t,this.context=e}function $(t,e){if(null==e)return t.__?$(t.__,t.__i+1):null;for(var i;e<t.__k.length;e++)if(null!=(i=t.__k[e])&&null!=i.__e)return i.__e;return"function"==typeof t.type?$(t):null}function nv(t){if(t.__P&&t.__d){var e=t.__v,i=e.__e,n=[],r=[],s=Kd({},e);s.__v=e.__v+1,Nd.vnode&&Nd.vnode(s),fv(t.__P,s,e,t.__n,t.__P.namespaceURI,32&e.__u?[i]:null,n,null==i?$(e):i,!!(32&e.__u),r),s.__v=e.__v,s.__.__k[s.__i]=s,mv(n,s,r),e.__e=e.__=null,s.__e!=i&&rv(s)}}function rv(t){if(null!=(t=t.__)&&null!=t.__c)return t.__e=t.__c.base=null,t.__k.some(function(e){if(null!=e&&null!=e.__e)return t.__e=t.__c.base=e.__e}),rv(t)}function sv(t){(!t.__d&&(t.__d=!0)&&Dd.push(t)&&!ov.__r++||jd!=Nd.debounceRendering)&&((jd=Nd.debounceRendering)||Ud)(ov)}function ov(){try{for(var t,e=1;Dd.length;)Dd.length>e&&Dd.sort(Ld),t=Dd.shift(),e=Dd.length,nv(t)}finally{Dd.length=ov.__r=0}}function av(t,e,i,n,r,s,o,a,l,h,u){var c,d,v,f,p,m,g,b=n&&n.__k||Gd,y=e.length;for(l=function(t,e,i,n,r){var s,o,a,l,h,u=i.length,c=u,d=0;for(t.__k=new Array(r),s=0;s<r;s++)null!=(o=e[s])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=t.__k[s]=tv(null,o,null,null,null):Yd(o)?o=t.__k[s]=tv(ev,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=t.__k[s]=tv(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):t.__k[s]=o,l=s+d,o.__=t,o.__b=t.__b+1,a=null,-1!=(h=o.__i=uv(o,i,l,c))&&(c--,(a=i[h])&&(a.__u|=2)),null==a||null==a.__v?(-1==h&&(r>u?d--:r<u&&d++),"function"!=typeof o.type&&(o.__u|=4)):h!=l&&(h==l-1?d--:h==l+1?d++:(h>l?d--:d++,o.__u|=4))):t.__k[s]=null;if(c)for(s=0;s<u;s++)null!=(a=i[s])&&!(2&a.__u)&&(a.__e==n&&(n=$(a)),wv(a,a));return n}(i,e,b,l,y),c=0;c<y;c++)null!=(v=i.__k[c])&&(d=-1!=v.__i&&b[v.__i]||Jd,v.__i=c,m=fv(t,v,d,r,s,o,a,l,h,u),f=v.__e,v.ref&&d.ref!=v.ref&&(d.ref&&yv(d.ref,null,v),u.push(v.ref,v.__c||f,v)),null==p&&null!=f&&(p=f),(g=!!(4&v.__u))||d.__k===v.__k?(l=lv(v,l,t,g),g&&d.__e&&(d.__e=null)):"function"==typeof v.type&&void 0!==m?l=m:f&&(l=f.nextSibling),v.__u&=-7);return i.__e=p,l}function lv(t,e,i,n){var r,s;if("function"==typeof t.type){for(r=t.__k,s=0;r&&s<r.length;s++)r[s]&&(r[s].__=t,e=lv(r[s],e,i,n));return e}t.__e!=e&&(n&&(e&&t.type&&!e.parentNode&&(e=$(t)),i.insertBefore(t.__e,e||null)),e=t.__e);do{e=e&&e.nextSibling}while(null!=e&&8==e.nodeType);return e}function hv(t,e){return e=e||[],null==t||"boolean"==typeof t||(Yd(t)?t.some(function(t){hv(t,e)}):e.push(t)),e}function uv(t,e,i,n){var r,s,o,a=t.key,l=t.type,h=e[i],u=null!=h&&!(2&h.__u);if(null===h&&null==a||u&&a==h.key&&l==h.type)return i;if(n>(u?1:0))for(r=i-1,s=i+1;r>=0||s<e.length;)if(null!=(h=e[o=r>=0?r--:s++])&&!(2&h.__u)&&a==h.key&&l==h.type)return o;return-1}function cv(t,e,i){"-"==e[0]?t.setProperty(e,null==i?"":i):t[e]=null==i?"":"number"!=typeof i||Zd.test(e)?i:i+"px"}function dv(t,e,i,n,r){var s,o;t:if("style"==e)if("string"==typeof i)t.style.cssText=i;else{if("string"==typeof n&&(t.style.cssText=n=""),n)for(e in n)i&&e in i||cv(t.style,e,"");if(i)for(e in i)n&&i[e]==n[e]||cv(t.style,e,i[e])}else if("o"==e[0]&&"n"==e[1])s=e!=(e=e.replace($d,"$1")),o=e.toLowerCase(),e=o in t||"onFocusOut"==e||"onFocusIn"==e?o.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=i,i?n?i[Wd]=n[Wd]:(i[Wd]=Vd,t.addEventListener(e,s?qd:Hd,s)):t.removeEventListener(e,s?qd:Hd,s);else{if("http://www.w3.org/2000/svg"==r)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=e&&"height"!=e&&"href"!=e&&"list"!=e&&"form"!=e&&"tabIndex"!=e&&"download"!=e&&"rowSpan"!=e&&"colSpan"!=e&&"role"!=e&&"popover"!=e&&e in t)try{t[e]=null==i?"":i;break t}catch(t){}"function"==typeof i||(null==i||!1===i&&"-"!=e[4]?t.removeAttribute(e):t.setAttribute(e,"popover"==e&&1==i?"":i))}}function vv(t){return function(e){if(this.l){var i=this.l[e.type+t];if(null==e[zd])e[zd]=Vd++;else if(e[zd]<i[Wd])return;return i(Nd.event?Nd.event(e):e)}}}function fv(t,e,i,n,r,s,o,a,l,h){var u,c,d,v,f,p,m,g,b,y,$,w,k,x,S,C=e.type;if(void 0!==e.constructor)return null;128&i.__u&&(l=!!(32&i.__u),s=[a=e.__e=i.__e]),(u=Nd.__b)&&u(e);t:if("function"==typeof C)try{if(g=e.props,b=C.prototype&&C.prototype.render,y=(u=C.contextType)&&n[u.__c],$=u?y?y.props.value:u.__:n,i.__c?m=(c=e.__c=i.__c).__=c.__E:(b?e.__c=c=new C(g,$):(e.__c=c=new iv(g,$),c.constructor=C,c.render=kv),y&&y.sub(c),c.state||(c.state={}),c.__n=n,d=c.__d=!0,c.__h=[],c._sb=[]),b&&null==c.__s&&(c.__s=c.state),b&&null!=C.getDerivedStateFromProps&&(c.__s==c.state&&(c.__s=Kd({},c.__s)),Kd(c.__s,C.getDerivedStateFromProps(g,c.__s))),v=c.props,f=c.state,c.__v=e,d)b&&null==C.getDerivedStateFromProps&&null!=c.componentWillMount&&c.componentWillMount(),b&&null!=c.componentDidMount&&c.__h.push(c.componentDidMount);else{if(b&&null==C.getDerivedStateFromProps&&g!==v&&null!=c.componentWillReceiveProps&&c.componentWillReceiveProps(g,$),e.__v==i.__v||!c.__e&&null!=c.shouldComponentUpdate&&!1===c.shouldComponentUpdate(g,c.__s,$)){e.__v!=i.__v&&(c.props=g,c.state=c.__s,c.__d=!1),e.__e=i.__e,e.__k=i.__k,e.__k.some(function(t){t&&(t.__=e)}),Gd.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break t}null!=c.componentWillUpdate&&c.componentWillUpdate(g,c.__s,$),b&&null!=c.componentDidUpdate&&c.__h.push(function(){c.componentDidUpdate(v,f,p)})}if(c.context=$,c.props=g,c.__P=t,c.__e=!1,w=Nd.__r,k=0,b)c.state=c.__s,c.__d=!1,w&&w(e),u=c.render(c.props,c.state,c.context),Gd.push.apply(c.__h,c._sb),c._sb=[];else do{c.__d=!1,w&&w(e),u=c.render(c.props,c.state,c.context),c.state=c.__s}while(c.__d&&++k<25);c.state=c.__s,null!=c.getChildContext&&(n=Kd(Kd({},n),c.getChildContext())),b&&!d&&null!=c.getSnapshotBeforeUpdate&&(p=c.getSnapshotBeforeUpdate(v,f)),x=null!=u&&u.type===ev&&null==u.key?gv(u.props.children):u,a=av(t,Yd(x)?x:[x],e,i,n,r,s,o,a,l,h),c.base=e.__e,e.__u&=-161,c.__h.length&&o.push(c),m&&(c.__E=c.__=null)}catch(t){if(e.__v=null,l||null!=s)if(t.then){for(e.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,e.__e=a}else{for(S=s.length;S--;)Xd(s[S]);pv(e)}else e.__e=i.__e,e.__k=i.__k,t.then||pv(e);Nd.__e(t,e,i)}else null==s&&e.__v==i.__v?(e.__k=i.__k,e.__e=i.__e):a=e.__e=bv(i.__e,e,i,n,r,s,o,l,h);return(u=Nd.diffed)&&u(e),128&e.__u?void 0:a}function pv(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(pv))}function mv(t,e,i){for(var n=0;n<i.length;n++)yv(i[n],i[++n],i[++n]);Nd.__c&&Nd.__c(e,t),t.some(function(e){try{t=e.__h,e.__h=[],t.some(function(t){t.call(e)})}catch(t){Nd.__e(t,e.__v)}})}function gv(t){return"object"!=typeof t||null==t||t.__b>0?t:Yd(t)?t.map(gv):void 0!==t.constructor?null:Kd({},t)}function bv(t,e,i,n,r,s,o,a,l){var h,u,c,d,v,f,p,m=i.props||Jd,g=e.props,b=e.type;if("svg"==b?r="http://www.w3.org/2000/svg":"math"==b?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),null!=s)for(h=0;h<s.length;h++)if((v=s[h])&&"setAttribute"in v==!!b&&(b?v.localName==b:3==v.nodeType)){t=v,s[h]=null;break}if(null==t){if(null==b)return document.createTextNode(g);t=document.createElementNS(r,b,g.is&&g),a&&(Nd.__m&&Nd.__m(e,s),a=!1),s=null}if(null==b)m===g||a&&t.data==g||(t.data=g);else{if(s="textarea"==b&&null!=g.defaultValue?null:s&&Rd.call(t.childNodes),!a&&null!=s)for(m={},h=0;h<t.attributes.length;h++)m[(v=t.attributes[h]).name]=v.value;for(h in m)v=m[h],"dangerouslySetInnerHTML"==h?c=v:"children"==h||h in g||"value"==h&&"defaultValue"in g||"checked"==h&&"defaultChecked"in g||dv(t,h,null,v,r);for(h in g)v=g[h],"children"==h?d=v:"dangerouslySetInnerHTML"==h?u=v:"value"==h?f=v:"checked"==h?p=v:a&&"function"!=typeof v||m[h]===v||dv(t,h,v,m[h],r);if(u)a||c&&(u.__html==c.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),e.__k=[];else if(c&&(t.innerHTML=""),av("template"==e.type?t.content:t,Yd(d)?d:[d],e,i,n,"foreignObject"==b?"http://www.w3.org/1999/xhtml":r,s,o,s?s[0]:i.__k&&$(i,0),a,l),null!=s)for(h=s.length;h--;)Xd(s[h]);a&&"textarea"!=b||(h="value","progress"==b&&null==f?t.removeAttribute("value"):null!=f&&(f!==t[h]||"progress"==b&&!f||"option"==b&&f!=m[h])&&dv(t,h,f,m[h],r),h="checked",null!=p&&p!=t[h]&&dv(t,h,p,m[h],r))}return t}function yv(t,e,i){try{if("function"==typeof t){var n="function"==typeof t.__u;n&&t.__u(),n&&null==e||(t.__u=t(e))}else t.current=e}catch(t){Nd.__e(t,i)}}function wv(t,e,i){var n,r;if(Nd.unmount&&Nd.unmount(t),(n=t.ref)&&(n.current&&n.current!=t.__e||yv(n,null,e)),null!=(n=t.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(t){Nd.__e(t,e)}n.base=n.__P=null}if(n=t.__k)for(r=0;r<n.length;r++)n[r]&&wv(n[r],e,i||"function"!=typeof t.type);i||Xd(t.__e),t.__c=t.__=t.__e=void 0}function kv(t,e,i){return this.constructor(t,i)}function xv(t,e,i){var n,r,s;e==document&&(e=document.documentElement),Nd.__&&Nd.__(t,e),n=!1?null:e.__k,r=[],s=[],fv(e,t=e.__k=Qd(ev,null,[t]),n||Jd,Jd,e.namespaceURI,n?null:e.firstChild?Rd.call(e.childNodes):null,r,n?n.__e:e.firstChild,false,s),mv(r,t,s)}Rd=Gd.slice,Nd={__e:function(t,e,i,n){for(var r,s,o;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&null!=s.getDerivedStateFromError&&(r.setState(s.getDerivedStateFromError(t)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(t,n||{}),o=r.__d),o)return r.__E=r}catch(e){t=e}throw t}},Pd=0,Bd=function(t){return null!=t&&void 0===t.constructor},iv.prototype.setState=function(t,e){var i;i=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=Kd({},this.state),"function"==typeof t&&(t=t(Kd({},i),this.props)),t&&Kd(i,t),null!=t&&this.__v&&(e&&this._sb.push(e),sv(this))},iv.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),sv(this))},iv.prototype.render=ev,Dd=[],Ud="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ld=function(t,e){return t.__v.__b-e.__v.__b},ov.__r=0,Fd=Math.random().toString(8),zd="__d"+Fd,Wd="__a"+Fd,$d=/(PointerCapture)$|Capture$/i,Vd=0,Hd=vv(!1),qd=vv(!0);var Sv=0;function Cv(t,e,i,n,r,s){e||(e={});var o,a,l=e;if("ref"in l)for(a in l={},e)"ref"==a?o=e[a]:l[a]=e[a];var h={type:t,props:l,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Sv,__i:-1,__u:0,__source:r,__self:s};if("function"==typeof t&&(o=t.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return Nd.vnode&&Nd.vnode(h),h}var _v,Iv,Av,Tv,Ev=0,Mv=[],Ov=Nd,Rv=Ov.__b,Nv=Ov.__r,Pv=Ov.diffed,Bv=Ov.__c,Dv=Ov.unmount,jv=Ov.__;function Uv(t,e){Ov.__h&&Ov.__h(Iv,t,Ev||e),Ev=0;var i=Iv.__H||(Iv.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function Lv(t){return Ev=1,function(t,e,i){var n=Uv(_v++,2);if(n.t=t,!n.__c&&(n.__=[i?i(e):Yv(void 0,e),function(t){var e=n.__N?n.__N[0]:n.__[0],i=n.t(e,t);e!==i&&(n.__N=[i,n.__[1]],n.__c.setState({}))}],n.__c=Iv,!Iv.__f)){var r=function(t,e,i){if(!n.__c.__H)return!0;var r=n.__c.__H.__.filter(function(t){return t.__c});if(r.every(function(t){return!t.__N}))return!s||s.call(this,t,e,i);var o=n.__c.props!==t;return r.some(function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(o=!0)}}),s&&s.call(this,t,e,i)||o};Iv.__f=!0;var s=Iv.shouldComponentUpdate,o=Iv.componentWillUpdate;Iv.componentWillUpdate=function(t,e,i){if(this.__e){var n=s;s=void 0,r(t,e,i),s=n}o&&o.call(this,t,e,i)},Iv.shouldComponentUpdate=r}return n.__N||n.__}(Yv,t)}function Fv(t,e){var i=Uv(_v++,3);!Ov.__s&&Zv(i.__H,e)&&(i.__=t,i.u=e,Iv.__H.__h.push(i))}function zv(t){return Ev=5,Wv(function(){return{current:t}},[])}function Wv(t,e){var i=Uv(_v++,7);return Zv(i.__H,e)&&(i.__=t(),i.__H=e,i.__h=t),i.__}function $v(t,e){return Ev=8,Wv(function(){return t},e)}function Vv(){for(var t;t=Mv.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(Jv),e.__h.some(Gv),e.__h=[]}catch(i){e.__h=[],Ov.__e(i,t.__v)}}}Ov.__b=function(t){Iv=null,Rv&&Rv(t)},Ov.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),jv&&jv(t,e)},Ov.__r=function(t){Nv&&Nv(t),_v=0;var e=(Iv=t.__c).__H;e&&(Av===Iv?(e.__h=[],Iv.__h=[],e.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(e.__h.some(Jv),e.__h.some(Gv),e.__h=[],_v=0)),Av=Iv},Ov.diffed=function(t){Pv&&Pv(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==Mv.push(e)&&Tv===Ov.requestAnimationFrame||((Tv=Ov.requestAnimationFrame)||qv)(Vv)),e.__H.__.some(function(t){t.u&&(t.__H=t.u),t.u=void 0})),Av=Iv=null},Ov.__c=function(t,e){e.some(function(t){try{t.__h.some(Jv),t.__h=t.__h.filter(function(t){return!t.__||Gv(t)})}catch(i){e.some(function(t){t.__h&&(t.__h=[])}),e=[],Ov.__e(i,t.__v)}}),Bv&&Bv(t,e)},Ov.unmount=function(t){Dv&&Dv(t);var e,i=t.__c;i&&i.__H&&(i.__H.__.some(function(t){try{Jv(t)}catch(t){e=t}}),i.__H=void 0,e&&Ov.__e(e,i.__v))};var Hv="function"==typeof requestAnimationFrame;function qv(t){var e,i=function(){clearTimeout(n),Hv&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(i,35);Hv&&(e=requestAnimationFrame(i))}function Jv(t){var e=Iv,i=t.__c;"function"==typeof i&&(t.__c=void 0,i()),Iv=e}function Gv(t){var e=Iv;t.__c=t.__(),Iv=e}function Zv(t,e){return!t||t.length!==e.length||e.some(function(e,i){return e!==t[i]})}function Yv(t,e){return"function"==typeof e?e(t):e}var Kv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Xv(t){var{prompt:i,ctx:n}=t,[r,s]=Lv(""),[o,a]=Lv(""),[l,h]=Lv(!1),u=Kv.test(o.trim())&&!l,c=function(){var t=e(function*(){if(u){h(!0);try{yield n.dispatch("submit",{email:o.trim(),name:r.trim()})}finally{h(!1)}}});return function(){return t.apply(this,arguments)}}();return Cv("div",{class:"vt-widget",children:[Cv("p",{children:i}),Cv("div",{style:"display: flex; flex-direction: column; gap: 8px;",children:[Cv("input",{type:"text",class:"vt-widget-input",placeholder:"Your name",value:r,onInput:t=>s(t.currentTarget.value),disabled:l}),Cv("div",{style:"display: flex; gap: 8px; align-items: center;",children:[Cv("input",{type:"email",class:"vt-widget-input",style:"flex: 1; min-width: 0; margin: 0;",placeholder:"your@email.com",value:o,onInput:t=>a(t.currentTarget.value),onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),c())},disabled:l}),Cv("button",{type:"button",class:"vt-widget-btn","data-style":"outline",onClick:()=>{c()},disabled:!u,children:"Submit"})]})]})]})}var Qv={type:"collect_email",toolDescription:"ALWAYS use this tool instead of asking for email in plain text. Renders an interactive form to collect the user's name and email. Use whenever the user wants follow-up, a demo, a meeting, pricing info, or shows buying intent. NEVER ask for name or email via plain text.",parameters:{prompt:{type:"string",description:"Message to show above the input fields"}},render:(t,e)=>Cv(Xv,{prompt:"string"==typeof t.prompt?t.prompt:"What's your name and email?",ctx:e}),onAction:(t,i,n)=>e(function*(){if("submit"!==t)return{};var e="string"==typeof i.email?i.email.trim():"";if(!e||!Kv.test(e))return{};var r=n.buildEndpointUrl("/api/chat/widget/channels/"+n.channelId+"/actions"),s=n.token?{"x-api-key":n.token,"Content-Type":"application/json"}:{"Content-Type":"application/json"};try{var o=yield fetch(r,{method:"POST",headers:s,body:JSON.stringify({widget_type:"collect_email",action:"submit",data:{email:e,name:"string"==typeof i.name?i.name.trim():""},channel_id:n.channelId,distinct_id:n.distinctId,message_id:n.messageId})});return{success:!!(yield o.json()).success}}catch(t){return{}}})()},tf={fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function ef(t){return Cv("svg",i({width:24,height:24,viewBox:"0 0 24 24"},tf,t,{children:Cv("path",{d:"M18 6L6 18M6 6l12 12"})}))}function nf(t){return Cv("svg",i({width:24,height:24,viewBox:"0 0 24 24"},tf,t,{children:Cv("path",{d:"M15 18l-6-6 6-6"})}))}function rf(t){return Cv("svg",i({width:16,height:16,viewBox:"0 0 24 24",fill:"currentColor"},t,{children:Cv("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})}))}function sf(t){return Cv("svg",i({width:28,height:28,viewBox:"0 0 28 28",fill:"white"},t,{children:Cv("path",{d:"M14 3C7.925 3 3 7.262 3 12.5c0 2.56 1.166 4.884 3.063 6.606L4.5 24l5.25-2.625C11.1 21.79 12.52 22 14 22c6.075 0 11-4.262 11-9.5S20.075 3 14 3z"})}))}function of(t){return Cv("svg",i({width:22,height:22,viewBox:"0 0 24 24",fill:"currentColor"},t,{children:Cv("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2M7.5 13A1.5 1.5 0 0 0 6 14.5A1.5 1.5 0 0 0 7.5 16A1.5 1.5 0 0 0 9 14.5A1.5 1.5 0 0 0 7.5 13m9 0a1.5 1.5 0 0 0-1.5 1.5a1.5 1.5 0 0 0 1.5 1.5a1.5 1.5 0 0 0 1.5-1.5a1.5 1.5 0 0 0-1.5-1.5"})}))}function af(t){return Cv("svg",i({width:22,height:22,viewBox:"0 0 24 24",fill:"currentColor"},t,{children:Cv("path",{d:"M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4"})}))}function lf(t){return Cv("svg",i({width:36,height:36,viewBox:"0 0 24 24",fill:"white"},t,{children:Cv("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})}))}function hf(t){return Cv("svg",i({width:16,height:16,viewBox:"0 0 24 24"},tf,t,{children:[Cv("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),Cv("circle",{cx:"12",cy:"7",r:"4"})]}))}function uf(t){var{prompt:i,ctx:n}=t,[r,s]=Lv(!1),o=function(){var t=e(function*(){if(!r){s(!0);try{yield n.dispatch("escalate",{})}finally{s(!1)}}});return function(){return t.apply(this,arguments)}}();return Cv("div",{class:"vt-widget",children:[Cv("p",{children:i}),Cv("button",{type:"button",class:"vt-widget-btn","data-style":"outline",onClick:()=>{o()},disabled:r,children:[Cv(hf,{}),"Connect with a person"]})]})}var cf={type:"escalate_to_human",toolDescription:"Offer to connect the user with a human agent. Use when the user explicitly asks to speak with a person, when you cannot adequately help them, or when the conversation requires human judgment (billing, complaints, complex issues).",parameters:{prompt:{type:"string",description:"Message to show above the connect button"}},render:(t,e)=>Cv(uf,{prompt:"string"==typeof t.prompt?t.prompt:"Would you like me to connect you with a team member?",ctx:e}),onAction:(t,i,n)=>e(function*(){if("escalate"!==t)return{};var e=n.buildEndpointUrl("/api/chat/widget/channels/"+n.channelId+"/actions"),i=n.token?{"x-api-key":n.token,"Content-Type":"application/json"}:{"Content-Type":"application/json"};try{var r=yield fetch(e,{method:"POST",headers:i,body:JSON.stringify({widget_type:"escalate_to_human",action:"escalate",data:{},channel_id:n.channelId,distinct_id:n.distinctId,message_id:n.messageId})});return{success:!!(yield r.json()).success}}catch(t){return{}}})()},df=Symbol.for("preact-signals");function vf(){if(bf>1)bf--;else{var t,e=!1;for(!function(){var t=wf;for(wf=void 0;void 0!==t;)t.S.v===t.v&&(t.S.i=t.i),t=t.o}();void 0!==gf;){var i=gf;for(gf=void 0,yf++;void 0!==i;){var n=i.u;if(i.u=void 0,i.f&=-3,!(8&i.f)&&_f(i))try{i.c()}catch(i){e||(t=i,e=!0)}i=n}}if(yf=0,bf--,e)throw t}}var ff=void 0;function pf(t){var e=ff;ff=void 0;try{return t()}finally{ff=e}}var mf,gf=void 0,bf=0,yf=0,wf=void 0,kf=0;function xf(t){if(void 0!==ff){var e=t.n;if(void 0===e||e.t!==ff)return e={i:0,S:t,p:ff.s,n:void 0,t:ff,e:void 0,x:void 0,r:e},void 0!==ff.s&&(ff.s.n=e),ff.s=e,t.n=e,32&ff.f&&t.S(e),e;if(-1===e.i)return e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=ff.s,e.n=void 0,ff.s.n=e,ff.s=e),e}}function Sf(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function Cf(t,e){return new Sf(t,e)}function _f(t){for(var e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function If(t){for(var e=t.s;void 0!==e;e=e.n){var i=e.S.n;if(void 0!==i&&(e.r=i),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function Af(t){for(var e=t.s,i=void 0;void 0!==e;){var n=e.p;-1===e.i?(e.S.U(e),void 0!==n&&(n.n=e.n),void 0!==e.n&&(e.n.p=n)):i=e,e.S.n=e.r,void 0!==e.r&&(e.r=void 0),e=n}t.s=i}function Tf(t,e){Sf.call(this,void 0),this.x=t,this.s=void 0,this.g=kf-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name}function Ef(t,e){return new Tf(t,e)}function Mf(t){var e=t.m;if(t.m=void 0,"function"==typeof e){bf++;var i=ff;ff=void 0;try{e()}catch(e){throw t.f&=-2,t.f|=8,Of(t),e}finally{ff=i,vf()}}}function Of(t){for(var e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Mf(t)}function Rf(t){if(ff!==this)throw new Error("Out-of-order effect");Af(this),ff=t,this.f&=-2,8&this.f&&Of(this),vf()}function Nf(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==e?void 0:e.name}function Pf(t,e){var i=new Nf(t,e);try{i.c()}catch(t){throw i.d(),t}var n=i.d.bind(i);return n[Symbol.dispose]=n,n}function Bf(t,e){Nd[t]=e.bind(null,Nd[t]||function(){})}function Df(t){if(mf){var e=mf;mf=void 0,e()}mf=t&&t.S()}function jf(t){var e=this,i=t.data,n=function(t){return Wv(function(){return Cf(t)},[])}(i);n.value=i;var r=Wv(function(){for(var t=e.__v;t=t.__;)if(t.__c){t.__c.__$f|=4;break}return e.__$u.c=function(){var t,i=e.__$u.S(),n=r.value;i(),Bd(n)||3!==(null==(t=e.base)?void 0:t.nodeType)?(e.__$f|=1,e.setState({})):e.base.data=n},Ef(function(){var t=n.value.value;return 0===t?0:!0===t?"":t||""})},[]);return r.value}function Uf(t,e,i,n){var r=e in t&&void 0===t.ownerSVGElement,s=Cf(i);return{o:function(t,e){s.value=t,n=e},d:Pf(function(){var i=s.value.value;n[e]!==i&&(n[e]=i,r?t[e]=i:i?t.setAttribute(e,i):t.removeAttribute(e))})}}Sf.prototype.brand=df,Sf.prototype.h=function(){return!0},Sf.prototype.S=function(t){var e=this,i=this.t;i!==t&&void 0===t.e&&(t.x=i,this.t=t,void 0!==i?i.e=t:pf(function(){var t;null==(t=e.W)||t.call(e)}))},Sf.prototype.U=function(t){var e=this;if(void 0!==this.t){var i=t.e,n=t.x;void 0!==i&&(i.x=n,t.e=void 0),void 0!==n&&(n.e=i,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&pf(function(){var t;null==(t=e.Z)||t.call(e)}))}},Sf.prototype.subscribe=function(t){var e=this;return Pf(function(){var i=e.value,n=ff;ff=void 0;try{t(i)}finally{ff=n}},{name:"sub"})},Sf.prototype.valueOf=function(){return this.value},Sf.prototype.toString=function(){return this.value+""},Sf.prototype.toJSON=function(){return this.value},Sf.prototype.peek=function(){var t=this;return pf(function(){return t.value})},Object.defineProperty(Sf.prototype,"value",{get:function(){var t=xf(this);return void 0!==t&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(yf>100)throw new Error("Cycle detected");!function(t){0!==bf&&0===yf&&0!==t.l&&(t.l=0,wf={S:t,v:t.v,i:t.i,o:wf})}(this),this.v=t,this.i++,kf++,bf++;try{for(var e=this.t;void 0!==e;e=e.x)e.t.N()}finally{vf()}}}}),Tf.prototype=new Sf,Tf.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===kf)return!0;if(this.g=kf,this.f|=1,this.i>0&&!_f(this))return this.f&=-2,!0;var t=ff;try{If(this),ff=this;var e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return ff=t,Af(this),this.f&=-2,!0},Tf.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(var e=this.s;void 0!==e;e=e.n)e.S.S(e)}Sf.prototype.S.call(this,t)},Tf.prototype.U=function(t){if(void 0!==this.t&&(Sf.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(var e=this.s;void 0!==e;e=e.n)e.S.U(e)}},Tf.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;void 0!==t;t=t.x)t.t.N()}},Object.defineProperty(Tf.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=xf(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),Nf.prototype.c=function(){var t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var e=this.x();"function"==typeof e&&(this.m=e)}finally{t()}},Nf.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Mf(this),If(this),bf++;var t=ff;return ff=this,Rf.bind(this,t)},Nf.prototype.N=function(){2&this.f||(this.f|=2,this.u=gf,gf=this)},Nf.prototype.d=function(){this.f|=8,1&this.f||Of(this)},Nf.prototype.dispose=function(){this.d()},jf.displayName="_st",Object.defineProperties(Sf.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:jf},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Bf("__b",function(t,e){if("string"==typeof e.type){var i,n=e.props;for(var r in n)if("children"!==r){var s=n[r];s instanceof Sf&&(i||(e.__np=i={}),i[r]=s,n[r]=s.peek())}}t(e)}),Bf("__r",function(t,e){t(e),Df();var i,n=e.__c;n&&(n.__$f&=-2,void 0===(i=n.__$u)&&(n.__$u=i=function(){var t;return Pf(function(){t=this}),t.c=function(){n.__$f|=1,n.setState({})},t}())),Df(i)}),Bf("__e",function(t,e,i,n){Df(),t(e,i,n)}),Bf("diffed",function(t,e){var i;if(Df(),"string"==typeof e.type&&(i=e.__e)){var n=e.__np,r=e.props;if(n){var s=i.U;if(s)for(var o in s){var a=s[o];void 0===a||o in n||(a.d(),s[o]=void 0)}else i.U=s={};for(var l in n){var h=s[l],u=n[l];void 0===h?(h=Uf(i,l,u,r),s[l]=h):h.o(u,r)}}}t(e)}),Bf("unmount",function(t,e){if("string"==typeof e.type){var i=e.__e;if(i){var n=i.U;if(n)for(var r in i.U=void 0,n){var s=n[r];s&&s.d()}}}else{var o=e.__c;if(o){var a=o.__$u;a&&(o.__$u=void 0,a.d())}}t(e)}),Bf("__h",function(t,e,i,n){(n<3||9===n)&&(e.__$f|=2),t(e,i,n)}),iv.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var i=this.__$u,n=i&&void 0!==i.s;for(var r in e)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(n||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(n||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var s in t)if("__source"!==s&&t[s]!==this.props[s])return!0;for(var o in this.props)if(!(o in t))return!0;return!1};var Lf={primaryColor:"#7B68EE",fontFamily:"'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",borderRadius:"12px"};class Ff{constructor(){this.isOpen=Cf(!1),this.isVisible=Cf(!0),this.isLoading=Cf(!1),this.currentView=Cf("list"),this.channels=Cf([]),this.channel=Cf(null),this.messages=Cf([]),this.isTyping=Cf(!1),this.typingSender=Cf(null),this.typingSenderType=Cf(null),this.agentLastReadAt=Cf(null),this.initialUserReadAt=Cf(null),this.userScrolledUp=Cf(!1),this.unreadNewMessagesCount=Cf(0),this.theme=Cf(i({},Lf)),this.connectionState=Cf("disconnected"),this.ablyProjectId=Cf(null),this.realtimeChannelId=Cf(null),this.realtimeAttached=Cf(!1),this.pendingRealtimeChannelId=Cf(null),this.identityChangeInFlight=Cf(!1),this.lastConnectedDistinctId=Cf(null),this.Tt=new Map,this.isConnected=Ef(()=>"connected"===this.connectionState.value),this.polledUnreadTotal=Cf(null),this.unreadCount=Ef(()=>this.isOpen.value||null===this.polledUnreadTotal.value?this.channels.value.reduce((t,e)=>t+(e.unread_count||0),0):this.polledUnreadTotal.value),this.connectionBanner=Ef(()=>{var t=this.connectionState.value;return"suspended"===t?"reconnecting":"failed"===t?"failed":"none"}),this.realtimeReady=Ef(()=>{var t=this.channel.value;return!!t&&("connected"===this.connectionState.value&&this.realtimeAttached.value&&this.realtimeChannelId.value===t.id)})}setMessages(t){this.messages.value=t}patchChannelSummary(t,e){var n=this.channels.value.findIndex(e=>e.id===t);if(-1!==n){var r=[...this.channels.value];r[n]=i({},r[n],e),r.sort((t,e)=>{var i=t.last_message_at||t.created_at,n=e.last_message_at||e.created_at;return new Date(n).getTime()-new Date(i).getTime()}),this.channels.value=r}}prependChannelSummary(t){this.channels.value.some(e=>e.id===t.id)||(this.channels.value=[t,...this.channels.value])}clearActiveChannel(){this.channel.value=null,this.messages.value=[],this.isTyping.value=!1,this.typingSender.value=null,this.typingSenderType.value=null,this.userScrolledUp.value=!1,this.unreadNewMessagesCount.value=0,this.realtimeChannelId.value=null,this.realtimeAttached.value=!1,this.pendingRealtimeChannelId.value=null,this.agentLastReadAt.value=null,this.initialUserReadAt.value=null}prepareChannelSwitch(){this.messages.value=[],this.isTyping.value=!1,this.typingSender.value=null,this.typingSenderType.value=null,this.userScrolledUp.value=!1,this.unreadNewMessagesCount.value=0,this.agentLastReadAt.value=null,this.initialUserReadAt.value=null}cacheMessages(t,e){if(t){var i=e.filter(t=>!t.id.startsWith("temp-"));for(this.Tt.delete(t),this.Tt.set(t,i);this.Tt.size>Ff.MESSAGES_CACHE_LIMIT;){var n=this.Tt.keys().next().value;if(void 0===n)break;this.Tt.delete(n)}}}getCachedMessages(t){if(!t)return null;var e=this.Tt.get(t);return e?(this.Tt.delete(t),this.Tt.set(t,e),e):null}clearMessagesCache(){this.Tt.clear()}}Ff.MESSAGES_CACHE_LIMIT=10;var zf={bottom:20,right:20,left:20};function Wf(t,e){return void 0!==t&&Number.isFinite(t)?Math.max(0,t):e}function $f(t){return null===t?i({},zf):{bottom:Wf(null==t?void 0:t.bottom,zf.bottom),right:Wf(null==t?void 0:t.right,zf.right),left:Wf(null==t?void 0:t.left,zf.left)}}function Vf(t,e,i){t.style.bottom=i.bottom+"px","bottom-right"===e?(t.style.right=i.right+"px",t.style.left=""):(t.style.left=i.left+"px",t.style.right="")}var Hf="vtilt-bubble-pos";function qf(t){try{localStorage.setItem(Hf,JSON.stringify(t))}catch(t){}}function Jf(t,e,i){var n=t.getBoundingClientRect(),r=n.left-e,s=n.top-i,o=window.innerWidth-t.offsetWidth-r,a=-r,l=window.innerHeight-t.offsetHeight-s,h=-s;return{x:Math.min(Math.max(e,a),o),y:Math.min(Math.max(i,h),l)}}function Gf(t,e,i){t.style.transform="translate3d("+e+"px, "+i+"px, 0)"}function Zf(t,e){var i,n=null!==(i=null==e?void 0:e.handle)&&void 0!==i?i:t,r=null==e?void 0:e.onPositionChange,s=0,o=0,a=0,l=0,h=0,u=0,c=!1,d=!1,v=function(){try{var t=localStorage.getItem(Hf);if(!t)return null;var e=JSON.parse(t);if("number"==typeof e.x&&"number"==typeof e.y)return e}catch(t){}return null}();if(v){s=v.x,o=v.y;var f=t.style.transition;t.style.transition="none",Gf(t,s,o);var p=Jf(t,s,o);s=p.x,o=p.y,Gf(t,s,o),t.offsetHeight,t.style.transition=f}n.style.cursor="grab",n.style.touchAction="none";var m=e=>{0===e.button&&(c=!0,d=!1,a=e.clientX,l=e.clientY,h=s,u=o,n.setPointerCapture(e.pointerId),n.style.cursor="grabbing",t.style.transition="none")},g=e=>{if(c){var i=e.clientX-a,n=e.clientY-l;if(!(!d&&Math.abs(i)<5&&Math.abs(n)<5)){d=!0;var v={x:h+i,y:u+n},f=Jf(t,v.x,v.y);s=f.x,o=f.y,Gf(t,s,o),null==r||r()}}},b=()=>{c&&(c=!1,n.style.cursor="grab",t.style.transition="",d&&(qf({x:s,y:o}),null==r||r()))},y=t=>{d&&(t.stopPropagation(),t.preventDefault(),d=!1)},w=()=>{var e=s,i=o,n=Jf(t,s,o);s=n.x,o=n.y,Gf(t,s,o),e===s&&i===o||qf({x:s,y:o}),null==r||r()};return n.addEventListener("pointerdown",m),n.addEventListener("pointermove",g),n.addEventListener("pointerup",b),n.addEventListener("pointercancel",b),n.addEventListener("click",y,!0),window.addEventListener("resize",w),{destroy(){n.removeEventListener("pointerdown",m),n.removeEventListener("pointermove",g),n.removeEventListener("pointerup",b),n.removeEventListener("pointercancel",b),n.removeEventListener("click",y,!0),window.removeEventListener("resize",w)}}}function Yf(t){var{store:e,controller:i,bubbleRef:n}=t,r=e.unreadCount.value;return Cv("button",{type:"button",class:"vt-bubble",ref:n,onClick:()=>i.toggle(),"aria-label":"Open chat",children:[Cv(sf,{}),Cv("span",{class:"vt-bubble-badge","data-visible":r>0?"true":"false",children:r>99?"99+":r})]})}function Kf(t){var{channel:e,onSelect:i}=t,n=e.unread_count>0,r=function(t){var e=new Date(t),i=Date.now()-e.getTime(),n=Math.floor(i/6e4),r=Math.floor(i/36e5),s=Math.floor(i/864e5);if(n<1)return"Just now";if(n<60)return n+"m ago";if(r<24)return r+"h ago";if(s<7)return s+"d ago";return e.toLocaleDateString()}(e.last_message_at||e.created_at),s=e.last_message_preview||"No messages yet",o="user"===e.last_message_sender?"You: ":"",a="closed"===e.status?" · Closed":"";return Cv("button",{type:"button",class:"vt-channel-item","data-channel-id":e.id,onClick:()=>i(e.id),children:[Cv("div",{class:"vt-channel-avatar","data-mode":e.ai_mode?"ai":"support",children:e.ai_mode?Cv(of,{width:24,height:24}):Cv(af,{width:24,height:24})}),Cv("div",{class:"vt-channel-body",children:[Cv("div",{class:"vt-channel-row",children:[Cv("div",{class:"vt-channel-name","data-unread":n?"true":"false",children:e.ai_mode?"AI Assistant":"Support"}),Cv("div",{class:"vt-channel-time",children:r})]}),Cv("div",{class:"vt-channel-row",children:[Cv("div",{class:"vt-channel-preview","data-unread":n?"true":"false",children:[o,s,a]}),n&&Cv("div",{class:"vt-channel-unread",children:e.unread_count>99?"99+":e.unread_count})]})]})]})}function Xf(){return Cv("div",{style:"flex: 1; overflow: hidden;",children:[Cv(Qf,{}),Cv(Qf,{}),Cv(Qf,{}),Cv(Qf,{})]})}function Qf(){return Cv("div",{style:"padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--vtilt-border-light); background: white;",children:[Cv("div",{class:"vt-skeleton-circle",style:"width: 48px; height: 48px; flex-shrink: 0;"}),Cv("div",{style:"flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px;",children:[Cv("div",{class:"vt-skeleton",style:"height: 12px; width: 40%;"}),Cv("div",{class:"vt-skeleton",style:"height: 10px; width: 80%;"})]})]})}function tp(){return Cv(ev,{children:[Cv(ep,{direction:"in",widthPct:62,metaPx:92,height:40}),Cv(ep,{direction:"out",widthPct:42,metaPx:56,height:40}),Cv(ep,{direction:"in",widthPct:78,metaPx:76,height:60})]})}function ep(t){var{direction:e,widthPct:i,metaPx:n,height:r}=t;return Cv("div","in"===e?{style:"display: flex; gap: 10px; align-items: flex-end;",children:[Cv("div",{class:"vt-skeleton-circle",style:"width: 32px; height: 32px; flex-shrink: 0;"}),Cv("div",{style:"display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 85%;",children:[Cv("div",{class:"vt-skeleton",style:"width: "+i+"%; min-width: 96px; height: "+r+"px; border-radius: 20px 20px 20px 4px;"}),Cv("div",{class:"vt-skeleton",style:"height: 10px; width: "+n+"px; margin-top: 8px; margin-left: 6px; border-radius: 4px;"})]})]}:{style:"display: flex; flex-direction: column; align-items: flex-end;",children:[Cv("div",{class:"vt-skeleton",style:"width: "+i+"%; min-width: 80px; max-width: 80%; height: "+r+"px; border-radius: 20px 20px 4px 20px;"}),Cv("div",{class:"vt-skeleton",style:"height: 10px; width: "+n+"px; margin-top: 8px; margin-right: 6px; border-radius: 4px;"})]})}function ip(t){var{store:e,controller:i}=t,n=e.channels.value,r=e.isLoading.value;return 0===n.length&&r?Cv(Xf,{}):0===n.length?Cv(np,{controller:i}):Cv(ev,{children:[Cv("div",{class:"vt-list-root",children:n.map(t=>Cv(Kf,{channel:t,onSelect:t=>{i.selectChannel(t)}},t.id))}),Cv("div",{class:"vt-list-footer",children:Cv("button",{type:"button",class:"vt-new-channel-btn",onClick:()=>{i.createChannel()},children:["Send us a message",Cv(rf,{width:18,height:18})]})})]})}function np(t){var{controller:e}=t,i=e.config.greeting||"Hi! How can we help you today?";return Cv("div",{class:"vt-list-empty",children:[Cv("div",{class:"vt-list-empty-icon",children:Cv(lf,{})}),Cv("div",{class:"vt-list-empty-title",children:i}),Cv("div",{class:"vt-list-empty-subtitle",children:"Start a conversation with us"}),Cv("button",{type:"button",class:"vt-new-channel-btn",style:"width: auto; padding: 14px 28px;",onClick:()=>{e.createChannel()},children:["Send us a message",Cv(rf,{width:18,height:18})]})]})}function rp(t){var e,i,n,{store:r,controller:s}=t;if("list"===r.currentView.value)return Cv("div",{class:"vt-header","data-view":"list",children:[Cv("div",{class:"vt-header-title",children:"Messages"}),Cv("button",{type:"button",class:"vt-iconbtn vt-header-close",onClick:()=>s.close(),"aria-label":"Close",children:Cv(ef,{})})]});var o=null===(n=null!==(i=null===(e=r.channel.value)||void 0===e?void 0:e.ai_mode)&&void 0!==i?i:s.config.aiMode)||void 0===n||n;return Cv("div",{class:"vt-header","data-view":"conversation",children:[Cv("button",{type:"button",class:"vt-iconbtn vt-header-back",onClick:()=>s.goToChannelList(),"aria-label":"Back",children:Cv(nf,{})}),Cv("div",{class:"vt-header-avatar","data-mode":o?"ai":"support",children:Cv(o?of:af,{})}),Cv("div",{class:"vt-header-info",children:[Cv("div",{class:"vt-header-name",children:o?"AI Assistant":"Support"}),Cv("div",{class:"vt-header-status",children:"Online"})]}),Cv("button",{type:"button",class:"vt-iconbtn vt-header-close",onClick:()=>s.close(),"aria-label":"Close",children:Cv(ef,{})})]})}function sp(){return Cv("div",{class:"vt-closed-banner",children:"This conversation has been closed."})}function op(t){var{store:e}=t,i=e.connectionBanner.value,n=function(t,e){var[i,n]=Lv(!1);return Fv(()=>{if(t){var i=setTimeout(()=>n(!0),e);return()=>clearTimeout(i)}n(!1)},[t,e]),i}("reconnecting"===i,2500),r=$v(()=>{"undefined"!=typeof window&&window.location.reload()},[]);return"failed"===i?Cv("div",{class:"vt-conn-banner","data-kind":"failed",role:"alert",children:[Cv("span",{class:"vt-conn-banner-icon","aria-hidden":"true",children:Cv("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[Cv("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z"}),Cv("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),Cv("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),Cv("span",{class:"vt-conn-banner-text",children:"Connection lost"}),Cv("button",{type:"button",class:"vt-conn-banner-action",onClick:r,children:"Retry"})]}):n?Cv("div",{class:"vt-conn-banner","data-kind":"reconnecting",role:"status",children:[Cv("span",{class:"vt-conn-banner-dot","aria-hidden":"true"}),Cv("span",{class:"vt-conn-banner-text",children:"Reconnecting"})]}):null}function ap(t){var{store:e,controller:i}=t,[n,r]=Lv(""),s=zv(null),o=null==e.channel.value,a=()=>{var t=n.trim();t&&(i.stopUserTyping(),i.sendMessage(t),r(""),s.current&&(s.current.style.height="",s.current.focus()))};return Fv(()=>{s.current&&function(t){t.style.height="auto";var e=120,i=60;t.style.height=Math.min(Math.max(t.scrollHeight,i),e)+"px"}(s.current)},[n]),Cv("div",{class:"vt-input-container","data-pending":o?"true":"false",children:Cv("div",{class:"vt-input-box",children:[Cv("textarea",{class:"vt-input-textarea",ref:s,rows:1,placeholder:o?"Starting conversation…":"Message...",autocomplete:"off",autocorrect:"on",autocapitalize:"sentences",disabled:o,value:n,onInput:t=>{var e=t.currentTarget.value;r(e),i.notifyUserTyping()},onBlur:()=>{i.stopUserTyping()},onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),a())}}),Cv("button",{type:"button",class:"vt-input-send","data-active":n.trim().length>0?"true":"false",disabled:0===n.trim().length||o,onClick:a,"aria-label":"Send message",children:Cv(rf,{})})]})})}function lp(t,e){for(var i in t)if("__source"!==i&&!(i in e))return!0;for(var n in e)if("__source"!==n&&t[n]!==e[n])return!0;return!1}function hp(t,e){this.props=t,this.context=e}function up(t,e){function i(t){var i=this.props.ref;return i!=t.ref&&i&&("function"==typeof i?i(null):i.current=null),e?!e(this.props,t)||i!=t.ref:lp(this.props,t)}function n(e){return this.shouldComponentUpdate=i,Qd(t,e)}return n.displayName="Memo("+(t.displayName||t.name)+")",n.__f=n.prototype.isReactComponent=!0,n.type=t,n}(hp.prototype=new iv).isPureReactComponent=!0,hp.prototype.shouldComponentUpdate=function(t,e){return lp(this.props,t)||lp(this.state,e)};var cp=Nd.__b;Nd.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),cp&&cp(t)};var dp=Nd.__e;Nd.__e=function(t,e,i,n){if(t.then)for(var r,s=e;s=s.__;)if((r=s.__c)&&r.__c)return null==e.__e&&(e.__e=i.__e,e.__k=i.__k),r.__c(t,e);dp(t,e,i,n)};var vp=Nd.unmount;function fp(t,e,i){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(t){"function"==typeof t.__c&&t.__c()}),t.__c.__H=null),null!=(t=function(t,e){for(var i in e)t[i]=e[i];return t}({},t)).__c&&(t.__c.__P===i&&(t.__c.__P=e),t.__c.__e=!0,t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return fp(t,e,i)})),t}function pp(t,e,i){return t&&i&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return pp(t,e,i)}),t.__c&&t.__c.__P===e&&(t.__e&&i.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=i)),t}function mp(){this.__u=0,this.o=null,this.__b=null}function gp(t){var e=t.__&&t.__.__c;return e&&e.__a&&e.__a(t)}function bp(){this.i=null,this.l=null}Nd.unmount=function(t){var e=t.__c;e&&(e.__z=!0),e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),vp&&vp(t)},(mp.prototype=new iv).__c=function(t,e){var i=e.__c,n=this;null==n.o&&(n.o=[]),n.o.push(i);var r=gp(n.__v),s=!1,o=function(){s||n.__z||(s=!0,i.__R=null,r?r(l):l())};i.__R=o;var a=i.__P;i.__P=null;var l=function(){if(! --n.__u){if(n.state.__a){var t=n.state.__a;n.__v.__k[0]=pp(t,t.__c.__P,t.__c.__O)}var e;for(n.setState({__a:n.__b=null});e=n.o.pop();)e.__P=a,e.forceUpdate()}};n.__u++||32&e.__u||n.setState({__a:n.__b=n.__v.__k[0]}),t.then(o,o)},mp.prototype.componentWillUnmount=function(){this.o=[]},mp.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var i=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=fp(this.__b,i,n.__O=n.__P)}this.__b=null}var r=e.__a&&Qd(ev,null,t.fallback);return r&&(r.__u&=-33),[Qd(ev,null,e.__a?null:t.children),r]};var yp=function(t,e,i){if(++i[1]===i[0]&&t.l.delete(e),t.props.revealOrder&&("t"!==t.props.revealOrder[0]||!t.l.size))for(i=t.i;i;){for(;i.length>3;)i.pop()();if(i[1]<i[0])break;t.i=i=i[2]}};(bp.prototype=new iv).__a=function(t){var e=this,i=gp(e.__v),n=e.l.get(t);return n[0]++,function(r){var s=function(){e.props.revealOrder?(n.push(r),yp(e,t,n)):r()};i?i(s):s()}},bp.prototype.render=function(t){this.i=null,this.l=new Map;var e=hv(t.children);t.revealOrder&&"b"===t.revealOrder[0]&&e.reverse();for(var i=e.length;i--;)this.l.set(e[i],this.i=[1,0,this.i]);return t.children},bp.prototype.componentDidUpdate=bp.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,i){yp(t,i,e)})};var wp="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,kp=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,xp=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Sp=/[A-Z0-9]/g,Cp="undefined"!=typeof document,_p=function(t){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(t)};iv.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(iv.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Ip=Nd.event;Nd.event=function(t){return Ip&&(t=Ip(t)),t.persist=function(){},t.isPropagationStopped=function(){return this.cancelBubble},t.isDefaultPrevented=function(){return this.defaultPrevented},t.nativeEvent=t};var Ap={configurable:!0,get:function(){return this.class}},Tp=Nd.vnode;Nd.vnode=function(t){"string"==typeof t.type&&function(t){var e=t.props,i=t.type,n={},r=-1==i.indexOf("-");for(var s in e){var o=e[s];if(!("value"===s&&"defaultValue"in e&&null==o||Cp&&"children"===s&&"noscript"===i||"class"===s||"className"===s)){var a=s.toLowerCase();"defaultValue"===s&&"value"in e&&null==e.value?s="value":"download"===s&&!0===o?o="":"translate"===a&&"no"===o?o=!1:"o"===a[0]&&"n"===a[1]?"ondoubleclick"===a?s="ondblclick":"onchange"!==a||"input"!==i&&"textarea"!==i||_p(e.type)?"onfocus"===a?s="onfocusin":"onblur"===a?s="onfocusout":xp.test(s)&&(s=a):a=s="oninput":r&&kp.test(s)?s=s.replace(Sp,"-$&").toLowerCase():null===o&&(o=void 0),"oninput"===a&&n[s=a]&&(s="oninputCapture"),n[s]=o}}"select"==i&&(n.multiple&&Array.isArray(n.value)&&(n.value=hv(e.children).forEach(function(t){t.props.selected=-1!=n.value.indexOf(t.props.value)})),null!=n.defaultValue&&(n.value=hv(e.children).forEach(function(t){t.props.selected=n.multiple?-1!=n.defaultValue.indexOf(t.props.value):n.defaultValue==t.props.value}))),e.class&&!e.className?(n.class=e.class,Object.defineProperty(n,"className",Ap)):e.className&&(n.class=n.className=e.className),t.props=n}(t),t.$$typeof=wp,Tp&&Tp(t)};var Ep=Nd.__r;Nd.__r=function(t){Ep&&Ep(t),t.__c};var Mp=Nd.diffed;function Op(t,e){var i=Date.parse(t.created_at),n=Date.parse(e.created_at);return i!==n?i-n:t.id.localeCompare(e.id)}function Rp(t,e){return function(t){return t.length<2?t:[...t].sort(Op)}([...t,e])}Nd.diffed=function(t){Mp&&Mp(t);var e=t.props,i=t.__e;null!=i&&"textarea"===t.type&&"value"in e&&e.value!==i.value&&(i.value=null==e.value?"":e.value)};var Np="chat.stream",Pp=/<!--vtilt:widget:([\s\S]*?)-->/g;function Bp(t){for(var e,i,n=[],r=new RegExp(Pp.source,"g");null!==(i=r.exec(t));)try{var s=JSON.parse(i[1]);s.type&&n.push({type:s.type,params:null!==(e=s.params)&&void 0!==e?e:{}})}catch(t){}return n}function Dp(t){return jp.apply(this,arguments)}function jp(){return jp=e(function*(t){var e,n,r,{store:s,response:o,channelId:a,tempId:l,signal:h,isActive:u,onStreamStart:c,onComplete:d}=t,v=()=>{var t;return!(null==h?void 0:h.aborted)&&(null===(t=null==u?void 0:u())||void 0===t||t)},f=o.headers.get("X-Vtilt-Message-Id"),p=o.headers.get("X-Vtilt-Message-Created-At"),m=null!==(e=null!=l?l:f)&&void 0!==e?e:"temp-ai-"+Date.now();if(v()&&(null==c||c(m),v())){var g={id:m,channel_id:a,sender_type:"ai",sender_id:null,sender_name:"AI Assistant",sender_avatar_url:null,content:"",content_type:"text",metadata:{},created_at:null!=p?p:(new Date).toISOString()};s.setMessages(Rp(s.messages.value,g));var b=null===(n=o.body)||void 0===n?void 0:n.getReader();if(!b)return uu().error(Np,"no response body reader available"),void Up(s,m);var y=new TextDecoder,w="",k=null,x=!0,S=()=>{if(v()){var t=s.messages.value.findIndex(t=>t.id===m);if(-1!==t){var e=[...s.messages.value];e[t]=i({},e[t],{content:w.replace(/<[^>]*$/,"")}),s.setMessages(e)}}else Up(s,m)},C=()=>{null===k&&(k=requestAnimationFrame(()=>{S(),k=null}))};try{for(;;){if(!v())return void Up(s,m);var{done:_,value:I}=yield b.read();if(_)break;var A=y.decode(I,{stream:!0});w+=A,x?(x=!1,S()):C()}if(!v())return void Up(s,m);null!==k&&(cancelAnimationFrame(k),k=null),S();var T=s.messages.value.findIndex(t=>t.id===m);if(-1!==T){var E=Bp(w),M=[...s.messages.value],O=i({},null!==(r=M[T].metadata)&&void 0!==r?r:{});E.length>0&&(O.At=E),M[T]=i({},M[T],{content:w,metadata:O}),s.setMessages(M)}null==d||d(m)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return void Up(s,m);uu().error(Np,"failed to handle streaming response:",t),Up(s,m)}finally{b.releaseLock(),null!==k&&cancelAnimationFrame(k)}}}),jp.apply(this,arguments)}function Up(t,e){var i=t.messages.value.filter(t=>t.id!==e);i.length!==t.messages.value.length&&t.setMessages(i)}var Lp=/<(?:p|ul|ol|li|h[1-6]|br|div|pre|blockquote)\b/i,Fp=new Set(["P","B","STRONG","I","EM","U","UL","OL","LI","BR","A","H1","H2","H3","H4","H5","H6","CODE","PRE","BLOCKQUOTE","DIV","SPAN"]);function zp(t){var e=t;return e=(e=(e=(e=(e=(e=e.replace(/\*\*(.+?)\*\*/g,"<b>$1</b>")).replace(/__(.+?)__/g,"<b>$1</b>")).replace(/\*(.+?)\*/g,"<i>$1</i>")).replace(/(?<!\w)_(.+?)_(?!\w)/g,"<i>$1</i>")).replace(/`([^`]+)`/g,"<code>$1</code>")).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>')}function Wp(t,e){for(var i=Array.from(t.children),n=0;n<i.length;){var r=i[n];if("LI"!==r.tagName)Wp(r,e),n++;else{for(var s=[],o=n;o<i.length&&"LI"===i[o].tagName;)s.push(i[o]),o++;var a=e.createElement("ul");for(var l of(t.insertBefore(a,s[0]),s))a.appendChild(l);n=o}}}function $p(t,e){if(void 0===e&&(e="text"),!t)return"";var i=t.trim();if(!i)return"";if("undefined"==typeof document)return i;var n=function(t,e){return"html"!==t&&!Lp.test(e)}(e,i)?function(t){if(!t||Lp.test(t))return t;for(var e=t.split("\n"),i=[],n=0;n<e.length;){var r=e[n],s=r.match(/^(#{1,6})\s+(.+)$/);if(s){var o=s[1].length;i.push("<h"+o+">"+zp(s[2])+"</h"+o+">"),n++}else if(/^[-*]\s+/.test(r)){for(var a=[];n<e.length&&/^[-*]\s+/.test(e[n]);)a.push("<li>"+zp(e[n].replace(/^[-*]\s+/,""))+"</li>"),n++;i.push("<ul>"+a.join("")+"</ul>")}else if(/^\d+\.\s+/.test(r)){for(var l=[];n<e.length&&/^\d+\.\s+/.test(e[n]);)l.push("<li>"+zp(e[n].replace(/^\d+\.\s+/,""))+"</li>"),n++;i.push("<ol>"+l.join("")+"</ol>")}else if(""!==r.trim()){for(var h=[];n<e.length&&""!==e[n].trim()&&!/^#{1,6}\s/.test(e[n])&&!/^[-*]\s+/.test(e[n])&&!/^\d+\.\s+/.test(e[n]);)h.push(zp(e[n])),n++;i.push("<p>"+h.join("<br>")+"</p>")}else n++}return i.join("")}(i):i,r=document.createElement("div");return r.innerHTML=n,function(t,e){var i=t=>{for(var n of Array.from(t.children))if(Fp.has(n.tagName)){for(var r of Array.from(n.attributes))"A"===n.tagName&&"href"===r.name||n.removeAttribute(r.name);"A"===n.tagName&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")),i(n)}else n.replaceWith(e.createTextNode(n.textContent||""))};i(t)}(r,document),Wp(r,document),r.innerHTML}var Vp=up(function(t){var{message:e,controller:i}=t,n=function(t){var e,i=null!==(e=t.metadata)&&void 0!==e?e:{},n=i.At;n&&0!==n.length||(n=i.widgets);n&&0!==n.length||!t.content||(n=Bp(t.content));return null!=n?n:[]}(e);return 0===n.length?null:Cv(ev,{children:n.map((t,n)=>{if(t.submitted)return Cv(Hp,{widget:t},n);var r=i.widgets.get(t.type);if(!r)return null;var s=i.getWidgetContext(e.id,t.type);return Cv("div",{children:r.render(t.params,s)},n)})})},(t,e)=>t.message===e.message&&t.controller===e.controller);function Hp(t){var e,i,{widget:n}=t;if("collect_email"===n.type){var r=null!==(e=n.submittedEmail)&&void 0!==e?e:"",s=null!==(i=n.submittedName)&&void 0!==i?i:"";return Cv("div",{class:"vt-widget",children:Cv("p",{class:"vt-widget-thanks",children:s?"✓ Thanks, "+s+"! We'll follow up at "+r+".":r?"✓ Thanks! We'll follow up at "+r+".":"✓ Thanks!"})})}return"escalate_to_human"===n.type?Cv("div",{class:"vt-widget",children:Cv("p",{class:"vt-widget-thanks",children:"✓ A team member has been notified. They'll join shortly."})}):Cv("div",{class:"vt-widget",children:Cv("p",{class:"vt-widget-thanks",children:"✓ Done"})})}var qp=up(function(t){var{message:e,controller:i,isReadByAgent:n}=t,r="user"===e.sender_type?"out":"in",s=Wv(()=>function(t){if("user"===t.sender_type)return"";if("ai"===t.sender_type)return"AI Assistant";return t.sender_name||"Agent"}(e),[e.sender_type,e.sender_name]);return Cv("div",{class:"vt-message","data-direction":r,children:[Cv("div",{class:"vt-message-row",children:["in"===r&&Cv(Gp,{senderType:e.sender_type}),Cv(Jp,{message:e})]}),Cv(Vp,{message:e,controller:i}),Cv("div",{class:"vt-message-meta",children:[s?Cv("span",{children:s}):null,s?Cv("span",{children:" · "}):null,Cv("time",{children:Yp(e.created_at)}),"out"===r?Cv(Zp,{message:e,controller:i}):null,"out"===r&&n?Cv("span",{children:" · Read"}):null]})]})},(t,e)=>t.message===e.message&&t.message.delivery_status===e.message.delivery_status&&t.controller===e.controller&&t.isReadByAgent===e.isReadByAgent);function Jp(t){var e,{message:i}=t,n=(null!==(e=i.content)&&void 0!==e?e:"").replace(Pp,"").trim();if(!n)return Cv("div",{class:"vt-message-bubble"});if(!Td(i))return Cv("div",{class:"vt-message-bubble",children:n});var r=$p(n,i.content_type);return Cv("div",{class:"vt-message-bubble",children:Cv("div",{class:"vt-md"+("user"===i.sender_type?" vt-user-md":""),dangerouslySetInnerHTML:{__html:r}})})}function Gp(t){var{senderType:e}=t,i="ai"===e;return Cv("div",{class:"vt-message-avatar","data-mode":i?"ai":"support",children:Cv(i?of:af,{width:16,height:16})})}function Zp(t){var{message:e,controller:i}=t,n=e.delivery_status;return n?Cv("span","pending"===n||"sending"===n?{children:" · Sending…"}:{children:[" · ",Cv("button",{type:"button",class:"vt-message-retry",onClick:()=>i.retryFailedMessage(e.id),children:"Failed — tap to retry"})]}):null}function Yp(t){if(!t)return"";var e=new Date(t);return Number.isNaN(e.getTime())?"":e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Kp(t){var{senderType:e,senderName:i}=t,n="ai"===e,r=n?"AI Assistant":i||"Agent";return Cv("div",{class:"vt-message","data-direction":"in","data-typing":"true",children:[Cv("div",{class:"vt-message-row",children:[Cv("div",{class:"vt-message-avatar","data-mode":n?"ai":"support",children:Cv(n?of:af,{width:16,height:16})}),Cv("div",{class:"vt-message-bubble","data-typing":"true","aria-label":r+" is typing",children:[Cv("span",{class:"vt-typing-dot"}),Cv("span",{class:"vt-typing-dot"}),Cv("span",{class:"vt-typing-dot"})]})]}),Cv("div",{class:"vt-message-meta",children:Cv("span",{children:r})})]})}function Xp(t){var{count:e,visible:i,onJump:n}=t;return Cv("button",{type:"button",class:"vt-new-pill","data-visible":i&&e>0?"true":"false","aria-label":"Jump to latest messages",onClick:n,children:Cv("span",{children:e>1?"↓ "+e+" new messages":"↓ 1 new message"})})}function Qp(t){var{store:e,scrollRef:i,messages:n,typingActive:r=!1}=t,s=zv(null),o=zv(0);return Fv(()=>{var t=i.current;if(t){var n=()=>{t.scrollHeight-t.scrollTop-t.clientHeight<80?e.userScrolledUp.value&&(e.userScrolledUp.value=!1,e.unreadNewMessagesCount.value=0):e.userScrolledUp.value||(e.userScrolledUp.value=!0)};return t.addEventListener("scroll",n,{passive:!0}),()=>t.removeEventListener("scroll",n)}},[i.current]),Fv(()=>{var t,r,a,l=i.current;if(l){var h=null!==(t=n[n.length-1])&&void 0!==t?t:null;if(h){var u=h.id,c=null!==(a=null===(r=h.content)||void 0===r?void 0:r.length)&&void 0!==a?a:0,d=u!==s.current,v=!d&&"ai"===h.sender_type&&c>o.current;if(d||v)if(s.current=u,o.current=c,d){if("user"===h.sender_type)return l.scrollTop=l.scrollHeight,e.userScrolledUp.value=!1,void(e.unreadNewMessagesCount.value=0);var f=l.scrollHeight-l.scrollTop-l.clientHeight<80;!e.userScrolledUp.value||f?l.scrollTop=l.scrollHeight:"agent"!==h.sender_type&&"ai"!==h.sender_type||(e.unreadNewMessagesCount.value=e.unreadNewMessagesCount.value+1)}else(t=>{var i=t.scrollHeight-t.scrollTop-t.clientHeight<80;e.userScrolledUp.value&&!i||(t.scrollTop=t.scrollHeight)})(l)}}},[n,i.current]),Fv(()=>{if(r){var t=i.current;if(t){var n=t.scrollHeight-t.scrollTop-t.clientHeight<80;e.userScrolledUp.value&&!n||(t.scrollTop=t.scrollHeight)}}},[r,i.current]),{jumpToBottom:()=>{var t=i.current;t&&(t.scrollTop=t.scrollHeight,e.userScrolledUp.value=!1,e.unreadNewMessagesCount.value=0)}}}function tm(t){var{store:e,controller:i}=t,n=zv(null),r=e.messages.value,s=e.channel.value,o=e.agentLastReadAt.value,a=e.isTyping.value,l=e.typingSenderType.value,h=e.typingSender.value,{jumpToBottom:u}=Qp({store:e,scrollRef:n,messages:r,typingActive:a});!function(t){var e,i,n,{store:r,controller:s,messages:o}=t;Fv(()=>{if(r.isOpen.value&&"conversation"===r.currentView.value&&r.channel.value){var t=setTimeout(()=>s.markAsRead(),80);return()=>clearTimeout(t)}},[null!==(i=null===(e=o[o.length-1])||void 0===e?void 0:e.id)&&void 0!==i?i:null,r.isOpen.value,r.currentView.value,null===(n=r.channel.value)||void 0===n?void 0:n.id])}({store:e,controller:i,messages:r});var c=!s&&e.isLoading.value&&0===r.length,d=!!s&&e.isLoading.value&&0===r.length,v=a&&("ai"===l||"agent"===l);return Cv("div",{class:"vt-messages-wrapper",children:[Cv("div",{class:"vt-messages",ref:n,children:c?Cv(Kp,{senderType:!1===i.config.aiMode?"agent":"ai"}):d?Cv(tp,{}):Cv(ev,{children:[r.map(t=>{return Cv(qp,{message:t,controller:i,isReadByAgent:(e=t.created_at,!!o&&new Date(e)<=new Date(o))},t.id);var e}),v&&Cv(Kp,{senderType:l,senderName:h})]})}),Cv(Xp,{count:e.unreadNewMessagesCount.value,visible:e.userScrolledUp.value,onJump:u})]})}function em(t){var e,{store:i,controller:n}=t,r="closed"===(null===(e=i.channel.value)||void 0===e?void 0:e.status);return Cv(ev,{children:[Cv(tm,{store:i,controller:n}),Cv(op,{store:i}),r?Cv(sp,{}):Cv(ap,{store:i,controller:n})]})}function im(t){var{store:e,controller:i}=t,n=e.currentView.value;return Cv("div",{class:"vt-panel vt-opening",children:[Cv(rp,{store:e,controller:i}),Cv("div",{class:"vt-content",children:Cv("list"===n?ip:em,{store:e,controller:i})})]})}var nm="vtilt-chat-font";function rm(t){!function(){if("undefined"!=typeof document&&!document.getElementById(nm)){var t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);var e=document.createElement("link");e.id=nm,e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap",document.head.appendChild(e)}}();var e=document.createElement("div");e.id="vtilt-chat-host",e.style.cssText="all: initial; position: fixed; inset: auto; z-index: 999999; pointer-events: none;",document.body.appendChild(e);var i=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent='\n/* Load Inter so the widget looks like vTilt on every host page. The @import\n sits at the very top of the stylesheet (required by the spec) and only\n fetches the variable-axis subset we need. If the host\'s CSP blocks Google\n Fonts the font-family fallback chain below keeps the widget legible. */\n@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");\n\n:host {\n --vtilt-primary: #7B68EE;\n --vtilt-primary-shadow: rgba(123, 104, 238, 0.4);\n --vtilt-font: "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n --vtilt-radius: 16px;\n --vtilt-text: #000000;\n --vtilt-text-muted: #666666;\n --vtilt-text-subtle: #888888;\n --vtilt-bg: #ffffff;\n --vtilt-bg-list: #FAFAFA;\n --vtilt-border: #E5E5E5;\n --vtilt-border-light: #EEEEEE;\n --vtilt-skeleton: #E8E8EA;\n --vtilt-online: #16A34A;\n\n all: initial;\n font-family: var(--vtilt-font);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: var(--vtilt-text);\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n\nbutton {\n font-family: inherit;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n touch-action: manipulation;\n}\n\n/* =========================================================================\n * Container + bubble + panel\n * ========================================================================= */\n\n/* The host element gets \'all: initial\' inline (set in ChatRoot.tsx) so the\n host page can\'t position or style it. Inline styles win over \':host\' rules\n in the cascade, so the host\'s effective font-family / color end up at the\n UA default — and shadow children inherit from there. We re-establish the\n widget typography on .vt-container (which lives *inside* the shadow tree)\n so every descendant inherits Inter + the themed text color, regardless of\n what the host page or the host element\'s inline reset look like. */\n.vt-container {\n position: fixed;\n bottom: var(--vt-bubble-offset-bottom, 20px);\n /* Pin the container to the bubble\'s intrinsic size so it keeps the\n * same bounding box even after the bubble itself goes display:none on\n * open. Without this the container collapses to 0x0 and the absolutely\n * positioned panel anchors at that zero-size point — which means the\n * opened panel no longer overlaps the bubble\'s last visible footprint\n * for any non-default anchor (e.g. a bubble dragged to the bottom-left\n * with data-position="bottom-right" would see the panel jump 60px away\n * from where the bubble had been). With a fixed container size, the\n * panel\'s [data-panel-anchor] corner always coincides with the matching\n * corner of the bubble, regardless of drag offset. */\n width: 60px;\n height: 60px;\n z-index: 999999;\n font-family: var(--vtilt-font);\n font-size: 14px;\n line-height: 1.4;\n color: var(--vtilt-text);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n.vt-container[data-position="bottom-right"] {\n right: var(--vt-bubble-offset-right, 20px);\n}\n.vt-container[data-position="bottom-left"] {\n left: var(--vt-bubble-offset-left, 20px);\n}\n.vt-container[data-hidden="true"] { display: none; }\n\n.vt-bubble {\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: var(--vtilt-primary);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 16px var(--vtilt-primary-shadow);\n transition: transform 0.15s ease, box-shadow 0.15s ease;\n position: relative;\n border: none;\n}\n.vt-bubble:hover { transform: scale(1.05); box-shadow: 0 6px 20px var(--vtilt-primary-shadow); }\n.vt-bubble:active { transform: scale(0.95); }\n.vt-container[data-open="true"] .vt-bubble { display: none; }\n.vt-container[data-draggable="true"] .vt-bubble:hover,\n.vt-container[data-draggable="true"] .vt-bubble:active { transform: none; }\n\n.vt-bubble-badge {\n display: none;\n position: absolute;\n top: -4px;\n right: -4px;\n background: #E53935;\n color: white;\n font-size: 11px;\n font-weight: 700;\n min-width: 20px;\n height: 20px;\n border-radius: 10px;\n align-items: center;\n justify-content: center;\n padding: 0 6px;\n border: 2px solid white;\n}\n.vt-bubble-badge[data-visible="true"] { display: flex; }\n\n/* Panel position is driven by [data-panel-anchor] on the container.\n * The chat widget recomputes the anchor from the bubble\'s actual viewport\n * position (see usePanelAnchor in ui/ChatRoot.tsx) so the panel always\n * extends into whichever side has more room — even after the bubble has\n * been dragged across the viewport. The default anchor (no attribute) is\n * "bottom-right" so the very first paint, before JS has computed the\n * anchor, matches the most common default position.\n *\n * Per-anchor max-width / max-height are exposed as the CSS variables\n * --vt-panel-max-w and --vt-panel-max-h. JS sets them to the available\n * room from the chosen anchor (capped by the panel\'s intrinsic 380x600\n * design size), so on small or oddly-shaped viewports the panel never\n * overruns the opposite edge. The min(...) wrapper falls back to the\n * original "viewport minus 40px" formula when the variables aren\'t set. */\n.vt-panel {\n display: none;\n flex-direction: column;\n position: absolute;\n bottom: 0;\n right: 0;\n width: 380px;\n height: 600px;\n /* Effective size = min(intrinsic, room-from-anchor, viewport-minus-margin).\n * The viewport term is a backstop: while the chat is open we deliberately\n * freeze the per-anchor variable, so a viewport resize during open could\n * otherwise leave a stale value that overruns the opposite edge. */\n max-width: min(380px, var(--vt-panel-max-w, calc(100vw - 40px)), calc(100vw - 40px));\n max-height: min(600px, var(--vt-panel-max-h, calc(100vh - 40px)), calc(100vh - 40px));\n max-height: min(600px, var(--vt-panel-max-h, calc(100dvh - 40px)), calc(100dvh - 40px));\n background: var(--vtilt-bg);\n border-radius: var(--vtilt-radius);\n box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);\n overflow: hidden;\n}\n.vt-container[data-panel-anchor="bottom-left"] .vt-panel { right: auto; left: 0; }\n.vt-container[data-panel-anchor="top-right"] .vt-panel { bottom: auto; top: 0; }\n.vt-container[data-panel-anchor="top-left"] .vt-panel { bottom: auto; top: 0; right: auto; left: 0; }\n.vt-container[data-open="true"] .vt-panel { display: flex; }\n.vt-container[data-open="true"] .vt-panel.vt-opening {\n animation: vt-open 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;\n /* The animation scales from 0.4 to 1; transform-origin decides which\n * corner of the panel that scale grows from. JS sets --vt-panel-origin\n * to the same corner usePanelAnchor picked for [data-panel-anchor], so\n * the panel always appears to "pop" out of the bubble. The fallback\n * matches the default bottom-right anchor used before JS computes a\n * direction (or in environments where the variable isn\'t set). */\n transform-origin: var(--vt-panel-origin, bottom right);\n}\n\n@keyframes vt-open {\n from { opacity: 0; transform: scale(0.4); }\n to { opacity: 1; transform: scale(1); }\n}\n\n/* =========================================================================\n * Header\n * ========================================================================= */\n\n.vt-header {\n background: var(--vtilt-bg);\n border-bottom: 1px solid var(--vtilt-border);\n padding: 18px 16px;\n padding-top: max(18px, env(safe-area-inset-top, 18px));\n display: flex;\n align-items: center;\n min-height: 60px;\n flex-shrink: 0;\n gap: 12px;\n}\n.vt-header[data-view="list"] {\n justify-content: space-between;\n}\n.vt-header[data-view="conversation"] {\n padding: 12px 16px;\n padding-top: max(12px, env(safe-area-inset-top, 12px));\n}\n\n.vt-header-title { font-weight: 600; font-size: 17px; color: var(--vtilt-text); }\n.vt-header-info { flex: 1; min-width: 0; }\n.vt-header-name { font-weight: 600; font-size: 16px; color: var(--vtilt-text); }\n.vt-header-status {\n font-size: 13px;\n color: var(--vtilt-online);\n display: flex;\n align-items: center;\n gap: 5px;\n margin-top: 1px;\n}\n.vt-header-status::before {\n content: "";\n width: 7px;\n height: 7px;\n background: var(--vtilt-online);\n border-radius: 50%;\n}\n\n.vt-iconbtn {\n background: transparent;\n border: none;\n color: var(--vtilt-text-muted);\n padding: 6px;\n border-radius: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n.vt-iconbtn:hover { color: var(--vtilt-text); background: #F0F0F0; }\n.vt-header-back { margin-left: -6px; }\n.vt-header-close { margin-right: -6px; }\n\n.vt-header-avatar {\n width: 44px;\n height: 44px;\n border-radius: 50%;\n background: var(--vtilt-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: white;\n}\n.vt-header-avatar[data-mode="support"] { background: #DEDEDE; color: #666; }\n\n/* =========================================================================\n * Content area (channel list, conversation)\n * ========================================================================= */\n\n.vt-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n min-height: 0;\n background: var(--vtilt-bg);\n}\n\n/* Channel list ----------------------------------------------------------- */\n\n.vt-list-root {\n flex: 1;\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n}\n\n.vt-list-empty {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 48px 24px;\n text-align: center;\n}\n.vt-list-empty-icon {\n width: 72px;\n height: 72px;\n margin-bottom: 24px;\n background: var(--vtilt-primary);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.vt-list-empty-title {\n font-size: 18px;\n font-weight: 600;\n color: var(--vtilt-text);\n margin-bottom: 12px;\n line-height: 1.4;\n max-width: 280px;\n}\n.vt-list-empty-subtitle {\n font-size: 14px;\n color: var(--vtilt-text-muted);\n margin-bottom: 28px;\n}\n\n.vt-channel-item {\n padding: 14px 16px;\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 12px;\n background: var(--vtilt-bg);\n border: none;\n width: 100%;\n text-align: left;\n border-bottom: 1px solid var(--vtilt-border-light);\n transition: background 0.1s ease;\n font: inherit;\n color: inherit;\n}\n.vt-channel-item:hover { background: #F5F5F5; }\n.vt-channel-item:active { background: #EBEBEB; }\n\n.vt-channel-avatar {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n background: var(--vtilt-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: white;\n}\n.vt-channel-avatar[data-mode="support"] { background: #DEDEDE; color: #666; }\n\n.vt-channel-body { flex: 1; min-width: 0; }\n.vt-channel-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n margin-bottom: 4px;\n}\n.vt-channel-name {\n font-weight: 500;\n font-size: 15px;\n color: var(--vtilt-text);\n line-height: 1.2;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.vt-channel-name[data-unread="true"] { font-weight: 600; }\n.vt-channel-time {\n font-size: 13px;\n color: var(--vtilt-text-subtle);\n white-space: nowrap;\n flex-shrink: 0;\n}\n.vt-channel-preview {\n font-size: 14px;\n color: var(--vtilt-text-subtle);\n font-weight: 400;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n flex: 1;\n min-width: 0;\n line-height: 1.4;\n}\n.vt-channel-preview[data-unread="true"] { color: #333; }\n.vt-channel-unread {\n min-width: 20px;\n height: 20px;\n padding: 0 6px;\n background: var(--vtilt-primary);\n border-radius: 10px;\n flex-shrink: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n font-weight: 600;\n color: #FFFFFF;\n line-height: 1;\n}\n\n.vt-list-footer {\n padding: 16px;\n padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));\n border-top: 1px solid var(--vtilt-border);\n}\n\n.vt-new-channel-btn {\n width: 100%;\n background: var(--vtilt-primary);\n color: white;\n border: none;\n border-radius: 100px;\n padding: 14px 24px;\n font-weight: 500;\n font-size: 15px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n box-shadow: 0 2px 8px var(--vtilt-primary-shadow);\n transition: opacity 0.1s ease;\n}\n.vt-new-channel-btn:hover { opacity: 0.9; }\n.vt-new-channel-btn:active { opacity: 0.8; }\n\n/* Conversation ----------------------------------------------------------- */\n\n.vt-messages-wrapper {\n position: relative;\n flex: 1;\n display: flex;\n flex-direction: column;\n min-height: 0;\n}\n\n.vt-messages {\n flex: 1;\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n padding: 20px 16px 24px 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-height: 0;\n background: var(--vtilt-bg-list);\n}\n\n.vt-message {\n display: flex;\n flex-direction: column;\n animation: vt-message-in 0.22s ease-out both;\n}\n.vt-message[data-direction="in"] { align-items: flex-start; }\n.vt-message[data-direction="out"] { align-items: flex-end; }\n\n.vt-message-row {\n display: flex;\n gap: 10px;\n align-items: flex-end;\n max-width: 85%;\n}\n.vt-message[data-direction="out"] .vt-message-row {\n flex-direction: row-reverse;\n}\n\n.vt-message-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: var(--vtilt-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n color: white;\n}\n.vt-message-avatar[data-mode="support"] { background: #DEDEDE; color: #666; }\n\n.vt-message-bubble {\n padding: 10px 14px;\n background: var(--vtilt-bg);\n border-radius: 20px 20px 20px 4px;\n font-size: 14px;\n line-height: 1.4;\n color: var(--vtilt-text);\n word-wrap: break-word;\n overflow-wrap: anywhere;\n min-width: 0;\n}\n.vt-message[data-direction="out"] .vt-message-bubble {\n background: var(--vtilt-primary);\n color: white;\n border-radius: 20px 20px 4px 20px;\n}\n\n.vt-message-meta {\n font-size: 12px;\n color: var(--vtilt-text-subtle);\n margin-top: 6px;\n}\n.vt-message[data-direction="in"] .vt-message-meta { margin-left: 46px; }\n.vt-message[data-direction="out"] .vt-message-meta { margin-right: 4px; }\n\n.vt-message-retry {\n font: inherit;\n font-size: inherit;\n color: var(--vtilt-error, #dc2626);\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n text-decoration: underline;\n}\n\n@keyframes vt-message-in {\n from { opacity: 0; transform: translateY(4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n\n/* Markdown content rules (parity with chat-message-content.css) */\n.vt-md {\n max-width: 100%;\n overflow-wrap: anywhere;\n word-break: break-word;\n font-size: inherit;\n line-height: 1.45;\n}\n.vt-md p { margin: 0 0 0.5em 0; }\n.vt-md p:last-child { margin-bottom: 0; }\n.vt-md :is(b, strong) { font-weight: 600; }\n.vt-md :is(i, em) { font-style: italic; }\n.vt-md u { text-decoration: underline; }\n.vt-md :is(h1, h2, h3, h4, h5, h6) {\n font-size: 1em;\n font-weight: 600;\n margin: 0.65em 0 0.35em 0;\n line-height: 1.3;\n}\n.vt-md :is(h1, h2, h3):first-child { margin-top: 0.15em; }\n.vt-md :is(ul, ol) {\n list-style: none;\n margin: 0.5em 0;\n padding: 0 0 0 0.35em;\n}\n.vt-md li {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: 0.35em;\n margin: 0.2em 0;\n padding: 0;\n line-height: 1.45;\n}\n.vt-md ul > li::before {\n content: "•";\n display: inline-block;\n flex: 0 0 auto;\n line-height: 1.45;\n}\n.vt-md ul ul > li::before { content: "◦"; }\n.vt-md ol { counter-reset: vt-ol; }\n.vt-md ol > li { counter-increment: vt-ol; }\n.vt-md ol > li::before {\n content: counter(vt-ol) ".";\n display: inline-block;\n flex: 0 0 auto;\n min-width: 1.1em;\n line-height: 1.45;\n}\n.vt-md ol ol { counter-reset: vt-ol; }\n.vt-md li > :is(ul, ol) {\n flex: 1 0 100%;\n width: 100%;\n margin: 0.25em 0 0 0;\n padding-left: 0.75em;\n}\n.vt-md code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 0.9em;\n background: rgba(0, 0, 0, 0.06);\n padding: 0.1em 0.35em;\n border-radius: 4px;\n}\n.vt-md pre {\n margin: 0.5em 0;\n padding: 0.5em 0.65em;\n border-radius: 6px;\n background: rgba(0, 0, 0, 0.06);\n overflow-x: auto;\n white-space: pre-wrap;\n}\n.vt-md pre code { background: none; padding: 0; }\n.vt-md blockquote {\n margin: 0.5em 0;\n padding-left: 0.75em;\n border-left: 3px solid rgba(0, 0, 0, 0.15);\n}\n.vt-md a { color: inherit; text-decoration: underline; }\n\n/* Brand-colored "out" bubble inverts code/pre/quote backdrop. */\n.vt-user-md code { background: rgba(255, 255, 255, 0.2); }\n.vt-user-md pre { background: rgba(255, 255, 255, 0.15); }\n.vt-user-md pre code { background: none; }\n.vt-user-md blockquote { border-left-color: rgba(255, 255, 255, 0.35); }\n\n/* Typing bubble + new-messages pill -------------------------------------\n *\n * The typing indicator is no longer a separate strip above the composer\n * - it is an inline .vt-message rendered as the last child of the\n * message list, reusing the avatar + bubble shape so the dots morph\n * into the real message when it arrives. The only typing-specific\n * style is the [data-typing] modifier that switches the bubble layout\n * to inline-flex so the three dots sit horizontally instead of\n * stacking. The dot animation rules are reused by TypingBubble. */\n\n.vt-message-bubble[data-typing="true"] {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n /* Critical: do NOT override the base .vt-message-bubble padding here.\n * The row uses align-items: flex-end, so a bubble shorter than a\n * single-line text bubble would bottom-align with the avatar and\n * visually sit lower than where the real message will appear. We\n * inherit 10px 14px from the base, then enforce a min content\n * height of one text line (14px font-size * 1.4 line-height) so the\n * total bubble height matches a single-line text bubble exactly.\n * When the dots morph into text the bubble stays put — no jolt. */\n min-height: 1.4em;\n}\n.vt-typing-dot {\n width: 6px;\n height: 6px;\n background: #B5B5B5;\n border-radius: 50%;\n animation: vt-typing-bounce 1.2s infinite;\n}\n.vt-typing-dot:nth-child(2) { animation-delay: 0.2s; }\n.vt-typing-dot:nth-child(3) { animation-delay: 0.4s; }\n@keyframes vt-typing-bounce {\n 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }\n 30% { opacity: 1; transform: translateY(-2px); }\n}\n\n.vt-new-pill {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n bottom: 12px;\n background: var(--vtilt-primary);\n color: white;\n padding: 6px 14px;\n border-radius: 999px;\n font-size: 13px;\n font-weight: 500;\n cursor: pointer;\n border: none;\n box-shadow: 0 2px 8px rgba(0,0,0,0.15);\n display: none;\n align-items: center;\n gap: 6px;\n z-index: 5;\n transition: opacity 0.15s ease;\n}\n.vt-new-pill[data-visible="true"] { display: flex; }\n.vt-new-pill:hover { opacity: 0.92; }\n\n/* Closed banner + connection banner ------------------------------------- */\n\n.vt-closed-banner {\n padding: 12px 16px;\n padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));\n border-top: 1px solid var(--vtilt-border);\n text-align: center;\n background: var(--vtilt-bg-list);\n flex-shrink: 0;\n font-size: 14px;\n color: var(--vtilt-text-subtle);\n}\n\n/* Connection banner.\n *\n * Two visual modes:\n * - data-kind="reconnecting": slim pill. Pulsing dot + "Reconnecting"\n * label. Slate background — informational, not alarming.\n * - data-kind="failed": actionable card. Warning icon + "Connection\n * lost" + Retry button. Red because the user must act.\n */\n.vt-conn-banner {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n border-top: 1px solid var(--vtilt-border);\n font-size: 12px;\n font-weight: 500;\n flex-shrink: 0;\n}\n.vt-conn-banner[data-kind="reconnecting"] {\n background: #F8FAFC;\n color: #475569;\n justify-content: center;\n}\n.vt-conn-banner[data-kind="failed"] {\n background: #FEF2F2;\n color: #991B1B;\n}\n.vt-conn-banner-icon {\n display: inline-flex;\n flex-shrink: 0;\n color: #DC2626;\n}\n.vt-conn-banner-text {\n flex: 1;\n}\n.vt-conn-banner[data-kind="reconnecting"] .vt-conn-banner-text {\n flex: 0 0 auto;\n}\n.vt-conn-banner-dot {\n display: inline-block;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: #F59E0B;\n flex-shrink: 0;\n animation: vt-conn-pulse 1.4s ease-in-out infinite;\n}\n@keyframes vt-conn-pulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.4; transform: scale(0.85); }\n}\n.vt-conn-banner-action {\n appearance: none;\n border: 1px solid #DC2626;\n background: transparent;\n color: #DC2626;\n font: inherit;\n font-weight: 600;\n font-size: 11px;\n padding: 3px 10px;\n border-radius: 999px;\n cursor: pointer;\n flex-shrink: 0;\n transition: background 0.12s ease, color 0.12s ease;\n}\n.vt-conn-banner-action:hover,\n.vt-conn-banner-action:focus-visible {\n background: #DC2626;\n color: #FFFFFF;\n outline: none;\n}\n@media (prefers-reduced-motion: reduce) {\n .vt-conn-banner-dot {\n animation: none;\n }\n}\n\n/* Input ----------------------------------------------------------------- */\n\n.vt-input-container {\n padding: 8px 12px;\n padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));\n border-top: 1px solid var(--vtilt-border);\n flex-shrink: 0;\n background: var(--vtilt-bg);\n}\n.vt-input-box {\n position: relative;\n border: 1px solid #DDD;\n border-radius: 12px;\n background: var(--vtilt-bg);\n transition: border-color 0.15s ease, box-shadow 0.15s ease;\n}\n.vt-input-box:focus-within {\n border-color: var(--vtilt-primary);\n box-shadow: 0 0 0 2px rgba(123, 104, 238, 0.12);\n}\n.vt-input-textarea {\n width: 100%;\n box-sizing: border-box;\n border: none;\n border-radius: 0;\n padding: 12px 48px 12px 12px;\n font-size: 16px;\n line-height: 1.4;\n outline: none;\n background: transparent;\n color: var(--vtilt-text);\n resize: none;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 60px;\n max-height: 120px;\n font-family: inherit;\n}\n.vt-input-textarea::placeholder { color: #999; }\n.vt-input-textarea:disabled { color: #BBB; cursor: not-allowed; }\n\n.vt-input-send {\n position: absolute;\n right: 4px;\n bottom: 4px;\n background: #E5E5E5;\n color: #999;\n border: none;\n border-radius: 50%;\n padding: 0;\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;\n opacity: 0.6;\n}\n.vt-input-send[data-active="true"] {\n background: var(--vtilt-primary);\n color: white;\n cursor: pointer;\n opacity: 1;\n}\n.vt-input-send[data-active="true"]:hover { opacity: 0.9; }\n.vt-input-send[data-active="true"]:active { opacity: 0.8; transform: scale(0.95); }\n.vt-input-send:disabled { cursor: not-allowed; }\n\n.vt-input-container[data-pending="true"] .vt-input-box {\n background: var(--vtilt-bg-list);\n border-color: var(--vtilt-border-light);\n}\n\n/* Skeletons ------------------------------------------------------------- */\n\n@keyframes vt-skeleton-pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.55; }\n}\n.vt-skeleton {\n background: var(--vtilt-skeleton);\n border-radius: 6px;\n animation: vt-skeleton-pulse 2.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n.vt-skeleton-circle {\n background: var(--vtilt-skeleton);\n border-radius: 50%;\n animation: vt-skeleton-pulse 2.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n\n/* Built-in widgets ------------------------------------------------------ */\n\n.vt-widget { margin-top: 10px; }\n.vt-widget p { margin: 0 0 10px 0; font-size: 14px; color: #333; }\n.vt-widget-input {\n font-family: inherit;\n font-size: 14px;\n padding: 8px 10px;\n border: 1px solid #DDD;\n border-radius: 8px;\n width: 100%;\n margin-bottom: 8px;\n}\n.vt-widget-input:focus { outline: none; border-color: var(--vtilt-primary); }\n.vt-widget-btn {\n padding: 10px 16px;\n background: var(--vtilt-primary);\n color: white;\n border: none;\n border-radius: 12px;\n font-size: 14px;\n font-weight: 600;\n cursor: pointer;\n}\n.vt-widget-btn[data-style="outline"] {\n background: transparent;\n color: var(--vtilt-primary);\n border: 2px solid var(--vtilt-primary);\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n.vt-widget-btn:disabled { opacity: 0.6; cursor: not-allowed; }\n.vt-widget-thanks { font-size: 13px; color: var(--vtilt-online); margin: 0; }\n\n/* Mobile fullscreen ----------------------------------------------------\n *\n * On viewports <=480px the open panel covers the whole device, regardless\n * of where the bubble was dragged. The rules live in a media query (not\n * a JS-driven data attribute) so they remain correct on viewport resize\n * — rotation, browser-window resize, devtools toggling — without needing\n * a re-render to update an attribute.\n *\n * "transform: none !important" is required because bubble-drag.ts sets\n * an inline "transform: translate3d(...)" on the container. Per the CSS\n * cascade, author !important declarations win over inline normal styles,\n * so the open panel snaps back to (0, 0) and fills the viewport even\n * after the user has dragged the bubble away from its anchor corner.\n */\n\n@media (max-width: 480px) {\n .vt-bubble { width: 56px; height: 56px; }\n .vt-container { width: 56px; height: 56px; }\n\n .vt-container[data-open="true"] {\n top: 0; left: 0; right: 0; bottom: 0;\n /* Stretch the container from a 56x56 box back to the viewport so the\n * fullscreen panel inside has room to fill the screen. */\n width: auto; height: auto;\n transform: none !important;\n }\n .vt-container[data-open="true"] .vt-panel {\n position: absolute;\n top: 0; left: 0; right: 0; bottom: 0;\n width: 100%;\n max-width: none;\n height: 100%;\n max-height: none;\n border-radius: 0;\n box-shadow: none;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }\n}\n',i.appendChild(n);var r=document.createElement("div");return r.style.cssText="pointer-events: auto;",i.appendChild(r),function(t,e){var i=()=>{var i=e.theme.value;t.style.setProperty("--vtilt-primary",i.primaryColor),t.style.setProperty("--vtilt-primary-shadow",i.primaryColor+"66"),t.style.setProperty("--vtilt-font",i.fontFamily),t.style.setProperty("--vtilt-radius",i.borderRadius)};i(),e.theme.subscribe(i)}(e,t.store),xv(Cv(sm,{store:t.store,controller:t.controller,position:t.position,bubbleDraggable:t.bubbleDraggable}),r),{host:e,destroy(){xv(null,r),e.remove()}}}function sm(t){var{store:e,controller:i,position:n,bubbleDraggable:r}=t,s=zv(null),o=zv(null),a=zv(null),l=function(t,e){return $v(()=>{var i=e.current;if(i&&"undefined"!=typeof window&&!t.isOpen.value){var n=i.getBoundingClientRect();if(0!==n.width&&0!==n.height){var r=window.innerWidth,s=window.innerHeight,o=(n.left+n.right)/2>r/2?"right":"left",a=(n.top+n.bottom)/2>s/2?"bottom":"top",l=a+"-"+o;i.setAttribute("data-panel-anchor",l),i.style.setProperty("--vt-panel-origin",a+" "+o);var h="right"===o?n.right:r-n.left,u="bottom"===a?n.bottom:s-n.top;i.style.setProperty("--vt-panel-max-w",Math.max(0,h-20)+"px"),i.style.setProperty("--vt-panel-max-h",Math.max(0,u-20)+"px")}}},[t,e])}(e,s);return function(t,e){var i=Uv(_v++,4);!Ov.__s&&Zv(i.__H,e)&&(i.__=t,i.u=e,Iv.__h.push(i))}(()=>{if(r&&s.current&&o.current)return a.current=Zf(s.current,{handle:o.current,onPositionChange:l}),()=>{var t;null===(t=a.current)||void 0===t||t.destroy(),a.current=null}},[r,l]),Fv(()=>{l();var t=()=>l();window.addEventListener("resize",t);var i=e.isOpen.subscribe(t=>{t||l()});return()=>{window.removeEventListener("resize",t),i()}},[e,l]),function(t){Fv(()=>{var e=t.isOpen.value,i=t.isOpen.subscribe(t=>{var i,n;if("undefined"!=typeof document){var r=function(t,e,i){return i?e&&!t?{nextWasOpen:!0,shouldLock:!0,shouldUnlock:!1}:!e&&t?{nextWasOpen:!1,shouldLock:!1,shouldUnlock:!0}:{nextWasOpen:e,shouldLock:!1,shouldUnlock:!1}:{nextWasOpen:e,shouldLock:!1,shouldUnlock:!1}}(e,t,"undefined"!=typeof window&&window.innerWidth<=480);e=r.nextWasOpen;var s=document.documentElement,o=document.body;if(r.shouldLock){var a=null!==(i=null===window||void 0===window?void 0:window.scrollY)&&void 0!==i?i:0;s.style.setProperty("overflow","hidden","important"),o.style.setProperty("overflow","hidden","important"),o.style.setProperty("position","fixed","important"),o.style.setProperty("width","100%","important"),o.style.top="-"+a+"px",o.dataset.vtScrollY=String(a)}else if(r.shouldUnlock){var l=Number(null!==(n=o.dataset.vtScrollY)&&void 0!==n?n:0);s.style.removeProperty("overflow"),o.style.removeProperty("overflow"),o.style.removeProperty("position"),o.style.removeProperty("width"),o.style.top="",delete o.dataset.vtScrollY,null===window||void 0===window||window.scrollTo(0,l)}}else e=t});return i},[t])}(e),Cv("div",{ref:s,class:"vt-container","data-position":n,"data-draggable":r?"true":"false","data-hidden":e.isVisible.value?"false":"true","data-open":e.isOpen.value?"true":"false",children:[Cv(Yf,{store:e,controller:i,bubbleRef:o}),Cv(im,{store:e,controller:i})]})}var om=Object.defineProperty,am=Object.defineProperties,lm=Object.getOwnPropertyDescriptors,hm=Object.getOwnPropertySymbols,um=Object.prototype.hasOwnProperty,cm=Object.prototype.propertyIsEnumerable,dm=(t,e,i)=>e in t?om(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,vm=(t,e)=>{for(var i in e||(e={}))um.call(e,i)&&dm(t,i,e[i]);if(hm)for(var i of hm(e))cm.call(e,i)&&dm(t,i,e[i]);return t},fm=(t,e)=>am(t,lm(e)),pm=function(t,e){this[0]=t,this[1]=e},mm=class{},gm="undefined"!=typeof global?global:"undefined"!=typeof window?window:self;function bm(t,e){return(""+t).padStart(e?3:2,"0")}function ym(t){return mm.Config.logTimestamps?function(e){var i=new Date;t(bm(i.getHours())+":"+bm(i.getMinutes())+":"+bm(i.getSeconds())+"."+bm(i.getMilliseconds(),1)+" "+e)}:function(e){t(e)}}var wm=class t{constructor(){this.deprecated=(t,e)=>{this.deprecationWarning(t+" is deprecated and will be removed in a future version. "+e)},this.shouldLog=t=>t<=this.logLevel,this.setLog=(t,e)=>{void 0!==t&&(this.logLevel=t),void 0!==e&&(this.logHandler=this.logErrorHandler=e)},this.logLevel=t.defaultLogLevel,this.logHandler=t.defaultLogHandler,this.logErrorHandler=t.defaultLogErrorHandler}static initLogHandlers(){var e,i,n,[r,s]=("function"==typeof(null==(e=null==gm?void 0:gm.console)?void 0:e.log)?(i=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];console.log.apply(console,e)},n=console.warn?function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];console.warn.apply(console,e)}:i):i=n=function(){},[i,n].map(ym));this.defaultLogHandler=r,this.defaultLogErrorHandler=s,this.defaultLogger=new t}static logActionNoStrip(t,e,i,n){t.logAction(e,i,n)}logAction(t,e,i){this.shouldLog(t)&&(1===t?this.logErrorHandler:this.logHandler)("Ably: "+e+": "+i,t)}renamedClientOption(t,e){this.deprecationWarning("The `"+t+"` client option has been renamed to `"+e+"`. Please update your code to use `"+e+"` instead. `"+t+"` will be removed in a future version.")}renamedMethod(t,e,i){this.deprecationWarning("`"+t+"`’s `"+e+"` method has been renamed to `"+i+"`. Please update your code to use `"+i+"` instead. `"+e+"` will be removed in a future version.")}deprecationWarning(t){this.shouldLog(1)&&this.logErrorHandler("Ably: Deprecation warning - "+t,1)}};wm.defaultLogLevel=1,wm.LOG_NONE=0,wm.LOG_ERROR=1,wm.LOG_MAJOR=2,wm.LOG_MINOR=3,wm.LOG_MICRO=4,wm.logAction=(t,e,i,n)=>{wm.logActionNoStrip(t,e,i,n)};var km=wm,xm={};function Sm(t){var e="["+t.constructor.name;return t.message&&(e+=": "+t.message),t.statusCode&&(e+="; statusCode="+t.statusCode),t.code&&(e+="; code="+t.code),t.cause&&(e+="; cause="+Km(t.cause)),!t.href||t.message&&t.message.indexOf("help.ably.io")>-1||(e+="; see "+t.href+" "),e+="]"}((t,e)=>{for(var i in e)om(t,i,{get:e[i],enumerable:!0})})(xm,{Format:()=>Hm,allSame:()=>Vm,allToLowerCase:()=>og,allToUpperCase:()=>ag,arrChooseN:()=>ig,arrDeleteValue:()=>Lm,arrEquals:()=>pg,arrIntersect:()=>jm,arrIntersectOb:()=>Um,arrPopRandomElement:()=>qm,arrWithoutValue:()=>Fm,cheapRandStr:()=>tg,containsValue:()=>Bm,copy:()=>Am,createMissingPluginError:()=>mg,dataSizeBytes:()=>Qm,decodeBody:()=>rg,encodeBody:()=>sg,ensureArray:()=>Tm,forInOwnNonNullProperties:()=>$m,getBackoffCoefficient:()=>lg,getGlobalObject:()=>cg,getJitterCoefficient:()=>hg,getRetryTime:()=>ug,inherits:()=>Pm,inspectBody:()=>Xm,inspectError:()=>Km,intersect:()=>Dm,isEmpty:()=>Mm,isErrorInfoOrPartialErrorInfo:()=>Ym,isNil:()=>Om,isObject:()=>Em,keysArray:()=>zm,listenerToAsyncIterator:()=>wg,matchDerivedChannel:()=>vg,mixin:()=>Im,parseQueryString:()=>Zm,prototypicalClone:()=>Nm,randomString:()=>eg,shallowClone:()=>Rm,shallowEquals:()=>dg,stringifyValues:()=>Gm,throwMissingPluginError:()=>gg,toBase64:()=>fg,toQueryString:()=>Jm,valuesArray:()=>Wm,whenPromiseSettles:()=>ng,withTimeoutAsync:()=>bg});var Cm=class t extends Error{constructor(e,i,n,r){super(e),void 0!==Object.setPrototypeOf&&Object.setPrototypeOf(this,t.prototype),this.code=i,this.statusCode=n,this.cause=r}toString(){return Sm(this)}static fromValues(e){var{message:i,code:n,statusCode:r}=e;if("string"!=typeof i||"number"!=typeof n||"number"!=typeof r)throw new Error("ErrorInfo.fromValues(): invalid values: "+mm.Config.inspect(e));var s=Object.assign(new t(i,n,r),e);return s.code&&!s.href&&(s.href="https://help.ably.io/error/"+s.code),s}},_m=class t extends Error{constructor(e,i,n,r){super(e),void 0!==Object.setPrototypeOf&&Object.setPrototypeOf(this,t.prototype),this.code=i,this.statusCode=n,this.cause=r}toString(){return Sm(this)}static fromValues(e){var{message:i,code:n,statusCode:r}=e;if("string"!=typeof i||!Om(n)&&"number"!=typeof n||!Om(r)&&"number"!=typeof r)throw new Error("PartialErrorInfo.fromValues(): invalid values: "+mm.Config.inspect(e));var s=Object.assign(new t(i,n,r),e);return s.code&&!s.href&&(s.href="https://help.ably.io/error/"+s.code),s}};function Im(t){for(var e=0;e<(arguments.length<=1?0:arguments.length-1);e++){var i=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];if(!i)break;for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}function Am(t){return Im({},t)}function Tm(t){return Om(t)?[]:Array.isArray(t)?t:[t]}function Em(t){return"[object Object]"==Object.prototype.toString.call(t)}function Mm(t){for(var e in t)return!1;return!0}function Om(t){return null==t}function Rm(t){var e=new Object;for(var i in t)e[i]=t[i];return e}function Nm(t,e){class i{}i.prototype=t;var n=new i;return e&&Im(n,e),n}var Pm=function(t,e){mm.Config.inherits?mm.Config.inherits(t,e):(t.super_=e,t.prototype=Nm(e.prototype,{constructor:t}))};function Bm(t,e){for(var i in t)if(t[i]==e)return!0;return!1}function Dm(t,e){return Array.isArray(e)?jm(t,e):Um(t,e)}function jm(t,e){for(var i=[],n=0;n<t.length;n++){var r=t[n];-1!=e.indexOf(r)&&i.push(r)}return i}function Um(t,e){for(var i=[],n=0;n<t.length;n++){var r=t[n];r in e&&i.push(r)}return i}function Lm(t,e){var i=t.indexOf(e),n=-1!=i;return n&&t.splice(i,1),n}function Fm(t,e){var i=t.slice();return Lm(i,e),i}function zm(t,e){var i=[];for(var n in t)e&&!Object.prototype.hasOwnProperty.call(t,n)||i.push(n);return i}function Wm(t,e){var i=[];for(var n in t)e&&!Object.prototype.hasOwnProperty.call(t,n)||i.push(t[n]);return i}function $m(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&t[i]&&e(i)}function Vm(t,e){if(0===t.length)return!0;var i=t[0][e];return t.every(function(t){return t[e]===i})}var Hm=(t=>(t.msgpack="msgpack",t.json="json",t))(Hm||{});function qm(t){return t.splice((e=t,Math.floor(Math.random()*e.length)),1)[0];var e}function Jm(t){var e=[];if(t)for(var i in t)e.push(encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return e.length?"?"+e.join("&"):""}function Gm(t){return Object.fromEntries(Object.entries(t).map(t=>{var[e,i]=t;return[e,String(i)]}))}function Zm(t){for(var e,i=/([^?&=]+)=?([^&]*)/g,n={};e=i.exec(t);)n[decodeURIComponent(e[1])]=decodeURIComponent(e[2]);return n}function Ym(t){return"object"==typeof t&&null!==t&&(t instanceof Cm||t instanceof _m)}function Km(t){var e,i;return t instanceof Error||"ErrorInfo"===(null==(e=null==t?void 0:t.constructor)?void 0:e.name)||"PartialErrorInfo"===(null==(i=null==t?void 0:t.constructor)?void 0:i.name)?t.toString():mm.Config.inspect(t)}function Xm(t){return mm.BufferUtils.isBuffer(t)?t.toString():"string"==typeof t?t:mm.Config.inspect(t)}function Qm(t){if(mm.BufferUtils.isBuffer(t))return mm.BufferUtils.byteLength(t);if("string"==typeof t)return mm.Config.stringByteSize(t);if("number"==typeof t)return 8;if("boolean"==typeof t)return 1;throw new Error("Expected input of Utils.dataSizeBytes to be a string, a number, a boolean or a buffer, but was: "+typeof t)}function tg(){return String(Math.random()).substr(2)}var eg=function(){var t=e(function*(t){var e=yield mm.Config.getRandomArrayBuffer(t);return mm.BufferUtils.base64Encode(e)});return function(e){return t.apply(this,arguments)}}();function ig(t,e){for(var i=Math.min(e,t.length),n=t.slice(),r=[],s=0;s<i;s++)r.push(qm(n));return r}function ng(t,e){t.then(t=>{null==e||e(null,t)}).catch(t=>{null==e||e(t)})}function rg(t,e,i){return"msgpack"==i?(e||gg("MsgPack"),e.decode(t)):JSON.parse(String(t))}function sg(t,e,i){return"msgpack"==i?(e||gg("MsgPack"),e.encode(t,!0)):JSON.stringify(t)}function og(t){return t.map(function(t){return t&&t.toLowerCase()})}function ag(t){return t.map(function(t){return t&&t.toUpperCase()})}function lg(t){return Math.min((t+2)/3,2)}function hg(){return 1-.2*Math.random()}function ug(t,e){return t*lg(e)*hg()}function cg(){return"undefined"!=typeof global?global:"undefined"!=typeof window?window:self}function dg(t,e){return Object.keys(t).every(i=>t[i]===e[i])&&Object.keys(e).every(i=>e[i]===t[i])}function vg(t){var e=t.match(/^(\[([^?]*)(?:(.*))\])?(.+)$/);if(!e||!e.length||e.length<5)throw new Cm("regex match failed",400,40010);if(e[2])throw new Cm("cannot use a derived option with a "+e[2]+" channel",400,40010);return{qualifierParam:e[3]||"",channelName:e[4]}}function fg(t){var e=mm.BufferUtils,i=e.utf8Encode(t);return e.base64Encode(i)}function pg(t,e){return t.length===e.length&&t.every(function(t,i){return t===e[i]})}function mg(t){return new Cm(t+" plugin not provided",40019,400)}function gg(t){throw mg(t)}function bg(t,e,i){return yg.apply(this,arguments)}function yg(){return yg=e(function*(t,e,i){void 0===e&&(e=5e3),void 0===i&&(i="Timeout expired");var n=new Cm(i,5e4,500);return Promise.race([t,new Promise((t,i)=>setTimeout(()=>i(n),e))])}),yg.apply(this,arguments)}function wg(t){return e=this,i=null,n=function*(){var e=[],i=null,n=t(t=>{if(i){var n=i;i=null,n(t)}else e.push(t)});try{for(;;)if(e.length>0)yield e.shift();else{if(i)throw new Cm("Concurrent next() calls are not supported",4e4,400);var r=yield new pm(new Promise(t=>{i=t}));yield r}}finally{n()}},r=(t,e,i,s)=>{try{var o=n[t](e),a=(e=o.value)instanceof pm,l=o.done;Promise.resolve(a?e[0]:e).then(n=>a?r("return"===t?t:"next",e[1]?{done:n.done,value:n.value}:n,i,s):i({value:n,done:l})).catch(t=>r("throw",t,i,s))}catch(t){s(t)}},s=t=>o[t]=e=>new Promise((i,n)=>r(t,e,i,n)),o={},n=n.apply(e,i),o[Symbol.asyncIterator]=()=>o,s("next"),s("throw"),s("return"),o;var e,i,n,r,s,o}var kg="2.17.0",xg={ENDPOINT:"main",ENVIRONMENT:"",REST_HOST:"rest.ably.io",REALTIME_HOST:"realtime.ably.io",FALLBACK_HOSTS:["main.a.fallback.ably-realtime.com","main.b.fallback.ably-realtime.com","main.c.fallback.ably-realtime.com","main.d.fallback.ably-realtime.com","main.e.fallback.ably-realtime.com"],PORT:80,TLS_PORT:443,TIMEOUTS:{disconnectedRetryTimeout:15e3,suspendedRetryTimeout:3e4,httpRequestTimeout:1e4,httpMaxRetryDuration:15e3,channelRetryTimeout:15e3,fallbackRetryTimeout:6e5,connectionStateTtl:12e4,realtimeRequestTimeout:1e4,recvTimeout:9e4,webSocketConnectTimeout:1e4,webSocketSlowTimeout:4e3},httpMaxRetryCount:3,maxMessageSize:65536,version:kg,protocolVersion:5,agent:"ably-js/"+kg,getPort:function(t,e){return e||t.tls?t.tlsPort:t.port},getHttpScheme:function(t){return t.tls?"https://":"http://"},getPrimaryDomainFromEndpoint:Cg,getEndpointFallbackHosts:_g,getFallbackHosts:Ag,getHosts:function(t){return[t.primaryDomain].concat(Ag(t))},checkHost:Tg,objectifyOptions:function(t,e,i,n,r){if(void 0===t){var s=e?i+" must be initialized with either a client options object, an Ably API key, or an Ably Token":i+" must be initialized with a client options object";throw km.logAction(n,km.LOG_ERROR,i+"()",s),new Error(s)}var o;if("string"==typeof t)if(-1==t.indexOf(":")){if(!e){var a=i+" cannot be initialized with just an Ably Token; you must provide a client options object with a `plugins` property. (Set this Ably Token as the object’s `token` property.)";throw km.logAction(n,km.LOG_ERROR,i+"()",a),new Error(a)}o={token:t}}else{if(!e){var l=i+" cannot be initialized with just an Ably API key; you must provide a client options object with a `plugins` property. (Set this Ably API key as the object’s `key` property.)";throw km.logAction(n,km.LOG_ERROR,i+"()",l),new Error(l)}o={key:t}}else o=t;r&&(o=fm(vm({},o),{plugins:vm(vm({},r),o.plugins)}));return o},normaliseOptions:function(t,e,i){var n=null!=i?i:km.defaultLogger;t.environment&&n.deprecated("The `environment` client option","Use the `endpoint` client option instead.");t.restHost&&n.deprecated("The `restHost` client option","Use the `endpoint` client option instead.");t.realtimeHost&&n.deprecated("The `realtimeHost` client option","Use the `endpoint` client option instead.");Mg(t),"function"==typeof t.recover&&!0===t.closeOnUnload&&(km.logAction(n,km.LOG_ERROR,"Defaults.normaliseOptions","closeOnUnload was true and a session recovery function was set - these are mutually exclusive, so unsetting the latter"),t.recover=void 0);"closeOnUnload"in t||(t.closeOnUnload=!t.recover);"queueMessages"in t||(t.queueMessages=!0);var r=t.endpoint||xg.ENDPOINT;t.fallbackHosts||t.restHost||t.realtimeHost||t.port||t.tlsPort||(t.fallbackHosts=_g(t.environment||r));var s=t.environment&&t.environment+".realtime.ably.net",o=t.restHost||t.realtimeHost||s||Cg(r);(t.fallbackHosts||[]).concat(o).forEach(Tg),t.port=t.port||xg.PORT,t.tlsPort=t.tlsPort||xg.TLS_PORT,"tls"in t||(t.tls=!0);var a=function(t){var e={};for(var i in xg.TIMEOUTS)e[i]=t[i]||xg.TIMEOUTS[i];return e}(t);t.useBinaryProtocol=!!e&&("useBinaryProtocol"in t?mm.Config.supportsBinary&&t.useBinaryProtocol:mm.Config.preferBinary);var l={};t.clientId&&(l["X-Ably-ClientId"]=mm.BufferUtils.base64Encode(mm.BufferUtils.utf8Encode(t.clientId)));"idempotentRestPublishing"in t||(t.idempotentRestPublishing=!0);var h=null,u=t.connectivityCheckUrl;if(t.connectivityCheckUrl){var[c,d]=t.connectivityCheckUrl.split("?");h=d?Zm(d):{},-1===c.indexOf("://")&&(c="https://"+c),u=c}var v=t.wsConnectivityCheckUrl;v&&-1===v.indexOf("://")&&(v="wss://"+v);return fm(vm({},t),{primaryDomain:o,maxMessageSize:t.maxMessageSize||xg.maxMessageSize,timeouts:a,connectivityCheckParams:h,connectivityCheckUrl:u,wsConnectivityCheckUrl:v,headers:l})},defaultGetHeaders:function(t,e){var{format:i,protocolVersion:n=Ng.protocolVersion}=void 0===e?{}:e;return{accept:Rg[null!=i?i:t.useBinaryProtocol?"msgpack":"json"],"X-Ably-Version":n.toString(),"Ably-Agent":Eg(t)}},defaultPostHeaders:function(t,e){var{format:i,protocolVersion:n=Ng.protocolVersion}=void 0===e?{}:e,r=Rg[null!=i?i:t.useBinaryProtocol?"msgpack":"json"];return{accept:r,"content-type":r,"X-Ably-Version":n.toString(),"Ably-Agent":Eg(t)}}};function Sg(t){return t.includes(".")||t.includes("::")||"localhost"===t}function Cg(t){return Sg(t)?t:t.startsWith("nonprod:")?t.replace("nonprod:","")+".realtime.ably-nonprod.net":t+".realtime.ably.net"}function _g(t){return Sg(t)?[]:t.startsWith("nonprod:")?Ig(t.replace("nonprod:",""),"ably-realtime-nonprod.com"):Ig(t,"ably-realtime.com")}function Ig(t,e){return["a","b","c","d","e"].map(i=>t+"."+i+".fallback."+e)}function Ag(t){var e=t.fallbackHosts,i=void 0!==t.httpMaxRetryCount?t.httpMaxRetryCount:xg.httpMaxRetryCount;return e?ig(e,i):[]}function Tg(t){if("string"!=typeof t)throw new Cm("host must be a string; was a "+typeof t,4e4,400);if(!t.length)throw new Cm("host must not be zero-length",4e4,400)}function Eg(t){var e=xg.agent;if(t.agents)for(var i in t.agents)e+=" "+i+"/"+t.agents[i];return e}function Mg(t){if(t.endpoint&&(t.environment||t.restHost||t.realtimeHost))throw new Cm("The `endpoint` option cannot be used in conjunction with the `environment`, `restHost`, or `realtimeHost` options.",40106,400);if(t.environment&&(t.restHost||t.realtimeHost))throw new Cm("The `environment` option cannot be used in conjunction with the `restHost`, or `realtimeHost` options.",40106,400)}function Og(t,e,i){var n=i||{};if(n.cipher){t||gg("Crypto");var r=t.getCipher(n.cipher,e);n.cipher=r.cipherParams,n.channelCipher=r.cipher}else"cipher"in n&&(n.cipher=void 0,n.channelCipher=null);return n}var Rg={json:"application/json",xml:"application/xml",html:"text/html",msgpack:"application/x-msgpack",text:"text/plain"},Ng={protocolVersion:xg.protocolVersion};var Pg=xg;var Bg=class t{constructor(t,e){this.logger=t,this.members=e||[]}call(t,e){for(var i of this.members)if(i)try{i(t,e)}catch(t){km.logAction(this.logger,km.LOG_ERROR,"Multicaster multiple callback handler","Unexpected exception: "+t+"; stack = "+t.stack)}}push(){this.members.push(...arguments)}createPromise(){return new Promise((t,e)=>{this.push((i,n)=>{i?e(i):t(n)})})}resolveAll(t){this.call(null,t)}rejectAll(t){this.call(t)}static create(e,i){var n=new t(e,i);return Object.assign((t,e)=>n.call(t,e),{push:t=>n.push(t),createPromise:()=>n.createPromise(),resolveAll:t=>n.resolveAll(t),rejectAll:t=>n.rejectAll(t)})}},Dg=(t=>(t.Get="get",t.Delete="delete",t.Post="post",t.Put="put",t.Patch="patch",t))(Dg||{}),jg=Dg,Ug=(t=>(t[t.Success=200]="Success",t[t.NoContent=204]="NoContent",t[t.BadRequest=400]="BadRequest",t[t.Unauthorized=401]="Unauthorized",t[t.Forbidden=403]="Forbidden",t[t.RequestTimeout=408]="RequestTimeout",t[t.InternalServerError=500]="InternalServerError",t))(Ug||{});var Lg=Ug,Fg=Math.pow(2,17);function zg(t){return Ym(t)?(t.code||(403===t.statusCode?t.code=40300:(t.code=40170,t.statusCode=401)),t):new Cm(Km(t),t.code||40170,t.statusCode||401)}function Wg(t){if(!t)return"";"string"==typeof t&&(t=JSON.parse(t));var e=Object.create(null),i=zm(t,!0);if(!i)return"";i.sort();for(var n=0;n<i.length;n++)e[i[n]]=t[i[n]].sort();return JSON.stringify(e)}function $g(t,e){if(t.authCallback);else if(t.authUrl);else if(t.key);else if(!t.tokenDetails){var i="authOptions must include valid authentication parameters";throw km.logAction(e,km.LOG_ERROR,"Auth()",i),new Error(i)}}var Vg=0;var Hg=class{constructor(t,e){if(this.authOptions={},this.client=t,this.tokenParams=e.defaultTokenParams||{},this.currentTokenRequestId=null,this.waitingForTokenRequest=null,function(t){return t.useTokenAuth||!function(t){return"useTokenAuth"in t&&!t.useTokenAuth}(t)&&(t.authCallback||t.authUrl||t.token||t.tokenDetails)}(e))(function(t){return!t.key&&!t.authCallback&&!t.authUrl})(e)&&km.logAction(this.logger,km.LOG_ERROR,"Auth()","Warning: library initialized with a token literal without any way to renew the token when it expires (no authUrl, authCallback, or key). See https://help.ably.io/error/40171 for help"),this.Et(e.defaultTokenParams,e),$g(this.authOptions,this.logger);else{if(!e.key){var i="No authentication options provided; need one of: key, authUrl, or authCallback (or for testing only, token or tokenDetails)";throw km.logAction(this.logger,km.LOG_ERROR,"Auth()",i),new Cm(i,40160,401)}this.Mt(e)}}get logger(){return this.client.logger}authorize(t,i){var n=this;return e(function*(){if(i&&i.key&&n.authOptions.key!==i.key)throw new Cm("Unable to update auth options with incompatible key",40102,401);try{var e=yield n.Ot(null!=t?t:null,null!=i?i:null);return n.client.connection?new Promise((t,i)=>{n.client.connection.connectionManager.onAuthUpdated(e,(e,n)=>e?i(e):t(n))}):e}catch(t){throw n.client.connection&&t.statusCode===Lg.Forbidden&&n.client.connection.connectionManager.actOnErrorFromAuthorize(t),t}})()}Ot(t,i){var n=this;return e(function*(){n.tokenDetails=null,n.Et(t,i),$g(n.authOptions,n.logger);try{return n.Rt(!0)}finally{delete n.tokenParams.timestamp,delete n.authOptions.queryTime}})()}requestToken(t,i){var n=this;return e(function*(){var e,r=i||n.authOptions,s=t||Am(n.tokenParams),o=n.client;if(r.authCallback)e=r.authCallback;else if(r.authUrl)e=(t,e)=>{var i,s=Im({accept:"application/json, text/plain"},r.authHeaders),o=r.authMethod&&"post"===r.authMethod.toLowerCase(),a=r.authUrl.indexOf("?");a>-1&&(i=Zm(r.authUrl.slice(a)),r.authUrl=r.authUrl.slice(0,a),o||(r.authParams=Im(i,r.authParams)));var l=Im({},r.authParams||{},t),h=t=>{var i,n,r=null!=(i=t.body)?i:null,s=null;if(t.error);else{var o=null!=(n=t.headers["content-type"])?n:null;s=Array.isArray(o)?o.join(", "):o}if(t.error)e(t.error,null);else if(t.unpacked)e(null,r);else if(mm.BufferUtils.isBuffer(r)&&(r=r.toString()),s){var a=s.indexOf("application/json")>-1,l=s.indexOf("text/plain")>-1||s.indexOf("application/jwt")>-1;if(a||l){if(a){if(r.length>Fg)return void e(new Cm("authUrl response exceeded max permitted length",40170,401),null);try{r=JSON.parse(r)}catch(t){return void e(new Cm("Unexpected error processing authURL response; err = "+t.message,40170,401),null)}}e(null,r,s)}else e(new Cm("authUrl responded with unacceptable content-type "+s+", should be either text/plain, application/jwt or application/json",40170,401),null)}else e(new Cm("authUrl response is missing a content-type header",40170,401),null)};if(o){var u=s||{};u["content-type"]="application/x-www-form-urlencoded";var c=Jm(l).slice(1);ng(n.client.http.doUri(jg.Post,r.authUrl,u,c,i),(t,e)=>h(t||e))}else ng(n.client.http.doUri(jg.Get,r.authUrl,s||{},null,l),(t,e)=>h(t||e))};else{if(!r.key){throw km.logAction(n.logger,km.LOG_ERROR,"Auth()","library initialized with a token literal without any way to renew the token when it expires (no authUrl, authCallback, or key). See https://help.ably.io/error/40171 for help"),new Cm("Need a new token, but authOptions does not include any way to request one (no authUrl, authCallback, or key)",40171,403)}e=(t,e)=>{ng(n.createTokenRequest(t,r),(t,i)=>e(t,null!=i?i:null))}}"capability"in s&&(s.capability=Wg(s.capability));return new Promise((t,i)=>{var a=!1,l=n.client.options.timeouts.realtimeRequestTimeout,h=setTimeout(()=>{a=!0;var t="Token request callback timed out after "+l/1e3+" seconds";km.logAction(n.logger,km.LOG_ERROR,"Auth.requestToken()",t),i(new Cm(t,40170,401))},l);e(s,(e,s,l)=>{if(!a){if(clearTimeout(h),e)return km.logAction(n.logger,km.LOG_ERROR,"Auth.requestToken()","token request signing call returned error; err = "+Km(e)),void i(zg(e));if("string"!=typeof s){if("object"!=typeof s||null===s){var u="Expected token request callback to call back with a token string or token request/details object, but got a "+typeof s;return km.logAction(n.logger,km.LOG_ERROR,"Auth.requestToken()",u),void i(new Cm(u,40170,401))}var c=JSON.stringify(s).length;if(c>Fg&&!r.suppressMaxLengthCheck)i(new Cm("Token request/details object exceeded max permitted stringified size (was "+c+" bytes)",40170,401));else if("issued"in s)t(s);else{if(!("keyName"in s)){var d="Expected token request callback to call back with a token string, token request object, or token details object";return km.logAction(n.logger,km.LOG_ERROR,"Auth.requestToken()",d),void i(new Cm(d,40170,401))}var v,f,p,m;f=(e,r,s)=>{if(e)return km.logAction(n.logger,km.LOG_ERROR,"Auth.requestToken()","token request API call returned error; err = "+Km(e)),void i(zg(e));s||(r=JSON.parse(r)),t(r)},p="/keys/"+(v=s).keyName+"/requestToken",m=Pg.defaultPostHeaders(n.client.options,{format:"json"}),r.requestHeaders&&Im(m,r.requestHeaders),ng(n.client.http.do(jg.Post,function(t){return o.baseUri(t)+p},m,JSON.stringify(v),null),(t,e)=>t?f(t):f(e.error,e.body,e.unpacked))}}else 0===s.length?i(new Cm("Token string is empty",40170,401)):s.length>Fg?i(new Cm("Token string exceeded max permitted length (was "+s.length+" bytes)",40170,401)):"undefined"===s||"null"===s?i(new Cm("Token string was literal null/undefined",40170,401)):"{"!==s[0]||l&&l.indexOf("application/jwt")>-1?t({token:s}):i(new Cm("Token was double-encoded; make sure you're not JSON-encoding an already encoded token request or details",40170,401))}})})})()}createTokenRequest(t,i){var n=this;return e(function*(){i=i||n.authOptions,t=t||Am(n.tokenParams);var e=i.key;if(!e)throw new Cm("No key specified",40101,403);var r=e.split(":"),s=r[0],o=r[1];if(!o)throw new Cm("Invalid key specified",40101,403);if(""===t.clientId)throw new Cm("clientId can’t be an empty string",40012,400);"capability"in t&&(t.capability=Wg(t.capability));var a=Im({keyName:s},t),l=t.clientId||"",h=t.ttl||"",u=t.capability||"";a.timestamp||(a.timestamp=yield n.Nt(i&&i.queryTime));var c=a.nonce||(a.nonce=("000000"+Math.floor(1e16*Math.random())).slice(-16)),d=a.timestamp,v=a.keyName+"\n"+h+"\n"+u+"\n"+l+"\n"+d+"\n"+c+"\n";return a.mac=a.mac||((t,e)=>{var i=mm.BufferUtils,n=i.utf8Encode(t),r=i.utf8Encode(e),s=i.hmacSha256(n,r);return i.base64Encode(s)})(v,o),a})()}getAuthParams(){var t=this;return e(function*(){if("basic"==t.method)return{key:t.key};var e=yield t.Rt(!1);if(!e)throw new Error("Auth.getAuthParams(): _ensureValidAuthCredentials returned no error or tokenDetails");return{access_token:e.token}})()}getAuthHeaders(){var t=this;return e(function*(){if("basic"==t.method)return{authorization:"Basic "+t.basicKey};var e=yield t.Rt(!1);if(!e)throw new Error("Auth.getAuthParams(): _ensureValidAuthCredentials returned no error or tokenDetails");return{authorization:"Bearer "+fg(e.token)}})()}Mt(t){this.method="basic",this.key=t.key,this.basicKey=fg(t.key),this.authOptions=t||{},"clientId"in t&&this.Pt(t.clientId)}Et(t,e){this.method="token",t&&(this.tokenParams=t),e&&(e.token&&(e.tokenDetails="string"==typeof e.token?{token:e.token}:e.token),e.tokenDetails&&(this.tokenDetails=e.tokenDetails),"clientId"in e&&this.Pt(e.clientId),this.authOptions=e)}Rt(t){var i=this;return e(function*(){var e=i.tokenDetails;if(e){if(i.Bt(e.clientId))throw new Cm("Mismatch between clientId in token ("+e.clientId+") and current clientId ("+i.clientId+")",40102,403);if(!i.client.isTimeOffsetSet()||!e.expires||e.expires>=i.client.getTimestampUsingOffset())return e;i.tokenDetails=null}var n=(i.waitingForTokenRequest||(i.waitingForTokenRequest=Bg.create(i.logger))).createPromise();if(null!==i.currentTokenRequestId&&!t)return n;var r,s=i.currentTokenRequestId=Vg++,o=null;try{r=yield i.requestToken(i.tokenParams,i.authOptions)}catch(t){o=t}if(i.currentTokenRequestId>s)return n;i.currentTokenRequestId=null;var a=i.waitingForTokenRequest;return i.waitingForTokenRequest=null,o?(null==a||a.rejectAll(o),n):(null==a||a.resolveAll(i.tokenDetails=r),n)})()}Pt(t){if("string"!=typeof t&&null!==t)throw new Cm("clientId must be either a string or null",40012,400);if("*"===t)throw new Cm('Can’t use "*" as a clientId as that string is reserved. (To change the default token request behaviour to use a wildcard clientId, instantiate the library with {defaultTokenParams: {clientId: "*"}}), or if calling authorize(), pass it in as a tokenParam: authorize({clientId: "*"}, authOptions)',40012,400);var e=this.Dt(t);if(e)throw e}Dt(t){if(this.Bt(t)){var e="Unexpected clientId mismatch: client has "+this.clientId+", requested "+t,i=new Cm(e,40102,401);return km.logAction(this.logger,km.LOG_ERROR,"Auth._uncheckedSetClientId()",e),i}return this.clientId=this.tokenParams.clientId=t,null}Bt(t){return!(!this.clientId||"*"===this.clientId||!t||"*"===t||this.clientId===t)}static isTokenErr(t){return t.code&&t.code>=40140&&t.code<40150}revokeTokens(t,e){return this.client.rest.revokeTokens(t,e)}Nt(t){var i=this;return e(function*(){return i.client.getTimestamp(t||!!i.authOptions.queryTime)})()}};function qg(t){var e=[];if(t)for(var i in t)e.push(i+"="+t[i]);return e.join("&")}function Jg(t,e){return t+(e?"?":"")+qg(e)}var Gg=class{constructor(t){this.client=t,this.platformHttp=new mm.Http(t),this.checkConnectivity=this.platformHttp.checkConnectivity?()=>this.platformHttp.checkConnectivity():void 0}get logger(){var t,e;return null!=(e=null==(t=this.client)?void 0:t.logger)?e:km.defaultLogger}get supportsAuthHeaders(){return this.platformHttp.supportsAuthHeaders}get supportsLinkHeaders(){return this.platformHttp.supportsLinkHeaders}jt(t){var e=t.connection,i=e&&e.connectionManager.host;return i?[i].concat(Pg.getFallbackHosts(t.options)):Pg.getHosts(t.options)}do(t,i,n,r,s){var o=this;return e(function*(){try{var a=o.client;if(!a)return{error:new Cm("http.do called without client",5e4,500)};var l="function"==typeof i?i:function(t){return a.baseUri(t)+i},h=a.Ut;if(h){if(h.validUntil>Date.now()){var u=yield o.doUri(t,l(h.host),n,r,s);return u.error&&o.platformHttp.shouldFallback(u.error)?(a.Ut=null,o.do(t,i,n,r,s)):u}a.Ut=null}var c=o.jt(a);if(1===c.length)return o.doUri(t,l(c[0]),n,r,s);var d=null,v=function(){var i=e(function*(e,i){var h=e.shift();d=null!=d?d:new Date;var u=yield o.doUri(t,l(h),n,r,s);return u.error&&o.platformHttp.shouldFallback(u.error)&&e.length?Date.now()-d.getTime()>a.options.timeouts.httpMaxRetryDuration?{error:new Cm("Timeout for trying fallback hosts retries. Total elapsed time exceeded the "+a.options.timeouts.httpMaxRetryDuration+"ms limit",50003,500)}:v(e,!0):(i&&(a.Ut={host:h,validUntil:Date.now()+a.options.timeouts.fallbackRetryTimeout}),u)});return function(t,e){return i.apply(this,arguments)}}();return v(c)}catch(t){return{error:new Cm("Unexpected error in Http.do: "+Km(t),500,5e4)}}})()}doUri(t,i,n,r,s){var o=this;return e(function*(){try{!function(t,e,i,n,r){r.shouldLog(km.LOG_MICRO)&&km.logActionNoStrip(r,km.LOG_MICRO,"Http."+t+"()","Sending; "+Jg(e,n)+"; Body"+(mm.BufferUtils.isBuffer(i)?" (Base64): "+mm.BufferUtils.base64Encode(i):": "+i))}(t,i,r,s,o.logger);var e=yield o.platformHttp.doUri(t,i,n,r,s);return o.logger.shouldLog(km.LOG_MICRO)&&function(t,e,i,n,r){t.error?km.logActionNoStrip(r,km.LOG_MICRO,"Http."+e+"()","Received Error; "+Jg(i,n)+"; Error: "+Km(t.error)):km.logActionNoStrip(r,km.LOG_MICRO,"Http."+e+"()","Received; "+Jg(i,n)+"; Headers: "+qg(t.headers)+"; StatusCode: "+t.statusCode+"; Body"+(mm.BufferUtils.isBuffer(t.body)?" (Base64): "+mm.BufferUtils.base64Encode(t.body):": "+t.body))}(e,t,i,s,o.logger),e}catch(t){return{error:new Cm("Unexpected error in Http.doUri: "+Km(t),500,5e4)}}})()}};function Zg(t,e,i){for(var n,r,s,o=0;o<t.length;o++)if(n=t[o],i&&(n=n[i]),Array.isArray(n)){for(;-1!==(r=n.indexOf(e));)n.splice(r,1);i&&0===n.length&&delete t[o][i]}else if(Em(n))for(s in n)Object.prototype.hasOwnProperty.call(n,s)&&Array.isArray(n[s])&&Zg([n],e,s)}var Yg=class{constructor(t){this.logger=t,this.any=[],this.events=Object.create(null),this.anyOnce=[],this.eventsOnce=Object.create(null)}on(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(1===e.length){var n=e[0];if("function"!=typeof n)throw new Error("EventListener.on(): Invalid arguments: "+mm.Config.inspect(e));this.any.push(n)}if(2===e.length){var[r,s]=e;if("function"!=typeof s)throw new Error("EventListener.on(): Invalid arguments: "+mm.Config.inspect(e));if(Om(r))this.any.push(s);else if(Array.isArray(r))r.forEach(t=>{this.on(t,s)});else{if("string"!=typeof r)throw new Error("EventListener.on(): Invalid arguments: "+mm.Config.inspect(e));(this.events[r]||(this.events[r]=[])).push(s)}}}off(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(0==e.length||Om(e[0])&&Om(e[1]))return this.any=[],this.events=Object.create(null),this.anyOnce=[],void(this.eventsOnce=Object.create(null));var[n,r]=e,s=null,o=null;if(1!==e.length&&r){if("function"!=typeof r)throw new Error("EventEmitter.off(): invalid arguments:"+mm.Config.inspect(e));[o,s]=[n,r]}else"function"==typeof n?s=n:o=n;if(s&&Om(o))Zg([this.any,this.events,this.anyOnce,this.eventsOnce],s);else if(Array.isArray(o))o.forEach(t=>{this.off(t,s)});else{if("string"!=typeof o)throw new Error("EventEmitter.off(): invalid arguments:"+mm.Config.inspect(e));s?Zg([this.events,this.eventsOnce],s,o):(delete this.events[o],delete this.eventsOnce[o])}}listeners(t){if(t){var e=this.events[t]||[];return this.eventsOnce[t]&&Array.prototype.push.apply(e,this.eventsOnce[t]),e.length?e:null}return this.any.length?this.any:null}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var r={event:t},s=[];this.anyOnce.length&&(Array.prototype.push.apply(s,this.anyOnce),this.anyOnce=[]),this.any.length&&Array.prototype.push.apply(s,this.any);var o=this.eventsOnce[t];o&&(Array.prototype.push.apply(s,o),delete this.eventsOnce[t]);var a=this.events[t];a&&Array.prototype.push.apply(s,a),s.forEach(t=>{!function(t,e,i,n){try{i.apply(e,n)}catch(e){km.logAction(t,km.LOG_ERROR,"EventEmitter.emit()","Unexpected listener exception: "+e+"; stack = "+(e&&e.stack))}}(this.logger,r,t,i)})}once(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=e.length;if(0===n||1===n&&"function"!=typeof e[0]){var r=e[0];return new Promise(t=>{this.once(r,t)})}var[s,o]=e;if(1===e.length&&"function"==typeof s)this.anyOnce.push(s);else if(Om(s)){if("function"!=typeof o)throw new Error("EventEmitter.once(): Invalid arguments:"+mm.Config.inspect(e));this.anyOnce.push(o)}else if(Array.isArray(s)){var a=this,l=function(){var t=Array.prototype.slice.call(arguments);if(s.forEach(function(t){a.off(t,l)}),"function"!=typeof o)throw new Error("EventEmitter.once(): Invalid arguments:"+mm.Config.inspect(e));o.apply(this,t)};s.forEach(function(t){a.on(t,l)})}else{if("string"!=typeof s)throw new Error("EventEmitter.once(): Invalid arguments:"+mm.Config.inspect(e));var h=this.eventsOnce[s]||(this.eventsOnce[s]=[]);if(o){if("function"!=typeof o)throw new Error("EventEmitter.once(): Invalid arguments:"+mm.Config.inspect(e));h.push(o)}}}whenState(t,i){var n=this;return e(function*(){if("string"!=typeof t||"string"!=typeof i)throw new Error("whenState requires a valid state String argument");return t===i?null:n.once(t)})()}},Kg={HEARTBEAT:0,ACK:1,NACK:2,CONNECT:3,CONNECTED:4,DISCONNECT:5,DISCONNECTED:6,CLOSE:7,CLOSED:8,ERROR:9,ATTACH:10,ATTACHED:11,DETACH:12,DETACHED:13,PRESENCE:14,MESSAGE:15,SYNC:16,AUTH:17,ACTIVATE:18,OBJECT:19,OBJECT_SYNC:20,ANNOTATION:21},Xg=[];Object.keys(Kg).forEach(function(t){Xg[Kg[t]]=t});var Qg={HAS_PRESENCE:1,HAS_BACKLOG:2,RESUMED:4,TRANSIENT:16,ATTACH_RESUME:32,HAS_OBJECTS:128,PRESENCE:65536,PUBLISH:1<<17,SUBSCRIBE:1<<18,PRESENCE_SUBSCRIBE:1<<19,ANNOTATION_PUBLISH:1<<21,ANNOTATION_SUBSCRIBE:1<<22,OBJECT_SUBSCRIBE:1<<24,OBJECT_PUBLISH:1<<25},tb=Object.keys(Qg);Qg.MODE_ALL=Qg.PRESENCE|Qg.PUBLISH|Qg.SUBSCRIBE|Qg.PRESENCE_SUBSCRIBE|Qg.ANNOTATION_PUBLISH|Qg.ANNOTATION_SUBSCRIBE|Qg.OBJECT_SUBSCRIBE|Qg.OBJECT_PUBLISH;var eb=["PRESENCE","PUBLISH","SUBSCRIBE","PRESENCE_SUBSCRIBE","ANNOTATION_PUBLISH","ANNOTATION_SUBSCRIBE","OBJECT_SUBSCRIBE","OBJECT_PUBLISH"];function ib(){return(ib=e(function*(t,e){var{data:i,encoding:n}=yield nb(t.data,t.encoding,e);return t.data=i,t.encoding=n,t})).apply(this,arguments)}function nb(t,e,i){return rb.apply(this,arguments)}function rb(){return(rb=e(function*(t,e,i){var n=i.channelCipher,r=t,s=e?e+"/":"";return mm.BufferUtils.isBuffer(r)||(r=mm.BufferUtils.utf8Encode(String(r)),s+="utf-8/"),{data:yield n.encrypt(r),encoding:s=s+"cipher+"+n.algorithm}})).apply(this,arguments)}function sb(){return sb=e(function*(t,e){var{data:i,encoding:n}=ob(t.data,t.encoding);return t.data=i,t.encoding=n,null!=e&&e.cipher?function(t,e){return ib.apply(this,arguments)}(t,e):t}),sb.apply(this,arguments)}function ob(t,e){if("string"==typeof t||mm.BufferUtils.isBuffer(t)||null==t)return{data:t,encoding:e};if(Em(t)||Array.isArray(t))return{data:JSON.stringify(t),encoding:e?e+"/json":"json"};throw new Cm("Data type is unsupported",40013,400)}function ab(){return(ab=e(function*(t,e){var{data:i,encoding:n,error:r}=yield lb(t.data,t.encoding,e);if(t.data=i,t.encoding=n,r)throw r})).apply(this,arguments)}function lb(t,e,i){return hb.apply(this,arguments)}function hb(){return hb=e(function*(t,e,i){var n,r=function(t){return t&&t.channelOptions?t:{channelOptions:t,plugins:{},baseEncodedPreviousPayload:void 0}}(i),s=t,o=t,a=e;if(e){var l,h=e.split("/"),u=h.length,c="";try{for(;(l=u)>0;){var d=h[--u].match(/([-\w]+)(\+([\w-]+))?/);if(!d)break;switch(c=d[1]){case"base64":o=mm.BufferUtils.base64Decode(String(o)),l==h.length&&(s=o);continue;case"utf-8":o=mm.BufferUtils.utf8Decode(o);continue;case"json":o=JSON.parse(o);continue;case"cipher":if(null!=r.channelOptions&&r.channelOptions.cipher&&r.channelOptions.channelCipher){var v=d[3],f=r.channelOptions.channelCipher;if(v!=f.algorithm)throw new Error("Unable to decrypt message with given cipher; incompatible cipher params");o=yield f.decrypt(o);continue}throw new Error("Unable to decrypt message; not an encrypted channel");case"vcdiff":if(!r.plugins||!r.plugins.vcdiff)throw new Cm("Missing Vcdiff decoder (https://github.com/ably-forks/vcdiff-decoder)",40019,400);if("undefined"==typeof Uint8Array)throw new Cm("Delta decoding not supported on this browser (need ArrayBuffer & Uint8Array)",40020,400);try{var p=r.baseEncodedPreviousPayload;"string"==typeof p&&(p=mm.BufferUtils.utf8Encode(p));var m=mm.BufferUtils.toBuffer(p);o=mm.BufferUtils.toBuffer(o),s=o=mm.BufferUtils.arrayBufferViewToBuffer(r.plugins.vcdiff.decode(o,m))}catch(t){throw new Cm("Vcdiff delta decode failed with "+t,40018,400)}continue;default:throw new Error("Unknown encoding")}}}catch(t){var g=t;n=new Cm("Error processing the "+c+" encoding, decoder returned ‘"+g.message+"’",g.code||40013,400)}finally{a=l<=0?null:h.slice(0,l).join("/")}}return n?{error:n,data:o,encoding:a}:(r.baseEncodedPreviousPayload=s,{data:o,encoding:a})}),hb.apply(this,arguments)}function ub(){var t=arguments.length>0?"json":"msgpack",{data:e,encoding:i}=cb(this.data,this.encoding,t);return Object.assign({},this,{encoding:i,data:e})}function cb(t,e,i){return t&&mm.BufferUtils.isBuffer(t)?"msgpack"===i?{data:mm.BufferUtils.toBuffer(t),encoding:e}:{data:mm.BufferUtils.base64Encode(t),encoding:e?e+"/base64":"base64"}:{data:t,encoding:e}}var db={encryptData:nb,encodeData:ob,encodeDataForWire:cb,decodeData:lb};function vb(t){var e,{id:i,connectionId:n,timestamp:r}=t;switch(t.action){case Kg.MESSAGE:e=t.messages;break;case Kg.PRESENCE:case Kg.SYNC:e=t.presence;break;case Kg.ANNOTATION:e=t.annotations;break;case Kg.OBJECT:case Kg.OBJECT_SYNC:e=t.state;break;default:throw new Cm("Unexpected action "+t.action,4e4,400)}for(var s=0;s<e.length;s++){var o=e[s];o.connectionId||(o.connectionId=n),o.timestamp||(o.timestamp=r),i&&!o.id&&(o.id=i+":"+s)}}function fb(t,e){var i="["+e;for(var n in t)"data"===n?"string"==typeof t.data?i+="; data="+t.data:mm.BufferUtils.isBuffer(t.data)?i+="; data (buffer)="+mm.BufferUtils.base64Encode(t.data):void 0!==t.data&&(i+="; data (json)="+JSON.stringify(t.data)):!n||"extras"!==n&&"operation"!==n?"version"===n?i+="; version="+JSON.stringify(t[n]):"annotations"===n?i+="; annotations="+JSON.stringify(t[n]):void 0!==t[n]&&(i+="; "+n+"="+t[n]):i+="; "+n+"="+JSON.stringify(t[n]);return i+="]"}var pb=class{},mb=class{constructor(t){var e,i,n,r,s,o,a,l,h,u;this.Platform=mm,this.ErrorInfo=Cm,this.Logger=km,this.Defaults=Pg,this.Utils=xm,this.EventEmitter=Yg,this.MessageEncoding=db,this.Lt=null!=(e=t.plugins)?e:null,this.logger=new km,this.logger.setLog(t.logLevel,t.logHandler),this.Ft=null!=(n=null==(i=t.plugins)?void 0:i.MsgPack)?n:null;var c=this.options=Pg.normaliseOptions(t,this.Ft,this.logger);if(c.key){var d=c.key.match(/^([^:\s]+):([^:.\s]+)$/);if(!d){var v="invalid key parameter";throw km.logAction(this.logger,km.LOG_ERROR,"BaseClient()",v),new Cm(v,40400,404)}c.keyName=d[1],c.keySecret=d[2]}if("clientId"in c){if("string"!=typeof c.clientId&&null!==c.clientId)throw new Cm("clientId must be either a string or null",40012,400);if("*"===c.clientId)throw new Cm('Can’t use "*" as a clientId as that string is reserved. (To change the default token request behaviour to use a wildcard clientId, use {defaultTokenParams: {clientId: "*"}})',40012,400)}this.Ut=null,this.serverTimeOffset=null,this.http=new Gg(this),this.auth=new Hg(this,c),this.zt=(null==(r=t.plugins)?void 0:r.Rest)?new t.plugins.Rest(this):null,this.Wt=null!=(o=null==(s=t.plugins)?void 0:s.Crypto)?o:null,this.__FilteredSubscriptions=null!=(l=null==(a=t.plugins)?void 0:a.MessageInteractions)?l:null,this.$t=null!=(u=null==(h=t.plugins)?void 0:h.Annotations)?u:null}get rest(){return this.zt||gg("Rest"),this.zt}get Vt(){return this.__FilteredSubscriptions||gg("MessageInteractions"),this.__FilteredSubscriptions}get channels(){return this.rest.channels}get push(){return this.rest.push}device(){var t;return(null==(t=this.options.plugins)?void 0:t.Push)&&this.push.LocalDevice||gg("Push"),this.Ht||(this.Ht=this.push.LocalDevice.load(this)),this.Ht}baseUri(t){return Pg.getHttpScheme(this.options)+t+":"+Pg.getPort(this.options,!1)}stats(t){var i=this;return e(function*(){return i.rest.stats(t)})()}time(t){var i=this;return e(function*(){return i.rest.time(t)})()}request(t,i,n,r,s,o){var a=this;return e(function*(){return a.rest.request(t,i,n,r,s,o)})()}batchPublish(t){return this.rest.batchPublish(t)}batchPresence(t){return this.rest.batchPresence(t)}setLog(t){this.logger.setLog(t.level,t.handler)}getTimestamp(t){var i=this;return e(function*(){return!i.isTimeOffsetSet()&&t?i.time():i.getTimestampUsingOffset()})()}getTimestampUsingOffset(){return Date.now()+(this.serverTimeOffset||0)}isTimeOffsetSet(){return null!==this.serverTimeOffset}};mb.Platform=mm;var gb=mb,bb=["message.create","message.update","message.delete","meta","message.summary","message.append"];function yb(t){var e=0;return t.name&&(e+=t.name.length),t.clientId&&(e+=t.clientId.length),t.extras&&(e+=JSON.stringify(t.extras).length),t.data&&(e+=Qm(t.data)),e}function wb(){return(wb=e(function*(t,e){return Promise.all(t.map(t=>t.encode(e)))})).apply(this,arguments)}var kb=class t extends pb{expandFields(){if(this.version||(this.version={}),!this.version.serial&&this.serial&&(this.version.serial=this.serial),!this.version.timestamp&&this.timestamp&&(this.version.timestamp=this.timestamp),this.annotations?this.annotations.summary||(this.annotations.summary={}):this.annotations={summary:{}},this.annotations&&this.annotations.summary)for(var[t,e]of Object.entries(this.annotations.summary))if(t.endsWith(":distinct.v1")||t.endsWith(":unique.v1")||t.endsWith(":multiple.v1"))for(var[,i]of Object.entries(e))i.clipped||(i.clipped=!1);else t.endsWith(":flag.v1")&&(e.clipped||(e.clipped=!1))}encode(t){var i=this;return e(function*(){return function(t,e){return sb.apply(this,arguments)}(Object.assign(new xb,i,{action:bb.indexOf(i.action||"message.create")}),t)})()}static fromValues(e){return Object.assign(new t,e)}static fromValuesArray(e){return e.map(e=>t.fromValues(e))}toString(){return fb(this,"Message")}},xb=class t extends pb{toJSON(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return ub.call(this,...e)}static fromValues(e){return Object.assign(new t,e)}static fromValuesArray(e){return e.map(e=>t.fromValues(e))}decodeWithErr(t,i){var n=this;return e(function*(){var e,r,s=Object.assign(new kb,fm(vm({},n),{action:(e=n.action,bb[e||0]||"unknown")}));try{yield function(t,e){return ab.apply(this,arguments)}(s,t)}catch(t){km.logAction(i,km.LOG_ERROR,"WireMessage.decode()",Km(t)),r=t}return s.expandFields(),{decoded:s,err:r}})()}decode(t,i){var n=this;return e(function*(){var{decoded:e}=yield n.decodeWithErr(t,i);return e})()}toString(){return fb(this,"WireMessage")}},Sb=kb,Cb=class{constructor(t,e,i,n,r){this.previous=t,this.current=e,"attached"===e&&(this.resumed=i,this.hasBacklog=n),r&&(this.reason=r)}},_b=function(){};function Ib(t){var e=t||{},{agent:i}=e;return((t,e)=>{var i={};for(var n in t)um.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&hm)for(var n of hm(t))e.indexOf(n)<0&&cm.call(t,n)&&(i[n]=t[n]);return i})(e,["agent"])}var Ab=class t extends Yg{constructor(t,i,n){var r,s,o;super(t.logger),this.qt=null,this.Jt=0,this.retryCount=0,this.history=function(){var t=e(function*(t){var e=this.client.rest.channelMixin;if(t&&t.untilAttach){if("attached"!==this.state)throw new Cm("option untilAttach requires the channel to be attached",4e4,400);if(!this.properties.attachSerial)throw new Cm("untilAttach was specified and channel is attached, but attachSerial is not defined",4e4,400);delete t.untilAttach,t.from_serial=this.properties.attachSerial}return e.history(this,t)});return function(e){return t.apply(this,arguments)}}(),this.whenState=t=>Yg.prototype.whenState.call(this,t,this.state),this.name=i,this.channelOptions=Og(null!=(r=t.Wt)?r:null,this.logger,n),this.client=t,this.Gt=t.Zt?new t.Zt.RealtimePresence(this):null,t.$t&&(this.qt=new t.$t.RealtimeAnnotations(this)),this.connectionManager=t.connection.connectionManager,this.state="initialized",this.subscriptions=new Yg(this.logger),this.syncChannelSerial=void 0,this.properties={attachSerial:void 0,channelSerial:void 0},this.setOptions(n),this.errorReason=null,this.Yt=!1,this.Kt={channelOptions:this.channelOptions,plugins:t.options.plugins||{},baseEncodedPreviousPayload:void 0},this.Xt={messageId:null,protocolMessageChannelSerial:null,decodeFailureRecoveryInProgress:null},this.Qt=new Yg(this.logger),(null==(s=t.options.plugins)?void 0:s.Push)&&(this.te=new t.options.plugins.Push.PushChannel(this)),(null==(o=t.options.plugins)?void 0:o.LiveObjects)&&(this.ee=new t.options.plugins.LiveObjects.RealtimeObject(this))}get presence(){return this.Gt||gg("RealtimePresence"),this.Gt}get annotations(){return this.qt||gg("Annotations"),this.qt}get push(){return this.te||gg("Push"),this.te}get object(){return this.ee||gg("LiveObjects"),this.ee}invalidStateError(){return new Cm("Channel operation failed as channel state is "+this.state,90001,400,this.errorReason||void 0)}static processListenerArgs(t){return"function"==typeof(t=Array.prototype.slice.call(t))[0]&&t.unshift(null),t}setOptions(t){var i=this;return e(function*(){var e,n=i.channelOptions,r=function(t){if(t&&"params"in t&&!Em(t.params))return new Cm("options.params must be an object",4e4,400);if(t&&"modes"in t){if(!Array.isArray(t.modes))return new Cm("options.modes must be an array",4e4,400);for(var e=0;e<t.modes.length;e++){var i=t.modes[e];if(!i||"string"!=typeof i||!eb.includes(String.prototype.toUpperCase.call(i)))return new Cm("Invalid channel mode: "+i,4e4,400)}}}(t);if(r)throw r;if(i.channelOptions=Og(null!=(e=i.client.Wt)?e:null,i.logger,t),i.Kt&&(i.Kt.channelOptions=i.channelOptions),i.ie(t,n))return i.attachImpl(),new Promise((t,e)=>{i.Qt.once(["attached","update","detached","failed"],function(i){switch(this.event){case"update":case"attached":t();break;default:e(i.reason)}})})})()}ie(t,e){if("attached"!==this.state&&"attaching"!==this.state)return!1;if(null==t?void 0:t.params){var i=Ib(t.params),n=Ib(e.params);if(Object.keys(i).length!==Object.keys(n).length)return!0;if(!dg(n,i))return!0}return!(!(null==t?void 0:t.modes)||e.modes&&pg(t.modes,e.modes))}publish(){var t=arguments,i=this;return e(function*(){var e,n,r=t.length<=0?void 0:t[0],s=t.length<=1?void 0:t[1];if("string"==typeof r||null==r)e=[Sb.fromValues({name:r,data:s})],n=t.length<=2?void 0:t[2];else if(Em(r))e=[Sb.fromValues(r)],n=t.length<=1?void 0:t[1];else{if(!Array.isArray(r))throw new Cm("The single-argument form of publish() expects a message object or an array of message objects",40013,400);e=Sb.fromValuesArray(r),n=t.length<=1?void 0:t[1]}var o=i.client.options.maxMessageSize,a=yield function(t,e){return wb.apply(this,arguments)}(e,i.channelOptions),l=function(t){for(var e,i=0,n=0;n<t.length;n++)i+=(e=t[n]).size||(e.size=yb(e));return i}(a);if(l>o)throw new Cm("Maximum size of messages that can be published at once exceeded (was "+l+" bytes; limit is "+o+" bytes)",40009,400);i.throwIfUnpublishableState();var h=Ob({action:Kg.MESSAGE,channel:i.name,messages:a,params:n?Gm(n):void 0});return(yield i.sendMessage(h))||{serials:[]}})()}throwIfUnpublishableState(){if(!this.connectionManager.activeState())throw this.connectionManager.getError();if("failed"===this.state||"suspended"===this.state)throw this.invalidStateError()}onEvent(t){for(var e=this.subscriptions,i=0;i<t.length;i++){var n=t[i];e.emit(n.name,n)}}attach(){var t=this;return e(function*(){return"attached"===t.state?null:new Promise((e,i)=>{t.ne(!1,null,(t,n)=>t?i(t):e(n))})})()}ne(t,e,i){i||(i=t=>{t&&km.logAction(this.logger,km.LOG_ERROR,"RealtimeChannel._attach()","Channel attach failed: "+t.toString())});var n=this.connectionManager;n.activeState()?(("attaching"!==this.state||t)&&this.requestState("attaching",e),this.once(function(t){switch(this.event){case"attached":null==i||i(null,t);break;case"detached":case"suspended":case"failed":null==i||i(t.reason||n.getError()||new Cm("Unable to attach; reason unknown; state = "+this.event,9e4,500));break;case"detaching":null==i||i(new Cm("Attach request superseded by a subsequent detach request",9e4,409))}})):i(n.getError())}attachImpl(){var t=Ob({action:Kg.ATTACH,channel:this.name,params:this.channelOptions.params,channelSerial:this.properties.channelSerial});this.channelOptions.modes&&t.encodeModesToFlags(ag(this.channelOptions.modes)),this.Yt&&t.setFlag("ATTACH_RESUME"),this.Xt.decodeFailureRecoveryInProgress&&(t.channelSerial=this.Xt.protocolMessageChannelSerial),this.sendMessage(t).catch(_b)}detach(){var t=this;return e(function*(){var e=t.connectionManager;switch(t.state){case"suspended":return void t.notifyState("detached");case"detached":return;case"failed":throw new Cm("Unable to detach; channel state = failed",90001,400);default:if("connected"!==e.state.state)return void t.notifyState("detached");t.requestState("detaching");case"detaching":return new Promise((i,n)=>{t.once(function(t){switch(this.event){case"detached":i();break;case"attached":case"suspended":case"failed":n(t.reason||e.getError()||new Cm("Unable to detach; reason unknown; state = "+this.event,9e4,500));break;case"attaching":n(new Cm("Detach request superseded by a subsequent attach request",9e4,409))}})})}})()}detachImpl(){var t=Ob({action:Kg.DETACH,channel:this.name});this.sendMessage(t).catch(_b)}subscribe(){var i=arguments,n=this;return e(function*(){for(var e=i.length,r=new Array(e),s=0;s<e;s++)r[s]=i[s];var[o,a]=t.processListenerArgs(r);if("failed"===n.state)throw Cm.fromValues(n.invalidStateError());return o&&"object"==typeof o&&!Array.isArray(o)?n.client.Vt.subscribeFilter(n,o,a):n.subscriptions.on(o,a),!1!==n.channelOptions.attachOnSubscribe?n.attach():null})()}unsubscribe(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];var[s,o]=t.processListenerArgs(n);"object"==typeof s&&!o||(null==(e=this.filteredSubscriptions)?void 0:e.has(o))?this.client.Vt.getAndDeleteFilteredSubscriptions(this,s,o).forEach(t=>this.subscriptions.off(t)):this.subscriptions.off(s,o)}sync(){switch(this.state){case"initialized":case"detaching":case"detached":throw new _m("Unable to sync to channel; not attached",4e4)}var t=this.connectionManager;if(!t.activeState())throw t.getError();var e=Ob({action:Kg.SYNC,channel:this.name});this.syncChannelSerial&&(e.channelSerial=this.syncChannelSerial),t.send(e)}sendMessage(t){var i=this;return e(function*(){return new Promise((e,n)=>{i.connectionManager.send(t,i.client.options.queueMessages,(t,i)=>{t?n(t):e(i)})})})()}sendPresence(t){var i=this;return e(function*(){var e=Ob({action:Kg.PRESENCE,channel:i.name,presence:t});yield i.sendMessage(e)})()}sendState(t){var i=this;return e(function*(){var e=Ob({action:Kg.OBJECT,channel:i.name,state:t});yield i.sendMessage(e)})()}processMessage(t){var i=this;return e(function*(){t.action!==Kg.ATTACHED&&t.action!==Kg.MESSAGE&&t.action!==Kg.PRESENCE&&t.action!==Kg.OBJECT&&t.action!==Kg.ANNOTATION||i.setChannelSerial(t.channelSerial);var e,n=!1;switch(t.action){case Kg.ATTACHED:i.properties.attachSerial=t.channelSerial,i.Jt=t.getMode(),i.params=t.params||{};var r=t.decodeModesFromFlags();i.modes=r&&og(r)||void 0;var s=t.hasFlag("RESUMED"),o=t.hasFlag("HAS_PRESENCE"),a=t.hasFlag("HAS_BACKLOG"),l=t.hasFlag("HAS_OBJECTS");if("attached"===i.state){s||(i.Gt&&i.Gt.onAttached(o),i.ee&&i.ee.onAttached(l));var h=new Cb(i.state,i.state,s,a,t.error);i.Qt.emit("update",h),s&&!i.channelOptions.updateOnAttached||i.emit("update",h)}else"detaching"===i.state?i.checkPendingState():i.notifyState("attached",t.error,s,o,a,l);break;case Kg.DETACHED:var u=t.error?Cm.fromValues(t.error):new Cm("Channel detached",90001,404);"detaching"===i.state?i.notifyState("detached",u):"attaching"===i.state?i.notifyState("suspended",u):"attached"!==i.state&&"suspended"!==i.state||i.requestState("attaching",u);break;case Kg.SYNC:if(n=!0,e=i.syncChannelSerial=t.channelSerial,!t.presence)break;case Kg.PRESENCE:if(!t.presence)break;vb(t);var c=i.channelOptions;if(i.Gt){var d=yield Promise.all(t.presence.map(t=>t.decode(c,i.logger)));i.Gt.setPresence(d,n,e)}break;case Kg.OBJECT:case Kg.OBJECT_SYNC:if(!i.ee||!t.state)return;vb(t);var v=i.client.connection.connectionManager.getActiveTransportFormat(),f=t.state.map(t=>t.decode(i.client,v));t.action===Kg.OBJECT?i.ee.handleObjectMessages(f):i.ee.handleObjectSyncMessages(f,t.channelSerial);break;case Kg.MESSAGE:if("attached"!==i.state)return;vb(t);var p=t.messages,m=p[0],g=p[p.length-1];if(m.extras&&m.extras.delta&&m.extras.delta.from!==i.Xt.messageId){var b='Delta message decode failure - previous message not available for message "'+t.id+'" on this channel "'+i.name+'".';km.logAction(i.logger,km.LOG_ERROR,"RealtimeChannel.processMessage()",b),i.re(new Cm(b,40018,400));break}for(var y=[],w=0;w<p.length;w++){var{decoded:k,err:x}=yield p[w].decodeWithErr(i.Kt,i.logger);if(y[w]=k,x)switch(x.code){case 40018:return void i.re(x);case 40019:case 40021:return void i.notifyState("failed",x)}}i.Xt.messageId=g.id,i.Xt.protocolMessageChannelSerial=t.channelSerial,i.onEvent(y);break;case Kg.ANNOTATION:vb(t);var S=i.channelOptions;if(i.qt){var C=yield Promise.all((t.annotations||[]).map(t=>t.decode(S,i.logger)));i.qt.se(C)}break;case Kg.ERROR:var _=t.error;_&&80016==_.code?i.checkPendingState():i.notifyState("failed",Cm.fromValues(_))}})()}re(t){this.Xt.decodeFailureRecoveryInProgress||(this.Xt.decodeFailureRecoveryInProgress=!0,this.ne(!0,t,()=>{this.Xt.decodeFailureRecoveryInProgress=!1}))}onAttached(){}notifyState(t,e,i,n,r,s){if(this.clearStateTimer(),["detached","suspended","failed"].includes(t)&&(this.properties.channelSerial=null),t!==this.state){this.Gt&&this.Gt.actOnChannelState(t,n,e),this.ee&&this.ee.actOnChannelState(t,s),"suspended"===t&&this.connectionManager.state.sendEvents?this.startRetryTimer():this.cancelRetryTimer(),e&&(this.errorReason=e);var o=new Cb(this.state,t,i,r,e),a='Channel state for channel "'+this.name+'"',l=t+(e?"; reason: "+e:"");"failed"===t&&km.logAction(this.logger,km.LOG_ERROR,a,l),"attaching"!==t&&"suspended"!==t&&(this.retryCount=0),"attached"===t&&this.onAttached(),"attached"===t?this.Yt=!0:"detaching"!==t&&"failed"!==t||(this.Yt=!1),this.state=t,this.Qt.emit(t,o),this.emit(t,o)}}requestState(t,e){this.notifyState(t,e),this.checkPendingState()}checkPendingState(){if(this.connectionManager.state.sendEvents)switch(this.state){case"attaching":this.startStateTimerIfNotRunning(),this.attachImpl();break;case"detaching":this.startStateTimerIfNotRunning(),this.detachImpl();break;case"attached":this.sync()}}timeoutPendingState(){switch(this.state){case"attaching":var t=new Cm("Channel attach timed out",90007,408);this.notifyState("suspended",t);break;case"detaching":var e=new Cm("Channel detach timed out",90007,408);this.notifyState("attached",e);break;default:this.checkPendingState()}}startStateTimerIfNotRunning(){this.stateTimer||(this.stateTimer=setTimeout(()=>{this.stateTimer=null,this.timeoutPendingState()},this.client.options.timeouts.realtimeRequestTimeout))}clearStateTimer(){var t=this.stateTimer;t&&(clearTimeout(t),this.stateTimer=null)}startRetryTimer(){if(!this.retryTimer){this.retryCount++;var t=ug(this.client.options.timeouts.channelRetryTimeout,this.retryCount);this.retryTimer=setTimeout(()=>{"suspended"===this.state&&this.connectionManager.state.sendEvents&&(this.retryTimer=null,this.requestState("attaching"))},t)}}cancelRetryTimer(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}getReleaseErr(){var t=this.state;return"initialized"===t||"detached"===t||"failed"===t?null:new Cm("Can only release a channel in a state where there is no possibility of further updates from the server being received (initialized, detached, or failed); was "+t,90001,400)}setChannelSerial(t){t&&(this.properties.channelSerial=t)}status(){var t=this;return e(function*(){return t.client.rest.channelMixin.status(t)})()}getMessage(t){var i=this;return e(function*(){return i.client.rest.channelMixin.getMessage(i,t)})()}updateMessage(t,i,n){var r=this;return e(function*(){return r.sendUpdate(t,"message.update",i,n)})()}deleteMessage(t,i,n){var r=this;return e(function*(){return r.sendUpdate(t,"message.delete",i,n)})()}appendMessage(t,i,n){var r=this;return e(function*(){return r.sendUpdate(t,"message.append",i,n)})()}sendUpdate(t,i,n,r){var s=this;return e(function*(){var e,o;if(!t.serial)throw new Cm('This message lacks a serial and cannot be updated. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.',40003,400);s.throwIfUnpublishableState();var a=Sb.fromValues(fm(vm({},t),{action:i,version:n})),l=yield a.encode(s.channelOptions),h=Ob({action:Kg.MESSAGE,channel:s.name,messages:[l],params:r?Gm(r):void 0}),u=yield s.sendMessage(h);return{versionSerial:null!=(o=null==(e=null==u?void 0:u.serials)?void 0:e[0])?o:null}})()}getMessageVersions(t,i){var n=this;return e(function*(){return n.client.rest.channelMixin.getMessageVersions(n,t,i)})()}ensureAttached(){var t=this;return e(function*(){switch(t.state){case"attached":case"suspended":break;case"initialized":case"detached":case"detaching":case"attaching":yield t.attach();break;default:throw Cm.fromValues(t.invalidStateError())}})()}},Tb=sg;function Eb(t){var e=[];if(t)for(var i=0;i<t.length;i++)e.push(t[i].toString());return"[ "+e.join(", ")+" ]"}function Mb(t,e,i,n,r,s){return function(t,e,i,n){var r,s,o,a,l;t.error&&(r=Cm.fromValues(t.error));t.messages&&(s=xb.fromValuesArray(t.messages));e&&t.presence&&(o=e.WirePresenceMessage.fromValuesArray(t.presence));i&&t.annotations&&(a=i.WireAnnotation.fromValuesArray(t.annotations));n&&t.state&&(l=n.WireObjectMessage.fromValuesArray(t.state,xm,db));return Object.assign(new Nb,fm(vm({},t),{presence:o,messages:s,annotations:a,state:l,error:r}))}(rg(t,e,s),i,n,r)}function Ob(t){return Object.assign(new Nb,t)}function Rb(t,e,i,n){var r="[ProtocolMessage";void 0!==t.action&&(r+="; action="+Xg[t.action]||t.action);for(var s,o=["id","channel","channelSerial","connectionId","count","msgSerial","timestamp"],a=0;a<o.length;a++)void 0!==t[s=o[a]]&&(r+="; "+s+"="+t[s]);if(t.messages&&(r+="; messages="+Eb(xb.fromValuesArray(t.messages))),t.presence&&e&&(r+="; presence="+Eb(e.WirePresenceMessage.fromValuesArray(t.presence))),t.annotations&&i&&(r+="; annotations="+Eb(i.WireAnnotation.fromValuesArray(t.annotations))),t.state&&n&&(r+="; state="+Eb(n.WireObjectMessage.fromValuesArray(t.state,xm,db))),t.error&&(r+="; error="+Cm.fromValues(t.error).toString()),t.auth&&t.auth.accessToken&&(r+="; token="+t.auth.accessToken),t.flags&&(r+="; flags="+tb.filter(t.hasFlag).join(",")),t.params){var l="";$m(t.params,function(e){l.length>0&&(l+="; "),l+=e+"="+t.params[e]}),l.length>0&&(r+="; params=["+l+"]")}return r+="]"}var Nb=class{constructor(){this.hasFlag=t=>(this.flags&Qg[t])>0}setFlag(t){return this.flags=this.flags|Qg[t]}getMode(){return(this.flags||0)&Qg.MODE_ALL}encodeModesToFlags(t){t.forEach(t=>this.setFlag(t))}decodeModesFromFlags(){var t=[];return eb.forEach(e=>{this.hasFlag(e)&&t.push(e)}),t.length>0?t:void 0}},Pb=class extends Yg{constructor(t){super(t),this.messages=[]}count(){return this.messages.length}push(t){this.messages.push(t)}shift(){return this.messages.shift()}last(){return this.messages[this.messages.length-1]}copyAll(){return this.messages.slice()}append(t){this.messages.push.apply(this.messages,t)}prepend(t){this.messages.unshift.apply(this.messages,t)}completeMessages(t,e,i){e=e||null;var n=this.messages;if(0===n.length)throw new Error("MessageQueue.completeMessages(): completeMessages called on any empty MessageQueue");var r=[];if("all"===t)r=n.splice(0);else{var s=n[0];if(s){var o=s.message.msgSerial,a=t.serial+t.count;a>o&&(r=n.splice(0,a-o))}}for(var l=0;l<r.length;l++){var h=r[l],u=null==i?void 0:i[l];h.callback(e,u)}0==n.length&&this.emit("idle")}completeAllMessages(t){this.completeMessages("all",t)}resetSendAttempted(){for(var t of this.messages)t.sendAttempted=!1}clear(){this.messages=[],this.emit("idle")}},Bb=class{constructor(t,e){this.message=t,this.callback=e,this.merged=!1;var i=t.action;this.sendAttempted=!1,this.ackRequired="number"==typeof i&&[Kg.MESSAGE,Kg.PRESENCE,Kg.ANNOTATION,Kg.OBJECT].includes(i)}},Db=class extends Yg{constructor(t){super(t.logger),this.transport=t,this.messageQueue=new Pb(this.logger),t.on("ack",(t,e,i)=>{this.onAck(t,e,i)}),t.on("nack",(t,e,i)=>{this.onNack(t,e,i)})}onAck(t,e,i){this.messageQueue.completeMessages({serial:t,count:e},null,i)}onNack(t,e,i){km.logAction(this.logger,km.LOG_ERROR,"Protocol.onNack()","serial = "+t+"; count = "+e+"; err = "+Km(i)),i||(i=new Cm("Unable to send message; channel not responding",50001,500)),this.messageQueue.completeMessages({serial:t,count:e},i)}onceIdle(t){var e=this.messageQueue;0!==e.count()?e.once("idle",t):t()}send(t){t.ackRequired&&this.messageQueue.push(t),this.logger.shouldLog(km.LOG_MICRO)&&km.logActionNoStrip(this.logger,km.LOG_MICRO,"Protocol.send()","sending msg; "+Rb(t.message,this.transport.connectionManager.realtime.Zt,this.transport.connectionManager.realtime.$t,this.transport.connectionManager.realtime.oe)),t.sendAttempted=!0,this.transport.send(t.message)}getTransport(){return this.transport}getPendingMessages(){return this.messageQueue.copyAll()}clearPendingMessages(){return this.messageQueue.clear()}finish(){var t=this.transport;this.onceIdle(function(){t.disconnect()})}},jb=class{constructor(t,e,i,n){this.previous=t,this.current=e,i&&(this.retryIn=i),n&&(this.reason=n)}},Ub={DISCONNECTED:80003,SUSPENDED:80002,FAILED:8e4,CLOSING:80017,CLOSED:80017,UNKNOWN_CONNECTION_ERR:50002,UNKNOWN_CHANNEL_ERR:50001};var Lb,Fb,zb={disconnected:()=>Cm.fromValues({statusCode:400,code:Ub.DISCONNECTED,message:"Connection to server temporarily unavailable"}),suspended:()=>Cm.fromValues({statusCode:400,code:Ub.SUSPENDED,message:"Connection to server unavailable"}),failed:()=>Cm.fromValues({statusCode:400,code:Ub.FAILED,message:"Connection failed or disconnected by server"}),closing:()=>Cm.fromValues({statusCode:400,code:Ub.CLOSING,message:"Connection closing"}),closed:()=>Cm.fromValues({statusCode:400,code:Ub.CLOSED,message:"Connection closed"}),unknownConnectionErr:()=>Cm.fromValues({statusCode:500,code:Ub.UNKNOWN_CONNECTION_ERR,message:"Internal connection error"}),unknownChannelErr:()=>Cm.fromValues({statusCode:500,code:Ub.UNKNOWN_CONNECTION_ERR,message:"Internal channel error"})},Wb=Ob({action:Kg.CLOSE}),$b=Ob({action:Kg.DISCONNECT}),Vb=class extends Yg{constructor(t,e,i,n){super(t.logger),n&&(i.format=void 0,i.heartbeats=!0),this.connectionManager=t,this.auth=e,this.params=i,this.timeouts=i.options.timeouts,this.format=i.format,this.isConnected=!1,this.isFinished=!1,this.isDisposed=!1,this.maxIdleInterval=null,this.idleTimer=null,this.lastActivity=null}connect(){}close(){this.isConnected&&this.requestClose(),this.finish("closed",zb.closed())}disconnect(t){this.isConnected&&this.requestDisconnect(),this.finish("disconnected",t||zb.disconnected())}fail(t){this.isConnected&&this.requestDisconnect(),this.finish("failed",t||zb.failed())}finish(t,e){var i;this.isFinished||(this.isFinished=!0,this.isConnected=!1,this.maxIdleInterval=null,clearTimeout(null!=(i=this.idleTimer)?i:void 0),this.idleTimer=null,this.emit(t,e),this.dispose())}onProtocolMessage(t){switch(this.logger.shouldLog(km.LOG_MICRO)&&km.logActionNoStrip(this.logger,km.LOG_MICRO,"Transport.onProtocolMessage()","received on "+this.shortName+": "+Rb(t,this.connectionManager.realtime.Zt,this.connectionManager.realtime.$t,this.connectionManager.realtime.oe)+"; connectionId = "+this.connectionManager.connectionId),this.onActivity(),t.action){case Kg.HEARTBEAT:km.logActionNoStrip(this.logger,km.LOG_MICRO,"Transport.onProtocolMessage()",this.shortName+" heartbeat; connectionId = "+this.connectionManager.connectionId),this.emit("heartbeat",t.id);break;case Kg.CONNECTED:this.onConnect(t),this.emit("connected",t.error,t.connectionId,t.connectionDetails,t);break;case Kg.CLOSED:this.onClose(t);break;case Kg.DISCONNECTED:this.onDisconnect(t);break;case Kg.ACK:this.emit("ack",t.msgSerial,t.count,t.res);break;case Kg.NACK:this.emit("nack",t.msgSerial,t.count,t.error);break;case Kg.SYNC:this.connectionManager.onChannelMessage(t,this);break;case Kg.ACTIVATE:break;case Kg.AUTH:ng(this.auth.authorize(),t=>{t&&km.logAction(this.logger,km.LOG_ERROR,"Transport.onProtocolMessage()","Ably requested re-authentication, but unable to obtain a new token: "+Km(t))});break;case Kg.ERROR:if(void 0===t.channel){this.onFatalError(t);break}this.connectionManager.onChannelMessage(t,this);break;default:this.connectionManager.onChannelMessage(t,this)}}onConnect(t){if(this.isConnected=!0,!t.connectionDetails)throw new Error("Transport.onConnect(): Connect message recieved without connectionDetails");var e=t.connectionDetails.maxIdleInterval;e&&(this.maxIdleInterval=e+this.timeouts.realtimeRequestTimeout,this.onActivity())}onDisconnect(t){var e=t&&t.error;this.finish("disconnected",e)}onFatalError(t){var e=t&&t.error;this.finish("failed",e)}onClose(t){var e=t&&t.error;this.finish("closed",e)}requestClose(){this.send(Wb)}requestDisconnect(){this.send($b)}ping(t){var e={action:Kg.HEARTBEAT};t&&(e.id=t),this.send(Ob(e))}dispose(){this.isDisposed=!0,this.off()}onActivity(){this.maxIdleInterval&&(this.lastActivity=this.connectionManager.lastActivity=Date.now(),this.setIdleTimer(this.maxIdleInterval+100))}setIdleTimer(t){this.idleTimer||(this.idleTimer=setTimeout(()=>{this.onIdleTimerExpire()},t))}onIdleTimerExpire(){if(!this.lastActivity||!this.maxIdleInterval)throw new Error("Transport.onIdleTimerExpire(): lastActivity/maxIdleInterval not set");this.idleTimer=null;var t=Date.now()-this.lastActivity,e=this.maxIdleInterval-t;if(e<=0){var i="No activity seen from realtime in "+t+"ms; assuming connection has dropped";km.logAction(this.logger,km.LOG_ERROR,"Transport.onIdleTimerExpire()",i),this.disconnect(new Cm(i,80003,408))}else this.setIdleTimer(e+100)}static tryConnect(t,e,i,n,r){var s,o=new t(e,i,n),a=function(t){clearTimeout(s),r({event:this.event,error:t})},l=e.options.timeouts.realtimeRequestTimeout;return s=setTimeout(()=>{o.off(["preconnect","disconnected","failed"]),o.dispose(),a.call({event:"disconnected"},new Cm("Timeout waiting for transport to indicate itself viable",5e4,500))},l),o.on(["failed","disconnected"],a),o.on("preconnect",function(){clearTimeout(s),o.off(["failed","disconnected"],a),r(null,o)}),o.connect(),o}static isAvailable(){throw new Cm("isAvailable not implemented for transport",5e4,500)}};(Fb=Lb||(Lb={})).WebSocket="web_socket",Fb.Comet="comet",Fb.XhrPolling="xhr_polling";var Hb="undefined"!=typeof global?global:"undefined"!=typeof window?window:self,qb=()=>{var t;return void 0!==mm.WebStorage&&(null==(t=mm.WebStorage)?void 0:t.localSupported)},Jb=()=>{var t;return void 0!==mm.WebStorage&&(null==(t=mm.WebStorage)?void 0:t.sessionSupported)},Gb=function(){},Zb="ably-transport-preference";function Yb(t){try{return JSON.parse(t)}catch(t){return null}}var Kb=class{constructor(t,e,i,n){this.options=t,this.host=e,this.mode=i,this.connectionKey=n,this.format=t.useBinaryProtocol?"msgpack":"json"}getConnectParams(t){var e=t?Am(t):{},i=this.options;switch(this.mode){case"resume":e.resume=this.connectionKey;break;case"recover":var n=Yb(i.recover);n&&(e.recover=n.connectionKey)}return void 0!==i.clientId&&(e.clientId=i.clientId),!1===i.echoMessages&&(e.echo="false"),void 0!==this.format&&(e.format=this.format),void 0!==this.stream&&(e.stream=this.stream),void 0!==this.heartbeats&&(e.heartbeats=this.heartbeats),e.v=Pg.protocolVersion,e.agent=Eg(this.options),void 0!==i.transportParams&&Im(e,i.transportParams),e}toString(){var t="[mode="+this.mode;return this.host&&(t+=",host="+this.host),this.connectionKey&&(t+=",connectionKey="+this.connectionKey),this.format&&(t+=",format="+this.format),t+="]"}},Xb=class t extends Yg{constructor(t,e){super(t.logger),this.supportedTransports={},this.disconnectedRetryCount=0,this.pendingChannelMessagesState={isProcessing:!1,queue:[]},this.realtime=t,this.initTransports(),this.options=e;var i=e.timeouts,n=i.webSocketConnectTimeout+i.realtimeRequestTimeout;if(this.states={initialized:{state:"initialized",terminal:!1,queueEvents:!0,sendEvents:!1,failState:"disconnected"},connecting:{state:"connecting",terminal:!1,queueEvents:!0,sendEvents:!1,retryDelay:n,failState:"disconnected"},connected:{state:"connected",terminal:!1,queueEvents:!1,sendEvents:!0,failState:"disconnected"},disconnected:{state:"disconnected",terminal:!1,queueEvents:!0,sendEvents:!1,retryDelay:i.disconnectedRetryTimeout,failState:"disconnected"},suspended:{state:"suspended",terminal:!1,queueEvents:!1,sendEvents:!1,retryDelay:i.suspendedRetryTimeout,failState:"suspended"},closing:{state:"closing",terminal:!1,queueEvents:!1,sendEvents:!1,retryDelay:i.realtimeRequestTimeout,failState:"closed"},closed:{state:"closed",terminal:!0,queueEvents:!1,sendEvents:!1,failState:"closed"},failed:{state:"failed",terminal:!0,queueEvents:!1,sendEvents:!1,failState:"failed"}},this.state=this.states.initialized,this.errorReason=null,this.queuedMessages=new Pb(this.logger),this.msgSerial=0,this.connectionDetails=void 0,this.connectionId=void 0,this.connectionKey=void 0,this.connectionStateTtl=i.connectionStateTtl,this.maxIdleInterval=null,this.transports=Dm(e.transports||Pg.defaultTransports,this.supportedTransports),this.transportPreference=null,this.transports.includes(Lb.WebSocket)&&(this.webSocketTransportAvailable=!0),this.transports.includes(Lb.XhrPolling)?this.baseTransport=Lb.XhrPolling:this.transports.includes(Lb.Comet)&&(this.baseTransport=Lb.Comet),this.domains=Pg.getHosts(e),this.activeProtocol=null,this.host=null,this.lastAutoReconnectAttempt=null,this.lastActivity=null,this.forceFallbackHost=!1,this.connectCounter=0,this.wsCheckResult=null,this.webSocketSlowTimer=null,this.webSocketGiveUpTimer=null,this.abandonedWebSocket=!1,!this.transports.length){var r="no requested transports available";throw km.logAction(this.logger,km.LOG_ERROR,"realtime.ConnectionManager()",r),new Error(r)}var s=mm.Config.addEventListener;s&&(Jb()&&"function"==typeof e.recover&&s("beforeunload",this.persistConnection.bind(this)),!0===e.closeOnUnload&&s("beforeunload",()=>{this.requestState({state:"closing"})}),s("online",()=>{var t;this.state==this.states.disconnected||this.state==this.states.suspended?this.requestState({state:"connecting"}):this.state==this.states.connecting&&(null==(t=this.pendingTransport)||t.off(),this.disconnectAllTransports(),this.startConnect())}),s("offline",()=>{this.state==this.states.connected&&this.disconnectAllTransports()}))}static supportedTransports(t){var e={supportedTransports:{}};return this.initTransports(t,e),e.supportedTransports}static initTransports(t,e){var i=vm(vm({},mm.Transports.bundledImplementations),t);[Lb.WebSocket,...mm.Transports.order].forEach(t=>{var n=i[t];n&&n.isAvailable()&&(e.supportedTransports[t]=n)})}initTransports(){t.initTransports(this.realtime.ae,this)}createTransportParams(t,e){return new Kb(this.options,t,e,this.connectionKey)}getTransportParams(t){(t=>{if(this.connectionKey)t("resume");else if("string"!=typeof this.options.recover){var e=this.options.recover,i=this.getSessionRecoverData();this.sessionRecoveryName(),i&&"function"==typeof e?e(i,e=>{e?(this.options.recover=i.recoveryKey,t("recover")):t("clean")}):t("clean")}else t("recover")})(e=>{var i=this.createTransportParams(null,e);if("recover"===e){var n=Yb(this.options.recover);n&&(this.msgSerial=n.msgSerial)}t(i)})}tryATransport(t,e,i){this.proposedTransport=Vb.tryConnect(this.supportedTransports[e],this,this.realtime.auth,t,(n,r)=>{var s,o=this.state;if(o==this.states.closing||o==this.states.closed||o==this.states.failed)return r&&r.close(),void i(!0);n?!Hg.isTokenErr(n.error)||this.errorReason&&Hg.isTokenErr(this.errorReason)?"failed"===n.event?(this.notifyState({state:"failed",error:n.error}),i(!0)):"disconnected"===n.event&&(!(s=n.error).statusCode||!s.code||s.statusCode>=500||Object.values(Ub).includes(s.code)?i(!1):(this.notifyState({state:this.states.connecting.failState,error:n.error}),i(!0))):(this.errorReason=n.error,ng(this.realtime.auth.Ot(null,null),n=>{n?this.actOnErrorFromAuthorize(n):this.tryATransport(t,e,i)})):(this.setTransportPending(r,t),i(null,r))})}setTransportPending(t,e){var i=e.mode;this.pendingTransport=t,this.cancelWebSocketSlowTimer(),this.cancelWebSocketGiveUpTimer(),t.once("connected",(e,n,r)=>{this.activateTransport(e,t,n,r),"recover"===i&&this.options.recover&&(delete this.options.recover,this.unpersistConnection())});var n=this;t.on(["disconnected","closed","failed"],function(e){n.deactivateTransport(t,this.event,e)}),this.emit("transport.pending",t)}activateTransport(t,e,i,n){t&&km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.activateTransport()","error = "+t),this.persistTransportPreference(e);var r=this.state,s=this.states.connected.state;if(r.state==this.states.closing.state||r.state==this.states.closed.state||r.state==this.states.failed.state)return e.disconnect(),!1;if(delete this.pendingTransport,!e.isConnected)return!1;var o=this.activeProtocol;this.activeProtocol=new Db(e),this.host=e.params.host;var a=n.connectionKey;if(a&&this.connectionKey!=a&&this.setConnection(i,n,!!t),this.onConnectionDetailsUpdate(n,e),mm.Config.nextTick(()=>{e.on("connected",(t,i,n)=>{this.onConnectionDetailsUpdate(n,e),this.emit("update",new jb(s,s,null,t))})}),r.state===this.states.connected.state?t&&(this.errorReason=this.realtime.connection.errorReason=t,this.emit("update",new jb(s,s,null,t))):(this.notifyState({state:"connected",error:t}),this.errorReason=this.realtime.connection.errorReason=t||null),this.emit("transport.active",e),o)if(o.messageQueue.count()>0&&km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.activateTransport()","Previous active protocol (for transport "+o.transport.shortName+", new one is "+e.shortName+") finishing with "+o.messageQueue.count()+" messages still pending"),o.transport===e){var l="Assumption violated: activating a transport that was also the transport for the previous active protocol; transport = "+e.shortName+"; stack = "+(new Error).stack;km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.activateTransport()",l)}else o.finish();return!0}deactivateTransport(t,e,i){var n=this.activeProtocol,r=n&&n.getTransport()===t,s=t===this.pendingTransport,o=this.noTransportsScheduledForActivation();if(i&&i.message,r&&(this.queuePendingMessages(n.getPendingMessages()),n.clearPendingMessages(),this.activeProtocol=this.host=null),this.emit("transport.inactive",t),r&&o||r&&"failed"===e||"closed"===e||null===n&&s){if("disconnected"===e&&i&&i.statusCode>500&&this.domains.length>1)return this.unpersistTransportPreference(),this.forceFallbackHost=!0,void this.notifyState({state:e,error:i,retryImmediately:!0});var a="failed"===e&&Hg.isTokenErr(i)?"disconnected":e;this.notifyState({state:a,error:i})}else;}noTransportsScheduledForActivation(){return!this.pendingTransport||!this.pendingTransport.isConnected}setConnection(t,e,i){var n=this.connectionId;(n&&n!==t||!n&&i)&&(this.msgSerial=0,this.queuedMessages.resetSendAttempted()),this.connectionId,this.realtime.connection.id=this.connectionId=t,this.realtime.connection.key=this.connectionKey=e.connectionKey}clearConnection(){this.realtime.connection.id=this.connectionId=void 0,this.realtime.connection.key=this.connectionKey=void 0,this.msgSerial=0,this.unpersistConnection()}createRecoveryKey(){return this.connectionKey?JSON.stringify({connectionKey:this.connectionKey,msgSerial:this.msgSerial,channelSerials:this.realtime.channels.channelSerials()}):null}checkConnectionStateFreshness(){this.lastActivity&&this.connectionId&&(Date.now()-this.lastActivity>this.connectionStateTtl+this.maxIdleInterval&&(this.clearConnection(),this.states.connecting.failState="suspended"))}persistConnection(){if(Jb()){var t=this.createRecoveryKey();t&&this.setSessionRecoverData({recoveryKey:t,disconnectedAt:Date.now(),location:Hb.location,clientId:this.realtime.auth.clientId})}}unpersistConnection(){this.clearSessionRecoverData()}getActiveTransportFormat(){var t;return null==(t=this.activeProtocol)?void 0:t.getTransport().format}getError(){if(this.errorReason){var t=_m.fromValues(this.errorReason);return t.cause=this.errorReason,t}return this.getStateError()}getStateError(){var t,e;return null==(e=(t=zb)[this.state.state])?void 0:e.call(t)}activeState(){return this.state.queueEvents||this.state.sendEvents}enactStateChange(t){var e=t.current+(t.reason?"; reason: "+t.reason:"");"failed"===t.current&&km.logAction(this.logger,km.LOG_ERROR,"Connection state",e);var i=this.state=this.states[t.current];t.reason&&(this.errorReason=t.reason,this.realtime.connection.errorReason=t.reason),(i.terminal||"suspended"===i.state)&&this.clearConnection(),this.emit("connectionstate",t)}startTransitionTimer(t){this.transitionTimer&&clearTimeout(this.transitionTimer),this.transitionTimer=setTimeout(()=>{this.transitionTimer&&(this.transitionTimer=null,this.notifyState({state:t.failState}))},t.retryDelay)}cancelTransitionTimer(){this.transitionTimer&&(clearTimeout(this.transitionTimer),this.transitionTimer=null)}startSuspendTimer(){this.suspendTimer||(this.suspendTimer=setTimeout(()=>{this.suspendTimer&&(this.suspendTimer=null,this.states.connecting.failState="suspended",this.notifyState({state:"suspended"}))},this.connectionStateTtl))}checkSuspendTimer(t){"disconnected"!==t&&"suspended"!==t&&"connecting"!==t&&this.cancelSuspendTimer()}cancelSuspendTimer(){this.states.connecting.failState="disconnected",this.suspendTimer&&(clearTimeout(this.suspendTimer),this.suspendTimer=null)}startRetryTimer(t){this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.requestState({state:"connecting"})},t)}cancelRetryTimer(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}startWebSocketSlowTimer(){this.webSocketSlowTimer=setTimeout(()=>{this.checkWsConnectivity().then(()=>{this.wsCheckResult=!0}).catch(()=>{this.wsCheckResult=!1}),this.realtime.http.checkConnectivity&&ng(this.realtime.http.checkConnectivity(),(t,e)=>{!t&&e||(this.cancelWebSocketGiveUpTimer(),this.notifyState({state:"disconnected",error:new Cm("Unable to connect (network unreachable)",80003,404)}))})},this.options.timeouts.webSocketSlowTimeout)}cancelWebSocketSlowTimer(){this.webSocketSlowTimer&&(clearTimeout(this.webSocketSlowTimer),this.webSocketSlowTimer=null)}startWebSocketGiveUpTimer(t){this.webSocketGiveUpTimer=setTimeout(()=>{var e,i;this.wsCheckResult||this.baseTransport&&(this.abandonedWebSocket=!0,null==(e=this.proposedTransport)||e.dispose(),null==(i=this.pendingTransport)||i.dispose(),this.connectBase(t,++this.connectCounter))},this.options.timeouts.webSocketConnectTimeout)}cancelWebSocketGiveUpTimer(){this.webSocketGiveUpTimer&&(clearTimeout(this.webSocketGiveUpTimer),this.webSocketGiveUpTimer=null)}notifyState(t){var e,i,n=t.state,r="disconnected"===n&&(this.state===this.states.connected||t.retryImmediately||this.state===this.states.connecting&&t.error&&Hg.isTokenErr(t.error)&&!(this.errorReason&&Hg.isTokenErr(this.errorReason)));if(n!=this.state.state&&(this.cancelTransitionTimer(),this.cancelRetryTimer(),this.cancelWebSocketSlowTimer(),this.cancelWebSocketGiveUpTimer(),this.checkSuspendTimer(t.state),"suspended"!==n&&"connected"!==n||(this.disconnectedRetryCount=0),!this.state.terminal)){var s=this.states[t.state],o=s.retryDelay;"disconnected"===s.state&&(this.disconnectedRetryCount++,o=ug(s.retryDelay,this.disconnectedRetryCount));var a=new jb(this.state.state,s.state,o,t.error||(null==(i=(e=zb)[s.state])?void 0:i.call(e)));if(r){var l=()=>{this.state===this.states.disconnected&&(this.lastAutoReconnectAttempt=Date.now(),this.requestState({state:"connecting"}))},h=this.lastAutoReconnectAttempt&&Date.now()-this.lastAutoReconnectAttempt+1;h&&h<1e3?setTimeout(l,1e3-h):mm.Config.nextTick(l)}else"disconnected"!==n&&"suspended"!==n||this.startRetryTimer(o);("disconnected"===n&&!r||"suspended"===n||s.terminal)&&mm.Config.nextTick(()=>{this.disconnectAllTransports()}),"connected"!=n||this.activeProtocol||km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.notifyState()","Broken invariant: attempted to go into connected state, but there is no active protocol"),this.enactStateChange(a),this.state.sendEvents?this.sendQueuedMessages():this.state.queueEvents||(this.realtime.channels.propogateConnectionInterruption(n,a.reason),this.failQueuedMessages(a.reason))}}requestState(t){var e,i,n=t.state;if(n!=this.state.state&&(this.cancelWebSocketSlowTimer(),this.cancelWebSocketGiveUpTimer(),this.cancelTransitionTimer(),this.cancelRetryTimer(),this.checkSuspendTimer(n),!("connecting"==n&&"connected"==this.state.state||"closing"==n&&"closed"==this.state.state))){var r=this.states[n],s=new jb(this.state.state,r.state,null,t.error||(null==(i=(e=zb)[r.state])?void 0:i.call(e)));this.enactStateChange(s),"connecting"==n&&mm.Config.nextTick(()=>{this.startConnect()}),"closing"==n&&this.closeImpl()}}startConnect(){if(this.state===this.states.connecting){var t=this.realtime.auth,e=++this.connectCounter,i=()=>{this.checkConnectionStateFreshness(),this.getTransportParams(t=>{if("recover"===t.mode&&t.options.recover){var i=Yb(t.options.recover);i&&this.realtime.channels.recoverChannels(i.channelSerials)}e===this.connectCounter&&this.connectImpl(t,e)})};if(this.startSuspendTimer(),this.startTransitionTimer(this.states.connecting),"basic"===t.method)i();else{var n=t=>{e===this.connectCounter&&(t?this.actOnErrorFromAuthorize(t):i())};this.errorReason&&Hg.isTokenErr(this.errorReason)?ng(t.Ot(null,null),n):ng(t.Rt(!1),n)}}}connectImpl(t,e){if(this.state.state===this.states.connecting.state){var i=this.getTransportPreference();i&&i===this.baseTransport&&this.webSocketTransportAvailable&&this.checkWsConnectivity().then(()=>{this.unpersistTransportPreference(),this.state===this.states.connecting&&(this.disconnectAllTransports(),this.connectWs(t,++this.connectCounter))}).catch(Gb),i&&i===this.baseTransport||this.baseTransport&&!this.webSocketTransportAvailable?this.connectBase(t,e):this.connectWs(t,e)}}connectWs(t,e){this.wsCheckResult=null,this.abandonedWebSocket=!1,this.startWebSocketSlowTimer(),this.startWebSocketGiveUpTimer(t),this.tryTransportWithFallbacks("web_socket",t,!0,e,()=>!1!==this.wsCheckResult&&!this.abandonedWebSocket)}connectBase(t,e){this.baseTransport?this.tryTransportWithFallbacks(this.baseTransport,t,!1,e,()=>!0):this.notifyState({state:"disconnected",error:new Cm("No transports left to try",8e4,404)})}tryTransportWithFallbacks(t,e,i,n,r){var s=t=>{this.notifyState({state:this.states.connecting.failState,error:t})},o=this.domains.slice(),a=(t,e)=>{n===this.connectCounter&&(r()?e||t||h():e&&e.dispose())},l=o.shift();if(l){e.host=l;var h=()=>{o.length?this.realtime.http.checkConnectivity?ng(this.realtime.http.checkConnectivity(),(i,l)=>{n===this.connectCounter&&r()&&(i?s(i):l?(e.host=qm(o),this.tryATransport(e,t,a)):s(new Cm("Unable to connect (network unreachable)",80003,404)))}):s(new _m("Internal error: Http.checkConnectivity not set",null,500)):s(new Cm("Unable to connect (and no more fallback hosts to try)",80003,404))};if(this.forceFallbackHost&&o.length)return this.forceFallbackHost=!1,void h();this.tryATransport(e,t,a)}else s(new Cm("Unable to connect (no available host)",80003,404))}closeImpl(){this.cancelSuspendTimer(),this.startTransitionTimer(this.states.closing),this.pendingTransport&&this.pendingTransport.close(),this.activeProtocol&&this.activeProtocol.getTransport().close(),this.notifyState({state:"closed"})}onAuthUpdated(t,e){var i;switch(this.state.state){case"connected":var n=null==(i=this.activeProtocol)?void 0:i.getTransport();n&&n.onAuthUpdated&&n.onAuthUpdated(t);var r=Ob({action:Kg.AUTH,auth:{accessToken:t.token}});this.send(r);var s=()=>{this.off(o),e(null,t)},o=t=>{"failed"===t.current&&(this.off(s),this.off(o),e(t.reason||this.getStateError()))};this.once("connectiondetails",s),this.on("connectionstate",o);break;case"connecting":this.disconnectAllTransports();default:var a=i=>{switch(i.current){case"connected":this.off(a),e(null,t);break;case"failed":case"closed":case"suspended":this.off(a),e(i.reason||this.getStateError())}};this.on("connectionstate",a),"connecting"===this.state.state?this.startConnect():this.requestState({state:"connecting"})}}disconnectAllTransports(){this.connectCounter++,this.pendingTransport&&this.pendingTransport.disconnect(),delete this.pendingTransport,this.proposedTransport&&this.proposedTransport.disconnect(),delete this.pendingTransport,this.activeProtocol&&this.activeProtocol.getTransport().disconnect()}send(t,e,i){i=i||Gb;var n=this.state;if(n.sendEvents)this.sendImpl(new Bb(t,i));else if(e&&n.queueEvents)this.logger.shouldLog(km.LOG_MICRO),this.queue(t,i);else{var r="rejecting event, queueEvent was "+e+", state was "+n.state;i(this.errorReason||new Cm(r,9e4,400))}}sendImpl(t){var e=t.message;t.ackRequired&&!t.sendAttempted&&(e.msgSerial=this.msgSerial++);try{this.activeProtocol.send(t)}catch(t){km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.sendImpl()","Unexpected exception in transport.send(): "+t.stack)}}queue(t,e){this.queuedMessages.push(new Bb(t,e))}sendQueuedMessages(){for(var t;t=this.queuedMessages.shift();)this.sendImpl(t)}queuePendingMessages(t){t&&t.length&&this.queuedMessages.prepend(t)}failQueuedMessages(t){var e=this.queuedMessages.count();e>0&&(km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.failQueuedMessages()","failing "+e+" queued messages, err = "+Km(t)),this.queuedMessages.completeAllMessages(t))}onChannelMessage(t,e){this.pendingChannelMessagesState.queue.push({message:t,transport:e}),this.pendingChannelMessagesState.isProcessing||this.processNextPendingChannelMessage()}processNextPendingChannelMessage(){if(this.pendingChannelMessagesState.queue.length>0){this.pendingChannelMessagesState.isProcessing=!0;var t=this.pendingChannelMessagesState.queue.shift();this.processChannelMessage(t.message).catch(t=>{km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.processNextPendingChannelMessage() received error ",t)}).finally(()=>{this.pendingChannelMessagesState.isProcessing=!1,this.processNextPendingChannelMessage()})}}processChannelMessage(t){var i=this;return e(function*(){yield i.realtime.channels.processChannelMessage(t)})()}ping(){var t=this;return e(function*(){var e;if("connected"!==t.state.state)throw new Cm("Unable to ping service; not connected",4e4,400);var i=null==(e=t.activeProtocol)?void 0:e.getTransport();if(!i)throw t.getStateError();var n=Date.now(),r=tg();return bg(new Promise(t=>{var e=s=>{s===r&&(i.off("heartbeat",e),t(Date.now()-n))};i.on("heartbeat",e),i.ping(r)}),t.options.timeouts.realtimeRequestTimeout,"Timeout waiting for heartbeat response")})()}abort(t){this.activeProtocol.getTransport().fail(t)}getTransportPreference(){var t,e;return this.transportPreference||qb()&&(null==(e=null==(t=mm.WebStorage)?void 0:t.get)?void 0:e.call(t,Zb))}persistTransportPreference(t){var e,i;this.transportPreference=t.shortName,qb()&&(null==(i=null==(e=mm.WebStorage)?void 0:e.set)||i.call(e,Zb,t.shortName))}unpersistTransportPreference(){var t,e;this.transportPreference=null,qb()&&(null==(e=null==(t=mm.WebStorage)?void 0:t.remove)||e.call(t,Zb))}actOnErrorFromAuthorize(t){if(40171===t.code)this.notifyState({state:"failed",error:t});else if(40102===t.code)this.notifyState({state:"failed",error:t});else if(t.statusCode===Lg.Forbidden){var e="Client configured authentication provider returned 403; failing the connection";km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.actOnErrorFromAuthorize()",e),this.notifyState({state:"failed",error:new Cm(e,80019,403,t)})}else{this.notifyState({state:this.state.failState,error:new Cm("Client configured authentication provider request failed",80019,401,t)})}}onConnectionDetailsUpdate(t,e){if(t){this.connectionDetails=t,t.maxMessageSize&&(this.options.maxMessageSize=t.maxMessageSize);var i=t.clientId;if(i){var n=this.realtime.auth.Dt(i);if(n)return km.logAction(this.logger,km.LOG_ERROR,"ConnectionManager.onConnectionDetailsUpdate()",n.message),void e.fail(n)}var r=t.connectionStateTtl;r&&(this.connectionStateTtl=r),this.maxIdleInterval=t.maxIdleInterval,this.emit("connectiondetails",t)}}checkWsConnectivity(){var t=this.options.wsConnectivityCheckUrl||Pg.wsConnectivityCheckUrl,e=new mm.Config.WebSocket(t);return new Promise((t,i)=>{var n=!1;e.onopen=()=>{n||(n=!0,t(),e.close())},e.onclose=e.onerror=()=>{n||(n=!0,i())}})}sessionRecoveryName(){return this.options.recoveryKeyStorageName||"ably-connection-recovery"}getSessionRecoverData(){var t,e;return Jb()&&(null==(e=null==(t=mm.WebStorage)?void 0:t.getSession)?void 0:e.call(t,this.sessionRecoveryName()))}setSessionRecoverData(t){var e,i;return Jb()&&(null==(i=null==(e=mm.WebStorage)?void 0:e.setSession)?void 0:i.call(e,this.sessionRecoveryName(),t))}clearSessionRecoverData(){var t,e;return Jb()&&(null==(e=null==(t=mm.WebStorage)?void 0:t.removeSession)?void 0:e.call(t,this.sessionRecoveryName()))}},Qb=class extends Yg{constructor(t,e){super(t.logger),this.whenState=t=>Yg.prototype.whenState.call(this,t,this.state),this.ably=t,this.connectionManager=new Xb(t,e),this.state=this.connectionManager.state.state,this.key=void 0,this.id=void 0,this.errorReason=null,this.connectionManager.on("connectionstate",t=>{var e=this.state=t.current;mm.Config.nextTick(()=>{this.emit(e,t)})}),this.connectionManager.on("update",t=>{mm.Config.nextTick(()=>{this.emit("update",t)})})}connect(){this.connectionManager.requestState({state:"connecting"})}ping(){var t=this;return e(function*(){return t.connectionManager.ping()})()}close(){this.connectionManager.requestState({state:"closing"})}get recoveryKey(){return this.logger.deprecationWarning("The `Connection.recoveryKey` attribute has been replaced by the `Connection.createRecoveryKey()` method. Replace your usage of `recoveryKey` with the return value of `createRecoveryKey()`. `recoveryKey` will be removed in a future version."),this.createRecoveryKey()}createRecoveryKey(){return this.connectionManager.createRecoveryKey()}},ty=class t extends gb{constructor(e){var i,n,r,s;if(super(Pg.objectifyOptions(e,!1,"BaseRealtime",km.defaultLogger)),"string"==typeof EdgeRuntime)throw new Cm('Ably.Realtime instance cannot be used in Vercel Edge runtime. If you are running Vercel Edge functions, please replace your "new Ably.Realtime()" with "new Ably.Rest()" and use Ably Rest API instead of the Realtime API. If you are server-rendering your application in the Vercel Edge runtime, please use the condition "if (typeof EdgeRuntime === \'string\')" to prevent instantiating Ably.Realtime instance during SSR in the Vercel Edge runtime.',4e4,400);this.ae=t.transportImplementationsFromPlugins(this.options.plugins),this.Zt=null!=(n=null==(i=this.options.plugins)?void 0:i.RealtimePresence)?n:null,this.oe=null!=(s=null==(r=this.options.plugins)?void 0:r.LiveObjects)?s:null,this.connection=new Qb(this,this.options),this.le=new iy(this),!1!==this.options.autoConnect&&this.connect()}static transportImplementationsFromPlugins(t){var e={};return(null==t?void 0:t.WebSocketTransport)&&(e[Lb.WebSocket]=t.WebSocketTransport),(null==t?void 0:t.XHRPolling)&&(e[Lb.XhrPolling]=t.XHRPolling),e}get channels(){return this.le}get clientId(){return this.auth.clientId}connect(){this.connection.connect()}close(){this.connection.close()}};ty.EventEmitter=Yg;var ey=ty,iy=class extends Yg{constructor(t){super(t.logger),this.realtime=t,this.all=Object.create(null),t.connection.connectionManager.on("transport.active",()=>{this.onTransportActive()})}channelSerials(){var t={};for(var e of zm(this.all,!0)){var i=this.all[e];i.properties.channelSerial&&(t[e]=i.properties.channelSerial)}return t}recoverChannels(t){for(var e of zm(t,!0)){this.get(e).properties.channelSerial=t[e]}}processChannelMessage(t){var i=this;return e(function*(){var e=t.channel;if(void 0!==e){var n=i.all[e];n?yield n.processMessage(t):km.logAction(i.logger,km.LOG_ERROR,"Channels.processChannelMessage()","received event for non-existent channel: "+e)}else km.logAction(i.logger,km.LOG_ERROR,"Channels.processChannelMessage()","received event unspecified channel, action = "+t.action)})()}onTransportActive(){for(var t in this.all){var e=this.all[t];"attaching"===e.state||"detaching"===e.state?e.checkPendingState():"suspended"===e.state?e.ne(!1,null):"attached"===e.state&&e.requestState("attaching")}}propogateConnectionInterruption(t,e){var i=["attaching","attached","detaching","suspended"],n={closing:"detached",closed:"detached",failed:"failed",suspended:"suspended"}[t];for(var r in this.all){var s=this.all[r];i.includes(s.state)&&s.notifyState(n,e)}}get(t,e){t=String(t);var i=this.all[t];if(i){if(e){if(i.ie(e,i.channelOptions))throw new Cm("Channels.get() cannot be used to set channel options that would cause the channel to reattach. Please, use RealtimeChannel.setOptions() instead.",4e4,400);i.setOptions(e)}}else i=this.all[t]=new Ab(this.realtime,t,e);return i}getDerived(t,e,i){if(e.filter){var n=fg(e.filter),r=vg(t);t="[filter="+n+r.qualifierParam+"]"+r.channelName}return this.get(t,i)}release(t){t=String(t);var e=this.all[t];if(e){var i=e.getReleaseErr();if(i)throw i;delete this.all[t]}}},ny=ey,ry=Uint8Array,sy=Uint32Array,oy=Math.pow,ay=new sy(8),ly=[],hy=new sy(64);function uy(t){return(t-(0|t))*oy(2,32)|0}for(var cy,dy,vy=2,fy=0;fy<64;){for(cy=!0,dy=2;dy<=vy/2;dy++)vy%dy===0&&(cy=!1);cy&&(fy<8&&(ay[fy]=uy(oy(vy,.5))),ly[fy]=uy(oy(vy,1/3)),fy++),vy++}var py=!!new ry(new sy([1]).buffer)[0];function my(t){return py?t>>>24|(t>>>16&255)<<8|(65280&t)<<8|t<<24:t}function gy(t,e){return t>>>e|t<<32-e}function by(t){var e,i=ay.slice(),n=t.length,r=8*n,s=512-(r+64)%512-1+r+65,o=new ry(s/8),a=new sy(o.buffer);o.set(t,0),o[n]=128,a[a.length-1]=my(r);for(var l=0;l<s/32;l+=16){var h=i.slice();for(e=0;e<64;e++){var u;if(e<16)u=my(a[l+e]);else{var c=hy[e-15],d=hy[e-2];u=hy[e-7]+hy[e-16]+(gy(c,7)^gy(c,18)^c>>>3)+(gy(d,17)^gy(d,19)^d>>>10)}hy[e]=u|=0;for(var v=(gy(h[4],6)^gy(h[4],11)^gy(h[4],25))+(h[4]&h[5]^~h[4]&h[6])+h[7]+u+ly[e],f=(gy(h[0],2)^gy(h[0],13)^gy(h[0],22))+(h[0]&h[1]^h[2]&(h[0]^h[1])),p=7;p>0;p--)h[p]=h[p-1];h[0]=v+f|0,h[4]=h[4]+v|0}for(e=0;e<8;e++)i[e]=i[e]+h[e]|0}return new ry(new sy(i.map(function(t){return my(t)})).buffer)}var yy,wy=new class{constructor(){this.base64CharSet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",this.hexCharSet="0123456789abcdef"}uint8ViewToBase64(t){for(var e,i,n,r,s="",o=this.base64CharSet,a=t.byteLength,l=a%3,h=a-l,u=0;u<h;u+=3)e=(258048&(r=t[u]<<16|t[u+1]<<8|t[u+2]))>>12,i=(4032&r)>>6,n=63&r,s+=o[(16515072&r)>>18]+o[e]+o[i]+o[n];return 1==l?(e=(3&(r=t[h]))<<4,s+=o[(252&r)>>2]+o[e]+"=="):2==l&&(e=(1008&(r=t[h]<<8|t[h+1]))>>4,i=(15&r)<<2,s+=o[(64512&r)>>10]+o[e]+o[i]+"="),s}base64ToArrayBuffer(t){for(var e=null==atob?void 0:atob(t),i=e.length,n=new Uint8Array(i),r=0;r<i;r++){var s=e.charCodeAt(r);n[r]=s}return this.toArrayBuffer(n)}isBuffer(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}toBuffer(t){if(!ArrayBuffer)throw new Error("Can't convert to Buffer: browser does not support the necessary types");if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(this.toArrayBuffer(t));throw new Error("BufferUtils.toBuffer expected an ArrayBuffer or a view onto one")}toArrayBuffer(t){if(!ArrayBuffer)throw new Error("Can't convert to ArrayBuffer: browser does not support the necessary types");if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);throw new Error("BufferUtils.toArrayBuffer expected an ArrayBuffer or a view onto one")}base64Encode(t){return this.uint8ViewToBase64(this.toBuffer(t))}base64UrlEncode(t){return this.base64Encode(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}base64Decode(t){if(ArrayBuffer&&mm.Config.atob)return this.base64ToArrayBuffer(t);throw new Error("Expected ArrayBuffer to exist and Platform.Config.atob to be configured")}hexEncode(t){return this.toBuffer(t).reduce((t,e)=>t+e.toString(16).padStart(2,"0"),"")}hexDecode(t){if(t.length%2!=0)throw new Error("Can't create a byte array from a hex string of odd length");for(var e=new Uint8Array(t.length/2),i=0;i<e.length;i++)e[i]=parseInt(t.slice(2*i,2*(i+1)),16);return this.toArrayBuffer(e)}utf8Encode(t){if(mm.Config.TextEncoder){var e=(new mm.Config.TextEncoder).encode(t);return this.toArrayBuffer(e)}throw new Error("Expected TextEncoder to be configured")}utf8Decode(t){if(!this.isBuffer(t))throw new Error("Expected input of utf8decode to be an arraybuffer or typed array");if(TextDecoder)return(new TextDecoder).decode(t);throw new Error("Expected TextDecoder to be configured")}areBuffersEqual(t,e){if(!t||!e)return!1;var i=this.toArrayBuffer(t),n=this.toArrayBuffer(e);if(i.byteLength!=n.byteLength)return!1;for(var r=new Uint8Array(i),s=new Uint8Array(n),o=0;o<r.length;o++)if(r[o]!=s[o])return!1;return!0}byteLength(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}arrayBufferViewToBuffer(t){return this.toArrayBuffer(t)}concat(t){var e=t.reduce((t,e)=>t+e.byteLength,0),i=new Uint8Array(e),n=0;for(var r of t){var s=this.toBuffer(r);i.set(s,n),n+=s.byteLength}return i.buffer}sha256(t){var e=by(this.toBuffer(t));return this.toArrayBuffer(e)}hmacSha256(t,e){var i=function(t,e){if(t.length>64&&(t=by(t)),t.length<64){var i=new Uint8Array(64);i.set(t,0),t=i}for(var n=new Uint8Array(64),r=new Uint8Array(64),s=0;s<64;s++)n[s]=54^t[s],r[s]=92^t[s];var o=new Uint8Array(e.length+64);o.set(n,0),o.set(e,64);var a=new Uint8Array(96);return a.set(r,0),a.set(by(o),64),by(a)}(this.toBuffer(e),this.toBuffer(t));return this.toArrayBuffer(i)}},ky=(t=>(t[t.REQ_SEND=0]="REQ_SEND",t[t.REQ_RECV=1]="REQ_RECV",t[t.REQ_RECV_POLL=2]="REQ_RECV_POLL",t[t.REQ_RECV_STREAM=3]="REQ_RECV_STREAM",t))(ky||{}),xy=ky;function Sy(){return new Cm("No HTTP request plugin provided. Provide at least one of the FetchRequest or XHRRequest plugins.",400,4e4)}var Cy=(yy=class{constructor(t){var i;this.checksInProgress=null,this.checkConnectivity=void 0,this.supportsAuthHeaders=!1,this.supportsLinkHeaders=!1,this.client=null!=t?t:null;var n=(null==t?void 0:t.options.connectivityCheckUrl)||Pg.connectivityCheckUrl,r=null!=(i=null==t?void 0:t.options.connectivityCheckParams)?i:null,s=!(null==t?void 0:t.options.connectivityCheckUrl),o=vm(vm({},Cy.bundledRequestImplementations),null==t?void 0:t.Lt),a=o.XHRRequest,l=o.FetchRequest,h=!(!a&&!l);if(!h)throw Sy();mm.Config.xhrSupported&&a?(this.supportsAuthHeaders=!0,this.Request=function(){var i=e(function*(e,i,n,r,s){return new Promise(o=>{var l,h=a.createRequest(i,n,r,s,xy.REQ_SEND,null!=(l=t&&t.options.timeouts)?l:null,this.logger,e);h.once("complete",(t,e,i,n,r)=>o({error:t,body:e,headers:i,unpacked:n,statusCode:r})),h.exec()})});return function(t,e,n,r,s){return i.apply(this,arguments)}}(),(null==t?void 0:t.options.disableConnectivityCheck)?this.checkConnectivity=e(function*(){return!0}):this.checkConnectivity=e(function*(){var t,e,i=yield this.doUri(jg.Get,n,null,null,r);return s?!i.error&&"yes"==(null==(t=i.body)?void 0:t.replace(/\n/,"")):!i.error&&((e=i.statusCode)>=200&&e<400)})):mm.Config.fetchSupported&&l?(this.supportsAuthHeaders=!0,this.Request=function(){var i=e(function*(e,i,n,r,s){return l(e,null!=t?t:null,i,n,r,s)});return function(t,e,n,r,s){return i.apply(this,arguments)}}(),(null==t?void 0:t.options.disableConnectivityCheck)?this.checkConnectivity=e(function*(){return!0}):this.checkConnectivity=e(function*(){var t,e=yield this.doUri(jg.Get,n,null,null,null);return!e.error&&"yes"==(null==(t=e.body)?void 0:t.replace(/\n/,""))})):this.Request=e(function*(){return{error:h?new _m("no supported HTTP transports available",null,400):Sy()}})}get logger(){var t,e;return null!=(e=null==(t=this.client)?void 0:t.logger)?e:km.defaultLogger}doUri(t,i,n,r,s){var o=this;return e(function*(){return o.Request?o.Request(t,i,n,s,r):{error:new _m("Request invoked before assigned to",null,500)}})()}shouldFallback(t){var e=t.statusCode;return 408===e&&!t.code||400===e&&!t.code||e>=500&&e<=504}},yy.methods=[jg.Get,jg.Delete,jg.Post,jg.Put,jg.Patch],yy.methodsWithoutBody=[jg.Get,jg.Delete],yy.methodsWithBody=[jg.Post,jg.Put,jg.Patch],yy),_y=Cy,Iy="ablyjs-storage-test",Ay="undefined"!=typeof global?global:"undefined"!=typeof window?window:self,Ty=new class{constructor(){try{Ay.sessionStorage.setItem(Iy,Iy),Ay.sessionStorage.removeItem(Iy),this.sessionSupported=!0}catch(t){this.sessionSupported=!1}try{Ay.localStorage.setItem(Iy,Iy),Ay.localStorage.removeItem(Iy),this.localSupported=!0}catch(t){this.localSupported=!1}}get(t){return this.he(t,!1)}getSession(t){return this.he(t,!0)}remove(t){return this.ue(t,!1)}removeSession(t){return this.ue(t,!0)}set(t,e,i){return this.ce(t,e,i,!1)}setSession(t,e,i){return this.ce(t,e,i,!0)}ce(t,e,i,n){var r={value:e};return i&&(r.expires=Date.now()+i),this.storageInterface(n).setItem(t,JSON.stringify(r))}he(t,e){if(e&&!this.sessionSupported)throw new Error("Session Storage not supported");if(!e&&!this.localSupported)throw new Error("Local Storage not supported");var i=this.storageInterface(e).getItem(t);if(!i)return null;var n=JSON.parse(i);return n.expires&&n.expires<Date.now()?(this.storageInterface(e).removeItem(t),null):n.value}ue(t,e){return this.storageInterface(e).removeItem(t)}storageInterface(t){return t?Ay.sessionStorage:Ay.localStorage}},Ey=cg(),My="string"==typeof EdgeRuntime;"undefined"!=typeof Window||"undefined"!=typeof WorkerGlobalScope||My||console.log("Warning: this distribution of Ably is intended for browsers. On nodejs, please use the 'ably' package on npm");var Oy,Ry,Ny={agent:"browser",logTimestamps:!0,userAgent:Ey.navigator&&Ey.navigator.userAgent.toString(),currentUrl:Ey.location&&Ey.location.href,binaryType:"arraybuffer",WebSocket:Ey.WebSocket,fetchSupported:!!Ey.fetch,xhrSupported:Ey.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,allowComet:(Ry=Ey.location,!Ey.WebSocket||!Ry||!Ry.origin||Ry.origin.indexOf("http")>-1),useProtocolHeartbeats:!0,supportsBinary:!!Ey.TextDecoder,preferBinary:!1,ArrayBuffer:Ey.ArrayBuffer,atob:Ey.atob,nextTick:"function"==typeof Ey.queueMicrotask?t=>Ey.queueMicrotask(t):t=>Promise.resolve().then(t),addEventListener:Ey.addEventListener,inspect:JSON.stringify,stringByteSize:function(t){return Ey.TextDecoder&&(new Ey.TextEncoder).encode(t).length||t.length},TextEncoder:Ey.TextEncoder,TextDecoder:Ey.TextDecoder,getRandomArrayBuffer:(Oy=e(function*(t){var e=new Uint8Array(t);return Ey.crypto.getRandomValues(e),e.buffer}),function(t){return Oy.apply(this,arguments)}),isWebworker:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,push:{platform:"browser",formFactor:"desktop",storage:Ty}},Py=Ny;Lb.XhrPolling;var By=Lb.WebSocket;var Dy=class extends Vb{constructor(t,e,i){super(t,e,i),this.shortName=By,i.heartbeats=mm.Config.useProtocolHeartbeats,this.wsHost=i.host}static isAvailable(){return!!mm.Config.WebSocket}createWebSocket(t,e){return this.uri=t+Jm(e),new mm.Config.WebSocket(this.uri)}toString(){return"WebSocketTransport; uri="+this.uri}connect(){Vb.prototype.connect.call(this);var t=this,e=this.params,i=e.options,n=(i.tls?"wss://":"ws://")+this.wsHost+":"+Pg.getPort(i)+"/";ng(this.auth.getAuthParams(),function(i,r){if(!t.isDisposed){for(var s in r)" "+s+": "+r[s]+";";if(i)t.disconnect(i);else{var o=e.getConnectParams(r);try{var a=t.wsConnection=t.createWebSocket(n,o);a.binaryType=mm.Config.binaryType,a.onopen=function(){t.onWsOpen()},a.onclose=function(e){t.onWsClose(e)},a.onmessage=function(e){t.onWsData(e.data)},a.onerror=function(e){t.onWsError(e)},a.on&&a.on("ping",function(){t.onActivity()})}catch(e){km.logAction(t.logger,km.LOG_ERROR,"WebSocketTransport.connect()","Unexpected exception creating websocket: err = "+(e.stack||e.message)),t.disconnect(e)}}}})}send(t){var e=this.wsConnection;if(e)try{e.send(Tb(t,this.connectionManager.realtime.Ft,this.params.format))}catch(t){var i="Exception from ws connection when trying to send: "+Km(t);km.logAction(this.logger,km.LOG_ERROR,"WebSocketTransport.send()",i),this.finish("disconnected",new Cm(i,5e4,500))}else km.logAction(this.logger,km.LOG_ERROR,"WebSocketTransport.send()","No socket connection")}onWsData(t){try{this.onProtocolMessage(Mb(t,this.connectionManager.realtime.Ft,this.connectionManager.realtime.Zt,this.connectionManager.realtime.$t,this.connectionManager.realtime.oe,this.format))}catch(t){km.logAction(this.logger,km.LOG_ERROR,"WebSocketTransport.onWsData()","Unexpected exception handing channel message: "+t.stack)}}onWsOpen(){this.emit("preconnect")}onWsClose(t){var e,i;if("object"==typeof t?(i=t.code,e=t.wasClean||1e3===i):e=1e3==(i=t),delete this.wsConnection,e){var n=new Cm("Websocket closed",80003,400);this.finish("disconnected",n)}else{var r=new Cm("Unclean disconnection of WebSocket ; code = "+i,80003,400);this.finish("disconnected",r)}this.emit("disposed")}onWsError(t){mm.Config.nextTick(()=>{this.disconnect(Error(t.message))})}dispose(){this.isDisposed=!0;var t=this.wsConnection;t&&(t.onmessage=function(){},delete this.wsConnection,mm.Config.nextTick(()=>{if(!t)throw new Error("WebSocketTransport.dispose(): wsConnection is not defined");t.close()}))}},jy={order:["xhr_polling"],bundledImplementations:{}},Uy={connectivityCheckUrl:"https://internet-up.ably-realtime.com/is-the-internet-up.txt",wsConnectivityCheckUrl:"wss://ws-up.ably-realtime.com",defaultTransports:[Lb.XhrPolling,Lb.WebSocket]};function Ly(t,e,i,n,r,s){return Fy.apply(this,arguments)}function Fy(){return Fy=e(function*(t,i,n,r,s,o){var a,l=new Headers(r||{}),h=t?t.toUpperCase():Om(o)?"GET":"POST",u=new AbortController,c=new Promise(t=>{a=setTimeout(()=>{u.abort(),t({error:new _m("Request timed out",null,408)})},i?i.options.timeouts.httpRequestTimeout:Pg.TIMEOUTS.httpRequestTimeout)}),d={method:h,headers:l,body:o,signal:u.signal};mm.Config.isWebworker||(d.credentials=l.has("authorization")?"include":"same-origin");var v=e(function*(){try{var t=new URLSearchParams(s||{});t.set("rnd",tg());var e=n+"?"+t,i=yield cg().fetch(e,d);if(clearTimeout(a),204==i.status)return{error:null,statusCode:i.status};var r,o=i.headers.get("Content-Type");r=o&&o.indexOf("application/x-msgpack")>-1?yield i.arrayBuffer():o&&o.indexOf("application/json")>-1?yield i.json():yield i.text();var l=!!o&&-1===o.indexOf("application/x-msgpack"),h=function(t){var e={};return t.forEach((t,i)=>{e[i]=t}),e}(i.headers);if(i.ok)return{error:null,body:r,headers:h,unpacked:l,statusCode:i.status};var u=function(t,e){if(function(t,e){return!!e.get("x-ably-errorcode")}(0,e))return t.error&&Cm.fromValues(t.error)}(r,i.headers)||new _m("Error response received from server: "+i.status+" body was: "+mm.Config.inspect(r),null,i.status);return{error:u,body:r,headers:h,unpacked:l,statusCode:i.status}}catch(u){return clearTimeout(a),{error:u}}})();return Promise.race([c,v])}),Fy.apply(this,arguments)}var zy;function Wy(t,e){var n,r,s=null!==(n=t.metadata)&&void 0!==n?n:{},o=null!==(r=e.metadata)&&void 0!==r?r:{};return!o.widgets&&s.At?i({},e,{metadata:i({},o,{At:s.At})}):e}function $y(t,e,n,r){var s,o,a,l=(o=t.messages.value,a=e.id,o.some(t=>t.id===a));if(t.setMessages(function(t,e){var i=t.findIndex(t=>t.id===e.id);if(-1!==i){var n=t[i],r=Wy(n,e);if(function(t,e){return t.id===e.id&&t.channel_id===e.channel_id&&t.sender_type===e.sender_type&&t.sender_id===e.sender_id&&t.sender_name===e.sender_name&&t.sender_avatar_url===e.sender_avatar_url&&t.content===e.content&&t.content_type===e.content_type&&t.created_at===e.created_at&&t.metadata===e.metadata}(n,r))return t;var s=[...t];return s[i]=r,s}if("ai"===e.sender_type){var o=t.findIndex(t=>t.id.startsWith("temp-ai-"));if(-1!==o){var a=Wy(t[o],e),l=[...t];return l[o]=a,l}}return Rp(t,e)}(t.messages.value,e)),"user"!==e.sender_type||e.sender_id!==n){if(!l){if("ai"===e.sender_type||"agent"===e.sender_type){var h=t.isOpen.value,u=(null===(s=t.channel.value)||void 0===s?void 0:s.id)===e.channel_id;if(h&&u)r.onAgentMessageWhileOpen();else{var c=t.channels.value.findIndex(t=>t.id===e.channel_id);if(-1!==c){var d=[...t.channels.value];d[c]=i({},d[c],{unread_count:(d[c].unread_count||0)+1}),t.channels.value=d}}r.onTrack(e)}t.isTyping.value=!1,t.typingSender.value=null,t.typingSenderType.value=null,r.onMessageDispatched(e)}}else r.onMessageDispatched(e)}mm.BufferUtils=wy,mm.Http=_y,mm.Config=Py,mm.Transports=jy,mm.WebStorage=Ty,_y.bundledRequestImplementations={},km.initLogHandlers(),mm.Defaults=(zy=Uy,Object.assign(xg,zy)),mm.Config.agent&&(mm.Defaults.agent+=" "+mm.Config.agent);var Vy="chat.ably";function Hy(t,e,i){return qy.apply(this,arguments)}function qy(){return(qy=e(function*(t,e,n){return Sd(t,xd,{method:"POST",body:JSON.stringify(i({distinct_id:e},n&&{channel_id:n}))})})).apply(this,arguments)}function Jy(){return(Jy=e(function*(t,e){var i=yield Hy(t,e);return(null==i?void 0:i.tokenRequest)?i.clientId&&null!=i.project_id?{tokenRequest:i.tokenRequest,clientId:i.clientId,projectId:i.project_id}:(uu().warn(Vy,"token:request:incomplete — missing clientId or project_id"),null):(uu().warn(Vy,"token:request:failed (initial)"),null)})).apply(this,arguments)}var Gy="chat.ably";function Zy(t,e){var i=(()=>{if(!e||"object"!=typeof e)return String(e);var t=e,i="string"==typeof t.message?t.message:String(e),n="number"==typeof t.code?t.code:null,r="number"==typeof t.statusCode?t.statusCode:null;return n||r?i+" (code="+(null!=n?n:"-")+", status="+(null!=r?r:"-")+")":i})(),n=i.toLowerCase();return n.includes("timeout for trying fallback hosts")||n.includes("connection failed")||n.includes("network")||n.includes("failed to fetch")?t+" — "+i+" (browser cannot reach Ably hosts (*.ably.io / *.ably-realtime.com) — check ad-blocker, firewall, VPN, or offline state)":t+" — "+i}var Yy=t=>new ny(t);class Ky{constructor(t,e,i,n){void 0===n&&(n=Yy),this.instance=t,this.store=e,this.hooks=i,this.de=null,this.ve=null,this.fe=null,this.pe=null,this.me=null,this.ge=n}get clientId(){var t,e;return null!==(e=null===(t=this.de)||void 0===t?void 0:t.auth.clientId)&&void 0!==e?e:null}get isLive(){return null!=this.de}get currentChannelId(){return this.store.realtimeChannelId.value}ensureConnected(){var t=this;return e(function*(){if(!t.de){t.store.connectionState.value="connecting",uu().debug(Gy,"connect:start");var n=t.hooks.getDistinctId(),r=yield function(t,e){return Jy.apply(this,arguments)}(t.instance,n);if(r){t.store.ablyProjectId.value=r.projectId;var s,o=r.clientId,a=t.ge({plugins:{WebSocketTransport:Dy,FetchRequest:Ly},authCallback:(s={instance:t.instance,getDistinctId:()=>t.hooks.getDistinctId(),getChannelScope:()=>{var e,i,n,r;return null!==(r=null!==(i=null!==(e=t.store.pendingRealtimeChannelId.value)&&void 0!==e?e:t.store.realtimeChannelId.value)&&void 0!==i?i:null===(n=t.store.channel.value)||void 0===n?void 0:n.id)&&void 0!==r?r:null},getLiveClientId:()=>{var e,i;return null!==(i=null===(e=t.de)||void 0===e?void 0:e.auth.clientId)&&void 0!==i?i:null},onIdentityChange:()=>t.hooks.onIdentityChange()},function(){var t=e(function*(t,e){try{var i=s.getChannelScope(),n=yield Hy(s.instance,s.getDistinctId(),null!=i?i:void 0);if(!(null==n?void 0:n.tokenRequest))return void e("Failed to refresh token",null);var r=n.tokenRequest.clientId,o=s.getLiveClientId();if(o&&r&&r!==o)return uu().warn(Vy,"token:request:clientid-mismatch — recreating connection"),e("clientId changed; recreating connection",null),void s.onIdentityChange();e(null,n.tokenRequest)}catch(t){e(String(t),null)}});return function(e,i){return t.apply(this,arguments)}}()),authMethod:"POST"});t.de=a,a.connection.on("connected",()=>{t.store.connectionState.value="connected",t.be(),uu().debug(Gy,"connect:connected")}),a.connection.on("disconnected",()=>{t.store.connectionState.value="disconnected",uu().debug(Gy,"connect:disconnected")}),a.connection.on("suspended",()=>{t.store.connectionState.value="suspended",uu().debug(Gy,"connect:suspended")}),a.connection.on("failed",()=>{t.store.connectionState.value="failed",uu().debug(Gy,"connect:failed")});try{yield a.auth.authorize(r.tokenRequest)}catch(e){return uu().error(Gy,Zy("connect:authorize-failed",e)),void(t.store.connectionState.value="failed")}var l=a.connection.state;"connected"===l?(t.store.connectionState.value="connected",t.be(),uu().debug(Gy,"connect:connected (sync)")):"disconnected"!==l&&"suspended"!==l&&"failed"!==l||(t.store.connectionState.value=l,uu().debug(Gy,"connect:"+l+" (sync)"));var h="chat:"+r.projectId+":notifications";t.ve=a.channels.get(h),t.ve.subscribe("notification",e=>{!function(t,e,n){var r,s,o,{type:a,channel_id:l,data:h}=e;if("new_channel"!==a)if("channel_updated"===a&&h){var u=t.channels.value.findIndex(t=>t.id===l);if(-1!==u){var c={};void 0!==h.last_message_at&&(c.last_message_at=h.last_message_at),void 0!==h.last_message_preview&&(c.last_message_preview=h.last_message_preview),void 0!==h.last_message_sender&&(c.last_message_sender=h.last_message_sender),void 0!==h.user_unread_count&&(t.isOpen.value&&(null===(r=t.channel.value)||void 0===r?void 0:r.id)===l||(c.unread_count=h.user_unread_count)),void 0!==h.status&&(c.status=h.status),void 0!==h.ai_mode&&(c.ai_mode=h.ai_mode),t.patchChannelSummary(l,c)}(null===(s=t.channel.value)||void 0===s?void 0:s.id)===l&&"closed"===h.status&&(t.channel.value=i({},t.channel.value,{status:"closed"}))}else"channel_closed"===a&&(t.patchChannelSummary(l,{status:"closed"}),(null===(o=t.channel.value)||void 0===o?void 0:o.id)===l&&(t.channel.value=i({},t.channel.value,{status:"closed"})));else n.onNewChannel()}(t.store,e.data,{onNewChannel:t.hooks.onNewChannelNotification})}),t.store.lastConnectedDistinctId.value=o.split(":").slice(1).join(":")||n}else t.store.connectionState.value="failed"}})()}refreshToken(t){var i=this;return e(function*(){var e=i.de;if(!e)return!1;if("failed"===e.connection.state)return uu().warn(Gy,"token:skip — connection failed"),i.hooks.onIdentityChange(),!1;var n=yield Hy(i.instance,i.hooks.getDistinctId(),t);if(!(null==n?void 0:n.tokenRequest))return uu().warn(Gy,"token:request:failed",null!=t?t:"(list)"),!1;var r=n.tokenRequest.clientId,s=e.auth.clientId;if(s&&r&&r!==s)return uu().warn(Gy,"token:request:clientid-mismatch — recreating connection"),i.hooks.onIdentityChange(),!1;try{return yield e.auth.authorize(n.tokenRequest),!0}catch(t){return uu().warn(Gy,Zy("token:authorize-failed",t)),!1}})()}attachConversation(t){var i=this;return e(function*(){var e;if(yield i.ensureConnected(),i.de&&null!=i.store.ablyProjectId.value){if(i.fe||i.pe||i.me){var n=null!==(e=i.me)&&void 0!==e?e:i.ye();try{yield n}catch(t){}}if(i.store.pendingRealtimeChannelId.value=t,!(yield i.refreshToken(t)))return uu().warn(Gy,"channel:attach:no-capability for",t),void(i.store.pendingRealtimeChannelId.value===t&&(i.store.pendingRealtimeChannelId.value=null));var r="chat:"+i.store.ablyProjectId.value+":"+t,s=r+":typing",o=i.de.channels.get(r),a=i.de.channels.get(s);i.fe=o,i.pe=a;var l=()=>i.fe!==o||i.pe!==a;uu().debug(Gy,"channel:attach:start",t);try{if(yield o.attach(),l())return void uu().debug(Gy,"channel:attach:superseded",t);if(o.subscribe("message",t=>{i.fe===o&&$y(i.store,t.data,i.hooks.getDistinctId()||null,{onAgentMessageWhileOpen:i.hooks.onAgentMessageWhileOpen,onTrack:i.hooks.onMessageTrack,onMessageDispatched:i.hooks.onMessageDispatched})}),o.subscribe("read",t=>{var e,n;i.fe===o&&(e=i.store,"agent"===(n=t.data).reader_type&&(e.agentLastReadAt.value=n.read_at))}),yield a.attach(),l())return void uu().debug(Gy,"channel:attach:superseded",t);if(a.subscribe("typing",t=>{i.pe===a&&function(t,e,i){if("user"!==e.sender_type){t.isTyping.value=e.is_typing,t.typingSenderType.value=e.is_typing?e.sender_type:null;var n="ai"===e.sender_type?null:e.sender_name||("agent"===e.sender_type?"Agent":null);t.typingSender.value=e.is_typing?n:null,i.onTyping(e.is_typing,n||"")}}(i.store,t.data,{onTyping:i.hooks.onTypingDispatched})}),i.store.pendingRealtimeChannelId.value!==t)return void uu().debug(Gy,"channel:attach:abandoned (pending cleared)",t);i.store.realtimeChannelId.value=t,i.store.realtimeAttached.value=!0,i.store.pendingRealtimeChannelId.value===t&&(i.store.pendingRealtimeChannelId.value=null),uu().debug(Gy,"channel:realtime.attached",{channelId:t})}catch(e){if(l())return void uu().debug(Gy,"channel:attach:superseded (after error)",t);uu().error(Gy,"channel:attach:failed",e),i.store.realtimeAttached.value=!1,i.store.pendingRealtimeChannelId.value===t&&(i.store.pendingRealtimeChannelId.value=null),yield i.ye()}}})()}detachConversation(){var t=this.ye().finally(()=>{this.me===t&&(this.me=null)});return this.me=t,t}ye(){var t=this.de,e=this.fe,i=this.pe;return this.fe=null,this.pe=null,Promise.all([this.we(t,e),this.we(t,i)]).then(()=>{})}publishTyping(t){var e=this.pe;e&&e.publish("typing",t).catch(t=>{uu().warn(Gy,"failed to publish typing indicator:",t)})}disconnectAll(){var t=this;return e(function*(){if(t.me)try{yield t.me}catch(t){}var e=t.de,i=t.fe,n=t.pe,r=t.ve;if(t.fe=null,t.pe=null,t.ve=null,t.store.realtimeChannelId.value=null,t.store.realtimeAttached.value=!1,null==i||i.unsubscribe(),null==n||n.unsubscribe(),null==r||r.unsubscribe(),e){try{e.close()}catch(t){uu().debug(Gy,"disconnect:close:error",t)}t.de=null}t.store.ablyProjectId.value=null,t.store.connectionState.value="disconnected",t.store.lastConnectedDistinctId.value=null})()}be(){var t,e=null===(t=this.de)||void 0===t?void 0:t.auth.clientId,i=this.store.lastConnectedDistinctId.value;if(e&&i){var n=e.split(":").slice(1).join(":")||e;n&&n!==i&&(uu().warn(Gy,"identity:drift detected on connected — recreating"),this.hooks.onIdentityChange())}}we(t,i){return e(function*(){if(i&&t){i.unsubscribe();try{yield i.detach()}catch(t){}}})()}}var Xy=["delivery_status"];function Qy(t,e,r){var s=t.messages.value,o=s.findIndex(t=>t.id===e);if(-1!==o){var a=s[o];if(a.delivery_status!==r){var l=[...s];if(void 0===r){var h=n(a,Xy);l[o]=h}else l[o]=i({},a,{delivery_status:r});t.setMessages(l)}}}function tw(t,e){return ew.apply(this,arguments)}function ew(){return ew=e(function*(t,e){var i;if(!t.ok)return!1;if(t.headers.get("X-Vtilt-User-Message-Id")===e)return!0;var n=t.headers.get("content-type")||"";if(n.includes("text/plain"))return t.ok;if(n.includes("application/json"))try{var r=yield t.clone().json();return(null===(i=null==r?void 0:r.message)||void 0===i?void 0:i.id)===e}catch(t){return!1}return t.ok}),ew.apply(this,arguments)}function iw(t,e){return"vtilt-chat-outbox:"+t+":"+e}function nw(t){return t+":last-channel"}class rw{constructor(t){this.ke=t,this.xe=[]}list(){var t=this.Se();return t.length>0?(this.xe=t,t):this.xe}get(t){return this.list().find(e=>e.messageId===t)}upsert(t){var e=this.list().filter(e=>e.messageId!==t.messageId);e.push(t),this.Ce(e)}patch(t,e){var n=this.list(),r=n.findIndex(e=>e.messageId===t);-1!==r&&(n[r]=i({},n[r],e),this.Ce(n))}remove(t){this.Ce(this.list().filter(e=>e.messageId!==t))}dueEntries(t){return void 0===t&&(t=Date.now()),this.list().filter(e=>"sending"!==e.state&&e.nextRetryAt<=t&&!(e.newChannel&&!e.channelId))}requeueStaleSending(t,e){var n;void 0===t&&(t=3e4),void 0===e&&(e=Date.now());for(var r=this.list(),s=!1,o=0;o<r.length;o++){var a=r[o];if("sending"===a.state){var l=null!==(n=a.sendingSince)&&void 0!==n?n:0;(!l||e-l>=t)&&(r[o]=i({},a,{state:"pending",sendingSince:void 0}),s=!0)}}s&&this.Ce(r)}Se(){if("undefined"==typeof sessionStorage)return[];try{var t=sessionStorage.getItem(this.ke);if(!t)return[];var e=JSON.parse(t);return Array.isArray(e)?e:[]}catch(t){return[]}}Ce(t){if(this.xe=t,"undefined"!=typeof sessionStorage)try{0===t.length?sessionStorage.removeItem(this.ke):sessionStorage.setItem(this.ke,JSON.stringify(t))}catch(t){}}}function sw(t,e){return void 0===e&&(e=Date.now()),e+Math.min(6e4,1e3*Math.pow(2,Math.max(0,t-1)))}var ow="chat";class aw{constructor(t,e){var n,r,s,o,a,l,h,u,c;void 0===e&&(e={}),this._e=null,this.Ie=new Od,this.Ae=[],this.Te=[],this.Ee=[],this.Me=null,this.Oe=null,this.Re=null,this.Ne=!1,this.Pe=null,this.Be=!1,this.De=0,this.je=0,this.Ue=!1,this.Le=null,this.Fe=!1,this.ze=null,this.We=null,this.$e=!1,this.Ve=null,this.He=null,this.qe=!1,this.Je=null,this.Ge=()=>{this.Ze()},this.Ye=()=>{"undefined"!=typeof document&&"visible"===document.visibilityState&&this.Ze()},this.Ke=!1,this._instance=t,this.H=i({enabled:!0,position:"bottom-right",aiMode:!0,preload:!1},e,{theme:i({},Lf,e.theme)}),this.Xe=new Ff,this.Xe.isVisible.value=!1!==(null===(n=this.H.bubble)||void 0===n?void 0:n.visible),this.Xe.theme.value={primaryColor:null!==(s=null===(r=this.H.theme)||void 0===r?void 0:r.primaryColor)&&void 0!==s?s:Lf.primaryColor,fontFamily:null!==(a=null===(o=this.H.theme)||void 0===o?void 0:o.fontFamily)&&void 0!==a?a:Lf.fontFamily,borderRadius:null!==(h=null===(l=this.H.theme)||void 0===l?void 0:l.borderRadius)&&void 0!==h?h:Lf.borderRadius},this.Ie.register(Qv),this.Ie.register(cf),this.Qe=new Ky(t,this.Xe,{getDistinctId:()=>this.ti,onIdentityChange:()=>{this.ei()},onNewChannelNotification:()=>{this.getChannels()},onAgentMessageWhileOpen:()=>{setTimeout(()=>this.ii(),100)},onMessageTrack:t=>{var e,i,n,r;this.ni(t,t.channel_id,null!==(i=null===(e=this.Xe.channel.value)||void 0===e?void 0:e.ai_mode)&&void 0!==i&&i),"ai"!==t.sender_type&&"agent"!==t.sender_type||null===(r=(n=this.H).onMessageReceived)||void 0===r||r.call(n,{channelId:t.channel_id,messageId:t.id,senderType:t.sender_type})},onMessageDispatched:t=>{this.Ae.forEach(e=>e(t))},onTypingDispatched:(t,e)=>{this.Te.forEach(i=>i(t,e))}}),this.He=this.ri(),this.Le=this.Xe.realtimeReady.subscribe(t=>{if(t&&this.Ue){var e=Date.now()-this.je;this.Ue=!1,e<3e3&&(this.Be=!0,this.si(!0),this.De=Date.now(),this.oi())}}),this._e=rm({store:this.Xe,controller:this,position:null!==(u=this.H.position)&&void 0!==u?u:"bottom-right",bubbleDraggable:!!(null===(c=this.H.bubble)||void 0===c?void 0:c.draggable)}),this.ai(),this.Oe=this._instance._emitter.on("user:identified",()=>{this.ei()}),this.Re=this._instance._emitter.on("user:reset",()=>{this.ei()}),this.li=this.ti,this.hi=new rw(this.ui()),this.hi.requeueStaleSending(),this.ci(),this.Ze()}get isOpen(){return this.Xe.isOpen.value}get isConnected(){return this.Xe.isConnected.value}get isLoading(){return this.Xe.isLoading.value}get unreadCount(){return this.Xe.unreadCount.value}get channel(){return this.Xe.channel.value}get channels(){return this.Xe.channels.value}get currentView(){return this.Xe.currentView.value}get store(){return this.Xe}get widgets(){return this.Ie}get theme(){return this.Xe.theme.value}get config(){return this.H}open(){var t,e;this.Xe.isOpen.value||(this.Xe.isVisible.value=!0,this.Xe.isOpen.value=!0,this.Xe.polledUnreadTotal.value=null,this.Ve=Date.now(),null===(e=(t=this.H).onWidgetOpen)||void 0===e||e.call(t),this.Qe.ensureConnected(),0===this.Xe.channels.value.length&&this.getChannels())}close(){var t,e,i;if(this.Xe.isOpen.value){var n=this.Ve?Math.round((Date.now()-this.Ve)/1e3):0;this.Ve=null,this.Xe.isOpen.value=!1,this.stopUserTyping(),this.Ke||!1!==(null===(t=this.H.bubble)||void 0===t?void 0:t.visible)||(this.Xe.isVisible.value=!1);var r=this.Xe.messages.value.filter(t=>"user"===t.sender_type).length;null===(i=(e=this.H).onWidgetClose)||void 0===i||i.call(e,{timeOpenSeconds:n,messagesSent:r}),this.di()}}di(){var t=this;return e(function*(){yield t.Qe.detachConversation(),yield t.Qe.disconnectAll()})()}applyPolledUnreadCount(t){this.Xe.isOpen.value||(this.Xe.polledUnreadTotal.value=t)}toggle(){this.Xe.isOpen.value?this.close():this.open()}show(){this.Ke=!0,this.Xe.isVisible.value=!0}hide(){this.Ke=!1,this.Xe.isVisible.value=!1}getChannels(){var t=this;return e(function*(){t.Xe.isLoading.value=!0;try{var e=yield Sd(t._instance,yd+"?distinct_id="+encodeURIComponent(t.ti),{method:"GET"});e&&(t.Xe.channels.value=e.channels||[])}catch(t){uu().error(ow,"failed to fetch channels:",t)}finally{t.Xe.isLoading.value=!1}})()}selectChannel(t){var i=this;return e(function*(){var e=i.Xe.channels.value.find(e=>e.id===t);i.Xe.channel.value=e?i.fi(e):null,i.Xe.prepareChannelSwitch();var n=i.Xe.getCachedMessages(t);n&&(i.Xe.messages.value=n),i.Xe.currentView.value="conversation",i.Xe.isLoading.value=!0,i.Xe.pendingRealtimeChannelId.value=t,i.Qe.detachConversation();var r=!1,s=!1;try{var o=yield Sd(i._instance,yd+"/"+t+"?distinct_id="+encodeURIComponent(i.ti),{method:"GET"});if(i.Xe.pendingRealtimeChannelId.value!==t)return void(s=!0);if(!o)return void uu().error(ow,"selectChannel: server returned no data for channel",t);i.Xe.channel.value=o.channel;var a=o.messages||[];i.Xe.messages.value=a,i.Xe.cacheMessages(o.channel.id,a),i.Xe.agentLastReadAt.value=o.channel.agent_last_read_at||null,i.Xe.initialUserReadAt.value=o.channel.user_last_read_at||null,i.Qe.attachConversation(o.channel.id),i.Xe.isOpen.value&&i.ii(),r=!0}catch(t){uu().error(ow,"failed to select channel:",t)}finally{i.Xe.pendingRealtimeChannelId.value===t&&(i.Xe.pendingRealtimeChannelId.value=null),i.Xe.isLoading.value=!1,s||r||null!==i.Xe.channel.value||"conversation"!==i.Xe.currentView.value||(i.Xe.currentView.value="list")}})()}createChannel(t){var n=this;return e(function*(){var e,r,s,o=!0===(null==t?void 0:t.skipGreeting),a=!0===(null==t?void 0:t.preserveMessages),l=a?n.Xe.messages.value.slice():[];n.Xe.channel.value=null,a||n.Xe.prepareChannelSwitch(),n.Xe.currentView.value="conversation",n.Xe.isLoading.value=!0,n.Qe.detachConversation();var h=!1;try{var u=yield Sd(n._instance,yd,{method:"POST",body:JSON.stringify(i({distinct_id:n.ti,page_url:null===(e=null==zh?void 0:zh.location)||void 0===e?void 0:e.href,page_title:"undefined"!=typeof document?document.title:""},o&&{skip_greeting:!0}))});if(!u)return void uu().error(ow,"createChannel: server returned no data, channel was not created");n.Xe.channel.value=u.channel;var c=u.messages||[];if(l.length>0){var d=new Set(c.map(t=>t.id)),v=l.filter(t=>!d.has(t.id)).map(t=>t.channel_id?t:i({},t,{channel_id:u.channel.id}));n.Xe.messages.value=[...c,...v]}else n.Xe.messages.value=c;n.Xe.agentLastReadAt.value=u.channel.agent_last_read_at||null,n.Xe.initialUserReadAt.value=u.channel.user_last_read_at||null;var f={id:u.channel.id,status:u.channel.status,ai_mode:u.channel.ai_mode,last_message_at:u.channel.last_message_at,last_message_preview:u.channel.last_message_preview,last_message_sender:u.channel.last_message_sender,unread_count:0,user_last_read_at:u.channel.user_last_read_at,created_at:u.channel.created_at};n.Xe.prependChannelSummary(f),null===(s=(r=n.H).onConversationStart)||void 0===s||s.call(r,{channelId:u.channel.id,aiMode:u.channel.ai_mode}),n.Qe.attachConversation(u.channel.id),n.pi(u.channel.id),n.mi(u.channel.id),h=!0}catch(t){uu().error(ow,"failed to create channel:",t)}finally{if(n.Xe.pendingRealtimeChannelId.value=null,n.Xe.isLoading.value=!1,!h&&null===n.Xe.channel.value)if(l.length>0){var p=new Set(n.hi.list().map(t=>t.messageId)),m=l.filter(t=>p.has(t.id));m.length>0?(n.Xe.messages.value=m.map(t=>t.delivery_status?t:i({},t,{delivery_status:"failed"})),n.Xe.currentView.value="conversation"):(n.Xe.messages.value=[],n.Xe.currentView.value="list")}else n.Xe.currentView.value="list"}})()}goToChannelList(){var t,e,i,n=this.Xe.channel.value;if(n){var r=this.Xe.messages.value[this.Xe.messages.value.length-1];this.Xe.patchChannelSummary(n.id,{last_message_at:null!==(t=null==r?void 0:r.created_at)&&void 0!==t?t:void 0,last_message_preview:r?(i=r.content,i.replace(/\n?<!--vtilt:widget:[\s\S]*?-->/g,"").replace(/<[^>]*>/g,"").trim().substring(0,100)):void 0,last_message_sender:null!==(e=null==r?void 0:r.sender_type)&&void 0!==e?e:void 0,unread_count:0}),this.Xe.cacheMessages(n.id,this.Xe.messages.value)}this.Xe.clearActiveChannel(),this.Xe.currentView.value="list",this.Qe.detachConversation().then(()=>{this.Qe.isLive&&!this.Xe.pendingRealtimeChannelId.value&&this.Qe.refreshToken()})}gi(){this.ze&&(this.ze.abort(),this.ze=null),this.We&&(Up(this.Xe,this.We),this.We=null),this.bi(),this.yi()}bi(){for(var t=this.Xe.messages.value,e=-1,i=t.length-1;i>=0;i--)if("user"===t[i].sender_type){e=i;break}if(-1!==e){var n=t.filter((t,i)=>i<=e||"ai"!==t.sender_type);n.length!==t.length&&this.Xe.setMessages(n)}}wi(){this.$e=!0,this.Xe.isTyping.value=!0,this.Xe.typingSenderType.value="ai",this.Xe.typingSender.value="AI Assistant"}yi(){this.$e&&(this.$e=!1,this.Xe.isTyping.value=!1,this.Xe.typingSender.value=null,this.Xe.typingSenderType.value=null)}sendMessage(t,n){var r=this;return e(function*(){var e,s=Ed(t,n);if(s){r.Xe.identityChangeInFlight.value&&(yield r.ki());var{content:o,content_type:a,metadata:l}=s,h=!1!==(null==n?void 0:n.open),u="conversation"===r.Xe.currentView.value&&null!==r.Xe.channel.value,c=null!==(e=null==n?void 0:n.channel)&&void 0!==e?e:u?void 0:"new",d=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();var t=crypto.getRandomValues(new Uint8Array(16));t[6]=15&t[6]|64,t[8]=63&t[8]|128;var e=t=>t.toString(16).padStart(2,"0");return e(t[0])+e(t[1])+e(t[2])+e(t[3])+"-"+e(t[4])+e(t[5])+"-"+e(t[6])+e(t[7])+"-"+e(t[8])+e(t[9])+"-"+e(t[10])+e(t[11])+e(t[12])+e(t[13])+e(t[14])+e(t[15])}(),v=(new Date).toISOString(),f="new"===c;if(r.xi(i({messageId:d,channelId:"",distinctId:r.ti,body:o,content_type:a,metadata:l,created_at:v,state:"pending",attempts:0,nextRetryAt:0},f?{newChannel:{skipGreeting:!0}}:{})),r.Si(d),f){r.Xe.currentView.value="conversation",r.Xe.channel.value=null;var p={id:d,channel_id:"",sender_type:"user",sender_id:r.ti||null,sender_name:null,sender_avatar_url:null,content:o,content_type:a,metadata:l,created_at:v,delivery_status:"pending"};r.Xe.setMessages([p]),r.Xe.isLoading.value=!0,h&&r.open(),yield r.createChannel({skipGreeting:!0,preserveMessages:!0})}else h&&r.open(),c&&(yield r.selectChannel(c));if(!r.Xe.channel.value)throw uu().error(ow,"cannot send message: no active channel (channel creation or selection failed)"),r.hi.patch(d,{state:"failed"}),Qy(r.Xe,d,"failed"),new Error("No active channel");if("conversation"!==r.Xe.currentView.value)throw uu().error(ow,"cannot send message: not in conversation view"),r.hi.patch(d,{state:"failed"}),Qy(r.Xe,d,"failed"),new Error("Not in conversation view");var m,g=r.Xe.channel.value.id;if(r.hi.patch(d,{channelId:g,newChannel:void 0}),f){var b=r.Xe.messages.value.find(t=>t.id===d);if(!b)throw uu().error(ow,"sendMessage: optimistic temp message was lost during createChannel"),r.hi.patch(d,{state:"failed"}),new Error("Optimistic message lost");m=b}else m={id:d,channel_id:g,sender_type:"user",sender_id:r.ti||null,sender_name:null,sender_avatar_url:null,content:o,content_type:a,metadata:l,created_at:v,delivery_status:"pending"},r.Xe.setMessages([...r.Xe.messages.value,m]);try{yield r.Ci({messageId:d,channelId:g,body:o,content_type:a,metadata:l,tempMessage:m})}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)throw r.Ii(d),t;throw r.yi(),uu().error(ow,"failed to send message:",t),r.Ii(d),r.Ze(),t}}else uu().warn(ow,"sendMessage: message is empty")})()}retryFailedMessage(t){var e,i=this.hi.get(t);if(i&&"failed"===i.state){this.hi.patch(t,{state:"pending",nextRetryAt:0,sendingSince:void 0}),Qy(this.Xe,t,"pending");var n=i.channelId||(null===(e=this.Xe.channel.value)||void 0===e?void 0:e.id)||"";if(n){var r=this.Xe.messages.value.find(e=>e.id===t);r?(this.Si(t),this.Ci({messageId:t,channelId:n,body:i.body,content_type:i.content_type,metadata:i.metadata,tempMessage:r}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name?this.Ii(t):(uu().error(ow,"retry send failed:",e),this.Ii(t),this.Ze())})):this.Ze()}}}markAsRead(){this.ii()}triggerAIAfterWidgetAction(t){var n=this;return e(function*(){try{n.gi();var e=new AbortController;n.ze=e,n.wi();var r=n._instance.getConfig(),s=fu(r,wd(t)),o=yield fetch(s,{method:"POST",signal:e.signal,headers:i({"Content-Type":"application/json"},pu(r)),body:JSON.stringify({channel_id:t,distinct_id:n.ti,widget_action_trigger:!0})});if(!o.ok)return void n.yi();(o.headers.get("content-type")||"").includes("text/plain")&&(yield Dp({store:n.Xe,response:o,channelId:t,signal:e.signal,isActive:()=>n.ze===e,onStreamStart:t=>{n.yi(),n.ze===e&&(n.We=t)},onComplete:()=>{n.ze===e&&(n.ze=null,n.We=null)}}))}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return}})()}onMessage(t){return this.Ae.push(t),()=>{var e=this.Ae.indexOf(t);e>-1&&this.Ae.splice(e,1)}}onTyping(t){return this.Te.push(t),()=>{var e=this.Te.indexOf(t);e>-1&&this.Te.splice(e,1)}}onConnectionChange(t){return this.Ee.push(t),()=>{var e=this.Ee.indexOf(t);e>-1&&this.Ee.splice(e,1)}}updateConfig(t){var e,n,r,s,o,a,l;this.H=function(t,e){var n,r,s=e.bubble,o=t.bubble;if(s){var a=null===s.offset?void 0:void 0!==s.offset?i({},null===(n=t.bubble)||void 0===n?void 0:n.offset,s.offset):null===(r=t.bubble)||void 0===r?void 0:r.offset;o=i({},t.bubble,s,{offset:a})}return i({},t,e,{theme:e.theme?i({},t.theme,e.theme):t.theme,bubble:o})}(this.H,t),this.Xe.theme.value={primaryColor:null!==(n=null===(e=this.H.theme)||void 0===e?void 0:e.primaryColor)&&void 0!==n?n:Lf.primaryColor,fontFamily:null!==(s=null===(r=this.H.theme)||void 0===r?void 0:r.fontFamily)&&void 0!==s?s:Lf.fontFamily,borderRadius:null!==(a=null===(o=this.H.theme)||void 0===o?void 0:o.borderRadius)&&void 0!==a?a:Lf.borderRadius},(null===(l=this.H.bubble)||void 0===l?void 0:l.draggable)||this.ai()}ai(){var t,e,i,n,r=null===(t=this._e)||void 0===t?void 0:t.host;if(r){var s=null!==(e=this.H.position)&&void 0!==e?e:"bottom-right";!function(t,e){t.style.setProperty("--vt-bubble-offset-bottom",e.bottom+"px"),t.style.setProperty("--vt-bubble-offset-right",e.right+"px"),t.style.setProperty("--vt-bubble-offset-left",e.left+"px")}(r,$f(null===(i=this.H.bubble)||void 0===i?void 0:i.offset));var o=null===(n=r.shadowRoot)||void 0===n?void 0:n.querySelector(".vt-container");o instanceof HTMLElement&&o.setAttribute("data-position",s)}}registerWidget(t){this.Ie.register(t)}notifyUserTyping(){this.je=Date.now(),this.Xe.realtimeReady.value?(this.Be?Date.now()-this.De>4e3&&(this.si(!0),this.De=Date.now()):(this.Be=!0,this.si(!0),this.De=Date.now()),this.oi()):this.Ue=!0}stopUserTyping(){this.Ue=!1,this.Pe&&(clearTimeout(this.Pe),this.Pe=null),this.Be&&this.Xe.realtimeReady.value&&this.si(!1),this.Be=!1}oi(){this.Pe&&clearTimeout(this.Pe),this.Pe=setTimeout(()=>{this.Pe=null,this.Be&&this.Xe.realtimeReady.value&&this.si(!1),this.Be=!1},5e3)}destroy(){var t,e,i,n,r;this.Ai(),this.Je&&(clearTimeout(this.Je),this.Je=null),this.Qe.disconnectAll(),this.Pe&&(clearTimeout(this.Pe),this.Pe=null),null===(t=this.Oe)||void 0===t||t.call(this),this.Oe=null,null===(e=this.Re)||void 0===e||e.call(this),this.Re=null,null===(i=this.He)||void 0===i||i.call(this),this.He=null,null===(n=this.Le)||void 0===n||n.call(this),this.Le=null,null===(r=this._e)||void 0===r||r.destroy(),this._e=null,this.Ae=[],this.Te=[],this.Ee=[]}getWidgetContext(t,i){var n,r,s,o=this,a=this._instance.getConfig();return{channelId:null!==(r=null===(n=this.Xe.channel.value)||void 0===n?void 0:n.id)&&void 0!==r?r:"",distinctId:this.ti,primaryColor:this.Xe.theme.value.primaryColor,apiBase:a.api_host||"",token:a.token||"",messageId:t,buildEndpointUrl:t=>fu(this._instance.getConfig(),t),dispatch:(s=e(function*(e,n){var r=o.Ie.get(i);if(r){var s=o.getWidgetContext(t,i);try{var a=yield r.onAction(e,n,s);(null==a?void 0:a.success)&&o.markWidgetSubmittedAndFollowUp(t,i,n)}catch(t){uu().warn(ow,"widget action failed:",t)}}}),function(t,e){return s.apply(this,arguments)})}}markWidgetSubmittedAndFollowUp(t,e,n){var r,s,o,a,l=this.Xe.messages.value.find(e=>e.id===t);if(l){var h=i({},null!==(r=l.metadata)&&void 0!==r?r:{}),u=(null!==(o=null!==(s=h.At)&&void 0!==s?s:h.widgets)&&void 0!==o?o:[]).map(t=>{if(t.type!==e)return t;var r=i({},t,{submitted:!0});return n.email&&(r.submittedEmail=String(n.email).trim()),n.name&&(r.submittedName=String(n.name).trim()),r});h.widgets=u,h.At&&(h.At=u);var c=this.Xe.messages.value.map(e=>e.id===t?i({},e,{metadata:h}):e);this.Xe.setMessages(c);var d=null===(a=this.Xe.channel.value)||void 0===a?void 0:a.id;"escalate_to_human"!==e&&d&&this.triggerAIAfterWidgetAction(d)}}ui(){return iw(this._instance.getConfig().token||"unknown",this.ti)}Ti(){this.hi=new rw(this.ui()),this.hi.requeueStaleSending()}Si(t){this.hi.patch(t,{state:"sending",sendingSince:Date.now()})}Ii(t){var e,i,n=(null!==(i=null===(e=this.hi.get(t))||void 0===e?void 0:e.attempts)&&void 0!==i?i:0)+1;this.hi.patch(t,{state:"failed",attempts:n,nextRetryAt:sw(n),sendingSince:void 0}),Qy(this.Xe,t,"failed")}pi(t){for(var e of this.hi.list())e.newChannel&&!e.channelId&&this.hi.patch(e.messageId,{channelId:t,newChannel:void 0})}mi(t){!function(t,e){if("undefined"!=typeof sessionStorage)try{sessionStorage.setItem(nw(t),JSON.stringify({channelId:e,at:Date.now()}))}catch(t){}}(this.ui(),t)}Ei(t){var e=this.ti;if(t&&t!==e){var n=this._instance.getConfig().token||"unknown",r=new rw(iw(n,t)),s=r.list();for(var o of s)this.hi.upsert(i({},o,{distinctId:e})),r.remove(o.messageId)}}ci(){"undefined"!=typeof window&&(window.addEventListener("online",this.Ge),document.addEventListener("visibilitychange",this.Ye))}Ai(){"undefined"!=typeof window&&(window.removeEventListener("online",this.Ge),document.removeEventListener("visibilitychange",this.Ye))}xi(t){this.hi.upsert(t)}Mi(t,e){var i,n;this.hi.remove(t),Qy(this.Xe,t,void 0),null===(n=(i=this.H).onMessageDelivered)||void 0===n||n.call(i,{channelId:e,messageId:t})}Ze(){this.Je&&clearTimeout(this.Je),this.Je=setTimeout(()=>{this.Je=null,this.Oi()},0)}Oi(){var t=this;return e(function*(){if(!t.qe){t.qe=!0,t.hi.requeueStaleSending();try{var e=Date.now(),i=function*(e){var i=t.Xe.messages.value.some(t=>t.id===e.messageId&&"sending"===t.delivery_status);if(i)return 1;try{yield t.Ri(e)}catch(i){uu().warn(ow,"outbox drain failed:",i);var n=e.attempts+1;t.hi.patch(e.messageId,{state:"failed",attempts:n,nextRetryAt:sw(n)}),Qy(t.Xe,e.messageId,"failed")}};for(var n of t.hi.dueEntries(e))yield*i(n)}finally{t.qe=!1;var r=t.hi.dueEntries(Date.now());if(r.length>0){var s=Math.max(0,r[0].nextRetryAt-Date.now());t.Je=setTimeout(()=>{t.Je=null,t.Oi()},s)}}}})()}Ri(t){var i=this;return e(function*(){var e=t.channelId||void 0;if(!e&&t.newChannel){var n=function(t,e){if(void 0===e&&(e=Date.now()),"undefined"==typeof sessionStorage)return null;try{var i=sessionStorage.getItem(nw(t));if(!i)return null;var n=JSON.parse(i);return!(null==n?void 0:n.channelId)||"number"!=typeof n.at||e-n.at>12e4?null:n}catch(t){return null}}(i.ui());n&&(e=n.channelId,i.hi.patch(t.messageId,{channelId:e,newChannel:void 0}))}if(!e&&t.newChannel){var r=yield i.Ni(t.newChannel.skipGreeting);if(!(e=null!=r?r:void 0))throw new Error("Failed to create channel for outbox entry");i.hi.patch(t.messageId,{channelId:e,newChannel:void 0}),i.mi(e)}if(!e)throw new Error("Outbox entry missing channelId");var s=i.Xe.messages.value.find(e=>e.id===t.messageId);if(s)return i.Si(t.messageId),void(yield i.Ci({messageId:t.messageId,channelId:e,body:t.body,content_type:t.content_type,metadata:t.metadata,tempMessage:s}));yield i.Pi({messageId:t.messageId,channelId:e,body:t.body,content_type:t.content_type,metadata:t.metadata}),i.Mi(t.messageId,e)})()}Ni(t){var n=this;return e(function*(){var e,r,s,o=yield Sd(n._instance,yd,{method:"POST",body:JSON.stringify(i({distinct_id:n.ti,page_url:null===(e=null==zh?void 0:zh.location)||void 0===e?void 0:e.href,page_title:"undefined"!=typeof document?document.title:""},t&&{skip_greeting:!0}))}),a=null!==(s=null===(r=null==o?void 0:o.channel)||void 0===r?void 0:r.id)&&void 0!==s?s:null;return a&&(n.pi(a),n.mi(a)),a})()}Pi(t){var n=this;return e(function*(){var e,r=n._instance.getConfig(),s=fu(r,wd(t.channelId)),o=yield fetch(s,{method:"POST",keepalive:!0,headers:i({"Content-Type":"application/json"},pu(r)),body:JSON.stringify({id:t.messageId,channel_id:t.channelId,distinct_id:n.ti,content:t.body,content_type:t.content_type,metadata:t.metadata})});if(!o.ok)throw new Error("API error: "+o.status);if(!(yield tw(o,t.messageId)))throw new Error("User message not acknowledged");(o.headers.get("content-type")||"").includes("text/plain")&&(yield null===(e=o.body)||void 0===e?void 0:e.cancel().catch(()=>{}))})()}Ci(t){var n=this;return e(function*(){var e,r,s,o,a,{messageId:l,channelId:h,body:u,content_type:c,metadata:d,tempMessage:v}=t;Qy(n.Xe,l,"sending"),n.gi();var f=new AbortController;n.ze=f,!1!==(null===(e=n.Xe.channel.value)||void 0===e?void 0:e.ai_mode)&&n.wi();var p=n._instance.getConfig(),m=fu(p,wd(h)),g=yield fetch(m,{method:"POST",keepalive:!0,signal:f.signal,headers:i({"Content-Type":"application/json"},pu(p)),body:JSON.stringify({id:l,channel_id:h,distinct_id:n.ti,content:u,content_type:c,metadata:d})});if(!g.ok)throw new Error("API error: "+g.status);if(!(yield tw(g,l)))throw new Error("User message not acknowledged");if(n.Mi(l,h),(g.headers.get("content-type")||"").includes("text/plain"))yield Dp({store:n.Xe,response:g,channelId:h,signal:f.signal,isActive:()=>n.ze===f,onStreamStart:t=>{n.yi(),n.ze===f&&(n.We=t)},onComplete:()=>{var t,e,i,r;n.ze===f&&(n.ze=null,n.We=null),null===(e=(t=n.H).onMessageSent)||void 0===e||e.call(t,{channelId:h,messageId:v.id}),n.ni(v,h,null===(r=null===(i=n.Xe.channel.value)||void 0===i?void 0:i.ai_mode)||void 0===r||r)}});else{n.yi(),n.ze===f&&(n.ze=null);var b=yield g.json();if(null==b?void 0:b.message){var y=n.Xe.messages.value.findIndex(t=>t.id===b.message.id);if(-1===y&&(y=n.Xe.messages.value.findIndex(t=>t.id===l)),-1!==y){var w=[...n.Xe.messages.value];w[y]=b.message,n.Xe.setMessages(w)}null===(s=(r=n.H).onMessageSent)||void 0===s||s.call(r,{channelId:h,messageId:b.message.id}),n.ni(b.message,h,null!==(a=null===(o=n.Xe.channel.value)||void 0===o?void 0:o.ai_mode)&&void 0!==a&&a)}}})()}get ti(){return this._instance.getDistinctId()||""}fi(t){return{id:t.id,project_id:"",person_id:"",distinct_id:this.ti,status:t.status,ai_mode:t.ai_mode,unread_count:t.unread_count,last_message_at:t.last_message_at,last_message_preview:t.last_message_preview,last_message_sender:t.last_message_sender,user_last_read_at:t.user_last_read_at,agent_last_read_at:null,created_at:t.created_at}}ei(){var t=this;return e(function*(){if(!t.Ne){var e=t.ti;if(e&&e!==t.Xe.lastConnectedDistinctId.value){t.Ne=!0,t.Xe.identityChangeInFlight.value=!0,t.Xe.clearActiveChannel(),t.Xe.currentView.value="list",t.Ei(t.li),t.Ti(),t.li=e;try{yield t.Qe.disconnectAll(),t.Xe.channels.value=[],t.Xe.clearMessagesCache(),yield t.getChannels(),t.Xe.isOpen.value&&(yield t.Qe.ensureConnected()),t.Ze()}catch(t){uu().error(ow,"failed to recreate Ably client after identity change:",t)}finally{t.Ne=!1,t.Xe.identityChangeInFlight.value=!1}}}})()}ki(){return new Promise(t=>{if(this.Xe.identityChangeInFlight.value)var e=this.Xe.identityChangeInFlight.subscribe(i=>{i||(e(),t())});else t()})}ni(t,e,i){var n,r=this._instance.getRemoteConfig(),s=null==r?void 0:r.chatTracking;if("user"===t.sender_type){if(!1===(null==s?void 0:s.trackUserMessages))return}else if(("ai"===t.sender_type||"agent"===t.sender_type)&&!1===(null==s?void 0:s.trackAgentMessages))return;this._instance.capture(Md,{$channel_type:"chat",$conversation_id:e,$message_id:t.id,$direction:"user"===t.sender_type?"inbound":"outbound",$sender_type:t.sender_type,$content_preview:(null!==(n=t.content)&&void 0!==n?n:"").slice(0,100),$ai_mode:i})}ii(){var t,e=this.Xe.channel.value;if(e&&!this.Fe){var i=this.Xe.messages.value,n=i[i.length-1];if(n){var r=this.Xe.initialUserReadAt.value,s=i.some(t=>{return!("agent"!==t.sender_type&&"ai"!==t.sender_type||(e=t.created_at,r&&new Date(e)<=new Date(r)));var e}),o=this.Xe.channels.value.find(t=>t.id===e.id),a=(null!==(t=null==o?void 0:o.unread_count)&&void 0!==t?t:0)>0;(s||a)&&(this.Fe=!0,Sd(this._instance,kd(e.id),{method:"POST",body:JSON.stringify({channel_id:e.id,distinct_id:this.ti,read_at:n.created_at})}).then(t=>{t&&(this.Xe.initialUserReadAt.value=n.created_at,this.Xe.patchChannelSummary(e.id,{unread_count:0})),this.Fe=!1}).catch(()=>{this.Fe=!1}))}}}si(t){this.Qe.publishTyping({sender_type:"user",sender_name:null,is_typing:t,sender_id:this.ti})}ri(){return this.Xe.isConnected.subscribe(t=>{this.Me!==t&&(this.Me=t,this.Ee.forEach(e=>e(t)))})}}Gh.__VTiltExtensions__=Gh.__VTiltExtensions__||{},Gh.__VTiltExtensions__.initChat=function(t,e){return new aw(t,e)};var lw="external-scripts";Gh.__VTiltExtensions__=Gh.__VTiltExtensions__||{},Gh.__VTiltExtensions__.loadExternalDependency=(t,e,i)=>{if(function(t){var e=Gh.__VTiltExtensions__;if(!e)return!1;switch(t){case"chat":return!!e.initChat;case"recorder":return!!e.initSessionRecording;case"web-vitals":return!!e.webVitalsCallbacks;default:return!1}}(e))i();else{var n=((t,e)=>{var i=t.getConfig();return i.script_host?i.script_host.replace(/\/+$/gm,"")+"/"+e+".js":i.api_host?i.api_host.replace(/\/+$/gm,"")+"/dist/"+e+".js":(uu().error(lw,"cannot load "+e+".js: api_host is required"),"")})(t,e);((t,e,i)=>{if(t.getConfig().disable_external_dependency_loading)return uu().warn(lw,e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var n=null==Vh?void 0:Vh.querySelectorAll("script");if(n)for(var r,s=function(){if(n[o].src===e){var t=n[o];return t.__vtilt_loading_callback_fired?{v:i()}:(t.addEventListener("load",e=>{t.__vtilt_loading_callback_fired=!0,i(void 0,e)}),t.onerror=t=>i(t),{v:void 0})}},o=0;o<n.length;o++)if(r=s())return r.v;var a=()=>{var t;if(!Vh)return i("document not found");var n=Vh.createElement("script");n.type="text/javascript",n.crossOrigin="anonymous",n.src=e,n.onload=t=>{n.__vtilt_loading_callback_fired=!0,i(void 0,t)},n.onerror=t=>i(t);var r=Vh.querySelectorAll("body > script");r.length>0?null===(t=r[0].parentNode)||void 0===t||t.insertBefore(n,r[0]):Vh.body.appendChild(n)};(null==Vh?void 0:Vh.body)?a():null==Vh||Vh.addEventListener("DOMContentLoaded",a)})(t,n,i)}};var hw="1.13.1",uw="__vt_session",cw="__vt_window_id",dw="__vt_primary_window",vw="__vt_user_state",fw="__vt_device_id",pw="__vt_anonymous_id",mw="__vt_remote_config",gw="__vt_distinct_id",bw="__vt_user_properties",yw="localStorage",ww="localStorage+cookie",kw="sessionStorage",xw="memory",Sw="$initial_person_info",Cw="$pageview",_w="$pageleave",Iw="$identify",Aw="$alias",Tw="$set",Ew="$performance_event",Mw="$autocapture",Ow="$scroll_depth",Rw="$snapshot",Nw="$snapshot_items",Pw="$$client_ingestion_warning",Bw="$current_url",Dw="$pathname",jw="$prev_pageview_duration",Uw="$prev_pageview_pathname",Lw="$prev_pageview_url",Fw="$scroll_depth_pct",zw="$scroll_depth_max_pct",Ww="$prev_pageview_scroll_depth_pct";function $w(t,e){var n,r,s=e.bubble,o=null==t?void 0:t.bubble;if(s){var a=null===s.offset?void 0:void 0!==s.offset?i({},null===(n=null==t?void 0:t.bubble)||void 0===n?void 0:n.offset,s.offset):null===(r=null==t?void 0:t.bubble)||void 0===r?void 0:r.offset;o=i({},null==t?void 0:t.bubble,s,{offset:a})}return i({},t,e,{bubble:o})}class Vw{constructor(t){void 0===t&&(t={}),this.config=this.parseConfigFromScript(t)}parseConfigFromScript(t){if(!(null==Vh?void 0:Vh.currentScript))return i({token:t.token||""},t);var e=Vh.currentScript,n=i({token:""},t);n.api_host=e.getAttribute("data-api-host")||e.getAttribute("data-host")||t.api_host,n.script_host=e.getAttribute("data-script-host")||t.script_host,n.token=e.getAttribute("data-token")||t.token||"",n.domain=e.getAttribute("data-domain")||t.domain,n.storage=e.getAttribute("data-storage")||t.storage,n.stringifyPayload="false"!==e.getAttribute("data-stringify-payload");var r="true"===e.getAttribute("data-capture-performance");for(var s of(n.capture_performance=!!r||t.capture_performance,n.globalAttributes=i({},t.globalAttributes),Array.from(e.attributes)))s.name.startsWith("data-vt-")&&(n.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return n}getConfig(){return i({},this.config)}updateConfig(t){var e=function(t,e){return void 0===e.chat?e:i({},e,{chat:$w(t.chat,e.chat)})}(this.config,t);this.config=i({},this.config,e)}}var Hw=[pw,fw,gw,vw],qw=31536e3,Jw=["herokuapp.com","vercel.app","netlify.app"];function Gw(t){var e;if(!t||"undefined"==typeof document)return"";var i=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!i)return"";var n=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return n?"."+n[0]:""}class Zw{constructor(t){var e,i,n;this.memoryStorage=new Map,this.Bi=null,this.method=t.method,this.cross_subdomain=null!==(e=t.cross_subdomain)&&void 0!==e?e:function(){var t;if("undefined"==typeof document)return!1;var e=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!e)return!1;var i=e.split(".").slice(-2).join(".");return!Jw.includes(i)}(),this.sameSite=null!==(i=t.sameSite)&&void 0!==i?i:"Lax",this.secure=null!==(n=t.secure)&&void 0!==n?n:"undefined"!=typeof location&&"https:"===location.protocol}isLocalStorageSupported(){if(null!==this.Bi)return this.Bi;if(void 0===zh||!zh.localStorage)return this.Bi=!1,!1;try{var t="__vt_ls_test__";zh.localStorage.setItem(t,"1");var e="1"===zh.localStorage.getItem(t);return zh.localStorage.removeItem(t),this.Bi=e,e||uu().warn("storage","localStorage unavailable, using cookies"),e}catch(t){return this.Bi=!1,uu().warn("storage","localStorage unavailable, using cookies"),!1}}isCriticalProperty(t){return Hw.includes(t)}get(t){var e;try{switch(this.method){case xw:return null!==(e=this.memoryStorage.get(t))&&void 0!==e?e:null;case ww:return this.getLocalStoragePlusCookie(t);case yw:return this.getLocalStorage(t);case kw:return this.readFromSessionStorage(t);default:return this.getCookie(t)}}catch(e){return uu().warn("storage",'get error for "'+t+'":',e),null}}set(t,e,i){try{switch(this.method){case xw:this.memoryStorage.set(t,e);break;case ww:this.setLocalStoragePlusCookie(t,e,i);break;case yw:this.setLocalStorage(t,e);break;case kw:this.writeToSessionStorage(t,e);break;default:this.setCookie(t,e,null!=i?i:qw)}}catch(e){uu().warn("storage",'set error for "'+t+'":',e)}}remove(t){try{switch(this.method){case xw:this.memoryStorage.delete(t);break;case ww:this.removeLocalStoragePlusCookie(t);break;case yw:this.removeLocalStorage(t);break;case kw:this.removeFromSessionStorage(t);break;default:this.removeCookie(t)}}catch(e){uu().warn("storage",'remove error for "'+t+'":',e)}}getLocalStoragePlusCookie(t){if(this.isCriticalProperty(t)){var e=this.getCookie(t),i=this.getLocalStorage(t);if(null!==e){if(i!==e&&this.isLocalStorageSupported())try{null==zh||zh.localStorage.setItem(t,e)}catch(t){}return e}return null!==i?i:this.readFromSessionStorage(t)}return this.getLocalStorage(t)}setLocalStoragePlusCookie(t,e,i){this.setLocalStorage(t,e),this.isCriticalProperty(t)&&(this.setCookie(t,e,null!=i?i:qw),this.writeToSessionStorage(t,e))}removeLocalStoragePlusCookie(t){this.removeLocalStorage(t),this.isCriticalProperty(t)&&(this.removeCookie(t),this.removeFromSessionStorage(t))}getLocalStorage(t){var e;if(!this.isLocalStorageSupported())return null;try{return null!==(e=null==zh?void 0:zh.localStorage.getItem(t))&&void 0!==e?e:null}catch(t){return null}}setLocalStorage(t,e){if(this.isLocalStorageSupported())try{null==zh||zh.localStorage.setItem(t,e)}catch(t){uu().warn("storage","localStorage write error:",t)}}removeLocalStorage(t){if(this.isLocalStorageSupported())try{null==zh||zh.localStorage.removeItem(t)}catch(t){}}readFromSessionStorage(t){var e;try{return null!==(e=null==zh?void 0:zh.sessionStorage.getItem(t))&&void 0!==e?e:null}catch(t){return null}}writeToSessionStorage(t,e){try{null==zh||zh.sessionStorage.setItem(t,e)}catch(t){uu().warn("storage","sessionStorage write error:",t)}}removeFromSessionStorage(t){try{null==zh||zh.sessionStorage.removeItem(t)}catch(t){}}getCookie(t){if("undefined"==typeof document)return null;var e=t+"=";for(var i of document.cookie.split(";")){var n=i.trim();if(n.startsWith(e))try{return decodeURIComponent(n.slice(e.length))}catch(t){return n.slice(e.length)}}return null}setCookie(t,e,i){if("undefined"!=typeof document){var n=Gw(this.cross_subdomain),r=t+"="+encodeURIComponent(e)+"; Max-Age="+i+"; path=/; SameSite="+this.sameSite;this.secure&&(r+="; Secure"),n&&(r+="; domain="+n),document.cookie=r}}removeCookie(t){if("undefined"!=typeof document){var e=Gw(this.cross_subdomain);document.cookie=t+"=; Max-Age=0; path=/"+(e?"; domain="+e:""),document.cookie=t+"=; Max-Age=0; path=/"}}getWithExpiry(t){var e=this.get(t);if(!e)return null;try{var i=JSON.parse(e);return i.expiry&&Date.now()>i.expiry?(this.remove(t),null):i.value}catch(t){return null}}setWithExpiry(t,e,n){var r=i({value:e},n?{expiry:Date.now()+n}:{});this.set(t,JSON.stringify(r))}getJSON(t){var e=this.get(t);if(!e)return null;try{return JSON.parse(e)}catch(t){return null}}setJSON(t,e,i){this.set(t,JSON.stringify(e),i)}canUseSessionStorage(){if(void 0===zh||!(null==zh?void 0:zh.sessionStorage))return!1;try{var t="__vt_ss_test__";return zh.sessionStorage.setItem(t,"1"),zh.sessionStorage.removeItem(t),!0}catch(t){return!1}}getSessionStorage(){var t;return this.canUseSessionStorage()&&null!==(t=null==zh?void 0:zh.sessionStorage)&&void 0!==t?t:null}setMethod(t){this.method=t}getMethod(){return this.method}}class Yw{constructor(t,e){void 0===t&&(t="cookie"),this.Di=!1,this.storage=new Zw({method:t,cross_subdomain:e,sameSite:"Lax"}),this.R=void 0,uu().debug("session","ctor")}hydrateFromStorage(){uu().debug("session","hydrate"),this.ji()}getSessionId(){var t=this.Ui();return t||(t=Ou(16),this.Li(t),this.Di=!0),t}setSessionId(){var t=this.Ui(),e=t||Ou(16);return t||(this.Di=!0),this.Li(e),e}resetSessionId(){this.Fi(),this.Di=!0,this.setSessionId(),this.zi(Ou(16))}consumeSessionStart(){return!!this.Di&&(this.Di=!1,!0)}Ui(){return this.storage.get(uw)}Li(t){this.storage.set(uw,t,1800)}Fi(){this.storage.remove(uw)}getWindowId(){if(this.R)return this.R;var t=this.storage.getSessionStorage();if(t){var e=t.getItem(cw);if(e)return this.R=e,e}var i=Ou(16);return this.zi(i),i}zi(t){if(t!==this.R){this.R=t;var e=this.storage.getSessionStorage();e&&e.setItem(cw,t)}}ji(){var t=this.storage.getSessionStorage();if(t){var e=t.getItem(dw),i=t.getItem(cw);i&&!e?this.R=i:(i&&t.removeItem(cw),this.zi(Ou(16))),t.setItem(dw,"true"),this.Wi()}else this.R=Ou(16)}Wi(){var t=this.storage.getSessionStorage();zh&&t&&Pu(zh,"beforeunload",()=>{var t=this.storage.getSessionStorage();t&&t.removeItem(dw)},{capture:!1})}updateStorageMethod(t,e){this.storage=new Zw({method:t,cross_subdomain:e,sameSite:"Lax"})}}function Kw(t){if(!Vh)return null;var e=Vh.createElement("a");return e.href=t,e}function Xw(t){try{return decodeURIComponent(t).replace(/\+/g," ")}catch(e){return t.replace(/\+/g," ")}}function Qw(t){for(var e={},i=function(t){return((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"")}(t).split("&"),n=0;n<i.length;n++){var r=i[n];if(r){var s=r.indexOf("="),o=-1===s?r:r.slice(0,s);if(o){var a=Xw(o),l=-1===s?"":r.slice(s+1);e[a]=Xw(l)}}}return e}function tk(t,e){var i;return null!==(i=Qw(t)[e])&&void 0!==i?i:""}function ek(t,e,i){if(!t||!e||!e.length)return t;for(var n=t.split("#"),r=n[0]||"",s=n[1],o=r.split("?"),a=o[1],l=o[0],h=(a||"").split("&"),u=[],c=0;c<h.length;c++){var d=h[c].split("="),v=d[0],f=d.slice(1).join("=");-1!==e.indexOf(v)?u.push(v+"="+i):v&&u.push(v+(f?"="+f:""))}var p=u.join("&");return l+(p?"?"+p:"")+(s?"#"+s:"")}var ik="_fbp",nk="_fbc",rk=15552e3,sk=7776e3;function ok(){void 0!==Vh&&(function(){if(ak(ik))return;var t=Date.now(),e=Math.floor(1e9+9e9*Math.random()),i="fb.1."+t+"."+e;lk(ik,i,rk)}(),function(){if(!(null==Hh?void 0:Hh.search))return;try{var t=new URL(Hh.href).searchParams.get("fbclid");if(!(null==t?void 0:t.trim()))return;var e="fb.1."+Date.now()+"."+t.trim();lk(nk,e,sk)}catch(t){}}())}function ak(t){if(void 0===Vh||!(null==Vh?void 0:Vh.cookie))return null;var e=t+"=";for(var i of Vh.cookie.split(";")){var n=i.trim();if(n.startsWith(e))try{return decodeURIComponent(n.slice(e.length))}catch(t){return n.slice(e.length)}}return null}function lk(t,e,i){if(void 0!==Vh){var n=void 0!==Hh&&"https:"===Hh.protocol?"; Secure":"";Vh.cookie=t+"="+encodeURIComponent(e)+"; Max-Age="+i+"; path=/; SameSite=Lax"+n}}var hk="Mobile",uk="iOS",ck="Android",dk="Tablet",vk=ck+" "+dk,fk="iPad",pk="Apple",mk=pk+" Watch",gk="Safari",bk="BlackBerry",yk="Samsung",wk=yk+"Browser",kk=yk+" Internet",xk="Chrome",Sk=xk+" OS",Ck=xk+" "+uk,_k="Internet Explorer",Ik=_k+" "+hk,Ak="Opera",Tk=Ak+" Mini",Ek="Edge",Mk="Microsoft "+Ek,Ok="Firefox",Rk=Ok+" "+uk,Nk="Nintendo",Pk="PlayStation",Bk="Xbox",Dk=ck+" "+hk,jk=hk+" "+gk,Uk="Windows",Lk=Uk+" Phone",Fk="Nokia",zk="Ouya",Wk="Generic",$k=Wk+" "+hk.toLowerCase(),Vk=Wk+" "+dk.toLowerCase(),Hk="Konqueror",qk="(\\d+(\\.\\d+)?)",Jk=new RegExp("Version/"+qk),Gk=new RegExp(Bk,"i"),Zk=new RegExp(Pk+" \\w+","i"),Yk=new RegExp(Nk+" \\w+","i"),Kk=new RegExp(bk+"|PlayBook|BB10","i"),Xk={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function Qk(t,e){return t.toLowerCase().includes(e.toLowerCase())}var tx=(t,e)=>e&&Qk(e,pk)||function(t){return Qk(t,gk)&&!Qk(t,xk)&&!Qk(t,ck)}(t),ex=function(t,e){return e=e||"",Qk(t," OPR/")&&Qk(t,"Mini")?Tk:Qk(t," OPR/")?Ak:Kk.test(t)?bk:Qk(t,"IE"+hk)||Qk(t,"WPDesktop")?Ik:Qk(t,wk)?kk:Qk(t,Ek)||Qk(t,"Edg/")?Mk:Qk(t,"FBIOS")?"Facebook "+hk:Qk(t,"UCWEB")||Qk(t,"UCBrowser")?"UC Browser":Qk(t,"CriOS")?Ck:Qk(t,"CrMo")||Qk(t,xk)?xk:Qk(t,ck)&&Qk(t,gk)?Dk:Qk(t,"FxiOS")?Rk:Qk(t.toLowerCase(),Hk.toLowerCase())?Hk:tx(t,e)?Qk(t,hk)?jk:gk:Qk(t,Ok)?Ok:Qk(t,"MSIE")||Qk(t,"Trident/")?_k:Qk(t,"Gecko")?Ok:""},ix={[Ik]:[new RegExp("rv:"+qk)],[Mk]:[new RegExp(Ek+"?\\/"+qk)],[xk]:[new RegExp("("+xk+"|CrMo)\\/"+qk)],[Ck]:[new RegExp("CriOS\\/"+qk)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+qk)],[gk]:[Jk],[jk]:[Jk],[Ak]:[new RegExp("(Opera|OPR)\\/"+qk)],[Ok]:[new RegExp(Ok+"\\/"+qk)],[Rk]:[new RegExp("FxiOS\\/"+qk)],[Hk]:[new RegExp("Konqueror[:/]?"+qk,"i")],[bk]:[new RegExp(bk+" "+qk),Jk],[Dk]:[new RegExp("android\\s"+qk,"i")],[kk]:[new RegExp(wk+"\\/"+qk)],[_k]:[new RegExp("(rv:|MSIE )"+qk)],Mozilla:[new RegExp("rv:"+qk)]},nx=function(t,e){var i=ex(t,e),n=ix[i];if(void 0===n)return null;for(var r=0;r<n.length;r++){var s=n[r],o=t.match(s);if(o)return parseFloat(o[o.length-2])}return null},rx=[[new RegExp(Bk+"; "+Bk+" (.*?)[);]","i"),t=>[Bk,t&&t[1]||""]],[new RegExp(Nk,"i"),[Nk,""]],[new RegExp(Pk,"i"),[Pk,""]],[Kk,[bk,""]],[new RegExp(Uk,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Lk,""];if(new RegExp(hk).test(e)&&!/IEMobile\b/.test(e))return[Uk+" "+hk,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var n=i[1],r=Xk[n]||"";return/arm/i.test(e)&&(r="RT"),[Uk,r]}return[Uk,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[uk,e.join(".")]}return[uk,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=void 0===t[2]?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+ck+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ck+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[ck,e.join(".")]}return[ck,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var i=[t[1],t[2],t[3]||"0"];e[1]=i.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Sk,""]],[/Linux|debian/i,["Linux",""]]],sx=function(t){return Yk.test(t)?Nk:Zk.test(t)?Pk:Gk.test(t)?Bk:new RegExp(zk,"i").test(t)?zk:new RegExp("("+Lk+"|WPDesktop)","i").test(t)?Lk:/iPad/.test(t)?fk:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?mk:Kk.test(t)?bk:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Fk,"i").test(t)?Fk:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(hk).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?ck:vk:ck:new RegExp("(pda|"+hk+")","i").test(t)?$k:new RegExp(dk,"i").test(t)&&!new RegExp(dk+" pc","i").test(t)?Vk:""},ox="https?://(.*)",ax=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],lx=Du(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],ax),hx="<masked>";function ux(t,e){var i=lx.concat([]),n=Bu({},function(t){var e={};return Nu(Qw(t),function(t,i){"string"==typeof i&&i.startsWith("utm_")&&t&&(e[i]=t)}),e}(t));return Nu(i,function(e){if(e.startsWith("utm_")){if(!(e in n)){var i=tk(t,e);n[e]=i||null}}else{var r=tk(t,e);n[e]=r||null}}),n}function cx(t){var e=function(t){return t?0===t.search(ox+"google.([^/?]*)")?"google":0===t.search(ox+"bing.com")?"bing":0===t.search(ox+"yahoo.com")?"yahoo":0===t.search(ox+"duckduckgo.com")?"duckduckgo":null:null}(t),i="yahoo"!==e?"q":"p",n={};if(!function(t){return null===t}(e)){n.$search_engine=e;var r=Vh?tk(Vh.referrer,i):"";r.length&&(n.ph_keyword=r)}return n}function dx(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function vx(){return(null==Vh?void 0:Vh.referrer)||"$direct"}function fx(){var t;return(null==Vh?void 0:Vh.referrer)&&(null===(t=Kw(Vh.referrer))||void 0===t?void 0:t.host)||"$direct"}function px(t){var e=function(t){var e,{r:i,u:n}=t,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(e=Kw(i))||void 0===e?void 0:e.host};if(n){r.$current_url=n;var s=Kw(n);r.$host=null==s?void 0:s.host,r.$pathname=null==s?void 0:s.pathname,Bu(r,ux(n))}return i&&Bu(r,cx(i)),r}(t),i={};return Nu(e,function(t,e){var n;i["$initial_"+(n=String(e),n.startsWith("$")?n.substring(1):n)]=t}),i}function mx(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function gx(){try{return(new Date).getTimezoneOffset()}catch(t){return}}function bx(t,e){if(!Jh)return{};var i,n,r,s=t?Du([],ax,e||[]):[],[o,a]=function(t){for(var e=0;e<rx.length;e++){var[i,n]=rx[e],r=i.exec(t);if(r){var s="function"==typeof n?n(r,t):n;if(s)return s}}return["",""]}(Jh),l=ak(ik)||void 0,h=ak(nk)||void 0;return Bu(ju({$os:o,$os_version:a,$browser:ex(Jh,navigator.vendor),$device:sx(Jh),$device_type:(n=Jh,r=sx(n),r===fk||r===vk||"Kobo"===r||"Kindle Fire"===r||r===Vk?dk:r===Nk||r===Bk||r===Pk||r===zk?"Console":r===mk?"Wearable":r?hk:"Desktop"),$timezone:mx(),$timezone_offset:gx(),$fb_browser_id:l,$fb_click_id:h}),{$current_url:ek(null==Hh?void 0:Hh.href,s,hx),$host:null==Hh?void 0:Hh.host,$pathname:null==Hh?void 0:Hh.pathname,$raw_user_agent:Jh.length>1e3?Jh.substring(0,997)+"...":Jh,$browser_version:nx(Jh,navigator.vendor),$browser_language:dx(),$browser_language_prefix:(i=dx(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==zh?void 0:zh.screen.height,$screen_width:null==zh?void 0:zh.screen.width,$viewport_height:null==zh?void 0:zh.innerHeight,$viewport_width:null==zh?void 0:zh.innerWidth,$lib:"web",$lib_version:hw,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10)})}class yx{constructor(t,e){void 0===t&&(t="localStorage"),this.$i=!1,this.storage=new Zw({method:t,cross_subdomain:e,sameSite:"Lax"}),this.userIdentity=this.generateEphemeralIdentity(),uu().debug("user","ctor","ephemeral identity only")}hydrateFromStorage(){uu().debug("user","hydrate start"),this.userIdentity=this.loadUserIdentity();var t=this.userIdentity.anonymous_id,e=this.userIdentity.distinct_id;uu().debug("user","hydrate done","anonymous_id",t?t.slice(0,12)+"...":"n/a","distinct_id",e?e.slice(0,12)+"...":"null")}generateEphemeralIdentity(){return{distinct_id:null,anonymous_id:this.generateAnonymousId(),device_id:this.generateDeviceId(),properties:{},user_state:"anonymous"}}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){var t=this.userIdentity.anonymous_id;return t||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(pw,this.userIdentity.anonymous_id,qw),uu().debug("user","getAnonymousId generated (was missing)",this.userIdentity.anonymous_id.slice(0,12)+"..."),this.userIdentity.anonymous_id)}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}consumeFirstVisit(){return!!this.$i&&(this.$i=!1,!0)}applyUpdate(t){if(void 0!==t.distinct_id&&(this.userIdentity.distinct_id=t.distinct_id),void 0!==t.user_state&&(this.userIdentity.user_state=t.user_state),void 0!==t.device_id&&(this.userIdentity.device_id=t.device_id),t.properties_set&&(this.userIdentity.properties=i({},this.userIdentity.properties,t.properties_set)),t.properties_set_once)for(var e of Object.keys(t.properties_set_once))e in this.userIdentity.properties||(this.userIdentity.properties[e]=t.properties_set_once[e]);this.saveUserIdentity()}reset(t){this.userIdentity={distinct_id:null,anonymous_id:this.generateAnonymousId(),device_id:t?this.generateDeviceId():this.userIdentity.device_id,properties:{$last_vtilt_reset:(new Date).toISOString()},user_state:"anonymous"},this.saveUserIdentity()}set_initial_person_info(t,e){if(!this.getStoredUserProperties()[Sw]){var i=function(t,e){var i=t?Du([],ax,e||[]):[],n=null==Hh?void 0:Hh.href.substring(0,1e3);return{r:vx().substring(0,1e3),u:n?ek(n,i,hx):void 0}}(t,e);this.register_once({[Sw]:i},void 0)}}get_initial_props(){var t=this.getStoredUserProperties()[Sw];return t?px(t):{}}update_referrer_info(){var t={$referrer:vx(),$referring_domain:fx()};this.register_once(t,void 0)}loadUserIdentity(){var t=this.storage.get(pw),e=this.storage.get(fw),i=this.storage.get(gw),n=this.storage.get(vw),r=this.getStoredUserProperties(),s=t||this.generateAnonymousId(),o=e||this.generateDeviceId(),a=i||null,l=n||"anonymous";t?uu().debug("user","hydrate","loaded from storage",t.slice(0,12)+"..."):(this.$i=!0,uu().debug("user","hydrate","generated new anonymous_id"));var h=s||this.generateAnonymousId();return t||this.storage.set(pw,h,qw),e||this.storage.set(fw,o,qw),n||this.storage.set(vw,l,qw),{distinct_id:a,anonymous_id:h,device_id:o,properties:r,user_state:l}}saveUserIdentity(){this.storage.set(pw,this.userIdentity.anonymous_id,qw),this.storage.set(fw,this.userIdentity.device_id,qw),this.storage.set(vw,this.userIdentity.user_state,qw),this.userIdentity.distinct_id?this.storage.set(gw,this.userIdentity.distinct_id,qw):this.storage.remove(gw),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(bw)||{}}setStoredUserProperties(t){this.storage.setJSON(bw,t,qw)}register_once(t,e){var i=this.getStoredUserProperties(),n=!1;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(r in i||(i[r]=t[r],n=!0));if(e)for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(s in i||(i[s]=e[s],n=!0));n&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+Ou(16)}generateDeviceId(){return"device_"+Ou(16)}updateStorageMethod(t,e){this.storage=new Zw({method:t,cross_subdomain:e,sameSite:"Lax"})}}var wx=["LCP","CLS","FCP","INP"];class kx{constructor(t,e){this.Vi=!1,this.Hi=!1,this.qi=[],this.Ji=!1,this.Gi=[],this._instance=t,this.H=e}get isEnabled(){return!1!==this.H.enabled}get isStarted(){return this.Vi}get isLoaded(){return!!this.Zi}Yi(t){var e;if(this.Zi)t(this.Zi);else if(this.qi.push(t),!this.Hi){this.Hi=!0;var i=null===(e=Gh.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;if(!i)return uu().error("feature",this.name,"loadExternalDependency not available"),this.Hi=!1,void(this.qi=[]);i(this._instance,this.scriptName,t=>{if(this.Hi=!1,t)return uu().error("feature",this.name,"could not load "+this.scriptName+":",t),void(this.qi=[]);this.Zi||(this.Zi=this.Ki());var e=this.Zi,i=this.qi;for(var n of(this.qi=[],i))try{n(e)}catch(t){uu().error("feature",this.name,"load callback error:",t)}})}}startIfEnabled(){this.isEnabled&&!this.Vi&&(this.Vi=!0,this.Yi(t=>this.Xi(t)))}Xi(t){}stop(){this.Vi=!1}updateConfig(t){this.H=i({},this.H,t)}Qi(t){this.Ji?t():this.Gi.push(t)}tn(){if(!this.Ji){this.Ji=!0;var t=this.Gi;for(var e of(this.Gi=[],t))try{e()}catch(t){uu().error("feature",this.name,"deferred call error:",t)}}}en(){this.Ji=!1,this.Gi=[]}}class xx extends kx{startIfEnabledOrStop(t){if(this.isEnabled){if(this.Vi&&this.Zi)return;this.Vi=!0,this.Yi(t=>this.Xi(t))}else this.stop()}}var Sx=9e5,Cx="web-vitals";class _x extends kx{static extractConfig(t){var e=t.capture_performance;return"boolean"==typeof e?{web_vitals:e}:"object"==typeof e&&null!==e?e:{web_vitals:!1}}constructor(t,e){super(t,null!=e?e:_x.extractConfig(t.getConfig())),this.name="WebVitals",this.scriptName="web-vitals",this.q=this.nn()}get isEnabled(){var t=null==Hh?void 0:Hh.protocol;return("http:"===t||"https:"===t)&&!0===this.H.web_vitals}startIfEnabled(){if(this.isEnabled&&!this.Vi&&zh){var t=this.rn();t?(this.Vi=!0,this.Zi=t,this.sn(t)):(this.Vi=!0,this.Yi(t=>this.Xi(t)))}}stop(){this.Vi&&(this.an(),this.ln&&(clearTimeout(this.ln),this.ln=void 0),this.Vi=!1)}onConfigUpdate(t){var e=_x.extractConfig(t),i=this.isEnabled;this.H=e,i||!this.isEnabled||this.Vi?i&&!this.isEnabled&&this.Vi&&this.stop():this.startIfEnabled()}Ki(){var t=this.rn();if(!t)throw new Error("[vTilt:web-vitals] web-vitals loaded but callbacks not registered");return t}Xi(t){this.sn(t)}get allowedMetrics(){return this.H.web_vitals_allowed_metrics||wx}get flushTimeoutMs(){return this.H.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var t=this.H.__web_vitals_max_value;return void 0===t?Sx:0===t?0:t<6e4?Sx:t}nn(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}rn(){var t;return null===(t=Gh.__VTiltExtensions__)||void 0===t?void 0:t.webVitalsCallbacks}sn(t){var e=this.allowedMetrics,i=this.hn.bind(this);e.includes("LCP")&&t.onLCP&&t.onLCP(i),e.includes("CLS")&&t.onCLS&&t.onCLS(i,{reportAllChanges:!0}),e.includes("FCP")&&t.onFCP&&t.onFCP(i),e.includes("INP")&&t.onINP&&t.onINP(i),e.includes("TTFB")&&t.onTTFB&&t.onTTFB(i)}un(){var t;return null===(t=null==zh?void 0:zh.location)||void 0===t?void 0:t.href}cn(){return null==Hh?void 0:Hh.pathname}hn(t){var e,n,r;try{if(!zh||!Vh||!Hh)return;if(!(null==t?void 0:t.name)||void 0===(null==t?void 0:t.value))return void uu().warn(Cx,"invalid metric received",t);if(this.maxAllowedValue>0&&t.value>=this.maxAllowedValue&&"CLS"!==t.name)return void uu().warn(Cx,"ignoring "+t.name+" with value >= "+this.maxAllowedValue+"ms");var s=this.un(),o=this.cn();if(!s)return void uu().warn(Cx,"could not determine current URL");this.q.url&&this.q.url!==s&&this.an(),this.q.url||(this.q.url=s,this.q.pathname=o),this.q.firstMetricTimestamp||(this.q.firstMetricTimestamp=Date.now());var a=this.dn(t.attribution),l=null!==(r=null===(n=(e=this._instance).getSessionId)||void 0===n?void 0:n.call(e))&&void 0!==r?r:null,h=this.vn(),u=i({},t,{attribution:a,timestamp:Date.now(),$current_url:s,$session_id:l,$window_id:h}),c=this.q.metrics.findIndex(e=>e.name===t.name);c>=0?this.q.metrics[c]=u:this.q.metrics.push(u),this.fn(),this.q.metrics.length>=this.allowedMetrics.length&&this.an()}catch(t){uu().error(Cx,"error adding metric to buffer:",t)}}dn(t){if(t){var e=i({},t);return"interactionTargetElement"in e&&delete e.interactionTargetElement,e}}vn(){var t;try{return(null===(t=this._instance.sessionManager)||void 0===t?void 0:t.getWindowId())||null}catch(t){return null}}fn(){this.ln&&clearTimeout(this.ln),this.ln=setTimeout(()=>{this.an()},this.flushTimeoutMs)}an(){if(this.ln&&(clearTimeout(this.ln),this.ln=void 0),0!==this.q.metrics.length){try{var t={$pathname:this.q.pathname,$current_url:this.q.url};for(var e of this.q.metrics)t["$web_vitals_"+e.name+"_value"]=e.value,t["$web_vitals_"+e.name+"_event"]={name:e.name,value:e.value,delta:e.delta,rating:e.rating,id:e.id,navigationType:e.navigationType,attribution:e.attribution,$session_id:e.$session_id,$window_id:e.$window_id};this._instance.capture("$web_vitals",t)}catch(t){uu().error(Cx,"error flushing metrics:",t)}this.q=this.nn()}}}function Ix(t,e,i){try{if(!(e in t))return()=>{};var n=t[e],r=i(n);return eu(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),t[e]=r,()=>{t[e]=n}}catch(t){return()=>{}}}class Ax{constructor(t,e){var i;this.name="HistoryAutocapture",this.Vi=!1,this._instance=t,this.H=e||Ax.extractConfig(t.getConfig()),this.pn=(null===(i=null==zh?void 0:zh.location)||void 0===i?void 0:i.pathname)||""}static extractConfig(t){return{enabled:!1!==t.capture_pageview}}get isEnabled(){return!1!==this.H.enabled&&!1!==this._instance.getConfig().capture_pageview}get isStarted(){return this.Vi}startIfEnabled(){this.isEnabled&&!this.Vi&&this.mn()}stop(){this.Vi&&(this.gn&&(this.gn(),this.gn=void 0),this.Vi=!1)}onConfigUpdate(t){this.H=Ax.extractConfig(t),this.isEnabled&&!this.Vi?this.mn():!this.isEnabled&&this.Vi&&this.stop()}mn(){zh&&Hh&&(this.pn=Hh.pathname||"",this.bn(),this.yn(),this.Vi=!0,uu().info("history-autocapture","started"))}bn(){var t,e;if(null==zh?void 0:zh.history){var i=this;(null===(t=zh.history.pushState)||void 0===t?void 0:t.__vtilt_wrapped__)||Ix(zh.history,"pushState",t=>function(e,n,r){i.wn(r),t.call(this,e,n,r),i.kn("pushState")}),(null===(e=zh.history.replaceState)||void 0===e?void 0:e.__vtilt_wrapped__)||Ix(zh.history,"replaceState",t=>function(e,n,r){i.wn(r),t.call(this,e,n,r),i.kn("replaceState")})}}wn(t){var e;if(Hh){var i=Hh.pathname||"",n=null!==(e=function(t){if(!Hh)return null;if(null==t||""===t)return Hh.pathname||null;try{return new URL(String(t),Hh.href).pathname}catch(t){return null}}(t))&&void 0!==e?e:i;n!==i&&this._instance.tryCapturePageleave("spa_transition")}}yn(){if(!this.gn&&zh){var t=()=>{this.kn("popstate")};Pu(zh,"popstate",t),this.gn=()=>{null==zh||zh.removeEventListener("popstate",t)}}}kn(t){this.isEnabled&&this.Vi&&du(()=>{var e,i=null===(e=null==zh?void 0:zh.location)||void 0===e?void 0:e.pathname;if(i&&Hh&&Vh)if(i!==this.pn){uu().debug("history-autocapture",t,i),this.pn=i;var n={navigation_type:t};this._instance.capture(Cw,n)}else this.pn=i})}}var Tx=["a","button","form","input","select","textarea","label"],Ex="$copy_autocapture",Mx=['[id*="cookie" i]','[class*="cookie" i]','[id*="consent" i]','[class*="consent" i]','[id*="gdpr" i]','[class*="gdpr" i]','[id*="privacy-banner" i]','[class*="privacy-banner" i]','[id*="cookie-banner" i]','[class*="cookie-banner" i]','[id*="cookie-notice" i]','[class*="cookie-notice" i]',"#CybotCookiebotDialog",'[class^="CybotCookiebotDialog"]','[id^="onetrust"]','[class^="onetrust"]','[id^="cc-"]',".cc-banner",".cc-window",".cc-revoke",'[id^="cookieconsent"]','[class^="cookieconsent"]','[id^="gdpr-cookie"]','[id^="qc-cmp"]',"#termly-code-snippet-support",'[id^="iubenda"]','[id^="truste"]','[class^="truste"]',"#consent_blackbar",'[id^="didomi"]','[id^="usercentrics"]',"#uc-center-container",".klaro","#klaro","#cookiescript_injected",".cky-consent-container","#cky-consent","#cmplz-cookiebanner-container","#gdpr-cookie-message",'[class*="fs-cc"]','[class*="fc-cc"]',"[fs-cc]","[fs-cc-checkbox]",'[class*="cookie-preferences"]',"#cookie-preferences",'[role="dialog"][aria-label*="cookie" i]','[role="dialog"][aria-label*="consent" i]','[aria-describedby*="cookie" i]','[aria-label*="Cookie Preferences" i]'];function Ox(t){return t.replace(/^\s+|\s+$/g,"")}function Rx(t,e){return t.indexOf(e)>-1}function Nx(t){return 1===(null==t?void 0:t.nodeType)}function Px(t){return 3===(null==t?void 0:t.nodeType)}function Bx(t,e){var i;return(null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase())===e}function Dx(t){return 11===(null==t?void 0:t.nodeType)}function jx(t){return t?Ox(t).split(/\s+/):[]}function Ux(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className&&"string"==typeof t.className.baseVal?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return jx(e)}function Lx(t){return Qh(t)?null:Ox(t).split(/(\s+)/).filter(t=>Xx(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Fx(t){var e,i="";if(tS(t)&&!eS(t)&&t.childNodes&&t.childNodes.length)for(var n=0;n<t.childNodes.length;n++){var r=t.childNodes[n];Px(r)&&r.textContent&&(i+=null!==(e=Lx(r.textContent))&&void 0!==e?e:"")}return Ox(i)}function zx(t){var e,i="";if(t&&t.childNodes&&t.childNodes.length)for(var n=0;n<t.childNodes.length;n++){var r=t.childNodes[n];if(r&&"span"===(null===(e=r.tagName)||void 0===e?void 0:e.toLowerCase()))try{i=(i+" "+Fx(r)).trim(),r.childNodes&&r.childNodes.length&&(i=(i+" "+zx(r)).trim())}catch(t){}}return i}function Wx(t){var e=Fx(t);return Xx(e=(e+" "+zx(t)).trim())?e:""}function $x(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!Nx(e));return e}function Vx(t){var e=t.parentNode;return!(!e||!Nx(e))&&e}function Hx(t){var e=null==zh?void 0:zh.location.href;return!!(e&&t&&t.some(t=>e.match(t)))}var qx="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",Jx=new RegExp("^(?:"+qx+")$"),Gx=new RegExp(qx),Zx="\\d{3}-?\\d{2}-?\\d{4}",Yx=new RegExp("^("+Zx+")$"),Kx=new RegExp("("+Zx+")");function Xx(t,e){if(void 0===e&&(e=!0),Qh(t))return!1;if(Kh(t)){if(t=Ox(t),(e?Jx:Gx).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Yx:Kx).test(t))return!1}return!0}function Qx(t){return!!Kh(t)&&("_ngcontent"===t.substring(0,10)||"_nghost"===t.substring(0,7))}function tS(t){for(var e=t;e&&e.parentNode&&!Bx(e,"body");e=e.parentNode){var i=Ux(e);if(Rx(i,"vt-sensitive")||Rx(i,"vt-no-capture"))return!1}if(Rx(Ux(t),"vt-include"))return!0;var n=t.type||"";if(Kh(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var r=t.name||t.id||"";if(Kh(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function eS(t){return!!(Bx(t,"input")&&!["button","checkbox","submit","reset","radio"].includes(t.type)||Bx(t,"textarea")||"true"===t.getAttribute("contenteditable"))}function iS(t){if(!tS(t))return null;if(Bx(t,"input")){var e=t,i=(e.type||"text").toLowerCase();if("password"===i||"hidden"===i)return null;if("checkbox"===i||"radio"===i){var n={$el_value:e.checked?"true":"false"},r=function(t){var e=t.closest("label");if(e){var i=Ox(e.textContent||"");if(i&&Xx(i))return Lx(i)||null}if(t.id)try{var n=null===document||void 0===document?void 0:document.querySelector('label[for="'+t.id+'"]');if(n){var r=Ox(n.textContent||"");if(r&&Xx(r))return Lx(r)||null}}catch(t){}return null}(e);return r?n.$selected_text=r:e.value&&Xx(e.value)&&(n.$selected_text=e.value),n}var s=e.value;if(s&&Xx(s)){var o=Lx(s);if(o)return{$el_value:o}}return null}if(Bx(t,"select")){var a=t,l=a.selectedIndex;if(l>=0&&a.options[l]){var h=a.options[l],u={};h.value&&Xx(h.value)&&(u.$el_value=h.value);var c=h.text;if(c&&Xx(c)){var d=Lx(c);d&&(u.$selected_text=d)}if(u.$el_value||u.$selected_text)return u}return null}return Bx(t,"textarea"),null}function nS(t,e,i,n,r){if(void 0===i&&(i=void 0),!zh)return{capture:!1,reason:"no_window"};if(!t)return{capture:!1,reason:"no_element"};if(Bx(t,"html")||!Nx(t))return{capture:!1,reason:"html_element"};if((null==i?void 0:i.url_allowlist)&&!Hx(i.url_allowlist))return{capture:!1,reason:"url_allowlist_miss"};if((null==i?void 0:i.url_ignorelist)&&Hx(i.url_ignorelist))return{capture:!1,reason:"url_ignorelist_hit"};if(null==i?void 0:i.dom_event_allowlist){var s=i.dom_event_allowlist;if(s&&!s.some(t=>e.type===t))return{capture:!1,reason:"dom_event_not_allowed"}}for(var o=!1,a=[t],l=!0,h=t;h.parentNode&&!Bx(h,"body");)if(Dx(h.parentNode))a.push(h.parentNode.host),h=h.parentNode.host;else{if(!(l=Vx(h)))break;if(n||Tx.indexOf(l.tagName.toLowerCase())>-1)o=!0;else{var u=zh.getComputedStyle(l);u&&"pointer"===u.getPropertyValue("cursor")&&(o=!0)}a.push(l),h=l}if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(Xh(i))return!0;var n,r=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(n=r(s))return n.v;return!1}(a,i))return{capture:!1,reason:"element_allowlist_miss"};if(!function(t,e){var i=null==e?void 0:e.css_selector_allowlist;if(Xh(i))return!0;var n,r=function(t){if(i.some(e=>t.matches(e)))return{v:!0}};for(var s of t)if(n=r(s))return n.v;return!1}(a,i))return{capture:!1,reason:"css_selector_allowlist_miss"};if(function(t,e){var i=null==e?void 0:e.css_selector_ignorelist,n=void 0===i?Mx:i;if(0===n.length)return!1;for(var r of t)for(var s of n)try{if(r.matches(s))return!0}catch(t){}return!1}(a,i))return{capture:!1,reason:"css_selector_ignorelist_hit"};var c=zh.getComputedStyle(t);if(c&&"pointer"===c.getPropertyValue("cursor")&&"click"===e.type)return{capture:!0};var d=t.tagName.toLowerCase();switch(d){case"html":return{capture:!1,reason:"tag_html"};case"form":return(r||["submit"]).indexOf(e.type)>=0?{capture:!0}:{capture:!1,reason:"form_event_not_allowed"};case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(e.type)>=0?{capture:!0}:{capture:!1,reason:"input_event_not_allowed"};default:return o?(r||["click"]).indexOf(e.type)>=0?{capture:!0}:{capture:!1,reason:"dom_event_not_allowed"}:(r||["click"]).indexOf(e.type)>=0&&(Tx.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))?{capture:!0}:{capture:!1,reason:"tag_not_capturable"}}}function rS(t,e){return e.length>t?e.slice(0,t)+"...":e}function sS(t,e,i,n){var r=t.tagName.toLowerCase(),s={tag_name:r};Tx.indexOf(r)>-1&&!i&&(s.$el_text=rS(1024,"a"===r||"button"===r?Wx(t):Fx(t)));var o=Ux(t);o.length>0&&(s.classes=o.filter(t=>""!==t));for(var a=0;a<t.attributes.length;a++){var l=t.attributes[a];if((!eS(t)||-1!==["name","id","class","aria-label"].indexOf(l.name))&&(!(null==n?void 0:n.includes(l.name))&&!e&&Xx(l.value)&&!Qx(l.name))){var h=l.value;"class"===l.name&&(h=jx(h).join(" ")),s["attr__"+l.name]=rS(1024,h)}}for(var u=1,c=1,d=t;d=$x(d);)u++,d.tagName===t.tagName&&c++;return s.nth_child=u,s.nth_of_type=c,s}function oS(t){if(!tS(t))return{};for(var e={},i=0;i<t.attributes.length;i++){var n=t.attributes[i];if(n.name&&0===n.name.indexOf("data-vt-capture-attribute")){var r=n.name.replace("data-vt-capture-attribute-",""),s=n.value;r&&s&&Xx(s)&&(e[r]=s)}}return e}function aS(t){return t.replace(/"|\\"/g,'\\"')}function lS(t){var e=t.attr__class;return e?tu(e)?e:jx(e):void 0}function hS(t){return function(t){var e=t.map(t=>{var e,n,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var o=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(n=t.nth_of_type)&&void 0!==n?n:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),a={};return Object.entries(o).sort((t,e)=>{var[i]=t,[n]=e;return i.localeCompare(n)}).forEach(t=>{var[e,i]=t;return a[aS(e.toString())]=aS(String(i))}),(r+=":")+Object.entries(a).map(t=>{var[e,i]=t;return e+'="'+i+'"'}).join("")});return e.join(";")}(function(t){return t.map(t=>{var e,i,n={text:null===(e=t.$el_text)||void 0===e?void 0:e.slice(0,400),tag_name:t.tag_name,href:null===(i=t.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:lS(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Object.entries(t).filter(t=>{var[e]=t;return 0===e.indexOf("attr__")}).forEach(t=>{var[e,i]=t;return n.attributes[e]=i}),n})}(t))}var uS=[25,50,75,100];function cS(t){var e;if(!t)return null;var i=t.milestones,n=!0===i||"object"==typeof i&&null!==i,r="object"==typeof i&&null!==i&&(null===(e=i.thresholds)||void 0===e?void 0:e.length)?[...i.thresholds].sort((t,e)=>t-e):[...uS],s=!0===t.pageleave;return n||s?{milestones:n,thresholds:r,pageleave:s,scroll_root_selector:t.scroll_root_selector}:null}class dS{constructor(t){this.xn=t,this.Sn=0,this.Cn=new Set,this._n=null,this.In=null,this.An=null,this.Tn=null}start(){this.stop(),this.In=function(t){if(!zh)return null;if(t){var e=Array.isArray(t)?t:[t];for(var i of e){var n=null==Vh?void 0:Vh.querySelector(i);if(n instanceof Element)return n}}return zh}(this.xn.scroll_root_selector),this.In&&(this._n=()=>this.En(),Pu(this.In,"scroll",this._n,{passive:!0}),this.Mn(),this.Tn=this.xn.onPageview(()=>this.reset()))}stop(){this.Tn&&(this.Tn(),this.Tn=null),null!=this.An&&zh&&(zh.cancelAnimationFrame(this.An),this.An=null),this._n&&this.In&&(this.In.removeEventListener("scroll",this._n,{passive:!0}),this._n=null,this.In=null)}reset(){this.Sn=0,this.Cn.clear(),this.Mn()}getMaxPct(){return this.Sn}En(){zh&&null==this.An&&(this.An=zh.requestAnimationFrame(()=>{this.An=null,this.Mn()}))}Mn(){if(this.In){var t=function(t){var e,i,n,r,s,o;if(!t)return 0;if(t===zh){var a=null!==(e=zh.scrollY)&&void 0!==e?e:0,l=null!==(i=zh.innerHeight)&&void 0!==i?i:0,h=null==Vh?void 0:Vh.documentElement,u=null==Vh?void 0:Vh.body,c=Math.max(null!==(n=null==h?void 0:h.scrollHeight)&&void 0!==n?n:0,null!==(r=null==u?void 0:u.scrollHeight)&&void 0!==r?r:0,null!==(s=null==h?void 0:h.offsetHeight)&&void 0!==s?s:0,null!==(o=null==u?void 0:u.offsetHeight)&&void 0!==o?o:0)-l;return c<=0?100:Math.round(Math.min(100,a/c*100))}var d=t,v=d.scrollHeight-d.clientHeight;return v<=0?100:Math.round(Math.min(100,d.scrollTop/v*100))}(this.In);if(t>this.Sn&&(this.Sn=t),this.xn.milestones&&this.xn.isUrlAllowed())for(var e of this.xn.thresholds)this.Sn>=e&&!this.Cn.has(e)&&(this.Cn.add(e),this.xn.capture(Ow,{[Fw]:e,[zw]:this.Sn}))}}}function vS(t,e){return t.indexOf(e)>-1}class fS{constructor(){this.clicks=[],this.RAGE_CLICK_THRESHOLD_PX=30,this.RAGE_CLICK_TIMEOUT_MS=1e3,this.RAGE_CLICK_CLICK_COUNT=3}isRageClick(t,e,i){if(this.clicks=this.clicks.filter(t=>i-t.timestamp<this.RAGE_CLICK_TIMEOUT_MS),this.clicks.length>0){var n=this.clicks[this.clicks.length-1];Math.sqrt(Math.pow(t-n.x,2)+Math.pow(e-n.y,2))>this.RAGE_CLICK_THRESHOLD_PX&&(this.clicks=[])}return this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length>=this.RAGE_CLICK_CLICK_COUNT}}function pS(t,e){for(var i,n,r,s,{e:o,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:h,elementsChainAsString:u,captureElementValues:c}=e,d=[t],v=t;v.parentNode&&!Bx(v,"body");)Dx(v.parentNode)?(d.push(v.parentNode.host),v=v.parentNode.host):(d.push(v.parentNode),v=v.parentNode);var f,p=[],m={},g=!1,b=!1;for(var y of d){var w=tS(y);if("a"===y.tagName.toLowerCase()){var k=y.getAttribute("href");g=!!(w&&k&&Xx(k))&&k}vS(Ux(y),"vt-no-capture")&&(b=!0),p.push(sS(y,a,l,h));var x=oS(y);Object.assign(m,x)}if(b)return{props:{},explicitNoCapture:b};if(l||("a"===t.tagName.toLowerCase()||"button"===t.tagName.toLowerCase()?p[0].$el_text=Wx(t):p[0].$el_text=Fx(t)),"change"===o.type&&c){var S=iS(t);S&&(S.$el_value&&(p[0].$el_value=S.$el_value),S.$selected_text&&(p[0].$selected_text=S.$selected_text))}if(g){p[0].attr__href=g;var C=null===(i=Kw(g))||void 0===i?void 0:i.host,_=null===(n=null==zh?void 0:zh.location)||void 0===n?void 0:n.host;C&&_&&C!==_&&(f=g)}var I=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return Object.assign({},...e)}({$event_type:o.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:hS(p)},(null===(r=p[0])||void 0===r?void 0:r.$el_text)?{$el_text:null===(s=p[0])||void 0===s?void 0:s.$el_text}:{},f&&"click"===o.type?{$external_click_url:f}:{},m);return{props:I}}var mS=["copy","cut"];class gS{static extractConfig(t){return{enabled:!1!==t.autocapture}}constructor(t,e){this.name="Autocapture",this.On=!1,this.Rn=null,this.Nn=null,this.Pn=null,this.Bn=new fS,this.Dn=!0,this.jn=null,this.Un=null,this.Ln=null,this.Fn=null,this.zn=!1,this.Wn=null,this.$n=null,this._instance=t}get H(){var t=this._instance.getConfig().autocapture;if(t===this.Un&&this.jn)return this.jn;this.Un=t;var e=function(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}(t)?t:{};return e.url_allowlist&&(e.url_allowlist=e.url_allowlist.map(t=>"string"==typeof t?new RegExp(t):t)),e.url_ignorelist&&(e.url_ignorelist=e.url_ignorelist.map(t=>"string"==typeof t?new RegExp(t):t)),this.jn=e,e}get isEnabled(){return this.Vn().enabled}get isStarted(){return this.On}startIfEnabled(){var{enabled:t,reason:e}=this.Vn();t?this.On?(this.Hn(),this.qn()):(this.Jn(),this.On=!0,uu().info("autocapture","started; listening for click/change/submit events")):this.On?(uu().info("autocapture","stopping; reason:",null!=e?e:"unknown"),this.Gn(),this.On=!1):(uu().debug("autocapture","not started; reason:",null!=e?e:"unknown"),this.Zn())}stop(){this.On&&(this.Gn(),this.On=!1,uu().info("autocapture","stopped (DOM listeners detached)")),this.Zn()}getMaxScrollDepthPctForPageleave(){var t=cS(this.H.scroll_depth);return(null==t?void 0:t.pageleave)&&this.Wn?this.Wn.getMaxPct():null}onConfigUpdate(t){var e=t;"boolean"==typeof e.elementsChainAsString&&(this.Dn=e.elementsChainAsString),void 0!==e.autocapture_opt_out&&(this.Rn=!!e.autocapture_opt_out),this.startIfEnabled()}updateConfig(t){void 0!==t.enabled&&(this.Nn=t.enabled,t.enabled&&(this.Rn=!1),this.startIfEnabled())}getDiagnostics(){var t,e,i,{enabled:n,reason:r}=this.Vn(),s=cS(this.H.scroll_depth);return{isEnabled:n,isStarted:this.On,disabledReason:n?null:r,inputs:{configAutocapture:this._instance.getConfig().autocapture,isDisabledServerSide:null!==(t=this.Rn)&&void 0!==t&&t,userOverride:this.Nn,elementsChainAsString:this.Dn,captureCopiedText:!!this.H.capture_copied_text,scrollDepthMilestones:null!==(e=null==s?void 0:s.milestones)&&void 0!==e&&e,scrollDepthPageleave:null!==(i=null==s?void 0:s.pageleave)&&void 0!==i&&i,scrollDepthListenerAttached:null!==this.Wn}}}setElementSelectors(t){this.Pn=t}getElementSelectors(t){var e,i=[];return null===(e=this.Pn)||void 0===e||e.forEach(e=>{var n=null==Vh?void 0:Vh.querySelectorAll(e);null==n||n.forEach(n=>{t===n&&i.push(e)})}),i}Vn(){if(!1===this.Nn)return{enabled:!1,reason:"user_stop_called"};if(this.Rn)return{enabled:!1,reason:"server_opt_out"};if(!0===this.Nn)return{enabled:!0,reason:null};var t=this._instance.getConfig().autocapture;return!1===t?{enabled:!1,reason:"config_autocapture_false"}:null==t?{enabled:!1,reason:"config_autocapture_undefined"}:{enabled:!0,reason:null}}Jn(){this.Yn()?zh&&Vh&&(this.Ln=t=>{var e=t||(null==zh?void 0:zh.event);if(e)try{this.Kn(e)}catch(t){uu().error("autocapture","capture handler threw",t)}},Pu(Vh,"submit",this.Ln,{capture:!0}),Pu(Vh,"change",this.Ln,{capture:!0}),Pu(Vh,"click",this.Ln,{capture:!0}),this.Hn(),this.qn()):uu().warn("autocapture","browser unsupported (no querySelectorAll)")}Gn(){Vh&&(this.Ln&&(Vh.removeEventListener("submit",this.Ln,!0),Vh.removeEventListener("change",this.Ln,!0),Vh.removeEventListener("click",this.Ln,!0),this.Ln=null),this.Fn&&this.zn&&(Vh.removeEventListener("copy",this.Fn,!0),Vh.removeEventListener("cut",this.Fn,!0),this.zn=!1,this.Fn=null),this.Zn())}qn(){var t,e=cS(this.H.scroll_depth),i=this.isEnabled&&null!==e&&null!==cS(null==(t=this.H)?void 0:t.scroll_depth);i&&!this.Wn?(this.Wn=new dS({milestones:e.milestones,pageleave:e.pageleave,thresholds:e.thresholds,scroll_root_selector:e.scroll_root_selector,capture:(t,e)=>this._instance.capture(t,e),isUrlAllowed:()=>{return t=this.H,!(!zh||(null==t?void 0:t.url_allowlist)&&!Hx(t.url_allowlist)||(null==t?void 0:t.url_ignorelist)&&Hx(t.url_ignorelist));var t},onPageview:t=>(this.$n&&this.$n(),this.$n=this._instance.on(ku,e=>{(null==e?void 0:e.event)===Cw&&t()}),()=>{var t;null===(t=this.$n)||void 0===t||t.call(this),this.$n=null})}),this.Wn.start(),uu().info("autocapture","scroll depth tracking started",{milestones:e.milestones,pageleave:e.pageleave})):i||this.Zn()}Zn(){this.Wn&&(this.Wn.stop(),this.Wn=null,uu().info("autocapture","scroll depth tracking stopped")),this.$n&&(this.$n(),this.$n=null)}Hn(){if(Vh){var t=!!this.H.capture_copied_text;t&&!this.zn?(this.Fn=t=>{var e=t||(null==zh?void 0:zh.event);if(e)try{this.Kn(e,Ex)}catch(t){uu().error("autocapture","copy handler threw",t)}},Pu(Vh,"copy",this.Fn,{capture:!0}),Pu(Vh,"cut",this.Fn,{capture:!0}),this.zn=!0):!t&&this.zn&&this.Fn&&(Vh.removeEventListener("copy",this.Fn,!0),Vh.removeEventListener("cut",this.Fn,!0),this.zn=!1,this.Fn=null)}}Kn(t,e){var i,n,r,s,o,a,l,h;if(void 0===e&&(e="$autocapture"),this.isEnabled)if(t.isTrusted){var u=function(t){var e;return Xh(t.target)?t.srcElement||null:(null===(e=t.target)||void 0===e?void 0:e.shadowRoot)?t.composedPath()[0]||null:t.target||null}(t);if(Px(u)&&(u=u.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent)this._instance.getConfig().rageclick&&(null===(i=this.Bn)||void 0===i?void 0:i.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&(uu().info("autocapture","$rageclick detected"),this.Kn(t,"$rageclick"));var c=e===Ex;if(u){var d=nS(u,t,this.H,c,c?[...mS]:void 0);if(d.capture){var v=this._instance.getConfig(),{props:f,explicitNoCapture:p}=pS(u,{e:t,maskAllElementAttributes:null!==(s=v.mask_all_element_attributes)&&void 0!==s&&s,maskAllText:null!==(o=v.mask_all_text)&&void 0!==o&&o,elementAttributeIgnoreList:this.H.element_attribute_ignorelist,elementsChainAsString:this.Dn,captureElementValues:null!==(a=this.H.capture_element_values)&&void 0!==a&&a});if(p)return uu().debug("autocapture","skip: vt-no-capture class on element chain",{tag:null===(l=u.tagName)||void 0===l?void 0:l.toLowerCase()}),!1;var m=this.getElementSelectors(u);if(m&&m.length>0&&(f.$element_selectors=m),e===Ex){var g=Lx(null===(h=null==zh?void 0:zh.getSelection())||void 0===h?void 0:h.toString()),b=t.type||"clipboard";if(!g)return uu().debug("autocapture","skip copy: empty selection"),!1;f.$selected_content=g,f.$copy_type=b}return this._instance.capture(e,f),!0}uu().debug("autocapture","skip:",null!==(n=d.reason)&&void 0!==n?n:"unknown",{type:t.type,tag:null===(r=u.tagName)||void 0===r?void 0:r.toLowerCase()})}else uu().debug("autocapture","skip: no event target",{type:t.type})}else uu().debug("autocapture","skip: synthetic event (isTrusted=false)",{type:t.type})}Yn(){return eu(null==Vh?void 0:Vh.querySelectorAll)}}var bS="replay";class yS extends xx{constructor(t,e){super(t,e||yS.extractConfig(t.getConfig())),this.name="SessionRecording",this.scriptName="recorder"}static extractConfig(t){var e,i,n,r=t.session_recording||{};return{enabled:null!==(e=r.enabled)&&void 0!==e&&e,sampleRate:r.sampleRate,minimumDurationMs:r.minimumDurationMs,sessionIdleThresholdMs:r.sessionIdleThresholdMs,fullSnapshotIntervalMs:r.fullSnapshotIntervalMs,captureConsole:null!==(i=r.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(n=r.captureNetwork)&&void 0!==n&&n,captureCanvas:r.captureCanvas,blockClass:r.blockClass,blockSelector:r.blockSelector,skipDefaultInvisibleBlocking:r.skipDefaultInvisibleBlocking,ignoreClass:r.ignoreClass,maskTextClass:r.maskTextClass,maskTextSelector:r.maskTextSelector,maskAllInputs:r.maskAllInputs,maskInputOptions:r.maskInputOptions,masking:r.masking,recordHeaders:r.recordHeaders,recordBody:r.recordBody,compressEvents:r.compressEvents,__mutationThrottlerRefillRate:r.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:r.__mutationThrottlerBucketSize}}get isEnabled(){var t,e=this._instance.getConfig(),i=null!==(t=this.H.enabled)&&void 0!==t&&t,n=!e.disable_session_recording;return!!zh&&i&&n}get isStarted(){var t;return this.Vi&&!!(null===(t=this.Zi)||void 0===t?void 0:t.isStarted)}startIfEnabled(){this.startIfEnabledOrStop("recording_initialized")}startIfEnabledOrStop(t){var e;if(!this.isEnabled||!(null===(e=this.Zi)||void 0===e?void 0:e.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this.isEnabled&&i?(this.Vi=!0,this.Yi(e=>this.Xi(e,t)),uu().info(bS,"starting")):this.stop()}}stop(){du(()=>{var t;null===(t=this.Zi)||void 0===t||t.stop(),this.Vi=!1})}onConfigUpdate(t){var e;this.H=yS.extractConfig(t),null===(e=this.Zi)||void 0===e||e.updateConfig(this.H),this.startIfEnabledOrStop("config_updated")}Ki(){var t,e=null===(t=Gh.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;if(!e)throw new Error("[vTilt:replay] initSessionRecording not available after script load");return e(this._instance,this.H)}Xi(t,e){t.start(e)}get started(){return this.isStarted}get status(){var t;return(null===(t=this.Zi)||void 0===t?void 0:t.status)||"lazy_loading"}get sessionId(){var t;return(null===(t=this.Zi)||void 0===t?void 0:t.sessionId)||""}stopRecording(){this.stop()}log(t,e){var i;void 0===e&&(e="log"),(null===(i=this.Zi)||void 0===i?void 0:i.log)?this.Zi.log(t,e):uu().warn(bS,"log called before recorder was ready")}updateConfig(t){var e;this.H=i({},this.H,t),null===(e=this.Zi)||void 0===e||e.updateConfig(this.H)}}var wS="chat";class kS extends kx{constructor(t,e){super(t,e||kS.extractConfig(t.getConfig())),this.name="Chat",this.scriptName="chat",this.Xn=null,this.Qn=!1,this.tr=null,this.er=null,this.ir=[],this.nr=[],this.Ae=[],this.Te=[],this.Ee=[],this.Ke=!1,this.rr=null,this.V=()=>{if("visible"===document.visibilityState)return this.sr(),void this.ar();this.lr()}}static extractConfig(t){var e,i=t.chat||{};return{enabled:i.enabled,autoConfig:null===(e=i.autoConfig)||void 0===e||e,position:i.position,greeting:i.greeting,color:i.color,aiMode:i.aiMode,aiGreeting:i.aiGreeting,preload:i.preload,offlineMessage:i.offlineMessage,collectEmailOffline:i.collectEmailOffline,bubble:i.bubble}}get isEnabled(){var t;return!1!==this.H.enabled&&(!0===this.H.enabled||!this._instance.getConfig().disable_chat&&!0===(null===(t=this.Xn)||void 0===t?void 0:t.enabled))}startIfEnabled(){uu().debug(wS,"startIfEnabled"),this.hr().catch(t=>{uu().error(wS,"error starting:",t)})}stop(){this.destroy(),this.Vi=!1}onConfigUpdate(t){var e,i;this.H=kS.extractConfig(t),this.ur()||this.cr(),this.Zi&&(null===(i=(e=this.Zi).updateConfig)||void 0===i||i.call(e,this.getMergedConfig()))}Ki(){var t,e,i,n=null===(t=Gh.__VTiltExtensions__)||void 0===t?void 0:t.initChat;if(!n)throw new Error("[vTilt:chat] initChat not available after script load");var r=this.getMergedConfig(),s=n(this._instance,r);this.Ke&&s.show(),this.Ae.forEach(t=>s.onMessage(t)),this.Te.forEach(t=>s.onTyping(t)),this.Ee.forEach(t=>s.onConnectionChange(t)),null===(e=this.er)||void 0===e||e.destroy(),this.er=null;var o=null===(i=null==zh?void 0:zh.document)||void 0===i?void 0:i.getElementById("vtilt-chat-bubble");return o&&!o.closest("#vtilt-chat-container")&&o.remove(),s}Xi(t){this.nr.forEach(t=>t()),this.nr=[],t.isOpen||(this.sr(),this.ar()),uu().info(wS,"loaded and ready")}hr(){var t=this;return e(function*(){var e,i;try{if(!1===t.H.enabled)return void uu().info(wS,"disabled by code config");if(t._instance.getConfig().disable_chat)return void uu().info(wS,"disabled by disable_chat config");if(!1!==t.H.autoConfig&&(yield t.dr()),!t.isEnabled)return void uu().info(wS,"not enabled (check dashboard settings)");uu().debug(wS,"startIfEnabled enabled"),t.Vi=!0,!0===t.H.preload&&t.vr();var n=t.getMergedConfig();(null===(e=t.Xn)||void 0===e?void 0:e.enabled)&&!1!==(null===(i=n.bubble)||void 0===i?void 0:i.visible)&&t.pr(),uu().info(wS,"ready (lazy-load on demand)")}finally{t.tn()}})()}get isOpen(){var t,e;return null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.isOpen)&&void 0!==e&&e}get isConnected(){var t,e;return null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.isConnected)&&void 0!==e&&e}get isLoading(){var t,e;return this.Hi||null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.isLoading)&&void 0!==e&&e}get unreadCount(){var t,e;return null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.unreadCount)&&void 0!==e?e:0}get channel(){var t,e;return null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.channel)&&void 0!==e?e:null}get channels(){var t,e;return null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.channels)&&void 0!==e?e:[]}get currentView(){var t,e;return null!==(e=null===(t=this.Zi)||void 0===t?void 0:t.currentView)&&void 0!==e?e:"list"}open(){this.Qi(()=>{this.lr(),this.mr(()=>{var t;return null===(t=this.Zi)||void 0===t?void 0:t.open()})})}close(){this.Qi(()=>{this.Zi?(this.Zi.close(),this.sr(),this.ar()):this.mr(()=>{var t;null===(t=this.Zi)||void 0===t||t.close(),this.sr(),this.ar()})})}toggle(){this.Qi(()=>{this.Zi?this.Zi.toggle():this.open()})}show(){this.Qi(()=>{this.Ke=!0,this.Zi?this.Zi.show():this.Vi&&this.pr()})}hide(){this.Qi(()=>{var t;if(this.Ke=!1,this.Zi)this.Zi.hide();else{var e=null===(t=null==zh?void 0:zh.document)||void 0===t?void 0:t.getElementById("vtilt-chat-bubble");e&&(e.style.display="none")}})}getChannels(){this.Qi(()=>{this.mr(()=>{var t;return null===(t=this.Zi)||void 0===t?void 0:t.getChannels()})})}selectChannel(t){this.Qi(()=>{this.mr(()=>{var e;return null===(e=this.Zi)||void 0===e?void 0:e.selectChannel(t)})})}createChannel(){this.Qi(()=>{this.mr(()=>{var t;return null===(t=this.Zi)||void 0===t?void 0:t.createChannel()})})}goToChannelList(){this.Qi(()=>{this.Zi?this.Zi.goToChannelList():this.mr(()=>{var t;return null===(t=this.Zi)||void 0===t?void 0:t.goToChannelList()})})}sendMessage(t,e){return this.Zi?this.Zi.sendMessage(t,e):new Promise((i,n)=>{this.Qi(()=>{this.Zi?this.Zi.sendMessage(t,e).then(i).catch(n):(this.ir.push({content:t,options:e,resolve:i,reject:n}),this.mr(()=>{var t,e=this.ir;for(var i of(this.ir=[],e))null===(t=this.Zi)||void 0===t||t.sendMessage(i.content,i.options).then(i.resolve).catch(i.reject)}))})})}markAsRead(){this.Qi(()=>{this.Zi?this.Zi.markAsRead():this.mr(()=>{var t;return null===(t=this.Zi)||void 0===t?void 0:t.markAsRead()})})}registerWidget(t){this.Qi(()=>{var e,i;this.Zi?null===(i=(e=this.Zi).registerWidget)||void 0===i||i.call(e,t):this.mr(()=>{var e,i;null===(i=null===(e=this.Zi)||void 0===e?void 0:e.registerWidget)||void 0===i||i.call(e,t)})})}onMessage(t){return this.Ae.push(t),this.Zi?this.Zi.onMessage(t):()=>{var e=this.Ae.indexOf(t);e>-1&&this.Ae.splice(e,1)}}onTyping(t){return this.Te.push(t),this.Zi?this.Zi.onTyping(t):()=>{var e=this.Te.indexOf(t);e>-1&&this.Te.splice(e,1)}}onConnectionChange(t){return this.Ee.push(t),this.Zi?this.Zi.onConnectionChange(t):()=>{var e=this.Ee.indexOf(t);e>-1&&this.Ee.splice(e,1)}}ur(){var t;return!0===(null===(t=this.getMergedConfig().bubble)||void 0===t?void 0:t.draggable)}getMergedConfig(){var t,e,i,n,r,s,o,a,l,h,u,c,d,v,f,p,m,g,b,y,w,k,x,S,C,_=this.Xn,I=this.H;return{enabled:null!==(e=null!==(t=I.enabled)&&void 0!==t?t:null==_?void 0:_.enabled)&&void 0!==e&&e,autoConfig:null===(i=I.autoConfig)||void 0===i||i,position:null!==(r=null!==(n=I.position)&&void 0!==n?n:null==_?void 0:_.position)&&void 0!==r?r:"bottom-right",greeting:null!==(s=I.greeting)&&void 0!==s?s:null==_?void 0:_.greeting,color:null!==(a=null!==(o=I.color)&&void 0!==o?o:null==_?void 0:_.color)&&void 0!==a?a:"#6366f1",aiMode:null===(h=null!==(l=I.aiMode)&&void 0!==l?l:null==_?void 0:_.ai_enabled)||void 0===h||h,aiGreeting:null!==(u=I.aiGreeting)&&void 0!==u?u:null==_?void 0:_.ai_greeting,preload:null!==(c=I.preload)&&void 0!==c&&c,theme:null!==(d=I.theme)&&void 0!==d?d:{primaryColor:null!==(f=null!==(v=I.color)&&void 0!==v?v:null==_?void 0:_.color)&&void 0!==f?f:"#6366f1"},offlineMessage:null!==(p=I.offlineMessage)&&void 0!==p?p:null==_?void 0:_.offline_message,collectEmailOffline:null===(g=null!==(m=I.collectEmailOffline)&&void 0!==m?m:null==_?void 0:_.collect_email_offline)||void 0===g||g,bubble:{draggable:null!==(w=null!==(y=null===(b=I.bubble)||void 0===b?void 0:b.draggable)&&void 0!==y?y:null==_?void 0:_.bubble_draggable)&&void 0!==w&&w,visible:null===(S=null!==(x=null===(k=I.bubble)||void 0===k?void 0:k.visible)&&void 0!==x?x:null==_?void 0:_.bubble_visible)||void 0===S||S,offset:null===(C=I.bubble)||void 0===C?void 0:C.offset}}}cr(){var t,e,i=this.getMergedConfig(),n=null!==(t=i.position)&&void 0!==t?t:"bottom-right",r=$f(null===(e=i.bubble)||void 0===e?void 0:e.offset),s=document.getElementById("vtilt-chat-bubble");s&&Vf(s,n,r)}destroy(){du(()=>{var t,e,i;this.lr(),document.removeEventListener("visibilitychange",this.V),null===(t=this.Zi)||void 0===t||t.destroy(),this.Zi=void 0,this.Ke=!1,this.ir=[],this.nr=[],this.Ae=[],this.Te=[],this.Ee=[],this.en(),null===(e=this.er)||void 0===e||e.destroy(),this.er=null;var n=null===(i=null==zh?void 0:zh.document)||void 0===i?void 0:i.getElementById("vtilt-chat-bubble");n&&n.remove()})}dr(){var t=this;return e(function*(){if(!t.Qn){var e=t._instance.getConfig();if(!e.token)return uu().warn(wS,"cannot fetch settings: missing token"),void(t.Qn=!0);try{var i=fu(e,"/api/chat/settings"),n=yield fetch(i,{headers:pu(e)});if(!n.ok)return uu().warn(wS,"failed to fetch settings: "+n.status),void(t.Qn=!0);t.Xn=yield n.json(),t.Qn=!0,uu().info(wS,"loaded settings from dashboard")}catch(e){uu().warn(wS,"error fetching settings:",e),t.Qn=!0}}})()}sr(){var t=this;return e(function*(){var e,i,n,r,s,o,a=t._instance.getConfig(),l=a.token,h=null!==(n=null===(i=(e=t._instance).getDistinctId)||void 0===i?void 0:i.call(e))&&void 0!==n?n:"";if(uu().debug("chat","fetchUnread","distinctId",h?h.slice(0,12)+"...":"empty"),l&&h)try{var u=fu(a,"/api/chat/widget/unread"),c=u.includes("?")?"&":"?",d=""+u+c+"distinct_id="+encodeURIComponent(h),v=yield fetch(d,{headers:pu(a)});if(!v.ok)return;var f=yield v.json(),p=Number(null!==(r=f.unread_count)&&void 0!==r?r:0);null===(o=null===(s=t.Zi)||void 0===s?void 0:s.applyPolledUnreadCount)||void 0===o||o.call(s,p);var m=document.getElementById("vtilt-chat-bubble");if(!m)return;var g=m.querySelector(".vtilt-chat-bubble-badge");if(!g)return;p>0?(g.style.display="flex",g.textContent=p>99?"99+":String(p)):g.style.display="none"}catch(t){}else{var b=l?"missing distinctId":"missing token";uu().debug("chat","fetchUnread skip","reason",b)}})()}pr(){var t,e,i,n;if(null==zh?void 0:zh.document){var r=document.getElementById("vtilt-chat-bubble");if(r)return r.style.display="flex",void this.cr();var s=this.getMergedConfig(),o=null!==(t=s.position)&&void 0!==t?t:"bottom-right",a=$f(null===(e=s.bubble)||void 0===e?void 0:e.offset),l=s.color||"#6366f1",h=document.createElement("div");h.id="vtilt-chat-bubble",h.setAttribute("style",("\n position: fixed;\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: "+l+";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n z-index: 999999;\n ").trim()),Vf(h,o,a),h.innerHTML='\n <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>\n </svg>\n <div class="vtilt-chat-bubble-badge" style="\n display: none;\n position: absolute;\n top: -4px;\n right: -4px;\n background: #E53935;\n color: white;\n font-size: 11px;\n font-weight: 700;\n min-width: 20px;\n height: 20px;\n border-radius: 10px;\n align-items: center;\n justify-content: center;\n padding: 0 6px;\n box-sizing: border-box;\n border: 2px solid white;\n ">0</div>\n ';var u=!0===(null===(i=s.bubble)||void 0===i?void 0:i.draggable);u||(h.addEventListener("mouseenter",()=>{h.style.transform="scale(1.05)",h.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),h.addEventListener("mouseleave",()=>{h.style.transform="scale(1)",h.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"})),h.addEventListener("click",()=>{this.open()}),document.body.appendChild(h),u&&(null===(n=this.er)||void 0===n||n.destroy(),this.er=Zf(h)),this.sr(),this.ar(),document.addEventListener("visibilitychange",this.V)}}gr(){return"undefined"!=typeof document&&("visible"===document.visibilityState&&(!!document.getElementById("vtilt-chat-bubble")||!(!this.Zi||this.Zi.isOpen)))}ar(){this.gr()&&null===this.rr&&(this.rr=setInterval(()=>{this.sr()},3e4))}lr(){null!==this.rr&&(clearInterval(this.rr),this.rr=null)}vr(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this.Yi(()=>{}),{timeout:5e3}):setTimeout(()=>this.Yi(()=>{}),3e3)}mr(t){this.Zi?t():(this.nr.push(t),this.Yi(t=>this.Xi(t)))}}function xS(t,e){t("js",new Date);var{tagIds:n,configParams:r,sendPageView:s,debugMode:o,conversionLinker:a,linkerDomains:l}=e,h=i({},r||{});for(var u of(!1===s&&(h.send_page_view=!1),o&&(h.debug_mode=!0),!1===a&&(h.conversion_linker=!1),l&&l.length>0&&(h.linker={domains:l,decorate_forms:!0}),n))u&&t("config",u,h)}function SS(t,e){var i,n=(t.tagIds||[]).filter(t=>!!t);if(0===n.length)return null;var r,s,o,a=null!==(i=t.proxyMode)&&void 0!==i?i:"proxied";if("direct"===a)r=_S,s=_S,o="";else{var l=function(t){var e,i=void 0!==zh&&(null===(e=null==zh?void 0:zh.location)||void 0===e?void 0:e.origin)?zh.location.origin:"";if(!t)return i?{base:i,absoluteBase:i}:null;var n=t.replace(/\/+$/g,"");if(!n)return i?{base:i,absoluteBase:i}:null;try{var r=new URL(n),s=r.pathname.replace(/\/$/,""),o=""+r.origin+s;return{base:o,absoluteBase:o}}catch(t){}if(n.startsWith("/"))return{base:n,absoluteBase:i?""+i+n:n};return i?{base:i,absoluteBase:i}:null}(e);if(!l)return null;r=l.base,s=l.absoluteBase,o=CS}var h={};if("direct"!==a){var u=function(t){if(!t)return"";var e=t.startsWith("/")?t:"/"+t;return e.replace(/\/$/,"")}(o);h.transport_url=""+s.replace(/\/$/,"")+u}return{origin:r,gatewayPath:o,primaryTagId:n.find(t=>t.startsWith("G-"))||n[0]||"",tagIds:n,configParams:h,sendPageView:!1!==t.capturePageview,debugMode:!!t.debugMode,conversionLinker:!1!==t.conversionLinker,linkerDomains:t.linkerDomains}}var CS="/gt",_S="https://www.googletagmanager.com";function IS(t,e){var n=!0===t.advertising,r={ad_storage:n?"granted":"denied",ad_user_data:n?"granted":"denied",ad_personalization:n?"granted":"denied",analytics_storage:!0===t.analytics?"granted":"denied"};if(!e)return r;var s=i({},r);return Object.keys(r).forEach(i=>{var n=e[i];void 0!==n&&(s[i]=function(t,e){return"granted"===e?"granted":"denied"===e?"denied":"follow_advertising"===e?!0===t.advertising?"granted":"denied":"follow_analytics"===e&&!0===t.analytics?"granted":"denied"}(t,n))}),s}function AS(t){if(null==t)return null;var e=String(t).trim().toLowerCase();return e||null}function TS(t,e){if(t&&e){var i=e.split("."),n=t;for(var r of i){if(null==n||"object"!=typeof n)return;n=n[r]}return n}}function ES(t){if("number"==typeof t&&Number.isFinite(t))return t;if("string"==typeof t&&""!==t.trim()){var e=Number(t);if(Number.isFinite(e))return e}}function MS(t){if(null!=t)return"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):void 0}function OS(t){var{mapping:e,payload:i}=t,n={send_to:e.send_to},r=e.value_param_path||"value",s=e.currency_param_path||"currency",o=ES(TS(i,r));void 0!==o&&(n.value=o);var a=MS(TS(i,s))||e.default_currency||void 0;if(a&&(n.currency=a),!1!==e.send_transaction_id){var l=MS(TS(i,e.transaction_id_param_path||"transaction_id"));l&&(n.transaction_id=l)}return{send_to:e.send_to,params:n}}var RS=[{source:"$pageview",destination:"page_view",buildParams:t=>{var e,i={},n=MS(t.$current_url);n&&(i.page_location=n);var r=MS(t.$pathname);r&&(i.page_path=r);var s=null!==(e=MS(t.title))&&void 0!==e?e:MS(t.$title);s&&(i.page_title=s);var o=MS(t.$referrer);return o&&(i.page_referrer=o),i}},{source:"$pageleave",destination:"user_engagement",buildParams:t=>{var e,i,n={},r=ES(null!==(i=null!==(e=t.$dwell_time_ms)&&void 0!==e?e:t.engagement_time_msec)&&void 0!==i?i:t.$time_on_page_ms);return void 0!==r&&(n.engagement_time_msec=Math.round(r)),n}}];function NS(t,e,i){var n=e.split(".").filter(Boolean);if(0!==n.length)if(1!==n.length){for(var r=t,s=0;s<n.length-1;s++){var o=n[s],a=n[s+1];if(null==r||"object"!=typeof r||Array.isArray(r))return;var l=r;if(/^\d+$/.test(a)){var h=Array.isArray(l[o])?l[o]:[];Array.isArray(l[o])||(l[o]=h);for(var u=parseInt(a,10);h.length<=u;)h.push({});if(s+1===n.length-1)return void(h[u]=i);var c=h[u];c&&"object"==typeof c&&!Array.isArray(c)||(c={},h[u]=c),r=c,s++}else{var d=l[o];d&&"object"==typeof d&&!Array.isArray(d)||(d={},l[o]=d),r=d}}var v=n[n.length-1];r&&"object"==typeof r&&!Array.isArray(r)&&(r[v]=i)}else t[n[0]]=i}var PS=new Set(["client_id","user_id","first_visit","session_start"]);function BS(t,e,i,n){if(!function(t,e){return!(e&&(Array.isArray(e.exclude)&&e.exclude.includes(t)||Array.isArray(e.include)&&e.include.length>0&&!e.include.includes(t)))}(e,n.eventFilter))return{fired:!1};var r=(n.eventMappings||[]).find(t=>(null==t?void 0:t.source)===e);if(r&&r.destination){var{name:s,params:o}=function(t,e){var i={},n=Array.isArray(t.param_mappings)?t.param_mappings:[];for(var r of n){var s=null==r?void 0:r.source,o=null==r?void 0:r.destination;if(s&&o){var a=TS(e,s);void 0!==a&&(o.includes(".")?NS(i,o,a):i[o]=a)}}return{name:t.destination,params:i}}(r,i);return t("event",s,o),{fired:!0,eventName:s,params:o,source:"mapping"}}if(!1===n.autoForward)return{fired:!1};var a=RS.find(t=>t.source===e);if(a){var l=a.buildParams(i);return t("event",a.destination,l),{fired:!0,eventName:a.destination,params:l,source:"preset"}}if(e.startsWith("$"))return{fired:!1};var h=function(t){var e={};for(var[i,n]of Object.entries(t))i.startsWith("$")||PS.has(i)||void 0!==n&&(e[i]=n);return e}(i);return t("event",e,h),{fired:!0,eventName:e,params:h,source:"auto"}}function DS(){var t=null,e=[],i=[];return{call:function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];if((t=>{i.push(t),i.length>50&&i.shift()})(r),t)try{t(...r)}catch(t){}else e.push(r)},flush(i){for(t=i;e.length;){var n=e.shift();try{i(...n)}catch(t){}}},getRecentCalls:()=>i.slice()}}function jS(t){return US.apply(this,arguments)}function US(){return US=e(function*(t){try{var e="undefined"!=typeof crypto&&crypto.subtle?crypto.subtle:null;if(!e)return null;var i=(new TextEncoder).encode(t),n=yield e.digest("SHA-256",i),r=Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("");return r}catch(t){return null}}),US.apply(this,arguments)}function LS(){return(LS=e(function*(t){var e={},i=function(t){if(!t)return null;var e=String(t).trim().toLowerCase();if(!e)return null;if(!e.includes("@"))return null;var[i,n]=e.split("@");if(!i||!n)return null;if("gmail.com"===n||"googlemail.com"===n){var r=i.split("+")[0].replace(/\./g,"");return r?r+"@"+n:null}return i+"@"+n}(t.email),n=function(t){if(!t)return null;var e=String(t).trim();if(!e)return null;if(e.startsWith("+")){var i=e.slice(1).replace(/\D/g,"");return i?"+"+i:null}return null}(t.phone),r=AS(t.first_name),s=AS(t.last_name),o=AS(t.street),a=AS(t.city),l=AS(t.region),h=function(t){if(!t)return null;var e=String(t).trim().toUpperCase().replace(/\s+/g,"");return e||null}(t.postal_code),u=AS(t.country);if(i){var c=yield jS(i);c&&(e.sha256_email_address=c)}if(n){var d=yield jS(n);d&&(e.sha256_phone_number=d)}var v={};if(r){var f=yield jS(r);f&&(v.sha256_first_name=f)}if(s){var p=yield jS(s);p&&(v.sha256_last_name=p)}if(o){var m=yield jS(o);m&&(v.sha256_street=m)}return a&&(v.city=a),l&&(v.region=l),h&&(v.postal_code=h),u&&(v.country=u),Object.keys(v).length>0&&(e.address=v),0===Object.keys(e).length?null:e})).apply(this,arguments)}class FS{constructor(t){void 0===t&&(t=Number.POSITIVE_INFINITY),this.br=t,this.yr=[]}get length(){return this.yr.length}enqueue(t){return!(this.yr.length>=this.br)&&(this.yr.push(t),!0)}takeAll(){if(0===this.yr.length)return[];var t=this.yr;return this.yr=[],t}clear(){this.yr=[]}}var zS="google-tag";class WS{constructor(t,e){this.name="GoogleTagGateway",this.Vi=!1,this.wr=!1,this.kr=!1,this.Sr=!1,this.Cr=null,this._r=null,this.Ir=null,this.Ar=null,this.Tr=[],this.Er=100,this.Mr=new FS(100),this._instance=t,this.H=e||WS.extractConfig(t.getConfig()),this.Or=DS(),this.Rr()}static extractConfig(t){if(t.disable_google_tag)return{enabled:!1};var e=t.google_tag;return e?{enabled:(e.tagIds||[]).some(t=>!!t),remote:e}:{enabled:!1}}get isEnabled(){return!1!==this.H.enabled&&!!this.H.remote}get isStarted(){return this.Vi}get gtag(){return this.Or.call}get deliveryLog(){return this.Tr.slice()}startIfEnabled(){this.Vi||this.isEnabled&&this._instance.getConfig().__remote_config_loaded&&this.mn()}stop(){var t;this.Vi&&(null===(t=this.Ar)||void 0===t||t.call(this),this.Ar=null,this.Vi=!1)}onConfigUpdate(t){var e=WS.extractConfig(t),i=this.isEnabled;this.H=e;var n=!0===t.__remote_config_loaded;if(i&&!this.isEnabled)this.stop();else if(this.Vi&&e.remote&&this._r){var r=SS(e.remote,this._instance.getConfig().api_host);r&&(this._r=r,xS(this.Cr,r))}n&&!this.isEnabled&&this.Mr.clear(),n&&this.isEnabled&&!this.Vi&&this.startIfEnabled()}setUserData(t){var i=this;return e(function*(){var e=i.H.remote;if(e&&e.enhancedConversions){var n=yield function(t){return LS.apply(this,arguments)}(t);n&&i.Or.call("set","user_data",n)}})()}getRecentPublicCalls(){return this.Or.getRecentCalls()}mn(){var t=this.H.remote;if(t){var e=SS(t,this._instance.getConfig().api_host);if(e){this._r=e;var{gtag:i}=function(){var t,e,i=Gh,n=null!==(t=(e=i).dataLayer)&&void 0!==t?t:e.dataLayer=[],r=i.gtag;if(r)return{gtag:r,dataLayer:n};var s=function(){n.push(arguments)};return i.gtag=s,{gtag:s,dataLayer:n}}();this.Cr=i,this.Or.flush(i),this.Nr(),xS(i,e),this.wr||(this.wr=!0,function(t,e,i){var n=null==zh?void 0:zh.document;if(!n)return null;var{origin:r,gatewayPath:s,primaryTagId:o}=t;if(!r||!o)return null;var a=""+r.replace(/\/$/,"")+(s?s.startsWith("/")?s.replace(/\/$/,""):"/"+s.replace(/\/$/,""):"")+"/gtag/js?id="+encodeURIComponent(o)+"&l=dataLayer",l=n.querySelector('script[data-vtilt-gtag-loader="'+o+'"]');if(l)return l;var h=n.createElement("script");h.async=!0,h.src=a,h.setAttribute("data-vtilt-gtag-loader",o),h.onload=()=>null==e?void 0:e(),h.onerror=()=>{var t=new Error("[GoogleTagGateway] failed to load "+a);null==i||i(t)},(n.head||n.body||n.documentElement).appendChild(h)}(e,()=>{this.kr=!0},t=>{uu().warn(zS,t.message)})),this.Pr(),this.Vi=!0,this.Br()}else uu().warn(zS,"skipped — missing tag_ids or resolvable origin")}}Br(){for(var t of this.Mr.takeAll())this.Dr(t.event,t.payload)}Nr(){var t;if(!this.Sr&&this.Cr){var e=du(()=>this._instance.consentManager.getConsent());!function(t,e,n){t("consent","default",i({},IS(e,n),{wait_for_update:500}))}(this.Cr,e||{},null===(t=this.H.remote)||void 0===t?void 0:t.consentOverride),this.Sr=!0}}Rr(){if(!this.Ir){this.Ir=this._instance._emitter.on(ku,t=>{var e=t;e&&"string"==typeof e.event&&this.Dr(e.event,e.payload||{})})}}Dr(t,e){var i=this._instance.getConfig();if(!i.disable_google_tag)if(i.__remote_config_loaded){if(this.isEnabled&&(this.Vi||this.startIfEnabled(),this.Cr&&this.H.remote&&this.Vi)){var n=this.H.remote,r=n.tagIds||[],s=BS(this.Cr,t,e,n);if(s.fired&&s.eventName&&this.jr({ts:Date.now(),tag_ids:r,event_name:t,send_to:"ga4:"+s.eventName,status:"fired",reason:s.source}),!1!==n.sendAdsConversions){var o=function(t,e,i,n){var r=(n.conversions||[]).filter(t=>t.event_name===e);if(0===r.length)return[];var s=[];for(var o of r){var a=OS({mapping:o,payload:i});t("event","conversion",a.params),s.push(a)}return s}(this.Cr,t,e,n);for(var a of o)this.jr({ts:Date.now(),tag_ids:r,event_name:t,send_to:a.send_to,status:"fired"})}}}else this.Mr.enqueue({event:t,payload:e})}Pr(){if(!this.Ar){this.Ar=this._instance._emitter.on(wu,t=>{var e;if(this.Cr){var i,n,r,s=t;i=this.Cr,n=s.consent||{},r=null===(e=this.H.remote)||void 0===e?void 0:e.consentOverride,i("consent","update",IS(n,r))}})}}jr(t){this.Tr.push(t),this.Tr.length>this.Er&&this.Tr.shift()}}var $S="vtd-overlay";class VS{constructor(t,e){this.name="VtdOverlay",this.Vi=!1,this.Ur=null,this.Lr=null,this.Hi=!0,this.Fr=null,this.zr=null,this.Wr=null,this._instance=t,this.H=e||VS.extractConfig(t.getConfig())}static extractConfig(t){return{enabled:!1!==t.vtd_overlay}}get isEnabled(){return!1!==this.H.enabled}get isStarted(){return this.Vi}startIfEnabled(){}stop(){this.Vi&&du(()=>{this.$r(),this.Vi=!1})}onConfigUpdate(t){this.H=VS.extractConfig(t),!this.isEnabled&&this.Vi&&this.stop()}setDestinationUrl(t){var e;if(this.isEnabled)if(null==t?void 0:t.trim()){var i=t;try{i=decodeURIComponent(t)}catch(e){i=t}if(this.Vr(i)){var n=this.Hr(i);this.Lr=i,this.Ur=n,this.Hi=!0,this.qr(),this.Vi=!0,this._instance.capture("$vtd_view",{$vtd_url:i,$vtd_embed_url:n!==i?n:void 0,$current_url:null===(e=null==zh?void 0:zh.location)||void 0===e?void 0:e.href})}else uu().warn($S,"invalid URL: "+i)}else uu().warn($S,"empty URL provided");else uu().warn($S,"feature is disabled")}getDestinationUrl(){return this.Ur}close(){this._instance.capture("$vtd_close",{$vtd_url:this.Lr}),this.Fr?(this.Fr.classList.add("vtilt-vtd-closing"),setTimeout(()=>{this.$r(),this.Vi=!1,this.Ur=null,this.Lr=null},200)):(this.$r(),this.Vi=!1,this.Ur=null,this.Lr=null)}Vr(t){try{var e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol}catch(t){return!1}}Hr(t){try{var e=new URL(t),i=e.hostname.toLowerCase();if("youtube.com"===i||"www.youtube.com"===i||"m.youtube.com"===i){var n=e.searchParams.get("v");if(n){var r=e.searchParams.get("t"),s="https://www.youtube.com/embed/"+n+"?autoplay=1";return r&&(s+="&start="+r.replace("s","")),s}}if("youtu.be"===i){var o=e.pathname.slice(1);if(o){var a=e.searchParams.get("t"),l="https://www.youtube.com/embed/"+o+"?autoplay=1";return a&&(l+="&start="+a.replace("s","")),l}}if("vimeo.com"===i||"www.vimeo.com"===i){var h=e.pathname.match(/^\/(\d+)/);if(h)return"https://player.vimeo.com/video/"+h[1]+"?autoplay=1"}if("loom.com"===i||"www.loom.com"===i){var u=e.pathname.match(/^\/share\/([a-zA-Z0-9]+)/);if(u)return"https://www.loom.com/embed/"+u[1]+"?autoplay=1"}if(i.endsWith("wistia.com")){var c=e.pathname.match(/^\/medias\/([a-zA-Z0-9]+)/);if(c)return"https://fast.wistia.net/embed/iframe/"+c[1]+"?autoplay=1"}if("dailymotion.com"===i||"www.dailymotion.com"===i){var d=e.pathname.match(/^\/video\/([a-zA-Z0-9]+)/);if(d)return"https://www.dailymotion.com/embed/video/"+d[1]+"?autoplay=1"}if("open.spotify.com"===i){var v=e.pathname.match(/^\/(track|album|playlist|episode|show)\/([a-zA-Z0-9]+)/);if(v)return"https://open.spotify.com/embed/"+v[1]+"/"+v[2]}return"drive.google.com"===i&&e.pathname.includes("/view")?t.replace("/view","/preview"):t}catch(e){return t}}Jr(t){try{return new URL(t).hostname}catch(e){return t}}Gr(t){try{return"https://www.google.com/s2/favicons?domain="+new URL(t).hostname+"&sz=32"}catch(t){return""}}qr(){if(Vh&&this.Ur){this.$r(),this.Fr=Vh.createElement("div"),this.Fr.id="vtilt-vtd-overlay",this.Fr.className="vtilt-vtd-opening",this.Fr.setAttribute("style",this.Zr());var t=Vh.createElement("div");t.className="vtilt-vtd-modal",t.setAttribute("style",this.Yr());var e=Vh.createElement("div");e.className="vtilt-vtd-header",e.setAttribute("style",this.Kr()),e.innerHTML=this.Xr(),t.appendChild(e);var i=Vh.createElement("div");i.className="vtilt-vtd-iframe-wrapper",i.setAttribute("style",this.Qr()),this.Wr=Vh.createElement("div"),this.Wr.className="vtilt-vtd-loading",this.Wr.setAttribute("style",this.es()),this.Wr.innerHTML=this.ns(),i.appendChild(this.Wr),this.zr=Vh.createElement("iframe"),this.zr.id="vtilt-vtd-iframe",this.zr.className="vtilt-vtd-iframe",this.zr.setAttribute("style",this.rs()),this.zr.setAttribute("frameborder","0"),this.zr.setAttribute("allowfullscreen","true"),this.zr.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share");var n=()=>{this.Hi=!1,this.Wr&&(this.Wr.style.opacity="0",setTimeout(()=>{var t;(null===(t=this.Wr)||void 0===t?void 0:t.parentNode)&&(this.Wr.style.display="none")},300)),this.zr&&(this.zr.style.opacity="1")};this.zr.onload=n,this.zr.onerror=n,setTimeout(()=>{this.Hi&&n()},5e3),i.appendChild(this.zr),this.zr.src=this.Ur,t.appendChild(i),this.Fr.appendChild(t);var r=Vh.createElement("style");r.id="vtilt-vtd-styles",r.textContent=this.ss(),Vh.head.appendChild(r),Vh.body.appendChild(this.Fr),this.ls(),Vh.body.style.overflow="hidden"}}$r(){var t;(null===(t=this.Fr)||void 0===t?void 0:t.parentNode)&&(this.Fr.parentNode.removeChild(this.Fr),this.Fr=null,this.zr=null,this.Wr=null);var e=null==Vh?void 0:Vh.getElementById("vtilt-vtd-styles");(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e),(null==Vh?void 0:Vh.body)&&(Vh.body.style.overflow="")}ls(){var t,e,i,n=null===(t=this.Fr)||void 0===t?void 0:t.querySelector(".vtilt-vtd-close");null==n||n.addEventListener("click",()=>this.close());var r=null===(e=this.Fr)||void 0===e?void 0:e.querySelector(".vtilt-vtd-open");null==r||r.addEventListener("click",()=>{this.Lr&&(null==zh||zh.open(this.Lr,"_blank"))}),null===(i=this.Fr)||void 0===i||i.addEventListener("click",t=>{t.target===this.Fr&&this.close()});var s=t=>{"Escape"===t.key&&(this.close(),null==Vh||Vh.removeEventListener("keydown",s))};null==Vh||Vh.addEventListener("keydown",s)}Zr(){return'\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 2147483647;\n background: rgba(0, 0, 0, 0.85);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n '}Yr(){return"\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background: #0a0a0a;\n overflow: hidden;\n "}Kr(){return"\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 16px;\n height: 56px;\n background: linear-gradient(180deg, rgba(20, 20, 20, 1) 0%, rgba(15, 15, 15, 1) 100%);\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n gap: 16px;\n "}Xr(){var t=this.Lr||this.Ur,e=t?this.Jr(t):"";return'\n <div style="display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;">\n <img \n src="'+(t?this.Gr(t):"")+'" \n alt="" \n style="width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0;"\n onerror="this.style.display=\'none\'"\n />\n <div style="\n display: flex;\n flex-direction: column;\n min-width: 0;\n gap: 2px;\n ">\n <div style="\n color: rgba(255, 255, 255, 0.95);\n font-size: 14px;\n font-weight: 500;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.2;\n ">'+this.hs(e)+'</div>\n <div style="\n color: rgba(255, 255, 255, 0.45);\n font-size: 12px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.2;\n ">'+this.hs(this.us(t||"",50))+'</div>\n </div>\n </div>\n <div style="display: flex; align-items: center; gap: 8px; flex-shrink: 0;">\n <button class="vtilt-vtd-open vtilt-vtd-btn" title="Open in new tab">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>\n <polyline points="15 3 21 3 21 9"></polyline>\n <line x1="10" y1="14" x2="21" y2="3"></line>\n </svg>\n <span class="vtilt-vtd-btn-text">Open</span>\n </button>\n <button class="vtilt-vtd-close vtilt-vtd-btn vtilt-vtd-btn-primary" title="Close (Esc)">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n <span class="vtilt-vtd-btn-text">Close</span>\n </button>\n </div>\n '}Qr(){return"\n flex: 1;\n position: relative;\n background: #000;\n overflow: hidden;\n "}es(){return"\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n background: #0a0a0a;\n z-index: 1;\n transition: opacity 0.3s ease;\n "}ns(){var t=this.Lr||this.Ur,e=t?this.Jr(t):"";return'\n <div class="vtilt-vtd-spinner"></div>\n <div style="\n margin-top: 20px;\n color: rgba(255, 255, 255, 0.7);\n font-size: 14px;\n font-weight: 500;\n ">Loading '+this.hs(e)+'...</div>\n <div style="\n margin-top: 8px;\n color: rgba(255, 255, 255, 0.35);\n font-size: 12px;\n ">Press <kbd style="\n display: inline-block;\n padding: 2px 6px;\n background: rgba(255, 255, 255, 0.1);\n border-radius: 4px;\n font-family: inherit;\n font-size: 11px;\n ">Esc</kbd> to close</div>\n '}rs(){return"\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n border: none;\n background: white;\n opacity: 0;\n transition: opacity 0.3s ease;\n "}ss(){return"\n /* Animations */\n @keyframes vtilt-vtd-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n \n @keyframes vtilt-vtd-fade-out {\n from { opacity: 1; }\n to { opacity: 0; }\n }\n \n @keyframes vtilt-vtd-scale-in {\n from { opacity: 0; transform: scale(0.96); }\n to { opacity: 1; transform: scale(1); }\n }\n \n @keyframes vtilt-vtd-spin {\n to { transform: rotate(360deg); }\n }\n \n /* Container animations */\n #vtilt-vtd-overlay.vtilt-vtd-opening {\n animation: vtilt-vtd-fade-in 0.2s ease-out forwards;\n }\n \n #vtilt-vtd-overlay.vtilt-vtd-opening .vtilt-vtd-modal {\n animation: vtilt-vtd-scale-in 0.25s ease-out forwards;\n }\n \n #vtilt-vtd-overlay.vtilt-vtd-closing {\n animation: vtilt-vtd-fade-out 0.2s ease-in forwards;\n }\n \n /* Loading spinner */\n .vtilt-vtd-spinner {\n width: 40px;\n height: 40px;\n border: 3px solid rgba(255, 255, 255, 0.1);\n border-top-color: rgba(255, 255, 255, 0.8);\n border-radius: 50%;\n animation: vtilt-vtd-spin 0.8s linear infinite;\n }\n \n /* Button base styles */\n .vtilt-vtd-btn {\n background: rgba(255, 255, 255, 0.08);\n border: 1px solid rgba(255, 255, 255, 0.1);\n color: rgba(255, 255, 255, 0.9);\n padding: 8px 14px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 13px;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 6px;\n transition: all 0.15s ease;\n -webkit-tap-highlight-color: transparent;\n outline: none;\n }\n \n .vtilt-vtd-btn:hover {\n background: rgba(255, 255, 255, 0.14);\n border-color: rgba(255, 255, 255, 0.18);\n }\n \n .vtilt-vtd-btn:active {\n background: rgba(255, 255, 255, 0.18);\n transform: scale(0.98);\n }\n \n .vtilt-vtd-btn:focus-visible {\n box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);\n }\n \n /* Primary button variant */\n .vtilt-vtd-btn-primary {\n background: rgba(255, 255, 255, 0.95);\n border-color: transparent;\n color: #0a0a0a;\n }\n \n .vtilt-vtd-btn-primary:hover {\n background: rgba(255, 255, 255, 1);\n border-color: transparent;\n }\n \n .vtilt-vtd-btn-primary:active {\n background: rgba(255, 255, 255, 0.85);\n }\n \n /* Desktop responsive - modal with margin */\n @media (min-width: 768px) {\n #vtilt-vtd-overlay {\n padding: 32px;\n }\n \n .vtilt-vtd-modal {\n max-width: 1200px;\n max-height: 90vh;\n width: 100%;\n height: auto;\n min-height: 500px;\n border-radius: 16px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);\n }\n \n .vtilt-vtd-header {\n border-radius: 16px 16px 0 0;\n }\n \n .vtilt-vtd-iframe-wrapper {\n border-radius: 0 0 16px 16px;\n min-height: 400px;\n }\n }\n \n /* Large desktop - bigger modal */\n @media (min-width: 1400px) {\n #vtilt-vtd-overlay {\n padding: 48px;\n }\n \n .vtilt-vtd-modal {\n max-width: 1400px;\n max-height: 85vh;\n }\n }\n \n /* Tablet */\n @media (min-width: 768px) and (max-width: 1024px) {\n #vtilt-vtd-overlay {\n padding: 24px;\n }\n \n .vtilt-vtd-modal {\n max-width: 95%;\n max-height: 90vh;\n }\n }\n \n /* Mobile - fullscreen */\n @media (max-width: 767px) {\n #vtilt-vtd-overlay {\n padding: 0 !important;\n background: #0a0a0a !important;\n }\n \n .vtilt-vtd-modal {\n width: 100% !important;\n height: 100% !important;\n max-width: none !important;\n max-height: none !important;\n border-radius: 0 !important;\n }\n \n .vtilt-vtd-header {\n border-radius: 0 !important;\n padding: 0 12px !important;\n height: 52px !important;\n }\n \n .vtilt-vtd-btn {\n padding: 8px 10px !important;\n }\n \n .vtilt-vtd-btn-text {\n display: none !important;\n }\n \n .vtilt-vtd-iframe-wrapper {\n border-radius: 0 !important;\n }\n }\n \n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n #vtilt-vtd-overlay,\n #vtilt-vtd-overlay *,\n .vtilt-vtd-spinner {\n animation-duration: 0.01ms !important;\n transition-duration: 0.01ms !important;\n }\n }\n "}us(t,e){return t.length<=e?t:t.substring(0,e-3)+"..."}hs(t){if(void 0===Vh)return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");var e=Vh.createElement("div");return e.textContent=t,e.innerHTML}}var HS,qS="text/plain",JS=61440;!function(t){t.GZipJS="gzip-js",t.Base64="base64",t.None="none"}(HS||(HS={}));var GS=function(t,e){void 0===e&&(e="binary");var{data:i,compression:n}=t;if(i){var r=(t=>JSON.stringify(t,(t,e)=>"bigint"==typeof e?e.toString():e))(i),s=new Blob([r]).size;if(n===HS.GZipJS&&s>=1024)try{var o=Ic(Ec(r),{mtime:0});if("text-base64"===e){var a=Mc(o);if(a.length>0&&a.length<.95*s)return{contentType:qS,body:a,estimatedSize:a.length,compressionApplied:HS.Base64}}else{var l=new Blob([o],{type:qS});if(l.size>0&&l.size<.95*s)return{contentType:qS,body:l,estimatedSize:l.size,compressionApplied:HS.GZipJS}}}catch(t){}return{contentType:"application/json",body:r,estimatedSize:s,compressionApplied:null}}};function ZS(t,e){return e.compressionApplied?function(t,e){var i=t.includes("?")?"&":"?";return""+t+i+"compression="+e}(t.url,e.compressionApplied):t.url}function YS(t,e){var i={};return e&&(i["Content-Type"]=e),t.headers&&Object.assign(i,t.headers),t.projectToken&&(i[vu]=t.projectToken),i}var KS=[{name:"fetch",isAvailable:()=>"undefined"!=typeof fetch,method:t=>{var i=GS(t,"binary");if(i){var{contentType:n,body:r,estimatedSize:s}=i,o=ZS(t,i),a=YS(t,n),l=new AbortController,h=t.timeout?setTimeout(()=>l.abort(),t.timeout):null;fetch(o,{method:t.method||"POST",headers:a,body:r,keepalive:s<JS,signal:l.signal}).then(function(){var i=e(function*(e){var i,n=yield e.text(),r={statusCode:e.status,text:n};if(200===e.status){Tu();try{r.json=JSON.parse(n)}catch(t){}}null===(i=t.callback)||void 0===i||i.call(t,r)});return function(t){return i.apply(this,arguments)}}()).catch(()=>{var e;Au("capture"),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0})}).finally(()=>{h&&clearTimeout(h)})}}},{name:"XHR",isAvailable:()=>"undefined"!=typeof XMLHttpRequest,method:t=>{var e=GS(t,"binary");if(e){var{contentType:i,body:n}=e,r=ZS(t,e),s=YS(t,i),o=new XMLHttpRequest;for(var[a,l]of(o.open(t.method||"POST",r,!0),Object.entries(s)))o.setRequestHeader(a,l);t.timeout&&(o.timeout=t.timeout),o.onreadystatechange=()=>{var e;if(4===o.readyState){var i={statusCode:o.status,text:o.responseText};if(200===o.status){Tu();try{i.json=JSON.parse(o.responseText)}catch(t){}}null===(e=t.callback)||void 0===e||e.call(t,i)}},o.onerror=()=>{var e;Au("capture"),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0})},o.send(n)}}},{name:"sendBeacon",isAvailable:()=>"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:t=>{var e=GS(t,"text-base64");if(e){var{contentType:n,body:r,estimatedSize:s}=e;if(0!==s){var o=ZS(t,e),a=t.projectToken?function(t,e){if(!e||/[?&]token=/.test(t))return t;var i=t.includes("?")?"&":"?";return""+t+i+"token="+e}(o,t.projectToken):o;if(s<=JS)try{var l="string"==typeof r?new Blob([r],{type:n}):r;if("undefined"!=typeof navigator&&navigator.sendBeacon)if(navigator.sendBeacon(a,l))return}catch(t){}try{var h="string"==typeof r?new Blob([r],{type:n}):r,u=i({"Content-Type":n},t.headers||{});fetch(a,{method:t.method||"POST",headers:u,body:h,keepalive:s<JS}).catch(()=>{})}catch(t){}}}}}],XS=t=>{var e,i;if(Eu())null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0});else{var n=t.transport||"fetch",r=KS.find(t=>t.name===n&&t.isAvailable())||KS.find(t=>t.isAvailable());if(!r)return uu().error("request","no available transport method"),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0}));r.method(t)}};class QS{constructor(t,e){var i,n,r,s;this.cs=!0,this.ds=[],this.vs=(i=(null==e?void 0:e.flush_interval_ms)||3e3,n=250,r=5e3,s=3e3,"number"!=typeof i||isNaN(i)?s:Math.min(Math.max(i,n),r)),this.fs=t}get length(){return this.ds.length}enqueue(t){this.ds.push(t),this.ps||this.gs()}unload(){if(this.bs(),0!==this.ds.length){var t=this.ys();for(var e in t){var n=t[e];this.fs(i({},n,{transport:"sendBeacon"}))}}}enable(){this.cs=!1,this.gs()}pause(){this.cs=!0,this.bs()}flush(){this.bs(),this.ws(),this.gs()}gs(){this.cs||(this.ps=setTimeout(()=>{this.bs(),this.ws(),this.ds.length>0&&this.gs()},this.vs))}bs(){this.ps&&(clearTimeout(this.ps),this.ps=void 0)}ws(){if(0!==this.ds.length){var t=this.ys(),e=Date.now();for(var i in t){var n=t[i];n.events.forEach(t=>{var i=new Date(t.timestamp).getTime();t.$offset=Math.abs(i-e)}),this.fs(n)}}}ys(){var t={};return this.ds.forEach(e=>{var i=e.batchKey||e.url;t[i]||(t[i]={url:e.url,events:[],batchKey:e.batchKey}),t[i].events.push(e.event)}),this.ds=[],t}}class tC{constructor(t){this.ks=!1,this.xs=3e3,this.ds=[],this.Ss=!0,this.fs=t.sendRequest,this.Cs=t.sendBeacon,zh&&void 0!==$h&&"onLine"in $h&&(this.Ss=$h.onLine,Pu(zh,"online",()=>{this.Ss=!0,this.an()}),Pu(zh,"offline",()=>{this.Ss=!1}))}get length(){return this.ds.length}enqueue(t,e){if(void 0===e&&(e=0),e>=10)uu().error("retry","request failed after 10 retries, giving up");else if(!Eu()){var i=function(t){var e=3e3*Math.pow(2,t),i=e/2,n=Math.min(18e5,e),r=(Math.random()-.5)*(n-i);return Math.ceil(n+r)}(e),n=Date.now()+i;this.ds.push({retryAt:n,request:t,retriesPerformedSoFar:e+1});var r="enqueued failed request for retry in "+Math.round(i/1e3)+"s";this.Ss||(r+=" (browser is offline)"),uu().warn("retry",r),this.ks||(this.ks=!0,this._s())}}retriableRequest(t){var i=this;return e(function*(){try{var e=yield i.fs(t);200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&i.enqueue(t,0)}catch(e){i.enqueue(t,0)}})()}_s(){this.Is&&clearTimeout(this.Is),this.Is=setTimeout(()=>{this.Ss&&this.ds.length>0&&this.an(),this.ds.length>0?this._s():this.ks=!1},this.xs)}an(){var t=this,i=Date.now(),n=[],r=[];this.ds.forEach(t=>{t.retryAt<i?r.push(t):n.push(t)}),this.ds=n,r.forEach(function(){var i=e(function*(e){var{request:i,retriesPerformedSoFar:n}=e;try{var r=yield t.fs(i);200!==r.statusCode&&(r.statusCode<400||r.statusCode>=500)&&t.enqueue(i,n)}catch(e){t.enqueue(i,n)}});return function(t){return i.apply(this,arguments)}}())}unload(){this.Is&&(clearTimeout(this.Is),this.Is=void 0),this.ds.forEach(t=>{var{request:e}=t;try{this.Cs(e)}catch(t){uu().error("retry","failed to send beacon on unload",t)}}),this.ds=[]}}var eC="vt_rate_limit";class iC{constructor(t){var e,i;void 0===t&&(t={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(e=t.eventsPerSecond)&&void 0!==e?e:10,this.eventsBurstLimit=Math.max(null!==(i=t.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=t.persistence,this.captureWarning=t.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(t){var e,i,n,r;void 0===t&&(t=!1);var s=Date.now(),o=null!==(i=null===(e=this.persistence)||void 0===e?void 0:e.get(eC))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:s},a=(s-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=s,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var l=o.tokens<1;return l||t||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||t||null===(n=this.captureWarning)||void 0===n||n.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(r=this.persistence)||void 0===r||r.set(eC,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class nC{constructor(t){this.As=null,this.Ts=null,this.Es=t}get config(){return this.As}onApply(t){this.Ms=t}onLoad(t){this.Os=t}load(){var t,e=this.Es.getConfig();if(e.token){if(this.Ts||(this.Ts=i({},e)),null===(t=e.bootstrap)||void 0===t?void 0:t.remoteConfig)return this.As=e.bootstrap.remoteConfig,this.Rs(this.As),void this.Ns();var n=du(()=>zh.__VTILT_BOOTSTRAP__);if(null==n?void 0:n.remoteConfig)return this.As=n.remoteConfig,this.Rs(this.As),void this.Ns();du(()=>{var t=localStorage.getItem(mw+"_"+e.token);t&&(this.As=JSON.parse(t),this.Rs(this.As,!0))}),this.Ns()}}Ns(){var t=this.Es.getConfig();if(t.token)if(Eu())this.Es.updateConfig({__remote_config_loaded:!0});else{var e=this.Es.buildEndpointUrl("/api/d"),n=new AbortController,r=setTimeout(()=>n.abort(),3e3);(qh||fetch)(e,{method:"GET",signal:n.signal,headers:i({Accept:"application/json"},pu(t))}).then(t=>t.json()).then(e=>{var i;clearTimeout(r),Tu(),this.As=e,du(()=>{localStorage.setItem(mw+"_"+t.token,JSON.stringify(e))}),this.Rs(e),null===(i=this.Os)||void 0===i||i.call(this,e)}).catch(()=>{clearTimeout(r),Au("config"),this.Es.updateConfig({__remote_config_loaded:!0})})}}Rs(t,e){var n,r,s,o;void 0===e&&(e=!1);var a=this.Ts||this.Es.getConfig(),l={};for(var[,h]of this.Es.featureManager.getDescriptors())if(h.remoteConfig&&h.configKey){var u=t[h.remoteConfig.key];u&&void 0===a[h.configKey]&&(l[h.configKey]=h.remoteConfig.map(u))}if(t.analytics&&!e&&(void 0!==t.analytics.capturePageview&&void 0===a.capture_pageview&&(l.capture_pageview=t.analytics.capturePageview),void 0!==t.analytics.capturePageleave&&void 0===a.capture_pageleave&&(l.capture_pageleave=!!t.analytics.capturePageleave),void 0!==t.analytics.capturePerformance&&void 0===a.capture_performance&&(l.capture_performance=t.analytics.capturePerformance),void 0===a.autocapture)){var c=t.analytics.autocapture,d=t.analytics.scrollDepthMilestones,v=t.analytics.scrollDepthPageleave;void 0!==c&&(l.autocapture=c&&(d||v)?{scroll_depth:i({},d?{milestones:!0}:{},v?{pageleave:!0}:{})}:c)}e||(l.__remote_config_loaded=!0),void 0!==(null===(n=t.privacy)||void 0===n?void 0:n.respectDnt)&&void 0===a.respect_dnt&&(l.respect_dnt=t.privacy.respectDnt),void 0!==(null===(r=t.privacy)||void 0===r?void 0:r.requireConsent)&&void 0===a.require_consent&&(l.require_consent=t.privacy.requireConsent),void 0!==t.autocapture_opt_out&&(l.autocapture_opt_out=t.autocapture_opt_out),void 0!==t.elementsChainAsString&&(l.elementsChainAsString=t.elementsChainAsString),(null===(s=t.diagnostics)||void 0===s?void 0:s.defaultLogLevel)&&uu().setLevelFromRemote(t.diagnostics.defaultLogLevel),Object.keys(l).length>0&&this.Es.updateConfig(l),null===(o=this.Ms)||void 0===o||o.call(this,t)}}var rC=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"];function sC(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return[...rC,...e].some(t=>-1!==i.indexOf(t.toLowerCase()))}function oC(t,e){var i;if(void 0===e&&(e=[]),!t)return!1;var n=t.userAgent;if(n&&sC(n,e))return!0;try{var r=t.userAgentData;if(null===(i=null==r?void 0:r.brands)||void 0===i?void 0:i.some(t=>sC(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}var aC=36e5;function lC(){var t,e,i;return null!==(i=null===(e=null===(t=null==zh?void 0:zh.performance)||void 0===t?void 0:t.now)||void 0===e?void 0:e.call(t))&&void 0!==i?i:Date.now()}class hC{constructor(){this.Ps=lC(),this.Bs=null,this.Ds=lC(),this.js="",this.Us="",this.Ls="",this.Fs=""}onAfterPageview(){var t=lC();this.Ps=t,this.Bs=t,this.Fs="",Hh&&(this.js=Hh.href||"",this.Us=Hh.pathname||""),Vh&&(this.Ls=Vh.title||"")}peekEngagementSinceLastCaptureMs(){var t,e=lC(),i=null!==(t=this.Bs)&&void 0!==t?t:this.Ds,n=Math.round(e-i);return n<1&&(n=1),n>aC&&(n=aC),n}commitCaptureClock(){this.Bs=lC()}zs(){return this.js+"\0"+this.Us}clearLeaveDedupe(){this.Fs=""}tryCapturePageleave(t,e,i,n){if(function(t){var e=t.capture_pageleave;return!1!==e&&(!0===e||!1!==t.capture_pageview)}(t)){var r=this.zs();if((this.js||this.Us)&&r&&this.Fs!==r){this.Fs=r;var s=lC(),o=Math.round(s-this.Ps);o<1&&(o=1),o>aC&&(o=aC);var a={navigation_type:i,engagement_time_msec:o,[Bw]:this.js,[Dw]:this.Us,[jw]:Math.round(o/1e3),[Uw]:this.Us,[Lw]:this.js},l=this.js?function(t){try{return new URL(t).host}catch(t){return""}}(this.js):"";l&&(a.$host=l),this.Ls&&(a.title=this.Ls),n&&Object.assign(a,n),e(_w,a,{skip_engagement:!0})}}}}var uC=[Iw,Aw,Tw,_w,Rw,Nw,Ew,Pw],cC=new Set([Iw,Aw,Tw]),dC=new Set([_w,Pw,Rw,Nw,Ew]);class vC{constructor(t){this.Ws=!1,this.$s=!1,this.Vs=null,this.Hs=null,this.qs=new hC,this.Es=t}setVtPersonId(t){this.Hs=t}capture(t,e,n){var r,s,o;this.Es.sessionManager.setSessionId();var a=this.Es.getConfig();if(a.opt_out_useragent_filter||!oC($h,null!==(r=a.custom_blocked_useragents)&&void 0!==r?r:[]))if((null==$h?void 0:$h.userAgent)&&function(t){return!(t&&"string"==typeof t&&t.length>500)}($h.userAgent))if((null==n?void 0:n.skip_client_rate_limiting)||uC.includes(t)||this.Es.rateLimiter.shouldAllowEvent())if(!this.Es.getConfig().require_consent||cC.has(t)||(null===(s=this.Es.consentManager)||void 0===s?void 0:s.hasConsent())){var l=this.Es.buildUrl(),h=!0===(null==n?void 0:n.skip_engagement)||dC.has(t),u=i({},e);h||"number"==typeof u.engagement_time_msec||(u=i({},u,{engagement_time_msec:this.qs.peekEngagementSinceLastCaptureMs()}));var c=i({},this.Js(t,u),a.globalAttributes),d=JSON.stringify(c);if(!(v=d)||"string"!=typeof v||v.length<2||v.length>Ru)uu().debug("capture","dropped",t,{reason:"payload_invalid_size",bytes:d.length,limitBytes:Ru,hint:t===Mw?"Trim global / event properties; $elements is already off by default in compact mode.":"Trim event properties; payload exceeded the runaway-guard cap."});else{var v,f=t===Iw?this.Es.userManager.getAnonymousId():null!==(o=this.Es.userManager.getDistinctId())&&void 0!==o?o:this.Es.userManager.getAnonymousId(),p={timestamp:(new Date).toISOString(),event:t,payload:c,distinct_id:f,anonymous_id:this.Es.userManager.getAnonymousId()};this.Es.bufferEvent(t,l,p),uu().debug("capture","enqueued",t,i({distinct_id:f,$current_url:c.$current_url,$session_id:c.$session_id,$debug:c.$debug},t===Mw&&"object"==typeof c&&null!==c?{$event_type:c.$event_type}:{})),this.Hs&&(this.Hs=null),t===Cw?this.qs.onAfterPageview():this.qs.commitCaptureClock()}}else uu().debug("capture","dropped",t,{reason:"require_consent_and_no_consent"});else uu().debug("capture","dropped",t,{reason:"client_rate_limited",hint:"Token bucket (~10/s, burst ~100). $autocapture counts toward the same limit as custom events."});else uu().debug("capture","dropped",t,{reason:"invalid_or_missing_user_agent"});else uu().debug("capture","dropped",t,{reason:"bot"})}captureInternal(t,e){this.capture(t,e,{skip_client_rate_limiting:!0})}captureInitialPageview(){Vh&&("visible"===Vh.visibilityState?this.$s||(this.$s=!0,setTimeout(()=>{Vh&&Hh&&!1!==this.Es.getConfig().capture_pageview&&this.capture(Cw,{navigation_type:"initial_load"})},300),this.Vs&&(Vh.removeEventListener("visibilitychange",this.Vs),this.Vs=null)):this.Vs||(this.Vs=()=>this.captureInitialPageview(),Pu(Vh,"visibilitychange",this.Vs)))}tryCapturePageleave(t,e){this.qs.tryCapturePageleave(this.Es.getConfig(),(t,e,i)=>this.capture(t,e,i),t,e)}resetPageleaveDedupe(){this.qs.clearLeaveDedupe()}Gs(){if(this.Es.getConfig().debug)return!0;try{if(null==Hh?void 0:Hh.search)if("1"===new URLSearchParams(Hh.search).get("vtilt_debug"))return!0}catch(t){}return!1}Js(t,e){var n,r,s=this.Es.getConfig(),o=s.mask_personal_data_properties,a=s.custom_personal_data_properties,l=bx(o,a),h=ju(function(t,e,i){if(!Vh)return{};var n=e?Du([],ax,i||[]):[];return Bu({},ux(ek(Vh.URL,n,hx)))}(0,o,a)),u=this.Es.userManager.getUserProperties(),c=this.Es.userManager.get_initial_props(),d=this.Es.sessionManager.getSessionId(),v=this.Es.sessionManager.getWindowId(),f={};!this.Ws&&Object.keys(c).length>0&&Object.assign(f,c),e.$set_once&&Object.assign(f,e.$set_once);var p=i({},l,h,u,null!==(r=null===(n=this.Es.consentManager)||void 0===n?void 0:n.getConsentProperties())&&void 0!==r?r:{},{$session_id:d,$window_id:v},this.Hs?{$vt:this.Hs}:{},Object.keys(f).length>0?{$set_once:f}:{},e.$set?{$set:e.$set}:{},e);!this.Ws&&Object.keys(c).length>0&&(this.Ws=!0),t===Cw&&Vh&&(p.title=Vh.title),this.Gs()&&(p.$debug=!0);var m=this.Es.sessionManager.consumeSessionStart(),g=this.Es.userManager.consumeFirstVisit();return m&&(p.$session_start=!0),g&&(p.$first_visit=!0),p}}var fC=["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"];function pC(t){return!(!t||"string"!=typeof t)&&fC.includes(t.toLowerCase().trim())}class mC{constructor(t){this.Zs=null,this.Ys=null,this.Es=t}identify(t,e,n){var r;if("number"==typeof t&&(t=String(t),uu().warn("identify","first argument should be a string, not a number")),t)if(pC(t))uu().error("identify",'"'+t+'" appears to be a hardcoded string');else if("COOKIELESS_SENTINEL_VALUE"!==t){var s=JSON.stringify([t,e,n]);if(this.Zs!==s){var o=this.Es.userManager,a=o.getDistinctId(),l=o.getAnonymousId(),h=o.getDeviceId();if(!("identified"===o.getUserState())&&l!==t||t!==a){this.Es.capture(Iw,{distinct_id:t,$set:e||{},$set_once:n||{}});var u={user_state:"identified",distinct_id:t,properties_set:e,properties_set_once:n};if(!h){var c=a||l;u.device_id=c,u.properties_set=i({$had_persisted_distinct_id:!0,$device_id:c},u.properties_set||{})}o.applyUpdate(u),null===(r=this.Es._emitter)||void 0===r||r.emit("user:identified",{distinctId:t})}else(e||n)&&this.setUserProperties(e,n);this.Zs=s}}else uu().error("identify","cannot use sentinel value as distinct_id");else uu().error("identify","unique user id is required")}setUserProperties(t,e){var i,n;if(t||e){var r=this.Es.userManager,s=JSON.stringify([null!==(i=r.getDistinctId())&&void 0!==i?i:r.getAnonymousId(),t,e]);this.Ys!==s&&(r.applyUpdate({properties_set:t,properties_set_once:e}),this.Es.capture(Tw,{$set:t||{},$set_once:e||{}}),null===(n=this.Es._emitter)||void 0===n||n.emit("user:properties_set",{properties:t}),this.Ys=s)}}resetUser(t){var e;this.Es.sessionManager.resetSessionId(),this.Es.userManager.reset(t),this.Zs=null,this.Ys=null,null===(e=this.Es._emitter)||void 0===e||e.emit("user:reset")}alias(t,e){var i;if(t&&!pC(t)){var n=this.Es.userManager,r=null!==(i=null!=e?e:n.getDistinctId())&&void 0!==i?i:n.getAnonymousId();r&&!pC(r)?t!==r?this.Es.capture(Aw,{$original_id:r,$alias_id:t}):this.identify(t):uu().warn("alias","invalid original distinct ID")}else uu().warn("alias","invalid alias")}getUserIdentity(){return this.Es.userManager.getUserIdentity()}getDeviceId(){return this.Es.userManager.getDeviceId()}getUserState(){return this.Es.userManager.getUserState()}getDistinctId(){var t;return null!==(t=this.Es.userManager.getDistinctId())&&void 0!==t?t:this.Es.userManager.getAnonymousId()}getAnonymousId(){return this.Es.userManager.getAnonymousId()}}var gC="_vtilt_consent";class bC{constructor(t){this.Ks={},this.Xs=!1,this.Es=t,this.Qs()}setConsent(t){var e;this.Ks=i({},this.Ks,t),this.Xs=!0,this.eo(),null===(e=this.Es._emitter)||void 0===e||e.emit("consent:updated",{consent:this.Ks})}getConsent(){return i({},this.Ks)}hasConsent(){return this.Xs}setDefaultGranted(){this.Xs||(this.Ks={analytics:!0,marketing:!0,advertising:!0},this.Xs=!0)}getConsentProperties(){var t={};return void 0!==this.Ks.analytics&&(t.$consent_analytics=this.Ks.analytics),void 0!==this.Ks.marketing&&(t.$consent_marketing=this.Ks.marketing),void 0!==this.Ks.advertising&&(t.$consent_advertising=this.Ks.advertising),t}reset(){this.Ks={},this.Xs=!1,this.io()}Qs(){if(void 0!==Vh&&(null==Vh?void 0:Vh.cookie)){var t=gC+"=";for(var e of Vh.cookie.split(";")){var i=e.trim();if(i.startsWith(t)){try{var n=decodeURIComponent(i.slice(15)),r=JSON.parse(n);r&&"object"==typeof r&&(this.Ks=r,this.Xs=!0)}catch(t){}return}}}}eo(){if(void 0!==Vh){var t=encodeURIComponent(JSON.stringify(this.Ks)),e="undefined"!=typeof location&&"https:"===location.protocol?"; Secure":"";Vh.cookie=gC+"="+t+"; Max-Age=31536000; path=/; SameSite=Lax"+e}}io(){void 0!==Vh&&(Vh.cookie=gC+"=; Max-Age=0; path=/")}}class yC{constructor(t){this.no=new Map,this.ro=new Map,this.Es=t}register(t){this.no.set(t.name,t)}createInstances(){var t=this,e=this.Es.getConfig(),i=function(i,n){return t.ro.has(i)||t.so(e,n)?0:void du(()=>{var r=n.FeatureClass.extractConfig(e),s=new n.FeatureClass(t.Es,r);t.ro.set(i,s)})};for(var[n,r]of this.no)i(n,r)}initAll(){this.createInstances();var t=function(t){du(()=>{t.isStarted||t.startIfEnabled()})};for(var[,e]of this.ro)t(e)}notifyAll(t){var e=function(e){e.onConfigUpdate&&du(()=>e.onConfigUpdate(t))};for(var[,i]of this.ro)e(i)}get(t){return this.ro.get(t)}set(t,e){this.ro.set(t,e)}getDescriptors(){return this.no}so(t,e){if(e.disableKey&&!0===t[e.disableKey])return!0;if(e.configKey){var i=t[e.configKey];if(i&&"object"==typeof i&&!1===i.enabled)return!0}return!1}}class wC{constructor(t){this.ds=new FS,this.oo=!1,this.ao=!1,this.Es=t,this.lo(),this.oo||(this.ho=setTimeout(()=>this.forceFlush(),5e3))}push(t){this.oo?this.uo(t):this.ds.enqueue(t)}markConfigReady(){this.ao||(this.ao=!0,this.co())}forceFlush(){this.vo(),this.an(),this.oo=!0}lo(){this.oo=this.ao}co(){this.lo(),this.oo&&(this.vo(),this.an())}an(){var t=this.ds.takeAll();for(var e of t)this.uo(e);t.length>0&&this.Es.requestQueue.flush()}uo(t){if(this.ao){if(this.fo(t.name))return}else this.po(t.event);this.Es.sendRequest(t.url,t.event)}fo(t){var e=this.Es.getConfig();switch(t){case Cw:return!1===e.capture_pageview;case _w:return!1===e.capture_pageleave;case Ew:return!1===e.capture_performance;case Mw:case Ow:return!1===e.autocapture;default:return!1}}po(t){"object"==typeof t.payload&&null!==t.payload&&(t.payload.$config_pending=!0)}vo(){void 0!==this.ho&&(clearTimeout(this.ho),this.ho=void 0)}}var kC="vt";class xC{constructor(t){void 0===t&&(t={}),this.version=hw,this.__loaded=!1,this.mo=!1,this.bo=!1,this.yo=[],this.wo=!1,uu().debug("ctor","start"),this._emitter=new mu,this.configManager=new Vw(t);var e=this.configManager.getConfig();cu(e),this.sessionManager=new Yw(e.storage||"cookie",e.cross_subdomain_cookie),this.userManager=new yx(e.persistence||"localStorage+cookie",e.cross_subdomain_cookie),this.rateLimiter=new iC({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:t=>{this.ko.captureInternal(Pw,{$$client_ingestion_warning_message:t})}}),this.retryQueue=new tC({sendRequest:t=>this.xo(t),sendBeacon:t=>this.So(t)}),this.requestQueue=new QS(t=>this.Co(t),{flush_interval_ms:3e3}),this.consentManager=new bC(this),this.ko=new vC(this),this._o=new mC(this),this.Io=new yC(this),this.Ao=new nC(this),this.To(),this.Ao.onLoad(t=>{this._emitter.emit(yu,{config:t})}),this.Eo(),uu().debug("ctor","boot gate installed")}To(){this.Io.register({name:"HistoryAutocapture",configKey:"capture_pageview",FeatureClass:Ax}),this.Io.register({name:"Autocapture",configKey:"autocapture",FeatureClass:gS}),this.Io.register({name:"WebVitals",configKey:"capture_performance",FeatureClass:_x}),this.Io.register({name:"SessionRecording",configKey:"session_recording",disableKey:"disable_session_recording",remoteConfig:{key:"sessionRecording",map:t=>({enabled:t.enabled,sampleRate:t.sampleRate,minimumDurationMs:t.minimumDurationMs,fullSnapshotIntervalMs:t.fullSnapshotIntervalMs,maskAllInputs:t.maskAllInputs,captureConsole:t.captureConsole,captureCanvas:t.captureCanvas})},FeatureClass:yS}),this.Io.register({name:"Chat",configKey:"chat",disableKey:"disable_chat",remoteConfig:{key:"chat",map:t=>({enabled:t.enabled,position:t.widgetPosition,color:t.widgetColor})},FeatureClass:kS}),this.Io.register({name:"GoogleTagGateway",configKey:"google_tag",disableKey:"disable_google_tag",remoteConfig:{key:"googleTag",map:t=>t},FeatureClass:WS})}Eo(){var t=this,e=function(e){var i=t[e];t[e]=function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];if(t.bo)return i.apply(t,r);t.yo.push([e,...r])}};for(var i of xC.BOOT_GATED_METHODS)e(i)}Mo(){if(!this.bo){for(var t of(this.bo=!0,uu().debug("boot","start"),xC.BOOT_GATED_METHODS))delete this[t];uu().debug("boot","gate removed"),this.__loaded&&!this.wo?(uu().debug("boot","running _runPostBootInit"),this.Oo()):uu().debug("boot","skipping _runPostBootInit","loaded?",this.__loaded,"postBootDone?",this.wo),uu().debug("boot","flush pendingCalls",this.yo.length),this._execute_array(this.yo),this.yo=[]}}init(t,e,i){var n;if(i&&i!==kC){var r=null!==(n=_C[i])&&void 0!==n?n:new xC;return r._init(t,e,i),_C[i]=r,_C[kC][i]=r,r}return this._init(t,e,i)}_init(t,e,n){if(void 0===e&&(e={}),this.__loaded)return uu().warn("init","already initialized; re-initializing is a no-op"),this;this.configManager.updateConfig(i({},e,{token:t||e.token,name:n}));var r=this.configManager.getConfig();return cu(r),this.__loaded=!0,uu().debug("init","start","token present?",!!r.token,"name",null!=n?n:"vt"),this.Io.createInstances(),this.bo||void 0===Vh||"interactive"!==Vh.readyState&&"complete"!==Vh.readyState||(uu().debug("init","self-boot?",Vh.readyState),this.Mo()),this.bo&&!this.wo&&this.Oo(),uu().debug("init","postBootInitDone",this.wo),this}Oo(){if(!this.wo){this.wo=!0,uu().debug("postBoot","start");var t=this.configManager.getConfig();this.sessionManager=new Yw(t.storage||"cookie",t.cross_subdomain_cookie),this.sessionManager.hydrateFromStorage(),uu().debug("postBoot","sessionManager hydrated");var e=t.persistence||"localStorage+cookie";this.userManager.updateStorageMethod(e,t.cross_subdomain_cookie),this.userManager.hydrateFromStorage(),uu().debug("postBoot","userManager hydrated"),t.require_consent||this.consentManager.hasConsent()||this.consentManager.setDefaultGranted(),!0===this.consentManager.getConsent().advertising&&ok(),this._emitter.on("consent:updated",t=>{var e=t.consent;!0===e.advertising?ok():!1===e.advertising&&void 0!==Vh&&(Vh.cookie=ik+"=; Max-Age=0; path=/",Vh.cookie=nk+"=; Max-Age=0; path=/")}),this.Ro(),this.userManager.set_initial_person_info(t.mask_personal_data_properties,t.custom_personal_data_properties),this.No=new wC({sendRequest:(t,e)=>this.sendRequest(t,e),requestQueue:this.requestQueue,getConfig:()=>this.configManager.getConfig()}),this.Io.initAll(),uu().debug("postBoot","features inited"),this.Ao.load(),this.Po(),this.Bo();var i=this.configManager.getConfig();!1!==i.capture_pageview&&this.ko.captureInitialPageview(),this.Io.notifyAll(i),this._emitter.emit(gu,{config:i}),uu().debug("postBoot","done"),uu().info("init","SDK ready")}}startAutocapture(){var t=this.Io.get("Autocapture");if(!t){var e=gS.extractConfig(this.configManager.getConfig());t=new gS(this,e),this.Io.set("Autocapture",t)}t.updateConfig({enabled:!0})}stopAutocapture(){var t=this.Io.get("Autocapture");t&&t.updateConfig({enabled:!1})}isAutocaptureActive(){var t,e;return null!==(e=null===(t=this.Io.get("Autocapture"))||void 0===t?void 0:t.isStarted)&&void 0!==e&&e}getAutocaptureDiagnostics(){var t,e;return null!==(e=null===(t=this.Io.get("Autocapture"))||void 0===t?void 0:t.getDiagnostics())&&void 0!==e?e:null}startSessionRecording(){var t=this.Io.get("SessionRecording");t||(t=new yS(this),this.Io.set("SessionRecording",t)),t.updateConfig({enabled:!0}),t.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(xu)}stopSessionRecording(){var t;null===(t=this.Io.get("SessionRecording"))||void 0===t||t.stop(),this._emitter.emit(Su)}isRecordingActive(){var t;return"active"===(null===(t=this.Io.get("SessionRecording"))||void 0===t?void 0:t.status)}getSessionRecordingId(){var t;return(null===(t=this.Io.get("SessionRecording"))||void 0===t?void 0:t.sessionId)||null}openChat(){var t=this.Io.get("Chat");t?t.open():uu().warn("chat","openChat: feature not available")}closeChat(){var t=this.Io.get("Chat");t?t.close():uu().warn("chat","closeChat: feature not available")}toggleChat(){var t=this.Io.get("Chat");t?t.toggle():uu().warn("chat","toggleChat: feature not available")}showChat(){var t=this.Io.get("Chat");t?t.show():uu().warn("chat","showChat: feature not available")}hideChat(){var t=this.Io.get("Chat");t?t.hide():uu().warn("chat","hideChat: feature not available")}sendChatMessage(t,e){var i=this.Io.get("Chat");return i?i.sendMessage(t,e):(uu().warn("chat","sendChatMessage: feature not available"),Promise.resolve())}gtag(){for(var t=this.Io.get("GoogleTagGateway"),e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];t?t.gtag(...i):this.yo.push(["gtag",...i])}setGoogleUserData(t){var e=this.Io.get("GoogleTagGateway");return e?e.setUserData(t):Promise.resolve()}get featureManager(){return this.Io}on(t,e){return this._emitter.on(t,e)}once(t,e){return this._emitter.once(t,e)}off(t){this._emitter.off(t)}_is_bot(){var t,e=this.getConfig();return!e.opt_out_useragent_filter&&oC($h,null!==(t=e.custom_blocked_useragents)&&void 0!==t?t:[])}capture(t,e,i){this.ko.capture(t,e,i),this._emitter.emit(ku,{event:t,payload:e})}tryCapturePageleave(t){var e,i=null===(e=this.Io.get("Autocapture"))||void 0===e?void 0:e.getMaxScrollDepthPctForPageleave(),n=null!=i?{[Ww]:i}:void 0;this.ko.tryCapturePageleave(t,n)}identify(t,e,i){this._o.identify(t,e,i)}setUserProperties(t,e){this._o.setUserProperties(t,e)}resetUser(t){this._o.resetUser(t)}alias(t,e){this._o.alias(t,e)}setConsent(t){this.consentManager.setConsent(t)}getConsent(){return this.consentManager.getConsent()}getUserIdentity(){return this._o.getUserIdentity()}getDeviceId(){return this._o.getDeviceId()}getUserState(){return this._o.getUserState()}getConfig(){return this.configManager.getConfig()}getRemoteConfig(){return this.Ao.config}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this._o.getDistinctId()}getAnonymousId(){return this._o.getAnonymousId()}toString(){var t,e=null!==(t=this.configManager.getConfig().name)&&void 0!==t?t:kC;return e!==kC&&(e="vt."+e),e}updateConfig(t){var e,i=this.configManager.getConfig();this.configManager.updateConfig(t);var n=this.configManager.getConfig();!i.__remote_config_loaded&&n.__remote_config_loaded&&(null===(e=this.No)||void 0===e||e.markConfigReady()),this.Io.notifyAll(n),this._emitter.emit(bu,{config:n})}buildUrl(){return this.buildEndpointUrl("/api/e")}buildEndpointUrl(t){return fu(this.configManager.getConfig(),t)}sendRequest(t,e){this.Do()&&this.requestQueue.enqueue({url:t,event:e})}bufferEvent(t,e,i){t!==Rw&&t!==Nw?this.No.push({name:t,url:e,event:i}):this.sendRequest(e,i)}Do(){return!!this.configManager.getConfig().token||(this.mo||(uu().warn("config","token is required for tracking"),this.mo=!0),!1)}Co(t){"sendBeacon"!==t.transport?this.retryQueue.retriableRequest(t):this.So(t)}xo(t){return new Promise(e=>{var{url:i,events:n}=t,r=this.configManager.getConfig(),s=1===n.length?n[0]:{events:n},o=r.disable_compression?HS.None:HS.GZipJS;XS({url:i,data:s,method:"POST",transport:"XHR",compression:o,projectToken:r.token,callback:t=>e({statusCode:t.statusCode})})})}So(t){var{url:e,events:i}=t,n=this.configManager.getConfig(),r=1===i.length?i[0]:{events:i},s=n.disable_compression?HS.None:HS.GZipJS;XS({url:e,data:r,method:"POST",transport:"sendBeacon",compression:s,projectToken:n.token})}jo(t){this.sendRequest(t.url,t.event)}Po(){if(zh){var t=()=>{this.No.forceFlush(),this.requestQueue.unload(),this.retryQueue.unload()};Pu(zh,"beforeunload",t),Pu(zh,"pagehide",()=>{this.ko.tryCapturePageleave("pagehide"),t()}),Vh&&Pu(Vh,"visibilitychange",()=>{Vh&&("hidden"===Vh.visibilityState?this.ko.tryCapturePageleave("visibility_hidden"):"visible"===Vh.visibilityState&&this.ko.resetPageleaveDedupe())})}}Bo(){this.requestQueue.enable()}Ro(){du(()=>{var t,e;if(void 0!==Hh&&Hh.search){var i=new URL(Hh.href),n=i.searchParams.get("vt"),r=i.searchParams.get("vtd");if((null==n?void 0:n.trim())&&(this.ko.setVtPersonId(n.trim()),i.searchParams.delete("vt")),(null==r?void 0:r.trim())&&(this.Uo(r.trim()),i.searchParams.delete("vtd")),(null==n?void 0:n.trim())||(null==r?void 0:r.trim())){var s=i.pathname+(i.search||"")+i.hash;null===(e=null===(t=null==zh?void 0:zh.history)||void 0===t?void 0:t.replaceState)||void 0===e||e.call(t,{},"",s)}}})}Uo(t){this.vtdOverlay||(this.vtdOverlay=new VS(this),this.vtdOverlay.setDestinationUrl(t))}_execute_array(t){tu(t)&&t.forEach(t=>{if(t&&tu(t)&&t.length>0){var e=t[0],i=t.slice(1);"function"==typeof this[e]&&du(()=>this[e](...i))}})}_dom_loaded(){this.Bo()}}xC.BOOT_GATED_METHODS=["capture","identify","setUserProperties","resetUser","alias","setConsent","startAutocapture","stopAutocapture","startSessionRecording","stopSessionRecording","openChat","closeChat","toggleChat","showChat","hideChat","sendChatMessage"];var SC,CC,_C={};SC=_C[kC]=new xC,(CC=Gh.vt)&&Nu(CC._i,function(t){if(t&&tu(t)){var e=SC.init(t[0],t[1],t[2]),i=CC[t[2]||"vt"]||CC;e&&e._execute_array(i)}}),Gh.vt=SC,function(){function t(){if(!t.done){t.done=!0,uu().debug("dom","handler fired");var e=Object.keys(_C);uu().debug("boot","instance count",e.length),Nu(_C,(t,e)=>{uu().debug("boot","instance",e),t.Mo(),t._dom_loaded()})}}if(Vh&&"function"==typeof Vh.addEventListener)return uu().debug("dom","readyState",Vh.readyState),void("complete"===Vh.readyState||"interactive"===Vh.readyState?(uu().debug("dom","running handler sync"),t()):(uu().debug("dom","registered DOMContentLoaded listener"),Pu(Vh,"DOMContentLoaded",t,{capture:!1})));zh&&uu().error("dom","browser doesn't support document.addEventListener")}()}();
|
|
2
|
+
//# sourceMappingURL=array.full.chat.js.map
|