@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.
Files changed (109) hide show
  1. package/dist/all-external-dependencies.js.map +1 -1
  2. package/dist/array.chat.js +2 -0
  3. package/dist/array.chat.js.map +1 -0
  4. package/dist/array.chat.no-external.js +2 -0
  5. package/dist/array.chat.no-external.js.map +1 -0
  6. package/dist/array.full.chat.js +2 -0
  7. package/dist/array.full.chat.js.map +1 -0
  8. package/dist/array.full.chat.no-external.js +2 -0
  9. package/dist/array.full.chat.no-external.js.map +1 -0
  10. package/dist/array.full.js +1 -1
  11. package/dist/array.full.js.map +1 -1
  12. package/dist/array.full.no-external.js +2 -0
  13. package/dist/array.full.no-external.js.map +1 -0
  14. package/dist/array.js +1 -1
  15. package/dist/array.js.map +1 -1
  16. package/dist/array.no-external.js +1 -1
  17. package/dist/array.no-external.js.map +1 -1
  18. package/dist/chat.js +1 -1
  19. package/dist/chat.js.map +1 -1
  20. package/dist/entrypoints/all-external-dependencies.d.ts +10 -3
  21. package/dist/entrypoints/array.chat.d.ts +10 -0
  22. package/dist/entrypoints/array.chat.no-external.d.ts +6 -0
  23. package/dist/entrypoints/array.full.chat.d.ts +13 -0
  24. package/dist/entrypoints/array.full.chat.no-external.d.ts +7 -0
  25. package/dist/entrypoints/array.full.d.ts +5 -9
  26. package/dist/entrypoints/array.full.no-external.d.ts +12 -0
  27. package/dist/entrypoints/module.chat.es.d.ts +7 -0
  28. package/dist/entrypoints/module.full.chat.es.d.ts +12 -0
  29. package/dist/entrypoints/module.full.es.d.ts +12 -0
  30. package/dist/entrypoints/module.no-external.es.d.ts +1 -0
  31. package/dist/extensions/chat/bubble-drag.d.ts +20 -5
  32. package/dist/extensions/chat/chat-wrapper.d.ts +8 -2
  33. package/dist/extensions/chat/chat.d.ts +21 -221
  34. package/dist/extensions/chat/controller/__tests__/fakes/ably-realtime-fake.d.ts +84 -0
  35. package/dist/extensions/chat/controller/ably-client.d.ts +160 -0
  36. package/dist/extensions/chat/controller/ably-handlers.d.ts +95 -0
  37. package/dist/extensions/chat/controller/ably-token.d.ts +67 -0
  38. package/dist/extensions/chat/controller/chat-controller.d.ts +194 -0
  39. package/dist/extensions/chat/controller/message-delivery-status.d.ts +6 -0
  40. package/dist/extensions/chat/controller/message-order.d.ts +12 -0
  41. package/dist/extensions/chat/controller/message-stream.d.ts +49 -0
  42. package/dist/extensions/chat/lib/bubble-offset.d.ts +18 -0
  43. package/dist/extensions/chat/lib/merge-chat-config.d.ts +3 -0
  44. package/dist/extensions/chat/normalize-send-content.d.ts +2 -0
  45. package/dist/extensions/chat/outbox/message-delivery.d.ts +17 -0
  46. package/dist/extensions/chat/outbox/message-outbox.d.ts +57 -0
  47. package/dist/extensions/chat/store/chat-store.d.ts +122 -0
  48. package/dist/extensions/chat/types.d.ts +1 -19
  49. package/dist/extensions/chat/ui/ChannelItem.d.ts +12 -0
  50. package/dist/extensions/chat/ui/ChannelListView.d.ts +14 -0
  51. package/dist/extensions/chat/ui/ChatBubble.d.ts +14 -0
  52. package/dist/extensions/chat/ui/ChatHeader.d.ts +13 -0
  53. package/dist/extensions/chat/ui/ChatPanel.d.ts +14 -0
  54. package/dist/extensions/chat/ui/ChatRoot.d.ts +31 -0
  55. package/dist/extensions/chat/ui/ClosedBanner.d.ts +7 -0
  56. package/dist/extensions/chat/ui/ConnectionBanner.d.ts +32 -0
  57. package/dist/extensions/chat/ui/ConversationView.d.ts +14 -0
  58. package/dist/extensions/chat/ui/MessageBubble.d.ts +25 -0
  59. package/dist/extensions/chat/ui/MessageInput.d.ts +14 -0
  60. package/dist/extensions/chat/ui/MessageList.d.ts +19 -0
  61. package/dist/extensions/chat/ui/NewMessagesPill.d.ts +13 -0
  62. package/dist/extensions/chat/ui/Skeletons.d.ts +14 -0
  63. package/dist/extensions/chat/ui/TypingBubble.d.ts +23 -0
  64. package/dist/extensions/chat/ui/TypingIndicator.d.ts +12 -0
  65. package/dist/extensions/chat/ui/WidgetSlot.d.ts +20 -0
  66. package/dist/extensions/chat/ui/hooks/use-auto-mark-read.d.ts +18 -0
  67. package/dist/extensions/chat/ui/hooks/use-scroll-preservation.d.ts +33 -0
  68. package/dist/extensions/chat/ui/icons.d.ts +18 -0
  69. package/dist/extensions/chat/ui/message-render.d.ts +18 -0
  70. package/dist/extensions/chat/ui/shadow-styles.d.ts +13 -0
  71. package/dist/extensions/chat/ui/utils/mobile-body-scroll-lock.d.ts +14 -0
  72. package/dist/extensions/chat/widget-registry.d.ts +21 -5
  73. package/dist/extensions/chat/widgets/collect-email.d.ts +4 -2
  74. package/dist/extensions/chat/widgets/escalate-to-human.d.ts +2 -1
  75. package/dist/external-scripts-loader.js +1 -1
  76. package/dist/external-scripts-loader.js.map +1 -1
  77. package/dist/feature.d.ts +1 -0
  78. package/dist/lib/merge-vtilt-config.d.ts +9 -0
  79. package/dist/main.js +1 -1
  80. package/dist/main.js.map +1 -1
  81. package/dist/module.chat.d.ts +1788 -0
  82. package/dist/module.chat.js +2 -0
  83. package/dist/module.chat.js.map +1 -0
  84. package/dist/module.d.ts +48 -3
  85. package/dist/module.full.chat.d.ts +1792 -0
  86. package/dist/module.full.chat.js +2 -0
  87. package/dist/module.full.chat.js.map +1 -0
  88. package/dist/module.full.d.ts +1793 -0
  89. package/dist/module.full.js +2 -0
  90. package/dist/module.full.js.map +1 -0
  91. package/dist/module.js +1 -1
  92. package/dist/module.js.map +1 -1
  93. package/dist/module.no-external.d.ts +48 -3
  94. package/dist/module.no-external.js +1 -1
  95. package/dist/module.no-external.js.map +1 -1
  96. package/dist/recorder.js.map +1 -1
  97. package/dist/snippet-stub-methods.d.ts +14 -0
  98. package/dist/utils/globals.d.ts +53 -27
  99. package/dist/utils/index.d.ts +8 -0
  100. package/dist/vtilt.d.ts +6 -1
  101. package/dist/web-vitals.js.map +1 -1
  102. package/package.json +4 -1
  103. package/dist/extensions/chat/chat-styles.d.ts +0 -27
  104. package/dist/extensions/chat/message-content-styles.d.ts +0 -1
  105. package/dist/extensions/chat/message-html.d.ts +0 -6
  106. package/dist/extensions/chat/message-markdown.d.ts +0 -8
  107. package/dist/extensions/ga4-proxy.d.ts +0 -59
  108. package/dist/utils/type-utils.d.ts +0 -4
  109. package/dist/web-vitals.d.ts +0 -81
@@ -0,0 +1,2 @@
1
+ !function(){"use strict";function e(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function t(t){return function(){var n=this,r=arguments;return new Promise(function(i,s){var o=t.apply(n,r);function a(t){e(o,i,s,a,l,"next",t)}function l(t){e(o,i,s,a,l,"throw",t)}a(void 0)})}}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(null,arguments)}function r(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}var i,s=["inputs"],o=["inputId"],a=["inputs"],l=["inputId"],c=["type"],u=Object.defineProperty,d=(e,t,n)=>((e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),h=Object.defineProperty,p=(e,t,n)=>((e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),f=(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(f||{}),v={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},g={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},m={};function _(e){if(m[e])return m[e];var t=globalThis[e],n=t.prototype,r=e in v?v[e]:void 0,i=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),s=e in g?g[e]:void 0,o=Boolean(s&&s.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(i&&o&&!globalThis.Zone)return m[e]=t.prototype,t.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var l=a.contentWindow;if(!l)return t.prototype;var c=l[e].prototype;return document.body.removeChild(a),c?m[e]=c:n}catch(e){return n}}var y={};function b(e,t,n){var r,i=e+"."+String(n);if(y[i])return y[i].call(t);var s=_(e),o=null==(r=Object.getOwnPropertyDescriptor(s,n))?void 0:r.get;return o?(y[i]=o,o.call(t)):t[n]}var w={};function C(e,t,n){var r=e+"."+String(n);if(w[r])return w[r].bind(t);var i=_(e)[n];return"function"!=typeof i?t[n]:(w[r]=i,i.bind(t))}var S={ownerDocument:function(e){return b("Node",e,"ownerDocument")},childNodes:function(e){return b("Node",e,"childNodes")},parentNode:function(e){return b("Node",e,"parentNode")},parentElement:function(e){return b("Node",e,"parentElement")},textContent:function(e){return b("Node",e,"textContent")},contains:function(e,t){return C("Node",e,"contains")(t)},getRootNode:function(e){return C("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?b("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?b("Element",e,"shadowRoot"):null},querySelector:function(e,t){return b("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return b("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return _("MutationObserver").constructor},patch:function(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch(e){return()=>{}}}};function k(e){return e.nodeType===e.ELEMENT_NODE}function x(e){var t=e&&"host"in e&&"mode"in e&&S.host(e)||null;return Boolean(t&&"shadowRoot"in t&&S.shadowRoot(t)===e)}function I(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function T(e){try{var t=e.rules||e.cssRules;if(!t)return null;var n=e.href;!n&&e.ownerNode&&(n=e.ownerNode.baseURI);var r=Array.from(t,e=>E(e,n)).join("");return(i=r).includes(" background-clip: text;")&&!i.includes(" -webkit-background-clip: text;")&&(i=i.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),i}catch(e){return null}var i}function E(e,t){if(function(e){return"styleSheet"in e}(e)){var n;try{n=T(e.styleSheet)||function(e){var{cssText:t}=e;if(t.split('"').length<3)return t;var n=["@import","url("+JSON.stringify(e.href)+")"];return""===e.layerName?n.push("layer"):e.layerName&&n.push("layer("+e.layerName+")"),e.supportsText&&n.push("supports("+e.supportsText+")"),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(t){n=e.cssText}return e.styleSheet.href?F(n,e.styleSheet.href):n}var r,i=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(r=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,i=i.replace(r,"$1\\$2")),t?F(i,t):i}class A{constructor(){p(this,"idNodeMap",new Map),p(this,"nodeMetaMap",new WeakMap)}getId(e){var t;if(!e)return-1;var n=null==(t=this.getMeta(e))?void 0:t.id;return null!=n?n:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){var t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function O(e){var{element:t,maskInputOptions:n,tagName:r,type:i,value:s,maskInputFn:o}=e,a=s||"",l=i&&M(i);return(n[r.toLowerCase()]||l&&n[l])&&(a=o?o(a,t):"*".repeat(a.length)),a}function M(e){return e.toLowerCase()}var R="__rrweb_original__";function P(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?M(t):null}function L(e,t){var n,r;try{r=new URL(e,null!=t?t:window.location.href)}catch(e){return null}var i=r.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(n=null==i?void 0:i[1])&&void 0!==n?n:null}var N=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,D=/^(?:[a-z+]+:)?\/\//i,U=/^www\..*/i,B=/^(data:)([^,]*),(.*)/i;function F(e,t){return(e||"").replace(N,(e,n,r,i,s,o)=>{var a,l=r||s||o,c=n||i||"";if(!l)return e;if(D.test(l)||U.test(l))return"url("+c+l+c+")";if(B.test(l))return"url("+c+l+c+")";if("/"===l[0])return"url("+c+(((a=t).indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)+c+")";var u=t.split("/"),d=l.split("/");for(var h of(u.pop(),d))"."!==h&&(".."===h?u.pop():u.push(h));return"url("+c+u.join("/")+c+")"})}function j(e,t){return void 0===t&&(t=!1),t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function W(e,t){return function(e,t,n){void 0===n&&(n=!1);var r=Array.from(t.childNodes),i=[],s=0;if(r.length>1&&e&&"string"==typeof e)for(var o=j(e,n),a=o.length/e.length,l=1;l<r.length;l++)if(r[l].textContent&&"string"==typeof r[l].textContent){for(var c=j(r[l].textContent,n),u=3;u<c.length&&(c[u].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,u),1));u++);for(;u<c.length;u++){var d=c.substring(0,u),h=o.split(d),p=-1;if(2===h.length)p=h[0].length;else if(h.length>2&&""===h[0]&&""!==r[l-1].textContent)p=o.indexOf(d,1);else if(1===h.length){if(d=d.substring(0,d.length-1),(h=o.split(d)).length<=1)return i.push(e),i;u=101}else u===c.length-1&&(p=o.indexOf(d));if(h.length>=2&&u>100){var f=r[l-1].textContent;if(f&&"string"==typeof f){var v=j(f).length;p=o.indexOf(d,v)}-1===p&&(p=h[0].length)}if(-1!==p){for(var g=Math.floor(p/a);g>0&&g<e.length;){if((s+=1)>50*r.length)return i.push(e),i;var m=j(e.substring(0,g),n);if(m.length===p){i.push(e.substring(0,g)),e=e.substring(g),o=o.substring(p);break}m.length<p?g+=Math.max(1,Math.floor((p-m.length)/a)):g-=Math.max(1,Math.floor((m.length-p)*a))}break}}}return i.push(e),i}(e,t).join("/* rr_split */")}var H,z,V=1,q=new RegExp("[^a-z0-9-_:]");function $(){return V++}var G=/^[^ \t\n\r\u000c]+/,J=/^[, \t\n\r\u000c]+/;var K=new WeakMap;function Y(e,t){return t&&""!==t.trim()?X(e,t):t}function Z(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function X(e,t){var n=K.get(e);if(n||(n=e.createElement("a"),K.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function Q(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]||"background"===n&&["table","td","th"].includes(t)?Y(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,i=e.exec(t.substring(n));return i?(r=i[0],n+=r.length,r):""}for(var i=[];r(J),!(n>=t.length);){var s=r(G);if(","===s.slice(-1))s=Y(e,s.substring(0,s.length-1)),i.push(s);else{var o="";s=Y(e,s);for(var a=!1;;){var l=t.charAt(n);if(""===l){i.push((s+o).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,i.push((s+o).trim());break}"("===l&&(a=!0)}o+=l,n+=1}}}return i.join(", ")}(e,r):"style"===n?F(r,X(e)):"object"===t&&"data"===n?Y(e,r):r:r}function ee(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function te(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&te(S.parentNode(e),t,n);for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}return!!n&&te(S.parentNode(e),t,n)}function ne(e,t,n,r){var i;if(k(e)){if(i=e,!S.childNodes(i).length)return!1}else{if(null===S.parentElement(e))return!1;i=S.parentElement(e)}try{if("string"==typeof t){if(r){if(i.closest("."+t))return!0}else if(i.classList.contains(t))return!0}else if(te(i,t,r))return!0;if(n)if(r){if(i.closest(n))return!0}else if(i.matches(n))return!0}catch(e){}return!1}function re(e,t){var{doc:n,mirror:r,blockClass:i,blockSelector:s,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:u,dataURLOptions:d={},inlineImages:h,recordCanvas:p,keepIframeSrcFn:v,newlyAddedElement:g=!1,cssCaptured:m=!1}=t,_=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:f.Document,childNodes:[],compatMode:e.compatMode}:{type:f.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:f.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:_};case e.ELEMENT_NODE:return function(e,t){for(var n,{doc:r,blockClass:i,blockSelector:s,inlineStylesheet:o,maskInputOptions:a={},maskInputFn:l,dataURLOptions:c={},inlineImages:u,recordCanvas:d,keepIframeSrcFn:h,newlyAddedElement:p=!1,rootId:v}=t,g=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,i,s),m=function(e){if(e instanceof HTMLFormElement)return"form";var t=M(e.tagName);return q.test(t)?"div":t}(e),_={},y=e.attributes.length,b=0;b<y;b++){var w=e.attributes[b];ee(m,w.name,w.value)||(_[w.name]=Q(r,m,M(w.name),w.value))}if("link"===m&&o){var C=Array.from(r.styleSheets).find(t=>t.href===e.href),S=null;C&&(S=T(C)),S&&(delete _.rel,delete _.href,_._cssText=S)}if("style"===m&&e.sheet){var k=T(e.sheet);k&&(e.childNodes.length>1&&(k=W(k,e)),_._cssText=k)}if(["input","textarea","select"].includes(m)){var x=e.value,I=e.checked;"radio"!==_.type&&"checkbox"!==_.type&&"submit"!==_.type&&"button"!==_.type&&x?_.value=O({element:e,type:P(e),tagName:m,value:x,maskInputOptions:a,maskInputFn:l}):I&&(_.checked=I)}"option"===m&&(e.selected&&!a.select?_.selected=!0:delete _.selected);"dialog"===m&&e.open&&(_.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===m&&d)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var i=t.getImageData,s=R in i?i[R]:i;if(new Uint32Array(s.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(_.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){var E=e.toDataURL(c.type,c.quality),A=r.createElement("canvas");A.width=e.width,A.height=e.height,E!==A.toDataURL(c.type,c.quality)&&(_.rr_dataURL=E)}if("img"===m&&u){H||(H=r.createElement("canvas"),z=H.getContext("2d"));var L=e,N=L.currentSrc||L.getAttribute("src")||"<unknown-src>",D=L.crossOrigin,U=()=>{L.removeEventListener("load",U);try{H.width=L.naturalWidth,H.height=L.naturalHeight,z.drawImage(L,0,0),_.rr_dataURL=H.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==L.crossOrigin)return L.crossOrigin="anonymous",void(L.complete&&0!==L.naturalWidth?U():L.addEventListener("load",U));console.warn("Cannot inline img src="+N+"! Error: "+e)}"anonymous"===L.crossOrigin&&(D?_.crossOrigin=D:L.removeAttribute("crossorigin"))};L.complete&&0!==L.naturalWidth?U():L.addEventListener("load",U)}if(["audio","video"].includes(m)){var B=_;B.rr_mediaState=e.paused?"paused":"played",B.rr_mediaCurrentTime=e.currentTime,B.rr_mediaPlaybackRate=e.playbackRate,B.rr_mediaMuted=e.muted,B.rr_mediaLoop=e.loop,B.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(_.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(_.rr_scrollTop=e.scrollTop));if(g){var{width:F,height:j}=e.getBoundingClientRect();_={class:_.class,rr_width:F+"px",rr_height:j+"px"}}"iframe"!==m||h(_.src)||(e.contentDocument||(_.rr_src=_.src),delete _.src);try{customElements.get(m)&&(n=!0)}catch(e){}return{type:f.Element,tagName:m,attributes:_,childNodes:[],isSVG:Z(e)||void 0,needBlock:g,rootId:v,isCustom:n}}(e,{doc:n,blockClass:i,blockSelector:s,inlineStylesheet:a,maskInputOptions:l,maskInputFn:u,dataURLOptions:d,inlineImages:h,recordCanvas:p,keepIframeSrcFn:v,newlyAddedElement:g,rootId:_});case e.TEXT_NODE:return function(e,t){var{needsMask:n,maskTextFn:r,rootId:i,cssCaptured:s}=t,o=S.parentNode(e),a=o&&o.tagName,l="",c="STYLE"===a||void 0,u="SCRIPT"===a||void 0;u?l="SCRIPT_PLACEHOLDER":s||(l=S.textContent(e),c&&l&&(l=F(l,X(t.doc))));!c&&!u&&l&&n&&(l=r?r(l,S.parentElement(e)):l.replace(/[\S]/g,"*"));return{type:f.Text,textContent:l||"",rootId:i}}(e,{doc:n,needsMask:o,maskTextFn:c,rootId:_,cssCaptured:m});case e.CDATA_SECTION_NODE:return{type:f.CDATA,textContent:"",rootId:_};case e.COMMENT_NODE:return{type:f.Comment,textContent:S.textContent(e)||"",rootId:_};default:return!1}}function ie(e){return null==e?"":e.toLowerCase()}function se(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:e||{}}function oe(e,t){var{doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,slimDOMOptions:p,dataURLOptions:v={},inlineImages:g=!1,recordCanvas:m=!1,onSerialize:_,onIframeLoad:y,iframeLoadTimeout:b=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:C=5e3,keepIframeSrcFn:T=()=>!1,newlyAddedElement:E=!1,cssCaptured:A=!1}=t,{needsMask:O}=t,{preserveWhiteSpace:M=!0}=t;O||(O=ne(e,o,a,void 0===O));var R,P=re(e,{doc:n,mirror:r,blockClass:i,blockSelector:s,needsMask:O,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,dataURLOptions:v,inlineImages:g,recordCanvas:m,keepIframeSrcFn:T,newlyAddedElement:E,cssCaptured:A});if(!P)return console.warn(e,"not serialized"),null;R=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===f.Comment)return!0;if(e.type===f.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===L(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(ie(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===ie(e.attributes.name)||"icon"===ie(e.attributes.rel)||"apple-touch-icon"===ie(e.attributes.rel)||"shortcut icon"===ie(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&ie(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(ie(e.attributes.property).match(/^(og|twitter|fb):/)||ie(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===ie(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===ie(e.attributes.name)||"googlebot"===ie(e.attributes.name)||"bingbot"===ie(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===ie(e.attributes.name)||"generator"===ie(e.attributes.name)||"framework"===ie(e.attributes.name)||"publisher"===ie(e.attributes.name)||"progid"===ie(e.attributes.name)||ie(e.attributes.property).match(/^article:/)||ie(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===ie(e.attributes.name)||"yandex-verification"===ie(e.attributes.name)||"csrf-token"===ie(e.attributes.name)||"p:domain_verify"===ie(e.attributes.name)||"verify-v1"===ie(e.attributes.name)||"verification"===ie(e.attributes.name)||"shopify-checkout-api-token"===ie(e.attributes.name)))return!0}}return!1}(P,p)||!M&&P.type===f.Text&&!P.textContent.replace(/^\s+|\s+$/gm,"").length?-2:$();var N=Object.assign(P,{id:R});if(r.add(e,N),-2===R)return null;_&&_(e);var D=!l;if(N.type===f.Element){D=D&&!N.needBlock,delete N.needBlock;var U=S.shadowRoot(e);U&&I(U)&&(N.isShadowHost=!0)}if((N.type===f.Document||N.type===f.Element)&&D){p.headWhitespace&&N.type===f.Element&&"head"===N.tagName&&(M=!1);var B={doc:n,mirror:r,blockClass:i,blockSelector:s,needsMask:O,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:p,dataURLOptions:v,inlineImages:g,recordCanvas:m,preserveWhiteSpace:M,onSerialize:_,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:C,keepIframeSrcFn:T,cssCaptured:!1};if(N.type===f.Element&&"textarea"===N.tagName&&void 0!==N.attributes.value);else for(var F of(N.type===f.Element&&void 0!==N.attributes._cssText&&"string"==typeof N.attributes._cssText&&(B.cssCaptured=!0),Array.from(S.childNodes(e)))){var j=oe(F,B);j&&N.childNodes.push(j)}var W=null;if(k(e)&&(W=S.shadowRoot(e)))for(var H of Array.from(S.childNodes(W))){var z=oe(H,B);z&&(I(W)&&(z.isShadow=!0),N.childNodes.push(z))}}var V=S.parentNode(e);return V&&x(V)&&I(V)&&(N.isShadow=!0),N.type===f.Element&&"iframe"===N.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var i,s=!1;try{i=r.document.readyState}catch(e){return}if("complete"===i){var o="about:blank";if(r.location.href!==o||e.src===o||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(()=>{s||(t(),s=!0)},n);e.addEventListener("load",()=>{clearTimeout(a),s=!0,t()})}}}(e,()=>{var t=e.contentDocument;if(t&&y){var n=oe(t,{doc:t,mirror:r,blockClass:i,blockSelector:s,needsMask:O,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:p,dataURLOptions:v,inlineImages:g,recordCanvas:m,preserveWhiteSpace:M,onSerialize:_,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:C,keepIframeSrcFn:T});n&&y(e,n)}},b),N.type===f.Element&&"link"===N.tagName&&"string"==typeof N.attributes.rel&&("stylesheet"===N.attributes.rel||"preload"===N.attributes.rel&&"string"==typeof N.attributes.href&&"css"===L(N.attributes.href))&&function(e,t,n){var r,i=!1;try{r=e.sheet}catch(e){return}if(!r){var s=setTimeout(()=>{i||(t(),i=!0)},n);e.addEventListener("load",()=>{clearTimeout(s),i=!0,t()})}}(e,()=>{if(w){var t=oe(e,{doc:n,mirror:r,blockClass:i,blockSelector:s,needsMask:O,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:p,dataURLOptions:v,inlineImages:g,recordCanvas:m,preserveWhiteSpace:M,onSerialize:_,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:C,keepIframeSrcFn:T});t&&w(e,t)}},C),N}function ae(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function le(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var ce={exports:{}},ue=String,de=function(){return{isColorSupported:!1,reset:ue,bold:ue,dim:ue,italic:ue,underline:ue,inverse:ue,hidden:ue,strikethrough:ue,black:ue,red:ue,green:ue,yellow:ue,blue:ue,magenta:ue,cyan:ue,white:ue,gray:ue,bgBlack:ue,bgRed:ue,bgGreen:ue,bgYellow:ue,bgBlue:ue,bgMagenta:ue,bgCyan:ue,bgWhite:ue}};ce.exports=de(),ce.exports.createColors=de;var he=ce.exports,pe=le(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),fe=he,ve=pe,ge=class e extends Error{constructor(t,n,r,i,s,o){super(t),this.name="CssSyntaxError",this.reason=t,s&&(this.file=s),i&&(this.source=i),o&&(this.plugin=o),void 0!==n&&void 0!==r&&("number"==typeof n?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}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(e){if(!this.source)return"";var t=this.source;null==e&&(e=fe.isColorSupported),ve&&e&&(t=ve(t));var n,r,i=t.split(/\r?\n/),s=Math.max(this.line-3,0),o=Math.min(this.line+2,i.length),a=String(o).length;if(e){var{bold:l,gray:c,red:u}=fe.createColors(!0);n=e=>l(u(e)),r=e=>c(e)}else n=r=e=>e;return i.slice(s,o).map((e,t)=>{var i=s+1+t,o=" "+(" "+i).slice(-a)+" | ";if(i===this.line){var l=r(o.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return n(">")+r(o)+e+"\n "+l+n("^")}return" "+r(o)+e}).join("\n")}toString(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},me=ge;ge.default=ge;var _e={};_e.isClean=Symbol("isClean"),_e.my=Symbol("my");var ye={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var be=class{constructor(e){this.builder=e}atrule(e,t){var n="@"+e.name,r=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?n+=e.raws.afterName:r&&(n+=" "),e.nodes)this.block(e,n+r);else{var i=(e.raws.between||"")+(t?";":"");this.builder(n+r+i,e)}}beforeAfter(e,t){var n;n="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");for(var r=e.parent,i=0;r&&"root"!==r.type;)i+=1,r=r.parent;if(n.includes("\n")){var s=this.raw(e,null,"indent");if(s.length)for(var o=0;o<i;o++)n+=s}return n}block(e,t){var n,r=this.raw(e,"between","beforeOpen");this.builder(t+r+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),this.builder("}",e,"end")}body(e){for(var t=e.nodes.length-1;t>0&&"comment"===e.nodes[t].type;)t-=1;for(var n=this.raw(e,"semicolon"),r=0;r<e.nodes.length;r++){var i=e.nodes[r],s=this.raw(i,"before");s&&this.builder(s),this.stringify(i,t!==r||n)}}comment(e){var t=this.raw(e,"left","commentLeft"),n=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+n+"*/",e)}decl(e,t){var n=this.raw(e,"between","colon"),r=e.prop+n+this.rawValue(e,"value");e.important&&(r+=e.raws.important||" !important"),t&&(r+=";"),this.builder(r,e)}document(e){this.body(e)}raw(e,t,n){var r;if(n||(n=t),t&&void 0!==(r=e.raws[t]))return r;var i=e.parent;if("before"===n){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return ye[n];var s=e.root();if(s.rawCache||(s.rawCache={}),void 0!==s.rawCache[n])return s.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);var o,a="raw"+((o=n)[0].toUpperCase()+o.slice(1));return this[a]?r=this[a](s,e):s.walk(e=>{if(void 0!==(r=e.raws[t]))return!1}),void 0===r&&(r=ye[n]),s.rawCache[n]=r,r}rawBeforeClose(e){var t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return(t=e.raws.after).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){var n;return e.walkComments(e=>{if(void 0!==e.raws.before)return(n=e.raws.before).includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(e,t){var n;return e.walkDecls(e=>{if(void 0!==e.raws.before)return(n=e.raws.before).includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(e){var t;return e.walk(e=>{if("decl"!==e.type&&void 0!==(t=e.raws.between))return!1}),t}rawBeforeRule(e){var t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&void 0!==n.raws.before)return(t=n.raws.before).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){var t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){var t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t}rawIndent(e){return e.raws.indent?e.raws.indent:(e.walk(n=>{var r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&void 0!==n.raws.before){var i=n.raws.before.split("\n");return t=(t=i[i.length-1]).replace(/\S/g,""),!1}}),t);var t}rawSemicolon(e){var t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t}rawValue(e,t){var n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},we=be;be.default=be;var Ce=we;function Se(e,t){new Ce(t).stringify(e)}var ke=Se;Se.default=Se;var{isClean:xe,my:Ie}=_e,Te=me,Ee=we,Ae=ke;function Oe(e,t){var n=new e.constructor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&"proxyCache"!==r){var i=e[r],s=typeof i;"parent"===r&&"object"===s?t&&(n[r]=t):"source"===r?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>Oe(e,n)):("object"===s&&null!==i&&(i=Oe(i)),n[r]=i)}return n}var Me=class{constructor(e){for(var t in void 0===e&&(e={}),this.raws={},this[xe]=!1,this[Ie]=!0,e)if("nodes"===t)for(var n of(this.nodes=[],e[t]))"function"==typeof n.clone?this.append(n.clone()):this.append(n);else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){var t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,"$&"+t.input.from+":"+t.start.line+":"+t.start.column+"$&")}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e){for(var t in void 0===e&&(e={}),e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e){void 0===e&&(e={});var t=Oe(this);for(var n in e)t[n]=e[n];return t}cloneAfter(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t){if(void 0===t&&(t={}),this.source){var{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new Te(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[xe]){this[xe]=!1;for(var e=this;e=e.parent;)e[xe]=!1}}next(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e+1]}}positionBy(e,t){var n=this.source.start;if(e.index)n=this.positionInside(e.index,t);else if(e.word){var r=(t=this.toString()).indexOf(e.word);-1!==r&&(n=this.positionInside(r,t))}return n}positionInside(e,t){for(var n=t||this.toString(),r=this.source.start.column,i=this.source.start.line,s=0;s<e;s++)"\n"===n[s]?(r=1,i+=1):r+=1;return{column:r,line:i}}prev(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e-1]}}rangeBy(e){var t={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){var r=this.toString(),i=r.indexOf(e.word);-1!==i&&(t=this.positionInside(i,r),n=this.positionInside(i+e.word.length,r))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?n={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?n=this.positionInside(e.endIndex):e.index&&(n=this.positionInside(e.index+1));return(n.line<t.line||n.line===t.line&&n.column<=t.column)&&(n={column:t.column+1,line:t.line}),{end:n,start:t}}raw(e,t){return(new Ee).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(){if(this.parent){for(var e=this,t=!1,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];for(var s of r)s===this?t=!0:t?(this.parent.insertAfter(e,s),e=s):this.parent.insertBefore(e,s);t||this.remove()}return this}root(){for(var e=this;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){var n={},r=null==t;t=t||new Map;var i=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))n[s]=o.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof o&&o.toJSON)n[s]=o.toJSON(null,t);else if("source"===s){var a=t.get(o.input);null==a&&(a=i,t.set(o.input,i),i++),n[s]={end:o.end,inputId:a,start:o.start}}else n[s]=o}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e){void 0===e&&(e=Ae),e.stringify&&(e=e.stringify);var t="";return e(this,e=>{t+=e}),t}warn(e,t,n){var r={node:this};for(var i in n)r[i]=n[i];return e.warn(t,r)}get proxyOf(){return this}},Re=Me;Me.default=Me;var Pe=Re,Le=class extends Pe{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e=n({},e,{value:String(e.value)})),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Ne=Le;Le.default=Le;var De={nanoid:function(e){void 0===e&&(e=21);for(var t="",n=e;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t}},{SourceMapConsumer:Ue,SourceMapGenerator:Be}=pe,{existsSync:Fe,readFileSync:je}=pe,{dirname:We,join:He}=pe;var ze=class{constructor(e,t){if(!1!==t.map){this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");var n=t.map?t.map.prev:void 0,r=this.loadMap(t.from,n);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=We(this.mapFile)),r&&(this.text=r)}}consumer(){return this.consumerCache||(this.consumerCache=new Ue(this.text)),this.consumerCache}decodeInline(e){var t;if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var n=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+n)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){var t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(t){var n=e.lastIndexOf(t.pop()),r=e.indexOf("*/",n);n>-1&&r>-1&&(this.annotation=this.getAnnotationURL(e.substring(n,r)))}}loadFile(e){if(this.root=We(e),Fe(e))return this.mapFile=e,je(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof Ue)return Be.fromSourceMap(t).toString();if(t instanceof Be)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}var n=t(e);if(n){var r=this.loadFile(n);if(!r)throw new Error("Unable to load previous source map: "+n.toString());return r}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var i=this.annotation;return e&&(i=He(We(e),i)),this.loadFile(i)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Ve=ze;ze.default=ze;var{SourceMapConsumer:qe,SourceMapGenerator:$e}=pe,{fileURLToPath:Ge,pathToFileURL:Je}=pe,{isAbsolute:Ke,resolve:Ye}=pe,{nanoid:Ze}=De,Xe=pe,Qe=me,et=Ve,tt=Symbol("fromOffsetCache"),nt=Boolean(qe&&$e),rt=Boolean(Ye&&Ke),it=class{constructor(e,t){if(void 0===t&&(t={}),null==e||"object"==typeof e&&!e.toString)throw new Error("PostCSS received "+e+" instead of CSS string");if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!rt||/^\w+:\/\//.test(t.from)||Ke(t.from)?this.file=t.from:this.file=Ye(t.from)),rt&&nt){var n=new et(this.css,t);if(n.text){this.map=n;var r=n.consumer().file;!this.file&&r&&(this.file=this.mapResolve(r))}}this.file||(this.id="<input css "+Ze(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,n,r){var i,s,o;if(void 0===r&&(r={}),t&&"object"==typeof t){var a=t,l=n;if("number"==typeof a.offset){var c=this.fromOffset(a.offset);t=c.line,n=c.col}else t=a.line,n=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(!n){var d=this.fromOffset(t);t=d.line,n=d.col}var h=this.origin(t,n,s,o);return(i=h?new Qe(e,void 0===h.endLine?h.line:{column:h.column,line:h.line},void 0===h.endLine?h.column:{column:h.endColumn,line:h.endLine},h.source,h.file,r.plugin):new Qe(e,void 0===s?t:{column:n,line:t},void 0===s?n:{column:o,line:s},this.css,this.file,r.plugin)).input={column:n,endColumn:o,endLine:s,line:t,source:this.css},this.file&&(Je&&(i.input.url=Je(this.file).toString()),i.input.file=this.file),i}fromOffset(e){var t;if(this[tt])t=this[tt];else{var n=this.css.split("\n");t=new Array(n.length);for(var r=0,i=0,s=n.length;i<s;i++)t[i]=r,r+=n[i].length+1;this[tt]=t}var o=0;if(e>=t[t.length-1])o=t.length-1;else for(var a,l=t.length-2;o<l;)if(e<t[a=o+(l-o>>1)])l=a-1;else{if(!(e>=t[a+1])){o=a;break}o=a+1}return{col:e-t[o]+1,line:o+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:Ye(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,n,r){if(!this.map)return!1;var i,s,o=this.map.consumer(),a=o.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof n&&(i=o.originalPositionFor({column:r,line:n})),s=Ke(a.source)?Je(a.source):new URL(a.source,this.map.consumer().sourceRoot||Je(this.map.mapFile));var l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:s.toString()};if("file:"===s.protocol){if(!Ge)throw new Error("file: protocol is not available in this PostCSS build");l.file=Ge(s)}var c=o.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){var e={};for(var t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map=n({},this.map),e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},st=it;it.default=it,Xe&&Xe.registerInput&&Xe.registerInput(it);var{SourceMapConsumer:ot,SourceMapGenerator:at}=pe,{dirname:lt,relative:ct,resolve:ut,sep:dt}=pe,{pathToFileURL:ht}=pe,pt=st,ft=Boolean(ot&&at),vt=Boolean(lt&&ut&&ct&&dt),gt=class{constructor(e,t,n,r){this.stringify=e,this.mapOpts=n.map||{},this.root=t,this.opts=n,this.css=r,this.originalCSS=r,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}addAnnotation(){var e;e=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 t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(var e of this.previous()){var t=this.toUrl(this.path(e.file)),n=e.root||lt(e.file),r=void 0;!1===this.mapOpts.sourcesContent?(r=new ot(e.text)).sourcesContent&&(r.sourcesContent=null):r=e.consumer(),this.map.applySourceMap(r,t,this.toUrl(this.path(n)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root)for(var e,t=this.root.nodes.length-1;t>=0;t--)"comment"===(e=this.root.nodes[t]).type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),vt&&ft&&this.isMap())return this.generateMap();var e="";return this.stringify(this.root,t=>{e+=t}),[e]}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){var e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=at.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new at({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 at({file:this.outputFile(),ignoreInvalidMapping:!0});var e,t,n=1,r=1,i="<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=n,s.generated.column=r-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=i,s.original.line=1,s.original.column=0,this.map.addMapping(s))),(e=o.match(/\n/g))?(n+=e.length,t=o.lastIndexOf("\n"),r=o.length-t):r+=o.length,a&&"start"!==l){var c=a.parent||{raws:{}};("decl"===a.type||"atrule"===a.type&&!a.nodes)&&a===c.last&&!c.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=n,s.generated.column=r-2,this.map.addMapping(s)):(s.source=i,s.original.line=1,s.original.column=0,s.generated.line=n,s.generated.column=r-1,this.map.addMapping(s)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;var e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.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(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;var t=this.memoizedPaths.get(e);if(t)return t;var n=this.opts.to?lt(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(n=lt(ut(n,this.mapOpts.annotation)));var r=ct(n,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){var t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{var e=new pt(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){var e={};if(this.root)this.root.walk(t=>{if(t.source){var n=t.source.input.from;if(n&&!e[n]){e[n]=!0;var r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){var t=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(t,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){var t=this.memoizedFileURLs.get(e);if(t)return t;if(ht){var n=ht(e).toString();return this.memoizedFileURLs.set(e,n),n}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){var t=this.memoizedURLs.get(e);if(t)return t;"\\"===dt&&(e=e.replace(/\\/g,"/"));var n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}},mt=Re,_t=class extends mt{constructor(e){super(e),this.type="comment"}},yt=_t;_t.default=_t;var bt,wt,Ct,St,{isClean:kt,my:xt}=_e,It=Ne,Tt=yt,Et=Re;function At(e){return e.map(e=>(e.nodes&&(e.nodes=At(e.nodes)),delete e.source,e))}function Ot(e){if(e[kt]=!1,e.proxyOf.nodes)for(var t of e.proxyOf.nodes)Ot(t)}var Mt=class e extends Et{append(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r of t){var i=this.normalize(r,this.last);for(var s of i)this.proxyOf.nodes.push(s)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(var t of this.nodes)t.cleanRaws(e)}each(e){if(this.proxyOf.nodes){for(var t,n,r=this.getIterator();this.indexes[r]<this.proxyOf.nodes.length&&(t=this.indexes[r],!1!==(n=e(this.proxyOf.nodes[t],t)));)this.indexes[r]+=1;return delete this.indexes[r],n}}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e[t](...r.map(e=>"function"==typeof e?(t,n)=>e(t.toProxy(),n):e))}:"every"===t||"some"===t?n=>e[t](function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return n(e.toProxy(),...r)}):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){var n,r=this.index(e),i=this.normalize(t,this.proxyOf.nodes[r]).reverse();for(var s of(r=this.index(e),i))this.proxyOf.nodes.splice(r+1,0,s);for(var o in this.indexes)r<(n=this.indexes[o])&&(this.indexes[o]=n+i.length);return this.markDirty(),this}insertBefore(e,t){var n,r=this.index(e),i=0===r&&"prepend",s=this.normalize(t,this.proxyOf.nodes[r],i).reverse();for(var o of(r=this.index(e),s))this.proxyOf.nodes.splice(r,0,o);for(var a in this.indexes)r<=(n=this.indexes[a])&&(this.indexes[a]=n+s.length);return this.markDirty(),this}normalize(t,n){if("string"==typeof t)t=At(bt(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t))for(var r of t=t.slice(0))r.parent&&r.parent.removeChild(r,"ignore");else if("root"===t.type&&"document"!==this.type)for(var i of t=t.nodes.slice(0))i.parent&&i.parent.removeChild(i,"ignore");else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new It(t)]}else if(t.selector)t=[new wt(t)];else if(t.name)t=[new Ct(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new Tt(t)]}var s=t.map(t=>(t[xt]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[kt]&&Ot(t),void 0===t.raws.before&&n&&void 0!==n.raws.before&&(t.raws.before=n.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t));return s}prepend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r of t=t.reverse()){var i=this.normalize(r,this.first,"prepend").reverse();for(var s of i)this.proxyOf.nodes.unshift(s);for(var o in this.indexes)this.indexes[o]=this.indexes[o]+i.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(var e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){var t;for(var n in e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1),this.indexes)(t=this.indexes[n])>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{var r;try{r=e(t,n)}catch(e){throw t.addToError(e)}return!1!==r&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("atrule"===n.type&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if("atrule"===n.type&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("atrule"===e.type)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if("comment"===t.type)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("decl"===n.type&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if("decl"===n.type&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("decl"===e.type)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("rule"===n.type&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if("rule"===n.type&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("rule"===e.type)return t(e,n)}))}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]}};Mt.registerParse=e=>{bt=e},Mt.registerRule=e=>{wt=e},Mt.registerAtRule=e=>{Ct=e},Mt.registerRoot=e=>{St=e};var Rt=Mt;Mt.default=Mt,Mt.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,Ct.prototype):"rule"===e.type?Object.setPrototypeOf(e,wt.prototype):"decl"===e.type?Object.setPrototypeOf(e,It.prototype):"comment"===e.type?Object.setPrototypeOf(e,Tt.prototype):"root"===e.type&&Object.setPrototypeOf(e,St.prototype),e[xt]=!0,e.nodes&&e.nodes.forEach(e=>{Mt.rebuild(e)})};var Pt,Lt,Nt=Rt,Dt=class extends Nt{constructor(e){super(n({type:"document"},e)),this.nodes||(this.nodes=[])}toResult(e){return void 0===e&&(e={}),new Pt(new Lt,this,e).stringify()}};Dt.registerLazyResult=e=>{Pt=e},Dt.registerProcessor=e=>{Lt=e};var Ut=Dt;Dt.default=Dt;var Bt={},Ft=function(e){Bt[e]||(Bt[e]=!0,"undefined"!=typeof console&&console.warn&&console.warn(e))},jt=class{constructor(e,t){if(void 0===t&&(t={}),this.type="warning",this.text=e,t.node&&t.node.source){var n=t.node.rangeBy(t);this.line=n.start.line,this.column=n.start.column,this.endLine=n.end.line,this.endColumn=n.end.column}for(var r in t)this[r]=t[r]}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}},Wt=jt;jt.default=jt;var Ht=Wt,zt=class{constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var n=new Ht(e,t);return this.messages.push(n),n}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},Vt=zt;zt.default=zt;var qt="'".charCodeAt(0),$t='"'.charCodeAt(0),Gt="\\".charCodeAt(0),Jt="/".charCodeAt(0),Kt="\n".charCodeAt(0),Yt=" ".charCodeAt(0),Zt="\f".charCodeAt(0),Xt="\t".charCodeAt(0),Qt="\r".charCodeAt(0),en="[".charCodeAt(0),tn="]".charCodeAt(0),nn="(".charCodeAt(0),rn=")".charCodeAt(0),sn="{".charCodeAt(0),on="}".charCodeAt(0),an=";".charCodeAt(0),ln="*".charCodeAt(0),cn=":".charCodeAt(0),un="@".charCodeAt(0),dn=/[\t\n\f\r "#'()/;[\\\]{}]/g,hn=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,pn=/.[\r\n"'(/\\]/,fn=/[\da-f]/i,vn=Rt,gn=class extends vn{constructor(e){super(e),this.type="atrule"}append(){return this.proxyOf.nodes||(this.nodes=[]),super.append(...arguments)}prepend(){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...arguments)}},mn=gn;gn.default=gn,vn.registerAtRule(gn);var _n,yn,bn=Rt,wn=class extends bn{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,n){var r=super.normalize(e);if(t)if("prepend"===n)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(var i of r)i.raws.before=t.raws.before;return r}removeChild(e,t){var n=this.index(e);return!t&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e){return void 0===e&&(e={}),new _n(new yn,this,e).stringify()}};wn.registerLazyResult=e=>{_n=e},wn.registerProcessor=e=>{yn=e};var Cn=wn;wn.default=wn,bn.registerRoot(wn);var Sn={comma:e=>Sn.split(e,[","],!0),space:e=>Sn.split(e,[" ","\n","\t"]),split(e,t,n){var r=[],i="",s=!1,o=0,a=!1,l="",c=!1;for(var u of e)c?c=!1:"\\"===u?c=!0:a?u===l&&(a=!1):'"'===u||"'"===u?(a=!0,l=u):"("===u?o+=1:")"===u?o>0&&(o-=1):0===o&&t.includes(u)&&(s=!0),s?(""!==i&&r.push(i.trim()),i="",s=!1):i+=u;return(n||""!==i)&&r.push(i.trim()),r}},kn=Sn;Sn.default=Sn;var xn=Rt,In=kn,Tn=class extends xn{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return In.comma(this.selector)}set selectors(e){var t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(n)}},En=Tn;Tn.default=Tn,xn.registerRule(Tn);var An=Ne,On=function(e,t){void 0===t&&(t={});var n,r,i,s,o,a,l,c,u,d,h=e.css.valueOf(),p=t.ignoreErrors,f=h.length,v=0,g=[],m=[];function _(t){throw e.error("Unclosed "+t,v)}return{back:function(e){m.push(e)},endOfFile:function(){return 0===m.length&&v>=f},nextToken:function(e){if(m.length)return m.pop();if(!(v>=f)){var t=!!e&&e.ignoreUnclosed;switch(n=h.charCodeAt(v)){case Kt:case Yt:case Xt:case Qt:case Zt:r=v;do{r+=1,n=h.charCodeAt(r)}while(n===Yt||n===Kt||n===Xt||n===Qt||n===Zt);d=["space",h.slice(v,r)],v=r-1;break;case en:case tn:case sn:case on:case cn:case an:case rn:var y=String.fromCharCode(n);d=[y,y,v];break;case nn:if(c=g.length?g.pop()[1]:"",u=h.charCodeAt(v+1),"url"===c&&u!==qt&&u!==$t&&u!==Yt&&u!==Kt&&u!==Xt&&u!==Zt&&u!==Qt){r=v;do{if(a=!1,-1===(r=h.indexOf(")",r+1))){if(p||t){r=v;break}_("bracket")}for(l=r;h.charCodeAt(l-1)===Gt;)l-=1,a=!a}while(a);d=["brackets",h.slice(v,r+1),v,r],v=r}else r=h.indexOf(")",v+1),s=h.slice(v,r+1),-1===r||pn.test(s)?d=["(","(",v]:(d=["brackets",s,v,r],v=r);break;case qt:case $t:i=n===qt?"'":'"',r=v;do{if(a=!1,-1===(r=h.indexOf(i,r+1))){if(p||t){r=v+1;break}_("string")}for(l=r;h.charCodeAt(l-1)===Gt;)l-=1,a=!a}while(a);d=["string",h.slice(v,r+1),v,r],v=r;break;case un:dn.lastIndex=v+1,dn.test(h),r=0===dn.lastIndex?h.length-1:dn.lastIndex-2,d=["at-word",h.slice(v,r+1),v,r],v=r;break;case Gt:for(r=v,o=!0;h.charCodeAt(r+1)===Gt;)r+=1,o=!o;if(n=h.charCodeAt(r+1),o&&n!==Jt&&n!==Yt&&n!==Kt&&n!==Xt&&n!==Qt&&n!==Zt&&(r+=1,fn.test(h.charAt(r)))){for(;fn.test(h.charAt(r+1));)r+=1;h.charCodeAt(r+1)===Yt&&(r+=1)}d=["word",h.slice(v,r+1),v,r],v=r;break;default:n===Jt&&h.charCodeAt(v+1)===ln?(0===(r=h.indexOf("*/",v+2)+1)&&(p||t?r=h.length:_("comment")),d=["comment",h.slice(v,r+1),v,r],v=r):(hn.lastIndex=v+1,hn.test(h),r=0===hn.lastIndex?h.length-1:hn.lastIndex-2,d=["word",h.slice(v,r+1),v,r],g.push(d),v=r)}return v++,d}},position:function(){return v}}},Mn=yt,Rn=mn,Pn=Cn,Ln=En,Nn={empty:!0,space:!0};var Dn=class{constructor(e){this.input=e,this.root=new Pn,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){var t,n,r,i=new Rn;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);for(var s=!1,o=!1,a=[],l=[];!this.tokenizer.endOfFile();){if("("===(t=(e=this.tokenizer.nextToken())[0])||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){o=!0;break}if("}"===t){if(a.length>0){for(n=a[r=a.length-1];n&&"space"===n[0];)n=a[--r];n&&(i.source.end=this.getPosition(n[3]||n[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){s=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),s&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),o&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){var t=this.colon(e);if(!1!==t){for(var n,r=0,i=t-1;i>=0&&("space"===(n=e[i])[0]||2!==(r+=1));i--);throw this.input.error("Missed semicolon","word"===n[0]?n[3]+1:n[2])}}colon(e){var t,n,r,i=0;for(var[s,o]of e.entries()){if("("===(n=(t=o)[0])&&(i+=1),")"===n&&(i-=1),0===i&&":"===n){if(r){if("word"===r[0]&&"progid"===r[1])continue;return s}this.doubleColon(t)}r=t}return!1}comment(e){var t=new Mn;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;var n=e[1].slice(2,-2);if(/^\s*$/.test(n))t.text="",t.raws.left=n,t.raws.right="";else{var r=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=r[2],t.raws.left=r[1],t.raws.right=r[3]}}createTokenizer(){this.tokenizer=On(this.input)}decl(e,t){var n=new An;this.init(n,e[0][2]);var r,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(i[3]||i[2]||function(e){for(var t=e.length-1;t>=0;t--){var n=e[t],r=n[3]||n[2];if(r)return r}}(e)),n.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop="";e.length;){var s=e[0][0];if(":"===s||"space"===s||"comment"===s)break;n.prop+=e.shift()[1]}for(n.raws.between="";e.length;){if(":"===(r=e.shift())[0]){n.raws.between+=r[1];break}"word"===r[0]&&/\w/.test(r[1])&&this.unknownWord([r]),n.raws.between+=r[1]}"_"!==n.prop[0]&&"*"!==n.prop[0]||(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));for(var o,a=[];e.length&&("space"===(o=e[0][0])||"comment"===o);)a.push(e.shift());this.precheckMissedSemicolon(e);for(var l=e.length-1;l>=0;l--){if("!important"===(r=e[l])[1].toLowerCase()){n.important=!0;var c=this.stringFrom(e,l);" !important"!==(c=this.spacesFromEnd(e)+c)&&(n.raws.important=c);break}if("important"===r[1].toLowerCase()){for(var u=e.slice(0),d="",h=l;h>0;h--){var p=u[h][0];if(0===d.trim().indexOf("!")&&"space"!==p)break;d=u.pop()[1]+d}0===d.trim().indexOf("!")&&(n.important=!0,n.raws.important=d,e=u)}if("space"!==r[0]&&"comment"!==r[0])break}var f=e.some(e=>"space"!==e[0]&&"comment"!==e[0]);f&&(n.raws.between+=a.map(e=>e[1]).join(""),a=[]),this.raw(n,"value",a.concat(e),t),n.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){var t=new Ln;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){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(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}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(e){if(this.spaces+=e[1],this.current.nodes){var t=this.current.nodes[this.current.nodes.length-1];t&&"rule"===t.type&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){var t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){for(var t=!1,n=null,r=!1,i=null,s=[],o=e[1].startsWith("--"),a=[],l=e;l;){if(n=l[0],a.push(l),"("===n||"["===n)i||(i=l),s.push("("===n?")":"]");else if(o&&r&&"{"===n)i||(i=l),s.push("}");else if(0===s.length){if(";"===n){if(r)return void this.decl(a,o);break}if("{"===n)return void this.rule(a);if("}"===n){this.tokenizer.back(a.pop()),t=!0;break}":"===n&&(r=!0)}else n===s[s.length-1]&&(s.pop(),0===s.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),s.length>0&&this.unclosedBracket(i),t&&r){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 e;!this.tokenizer.endOfFile();)switch((e=this.tokenizer.nextToken())[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){for(var i,s,o,a,l=n.length,c="",u=!0,d=0;d<l;d+=1)"space"!==(s=(i=n[d])[0])||d!==l-1||r?"comment"===s?(a=n[d-1]?n[d-1][0]:"empty",o=n[d+1]?n[d+1][0]:"empty",Nn[a]||Nn[o]||","===c.slice(-1)?u=!1:c+=i[1]):c+=i[1]:u=!1;if(!u){var h=n.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:h,value:c}}e[t]=c}rule(e){e.pop();var t=new Ln;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){for(var t,n="";e.length&&("space"===(t=e[e.length-1][0])||"comment"===t);)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){for(var t,n="";e.length&&("space"===(t=e[0][0])||"comment"===t);)n+=e.shift()[1];return n}spacesFromEnd(e){for(var t="";e.length&&"space"===e[e.length-1][0];)t=e.pop()[1]+t;return t}stringFrom(e,t){for(var n="",r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){var e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Un=Rt,Bn=Dn,Fn=st;function jn(e,t){var n=new Fn(e,t),r=new Bn(n);try{r.parse()}catch(e){throw"production"!==process.env.NODE_ENV&&"CssSyntaxError"===e.name&&t&&t.from&&(/\.scss$/i.test(t.from)?e.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.sass/i.test(t.from)?e.message+="\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser":/\.less$/i.test(t.from)&&(e.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),e}return r.root}var Wn=jn;jn.default=jn,Un.registerParse(jn);var{isClean:Hn,my:zn}=_e,Vn=gt,qn=ke,$n=Rt,Gn=Ut,Jn=Ft,Kn=Vt,Yn=Wn,Zn=Cn,Xn={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Qn={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},er={Once:!0,postcssPlugin:!0,prepare:!0};function tr(e){return"object"==typeof e&&"function"==typeof e.then}function nr(e){var t=!1,n=Xn[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[n,n+"-"+t,0,n+"Exit",n+"Exit-"+t]:t?[n,n+"-"+t,n+"Exit",n+"Exit-"+t]:e.append?[n,0,n+"Exit"]:[n,n+"Exit"]}function rr(e){return{eventIndex:0,events:"document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:nr(e),iterator:0,node:e,visitorIndex:0,visitors:[]}}function ir(e){return e[Hn]=!1,e.nodes&&e.nodes.forEach(e=>ir(e)),e}var sr={},or=class e{constructor(t,r,i){var s;if(this.stringified=!1,this.processed=!1,"object"!=typeof r||null===r||"root"!==r.type&&"document"!==r.type)if(r instanceof e||r instanceof Kn)s=ir(r.root),r.map&&(void 0===i.map&&(i.map={}),i.map.inline||(i.map.inline=!1),i.map.prev=r.map);else{var o=Yn;i.syntax&&(o=i.syntax.parse),i.parser&&(o=i.parser),o.parse&&(o=o.parse);try{s=o(r,i)}catch(e){this.processed=!0,this.error=e}s&&!s[zn]&&$n.rebuild(s)}else s=ir(r);this.result=new Kn(t,s,i),this.helpers=n({},sr,{postcss:sr,result:this.result}),this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?n({},e,e.prepare(this.result)):e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){var n=this.result.lastPlugin;try{if(t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin){if(n.postcssVersion&&"production"!==process.env.NODE_ENV){var r=n.postcssPlugin,i=n.postcssVersion,s=this.result.processor.version,o=i.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 "+r+" uses "+i+". Perhaps this is the source of the error below.")}}else e.plugin=n.postcssPlugin,e.setMessage()}catch(e){console&&console.error&&console.error(e)}return e}prepareVisitors(){this.listeners={};var e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(var t of this.plugins)if("object"==typeof t)for(var n in t){if(!Qn[n]&&/^[A-Z]/.test(n))throw new Error("Unknown event "+n+" in "+t.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!er[n])if("object"==typeof t[n])for(var r in t[n])e(t,"*"===r?n:n+"-"+r.toLowerCase(),t[n][r]);else"function"==typeof t[n]&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}runAsync(){var e=this;return t(function*(){e.plugin=0;for(var t=0;t<e.plugins.length;t++){var n=e.plugins[t],r=e.runOnRoot(n);if(tr(r))try{yield r}catch(t){throw e.handleError(t)}}if(e.prepareVisitors(),e.hasListener){for(var i=e.result.root;!i[Hn];){i[Hn]=!0;for(var s=[rr(i)];s.length>0;){var o=e.visitTick(s);if(tr(o))try{yield o}catch(t){var a=s[s.length-1].node;throw e.handleError(t,a)}}}if(e.listeners.OnceExit){var l=function*(t){e.result.lastPlugin=c;try{if("document"===i.type){var n=i.nodes.map(n=>t(n,e.helpers));yield Promise.all(n)}else yield t(i,e.helpers)}catch(t){throw e.handleError(t)}};for(var[c,u]of e.listeners.OnceExit)yield*l(u)}}return e.processed=!0,e.stringify()})()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){var t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return tr(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(e){throw this.handleError(e)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=qn;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var n=new Vn(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[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 e of this.plugins){if(tr(this.runOnRoot(e)))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var t=this.result.root;!t[Hn];)t[Hn]=!0,this.walkSync(t);if(this.listeners.OnceExit)if("document"===t.type)for(var n of t.nodes)this.visitSync(this.listeners.OnceExit,n);else this.visitSync(this.listeners.OnceExit,t)}return this.result}then(e,t){return"production"!==process.env.NODE_ENV&&("from"in this.opts||Jn("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(e,t)}toString(){return this.css}visitSync(e,t){for(var[n,r]of e){this.result.lastPlugin=n;var i=void 0;try{i=r(t,this.helpers)}catch(e){throw this.handleError(e,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(tr(i))throw this.getAsyncError()}}visitTick(e){var t=e[e.length-1],{node:n,visitors:r}=t;if("root"===n.type||"document"===n.type||n.parent){if(r.length>0&&t.visitorIndex<r.length){var[i,s]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=i;try{return s(n.toProxy(),this.helpers)}catch(e){throw this.handleError(e,n)}}if(0!==t.iterator){for(var o,a=t.iterator;o=n.nodes[n.indexes[a]];)if(n.indexes[a]+=1,!o[Hn])return o[Hn]=!0,void e.push(rr(o));t.iterator=0,delete n.indexes[a]}for(var l=t.events;t.eventIndex<l.length;){var c=l[t.eventIndex];if(t.eventIndex+=1,0===c)return void(n.nodes&&n.nodes.length&&(n[Hn]=!0,t.iterator=n.getIterator()));if(this.listeners[c])return void(t.visitors=this.listeners[c])}e.pop()}else e.pop()}walkSync(e){e[Hn]=!0;var t=nr(e);for(var n of t)if(0===n)e.nodes&&e.each(e=>{e[Hn]||this.walkSync(e)});else{var r=this.listeners[n];if(r&&this.visitSync(r,e.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"}};or.registerPostcss=e=>{sr=e};var ar=or;or.default=or,Zn.registerLazyResult(or),Gn.registerLazyResult(or);var lr=gt,cr=ke,ur=Ft,dr=Wn,hr=Vt,pr=class{constructor(e,t,n){var r;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=n,this._map=void 0;var i=cr;this.result=new hr(this._processor,r,this._opts),this.result.css=t;var s=this;Object.defineProperty(this.result,"root",{get:()=>s.root});var o=new lr(i,r,this._opts,t);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(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return"production"!==process.env.NODE_ENV&&("from"in this._opts||ur("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(e,t)}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 e,t=dr;try{e=t(this._css,this._opts)}catch(e){this.error=e}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},fr=pr;pr.default=pr;var vr=fr,gr=ar,mr=Ut,_r=Cn,yr=class{constructor(e){void 0===e&&(e=[]),this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){var t=[];for(var n of e)if(!0===n.postcss?n=n():n.postcss&&(n=n.postcss),"object"==typeof n&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if("object"==typeof n&&n.postcssPlugin)t.push(n);else if("function"==typeof n)t.push(n);else{if("object"!=typeof n||!n.parse&&!n.stringify)throw new Error(n+" 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 t}process(e,t){return void 0===t&&(t={}),this.plugins.length||t.parser||t.stringifier||t.syntax?new gr(this,e,t):new vr(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},br=yr;yr.default=yr,_r.registerProcessor(yr),mr.registerProcessor(yr);var wr=Ne,Cr=Ve,Sr=yt,kr=mn,xr=st,Ir=Cn,Tr=En;function Er(e,t){if(Array.isArray(e))return e.map(e=>Er(e));var{inputs:i}=e,a=r(e,s);if(i)for(var l of(t=[],i)){var c=n({},l,{__proto__:xr.prototype});c.map&&(c.map=n({},c.map,{__proto__:Cr.prototype})),t.push(c)}if(a.nodes&&(a.nodes=e.nodes.map(e=>Er(e,t))),a.source){var u=a.source,{inputId:d}=u,h=r(u,o);a.source=h,null!=d&&(a.source.input=t[d])}if("root"===a.type)return new Ir(a);if("decl"===a.type)return new wr(a);if("rule"===a.type)return new Tr(a);if("comment"===a.type)return new Sr(a);if("atrule"===a.type)return new kr(a);throw new Error("Unknown node type: "+e.type)}var Ar=Er;Er.default=Er;var Or=me,Mr=Ne,Rr=ar,Pr=Rt,Lr=br,Nr=ke,Dr=Ar,Ur=Ut,Br=Wt,Fr=yt,jr=mn,Wr=Vt,Hr=st,zr=Wn,Vr=kn,qr=En,$r=Cn,Gr=Re;function Jr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),new Lr(t)}Jr.plugin=function(e,t){var n,r=!1;function i(){console&&console.warn&&!r&&(r=!0,console.warn(e+": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226"));var n=t(...arguments);return n.postcssPlugin=e,n.postcssVersion=(new Lr).version,n}return Object.defineProperty(i,"postcss",{get:()=>(n||(n=i()),n)}),i.process=function(e,t,n){return Jr([i(n)]).process(e,t)},i},Jr.stringify=Nr,Jr.parse=zr,Jr.fromJSON=Dr,Jr.list=Vr,Jr.comment=e=>new Fr(e),Jr.atRule=e=>new jr(e),Jr.decl=e=>new Mr(e),Jr.rule=e=>new qr(e),Jr.root=e=>new $r(e),Jr.document=e=>new Ur(e),Jr.CssSyntaxError=Or,Jr.Declaration=Mr,Jr.Container=Pr,Jr.Processor=Lr,Jr.Document=Ur,Jr.Comment=Fr,Jr.Warning=Br,Jr.AtRule=jr,Jr.Result=Wr,Jr.Input=Hr,Jr.Rule=qr,Jr.Root=$r,Jr.Node=Gr,Rr.registerPostcss(Jr);var Kr=Jr;Jr.default=Jr;var Yr=ae(Kr);Yr.stringify,Yr.fromJSON,Yr.plugin,Yr.parse,Yr.list,Yr.document,Yr.comment,Yr.atRule,Yr.rule,Yr.decl,Yr.root,Yr.CssSyntaxError,Yr.Declaration,Yr.Container,Yr.Processor,Yr.Document,Yr.Comment,Yr.Warning,Yr.AtRule,Yr.Result,Yr.Input,Yr.Rule,Yr.Root,Yr.Node;var Zr=Object.defineProperty,Xr=(e,t,n)=>((e,t,n)=>t in e?Zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);function Qr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ei(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var ti={exports:{}},ni=String,ri=function(){return{isColorSupported:!1,reset:ni,bold:ni,dim:ni,italic:ni,underline:ni,inverse:ni,hidden:ni,strikethrough:ni,black:ni,red:ni,green:ni,yellow:ni,blue:ni,magenta:ni,cyan:ni,white:ni,gray:ni,bgBlack:ni,bgRed:ni,bgGreen:ni,bgYellow:ni,bgBlue:ni,bgMagenta:ni,bgCyan:ni,bgWhite:ni}};ti.exports=ri(),ti.exports.createColors=ri;var ii=ti.exports,si=ei(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),oi=ii,ai=si,li=class e extends Error{constructor(t,n,r,i,s,o){super(t),this.name="CssSyntaxError",this.reason=t,s&&(this.file=s),i&&(this.source=i),o&&(this.plugin=o),void 0!==n&&void 0!==r&&("number"==typeof n?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}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(e){if(!this.source)return"";var t=this.source;null==e&&(e=oi.isColorSupported),ai&&e&&(t=ai(t));var n,r,i=t.split(/\r?\n/),s=Math.max(this.line-3,0),o=Math.min(this.line+2,i.length),a=String(o).length;if(e){var{bold:l,gray:c,red:u}=oi.createColors(!0);n=e=>l(u(e)),r=e=>c(e)}else n=r=e=>e;return i.slice(s,o).map((e,t)=>{var i=s+1+t,o=" "+(" "+i).slice(-a)+" | ";if(i===this.line){var l=r(o.replace(/\d/g," "))+e.slice(0,this.column-1).replace(/[^\t]/g," ");return n(">")+r(o)+e+"\n "+l+n("^")}return" "+r(o)+e}).join("\n")}toString(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e}},ci=li;li.default=li;var ui={};ui.isClean=Symbol("isClean"),ui.my=Symbol("my");var di={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var hi=class{constructor(e){this.builder=e}atrule(e,t){var n="@"+e.name,r=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?n+=e.raws.afterName:r&&(n+=" "),e.nodes)this.block(e,n+r);else{var i=(e.raws.between||"")+(t?";":"");this.builder(n+r+i,e)}}beforeAfter(e,t){var n;n="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");for(var r=e.parent,i=0;r&&"root"!==r.type;)i+=1,r=r.parent;if(n.includes("\n")){var s=this.raw(e,null,"indent");if(s.length)for(var o=0;o<i;o++)n+=s}return n}block(e,t){var n,r=this.raw(e,"between","beforeOpen");this.builder(t+r+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),this.builder("}",e,"end")}body(e){for(var t=e.nodes.length-1;t>0&&"comment"===e.nodes[t].type;)t-=1;for(var n=this.raw(e,"semicolon"),r=0;r<e.nodes.length;r++){var i=e.nodes[r],s=this.raw(i,"before");s&&this.builder(s),this.stringify(i,t!==r||n)}}comment(e){var t=this.raw(e,"left","commentLeft"),n=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+n+"*/",e)}decl(e,t){var n=this.raw(e,"between","colon"),r=e.prop+n+this.rawValue(e,"value");e.important&&(r+=e.raws.important||" !important"),t&&(r+=";"),this.builder(r,e)}document(e){this.body(e)}raw(e,t,n){var r;if(n||(n=t),t&&void 0!==(r=e.raws[t]))return r;var i=e.parent;if("before"===n){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return di[n];var s=e.root();if(s.rawCache||(s.rawCache={}),void 0!==s.rawCache[n])return s.rawCache[n];if("before"===n||"after"===n)return this.beforeAfter(e,n);var o,a="raw"+((o=n)[0].toUpperCase()+o.slice(1));return this[a]?r=this[a](s,e):s.walk(e=>{if(void 0!==(r=e.raws[t]))return!1}),void 0===r&&(r=di[n]),s.rawCache[n]=r,r}rawBeforeClose(e){var t;return e.walk(e=>{if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return(t=e.raws.after).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawBeforeComment(e,t){var n;return e.walkComments(e=>{if(void 0!==e.raws.before)return(n=e.raws.before).includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(e,t){var n;return e.walkDecls(e=>{if(void 0!==e.raws.before)return(n=e.raws.before).includes("\n")&&(n=n.replace(/[^\n]+$/,"")),!1}),void 0===n?n=this.raw(t,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(e){var t;return e.walk(e=>{if("decl"!==e.type&&void 0!==(t=e.raws.between))return!1}),t}rawBeforeRule(e){var t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&void 0!==n.raws.before)return(t=n.raws.before).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t}rawColon(e){var t;return e.walkDecls(e=>{if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t}rawEmptyBody(e){var t;return e.walk(e=>{if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t}rawIndent(e){return e.raws.indent?e.raws.indent:(e.walk(n=>{var r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&void 0!==n.raws.before){var i=n.raws.before.split("\n");return t=(t=i[i.length-1]).replace(/\S/g,""),!1}}),t);var t}rawSemicolon(e){var t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t}rawValue(e,t){var n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){this.body(e),e.raws.after&&this.builder(e.raws.after)}rule(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")}stringify(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)}},pi=hi;hi.default=hi;var fi=pi;function vi(e,t){new fi(t).stringify(e)}var gi=vi;vi.default=vi;var{isClean:mi,my:_i}=ui,yi=ci,bi=pi,wi=gi;function Ci(e,t){var n=new e.constructor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&"proxyCache"!==r){var i=e[r],s=typeof i;"parent"===r&&"object"===s?t&&(n[r]=t):"source"===r?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>Ci(e,n)):("object"===s&&null!==i&&(i=Ci(i)),n[r]=i)}return n}var Si=class{constructor(e){for(var t in void 0===e&&(e={}),this.raws={},this[mi]=!1,this[_i]=!0,e)if("nodes"===t)for(var n of(this.nodes=[],e[t]))"function"==typeof n.clone?this.append(n.clone()):this.append(n);else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){var t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,"$&"+t.input.from+":"+t.start.line+":"+t.start.column+"$&")}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e){for(var t in void 0===e&&(e={}),e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e){void 0===e&&(e={});var t=Ci(this);for(var n in e)t[n]=e[n];return t}cloneAfter(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t){if(void 0===t&&(t={}),this.source){var{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new yi(e)}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:"root"===t?()=>e.root().toProxy():e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0)}}markDirty(){if(this[mi]){this[mi]=!1;for(var e=this;e=e.parent;)e[mi]=!1}}next(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e+1]}}positionBy(e,t){var n=this.source.start;if(e.index)n=this.positionInside(e.index,t);else if(e.word){var r=(t=this.toString()).indexOf(e.word);-1!==r&&(n=this.positionInside(r,t))}return n}positionInside(e,t){for(var n=t||this.toString(),r=this.source.start.column,i=this.source.start.line,s=0;s<e;s++)"\n"===n[s]?(r=1,i+=1):r+=1;return{column:r,line:i}}prev(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e-1]}}rangeBy(e){var t={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){var r=this.toString(),i=r.indexOf(e.word);-1!==i&&(t=this.positionInside(i,r),n=this.positionInside(i+e.word.length,r))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?n={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?n=this.positionInside(e.endIndex):e.index&&(n=this.positionInside(e.index+1));return(n.line<t.line||n.line===t.line&&n.column<=t.column)&&(n={column:t.column+1,line:t.line}),{end:n,start:t}}raw(e,t){return(new bi).raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(){if(this.parent){for(var e=this,t=!1,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];for(var s of r)s===this?t=!0:t?(this.parent.insertAfter(e,s),e=s):this.parent.insertBefore(e,s);t||this.remove()}return this}root(){for(var e=this;e.parent&&"document"!==e.parent.type;)e=e.parent;return e}toJSON(e,t){var n={},r=null==t;t=t||new Map;var i=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))n[s]=o.map(e=>"object"==typeof e&&e.toJSON?e.toJSON(null,t):e);else if("object"==typeof o&&o.toJSON)n[s]=o.toJSON(null,t);else if("source"===s){var a=t.get(o.input);null==a&&(a=i,t.set(o.input,i),i++),n[s]={end:o.end,inputId:a,start:o.start}}else n[s]=o}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(e){void 0===e&&(e=wi),e.stringify&&(e=e.stringify);var t="";return e(this,e=>{t+=e}),t}warn(e,t,n){var r={node:this};for(var i in n)r[i]=n[i];return e.warn(t,r)}get proxyOf(){return this}},ki=Si;Si.default=Si;var xi=ki,Ii=class extends xi{constructor(e){e&&void 0!==e.value&&"string"!=typeof e.value&&(e=n({},e,{value:String(e.value)})),super(e),this.type="decl"}get variable(){return this.prop.startsWith("--")||"$"===this.prop[0]}},Ti=Ii;Ii.default=Ii;var Ei={nanoid:function(e){void 0===e&&(e=21);for(var t="",n=e;n--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t}},{SourceMapConsumer:Ai,SourceMapGenerator:Oi}=si,{existsSync:Mi,readFileSync:Ri}=si,{dirname:Pi,join:Li}=si;var Ni=class{constructor(e,t){if(!1!==t.map){this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");var n=t.map?t.map.prev:void 0,r=this.loadMap(t.from,n);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Pi(this.mapFile)),r&&(this.text=r)}}consumer(){return this.consumerCache||(this.consumerCache=new Ai(this.text)),this.consumerCache}decodeInline(e){var t;if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),Buffer?Buffer.from(t,"base64").toString():window.atob(t);var n=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+n)}getAnnotationURL(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(e){return"object"==typeof e&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))}loadAnnotation(e){var t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(t){var n=e.lastIndexOf(t.pop()),r=e.indexOf("*/",n);n>-1&&r>-1&&(this.annotation=this.getAnnotationURL(e.substring(n,r)))}}loadFile(e){if(this.root=Pi(e),Mi(e))return this.mapFile=e,Ri(e,"utf-8").toString().trim()}loadMap(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(t instanceof Ai)return Oi.fromSourceMap(t).toString();if(t instanceof Oi)return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}var n=t(e);if(n){var r=this.loadFile(n);if(!r)throw new Error("Unable to load previous source map: "+n.toString());return r}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var i=this.annotation;return e&&(i=Li(Pi(e),i)),this.loadFile(i)}}}startWith(e,t){return!!e&&e.substr(0,t.length)===t}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},Di=Ni;Ni.default=Ni;var{SourceMapConsumer:Ui,SourceMapGenerator:Bi}=si,{fileURLToPath:Fi,pathToFileURL:ji}=si,{isAbsolute:Wi,resolve:Hi}=si,{nanoid:zi}=Ei,Vi=si,qi=ci,$i=Di,Gi=Symbol("fromOffsetCache"),Ji=Boolean(Ui&&Bi),Ki=Boolean(Hi&&Wi),Yi=class{constructor(e,t){if(void 0===t&&(t={}),null==e||"object"==typeof e&&!e.toString)throw new Error("PostCSS received "+e+" instead of CSS string");if(this.css=e.toString(),"\ufeff"===this.css[0]||"￾"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!Ki||/^\w+:\/\//.test(t.from)||Wi(t.from)?this.file=t.from:this.file=Hi(t.from)),Ki&&Ji){var n=new $i(this.css,t);if(n.text){this.map=n;var r=n.consumer().file;!this.file&&r&&(this.file=this.mapResolve(r))}}this.file||(this.id="<input css "+zi(6)+">"),this.map&&(this.map.file=this.from)}error(e,t,n,r){var i,s,o;if(void 0===r&&(r={}),t&&"object"==typeof t){var a=t,l=n;if("number"==typeof a.offset){var c=this.fromOffset(a.offset);t=c.line,n=c.col}else t=a.line,n=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(!n){var d=this.fromOffset(t);t=d.line,n=d.col}var h=this.origin(t,n,s,o);return(i=h?new qi(e,void 0===h.endLine?h.line:{column:h.column,line:h.line},void 0===h.endLine?h.column:{column:h.endColumn,line:h.endLine},h.source,h.file,r.plugin):new qi(e,void 0===s?t:{column:n,line:t},void 0===s?n:{column:o,line:s},this.css,this.file,r.plugin)).input={column:n,endColumn:o,endLine:s,line:t,source:this.css},this.file&&(ji&&(i.input.url=ji(this.file).toString()),i.input.file=this.file),i}fromOffset(e){var t;if(this[Gi])t=this[Gi];else{var n=this.css.split("\n");t=new Array(n.length);for(var r=0,i=0,s=n.length;i<s;i++)t[i]=r,r+=n[i].length+1;this[Gi]=t}var o=0;if(e>=t[t.length-1])o=t.length-1;else for(var a,l=t.length-2;o<l;)if(e<t[a=o+(l-o>>1)])l=a-1;else{if(!(e>=t[a+1])){o=a;break}o=a+1}return{col:e-t[o]+1,line:o+1}}mapResolve(e){return/^\w+:\/\//.test(e)?e:Hi(this.map.consumer().sourceRoot||this.map.root||".",e)}origin(e,t,n,r){if(!this.map)return!1;var i,s,o=this.map.consumer(),a=o.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof n&&(i=o.originalPositionFor({column:r,line:n})),s=Wi(a.source)?ji(a.source):new URL(a.source,this.map.consumer().sourceRoot||ji(this.map.mapFile));var l={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:s.toString()};if("file:"===s.protocol){if(!Fi)throw new Error("file: protocol is not available in this PostCSS build");l.file=Fi(s)}var c=o.sourceContentFor(a.source);return c&&(l.source=c),l}toJSON(){var e={};for(var t of["hasBOM","css","file","id"])null!=this[t]&&(e[t]=this[t]);return this.map&&(e.map=n({},this.map),e.map.consumerCache&&(e.map.consumerCache=void 0)),e}get from(){return this.file||this.id}},Zi=Yi;Yi.default=Yi,Vi&&Vi.registerInput&&Vi.registerInput(Yi);var{SourceMapConsumer:Xi,SourceMapGenerator:Qi}=si,{dirname:es,relative:ts,resolve:ns,sep:rs}=si,{pathToFileURL:is}=si,ss=Zi,os=Boolean(Xi&&Qi),as=Boolean(es&&ns&&ts&&rs),ls=class{constructor(e,t,n,r){this.stringify=e,this.mapOpts=n.map||{},this.root=t,this.opts=n,this.css=r,this.originalCSS=r,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}addAnnotation(){var e;e=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 t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(var e of this.previous()){var t=this.toUrl(this.path(e.file)),n=e.root||es(e.file),r=void 0;!1===this.mapOpts.sourcesContent?(r=new Xi(e.text)).sourcesContent&&(r.sourcesContent=null):r=e.consumer(),this.map.applySourceMap(r,t,this.toUrl(this.path(n)))}}clearAnnotation(){if(!1!==this.mapOpts.annotation)if(this.root)for(var e,t=this.root.nodes.length-1;t>=0;t--)"comment"===(e=this.root.nodes[t]).type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),as&&os&&this.isMap())return this.generateMap();var e="";return this.stringify(this.root,t=>{e+=t}),[e]}generateMap(){if(this.root)this.generateString();else if(1===this.previous().length){var e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=Qi.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new Qi({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 Qi({file:this.outputFile(),ignoreInvalidMapping:!0});var e,t,n=1,r=1,i="<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=n,s.generated.column=r-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=i,s.original.line=1,s.original.column=0,this.map.addMapping(s))),(e=o.match(/\n/g))?(n+=e.length,t=o.lastIndexOf("\n"),r=o.length-t):r+=o.length,a&&"start"!==l){var c=a.parent||{raws:{}};("decl"===a.type||"atrule"===a.type&&!a.nodes)&&a===c.last&&!c.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=n,s.generated.column=r-2,this.map.addMapping(s)):(s.source=i,s.original.line=1,s.original.column=0,s.generated.line=n,s.generated.column=r-1,this.map.addMapping(s)))}})}isAnnotation(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(e=>e.annotation))}isInline(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;var e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(e=>e.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(e=>e.withContent())}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;var t=this.memoizedPaths.get(e);if(t)return t;var n=this.opts.to?es(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(n=es(ns(n,this.mapOpts.annotation)));var r=ts(n,e);return this.memoizedPaths.set(e,r),r}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){var t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{var e=new ss(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){var e={};if(this.root)this.root.walk(t=>{if(t.source){var n=t.source.input.from;if(n&&!e[n]){e[n]=!0;var r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){var t=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(t,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){var t=this.memoizedFileURLs.get(e);if(t)return t;if(is){var n=is(e).toString();return this.memoizedFileURLs.set(e,n),n}throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){var t=this.memoizedURLs.get(e);if(t)return t;"\\"===rs&&(e=e.replace(/\\/g,"/"));var n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}},cs=ki,us=class extends cs{constructor(e){super(e),this.type="comment"}},ds=us;us.default=us;var hs,ps,fs,vs,{isClean:gs,my:ms}=ui,_s=Ti,ys=ds,bs=ki;function ws(e){return e.map(e=>(e.nodes&&(e.nodes=ws(e.nodes)),delete e.source,e))}function Cs(e){if(e[gs]=!1,e.proxyOf.nodes)for(var t of e.proxyOf.nodes)Cs(t)}var Ss=class e extends bs{append(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r of t){var i=this.normalize(r,this.last);for(var s of i)this.proxyOf.nodes.push(s)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(var t of this.nodes)t.cleanRaws(e)}each(e){if(this.proxyOf.nodes){for(var t,n,r=this.getIterator();this.indexes[r]<this.proxyOf.nodes.length&&(t=this.indexes[r],!1!==(n=e(this.proxyOf.nodes[t],t)));)this.indexes[r]+=1;return delete this.indexes[r],n}}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get:(e,t)=>"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e[t](...r.map(e=>"function"==typeof e?(t,n)=>e(t.toProxy(),n):e))}:"every"===t||"some"===t?n=>e[t](function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return n(e.toProxy(),...r)}):"root"===t?()=>e.root().toProxy():"nodes"===t?e.nodes.map(e=>e.toProxy()):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t],set:(e,t,n)=>(e[t]===n||(e[t]=n,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0)}}index(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){var n,r=this.index(e),i=this.normalize(t,this.proxyOf.nodes[r]).reverse();for(var s of(r=this.index(e),i))this.proxyOf.nodes.splice(r+1,0,s);for(var o in this.indexes)r<(n=this.indexes[o])&&(this.indexes[o]=n+i.length);return this.markDirty(),this}insertBefore(e,t){var n,r=this.index(e),i=0===r&&"prepend",s=this.normalize(t,this.proxyOf.nodes[r],i).reverse();for(var o of(r=this.index(e),s))this.proxyOf.nodes.splice(r,0,o);for(var a in this.indexes)r<=(n=this.indexes[a])&&(this.indexes[a]=n+s.length);return this.markDirty(),this}normalize(t,n){if("string"==typeof t)t=ws(hs(t).nodes);else if(void 0===t)t=[];else if(Array.isArray(t))for(var r of t=t.slice(0))r.parent&&r.parent.removeChild(r,"ignore");else if("root"===t.type&&"document"!==this.type)for(var i of t=t.nodes.slice(0))i.parent&&i.parent.removeChild(i,"ignore");else if(t.type)t=[t];else if(t.prop){if(void 0===t.value)throw new Error("Value field is missed in node creation");"string"!=typeof t.value&&(t.value=String(t.value)),t=[new _s(t)]}else if(t.selector)t=[new ps(t)];else if(t.name)t=[new fs(t)];else{if(!t.text)throw new Error("Unknown node type in node creation");t=[new ys(t)]}var s=t.map(t=>(t[ms]||e.rebuild(t),(t=t.proxyOf).parent&&t.parent.removeChild(t),t[gs]&&Cs(t),void 0===t.raws.before&&n&&void 0!==n.raws.before&&(t.raws.before=n.raws.before.replace(/\S/g,"")),t.parent=this.proxyOf,t));return s}prepend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r of t=t.reverse()){var i=this.normalize(r,this.first,"prepend").reverse();for(var s of i)this.proxyOf.nodes.unshift(s);for(var o in this.indexes)this.indexes[o]=this.indexes[o]+i.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(var e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){var t;for(var n in e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1),this.indexes)(t=this.indexes[n])>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{var r;try{r=e(t,n)}catch(e){throw t.addToError(e)}return!1!==r&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("atrule"===n.type&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if("atrule"===n.type&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("atrule"===e.type)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if("comment"===t.type)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("decl"===n.type&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if("decl"===n.type&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("decl"===e.type)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if("rule"===n.type&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if("rule"===n.type&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if("rule"===e.type)return t(e,n)}))}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]}};Ss.registerParse=e=>{hs=e},Ss.registerRule=e=>{ps=e},Ss.registerAtRule=e=>{fs=e},Ss.registerRoot=e=>{vs=e};var ks=Ss;Ss.default=Ss,Ss.rebuild=e=>{"atrule"===e.type?Object.setPrototypeOf(e,fs.prototype):"rule"===e.type?Object.setPrototypeOf(e,ps.prototype):"decl"===e.type?Object.setPrototypeOf(e,_s.prototype):"comment"===e.type?Object.setPrototypeOf(e,ys.prototype):"root"===e.type&&Object.setPrototypeOf(e,vs.prototype),e[ms]=!0,e.nodes&&e.nodes.forEach(e=>{Ss.rebuild(e)})};var xs,Is,Ts=ks,Es=class extends Ts{constructor(e){super(n({type:"document"},e)),this.nodes||(this.nodes=[])}toResult(e){return void 0===e&&(e={}),new xs(new Is,this,e).stringify()}};Es.registerLazyResult=e=>{xs=e},Es.registerProcessor=e=>{Is=e};var As=Es;Es.default=Es;var Os={},Ms=function(e){Os[e]||(Os[e]=!0,"undefined"!=typeof console&&console.warn&&console.warn(e))},Rs=class{constructor(e,t){if(void 0===t&&(t={}),this.type="warning",this.text=e,t.node&&t.node.source){var n=t.node.rangeBy(t);this.line=n.start.line,this.column=n.start.column,this.endLine=n.end.line,this.endColumn=n.end.column}for(var r in t)this[r]=t[r]}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=Rs;Rs.default=Rs;var Ls=Ps,Ns=class{constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var n=new Ls(e,t);return this.messages.push(n),n}warnings(){return this.messages.filter(e=>"warning"===e.type)}get content(){return this.css}},Ds=Ns;Ns.default=Ns;var Us="'".charCodeAt(0),Bs='"'.charCodeAt(0),Fs="\\".charCodeAt(0),js="/".charCodeAt(0),Ws="\n".charCodeAt(0),Hs=" ".charCodeAt(0),zs="\f".charCodeAt(0),Vs="\t".charCodeAt(0),qs="\r".charCodeAt(0),$s="[".charCodeAt(0),Gs="]".charCodeAt(0),Js="(".charCodeAt(0),Ks=")".charCodeAt(0),Ys="{".charCodeAt(0),Zs="}".charCodeAt(0),Xs=";".charCodeAt(0),Qs="*".charCodeAt(0),eo=":".charCodeAt(0),to="@".charCodeAt(0),no=/[\t\n\f\r "#'()/;[\\\]{}]/g,ro=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,io=/.[\r\n"'(/\\]/,so=/[\da-f]/i,oo=ks,ao=class extends oo{constructor(e){super(e),this.type="atrule"}append(){return this.proxyOf.nodes||(this.nodes=[]),super.append(...arguments)}prepend(){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...arguments)}},lo=ao;ao.default=ao,oo.registerAtRule(ao);var co,uo,ho=ks,po=class extends ho{constructor(e){super(e),this.type="root",this.nodes||(this.nodes=[])}normalize(e,t,n){var r=super.normalize(e);if(t)if("prepend"===n)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(var i of r)i.raws.before=t.raws.before;return r}removeChild(e,t){var n=this.index(e);return!t&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e){return void 0===e&&(e={}),new co(new uo,this,e).stringify()}};po.registerLazyResult=e=>{co=e},po.registerProcessor=e=>{uo=e};var fo=po;po.default=po,ho.registerRoot(po);var vo={comma:e=>vo.split(e,[","],!0),space:e=>vo.split(e,[" ","\n","\t"]),split(e,t,n){var r=[],i="",s=!1,o=0,a=!1,l="",c=!1;for(var u of e)c?c=!1:"\\"===u?c=!0:a?u===l&&(a=!1):'"'===u||"'"===u?(a=!0,l=u):"("===u?o+=1:")"===u?o>0&&(o-=1):0===o&&t.includes(u)&&(s=!0),s?(""!==i&&r.push(i.trim()),i="",s=!1):i+=u;return(n||""!==i)&&r.push(i.trim()),r}},go=vo;vo.default=vo;var mo=ks,_o=go,yo=class extends mo{constructor(e){super(e),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return _o.comma(this.selector)}set selectors(e){var t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(n)}},bo=yo;yo.default=yo,mo.registerRule(yo);var wo=Ti,Co=function(e,t){void 0===t&&(t={});var n,r,i,s,o,a,l,c,u,d,h=e.css.valueOf(),p=t.ignoreErrors,f=h.length,v=0,g=[],m=[];function _(t){throw e.error("Unclosed "+t,v)}return{back:function(e){m.push(e)},endOfFile:function(){return 0===m.length&&v>=f},nextToken:function(e){if(m.length)return m.pop();if(!(v>=f)){var t=!!e&&e.ignoreUnclosed;switch(n=h.charCodeAt(v)){case Ws:case Hs:case Vs:case qs:case zs:r=v;do{r+=1,n=h.charCodeAt(r)}while(n===Hs||n===Ws||n===Vs||n===qs||n===zs);d=["space",h.slice(v,r)],v=r-1;break;case $s:case Gs:case Ys:case Zs:case eo:case Xs:case Ks:var y=String.fromCharCode(n);d=[y,y,v];break;case Js:if(c=g.length?g.pop()[1]:"",u=h.charCodeAt(v+1),"url"===c&&u!==Us&&u!==Bs&&u!==Hs&&u!==Ws&&u!==Vs&&u!==zs&&u!==qs){r=v;do{if(a=!1,-1===(r=h.indexOf(")",r+1))){if(p||t){r=v;break}_("bracket")}for(l=r;h.charCodeAt(l-1)===Fs;)l-=1,a=!a}while(a);d=["brackets",h.slice(v,r+1),v,r],v=r}else r=h.indexOf(")",v+1),s=h.slice(v,r+1),-1===r||io.test(s)?d=["(","(",v]:(d=["brackets",s,v,r],v=r);break;case Us:case Bs:i=n===Us?"'":'"',r=v;do{if(a=!1,-1===(r=h.indexOf(i,r+1))){if(p||t){r=v+1;break}_("string")}for(l=r;h.charCodeAt(l-1)===Fs;)l-=1,a=!a}while(a);d=["string",h.slice(v,r+1),v,r],v=r;break;case to:no.lastIndex=v+1,no.test(h),r=0===no.lastIndex?h.length-1:no.lastIndex-2,d=["at-word",h.slice(v,r+1),v,r],v=r;break;case Fs:for(r=v,o=!0;h.charCodeAt(r+1)===Fs;)r+=1,o=!o;if(n=h.charCodeAt(r+1),o&&n!==js&&n!==Hs&&n!==Ws&&n!==Vs&&n!==qs&&n!==zs&&(r+=1,so.test(h.charAt(r)))){for(;so.test(h.charAt(r+1));)r+=1;h.charCodeAt(r+1)===Hs&&(r+=1)}d=["word",h.slice(v,r+1),v,r],v=r;break;default:n===js&&h.charCodeAt(v+1)===Qs?(0===(r=h.indexOf("*/",v+2)+1)&&(p||t?r=h.length:_("comment")),d=["comment",h.slice(v,r+1),v,r],v=r):(ro.lastIndex=v+1,ro.test(h),r=0===ro.lastIndex?h.length-1:ro.lastIndex-2,d=["word",h.slice(v,r+1),v,r],g.push(d),v=r)}return v++,d}},position:function(){return v}}},So=ds,ko=lo,xo=fo,Io=bo,To={empty:!0,space:!0};var Eo=class{constructor(e){this.input=e,this.root=new xo,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){var t,n,r,i=new ko;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);for(var s=!1,o=!1,a=[],l=[];!this.tokenizer.endOfFile();){if("("===(t=(e=this.tokenizer.nextToken())[0])||"["===t?l.push("("===t?")":"]"):"{"===t&&l.length>0?l.push("}"):t===l[l.length-1]&&l.pop(),0===l.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){o=!0;break}if("}"===t){if(a.length>0){for(n=a[r=a.length-1];n&&"space"===n[0];)n=a[--r];n&&(i.source.end=this.getPosition(n[3]||n[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){s=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),s&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),o&&(i.nodes=[],this.current=i)}checkMissedSemicolon(e){var t=this.colon(e);if(!1!==t){for(var n,r=0,i=t-1;i>=0&&("space"===(n=e[i])[0]||2!==(r+=1));i--);throw this.input.error("Missed semicolon","word"===n[0]?n[3]+1:n[2])}}colon(e){var t,n,r,i=0;for(var[s,o]of e.entries()){if("("===(n=(t=o)[0])&&(i+=1),")"===n&&(i-=1),0===i&&":"===n){if(r){if("word"===r[0]&&"progid"===r[1])continue;return s}this.doubleColon(t)}r=t}return!1}comment(e){var t=new So;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;var n=e[1].slice(2,-2);if(/^\s*$/.test(n))t.text="",t.raws.left=n,t.raws.right="";else{var r=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=r[2],t.raws.left=r[1],t.raws.right=r[3]}}createTokenizer(){this.tokenizer=Co(this.input)}decl(e,t){var n=new wo;this.init(n,e[0][2]);var r,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(i[3]||i[2]||function(e){for(var t=e.length-1;t>=0;t--){var n=e[t],r=n[3]||n[2];if(r)return r}}(e)),n.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop="";e.length;){var s=e[0][0];if(":"===s||"space"===s||"comment"===s)break;n.prop+=e.shift()[1]}for(n.raws.between="";e.length;){if(":"===(r=e.shift())[0]){n.raws.between+=r[1];break}"word"===r[0]&&/\w/.test(r[1])&&this.unknownWord([r]),n.raws.between+=r[1]}"_"!==n.prop[0]&&"*"!==n.prop[0]||(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));for(var o,a=[];e.length&&("space"===(o=e[0][0])||"comment"===o);)a.push(e.shift());this.precheckMissedSemicolon(e);for(var l=e.length-1;l>=0;l--){if("!important"===(r=e[l])[1].toLowerCase()){n.important=!0;var c=this.stringFrom(e,l);" !important"!==(c=this.spacesFromEnd(e)+c)&&(n.raws.important=c);break}if("important"===r[1].toLowerCase()){for(var u=e.slice(0),d="",h=l;h>0;h--){var p=u[h][0];if(0===d.trim().indexOf("!")&&"space"!==p)break;d=u.pop()[1]+d}0===d.trim().indexOf("!")&&(n.important=!0,n.raws.important=d,e=u)}if("space"!==r[0]&&"comment"!==r[0])break}var f=e.some(e=>"space"!==e[0]&&"comment"!==e[0]);f&&(n.raws.between+=a.map(e=>e[1]).join(""),a=[]),this.raw(n,"value",a.concat(e),t),n.value.includes(":")&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){var t=new Io;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t}end(e){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(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}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(e){if(this.spaces+=e[1],this.current.nodes){var t=this.current.nodes[this.current.nodes.length-1];t&&"rule"===t.type&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){var t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)}other(e){for(var t=!1,n=null,r=!1,i=null,s=[],o=e[1].startsWith("--"),a=[],l=e;l;){if(n=l[0],a.push(l),"("===n||"["===n)i||(i=l),s.push("("===n?")":"]");else if(o&&r&&"{"===n)i||(i=l),s.push("}");else if(0===s.length){if(";"===n){if(r)return void this.decl(a,o);break}if("{"===n)return void this.rule(a);if("}"===n){this.tokenizer.back(a.pop()),t=!0;break}":"===n&&(r=!0)}else n===s[s.length-1]&&(s.pop(),0===s.length&&(i=null));l=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),s.length>0&&this.unclosedBracket(i),t&&r){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 e;!this.tokenizer.endOfFile();)switch((e=this.tokenizer.nextToken())[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){for(var i,s,o,a,l=n.length,c="",u=!0,d=0;d<l;d+=1)"space"!==(s=(i=n[d])[0])||d!==l-1||r?"comment"===s?(a=n[d-1]?n[d-1][0]:"empty",o=n[d+1]?n[d+1][0]:"empty",To[a]||To[o]||","===c.slice(-1)?u=!1:c+=i[1]):c+=i[1]:u=!1;if(!u){var h=n.reduce((e,t)=>e+t[1],"");e.raws[t]={raw:h,value:c}}e[t]=c}rule(e){e.pop();var t=new Io;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t}spacesAndCommentsFromEnd(e){for(var t,n="";e.length&&("space"===(t=e[e.length-1][0])||"comment"===t);)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){for(var t,n="";e.length&&("space"===(t=e[0][0])||"comment"===t);)n+=e.shift()[1];return n}spacesFromEnd(e){for(var t="";e.length&&"space"===e[e.length-1][0];)t=e.pop()[1]+t;return t}stringFrom(e,t){for(var n="",r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){var e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)}unclosedBracket(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})}},Ao=ks,Oo=Eo,Mo=Zi;function Ro(e,t){var n=new Mo(e,t),r=new Oo(n);try{r.parse()}catch(e){throw"production"!==process.env.NODE_ENV&&"CssSyntaxError"===e.name&&t&&t.from&&(/\.scss$/i.test(t.from)?e.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.sass/i.test(t.from)?e.message+="\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser":/\.less$/i.test(t.from)&&(e.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),e}return r.root}var Po=Ro;Ro.default=Ro,Ao.registerParse(Ro);var{isClean:Lo,my:No}=ui,Do=ls,Uo=gi,Bo=ks,Fo=As,jo=Ms,Wo=Ds,Ho=Po,zo=fo,Vo={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},$o={Once:!0,postcssPlugin:!0,prepare:!0};function Go(e){return"object"==typeof e&&"function"==typeof e.then}function Jo(e){var t=!1,n=Vo[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[n,n+"-"+t,0,n+"Exit",n+"Exit-"+t]:t?[n,n+"-"+t,n+"Exit",n+"Exit-"+t]:e.append?[n,0,n+"Exit"]:[n,n+"Exit"]}function Ko(e){return{eventIndex:0,events:"document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:Jo(e),iterator:0,node:e,visitorIndex:0,visitors:[]}}function Yo(e){return e[Lo]=!1,e.nodes&&e.nodes.forEach(e=>Yo(e)),e}var Zo={},Xo=class e{constructor(t,r,i){var s;if(this.stringified=!1,this.processed=!1,"object"!=typeof r||null===r||"root"!==r.type&&"document"!==r.type)if(r instanceof e||r instanceof Wo)s=Yo(r.root),r.map&&(void 0===i.map&&(i.map={}),i.map.inline||(i.map.inline=!1),i.map.prev=r.map);else{var o=Ho;i.syntax&&(o=i.syntax.parse),i.parser&&(o=i.parser),o.parse&&(o=o.parse);try{s=o(r,i)}catch(e){this.processed=!0,this.error=e}s&&!s[No]&&Bo.rebuild(s)}else s=Yo(r);this.result=new Wo(t,s,i),this.helpers=n({},Zo,{postcss:Zo,result:this.result}),this.plugins=this.processor.plugins.map(e=>"object"==typeof e&&e.prepare?n({},e,e.prepare(this.result)):e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(e,t){var n=this.result.lastPlugin;try{if(t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin){if(n.postcssVersion&&"production"!==process.env.NODE_ENV){var r=n.postcssPlugin,i=n.postcssVersion,s=this.result.processor.version,o=i.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 "+r+" uses "+i+". Perhaps this is the source of the error below.")}}else e.plugin=n.postcssPlugin,e.setMessage()}catch(e){console&&console.error&&console.error(e)}return e}prepareVisitors(){this.listeners={};var e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(var t of this.plugins)if("object"==typeof t)for(var n in t){if(!qo[n]&&/^[A-Z]/.test(n))throw new Error("Unknown event "+n+" in "+t.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!$o[n])if("object"==typeof t[n])for(var r in t[n])e(t,"*"===r?n:n+"-"+r.toLowerCase(),t[n][r]);else"function"==typeof t[n]&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}runAsync(){var e=this;return t(function*(){e.plugin=0;for(var t=0;t<e.plugins.length;t++){var n=e.plugins[t],r=e.runOnRoot(n);if(Go(r))try{yield r}catch(t){throw e.handleError(t)}}if(e.prepareVisitors(),e.hasListener){for(var i=e.result.root;!i[Lo];){i[Lo]=!0;for(var s=[Ko(i)];s.length>0;){var o=e.visitTick(s);if(Go(o))try{yield o}catch(t){var a=s[s.length-1].node;throw e.handleError(t,a)}}}if(e.listeners.OnceExit){var l=function*(t){e.result.lastPlugin=c;try{if("document"===i.type){var n=i.nodes.map(n=>t(n,e.helpers));yield Promise.all(n)}else yield t(i,e.helpers)}catch(t){throw e.handleError(t)}};for(var[c,u]of e.listeners.OnceExit)yield*l(u)}}return e.processed=!0,e.stringify()})()}runOnRoot(e){this.result.lastPlugin=e;try{if("object"==typeof e&&e.Once){if("document"===this.result.root.type){var t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return Go(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(e){throw this.handleError(e)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=Uo;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var n=new Do(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[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 e of this.plugins){if(Go(this.runOnRoot(e)))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var t=this.result.root;!t[Lo];)t[Lo]=!0,this.walkSync(t);if(this.listeners.OnceExit)if("document"===t.type)for(var n of t.nodes)this.visitSync(this.listeners.OnceExit,n);else this.visitSync(this.listeners.OnceExit,t)}return this.result}then(e,t){return"production"!==process.env.NODE_ENV&&("from"in this.opts||jo("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(e,t)}toString(){return this.css}visitSync(e,t){for(var[n,r]of e){this.result.lastPlugin=n;var i=void 0;try{i=r(t,this.helpers)}catch(e){throw this.handleError(e,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(Go(i))throw this.getAsyncError()}}visitTick(e){var t=e[e.length-1],{node:n,visitors:r}=t;if("root"===n.type||"document"===n.type||n.parent){if(r.length>0&&t.visitorIndex<r.length){var[i,s]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=i;try{return s(n.toProxy(),this.helpers)}catch(e){throw this.handleError(e,n)}}if(0!==t.iterator){for(var o,a=t.iterator;o=n.nodes[n.indexes[a]];)if(n.indexes[a]+=1,!o[Lo])return o[Lo]=!0,void e.push(Ko(o));t.iterator=0,delete n.indexes[a]}for(var l=t.events;t.eventIndex<l.length;){var c=l[t.eventIndex];if(t.eventIndex+=1,0===c)return void(n.nodes&&n.nodes.length&&(n[Lo]=!0,t.iterator=n.getIterator()));if(this.listeners[c])return void(t.visitors=this.listeners[c])}e.pop()}else e.pop()}walkSync(e){e[Lo]=!0;var t=Jo(e);for(var n of t)if(0===n)e.nodes&&e.each(e=>{e[Lo]||this.walkSync(e)});else{var r=this.listeners[n];if(r&&this.visitSync(r,e.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"}};Xo.registerPostcss=e=>{Zo=e};var Qo=Xo;Xo.default=Xo,zo.registerLazyResult(Xo),Fo.registerLazyResult(Xo);var ea=ls,ta=gi,na=Ms,ra=Po,ia=Ds,sa=class{constructor(e,t,n){var r;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=n,this._map=void 0;var i=ta;this.result=new ia(this._processor,r,this._opts),this.result.css=t;var s=this;Object.defineProperty(this.result,"root",{get:()=>s.root});var o=new ea(i,r,this._opts,t);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(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){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(e,t)}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 e,t=ra;try{e=t(this._css,this._opts)}catch(e){this.error=e}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}},oa=sa;sa.default=sa;var aa=oa,la=Qo,ca=As,ua=fo,da=class{constructor(e){void 0===e&&(e=[]),this.version="8.4.38",this.plugins=this.normalize(e)}normalize(e){var t=[];for(var n of e)if(!0===n.postcss?n=n():n.postcss&&(n=n.postcss),"object"==typeof n&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if("object"==typeof n&&n.postcssPlugin)t.push(n);else if("function"==typeof n)t.push(n);else{if("object"!=typeof n||!n.parse&&!n.stringify)throw new Error(n+" 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 t}process(e,t){return void 0===t&&(t={}),this.plugins.length||t.parser||t.stringifier||t.syntax?new la(this,e,t):new aa(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}},ha=da;da.default=da,ua.registerProcessor(da),ca.registerProcessor(da);var pa=Ti,fa=Di,va=ds,ga=lo,ma=Zi,_a=fo,ya=bo;function ba(e,t){if(Array.isArray(e))return e.map(e=>ba(e));var{inputs:i}=e,s=r(e,a);if(i)for(var o of(t=[],i)){var c=n({},o,{__proto__:ma.prototype});c.map&&(c.map=n({},c.map,{__proto__:fa.prototype})),t.push(c)}if(s.nodes&&(s.nodes=e.nodes.map(e=>ba(e,t))),s.source){var u=s.source,{inputId:d}=u,h=r(u,l);s.source=h,null!=d&&(s.source.input=t[d])}if("root"===s.type)return new _a(s);if("decl"===s.type)return new pa(s);if("rule"===s.type)return new ya(s);if("comment"===s.type)return new va(s);if("atrule"===s.type)return new ga(s);throw new Error("Unknown node type: "+e.type)}var wa=ba;ba.default=ba;var Ca=ci,Sa=Ti,ka=Qo,xa=ks,Ia=ha,Ta=gi,Ea=wa,Aa=As,Oa=Ps,Ma=ds,Ra=lo,Pa=Ds,La=Zi,Na=Po,Da=go,Ua=bo,Ba=fo,Fa=ki;function ja(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),new Ia(t)}ja.plugin=function(e,t){var n,r=!1;function i(){console&&console.warn&&!r&&(r=!0,console.warn(e+": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226"));var n=t(...arguments);return n.postcssPlugin=e,n.postcssVersion=(new Ia).version,n}return Object.defineProperty(i,"postcss",{get:()=>(n||(n=i()),n)}),i.process=function(e,t,n){return ja([i(n)]).process(e,t)},i},ja.stringify=Ta,ja.parse=Na,ja.fromJSON=Ea,ja.list=Da,ja.comment=e=>new Ma(e),ja.atRule=e=>new Ra(e),ja.decl=e=>new Sa(e),ja.rule=e=>new Ua(e),ja.root=e=>new Ba(e),ja.document=e=>new Aa(e),ja.CssSyntaxError=Ca,ja.Declaration=Sa,ja.Container=xa,ja.Processor=Ia,ja.Document=Aa,ja.Comment=Ma,ja.Warning=Oa,ja.AtRule=Ra,ja.Result=Pa,ja.Input=La,ja.Rule=Ua,ja.Root=Ba,ja.Node=Fa,ka.registerPostcss(ja);var Wa=ja;ja.default=ja;var Ha=Qr(Wa);Ha.stringify,Ha.fromJSON,Ha.plugin,Ha.parse,Ha.list,Ha.document,Ha.comment,Ha.atRule,Ha.rule,Ha.decl,Ha.root,Ha.CssSyntaxError,Ha.Declaration,Ha.Container,Ha.Processor,Ha.Document,Ha.Comment,Ha.Warning,Ha.AtRule,Ha.Result,Ha.Input,Ha.Rule,Ha.Root,Ha.Node;class za{constructor(){Xr(this,"parentElement",null),Xr(this,"parentNode",null),Xr(this,"ownerDocument"),Xr(this,"firstChild",null),Xr(this,"lastChild",null),Xr(this,"previousSibling",null),Xr(this,"nextSibling",null),Xr(this,"ELEMENT_NODE",1),Xr(this,"TEXT_NODE",3),Xr(this,"nodeType"),Xr(this,"nodeName"),Xr(this,"RRNodeType")}get childNodes(){for(var e=[],t=this.firstChild;t;)e.push(t),t=t.nextSibling;return e}contains(e){if(!(e instanceof za))return!1;if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}var Va={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},qa={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},$a={};function Ga(e){if($a[e])return $a[e];var t=globalThis[e],n=t.prototype,r=e in Va?Va[e]:void 0,i=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),s=e in qa?qa[e]:void 0,o=Boolean(s&&s.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(i&&o&&!globalThis.Zone)return $a[e]=t.prototype,t.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var l=a.contentWindow;if(!l)return t.prototype;var c=l[e].prototype;return document.body.removeChild(a),c?$a[e]=c:n}catch(e){return n}}var Ja={};function Ka(e,t,n){var r,i=e+"."+String(n);if(Ja[i])return Ja[i].call(t);var s=Ga(e),o=null==(r=Object.getOwnPropertyDescriptor(s,n))?void 0:r.get;return o?(Ja[i]=o,o.call(t)):t[n]}var Ya={};function Za(e,t,n){var r=e+"."+String(n);if(Ya[r])return Ya[r].bind(t);var i=Ga(e)[n];return"function"!=typeof i?t[n]:(Ya[r]=i,i.bind(t))}function Xa(){return Ga("MutationObserver").constructor}function Qa(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch(e){return()=>{}}}var el={ownerDocument:function(e){return Ka("Node",e,"ownerDocument")},childNodes:function(e){return Ka("Node",e,"childNodes")},parentNode:function(e){return Ka("Node",e,"parentNode")},parentElement:function(e){return Ka("Node",e,"parentElement")},textContent:function(e){return Ka("Node",e,"textContent")},contains:function(e,t){return Za("Node",e,"contains")(t)},getRootNode:function(e){return Za("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?Ka("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?Ka("Element",e,"shadowRoot"):null},querySelector:function(e,t){return Ka("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return Ka("Element",e,"querySelectorAll")(t)},mutationObserver:Xa,patch:Qa};function tl(e,t,n){void 0===n&&(n=document);var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}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 il(e,t,n){void 0===n&&(n={});var r=null,i=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();i||!1!==n.leading||(i=l);var c=t-(l-i),u=this;c<=0||c>t?(r&&(clearTimeout(r),r=null),i=l,e.apply(u,o)):r||!1===n.trailing||(r=setTimeout(()=>{i=!1===n.leading?0:Date.now(),r=null,e.apply(u,o)},c))}}function sl(e,t,n,r,i){void 0===i&&(i=window);var s=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),s&&s.set&&s.set.call(this,e)}}),()=>sl(e,t,s||{},!0)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(rl=new Proxy(rl,{get:(e,t,n)=>("map"===t&&console.error(nl),Reflect.get(e,t,n))}));var ol=Date.now;function al(e){var t,n,r,i,s=e.document;return{left:s.scrollingElement?s.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:s.documentElement.scrollLeft||(null==s?void 0:s.body)&&(null==(t=el.parentElement(s.body))?void 0:t.scrollLeft)||(null==(n=null==s?void 0:s.body)?void 0:n.scrollLeft)||0,top:s.scrollingElement?s.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==s?void 0:s.documentElement.scrollTop)||(null==s?void 0:s.body)&&(null==(r=el.parentElement(s.body))?void 0:r.scrollTop)||(null==(i=null==s?void 0:s.body)?void 0:i.scrollTop)||0}}function ll(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function cl(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function ul(e){return e?e.nodeType===e.ELEMENT_NODE?e:el.parentElement(e):null}function dl(e,t,n,r){if(!e)return!1;var i=ul(e);if(!i)return!1;try{if("string"==typeof t){if(i.classList.contains(t))return!0;if(r&&null!==i.closest("."+t))return!0}else if(te(i,t,r))return!0}catch(e){}if(n){if(i.matches(n))return!0;if(r&&null!==i.closest(n))return!0}return!1}function hl(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function pl(e,t){if(x(e))return!1;var n=t.getId(e);if(!t.has(n))return!0;var r=el.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||pl(r,t))}function fl(e){return Boolean(e.changedTouches)}function vl(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function gl(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ml(e){return!!e&&(e instanceof za&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(el.shadowRoot(e)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(ol=()=>(new Date).getTime());class _l{constructor(){d(this,"id",1),d(this,"styleIDMap",new WeakMap),d(this,"idStyleMap",new Map)}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){return this.has(e)?this.getId(e):(n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n);var n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function yl(e){var t,n=null;return"getRootNode"in e&&(null==(t=el.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&el.host(el.getRootNode(e))&&(n=el.host(el.getRootNode(e))),n}function bl(e){var t=el.ownerDocument(e);if(!t)return!1;var n=function(e){for(var t,n=e;t=yl(n);)n=t;return n}(e);return el.contains(t,n)}function wl(e){var t=el.ownerDocument(e);return!!t&&(el.contains(t,e)||bl(e))}var Cl=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Cl||{}),Sl=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(Sl||{}),kl=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(kl||{}),xl=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(xl||{}),Il=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Il||{}),Tl=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(Tl||{}),El=(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(El||{});function Al(e){return"__ln"in e}class Ol{constructor(){d(this,"length",0),d(this,"head",null),d(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){var t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Al(e.previousSibling)){var n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Al(e.nextSibling)&&e.nextSibling.__ln.previous){var r=e.nextSibling.__ln.previous;t.previous=r,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,r&&(r.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){var t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}var Ml,Rl=(e,t)=>e+"@"+t;class Pl{constructor(){d(this,"frozen",!1),d(this,"locked",!1),d(this,"texts",[]),d(this,"attributes",[]),d(this,"attributeMap",new WeakMap),d(this,"removes",[]),d(this,"mapRemoves",[]),d(this,"movedMap",{}),d(this,"addedSet",new Set),d(this,"movedSet",new Set),d(this,"droppedSet",new Set),d(this,"removesSubTreeCache",new Set),d(this,"mutationCb"),d(this,"blockClass"),d(this,"blockSelector"),d(this,"maskTextClass"),d(this,"maskTextSelector"),d(this,"inlineStylesheet"),d(this,"maskInputOptions"),d(this,"maskTextFn"),d(this,"maskInputFn"),d(this,"keepIframeSrcFn"),d(this,"recordCanvas"),d(this,"inlineImages"),d(this,"slimDOMOptions"),d(this,"dataURLOptions"),d(this,"doc"),d(this,"mirror"),d(this,"iframeManager"),d(this,"stylesheetManager"),d(this,"shadowDomManager"),d(this,"canvasManager"),d(this,"processedNodeManager"),d(this,"unattachedDoc"),d(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),d(this,"emit",()=>{if(!this.frozen&&!this.locked){for(var e=[],t=new Set,n=new Ol,r=e=>{for(var t=e,n=-2;-2===n;)n=(t=t&&t.nextSibling)&&this.mirror.getId(t);return n},i=i=>{var s=el.parentNode(i);if(s&&wl(i)){var o=!1;if(i.nodeType===Node.TEXT_NODE){var a=s.tagName;if("TEXTAREA"===a)return;"STYLE"===a&&this.addedSet.has(s)&&(o=!0)}var l=x(s)?this.mirror.getId(yl(i)):this.mirror.getId(s),c=r(i);if(-1===l||-1===c)return n.addNode(i);var u=oe(i,{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:e=>{vl(e,this.mirror)&&this.iframeManager.addIframe(e),gl(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ml(i)&&this.shadowDomManager.addShadowRoot(el.shadowRoot(i),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:o});u&&(e.push({parentId:l,nextId:c,node:u}),t.add(u.id))}};this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(var s of this.movedSet)Nl(this.removesSubTreeCache,s,this.mirror)&&!this.movedSet.has(el.parentNode(s))||i(s);for(var o of this.addedSet)Dl(this.droppedSet,o)||Nl(this.removesSubTreeCache,o,this.mirror)?Dl(this.movedSet,o)?i(o):this.droppedSet.add(o):i(o);for(var a=null;n.length;){var l=null;if(a){var c=this.mirror.getId(el.parentNode(a.value)),u=r(a.value);-1!==c&&-1!==u&&(l=a)}if(!l)for(var d=n.tail;d;){var h=d;if(d=d.previous,h){var p=this.mirror.getId(el.parentNode(h.value));if(-1===r(h.value))continue;if(-1!==p){l=h;break}var f=h.value,v=el.parentNode(f);if(v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE){var g=el.host(v);if(-1!==this.mirror.getId(g)){l=h;break}}}}if(!l){for(;n.head;)n.removeNode(n.head.value);break}a=l.previous,n.removeNode(l.value),i(l.value)}var m={texts:this.texts.map(e=>{var t=e.node,n=el.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{var{attributes:t}=e;if("string"==typeof t.style){var n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(m.texts.length||m.attributes.length||m.removes.length||m.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(m))}}),d(this,"genTextAreaValueMutation",e=>{var t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));var n=Array.from(el.childNodes(e),e=>el.textContent(e)||"").join("");t.attributes.value=O({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:P(e),value:n,maskInputFn:this.maskInputFn})}),d(this,"processMutation",e=>{if(!hl(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":var t=el.textContent(e.target);dl(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:ne(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,ul(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break;case"attributes":var n=e.target,r=e.attributeName,i=e.target.getAttribute(r);if("value"===r){var s=P(n);i=O({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:s,value:i,maskInputFn:this.maskInputFn})}if(dl(e.target,this.blockClass,this.blockSelector,!1)||i===e.oldValue)return;var o=this.attributeMap.get(e.target);if("IFRAME"===n.tagName&&"src"===r&&!this.keepIframeSrcFn(i)){if(n.contentDocument)return;r="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o),this.attributeMap.set(e.target,o)),"type"===r&&"INPUT"===n.tagName&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!ee(n.tagName,r))if(o.attributes[r]=Q(this.doc,M(n.tagName),M(r),i),"style"===r){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}var a=this.unattachedDoc.createElement("span");for(var l of(e.oldValue&&a.setAttribute("style",e.oldValue),Array.from(n.style))){var c=n.style.getPropertyValue(l),u=n.style.getPropertyPriority(l);c!==a.style.getPropertyValue(l)||u!==a.style.getPropertyPriority(l)?o.styleDiff[l]=""===u?c:[c,u]:o._unchangedStyles[l]=[c,u]}for(var d of Array.from(a.style))""===n.style.getPropertyValue(d)&&(o.styleDiff[d]=!1)}else"open"===r&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?o.attributes.rr_open_mode="modal":o.attributes.rr_open_mode="non-modal");break;case"childList":if(dl(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{var n=this.mirror.getId(t),r=x(e.target)?this.mirror.getId(el.host(e.target)):this.mirror.getId(e.target);dl(e.target,this.blockClass,this.blockSelector,!1)||hl(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Ll(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||pl(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Rl(n,r)]?Ll(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!x(e.target)||!I(e.target))||void 0}),function(e,t){var n=[e];for(;n.length;){var r=n.pop();t.has(r)||(t.add(r),el.childNodes(r).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),d(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(hl(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);var n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Rl(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);dl(e,this.blockClass,this.blockSelector,!1)||(el.childNodes(e).forEach(e=>this.genAdds(e)),ml(e)&&el.childNodes(el.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}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 Ll(e,t){e.delete(t),el.childNodes(t).forEach(t=>Ll(e,t))}function Nl(e,t,n){return 0!==e.size&&function(e,t){var n=el.parentNode(t);return!!n&&e.has(n)}(e,t)}function Dl(e,t){return 0!==e.size&&Ul(e,t)}function Ul(e,t){var n=el.parentNode(t);return!!n&&(!!e.has(n)||Ul(e,n))}var Bl=e=>{if(!Ml)return e;return function(){try{return e(...arguments)}catch(e){if(Ml&&!0===Ml(e))return;throw e}}},Fl=[];function jl(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function Wl(e,t){var n=new Pl;Fl.push(n),n.init(e);var r=new(Xa())(Bl(n.processMutations.bind(n)));return r.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),r}function Hl(e){var{mouseInteractionCb:t,doc:r,mirror:i,blockClass:s,blockSelector:o,sampling:a}=e;if(!1===a.mouseInteraction)return()=>{};var l=!0===a.mouseInteraction||void 0===a.mouseInteraction?{}:a.mouseInteraction,c=[],u=null;return Object.keys(kl).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==l[e]).forEach(e=>{var a=M(e),l=(e=>r=>{var a=jl(r);if(!dl(a,s,o,!0)){var l=null,c=e;if("pointerType"in r){switch(r.pointerType){case"mouse":l=xl.Mouse;break;case"touch":l=xl.Touch;break;case"pen":l=xl.Pen}l===xl.Touch?kl[e]===kl.MouseDown?c="TouchStart":kl[e]===kl.MouseUp&&(c="TouchEnd"):xl.Pen}else fl(r)&&(l=xl.Touch);null!==l?(u=l,(c.startsWith("Touch")&&l===xl.Touch||c.startsWith("Mouse")&&l===xl.Mouse)&&(l=null)):kl[e]===kl.Click&&(l=u,u=null);var d=fl(r)?r.changedTouches[0]:r;if(d){var h=i.getId(a),{clientX:p,clientY:f}=d;Bl(t)(n({type:kl[c],id:h,x:p,y:f},null!==l&&{pointerType:l}))}}})(e);if(window.PointerEvent)switch(kl[e]){case kl.MouseDown:case kl.MouseUp:a=a.replace("mouse","pointer");break;case kl.TouchStart:case kl.TouchEnd:return}c.push(tl(a,l,r))}),Bl(()=>{c.forEach(e=>e())})}function zl(e){var{scrollCb:t,doc:n,mirror:r,blockClass:i,blockSelector:s,sampling:o}=e;return tl("scroll",Bl(il(Bl(e=>{var o=jl(e);if(o&&!dl(o,i,s,!0)){var a=r.getId(o);if(o===n&&n.defaultView){var l=al(n.defaultView);t({id:a,x:l.left,y:l.top})}else t({id:a,x:o.scrollLeft,y:o.scrollTop})}}),o.scroll||100)),n)}var Vl=["INPUT","TEXTAREA","SELECT"],ql=new WeakMap;function $l(e){return function(e,t){if(Yl("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||Yl("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||Yl("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||Yl("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){var n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){var r=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(r)}return t}(e,[])}function Gl(e,t,n){var r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function Jl(e,t){var n,r,i,{mirror:s,stylesheetManager:o}=e,a=null;a="#document"===t.nodeName?s.getId(t):s.getId(el.host(t));var l="#document"===t.nodeName?null==(n=t.defaultView)?void 0:n.Document:null==(i=null==(r=t.ownerDocument)?void 0:r.defaultView)?void 0:i.ShadowRoot,c=(null==l?void 0:l.prototype)?Object.getOwnPropertyDescriptor(null==l?void 0:l.prototype,"adoptedStyleSheets"):void 0;return null!==a&&-1!==a&&l&&c?(Object.defineProperty(t,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null==(e=c.get)?void 0:e.call(this)},set(e){var t,n=null==(t=c.set)?void 0:t.call(this,e);if(null!==a&&-1!==a)try{o.adoptStyleSheets(e,a)}catch(e){}return n}}),Bl(()=>{Object.defineProperty(t,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function Kl(e,t){void 0===t&&(t={});var r,i=e.doc.defaultView;if(!i)return()=>{};!function(e,t){var{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:s,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p,customElementCb:f}=e;e.mutationCb=function(){t.mutation&&t.mutation(...arguments),n(...arguments)},e.mousemoveCb=function(){t.mousemove&&t.mousemove(...arguments),r(...arguments)},e.mouseInteractionCb=function(){t.mouseInteraction&&t.mouseInteraction(...arguments),i(...arguments)},e.scrollCb=function(){t.scroll&&t.scroll(...arguments),s(...arguments)},e.viewportResizeCb=function(){t.viewportResize&&t.viewportResize(...arguments),o(...arguments)},e.inputCb=function(){t.input&&t.input(...arguments),a(...arguments)},e.mediaInteractionCb=function(){t.mediaInteaction&&t.mediaInteaction(...arguments),l(...arguments)},e.styleSheetRuleCb=function(){t.styleSheetRule&&t.styleSheetRule(...arguments),c(...arguments)},e.styleDeclarationCb=function(){t.styleDeclaration&&t.styleDeclaration(...arguments),u(...arguments)},e.canvasMutationCb=function(){t.canvasMutation&&t.canvasMutation(...arguments),d(...arguments)},e.fontCb=function(){t.font&&t.font(...arguments),h(...arguments)},e.selectionCb=function(){t.selection&&t.selection(...arguments),p(...arguments)},e.customElementCb=function(){t.customElement&&t.customElement(...arguments),f(...arguments)}}(e,t),e.recordDOM&&(r=Wl(e,e.doc));var s=function(e){var{mousemoveCb:t,sampling:n,doc:r,mirror:i}=e;if(!1===n.mousemove)return()=>{};var s,o="number"==typeof n.mousemove?n.mousemove:50,a="number"==typeof n.mousemoveCallback?n.mousemoveCallback:500,l=[],c=il(Bl(e=>{var n=Date.now()-s;t(l.map(e=>(e.timeOffset-=n,e)),e),l=[],s=null}),a),u=Bl(il(Bl(e=>{var t=jl(e),{clientX:n,clientY:r}=fl(e)?e.changedTouches[0]:e;s||(s=ol()),l.push({x:n,y:r,id:i.getId(t),timeOffset:ol()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Sl.Drag:e instanceof MouseEvent?Sl.MouseMove:Sl.TouchMove)}),o,{trailing:!1})),d=[tl("mousemove",u,r),tl("touchmove",u,r),tl("drag",u,r)];return Bl(()=>{d.forEach(e=>e())})}(e),o=Hl(e),a=zl(e),l=function(e,t){var{viewportResizeCb:n}=e,{win:r}=t,i=-1,s=-1;return tl("resize",Bl(il(Bl(()=>{var e=ll(),t=cl();i===e&&s===t||(n({width:Number(t),height:Number(e)}),i=e,s=t)}),200)),r)}(e,{win:i}),c=function(e){var{inputCb:t,doc:r,mirror:i,blockClass:s,blockSelector:o,ignoreClass:a,ignoreSelector:l,maskInputOptions:c,maskInputFn:u,sampling:d,userTriggeredOnInput:h}=e;function p(e){var t=jl(e),n=e.isTrusted,i=t&&t.tagName;if(t&&"OPTION"===i&&(t=el.parentElement(t)),t&&i&&!(Vl.indexOf(i)<0)&&!dl(t,s,o,!0)&&!(t.classList.contains(a)||l&&t.matches(l))){var d=t.value,p=!1,v=P(t)||"";"radio"===v||"checkbox"===v?p=t.checked:(c[i.toLowerCase()]||c[v])&&(d=O({element:t,maskInputOptions:c,tagName:i,type:v,value:d,maskInputFn:u})),f(t,h?{text:d,isChecked:p,userTriggered:n}:{text:d,isChecked:p});var g=t.name;"radio"===v&&g&&p&&r.querySelectorAll('input[type="radio"][name="'+g+'"]').forEach(e=>{if(e!==t){var n=e.value;f(e,h?{text:n,isChecked:!p,userTriggered:!1}:{text:n,isChecked:!p})}})}}function f(e,r){var s=ql.get(e);if(!s||s.text!==r.text||s.isChecked!==r.isChecked){ql.set(e,r);var o=i.getId(e);Bl(t)(n({},r,{id:o}))}}var v=("last"===d.input?["change"]:["input","change"]).map(e=>tl(e,Bl(p),r)),g=r.defaultView;if(!g)return()=>{v.forEach(e=>e())};var m=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),_=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&v.push(..._.map(e=>sl(e[0],e[1],{set(){Bl(p)({target:this,isTrusted:!1})}},!1,g))),Bl(()=>{v.forEach(e=>e())})}(e),u=function(e){var{mediaInteractionCb:t,blockClass:n,blockSelector:r,mirror:i,sampling:s,doc:o}=e,a=Bl(e=>il(Bl(s=>{var o=jl(s);if(o&&!dl(o,n,r,!0)){var{currentTime:a,volume:l,muted:c,playbackRate:u,loop:d}=o;t({type:e,id:i.getId(o),currentTime:a,volume:l,muted:c,playbackRate:u,loop:d})}}),s.media||500)),l=[tl("play",a(Tl.Play),o),tl("pause",a(Tl.Pause),o),tl("seeked",a(Tl.Seeked),o),tl("volumechange",a(Tl.VolumeChange),o),tl("ratechange",a(Tl.RateChange),o)];return Bl(()=>{l.forEach(e=>e())})}(e),d=()=>{},h=()=>{},p=()=>{},f=()=>{};e.recordDOM&&(d=function(e,t){var{styleSheetRuleCb:n,mirror:r,stylesheetManager:i}=e,{win:s}=t;if(!s.CSSStyleSheet||!s.CSSStyleSheet.prototype)return()=>{};var o=s.CSSStyleSheet.prototype.insertRule;s.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Bl((e,t,s)=>{var[o,a]=s,{id:l,styleId:c}=Gl(t,r,i.styleMirror);return(l&&-1!==l||c&&-1!==c)&&n({id:l,styleId:c,adds:[{rule:o,index:a}]}),e.apply(t,s)})}),s.CSSStyleSheet.prototype.addRule=function(e,t,n){void 0===n&&(n=this.cssRules.length);var r=e+" { "+t+" }";return s.CSSStyleSheet.prototype.insertRule.apply(this,[r,n])};var a,l,c=s.CSSStyleSheet.prototype.deleteRule;s.CSSStyleSheet.prototype.deleteRule=new Proxy(c,{apply:Bl((e,t,s)=>{var[o]=s,{id:a,styleId:l}=Gl(t,r,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&n({id:a,styleId:l,removes:[{index:o}]}),e.apply(t,s)})}),s.CSSStyleSheet.prototype.removeRule=function(e){return s.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},s.CSSStyleSheet.prototype.replace&&(a=s.CSSStyleSheet.prototype.replace,s.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:Bl((e,t,s)=>{var[o]=s,{id:a,styleId:l}=Gl(t,r,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&n({id:a,styleId:l,replace:o}),e.apply(t,s)})})),s.CSSStyleSheet.prototype.replaceSync&&(l=s.CSSStyleSheet.prototype.replaceSync,s.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:Bl((e,t,s)=>{var[o]=s,{id:a,styleId:l}=Gl(t,r,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&n({id:a,styleId:l,replaceSync:o}),e.apply(t,s)})}));var u={};Zl("CSSGroupingRule")?u.CSSGroupingRule=s.CSSGroupingRule:(Zl("CSSMediaRule")&&(u.CSSMediaRule=s.CSSMediaRule),Zl("CSSConditionRule")&&(u.CSSConditionRule=s.CSSConditionRule),Zl("CSSSupportsRule")&&(u.CSSSupportsRule=s.CSSSupportsRule));var d={};return Object.entries(u).forEach(e=>{var[t,s]=e;d[t]={insertRule:s.prototype.insertRule,deleteRule:s.prototype.deleteRule},s.prototype.insertRule=new Proxy(d[t].insertRule,{apply:Bl((e,t,s)=>{var[o,a]=s,{id:l,styleId:c}=Gl(t.parentStyleSheet,r,i.styleMirror);return(l&&-1!==l||c&&-1!==c)&&n({id:l,styleId:c,adds:[{rule:o,index:[...$l(t),a||0]}]}),e.apply(t,s)})}),s.prototype.deleteRule=new Proxy(d[t].deleteRule,{apply:Bl((e,t,s)=>{var[o]=s,{id:a,styleId:l}=Gl(t.parentStyleSheet,r,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&n({id:a,styleId:l,removes:[{index:[...$l(t),o]}]}),e.apply(t,s)})})}),Bl(()=>{s.CSSStyleSheet.prototype.insertRule=o,s.CSSStyleSheet.prototype.deleteRule=c,a&&(s.CSSStyleSheet.prototype.replace=a),l&&(s.CSSStyleSheet.prototype.replaceSync=l),Object.entries(u).forEach(e=>{var[t,n]=e;n.prototype.insertRule=d[t].insertRule,n.prototype.deleteRule=d[t].deleteRule})})}(e,{win:i}),h=Jl(e,e.doc),p=function(e,t){var{styleDeclarationCb:n,mirror:r,ignoreCSSAttributes:i,stylesheetManager:s}=e,{win:o}=t,a=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(a,{apply:Bl((e,t,o)=>{var l,[c,u,d]=o;if(i.has(c))return a.apply(t,[c,u,d]);var{id:h,styleId:p}=Gl(null==(l=t.parentRule)?void 0:l.parentStyleSheet,r,s.styleMirror);return(h&&-1!==h||p&&-1!==p)&&n({id:h,styleId:p,set:{property:c,value:u,priority:d},index:$l(t.parentRule)}),e.apply(t,o)})});var l=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(l,{apply:Bl((e,t,o)=>{var a,[c]=o;if(i.has(c))return l.apply(t,[c]);var{id:u,styleId:d}=Gl(null==(a=t.parentRule)?void 0:a.parentStyleSheet,r,s.styleMirror);return(u&&-1!==u||d&&-1!==d)&&n({id:u,styleId:d,remove:{property:c},index:$l(t.parentRule)}),e.apply(t,o)})}),Bl(()=>{o.CSSStyleDeclaration.prototype.setProperty=a,o.CSSStyleDeclaration.prototype.removeProperty=l})}(e,{win:i}),e.collectFonts&&(f=function(e){var{fontCb:t,doc:n}=e,r=n.defaultView;if(!r)return()=>{};var i=[],s=new WeakMap,o=r.FontFace;r.FontFace=function(e,t,n){var r=new o(e,t,n);return s.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};var a=Qa(n.fonts,"add",function(e){return function(n){return setTimeout(Bl(()=>{var e=s.get(n);e&&(t(e),s.delete(n))}),0),e.apply(this,[n])}});return i.push(()=>{r.FontFace=o}),i.push(a),Bl(()=>{i.forEach(e=>e())})}(e)));var v=function(e){var{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:s}=e,o=!0,a=Bl(()=>{var e=t.getSelection();if(!(!e||o&&(null==e?void 0:e.isCollapsed))){o=e.isCollapsed||!1;for(var a=[],l=e.rangeCount||0,c=0;c<l;c++){var u=e.getRangeAt(c),{startContainer:d,startOffset:h,endContainer:p,endOffset:f}=u;dl(d,r,i,!0)||dl(p,r,i,!0)||a.push({start:n.getId(d),startOffset:h,end:n.getId(p),endOffset:f})}s({ranges:a})}});return a(),tl("selectionchange",a)}(e),g=function(e){var{doc:t,customElementCb:n}=e,r=t.defaultView;return r&&r.customElements?Qa(r.customElements,"define",function(e){return function(t,r,i){try{n({define:{name:t}})}catch(e){console.warn("Custom element callback failed for "+t)}return e.apply(this,[t,r,i])}}):()=>{}}(e),m=[];for(var _ of e.plugins)m.push(_.observer(_.callback,i,_.options));return Bl(()=>{Fl.forEach(e=>e.reset()),null==r||r.disconnect(),s(),o(),a(),l(),c(),u(),d(),h(),p(),f(),v(),g(),m.forEach(e=>e())})}function Yl(e){return void 0!==window[e]}function Zl(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class Xl{constructor(e){d(this,"iframeIdToRemoteIdMap",new WeakMap),d(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=e}getId(e,t,n,r){var i=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e),o=i.get(t);return o||(o=this.generateIdFn(),i.set(t,o),s.set(o,t)),o}getIds(e,t){var n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){var r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;var i=r.get(t);return i||-1}getRemoteIds(e,t){var n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){var t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){var t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Ql{constructor(e){d(this,"iframes",new WeakMap),d(this,"crossOriginIframeMap",new WeakMap),d(this,"crossOriginIframeMirror",new Xl($)),d(this,"crossOriginIframeStyleMirror"),d(this,"crossOriginIframeRootIdMap",new WeakMap),d(this,"mirror"),d(this,"mutationCb"),d(this,"wrappedEmit"),d(this,"loadListener"),d(this,"stylesheetManager"),d(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Xl(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,r;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(n=e.contentWindow)||n.addEventListener("message",this.handleMessage.bind(this))),null==(r=this.loadListener)||r.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){var t=e;if("rrweb"===t.data.type&&t.origin===t.data.origin&&e.source){var n=this.crossOriginIframeMap.get(e.source);if(n){var r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}}}transformCrossOriginEvent(e,t){var n;switch(t.type){case Cl.FullSnapshot:this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);var r=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,r),this.patchRootIdOnNode(t.data.node,r),{timestamp:t.timestamp,type:Cl.IncrementalSnapshot,data:{source:Sl.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Cl.Meta:case Cl.Load:case Cl.DomContentLoaded:return!1;case Cl.Plugin:return t;case Cl.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Cl.IncrementalSnapshot:switch(t.data.source){case Sl.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);var n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Sl.Drag:case Sl.TouchMove:case Sl.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case Sl.ViewportResize:return!1;case Sl.MediaInteraction:case Sl.MouseInteraction:case Sl.Scroll:case Sl.CanvasMutation:case Sl.Input:return this.replaceIds(t.data,e,["id"]),t;case Sl.StyleSheetRule:case Sl.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Sl.Font:return t;case Sl.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case Sl.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(n=t.data.styles)||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,r){for(var i of r)(Array.isArray(t[i])||"number"==typeof t[i])&&(Array.isArray(t[i])?t[i]=e.getIds(n,t[i]):t[i]=e.getId(n,t[i]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===El.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}}class ec{constructor(e){d(this,"shadowDoms",new WeakSet),d(this,"mutationCb"),d(this,"scrollCb"),d(this,"bypassOptions"),d(this,"mirror"),d(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(I(e)&&!this.shadowDoms.has(e)){this.shadowDoms.add(e);var r=Wl(n({},this.bypassOptions,{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push(()=>r.disconnect()),this.restoreHandlers.push(zl(n({},this.bypassOptions,{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(el.host(e))),this.restoreHandlers.push(Jl({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){var n=this;this.restoreHandlers.push(Qa(e.prototype,"attachShadow",function(e){return function(r){var i=e.call(this,r),s=el.shadowRoot(this);return s&&wl(this)&&n.addShadowRoot(s,t),i}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(e){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var tc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",nc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),rc=0;rc<64;rc++)nc[tc.charCodeAt(rc)]=rc;var ic=new Map;var sc=(e,t,n)=>{if(e&&(lc(e,t)||"object"==typeof e)){var r=function(e,t){var n=ic.get(e);return n||(n=new Map,ic.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name),i=r.indexOf(e);return-1===i&&(i=r.length,r.push(e)),i}};function oc(e,t,n){if(e instanceof Array)return e.map(e=>oc(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:function(e){var t,n=new Uint8Array(e),r=n.length,i="";for(t=0;t<r;t+=3)i+=tc[n[t]>>2],i+=tc[(3&n[t])<<4|n[t+1]>>4],i+=tc[(15&n[t+1])<<2|n[t+2]>>6],i+=tc[63&n[t+2]];return r%3==2?i=i.substring(0,i.length-1)+"=":r%3==1&&(i=i.substring(0,i.length-2)+"=="),i}(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[oc(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){var r=e.constructor.name,{src:i}=e;return{rr_type:r,src:i}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}return e instanceof ImageData?{rr_type:e.constructor.name,args:[oc(e.data,t,n),e.width,e.height]}:lc(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:sc(e,t,n)}:e}var ac=(e,t,n)=>e.map(e=>oc(e,t,n)),lc=(e,t)=>{var n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function cc(e,t,n,r){var i=[];try{var s=Qa(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(i){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,t,n,!0)){var l=function(e){return"experimental-webgl"===e?"webgl":e}(i);if("__context"in this||(this.__context=l),r&&["webgl","webgl2"].includes(l))if(o[0]&&"object"==typeof o[0]){var c=o[0];c.preserveDrawingBuffer||(c.preserveDrawingBuffer=!0)}else o.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[i,...o])}});i.push(s)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(e=>e())}}function uc(e,t,n,r,i,s){var o=[],a=Object.getOwnPropertyNames(e),l=function(a){if(["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(a))return 0;try{if("function"!=typeof e[a])return 0;var l=Qa(e,a,function(e){return function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=e.apply(this,l);if(sc(u,s,this),"tagName"in this.canvas&&!dl(this.canvas,r,i,!0)){var d=ac(l,s,this),h={type:t,property:a,args:d};n(this.canvas,h)}return u}});o.push(l)}catch(r){var c=sl(e,a,{set(e){n(this.canvas,{type:t,property:a,args:[e],setter:!0})}});o.push(c)}};for(var c of a)l(c);return o}var dc,hc,pc,fc,vc="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",gc="undefined"!=typeof window&&window.Blob&&new Blob([(dc=vc,Uint8Array.from(atob(dc),e=>e.charCodeAt(0)))],{type:"text/javascript;charset=utf-8"});function mc(e){var t;try{if(!(t=gc&&(window.URL||window.webkitURL).createObjectURL(gc)))throw"";var n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),n}catch(t){return new Worker("data:text/javascript;base64,"+vc,{name:null==e?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}class _c{constructor(e){d(this,"pendingCanvasMutations",new Map),d(this,"rafStamps",{latestId:0,invokeId:null}),d(this,"mirror"),d(this,"mutationCb"),d(this,"resetObservers"),d(this,"frozen",!1),d(this,"locked",!1),d(this,"processMutation",(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});var{sampling:t="all",win:n,blockClass:r,blockSelector:i,recordCanvas:s,dataURLOptions:o}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,i),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,i,{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(e,n,r,i,s){var o=this,a=cc(n,r,i,!0),l=new Map,c=new mc;c.onmessage=e=>{var{id:t}=e.data;if(l.set(t,!1),"base64"in e.data){var{base64:n,type:r,width:i,height:s}=e.data;this.mutationCb({id:t,type:Il["2D"],commands:[{property:"clearRect",args:[0,0,i,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})}};var u,d=1e3/e,h=0,p=e=>{var a;h&&e-h<d?u=requestAnimationFrame(p):(h=e,(a=[],n.document.querySelectorAll("canvas").forEach(e=>{dl(e,r,i,!0)||a.push(e)}),a).forEach(function(){var e=t(function*(e){var t,n=o.mirror.getId(e);if(!l.get(n)&&0!==e.width&&0!==e.height){if(l.set(n,!0),["webgl","webgl2"].includes(e.__context)){var r=e.getContext(e.__context);!1===(null==(t=null==r?void 0:r.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&r.clear(r.COLOR_BUFFER_BIT)}var i=yield createImageBitmap(e);c.postMessage({id:n,bitmap:i,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[i])}});return function(t){return e.apply(this,arguments)}}()),u=requestAnimationFrame(p))};u=requestAnimationFrame(p),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();var r=cc(e,t,n,!1),i=function(e,t,n,r){var i=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype),o=function(s){try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])return 1;var o=Qa(t.CanvasRenderingContext2D.prototype,s,function(i){return function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return dl(this.canvas,n,r,!0)||setTimeout(()=>{var n=ac(a,t,this);e(this.canvas,{type:Il["2D"],property:s,args:n})},0),i.apply(this,a)}});i.push(o)}catch(n){var a=sl(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:Il["2D"],property:s,args:[t],setter:!0})}});i.push(a)}};for(var a of s)o(a);return()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r){var i=[];return i.push(...uc(t.WebGLRenderingContext.prototype,Il.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&i.push(...uc(t.WebGL2RenderingContext.prototype,Il.WebGL2,e,n,r,t)),()=>{i.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){var e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{var n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(!this.frozen&&!this.locked){var n=this.pendingCanvasMutations.get(e);if(n&&-1!==t){var i=n.map(e=>r(e,c)),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:i}),this.pendingCanvasMutations.delete(e)}}}}class yc{constructor(e){d(this,"trackedLinkElements",new WeakSet),d(this,"mutationCb"),d(this,"adoptedStyleSheetCb"),d(this,"styleMirror",new _l),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){var n=this;if(0!==e.length){var r={id:t,styleIds:[]},i=[],s=function(e){var t;n.styleMirror.has(e)?t=n.styleMirror.getId(e):(t=n.styleMirror.add(e),i.push({styleId:t,rules:Array.from(e.rules||CSSRule,(t,n)=>({rule:E(t,e.href),index:n}))})),r.styleIds.push(t)};for(var o of e)s(o);i.length>0&&(r.styles=i),this.adoptedStyleSheetCb(r)}}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}class bc{constructor(){d(this,"nodeMap",new WeakMap),d(this,"active",!1)}inOtherBuffer(e,t){var n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}}var wc=!1;try{if(2!==Array.from([1],e=>2*e)[0]){var Cc=document.createElement("iframe");document.body.appendChild(Cc),Array.from=(null==(i=Cc.contentWindow)?void 0:i.Array.from)||Array.from,document.body.removeChild(Cc)}}catch(e){console.debug("Unable to override Array.from",e)}var Sc,kc,xc=new A;function Ic(e){void 0===e&&(e={});var{emit:t,checkoutEveryNms:r,checkoutEveryNth:i,blockClass:s="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:l=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:d=!0,maskAllInputs:h,maskInputOptions:p,slimDOMOptions:f,maskInputFn:v,maskTextFn:g,hooks:m,packFn:_,sampling:y={},dataURLOptions:b={},mousemoveWait:w,recordDOM:C=!0,recordCanvas:S=!1,recordCrossOriginIframes:k=!1,recordAfter:x=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:T=!1,inlineImages:E=!1,plugins:O,keepIframeSrcFn:M=()=>!1,ignoreCSSAttributes:R=new Set([]),errorHandler:P}=e;Ml=P;var L=!k||window.parent===window,N=!1;if(!L)try{window.parent.document&&(N=!1)}catch(e){N=!0}if(L&&!t)throw new Error("emit function is required");if(!L&&!N)return()=>{};void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),xc.reset();var D,U=!0===h?{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!==p?p:{password:!0},B=se(f);!function(e){void 0===e&&(e=window),"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();var F=0,j=e=>{for(var t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return _&&!N&&(e=_(e)),e};hc=(e,n)=>{var s,o=e;if(o.timestamp=ol(),!(null==(s=Fl[0])?void 0:s.isFrozen())||o.type===Cl.FullSnapshot||o.type===Cl.IncrementalSnapshot&&o.data.source===Sl.Mutation||Fl.forEach(e=>e.unfreeze()),L)null==t||t(j(o),n);else if(N){var a={type:"rrweb",event:j(o),origin:window.location.origin,isCheckout:n};window.parent.postMessage(a,"*")}if(o.type===Cl.FullSnapshot)D=o,F=0;else if(o.type===Cl.IncrementalSnapshot){if(o.data.source===Sl.Mutation&&o.data.isAttachIframe)return;F++;var l=i&&F>=i,c=r&&o.timestamp-D.timestamp>r;(l||c)&&pc(!0)}};var W=e=>{hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.Mutation},e)})},H=e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.Scroll},e)}),z=e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.CanvasMutation},e)}),V=new yc({mutationCb:W,adoptedStyleSheetCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.AdoptedStyleSheet},e)})}),q=new Ql({mirror:xc,mutationCb:W,stylesheetManager:V,recordCrossOriginIframes:k,wrappedEmit:hc});for(var $ of O||[])$.getMirror&&$.getMirror({nodeMirror:xc,crossOriginIframeMirror:q.crossOriginIframeMirror,crossOriginIframeStyleMirror:q.crossOriginIframeStyleMirror});var G=new bc;fc=new _c({recordCanvas:S,mutationCb:z,win:window,blockClass:s,blockSelector:o,mirror:xc,sampling:y.canvas,dataURLOptions:b});var J=new ec({mutationCb:W,scrollCb:H,bypassOptions:{blockClass:s,blockSelector:o,maskTextClass:c,maskTextSelector:u,inlineStylesheet:d,maskInputOptions:U,dataURLOptions:b,maskTextFn:g,maskInputFn:v,recordCanvas:S,inlineImages:E,sampling:y,slimDOMOptions:B,iframeManager:q,stylesheetManager:V,canvasManager:fc,keepIframeSrcFn:M,processedNodeManager:G},mirror:xc});pc=function(e){if(void 0===e&&(e=!1),C){hc({type:Cl.Meta,data:{href:window.location.href,width:cl(),height:ll()}},e),V.reset(),J.init(),Fl.forEach(e=>e.lock());var t=function(e,t){var{mirror:n=new A,blockClass:r="rr-block",blockSelector:i=null,maskTextClass:s="rr-mask",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:h,slimDOM:p=!1,dataURLOptions:f,preserveWhiteSpace:v,onSerialize:g,onIframeLoad:m,iframeLoadTimeout:_,onStylesheetLoad:y,stylesheetLoadTimeout:b,keepIframeSrcFn:w=()=>!1}=t||{};return oe(e,{doc:e,mirror:n,blockClass:r,blockSelector:i,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:d,maskInputFn:h,slimDOMOptions:se(p),dataURLOptions:f,inlineImages:l,recordCanvas:c,preserveWhiteSpace:v,onSerialize:g,onIframeLoad:m,iframeLoadTimeout:_,onStylesheetLoad:y,stylesheetLoadTimeout:b,keepIframeSrcFn:w,newlyAddedElement:!1})}(document,{mirror:xc,blockClass:s,blockSelector:o,maskTextClass:c,maskTextSelector:u,inlineStylesheet:d,maskAllInputs:U,maskTextFn:g,maskInputFn:v,slimDOM:B,dataURLOptions:b,recordCanvas:S,inlineImages:E,onSerialize:e=>{vl(e,xc)&&q.addIframe(e),gl(e,xc)&&V.trackLinkElement(e),ml(e)&&J.addShadowRoot(el.shadowRoot(e),document)},onIframeLoad:(e,t)=>{q.attachIframe(e,t),J.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{V.attachLinkElement(e,t)},keepIframeSrcFn:M});if(!t)return console.warn("Failed to snapshot the document");hc({type:Cl.FullSnapshot,data:{node:t,initialOffset:al(window)}},e),Fl.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&V.adoptStyleSheets(document.adoptedStyleSheets,xc.getId(document))}};try{var K=[],Y=e=>{var t;return Bl(Kl)({mutationCb:W,mousemoveCb:(e,t)=>hc({type:Cl.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.MouseInteraction},e)}),scrollCb:H,viewportResizeCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.ViewportResize},e)}),inputCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.Input},e)}),mediaInteractionCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.MediaInteraction},e)}),styleSheetRuleCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.StyleSheetRule},e)}),styleDeclarationCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.StyleDeclaration},e)}),canvasMutationCb:z,fontCb:e=>hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.Font},e)}),selectionCb:e=>{hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.Selection},e)})},customElementCb:e=>{hc({type:Cl.IncrementalSnapshot,data:n({source:Sl.CustomElement},e)})},blockClass:s,ignoreClass:a,ignoreSelector:l,maskTextClass:c,maskTextSelector:u,maskInputOptions:U,inlineStylesheet:d,sampling:y,recordDOM:C,recordCanvas:S,inlineImages:E,userTriggeredOnInput:I,collectFonts:T,doc:e,maskInputFn:v,maskTextFn:g,keepIframeSrcFn:M,blockSelector:o,slimDOMOptions:B,dataURLOptions:b,mirror:xc,iframeManager:q,stylesheetManager:V,shadowDomManager:J,processedNodeManager:G,canvasManager:fc,ignoreCSSAttributes:R,plugins:(null==(t=null==O?void 0:O.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>hc({type:Cl.Plugin,data:{plugin:e.name,payload:t}})})))||[]},m)};q.addLoadListener(e=>{try{K.push(Y(e.contentDocument))}catch(e){console.warn(e)}});var Z=()=>{pc(),K.push(Y(document)),wc=!0};return["interactive","complete"].includes(document.readyState)?Z():(K.push(tl("DOMContentLoaded",()=>{hc({type:Cl.DomContentLoaded,data:{}}),"DOMContentLoaded"===x&&Z()})),K.push(tl("load",()=>{hc({type:Cl.Load,data:{}}),"load"===x&&Z()},window))),()=>{K.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes("cross-origin")||console.warn(e)}}),G.destroy(),wc=!1,Ml=void 0}}catch(e){console.warn(e)}}Ic.addCustomEvent=(e,t)=>{if(!wc)throw new Error("please add custom event after start recording");hc({type:Cl.Custom,data:{tag:e,payload:t}})},Ic.freezePage=()=>{Fl.forEach(e=>e.freeze())},Ic.takeFullSnapshot=e=>{if(!wc)throw new Error("please take full snapshot after start recording");pc(e)},Ic.mirror=xc,(kc=Sc||(Sc={}))[kc.NotStarted=0]="NotStarted",kc[kc.Running=1]="Running",kc[kc.Stopped=2]="Stopped";var Tc=Object.defineProperty,Ec=(e,t,n)=>((e,t,n)=>t in e?Tc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class Ac{constructor(e){Ec(this,"fileName"),Ec(this,"functionName"),Ec(this,"lineNumber"),Ec(this,"columnNumber"),this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}toString(){var e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?this.functionName+" ("+this.fileName+":"+e+":"+t+")":this.fileName+":"+e+":"+t}}var Oc=/(^|@)\S+:\d+/,Mc=/^\s*at .*(\S+:\d+|\(native\))/m,Rc=/^(eval@)?(\[native code])?$/,Pc={parse:function(e){return e?void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(Mc)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):(console.warn("[console-record-plugin]: Failed to parse error object:",e),[]):[]},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error("Cannot parse given url: "+e);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(e){return e.stack.split("\n").filter(function(e){return!!e.match(Mc)},this).map(function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var t=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),n=t.match(/ (\((.+):(\d+):(\d+)\)$)/),r=(t=n?t.replace(n[0],""):t).split(/\s+/).slice(1),i=this.extractLocation(n?n[1]:r.pop()),s=r.join(" ")||void 0,o=["eval","<anonymous>"].indexOf(i[0])>-1?void 0:i[0];return new Ac({functionName:s,fileName:o,lineNumber:i[1],columnNumber:i[2]})},this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter(function(e){return!e.match(Rc)},this).map(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new Ac({functionName:e});var t=/((.*".+"[^@]*)?[^@]*)(?:@)/,n=e.match(t),r=n&&n[1]?n[1]:void 0,i=this.extractLocation(e.replace(t,""));return new Ac({functionName:r,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)/i,n=e.message.split("\n"),r=[],i=2,s=n.length;i<s;i+=2){var o=t.exec(n[i]);o&&r.push(new Ac({fileName:o[2],lineNumber:parseFloat(o[1])}))}return r},parseOpera10:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,n=e.stacktrace.split("\n"),r=[],i=0,s=n.length;i<s;i+=2){var o=t.exec(n[i]);o&&r.push(new Ac({functionName:o[3]||void 0,fileName:o[2],lineNumber:parseFloat(o[1])}))}return r},parseOpera11:function(e){return e.stack.split("\n").filter(function(e){return!!e.match(Oc)&&!e.match(/^Error created at/)},this).map(function(e){var t=e.split("@"),n=this.extractLocation(t.pop()),r=(t.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Ac({functionName:r,fileName:n[0],lineNumber:n[1],columnNumber:n[2]})},this)}};function Lc(e){if(!e||!e.outerHTML)return"";for(var t="";e.parentElement;){var n=e.localName;if(!n)break;n=n.toLowerCase();var r=e.parentElement,i=[];if(r.children&&r.children.length>0)for(var s=0;s<r.children.length;s++){var o=r.children[s];o.localName&&o.localName.toLowerCase&&o.localName.toLowerCase()===n&&i.push(o)}i.length>1&&(n+=":eq("+i.indexOf(e)+")"),t=n+(t?">"+t:""),e=r}return t}function Nc(e){return"[object Object]"===Object.prototype.toString.call(e)}function Dc(e,t){if(0===t)return!0;var n=Object.keys(e);for(var r of n)if(Nc(e[r])&&Dc(e[r],t-1))return!0;return!1}function Uc(e,t){var n={numOfKeysLimit:50,depthOfLimit:4};Object.assign(n,t);var r=[],i=[];return JSON.stringify(e,function(e,t){if(r.length>0){var s=r.indexOf(this);~s?r.splice(s+1):r.push(this),~s?i.splice(s,1/0,e):i.push(e),~r.indexOf(t)&&(t=r[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,r.indexOf(t)).join(".")+"]")}else r.push(t);if(null===t)return t;if(void 0===t)return"undefined";if(function(e){if(Nc(e)&&Object.keys(e).length>n.numOfKeysLimit)return!0;if("function"==typeof e)return!0;if(Nc(e)&&Dc(e,n.depthOfLimit))return!0;return!1}(t))return function(e){var t=e.toString();n.stringLengthLimit&&t.length>n.stringLengthLimit&&(t=t.slice(0,n.stringLengthLimit)+"...");return t}(t);if("bigint"==typeof t)return t.toString()+"n";if(t instanceof Event){var o={};for(var a in t){var l=t[a];Array.isArray(l)?o[a]=Lc(l.length?l[0]:null):o[a]=l}return o}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t})}var Bc={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 Fc(e,t,n){var r,i=n?Object.assign({},Bc,n):Bc,s=i.logger;if(!s)return()=>{};r="string"==typeof s?t[s]:s;var o=0,a=!1,l=[];if(i.level.includes("error")){var c=t=>{var n=t.message,r=t.error,s=Pc.parse(r).map(e=>e.toString()),o=[Uc(n,i.stringifyOptions)];e({level:"error",trace:s,payload:o})};t.addEventListener("error",c),l.push(()=>{t.removeEventListener("error",c)});var u=t=>{var n,r;t.reason instanceof Error?r=[Uc("Uncaught (in promise) "+(n=t.reason).name+": "+n.message,i.stringifyOptions)]:(n=new Error,r=[Uc("Uncaught (in promise)",i.stringifyOptions),Uc(t.reason,i.stringifyOptions)]);var s=Pc.parse(n).map(e=>e.toString());e({level:"error",trace:s,payload:r})};t.addEventListener("unhandledrejection",u),l.push(()=>{t.removeEventListener("unhandledrejection",u)})}for(var d of i.level)l.push(h(r,d));return()=>{l.forEach(e=>e())};function h(t,n){var r=this;return t[n]?function(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch(e){return()=>{}}}(t,n,t=>function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];if(t.apply(r,l),!("assert"===n&&l[0]||a)){a=!0;try{var u=Pc.parse(new Error).map(e=>e.toString()).splice(1),d=("assert"===n?l.slice(1):l).map(e=>Uc(e,i.stringifyOptions));++o<i.lengthThreshold?e({level:n,trace:u,payload:d}):o===i.lengthThreshold&&e({level:"warn",trace:[],payload:[Uc("The number of log records reached the threshold.")]})}catch(e){t("rrweb logger error:",e,...l)}finally{a=!1}}}):()=>{}}}var jc="undefined"!=typeof window?window:void 0,Wc="undefined"!=typeof globalThis?globalThis:jc,Hc=null==Wc?void 0:Wc.navigator,zc=null==Wc?void 0:Wc.document,Vc=null==Wc?void 0:Wc.location,qc=null==Wc?void 0:Wc.fetch;jc&&zc&&zc.createElement,null==Wc||Wc.XMLHttpRequest,null==Wc||Wc.AbortController;var $c=null==Hc?void 0:Hc.userAgent,Gc=null!=jc?jc:{},Jc=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Jc||{}),Kc=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(Kc||{});function Yc(e){return"string"==typeof e}function Zc(e){return void 0===e}function Xc(e){return null==e}function Qc(e){return Array.isArray(e)}function eu(e){return"function"==typeof e}var tu={none:0,error:1,warn:2,info:3,debug:4},nu="[vTilt]",ru=new Set(["none","error","warn","info","debug"]);function iu(){return"undefined"!=typeof console}function su(e){var t=e.length>0&&"string"==typeof e[0]?e[0]:"",n=t?e.slice(1):e;return[t?nu+":"+t:nu,...n]}var ou="warn",au=!1;var lu=null;function cu(){return lu||(lu={setLevel(e,t){void 0===t&&(t=!1),ou=e,t&&(au=!0)},setLevelFromRemote(e){au||e&&ru.has(e)&&(ou=e)},getLevel:()=>ou,isLockedByInit:()=>au,debug(){if(!(tu[ou]<tu.debug)&&iu()){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.log(...su(t))}},info(){if(!(tu[ou]<tu.info)&&iu()){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.log(...su(t))}},warn(){if(!(tu[ou]<tu.warn)&&iu()){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.warn(...su(t))}},error(){if(!(tu[ou]<tu.error)&&iu()){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.error(...su(t))}}}),lu}function uu(e,t){void 0===t&&(t=!0);var n=void 0!==e.log_level||!!e.debug,r=function(e){return e.log_level&&ru.has(e.log_level)?e.log_level:e.debug?"debug":"warn"}(e);return cu().setLevel(r,t&&n),r}function du(e,t){try{return e()}catch(e){return t}}var hu="x-api-key";function pu(e,t,n){void 0===n&&(n={});var{api_host:r,token:i}=e,s=""+(r?r.replace(/\/+$/gm,""):"")+t;if(n.includeTokenQuery&&i){var o=s.includes("?")?"&":"?";s=""+s+o+"token="+i}return s}function fu(e){return e.token?{[hu]:e.token}:{}}class vu{constructor(){this._events=new Map,this._onceEvents=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>{var n;null===(n=this._events.get(e))||void 0===n||n.delete(t)}}once(e,t){return this._onceEvents.has(e)||this._onceEvents.set(e,new Set),this._onceEvents.get(e).add(t),()=>{var n;null===(n=this._onceEvents.get(e))||void 0===n||n.delete(t)}}emit(e,t){var n,r;null===(n=this._events.get(e))||void 0===n||n.forEach(n=>{try{n(t)}catch(t){cu().error("emitter",'error in event listener for "'+e+'":',t)}});var i=this._onceEvents.get(e);i&&(i.forEach(n=>{try{n(t)}catch(t){cu().error("emitter",'error in once listener for "'+e+'":',t)}}),this._onceEvents.delete(e)),null===(r=this._events.get("*"))||void 0===r||r.forEach(n=>{try{n({event:e,payload:t})}catch(e){cu().error("emitter","error in wildcard listener:",e)}})}off(e){e?(this._events.delete(e),this._onceEvents.delete(e)):(this._events.clear(),this._onceEvents.clear())}listenerCount(e){var t,n,r,i;return(null!==(n=null===(t=this._events.get(e))||void 0===t?void 0:t.size)&&void 0!==n?n:0)+(null!==(i=null===(r=this._onceEvents.get(e))||void 0===r?void 0:r.size)&&void 0!==i?i:0)}hasListeners(e){return this.listenerCount(e)>0}}var gu="sdk:initialized",mu="sdk:config_updated",_u="sdk:remote_config_loaded",yu="consent:updated",bu="event:captured",wu="recording:started",Cu="recording:stopped",Su=0,ku=!1,xu=!1;function Iu(e){(Su+=1)<2||(ku=!0,xu||(xu=!0,cu().warn(e,"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(){Su=0}function Eu(){return ku}var Au="23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ou(e){for(var t=(2<<31-Math.clz32(57))-1,n=Math.ceil(1.6*t*e/57),r="";r.length<e;)for(var i=crypto.getRandomValues(new Uint8Array(n)),s=0;s<n&&r.length<e;s++){var o=i[s]&t;o<57&&(r+=Au[o])}return r}var Mu=1048576;function Ru(e,t,n){if(e)if(Array.isArray(e))e.forEach((e,r)=>{t.call(n,e,r)});else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(n,e[r],r)}function Pu(e,t,n,r){var{capture:i=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,n,{capture:i,passive:s})}function Lu(e,t){if(!t)return e;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function Nu(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];for(var i of n)for(var s of i)e.push(s);return e}function Du(e){var t={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=e[n];null!=r&&""!==r&&(t[n]=r)}return t}var Uu=[".sr-only",".visually-hidden",".w-condition-invisible",'[class*="w-condition-invisible"]','[class*="condition-invisible"]','input[type="hidden"]'].join(", ");function Bu(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i=function(){for(var e=new Set,t=[],n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];for(var s of r)if(s)for(var o of s.split(",")){var a=o.trim();a&&!e.has(a)&&(e.add(a),t.push(a))}return t}(...e?[]:[Uu],...n);return i.length>0?i.join(", "):void 0}var Fu=[Kc.MouseMove,Kc.MouseInteraction,Kc.Scroll,Kc.ViewportResize,Kc.Input,Kc.TouchMove,Kc.MediaInteraction,Kc.Drag];function ju(e){try{return new Blob([JSON.stringify(e)]).size}catch(t){return 2*JSON.stringify(e).length}}function Wu(e,t){if(void 0===t&&(t=6606028.8),e.size>=t&&e.data.length>1){var n=Math.floor(e.data.length/2),r=e.data.slice(0,n),i=e.data.slice(n);return[...Wu({size:ju(r),data:r,sessionId:e.sessionId,windowId:e.windowId}),...Wu({size:ju(i),data:i,sessionId:e.sessionId,windowId:e.windowId})]}return[e]}function Hu(e){return e.type===Jc.Custom&&"sessionIdle"===e.data.tag}function zu(e){return 3===e.type&&Fu.includes(e.data.source)}function Vu(e,t,n,r,i){return e<t||e>n?(cu().warn("replay",r+" must be between "+t+" and "+n+". Using default: "+i),i):e}var qu=Uint8Array,$u=Uint16Array,Gu=Int32Array,Ju=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]),Ku=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]),Yu=new qu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zu=function(e,t){for(var n=new $u(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Gu(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return{b:n,r:i}},Xu=Zu(Ju,2),Qu=Xu.b,ed=Xu.r;Qu[28]=258,ed[258]=28;for(var td=Zu(Ku,0).r,nd=new $u(32768),rd=0;rd<32768;++rd){var id=(43690&rd)>>1|(21845&rd)<<1;id=(61680&(id=(52428&id)>>2|(13107&id)<<2))>>4|(3855&id)<<4,nd[rd]=((65280&id)>>8|(255&id)<<8)>>1}var sd=function(e,t,n){for(var r=e.length,i=0,s=new $u(t);i<r;++i)e[i]&&++s[e[i]-1];var o,a=new $u(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(n){o=new $u(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],u=t-e[i],d=a[e[i]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[nd[d]>>l]=c}else for(o=new $u(r),i=0;i<r;++i)e[i]&&(o[i]=nd[a[e[i]-1]++]>>15-e[i]);return o},od=new qu(288);for(rd=0;rd<144;++rd)od[rd]=8;for(rd=144;rd<256;++rd)od[rd]=9;for(rd=256;rd<280;++rd)od[rd]=7;for(rd=280;rd<288;++rd)od[rd]=8;var ad=new qu(32);for(rd=0;rd<32;++rd)ad[rd]=5;var ld=sd(od,9,0),cd=sd(ad,5,0),ud=function(e){return(e+7)/8|0},dd=function(e,t,n){return(null==n||n>e.length)&&(n=e.length),new qu(e.subarray(t,n))},hd=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},pd=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},fd=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return{t:wd,l:0};if(1==i){var o=new qu(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,u=1,d=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=n[n[c].f<n[d].f?c++:d++],l=n[c!=u&&n[c].f<n[d].f?c++:d++],n[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(r=1;r<i;++r)s[r].s>h&&(h=s[r].s);var p=new $u(h+1),f=vd(n[u-1],p,0);if(f>t){r=0;var v=0,g=f-t,m=1<<g;for(s.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var _=s[r].s;if(!(p[_]>t))break;v+=m-(1<<f-p[_]),p[_]=t}for(v>>=g;v>0;){var y=s[r].s;p[y]<t?v-=1<<t-p[y]++-1:++r}for(;r>=0&&v;--r){var b=s[r].s;p[b]==t&&(--p[b],++v)}f=t}return{t:new qu(p),l:f}},vd=function(e,t,n){return-1==e.s?Math.max(vd(e.l,t,n+1),vd(e.r,t,n+1)):t[e.s]=n},gd=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new $u(++t),r=0,i=e[0],s=1,o=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==i&&a!=t)++s;else{if(!i&&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(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=e[a]}return{c:n.subarray(0,r),n:t}},md=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},_d=function(e,t,n){var r=n.length,i=ud(t+2);e[i]=255&r,e[i+1]=r>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;s<r;++s)e[i+s+4]=n[s];return 8*(i+4+r)},yd=function(e,t,n,r,i,s,o,a,l,c,u){hd(t,u++,n),++i[256];for(var d=fd(i,15),h=d.t,p=d.l,f=fd(s,15),v=f.t,g=f.l,m=gd(h),_=m.c,y=m.n,b=gd(v),w=b.c,C=b.n,S=new $u(19),k=0;k<_.length;++k)++S[31&_[k]];for(k=0;k<w.length;++k)++S[31&w[k]];for(var x=fd(S,7),I=x.t,T=x.l,E=19;E>4&&!I[Yu[E-1]];--E);var A,O,M,R,P=c+5<<3,L=md(i,od)+md(s,ad)+o,N=md(i,h)+md(s,v)+o+14+3*E+md(S,I)+2*S[16]+3*S[17]+7*S[18];if(l>=0&&P<=L&&P<=N)return _d(t,u,e.subarray(l,l+c));if(hd(t,u,1+(N<L)),u+=2,N<L){A=sd(h,p,0),O=h,M=sd(v,g,0),R=v;var D=sd(I,T,0);hd(t,u,y-257),hd(t,u+5,C-1),hd(t,u+10,E-4),u+=14;for(k=0;k<E;++k)hd(t,u+3*k,I[Yu[k]]);u+=3*E;for(var U=[_,w],B=0;B<2;++B){var F=U[B];for(k=0;k<F.length;++k){var j=31&F[k];hd(t,u,D[j]),u+=I[j],j>15&&(hd(t,u,F[k]>>5&127),u+=F[k]>>12)}}}else A=ld,O=od,M=cd,R=ad;for(k=0;k<a;++k){var W=r[k];if(W>255){pd(t,u,A[(j=W>>18&31)+257]),u+=O[j+257],j>7&&(hd(t,u,W>>23&31),u+=Ju[j]);var H=31&W;pd(t,u,M[H]),u+=R[H],H>3&&(pd(t,u,W>>5&8191),u+=Ku[H])}else pd(t,u,A[W]),u+=O[W]}return pd(t,u,A[256]),u+O[256]},bd=new Gu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wd=new qu(0),Cd=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&-306674912)^n>>>1;e[t]=n}return e}(),Sd=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new qu(s.length+e.length);o.set(s),o.set(e,s.length),e=o,i.w=s.length}return function(e,t,n,r,i,s){var o=s.z||e.length,a=new qu(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=s.l,u=7&(s.r||0);if(t){u&&(l[0]=s.r>>3);for(var d=bd[t-1],h=d>>13,p=8191&d,f=(1<<n)-1,v=s.p||new $u(32768),g=s.h||new $u(f+1),m=Math.ceil(n/3),_=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<_)&f},b=new Gu(25e3),w=new $u(288),C=new $u(32),S=0,k=0,x=s.i||0,I=0,T=s.w||0,E=0;x+2<o;++x){var A=y(x),O=32767&x,M=g[A];if(v[O]=M,g[A]=O,T<=x){var R=o-x;if((S>7e3||I>24576)&&(R>423||!c)){u=yd(e,l,0,b,w,C,k,I,E,x-E,u),I=S=k=0,E=x;for(var P=0;P<286;++P)w[P]=0;for(P=0;P<30;++P)C[P]=0}var L=2,N=0,D=p,U=O-M&32767;if(R>2&&A==y(x-U))for(var B=Math.min(h,R)-1,F=Math.min(32767,x),j=Math.min(258,R);U<=F&&--D&&O!=M;){if(e[x+L]==e[x+L-U]){for(var W=0;W<j&&e[x+W]==e[x+W-U];++W);if(W>L){if(L=W,N=U,W>B)break;var H=Math.min(U,W-2),z=0;for(P=0;P<H;++P){var V=x-U+P&32767,q=V-v[V]&32767;q>z&&(z=q,M=V)}}}U+=(O=M)-(M=v[O])&32767}if(N){b[I++]=268435456|ed[L]<<18|td[N];var $=31&ed[L],G=31&td[N];k+=Ju[$]+Ku[G],++w[257+$],++C[G],T=x+L,++S}else b[I++]=e[x],++w[e[x]]}}for(x=Math.max(x,T);x<o;++x)b[I++]=e[x],++w[e[x]];u=yd(e,l,c,b,w,C,k,I,E,x-E,u),c||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=g,s.p=v,s.i=x,s.w=T)}else{for(x=s.w||0;x<o+c;x+=65535){var J=x+65535;J>=o&&(l[u/8|0]=c,J=o),u=_d(l,u+1,e.subarray(x,J))}s.i=o}return dd(a,0,r+ud(u)+i)}(e,null==t.level?6:t.level,null==t.mem?i.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,n,r,i)},kd=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function xd(e,t){t||(t={});var n=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=Cd[255&n^t[r]]^n>>>8;e=n},d:function(){return~e}}}(),r=e.length;n.p(e);var i=Sd(e,t,function(e){return 10+(e.filename?e.filename.length+1:0)}(t),8),s=i.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&kd(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}}(i,t),kd(i,s-8,n.d()),kd(i,s-4,r),i}var Id="undefined"!=typeof TextEncoder&&new TextEncoder,Td="undefined"!=typeof TextDecoder&&new TextDecoder;try{Td.decode(wd,{stream:!0})}catch(e){}function Ed(e,t){if(Id)return Id.encode(e);for(var n=e.length,r=new qu(e.length+(e.length>>1)),i=0,s=function(e){r[i++]=e},o=0;o<n;++o){if(i+5>r.length){var a=new qu(i+8+(n-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.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 dd(r,0,i)}function Ad(e){if("undefined"==typeof btoa)throw new Error("btoa is not available in this environment");for(var t="",n=0;n<e.length;n+=32768){var r=Math.min(n+32768,e.length),i=e.subarray(n,r);t+=String.fromCharCode.apply(null,i)}return btoa(t)}var Od="replay";function Md(){var e,t;return null===(t=null===(e=null==Gc?void 0:Gc.__VTiltExtensions__)||void 0===e?void 0:e.rrweb)||void 0===t?void 0:t.record}function Rd(e,t){var n=e.includes("?")?"&":"?";return""+e+n+"compression="+t}function Pd(e){return{rrwebMethod:e,enqueuedAt:Date.now(),attempt:1}}class Ld{constructor(e,t){void 0===t&&(t={}),this._endpoint="/api/s",this._captureStarted=!1,this._isIdle="unknown",this._lastActivityTimestamp=Date.now(),this._sessionId="",this._windowId="",this._queuedRRWebEvents=[],this._onBeforeUnload=()=>{this._forceFlushBuffer()},this._onPageHide=()=>{this._forceFlushBuffer()},this._onOffline=()=>{this._tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this._tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{if(null==zc?void 0:zc.visibilityState){var e="window "+zc.visibilityState;this._tryAddCustomEvent(e,{}),"hidden"===zc.visibilityState&&this._forceFlushBuffer()}},this._instance=e,this._config=t,this._buffer=this._clearBuffer()}get isStarted(){return this._captureStarted}get started(){return this._captureStarted}get sessionId(){return this._sessionId}get status(){return this._captureStarted?!0===this._isIdle?"paused":"active":"disabled"}start(e){this._isRecordingEnabled()?(this._startCapture(e),jc&&(Pu(jc,"beforeunload",this._onBeforeUnload),Pu(jc,"pagehide",this._onPageHide),Pu(jc,"offline",this._onOffline),Pu(jc,"online",this._onOnline),Pu(jc,"visibilitychange",this._onVisibilityChange))):this.stop()}stop(){this._captureStarted&&this._stopRrweb&&(this._stopRrweb(),this._stopRrweb=void 0,this._captureStarted=!1,jc&&(jc.removeEventListener("beforeunload",this._onBeforeUnload),jc.removeEventListener("pagehide",this._onPageHide),jc.removeEventListener("offline",this._onOffline),jc.removeEventListener("online",this._onOnline),jc.removeEventListener("visibilitychange",this._onVisibilityChange)),this._forceFlushBuffer(),this._clearBuffer(),this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),cu().info(Od,"stopped"))}stopRecording(){this.stop()}addCustomEvent(e,t){return this._tryAddCustomEvent(e,t)}takeFullSnapshot(){return this._tryTakeFullSnapshot()}log(e,t){void 0===t&&(t="log"),this.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}updateConfig(e){this._config=n({},this._config,e)}_isRecordingEnabled(){return!!this._config.enabled&&!!jc}_startCapture(e){var t;if(void 0!==Object.assign&&void 0!==Array.from&&!this._captureStarted){this._captureStarted=!0;var n=this._instance.getSessionId();this._sessionId=n||this._generateId(),this._windowId=(null===(t=this._instance.sessionManager)||void 0===t?void 0:t.getWindowId())||this._generateId(),Md()?this._onScriptLoaded():this._loadRecorder(()=>{this._onScriptLoaded()}),cu().info(Od,"starting"),e&&this._reportStarted(e)}}_loadRecorder(e){var t,n=null===(t=Gc.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;n?n(this._instance,"recorder",t=>{t?cu().error(Od,"could not load recorder:",t):e()}):cu().error(Od,"loadExternalDependency not available; make sure external-scripts-loader is initialized")}_onScriptLoaded(){var e,t,r=Md();if(r){var i={blockClass:this._config.blockClass||"vt-no-capture",ignoreClass:this._config.ignoreClass||"vt-ignore-input",maskTextClass:this._config.maskTextClass||"vt-mask",maskTextSelector:this._config.maskTextSelector,maskTextFn:void 0,maskAllInputs:null===(e=this._config.maskAllInputs)||void 0===e||e,maskInputOptions:n({password:!0},this._config.maskInputOptions),maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},s=this._getCanvasConfig();s.enabled&&(i.recordCanvas=!0,i.sampling={canvas:s.fps},i.dataURLOptions={type:"image/webp",quality:s.quality});var o=this._getMaskingConfig();o&&(i.maskAllInputs=null===(t=o.maskAllInputs)||void 0===t||t,i.maskTextSelector=o.maskTextSelector),i.blockSelector=Bu(this._config.skipDefaultInvisibleBlocking,this._config.blockSelector,null==o?void 0:o.blockSelector);var a=this._gatherRRWebPlugins();this._stopRrweb=r(n({emit:e=>{this.onRRwebEmit(e)},plugins:a},i)),this._lastActivityTimestamp=Date.now(),this._isIdle="boolean"==typeof this._isIdle?this._isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:a.map(e=>null==e?void 0:e.name)})}else cu().error(Od,"onScriptLoaded was called but rrwebRecord is not available")}_gatherRRWebPlugins(){var e,t,n=[];if(this._config.captureConsole)try{var r=null===(t=null===(e=Gc.__VTiltExtensions__)||void 0===e?void 0:e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;r&&n.push(r())}catch(e){cu().warn(Od,"failed to load console plugin",e)}return n}onRRwebEmit(e){if(this._processQueuedEvents(),e&&"object"==typeof e){if(e.type===Jc.Meta){var t=e.data;this._lastHref=t.href}if(function(e){return e.type===Jc.Custom&&"recording paused"===e.data.tag}(e)||Hu(e));else if(!0===this._isIdle&&!zu(e))return;e.type===Jc.FullSnapshot&&this._scheduleFullSnapshot();var r=function(e){if(e.type!==Jc.Plugin||"rrweb/console@1"!==e.data.plugin)return e;var t=e.data.payload;if(!(null==t?void 0:t.payload))return e;var r=t.payload.map(e=>"string"==typeof e&&e.length>1e3?e.substring(0,1e3)+"... [truncated]":e);return n({},e,{data:n({},e.data,{payload:n({},t,{payload:r})})})}(e);if(this._updateWindowAndSessionIds(r),!0!==this._isIdle||Hu(r)){var i={$snapshot_bytes:ju(r),$snapshot_data:r,$session_id:this._sessionId,$window_id:this._windowId};"disabled"!==this.status?this._captureSnapshotBuffered(i):this._clearBuffer()}}}_processQueuedEvents(){if(0!==this._queuedRRWebEvents.length){var e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach(e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)})}}_updateWindowAndSessionIds(e){var t,n=zu(e);if(!n&&!this._isIdle){var r=e.timestamp-this._lastActivityTimestamp,i=this._config.sessionIdleThresholdMs||3e5;r>i&&(this._isIdle=!0,this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:i,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size}),this._flushBuffer())}var s=!1;if(n&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){var o="unknown"===this._isIdle;this._isIdle=!1,o||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),s=!0)}if(!this._isIdle){var a=this._instance.getSessionId();this._sessionId&&a&&a!==this._sessionId?(this._forceFlushBuffer(),this._clearBuffer(),this._sessionId=a,this._windowId=(null===(t=this._instance.sessionManager)||void 0===t?void 0:t.getWindowId())||this._generateId(),this._buffer.sessionId=this._sessionId,this._buffer.windowId=this._windowId,this._scheduleFullSnapshot(),this._tryTakeFullSnapshot(),this._reportStarted("session_id_changed")):s&&(this._scheduleFullSnapshot(),this._tryTakeFullSnapshot())}}_clearBuffer(){return this._buffer={size:0,data:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_flushBuffer(){return this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0),"paused"===this.status||"disabled"===this.status?(this._flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3),this._buffer):(this._sendBufferContents(),this._clearBuffer())}_forceFlushBuffer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0),this._sendBufferContents()}_sendBufferContents(){this._buffer.data.length>0&&Wu(this._buffer).forEach(e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId})})}_captureSnapshotBuffered(e){var t,n=2+((null===(t=this._buffer)||void 0===t?void 0:t.data.length)||0),r=e.$snapshot_bytes;!this._isIdle&&(this._buffer.size+r+n>943718.4||this._buffer.sessionId!==this._sessionId)&&(this._buffer=this._flushBuffer()),this._buffer.size+=r,this._buffer.data.push(e.$snapshot_data),this._flushBufferTimer||this._isIdle||(this._flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_captureSnapshot(e){var t=this._instance.getConfig(),n=t.token||"";if(n){if(!Eu()){var r=!1!==this._config.compressEvents,i={token:n,distinct_id:this._instance.getDistinctId()||this._instance.getAnonymousId()||"",$session_id:this._sessionId,$window_id:this._windowId,$snapshot_data:e.$snapshot_data,$snapshot_bytes:e.$snapshot_bytes,$lib:"web",$lib_version:this._instance.version||"unknown",timestamp:Date.now()};this._sendSnapshot(t,n,i,r)}}else cu().warn(Od,"missing token, cannot send snapshot")}_sendSnapshot(e,t,n,r){var i=JSON.stringify(n),s=n.$snapshot_data,o=Array.isArray(s)&&s.some(e=>2===(null==e?void 0:e.type));if(i.length>61440||o){var a=pu(e,this._endpoint);this._sendViaFetch(a,t,i,r)}else{var l=pu(e,this._endpoint,{includeTokenQuery:!0});this._sendViaBeacon(l,t,i,r)}}_sendViaFetch(e,t,n,r){if(r&&void 0!==jc)try{var i=xd(Ed(n));if(i.length>0){var s=new Blob([i],{type:"application/octet-stream"});if(s.size>0){var o=Rd(e,"gzip-js");return void this._fetchWithRetry(o,t,s,"application/octet-stream")}}}catch(e){cu().warn(Od,"compression failed, sending uncompressed")}var a=new Blob([n],{type:"application/json"});this._fetchWithRetry(e,t,a,"application/json")}_sendViaBeacon(e,t,n,r){if(r&&void 0!==jc)try{var i=xd(Ed(n));if(i.length>0){var s=Ad(i);if(s.length>0&&s.length<=61440){var o=Rd(e,"base64"),a=new Blob([s],{type:"text/plain"});if("undefined"!=typeof navigator&&navigator.sendBeacon&&navigator.sendBeacon(o,a))return;return void this._fetchWithRetry(o,"",a,"text/plain")}}}catch(e){cu().warn(Od,"compression failed, sending uncompressed")}var l=new Blob([n],{type:"application/json"});"undefined"!=typeof navigator&&navigator.sendBeacon&&navigator.sendBeacon(e,l)||this._fetchWithRetry(e,"",l,"application/json")}_fetchWithRetry(e,t,n,r,i){void 0===i&&(i=0);var s=n.size<6e4,o={"Content-Type":r};t&&(o[hu]=t),fetch(e,{method:"POST",body:n,headers:o,keepalive:s}).then(s=>{if(!s.ok)return s.status>=400&&s.status<500?(Tu(),void cu().warn(Od,"snapshot rejected by server ("+s.status+"), not retrying")):void this._scheduleRetry(e,t,n,r,i);Tu()}).catch(()=>{Iu(Od),this._scheduleRetry(e,t,n,r,i)})}_scheduleRetry(e,t,n,r,i){if(i>=5)cu().error(Od,"failed to send snapshot after 5 retries, giving up");else if(!Eu()){var s=3e3*Math.pow(2,i),o=Math.min(s,3e4),a=(Math.random()-.5)*o,l=Math.ceil(o+a);cu().warn(Od,"snapshot send failed, retrying in "+Math.round(l/1e3)+"s (attempt "+(i+1)+"/5)"),setTimeout(()=>{this._fetchWithRetry(e,t,n,r,i+1)},l)}}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0!==this._isIdle){var e=this._config.fullSnapshotIntervalMs||3e5;this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},e)}}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return this._queuedRRWebEvents.length<10?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt+1,rrwebMethod:e.rrwebMethod}):cu().warn(Od,"could not emit queued rrweb event",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(Pd(()=>Md().addCustomEvent(e,t)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Pd(()=>Md().takeFullSnapshot()))}_getCanvasConfig(){var e,t,n,r=this._config.captureCanvas,i=null!==(e=null==r?void 0:r.recordCanvas)&&void 0!==e&&e,s=null!==(t=null==r?void 0:r.canvasFps)&&void 0!==t?t:4,o=null!==(n=null==r?void 0:r.canvasQuality)&&void 0!==n?n:.4;return{enabled:i,fps:Vu(s,0,12,"canvas recording fps",4),quality:Vu(o,0,1,"canvas recording quality",.4)}}_getMaskingConfig(){var e,t=this._config.masking;if(t)return{maskAllInputs:null===(e=t.maskAllInputs)||void 0===e||e,maskTextSelector:t.maskTextSelector,blockSelector:t.blockSelector}}_generateId(){return Math.random().toString(36).substring(2,15)}_reportStarted(e,t){cu().info(Od,e.replace(/_/g," "),t),"recording_initialized"!==e&&"session_id_changed"!==e&&this._tryAddCustomEvent(e,t)}}Gc.__VTiltExtensions__=Gc.__VTiltExtensions__||{},Gc.__VTiltExtensions__.rrweb={record:Ic,version:"v2"},Gc.__VTiltExtensions__.rrwebPlugins={getRecordConsolePlugin:e=>({name:"rrweb/console@1",observer:Fc,options:e})},Gc.__VTiltExtensions__.initSessionRecording=function(e,t){return new Ld(e,t)};var Nd,Dd=-1,Ud=function(e){addEventListener("pageshow",function(t){t.persisted&&(Dd=t.timeStamp,e(t))},!0)},Bd=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},Fd=function(){var e=Bd();return e&&e.activationStart||0},jd=function(e,t){var n=Bd(),r="navigate";return Dd>=0?r="back-forward-cache":n&&(document.prerendering||Fd()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},Wd=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver(function(e){Promise.resolve().then(function(){t(e.getEntries())})});return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},Hd=function(e,t,n,r){var i,s;return function(o){t.value>=0&&(o||r)&&((s=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=s,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},zd=function(e){requestAnimationFrame(function(){return requestAnimationFrame(function(){return e()})})},Vd=function(e){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||e(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},qd=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},$d=-1,Gd=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Jd=function(e){"hidden"===document.visibilityState&&$d>-1&&($d="visibilitychange"===e.type?e.timeStamp:0,Yd())},Kd=function(){addEventListener("visibilitychange",Jd,!0),addEventListener("prerenderingchange",Jd,!0)},Yd=function(){removeEventListener("visibilitychange",Jd,!0),removeEventListener("prerenderingchange",Jd,!0)},Zd=function(){return $d<0&&($d=Gd(),Kd(),Ud(function(){setTimeout(function(){$d=Gd(),Kd()},0)})),{get firstHiddenTime(){return $d}}},Xd=function(e){document.prerendering?addEventListener("prerenderingchange",function(){return e()},!0):e()},Qd=[1800,3e3],eh=function(e,t){t=t||{},Xd(function(){var n,r=Zd(),i=jd("FCP"),s=Wd("paint",function(e){e.forEach(function(e){"first-contentful-paint"===e.name&&(s.disconnect(),e.startTime<r.firstHiddenTime&&(i.value=Math.max(e.startTime-Fd(),0),i.entries.push(e),n(!0)))})});s&&(n=Hd(e,i,Qd,t.reportAllChanges),Ud(function(r){i=jd("FCP"),n=Hd(e,i,Qd,t.reportAllChanges),zd(function(){i.value=performance.now()-r.timeStamp,n(!0)})}))})},th=[.1,.25],nh=0,rh=1/0,ih=0,sh=function(e){e.forEach(function(e){e.interactionId&&(rh=Math.min(rh,e.interactionId),ih=Math.max(ih,e.interactionId),nh=ih?(ih-rh)/7+1:0)})},oh=function(){return Nd?nh:performance.interactionCount||0},ah=[200,500],lh=0,ch=function(){return oh()-lh},uh=[],dh={},hh=function(e){var t=uh[uh.length-1],n=dh[e.interactionId];if(n||uh.length<10||e.duration>t.latency){if(n)n.entries.push(e),n.latency=Math.max(n.latency,e.duration);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};dh[r.id]=r,uh.push(r)}uh.sort(function(e,t){return t.latency-e.latency}),uh.splice(10).forEach(function(e){delete dh[e.id]})}},ph=[2500,4e3],fh={},vh=[800,1800],gh=function e(t){document.prerendering?Xd(function(){return e(t)}):"complete"!==document.readyState?addEventListener("load",function(){return e(t)},!0):setTimeout(t,0)},mh={onLCP:function(e,t){t=t||{},Xd(function(){var n,r=Zd(),i=jd("LCP"),s=function(e){var t=e[e.length-1];t&&t.startTime<r.firstHiddenTime&&(i.value=Math.max(t.startTime-Fd(),0),i.entries=[t],n())},o=Wd("largest-contentful-paint",s);if(o){n=Hd(e,i,ph,t.reportAllChanges);var a=qd(function(){fh[i.id]||(s(o.takeRecords()),o.disconnect(),fh[i.id]=!0,n(!0))});["keydown","click"].forEach(function(e){addEventListener(e,function(){return setTimeout(a,0)},!0)}),Vd(a),Ud(function(r){i=jd("LCP"),n=Hd(e,i,ph,t.reportAllChanges),zd(function(){i.value=performance.now()-r.timeStamp,fh[i.id]=!0,n(!0)})})}})},onCLS:function(e,t){t=t||{},eh(qd(function(){var n,r=jd("CLS",0),i=0,s=[],o=function(e){e.forEach(function(e){if(!e.hadRecentInput){var t=s[0],n=s[s.length-1];i&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(i+=e.value,s.push(e)):(i=e.value,s=[e])}}),i>r.value&&(r.value=i,r.entries=s,n())},a=Wd("layout-shift",o);a&&(n=Hd(e,r,th,t.reportAllChanges),Vd(function(){o(a.takeRecords()),n(!0)}),Ud(function(){i=0,r=jd("CLS",0),n=Hd(e,r,th,t.reportAllChanges),zd(function(){return n()})}),setTimeout(n,0))}))},onFCP:eh,onINP:function(e,t){t=t||{},Xd(function(){var n;"interactionCount"in performance||Nd||(Nd=Wd("event",sh,{type:"event",buffered:!0,durationThreshold:0}));var r,i=jd("INP"),s=function(e){e.forEach(function(e){e.interactionId&&hh(e),"first-input"===e.entryType&&!uh.some(function(t){return t.entries.some(function(t){return e.duration===t.duration&&e.startTime===t.startTime})})&&hh(e)});var t,n=(t=Math.min(uh.length-1,Math.floor(ch()/50)),uh[t]);n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r())},o=Wd("event",s,{durationThreshold:null!==(n=t.durationThreshold)&&void 0!==n?n:40});r=Hd(e,i,ah,t.reportAllChanges),o&&("PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&o.observe({type:"first-input",buffered:!0}),Vd(function(){s(o.takeRecords()),i.value<0&&ch()>0&&(i.value=0,i.entries=[]),r(!0)}),Ud(function(){uh=[],lh=oh(),i=jd("INP"),r=Hd(e,i,ah,t.reportAllChanges)}))})},onTTFB:function(e,t){t=t||{};var n=jd("TTFB"),r=Hd(e,n,vh,t.reportAllChanges);gh(function(){var i=Bd();if(i){var s=i.responseStart;if(s<=0||s>performance.now())return;n.value=Math.max(s-Fd(),0),n.entries=[i],r(!0),Ud(function(){n=jd("TTFB",0),(r=Hd(e,n,vh,t.reportAllChanges))(!0)})}})}};Gc.__VTiltExtensions__=Gc.__VTiltExtensions__||{},Gc.__VTiltExtensions__.webVitalsCallbacks=mh;var _h="/api/chat/widget/channels",yh=e=>"/api/chat/widget/channels/"+e+"/messages",bh=e=>"/api/chat/widget/channels/"+e+"/read",wh="/api/chat/token/widget";function Ch(e,t,n){return Sh.apply(this,arguments)}function Sh(){return(Sh=t(function*(e,t,r){void 0===r&&(r={});var i=e.getConfig(),s=pu(i,t);try{var o=yield fetch(s,n({},r,{headers:n({"Content-Type":"application/json"},fu(i),r.headers)}));if(!o.ok)throw new Error("API error: "+o.status);return yield o.json()}catch(e){return cu().error("chat","API request failed:",e),null}})).apply(this,arguments)}var kh="rich_format",xh="markdown",Ih=/^[a-zA-Z0-9_-]{1,64}$/;function Th(e){return"user"===e.sender_type?function(e){var t;return"html"===e.content_type||(null===(t=e.metadata)||void 0===t?void 0:t[kh])===xh}(e):"ai"===e.sender_type||"agent"===e.sender_type}function Eh(e,t){var n,r=function(e){return"string"==typeof e?{raw:e,format:"text"}:"markdown"in e?{raw:e.markdown,format:"markdown"}:"html"in e?{raw:e.html,format:"html"}:"text"in e?{raw:e.text,format:"text"}:null}(e);if(!r)return null;var i="string"==typeof e?null!==(n=null==t?void 0:t.format)&&void 0!==n?n:"text":r.format,s=r.raw.trim();if(!s)return null;var o={};if(null==t?void 0:t.source){var a=function(e){var t=e.trim();if(Ih.test(t))return t}(t.source);a&&(o.message_source=a)}return"html"===i?{content:s,content_type:"html",metadata:o}:"markdown"===i?(o[kh]=xh,{content:s,content_type:"text",metadata:o}):{content:s,content_type:"text",metadata:o}}var Ah="$channel_message";class Oh{constructor(){this._widgets=new Map}register(e){this._widgets.has(e.type)||this._widgets.set(e.type,e)}get(e){return this._widgets.get(e)}getAll(){return Array.from(this._widgets.values())}getToolDefinitions(){var e={};for(var t of this._widgets.values())e[t.type]={description:t.toolDescription,parameters:t.parameters};return e}}var Mh,Rh,Ph,Lh,Nh,Dh,Uh,Bh,Fh,jh,Wh,Hh,zh,Vh,qh,$h={},Gh=[],Jh=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Kh=Array.isArray;function Yh(e,t){for(var n in t)e[n]=t[n];return e}function Zh(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Xh(e,t,n){var r,i,s,o={};for(s in t)"key"==s?r=t[s]:"ref"==s?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?Mh.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===o[s]&&(o[s]=e.defaultProps[s]);return Qh(e,o,r,i,null)}function Qh(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++Ph:i,__i:-1,__u:0};return null==i&&null!=Rh.vnode&&Rh.vnode(s),s}function ep(e){return e.children}function tp(e,t){this.props=e,this.context=t}function np(e,t){if(null==t)return e.__?np(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?np(e):null}function rp(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],s=Yh({},t);s.__v=t.__v+1,Rh.vnode&&Rh.vnode(s),fp(e.__P,s,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,null==n?np(t):n,!!(32&t.__u),i),s.__v=t.__v,s.__.__k[s.__i]=s,gp(r,s,i),t.__e=t.__=null,s.__e!=n&&ip(s)}}function ip(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),ip(e)}function sp(e){(!e.__d&&(e.__d=!0)&&Nh.push(e)&&!op.__r++||Dh!=Rh.debounceRendering)&&((Dh=Rh.debounceRendering)||Uh)(op)}function op(){try{for(var e,t=1;Nh.length;)Nh.length>t&&Nh.sort(Bh),e=Nh.shift(),t=Nh.length,rp(e)}finally{Nh.length=op.__r=0}}function ap(e,t,n,r,i,s,o,a,l,c,u){var d,h,p,f,v,g,m,_=r&&r.__k||Gh,y=t.length;for(l=function(e,t,n,r,i){var s,o,a,l,c,u=n.length,d=u,h=0;for(e.__k=new Array(i),s=0;s<i;s++)null!=(o=t[s])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=e.__k[s]=Qh(null,o,null,null,null):Kh(o)?o=e.__k[s]=Qh(ep,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=e.__k[s]=Qh(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[s]=o,l=s+h,o.__=e,o.__b=e.__b+1,a=null,-1!=(c=o.__i=up(o,n,l,d))&&(d--,(a=n[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(i>u?h--:i<u&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[s]=null;if(d)for(s=0;s<u;s++)null!=(a=n[s])&&!(2&a.__u)&&(a.__e==r&&(r=np(a)),bp(a,a));return r}(n,t,_,l,y),d=0;d<y;d++)null!=(p=n.__k[d])&&(h=-1!=p.__i&&_[p.__i]||$h,p.__i=d,g=fp(e,p,h,i,s,o,a,l,c,u),f=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&yp(h.ref,null,p),u.push(p.ref,p.__c||f,p)),null==v&&null!=f&&(v=f),(m=!!(4&p.__u))||h.__k===p.__k?(l=lp(p,l,e,m),m&&h.__e&&(h.__e=null)):"function"==typeof p.type&&void 0!==g?l=g:f&&(l=f.nextSibling),p.__u&=-7);return n.__e=v,l}function lp(e,t,n,r){var i,s;if("function"==typeof e.type){for(i=e.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=e,t=lp(i[s],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=np(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function cp(e,t){return t=t||[],null==e||"boolean"==typeof e||(Kh(e)?e.some(function(e){cp(e,t)}):t.push(e)),t}function up(e,t,n,r){var i,s,o,a=e.key,l=e.type,c=t[n],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&l==c.type)return n;if(r>(u?1:0))for(i=n-1,s=n+1;i>=0||s<t.length;)if(null!=(c=t[o=i>=0?i--:s++])&&!(2&c.__u)&&a==c.key&&l==c.type)return o;return-1}function dp(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||Jh.test(t)?n:n+"px"}function hp(e,t,n,r,i){var s,o;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||dp(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||dp(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])s=t!=(t=t.replace(Hh,"$1")),o=t.toLowerCase(),t=o in e||"onFocusOut"==t||"onFocusIn"==t?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n[Wh]=r[Wh]:(n[Wh]=zh,e.addEventListener(t,s?qh:Vh,s)):e.removeEventListener(t,s?qh:Vh,s);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function pp(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t[jh])t[jh]=zh++;else if(t[jh]<n[Wh])return;return n(Rh.event?Rh.event(t):t)}}}function fp(e,t,n,r,i,s,o,a,l,c){var u,d,h,p,f,v,g,m,_,y,b,w,C,S,k,x=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),s=[a=t.__e=n.__e]),(u=Rh.__b)&&u(t);e:if("function"==typeof x)try{if(m=t.props,_=x.prototype&&x.prototype.render,y=(u=x.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(_?t.__c=d=new x(m,b):(t.__c=d=new tp(m,b),d.constructor=x,d.render=wp),y&&y.sub(d),d.state||(d.state={}),d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),_&&null==d.__s&&(d.__s=d.state),_&&null!=x.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=Yh({},d.__s)),Yh(d.__s,x.getDerivedStateFromProps(m,d.__s))),p=d.props,f=d.state,d.__v=t,h)_&&null==x.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),_&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(_&&null==x.getDerivedStateFromProps&&m!==p&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(m,b),t.__v==n.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(m,d.__s,b)){t.__v!=n.__v&&(d.props=m,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),Gh.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&o.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(m,d.__s,b),_&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(p,f,v)})}if(d.context=b,d.props=m,d.__P=e,d.__e=!1,w=Rh.__r,C=0,_)d.state=d.__s,d.__d=!1,w&&w(t),u=d.render(d.props,d.state,d.context),Gh.push.apply(d.__h,d._sb),d._sb=[];else do{d.__d=!1,w&&w(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++C<25);d.state=d.__s,null!=d.getChildContext&&(r=Yh(Yh({},r),d.getChildContext())),_&&!h&&null!=d.getSnapshotBeforeUpdate&&(v=d.getSnapshotBeforeUpdate(p,f)),S=null!=u&&u.type===ep&&null==u.key?mp(u.props.children):u,a=ap(e,Kh(S)?S:[S],t,n,r,i,s,o,a,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),g&&(d.__E=d.__=null)}catch(e){if(t.__v=null,l||null!=s)if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else{for(k=s.length;k--;)Zh(s[k]);vp(t)}else t.__e=n.__e,t.__k=n.__k,e.then||vp(t);Rh.__e(e,t,n)}else null==s&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):a=t.__e=_p(n.__e,t,n,r,i,s,o,l,c);return(u=Rh.diffed)&&u(t),128&t.__u?void 0:a}function vp(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(vp))}function gp(e,t,n){for(var r=0;r<n.length;r++)yp(n[r],n[++r],n[++r]);Rh.__c&&Rh.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Rh.__e(e,t.__v)}})}function mp(e){return"object"!=typeof e||null==e||e.__b>0?e:Kh(e)?e.map(mp):void 0!==e.constructor?null:Yh({},e)}function _p(e,t,n,r,i,s,o,a,l){var c,u,d,h,p,f,v,g=n.props||$h,m=t.props,_=t.type;if("svg"==_?i="http://www.w3.org/2000/svg":"math"==_?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=s)for(c=0;c<s.length;c++)if((p=s[c])&&"setAttribute"in p==!!_&&(_?p.localName==_:3==p.nodeType)){e=p,s[c]=null;break}if(null==e){if(null==_)return document.createTextNode(m);e=document.createElementNS(i,_,m.is&&m),a&&(Rh.__m&&Rh.__m(t,s),a=!1),s=null}if(null==_)g===m||a&&e.data==m||(e.data=m);else{if(s="textarea"==_&&null!=m.defaultValue?null:s&&Mh.call(e.childNodes),!a&&null!=s)for(g={},c=0;c<e.attributes.length;c++)g[(p=e.attributes[c]).name]=p.value;for(c in g)p=g[c],"dangerouslySetInnerHTML"==c?d=p:"children"==c||c in m||"value"==c&&"defaultValue"in m||"checked"==c&&"defaultChecked"in m||hp(e,c,null,p,i);for(c in m)p=m[c],"children"==c?h=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?f=p:"checked"==c?v=p:a&&"function"!=typeof p||g[c]===p||hp(e,c,p,g[c],i);if(u)a||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),ap("template"==t.type?e.content:e,Kh(h)?h:[h],t,n,r,"foreignObject"==_?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:n.__k&&np(n,0),a,l),null!=s)for(c=s.length;c--;)Zh(s[c]);a&&"textarea"!=_||(c="value","progress"==_&&null==f?e.removeAttribute("value"):null!=f&&(f!==e[c]||"progress"==_&&!f||"option"==_&&f!=g[c])&&hp(e,c,f,g[c],i),c="checked",null!=v&&v!=e[c]&&hp(e,c,v,g[c],i))}return e}function yp(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(e){Rh.__e(e,n)}}function bp(e,t,n){var r,i;if(Rh.unmount&&Rh.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||yp(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){Rh.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&bp(r[i],t,n||"function"!=typeof e.type);n||Zh(e.__e),e.__c=e.__=e.__e=void 0}function wp(e,t,n){return this.constructor(e,n)}function Cp(e,t,n){var r,i,s;t==document&&(t=document.documentElement),Rh.__&&Rh.__(e,t),r=!1?null:t.__k,i=[],s=[],fp(t,e=t.__k=Xh(ep,null,[e]),r||$h,$h,t.namespaceURI,r?null:t.firstChild?Mh.call(t.childNodes):null,i,r?r.__e:t.firstChild,false,s),gp(i,e,s)}Mh=Gh.slice,Rh={__e:function(e,t,n,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&null!=s.getDerivedStateFromError&&(i.setState(s.getDerivedStateFromError(e)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},Ph=0,Lh=function(e){return null!=e&&void 0===e.constructor},tp.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=Yh({},this.state),"function"==typeof e&&(e=e(Yh({},n),this.props)),e&&Yh(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),sp(this))},tp.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),sp(this))},tp.prototype.render=ep,Nh=[],Uh="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Bh=function(e,t){return e.__v.__b-t.__v.__b},op.__r=0,Fh=Math.random().toString(8),jh="__d"+Fh,Wh="__a"+Fh,Hh=/(PointerCapture)$|Capture$/i,zh=0,Vh=pp(!1),qh=pp(!0);var Sp=0;function kp(e,t,n,r,i,s){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?o=t[a]:l[a]=t[a];var c={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Sp,__i:-1,__u:0,__source:i,__self:s};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return Rh.vnode&&Rh.vnode(c),c}var xp,Ip,Tp,Ep,Ap=0,Op=[],Mp=Rh,Rp=Mp.__b,Pp=Mp.__r,Lp=Mp.diffed,Np=Mp.__c,Dp=Mp.unmount,Up=Mp.__;function Bp(e,t){Mp.__h&&Mp.__h(Ip,e,Ap||t),Ap=0;var n=Ip.__H||(Ip.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Fp(e){return Ap=1,function(e,t,n){var r=Bp(xp++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Yp(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Ip,!Ip.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!s||s.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),s&&s.call(this,e,t,n)||o};Ip.__f=!0;var s=Ip.shouldComponentUpdate,o=Ip.componentWillUpdate;Ip.componentWillUpdate=function(e,t,n){if(this.__e){var r=s;s=void 0,i(e,t,n),s=r}o&&o.call(this,e,t,n)},Ip.shouldComponentUpdate=i}return r.__N||r.__}(Yp,e)}function jp(e,t){var n=Bp(xp++,3);!Mp.__s&&Kp(n.__H,t)&&(n.__=e,n.u=t,Ip.__H.__h.push(n))}function Wp(e){return Ap=5,Hp(function(){return{current:e}},[])}function Hp(e,t){var n=Bp(xp++,7);return Kp(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function zp(e,t){return Ap=8,Hp(function(){return e},t)}function Vp(){for(var e;e=Op.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Gp),t.__h.some(Jp),t.__h=[]}catch(n){t.__h=[],Mp.__e(n,e.__v)}}}Mp.__b=function(e){Ip=null,Rp&&Rp(e)},Mp.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Up&&Up(e,t)},Mp.__r=function(e){Pp&&Pp(e),xp=0;var t=(Ip=e.__c).__H;t&&(Tp===Ip?(t.__h=[],Ip.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Gp),t.__h.some(Jp),t.__h=[],xp=0)),Tp=Ip},Mp.diffed=function(e){Lp&&Lp(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==Op.push(t)&&Ep===Mp.requestAnimationFrame||((Ep=Mp.requestAnimationFrame)||$p)(Vp)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Tp=Ip=null},Mp.__c=function(e,t){t.some(function(e){try{e.__h.some(Gp),e.__h=e.__h.filter(function(e){return!e.__||Jp(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],Mp.__e(n,e.__v)}}),Np&&Np(e,t)},Mp.unmount=function(e){Dp&&Dp(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Gp(e)}catch(e){t=e}}),n.__H=void 0,t&&Mp.__e(t,n.__v))};var qp="function"==typeof requestAnimationFrame;function $p(e){var t,n=function(){clearTimeout(r),qp&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);qp&&(t=requestAnimationFrame(n))}function Gp(e){var t=Ip,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ip=t}function Jp(e){var t=Ip;e.__c=e.__(),Ip=t}function Kp(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Yp(e,t){return"function"==typeof t?t(e):t}var Zp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Xp(e){var{prompt:n,ctx:r}=e,[i,s]=Fp(""),[o,a]=Fp(""),[l,c]=Fp(!1),u=Zp.test(o.trim())&&!l,d=function(){var e=t(function*(){if(u){c(!0);try{yield r.dispatch("submit",{email:o.trim(),name:i.trim()})}finally{c(!1)}}});return function(){return e.apply(this,arguments)}}();return kp("div",{class:"vt-widget",children:[kp("p",{children:n}),kp("div",{style:"display: flex; flex-direction: column; gap: 8px;",children:[kp("input",{type:"text",class:"vt-widget-input",placeholder:"Your name",value:i,onInput:e=>s(e.currentTarget.value),disabled:l}),kp("div",{style:"display: flex; gap: 8px; align-items: center;",children:[kp("input",{type:"email",class:"vt-widget-input",style:"flex: 1; min-width: 0; margin: 0;",placeholder:"your@email.com",value:o,onInput:e=>a(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d())},disabled:l}),kp("button",{type:"button",class:"vt-widget-btn","data-style":"outline",onClick:()=>{d()},disabled:!u,children:"Submit"})]})]})]})}var Qp={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:(e,t)=>kp(Xp,{prompt:"string"==typeof e.prompt?e.prompt:"What's your name and email?",ctx:t}),onAction:(e,n,r)=>t(function*(){if("submit"!==e)return{};var t="string"==typeof n.email?n.email.trim():"";if(!t||!Zp.test(t))return{};var i=r.buildEndpointUrl("/api/chat/widget/channels/"+r.channelId+"/actions"),s=r.token?{"x-api-key":r.token,"Content-Type":"application/json"}:{"Content-Type":"application/json"};try{var o=yield fetch(i,{method:"POST",headers:s,body:JSON.stringify({widget_type:"collect_email",action:"submit",data:{email:t,name:"string"==typeof n.name?n.name.trim():""},channel_id:r.channelId,distinct_id:r.distinctId,message_id:r.messageId})});return{success:!!(yield o.json()).success}}catch(e){return{}}})()},ef={fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function tf(e){return kp("svg",n({width:24,height:24,viewBox:"0 0 24 24"},ef,e,{children:kp("path",{d:"M18 6L6 18M6 6l12 12"})}))}function nf(e){return kp("svg",n({width:24,height:24,viewBox:"0 0 24 24"},ef,e,{children:kp("path",{d:"M15 18l-6-6 6-6"})}))}function rf(e){return kp("svg",n({width:16,height:16,viewBox:"0 0 24 24",fill:"currentColor"},e,{children:kp("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})}))}function sf(e){return kp("svg",n({width:28,height:28,viewBox:"0 0 28 28",fill:"white"},e,{children:kp("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(e){return kp("svg",n({width:22,height:22,viewBox:"0 0 24 24",fill:"currentColor"},e,{children:kp("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(e){return kp("svg",n({width:22,height:22,viewBox:"0 0 24 24",fill:"currentColor"},e,{children:kp("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(e){return kp("svg",n({width:36,height:36,viewBox:"0 0 24 24",fill:"white"},e,{children:kp("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 cf(e){return kp("svg",n({width:16,height:16,viewBox:"0 0 24 24"},ef,e,{children:[kp("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),kp("circle",{cx:"12",cy:"7",r:"4"})]}))}function uf(e){var{prompt:n,ctx:r}=e,[i,s]=Fp(!1),o=function(){var e=t(function*(){if(!i){s(!0);try{yield r.dispatch("escalate",{})}finally{s(!1)}}});return function(){return e.apply(this,arguments)}}();return kp("div",{class:"vt-widget",children:[kp("p",{children:n}),kp("button",{type:"button",class:"vt-widget-btn","data-style":"outline",onClick:()=>{o()},disabled:i,children:[kp(cf,{}),"Connect with a person"]})]})}var df={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:(e,t)=>kp(uf,{prompt:"string"==typeof e.prompt?e.prompt:"Would you like me to connect you with a team member?",ctx:t}),onAction:(e,n,r)=>t(function*(){if("escalate"!==e)return{};var t=r.buildEndpointUrl("/api/chat/widget/channels/"+r.channelId+"/actions"),n=r.token?{"x-api-key":r.token,"Content-Type":"application/json"}:{"Content-Type":"application/json"};try{var i=yield fetch(t,{method:"POST",headers:n,body:JSON.stringify({widget_type:"escalate_to_human",action:"escalate",data:{},channel_id:r.channelId,distinct_id:r.distinctId,message_id:r.messageId})});return{success:!!(yield i.json()).success}}catch(e){return{}}})()},hf=Symbol.for("preact-signals");function pf(){if(_f>1)_f--;else{var e,t=!1;for(!function(){var e=bf;for(bf=void 0;void 0!==e;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();void 0!==mf;){var n=mf;for(mf=void 0,yf++;void 0!==n;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&xf(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(yf=0,_f--,t)throw e}}var ff=void 0;function vf(e){var t=ff;ff=void 0;try{return e()}finally{ff=t}}var gf,mf=void 0,_f=0,yf=0,bf=void 0,wf=0;function Cf(e){if(void 0!==ff){var t=e.n;if(void 0===t||t.t!==ff)return t={i:0,S:e,p:ff.s,n:void 0,t:ff,e:void 0,x:void 0,r:t},void 0!==ff.s&&(ff.s.n=t),ff.s=t,e.n=t,32&ff.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=ff.s,t.n=void 0,ff.s.n=t,ff.s=t),t}}function Sf(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function kf(e,t){return new Sf(e,t)}function xf(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function If(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function Tf(e){for(var t=e.s,n=void 0;void 0!==t;){var r=t.p;-1===t.i?(t.S.U(t),void 0!==r&&(r.n=t.n),void 0!==t.n&&(t.n.p=r)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=r}e.s=n}function Ef(e,t){Sf.call(this,void 0),this.x=e,this.s=void 0,this.g=wf-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Af(e,t){return new Ef(e,t)}function Of(e){var t=e.m;if(e.m=void 0,"function"==typeof t){_f++;var n=ff;ff=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Mf(e),t}finally{ff=n,pf()}}}function Mf(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Of(e)}function Rf(e){if(ff!==this)throw new Error("Out-of-order effect");Tf(this),ff=e,this.f&=-2,8&this.f&&Mf(this),pf()}function Pf(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==t?void 0:t.name}function Lf(e,t){var n=new Pf(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}function Nf(e,t){Rh[e]=t.bind(null,Rh[e]||function(){})}function Df(e){if(gf){var t=gf;gf=void 0,t()}gf=e&&e.S()}function Uf(e){var t=this,n=e.data,r=function(e){return Hp(function(){return kf(e)},[])}(n);r.value=n;var i=Hp(function(){for(var e=t.__v;e=e.__;)if(e.__c){e.__c.__$f|=4;break}return t.__$u.c=function(){var e,n=t.__$u.S(),r=i.value;n(),Lh(r)||3!==(null==(e=t.base)?void 0:e.nodeType)?(t.__$f|=1,t.setState({})):t.base.data=r},Af(function(){var e=r.value.value;return 0===e?0:!0===e?"":e||""})},[]);return i.value}function Bf(e,t,n,r){var i=t in e&&void 0===e.ownerSVGElement,s=kf(n);return{o:function(e,t){s.value=e,r=t},d:Lf(function(){var n=s.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n?e.setAttribute(t,n):e.removeAttribute(t))})}}Sf.prototype.brand=hf,Sf.prototype.h=function(){return!0},Sf.prototype.S=function(e){var t=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:vf(function(){var e;null==(e=t.W)||e.call(t)}))},Sf.prototype.U=function(e){var t=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&vf(function(){var e;null==(e=t.Z)||e.call(t)}))}},Sf.prototype.subscribe=function(e){var t=this;return Lf(function(){var n=t.value,r=ff;ff=void 0;try{e(n)}finally{ff=r}},{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 e=this;return vf(function(){return e.value})},Object.defineProperty(Sf.prototype,"value",{get:function(){var e=Cf(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(yf>100)throw new Error("Cycle detected");!function(e){0!==_f&&0===yf&&0!==e.l&&(e.l=0,bf={S:e,v:e.v,i:e.i,o:bf})}(this),this.v=e,this.i++,wf++,_f++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{pf()}}}}),Ef.prototype=new Sf,Ef.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===wf)return!0;if(this.g=wf,this.f|=1,this.i>0&&!xf(this))return this.f&=-2,!0;var e=ff;try{If(this),ff=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return ff=e,Tf(this),this.f&=-2,!0},Ef.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}Sf.prototype.S.call(this,e)},Ef.prototype.U=function(e){if(void 0!==this.t&&(Sf.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},Ef.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(Ef.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Cf(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Pf.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.m=t)}finally{e()}},Pf.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Of(this),If(this),_f++;var e=ff;return ff=this,Rf.bind(this,e)},Pf.prototype.N=function(){2&this.f||(this.f|=2,this.u=mf,mf=this)},Pf.prototype.d=function(){this.f|=8,1&this.f||Mf(this)},Pf.prototype.dispose=function(){this.d()},Uf.displayName="_st",Object.defineProperties(Sf.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Uf},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Nf("__b",function(e,t){if("string"==typeof t.type){var n,r=t.props;for(var i in r)if("children"!==i){var s=r[i];s instanceof Sf&&(n||(t.__np=n={}),n[i]=s,r[i]=s.peek())}}e(t)}),Nf("__r",function(e,t){e(t),Df();var n,r=t.__c;r&&(r.__$f&=-2,void 0===(n=r.__$u)&&(r.__$u=n=function(){var e;return Lf(function(){e=this}),e.c=function(){r.__$f|=1,r.setState({})},e}())),Df(n)}),Nf("__e",function(e,t,n,r){Df(),e(t,n,r)}),Nf("diffed",function(e,t){var n;if(Df(),"string"==typeof t.type&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var s=n.U;if(s)for(var o in s){var a=s[o];void 0===a||o in r||(a.d(),s[o]=void 0)}else n.U=s={};for(var l in r){var c=s[l],u=r[l];void 0===c?(c=Bf(n,l,u,i),s[l]=c):c.o(u,i)}}}e(t)}),Nf("unmount",function(e,t){if("string"==typeof t.type){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var s=r[i];s&&s.d()}}}else{var o=t.__c;if(o){var a=o.__$u;a&&(o.__$u=void 0,a.d())}}e(t)}),Nf("__h",function(e,t,n,r){(r<3||9===r)&&(t.__$f|=2),e(t,n,r)}),tp.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&void 0!==n.s;for(var i in t)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(r||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var s in e)if("__source"!==s&&e[s]!==this.props[s])return!0;for(var o in this.props)if(!(o in e))return!0;return!1};var Ff={primaryColor:"#7B68EE",fontFamily:"'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",borderRadius:"12px"};class jf{constructor(){this.isOpen=kf(!1),this.isVisible=kf(!0),this.isLoading=kf(!1),this.currentView=kf("list"),this.channels=kf([]),this.channel=kf(null),this.messages=kf([]),this.isTyping=kf(!1),this.typingSender=kf(null),this.typingSenderType=kf(null),this.agentLastReadAt=kf(null),this.initialUserReadAt=kf(null),this.userScrolledUp=kf(!1),this.unreadNewMessagesCount=kf(0),this.theme=kf(n({},Ff)),this.connectionState=kf("disconnected"),this.ablyProjectId=kf(null),this.realtimeChannelId=kf(null),this.realtimeAttached=kf(!1),this.pendingRealtimeChannelId=kf(null),this.identityChangeInFlight=kf(!1),this.lastConnectedDistinctId=kf(null),this._messagesCache=new Map,this.isConnected=Af(()=>"connected"===this.connectionState.value),this.polledUnreadTotal=kf(null),this.unreadCount=Af(()=>this.isOpen.value||null===this.polledUnreadTotal.value?this.channels.value.reduce((e,t)=>e+(t.unread_count||0),0):this.polledUnreadTotal.value),this.connectionBanner=Af(()=>{var e=this.connectionState.value;return"suspended"===e?"reconnecting":"failed"===e?"failed":"none"}),this.realtimeReady=Af(()=>{var e=this.channel.value;return!!e&&("connected"===this.connectionState.value&&this.realtimeAttached.value&&this.realtimeChannelId.value===e.id)})}setMessages(e){this.messages.value=e}patchChannelSummary(e,t){var r=this.channels.value.findIndex(t=>t.id===e);if(-1!==r){var i=[...this.channels.value];i[r]=n({},i[r],t),i.sort((e,t)=>{var n=e.last_message_at||e.created_at,r=t.last_message_at||t.created_at;return new Date(r).getTime()-new Date(n).getTime()}),this.channels.value=i}}prependChannelSummary(e){this.channels.value.some(t=>t.id===e.id)||(this.channels.value=[e,...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(e,t){if(e){var n=t.filter(e=>!e.id.startsWith("temp-"));for(this._messagesCache.delete(e),this._messagesCache.set(e,n);this._messagesCache.size>jf.MESSAGES_CACHE_LIMIT;){var r=this._messagesCache.keys().next().value;if(void 0===r)break;this._messagesCache.delete(r)}}}getCachedMessages(e){if(!e)return null;var t=this._messagesCache.get(e);return t?(this._messagesCache.delete(e),this._messagesCache.set(e,t),t):null}clearMessagesCache(){this._messagesCache.clear()}}jf.MESSAGES_CACHE_LIMIT=10;var Wf={bottom:20,right:20,left:20};function Hf(e,t){return void 0!==e&&Number.isFinite(e)?Math.max(0,e):t}function zf(e){return null===e?n({},Wf):{bottom:Hf(null==e?void 0:e.bottom,Wf.bottom),right:Hf(null==e?void 0:e.right,Wf.right),left:Hf(null==e?void 0:e.left,Wf.left)}}function Vf(e,t,n){e.style.bottom=n.bottom+"px","bottom-right"===t?(e.style.right=n.right+"px",e.style.left=""):(e.style.left=n.left+"px",e.style.right="")}var qf="vtilt-bubble-pos";function $f(e){try{localStorage.setItem(qf,JSON.stringify(e))}catch(e){}}function Gf(e,t,n){var r=e.getBoundingClientRect(),i=r.left-t,s=r.top-n,o=window.innerWidth-e.offsetWidth-i,a=-i,l=window.innerHeight-e.offsetHeight-s,c=-s;return{x:Math.min(Math.max(t,a),o),y:Math.min(Math.max(n,c),l)}}function Jf(e,t,n){e.style.transform="translate3d("+t+"px, "+n+"px, 0)"}function Kf(e,t){var n,r=null!==(n=null==t?void 0:t.handle)&&void 0!==n?n:e,i=null==t?void 0:t.onPositionChange,s=0,o=0,a=0,l=0,c=0,u=0,d=!1,h=!1,p=function(){try{var e=localStorage.getItem(qf);if(!e)return null;var t=JSON.parse(e);if("number"==typeof t.x&&"number"==typeof t.y)return t}catch(e){}return null}();if(p){s=p.x,o=p.y;var f=e.style.transition;e.style.transition="none",Jf(e,s,o);var v=Gf(e,s,o);s=v.x,o=v.y,Jf(e,s,o),e.offsetHeight,e.style.transition=f}r.style.cursor="grab",r.style.touchAction="none";var g=t=>{0===t.button&&(d=!0,h=!1,a=t.clientX,l=t.clientY,c=s,u=o,r.setPointerCapture(t.pointerId),r.style.cursor="grabbing",e.style.transition="none")},m=t=>{if(d){var n=t.clientX-a,r=t.clientY-l;if(!(!h&&Math.abs(n)<5&&Math.abs(r)<5)){h=!0;var p={x:c+n,y:u+r},f=Gf(e,p.x,p.y);s=f.x,o=f.y,Jf(e,s,o),null==i||i()}}},_=()=>{d&&(d=!1,r.style.cursor="grab",e.style.transition="",h&&($f({x:s,y:o}),null==i||i()))},y=e=>{h&&(e.stopPropagation(),e.preventDefault(),h=!1)},b=()=>{var t=s,n=o,r=Gf(e,s,o);s=r.x,o=r.y,Jf(e,s,o),t===s&&n===o||$f({x:s,y:o}),null==i||i()};return r.addEventListener("pointerdown",g),r.addEventListener("pointermove",m),r.addEventListener("pointerup",_),r.addEventListener("pointercancel",_),r.addEventListener("click",y,!0),window.addEventListener("resize",b),{destroy(){r.removeEventListener("pointerdown",g),r.removeEventListener("pointermove",m),r.removeEventListener("pointerup",_),r.removeEventListener("pointercancel",_),r.removeEventListener("click",y,!0),window.removeEventListener("resize",b)}}}function Yf(e){var{store:t,controller:n,bubbleRef:r}=e,i=t.unreadCount.value;return kp("button",{type:"button",class:"vt-bubble",ref:r,onClick:()=>n.toggle(),"aria-label":"Open chat",children:[kp(sf,{}),kp("span",{class:"vt-bubble-badge","data-visible":i>0?"true":"false",children:i>99?"99+":i})]})}function Zf(e){var{channel:t,onSelect:n}=e,r=t.unread_count>0,i=function(e){var t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5);if(r<1)return"Just now";if(r<60)return r+"m ago";if(i<24)return i+"h ago";if(s<7)return s+"d ago";return t.toLocaleDateString()}(t.last_message_at||t.created_at),s=t.last_message_preview||"No messages yet",o="user"===t.last_message_sender?"You: ":"",a="closed"===t.status?" · Closed":"";return kp("button",{type:"button",class:"vt-channel-item","data-channel-id":t.id,onClick:()=>n(t.id),children:[kp("div",{class:"vt-channel-avatar","data-mode":t.ai_mode?"ai":"support",children:t.ai_mode?kp(of,{width:24,height:24}):kp(af,{width:24,height:24})}),kp("div",{class:"vt-channel-body",children:[kp("div",{class:"vt-channel-row",children:[kp("div",{class:"vt-channel-name","data-unread":r?"true":"false",children:t.ai_mode?"AI Assistant":"Support"}),kp("div",{class:"vt-channel-time",children:i})]}),kp("div",{class:"vt-channel-row",children:[kp("div",{class:"vt-channel-preview","data-unread":r?"true":"false",children:[o,s,a]}),r&&kp("div",{class:"vt-channel-unread",children:t.unread_count>99?"99+":t.unread_count})]})]})]})}function Xf(){return kp("div",{style:"flex: 1; overflow: hidden;",children:[kp(Qf,{}),kp(Qf,{}),kp(Qf,{}),kp(Qf,{})]})}function Qf(){return kp("div",{style:"padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--vtilt-border-light); background: white;",children:[kp("div",{class:"vt-skeleton-circle",style:"width: 48px; height: 48px; flex-shrink: 0;"}),kp("div",{style:"flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px;",children:[kp("div",{class:"vt-skeleton",style:"height: 12px; width: 40%;"}),kp("div",{class:"vt-skeleton",style:"height: 10px; width: 80%;"})]})]})}function ev(){return kp(ep,{children:[kp(tv,{direction:"in",widthPct:62,metaPx:92,height:40}),kp(tv,{direction:"out",widthPct:42,metaPx:56,height:40}),kp(tv,{direction:"in",widthPct:78,metaPx:76,height:60})]})}function tv(e){var{direction:t,widthPct:n,metaPx:r,height:i}=e;return kp("div","in"===t?{style:"display: flex; gap: 10px; align-items: flex-end;",children:[kp("div",{class:"vt-skeleton-circle",style:"width: 32px; height: 32px; flex-shrink: 0;"}),kp("div",{style:"display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 85%;",children:[kp("div",{class:"vt-skeleton",style:"width: "+n+"%; min-width: 96px; height: "+i+"px; border-radius: 20px 20px 20px 4px;"}),kp("div",{class:"vt-skeleton",style:"height: 10px; width: "+r+"px; margin-top: 8px; margin-left: 6px; border-radius: 4px;"})]})]}:{style:"display: flex; flex-direction: column; align-items: flex-end;",children:[kp("div",{class:"vt-skeleton",style:"width: "+n+"%; min-width: 80px; max-width: 80%; height: "+i+"px; border-radius: 20px 20px 4px 20px;"}),kp("div",{class:"vt-skeleton",style:"height: 10px; width: "+r+"px; margin-top: 8px; margin-right: 6px; border-radius: 4px;"})]})}function nv(e){var{store:t,controller:n}=e,r=t.channels.value,i=t.isLoading.value;return 0===r.length&&i?kp(Xf,{}):0===r.length?kp(rv,{controller:n}):kp(ep,{children:[kp("div",{class:"vt-list-root",children:r.map(e=>kp(Zf,{channel:e,onSelect:e=>{n.selectChannel(e)}},e.id))}),kp("div",{class:"vt-list-footer",children:kp("button",{type:"button",class:"vt-new-channel-btn",onClick:()=>{n.createChannel()},children:["Send us a message",kp(rf,{width:18,height:18})]})})]})}function rv(e){var{controller:t}=e,n=t.config.greeting||"Hi! How can we help you today?";return kp("div",{class:"vt-list-empty",children:[kp("div",{class:"vt-list-empty-icon",children:kp(lf,{})}),kp("div",{class:"vt-list-empty-title",children:n}),kp("div",{class:"vt-list-empty-subtitle",children:"Start a conversation with us"}),kp("button",{type:"button",class:"vt-new-channel-btn",style:"width: auto; padding: 14px 28px;",onClick:()=>{t.createChannel()},children:["Send us a message",kp(rf,{width:18,height:18})]})]})}function iv(e){var t,n,r,{store:i,controller:s}=e;if("list"===i.currentView.value)return kp("div",{class:"vt-header","data-view":"list",children:[kp("div",{class:"vt-header-title",children:"Messages"}),kp("button",{type:"button",class:"vt-iconbtn vt-header-close",onClick:()=>s.close(),"aria-label":"Close",children:kp(tf,{})})]});var o=null===(r=null!==(n=null===(t=i.channel.value)||void 0===t?void 0:t.ai_mode)&&void 0!==n?n:s.config.aiMode)||void 0===r||r;return kp("div",{class:"vt-header","data-view":"conversation",children:[kp("button",{type:"button",class:"vt-iconbtn vt-header-back",onClick:()=>s.goToChannelList(),"aria-label":"Back",children:kp(nf,{})}),kp("div",{class:"vt-header-avatar","data-mode":o?"ai":"support",children:kp(o?of:af,{})}),kp("div",{class:"vt-header-info",children:[kp("div",{class:"vt-header-name",children:o?"AI Assistant":"Support"}),kp("div",{class:"vt-header-status",children:"Online"})]}),kp("button",{type:"button",class:"vt-iconbtn vt-header-close",onClick:()=>s.close(),"aria-label":"Close",children:kp(tf,{})})]})}function sv(){return kp("div",{class:"vt-closed-banner",children:"This conversation has been closed."})}function ov(e){var{store:t}=e,n=t.connectionBanner.value,r=function(e,t){var[n,r]=Fp(!1);return jp(()=>{if(e){var n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)}r(!1)},[e,t]),n}("reconnecting"===n,2500),i=zp(()=>{"undefined"!=typeof window&&window.location.reload()},[]);return"failed"===n?kp("div",{class:"vt-conn-banner","data-kind":"failed",role:"alert",children:[kp("span",{class:"vt-conn-banner-icon","aria-hidden":"true",children:kp("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[kp("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"}),kp("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),kp("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),kp("span",{class:"vt-conn-banner-text",children:"Connection lost"}),kp("button",{type:"button",class:"vt-conn-banner-action",onClick:i,children:"Retry"})]}):r?kp("div",{class:"vt-conn-banner","data-kind":"reconnecting",role:"status",children:[kp("span",{class:"vt-conn-banner-dot","aria-hidden":"true"}),kp("span",{class:"vt-conn-banner-text",children:"Reconnecting"})]}):null}function av(e){var{store:t,controller:n}=e,[r,i]=Fp(""),s=Wp(null),o=null==t.channel.value,a=()=>{var e=r.trim();e&&(n.stopUserTyping(),n.sendMessage(e),i(""),s.current&&(s.current.style.height="",s.current.focus()))};return jp(()=>{s.current&&function(e){e.style.height="auto";var t=120,n=60;e.style.height=Math.min(Math.max(e.scrollHeight,n),t)+"px"}(s.current)},[r]),kp("div",{class:"vt-input-container","data-pending":o?"true":"false",children:kp("div",{class:"vt-input-box",children:[kp("textarea",{class:"vt-input-textarea",ref:s,rows:1,placeholder:o?"Starting conversation…":"Message...",autocomplete:"off",autocorrect:"on",autocapitalize:"sentences",disabled:o,value:r,onInput:e=>{var t=e.currentTarget.value;i(t),n.notifyUserTyping()},onBlur:()=>{n.stopUserTyping()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),a())}}),kp("button",{type:"button",class:"vt-input-send","data-active":r.trim().length>0?"true":"false",disabled:0===r.trim().length||o,onClick:a,"aria-label":"Send message",children:kp(rf,{})})]})})}function lv(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function cv(e,t){this.props=e,this.context=t}function uv(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&("function"==typeof n?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:lv(this.props,e)}function r(t){return this.shouldComponentUpdate=n,Xh(e,t)}return r.displayName="Memo("+(e.displayName||e.name)+")",r.__f=r.prototype.isReactComponent=!0,r.type=e,r}(cv.prototype=new tp).isPureReactComponent=!0,cv.prototype.shouldComponentUpdate=function(e,t){return lv(this.props,e)||lv(this.state,t)};var dv=Rh.__b;Rh.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),dv&&dv(e)};var hv=Rh.__e;Rh.__e=function(e,t,n,r){if(e.then)for(var i,s=t;s=s.__;)if((i=s.__c)&&i.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t);hv(e,t,n,r)};var pv=Rh.unmount;function fv(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=function(e,t){for(var n in t)e[n]=t[n];return e}({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return fv(e,t,n)})),e}function vv(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return vv(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function gv(){this.__u=0,this.o=null,this.__b=null}function mv(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function _v(){this.i=null,this.l=null}Rh.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),pv&&pv(e)},(gv.prototype=new tp).__c=function(e,t){var n=t.__c,r=this;null==r.o&&(r.o=[]),r.o.push(n);var i=mv(r.__v),s=!1,o=function(){s||r.__z||(s=!0,n.__R=null,i?i(l):l())};n.__R=o;var a=n.__P;n.__P=null;var l=function(){if(! --r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=vv(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=a,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},gv.prototype.componentWillUnmount=function(){this.o=[]},gv.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=fv(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&Xh(ep,null,e.fallback);return i&&(i.__u&=-33),[Xh(ep,null,t.__a?null:e.children),i]};var yv=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(_v.prototype=new tp).__a=function(e){var t=this,n=mv(t.__v),r=t.l.get(e);return r[0]++,function(i){var s=function(){t.props.revealOrder?(r.push(i),yv(t,e,r)):i()};n?n(s):s()}},_v.prototype.render=function(e){this.i=null,this.l=new Map;var t=cp(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},_v.prototype.componentDidUpdate=_v.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){yv(e,n,t)})};var bv="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,wv=/^(?: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]/,Cv=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Sv=/[A-Z0-9]/g,kv="undefined"!=typeof document,xv=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};tp.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(tp.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Iv=Rh.event;Rh.event=function(e){return Iv&&(e=Iv(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Tv={configurable:!0,get:function(){return this.class}},Ev=Rh.vnode;Rh.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,r={},i=-1==n.indexOf("-");for(var s in t){var o=t[s];if(!("value"===s&&"defaultValue"in t&&null==o||kv&&"children"===s&&"noscript"===n||"class"===s||"className"===s)){var a=s.toLowerCase();"defaultValue"===s&&"value"in t&&null==t.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"!==n&&"textarea"!==n||xv(t.type)?"onfocus"===a?s="onfocusin":"onblur"===a?s="onfocusout":Cv.test(s)&&(s=a):a=s="oninput":i&&wv.test(s)?s=s.replace(Sv,"-$&").toLowerCase():null===o&&(o=void 0),"oninput"===a&&r[s=a]&&(s="oninputCapture"),r[s]=o}}"select"==n&&(r.multiple&&Array.isArray(r.value)&&(r.value=cp(t.children).forEach(function(e){e.props.selected=-1!=r.value.indexOf(e.props.value)})),null!=r.defaultValue&&(r.value=cp(t.children).forEach(function(e){e.props.selected=r.multiple?-1!=r.defaultValue.indexOf(e.props.value):r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",Tv)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=bv,Ev&&Ev(e)};var Av=Rh.__r;Rh.__r=function(e){Av&&Av(e),e.__c};var Ov=Rh.diffed;function Mv(e,t){var n=Date.parse(e.created_at),r=Date.parse(t.created_at);return n!==r?n-r:e.id.localeCompare(t.id)}function Rv(e,t){return function(e){return e.length<2?e:[...e].sort(Mv)}([...e,t])}Rh.diffed=function(e){Ov&&Ov(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value)};var Pv="chat.stream",Lv=/<!--vtilt:widget:([\s\S]*?)-->/g;function Nv(e){for(var t,n,r=[],i=new RegExp(Lv.source,"g");null!==(n=i.exec(e));)try{var s=JSON.parse(n[1]);s.type&&r.push({type:s.type,params:null!==(t=s.params)&&void 0!==t?t:{}})}catch(e){}return r}function Dv(e){return Uv.apply(this,arguments)}function Uv(){return Uv=t(function*(e){var t,r,i,{store:s,response:o,channelId:a,tempId:l,signal:c,isActive:u,onStreamStart:d,onComplete:h}=e,p=()=>{var e;return!(null==c?void 0:c.aborted)&&(null===(e=null==u?void 0:u())||void 0===e||e)},f=o.headers.get("X-Vtilt-Message-Id"),v=o.headers.get("X-Vtilt-Message-Created-At"),g=null!==(t=null!=l?l:f)&&void 0!==t?t:"temp-ai-"+Date.now();if(p()&&(null==d||d(g),p())){var m={id:g,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!=v?v:(new Date).toISOString()};s.setMessages(Rv(s.messages.value,m));var _=null===(r=o.body)||void 0===r?void 0:r.getReader();if(!_)return cu().error(Pv,"no response body reader available"),void Bv(s,g);var y=new TextDecoder,b="",w=null,C=!0,S=()=>{if(p()){var e=s.messages.value.findIndex(e=>e.id===g);if(-1!==e){var t=[...s.messages.value];t[e]=n({},t[e],{content:b.replace(/<[^>]*$/,"")}),s.setMessages(t)}}else Bv(s,g)},k=()=>{null===w&&(w=requestAnimationFrame(()=>{S(),w=null}))};try{for(;;){if(!p())return void Bv(s,g);var{done:x,value:I}=yield _.read();if(x)break;var T=y.decode(I,{stream:!0});b+=T,C?(C=!1,S()):k()}if(!p())return void Bv(s,g);null!==w&&(cancelAnimationFrame(w),w=null),S();var E=s.messages.value.findIndex(e=>e.id===g);if(-1!==E){var A=Nv(b),O=[...s.messages.value],M=n({},null!==(i=O[E].metadata)&&void 0!==i?i:{});A.length>0&&(M._widgets=A),O[E]=n({},O[E],{content:b,metadata:M}),s.setMessages(O)}null==h||h(g)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return void Bv(s,g);cu().error(Pv,"failed to handle streaming response:",e),Bv(s,g)}finally{_.releaseLock(),null!==w&&cancelAnimationFrame(w)}}}),Uv.apply(this,arguments)}function Bv(e,t){var n=e.messages.value.filter(e=>e.id!==t);n.length!==e.messages.value.length&&e.setMessages(n)}var Fv=/<(?:p|ul|ol|li|h[1-6]|br|div|pre|blockquote)\b/i,jv=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 Wv(e){var t=e;return t=(t=(t=(t=(t=(t=t.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 Hv(e,t){for(var n=Array.from(e.children),r=0;r<n.length;){var i=n[r];if("LI"!==i.tagName)Hv(i,t),r++;else{for(var s=[],o=r;o<n.length&&"LI"===n[o].tagName;)s.push(n[o]),o++;var a=t.createElement("ul");for(var l of(e.insertBefore(a,s[0]),s))a.appendChild(l);r=o}}}function zv(e,t){if(void 0===t&&(t="text"),!e)return"";var n=e.trim();if(!n)return"";if("undefined"==typeof document)return n;var r=function(e,t){return"html"!==e&&!Fv.test(t)}(t,n)?function(e){if(!e||Fv.test(e))return e;for(var t=e.split("\n"),n=[],r=0;r<t.length;){var i=t[r],s=i.match(/^(#{1,6})\s+(.+)$/);if(s){var o=s[1].length;n.push("<h"+o+">"+Wv(s[2])+"</h"+o+">"),r++}else if(/^[-*]\s+/.test(i)){for(var a=[];r<t.length&&/^[-*]\s+/.test(t[r]);)a.push("<li>"+Wv(t[r].replace(/^[-*]\s+/,""))+"</li>"),r++;n.push("<ul>"+a.join("")+"</ul>")}else if(/^\d+\.\s+/.test(i)){for(var l=[];r<t.length&&/^\d+\.\s+/.test(t[r]);)l.push("<li>"+Wv(t[r].replace(/^\d+\.\s+/,""))+"</li>"),r++;n.push("<ol>"+l.join("")+"</ol>")}else if(""!==i.trim()){for(var c=[];r<t.length&&""!==t[r].trim()&&!/^#{1,6}\s/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r]);)c.push(Wv(t[r])),r++;n.push("<p>"+c.join("<br>")+"</p>")}else r++}return n.join("")}(n):n,i=document.createElement("div");return i.innerHTML=r,function(e,t){var n=e=>{for(var r of Array.from(e.children))if(jv.has(r.tagName)){for(var i of Array.from(r.attributes))"A"===r.tagName&&"href"===i.name||r.removeAttribute(i.name);"A"===r.tagName&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")),n(r)}else r.replaceWith(t.createTextNode(r.textContent||""))};n(e)}(i,document),Hv(i,document),i.innerHTML}var Vv=uv(function(e){var{message:t,controller:n}=e,r=function(e){var t,n=null!==(t=e.metadata)&&void 0!==t?t:{},r=n._widgets;r&&0!==r.length||(r=n.widgets);r&&0!==r.length||!e.content||(r=Nv(e.content));return null!=r?r:[]}(t);return 0===r.length?null:kp(ep,{children:r.map((e,r)=>{if(e.submitted)return kp(qv,{widget:e},r);var i=n.widgets.get(e.type);if(!i)return null;var s=n.getWidgetContext(t.id,e.type);return kp("div",{children:i.render(e.params,s)},r)})})},(e,t)=>e.message===t.message&&e.controller===t.controller);function qv(e){var t,n,{widget:r}=e;if("collect_email"===r.type){var i=null!==(t=r.submittedEmail)&&void 0!==t?t:"",s=null!==(n=r.submittedName)&&void 0!==n?n:"";return kp("div",{class:"vt-widget",children:kp("p",{class:"vt-widget-thanks",children:s?"✓ Thanks, "+s+"! We'll follow up at "+i+".":i?"✓ Thanks! We'll follow up at "+i+".":"✓ Thanks!"})})}return"escalate_to_human"===r.type?kp("div",{class:"vt-widget",children:kp("p",{class:"vt-widget-thanks",children:"✓ A team member has been notified. They'll join shortly."})}):kp("div",{class:"vt-widget",children:kp("p",{class:"vt-widget-thanks",children:"✓ Done"})})}var $v=uv(function(e){var{message:t,controller:n,isReadByAgent:r}=e,i="user"===t.sender_type?"out":"in",s=Hp(()=>function(e){if("user"===e.sender_type)return"";if("ai"===e.sender_type)return"AI Assistant";return e.sender_name||"Agent"}(t),[t.sender_type,t.sender_name]);return kp("div",{class:"vt-message","data-direction":i,children:[kp("div",{class:"vt-message-row",children:["in"===i&&kp(Jv,{senderType:t.sender_type}),kp(Gv,{message:t})]}),kp(Vv,{message:t,controller:n}),kp("div",{class:"vt-message-meta",children:[s?kp("span",{children:s}):null,s?kp("span",{children:" · "}):null,kp("time",{children:Yv(t.created_at)}),"out"===i?kp(Kv,{message:t,controller:n}):null,"out"===i&&r?kp("span",{children:" · Read"}):null]})]})},(e,t)=>e.message===t.message&&e.message.delivery_status===t.message.delivery_status&&e.controller===t.controller&&e.isReadByAgent===t.isReadByAgent);function Gv(e){var t,{message:n}=e,r=(null!==(t=n.content)&&void 0!==t?t:"").replace(Lv,"").trim();if(!r)return kp("div",{class:"vt-message-bubble"});if(!Th(n))return kp("div",{class:"vt-message-bubble",children:r});var i=zv(r,n.content_type);return kp("div",{class:"vt-message-bubble",children:kp("div",{class:"vt-md"+("user"===n.sender_type?" vt-user-md":""),dangerouslySetInnerHTML:{__html:i}})})}function Jv(e){var{senderType:t}=e,n="ai"===t;return kp("div",{class:"vt-message-avatar","data-mode":n?"ai":"support",children:kp(n?of:af,{width:16,height:16})})}function Kv(e){var{message:t,controller:n}=e,r=t.delivery_status;return r?kp("span","pending"===r||"sending"===r?{children:" · Sending…"}:{children:[" · ",kp("button",{type:"button",class:"vt-message-retry",onClick:()=>n.retryFailedMessage(t.id),children:"Failed — tap to retry"})]}):null}function Yv(e){if(!e)return"";var t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zv(e){var{senderType:t,senderName:n}=e,r="ai"===t,i=r?"AI Assistant":n||"Agent";return kp("div",{class:"vt-message","data-direction":"in","data-typing":"true",children:[kp("div",{class:"vt-message-row",children:[kp("div",{class:"vt-message-avatar","data-mode":r?"ai":"support",children:kp(r?of:af,{width:16,height:16})}),kp("div",{class:"vt-message-bubble","data-typing":"true","aria-label":i+" is typing",children:[kp("span",{class:"vt-typing-dot"}),kp("span",{class:"vt-typing-dot"}),kp("span",{class:"vt-typing-dot"})]})]}),kp("div",{class:"vt-message-meta",children:kp("span",{children:i})})]})}function Xv(e){var{count:t,visible:n,onJump:r}=e;return kp("button",{type:"button",class:"vt-new-pill","data-visible":n&&t>0?"true":"false","aria-label":"Jump to latest messages",onClick:r,children:kp("span",{children:t>1?"↓ "+t+" new messages":"↓ 1 new message"})})}function Qv(e){var{store:t,scrollRef:n,messages:r,typingActive:i=!1}=e,s=Wp(null),o=Wp(0);return jp(()=>{var e=n.current;if(e){var r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<80?t.userScrolledUp.value&&(t.userScrolledUp.value=!1,t.unreadNewMessagesCount.value=0):t.userScrolledUp.value||(t.userScrolledUp.value=!0)};return e.addEventListener("scroll",r,{passive:!0}),()=>e.removeEventListener("scroll",r)}},[n.current]),jp(()=>{var e,i,a,l=n.current;if(l){var c=null!==(e=r[r.length-1])&&void 0!==e?e:null;if(c){var u=c.id,d=null!==(a=null===(i=c.content)||void 0===i?void 0:i.length)&&void 0!==a?a:0,h=u!==s.current,p=!h&&"ai"===c.sender_type&&d>o.current;if(h||p)if(s.current=u,o.current=d,h){if("user"===c.sender_type)return l.scrollTop=l.scrollHeight,t.userScrolledUp.value=!1,void(t.unreadNewMessagesCount.value=0);var f=l.scrollHeight-l.scrollTop-l.clientHeight<80;!t.userScrolledUp.value||f?l.scrollTop=l.scrollHeight:"agent"!==c.sender_type&&"ai"!==c.sender_type||(t.unreadNewMessagesCount.value=t.unreadNewMessagesCount.value+1)}else(e=>{var n=e.scrollHeight-e.scrollTop-e.clientHeight<80;t.userScrolledUp.value&&!n||(e.scrollTop=e.scrollHeight)})(l)}}},[r,n.current]),jp(()=>{if(i){var e=n.current;if(e){var r=e.scrollHeight-e.scrollTop-e.clientHeight<80;t.userScrolledUp.value&&!r||(e.scrollTop=e.scrollHeight)}}},[i,n.current]),{jumpToBottom:()=>{var e=n.current;e&&(e.scrollTop=e.scrollHeight,t.userScrolledUp.value=!1,t.unreadNewMessagesCount.value=0)}}}function eg(e){var{store:t,controller:n}=e,r=Wp(null),i=t.messages.value,s=t.channel.value,o=t.agentLastReadAt.value,a=t.isTyping.value,l=t.typingSenderType.value,c=t.typingSender.value,{jumpToBottom:u}=Qv({store:t,scrollRef:r,messages:i,typingActive:a});!function(e){var t,n,r,{store:i,controller:s,messages:o}=e;jp(()=>{if(i.isOpen.value&&"conversation"===i.currentView.value&&i.channel.value){var e=setTimeout(()=>s.markAsRead(),80);return()=>clearTimeout(e)}},[null!==(n=null===(t=o[o.length-1])||void 0===t?void 0:t.id)&&void 0!==n?n:null,i.isOpen.value,i.currentView.value,null===(r=i.channel.value)||void 0===r?void 0:r.id])}({store:t,controller:n,messages:i});var d=!s&&t.isLoading.value&&0===i.length,h=!!s&&t.isLoading.value&&0===i.length,p=a&&("ai"===l||"agent"===l);return kp("div",{class:"vt-messages-wrapper",children:[kp("div",{class:"vt-messages",ref:r,children:d?kp(Zv,{senderType:!1===n.config.aiMode?"agent":"ai"}):h?kp(ev,{}):kp(ep,{children:[i.map(e=>{return kp($v,{message:e,controller:n,isReadByAgent:(t=e.created_at,!!o&&new Date(t)<=new Date(o))},e.id);var t}),p&&kp(Zv,{senderType:l,senderName:c})]})}),kp(Xv,{count:t.unreadNewMessagesCount.value,visible:t.userScrolledUp.value,onJump:u})]})}function tg(e){var t,{store:n,controller:r}=e,i="closed"===(null===(t=n.channel.value)||void 0===t?void 0:t.status);return kp(ep,{children:[kp(eg,{store:n,controller:r}),kp(ov,{store:n}),i?kp(sv,{}):kp(av,{store:n,controller:r})]})}function ng(e){var{store:t,controller:n}=e,r=t.currentView.value;return kp("div",{class:"vt-panel vt-opening",children:[kp(iv,{store:t,controller:n}),kp("div",{class:"vt-content",children:kp("list"===r?nv:tg,{store:t,controller:n})})]})}var rg="vtilt-chat-font";function ig(e){!function(){if("undefined"!=typeof document&&!document.getElementById(rg)){var e=document.createElement("link");e.rel="preconnect",e.href="https://fonts.gstatic.com",e.crossOrigin="anonymous",document.head.appendChild(e);var t=document.createElement("link");t.id=rg,t.rel="stylesheet",t.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap",document.head.appendChild(t)}}();var t=document.createElement("div");t.id="vtilt-chat-host",t.style.cssText="all: initial; position: fixed; inset: auto; z-index: 999999; pointer-events: none;",document.body.appendChild(t);var n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.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',n.appendChild(r);var i=document.createElement("div");return i.style.cssText="pointer-events: auto;",n.appendChild(i),function(e,t){var n=()=>{var n=t.theme.value;e.style.setProperty("--vtilt-primary",n.primaryColor),e.style.setProperty("--vtilt-primary-shadow",n.primaryColor+"66"),e.style.setProperty("--vtilt-font",n.fontFamily),e.style.setProperty("--vtilt-radius",n.borderRadius)};n(),t.theme.subscribe(n)}(t,e.store),Cp(kp(sg,{store:e.store,controller:e.controller,position:e.position,bubbleDraggable:e.bubbleDraggable}),i),{host:t,destroy(){Cp(null,i),t.remove()}}}function sg(e){var{store:t,controller:n,position:r,bubbleDraggable:i}=e,s=Wp(null),o=Wp(null),a=Wp(null),l=function(e,t){return zp(()=>{var n=t.current;if(n&&"undefined"!=typeof window&&!e.isOpen.value){var r=n.getBoundingClientRect();if(0!==r.width&&0!==r.height){var i=window.innerWidth,s=window.innerHeight,o=(r.left+r.right)/2>i/2?"right":"left",a=(r.top+r.bottom)/2>s/2?"bottom":"top",l=a+"-"+o;n.setAttribute("data-panel-anchor",l),n.style.setProperty("--vt-panel-origin",a+" "+o);var c="right"===o?r.right:i-r.left,u="bottom"===a?r.bottom:s-r.top;n.style.setProperty("--vt-panel-max-w",Math.max(0,c-20)+"px"),n.style.setProperty("--vt-panel-max-h",Math.max(0,u-20)+"px")}}},[e,t])}(t,s);return function(e,t){var n=Bp(xp++,4);!Mp.__s&&Kp(n.__H,t)&&(n.__=e,n.u=t,Ip.__h.push(n))}(()=>{if(i&&s.current&&o.current)return a.current=Kf(s.current,{handle:o.current,onPositionChange:l}),()=>{var e;null===(e=a.current)||void 0===e||e.destroy(),a.current=null}},[i,l]),jp(()=>{l();var e=()=>l();window.addEventListener("resize",e);var n=t.isOpen.subscribe(e=>{e||l()});return()=>{window.removeEventListener("resize",e),n()}},[t,l]),function(e){jp(()=>{var t=e.isOpen.value,n=e.isOpen.subscribe(e=>{var n,r;if("undefined"!=typeof document){var i=function(e,t,n){return n?t&&!e?{nextWasOpen:!0,shouldLock:!0,shouldUnlock:!1}:!t&&e?{nextWasOpen:!1,shouldLock:!1,shouldUnlock:!0}:{nextWasOpen:t,shouldLock:!1,shouldUnlock:!1}:{nextWasOpen:t,shouldLock:!1,shouldUnlock:!1}}(t,e,"undefined"!=typeof window&&window.innerWidth<=480);t=i.nextWasOpen;var s=document.documentElement,o=document.body;if(i.shouldLock){var a=null!==(n=null===window||void 0===window?void 0:window.scrollY)&&void 0!==n?n: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(i.shouldUnlock){var l=Number(null!==(r=o.dataset.vtScrollY)&&void 0!==r?r: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 t=e});return n},[e])}(t),kp("div",{ref:s,class:"vt-container","data-position":r,"data-draggable":i?"true":"false","data-hidden":t.isVisible.value?"false":"true","data-open":t.isOpen.value?"true":"false",children:[kp(Yf,{store:t,controller:n,bubbleRef:o}),kp(ng,{store:t,controller:n})]})}var og=Object.defineProperty,ag=Object.defineProperties,lg=Object.getOwnPropertyDescriptors,cg=Object.getOwnPropertySymbols,ug=Object.prototype.hasOwnProperty,dg=Object.prototype.propertyIsEnumerable,hg=(e,t,n)=>t in e?og(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pg=(e,t)=>{for(var n in t||(t={}))ug.call(t,n)&&hg(e,n,t[n]);if(cg)for(var n of cg(t))dg.call(t,n)&&hg(e,n,t[n]);return e},fg=(e,t)=>ag(e,lg(t)),vg=function(e,t){this[0]=e,this[1]=t},gg=class{},mg="undefined"!=typeof global?global:"undefined"!=typeof window?window:self;function _g(e,t){return(""+e).padStart(t?3:2,"0")}function yg(e){return gg.Config.logTimestamps?function(t){var n=new Date;e(_g(n.getHours())+":"+_g(n.getMinutes())+":"+_g(n.getSeconds())+"."+_g(n.getMilliseconds(),1)+" "+t)}:function(t){e(t)}}var bg=class e{constructor(){this.deprecated=(e,t)=>{this.deprecationWarning(e+" is deprecated and will be removed in a future version. "+t)},this.shouldLog=e=>e<=this.logLevel,this.setLog=(e,t)=>{void 0!==e&&(this.logLevel=e),void 0!==t&&(this.logHandler=this.logErrorHandler=t)},this.logLevel=e.defaultLogLevel,this.logHandler=e.defaultLogHandler,this.logErrorHandler=e.defaultLogErrorHandler}static initLogHandlers(){var t,n,r,[i,s]=("function"==typeof(null==(t=null==mg?void 0:mg.console)?void 0:t.log)?(n=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.log.apply(console,t)},r=console.warn?function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.warn.apply(console,t)}:n):n=r=function(){},[n,r].map(yg));this.defaultLogHandler=i,this.defaultLogErrorHandler=s,this.defaultLogger=new e}static logActionNoStrip(e,t,n,r){e.logAction(t,n,r)}logAction(e,t,n){this.shouldLog(e)&&(1===e?this.logErrorHandler:this.logHandler)("Ably: "+t+": "+n,e)}renamedClientOption(e,t){this.deprecationWarning("The `"+e+"` client option has been renamed to `"+t+"`. Please update your code to use `"+t+"` instead. `"+e+"` will be removed in a future version.")}renamedMethod(e,t,n){this.deprecationWarning("`"+e+"`’s `"+t+"` method has been renamed to `"+n+"`. Please update your code to use `"+n+"` instead. `"+t+"` will be removed in a future version.")}deprecationWarning(e){this.shouldLog(1)&&this.logErrorHandler("Ably: Deprecation warning - "+e,1)}};bg.defaultLogLevel=1,bg.LOG_NONE=0,bg.LOG_ERROR=1,bg.LOG_MAJOR=2,bg.LOG_MINOR=3,bg.LOG_MICRO=4,bg.logAction=(e,t,n,r)=>{bg.logActionNoStrip(e,t,n,r)};var wg=bg,Cg={};function Sg(e){var t="["+e.constructor.name;return e.message&&(t+=": "+e.message),e.statusCode&&(t+="; statusCode="+e.statusCode),e.code&&(t+="; code="+e.code),e.cause&&(t+="; cause="+Zg(e.cause)),!e.href||e.message&&e.message.indexOf("help.ably.io")>-1||(t+="; see "+e.href+" "),t+="]"}((e,t)=>{for(var n in t)og(e,n,{get:t[n],enumerable:!0})})(Cg,{Format:()=>qg,allSame:()=>Vg,allToLowerCase:()=>om,allToUpperCase:()=>am,arrChooseN:()=>nm,arrDeleteValue:()=>Fg,arrEquals:()=>vm,arrIntersect:()=>Ug,arrIntersectOb:()=>Bg,arrPopRandomElement:()=>$g,arrWithoutValue:()=>jg,cheapRandStr:()=>em,containsValue:()=>Ng,copy:()=>Tg,createMissingPluginError:()=>gm,dataSizeBytes:()=>Qg,decodeBody:()=>im,encodeBody:()=>sm,ensureArray:()=>Eg,forInOwnNonNullProperties:()=>zg,getBackoffCoefficient:()=>lm,getGlobalObject:()=>dm,getJitterCoefficient:()=>cm,getRetryTime:()=>um,inherits:()=>Lg,inspectBody:()=>Xg,inspectError:()=>Zg,intersect:()=>Dg,isEmpty:()=>Og,isErrorInfoOrPartialErrorInfo:()=>Yg,isNil:()=>Mg,isObject:()=>Ag,keysArray:()=>Wg,listenerToAsyncIterator:()=>bm,matchDerivedChannel:()=>pm,mixin:()=>Ig,parseQueryString:()=>Kg,prototypicalClone:()=>Pg,randomString:()=>tm,shallowClone:()=>Rg,shallowEquals:()=>hm,stringifyValues:()=>Jg,throwMissingPluginError:()=>mm,toBase64:()=>fm,toQueryString:()=>Gg,valuesArray:()=>Hg,whenPromiseSettles:()=>rm,withTimeoutAsync:()=>_m});var kg=class e extends Error{constructor(t,n,r,i){super(t),void 0!==Object.setPrototypeOf&&Object.setPrototypeOf(this,e.prototype),this.code=n,this.statusCode=r,this.cause=i}toString(){return Sg(this)}static fromValues(t){var{message:n,code:r,statusCode:i}=t;if("string"!=typeof n||"number"!=typeof r||"number"!=typeof i)throw new Error("ErrorInfo.fromValues(): invalid values: "+gg.Config.inspect(t));var s=Object.assign(new e(n,r,i),t);return s.code&&!s.href&&(s.href="https://help.ably.io/error/"+s.code),s}},xg=class e extends Error{constructor(t,n,r,i){super(t),void 0!==Object.setPrototypeOf&&Object.setPrototypeOf(this,e.prototype),this.code=n,this.statusCode=r,this.cause=i}toString(){return Sg(this)}static fromValues(t){var{message:n,code:r,statusCode:i}=t;if("string"!=typeof n||!Mg(r)&&"number"!=typeof r||!Mg(i)&&"number"!=typeof i)throw new Error("PartialErrorInfo.fromValues(): invalid values: "+gg.Config.inspect(t));var s=Object.assign(new e(n,r,i),t);return s.code&&!s.href&&(s.href="https://help.ably.io/error/"+s.code),s}};function Ig(e){for(var t=0;t<(arguments.length<=1?0:arguments.length-1);t++){var n=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];if(!n)break;for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}function Tg(e){return Ig({},e)}function Eg(e){return Mg(e)?[]:Array.isArray(e)?e:[e]}function Ag(e){return"[object Object]"==Object.prototype.toString.call(e)}function Og(e){for(var t in e)return!1;return!0}function Mg(e){return null==e}function Rg(e){var t=new Object;for(var n in e)t[n]=e[n];return t}function Pg(e,t){class n{}n.prototype=e;var r=new n;return t&&Ig(r,t),r}var Lg=function(e,t){gg.Config.inherits?gg.Config.inherits(e,t):(e.super_=t,e.prototype=Pg(t.prototype,{constructor:e}))};function Ng(e,t){for(var n in e)if(e[n]==t)return!0;return!1}function Dg(e,t){return Array.isArray(t)?Ug(e,t):Bg(e,t)}function Ug(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r];-1!=t.indexOf(i)&&n.push(i)}return n}function Bg(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r];i in t&&n.push(i)}return n}function Fg(e,t){var n=e.indexOf(t),r=-1!=n;return r&&e.splice(n,1),r}function jg(e,t){var n=e.slice();return Fg(n,t),n}function Wg(e,t){var n=[];for(var r in e)t&&!Object.prototype.hasOwnProperty.call(e,r)||n.push(r);return n}function Hg(e,t){var n=[];for(var r in e)t&&!Object.prototype.hasOwnProperty.call(e,r)||n.push(e[r]);return n}function zg(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&e[n]&&t(n)}function Vg(e,t){if(0===e.length)return!0;var n=e[0][t];return e.every(function(e){return e[t]===n})}var qg=(e=>(e.msgpack="msgpack",e.json="json",e))(qg||{});function $g(e){return e.splice((t=e,Math.floor(Math.random()*t.length)),1)[0];var t}function Gg(e){var t=[];if(e)for(var n in e)t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.length?"?"+t.join("&"):""}function Jg(e){return Object.fromEntries(Object.entries(e).map(e=>{var[t,n]=e;return[t,String(n)]}))}function Kg(e){for(var t,n=/([^?&=]+)=?([^&]*)/g,r={};t=n.exec(e);)r[decodeURIComponent(t[1])]=decodeURIComponent(t[2]);return r}function Yg(e){return"object"==typeof e&&null!==e&&(e instanceof kg||e instanceof xg)}function Zg(e){var t,n;return e instanceof Error||"ErrorInfo"===(null==(t=null==e?void 0:e.constructor)?void 0:t.name)||"PartialErrorInfo"===(null==(n=null==e?void 0:e.constructor)?void 0:n.name)?e.toString():gg.Config.inspect(e)}function Xg(e){return gg.BufferUtils.isBuffer(e)?e.toString():"string"==typeof e?e:gg.Config.inspect(e)}function Qg(e){if(gg.BufferUtils.isBuffer(e))return gg.BufferUtils.byteLength(e);if("string"==typeof e)return gg.Config.stringByteSize(e);if("number"==typeof e)return 8;if("boolean"==typeof e)return 1;throw new Error("Expected input of Utils.dataSizeBytes to be a string, a number, a boolean or a buffer, but was: "+typeof e)}function em(){return String(Math.random()).substr(2)}var tm=function(){var e=t(function*(e){var t=yield gg.Config.getRandomArrayBuffer(e);return gg.BufferUtils.base64Encode(t)});return function(t){return e.apply(this,arguments)}}();function nm(e,t){for(var n=Math.min(t,e.length),r=e.slice(),i=[],s=0;s<n;s++)i.push($g(r));return i}function rm(e,t){e.then(e=>{null==t||t(null,e)}).catch(e=>{null==t||t(e)})}function im(e,t,n){return"msgpack"==n?(t||mm("MsgPack"),t.decode(e)):JSON.parse(String(e))}function sm(e,t,n){return"msgpack"==n?(t||mm("MsgPack"),t.encode(e,!0)):JSON.stringify(e)}function om(e){return e.map(function(e){return e&&e.toLowerCase()})}function am(e){return e.map(function(e){return e&&e.toUpperCase()})}function lm(e){return Math.min((e+2)/3,2)}function cm(){return 1-.2*Math.random()}function um(e,t){return e*lm(t)*cm()}function dm(){return"undefined"!=typeof global?global:"undefined"!=typeof window?window:self}function hm(e,t){return Object.keys(e).every(n=>e[n]===t[n])&&Object.keys(t).every(n=>t[n]===e[n])}function pm(e){var t=e.match(/^(\[([^?]*)(?:(.*))\])?(.+)$/);if(!t||!t.length||t.length<5)throw new kg("regex match failed",400,40010);if(t[2])throw new kg("cannot use a derived option with a "+t[2]+" channel",400,40010);return{qualifierParam:t[3]||"",channelName:t[4]}}function fm(e){var t=gg.BufferUtils,n=t.utf8Encode(e);return t.base64Encode(n)}function vm(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function gm(e){return new kg(e+" plugin not provided",40019,400)}function mm(e){throw gm(e)}function _m(e,t,n){return ym.apply(this,arguments)}function ym(){return ym=t(function*(e,t,n){void 0===t&&(t=5e3),void 0===n&&(n="Timeout expired");var r=new kg(n,5e4,500);return Promise.race([e,new Promise((e,n)=>setTimeout(()=>n(r),t))])}),ym.apply(this,arguments)}function bm(e){return t=this,n=null,r=function*(){var t=[],n=null,r=e(e=>{if(n){var r=n;n=null,r(e)}else t.push(e)});try{for(;;)if(t.length>0)yield t.shift();else{if(n)throw new kg("Concurrent next() calls are not supported",4e4,400);var i=yield new vg(new Promise(e=>{n=e}));yield i}}finally{r()}},i=(e,t,n,s)=>{try{var o=r[e](t),a=(t=o.value)instanceof vg,l=o.done;Promise.resolve(a?t[0]:t).then(r=>a?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,s):n({value:r,done:l})).catch(e=>i("throw",e,n,s))}catch(e){s(e)}},s=e=>o[e]=t=>new Promise((n,r)=>i(e,t,n,r)),o={},r=r.apply(t,n),o[Symbol.asyncIterator]=()=>o,s("next"),s("throw"),s("return"),o;var t,n,r,i,s,o}var wm="2.17.0",Cm={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:wm,protocolVersion:5,agent:"ably-js/"+wm,getPort:function(e,t){return t||e.tls?e.tlsPort:e.port},getHttpScheme:function(e){return e.tls?"https://":"http://"},getPrimaryDomainFromEndpoint:km,getEndpointFallbackHosts:xm,getFallbackHosts:Tm,getHosts:function(e){return[e.primaryDomain].concat(Tm(e))},checkHost:Em,objectifyOptions:function(e,t,n,r,i){if(void 0===e){var s=t?n+" must be initialized with either a client options object, an Ably API key, or an Ably Token":n+" must be initialized with a client options object";throw wg.logAction(r,wg.LOG_ERROR,n+"()",s),new Error(s)}var o;if("string"==typeof e)if(-1==e.indexOf(":")){if(!t){var a=n+" 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 wg.logAction(r,wg.LOG_ERROR,n+"()",a),new Error(a)}o={token:e}}else{if(!t){var l=n+" 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 wg.logAction(r,wg.LOG_ERROR,n+"()",l),new Error(l)}o={key:e}}else o=e;i&&(o=fg(pg({},o),{plugins:pg(pg({},i),o.plugins)}));return o},normaliseOptions:function(e,t,n){var r=null!=n?n:wg.defaultLogger;e.environment&&r.deprecated("The `environment` client option","Use the `endpoint` client option instead.");e.restHost&&r.deprecated("The `restHost` client option","Use the `endpoint` client option instead.");e.realtimeHost&&r.deprecated("The `realtimeHost` client option","Use the `endpoint` client option instead.");Om(e),"function"==typeof e.recover&&!0===e.closeOnUnload&&(wg.logAction(r,wg.LOG_ERROR,"Defaults.normaliseOptions","closeOnUnload was true and a session recovery function was set - these are mutually exclusive, so unsetting the latter"),e.recover=void 0);"closeOnUnload"in e||(e.closeOnUnload=!e.recover);"queueMessages"in e||(e.queueMessages=!0);var i=e.endpoint||Cm.ENDPOINT;e.fallbackHosts||e.restHost||e.realtimeHost||e.port||e.tlsPort||(e.fallbackHosts=xm(e.environment||i));var s=e.environment&&e.environment+".realtime.ably.net",o=e.restHost||e.realtimeHost||s||km(i);(e.fallbackHosts||[]).concat(o).forEach(Em),e.port=e.port||Cm.PORT,e.tlsPort=e.tlsPort||Cm.TLS_PORT,"tls"in e||(e.tls=!0);var a=function(e){var t={};for(var n in Cm.TIMEOUTS)t[n]=e[n]||Cm.TIMEOUTS[n];return t}(e);e.useBinaryProtocol=!!t&&("useBinaryProtocol"in e?gg.Config.supportsBinary&&e.useBinaryProtocol:gg.Config.preferBinary);var l={};e.clientId&&(l["X-Ably-ClientId"]=gg.BufferUtils.base64Encode(gg.BufferUtils.utf8Encode(e.clientId)));"idempotentRestPublishing"in e||(e.idempotentRestPublishing=!0);var c=null,u=e.connectivityCheckUrl;if(e.connectivityCheckUrl){var[d,h]=e.connectivityCheckUrl.split("?");c=h?Kg(h):{},-1===d.indexOf("://")&&(d="https://"+d),u=d}var p=e.wsConnectivityCheckUrl;p&&-1===p.indexOf("://")&&(p="wss://"+p);return fg(pg({},e),{primaryDomain:o,maxMessageSize:e.maxMessageSize||Cm.maxMessageSize,timeouts:a,connectivityCheckParams:c,connectivityCheckUrl:u,wsConnectivityCheckUrl:p,headers:l})},defaultGetHeaders:function(e,t){var{format:n,protocolVersion:r=Pm.protocolVersion}=void 0===t?{}:t;return{accept:Rm[null!=n?n:e.useBinaryProtocol?"msgpack":"json"],"X-Ably-Version":r.toString(),"Ably-Agent":Am(e)}},defaultPostHeaders:function(e,t){var{format:n,protocolVersion:r=Pm.protocolVersion}=void 0===t?{}:t,i=Rm[null!=n?n:e.useBinaryProtocol?"msgpack":"json"];return{accept:i,"content-type":i,"X-Ably-Version":r.toString(),"Ably-Agent":Am(e)}}};function Sm(e){return e.includes(".")||e.includes("::")||"localhost"===e}function km(e){return Sm(e)?e:e.startsWith("nonprod:")?e.replace("nonprod:","")+".realtime.ably-nonprod.net":e+".realtime.ably.net"}function xm(e){return Sm(e)?[]:e.startsWith("nonprod:")?Im(e.replace("nonprod:",""),"ably-realtime-nonprod.com"):Im(e,"ably-realtime.com")}function Im(e,t){return["a","b","c","d","e"].map(n=>e+"."+n+".fallback."+t)}function Tm(e){var t=e.fallbackHosts,n=void 0!==e.httpMaxRetryCount?e.httpMaxRetryCount:Cm.httpMaxRetryCount;return t?nm(t,n):[]}function Em(e){if("string"!=typeof e)throw new kg("host must be a string; was a "+typeof e,4e4,400);if(!e.length)throw new kg("host must not be zero-length",4e4,400)}function Am(e){var t=Cm.agent;if(e.agents)for(var n in e.agents)t+=" "+n+"/"+e.agents[n];return t}function Om(e){if(e.endpoint&&(e.environment||e.restHost||e.realtimeHost))throw new kg("The `endpoint` option cannot be used in conjunction with the `environment`, `restHost`, or `realtimeHost` options.",40106,400);if(e.environment&&(e.restHost||e.realtimeHost))throw new kg("The `environment` option cannot be used in conjunction with the `restHost`, or `realtimeHost` options.",40106,400)}function Mm(e,t,n){var r=n||{};if(r.cipher){e||mm("Crypto");var i=e.getCipher(r.cipher,t);r.cipher=i.cipherParams,r.channelCipher=i.cipher}else"cipher"in r&&(r.cipher=void 0,r.channelCipher=null);return r}var Rm={json:"application/json",xml:"application/xml",html:"text/html",msgpack:"application/x-msgpack",text:"text/plain"},Pm={protocolVersion:Cm.protocolVersion};var Lm=Cm;var Nm=class e{constructor(e,t){this.logger=e,this.members=t||[]}call(e,t){for(var n of this.members)if(n)try{n(e,t)}catch(e){wg.logAction(this.logger,wg.LOG_ERROR,"Multicaster multiple callback handler","Unexpected exception: "+e+"; stack = "+e.stack)}}push(){this.members.push(...arguments)}createPromise(){return new Promise((e,t)=>{this.push((n,r)=>{n?t(n):e(r)})})}resolveAll(e){this.call(null,e)}rejectAll(e){this.call(e)}static create(t,n){var r=new e(t,n);return Object.assign((e,t)=>r.call(e,t),{push:e=>r.push(e),createPromise:()=>r.createPromise(),resolveAll:e=>r.resolveAll(e),rejectAll:e=>r.rejectAll(e)})}},Dm=(e=>(e.Get="get",e.Delete="delete",e.Post="post",e.Put="put",e.Patch="patch",e))(Dm||{}),Um=Dm,Bm=(e=>(e[e.Success=200]="Success",e[e.NoContent=204]="NoContent",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.Forbidden=403]="Forbidden",e[e.RequestTimeout=408]="RequestTimeout",e[e.InternalServerError=500]="InternalServerError",e))(Bm||{});var Fm=Bm,jm=Math.pow(2,17);function Wm(e){return Yg(e)?(e.code||(403===e.statusCode?e.code=40300:(e.code=40170,e.statusCode=401)),e):new kg(Zg(e),e.code||40170,e.statusCode||401)}function Hm(e){if(!e)return"";"string"==typeof e&&(e=JSON.parse(e));var t=Object.create(null),n=Wg(e,!0);if(!n)return"";n.sort();for(var r=0;r<n.length;r++)t[n[r]]=e[n[r]].sort();return JSON.stringify(t)}function zm(e,t){if(e.authCallback);else if(e.authUrl);else if(e.key);else if(!e.tokenDetails){var n="authOptions must include valid authentication parameters";throw wg.logAction(t,wg.LOG_ERROR,"Auth()",n),new Error(n)}}var Vm=0;var qm=class{constructor(e,t){if(this.authOptions={},this.client=e,this.tokenParams=t.defaultTokenParams||{},this.currentTokenRequestId=null,this.waitingForTokenRequest=null,function(e){return e.useTokenAuth||!function(e){return"useTokenAuth"in e&&!e.useTokenAuth}(e)&&(e.authCallback||e.authUrl||e.token||e.tokenDetails)}(t))(function(e){return!e.key&&!e.authCallback&&!e.authUrl})(t)&&wg.logAction(this.logger,wg.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._saveTokenOptions(t.defaultTokenParams,t),zm(this.authOptions,this.logger);else{if(!t.key){var n="No authentication options provided; need one of: key, authUrl, or authCallback (or for testing only, token or tokenDetails)";throw wg.logAction(this.logger,wg.LOG_ERROR,"Auth()",n),new kg(n,40160,401)}this._saveBasicOptions(t)}}get logger(){return this.client.logger}authorize(e,n){var r=this;return t(function*(){if(n&&n.key&&r.authOptions.key!==n.key)throw new kg("Unable to update auth options with incompatible key",40102,401);try{var t=yield r._forceNewToken(null!=e?e:null,null!=n?n:null);return r.client.connection?new Promise((e,n)=>{r.client.connection.connectionManager.onAuthUpdated(t,(t,r)=>t?n(t):e(r))}):t}catch(e){throw r.client.connection&&e.statusCode===Fm.Forbidden&&r.client.connection.connectionManager.actOnErrorFromAuthorize(e),e}})()}_forceNewToken(e,n){var r=this;return t(function*(){r.tokenDetails=null,r._saveTokenOptions(e,n),zm(r.authOptions,r.logger);try{return r._ensureValidAuthCredentials(!0)}finally{delete r.tokenParams.timestamp,delete r.authOptions.queryTime}})()}requestToken(e,n){var r=this;return t(function*(){var t,i=n||r.authOptions,s=e||Tg(r.tokenParams),o=r.client;if(i.authCallback)t=i.authCallback;else if(i.authUrl)t=(e,t)=>{var n,s=Ig({accept:"application/json, text/plain"},i.authHeaders),o=i.authMethod&&"post"===i.authMethod.toLowerCase(),a=i.authUrl.indexOf("?");a>-1&&(n=Kg(i.authUrl.slice(a)),i.authUrl=i.authUrl.slice(0,a),o||(i.authParams=Ig(n,i.authParams)));var l=Ig({},i.authParams||{},e),c=e=>{var n,r,i=null!=(n=e.body)?n:null,s=null;if(e.error);else{var o=null!=(r=e.headers["content-type"])?r:null;s=Array.isArray(o)?o.join(", "):o}if(e.error)t(e.error,null);else if(e.unpacked)t(null,i);else if(gg.BufferUtils.isBuffer(i)&&(i=i.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(i.length>jm)return void t(new kg("authUrl response exceeded max permitted length",40170,401),null);try{i=JSON.parse(i)}catch(e){return void t(new kg("Unexpected error processing authURL response; err = "+e.message,40170,401),null)}}t(null,i,s)}else t(new kg("authUrl responded with unacceptable content-type "+s+", should be either text/plain, application/jwt or application/json",40170,401),null)}else t(new kg("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 d=Gg(l).slice(1);rm(r.client.http.doUri(Um.Post,i.authUrl,u,d,n),(e,t)=>c(e||t))}else rm(r.client.http.doUri(Um.Get,i.authUrl,s||{},null,l),(e,t)=>c(e||t))};else{if(!i.key){throw wg.logAction(r.logger,wg.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 kg("Need a new token, but authOptions does not include any way to request one (no authUrl, authCallback, or key)",40171,403)}t=(e,t)=>{rm(r.createTokenRequest(e,i),(e,n)=>t(e,null!=n?n:null))}}"capability"in s&&(s.capability=Hm(s.capability));return new Promise((e,n)=>{var a=!1,l=r.client.options.timeouts.realtimeRequestTimeout,c=setTimeout(()=>{a=!0;var e="Token request callback timed out after "+l/1e3+" seconds";wg.logAction(r.logger,wg.LOG_ERROR,"Auth.requestToken()",e),n(new kg(e,40170,401))},l);t(s,(t,s,l)=>{if(!a){if(clearTimeout(c),t)return wg.logAction(r.logger,wg.LOG_ERROR,"Auth.requestToken()","token request signing call returned error; err = "+Zg(t)),void n(Wm(t));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 wg.logAction(r.logger,wg.LOG_ERROR,"Auth.requestToken()",u),void n(new kg(u,40170,401))}var d=JSON.stringify(s).length;if(d>jm&&!i.suppressMaxLengthCheck)n(new kg("Token request/details object exceeded max permitted stringified size (was "+d+" bytes)",40170,401));else if("issued"in s)e(s);else{if(!("keyName"in s)){var h="Expected token request callback to call back with a token string, token request object, or token details object";return wg.logAction(r.logger,wg.LOG_ERROR,"Auth.requestToken()",h),void n(new kg(h,40170,401))}var p,f,v,g;f=(t,i,s)=>{if(t)return wg.logAction(r.logger,wg.LOG_ERROR,"Auth.requestToken()","token request API call returned error; err = "+Zg(t)),void n(Wm(t));s||(i=JSON.parse(i)),e(i)},v="/keys/"+(p=s).keyName+"/requestToken",g=Lm.defaultPostHeaders(r.client.options,{format:"json"}),i.requestHeaders&&Ig(g,i.requestHeaders),rm(r.client.http.do(Um.Post,function(e){return o.baseUri(e)+v},g,JSON.stringify(p),null),(e,t)=>e?f(e):f(t.error,t.body,t.unpacked))}}else 0===s.length?n(new kg("Token string is empty",40170,401)):s.length>jm?n(new kg("Token string exceeded max permitted length (was "+s.length+" bytes)",40170,401)):"undefined"===s||"null"===s?n(new kg("Token string was literal null/undefined",40170,401)):"{"!==s[0]||l&&l.indexOf("application/jwt")>-1?e({token:s}):n(new kg("Token was double-encoded; make sure you're not JSON-encoding an already encoded token request or details",40170,401))}})})})()}createTokenRequest(e,n){var r=this;return t(function*(){n=n||r.authOptions,e=e||Tg(r.tokenParams);var t=n.key;if(!t)throw new kg("No key specified",40101,403);var i=t.split(":"),s=i[0],o=i[1];if(!o)throw new kg("Invalid key specified",40101,403);if(""===e.clientId)throw new kg("clientId can’t be an empty string",40012,400);"capability"in e&&(e.capability=Hm(e.capability));var a=Ig({keyName:s},e),l=e.clientId||"",c=e.ttl||"",u=e.capability||"";a.timestamp||(a.timestamp=yield r._getTimestamp(n&&n.queryTime));var d=a.nonce||(a.nonce=("000000"+Math.floor(1e16*Math.random())).slice(-16)),h=a.timestamp,p=a.keyName+"\n"+c+"\n"+u+"\n"+l+"\n"+h+"\n"+d+"\n";return a.mac=a.mac||((e,t)=>{var n=gg.BufferUtils,r=n.utf8Encode(e),i=n.utf8Encode(t),s=n.hmacSha256(r,i);return n.base64Encode(s)})(p,o),a})()}getAuthParams(){var e=this;return t(function*(){if("basic"==e.method)return{key:e.key};var t=yield e._ensureValidAuthCredentials(!1);if(!t)throw new Error("Auth.getAuthParams(): _ensureValidAuthCredentials returned no error or tokenDetails");return{access_token:t.token}})()}getAuthHeaders(){var e=this;return t(function*(){if("basic"==e.method)return{authorization:"Basic "+e.basicKey};var t=yield e._ensureValidAuthCredentials(!1);if(!t)throw new Error("Auth.getAuthParams(): _ensureValidAuthCredentials returned no error or tokenDetails");return{authorization:"Bearer "+fm(t.token)}})()}_saveBasicOptions(e){this.method="basic",this.key=e.key,this.basicKey=fm(e.key),this.authOptions=e||{},"clientId"in e&&this._userSetClientId(e.clientId)}_saveTokenOptions(e,t){this.method="token",e&&(this.tokenParams=e),t&&(t.token&&(t.tokenDetails="string"==typeof t.token?{token:t.token}:t.token),t.tokenDetails&&(this.tokenDetails=t.tokenDetails),"clientId"in t&&this._userSetClientId(t.clientId),this.authOptions=t)}_ensureValidAuthCredentials(e){var n=this;return t(function*(){var t=n.tokenDetails;if(t){if(n._tokenClientIdMismatch(t.clientId))throw new kg("Mismatch between clientId in token ("+t.clientId+") and current clientId ("+n.clientId+")",40102,403);if(!n.client.isTimeOffsetSet()||!t.expires||t.expires>=n.client.getTimestampUsingOffset())return t;n.tokenDetails=null}var r=(n.waitingForTokenRequest||(n.waitingForTokenRequest=Nm.create(n.logger))).createPromise();if(null!==n.currentTokenRequestId&&!e)return r;var i,s=n.currentTokenRequestId=Vm++,o=null;try{i=yield n.requestToken(n.tokenParams,n.authOptions)}catch(e){o=e}if(n.currentTokenRequestId>s)return r;n.currentTokenRequestId=null;var a=n.waitingForTokenRequest;return n.waitingForTokenRequest=null,o?(null==a||a.rejectAll(o),r):(null==a||a.resolveAll(n.tokenDetails=i),r)})()}_userSetClientId(e){if("string"!=typeof e&&null!==e)throw new kg("clientId must be either a string or null",40012,400);if("*"===e)throw new kg('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 t=this._uncheckedSetClientId(e);if(t)throw t}_uncheckedSetClientId(e){if(this._tokenClientIdMismatch(e)){var t="Unexpected clientId mismatch: client has "+this.clientId+", requested "+e,n=new kg(t,40102,401);return wg.logAction(this.logger,wg.LOG_ERROR,"Auth._uncheckedSetClientId()",t),n}return this.clientId=this.tokenParams.clientId=e,null}_tokenClientIdMismatch(e){return!(!this.clientId||"*"===this.clientId||!e||"*"===e||this.clientId===e)}static isTokenErr(e){return e.code&&e.code>=40140&&e.code<40150}revokeTokens(e,t){return this.client.rest.revokeTokens(e,t)}_getTimestamp(e){var n=this;return t(function*(){return n.client.getTimestamp(e||!!n.authOptions.queryTime)})()}};function $m(e){var t=[];if(e)for(var n in e)t.push(n+"="+e[n]);return t.join("&")}function Gm(e,t){return e+(t?"?":"")+$m(t)}var Jm=class{constructor(e){this.client=e,this.platformHttp=new gg.Http(e),this.checkConnectivity=this.platformHttp.checkConnectivity?()=>this.platformHttp.checkConnectivity():void 0}get logger(){var e,t;return null!=(t=null==(e=this.client)?void 0:e.logger)?t:wg.defaultLogger}get supportsAuthHeaders(){return this.platformHttp.supportsAuthHeaders}get supportsLinkHeaders(){return this.platformHttp.supportsLinkHeaders}_getHosts(e){var t=e.connection,n=t&&t.connectionManager.host;return n?[n].concat(Lm.getFallbackHosts(e.options)):Lm.getHosts(e.options)}do(e,n,r,i,s){var o=this;return t(function*(){try{var a=o.client;if(!a)return{error:new kg("http.do called without client",5e4,500)};var l="function"==typeof n?n:function(e){return a.baseUri(e)+n},c=a._currentFallback;if(c){if(c.validUntil>Date.now()){var u=yield o.doUri(e,l(c.host),r,i,s);return u.error&&o.platformHttp.shouldFallback(u.error)?(a._currentFallback=null,o.do(e,n,r,i,s)):u}a._currentFallback=null}var d=o._getHosts(a);if(1===d.length)return o.doUri(e,l(d[0]),r,i,s);var h=null,p=function(){var n=t(function*(t,n){var c=t.shift();h=null!=h?h:new Date;var u=yield o.doUri(e,l(c),r,i,s);return u.error&&o.platformHttp.shouldFallback(u.error)&&t.length?Date.now()-h.getTime()>a.options.timeouts.httpMaxRetryDuration?{error:new kg("Timeout for trying fallback hosts retries. Total elapsed time exceeded the "+a.options.timeouts.httpMaxRetryDuration+"ms limit",50003,500)}:p(t,!0):(n&&(a._currentFallback={host:c,validUntil:Date.now()+a.options.timeouts.fallbackRetryTimeout}),u)});return function(e,t){return n.apply(this,arguments)}}();return p(d)}catch(e){return{error:new kg("Unexpected error in Http.do: "+Zg(e),500,5e4)}}})()}doUri(e,n,r,i,s){var o=this;return t(function*(){try{!function(e,t,n,r,i){i.shouldLog(wg.LOG_MICRO)&&wg.logActionNoStrip(i,wg.LOG_MICRO,"Http."+e+"()","Sending; "+Gm(t,r)+"; Body"+(gg.BufferUtils.isBuffer(n)?" (Base64): "+gg.BufferUtils.base64Encode(n):": "+n))}(e,n,i,s,o.logger);var t=yield o.platformHttp.doUri(e,n,r,i,s);return o.logger.shouldLog(wg.LOG_MICRO)&&function(e,t,n,r,i){e.error?wg.logActionNoStrip(i,wg.LOG_MICRO,"Http."+t+"()","Received Error; "+Gm(n,r)+"; Error: "+Zg(e.error)):wg.logActionNoStrip(i,wg.LOG_MICRO,"Http."+t+"()","Received; "+Gm(n,r)+"; Headers: "+$m(e.headers)+"; StatusCode: "+e.statusCode+"; Body"+(gg.BufferUtils.isBuffer(e.body)?" (Base64): "+gg.BufferUtils.base64Encode(e.body):": "+e.body))}(t,e,n,s,o.logger),t}catch(e){return{error:new kg("Unexpected error in Http.doUri: "+Zg(e),500,5e4)}}})()}};function Km(e,t,n){for(var r,i,s,o=0;o<e.length;o++)if(r=e[o],n&&(r=r[n]),Array.isArray(r)){for(;-1!==(i=r.indexOf(t));)r.splice(i,1);n&&0===r.length&&delete e[o][n]}else if(Ag(r))for(s in r)Object.prototype.hasOwnProperty.call(r,s)&&Array.isArray(r[s])&&Km([r],t,s)}var Ym=class{constructor(e){this.logger=e,this.any=[],this.events=Object.create(null),this.anyOnce=[],this.eventsOnce=Object.create(null)}on(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(1===t.length){var r=t[0];if("function"!=typeof r)throw new Error("EventListener.on(): Invalid arguments: "+gg.Config.inspect(t));this.any.push(r)}if(2===t.length){var[i,s]=t;if("function"!=typeof s)throw new Error("EventListener.on(): Invalid arguments: "+gg.Config.inspect(t));if(Mg(i))this.any.push(s);else if(Array.isArray(i))i.forEach(e=>{this.on(e,s)});else{if("string"!=typeof i)throw new Error("EventListener.on(): Invalid arguments: "+gg.Config.inspect(t));(this.events[i]||(this.events[i]=[])).push(s)}}}off(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(0==t.length||Mg(t[0])&&Mg(t[1]))return this.any=[],this.events=Object.create(null),this.anyOnce=[],void(this.eventsOnce=Object.create(null));var[r,i]=t,s=null,o=null;if(1!==t.length&&i){if("function"!=typeof i)throw new Error("EventEmitter.off(): invalid arguments:"+gg.Config.inspect(t));[o,s]=[r,i]}else"function"==typeof r?s=r:o=r;if(s&&Mg(o))Km([this.any,this.events,this.anyOnce,this.eventsOnce],s);else if(Array.isArray(o))o.forEach(e=>{this.off(e,s)});else{if("string"!=typeof o)throw new Error("EventEmitter.off(): invalid arguments:"+gg.Config.inspect(t));s?Km([this.events,this.eventsOnce],s,o):(delete this.events[o],delete this.eventsOnce[o])}}listeners(e){if(e){var t=this.events[e]||[];return this.eventsOnce[e]&&Array.prototype.push.apply(t,this.eventsOnce[e]),t.length?t:null}return this.any.length?this.any:null}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i={event:e},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[e];o&&(Array.prototype.push.apply(s,o),delete this.eventsOnce[e]);var a=this.events[e];a&&Array.prototype.push.apply(s,a),s.forEach(e=>{!function(e,t,n,r){try{n.apply(t,r)}catch(t){wg.logAction(e,wg.LOG_ERROR,"EventEmitter.emit()","Unexpected listener exception: "+t+"; stack = "+(t&&t.stack))}}(this.logger,i,e,n)})}once(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.length;if(0===r||1===r&&"function"!=typeof t[0]){var i=t[0];return new Promise(e=>{this.once(i,e)})}var[s,o]=t;if(1===t.length&&"function"==typeof s)this.anyOnce.push(s);else if(Mg(s)){if("function"!=typeof o)throw new Error("EventEmitter.once(): Invalid arguments:"+gg.Config.inspect(t));this.anyOnce.push(o)}else if(Array.isArray(s)){var a=this,l=function(){var e=Array.prototype.slice.call(arguments);if(s.forEach(function(e){a.off(e,l)}),"function"!=typeof o)throw new Error("EventEmitter.once(): Invalid arguments:"+gg.Config.inspect(t));o.apply(this,e)};s.forEach(function(e){a.on(e,l)})}else{if("string"!=typeof s)throw new Error("EventEmitter.once(): Invalid arguments:"+gg.Config.inspect(t));var c=this.eventsOnce[s]||(this.eventsOnce[s]=[]);if(o){if("function"!=typeof o)throw new Error("EventEmitter.once(): Invalid arguments:"+gg.Config.inspect(t));c.push(o)}}}whenState(e,n){var r=this;return t(function*(){if("string"!=typeof e||"string"!=typeof n)throw new Error("whenState requires a valid state String argument");return e===n?null:r.once(e)})()}},Zm={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},Xm=[];Object.keys(Zm).forEach(function(e){Xm[Zm[e]]=e});var Qm={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},e_=Object.keys(Qm);Qm.MODE_ALL=Qm.PRESENCE|Qm.PUBLISH|Qm.SUBSCRIBE|Qm.PRESENCE_SUBSCRIBE|Qm.ANNOTATION_PUBLISH|Qm.ANNOTATION_SUBSCRIBE|Qm.OBJECT_SUBSCRIBE|Qm.OBJECT_PUBLISH;var t_=["PRESENCE","PUBLISH","SUBSCRIBE","PRESENCE_SUBSCRIBE","ANNOTATION_PUBLISH","ANNOTATION_SUBSCRIBE","OBJECT_SUBSCRIBE","OBJECT_PUBLISH"];function n_(){return(n_=t(function*(e,t){var{data:n,encoding:r}=yield r_(e.data,e.encoding,t);return e.data=n,e.encoding=r,e})).apply(this,arguments)}function r_(e,t,n){return i_.apply(this,arguments)}function i_(){return(i_=t(function*(e,t,n){var r=n.channelCipher,i=e,s=t?t+"/":"";return gg.BufferUtils.isBuffer(i)||(i=gg.BufferUtils.utf8Encode(String(i)),s+="utf-8/"),{data:yield r.encrypt(i),encoding:s=s+"cipher+"+r.algorithm}})).apply(this,arguments)}function s_(){return s_=t(function*(e,t){var{data:n,encoding:r}=o_(e.data,e.encoding);return e.data=n,e.encoding=r,null!=t&&t.cipher?function(e,t){return n_.apply(this,arguments)}(e,t):e}),s_.apply(this,arguments)}function o_(e,t){if("string"==typeof e||gg.BufferUtils.isBuffer(e)||null==e)return{data:e,encoding:t};if(Ag(e)||Array.isArray(e))return{data:JSON.stringify(e),encoding:t?t+"/json":"json"};throw new kg("Data type is unsupported",40013,400)}function a_(){return(a_=t(function*(e,t){var{data:n,encoding:r,error:i}=yield l_(e.data,e.encoding,t);if(e.data=n,e.encoding=r,i)throw i})).apply(this,arguments)}function l_(e,t,n){return c_.apply(this,arguments)}function c_(){return c_=t(function*(e,t,n){var r,i=function(e){return e&&e.channelOptions?e:{channelOptions:e,plugins:{},baseEncodedPreviousPayload:void 0}}(n),s=e,o=e,a=t;if(t){var l,c=t.split("/"),u=c.length,d="";try{for(;(l=u)>0;){var h=c[--u].match(/([-\w]+)(\+([\w-]+))?/);if(!h)break;switch(d=h[1]){case"base64":o=gg.BufferUtils.base64Decode(String(o)),l==c.length&&(s=o);continue;case"utf-8":o=gg.BufferUtils.utf8Decode(o);continue;case"json":o=JSON.parse(o);continue;case"cipher":if(null!=i.channelOptions&&i.channelOptions.cipher&&i.channelOptions.channelCipher){var p=h[3],f=i.channelOptions.channelCipher;if(p!=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(!i.plugins||!i.plugins.vcdiff)throw new kg("Missing Vcdiff decoder (https://github.com/ably-forks/vcdiff-decoder)",40019,400);if("undefined"==typeof Uint8Array)throw new kg("Delta decoding not supported on this browser (need ArrayBuffer & Uint8Array)",40020,400);try{var v=i.baseEncodedPreviousPayload;"string"==typeof v&&(v=gg.BufferUtils.utf8Encode(v));var g=gg.BufferUtils.toBuffer(v);o=gg.BufferUtils.toBuffer(o),s=o=gg.BufferUtils.arrayBufferViewToBuffer(i.plugins.vcdiff.decode(o,g))}catch(e){throw new kg("Vcdiff delta decode failed with "+e,40018,400)}continue;default:throw new Error("Unknown encoding")}}}catch(e){var m=e;r=new kg("Error processing the "+d+" encoding, decoder returned ‘"+m.message+"’",m.code||40013,400)}finally{a=l<=0?null:c.slice(0,l).join("/")}}return r?{error:r,data:o,encoding:a}:(i.baseEncodedPreviousPayload=s,{data:o,encoding:a})}),c_.apply(this,arguments)}function u_(){var e=arguments.length>0?"json":"msgpack",{data:t,encoding:n}=d_(this.data,this.encoding,e);return Object.assign({},this,{encoding:n,data:t})}function d_(e,t,n){return e&&gg.BufferUtils.isBuffer(e)?"msgpack"===n?{data:gg.BufferUtils.toBuffer(e),encoding:t}:{data:gg.BufferUtils.base64Encode(e),encoding:t?t+"/base64":"base64"}:{data:e,encoding:t}}var h_={encryptData:r_,encodeData:o_,encodeDataForWire:d_,decodeData:l_};function p_(e){var t,{id:n,connectionId:r,timestamp:i}=e;switch(e.action){case Zm.MESSAGE:t=e.messages;break;case Zm.PRESENCE:case Zm.SYNC:t=e.presence;break;case Zm.ANNOTATION:t=e.annotations;break;case Zm.OBJECT:case Zm.OBJECT_SYNC:t=e.state;break;default:throw new kg("Unexpected action "+e.action,4e4,400)}for(var s=0;s<t.length;s++){var o=t[s];o.connectionId||(o.connectionId=r),o.timestamp||(o.timestamp=i),n&&!o.id&&(o.id=n+":"+s)}}function f_(e,t){var n="["+t;for(var r in e)"data"===r?"string"==typeof e.data?n+="; data="+e.data:gg.BufferUtils.isBuffer(e.data)?n+="; data (buffer)="+gg.BufferUtils.base64Encode(e.data):void 0!==e.data&&(n+="; data (json)="+JSON.stringify(e.data)):!r||"extras"!==r&&"operation"!==r?"version"===r?n+="; version="+JSON.stringify(e[r]):"annotations"===r?n+="; annotations="+JSON.stringify(e[r]):void 0!==e[r]&&(n+="; "+r+"="+e[r]):n+="; "+r+"="+JSON.stringify(e[r]);return n+="]"}var v_=class{},g_=class{constructor(e){var t,n,r,i,s,o,a,l,c,u;this.Platform=gg,this.ErrorInfo=kg,this.Logger=wg,this.Defaults=Lm,this.Utils=Cg,this.EventEmitter=Ym,this.MessageEncoding=h_,this._additionalHTTPRequestImplementations=null!=(t=e.plugins)?t:null,this.logger=new wg,this.logger.setLog(e.logLevel,e.logHandler),this._MsgPack=null!=(r=null==(n=e.plugins)?void 0:n.MsgPack)?r:null;var d=this.options=Lm.normaliseOptions(e,this._MsgPack,this.logger);if(d.key){var h=d.key.match(/^([^:\s]+):([^:.\s]+)$/);if(!h){var p="invalid key parameter";throw wg.logAction(this.logger,wg.LOG_ERROR,"BaseClient()",p),new kg(p,40400,404)}d.keyName=h[1],d.keySecret=h[2]}if("clientId"in d){if("string"!=typeof d.clientId&&null!==d.clientId)throw new kg("clientId must be either a string or null",40012,400);if("*"===d.clientId)throw new kg('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._currentFallback=null,this.serverTimeOffset=null,this.http=new Jm(this),this.auth=new qm(this,d),this._rest=(null==(i=e.plugins)?void 0:i.Rest)?new e.plugins.Rest(this):null,this._Crypto=null!=(o=null==(s=e.plugins)?void 0:s.Crypto)?o:null,this.__FilteredSubscriptions=null!=(l=null==(a=e.plugins)?void 0:a.MessageInteractions)?l:null,this._Annotations=null!=(u=null==(c=e.plugins)?void 0:c.Annotations)?u:null}get rest(){return this._rest||mm("Rest"),this._rest}get _FilteredSubscriptions(){return this.__FilteredSubscriptions||mm("MessageInteractions"),this.__FilteredSubscriptions}get channels(){return this.rest.channels}get push(){return this.rest.push}device(){var e;return(null==(e=this.options.plugins)?void 0:e.Push)&&this.push.LocalDevice||mm("Push"),this._device||(this._device=this.push.LocalDevice.load(this)),this._device}baseUri(e){return Lm.getHttpScheme(this.options)+e+":"+Lm.getPort(this.options,!1)}stats(e){var n=this;return t(function*(){return n.rest.stats(e)})()}time(e){var n=this;return t(function*(){return n.rest.time(e)})()}request(e,n,r,i,s,o){var a=this;return t(function*(){return a.rest.request(e,n,r,i,s,o)})()}batchPublish(e){return this.rest.batchPublish(e)}batchPresence(e){return this.rest.batchPresence(e)}setLog(e){this.logger.setLog(e.level,e.handler)}getTimestamp(e){var n=this;return t(function*(){return!n.isTimeOffsetSet()&&e?n.time():n.getTimestampUsingOffset()})()}getTimestampUsingOffset(){return Date.now()+(this.serverTimeOffset||0)}isTimeOffsetSet(){return null!==this.serverTimeOffset}};g_.Platform=gg;var m_=g_,__=["message.create","message.update","message.delete","meta","message.summary","message.append"];function y_(e){var t=0;return e.name&&(t+=e.name.length),e.clientId&&(t+=e.clientId.length),e.extras&&(t+=JSON.stringify(e.extras).length),e.data&&(t+=Qg(e.data)),t}function b_(){return(b_=t(function*(e,t){return Promise.all(e.map(e=>e.encode(t)))})).apply(this,arguments)}var w_=class e extends v_{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[e,t]of Object.entries(this.annotations.summary))if(e.endsWith(":distinct.v1")||e.endsWith(":unique.v1")||e.endsWith(":multiple.v1"))for(var[,n]of Object.entries(t))n.clipped||(n.clipped=!1);else e.endsWith(":flag.v1")&&(t.clipped||(t.clipped=!1))}encode(e){var n=this;return t(function*(){return function(e,t){return s_.apply(this,arguments)}(Object.assign(new C_,n,{action:__.indexOf(n.action||"message.create")}),e)})()}static fromValues(t){return Object.assign(new e,t)}static fromValuesArray(t){return t.map(t=>e.fromValues(t))}toString(){return f_(this,"Message")}},C_=class e extends v_{toJSON(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return u_.call(this,...t)}static fromValues(t){return Object.assign(new e,t)}static fromValuesArray(t){return t.map(t=>e.fromValues(t))}decodeWithErr(e,n){var r=this;return t(function*(){var t,i,s=Object.assign(new w_,fg(pg({},r),{action:(t=r.action,__[t||0]||"unknown")}));try{yield function(e,t){return a_.apply(this,arguments)}(s,e)}catch(e){wg.logAction(n,wg.LOG_ERROR,"WireMessage.decode()",Zg(e)),i=e}return s.expandFields(),{decoded:s,err:i}})()}decode(e,n){var r=this;return t(function*(){var{decoded:t}=yield r.decodeWithErr(e,n);return t})()}toString(){return f_(this,"WireMessage")}},S_=w_,k_=class{constructor(e,t,n,r,i){this.previous=e,this.current=t,"attached"===t&&(this.resumed=n,this.hasBacklog=r),i&&(this.reason=i)}},x_=function(){};function I_(e){var t=e||{},{agent:n}=t;return((e,t)=>{var n={};for(var r in e)ug.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&cg)for(var r of cg(e))t.indexOf(r)<0&&dg.call(e,r)&&(n[r]=e[r]);return n})(t,["agent"])}var T_=class e extends Ym{constructor(e,n,r){var i,s,o;super(e.logger),this._annotations=null,this._mode=0,this.retryCount=0,this.history=function(){var e=t(function*(e){var t=this.client.rest.channelMixin;if(e&&e.untilAttach){if("attached"!==this.state)throw new kg("option untilAttach requires the channel to be attached",4e4,400);if(!this.properties.attachSerial)throw new kg("untilAttach was specified and channel is attached, but attachSerial is not defined",4e4,400);delete e.untilAttach,e.from_serial=this.properties.attachSerial}return t.history(this,e)});return function(t){return e.apply(this,arguments)}}(),this.whenState=e=>Ym.prototype.whenState.call(this,e,this.state),this.name=n,this.channelOptions=Mm(null!=(i=e._Crypto)?i:null,this.logger,r),this.client=e,this._presence=e._RealtimePresence?new e._RealtimePresence.RealtimePresence(this):null,e._Annotations&&(this._annotations=new e._Annotations.RealtimeAnnotations(this)),this.connectionManager=e.connection.connectionManager,this.state="initialized",this.subscriptions=new Ym(this.logger),this.syncChannelSerial=void 0,this.properties={attachSerial:void 0,channelSerial:void 0},this.setOptions(r),this.errorReason=null,this._attachResume=!1,this._decodingContext={channelOptions:this.channelOptions,plugins:e.options.plugins||{},baseEncodedPreviousPayload:void 0},this._lastPayload={messageId:null,protocolMessageChannelSerial:null,decodeFailureRecoveryInProgress:null},this._allChannelChanges=new Ym(this.logger),(null==(s=e.options.plugins)?void 0:s.Push)&&(this._push=new e.options.plugins.Push.PushChannel(this)),(null==(o=e.options.plugins)?void 0:o.LiveObjects)&&(this._object=new e.options.plugins.LiveObjects.RealtimeObject(this))}get presence(){return this._presence||mm("RealtimePresence"),this._presence}get annotations(){return this._annotations||mm("Annotations"),this._annotations}get push(){return this._push||mm("Push"),this._push}get object(){return this._object||mm("LiveObjects"),this._object}invalidStateError(){return new kg("Channel operation failed as channel state is "+this.state,90001,400,this.errorReason||void 0)}static processListenerArgs(e){return"function"==typeof(e=Array.prototype.slice.call(e))[0]&&e.unshift(null),e}setOptions(e){var n=this;return t(function*(){var t,r=n.channelOptions,i=function(e){if(e&&"params"in e&&!Ag(e.params))return new kg("options.params must be an object",4e4,400);if(e&&"modes"in e){if(!Array.isArray(e.modes))return new kg("options.modes must be an array",4e4,400);for(var t=0;t<e.modes.length;t++){var n=e.modes[t];if(!n||"string"!=typeof n||!t_.includes(String.prototype.toUpperCase.call(n)))return new kg("Invalid channel mode: "+n,4e4,400)}}}(e);if(i)throw i;if(n.channelOptions=Mm(null!=(t=n.client._Crypto)?t:null,n.logger,e),n._decodingContext&&(n._decodingContext.channelOptions=n.channelOptions),n._shouldReattachToSetOptions(e,r))return n.attachImpl(),new Promise((e,t)=>{n._allChannelChanges.once(["attached","update","detached","failed"],function(n){switch(this.event){case"update":case"attached":e();break;default:t(n.reason)}})})})()}_shouldReattachToSetOptions(e,t){if("attached"!==this.state&&"attaching"!==this.state)return!1;if(null==e?void 0:e.params){var n=I_(e.params),r=I_(t.params);if(Object.keys(n).length!==Object.keys(r).length)return!0;if(!hm(r,n))return!0}return!(!(null==e?void 0:e.modes)||t.modes&&vm(e.modes,t.modes))}publish(){var e=arguments,n=this;return t(function*(){var t,r,i=e.length<=0?void 0:e[0],s=e.length<=1?void 0:e[1];if("string"==typeof i||null==i)t=[S_.fromValues({name:i,data:s})],r=e.length<=2?void 0:e[2];else if(Ag(i))t=[S_.fromValues(i)],r=e.length<=1?void 0:e[1];else{if(!Array.isArray(i))throw new kg("The single-argument form of publish() expects a message object or an array of message objects",40013,400);t=S_.fromValuesArray(i),r=e.length<=1?void 0:e[1]}var o=n.client.options.maxMessageSize,a=yield function(e,t){return b_.apply(this,arguments)}(t,n.channelOptions),l=function(e){for(var t,n=0,r=0;r<e.length;r++)n+=(t=e[r]).size||(t.size=y_(t));return n}(a);if(l>o)throw new kg("Maximum size of messages that can be published at once exceeded (was "+l+" bytes; limit is "+o+" bytes)",40009,400);n.throwIfUnpublishableState();var c=M_({action:Zm.MESSAGE,channel:n.name,messages:a,params:r?Jg(r):void 0});return(yield n.sendMessage(c))||{serials:[]}})()}throwIfUnpublishableState(){if(!this.connectionManager.activeState())throw this.connectionManager.getError();if("failed"===this.state||"suspended"===this.state)throw this.invalidStateError()}onEvent(e){for(var t=this.subscriptions,n=0;n<e.length;n++){var r=e[n];t.emit(r.name,r)}}attach(){var e=this;return t(function*(){return"attached"===e.state?null:new Promise((t,n)=>{e._attach(!1,null,(e,r)=>e?n(e):t(r))})})()}_attach(e,t,n){n||(n=e=>{e&&wg.logAction(this.logger,wg.LOG_ERROR,"RealtimeChannel._attach()","Channel attach failed: "+e.toString())});var r=this.connectionManager;r.activeState()?(("attaching"!==this.state||e)&&this.requestState("attaching",t),this.once(function(e){switch(this.event){case"attached":null==n||n(null,e);break;case"detached":case"suspended":case"failed":null==n||n(e.reason||r.getError()||new kg("Unable to attach; reason unknown; state = "+this.event,9e4,500));break;case"detaching":null==n||n(new kg("Attach request superseded by a subsequent detach request",9e4,409))}})):n(r.getError())}attachImpl(){var e=M_({action:Zm.ATTACH,channel:this.name,params:this.channelOptions.params,channelSerial:this.properties.channelSerial});this.channelOptions.modes&&e.encodeModesToFlags(am(this.channelOptions.modes)),this._attachResume&&e.setFlag("ATTACH_RESUME"),this._lastPayload.decodeFailureRecoveryInProgress&&(e.channelSerial=this._lastPayload.protocolMessageChannelSerial),this.sendMessage(e).catch(x_)}detach(){var e=this;return t(function*(){var t=e.connectionManager;switch(e.state){case"suspended":return void e.notifyState("detached");case"detached":return;case"failed":throw new kg("Unable to detach; channel state = failed",90001,400);default:if("connected"!==t.state.state)return void e.notifyState("detached");e.requestState("detaching");case"detaching":return new Promise((n,r)=>{e.once(function(e){switch(this.event){case"detached":n();break;case"attached":case"suspended":case"failed":r(e.reason||t.getError()||new kg("Unable to detach; reason unknown; state = "+this.event,9e4,500));break;case"attaching":r(new kg("Detach request superseded by a subsequent attach request",9e4,409))}})})}})()}detachImpl(){var e=M_({action:Zm.DETACH,channel:this.name});this.sendMessage(e).catch(x_)}subscribe(){var n=arguments,r=this;return t(function*(){for(var t=n.length,i=new Array(t),s=0;s<t;s++)i[s]=n[s];var[o,a]=e.processListenerArgs(i);if("failed"===r.state)throw kg.fromValues(r.invalidStateError());return o&&"object"==typeof o&&!Array.isArray(o)?r.client._FilteredSubscriptions.subscribeFilter(r,o,a):r.subscriptions.on(o,a),!1!==r.channelOptions.attachOnSubscribe?r.attach():null})()}unsubscribe(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var[s,o]=e.processListenerArgs(r);"object"==typeof s&&!o||(null==(t=this.filteredSubscriptions)?void 0:t.has(o))?this.client._FilteredSubscriptions.getAndDeleteFilteredSubscriptions(this,s,o).forEach(e=>this.subscriptions.off(e)):this.subscriptions.off(s,o)}sync(){switch(this.state){case"initialized":case"detaching":case"detached":throw new xg("Unable to sync to channel; not attached",4e4)}var e=this.connectionManager;if(!e.activeState())throw e.getError();var t=M_({action:Zm.SYNC,channel:this.name});this.syncChannelSerial&&(t.channelSerial=this.syncChannelSerial),e.send(t)}sendMessage(e){var n=this;return t(function*(){return new Promise((t,r)=>{n.connectionManager.send(e,n.client.options.queueMessages,(e,n)=>{e?r(e):t(n)})})})()}sendPresence(e){var n=this;return t(function*(){var t=M_({action:Zm.PRESENCE,channel:n.name,presence:e});yield n.sendMessage(t)})()}sendState(e){var n=this;return t(function*(){var t=M_({action:Zm.OBJECT,channel:n.name,state:e});yield n.sendMessage(t)})()}processMessage(e){var n=this;return t(function*(){e.action!==Zm.ATTACHED&&e.action!==Zm.MESSAGE&&e.action!==Zm.PRESENCE&&e.action!==Zm.OBJECT&&e.action!==Zm.ANNOTATION||n.setChannelSerial(e.channelSerial);var t,r=!1;switch(e.action){case Zm.ATTACHED:n.properties.attachSerial=e.channelSerial,n._mode=e.getMode(),n.params=e.params||{};var i=e.decodeModesFromFlags();n.modes=i&&om(i)||void 0;var s=e.hasFlag("RESUMED"),o=e.hasFlag("HAS_PRESENCE"),a=e.hasFlag("HAS_BACKLOG"),l=e.hasFlag("HAS_OBJECTS");if("attached"===n.state){s||(n._presence&&n._presence.onAttached(o),n._object&&n._object.onAttached(l));var c=new k_(n.state,n.state,s,a,e.error);n._allChannelChanges.emit("update",c),s&&!n.channelOptions.updateOnAttached||n.emit("update",c)}else"detaching"===n.state?n.checkPendingState():n.notifyState("attached",e.error,s,o,a,l);break;case Zm.DETACHED:var u=e.error?kg.fromValues(e.error):new kg("Channel detached",90001,404);"detaching"===n.state?n.notifyState("detached",u):"attaching"===n.state?n.notifyState("suspended",u):"attached"!==n.state&&"suspended"!==n.state||n.requestState("attaching",u);break;case Zm.SYNC:if(r=!0,t=n.syncChannelSerial=e.channelSerial,!e.presence)break;case Zm.PRESENCE:if(!e.presence)break;p_(e);var d=n.channelOptions;if(n._presence){var h=yield Promise.all(e.presence.map(e=>e.decode(d,n.logger)));n._presence.setPresence(h,r,t)}break;case Zm.OBJECT:case Zm.OBJECT_SYNC:if(!n._object||!e.state)return;p_(e);var p=n.client.connection.connectionManager.getActiveTransportFormat(),f=e.state.map(e=>e.decode(n.client,p));e.action===Zm.OBJECT?n._object.handleObjectMessages(f):n._object.handleObjectSyncMessages(f,e.channelSerial);break;case Zm.MESSAGE:if("attached"!==n.state)return;p_(e);var v=e.messages,g=v[0],m=v[v.length-1];if(g.extras&&g.extras.delta&&g.extras.delta.from!==n._lastPayload.messageId){var _='Delta message decode failure - previous message not available for message "'+e.id+'" on this channel "'+n.name+'".';wg.logAction(n.logger,wg.LOG_ERROR,"RealtimeChannel.processMessage()",_),n._startDecodeFailureRecovery(new kg(_,40018,400));break}for(var y=[],b=0;b<v.length;b++){var{decoded:w,err:C}=yield v[b].decodeWithErr(n._decodingContext,n.logger);if(y[b]=w,C)switch(C.code){case 40018:return void n._startDecodeFailureRecovery(C);case 40019:case 40021:return void n.notifyState("failed",C)}}n._lastPayload.messageId=m.id,n._lastPayload.protocolMessageChannelSerial=e.channelSerial,n.onEvent(y);break;case Zm.ANNOTATION:p_(e);var S=n.channelOptions;if(n._annotations){var k=yield Promise.all((e.annotations||[]).map(e=>e.decode(S,n.logger)));n._annotations._processIncoming(k)}break;case Zm.ERROR:var x=e.error;x&&80016==x.code?n.checkPendingState():n.notifyState("failed",kg.fromValues(x))}})()}_startDecodeFailureRecovery(e){this._lastPayload.decodeFailureRecoveryInProgress||(this._lastPayload.decodeFailureRecoveryInProgress=!0,this._attach(!0,e,()=>{this._lastPayload.decodeFailureRecoveryInProgress=!1}))}onAttached(){}notifyState(e,t,n,r,i,s){if(this.clearStateTimer(),["detached","suspended","failed"].includes(e)&&(this.properties.channelSerial=null),e!==this.state){this._presence&&this._presence.actOnChannelState(e,r,t),this._object&&this._object.actOnChannelState(e,s),"suspended"===e&&this.connectionManager.state.sendEvents?this.startRetryTimer():this.cancelRetryTimer(),t&&(this.errorReason=t);var o=new k_(this.state,e,n,i,t),a='Channel state for channel "'+this.name+'"',l=e+(t?"; reason: "+t:"");"failed"===e&&wg.logAction(this.logger,wg.LOG_ERROR,a,l),"attaching"!==e&&"suspended"!==e&&(this.retryCount=0),"attached"===e&&this.onAttached(),"attached"===e?this._attachResume=!0:"detaching"!==e&&"failed"!==e||(this._attachResume=!1),this.state=e,this._allChannelChanges.emit(e,o),this.emit(e,o)}}requestState(e,t){this.notifyState(e,t),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 e=new kg("Channel attach timed out",90007,408);this.notifyState("suspended",e);break;case"detaching":var t=new kg("Channel detach timed out",90007,408);this.notifyState("attached",t);break;default:this.checkPendingState()}}startStateTimerIfNotRunning(){this.stateTimer||(this.stateTimer=setTimeout(()=>{this.stateTimer=null,this.timeoutPendingState()},this.client.options.timeouts.realtimeRequestTimeout))}clearStateTimer(){var e=this.stateTimer;e&&(clearTimeout(e),this.stateTimer=null)}startRetryTimer(){if(!this.retryTimer){this.retryCount++;var e=um(this.client.options.timeouts.channelRetryTimeout,this.retryCount);this.retryTimer=setTimeout(()=>{"suspended"===this.state&&this.connectionManager.state.sendEvents&&(this.retryTimer=null,this.requestState("attaching"))},e)}}cancelRetryTimer(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}getReleaseErr(){var e=this.state;return"initialized"===e||"detached"===e||"failed"===e?null:new kg("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 "+e,90001,400)}setChannelSerial(e){e&&(this.properties.channelSerial=e)}status(){var e=this;return t(function*(){return e.client.rest.channelMixin.status(e)})()}getMessage(e){var n=this;return t(function*(){return n.client.rest.channelMixin.getMessage(n,e)})()}updateMessage(e,n,r){var i=this;return t(function*(){return i.sendUpdate(e,"message.update",n,r)})()}deleteMessage(e,n,r){var i=this;return t(function*(){return i.sendUpdate(e,"message.delete",n,r)})()}appendMessage(e,n,r){var i=this;return t(function*(){return i.sendUpdate(e,"message.append",n,r)})()}sendUpdate(e,n,r,i){var s=this;return t(function*(){var t,o;if(!e.serial)throw new kg('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=S_.fromValues(fg(pg({},e),{action:n,version:r})),l=yield a.encode(s.channelOptions),c=M_({action:Zm.MESSAGE,channel:s.name,messages:[l],params:i?Jg(i):void 0}),u=yield s.sendMessage(c);return{versionSerial:null!=(o=null==(t=null==u?void 0:u.serials)?void 0:t[0])?o:null}})()}getMessageVersions(e,n){var r=this;return t(function*(){return r.client.rest.channelMixin.getMessageVersions(r,e,n)})()}ensureAttached(){var e=this;return t(function*(){switch(e.state){case"attached":case"suspended":break;case"initialized":case"detached":case"detaching":case"attaching":yield e.attach();break;default:throw kg.fromValues(e.invalidStateError())}})()}},E_=sm;function A_(e){var t=[];if(e)for(var n=0;n<e.length;n++)t.push(e[n].toString());return"[ "+t.join(", ")+" ]"}function O_(e,t,n,r,i,s){return function(e,t,n,r){var i,s,o,a,l;e.error&&(i=kg.fromValues(e.error));e.messages&&(s=C_.fromValuesArray(e.messages));t&&e.presence&&(o=t.WirePresenceMessage.fromValuesArray(e.presence));n&&e.annotations&&(a=n.WireAnnotation.fromValuesArray(e.annotations));r&&e.state&&(l=r.WireObjectMessage.fromValuesArray(e.state,Cg,h_));return Object.assign(new P_,fg(pg({},e),{presence:o,messages:s,annotations:a,state:l,error:i}))}(im(e,t,s),n,r,i)}function M_(e){return Object.assign(new P_,e)}function R_(e,t,n,r){var i="[ProtocolMessage";void 0!==e.action&&(i+="; action="+Xm[e.action]||e.action);for(var s,o=["id","channel","channelSerial","connectionId","count","msgSerial","timestamp"],a=0;a<o.length;a++)void 0!==e[s=o[a]]&&(i+="; "+s+"="+e[s]);if(e.messages&&(i+="; messages="+A_(C_.fromValuesArray(e.messages))),e.presence&&t&&(i+="; presence="+A_(t.WirePresenceMessage.fromValuesArray(e.presence))),e.annotations&&n&&(i+="; annotations="+A_(n.WireAnnotation.fromValuesArray(e.annotations))),e.state&&r&&(i+="; state="+A_(r.WireObjectMessage.fromValuesArray(e.state,Cg,h_))),e.error&&(i+="; error="+kg.fromValues(e.error).toString()),e.auth&&e.auth.accessToken&&(i+="; token="+e.auth.accessToken),e.flags&&(i+="; flags="+e_.filter(e.hasFlag).join(",")),e.params){var l="";zg(e.params,function(t){l.length>0&&(l+="; "),l+=t+"="+e.params[t]}),l.length>0&&(i+="; params=["+l+"]")}return i+="]"}var P_=class{constructor(){this.hasFlag=e=>(this.flags&Qm[e])>0}setFlag(e){return this.flags=this.flags|Qm[e]}getMode(){return(this.flags||0)&Qm.MODE_ALL}encodeModesToFlags(e){e.forEach(e=>this.setFlag(e))}decodeModesFromFlags(){var e=[];return t_.forEach(t=>{this.hasFlag(t)&&e.push(t)}),e.length>0?e:void 0}},L_=class extends Ym{constructor(e){super(e),this.messages=[]}count(){return this.messages.length}push(e){this.messages.push(e)}shift(){return this.messages.shift()}last(){return this.messages[this.messages.length-1]}copyAll(){return this.messages.slice()}append(e){this.messages.push.apply(this.messages,e)}prepend(e){this.messages.unshift.apply(this.messages,e)}completeMessages(e,t,n){t=t||null;var r=this.messages;if(0===r.length)throw new Error("MessageQueue.completeMessages(): completeMessages called on any empty MessageQueue");var i=[];if("all"===e)i=r.splice(0);else{var s=r[0];if(s){var o=s.message.msgSerial,a=e.serial+e.count;a>o&&(i=r.splice(0,a-o))}}for(var l=0;l<i.length;l++){var c=i[l],u=null==n?void 0:n[l];c.callback(t,u)}0==r.length&&this.emit("idle")}completeAllMessages(e){this.completeMessages("all",e)}resetSendAttempted(){for(var e of this.messages)e.sendAttempted=!1}clear(){this.messages=[],this.emit("idle")}},N_=class{constructor(e,t){this.message=e,this.callback=t,this.merged=!1;var n=e.action;this.sendAttempted=!1,this.ackRequired="number"==typeof n&&[Zm.MESSAGE,Zm.PRESENCE,Zm.ANNOTATION,Zm.OBJECT].includes(n)}},D_=class extends Ym{constructor(e){super(e.logger),this.transport=e,this.messageQueue=new L_(this.logger),e.on("ack",(e,t,n)=>{this.onAck(e,t,n)}),e.on("nack",(e,t,n)=>{this.onNack(e,t,n)})}onAck(e,t,n){this.messageQueue.completeMessages({serial:e,count:t},null,n)}onNack(e,t,n){wg.logAction(this.logger,wg.LOG_ERROR,"Protocol.onNack()","serial = "+e+"; count = "+t+"; err = "+Zg(n)),n||(n=new kg("Unable to send message; channel not responding",50001,500)),this.messageQueue.completeMessages({serial:e,count:t},n)}onceIdle(e){var t=this.messageQueue;0!==t.count()?t.once("idle",e):e()}send(e){e.ackRequired&&this.messageQueue.push(e),this.logger.shouldLog(wg.LOG_MICRO)&&wg.logActionNoStrip(this.logger,wg.LOG_MICRO,"Protocol.send()","sending msg; "+R_(e.message,this.transport.connectionManager.realtime._RealtimePresence,this.transport.connectionManager.realtime._Annotations,this.transport.connectionManager.realtime._liveObjectsPlugin)),e.sendAttempted=!0,this.transport.send(e.message)}getTransport(){return this.transport}getPendingMessages(){return this.messageQueue.copyAll()}clearPendingMessages(){return this.messageQueue.clear()}finish(){var e=this.transport;this.onceIdle(function(){e.disconnect()})}},U_=class{constructor(e,t,n,r){this.previous=e,this.current=t,n&&(this.retryIn=n),r&&(this.reason=r)}},B_={DISCONNECTED:80003,SUSPENDED:80002,FAILED:8e4,CLOSING:80017,CLOSED:80017,UNKNOWN_CONNECTION_ERR:50002,UNKNOWN_CHANNEL_ERR:50001};var F_,j_,W_={disconnected:()=>kg.fromValues({statusCode:400,code:B_.DISCONNECTED,message:"Connection to server temporarily unavailable"}),suspended:()=>kg.fromValues({statusCode:400,code:B_.SUSPENDED,message:"Connection to server unavailable"}),failed:()=>kg.fromValues({statusCode:400,code:B_.FAILED,message:"Connection failed or disconnected by server"}),closing:()=>kg.fromValues({statusCode:400,code:B_.CLOSING,message:"Connection closing"}),closed:()=>kg.fromValues({statusCode:400,code:B_.CLOSED,message:"Connection closed"}),unknownConnectionErr:()=>kg.fromValues({statusCode:500,code:B_.UNKNOWN_CONNECTION_ERR,message:"Internal connection error"}),unknownChannelErr:()=>kg.fromValues({statusCode:500,code:B_.UNKNOWN_CONNECTION_ERR,message:"Internal channel error"})},H_=M_({action:Zm.CLOSE}),z_=M_({action:Zm.DISCONNECT}),V_=class extends Ym{constructor(e,t,n,r){super(e.logger),r&&(n.format=void 0,n.heartbeats=!0),this.connectionManager=e,this.auth=t,this.params=n,this.timeouts=n.options.timeouts,this.format=n.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",W_.closed())}disconnect(e){this.isConnected&&this.requestDisconnect(),this.finish("disconnected",e||W_.disconnected())}fail(e){this.isConnected&&this.requestDisconnect(),this.finish("failed",e||W_.failed())}finish(e,t){var n;this.isFinished||(this.isFinished=!0,this.isConnected=!1,this.maxIdleInterval=null,clearTimeout(null!=(n=this.idleTimer)?n:void 0),this.idleTimer=null,this.emit(e,t),this.dispose())}onProtocolMessage(e){switch(this.logger.shouldLog(wg.LOG_MICRO)&&wg.logActionNoStrip(this.logger,wg.LOG_MICRO,"Transport.onProtocolMessage()","received on "+this.shortName+": "+R_(e,this.connectionManager.realtime._RealtimePresence,this.connectionManager.realtime._Annotations,this.connectionManager.realtime._liveObjectsPlugin)+"; connectionId = "+this.connectionManager.connectionId),this.onActivity(),e.action){case Zm.HEARTBEAT:wg.logActionNoStrip(this.logger,wg.LOG_MICRO,"Transport.onProtocolMessage()",this.shortName+" heartbeat; connectionId = "+this.connectionManager.connectionId),this.emit("heartbeat",e.id);break;case Zm.CONNECTED:this.onConnect(e),this.emit("connected",e.error,e.connectionId,e.connectionDetails,e);break;case Zm.CLOSED:this.onClose(e);break;case Zm.DISCONNECTED:this.onDisconnect(e);break;case Zm.ACK:this.emit("ack",e.msgSerial,e.count,e.res);break;case Zm.NACK:this.emit("nack",e.msgSerial,e.count,e.error);break;case Zm.SYNC:this.connectionManager.onChannelMessage(e,this);break;case Zm.ACTIVATE:break;case Zm.AUTH:rm(this.auth.authorize(),e=>{e&&wg.logAction(this.logger,wg.LOG_ERROR,"Transport.onProtocolMessage()","Ably requested re-authentication, but unable to obtain a new token: "+Zg(e))});break;case Zm.ERROR:if(void 0===e.channel){this.onFatalError(e);break}this.connectionManager.onChannelMessage(e,this);break;default:this.connectionManager.onChannelMessage(e,this)}}onConnect(e){if(this.isConnected=!0,!e.connectionDetails)throw new Error("Transport.onConnect(): Connect message recieved without connectionDetails");var t=e.connectionDetails.maxIdleInterval;t&&(this.maxIdleInterval=t+this.timeouts.realtimeRequestTimeout,this.onActivity())}onDisconnect(e){var t=e&&e.error;this.finish("disconnected",t)}onFatalError(e){var t=e&&e.error;this.finish("failed",t)}onClose(e){var t=e&&e.error;this.finish("closed",t)}requestClose(){this.send(H_)}requestDisconnect(){this.send(z_)}ping(e){var t={action:Zm.HEARTBEAT};e&&(t.id=e),this.send(M_(t))}dispose(){this.isDisposed=!0,this.off()}onActivity(){this.maxIdleInterval&&(this.lastActivity=this.connectionManager.lastActivity=Date.now(),this.setIdleTimer(this.maxIdleInterval+100))}setIdleTimer(e){this.idleTimer||(this.idleTimer=setTimeout(()=>{this.onIdleTimerExpire()},e))}onIdleTimerExpire(){if(!this.lastActivity||!this.maxIdleInterval)throw new Error("Transport.onIdleTimerExpire(): lastActivity/maxIdleInterval not set");this.idleTimer=null;var e=Date.now()-this.lastActivity,t=this.maxIdleInterval-e;if(t<=0){var n="No activity seen from realtime in "+e+"ms; assuming connection has dropped";wg.logAction(this.logger,wg.LOG_ERROR,"Transport.onIdleTimerExpire()",n),this.disconnect(new kg(n,80003,408))}else this.setIdleTimer(t+100)}static tryConnect(e,t,n,r,i){var s,o=new e(t,n,r),a=function(e){clearTimeout(s),i({event:this.event,error:e})},l=t.options.timeouts.realtimeRequestTimeout;return s=setTimeout(()=>{o.off(["preconnect","disconnected","failed"]),o.dispose(),a.call({event:"disconnected"},new kg("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),i(null,o)}),o.connect(),o}static isAvailable(){throw new kg("isAvailable not implemented for transport",5e4,500)}};(j_=F_||(F_={})).WebSocket="web_socket",j_.Comet="comet",j_.XhrPolling="xhr_polling";var q_="undefined"!=typeof global?global:"undefined"!=typeof window?window:self,$_=()=>{var e;return void 0!==gg.WebStorage&&(null==(e=gg.WebStorage)?void 0:e.localSupported)},G_=()=>{var e;return void 0!==gg.WebStorage&&(null==(e=gg.WebStorage)?void 0:e.sessionSupported)},J_=function(){},K_="ably-transport-preference";function Y_(e){try{return JSON.parse(e)}catch(e){return null}}var Z_=class{constructor(e,t,n,r){this.options=e,this.host=t,this.mode=n,this.connectionKey=r,this.format=e.useBinaryProtocol?"msgpack":"json"}getConnectParams(e){var t=e?Tg(e):{},n=this.options;switch(this.mode){case"resume":t.resume=this.connectionKey;break;case"recover":var r=Y_(n.recover);r&&(t.recover=r.connectionKey)}return void 0!==n.clientId&&(t.clientId=n.clientId),!1===n.echoMessages&&(t.echo="false"),void 0!==this.format&&(t.format=this.format),void 0!==this.stream&&(t.stream=this.stream),void 0!==this.heartbeats&&(t.heartbeats=this.heartbeats),t.v=Lm.protocolVersion,t.agent=Am(this.options),void 0!==n.transportParams&&Ig(t,n.transportParams),t}toString(){var e="[mode="+this.mode;return this.host&&(e+=",host="+this.host),this.connectionKey&&(e+=",connectionKey="+this.connectionKey),this.format&&(e+=",format="+this.format),e+="]"}},X_=class e extends Ym{constructor(e,t){super(e.logger),this.supportedTransports={},this.disconnectedRetryCount=0,this.pendingChannelMessagesState={isProcessing:!1,queue:[]},this.realtime=e,this.initTransports(),this.options=t;var n=t.timeouts,r=n.webSocketConnectTimeout+n.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:r,failState:"disconnected"},connected:{state:"connected",terminal:!1,queueEvents:!1,sendEvents:!0,failState:"disconnected"},disconnected:{state:"disconnected",terminal:!1,queueEvents:!0,sendEvents:!1,retryDelay:n.disconnectedRetryTimeout,failState:"disconnected"},suspended:{state:"suspended",terminal:!1,queueEvents:!1,sendEvents:!1,retryDelay:n.suspendedRetryTimeout,failState:"suspended"},closing:{state:"closing",terminal:!1,queueEvents:!1,sendEvents:!1,retryDelay:n.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 L_(this.logger),this.msgSerial=0,this.connectionDetails=void 0,this.connectionId=void 0,this.connectionKey=void 0,this.connectionStateTtl=n.connectionStateTtl,this.maxIdleInterval=null,this.transports=Dg(t.transports||Lm.defaultTransports,this.supportedTransports),this.transportPreference=null,this.transports.includes(F_.WebSocket)&&(this.webSocketTransportAvailable=!0),this.transports.includes(F_.XhrPolling)?this.baseTransport=F_.XhrPolling:this.transports.includes(F_.Comet)&&(this.baseTransport=F_.Comet),this.domains=Lm.getHosts(t),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 i="no requested transports available";throw wg.logAction(this.logger,wg.LOG_ERROR,"realtime.ConnectionManager()",i),new Error(i)}var s=gg.Config.addEventListener;s&&(G_()&&"function"==typeof t.recover&&s("beforeunload",this.persistConnection.bind(this)),!0===t.closeOnUnload&&s("beforeunload",()=>{this.requestState({state:"closing"})}),s("online",()=>{var e;this.state==this.states.disconnected||this.state==this.states.suspended?this.requestState({state:"connecting"}):this.state==this.states.connecting&&(null==(e=this.pendingTransport)||e.off(),this.disconnectAllTransports(),this.startConnect())}),s("offline",()=>{this.state==this.states.connected&&this.disconnectAllTransports()}))}static supportedTransports(e){var t={supportedTransports:{}};return this.initTransports(e,t),t.supportedTransports}static initTransports(e,t){var n=pg(pg({},gg.Transports.bundledImplementations),e);[F_.WebSocket,...gg.Transports.order].forEach(e=>{var r=n[e];r&&r.isAvailable()&&(t.supportedTransports[e]=r)})}initTransports(){e.initTransports(this.realtime._additionalTransportImplementations,this)}createTransportParams(e,t){return new Z_(this.options,e,t,this.connectionKey)}getTransportParams(e){(e=>{if(this.connectionKey)e("resume");else if("string"!=typeof this.options.recover){var t=this.options.recover,n=this.getSessionRecoverData();this.sessionRecoveryName(),n&&"function"==typeof t?t(n,t=>{t?(this.options.recover=n.recoveryKey,e("recover")):e("clean")}):e("clean")}else e("recover")})(t=>{var n=this.createTransportParams(null,t);if("recover"===t){var r=Y_(this.options.recover);r&&(this.msgSerial=r.msgSerial)}e(n)})}tryATransport(e,t,n){this.proposedTransport=V_.tryConnect(this.supportedTransports[t],this,this.realtime.auth,e,(r,i)=>{var s,o=this.state;if(o==this.states.closing||o==this.states.closed||o==this.states.failed)return i&&i.close(),void n(!0);r?!qm.isTokenErr(r.error)||this.errorReason&&qm.isTokenErr(this.errorReason)?"failed"===r.event?(this.notifyState({state:"failed",error:r.error}),n(!0)):"disconnected"===r.event&&(!(s=r.error).statusCode||!s.code||s.statusCode>=500||Object.values(B_).includes(s.code)?n(!1):(this.notifyState({state:this.states.connecting.failState,error:r.error}),n(!0))):(this.errorReason=r.error,rm(this.realtime.auth._forceNewToken(null,null),r=>{r?this.actOnErrorFromAuthorize(r):this.tryATransport(e,t,n)})):(this.setTransportPending(i,e),n(null,i))})}setTransportPending(e,t){var n=t.mode;this.pendingTransport=e,this.cancelWebSocketSlowTimer(),this.cancelWebSocketGiveUpTimer(),e.once("connected",(t,r,i)=>{this.activateTransport(t,e,r,i),"recover"===n&&this.options.recover&&(delete this.options.recover,this.unpersistConnection())});var r=this;e.on(["disconnected","closed","failed"],function(t){r.deactivateTransport(e,this.event,t)}),this.emit("transport.pending",e)}activateTransport(e,t,n,r){e&&wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.activateTransport()","error = "+e),this.persistTransportPreference(t);var i=this.state,s=this.states.connected.state;if(i.state==this.states.closing.state||i.state==this.states.closed.state||i.state==this.states.failed.state)return t.disconnect(),!1;if(delete this.pendingTransport,!t.isConnected)return!1;var o=this.activeProtocol;this.activeProtocol=new D_(t),this.host=t.params.host;var a=r.connectionKey;if(a&&this.connectionKey!=a&&this.setConnection(n,r,!!e),this.onConnectionDetailsUpdate(r,t),gg.Config.nextTick(()=>{t.on("connected",(e,n,r)=>{this.onConnectionDetailsUpdate(r,t),this.emit("update",new U_(s,s,null,e))})}),i.state===this.states.connected.state?e&&(this.errorReason=this.realtime.connection.errorReason=e,this.emit("update",new U_(s,s,null,e))):(this.notifyState({state:"connected",error:e}),this.errorReason=this.realtime.connection.errorReason=e||null),this.emit("transport.active",t),o)if(o.messageQueue.count()>0&&wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.activateTransport()","Previous active protocol (for transport "+o.transport.shortName+", new one is "+t.shortName+") finishing with "+o.messageQueue.count()+" messages still pending"),o.transport===t){var l="Assumption violated: activating a transport that was also the transport for the previous active protocol; transport = "+t.shortName+"; stack = "+(new Error).stack;wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.activateTransport()",l)}else o.finish();return!0}deactivateTransport(e,t,n){var r=this.activeProtocol,i=r&&r.getTransport()===e,s=e===this.pendingTransport,o=this.noTransportsScheduledForActivation();if(n&&n.message,i&&(this.queuePendingMessages(r.getPendingMessages()),r.clearPendingMessages(),this.activeProtocol=this.host=null),this.emit("transport.inactive",e),i&&o||i&&"failed"===t||"closed"===t||null===r&&s){if("disconnected"===t&&n&&n.statusCode>500&&this.domains.length>1)return this.unpersistTransportPreference(),this.forceFallbackHost=!0,void this.notifyState({state:t,error:n,retryImmediately:!0});var a="failed"===t&&qm.isTokenErr(n)?"disconnected":t;this.notifyState({state:a,error:n})}else;}noTransportsScheduledForActivation(){return!this.pendingTransport||!this.pendingTransport.isConnected}setConnection(e,t,n){var r=this.connectionId;(r&&r!==e||!r&&n)&&(this.msgSerial=0,this.queuedMessages.resetSendAttempted()),this.connectionId,this.realtime.connection.id=this.connectionId=e,this.realtime.connection.key=this.connectionKey=t.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(G_()){var e=this.createRecoveryKey();e&&this.setSessionRecoverData({recoveryKey:e,disconnectedAt:Date.now(),location:q_.location,clientId:this.realtime.auth.clientId})}}unpersistConnection(){this.clearSessionRecoverData()}getActiveTransportFormat(){var e;return null==(e=this.activeProtocol)?void 0:e.getTransport().format}getError(){if(this.errorReason){var e=xg.fromValues(this.errorReason);return e.cause=this.errorReason,e}return this.getStateError()}getStateError(){var e,t;return null==(t=(e=W_)[this.state.state])?void 0:t.call(e)}activeState(){return this.state.queueEvents||this.state.sendEvents}enactStateChange(e){var t=e.current+(e.reason?"; reason: "+e.reason:"");"failed"===e.current&&wg.logAction(this.logger,wg.LOG_ERROR,"Connection state",t);var n=this.state=this.states[e.current];e.reason&&(this.errorReason=e.reason,this.realtime.connection.errorReason=e.reason),(n.terminal||"suspended"===n.state)&&this.clearConnection(),this.emit("connectionstate",e)}startTransitionTimer(e){this.transitionTimer&&clearTimeout(this.transitionTimer),this.transitionTimer=setTimeout(()=>{this.transitionTimer&&(this.transitionTimer=null,this.notifyState({state:e.failState}))},e.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(e){"disconnected"!==e&&"suspended"!==e&&"connecting"!==e&&this.cancelSuspendTimer()}cancelSuspendTimer(){this.states.connecting.failState="disconnected",this.suspendTimer&&(clearTimeout(this.suspendTimer),this.suspendTimer=null)}startRetryTimer(e){this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.requestState({state:"connecting"})},e)}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&&rm(this.realtime.http.checkConnectivity(),(e,t)=>{!e&&t||(this.cancelWebSocketGiveUpTimer(),this.notifyState({state:"disconnected",error:new kg("Unable to connect (network unreachable)",80003,404)}))})},this.options.timeouts.webSocketSlowTimeout)}cancelWebSocketSlowTimer(){this.webSocketSlowTimer&&(clearTimeout(this.webSocketSlowTimer),this.webSocketSlowTimer=null)}startWebSocketGiveUpTimer(e){this.webSocketGiveUpTimer=setTimeout(()=>{var t,n;this.wsCheckResult||this.baseTransport&&(this.abandonedWebSocket=!0,null==(t=this.proposedTransport)||t.dispose(),null==(n=this.pendingTransport)||n.dispose(),this.connectBase(e,++this.connectCounter))},this.options.timeouts.webSocketConnectTimeout)}cancelWebSocketGiveUpTimer(){this.webSocketGiveUpTimer&&(clearTimeout(this.webSocketGiveUpTimer),this.webSocketGiveUpTimer=null)}notifyState(e){var t,n,r=e.state,i="disconnected"===r&&(this.state===this.states.connected||e.retryImmediately||this.state===this.states.connecting&&e.error&&qm.isTokenErr(e.error)&&!(this.errorReason&&qm.isTokenErr(this.errorReason)));if(r!=this.state.state&&(this.cancelTransitionTimer(),this.cancelRetryTimer(),this.cancelWebSocketSlowTimer(),this.cancelWebSocketGiveUpTimer(),this.checkSuspendTimer(e.state),"suspended"!==r&&"connected"!==r||(this.disconnectedRetryCount=0),!this.state.terminal)){var s=this.states[e.state],o=s.retryDelay;"disconnected"===s.state&&(this.disconnectedRetryCount++,o=um(s.retryDelay,this.disconnectedRetryCount));var a=new U_(this.state.state,s.state,o,e.error||(null==(n=(t=W_)[s.state])?void 0:n.call(t)));if(i){var l=()=>{this.state===this.states.disconnected&&(this.lastAutoReconnectAttempt=Date.now(),this.requestState({state:"connecting"}))},c=this.lastAutoReconnectAttempt&&Date.now()-this.lastAutoReconnectAttempt+1;c&&c<1e3?setTimeout(l,1e3-c):gg.Config.nextTick(l)}else"disconnected"!==r&&"suspended"!==r||this.startRetryTimer(o);("disconnected"===r&&!i||"suspended"===r||s.terminal)&&gg.Config.nextTick(()=>{this.disconnectAllTransports()}),"connected"!=r||this.activeProtocol||wg.logAction(this.logger,wg.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(r,a.reason),this.failQueuedMessages(a.reason))}}requestState(e){var t,n,r=e.state;if(r!=this.state.state&&(this.cancelWebSocketSlowTimer(),this.cancelWebSocketGiveUpTimer(),this.cancelTransitionTimer(),this.cancelRetryTimer(),this.checkSuspendTimer(r),!("connecting"==r&&"connected"==this.state.state||"closing"==r&&"closed"==this.state.state))){var i=this.states[r],s=new U_(this.state.state,i.state,null,e.error||(null==(n=(t=W_)[i.state])?void 0:n.call(t)));this.enactStateChange(s),"connecting"==r&&gg.Config.nextTick(()=>{this.startConnect()}),"closing"==r&&this.closeImpl()}}startConnect(){if(this.state===this.states.connecting){var e=this.realtime.auth,t=++this.connectCounter,n=()=>{this.checkConnectionStateFreshness(),this.getTransportParams(e=>{if("recover"===e.mode&&e.options.recover){var n=Y_(e.options.recover);n&&this.realtime.channels.recoverChannels(n.channelSerials)}t===this.connectCounter&&this.connectImpl(e,t)})};if(this.startSuspendTimer(),this.startTransitionTimer(this.states.connecting),"basic"===e.method)n();else{var r=e=>{t===this.connectCounter&&(e?this.actOnErrorFromAuthorize(e):n())};this.errorReason&&qm.isTokenErr(this.errorReason)?rm(e._forceNewToken(null,null),r):rm(e._ensureValidAuthCredentials(!1),r)}}}connectImpl(e,t){if(this.state.state===this.states.connecting.state){var n=this.getTransportPreference();n&&n===this.baseTransport&&this.webSocketTransportAvailable&&this.checkWsConnectivity().then(()=>{this.unpersistTransportPreference(),this.state===this.states.connecting&&(this.disconnectAllTransports(),this.connectWs(e,++this.connectCounter))}).catch(J_),n&&n===this.baseTransport||this.baseTransport&&!this.webSocketTransportAvailable?this.connectBase(e,t):this.connectWs(e,t)}}connectWs(e,t){this.wsCheckResult=null,this.abandonedWebSocket=!1,this.startWebSocketSlowTimer(),this.startWebSocketGiveUpTimer(e),this.tryTransportWithFallbacks("web_socket",e,!0,t,()=>!1!==this.wsCheckResult&&!this.abandonedWebSocket)}connectBase(e,t){this.baseTransport?this.tryTransportWithFallbacks(this.baseTransport,e,!1,t,()=>!0):this.notifyState({state:"disconnected",error:new kg("No transports left to try",8e4,404)})}tryTransportWithFallbacks(e,t,n,r,i){var s=e=>{this.notifyState({state:this.states.connecting.failState,error:e})},o=this.domains.slice(),a=(e,t)=>{r===this.connectCounter&&(i()?t||e||c():t&&t.dispose())},l=o.shift();if(l){t.host=l;var c=()=>{o.length?this.realtime.http.checkConnectivity?rm(this.realtime.http.checkConnectivity(),(n,l)=>{r===this.connectCounter&&i()&&(n?s(n):l?(t.host=$g(o),this.tryATransport(t,e,a)):s(new kg("Unable to connect (network unreachable)",80003,404)))}):s(new xg("Internal error: Http.checkConnectivity not set",null,500)):s(new kg("Unable to connect (and no more fallback hosts to try)",80003,404))};if(this.forceFallbackHost&&o.length)return this.forceFallbackHost=!1,void c();this.tryATransport(t,e,a)}else s(new kg("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(e,t){var n;switch(this.state.state){case"connected":var r=null==(n=this.activeProtocol)?void 0:n.getTransport();r&&r.onAuthUpdated&&r.onAuthUpdated(e);var i=M_({action:Zm.AUTH,auth:{accessToken:e.token}});this.send(i);var s=()=>{this.off(o),t(null,e)},o=e=>{"failed"===e.current&&(this.off(s),this.off(o),t(e.reason||this.getStateError()))};this.once("connectiondetails",s),this.on("connectionstate",o);break;case"connecting":this.disconnectAllTransports();default:var a=n=>{switch(n.current){case"connected":this.off(a),t(null,e);break;case"failed":case"closed":case"suspended":this.off(a),t(n.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(e,t,n){n=n||J_;var r=this.state;if(r.sendEvents)this.sendImpl(new N_(e,n));else if(t&&r.queueEvents)this.logger.shouldLog(wg.LOG_MICRO),this.queue(e,n);else{var i="rejecting event, queueEvent was "+t+", state was "+r.state;n(this.errorReason||new kg(i,9e4,400))}}sendImpl(e){var t=e.message;e.ackRequired&&!e.sendAttempted&&(t.msgSerial=this.msgSerial++);try{this.activeProtocol.send(e)}catch(e){wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.sendImpl()","Unexpected exception in transport.send(): "+e.stack)}}queue(e,t){this.queuedMessages.push(new N_(e,t))}sendQueuedMessages(){for(var e;e=this.queuedMessages.shift();)this.sendImpl(e)}queuePendingMessages(e){e&&e.length&&this.queuedMessages.prepend(e)}failQueuedMessages(e){var t=this.queuedMessages.count();t>0&&(wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.failQueuedMessages()","failing "+t+" queued messages, err = "+Zg(e)),this.queuedMessages.completeAllMessages(e))}onChannelMessage(e,t){this.pendingChannelMessagesState.queue.push({message:e,transport:t}),this.pendingChannelMessagesState.isProcessing||this.processNextPendingChannelMessage()}processNextPendingChannelMessage(){if(this.pendingChannelMessagesState.queue.length>0){this.pendingChannelMessagesState.isProcessing=!0;var e=this.pendingChannelMessagesState.queue.shift();this.processChannelMessage(e.message).catch(e=>{wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.processNextPendingChannelMessage() received error ",e)}).finally(()=>{this.pendingChannelMessagesState.isProcessing=!1,this.processNextPendingChannelMessage()})}}processChannelMessage(e){var n=this;return t(function*(){yield n.realtime.channels.processChannelMessage(e)})()}ping(){var e=this;return t(function*(){var t;if("connected"!==e.state.state)throw new kg("Unable to ping service; not connected",4e4,400);var n=null==(t=e.activeProtocol)?void 0:t.getTransport();if(!n)throw e.getStateError();var r=Date.now(),i=em();return _m(new Promise(e=>{var t=s=>{s===i&&(n.off("heartbeat",t),e(Date.now()-r))};n.on("heartbeat",t),n.ping(i)}),e.options.timeouts.realtimeRequestTimeout,"Timeout waiting for heartbeat response")})()}abort(e){this.activeProtocol.getTransport().fail(e)}getTransportPreference(){var e,t;return this.transportPreference||$_()&&(null==(t=null==(e=gg.WebStorage)?void 0:e.get)?void 0:t.call(e,K_))}persistTransportPreference(e){var t,n;this.transportPreference=e.shortName,$_()&&(null==(n=null==(t=gg.WebStorage)?void 0:t.set)||n.call(t,K_,e.shortName))}unpersistTransportPreference(){var e,t;this.transportPreference=null,$_()&&(null==(t=null==(e=gg.WebStorage)?void 0:e.remove)||t.call(e,K_))}actOnErrorFromAuthorize(e){if(40171===e.code)this.notifyState({state:"failed",error:e});else if(40102===e.code)this.notifyState({state:"failed",error:e});else if(e.statusCode===Fm.Forbidden){var t="Client configured authentication provider returned 403; failing the connection";wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.actOnErrorFromAuthorize()",t),this.notifyState({state:"failed",error:new kg(t,80019,403,e)})}else{this.notifyState({state:this.state.failState,error:new kg("Client configured authentication provider request failed",80019,401,e)})}}onConnectionDetailsUpdate(e,t){if(e){this.connectionDetails=e,e.maxMessageSize&&(this.options.maxMessageSize=e.maxMessageSize);var n=e.clientId;if(n){var r=this.realtime.auth._uncheckedSetClientId(n);if(r)return wg.logAction(this.logger,wg.LOG_ERROR,"ConnectionManager.onConnectionDetailsUpdate()",r.message),void t.fail(r)}var i=e.connectionStateTtl;i&&(this.connectionStateTtl=i),this.maxIdleInterval=e.maxIdleInterval,this.emit("connectiondetails",e)}}checkWsConnectivity(){var e=this.options.wsConnectivityCheckUrl||Lm.wsConnectivityCheckUrl,t=new gg.Config.WebSocket(e);return new Promise((e,n)=>{var r=!1;t.onopen=()=>{r||(r=!0,e(),t.close())},t.onclose=t.onerror=()=>{r||(r=!0,n())}})}sessionRecoveryName(){return this.options.recoveryKeyStorageName||"ably-connection-recovery"}getSessionRecoverData(){var e,t;return G_()&&(null==(t=null==(e=gg.WebStorage)?void 0:e.getSession)?void 0:t.call(e,this.sessionRecoveryName()))}setSessionRecoverData(e){var t,n;return G_()&&(null==(n=null==(t=gg.WebStorage)?void 0:t.setSession)?void 0:n.call(t,this.sessionRecoveryName(),e))}clearSessionRecoverData(){var e,t;return G_()&&(null==(t=null==(e=gg.WebStorage)?void 0:e.removeSession)?void 0:t.call(e,this.sessionRecoveryName()))}},Q_=class extends Ym{constructor(e,t){super(e.logger),this.whenState=e=>Ym.prototype.whenState.call(this,e,this.state),this.ably=e,this.connectionManager=new X_(e,t),this.state=this.connectionManager.state.state,this.key=void 0,this.id=void 0,this.errorReason=null,this.connectionManager.on("connectionstate",e=>{var t=this.state=e.current;gg.Config.nextTick(()=>{this.emit(t,e)})}),this.connectionManager.on("update",e=>{gg.Config.nextTick(()=>{this.emit("update",e)})})}connect(){this.connectionManager.requestState({state:"connecting"})}ping(){var e=this;return t(function*(){return e.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()}},ey=class e extends m_{constructor(t){var n,r,i,s;if(super(Lm.objectifyOptions(t,!1,"BaseRealtime",wg.defaultLogger)),"string"==typeof EdgeRuntime)throw new kg('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._additionalTransportImplementations=e.transportImplementationsFromPlugins(this.options.plugins),this._RealtimePresence=null!=(r=null==(n=this.options.plugins)?void 0:n.RealtimePresence)?r:null,this._liveObjectsPlugin=null!=(s=null==(i=this.options.plugins)?void 0:i.LiveObjects)?s:null,this.connection=new Q_(this,this.options),this._channels=new ny(this),!1!==this.options.autoConnect&&this.connect()}static transportImplementationsFromPlugins(e){var t={};return(null==e?void 0:e.WebSocketTransport)&&(t[F_.WebSocket]=e.WebSocketTransport),(null==e?void 0:e.XHRPolling)&&(t[F_.XhrPolling]=e.XHRPolling),t}get channels(){return this._channels}get clientId(){return this.auth.clientId}connect(){this.connection.connect()}close(){this.connection.close()}};ey.EventEmitter=Ym;var ty=ey,ny=class extends Ym{constructor(e){super(e.logger),this.realtime=e,this.all=Object.create(null),e.connection.connectionManager.on("transport.active",()=>{this.onTransportActive()})}channelSerials(){var e={};for(var t of Wg(this.all,!0)){var n=this.all[t];n.properties.channelSerial&&(e[t]=n.properties.channelSerial)}return e}recoverChannels(e){for(var t of Wg(e,!0)){this.get(t).properties.channelSerial=e[t]}}processChannelMessage(e){var n=this;return t(function*(){var t=e.channel;if(void 0!==t){var r=n.all[t];r?yield r.processMessage(e):wg.logAction(n.logger,wg.LOG_ERROR,"Channels.processChannelMessage()","received event for non-existent channel: "+t)}else wg.logAction(n.logger,wg.LOG_ERROR,"Channels.processChannelMessage()","received event unspecified channel, action = "+e.action)})()}onTransportActive(){for(var e in this.all){var t=this.all[e];"attaching"===t.state||"detaching"===t.state?t.checkPendingState():"suspended"===t.state?t._attach(!1,null):"attached"===t.state&&t.requestState("attaching")}}propogateConnectionInterruption(e,t){var n=["attaching","attached","detaching","suspended"],r={closing:"detached",closed:"detached",failed:"failed",suspended:"suspended"}[e];for(var i in this.all){var s=this.all[i];n.includes(s.state)&&s.notifyState(r,t)}}get(e,t){e=String(e);var n=this.all[e];if(n){if(t){if(n._shouldReattachToSetOptions(t,n.channelOptions))throw new kg("Channels.get() cannot be used to set channel options that would cause the channel to reattach. Please, use RealtimeChannel.setOptions() instead.",4e4,400);n.setOptions(t)}}else n=this.all[e]=new T_(this.realtime,e,t);return n}getDerived(e,t,n){if(t.filter){var r=fm(t.filter),i=pm(e);e="[filter="+r+i.qualifierParam+"]"+i.channelName}return this.get(e,n)}release(e){e=String(e);var t=this.all[e];if(t){var n=t.getReleaseErr();if(n)throw n;delete this.all[e]}}},ry=ty,iy=Uint8Array,sy=Uint32Array,oy=Math.pow,ay=new sy(8),ly=[],cy=new sy(64);function uy(e){return(e-(0|e))*oy(2,32)|0}for(var dy,hy,py=2,fy=0;fy<64;){for(dy=!0,hy=2;hy<=py/2;hy++)py%hy===0&&(dy=!1);dy&&(fy<8&&(ay[fy]=uy(oy(py,.5))),ly[fy]=uy(oy(py,1/3)),fy++),py++}var vy=!!new iy(new sy([1]).buffer)[0];function gy(e){return vy?e>>>24|(e>>>16&255)<<8|(65280&e)<<8|e<<24:e}function my(e,t){return e>>>t|e<<32-t}function _y(e){var t,n=ay.slice(),r=e.length,i=8*r,s=512-(i+64)%512-1+i+65,o=new iy(s/8),a=new sy(o.buffer);o.set(e,0),o[r]=128,a[a.length-1]=gy(i);for(var l=0;l<s/32;l+=16){var c=n.slice();for(t=0;t<64;t++){var u;if(t<16)u=gy(a[l+t]);else{var d=cy[t-15],h=cy[t-2];u=cy[t-7]+cy[t-16]+(my(d,7)^my(d,18)^d>>>3)+(my(h,17)^my(h,19)^h>>>10)}cy[t]=u|=0;for(var p=(my(c[4],6)^my(c[4],11)^my(c[4],25))+(c[4]&c[5]^~c[4]&c[6])+c[7]+u+ly[t],f=(my(c[0],2)^my(c[0],13)^my(c[0],22))+(c[0]&c[1]^c[2]&(c[0]^c[1])),v=7;v>0;v--)c[v]=c[v-1];c[0]=p+f|0,c[4]=c[4]+p|0}for(t=0;t<8;t++)n[t]=n[t]+c[t]|0}return new iy(new sy(n.map(function(e){return gy(e)})).buffer)}var yy,by=new class{constructor(){this.base64CharSet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",this.hexCharSet="0123456789abcdef"}uint8ViewToBase64(e){for(var t,n,r,i,s="",o=this.base64CharSet,a=e.byteLength,l=a%3,c=a-l,u=0;u<c;u+=3)t=(258048&(i=e[u]<<16|e[u+1]<<8|e[u+2]))>>12,n=(4032&i)>>6,r=63&i,s+=o[(16515072&i)>>18]+o[t]+o[n]+o[r];return 1==l?(t=(3&(i=e[c]))<<4,s+=o[(252&i)>>2]+o[t]+"=="):2==l&&(t=(1008&(i=e[c]<<8|e[c+1]))>>4,n=(15&i)<<2,s+=o[(64512&i)>>10]+o[t]+o[n]+"="),s}base64ToArrayBuffer(e){for(var t=null==atob?void 0:atob(e),n=t.length,r=new Uint8Array(n),i=0;i<n;i++){var s=t.charCodeAt(i);r[i]=s}return this.toArrayBuffer(r)}isBuffer(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}toBuffer(e){if(!ArrayBuffer)throw new Error("Can't convert to Buffer: browser does not support the necessary types");if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(this.toArrayBuffer(e));throw new Error("BufferUtils.toBuffer expected an ArrayBuffer or a view onto one")}toArrayBuffer(e){if(!ArrayBuffer)throw new Error("Can't convert to ArrayBuffer: browser does not support the necessary types");if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);throw new Error("BufferUtils.toArrayBuffer expected an ArrayBuffer or a view onto one")}base64Encode(e){return this.uint8ViewToBase64(this.toBuffer(e))}base64UrlEncode(e){return this.base64Encode(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}base64Decode(e){if(ArrayBuffer&&gg.Config.atob)return this.base64ToArrayBuffer(e);throw new Error("Expected ArrayBuffer to exist and Platform.Config.atob to be configured")}hexEncode(e){return this.toBuffer(e).reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}hexDecode(e){if(e.length%2!=0)throw new Error("Can't create a byte array from a hex string of odd length");for(var t=new Uint8Array(e.length/2),n=0;n<t.length;n++)t[n]=parseInt(e.slice(2*n,2*(n+1)),16);return this.toArrayBuffer(t)}utf8Encode(e){if(gg.Config.TextEncoder){var t=(new gg.Config.TextEncoder).encode(e);return this.toArrayBuffer(t)}throw new Error("Expected TextEncoder to be configured")}utf8Decode(e){if(!this.isBuffer(e))throw new Error("Expected input of utf8decode to be an arraybuffer or typed array");if(TextDecoder)return(new TextDecoder).decode(e);throw new Error("Expected TextDecoder to be configured")}areBuffersEqual(e,t){if(!e||!t)return!1;var n=this.toArrayBuffer(e),r=this.toArrayBuffer(t);if(n.byteLength!=r.byteLength)return!1;for(var i=new Uint8Array(n),s=new Uint8Array(r),o=0;o<i.length;o++)if(i[o]!=s[o])return!1;return!0}byteLength(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}arrayBufferViewToBuffer(e){return this.toArrayBuffer(e)}concat(e){var t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(var i of e){var s=this.toBuffer(i);n.set(s,r),r+=s.byteLength}return n.buffer}sha256(e){var t=_y(this.toBuffer(e));return this.toArrayBuffer(t)}hmacSha256(e,t){var n=function(e,t){if(e.length>64&&(e=_y(e)),e.length<64){var n=new Uint8Array(64);n.set(e,0),e=n}for(var r=new Uint8Array(64),i=new Uint8Array(64),s=0;s<64;s++)r[s]=54^e[s],i[s]=92^e[s];var o=new Uint8Array(t.length+64);o.set(r,0),o.set(t,64);var a=new Uint8Array(96);return a.set(i,0),a.set(_y(o),64),_y(a)}(this.toBuffer(t),this.toBuffer(e));return this.toArrayBuffer(n)}},wy=(e=>(e[e.REQ_SEND=0]="REQ_SEND",e[e.REQ_RECV=1]="REQ_RECV",e[e.REQ_RECV_POLL=2]="REQ_RECV_POLL",e[e.REQ_RECV_STREAM=3]="REQ_RECV_STREAM",e))(wy||{}),Cy=wy;function Sy(){return new kg("No HTTP request plugin provided. Provide at least one of the FetchRequest or XHRRequest plugins.",400,4e4)}var ky=(yy=class{constructor(e){var n;this.checksInProgress=null,this.checkConnectivity=void 0,this.supportsAuthHeaders=!1,this.supportsLinkHeaders=!1,this.client=null!=e?e:null;var r=(null==e?void 0:e.options.connectivityCheckUrl)||Lm.connectivityCheckUrl,i=null!=(n=null==e?void 0:e.options.connectivityCheckParams)?n:null,s=!(null==e?void 0:e.options.connectivityCheckUrl),o=pg(pg({},ky.bundledRequestImplementations),null==e?void 0:e._additionalHTTPRequestImplementations),a=o.XHRRequest,l=o.FetchRequest,c=!(!a&&!l);if(!c)throw Sy();gg.Config.xhrSupported&&a?(this.supportsAuthHeaders=!0,this.Request=function(){var n=t(function*(t,n,r,i,s){return new Promise(o=>{var l,c=a.createRequest(n,r,i,s,Cy.REQ_SEND,null!=(l=e&&e.options.timeouts)?l:null,this.logger,t);c.once("complete",(e,t,n,r,i)=>o({error:e,body:t,headers:n,unpacked:r,statusCode:i})),c.exec()})});return function(e,t,r,i,s){return n.apply(this,arguments)}}(),(null==e?void 0:e.options.disableConnectivityCheck)?this.checkConnectivity=t(function*(){return!0}):this.checkConnectivity=t(function*(){var e,t,n=yield this.doUri(Um.Get,r,null,null,i);return s?!n.error&&"yes"==(null==(e=n.body)?void 0:e.replace(/\n/,"")):!n.error&&((t=n.statusCode)>=200&&t<400)})):gg.Config.fetchSupported&&l?(this.supportsAuthHeaders=!0,this.Request=function(){var n=t(function*(t,n,r,i,s){return l(t,null!=e?e:null,n,r,i,s)});return function(e,t,r,i,s){return n.apply(this,arguments)}}(),(null==e?void 0:e.options.disableConnectivityCheck)?this.checkConnectivity=t(function*(){return!0}):this.checkConnectivity=t(function*(){var e,t=yield this.doUri(Um.Get,r,null,null,null);return!t.error&&"yes"==(null==(e=t.body)?void 0:e.replace(/\n/,""))})):this.Request=t(function*(){return{error:c?new xg("no supported HTTP transports available",null,400):Sy()}})}get logger(){var e,t;return null!=(t=null==(e=this.client)?void 0:e.logger)?t:wg.defaultLogger}doUri(e,n,r,i,s){var o=this;return t(function*(){return o.Request?o.Request(e,n,r,s,i):{error:new xg("Request invoked before assigned to",null,500)}})()}shouldFallback(e){var t=e.statusCode;return 408===t&&!e.code||400===t&&!e.code||t>=500&&t<=504}},yy.methods=[Um.Get,Um.Delete,Um.Post,Um.Put,Um.Patch],yy.methodsWithoutBody=[Um.Get,Um.Delete],yy.methodsWithBody=[Um.Post,Um.Put,Um.Patch],yy),xy=ky,Iy="ablyjs-storage-test",Ty="undefined"!=typeof global?global:"undefined"!=typeof window?window:self,Ey=new class{constructor(){try{Ty.sessionStorage.setItem(Iy,Iy),Ty.sessionStorage.removeItem(Iy),this.sessionSupported=!0}catch(e){this.sessionSupported=!1}try{Ty.localStorage.setItem(Iy,Iy),Ty.localStorage.removeItem(Iy),this.localSupported=!0}catch(e){this.localSupported=!1}}get(e){return this._get(e,!1)}getSession(e){return this._get(e,!0)}remove(e){return this._remove(e,!1)}removeSession(e){return this._remove(e,!0)}set(e,t,n){return this._set(e,t,n,!1)}setSession(e,t,n){return this._set(e,t,n,!0)}_set(e,t,n,r){var i={value:t};return n&&(i.expires=Date.now()+n),this.storageInterface(r).setItem(e,JSON.stringify(i))}_get(e,t){if(t&&!this.sessionSupported)throw new Error("Session Storage not supported");if(!t&&!this.localSupported)throw new Error("Local Storage not supported");var n=this.storageInterface(t).getItem(e);if(!n)return null;var r=JSON.parse(n);return r.expires&&r.expires<Date.now()?(this.storageInterface(t).removeItem(e),null):r.value}_remove(e,t){return this.storageInterface(t).removeItem(e)}storageInterface(e){return e?Ty.sessionStorage:Ty.localStorage}},Ay=dm(),Oy="string"==typeof EdgeRuntime;"undefined"!=typeof Window||"undefined"!=typeof WorkerGlobalScope||Oy||console.log("Warning: this distribution of Ably is intended for browsers. On nodejs, please use the 'ably' package on npm");var My,Ry,Py={agent:"browser",logTimestamps:!0,userAgent:Ay.navigator&&Ay.navigator.userAgent.toString(),currentUrl:Ay.location&&Ay.location.href,binaryType:"arraybuffer",WebSocket:Ay.WebSocket,fetchSupported:!!Ay.fetch,xhrSupported:Ay.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,allowComet:(Ry=Ay.location,!Ay.WebSocket||!Ry||!Ry.origin||Ry.origin.indexOf("http")>-1),useProtocolHeartbeats:!0,supportsBinary:!!Ay.TextDecoder,preferBinary:!1,ArrayBuffer:Ay.ArrayBuffer,atob:Ay.atob,nextTick:"function"==typeof Ay.queueMicrotask?e=>Ay.queueMicrotask(e):e=>Promise.resolve().then(e),addEventListener:Ay.addEventListener,inspect:JSON.stringify,stringByteSize:function(e){return Ay.TextDecoder&&(new Ay.TextEncoder).encode(e).length||e.length},TextEncoder:Ay.TextEncoder,TextDecoder:Ay.TextDecoder,getRandomArrayBuffer:(My=t(function*(e){var t=new Uint8Array(e);return Ay.crypto.getRandomValues(t),t.buffer}),function(e){return My.apply(this,arguments)}),isWebworker:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,push:{platform:"browser",formFactor:"desktop",storage:Ey}},Ly=Py;F_.XhrPolling;var Ny=F_.WebSocket;var Dy=class extends V_{constructor(e,t,n){super(e,t,n),this.shortName=Ny,n.heartbeats=gg.Config.useProtocolHeartbeats,this.wsHost=n.host}static isAvailable(){return!!gg.Config.WebSocket}createWebSocket(e,t){return this.uri=e+Gg(t),new gg.Config.WebSocket(this.uri)}toString(){return"WebSocketTransport; uri="+this.uri}connect(){V_.prototype.connect.call(this);var e=this,t=this.params,n=t.options,r=(n.tls?"wss://":"ws://")+this.wsHost+":"+Lm.getPort(n)+"/";rm(this.auth.getAuthParams(),function(n,i){if(!e.isDisposed){for(var s in i)" "+s+": "+i[s]+";";if(n)e.disconnect(n);else{var o=t.getConnectParams(i);try{var a=e.wsConnection=e.createWebSocket(r,o);a.binaryType=gg.Config.binaryType,a.onopen=function(){e.onWsOpen()},a.onclose=function(t){e.onWsClose(t)},a.onmessage=function(t){e.onWsData(t.data)},a.onerror=function(t){e.onWsError(t)},a.on&&a.on("ping",function(){e.onActivity()})}catch(t){wg.logAction(e.logger,wg.LOG_ERROR,"WebSocketTransport.connect()","Unexpected exception creating websocket: err = "+(t.stack||t.message)),e.disconnect(t)}}}})}send(e){var t=this.wsConnection;if(t)try{t.send(E_(e,this.connectionManager.realtime._MsgPack,this.params.format))}catch(e){var n="Exception from ws connection when trying to send: "+Zg(e);wg.logAction(this.logger,wg.LOG_ERROR,"WebSocketTransport.send()",n),this.finish("disconnected",new kg(n,5e4,500))}else wg.logAction(this.logger,wg.LOG_ERROR,"WebSocketTransport.send()","No socket connection")}onWsData(e){try{this.onProtocolMessage(O_(e,this.connectionManager.realtime._MsgPack,this.connectionManager.realtime._RealtimePresence,this.connectionManager.realtime._Annotations,this.connectionManager.realtime._liveObjectsPlugin,this.format))}catch(e){wg.logAction(this.logger,wg.LOG_ERROR,"WebSocketTransport.onWsData()","Unexpected exception handing channel message: "+e.stack)}}onWsOpen(){this.emit("preconnect")}onWsClose(e){var t,n;if("object"==typeof e?(n=e.code,t=e.wasClean||1e3===n):t=1e3==(n=e),delete this.wsConnection,t){var r=new kg("Websocket closed",80003,400);this.finish("disconnected",r)}else{var i=new kg("Unclean disconnection of WebSocket ; code = "+n,80003,400);this.finish("disconnected",i)}this.emit("disposed")}onWsError(e){gg.Config.nextTick(()=>{this.disconnect(Error(e.message))})}dispose(){this.isDisposed=!0;var e=this.wsConnection;e&&(e.onmessage=function(){},delete this.wsConnection,gg.Config.nextTick(()=>{if(!e)throw new Error("WebSocketTransport.dispose(): wsConnection is not defined");e.close()}))}},Uy={order:["xhr_polling"],bundledImplementations:{}},By={connectivityCheckUrl:"https://internet-up.ably-realtime.com/is-the-internet-up.txt",wsConnectivityCheckUrl:"wss://ws-up.ably-realtime.com",defaultTransports:[F_.XhrPolling,F_.WebSocket]};function Fy(e,t,n,r,i,s){return jy.apply(this,arguments)}function jy(){return jy=t(function*(e,n,r,i,s,o){var a,l=new Headers(i||{}),c=e?e.toUpperCase():Mg(o)?"GET":"POST",u=new AbortController,d=new Promise(e=>{a=setTimeout(()=>{u.abort(),e({error:new xg("Request timed out",null,408)})},n?n.options.timeouts.httpRequestTimeout:Lm.TIMEOUTS.httpRequestTimeout)}),h={method:c,headers:l,body:o,signal:u.signal};gg.Config.isWebworker||(h.credentials=l.has("authorization")?"include":"same-origin");var p=t(function*(){try{var e=new URLSearchParams(s||{});e.set("rnd",em());var t=r+"?"+e,n=yield dm().fetch(t,h);if(clearTimeout(a),204==n.status)return{error:null,statusCode:n.status};var i,o=n.headers.get("Content-Type");i=o&&o.indexOf("application/x-msgpack")>-1?yield n.arrayBuffer():o&&o.indexOf("application/json")>-1?yield n.json():yield n.text();var l=!!o&&-1===o.indexOf("application/x-msgpack"),c=function(e){var t={};return e.forEach((e,n)=>{t[n]=e}),t}(n.headers);if(n.ok)return{error:null,body:i,headers:c,unpacked:l,statusCode:n.status};var u=function(e,t){if(function(e,t){return!!t.get("x-ably-errorcode")}(0,t))return e.error&&kg.fromValues(e.error)}(i,n.headers)||new xg("Error response received from server: "+n.status+" body was: "+gg.Config.inspect(i),null,n.status);return{error:u,body:i,headers:c,unpacked:l,statusCode:n.status}}catch(u){return clearTimeout(a),{error:u}}})();return Promise.race([d,p])}),jy.apply(this,arguments)}var Wy;function Hy(e,t){var r,i,s=null!==(r=e.metadata)&&void 0!==r?r:{},o=null!==(i=t.metadata)&&void 0!==i?i:{};return!o.widgets&&s._widgets?n({},t,{metadata:n({},o,{_widgets:s._widgets})}):t}function zy(e,t,r,i){var s,o,a,l=(o=e.messages.value,a=t.id,o.some(e=>e.id===a));if(e.setMessages(function(e,t){var n=e.findIndex(e=>e.id===t.id);if(-1!==n){var r=e[n],i=Hy(r,t);if(function(e,t){return e.id===t.id&&e.channel_id===t.channel_id&&e.sender_type===t.sender_type&&e.sender_id===t.sender_id&&e.sender_name===t.sender_name&&e.sender_avatar_url===t.sender_avatar_url&&e.content===t.content&&e.content_type===t.content_type&&e.created_at===t.created_at&&e.metadata===t.metadata}(r,i))return e;var s=[...e];return s[n]=i,s}if("ai"===t.sender_type){var o=e.findIndex(e=>e.id.startsWith("temp-ai-"));if(-1!==o){var a=Hy(e[o],t),l=[...e];return l[o]=a,l}}return Rv(e,t)}(e.messages.value,t)),"user"!==t.sender_type||t.sender_id!==r){if(!l){if("ai"===t.sender_type||"agent"===t.sender_type){var c=e.isOpen.value,u=(null===(s=e.channel.value)||void 0===s?void 0:s.id)===t.channel_id;if(c&&u)i.onAgentMessageWhileOpen();else{var d=e.channels.value.findIndex(e=>e.id===t.channel_id);if(-1!==d){var h=[...e.channels.value];h[d]=n({},h[d],{unread_count:(h[d].unread_count||0)+1}),e.channels.value=h}}i.onTrack(t)}e.isTyping.value=!1,e.typingSender.value=null,e.typingSenderType.value=null,i.onMessageDispatched(t)}}else i.onMessageDispatched(t)}gg.BufferUtils=by,gg.Http=xy,gg.Config=Ly,gg.Transports=Uy,gg.WebStorage=Ey,xy.bundledRequestImplementations={},wg.initLogHandlers(),gg.Defaults=(Wy=By,Object.assign(Cm,Wy)),gg.Config.agent&&(gg.Defaults.agent+=" "+gg.Config.agent);var Vy="chat.ably";function qy(e,t,n){return $y.apply(this,arguments)}function $y(){return($y=t(function*(e,t,r){return Ch(e,wh,{method:"POST",body:JSON.stringify(n({distinct_id:t},r&&{channel_id:r}))})})).apply(this,arguments)}function Gy(){return(Gy=t(function*(e,t){var n=yield qy(e,t);return(null==n?void 0:n.tokenRequest)?n.clientId&&null!=n.project_id?{tokenRequest:n.tokenRequest,clientId:n.clientId,projectId:n.project_id}:(cu().warn(Vy,"token:request:incomplete — missing clientId or project_id"),null):(cu().warn(Vy,"token:request:failed (initial)"),null)})).apply(this,arguments)}var Jy="chat.ably";function Ky(e,t){var n=(()=>{if(!t||"object"!=typeof t)return String(t);var e=t,n="string"==typeof e.message?e.message:String(t),r="number"==typeof e.code?e.code:null,i="number"==typeof e.statusCode?e.statusCode:null;return r||i?n+" (code="+(null!=r?r:"-")+", status="+(null!=i?i:"-")+")":n})(),r=n.toLowerCase();return r.includes("timeout for trying fallback hosts")||r.includes("connection failed")||r.includes("network")||r.includes("failed to fetch")?e+" — "+n+" (browser cannot reach Ably hosts (*.ably.io / *.ably-realtime.com) — check ad-blocker, firewall, VPN, or offline state)":e+" — "+n}var Yy=e=>new ry(e);class Zy{constructor(e,t,n,r){void 0===r&&(r=Yy),this.instance=e,this.store=t,this.hooks=n,this._client=null,this._notificationsChannel=null,this._conversationChannel=null,this._typingChannel=null,this._teardownInFlight=null,this._factory=r}get clientId(){var e,t;return null!==(t=null===(e=this._client)||void 0===e?void 0:e.auth.clientId)&&void 0!==t?t:null}get isLive(){return null!=this._client}get currentChannelId(){return this.store.realtimeChannelId.value}ensureConnected(){var e=this;return t(function*(){if(!e._client){e.store.connectionState.value="connecting",cu().debug(Jy,"connect:start");var r=e.hooks.getDistinctId(),i=yield function(e,t){return Gy.apply(this,arguments)}(e.instance,r);if(i){e.store.ablyProjectId.value=i.projectId;var s,o=i.clientId,a=e._factory({plugins:{WebSocketTransport:Dy,FetchRequest:Fy},authCallback:(s={instance:e.instance,getDistinctId:()=>e.hooks.getDistinctId(),getChannelScope:()=>{var t,n,r,i;return null!==(i=null!==(n=null!==(t=e.store.pendingRealtimeChannelId.value)&&void 0!==t?t:e.store.realtimeChannelId.value)&&void 0!==n?n:null===(r=e.store.channel.value)||void 0===r?void 0:r.id)&&void 0!==i?i:null},getLiveClientId:()=>{var t,n;return null!==(n=null===(t=e._client)||void 0===t?void 0:t.auth.clientId)&&void 0!==n?n:null},onIdentityChange:()=>e.hooks.onIdentityChange()},function(){var e=t(function*(e,t){try{var n=s.getChannelScope(),r=yield qy(s.instance,s.getDistinctId(),null!=n?n:void 0);if(!(null==r?void 0:r.tokenRequest))return void t("Failed to refresh token",null);var i=r.tokenRequest.clientId,o=s.getLiveClientId();if(o&&i&&i!==o)return cu().warn(Vy,"token:request:clientid-mismatch — recreating connection"),t("clientId changed; recreating connection",null),void s.onIdentityChange();t(null,r.tokenRequest)}catch(e){t(String(e),null)}});return function(t,n){return e.apply(this,arguments)}}()),authMethod:"POST"});e._client=a,a.connection.on("connected",()=>{e.store.connectionState.value="connected",e._checkClientIdDrift(),cu().debug(Jy,"connect:connected")}),a.connection.on("disconnected",()=>{e.store.connectionState.value="disconnected",cu().debug(Jy,"connect:disconnected")}),a.connection.on("suspended",()=>{e.store.connectionState.value="suspended",cu().debug(Jy,"connect:suspended")}),a.connection.on("failed",()=>{e.store.connectionState.value="failed",cu().debug(Jy,"connect:failed")});try{yield a.auth.authorize(i.tokenRequest)}catch(t){return cu().error(Jy,Ky("connect:authorize-failed",t)),void(e.store.connectionState.value="failed")}var l=a.connection.state;"connected"===l?(e.store.connectionState.value="connected",e._checkClientIdDrift(),cu().debug(Jy,"connect:connected (sync)")):"disconnected"!==l&&"suspended"!==l&&"failed"!==l||(e.store.connectionState.value=l,cu().debug(Jy,"connect:"+l+" (sync)"));var c="chat:"+i.projectId+":notifications";e._notificationsChannel=a.channels.get(c),e._notificationsChannel.subscribe("notification",t=>{!function(e,t,r){var i,s,o,{type:a,channel_id:l,data:c}=t;if("new_channel"!==a)if("channel_updated"===a&&c){var u=e.channels.value.findIndex(e=>e.id===l);if(-1!==u){var d={};void 0!==c.last_message_at&&(d.last_message_at=c.last_message_at),void 0!==c.last_message_preview&&(d.last_message_preview=c.last_message_preview),void 0!==c.last_message_sender&&(d.last_message_sender=c.last_message_sender),void 0!==c.user_unread_count&&(e.isOpen.value&&(null===(i=e.channel.value)||void 0===i?void 0:i.id)===l||(d.unread_count=c.user_unread_count)),void 0!==c.status&&(d.status=c.status),void 0!==c.ai_mode&&(d.ai_mode=c.ai_mode),e.patchChannelSummary(l,d)}(null===(s=e.channel.value)||void 0===s?void 0:s.id)===l&&"closed"===c.status&&(e.channel.value=n({},e.channel.value,{status:"closed"}))}else"channel_closed"===a&&(e.patchChannelSummary(l,{status:"closed"}),(null===(o=e.channel.value)||void 0===o?void 0:o.id)===l&&(e.channel.value=n({},e.channel.value,{status:"closed"})));else r.onNewChannel()}(e.store,t.data,{onNewChannel:e.hooks.onNewChannelNotification})}),e.store.lastConnectedDistinctId.value=o.split(":").slice(1).join(":")||r}else e.store.connectionState.value="failed"}})()}refreshToken(e){var n=this;return t(function*(){var t=n._client;if(!t)return!1;if("failed"===t.connection.state)return cu().warn(Jy,"token:skip — connection failed"),n.hooks.onIdentityChange(),!1;var r=yield qy(n.instance,n.hooks.getDistinctId(),e);if(!(null==r?void 0:r.tokenRequest))return cu().warn(Jy,"token:request:failed",null!=e?e:"(list)"),!1;var i=r.tokenRequest.clientId,s=t.auth.clientId;if(s&&i&&i!==s)return cu().warn(Jy,"token:request:clientid-mismatch — recreating connection"),n.hooks.onIdentityChange(),!1;try{return yield t.auth.authorize(r.tokenRequest),!0}catch(e){return cu().warn(Jy,Ky("token:authorize-failed",e)),!1}})()}attachConversation(e){var n=this;return t(function*(){var t;if(yield n.ensureConnected(),n._client&&null!=n.store.ablyProjectId.value){if(n._conversationChannel||n._typingChannel||n._teardownInFlight){var r=null!==(t=n._teardownInFlight)&&void 0!==t?t:n._teardownActive();try{yield r}catch(e){}}if(n.store.pendingRealtimeChannelId.value=e,!(yield n.refreshToken(e)))return cu().warn(Jy,"channel:attach:no-capability for",e),void(n.store.pendingRealtimeChannelId.value===e&&(n.store.pendingRealtimeChannelId.value=null));var i="chat:"+n.store.ablyProjectId.value+":"+e,s=i+":typing",o=n._client.channels.get(i),a=n._client.channels.get(s);n._conversationChannel=o,n._typingChannel=a;var l=()=>n._conversationChannel!==o||n._typingChannel!==a;cu().debug(Jy,"channel:attach:start",e);try{if(yield o.attach(),l())return void cu().debug(Jy,"channel:attach:superseded",e);if(o.subscribe("message",e=>{n._conversationChannel===o&&zy(n.store,e.data,n.hooks.getDistinctId()||null,{onAgentMessageWhileOpen:n.hooks.onAgentMessageWhileOpen,onTrack:n.hooks.onMessageTrack,onMessageDispatched:n.hooks.onMessageDispatched})}),o.subscribe("read",e=>{var t,r;n._conversationChannel===o&&(t=n.store,"agent"===(r=e.data).reader_type&&(t.agentLastReadAt.value=r.read_at))}),yield a.attach(),l())return void cu().debug(Jy,"channel:attach:superseded",e);if(a.subscribe("typing",e=>{n._typingChannel===a&&function(e,t,n){if("user"!==t.sender_type){e.isTyping.value=t.is_typing,e.typingSenderType.value=t.is_typing?t.sender_type:null;var r="ai"===t.sender_type?null:t.sender_name||("agent"===t.sender_type?"Agent":null);e.typingSender.value=t.is_typing?r:null,n.onTyping(t.is_typing,r||"")}}(n.store,e.data,{onTyping:n.hooks.onTypingDispatched})}),n.store.pendingRealtimeChannelId.value!==e)return void cu().debug(Jy,"channel:attach:abandoned (pending cleared)",e);n.store.realtimeChannelId.value=e,n.store.realtimeAttached.value=!0,n.store.pendingRealtimeChannelId.value===e&&(n.store.pendingRealtimeChannelId.value=null),cu().debug(Jy,"channel:realtime.attached",{channelId:e})}catch(t){if(l())return void cu().debug(Jy,"channel:attach:superseded (after error)",e);cu().error(Jy,"channel:attach:failed",t),n.store.realtimeAttached.value=!1,n.store.pendingRealtimeChannelId.value===e&&(n.store.pendingRealtimeChannelId.value=null),yield n._teardownActive()}}})()}detachConversation(){var e=this._teardownActive().finally(()=>{this._teardownInFlight===e&&(this._teardownInFlight=null)});return this._teardownInFlight=e,e}_teardownActive(){var e=this._client,t=this._conversationChannel,n=this._typingChannel;return this._conversationChannel=null,this._typingChannel=null,Promise.all([this._teardownChannel(e,t),this._teardownChannel(e,n)]).then(()=>{})}publishTyping(e){var t=this._typingChannel;t&&t.publish("typing",e).catch(e=>{cu().warn(Jy,"failed to publish typing indicator:",e)})}disconnectAll(){var e=this;return t(function*(){if(e._teardownInFlight)try{yield e._teardownInFlight}catch(e){}var t=e._client,n=e._conversationChannel,r=e._typingChannel,i=e._notificationsChannel;if(e._conversationChannel=null,e._typingChannel=null,e._notificationsChannel=null,e.store.realtimeChannelId.value=null,e.store.realtimeAttached.value=!1,null==n||n.unsubscribe(),null==r||r.unsubscribe(),null==i||i.unsubscribe(),t){try{t.close()}catch(e){cu().debug(Jy,"disconnect:close:error",e)}e._client=null}e.store.ablyProjectId.value=null,e.store.connectionState.value="disconnected",e.store.lastConnectedDistinctId.value=null})()}_checkClientIdDrift(){var e,t=null===(e=this._client)||void 0===e?void 0:e.auth.clientId,n=this.store.lastConnectedDistinctId.value;if(t&&n){var r=t.split(":").slice(1).join(":")||t;r&&r!==n&&(cu().warn(Jy,"identity:drift detected on connected — recreating"),this.hooks.onIdentityChange())}}_teardownChannel(e,n){return t(function*(){if(n&&e){n.unsubscribe();try{yield n.detach()}catch(e){}}})()}}var Xy=["delivery_status"];function Qy(e,t,i){var s=e.messages.value,o=s.findIndex(e=>e.id===t);if(-1!==o){var a=s[o];if(a.delivery_status!==i){var l=[...s];if(void 0===i){var c=r(a,Xy);l[o]=c}else l[o]=n({},a,{delivery_status:i});e.setMessages(l)}}}function eb(e,t){return tb.apply(this,arguments)}function tb(){return tb=t(function*(e,t){var n;if(!e.ok)return!1;if(e.headers.get("X-Vtilt-User-Message-Id")===t)return!0;var r=e.headers.get("content-type")||"";if(r.includes("text/plain"))return e.ok;if(r.includes("application/json"))try{var i=yield e.clone().json();return(null===(n=null==i?void 0:i.message)||void 0===n?void 0:n.id)===t}catch(e){return!1}return e.ok}),tb.apply(this,arguments)}function nb(e,t){return"vtilt-chat-outbox:"+e+":"+t}function rb(e){return e+":last-channel"}class ib{constructor(e){this._storageKey=e,this._memory=[]}list(){var e=this._readStorage();return e.length>0?(this._memory=e,e):this._memory}get(e){return this.list().find(t=>t.messageId===e)}upsert(e){var t=this.list().filter(t=>t.messageId!==e.messageId);t.push(e),this._write(t)}patch(e,t){var r=this.list(),i=r.findIndex(t=>t.messageId===e);-1!==i&&(r[i]=n({},r[i],t),this._write(r))}remove(e){this._write(this.list().filter(t=>t.messageId!==e))}dueEntries(e){return void 0===e&&(e=Date.now()),this.list().filter(t=>"sending"!==t.state&&t.nextRetryAt<=e&&!(t.newChannel&&!t.channelId))}requeueStaleSending(e,t){var r;void 0===e&&(e=3e4),void 0===t&&(t=Date.now());for(var i=this.list(),s=!1,o=0;o<i.length;o++){var a=i[o];if("sending"===a.state){var l=null!==(r=a.sendingSince)&&void 0!==r?r:0;(!l||t-l>=e)&&(i[o]=n({},a,{state:"pending",sendingSince:void 0}),s=!0)}}s&&this._write(i)}_readStorage(){if("undefined"==typeof sessionStorage)return[];try{var e=sessionStorage.getItem(this._storageKey);if(!e)return[];var t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return[]}}_write(e){if(this._memory=e,"undefined"!=typeof sessionStorage)try{0===e.length?sessionStorage.removeItem(this._storageKey):sessionStorage.setItem(this._storageKey,JSON.stringify(e))}catch(e){}}}function sb(e,t){return void 0===t&&(t=Date.now()),t+Math.min(6e4,1e3*Math.pow(2,Math.max(0,e-1)))}var ob="chat";class ab{constructor(e,t){var r,i,s,o,a,l,c,u,d;void 0===t&&(t={}),this._ui=null,this._registry=new Oh,this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._lastConnectedNotified=null,this._unsubscribeIdentity=null,this._unsubscribeReset=null,this._identityChangeInFlight=!1,this._typingIdleTimer=null,this._isUserTyping=!1,this._lastTypingPublishAt=0,this._lastTypingActivityAt=0,this._pendingTypingIntent=!1,this._disposeRealtimeReadyWatcher=null,this._isMarkingRead=!1,this._streamAbort=null,this._streamingMessageId=null,this._optimisticAiTyping=!1,this._openedAt=null,this._disposeConnectionWatcher=null,this._drainInFlight=!1,this._drainTimer=null,this._onOutboxOnline=()=>{this._scheduleDrainOutbox()},this._onOutboxVisible=()=>{"undefined"!=typeof document&&"visible"===document.visibilityState&&this._scheduleDrainOutbox()},this._bubbleExplicitShow=!1,this._instance=e,this._config=n({enabled:!0,position:"bottom-right",aiMode:!0,preload:!1},t,{theme:n({},Ff,t.theme)}),this._store=new jf,this._store.isVisible.value=!1!==(null===(r=this._config.bubble)||void 0===r?void 0:r.visible),this._store.theme.value={primaryColor:null!==(s=null===(i=this._config.theme)||void 0===i?void 0:i.primaryColor)&&void 0!==s?s:Ff.primaryColor,fontFamily:null!==(a=null===(o=this._config.theme)||void 0===o?void 0:o.fontFamily)&&void 0!==a?a:Ff.fontFamily,borderRadius:null!==(c=null===(l=this._config.theme)||void 0===l?void 0:l.borderRadius)&&void 0!==c?c:Ff.borderRadius},this._registry.register(Qp),this._registry.register(df),this._ably=new Zy(e,this._store,{getDistinctId:()=>this._distinctId,onIdentityChange:()=>{this._handleIdentityChange()},onNewChannelNotification:()=>{this.getChannels()},onAgentMessageWhileOpen:()=>{setTimeout(()=>this._autoMarkAsRead(),100)},onMessageTrack:e=>{var t,n,r,i;this._trackChatMessage(e,e.channel_id,null!==(n=null===(t=this._store.channel.value)||void 0===t?void 0:t.ai_mode)&&void 0!==n&&n),"ai"!==e.sender_type&&"agent"!==e.sender_type||null===(i=(r=this._config).onMessageReceived)||void 0===i||i.call(r,{channelId:e.channel_id,messageId:e.id,senderType:e.sender_type})},onMessageDispatched:e=>{this._messageCallbacks.forEach(t=>t(e))},onTypingDispatched:(e,t)=>{this._typingCallbacks.forEach(n=>n(e,t))}}),this._disposeConnectionWatcher=this._watchConnectionState(),this._disposeRealtimeReadyWatcher=this._store.realtimeReady.subscribe(e=>{if(e&&this._pendingTypingIntent){var t=Date.now()-this._lastTypingActivityAt;this._pendingTypingIntent=!1,t<3e3&&(this._isUserTyping=!0,this._publishTyping(!0),this._lastTypingPublishAt=Date.now(),this._scheduleTypingIdle())}}),this._ui=ig({store:this._store,controller:this,position:null!==(u=this._config.position)&&void 0!==u?u:"bottom-right",bubbleDraggable:!!(null===(d=this._config.bubble)||void 0===d?void 0:d.draggable)}),this._applyBubbleLayout(),this._unsubscribeIdentity=this._instance._emitter.on("user:identified",()=>{this._handleIdentityChange()}),this._unsubscribeReset=this._instance._emitter.on("user:reset",()=>{this._handleIdentityChange()}),this._outboxDistinctId=this._distinctId,this._outbox=new ib(this._outboxStorageKey()),this._outbox.requeueStaleSending(),this._bindOutboxLifecycle(),this._scheduleDrainOutbox()}get isOpen(){return this._store.isOpen.value}get isConnected(){return this._store.isConnected.value}get isLoading(){return this._store.isLoading.value}get unreadCount(){return this._store.unreadCount.value}get channel(){return this._store.channel.value}get channels(){return this._store.channels.value}get currentView(){return this._store.currentView.value}get store(){return this._store}get widgets(){return this._registry}get theme(){return this._store.theme.value}get config(){return this._config}open(){var e,t;this._store.isOpen.value||(this._store.isVisible.value=!0,this._store.isOpen.value=!0,this._store.polledUnreadTotal.value=null,this._openedAt=Date.now(),null===(t=(e=this._config).onWidgetOpen)||void 0===t||t.call(e),this._ably.ensureConnected(),0===this._store.channels.value.length&&this.getChannels())}close(){var e,t,n;if(this._store.isOpen.value){var r=this._openedAt?Math.round((Date.now()-this._openedAt)/1e3):0;this._openedAt=null,this._store.isOpen.value=!1,this.stopUserTyping(),this._bubbleExplicitShow||!1!==(null===(e=this._config.bubble)||void 0===e?void 0:e.visible)||(this._store.isVisible.value=!1);var i=this._store.messages.value.filter(e=>"user"===e.sender_type).length;null===(n=(t=this._config).onWidgetClose)||void 0===n||n.call(t,{timeOpenSeconds:r,messagesSent:i}),this._teardownRealtimeOnClose()}}_teardownRealtimeOnClose(){var e=this;return t(function*(){yield e._ably.detachConversation(),yield e._ably.disconnectAll()})()}applyPolledUnreadCount(e){this._store.isOpen.value||(this._store.polledUnreadTotal.value=e)}toggle(){this._store.isOpen.value?this.close():this.open()}show(){this._bubbleExplicitShow=!0,this._store.isVisible.value=!0}hide(){this._bubbleExplicitShow=!1,this._store.isVisible.value=!1}getChannels(){var e=this;return t(function*(){e._store.isLoading.value=!0;try{var t=yield Ch(e._instance,_h+"?distinct_id="+encodeURIComponent(e._distinctId),{method:"GET"});t&&(e._store.channels.value=t.channels||[])}catch(e){cu().error(ob,"failed to fetch channels:",e)}finally{e._store.isLoading.value=!1}})()}selectChannel(e){var n=this;return t(function*(){var t=n._store.channels.value.find(t=>t.id===e);n._store.channel.value=t?n._stubChannelFromSummary(t):null,n._store.prepareChannelSwitch();var r=n._store.getCachedMessages(e);r&&(n._store.messages.value=r),n._store.currentView.value="conversation",n._store.isLoading.value=!0,n._store.pendingRealtimeChannelId.value=e,n._ably.detachConversation();var i=!1,s=!1;try{var o=yield Ch(n._instance,_h+"/"+e+"?distinct_id="+encodeURIComponent(n._distinctId),{method:"GET"});if(n._store.pendingRealtimeChannelId.value!==e)return void(s=!0);if(!o)return void cu().error(ob,"selectChannel: server returned no data for channel",e);n._store.channel.value=o.channel;var a=o.messages||[];n._store.messages.value=a,n._store.cacheMessages(o.channel.id,a),n._store.agentLastReadAt.value=o.channel.agent_last_read_at||null,n._store.initialUserReadAt.value=o.channel.user_last_read_at||null,n._ably.attachConversation(o.channel.id),n._store.isOpen.value&&n._autoMarkAsRead(),i=!0}catch(e){cu().error(ob,"failed to select channel:",e)}finally{n._store.pendingRealtimeChannelId.value===e&&(n._store.pendingRealtimeChannelId.value=null),n._store.isLoading.value=!1,s||i||null!==n._store.channel.value||"conversation"!==n._store.currentView.value||(n._store.currentView.value="list")}})()}createChannel(e){var r=this;return t(function*(){var t,i,s,o=!0===(null==e?void 0:e.skipGreeting),a=!0===(null==e?void 0:e.preserveMessages),l=a?r._store.messages.value.slice():[];r._store.channel.value=null,a||r._store.prepareChannelSwitch(),r._store.currentView.value="conversation",r._store.isLoading.value=!0,r._ably.detachConversation();var c=!1;try{var u=yield Ch(r._instance,_h,{method:"POST",body:JSON.stringify(n({distinct_id:r._distinctId,page_url:null===(t=null==jc?void 0:jc.location)||void 0===t?void 0:t.href,page_title:"undefined"!=typeof document?document.title:""},o&&{skip_greeting:!0}))});if(!u)return void cu().error(ob,"createChannel: server returned no data, channel was not created");r._store.channel.value=u.channel;var d=u.messages||[];if(l.length>0){var h=new Set(d.map(e=>e.id)),p=l.filter(e=>!h.has(e.id)).map(e=>e.channel_id?e:n({},e,{channel_id:u.channel.id}));r._store.messages.value=[...d,...p]}else r._store.messages.value=d;r._store.agentLastReadAt.value=u.channel.agent_last_read_at||null,r._store.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};r._store.prependChannelSummary(f),null===(s=(i=r._config).onConversationStart)||void 0===s||s.call(i,{channelId:u.channel.id,aiMode:u.channel.ai_mode}),r._ably.attachConversation(u.channel.id),r._bindOutboxToChannel(u.channel.id),r._rememberLastCreatedChannel(u.channel.id),c=!0}catch(e){cu().error(ob,"failed to create channel:",e)}finally{if(r._store.pendingRealtimeChannelId.value=null,r._store.isLoading.value=!1,!c&&null===r._store.channel.value)if(l.length>0){var v=new Set(r._outbox.list().map(e=>e.messageId)),g=l.filter(e=>v.has(e.id));g.length>0?(r._store.messages.value=g.map(e=>e.delivery_status?e:n({},e,{delivery_status:"failed"})),r._store.currentView.value="conversation"):(r._store.messages.value=[],r._store.currentView.value="list")}else r._store.currentView.value="list"}})()}goToChannelList(){var e,t,n,r=this._store.channel.value;if(r){var i=this._store.messages.value[this._store.messages.value.length-1];this._store.patchChannelSummary(r.id,{last_message_at:null!==(e=null==i?void 0:i.created_at)&&void 0!==e?e:void 0,last_message_preview:i?(n=i.content,n.replace(/\n?<!--vtilt:widget:[\s\S]*?-->/g,"").replace(/<[^>]*>/g,"").trim().substring(0,100)):void 0,last_message_sender:null!==(t=null==i?void 0:i.sender_type)&&void 0!==t?t:void 0,unread_count:0}),this._store.cacheMessages(r.id,this._store.messages.value)}this._store.clearActiveChannel(),this._store.currentView.value="list",this._ably.detachConversation().then(()=>{this._ably.isLive&&!this._store.pendingRealtimeChannelId.value&&this._ably.refreshToken()})}_cancelActiveStream(){this._streamAbort&&(this._streamAbort.abort(),this._streamAbort=null),this._streamingMessageId&&(Bv(this._store,this._streamingMessageId),this._streamingMessageId=null),this._stripTrailingAiAfterLastUser(),this._clearOptimisticAiTyping()}_stripTrailingAiAfterLastUser(){for(var e=this._store.messages.value,t=-1,n=e.length-1;n>=0;n--)if("user"===e[n].sender_type){t=n;break}if(-1!==t){var r=e.filter((e,n)=>n<=t||"ai"!==e.sender_type);r.length!==e.length&&this._store.setMessages(r)}}_showOptimisticAiTyping(){this._optimisticAiTyping=!0,this._store.isTyping.value=!0,this._store.typingSenderType.value="ai",this._store.typingSender.value="AI Assistant"}_clearOptimisticAiTyping(){this._optimisticAiTyping&&(this._optimisticAiTyping=!1,this._store.isTyping.value=!1,this._store.typingSender.value=null,this._store.typingSenderType.value=null)}sendMessage(e,r){var i=this;return t(function*(){var t,s=Eh(e,r);if(s){i._store.identityChangeInFlight.value&&(yield i._waitForIdentityChange());var{content:o,content_type:a,metadata:l}=s,c=!1!==(null==r?void 0:r.open),u="conversation"===i._store.currentView.value&&null!==i._store.channel.value,d=null!==(t=null==r?void 0:r.channel)&&void 0!==t?t:u?void 0:"new",h=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();var e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;var t=e=>e.toString(16).padStart(2,"0");return t(e[0])+t(e[1])+t(e[2])+t(e[3])+"-"+t(e[4])+t(e[5])+"-"+t(e[6])+t(e[7])+"-"+t(e[8])+t(e[9])+"-"+t(e[10])+t(e[11])+t(e[12])+t(e[13])+t(e[14])+t(e[15])}(),p=(new Date).toISOString(),f="new"===d;if(i._enqueueOutbox(n({messageId:h,channelId:"",distinctId:i._distinctId,body:o,content_type:a,metadata:l,created_at:p,state:"pending",attempts:0,nextRetryAt:0},f?{newChannel:{skipGreeting:!0}}:{})),i._markOutboxSending(h),f){i._store.currentView.value="conversation",i._store.channel.value=null;var v={id:h,channel_id:"",sender_type:"user",sender_id:i._distinctId||null,sender_name:null,sender_avatar_url:null,content:o,content_type:a,metadata:l,created_at:p,delivery_status:"pending"};i._store.setMessages([v]),i._store.isLoading.value=!0,c&&i.open(),yield i.createChannel({skipGreeting:!0,preserveMessages:!0})}else c&&i.open(),d&&(yield i.selectChannel(d));if(!i._store.channel.value)throw cu().error(ob,"cannot send message: no active channel (channel creation or selection failed)"),i._outbox.patch(h,{state:"failed"}),Qy(i._store,h,"failed"),new Error("No active channel");if("conversation"!==i._store.currentView.value)throw cu().error(ob,"cannot send message: not in conversation view"),i._outbox.patch(h,{state:"failed"}),Qy(i._store,h,"failed"),new Error("Not in conversation view");var g,m=i._store.channel.value.id;if(i._outbox.patch(h,{channelId:m,newChannel:void 0}),f){var _=i._store.messages.value.find(e=>e.id===h);if(!_)throw cu().error(ob,"sendMessage: optimistic temp message was lost during createChannel"),i._outbox.patch(h,{state:"failed"}),new Error("Optimistic message lost");g=_}else g={id:h,channel_id:m,sender_type:"user",sender_id:i._distinctId||null,sender_name:null,sender_avatar_url:null,content:o,content_type:a,metadata:l,created_at:p,delivery_status:"pending"},i._store.setMessages([...i._store.messages.value,g]);try{yield i._postUserMessage({messageId:h,channelId:m,body:o,content_type:a,metadata:l,tempMessage:g})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw i._failOutboxMessage(h),e;throw i._clearOptimisticAiTyping(),cu().error(ob,"failed to send message:",e),i._failOutboxMessage(h),i._scheduleDrainOutbox(),e}}else cu().warn(ob,"sendMessage: message is empty")})()}retryFailedMessage(e){var t,n=this._outbox.get(e);if(n&&"failed"===n.state){this._outbox.patch(e,{state:"pending",nextRetryAt:0,sendingSince:void 0}),Qy(this._store,e,"pending");var r=n.channelId||(null===(t=this._store.channel.value)||void 0===t?void 0:t.id)||"";if(r){var i=this._store.messages.value.find(t=>t.id===e);i?(this._markOutboxSending(e),this._postUserMessage({messageId:e,channelId:r,body:n.body,content_type:n.content_type,metadata:n.metadata,tempMessage:i}).catch(t=>{t instanceof DOMException&&"AbortError"===t.name?this._failOutboxMessage(e):(cu().error(ob,"retry send failed:",t),this._failOutboxMessage(e),this._scheduleDrainOutbox())})):this._scheduleDrainOutbox()}}}markAsRead(){this._autoMarkAsRead()}triggerAIAfterWidgetAction(e){var r=this;return t(function*(){try{r._cancelActiveStream();var t=new AbortController;r._streamAbort=t,r._showOptimisticAiTyping();var i=r._instance.getConfig(),s=pu(i,yh(e)),o=yield fetch(s,{method:"POST",signal:t.signal,headers:n({"Content-Type":"application/json"},fu(i)),body:JSON.stringify({channel_id:e,distinct_id:r._distinctId,widget_action_trigger:!0})});if(!o.ok)return void r._clearOptimisticAiTyping();(o.headers.get("content-type")||"").includes("text/plain")&&(yield Dv({store:r._store,response:o,channelId:e,signal:t.signal,isActive:()=>r._streamAbort===t,onStreamStart:e=>{r._clearOptimisticAiTyping(),r._streamAbort===t&&(r._streamingMessageId=e)},onComplete:()=>{r._streamAbort===t&&(r._streamAbort=null,r._streamingMessageId=null)}}))}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return}})()}onMessage(e){return this._messageCallbacks.push(e),()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}updateConfig(e){var t,r,i,s,o,a,l;this._config=function(e,t){var r,i,s=t.bubble,o=e.bubble;if(s){var a=null===s.offset?void 0:void 0!==s.offset?n({},null===(r=e.bubble)||void 0===r?void 0:r.offset,s.offset):null===(i=e.bubble)||void 0===i?void 0:i.offset;o=n({},e.bubble,s,{offset:a})}return n({},e,t,{theme:t.theme?n({},e.theme,t.theme):e.theme,bubble:o})}(this._config,e),this._store.theme.value={primaryColor:null!==(r=null===(t=this._config.theme)||void 0===t?void 0:t.primaryColor)&&void 0!==r?r:Ff.primaryColor,fontFamily:null!==(s=null===(i=this._config.theme)||void 0===i?void 0:i.fontFamily)&&void 0!==s?s:Ff.fontFamily,borderRadius:null!==(a=null===(o=this._config.theme)||void 0===o?void 0:o.borderRadius)&&void 0!==a?a:Ff.borderRadius},(null===(l=this._config.bubble)||void 0===l?void 0:l.draggable)||this._applyBubbleLayout()}_applyBubbleLayout(){var e,t,n,r,i=null===(e=this._ui)||void 0===e?void 0:e.host;if(i){var s=null!==(t=this._config.position)&&void 0!==t?t:"bottom-right";!function(e,t){e.style.setProperty("--vt-bubble-offset-bottom",t.bottom+"px"),e.style.setProperty("--vt-bubble-offset-right",t.right+"px"),e.style.setProperty("--vt-bubble-offset-left",t.left+"px")}(i,zf(null===(n=this._config.bubble)||void 0===n?void 0:n.offset));var o=null===(r=i.shadowRoot)||void 0===r?void 0:r.querySelector(".vt-container");o instanceof HTMLElement&&o.setAttribute("data-position",s)}}registerWidget(e){this._registry.register(e)}notifyUserTyping(){this._lastTypingActivityAt=Date.now(),this._store.realtimeReady.value?(this._isUserTyping?Date.now()-this._lastTypingPublishAt>4e3&&(this._publishTyping(!0),this._lastTypingPublishAt=Date.now()):(this._isUserTyping=!0,this._publishTyping(!0),this._lastTypingPublishAt=Date.now()),this._scheduleTypingIdle()):this._pendingTypingIntent=!0}stopUserTyping(){this._pendingTypingIntent=!1,this._typingIdleTimer&&(clearTimeout(this._typingIdleTimer),this._typingIdleTimer=null),this._isUserTyping&&this._store.realtimeReady.value&&this._publishTyping(!1),this._isUserTyping=!1}_scheduleTypingIdle(){this._typingIdleTimer&&clearTimeout(this._typingIdleTimer),this._typingIdleTimer=setTimeout(()=>{this._typingIdleTimer=null,this._isUserTyping&&this._store.realtimeReady.value&&this._publishTyping(!1),this._isUserTyping=!1},5e3)}destroy(){var e,t,n,r,i;this._unbindOutboxLifecycle(),this._drainTimer&&(clearTimeout(this._drainTimer),this._drainTimer=null),this._ably.disconnectAll(),this._typingIdleTimer&&(clearTimeout(this._typingIdleTimer),this._typingIdleTimer=null),null===(e=this._unsubscribeIdentity)||void 0===e||e.call(this),this._unsubscribeIdentity=null,null===(t=this._unsubscribeReset)||void 0===t||t.call(this),this._unsubscribeReset=null,null===(n=this._disposeConnectionWatcher)||void 0===n||n.call(this),this._disposeConnectionWatcher=null,null===(r=this._disposeRealtimeReadyWatcher)||void 0===r||r.call(this),this._disposeRealtimeReadyWatcher=null,null===(i=this._ui)||void 0===i||i.destroy(),this._ui=null,this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[]}getWidgetContext(e,n){var r,i,s,o=this,a=this._instance.getConfig();return{channelId:null!==(i=null===(r=this._store.channel.value)||void 0===r?void 0:r.id)&&void 0!==i?i:"",distinctId:this._distinctId,primaryColor:this._store.theme.value.primaryColor,apiBase:a.api_host||"",token:a.token||"",messageId:e,buildEndpointUrl:e=>pu(this._instance.getConfig(),e),dispatch:(s=t(function*(t,r){var i=o._registry.get(n);if(i){var s=o.getWidgetContext(e,n);try{var a=yield i.onAction(t,r,s);(null==a?void 0:a.success)&&o.markWidgetSubmittedAndFollowUp(e,n,r)}catch(e){cu().warn(ob,"widget action failed:",e)}}}),function(e,t){return s.apply(this,arguments)})}}markWidgetSubmittedAndFollowUp(e,t,r){var i,s,o,a,l=this._store.messages.value.find(t=>t.id===e);if(l){var c=n({},null!==(i=l.metadata)&&void 0!==i?i:{}),u=(null!==(o=null!==(s=c._widgets)&&void 0!==s?s:c.widgets)&&void 0!==o?o:[]).map(e=>{if(e.type!==t)return e;var i=n({},e,{submitted:!0});return r.email&&(i.submittedEmail=String(r.email).trim()),r.name&&(i.submittedName=String(r.name).trim()),i});c.widgets=u,c._widgets&&(c._widgets=u);var d=this._store.messages.value.map(t=>t.id===e?n({},t,{metadata:c}):t);this._store.setMessages(d);var h=null===(a=this._store.channel.value)||void 0===a?void 0:a.id;"escalate_to_human"!==t&&h&&this.triggerAIAfterWidgetAction(h)}}_outboxStorageKey(){return nb(this._instance.getConfig().token||"unknown",this._distinctId)}_refreshOutboxKey(){this._outbox=new ib(this._outboxStorageKey()),this._outbox.requeueStaleSending()}_markOutboxSending(e){this._outbox.patch(e,{state:"sending",sendingSince:Date.now()})}_failOutboxMessage(e){var t,n,r=(null!==(n=null===(t=this._outbox.get(e))||void 0===t?void 0:t.attempts)&&void 0!==n?n:0)+1;this._outbox.patch(e,{state:"failed",attempts:r,nextRetryAt:sb(r),sendingSince:void 0}),Qy(this._store,e,"failed")}_bindOutboxToChannel(e){for(var t of this._outbox.list())t.newChannel&&!t.channelId&&this._outbox.patch(t.messageId,{channelId:e,newChannel:void 0})}_rememberLastCreatedChannel(e){!function(e,t){if("undefined"!=typeof sessionStorage)try{sessionStorage.setItem(rb(e),JSON.stringify({channelId:t,at:Date.now()}))}catch(e){}}(this._outboxStorageKey(),e)}_migrateOutboxFromDistinctId(e){var t=this._distinctId;if(e&&e!==t){var r=this._instance.getConfig().token||"unknown",i=new ib(nb(r,e)),s=i.list();for(var o of s)this._outbox.upsert(n({},o,{distinctId:t})),i.remove(o.messageId)}}_bindOutboxLifecycle(){"undefined"!=typeof window&&(window.addEventListener("online",this._onOutboxOnline),document.addEventListener("visibilitychange",this._onOutboxVisible))}_unbindOutboxLifecycle(){"undefined"!=typeof window&&(window.removeEventListener("online",this._onOutboxOnline),document.removeEventListener("visibilitychange",this._onOutboxVisible))}_enqueueOutbox(e){this._outbox.upsert(e)}_markMessageDelivered(e,t){var n,r;this._outbox.remove(e),Qy(this._store,e,void 0),null===(r=(n=this._config).onMessageDelivered)||void 0===r||r.call(n,{channelId:t,messageId:e})}_scheduleDrainOutbox(){this._drainTimer&&clearTimeout(this._drainTimer),this._drainTimer=setTimeout(()=>{this._drainTimer=null,this._drainOutbox()},0)}_drainOutbox(){var e=this;return t(function*(){if(!e._drainInFlight){e._drainInFlight=!0,e._outbox.requeueStaleSending();try{var t=Date.now(),n=function*(t){var n=e._store.messages.value.some(e=>e.id===t.messageId&&"sending"===e.delivery_status);if(n)return 1;try{yield e._deliverOutboxEntry(t)}catch(n){cu().warn(ob,"outbox drain failed:",n);var r=t.attempts+1;e._outbox.patch(t.messageId,{state:"failed",attempts:r,nextRetryAt:sb(r)}),Qy(e._store,t.messageId,"failed")}};for(var r of e._outbox.dueEntries(t))yield*n(r)}finally{e._drainInFlight=!1;var i=e._outbox.dueEntries(Date.now());if(i.length>0){var s=Math.max(0,i[0].nextRetryAt-Date.now());e._drainTimer=setTimeout(()=>{e._drainTimer=null,e._drainOutbox()},s)}}}})()}_deliverOutboxEntry(e){var n=this;return t(function*(){var t=e.channelId||void 0;if(!t&&e.newChannel){var r=function(e,t){if(void 0===t&&(t=Date.now()),"undefined"==typeof sessionStorage)return null;try{var n=sessionStorage.getItem(rb(e));if(!n)return null;var r=JSON.parse(n);return!(null==r?void 0:r.channelId)||"number"!=typeof r.at||t-r.at>12e4?null:r}catch(e){return null}}(n._outboxStorageKey());r&&(t=r.channelId,n._outbox.patch(e.messageId,{channelId:t,newChannel:void 0}))}if(!t&&e.newChannel){var i=yield n._createChannelIdForOutbox(e.newChannel.skipGreeting);if(!(t=null!=i?i:void 0))throw new Error("Failed to create channel for outbox entry");n._outbox.patch(e.messageId,{channelId:t,newChannel:void 0}),n._rememberLastCreatedChannel(t)}if(!t)throw new Error("Outbox entry missing channelId");var s=n._store.messages.value.find(t=>t.id===e.messageId);if(s)return n._markOutboxSending(e.messageId),void(yield n._postUserMessage({messageId:e.messageId,channelId:t,body:e.body,content_type:e.content_type,metadata:e.metadata,tempMessage:s}));yield n._postUserMessageSilent({messageId:e.messageId,channelId:t,body:e.body,content_type:e.content_type,metadata:e.metadata}),n._markMessageDelivered(e.messageId,t)})()}_createChannelIdForOutbox(e){var r=this;return t(function*(){var t,i,s,o=yield Ch(r._instance,_h,{method:"POST",body:JSON.stringify(n({distinct_id:r._distinctId,page_url:null===(t=null==jc?void 0:jc.location)||void 0===t?void 0:t.href,page_title:"undefined"!=typeof document?document.title:""},e&&{skip_greeting:!0}))}),a=null!==(s=null===(i=null==o?void 0:o.channel)||void 0===i?void 0:i.id)&&void 0!==s?s:null;return a&&(r._bindOutboxToChannel(a),r._rememberLastCreatedChannel(a)),a})()}_postUserMessageSilent(e){var r=this;return t(function*(){var t,i=r._instance.getConfig(),s=pu(i,yh(e.channelId)),o=yield fetch(s,{method:"POST",keepalive:!0,headers:n({"Content-Type":"application/json"},fu(i)),body:JSON.stringify({id:e.messageId,channel_id:e.channelId,distinct_id:r._distinctId,content:e.body,content_type:e.content_type,metadata:e.metadata})});if(!o.ok)throw new Error("API error: "+o.status);if(!(yield eb(o,e.messageId)))throw new Error("User message not acknowledged");(o.headers.get("content-type")||"").includes("text/plain")&&(yield null===(t=o.body)||void 0===t?void 0:t.cancel().catch(()=>{}))})()}_postUserMessage(e){var r=this;return t(function*(){var t,i,s,o,a,{messageId:l,channelId:c,body:u,content_type:d,metadata:h,tempMessage:p}=e;Qy(r._store,l,"sending"),r._cancelActiveStream();var f=new AbortController;r._streamAbort=f,!1!==(null===(t=r._store.channel.value)||void 0===t?void 0:t.ai_mode)&&r._showOptimisticAiTyping();var v=r._instance.getConfig(),g=pu(v,yh(c)),m=yield fetch(g,{method:"POST",keepalive:!0,signal:f.signal,headers:n({"Content-Type":"application/json"},fu(v)),body:JSON.stringify({id:l,channel_id:c,distinct_id:r._distinctId,content:u,content_type:d,metadata:h})});if(!m.ok)throw new Error("API error: "+m.status);if(!(yield eb(m,l)))throw new Error("User message not acknowledged");if(r._markMessageDelivered(l,c),(m.headers.get("content-type")||"").includes("text/plain"))yield Dv({store:r._store,response:m,channelId:c,signal:f.signal,isActive:()=>r._streamAbort===f,onStreamStart:e=>{r._clearOptimisticAiTyping(),r._streamAbort===f&&(r._streamingMessageId=e)},onComplete:()=>{var e,t,n,i;r._streamAbort===f&&(r._streamAbort=null,r._streamingMessageId=null),null===(t=(e=r._config).onMessageSent)||void 0===t||t.call(e,{channelId:c,messageId:p.id}),r._trackChatMessage(p,c,null===(i=null===(n=r._store.channel.value)||void 0===n?void 0:n.ai_mode)||void 0===i||i)}});else{r._clearOptimisticAiTyping(),r._streamAbort===f&&(r._streamAbort=null);var _=yield m.json();if(null==_?void 0:_.message){var y=r._store.messages.value.findIndex(e=>e.id===_.message.id);if(-1===y&&(y=r._store.messages.value.findIndex(e=>e.id===l)),-1!==y){var b=[...r._store.messages.value];b[y]=_.message,r._store.setMessages(b)}null===(s=(i=r._config).onMessageSent)||void 0===s||s.call(i,{channelId:c,messageId:_.message.id}),r._trackChatMessage(_.message,c,null!==(a=null===(o=r._store.channel.value)||void 0===o?void 0:o.ai_mode)&&void 0!==a&&a)}}})()}get _distinctId(){return this._instance.getDistinctId()||""}_stubChannelFromSummary(e){return{id:e.id,project_id:"",person_id:"",distinct_id:this._distinctId,status:e.status,ai_mode:e.ai_mode,unread_count:e.unread_count,last_message_at:e.last_message_at,last_message_preview:e.last_message_preview,last_message_sender:e.last_message_sender,user_last_read_at:e.user_last_read_at,agent_last_read_at:null,created_at:e.created_at}}_handleIdentityChange(){var e=this;return t(function*(){if(!e._identityChangeInFlight){var t=e._distinctId;if(t&&t!==e._store.lastConnectedDistinctId.value){e._identityChangeInFlight=!0,e._store.identityChangeInFlight.value=!0,e._store.clearActiveChannel(),e._store.currentView.value="list",e._migrateOutboxFromDistinctId(e._outboxDistinctId),e._refreshOutboxKey(),e._outboxDistinctId=t;try{yield e._ably.disconnectAll(),e._store.channels.value=[],e._store.clearMessagesCache(),yield e.getChannels(),e._store.isOpen.value&&(yield e._ably.ensureConnected()),e._scheduleDrainOutbox()}catch(e){cu().error(ob,"failed to recreate Ably client after identity change:",e)}finally{e._identityChangeInFlight=!1,e._store.identityChangeInFlight.value=!1}}}})()}_waitForIdentityChange(){return new Promise(e=>{if(this._store.identityChangeInFlight.value)var t=this._store.identityChangeInFlight.subscribe(n=>{n||(t(),e())});else e()})}_trackChatMessage(e,t,n){var r,i=this._instance.getRemoteConfig(),s=null==i?void 0:i.chatTracking;if("user"===e.sender_type){if(!1===(null==s?void 0:s.trackUserMessages))return}else if(("ai"===e.sender_type||"agent"===e.sender_type)&&!1===(null==s?void 0:s.trackAgentMessages))return;this._instance.capture(Ah,{$channel_type:"chat",$conversation_id:t,$message_id:e.id,$direction:"user"===e.sender_type?"inbound":"outbound",$sender_type:e.sender_type,$content_preview:(null!==(r=e.content)&&void 0!==r?r:"").slice(0,100),$ai_mode:n})}_autoMarkAsRead(){var e,t=this._store.channel.value;if(t&&!this._isMarkingRead){var n=this._store.messages.value,r=n[n.length-1];if(r){var i=this._store.initialUserReadAt.value,s=n.some(e=>{return!("agent"!==e.sender_type&&"ai"!==e.sender_type||(t=e.created_at,i&&new Date(t)<=new Date(i)));var t}),o=this._store.channels.value.find(e=>e.id===t.id),a=(null!==(e=null==o?void 0:o.unread_count)&&void 0!==e?e:0)>0;(s||a)&&(this._isMarkingRead=!0,Ch(this._instance,bh(t.id),{method:"POST",body:JSON.stringify({channel_id:t.id,distinct_id:this._distinctId,read_at:r.created_at})}).then(e=>{e&&(this._store.initialUserReadAt.value=r.created_at,this._store.patchChannelSummary(t.id,{unread_count:0})),this._isMarkingRead=!1}).catch(()=>{this._isMarkingRead=!1}))}}}_publishTyping(e){this._ably.publishTyping({sender_type:"user",sender_name:null,is_typing:e,sender_id:this._distinctId})}_watchConnectionState(){return this._store.isConnected.subscribe(e=>{this._lastConnectedNotified!==e&&(this._lastConnectedNotified=e,this._connectionCallbacks.forEach(t=>t(e)))})}}Gc.__VTiltExtensions__=Gc.__VTiltExtensions__||{},Gc.__VTiltExtensions__.initChat=function(e,t){return new ab(e,t)};var lb="1.13.1",cb="__vt_session",ub="__vt_window_id",db="__vt_primary_window",hb="__vt_user_state",pb="__vt_device_id",fb="__vt_anonymous_id",vb="__vt_remote_config",gb="__vt_distinct_id",mb="__vt_user_properties",_b="localStorage",yb="localStorage+cookie",bb="sessionStorage",wb="memory",Cb="$initial_person_info",Sb="$pageview",kb="$pageleave",xb="$identify",Ib="$alias",Tb="$set",Eb="$performance_event",Ab="$autocapture",Ob="$scroll_depth",Mb="$snapshot",Rb="$snapshot_items",Pb="$$client_ingestion_warning",Lb="$current_url",Nb="$pathname",Db="$prev_pageview_duration",Ub="$prev_pageview_pathname",Bb="$prev_pageview_url",Fb="$scroll_depth_pct",jb="$scroll_depth_max_pct",Wb="$prev_pageview_scroll_depth_pct";function Hb(e,t){var r,i,s=t.bubble,o=null==e?void 0:e.bubble;if(s){var a=null===s.offset?void 0:void 0!==s.offset?n({},null===(r=null==e?void 0:e.bubble)||void 0===r?void 0:r.offset,s.offset):null===(i=null==e?void 0:e.bubble)||void 0===i?void 0:i.offset;o=n({},null==e?void 0:e.bubble,s,{offset:a})}return n({},e,t,{bubble:o})}class zb{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!(null==zc?void 0:zc.currentScript))return n({token:e.token||""},e);var t=zc.currentScript,r=n({token:""},e);r.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,r.script_host=t.getAttribute("data-script-host")||e.script_host,r.token=t.getAttribute("data-token")||e.token||"",r.domain=t.getAttribute("data-domain")||e.domain,r.storage=t.getAttribute("data-storage")||e.storage,r.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var i="true"===t.getAttribute("data-capture-performance");for(var s of(r.capture_performance=!!i||e.capture_performance,r.globalAttributes=n({},e.globalAttributes),Array.from(t.attributes)))s.name.startsWith("data-vt-")&&(r.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return r}getConfig(){return n({},this.config)}updateConfig(e){var t=function(e,t){return void 0===t.chat?t:n({},t,{chat:Hb(e.chat,t.chat)})}(this.config,e);this.config=n({},this.config,t)}}var Vb=[fb,pb,gb,hb],qb=31536e3,$b=["herokuapp.com","vercel.app","netlify.app"];function Gb(e){var t;if(!e||"undefined"==typeof document)return"";var n=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!n)return"";var r=n.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return r?"."+r[0]:""}class Jb{constructor(e){var t,n,r;this.memoryStorage=new Map,this._localStorageSupported=null,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var n=t.split(".").slice(-2).join(".");return!$b.includes(n)}(),this.sameSite=null!==(n=e.sameSite)&&void 0!==n?n:"Lax",this.secure=null!==(r=e.secure)&&void 0!==r?r:"undefined"!=typeof location&&"https:"===location.protocol}isLocalStorageSupported(){if(null!==this._localStorageSupported)return this._localStorageSupported;if(void 0===jc||!jc.localStorage)return this._localStorageSupported=!1,!1;try{var e="__vt_ls_test__";jc.localStorage.setItem(e,"1");var t="1"===jc.localStorage.getItem(e);return jc.localStorage.removeItem(e),this._localStorageSupported=t,t||cu().warn("storage","localStorage unavailable, using cookies"),t}catch(e){return this._localStorageSupported=!1,cu().warn("storage","localStorage unavailable, using cookies"),!1}}isCriticalProperty(e){return Vb.includes(e)}get(e){var t;try{switch(this.method){case wb:return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;case yb:return this.getLocalStoragePlusCookie(e);case _b:return this.getLocalStorage(e);case bb:return this.readFromSessionStorage(e);default:return this.getCookie(e)}}catch(t){return cu().warn("storage",'get error for "'+e+'":',t),null}}set(e,t,n){try{switch(this.method){case wb:this.memoryStorage.set(e,t);break;case yb:this.setLocalStoragePlusCookie(e,t,n);break;case _b:this.setLocalStorage(e,t);break;case bb:this.writeToSessionStorage(e,t);break;default:this.setCookie(e,t,null!=n?n:qb)}}catch(t){cu().warn("storage",'set error for "'+e+'":',t)}}remove(e){try{switch(this.method){case wb:this.memoryStorage.delete(e);break;case yb:this.removeLocalStoragePlusCookie(e);break;case _b:this.removeLocalStorage(e);break;case bb:this.removeFromSessionStorage(e);break;default:this.removeCookie(e)}}catch(t){cu().warn("storage",'remove error for "'+e+'":',t)}}getLocalStoragePlusCookie(e){if(this.isCriticalProperty(e)){var t=this.getCookie(e),n=this.getLocalStorage(e);if(null!==t){if(n!==t&&this.isLocalStorageSupported())try{null==jc||jc.localStorage.setItem(e,t)}catch(e){}return t}return null!==n?n:this.readFromSessionStorage(e)}return this.getLocalStorage(e)}setLocalStoragePlusCookie(e,t,n){this.setLocalStorage(e,t),this.isCriticalProperty(e)&&(this.setCookie(e,t,null!=n?n:qb),this.writeToSessionStorage(e,t))}removeLocalStoragePlusCookie(e){this.removeLocalStorage(e),this.isCriticalProperty(e)&&(this.removeCookie(e),this.removeFromSessionStorage(e))}getLocalStorage(e){var t;if(!this.isLocalStorageSupported())return null;try{return null!==(t=null==jc?void 0:jc.localStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}setLocalStorage(e,t){if(this.isLocalStorageSupported())try{null==jc||jc.localStorage.setItem(e,t)}catch(e){cu().warn("storage","localStorage write error:",e)}}removeLocalStorage(e){if(this.isLocalStorageSupported())try{null==jc||jc.localStorage.removeItem(e)}catch(e){}}readFromSessionStorage(e){var t;try{return null!==(t=null==jc?void 0:jc.sessionStorage.getItem(e))&&void 0!==t?t:null}catch(e){return null}}writeToSessionStorage(e,t){try{null==jc||jc.sessionStorage.setItem(e,t)}catch(e){cu().warn("storage","sessionStorage write error:",e)}}removeFromSessionStorage(e){try{null==jc||jc.sessionStorage.removeItem(e)}catch(e){}}getCookie(e){if("undefined"==typeof document)return null;var t=e+"=";for(var n of document.cookie.split(";")){var r=n.trim();if(r.startsWith(t))try{return decodeURIComponent(r.slice(t.length))}catch(e){return r.slice(t.length)}}return null}setCookie(e,t,n){if("undefined"!=typeof document){var r=Gb(this.cross_subdomain),i=e+"="+encodeURIComponent(t)+"; Max-Age="+n+"; path=/; SameSite="+this.sameSite;this.secure&&(i+="; Secure"),r&&(i+="; domain="+r),document.cookie=i}}removeCookie(e){if("undefined"!=typeof document){var t=Gb(this.cross_subdomain);document.cookie=e+"=; Max-Age=0; path=/"+(t?"; domain="+t:""),document.cookie=e+"=; Max-Age=0; path=/"}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var n=JSON.parse(t);return n.expiry&&Date.now()>n.expiry?(this.remove(e),null):n.value}catch(e){return null}}setWithExpiry(e,t,r){var i=n({value:t},r?{expiry:Date.now()+r}:{});this.set(e,JSON.stringify(i))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,n){this.set(e,JSON.stringify(t),n)}canUseSessionStorage(){if(void 0===jc||!(null==jc?void 0:jc.sessionStorage))return!1;try{var e="__vt_ss_test__";return jc.sessionStorage.setItem(e,"1"),jc.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==jc?void 0:jc.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class Kb{constructor(e,t){void 0===e&&(e="cookie"),this._isNewSession=!1,this.storage=new Jb({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,cu().debug("session","ctor")}hydrateFromStorage(){cu().debug("session","hydrate"),this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=Ou(16),this._storeSessionId(e),this._isNewSession=!0),e}setSessionId(){var e=this._getSessionIdRaw(),t=e||Ou(16);return e||(this._isNewSession=!0),this._storeSessionId(t),t}resetSessionId(){this._clearSessionId(),this._isNewSession=!0,this.setSessionId(),this._setWindowId(Ou(16))}consumeSessionStart(){return!!this._isNewSession&&(this._isNewSession=!1,!0)}_getSessionIdRaw(){return this.storage.get(cb)}_storeSessionId(e){this.storage.set(cb,e,1800)}_clearSessionId(){this.storage.remove(cb)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(ub);if(t)return this._windowId=t,t}var n=Ou(16);return this._setWindowId(n),n}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(ub,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(db),n=e.getItem(ub);n&&!t?this._windowId=n:(n&&e.removeItem(ub),this._setWindowId(Ou(16))),e.setItem(db,"true"),this._listenToUnload()}else this._windowId=Ou(16)}_listenToUnload(){var e=this.storage.getSessionStorage();jc&&e&&Pu(jc,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(db)},{capture:!1})}updateStorageMethod(e,t){this.storage=new Jb({method:e,cross_subdomain:t,sameSite:"Lax"})}}function Yb(e){if(!zc)return null;var t=zc.createElement("a");return t.href=e,t}function Zb(e){try{return decodeURIComponent(e).replace(/\+/g," ")}catch(t){return e.replace(/\+/g," ")}}function Xb(e){for(var t={},n=function(e){return((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"")}(e).split("&"),r=0;r<n.length;r++){var i=n[r];if(i){var s=i.indexOf("="),o=-1===s?i:i.slice(0,s);if(o){var a=Zb(o),l=-1===s?"":i.slice(s+1);t[a]=Zb(l)}}}return t}function Qb(e,t){var n;return null!==(n=Xb(e)[t])&&void 0!==n?n:""}function ew(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("="),p=h[0],f=h.slice(1).join("=");-1!==t.indexOf(p)?u.push(p+"="+n):p&&u.push(p+(f?"="+f:""))}var v=u.join("&");return l+(v?"?"+v:"")+(s?"#"+s:"")}var tw="_fbp",nw="_fbc",rw=15552e3,iw=7776e3;function sw(){void 0!==zc&&(function(){if(ow(tw))return;var e=Date.now(),t=Math.floor(1e9+9e9*Math.random()),n="fb.1."+e+"."+t;aw(tw,n,rw)}(),function(){if(!(null==Vc?void 0:Vc.search))return;try{var e=new URL(Vc.href).searchParams.get("fbclid");if(!(null==e?void 0:e.trim()))return;var t="fb.1."+Date.now()+"."+e.trim();aw(nw,t,iw)}catch(e){}}())}function ow(e){if(void 0===zc||!(null==zc?void 0:zc.cookie))return null;var t=e+"=";for(var n of zc.cookie.split(";")){var r=n.trim();if(r.startsWith(t))try{return decodeURIComponent(r.slice(t.length))}catch(e){return r.slice(t.length)}}return null}function aw(e,t,n){if(void 0!==zc){var r=void 0!==Vc&&"https:"===Vc.protocol?"; Secure":"";zc.cookie=e+"="+encodeURIComponent(t)+"; Max-Age="+n+"; path=/; SameSite=Lax"+r}}var lw="Mobile",cw="iOS",uw="Android",dw="Tablet",hw=uw+" "+dw,pw="iPad",fw="Apple",vw=fw+" Watch",gw="Safari",mw="BlackBerry",_w="Samsung",yw=_w+"Browser",bw=_w+" Internet",ww="Chrome",Cw=ww+" OS",Sw=ww+" "+cw,kw="Internet Explorer",xw=kw+" "+lw,Iw="Opera",Tw=Iw+" Mini",Ew="Edge",Aw="Microsoft "+Ew,Ow="Firefox",Mw=Ow+" "+cw,Rw="Nintendo",Pw="PlayStation",Lw="Xbox",Nw=uw+" "+lw,Dw=lw+" "+gw,Uw="Windows",Bw=Uw+" Phone",Fw="Nokia",jw="Ouya",Ww="Generic",Hw=Ww+" "+lw.toLowerCase(),zw=Ww+" "+dw.toLowerCase(),Vw="Konqueror",qw="(\\d+(\\.\\d+)?)",$w=new RegExp("Version/"+qw),Gw=new RegExp(Lw,"i"),Jw=new RegExp(Pw+" \\w+","i"),Kw=new RegExp(Rw+" \\w+","i"),Yw=new RegExp(mw+"|PlayBook|BB10","i"),Zw={"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 Xw(e,t){return e.toLowerCase().includes(t.toLowerCase())}var Qw=(e,t)=>t&&Xw(t,fw)||function(e){return Xw(e,gw)&&!Xw(e,ww)&&!Xw(e,uw)}(e),eC=function(e,t){return t=t||"",Xw(e," OPR/")&&Xw(e,"Mini")?Tw:Xw(e," OPR/")?Iw:Yw.test(e)?mw:Xw(e,"IE"+lw)||Xw(e,"WPDesktop")?xw:Xw(e,yw)?bw:Xw(e,Ew)||Xw(e,"Edg/")?Aw:Xw(e,"FBIOS")?"Facebook "+lw:Xw(e,"UCWEB")||Xw(e,"UCBrowser")?"UC Browser":Xw(e,"CriOS")?Sw:Xw(e,"CrMo")||Xw(e,ww)?ww:Xw(e,uw)&&Xw(e,gw)?Nw:Xw(e,"FxiOS")?Mw:Xw(e.toLowerCase(),Vw.toLowerCase())?Vw:Qw(e,t)?Xw(e,lw)?Dw:gw:Xw(e,Ow)?Ow:Xw(e,"MSIE")||Xw(e,"Trident/")?kw:Xw(e,"Gecko")?Ow:""},tC={[xw]:[new RegExp("rv:"+qw)],[Aw]:[new RegExp(Ew+"?\\/"+qw)],[ww]:[new RegExp("("+ww+"|CrMo)\\/"+qw)],[Sw]:[new RegExp("CriOS\\/"+qw)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+qw)],[gw]:[$w],[Dw]:[$w],[Iw]:[new RegExp("(Opera|OPR)\\/"+qw)],[Ow]:[new RegExp(Ow+"\\/"+qw)],[Mw]:[new RegExp("FxiOS\\/"+qw)],[Vw]:[new RegExp("Konqueror[:/]?"+qw,"i")],[mw]:[new RegExp(mw+" "+qw),$w],[Nw]:[new RegExp("android\\s"+qw,"i")],[bw]:[new RegExp(yw+"\\/"+qw)],[kw]:[new RegExp("(rv:|MSIE )"+qw)],Mozilla:[new RegExp("rv:"+qw)]},nC=function(e,t){var n=eC(e,t),r=tC[n];if(void 0===r)return null;for(var i=0;i<r.length;i++){var s=r[i],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},rC=[[new RegExp(Lw+"; "+Lw+" (.*?)[);]","i"),e=>[Lw,e&&e[1]||""]],[new RegExp(Rw,"i"),[Rw,""]],[new RegExp(Pw,"i"),[Pw,""]],[Yw,[mw,""]],[new RegExp(Uw,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Bw,""];if(new RegExp(lw).test(t)&&!/IEMobile\b/.test(t))return[Uw+" "+lw,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=n[1],i=Zw[r]||"";return/arm/i.test(t)&&(i="RT"),[Uw,i]}return[Uw,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[cw,t.join(".")]}return[cw,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+uw+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+uw+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[uw,t.join(".")]}return[uw,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Cw,""]],[/Linux|debian/i,["Linux",""]]],iC=function(e){return Kw.test(e)?Rw:Jw.test(e)?Pw:Gw.test(e)?Lw:new RegExp(jw,"i").test(e)?jw:new RegExp("("+Bw+"|WPDesktop)","i").test(e)?Bw:/iPad/.test(e)?pw:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?vw:Yw.test(e)?mw:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Fw,"i").test(e)?Fw:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(lw).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?uw:hw:uw:new RegExp("(pda|"+lw+")","i").test(e)?Hw:new RegExp(dw,"i").test(e)&&!new RegExp(dw+" pc","i").test(e)?zw:""},sC="https?://(.*)",oC=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],aC=Nu(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],oC),lC="<masked>";function cC(e,t){var n=aC.concat([]),r=Lu({},function(e){var t={};return Ru(Xb(e),function(e,n){"string"==typeof n&&n.startsWith("utm_")&&e&&(t[n]=e)}),t}(e));return Ru(n,function(t){if(t.startsWith("utm_")){if(!(t in r)){var n=Qb(e,t);r[t]=n||null}}else{var i=Qb(e,t);r[t]=i||null}}),r}function uC(e){var t=function(e){return e?0===e.search(sC+"google.([^/?]*)")?"google":0===e.search(sC+"bing.com")?"bing":0===e.search(sC+"yahoo.com")?"yahoo":0===e.search(sC+"duckduckgo.com")?"duckduckgo":null:null}(e),n="yahoo"!==t?"q":"p",r={};if(!function(e){return null===e}(t)){r.$search_engine=t;var i=zc?Qb(zc.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function dC(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function hC(){return(null==zc?void 0:zc.referrer)||"$direct"}function pC(){var e;return(null==zc?void 0:zc.referrer)&&(null===(e=Yb(zc.referrer))||void 0===e?void 0:e.host)||"$direct"}function fC(e){var t=function(e){var t,{r:n,u:r}=e,i={$referrer:n,$referring_domain:null==n?void 0:"$direct"===n?"$direct":null===(t=Yb(n))||void 0===t?void 0:t.host};if(r){i.$current_url=r;var s=Yb(r);i.$host=null==s?void 0:s.host,i.$pathname=null==s?void 0:s.pathname,Lu(i,cC(r))}return n&&Lu(i,uC(n)),i}(e),n={};return Ru(t,function(e,t){var r;n["$initial_"+(r=String(t),r.startsWith("$")?r.substring(1):r)]=e}),n}function vC(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function gC(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function mC(e,t){if(!$c)return{};var n,r,i,s=e?Nu([],oC,t||[]):[],[o,a]=function(e){for(var t=0;t<rC.length;t++){var[n,r]=rC[t],i=n.exec(e);if(i){var s="function"==typeof r?r(i,e):r;if(s)return s}}return["",""]}($c),l=ow(tw)||void 0,c=ow(nw)||void 0;return Lu(Du({$os:o,$os_version:a,$browser:eC($c,navigator.vendor),$device:iC($c),$device_type:(r=$c,i=iC(r),i===pw||i===hw||"Kobo"===i||"Kindle Fire"===i||i===zw?dw:i===Rw||i===Lw||i===Pw||i===jw?"Console":i===vw?"Wearable":i?lw:"Desktop"),$timezone:vC(),$timezone_offset:gC(),$fb_browser_id:l,$fb_click_id:c}),{$current_url:ew(null==Vc?void 0:Vc.href,s,lC),$host:null==Vc?void 0:Vc.host,$pathname:null==Vc?void 0:Vc.pathname,$raw_user_agent:$c.length>1e3?$c.substring(0,997)+"...":$c,$browser_version:nC($c,navigator.vendor),$browser_language:dC(),$browser_language_prefix:(n=dC(),"string"==typeof n?n.split("-")[0]:void 0),$screen_height:null==jc?void 0:jc.screen.height,$screen_width:null==jc?void 0:jc.screen.width,$viewport_height:null==jc?void 0:jc.innerHeight,$viewport_width:null==jc?void 0:jc.innerWidth,$lib:"web",$lib_version:lb,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10)})}class _C{constructor(e,t){void 0===e&&(e="localStorage"),this._isFirstVisit=!1,this.storage=new Jb({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.generateEphemeralIdentity(),cu().debug("user","ctor","ephemeral identity only")}hydrateFromStorage(){cu().debug("user","hydrate start"),this.userIdentity=this.loadUserIdentity();var e=this.userIdentity.anonymous_id,t=this.userIdentity.distinct_id;cu().debug("user","hydrate done","anonymous_id",e?e.slice(0,12)+"...":"n/a","distinct_id",t?t.slice(0,12)+"...":"null")}generateEphemeralIdentity(){return{distinct_id:null,anonymous_id:this.generateAnonymousId(),device_id:this.generateDeviceId(),properties:{},user_state:"anonymous"}}getUserIdentity(){return n({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){var e=this.userIdentity.anonymous_id;return e||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(fb,this.userIdentity.anonymous_id,qb),cu().debug("user","getAnonymousId generated (was missing)",this.userIdentity.anonymous_id.slice(0,12)+"..."),this.userIdentity.anonymous_id)}getUserProperties(){return n({},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._isFirstVisit&&(this._isFirstVisit=!1,!0)}applyUpdate(e){if(void 0!==e.distinct_id&&(this.userIdentity.distinct_id=e.distinct_id),void 0!==e.user_state&&(this.userIdentity.user_state=e.user_state),void 0!==e.device_id&&(this.userIdentity.device_id=e.device_id),e.properties_set&&(this.userIdentity.properties=n({},this.userIdentity.properties,e.properties_set)),e.properties_set_once)for(var t of Object.keys(e.properties_set_once))t in this.userIdentity.properties||(this.userIdentity.properties[t]=e.properties_set_once[t]);this.saveUserIdentity()}reset(e){this.userIdentity={distinct_id:null,anonymous_id:this.generateAnonymousId(),device_id:e?this.generateDeviceId():this.userIdentity.device_id,properties:{$last_vtilt_reset:(new Date).toISOString()},user_state:"anonymous"},this.saveUserIdentity()}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[Cb]){var n=function(e,t){var n=e?Nu([],oC,t||[]):[],r=null==Vc?void 0:Vc.href.substring(0,1e3);return{r:hC().substring(0,1e3),u:r?ew(r,n,lC):void 0}}(e,t);this.register_once({[Cb]:n},void 0)}}get_initial_props(){var e=this.getStoredUserProperties()[Cb];return e?fC(e):{}}update_referrer_info(){var e={$referrer:hC(),$referring_domain:pC()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(fb),t=this.storage.get(pb),n=this.storage.get(gb),r=this.storage.get(hb),i=this.getStoredUserProperties(),s=e||this.generateAnonymousId(),o=t||this.generateDeviceId(),a=n||null,l=r||"anonymous";e?cu().debug("user","hydrate","loaded from storage",e.slice(0,12)+"..."):(this._isFirstVisit=!0,cu().debug("user","hydrate","generated new anonymous_id"));var c=s||this.generateAnonymousId();return e||this.storage.set(fb,c,qb),t||this.storage.set(pb,o,qb),r||this.storage.set(hb,l,qb),{distinct_id:a,anonymous_id:c,device_id:o,properties:i,user_state:l}}saveUserIdentity(){this.storage.set(fb,this.userIdentity.anonymous_id,qb),this.storage.set(pb,this.userIdentity.device_id,qb),this.storage.set(hb,this.userIdentity.user_state,qb),this.userIdentity.distinct_id?this.storage.set(gb,this.userIdentity.distinct_id,qb):this.storage.remove(gb),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(mb)||{}}setStoredUserProperties(e){this.storage.setJSON(mb,e,qb)}register_once(e,t){var n=this.getStoredUserProperties(),r=!1;for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(i in n||(n[i]=e[i],r=!0));if(t)for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(s in n||(n[s]=t[s],r=!0));r&&this.setStoredUserProperties(n)}generateAnonymousId(){return"anon_"+Ou(16)}generateDeviceId(){return"device_"+Ou(16)}updateStorageMethod(e,t){this.storage=new Jb({method:e,cross_subdomain:t,sameSite:"Lax"})}}var yC=["LCP","CLS","FCP","INP"];class bC{constructor(e,t){this._isStarted=!1,this._isLoading=!1,this._loadCallbacks=[],this._apiReady=!1,this._deferredCalls=[],this._instance=e,this._config=t}get isEnabled(){return!1!==this._config.enabled}get isStarted(){return this._isStarted}get isLoaded(){return!!this._loaded}_ensureLoaded(e){var t;if(this._loaded)e(this._loaded);else if(this._loadCallbacks.push(e),!this._isLoading){this._isLoading=!0;var n=null===(t=Gc.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!n)return cu().error("feature",this.name,"loadExternalDependency not available"),this._isLoading=!1,void(this._loadCallbacks=[]);n(this._instance,this.scriptName,e=>{if(this._isLoading=!1,e)return cu().error("feature",this.name,"could not load "+this.scriptName+":",e),void(this._loadCallbacks=[]);this._loaded||(this._loaded=this._createLoaded());var t=this._loaded,n=this._loadCallbacks;for(var r of(this._loadCallbacks=[],n))try{r(t)}catch(e){cu().error("feature",this.name,"load callback error:",e)}})}}startIfEnabled(){this.isEnabled&&!this._isStarted&&(this._isStarted=!0,this._ensureLoaded(e=>this._onLoaded(e)))}_onLoaded(e){}stop(){this._isStarted=!1}updateConfig(e){this._config=n({},this._config,e)}_deferCall(e){this._apiReady?e():this._deferredCalls.push(e)}_markApiReady(){if(!this._apiReady){this._apiReady=!0;var e=this._deferredCalls;for(var t of(this._deferredCalls=[],e))try{t()}catch(e){cu().error("feature",this.name,"deferred call error:",e)}}}_resetDeferral(){this._apiReady=!1,this._deferredCalls=[]}}class wC extends bC{startIfEnabledOrStop(e){if(this.isEnabled){if(this._isStarted&&this._loaded)return;this._isStarted=!0,this._ensureLoaded(e=>this._onLoaded(e))}else this.stop()}}var CC=9e5,SC="web-vitals";class kC extends bC{static extractConfig(e){var t=e.capture_performance;return"boolean"==typeof t?{web_vitals:t}:"object"==typeof t&&null!==t?t:{web_vitals:!1}}constructor(e,t){super(e,null!=t?t:kC.extractConfig(e.getConfig())),this.name="WebVitals",this.scriptName="web-vitals",this._buffer=this._createEmptyBuffer()}get isEnabled(){var e=null==Vc?void 0:Vc.protocol;return("http:"===e||"https:"===e)&&!0===this._config.web_vitals}startIfEnabled(){if(this.isEnabled&&!this._isStarted&&jc){var e=this._getWebVitalsCallbacks();e?(this._isStarted=!0,this._loaded=e,this._startCapturing(e)):(this._isStarted=!0,this._ensureLoaded(e=>this._onLoaded(e)))}}stop(){this._isStarted&&(this._flush(),this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),this._isStarted=!1)}onConfigUpdate(e){var t=kC.extractConfig(e),n=this.isEnabled;this._config=t,n||!this.isEnabled||this._isStarted?n&&!this.isEnabled&&this._isStarted&&this.stop():this.startIfEnabled()}_createLoaded(){var e=this._getWebVitalsCallbacks();if(!e)throw new Error("[vTilt:web-vitals] web-vitals loaded but callbacks not registered");return e}_onLoaded(e){this._startCapturing(e)}get allowedMetrics(){return this._config.web_vitals_allowed_metrics||yC}get flushTimeoutMs(){return this._config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this._config.__web_vitals_max_value;return void 0===e?CC:0===e?0:e<6e4?CC:e}_createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}_getWebVitalsCallbacks(){var e;return null===(e=Gc.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}_startCapturing(e){var t=this.allowedMetrics,n=this._addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(n),t.includes("CLS")&&e.onCLS&&e.onCLS(n,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(n),t.includes("INP")&&e.onINP&&e.onINP(n),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(n)}_getCurrentUrl(){var e;return null===(e=null==jc?void 0:jc.location)||void 0===e?void 0:e.href}_getCurrentPathname(){return null==Vc?void 0:Vc.pathname}_addToBuffer(e){var t,r,i;try{if(!jc||!zc||!Vc)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void cu().warn(SC,"invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void cu().warn(SC,"ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var s=this._getCurrentUrl(),o=this._getCurrentPathname();if(!s)return void cu().warn(SC,"could not determine current URL");this._buffer.url&&this._buffer.url!==s&&this._flush(),this._buffer.url||(this._buffer.url=s,this._buffer.pathname=o),this._buffer.firstMetricTimestamp||(this._buffer.firstMetricTimestamp=Date.now());var a=this._cleanAttribution(e.attribution),l=null!==(i=null===(r=(t=this._instance).getSessionId)||void 0===r?void 0:r.call(t))&&void 0!==i?i:null,c=this._getWindowId(),u=n({},e,{attribution:a,timestamp:Date.now(),$current_url:s,$session_id:l,$window_id:c}),d=this._buffer.metrics.findIndex(t=>t.name===e.name);d>=0?this._buffer.metrics[d]=u:this._buffer.metrics.push(u),this._scheduleFlush(),this._buffer.metrics.length>=this.allowedMetrics.length&&this._flush()}catch(e){cu().error(SC,"error adding metric to buffer:",e)}}_cleanAttribution(e){if(e){var t=n({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}_getWindowId(){var e;try{return(null===(e=this._instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}_scheduleFlush(){this._flushTimer&&clearTimeout(this._flushTimer),this._flushTimer=setTimeout(()=>{this._flush()},this.flushTimeoutMs)}_flush(){if(this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0),0!==this._buffer.metrics.length){try{var e={$pathname:this._buffer.pathname,$current_url:this._buffer.url};for(var t of this._buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this._instance.capture("$web_vitals",e)}catch(e){cu().error(SC,"error flushing metrics:",e)}this._buffer=this._createEmptyBuffer()}}}function xC(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return eu(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch(e){return()=>{}}}class IC{constructor(e,t){var n;this.name="HistoryAutocapture",this._isStarted=!1,this._instance=e,this._config=t||IC.extractConfig(e.getConfig()),this._lastPathname=(null===(n=null==jc?void 0:jc.location)||void 0===n?void 0:n.pathname)||""}static extractConfig(e){return{enabled:!1!==e.capture_pageview}}get isEnabled(){return!1!==this._config.enabled&&!1!==this._instance.getConfig().capture_pageview}get isStarted(){return this._isStarted}startIfEnabled(){this.isEnabled&&!this._isStarted&&this._start()}stop(){this._isStarted&&(this._popstateListener&&(this._popstateListener(),this._popstateListener=void 0),this._isStarted=!1)}onConfigUpdate(e){this._config=IC.extractConfig(e),this.isEnabled&&!this._isStarted?this._start():!this.isEnabled&&this._isStarted&&this.stop()}_start(){jc&&Vc&&(this._lastPathname=Vc.pathname||"",this._patchHistoryMethods(),this._setupPopstateListener(),this._isStarted=!0,cu().info("history-autocapture","started"))}_patchHistoryMethods(){var e,t;if(null==jc?void 0:jc.history){var n=this;(null===(e=jc.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||xC(jc.history,"pushState",e=>function(t,r,i){n._emitPageleaveIfPathWillChange(i),e.call(this,t,r,i),n._capturePageview("pushState")}),(null===(t=jc.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||xC(jc.history,"replaceState",e=>function(t,r,i){n._emitPageleaveIfPathWillChange(i),e.call(this,t,r,i),n._capturePageview("replaceState")})}}_emitPageleaveIfPathWillChange(e){var t;if(Vc){var n=Vc.pathname||"",r=null!==(t=function(e){if(!Vc)return null;if(null==e||""===e)return Vc.pathname||null;try{return new URL(String(e),Vc.href).pathname}catch(e){return null}}(e))&&void 0!==t?t:n;r!==n&&this._instance.tryCapturePageleave("spa_transition")}}_setupPopstateListener(){if(!this._popstateListener&&jc){var e=()=>{this._capturePageview("popstate")};Pu(jc,"popstate",e),this._popstateListener=()=>{null==jc||jc.removeEventListener("popstate",e)}}}_capturePageview(e){this.isEnabled&&this._isStarted&&du(()=>{var t,n=null===(t=null==jc?void 0:jc.location)||void 0===t?void 0:t.pathname;if(n&&Vc&&zc)if(n!==this._lastPathname){cu().debug("history-autocapture",e,n),this._lastPathname=n;var r={navigation_type:e};this._instance.capture(Sb,r)}else this._lastPathname=n})}}var TC=["a","button","form","input","select","textarea","label"],EC="$copy_autocapture",AC=['[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 OC(e){return e.replace(/^\s+|\s+$/g,"")}function MC(e,t){return e.indexOf(t)>-1}function RC(e){return 1===(null==e?void 0:e.nodeType)}function PC(e){return 3===(null==e?void 0:e.nodeType)}function LC(e,t){var n;return(null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase())===t}function NC(e){return 11===(null==e?void 0:e.nodeType)}function DC(e){return e?OC(e).split(/\s+/):[]}function UC(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className&&"string"==typeof e.className.baseVal?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return DC(t)}function BC(e){return Xc(e)?null:OC(e).split(/(\s+)/).filter(e=>ZC(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function FC(e){var t,n="";if(QC(e)&&!eS(e)&&e.childNodes&&e.childNodes.length)for(var r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];PC(i)&&i.textContent&&(n+=null!==(t=BC(i.textContent))&&void 0!==t?t:"")}return OC(n)}function jC(e){var t,n="";if(e&&e.childNodes&&e.childNodes.length)for(var r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(i&&"span"===(null===(t=i.tagName)||void 0===t?void 0:t.toLowerCase()))try{n=(n+" "+FC(i)).trim(),i.childNodes&&i.childNodes.length&&(n=(n+" "+jC(i)).trim())}catch(e){}}return n}function WC(e){var t=FC(e);return ZC(t=(t+" "+jC(e)).trim())?t:""}function HC(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!RC(t));return t}function zC(e){var t=e.parentNode;return!(!t||!RC(t))&&t}function VC(e){var t=null==jc?void 0:jc.location.href;return!!(t&&e&&e.some(e=>t.match(e)))}var qC="(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})",$C=new RegExp("^(?:"+qC+")$"),GC=new RegExp(qC),JC="\\d{3}-?\\d{2}-?\\d{4}",KC=new RegExp("^("+JC+")$"),YC=new RegExp("("+JC+")");function ZC(e,t){if(void 0===t&&(t=!0),Xc(e))return!1;if(Yc(e)){if(e=OC(e),(t?$C:GC).test((e||"").replace(/[- ]/g,"")))return!1;if((t?KC:YC).test(e))return!1}return!0}function XC(e){return!!Yc(e)&&("_ngcontent"===e.substring(0,10)||"_nghost"===e.substring(0,7))}function QC(e){for(var t=e;t&&t.parentNode&&!LC(t,"body");t=t.parentNode){var n=UC(t);if(MC(n,"vt-sensitive")||MC(n,"vt-no-capture"))return!1}if(MC(UC(e),"vt-include"))return!0;var r=e.type||"";if(Yc(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";if(Yc(i)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function eS(e){return!!(LC(e,"input")&&!["button","checkbox","submit","reset","radio"].includes(e.type)||LC(e,"textarea")||"true"===e.getAttribute("contenteditable"))}function tS(e){if(!QC(e))return null;if(LC(e,"input")){var t=e,n=(t.type||"text").toLowerCase();if("password"===n||"hidden"===n)return null;if("checkbox"===n||"radio"===n){var r={$el_value:t.checked?"true":"false"},i=function(e){var t=e.closest("label");if(t){var n=OC(t.textContent||"");if(n&&ZC(n))return BC(n)||null}if(e.id)try{var r=null===document||void 0===document?void 0:document.querySelector('label[for="'+e.id+'"]');if(r){var i=OC(r.textContent||"");if(i&&ZC(i))return BC(i)||null}}catch(e){}return null}(t);return i?r.$selected_text=i:t.value&&ZC(t.value)&&(r.$selected_text=t.value),r}var s=t.value;if(s&&ZC(s)){var o=BC(s);if(o)return{$el_value:o}}return null}if(LC(e,"select")){var a=e,l=a.selectedIndex;if(l>=0&&a.options[l]){var c=a.options[l],u={};c.value&&ZC(c.value)&&(u.$el_value=c.value);var d=c.text;if(d&&ZC(d)){var h=BC(d);h&&(u.$selected_text=h)}if(u.$el_value||u.$selected_text)return u}return null}return LC(e,"textarea"),null}function nS(e,t,n,r,i){if(void 0===n&&(n=void 0),!jc)return{capture:!1,reason:"no_window"};if(!e)return{capture:!1,reason:"no_element"};if(LC(e,"html")||!RC(e))return{capture:!1,reason:"html_element"};if((null==n?void 0:n.url_allowlist)&&!VC(n.url_allowlist))return{capture:!1,reason:"url_allowlist_miss"};if((null==n?void 0:n.url_ignorelist)&&VC(n.url_ignorelist))return{capture:!1,reason:"url_ignorelist_hit"};if(null==n?void 0:n.dom_event_allowlist){var s=n.dom_event_allowlist;if(s&&!s.some(e=>t.type===e))return{capture:!1,reason:"dom_event_not_allowed"}}for(var o=!1,a=[e],l=!0,c=e;c.parentNode&&!LC(c,"body");)if(NC(c.parentNode))a.push(c.parentNode.host),c=c.parentNode.host;else{if(!(l=zC(c)))break;if(r||TC.indexOf(l.tagName.toLowerCase())>-1)o=!0;else{var u=jc.getComputedStyle(l);u&&"pointer"===u.getPropertyValue("cursor")&&(o=!0)}a.push(l),c=l}if(!function(e,t){var n=null==t?void 0:t.element_allowlist;if(Zc(n))return!0;var r,i=function(e){if(n.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var s of e)if(r=i(s))return r.v;return!1}(a,n))return{capture:!1,reason:"element_allowlist_miss"};if(!function(e,t){var n=null==t?void 0:t.css_selector_allowlist;if(Zc(n))return!0;var r,i=function(e){if(n.some(t=>e.matches(t)))return{v:!0}};for(var s of e)if(r=i(s))return r.v;return!1}(a,n))return{capture:!1,reason:"css_selector_allowlist_miss"};if(function(e,t){var n=null==t?void 0:t.css_selector_ignorelist,r=void 0===n?AC:n;if(0===r.length)return!1;for(var i of e)for(var s of r)try{if(i.matches(s))return!0}catch(e){}return!1}(a,n))return{capture:!1,reason:"css_selector_ignorelist_hit"};var d=jc.getComputedStyle(e);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===t.type)return{capture:!0};var h=e.tagName.toLowerCase();switch(h){case"html":return{capture:!1,reason:"tag_html"};case"form":return(i||["submit"]).indexOf(t.type)>=0?{capture:!0}:{capture:!1,reason:"form_event_not_allowed"};case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(t.type)>=0?{capture:!0}:{capture:!1,reason:"input_event_not_allowed"};default:return o?(i||["click"]).indexOf(t.type)>=0?{capture:!0}:{capture:!1,reason:"dom_event_not_allowed"}:(i||["click"]).indexOf(t.type)>=0&&(TC.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))?{capture:!0}:{capture:!1,reason:"tag_not_capturable"}}}function rS(e,t){return t.length>e?t.slice(0,e)+"...":t}function iS(e,t,n,r){var i=e.tagName.toLowerCase(),s={tag_name:i};TC.indexOf(i)>-1&&!n&&(s.$el_text=rS(1024,"a"===i||"button"===i?WC(e):FC(e)));var o=UC(e);o.length>0&&(s.classes=o.filter(e=>""!==e));for(var a=0;a<e.attributes.length;a++){var l=e.attributes[a];if((!eS(e)||-1!==["name","id","class","aria-label"].indexOf(l.name))&&(!(null==r?void 0:r.includes(l.name))&&!t&&ZC(l.value)&&!XC(l.name))){var c=l.value;"class"===l.name&&(c=DC(c).join(" ")),s["attr__"+l.name]=rS(1024,c)}}for(var u=1,d=1,h=e;h=HC(h);)u++,h.tagName===e.tagName&&d++;return s.nth_child=u,s.nth_of_type=d,s}function sS(e){if(!QC(e))return{};for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];if(r.name&&0===r.name.indexOf("data-vt-capture-attribute")){var i=r.name.replace("data-vt-capture-attribute-",""),s=r.value;i&&s&&ZC(s)&&(t[i]=s)}}return t}function oS(e){return e.replace(/"|\\"/g,'\\"')}function aS(e){var t=e.attr__class;return t?Qc(t)?t:DC(t):void 0}function lS(e){return function(e){var t=e.map(e=>{var t,r,i="";if(e.tag_name&&(i+=e.tag_name),e.attr_class)for(var s of(e.attr_class.sort(),e.attr_class))i+="."+s.replace(/"/g,"");var o=n({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Object.entries(o).sort((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)}).forEach(e=>{var[t,n]=e;return a[oS(t.toString())]=oS(String(n))}),(i+=":")+Object.entries(a).map(e=>{var[t,n]=e;return t+'="'+n+'"'}).join("")});return t.join(";")}(function(e){return e.map(e=>{var t,n,r={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(n=e.attr__href)||void 0===n?void 0:n.slice(0,2048),attr_class:aS(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Object.entries(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,n]=e;return r.attributes[t]=n}),r})}(e))}var cS=[25,50,75,100];function uS(e){var t;if(!e)return null;var n=e.milestones,r=!0===n||"object"==typeof n&&null!==n,i="object"==typeof n&&null!==n&&(null===(t=n.thresholds)||void 0===t?void 0:t.length)?[...n.thresholds].sort((e,t)=>e-t):[...cS],s=!0===e.pageleave;return r||s?{milestones:r,thresholds:i,pageleave:s,scroll_root_selector:e.scroll_root_selector}:null}class dS{constructor(e){this._options=e,this._maxPctSeen=0,this._firedThresholds=new Set,this._scrollHandler=null,this._scrollTarget=null,this._rafId=null,this._pageviewUnsub=null}start(){this.stop(),this._scrollTarget=function(e){if(!jc)return null;if(e){var t=Array.isArray(e)?e:[e];for(var n of t){var r=null==zc?void 0:zc.querySelector(n);if(r instanceof Element)return r}}return jc}(this._options.scroll_root_selector),this._scrollTarget&&(this._scrollHandler=()=>this._scheduleScrollUpdate(),Pu(this._scrollTarget,"scroll",this._scrollHandler,{passive:!0}),this._onScroll(),this._pageviewUnsub=this._options.onPageview(()=>this.reset()))}stop(){this._pageviewUnsub&&(this._pageviewUnsub(),this._pageviewUnsub=null),null!=this._rafId&&jc&&(jc.cancelAnimationFrame(this._rafId),this._rafId=null),this._scrollHandler&&this._scrollTarget&&(this._scrollTarget.removeEventListener("scroll",this._scrollHandler,{passive:!0}),this._scrollHandler=null,this._scrollTarget=null)}reset(){this._maxPctSeen=0,this._firedThresholds.clear(),this._onScroll()}getMaxPct(){return this._maxPctSeen}_scheduleScrollUpdate(){jc&&null==this._rafId&&(this._rafId=jc.requestAnimationFrame(()=>{this._rafId=null,this._onScroll()}))}_onScroll(){if(this._scrollTarget){var e=function(e){var t,n,r,i,s,o;if(!e)return 0;if(e===jc){var a=null!==(t=jc.scrollY)&&void 0!==t?t:0,l=null!==(n=jc.innerHeight)&&void 0!==n?n:0,c=null==zc?void 0:zc.documentElement,u=null==zc?void 0:zc.body,d=Math.max(null!==(r=null==c?void 0:c.scrollHeight)&&void 0!==r?r:0,null!==(i=null==u?void 0:u.scrollHeight)&&void 0!==i?i:0,null!==(s=null==c?void 0:c.offsetHeight)&&void 0!==s?s:0,null!==(o=null==u?void 0:u.offsetHeight)&&void 0!==o?o:0)-l;return d<=0?100:Math.round(Math.min(100,a/d*100))}var h=e,p=h.scrollHeight-h.clientHeight;return p<=0?100:Math.round(Math.min(100,h.scrollTop/p*100))}(this._scrollTarget);if(e>this._maxPctSeen&&(this._maxPctSeen=e),this._options.milestones&&this._options.isUrlAllowed())for(var t of this._options.thresholds)this._maxPctSeen>=t&&!this._firedThresholds.has(t)&&(this._firedThresholds.add(t),this._options.capture(Ob,{[Fb]:t,[jb]:this._maxPctSeen}))}}}function hS(e,t){return e.indexOf(t)>-1}class pS{constructor(){this.clicks=[],this.RAGE_CLICK_THRESHOLD_PX=30,this.RAGE_CLICK_TIMEOUT_MS=1e3,this.RAGE_CLICK_CLICK_COUNT=3}isRageClick(e,t,n){if(this.clicks=this.clicks.filter(e=>n-e.timestamp<this.RAGE_CLICK_TIMEOUT_MS),this.clicks.length>0){var r=this.clicks[this.clicks.length-1];Math.sqrt(Math.pow(e-r.x,2)+Math.pow(t-r.y,2))>this.RAGE_CLICK_THRESHOLD_PX&&(this.clicks=[])}return this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length>=this.RAGE_CLICK_CLICK_COUNT}}function fS(e,t){for(var n,r,i,s,{e:o,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:c,elementsChainAsString:u,captureElementValues:d}=t,h=[e],p=e;p.parentNode&&!LC(p,"body");)NC(p.parentNode)?(h.push(p.parentNode.host),p=p.parentNode.host):(h.push(p.parentNode),p=p.parentNode);var f,v=[],g={},m=!1,_=!1;for(var y of h){var b=QC(y);if("a"===y.tagName.toLowerCase()){var w=y.getAttribute("href");m=!!(b&&w&&ZC(w))&&w}hS(UC(y),"vt-no-capture")&&(_=!0),v.push(iS(y,a,l,c));var C=sS(y);Object.assign(g,C)}if(_)return{props:{},explicitNoCapture:_};if(l||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?v[0].$el_text=WC(e):v[0].$el_text=FC(e)),"change"===o.type&&d){var S=tS(e);S&&(S.$el_value&&(v[0].$el_value=S.$el_value),S.$selected_text&&(v[0].$selected_text=S.$selected_text))}if(m){v[0].attr__href=m;var k=null===(n=Yb(m))||void 0===n?void 0:n.host,x=null===(r=null==jc?void 0:jc.location)||void 0===r?void 0:r.host;k&&x&&k!==x&&(f=m)}var I=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Object.assign({},...t)}({$event_type:o.type,$ce_version:1},u?{}:{$elements:v},{$elements_chain:lS(v)},(null===(i=v[0])||void 0===i?void 0:i.$el_text)?{$el_text:null===(s=v[0])||void 0===s?void 0:s.$el_text}:{},f&&"click"===o.type?{$external_click_url:f}:{},g);return{props:I}}var vS=["copy","cut"];class gS{static extractConfig(e){return{enabled:!1!==e.autocapture}}constructor(e,t){this.name="Autocapture",this._initialized=!1,this._isDisabledServerSide=null,this._userOverride=null,this._elementSelectors=null,this._rageclicks=new pS,this._elementsChainAsString=!0,this._cachedConfig=null,this._cachedConfigSource=null,this._domHandler=null,this._copyHandler=null,this._copyHandlerAttached=!1,this._scrollDepthTracker=null,this._pageviewUnsubscribe=null,this._instance=e}get _config(){var e=this._instance.getConfig().autocapture;if(e===this._cachedConfigSource&&this._cachedConfig)return this._cachedConfig;this._cachedConfigSource=e;var t=function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?e:{};return t.url_allowlist&&(t.url_allowlist=t.url_allowlist.map(e=>"string"==typeof e?new RegExp(e):e)),t.url_ignorelist&&(t.url_ignorelist=t.url_ignorelist.map(e=>"string"==typeof e?new RegExp(e):e)),this._cachedConfig=t,t}get isEnabled(){return this._evaluateEnabled().enabled}get isStarted(){return this._initialized}startIfEnabled(){var{enabled:e,reason:t}=this._evaluateEnabled();e?this._initialized?(this._syncCopyHandler(),this._syncScrollDepthHandler()):(this._addDomEventHandlers(),this._initialized=!0,cu().info("autocapture","started; listening for click/change/submit events")):this._initialized?(cu().info("autocapture","stopping; reason:",null!=t?t:"unknown"),this._removeDomEventHandlers(),this._initialized=!1):(cu().debug("autocapture","not started; reason:",null!=t?t:"unknown"),this._teardownScrollDepth())}stop(){this._initialized&&(this._removeDomEventHandlers(),this._initialized=!1,cu().info("autocapture","stopped (DOM listeners detached)")),this._teardownScrollDepth()}getMaxScrollDepthPctForPageleave(){var e=uS(this._config.scroll_depth);return(null==e?void 0:e.pageleave)&&this._scrollDepthTracker?this._scrollDepthTracker.getMaxPct():null}onConfigUpdate(e){var t=e;"boolean"==typeof t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),void 0!==t.autocapture_opt_out&&(this._isDisabledServerSide=!!t.autocapture_opt_out),this.startIfEnabled()}updateConfig(e){void 0!==e.enabled&&(this._userOverride=e.enabled,e.enabled&&(this._isDisabledServerSide=!1),this.startIfEnabled())}getDiagnostics(){var e,t,n,{enabled:r,reason:i}=this._evaluateEnabled(),s=uS(this._config.scroll_depth);return{isEnabled:r,isStarted:this._initialized,disabledReason:r?null:i,inputs:{configAutocapture:this._instance.getConfig().autocapture,isDisabledServerSide:null!==(e=this._isDisabledServerSide)&&void 0!==e&&e,userOverride:this._userOverride,elementsChainAsString:this._elementsChainAsString,captureCopiedText:!!this._config.capture_copied_text,scrollDepthMilestones:null!==(t=null==s?void 0:s.milestones)&&void 0!==t&&t,scrollDepthPageleave:null!==(n=null==s?void 0:s.pageleave)&&void 0!==n&&n,scrollDepthListenerAttached:null!==this._scrollDepthTracker}}}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,n=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach(t=>{var r=null==zc?void 0:zc.querySelectorAll(t);null==r||r.forEach(r=>{e===r&&n.push(t)})}),n}_evaluateEnabled(){if(!1===this._userOverride)return{enabled:!1,reason:"user_stop_called"};if(this._isDisabledServerSide)return{enabled:!1,reason:"server_opt_out"};if(!0===this._userOverride)return{enabled:!0,reason:null};var e=this._instance.getConfig().autocapture;return!1===e?{enabled:!1,reason:"config_autocapture_false"}:null==e?{enabled:!1,reason:"config_autocapture_undefined"}:{enabled:!0,reason:null}}_addDomEventHandlers(){this._isBrowserSupported()?jc&&zc&&(this._domHandler=e=>{var t=e||(null==jc?void 0:jc.event);if(t)try{this._captureEvent(t)}catch(e){cu().error("autocapture","capture handler threw",e)}},Pu(zc,"submit",this._domHandler,{capture:!0}),Pu(zc,"change",this._domHandler,{capture:!0}),Pu(zc,"click",this._domHandler,{capture:!0}),this._syncCopyHandler(),this._syncScrollDepthHandler()):cu().warn("autocapture","browser unsupported (no querySelectorAll)")}_removeDomEventHandlers(){zc&&(this._domHandler&&(zc.removeEventListener("submit",this._domHandler,!0),zc.removeEventListener("change",this._domHandler,!0),zc.removeEventListener("click",this._domHandler,!0),this._domHandler=null),this._copyHandler&&this._copyHandlerAttached&&(zc.removeEventListener("copy",this._copyHandler,!0),zc.removeEventListener("cut",this._copyHandler,!0),this._copyHandlerAttached=!1,this._copyHandler=null),this._teardownScrollDepth())}_syncScrollDepthHandler(){var e,t=uS(this._config.scroll_depth),n=this.isEnabled&&null!==t&&null!==uS(null==(e=this._config)?void 0:e.scroll_depth);n&&!this._scrollDepthTracker?(this._scrollDepthTracker=new dS({milestones:t.milestones,pageleave:t.pageleave,thresholds:t.thresholds,scroll_root_selector:t.scroll_root_selector,capture:(e,t)=>this._instance.capture(e,t),isUrlAllowed:()=>{return e=this._config,!(!jc||(null==e?void 0:e.url_allowlist)&&!VC(e.url_allowlist)||(null==e?void 0:e.url_ignorelist)&&VC(e.url_ignorelist));var e},onPageview:e=>(this._pageviewUnsubscribe&&this._pageviewUnsubscribe(),this._pageviewUnsubscribe=this._instance.on(bu,t=>{(null==t?void 0:t.event)===Sb&&e()}),()=>{var e;null===(e=this._pageviewUnsubscribe)||void 0===e||e.call(this),this._pageviewUnsubscribe=null})}),this._scrollDepthTracker.start(),cu().info("autocapture","scroll depth tracking started",{milestones:t.milestones,pageleave:t.pageleave})):n||this._teardownScrollDepth()}_teardownScrollDepth(){this._scrollDepthTracker&&(this._scrollDepthTracker.stop(),this._scrollDepthTracker=null,cu().info("autocapture","scroll depth tracking stopped")),this._pageviewUnsubscribe&&(this._pageviewUnsubscribe(),this._pageviewUnsubscribe=null)}_syncCopyHandler(){if(zc){var e=!!this._config.capture_copied_text;e&&!this._copyHandlerAttached?(this._copyHandler=e=>{var t=e||(null==jc?void 0:jc.event);if(t)try{this._captureEvent(t,EC)}catch(e){cu().error("autocapture","copy handler threw",e)}},Pu(zc,"copy",this._copyHandler,{capture:!0}),Pu(zc,"cut",this._copyHandler,{capture:!0}),this._copyHandlerAttached=!0):!e&&this._copyHandlerAttached&&this._copyHandler&&(zc.removeEventListener("copy",this._copyHandler,!0),zc.removeEventListener("cut",this._copyHandler,!0),this._copyHandlerAttached=!1,this._copyHandler=null)}}_captureEvent(e,t){var n,r,i,s,o,a,l,c;if(void 0===t&&(t="$autocapture"),this.isEnabled)if(e.isTrusted){var u=function(e){var t;return Zc(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}(e);if(PC(u)&&(u=u.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this._instance.getConfig().rageclick&&(null===(n=this._rageclicks)||void 0===n?void 0:n.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&(cu().info("autocapture","$rageclick detected"),this._captureEvent(e,"$rageclick"));var d=t===EC;if(u){var h=nS(u,e,this._config,d,d?[...vS]:void 0);if(h.capture){var p=this._instance.getConfig(),{props:f,explicitNoCapture:v}=fS(u,{e:e,maskAllElementAttributes:null!==(s=p.mask_all_element_attributes)&&void 0!==s&&s,maskAllText:null!==(o=p.mask_all_text)&&void 0!==o&&o,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,captureElementValues:null!==(a=this._config.capture_element_values)&&void 0!==a&&a});if(v)return cu().debug("autocapture","skip: vt-no-capture class on element chain",{tag:null===(l=u.tagName)||void 0===l?void 0:l.toLowerCase()}),!1;var g=this.getElementSelectors(u);if(g&&g.length>0&&(f.$element_selectors=g),t===EC){var m=BC(null===(c=null==jc?void 0:jc.getSelection())||void 0===c?void 0:c.toString()),_=e.type||"clipboard";if(!m)return cu().debug("autocapture","skip copy: empty selection"),!1;f.$selected_content=m,f.$copy_type=_}return this._instance.capture(t,f),!0}cu().debug("autocapture","skip:",null!==(r=h.reason)&&void 0!==r?r:"unknown",{type:e.type,tag:null===(i=u.tagName)||void 0===i?void 0:i.toLowerCase()})}else cu().debug("autocapture","skip: no event target",{type:e.type})}else cu().debug("autocapture","skip: synthetic event (isTrusted=false)",{type:e.type})}_isBrowserSupported(){return eu(null==zc?void 0:zc.querySelectorAll)}}var mS="replay";class _S extends wC{constructor(e,t){super(e,t||_S.extractConfig(e.getConfig())),this.name="SessionRecording",this.scriptName="recorder"}static extractConfig(e){var t,n,r,i=e.session_recording||{};return{enabled:null!==(t=i.enabled)&&void 0!==t&&t,sampleRate:i.sampleRate,minimumDurationMs:i.minimumDurationMs,sessionIdleThresholdMs:i.sessionIdleThresholdMs,fullSnapshotIntervalMs:i.fullSnapshotIntervalMs,captureConsole:null!==(n=i.captureConsole)&&void 0!==n&&n,captureNetwork:null!==(r=i.captureNetwork)&&void 0!==r&&r,captureCanvas:i.captureCanvas,blockClass:i.blockClass,blockSelector:i.blockSelector,skipDefaultInvisibleBlocking:i.skipDefaultInvisibleBlocking,ignoreClass:i.ignoreClass,maskTextClass:i.maskTextClass,maskTextSelector:i.maskTextSelector,maskAllInputs:i.maskAllInputs,maskInputOptions:i.maskInputOptions,masking:i.masking,recordHeaders:i.recordHeaders,recordBody:i.recordBody,compressEvents:i.compressEvents,__mutationThrottlerRefillRate:i.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:i.__mutationThrottlerBucketSize}}get isEnabled(){var e,t=this._instance.getConfig(),n=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!jc&&n&&r}get isStarted(){var e;return this._isStarted&&!!(null===(e=this._loaded)||void 0===e?void 0:e.isStarted)}startIfEnabled(){this.startIfEnabledOrStop("recording_initialized")}startIfEnabledOrStop(e){var t;if(!this.isEnabled||!(null===(t=this._loaded)||void 0===t?void 0:t.isStarted)){var n=void 0!==Object.assign&&void 0!==Array.from;this.isEnabled&&n?(this._isStarted=!0,this._ensureLoaded(t=>this._onLoaded(t,e)),cu().info(mS,"starting")):this.stop()}}stop(){du(()=>{var e;null===(e=this._loaded)||void 0===e||e.stop(),this._isStarted=!1})}onConfigUpdate(e){var t;this._config=_S.extractConfig(e),null===(t=this._loaded)||void 0===t||t.updateConfig(this._config),this.startIfEnabledOrStop("config_updated")}_createLoaded(){var e,t=null===(e=Gc.__VTiltExtensions__)||void 0===e?void 0:e.initSessionRecording;if(!t)throw new Error("[vTilt:replay] initSessionRecording not available after script load");return t(this._instance,this._config)}_onLoaded(e,t){e.start(t)}get started(){return this.isStarted}get status(){var e;return(null===(e=this._loaded)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._loaded)||void 0===e?void 0:e.sessionId)||""}stopRecording(){this.stop()}log(e,t){var n;void 0===t&&(t="log"),(null===(n=this._loaded)||void 0===n?void 0:n.log)?this._loaded.log(e,t):cu().warn(mS,"log called before recorder was ready")}updateConfig(e){var t;this._config=n({},this._config,e),null===(t=this._loaded)||void 0===t||t.updateConfig(this._config)}}var yS="chat";class bS extends bC{constructor(e,t){super(e,t||bS.extractConfig(e.getConfig())),this.name="Chat",this.scriptName="chat",this._serverConfig=null,this._configFetched=!1,this._loadError=null,this._bubbleDragHandle=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._bubbleExplicitShow=!1,this._unreadPollIntervalId=null,this._onVisibilityChange=()=>{if("visible"===document.visibilityState)return this._fetchUnreadForBubble(),void this._startUnreadPoll();this._stopUnreadPoll()}}static extractConfig(e){var t,n=e.chat||{};return{enabled:n.enabled,autoConfig:null===(t=n.autoConfig)||void 0===t||t,position:n.position,greeting:n.greeting,color:n.color,aiMode:n.aiMode,aiGreeting:n.aiGreeting,preload:n.preload,offlineMessage:n.offlineMessage,collectEmailOffline:n.collectEmailOffline,bubble:n.bubble}}get isEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!this._instance.getConfig().disable_chat&&!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}startIfEnabled(){cu().debug(yS,"startIfEnabled"),this._startAsync().catch(e=>{cu().error(yS,"error starting:",e)})}stop(){this.destroy(),this._isStarted=!1}onConfigUpdate(e){var t,n;this._config=bS.extractConfig(e),this._isBubbleDraggable()||this._syncBubbleLayout(),this._loaded&&(null===(n=(t=this._loaded).updateConfig)||void 0===n||n.call(t,this.getMergedConfig()))}_createLoaded(){var e,t,n,r=null===(e=Gc.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!r)throw new Error("[vTilt:chat] initChat not available after script load");var i=this.getMergedConfig(),s=r(this._instance,i);this._bubbleExplicitShow&&s.show(),this._messageCallbacks.forEach(e=>s.onMessage(e)),this._typingCallbacks.forEach(e=>s.onTyping(e)),this._connectionCallbacks.forEach(e=>s.onConnectionChange(e)),null===(t=this._bubbleDragHandle)||void 0===t||t.destroy(),this._bubbleDragHandle=null;var o=null===(n=null==jc?void 0:jc.document)||void 0===n?void 0:n.getElementById("vtilt-chat-bubble");return o&&!o.closest("#vtilt-chat-container")&&o.remove(),s}_onLoaded(e){this._pendingCallbacks.forEach(e=>e()),this._pendingCallbacks=[],e.isOpen||(this._fetchUnreadForBubble(),this._startUnreadPoll()),cu().info(yS,"loaded and ready")}_startAsync(){var e=this;return t(function*(){var t,n;try{if(!1===e._config.enabled)return void cu().info(yS,"disabled by code config");if(e._instance.getConfig().disable_chat)return void cu().info(yS,"disabled by disable_chat config");if(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),!e.isEnabled)return void cu().info(yS,"not enabled (check dashboard settings)");cu().debug(yS,"startIfEnabled enabled"),e._isStarted=!0,!0===e._config.preload&&e._schedulePreload();var r=e.getMergedConfig();(null===(t=e._serverConfig)||void 0===t?void 0:t.enabled)&&!1!==(null===(n=r.bubble)||void 0===n?void 0:n.visible)&&e._showBubble(),cu().info(yS,"ready (lazy-load on demand)")}finally{e._markApiReady()}})()}get isOpen(){var e,t;return null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.isOpen)&&void 0!==t&&t}get isConnected(){var e,t;return null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isLoading(){var e,t;return this._isLoading||null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.isLoading)&&void 0!==t&&t}get unreadCount(){var e,t;return null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.unreadCount)&&void 0!==t?t:0}get channel(){var e,t;return null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.channel)&&void 0!==t?t:null}get channels(){var e,t;return null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.channels)&&void 0!==t?t:[]}get currentView(){var e,t;return null!==(t=null===(e=this._loaded)||void 0===e?void 0:e.currentView)&&void 0!==t?t:"list"}open(){this._deferCall(()=>{this._stopUnreadPoll(),this._lazyLoadAndThen(()=>{var e;return null===(e=this._loaded)||void 0===e?void 0:e.open()})})}close(){this._deferCall(()=>{this._loaded?(this._loaded.close(),this._fetchUnreadForBubble(),this._startUnreadPoll()):this._lazyLoadAndThen(()=>{var e;null===(e=this._loaded)||void 0===e||e.close(),this._fetchUnreadForBubble(),this._startUnreadPoll()})})}toggle(){this._deferCall(()=>{this._loaded?this._loaded.toggle():this.open()})}show(){this._deferCall(()=>{this._bubbleExplicitShow=!0,this._loaded?this._loaded.show():this._isStarted&&this._showBubble()})}hide(){this._deferCall(()=>{var e;if(this._bubbleExplicitShow=!1,this._loaded)this._loaded.hide();else{var t=null===(e=null==jc?void 0:jc.document)||void 0===e?void 0:e.getElementById("vtilt-chat-bubble");t&&(t.style.display="none")}})}getChannels(){this._deferCall(()=>{this._lazyLoadAndThen(()=>{var e;return null===(e=this._loaded)||void 0===e?void 0:e.getChannels()})})}selectChannel(e){this._deferCall(()=>{this._lazyLoadAndThen(()=>{var t;return null===(t=this._loaded)||void 0===t?void 0:t.selectChannel(e)})})}createChannel(){this._deferCall(()=>{this._lazyLoadAndThen(()=>{var e;return null===(e=this._loaded)||void 0===e?void 0:e.createChannel()})})}goToChannelList(){this._deferCall(()=>{this._loaded?this._loaded.goToChannelList():this._lazyLoadAndThen(()=>{var e;return null===(e=this._loaded)||void 0===e?void 0:e.goToChannelList()})})}sendMessage(e,t){return this._loaded?this._loaded.sendMessage(e,t):new Promise((n,r)=>{this._deferCall(()=>{this._loaded?this._loaded.sendMessage(e,t).then(n).catch(r):(this._pendingMessages.push({content:e,options:t,resolve:n,reject:r}),this._lazyLoadAndThen(()=>{var e,t=this._pendingMessages;for(var n of(this._pendingMessages=[],t))null===(e=this._loaded)||void 0===e||e.sendMessage(n.content,n.options).then(n.resolve).catch(n.reject)}))})})}markAsRead(){this._deferCall(()=>{this._loaded?this._loaded.markAsRead():this._lazyLoadAndThen(()=>{var e;return null===(e=this._loaded)||void 0===e?void 0:e.markAsRead()})})}registerWidget(e){this._deferCall(()=>{var t,n;this._loaded?null===(n=(t=this._loaded).registerWidget)||void 0===n||n.call(t,e):this._lazyLoadAndThen(()=>{var t,n;null===(n=null===(t=this._loaded)||void 0===t?void 0:t.registerWidget)||void 0===n||n.call(t,e)})})}onMessage(e){return this._messageCallbacks.push(e),this._loaded?this._loaded.onMessage(e):()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),this._loaded?this._loaded.onTyping(e):()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),this._loaded?this._loaded.onConnectionChange(e):()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}_isBubbleDraggable(){var e;return!0===(null===(e=this.getMergedConfig().bubble)||void 0===e?void 0:e.draggable)}getMergedConfig(){var e,t,n,r,i,s,o,a,l,c,u,d,h,p,f,v,g,m,_,y,b,w,C,S,k,x=this._serverConfig,I=this._config;return{enabled:null!==(t=null!==(e=I.enabled)&&void 0!==e?e:null==x?void 0:x.enabled)&&void 0!==t&&t,autoConfig:null===(n=I.autoConfig)||void 0===n||n,position:null!==(i=null!==(r=I.position)&&void 0!==r?r:null==x?void 0:x.position)&&void 0!==i?i:"bottom-right",greeting:null!==(s=I.greeting)&&void 0!==s?s:null==x?void 0:x.greeting,color:null!==(a=null!==(o=I.color)&&void 0!==o?o:null==x?void 0:x.color)&&void 0!==a?a:"#6366f1",aiMode:null===(c=null!==(l=I.aiMode)&&void 0!==l?l:null==x?void 0:x.ai_enabled)||void 0===c||c,aiGreeting:null!==(u=I.aiGreeting)&&void 0!==u?u:null==x?void 0:x.ai_greeting,preload:null!==(d=I.preload)&&void 0!==d&&d,theme:null!==(h=I.theme)&&void 0!==h?h:{primaryColor:null!==(f=null!==(p=I.color)&&void 0!==p?p:null==x?void 0:x.color)&&void 0!==f?f:"#6366f1"},offlineMessage:null!==(v=I.offlineMessage)&&void 0!==v?v:null==x?void 0:x.offline_message,collectEmailOffline:null===(m=null!==(g=I.collectEmailOffline)&&void 0!==g?g:null==x?void 0:x.collect_email_offline)||void 0===m||m,bubble:{draggable:null!==(b=null!==(y=null===(_=I.bubble)||void 0===_?void 0:_.draggable)&&void 0!==y?y:null==x?void 0:x.bubble_draggable)&&void 0!==b&&b,visible:null===(S=null!==(C=null===(w=I.bubble)||void 0===w?void 0:w.visible)&&void 0!==C?C:null==x?void 0:x.bubble_visible)||void 0===S||S,offset:null===(k=I.bubble)||void 0===k?void 0:k.offset}}}_syncBubbleLayout(){var e,t,n=this.getMergedConfig(),r=null!==(e=n.position)&&void 0!==e?e:"bottom-right",i=zf(null===(t=n.bubble)||void 0===t?void 0:t.offset),s=document.getElementById("vtilt-chat-bubble");s&&Vf(s,r,i)}destroy(){du(()=>{var e,t,n;this._stopUnreadPoll(),document.removeEventListener("visibilitychange",this._onVisibilityChange),null===(e=this._loaded)||void 0===e||e.destroy(),this._loaded=void 0,this._bubbleExplicitShow=!1,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._resetDeferral(),null===(t=this._bubbleDragHandle)||void 0===t||t.destroy(),this._bubbleDragHandle=null;var r=null===(n=null==jc?void 0:jc.document)||void 0===n?void 0:n.getElementById("vtilt-chat-bubble");r&&r.remove()})}_fetchServerSettings(){var e=this;return t(function*(){if(!e._configFetched){var t=e._instance.getConfig();if(!t.token)return cu().warn(yS,"cannot fetch settings: missing token"),void(e._configFetched=!0);try{var n=pu(t,"/api/chat/settings"),r=yield fetch(n,{headers:fu(t)});if(!r.ok)return cu().warn(yS,"failed to fetch settings: "+r.status),void(e._configFetched=!0);e._serverConfig=yield r.json(),e._configFetched=!0,cu().info(yS,"loaded settings from dashboard")}catch(t){cu().warn(yS,"error fetching settings:",t),e._configFetched=!0}}})()}_fetchUnreadForBubble(){var e=this;return t(function*(){var t,n,r,i,s,o,a=e._instance.getConfig(),l=a.token,c=null!==(r=null===(n=(t=e._instance).getDistinctId)||void 0===n?void 0:n.call(t))&&void 0!==r?r:"";if(cu().debug("chat","fetchUnread","distinctId",c?c.slice(0,12)+"...":"empty"),l&&c)try{var u=pu(a,"/api/chat/widget/unread"),d=u.includes("?")?"&":"?",h=""+u+d+"distinct_id="+encodeURIComponent(c),p=yield fetch(h,{headers:fu(a)});if(!p.ok)return;var f=yield p.json(),v=Number(null!==(i=f.unread_count)&&void 0!==i?i:0);null===(o=null===(s=e._loaded)||void 0===s?void 0:s.applyPolledUnreadCount)||void 0===o||o.call(s,v);var g=document.getElementById("vtilt-chat-bubble");if(!g)return;var m=g.querySelector(".vtilt-chat-bubble-badge");if(!m)return;v>0?(m.style.display="flex",m.textContent=v>99?"99+":String(v)):m.style.display="none"}catch(e){}else{var _=l?"missing distinctId":"missing token";cu().debug("chat","fetchUnread skip","reason",_)}})()}_showBubble(){var e,t,n,r;if(null==jc?void 0:jc.document){var i=document.getElementById("vtilt-chat-bubble");if(i)return i.style.display="flex",void this._syncBubbleLayout();var s=this.getMergedConfig(),o=null!==(e=s.position)&&void 0!==e?e:"bottom-right",a=zf(null===(t=s.bubble)||void 0===t?void 0:t.offset),l=s.color||"#6366f1",c=document.createElement("div");c.id="vtilt-chat-bubble",c.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(c,o,a),c.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===(n=s.bubble)||void 0===n?void 0:n.draggable);u||(c.addEventListener("mouseenter",()=>{c.style.transform="scale(1.05)",c.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),c.addEventListener("mouseleave",()=>{c.style.transform="scale(1)",c.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"})),c.addEventListener("click",()=>{this.open()}),document.body.appendChild(c),u&&(null===(r=this._bubbleDragHandle)||void 0===r||r.destroy(),this._bubbleDragHandle=Kf(c)),this._fetchUnreadForBubble(),this._startUnreadPoll(),document.addEventListener("visibilitychange",this._onVisibilityChange)}}_shouldPollUnread(){return"undefined"!=typeof document&&("visible"===document.visibilityState&&(!!document.getElementById("vtilt-chat-bubble")||!(!this._loaded||this._loaded.isOpen)))}_startUnreadPoll(){this._shouldPollUnread()&&null===this._unreadPollIntervalId&&(this._unreadPollIntervalId=setInterval(()=>{this._fetchUnreadForBubble()},3e4))}_stopUnreadPoll(){null!==this._unreadPollIntervalId&&(clearInterval(this._unreadPollIntervalId),this._unreadPollIntervalId=null)}_schedulePreload(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this._ensureLoaded(()=>{}),{timeout:5e3}):setTimeout(()=>this._ensureLoaded(()=>{}),3e3)}_lazyLoadAndThen(e){this._loaded?e():(this._pendingCallbacks.push(e),this._ensureLoaded(e=>this._onLoaded(e)))}}function wS(e,t){e("js",new Date);var{tagIds:r,configParams:i,sendPageView:s,debugMode:o,conversionLinker:a,linkerDomains:l}=t,c=n({},i||{});for(var u of(!1===s&&(c.send_page_view=!1),o&&(c.debug_mode=!0),!1===a&&(c.conversion_linker=!1),l&&l.length>0&&(c.linker={domains:l,decorate_forms:!0}),r))u&&e("config",u,c)}function CS(e,t){var n,r=(e.tagIds||[]).filter(e=>!!e);if(0===r.length)return null;var i,s,o,a=null!==(n=e.proxyMode)&&void 0!==n?n:"proxied";if("direct"===a)i=kS,s=kS,o="";else{var l=function(e){var t,n=void 0!==jc&&(null===(t=null==jc?void 0:jc.location)||void 0===t?void 0:t.origin)?jc.location.origin:"";if(!e)return n?{base:n,absoluteBase:n}:null;var r=e.replace(/\/+$/g,"");if(!r)return n?{base:n,absoluteBase:n}:null;try{var i=new URL(r),s=i.pathname.replace(/\/$/,""),o=""+i.origin+s;return{base:o,absoluteBase:o}}catch(e){}if(r.startsWith("/"))return{base:r,absoluteBase:n?""+n+r:r};return n?{base:n,absoluteBase:n}:null}(t);if(!l)return null;i=l.base,s=l.absoluteBase,o=SS}var c={};if("direct"!==a){var u=function(e){if(!e)return"";var t=e.startsWith("/")?e:"/"+e;return t.replace(/\/$/,"")}(o);c.transport_url=""+s.replace(/\/$/,"")+u}return{origin:i,gatewayPath:o,primaryTagId:r.find(e=>e.startsWith("G-"))||r[0]||"",tagIds:r,configParams:c,sendPageView:!1!==e.capturePageview,debugMode:!!e.debugMode,conversionLinker:!1!==e.conversionLinker,linkerDomains:e.linkerDomains}}var SS="/gt",kS="https://www.googletagmanager.com";function xS(e,t){var r=!0===e.advertising,i={ad_storage:r?"granted":"denied",ad_user_data:r?"granted":"denied",ad_personalization:r?"granted":"denied",analytics_storage:!0===e.analytics?"granted":"denied"};if(!t)return i;var s=n({},i);return Object.keys(i).forEach(n=>{var r=t[n];void 0!==r&&(s[n]=function(e,t){return"granted"===t?"granted":"denied"===t?"denied":"follow_advertising"===t?!0===e.advertising?"granted":"denied":"follow_analytics"===t&&!0===e.analytics?"granted":"denied"}(e,r))}),s}function IS(e){if(null==e)return null;var t=String(e).trim().toLowerCase();return t||null}function TS(e,t){if(e&&t){var n=t.split("."),r=e;for(var i of n){if(null==r||"object"!=typeof r)return;r=r[i]}return r}}function ES(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){var t=Number(e);if(Number.isFinite(t))return t}}function AS(e){if(null!=e)return"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):void 0}function OS(e){var{mapping:t,payload:n}=e,r={send_to:t.send_to},i=t.value_param_path||"value",s=t.currency_param_path||"currency",o=ES(TS(n,i));void 0!==o&&(r.value=o);var a=AS(TS(n,s))||t.default_currency||void 0;if(a&&(r.currency=a),!1!==t.send_transaction_id){var l=AS(TS(n,t.transaction_id_param_path||"transaction_id"));l&&(r.transaction_id=l)}return{send_to:t.send_to,params:r}}var MS=[{source:"$pageview",destination:"page_view",buildParams:e=>{var t,n={},r=AS(e.$current_url);r&&(n.page_location=r);var i=AS(e.$pathname);i&&(n.page_path=i);var s=null!==(t=AS(e.title))&&void 0!==t?t:AS(e.$title);s&&(n.page_title=s);var o=AS(e.$referrer);return o&&(n.page_referrer=o),n}},{source:"$pageleave",destination:"user_engagement",buildParams:e=>{var t,n,r={},i=ES(null!==(n=null!==(t=e.$dwell_time_ms)&&void 0!==t?t:e.engagement_time_msec)&&void 0!==n?n:e.$time_on_page_ms);return void 0!==i&&(r.engagement_time_msec=Math.round(i)),r}}];function RS(e,t,n){var r=t.split(".").filter(Boolean);if(0!==r.length)if(1!==r.length){for(var i=e,s=0;s<r.length-1;s++){var o=r[s],a=r[s+1];if(null==i||"object"!=typeof i||Array.isArray(i))return;var l=i;if(/^\d+$/.test(a)){var c=Array.isArray(l[o])?l[o]:[];Array.isArray(l[o])||(l[o]=c);for(var u=parseInt(a,10);c.length<=u;)c.push({});if(s+1===r.length-1)return void(c[u]=n);var d=c[u];d&&"object"==typeof d&&!Array.isArray(d)||(d={},c[u]=d),i=d,s++}else{var h=l[o];h&&"object"==typeof h&&!Array.isArray(h)||(h={},l[o]=h),i=h}}var p=r[r.length-1];i&&"object"==typeof i&&!Array.isArray(i)&&(i[p]=n)}else e[r[0]]=n}var PS=new Set(["client_id","user_id","first_visit","session_start"]);function LS(e,t,n,r){if(!function(e,t){return!(t&&(Array.isArray(t.exclude)&&t.exclude.includes(e)||Array.isArray(t.include)&&t.include.length>0&&!t.include.includes(e)))}(t,r.eventFilter))return{fired:!1};var i=(r.eventMappings||[]).find(e=>(null==e?void 0:e.source)===t);if(i&&i.destination){var{name:s,params:o}=function(e,t){var n={},r=Array.isArray(e.param_mappings)?e.param_mappings:[];for(var i of r){var s=null==i?void 0:i.source,o=null==i?void 0:i.destination;if(s&&o){var a=TS(t,s);void 0!==a&&(o.includes(".")?RS(n,o,a):n[o]=a)}}return{name:e.destination,params:n}}(i,n);return e("event",s,o),{fired:!0,eventName:s,params:o,source:"mapping"}}if(!1===r.autoForward)return{fired:!1};var a=MS.find(e=>e.source===t);if(a){var l=a.buildParams(n);return e("event",a.destination,l),{fired:!0,eventName:a.destination,params:l,source:"preset"}}if(t.startsWith("$"))return{fired:!1};var c=function(e){var t={};for(var[n,r]of Object.entries(e))n.startsWith("$")||PS.has(n)||void 0!==r&&(t[n]=r);return t}(n);return e("event",t,c),{fired:!0,eventName:t,params:c,source:"auto"}}function NS(){var e=null,t=[],n=[];return{call:function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];if((e=>{n.push(e),n.length>50&&n.shift()})(i),e)try{e(...i)}catch(e){}else t.push(i)},flush(n){for(e=n;t.length;){var r=t.shift();try{n(...r)}catch(e){}}},getRecentCalls:()=>n.slice()}}function DS(e){return US.apply(this,arguments)}function US(){return US=t(function*(e){try{var t="undefined"!=typeof crypto&&crypto.subtle?crypto.subtle:null;if(!t)return null;var n=(new TextEncoder).encode(e),r=yield t.digest("SHA-256",n),i=Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("");return i}catch(e){return null}}),US.apply(this,arguments)}function BS(){return(BS=t(function*(e){var t={},n=function(e){if(!e)return null;var t=String(e).trim().toLowerCase();if(!t)return null;if(!t.includes("@"))return null;var[n,r]=t.split("@");if(!n||!r)return null;if("gmail.com"===r||"googlemail.com"===r){var i=n.split("+")[0].replace(/\./g,"");return i?i+"@"+r:null}return n+"@"+r}(e.email),r=function(e){if(!e)return null;var t=String(e).trim();if(!t)return null;if(t.startsWith("+")){var n=t.slice(1).replace(/\D/g,"");return n?"+"+n:null}return null}(e.phone),i=IS(e.first_name),s=IS(e.last_name),o=IS(e.street),a=IS(e.city),l=IS(e.region),c=function(e){if(!e)return null;var t=String(e).trim().toUpperCase().replace(/\s+/g,"");return t||null}(e.postal_code),u=IS(e.country);if(n){var d=yield DS(n);d&&(t.sha256_email_address=d)}if(r){var h=yield DS(r);h&&(t.sha256_phone_number=h)}var p={};if(i){var f=yield DS(i);f&&(p.sha256_first_name=f)}if(s){var v=yield DS(s);v&&(p.sha256_last_name=v)}if(o){var g=yield DS(o);g&&(p.sha256_street=g)}return a&&(p.city=a),l&&(p.region=l),c&&(p.postal_code=c),u&&(p.country=u),Object.keys(p).length>0&&(t.address=p),0===Object.keys(t).length?null:t})).apply(this,arguments)}class FS{constructor(e){void 0===e&&(e=Number.POSITIVE_INFINITY),this._maxItems=e,this._items=[]}get length(){return this._items.length}enqueue(e){return!(this._items.length>=this._maxItems)&&(this._items.push(e),!0)}takeAll(){if(0===this._items.length)return[];var e=this._items;return this._items=[],e}clear(){this._items=[]}}var jS="google-tag";class WS{constructor(e,t){this.name="GoogleTagGateway",this._isStarted=!1,this._scriptInjected=!1,this._scriptLoaded=!1,this._consentDefaultsPushed=!1,this._gtag=null,this._loaderOptions=null,this._unsubscribeCaptured=null,this._unsubscribeConsent=null,this._deliveryLog=[],this._maxDeliveryLog=100,this._pendingCaptures=new FS(100),this._instance=e,this._config=t||WS.extractConfig(e.getConfig()),this._publicApi=NS(),this._subscribeCaptured()}static extractConfig(e){if(e.disable_google_tag)return{enabled:!1};var t=e.google_tag;return t?{enabled:(t.tagIds||[]).some(e=>!!e),remote:t}:{enabled:!1}}get isEnabled(){return!1!==this._config.enabled&&!!this._config.remote}get isStarted(){return this._isStarted}get gtag(){return this._publicApi.call}get deliveryLog(){return this._deliveryLog.slice()}startIfEnabled(){this._isStarted||this.isEnabled&&this._instance.getConfig().__remote_config_loaded&&this._start()}stop(){var e;this._isStarted&&(null===(e=this._unsubscribeConsent)||void 0===e||e.call(this),this._unsubscribeConsent=null,this._isStarted=!1)}onConfigUpdate(e){var t=WS.extractConfig(e),n=this.isEnabled;this._config=t;var r=!0===e.__remote_config_loaded;if(n&&!this.isEnabled)this.stop();else if(this._isStarted&&t.remote&&this._loaderOptions){var i=CS(t.remote,this._instance.getConfig().api_host);i&&(this._loaderOptions=i,wS(this._gtag,i))}r&&!this.isEnabled&&this._pendingCaptures.clear(),r&&this.isEnabled&&!this._isStarted&&this.startIfEnabled()}setUserData(e){var n=this;return t(function*(){var t=n._config.remote;if(t&&t.enhancedConversions){var r=yield function(e){return BS.apply(this,arguments)}(e);r&&n._publicApi.call("set","user_data",r)}})()}getRecentPublicCalls(){return this._publicApi.getRecentCalls()}_start(){var e=this._config.remote;if(e){var t=CS(e,this._instance.getConfig().api_host);if(t){this._loaderOptions=t;var{gtag:n}=function(){var e,t,n=Gc,r=null!==(e=(t=n).dataLayer)&&void 0!==e?e:t.dataLayer=[],i=n.gtag;if(i)return{gtag:i,dataLayer:r};var s=function(){r.push(arguments)};return n.gtag=s,{gtag:s,dataLayer:r}}();this._gtag=n,this._publicApi.flush(n),this._pushConsentDefaultsOnce(),wS(n,t),this._scriptInjected||(this._scriptInjected=!0,function(e,t,n){var r=null==jc?void 0:jc.document;if(!r)return null;var{origin:i,gatewayPath:s,primaryTagId:o}=e;if(!i||!o)return null;var a=""+i.replace(/\/$/,"")+(s?s.startsWith("/")?s.replace(/\/$/,""):"/"+s.replace(/\/$/,""):"")+"/gtag/js?id="+encodeURIComponent(o)+"&l=dataLayer",l=r.querySelector('script[data-vtilt-gtag-loader="'+o+'"]');if(l)return l;var c=r.createElement("script");c.async=!0,c.src=a,c.setAttribute("data-vtilt-gtag-loader",o),c.onload=()=>null==t?void 0:t(),c.onerror=()=>{var e=new Error("[GoogleTagGateway] failed to load "+a);null==n||n(e)},(r.head||r.body||r.documentElement).appendChild(c)}(t,()=>{this._scriptLoaded=!0},e=>{cu().warn(jS,e.message)})),this._subscribeConsent(),this._isStarted=!0,this._drainPending()}else cu().warn(jS,"skipped — missing tag_ids or resolvable origin")}}_drainPending(){for(var e of this._pendingCaptures.takeAll())this._handleCaptured(e.event,e.payload)}_pushConsentDefaultsOnce(){var e;if(!this._consentDefaultsPushed&&this._gtag){var t=du(()=>this._instance.consentManager.getConsent());!function(e,t,r){e("consent","default",n({},xS(t,r),{wait_for_update:500}))}(this._gtag,t||{},null===(e=this._config.remote)||void 0===e?void 0:e.consentOverride),this._consentDefaultsPushed=!0}}_subscribeCaptured(){if(!this._unsubscribeCaptured){this._unsubscribeCaptured=this._instance._emitter.on(bu,e=>{var t=e;t&&"string"==typeof t.event&&this._handleCaptured(t.event,t.payload||{})})}}_handleCaptured(e,t){var n=this._instance.getConfig();if(!n.disable_google_tag)if(n.__remote_config_loaded){if(this.isEnabled&&(this._isStarted||this.startIfEnabled(),this._gtag&&this._config.remote&&this._isStarted)){var r=this._config.remote,i=r.tagIds||[],s=LS(this._gtag,e,t,r);if(s.fired&&s.eventName&&this._record({ts:Date.now(),tag_ids:i,event_name:e,send_to:"ga4:"+s.eventName,status:"fired",reason:s.source}),!1!==r.sendAdsConversions){var o=function(e,t,n,r){var i=(r.conversions||[]).filter(e=>e.event_name===t);if(0===i.length)return[];var s=[];for(var o of i){var a=OS({mapping:o,payload:n});e("event","conversion",a.params),s.push(a)}return s}(this._gtag,e,t,r);for(var a of o)this._record({ts:Date.now(),tag_ids:i,event_name:e,send_to:a.send_to,status:"fired"})}}}else this._pendingCaptures.enqueue({event:e,payload:t})}_subscribeConsent(){if(!this._unsubscribeConsent){this._unsubscribeConsent=this._instance._emitter.on(yu,e=>{var t;if(this._gtag){var n,r,i,s=e;n=this._gtag,r=s.consent||{},i=null===(t=this._config.remote)||void 0===t?void 0:t.consentOverride,n("consent","update",xS(r,i))}})}}_record(e){this._deliveryLog.push(e),this._deliveryLog.length>this._maxDeliveryLog&&this._deliveryLog.shift()}}var HS="vtd-overlay";class zS{constructor(e,t){this.name="VtdOverlay",this._isStarted=!1,this._destinationUrl=null,this._originalUrl=null,this._isLoading=!0,this._container=null,this._iframe=null,this._loadingEl=null,this._instance=e,this._config=t||zS.extractConfig(e.getConfig())}static extractConfig(e){return{enabled:!1!==e.vtd_overlay}}get isEnabled(){return!1!==this._config.enabled}get isStarted(){return this._isStarted}startIfEnabled(){}stop(){this._isStarted&&du(()=>{this._destroyOverlay(),this._isStarted=!1})}onConfigUpdate(e){this._config=zS.extractConfig(e),!this.isEnabled&&this._isStarted&&this.stop()}setDestinationUrl(e){var t;if(this.isEnabled)if(null==e?void 0:e.trim()){var n=e;try{n=decodeURIComponent(e)}catch(t){n=e}if(this._isValidUrl(n)){var r=this._toEmbedUrl(n);this._originalUrl=n,this._destinationUrl=r,this._isLoading=!0,this._showOverlay(),this._isStarted=!0,this._instance.capture("$vtd_view",{$vtd_url:n,$vtd_embed_url:r!==n?r:void 0,$current_url:null===(t=null==jc?void 0:jc.location)||void 0===t?void 0:t.href})}else cu().warn(HS,"invalid URL: "+n)}else cu().warn(HS,"empty URL provided");else cu().warn(HS,"feature is disabled")}getDestinationUrl(){return this._destinationUrl}close(){this._instance.capture("$vtd_close",{$vtd_url:this._originalUrl}),this._container?(this._container.classList.add("vtilt-vtd-closing"),setTimeout(()=>{this._destroyOverlay(),this._isStarted=!1,this._destinationUrl=null,this._originalUrl=null},200)):(this._destroyOverlay(),this._isStarted=!1,this._destinationUrl=null,this._originalUrl=null)}_isValidUrl(e){try{var t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}_toEmbedUrl(e){try{var t=new URL(e),n=t.hostname.toLowerCase();if("youtube.com"===n||"www.youtube.com"===n||"m.youtube.com"===n){var r=t.searchParams.get("v");if(r){var i=t.searchParams.get("t"),s="https://www.youtube.com/embed/"+r+"?autoplay=1";return i&&(s+="&start="+i.replace("s","")),s}}if("youtu.be"===n){var o=t.pathname.slice(1);if(o){var a=t.searchParams.get("t"),l="https://www.youtube.com/embed/"+o+"?autoplay=1";return a&&(l+="&start="+a.replace("s","")),l}}if("vimeo.com"===n||"www.vimeo.com"===n){var c=t.pathname.match(/^\/(\d+)/);if(c)return"https://player.vimeo.com/video/"+c[1]+"?autoplay=1"}if("loom.com"===n||"www.loom.com"===n){var u=t.pathname.match(/^\/share\/([a-zA-Z0-9]+)/);if(u)return"https://www.loom.com/embed/"+u[1]+"?autoplay=1"}if(n.endsWith("wistia.com")){var d=t.pathname.match(/^\/medias\/([a-zA-Z0-9]+)/);if(d)return"https://fast.wistia.net/embed/iframe/"+d[1]+"?autoplay=1"}if("dailymotion.com"===n||"www.dailymotion.com"===n){var h=t.pathname.match(/^\/video\/([a-zA-Z0-9]+)/);if(h)return"https://www.dailymotion.com/embed/video/"+h[1]+"?autoplay=1"}if("open.spotify.com"===n){var p=t.pathname.match(/^\/(track|album|playlist|episode|show)\/([a-zA-Z0-9]+)/);if(p)return"https://open.spotify.com/embed/"+p[1]+"/"+p[2]}return"drive.google.com"===n&&t.pathname.includes("/view")?e.replace("/view","/preview"):e}catch(t){return e}}_getHostname(e){try{return new URL(e).hostname}catch(t){return e}}_getFaviconUrl(e){try{return"https://www.google.com/s2/favicons?domain="+new URL(e).hostname+"&sz=32"}catch(e){return""}}_showOverlay(){if(zc&&this._destinationUrl){this._destroyOverlay(),this._container=zc.createElement("div"),this._container.id="vtilt-vtd-overlay",this._container.className="vtilt-vtd-opening",this._container.setAttribute("style",this._getBackdropStyles());var e=zc.createElement("div");e.className="vtilt-vtd-modal",e.setAttribute("style",this._getModalStyles());var t=zc.createElement("div");t.className="vtilt-vtd-header",t.setAttribute("style",this._getHeaderStyles()),t.innerHTML=this._getHeaderHTML(),e.appendChild(t);var n=zc.createElement("div");n.className="vtilt-vtd-iframe-wrapper",n.setAttribute("style",this._getIframeWrapperStyles()),this._loadingEl=zc.createElement("div"),this._loadingEl.className="vtilt-vtd-loading",this._loadingEl.setAttribute("style",this._getLoadingStyles()),this._loadingEl.innerHTML=this._getLoadingHTML(),n.appendChild(this._loadingEl),this._iframe=zc.createElement("iframe"),this._iframe.id="vtilt-vtd-iframe",this._iframe.className="vtilt-vtd-iframe",this._iframe.setAttribute("style",this._getIframeStyles()),this._iframe.setAttribute("frameborder","0"),this._iframe.setAttribute("allowfullscreen","true"),this._iframe.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share");var r=()=>{this._isLoading=!1,this._loadingEl&&(this._loadingEl.style.opacity="0",setTimeout(()=>{var e;(null===(e=this._loadingEl)||void 0===e?void 0:e.parentNode)&&(this._loadingEl.style.display="none")},300)),this._iframe&&(this._iframe.style.opacity="1")};this._iframe.onload=r,this._iframe.onerror=r,setTimeout(()=>{this._isLoading&&r()},5e3),n.appendChild(this._iframe),this._iframe.src=this._destinationUrl,e.appendChild(n),this._container.appendChild(e);var i=zc.createElement("style");i.id="vtilt-vtd-styles",i.textContent=this._getGlobalStyles(),zc.head.appendChild(i),zc.body.appendChild(this._container),this._attachEventListeners(),zc.body.style.overflow="hidden"}}_destroyOverlay(){var e;(null===(e=this._container)||void 0===e?void 0:e.parentNode)&&(this._container.parentNode.removeChild(this._container),this._container=null,this._iframe=null,this._loadingEl=null);var t=null==zc?void 0:zc.getElementById("vtilt-vtd-styles");(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t),(null==zc?void 0:zc.body)&&(zc.body.style.overflow="")}_attachEventListeners(){var e,t,n,r=null===(e=this._container)||void 0===e?void 0:e.querySelector(".vtilt-vtd-close");null==r||r.addEventListener("click",()=>this.close());var i=null===(t=this._container)||void 0===t?void 0:t.querySelector(".vtilt-vtd-open");null==i||i.addEventListener("click",()=>{this._originalUrl&&(null==jc||jc.open(this._originalUrl,"_blank"))}),null===(n=this._container)||void 0===n||n.addEventListener("click",e=>{e.target===this._container&&this.close()});var s=e=>{"Escape"===e.key&&(this.close(),null==zc||zc.removeEventListener("keydown",s))};null==zc||zc.addEventListener("keydown",s)}_getBackdropStyles(){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 '}_getModalStyles(){return"\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background: #0a0a0a;\n overflow: hidden;\n "}_getHeaderStyles(){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 "}_getHeaderHTML(){var e=this._originalUrl||this._destinationUrl,t=e?this._getHostname(e):"";return'\n <div style="display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;">\n <img \n src="'+(e?this._getFaviconUrl(e):"")+'" \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._escapeHtml(t)+'</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._escapeHtml(this._truncateUrl(e||"",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 '}_getIframeWrapperStyles(){return"\n flex: 1;\n position: relative;\n background: #000;\n overflow: hidden;\n "}_getLoadingStyles(){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 "}_getLoadingHTML(){var e=this._originalUrl||this._destinationUrl,t=e?this._getHostname(e):"";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._escapeHtml(t)+'...</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 '}_getIframeStyles(){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 "}_getGlobalStyles(){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 "}_truncateUrl(e,t){return e.length<=t?e:e.substring(0,t-3)+"..."}_escapeHtml(e){if(void 0===zc)return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");var t=zc.createElement("div");return t.textContent=e,t.innerHTML}}var VS,qS="text/plain",$S=61440;!function(e){e.GZipJS="gzip-js",e.Base64="base64",e.None="none"}(VS||(VS={}));var GS=function(e,t){void 0===t&&(t="binary");var{data:n,compression:r}=e;if(n){var i=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(n),s=new Blob([i]).size;if(r===VS.GZipJS&&s>=1024)try{var o=xd(Ed(i),{mtime:0});if("text-base64"===t){var a=Ad(o);if(a.length>0&&a.length<.95*s)return{contentType:qS,body:a,estimatedSize:a.length,compressionApplied:VS.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:VS.GZipJS}}}catch(e){}return{contentType:"application/json",body:i,estimatedSize:s,compressionApplied:null}}};function JS(e,t){return t.compressionApplied?function(e,t){var n=e.includes("?")?"&":"?";return""+e+n+"compression="+t}(e.url,t.compressionApplied):e.url}function KS(e,t){var n={};return t&&(n["Content-Type"]=t),e.headers&&Object.assign(n,e.headers),e.projectToken&&(n[hu]=e.projectToken),n}var YS=[{name:"fetch",isAvailable:()=>"undefined"!=typeof fetch,method:e=>{var n=GS(e,"binary");if(n){var{contentType:r,body:i,estimatedSize:s}=n,o=JS(e,n),a=KS(e,r),l=new AbortController,c=e.timeout?setTimeout(()=>l.abort(),e.timeout):null;fetch(o,{method:e.method||"POST",headers:a,body:i,keepalive:s<$S,signal:l.signal}).then(function(){var n=t(function*(t){var n,r=yield t.text(),i={statusCode:t.status,text:r};if(200===t.status){Tu();try{i.json=JSON.parse(r)}catch(e){}}null===(n=e.callback)||void 0===n||n.call(e,i)});return function(e){return n.apply(this,arguments)}}()).catch(()=>{var t;Iu("capture"),null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{c&&clearTimeout(c)})}}},{name:"XHR",isAvailable:()=>"undefined"!=typeof XMLHttpRequest,method:e=>{var t=GS(e,"binary");if(t){var{contentType:n,body:r}=t,i=JS(e,t),s=KS(e,n),o=new XMLHttpRequest;for(var[a,l]of(o.open(e.method||"POST",i,!0),Object.entries(s)))o.setRequestHeader(a,l);e.timeout&&(o.timeout=e.timeout),o.onreadystatechange=()=>{var t;if(4===o.readyState){var n={statusCode:o.status,text:o.responseText};if(200===o.status){Tu();try{n.json=JSON.parse(o.responseText)}catch(e){}}null===(t=e.callback)||void 0===t||t.call(e,n)}},o.onerror=()=>{var t;Iu("capture"),null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},o.send(r)}}},{name:"sendBeacon",isAvailable:()=>"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=GS(e,"text-base64");if(t){var{contentType:r,body:i,estimatedSize:s}=t;if(0!==s){var o=JS(e,t),a=e.projectToken?function(e,t){if(!t||/[?&]token=/.test(e))return e;var n=e.includes("?")?"&":"?";return""+e+n+"token="+t}(o,e.projectToken):o;if(s<=$S)try{var l="string"==typeof i?new Blob([i],{type:r}):i;if("undefined"!=typeof navigator&&navigator.sendBeacon)if(navigator.sendBeacon(a,l))return}catch(e){}try{var c="string"==typeof i?new Blob([i],{type:r}):i,u=n({"Content-Type":r},e.headers||{});fetch(a,{method:e.method||"POST",headers:u,body:c,keepalive:s<$S}).catch(()=>{})}catch(e){}}}}}],ZS=e=>{var t,n;if(Eu())null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0});else{var r=e.transport||"fetch",i=YS.find(e=>e.name===r&&e.isAvailable())||YS.find(e=>e.isAvailable());if(!i)return cu().error("request","no available transport method"),void(null===(n=e.callback)||void 0===n||n.call(e,{statusCode:0}));i.method(e)}};class XS{constructor(e,t){var n,r,i,s;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(n=(null==t?void 0:t.flush_interval_ms)||3e3,r=250,i=5e3,s=3e3,"number"!=typeof n||isNaN(n)?s:Math.min(Math.max(n,r),i)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var r=e[t];this._sendRequest(n({},r,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var n in e){var r=e[n];r.events.forEach(e=>{var n=new Date(e.timestamp).getTime();e.$offset=Math.abs(n-t)}),this._sendRequest(r)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var n=t.batchKey||t.url;e[n]||(e[n]={url:t.url,events:[],batchKey:t.batchKey}),e[n].events.push(t.event)}),this._queue=[],e}}class QS{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,jc&&void 0!==Hc&&"onLine"in Hc&&(this._areWeOnline=Hc.onLine,Pu(jc,"online",()=>{this._areWeOnline=!0,this._flush()}),Pu(jc,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)cu().error("retry","request failed after 10 retries, giving up");else if(!Eu()){var n=function(e){var t=3e3*Math.pow(2,e),n=t/2,r=Math.min(18e5,t),i=(Math.random()-.5)*(r-n);return Math.ceil(r+i)}(t),r=Date.now()+n;this._queue.push({retryAt:r,request:e,retriesPerformedSoFar:t+1});var i="enqueued failed request for retry in "+Math.round(n/1e3)+"s";this._areWeOnline||(i+=" (browser is offline)"),cu().warn("retry",i),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var n=this;return t(function*(){try{var t=yield n._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&n.enqueue(e,0)}catch(t){n.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,n=Date.now(),r=[],i=[];this._queue.forEach(e=>{e.retryAt<n?i.push(e):r.push(e)}),this._queue=r,i.forEach(function(){var n=t(function*(t){var{request:n,retriesPerformedSoFar:r}=t;try{var i=yield e._sendRequest(n);200!==i.statusCode&&(i.statusCode<400||i.statusCode>=500)&&e.enqueue(n,r)}catch(t){e.enqueue(n,r)}});return function(e){return n.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){cu().error("retry","failed to send beacon on unload",e)}}),this._queue=[]}}var ek="vt_rate_limit";class tk{constructor(e){var t,n;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(n=e.eventsBurstLimit)&&void 0!==n?n:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,n,r,i;void 0===e&&(e=!1);var s=Date.now(),o=null!==(n=null===(t=this.persistence)||void 0===t?void 0:t.get(ek))&&void 0!==n?n:{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||e||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||e||null===(r=this.captureWarning)||void 0===r||r.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(i=this.persistence)||void 0===i||i.set(ek,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class nk{constructor(e){this._remoteConfig=null,this._initConfig=null,this._host=e}get config(){return this._remoteConfig}onApply(e){this._onApply=e}onLoad(e){this._onLoad=e}load(){var e,t=this._host.getConfig();if(t.token){if(this._initConfig||(this._initConfig=n({},t)),null===(e=t.bootstrap)||void 0===e?void 0:e.remoteConfig)return this._remoteConfig=t.bootstrap.remoteConfig,this._apply(this._remoteConfig),void this._fetch();var r=du(()=>jc.__VTILT_BOOTSTRAP__);if(null==r?void 0:r.remoteConfig)return this._remoteConfig=r.remoteConfig,this._apply(this._remoteConfig),void this._fetch();du(()=>{var e=localStorage.getItem(vb+"_"+t.token);e&&(this._remoteConfig=JSON.parse(e),this._apply(this._remoteConfig,!0))}),this._fetch()}}_fetch(){var e=this._host.getConfig();if(e.token)if(Eu())this._host.updateConfig({__remote_config_loaded:!0});else{var t=this._host.buildEndpointUrl("/api/d"),r=new AbortController,i=setTimeout(()=>r.abort(),3e3);(qc||fetch)(t,{method:"GET",signal:r.signal,headers:n({Accept:"application/json"},fu(e))}).then(e=>e.json()).then(t=>{var n;clearTimeout(i),Tu(),this._remoteConfig=t,du(()=>{localStorage.setItem(vb+"_"+e.token,JSON.stringify(t))}),this._apply(t),null===(n=this._onLoad)||void 0===n||n.call(this,t)}).catch(()=>{clearTimeout(i),Iu("config"),this._host.updateConfig({__remote_config_loaded:!0})})}}_apply(e,t){var r,i,s,o;void 0===t&&(t=!1);var a=this._initConfig||this._host.getConfig(),l={};for(var[,c]of this._host.featureManager.getDescriptors())if(c.remoteConfig&&c.configKey){var u=e[c.remoteConfig.key];u&&void 0===a[c.configKey]&&(l[c.configKey]=c.remoteConfig.map(u))}if(e.analytics&&!t&&(void 0!==e.analytics.capturePageview&&void 0===a.capture_pageview&&(l.capture_pageview=e.analytics.capturePageview),void 0!==e.analytics.capturePageleave&&void 0===a.capture_pageleave&&(l.capture_pageleave=!!e.analytics.capturePageleave),void 0!==e.analytics.capturePerformance&&void 0===a.capture_performance&&(l.capture_performance=e.analytics.capturePerformance),void 0===a.autocapture)){var d=e.analytics.autocapture,h=e.analytics.scrollDepthMilestones,p=e.analytics.scrollDepthPageleave;void 0!==d&&(l.autocapture=d&&(h||p)?{scroll_depth:n({},h?{milestones:!0}:{},p?{pageleave:!0}:{})}:d)}t||(l.__remote_config_loaded=!0),void 0!==(null===(r=e.privacy)||void 0===r?void 0:r.respectDnt)&&void 0===a.respect_dnt&&(l.respect_dnt=e.privacy.respectDnt),void 0!==(null===(i=e.privacy)||void 0===i?void 0:i.requireConsent)&&void 0===a.require_consent&&(l.require_consent=e.privacy.requireConsent),void 0!==e.autocapture_opt_out&&(l.autocapture_opt_out=e.autocapture_opt_out),void 0!==e.elementsChainAsString&&(l.elementsChainAsString=e.elementsChainAsString),(null===(s=e.diagnostics)||void 0===s?void 0:s.defaultLogLevel)&&cu().setLevelFromRemote(e.diagnostics.defaultLogLevel),Object.keys(l).length>0&&this._host.updateConfig(l),null===(o=this._onApply)||void 0===o||o.call(this,e)}}var rk=["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 ik(e,t){if(void 0===t&&(t=[]),!e)return!1;var n=e.toLowerCase();return[...rk,...t].some(e=>-1!==n.indexOf(e.toLowerCase()))}function sk(e,t){var n;if(void 0===t&&(t=[]),!e)return!1;var r=e.userAgent;if(r&&ik(r,t))return!0;try{var i=e.userAgentData;if(null===(n=null==i?void 0:i.brands)||void 0===n?void 0:n.some(e=>ik(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver}var ok=36e5;function ak(){var e,t,n;return null!==(n=null===(t=null===(e=null==jc?void 0:jc.performance)||void 0===e?void 0:e.now)||void 0===t?void 0:t.call(e))&&void 0!==n?n:Date.now()}class lk{constructor(){this._pageEnterPerf=ak(),this._lastCapturePerf=null,this._bootPerf=ak(),this._prevUrl="",this._prevPathname="",this._prevTitle="",this._leaveEmittedForPageKey=""}onAfterPageview(){var e=ak();this._pageEnterPerf=e,this._lastCapturePerf=e,this._leaveEmittedForPageKey="",Vc&&(this._prevUrl=Vc.href||"",this._prevPathname=Vc.pathname||""),zc&&(this._prevTitle=zc.title||"")}peekEngagementSinceLastCaptureMs(){var e,t=ak(),n=null!==(e=this._lastCapturePerf)&&void 0!==e?e:this._bootPerf,r=Math.round(t-n);return r<1&&(r=1),r>ok&&(r=ok),r}commitCaptureClock(){this._lastCapturePerf=ak()}_pageKey(){return this._prevUrl+"\0"+this._prevPathname}clearLeaveDedupe(){this._leaveEmittedForPageKey=""}tryCapturePageleave(e,t,n,r){if(function(e){var t=e.capture_pageleave;return!1!==t&&(!0===t||!1!==e.capture_pageview)}(e)){var i=this._pageKey();if((this._prevUrl||this._prevPathname)&&i&&this._leaveEmittedForPageKey!==i){this._leaveEmittedForPageKey=i;var s=ak(),o=Math.round(s-this._pageEnterPerf);o<1&&(o=1),o>ok&&(o=ok);var a={navigation_type:n,engagement_time_msec:o,[Lb]:this._prevUrl,[Nb]:this._prevPathname,[Db]:Math.round(o/1e3),[Ub]:this._prevPathname,[Bb]:this._prevUrl},l=this._prevUrl?function(e){try{return new URL(e).host}catch(e){return""}}(this._prevUrl):"";l&&(a.$host=l),this._prevTitle&&(a.title=this._prevTitle),r&&Object.assign(a,r),t(kb,a,{skip_engagement:!0})}}}}var ck=[xb,Ib,Tb,kb,Mb,Rb,Eb,Pb],uk=new Set([xb,Ib,Tb]),dk=new Set([kb,Pb,Mb,Rb,Eb]);class hk{constructor(e){this._set_once_properties_sent=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this._vt_person_id=null,this._pageLifecycle=new lk,this._host=e}setVtPersonId(e){this._vt_person_id=e}capture(e,t,r){var i,s,o;this._host.sessionManager.setSessionId();var a=this._host.getConfig();if(a.opt_out_useragent_filter||!sk(Hc,null!==(i=a.custom_blocked_useragents)&&void 0!==i?i:[]))if((null==Hc?void 0:Hc.userAgent)&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(Hc.userAgent))if((null==r?void 0:r.skip_client_rate_limiting)||ck.includes(e)||this._host.rateLimiter.shouldAllowEvent())if(!this._host.getConfig().require_consent||uk.has(e)||(null===(s=this._host.consentManager)||void 0===s?void 0:s.hasConsent())){var l=this._host.buildUrl(),c=!0===(null==r?void 0:r.skip_engagement)||dk.has(e),u=n({},t);c||"number"==typeof u.engagement_time_msec||(u=n({},u,{engagement_time_msec:this._pageLifecycle.peekEngagementSinceLastCaptureMs()}));var d=n({},this._buildEventPayload(e,u),a.globalAttributes),h=JSON.stringify(d);if(!(p=h)||"string"!=typeof p||p.length<2||p.length>Mu)cu().debug("capture","dropped",e,{reason:"payload_invalid_size",bytes:h.length,limitBytes:Mu,hint:e===Ab?"Trim global / event properties; $elements is already off by default in compact mode.":"Trim event properties; payload exceeded the runaway-guard cap."});else{var p,f=e===xb?this._host.userManager.getAnonymousId():null!==(o=this._host.userManager.getDistinctId())&&void 0!==o?o:this._host.userManager.getAnonymousId(),v={timestamp:(new Date).toISOString(),event:e,payload:d,distinct_id:f,anonymous_id:this._host.userManager.getAnonymousId()};this._host.bufferEvent(e,l,v),cu().debug("capture","enqueued",e,n({distinct_id:f,$current_url:d.$current_url,$session_id:d.$session_id,$debug:d.$debug},e===Ab&&"object"==typeof d&&null!==d?{$event_type:d.$event_type}:{})),this._vt_person_id&&(this._vt_person_id=null),e===Sb?this._pageLifecycle.onAfterPageview():this._pageLifecycle.commitCaptureClock()}}else cu().debug("capture","dropped",e,{reason:"require_consent_and_no_consent"});else cu().debug("capture","dropped",e,{reason:"client_rate_limited",hint:"Token bucket (~10/s, burst ~100). $autocapture counts toward the same limit as custom events."});else cu().debug("capture","dropped",e,{reason:"invalid_or_missing_user_agent"});else cu().debug("capture","dropped",e,{reason:"bot"})}captureInternal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}captureInitialPageview(){zc&&("visible"===zc.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{zc&&Vc&&!1!==this._host.getConfig().capture_pageview&&this.capture(Sb,{navigation_type:"initial_load"})},300),this._visibility_state_listener&&(zc.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>this.captureInitialPageview(),Pu(zc,"visibilitychange",this._visibility_state_listener)))}tryCapturePageleave(e,t){this._pageLifecycle.tryCapturePageleave(this._host.getConfig(),(e,t,n)=>this.capture(e,t,n),e,t)}resetPageleaveDedupe(){this._pageLifecycle.clearLeaveDedupe()}_isDebugMode(){if(this._host.getConfig().debug)return!0;try{if(null==Vc?void 0:Vc.search)if("1"===new URLSearchParams(Vc.search).get("vtilt_debug"))return!0}catch(e){}return!1}_buildEventPayload(e,t){var r,i,s=this._host.getConfig(),o=s.mask_personal_data_properties,a=s.custom_personal_data_properties,l=mC(o,a),c=Du(function(e,t,n){if(!zc)return{};var r=t?Nu([],oC,n||[]):[];return Lu({},cC(ew(zc.URL,r,lC)))}(0,o,a)),u=this._host.userManager.getUserProperties(),d=this._host.userManager.get_initial_props(),h=this._host.sessionManager.getSessionId(),p=this._host.sessionManager.getWindowId(),f={};!this._set_once_properties_sent&&Object.keys(d).length>0&&Object.assign(f,d),t.$set_once&&Object.assign(f,t.$set_once);var v=n({},l,c,u,null!==(i=null===(r=this._host.consentManager)||void 0===r?void 0:r.getConsentProperties())&&void 0!==i?i:{},{$session_id:h,$window_id:p},this._vt_person_id?{$vt:this._vt_person_id}:{},Object.keys(f).length>0?{$set_once:f}:{},t.$set?{$set:t.$set}:{},t);!this._set_once_properties_sent&&Object.keys(d).length>0&&(this._set_once_properties_sent=!0),e===Sb&&zc&&(v.title=zc.title),this._isDebugMode()&&(v.$debug=!0);var g=this._host.sessionManager.consumeSessionStart(),m=this._host.userManager.consumeFirstVisit();return g&&(v.$session_start=!0),m&&(v.$first_visit=!0),v}}var pk=["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"];function fk(e){return!(!e||"string"!=typeof e)&&pk.includes(e.toLowerCase().trim())}class vk{constructor(e){this._lastIdentifyHash=null,this._lastSetPropertiesHash=null,this._host=e}identify(e,t,r){var i;if("number"==typeof e&&(e=String(e),cu().warn("identify","first argument should be a string, not a number")),e)if(fk(e))cu().error("identify",'"'+e+'" appears to be a hardcoded string');else if("COOKIELESS_SENTINEL_VALUE"!==e){var s=JSON.stringify([e,t,r]);if(this._lastIdentifyHash!==s){var o=this._host.userManager,a=o.getDistinctId(),l=o.getAnonymousId(),c=o.getDeviceId();if(!("identified"===o.getUserState())&&l!==e||e!==a){this._host.capture(xb,{distinct_id:e,$set:t||{},$set_once:r||{}});var u={user_state:"identified",distinct_id:e,properties_set:t,properties_set_once:r};if(!c){var d=a||l;u.device_id=d,u.properties_set=n({$had_persisted_distinct_id:!0,$device_id:d},u.properties_set||{})}o.applyUpdate(u),null===(i=this._host._emitter)||void 0===i||i.emit("user:identified",{distinctId:e})}else(t||r)&&this.setUserProperties(t,r);this._lastIdentifyHash=s}}else cu().error("identify","cannot use sentinel value as distinct_id");else cu().error("identify","unique user id is required")}setUserProperties(e,t){var n,r;if(e||t){var i=this._host.userManager,s=JSON.stringify([null!==(n=i.getDistinctId())&&void 0!==n?n:i.getAnonymousId(),e,t]);this._lastSetPropertiesHash!==s&&(i.applyUpdate({properties_set:e,properties_set_once:t}),this._host.capture(Tb,{$set:e||{},$set_once:t||{}}),null===(r=this._host._emitter)||void 0===r||r.emit("user:properties_set",{properties:e}),this._lastSetPropertiesHash=s)}}resetUser(e){var t;this._host.sessionManager.resetSessionId(),this._host.userManager.reset(e),this._lastIdentifyHash=null,this._lastSetPropertiesHash=null,null===(t=this._host._emitter)||void 0===t||t.emit("user:reset")}alias(e,t){var n;if(e&&!fk(e)){var r=this._host.userManager,i=null!==(n=null!=t?t:r.getDistinctId())&&void 0!==n?n:r.getAnonymousId();i&&!fk(i)?e!==i?this._host.capture(Ib,{$original_id:i,$alias_id:e}):this.identify(e):cu().warn("alias","invalid original distinct ID")}else cu().warn("alias","invalid alias")}getUserIdentity(){return this._host.userManager.getUserIdentity()}getDeviceId(){return this._host.userManager.getDeviceId()}getUserState(){return this._host.userManager.getUserState()}getDistinctId(){var e;return null!==(e=this._host.userManager.getDistinctId())&&void 0!==e?e:this._host.userManager.getAnonymousId()}getAnonymousId(){return this._host.userManager.getAnonymousId()}}var gk="_vtilt_consent";class mk{constructor(e){this._state={},this._hasBeenSet=!1,this._host=e,this._readFromCookie()}setConsent(e){var t;this._state=n({},this._state,e),this._hasBeenSet=!0,this._writeToCookie(),null===(t=this._host._emitter)||void 0===t||t.emit("consent:updated",{consent:this._state})}getConsent(){return n({},this._state)}hasConsent(){return this._hasBeenSet}setDefaultGranted(){this._hasBeenSet||(this._state={analytics:!0,marketing:!0,advertising:!0},this._hasBeenSet=!0)}getConsentProperties(){var e={};return void 0!==this._state.analytics&&(e.$consent_analytics=this._state.analytics),void 0!==this._state.marketing&&(e.$consent_marketing=this._state.marketing),void 0!==this._state.advertising&&(e.$consent_advertising=this._state.advertising),e}reset(){this._state={},this._hasBeenSet=!1,this._removeCookie()}_readFromCookie(){if(void 0!==zc&&(null==zc?void 0:zc.cookie)){var e=gk+"=";for(var t of zc.cookie.split(";")){var n=t.trim();if(n.startsWith(e)){try{var r=decodeURIComponent(n.slice(15)),i=JSON.parse(r);i&&"object"==typeof i&&(this._state=i,this._hasBeenSet=!0)}catch(e){}return}}}}_writeToCookie(){if(void 0!==zc){var e=encodeURIComponent(JSON.stringify(this._state)),t="undefined"!=typeof location&&"https:"===location.protocol?"; Secure":"";zc.cookie=gk+"="+e+"; Max-Age=31536000; path=/; SameSite=Lax"+t}}_removeCookie(){void 0!==zc&&(zc.cookie=gk+"=; Max-Age=0; path=/")}}class _k{constructor(e){this._descriptors=new Map,this._instances=new Map,this._host=e}register(e){this._descriptors.set(e.name,e)}createInstances(){var e=this,t=this._host.getConfig(),n=function(n,r){return e._instances.has(n)||e._isHardDisabled(t,r)?0:void du(()=>{var i=r.FeatureClass.extractConfig(t),s=new r.FeatureClass(e._host,i);e._instances.set(n,s)})};for(var[r,i]of this._descriptors)n(r,i)}initAll(){this.createInstances();var e=function(e){du(()=>{e.isStarted||e.startIfEnabled()})};for(var[,t]of this._instances)e(t)}notifyAll(e){var t=function(t){t.onConfigUpdate&&du(()=>t.onConfigUpdate(e))};for(var[,n]of this._instances)t(n)}get(e){return this._instances.get(e)}set(e,t){this._instances.set(e,t)}getDescriptors(){return this._descriptors}_isHardDisabled(e,t){if(t.disableKey&&!0===e[t.disableKey])return!0;if(t.configKey){var n=e[t.configKey];if(n&&"object"==typeof n&&!1===n.enabled)return!0}return!1}}class yk{constructor(e){this._queue=new FS,this._ready=!1,this._configReady=!1,this._host=e,this._checkReady(),this._ready||(this._safetyTimer=setTimeout(()=>this.forceFlush(),5e3))}push(e){this._ready?this._process(e):this._queue.enqueue(e)}markConfigReady(){this._configReady||(this._configReady=!0,this._tryFlush())}forceFlush(){this._clearSafetyTimer(),this._flush(),this._ready=!0}_checkReady(){this._ready=this._configReady}_tryFlush(){this._checkReady(),this._ready&&(this._clearSafetyTimer(),this._flush())}_flush(){var e=this._queue.takeAll();for(var t of e)this._process(t);e.length>0&&this._host.requestQueue.flush()}_process(e){if(this._configReady){if(this._isDisabledByConfig(e.name))return}else this._tagConfigPending(e.event);this._host.sendRequest(e.url,e.event)}_isDisabledByConfig(e){var t=this._host.getConfig();switch(e){case Sb:return!1===t.capture_pageview;case kb:return!1===t.capture_pageleave;case Eb:return!1===t.capture_performance;case Ab:case Ob:return!1===t.autocapture;default:return!1}}_tagConfigPending(e){"object"==typeof e.payload&&null!==e.payload&&(e.payload.$config_pending=!0)}_clearSafetyTimer(){void 0!==this._safetyTimer&&(clearTimeout(this._safetyTimer),this._safetyTimer=void 0)}}var bk="vt";class wk{constructor(e){void 0===e&&(e={}),this.version=lb,this.__loaded=!1,this._has_warned_about_config=!1,this._booted=!1,this._pendingCalls=[],this._postBootInitDone=!1,cu().debug("ctor","start"),this._emitter=new vu,this.configManager=new zb(e);var t=this.configManager.getConfig();uu(t),this.sessionManager=new Kb(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new _C(t.persistence||"localStorage+cookie",t.cross_subdomain_cookie),this.rateLimiter=new tk({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._captureManager.captureInternal(Pb,{$$client_ingestion_warning_message:e})}}),this.retryQueue=new QS({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new XS(e=>this._send_batched_request(e),{flush_interval_ms:3e3}),this.consentManager=new mk(this),this._captureManager=new hk(this),this._identityManager=new vk(this),this._featureManager=new _k(this),this._remoteConfigManager=new nk(this),this._registerFeatures(),this._remoteConfigManager.onLoad(e=>{this._emitter.emit(_u,{config:e})}),this._installBootGate(),cu().debug("ctor","boot gate installed")}_registerFeatures(){this._featureManager.register({name:"HistoryAutocapture",configKey:"capture_pageview",FeatureClass:IC}),this._featureManager.register({name:"Autocapture",configKey:"autocapture",FeatureClass:gS}),this._featureManager.register({name:"WebVitals",configKey:"capture_performance",FeatureClass:kC}),this._featureManager.register({name:"SessionRecording",configKey:"session_recording",disableKey:"disable_session_recording",remoteConfig:{key:"sessionRecording",map:e=>({enabled:e.enabled,sampleRate:e.sampleRate,minimumDurationMs:e.minimumDurationMs,fullSnapshotIntervalMs:e.fullSnapshotIntervalMs,maskAllInputs:e.maskAllInputs,captureConsole:e.captureConsole,captureCanvas:e.captureCanvas})},FeatureClass:_S}),this._featureManager.register({name:"Chat",configKey:"chat",disableKey:"disable_chat",remoteConfig:{key:"chat",map:e=>({enabled:e.enabled,position:e.widgetPosition,color:e.widgetColor})},FeatureClass:bS}),this._featureManager.register({name:"GoogleTagGateway",configKey:"google_tag",disableKey:"disable_google_tag",remoteConfig:{key:"googleTag",map:e=>e},FeatureClass:WS})}_installBootGate(){var e=this,t=function(t){var n=e[t];e[t]=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];if(e._booted)return n.apply(e,i);e._pendingCalls.push([t,...i])}};for(var n of wk.BOOT_GATED_METHODS)t(n)}_boot(){if(!this._booted){for(var e of(this._booted=!0,cu().debug("boot","start"),wk.BOOT_GATED_METHODS))delete this[e];cu().debug("boot","gate removed"),this.__loaded&&!this._postBootInitDone?(cu().debug("boot","running _runPostBootInit"),this._runPostBootInit()):cu().debug("boot","skipping _runPostBootInit","loaded?",this.__loaded,"postBootDone?",this._postBootInitDone),cu().debug("boot","flush pendingCalls",this._pendingCalls.length),this._execute_array(this._pendingCalls),this._pendingCalls=[]}}init(e,t,n){var r;if(n&&n!==bk){var i=null!==(r=kk[n])&&void 0!==r?r:new wk;return i._init(e,t,n),kk[n]=i,kk[bk][n]=i,i}return this._init(e,t,n)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return cu().warn("init","already initialized; re-initializing is a no-op"),this;this.configManager.updateConfig(n({},t,{token:e||t.token,name:r}));var i=this.configManager.getConfig();return uu(i),this.__loaded=!0,cu().debug("init","start","token present?",!!i.token,"name",null!=r?r:"vt"),this._featureManager.createInstances(),this._booted||void 0===zc||"interactive"!==zc.readyState&&"complete"!==zc.readyState||(cu().debug("init","self-boot?",zc.readyState),this._boot()),this._booted&&!this._postBootInitDone&&this._runPostBootInit(),cu().debug("init","postBootInitDone",this._postBootInitDone),this}_runPostBootInit(){if(!this._postBootInitDone){this._postBootInitDone=!0,cu().debug("postBoot","start");var e=this.configManager.getConfig();this.sessionManager=new Kb(e.storage||"cookie",e.cross_subdomain_cookie),this.sessionManager.hydrateFromStorage(),cu().debug("postBoot","sessionManager hydrated");var t=e.persistence||"localStorage+cookie";this.userManager.updateStorageMethod(t,e.cross_subdomain_cookie),this.userManager.hydrateFromStorage(),cu().debug("postBoot","userManager hydrated"),e.require_consent||this.consentManager.hasConsent()||this.consentManager.setDefaultGranted(),!0===this.consentManager.getConsent().advertising&&sw(),this._emitter.on("consent:updated",e=>{var t=e.consent;!0===t.advertising?sw():!1===t.advertising&&void 0!==zc&&(zc.cookie=tw+"=; Max-Age=0; path=/",zc.cookie=nw+"=; Max-Age=0; path=/")}),this._read_vt_param_from_url(),this.userManager.set_initial_person_info(e.mask_personal_data_properties,e.custom_personal_data_properties),this._eventBuffer=new yk({sendRequest:(e,t)=>this.sendRequest(e,t),requestQueue:this.requestQueue,getConfig:()=>this.configManager.getConfig()}),this._featureManager.initAll(),cu().debug("postBoot","features inited"),this._remoteConfigManager.load(),this._setup_unload_handler(),this._start_queue_if_opted_in();var n=this.configManager.getConfig();!1!==n.capture_pageview&&this._captureManager.captureInitialPageview(),this._featureManager.notifyAll(n),this._emitter.emit(gu,{config:n}),cu().debug("postBoot","done"),cu().info("init","SDK ready")}}startAutocapture(){var e=this._featureManager.get("Autocapture");if(!e){var t=gS.extractConfig(this.configManager.getConfig());e=new gS(this,t),this._featureManager.set("Autocapture",e)}e.updateConfig({enabled:!0})}stopAutocapture(){var e=this._featureManager.get("Autocapture");e&&e.updateConfig({enabled:!1})}isAutocaptureActive(){var e,t;return null!==(t=null===(e=this._featureManager.get("Autocapture"))||void 0===e?void 0:e.isStarted)&&void 0!==t&&t}getAutocaptureDiagnostics(){var e,t;return null!==(t=null===(e=this._featureManager.get("Autocapture"))||void 0===e?void 0:e.getDiagnostics())&&void 0!==t?t:null}startSessionRecording(){var e=this._featureManager.get("SessionRecording");e||(e=new _S(this),this._featureManager.set("SessionRecording",e)),e.updateConfig({enabled:!0}),e.startIfEnabledOrStop("recording_initialized"),this._emitter.emit(wu)}stopSessionRecording(){var e;null===(e=this._featureManager.get("SessionRecording"))||void 0===e||e.stop(),this._emitter.emit(Cu)}isRecordingActive(){var e;return"active"===(null===(e=this._featureManager.get("SessionRecording"))||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this._featureManager.get("SessionRecording"))||void 0===e?void 0:e.sessionId)||null}openChat(){var e=this._featureManager.get("Chat");e?e.open():cu().warn("chat","openChat: feature not available")}closeChat(){var e=this._featureManager.get("Chat");e?e.close():cu().warn("chat","closeChat: feature not available")}toggleChat(){var e=this._featureManager.get("Chat");e?e.toggle():cu().warn("chat","toggleChat: feature not available")}showChat(){var e=this._featureManager.get("Chat");e?e.show():cu().warn("chat","showChat: feature not available")}hideChat(){var e=this._featureManager.get("Chat");e?e.hide():cu().warn("chat","hideChat: feature not available")}sendChatMessage(e,t){var n=this._featureManager.get("Chat");return n?n.sendMessage(e,t):(cu().warn("chat","sendChatMessage: feature not available"),Promise.resolve())}gtag(){for(var e=this._featureManager.get("GoogleTagGateway"),t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];e?e.gtag(...n):this._pendingCalls.push(["gtag",...n])}setGoogleUserData(e){var t=this._featureManager.get("GoogleTagGateway");return t?t.setUserData(e):Promise.resolve()}get featureManager(){return this._featureManager}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}off(e){this._emitter.off(e)}_is_bot(){var e,t=this.getConfig();return!t.opt_out_useragent_filter&&sk(Hc,null!==(e=t.custom_blocked_useragents)&&void 0!==e?e:[])}capture(e,t,n){this._captureManager.capture(e,t,n),this._emitter.emit(bu,{event:e,payload:t})}tryCapturePageleave(e){var t,n=null===(t=this._featureManager.get("Autocapture"))||void 0===t?void 0:t.getMaxScrollDepthPctForPageleave(),r=null!=n?{[Wb]:n}:void 0;this._captureManager.tryCapturePageleave(e,r)}identify(e,t,n){this._identityManager.identify(e,t,n)}setUserProperties(e,t){this._identityManager.setUserProperties(e,t)}resetUser(e){this._identityManager.resetUser(e)}alias(e,t){this._identityManager.alias(e,t)}setConsent(e){this.consentManager.setConsent(e)}getConsent(){return this.consentManager.getConsent()}getUserIdentity(){return this._identityManager.getUserIdentity()}getDeviceId(){return this._identityManager.getDeviceId()}getUserState(){return this._identityManager.getUserState()}getConfig(){return this.configManager.getConfig()}getRemoteConfig(){return this._remoteConfigManager.config}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this._identityManager.getDistinctId()}getAnonymousId(){return this._identityManager.getAnonymousId()}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:bk;return t!==bk&&(t="vt."+t),t}updateConfig(e){var t,n=this.configManager.getConfig();this.configManager.updateConfig(e);var r=this.configManager.getConfig();!n.__remote_config_loaded&&r.__remote_config_loaded&&(null===(t=this._eventBuffer)||void 0===t||t.markConfigReady()),this._featureManager.notifyAll(r),this._emitter.emit(mu,{config:r})}buildUrl(){return this.buildEndpointUrl("/api/e")}buildEndpointUrl(e){return pu(this.configManager.getConfig(),e)}sendRequest(e,t){this._is_configured()&&this.requestQueue.enqueue({url:e,event:t})}bufferEvent(e,t,n){e!==Mb&&e!==Rb?this._eventBuffer.push({name:e,url:t,event:n}):this.sendRequest(t,n)}_is_configured(){return!!this.configManager.getConfig().token||(this._has_warned_about_config||(cu().warn("config","token is required for tracking"),this._has_warned_about_config=!0),!1)}_send_batched_request(e){"sendBeacon"!==e.transport?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:n,events:r}=e,i=this.configManager.getConfig(),s=1===r.length?r[0]:{events:r},o=i.disable_compression?VS.None:VS.GZipJS;ZS({url:n,data:s,method:"POST",transport:"XHR",compression:o,projectToken:i.token,callback:e=>t({statusCode:e.statusCode})})})}_send_beacon_request(e){var{url:t,events:n}=e,r=this.configManager.getConfig(),i=1===n.length?n[0]:{events:n},s=r.disable_compression?VS.None:VS.GZipJS;ZS({url:t,data:i,method:"POST",transport:"sendBeacon",compression:s,projectToken:r.token})}_send_retriable_request(e){this.sendRequest(e.url,e.event)}_setup_unload_handler(){if(jc){var e=()=>{this._eventBuffer.forceFlush(),this.requestQueue.unload(),this.retryQueue.unload()};Pu(jc,"beforeunload",e),Pu(jc,"pagehide",()=>{this._captureManager.tryCapturePageleave("pagehide"),e()}),zc&&Pu(zc,"visibilitychange",()=>{zc&&("hidden"===zc.visibilityState?this._captureManager.tryCapturePageleave("visibility_hidden"):"visible"===zc.visibilityState&&this._captureManager.resetPageleaveDedupe())})}}_start_queue_if_opted_in(){this.requestQueue.enable()}_read_vt_param_from_url(){du(()=>{var e,t;if(void 0!==Vc&&Vc.search){var n=new URL(Vc.href),r=n.searchParams.get("vt"),i=n.searchParams.get("vtd");if((null==r?void 0:r.trim())&&(this._captureManager.setVtPersonId(r.trim()),n.searchParams.delete("vt")),(null==i?void 0:i.trim())&&(this._initVtdOverlay(i.trim()),n.searchParams.delete("vtd")),(null==r?void 0:r.trim())||(null==i?void 0:i.trim())){var s=n.pathname+(n.search||"")+n.hash;null===(t=null===(e=null==jc?void 0:jc.history)||void 0===e?void 0:e.replaceState)||void 0===t||t.call(e,{},"",s)}}})}_initVtdOverlay(e){this.vtdOverlay||(this.vtdOverlay=new zS(this),this.vtdOverlay.setDestinationUrl(e))}_execute_array(e){Qc(e)&&e.forEach(e=>{if(e&&Qc(e)&&e.length>0){var t=e[0],n=e.slice(1);"function"==typeof this[t]&&du(()=>this[t](...n))}})}_dom_loaded(){this._start_queue_if_opted_in()}}wk.BOOT_GATED_METHODS=["capture","identify","setUserProperties","resetUser","alias","setConsent","startAutocapture","stopAutocapture","startSessionRecording","stopSessionRecording","openChat","closeChat","toggleChat","showChat","hideChat","sendChatMessage"];var Ck,Sk,kk={};Ck=kk[bk]=new wk,(Sk=Gc.vt)&&Ru(Sk._i,function(e){if(e&&Qc(e)){var t=Ck.init(e[0],e[1],e[2]),n=Sk[e[2]||"vt"]||Sk;t&&t._execute_array(n)}}),Gc.vt=Ck,function(){function e(){if(!e.done){e.done=!0,cu().debug("dom","handler fired");var t=Object.keys(kk);cu().debug("boot","instance count",t.length),Ru(kk,(e,t)=>{cu().debug("boot","instance",t),e._boot(),e._dom_loaded()})}}if(zc&&"function"==typeof zc.addEventListener)return cu().debug("dom","readyState",zc.readyState),void("complete"===zc.readyState||"interactive"===zc.readyState?(cu().debug("dom","running handler sync"),e()):(cu().debug("dom","registered DOMContentLoaded listener"),Pu(zc,"DOMContentLoaded",e,{capture:!1})));jc&&cu().error("dom","browser doesn't support document.addEventListener")}()}();
2
+ //# sourceMappingURL=array.full.chat.no-external.js.map