@dori-ai/dori-side-widget 1.13.184 → 1.13.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/widget.js +1 -1
- package/dist/widget.js.br +0 -0
- package/dist/widget.js.gz +0 -0
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/apply-CnbnshVa.js","./assets/report-BHr6U1PB.js","./assets/main-DtXI9PnM.js","./assets/provider-Hd-A5KNt.js","./assets/link-DAM_xeSY.js","./assets/mount-5SwUgqR8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
const e={},t=function(t,i,r){let n=Promise.resolve();if(i&&i.length>0){let t=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};const s=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");n=t(i.map(t=>{if(t=function(e,t){return new URL(e,t).href}(t,r),t in e)return;e[t]=!0;const i=t.endsWith(".css"),n=i?'[rel="stylesheet"]':"";if(r)for(let e=s.length-1;e>=0;e--){const r=s[e];if(r.href===t&&(!i||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${t}"]${n}`))return;const o=document.createElement("link");return o.rel=i?"stylesheet":"modulepreload",i||(o.as="script"),o.crossOrigin="",o.href=t,a&&o.setAttribute("nonce",a),document.head.appendChild(o),i?new Promise((e,i)=>{o.addEventListener("load",e),o.addEventListener("error",()=>i(new Error(`Unable to preload CSS for ${t}`)))}):void 0}))}function s(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return n.then(e=>{for(const t of e||[])"rejected"===t.status&&s(t.reason);return t().catch(s)})};let i=null;function r(e){let t=e.replace(/<thought>[\s\S]*?<\/thought>/gi,"");return t=t.replace(/<thought>[\s\S]*$/gi,""),t.trim()}const n=(e,t)=>{if(!e)return;const r=e.closest('[data-scroll-container="chat-messages"]');r&&null===i&&(i=setTimeout(()=>{i=null,t&&!t()||r.scrollTo({top:r.scrollHeight,behavior:"smooth"})},200))},s=(e,t,i=new Date)=>{const r=e?.feature_flags?.panel_greeting;return"string"==typeof r?r.trim():((e,t,i=new Date)=>{const r=e||"Dori";return`${i.getHours()>=18&&t.hiImEvening?t.hiImEvening:t.hiIm} ${r}!`})(e?.agent_name,t,i)};var o="undefined"!=typeof window?window:void 0,a="undefined"!=typeof globalThis?globalThis:o;"undefined"==typeof self&&(a.self=a),"undefined"==typeof File&&(a.File=function(){});var l=Array.prototype,c=l.forEach,u=l.indexOf,d=null==a?void 0:a.navigator,h=null==a?void 0:a.document,p=null==a?void 0:a.location,g=null==a?void 0:a.fetch,f=null!=a&&a.XMLHttpRequest&&"withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:void 0,_=null==a?void 0:a.AbortController,v=null==d?void 0:d.userAgent,m=null!=o?o:{},y={DEBUG:!1,LIB_VERSION:"1.343.2"};function w(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(c){return void i(c)}a.done?t(l):Promise.resolve(l).then(r,n)}function b(e){return function(){var t=this,i=arguments;return new Promise(function(r,n){var s=e.apply(t,i);function o(e){w(s,r,n,o,a,"next",e)}function a(e){w(s,r,n,o,a,"throw",e)}o(void 0)})}}function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},E.apply(null,arguments)}function S(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var k=["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"],x=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return k.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})},P=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function $(e,t){return-1!==e.indexOf(t)}var I=function(e){return e.trim()},T=function(e){return e.replace(/^\$/,"")},C=Array.isArray,F=Object.prototype,O=F.hasOwnProperty,R=F.toString,A=C||function(e){return"[object Array]"===R.call(e)},M=e=>"function"==typeof e,D=e=>e===Object(e)&&!A(e),L=e=>{if(D(e)){for(var t in e)if(O.call(e,t))return!1;return!0}return!1},N=e=>void 0===e,j=e=>"[object String]"==R.call(e),q=e=>j(e)&&0===e.trim().length,U=e=>null===e,H=e=>N(e)||U(e),W=e=>"[object Number]"==R.call(e)&&e==e,B=e=>W(e)&&e>0,z=e=>"[object Boolean]"===R.call(e),V=e=>$(P,e);function G(e){return null===e||"object"!=typeof e}function J(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function Y(e){return!N(Event)&&function(e,t){try{return e instanceof t}catch(i){return!1}}(e,Event)}var X=[!0,"true",1,"1","yes"],K=e=>$(X,e),Z=[!1,"false",0,"0","no"];function Q(e,t,i,r,n){return t>i&&(r.warn("min cannot be greater than max."),t=i),W(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),Q(n||i,t,i,r))}class ee{constructor(e){this.t={},this.i=e.i,this.o=Q(e.bucketSize,0,100,e.h),this.m=Q(e.refillRate,0,this.o,e.h),this.$=Q(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,r=Math.floor(i/this.$);if(r>0){var n=r*this.m;e.tokens=Math.min(e.tokens+n,this.o),e.lastAccess=e.lastAccess+r*this.$}}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.t[r];return n?this.S(n,i):(n={tokens:this.o,lastAccess:i},this.t[r]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null==(t=this.i)||t.call(this,e)),0===n.tokens)}stop(){this.t={}}}var te,ie,re,ne="Mobile",se="iOS",oe="Android",ae="Tablet",le=oe+" "+ae,ce="iPad",ue="Apple",de=ue+" Watch",he="Safari",pe="BlackBerry",ge="Samsung",fe=ge+"Browser",_e=ge+" Internet",ve="Chrome",me=ve+" OS",ye=ve+" "+se,we="Internet Explorer",be=we+" "+ne,Ee="Opera",Se=Ee+" Mini",ke="Edge",xe="Microsoft "+ke,Pe="Firefox",$e=Pe+" "+se,Ie="Nintendo",Te="PlayStation",Ce="Xbox",Fe=oe+" "+ne,Oe=ne+" "+he,Re="Windows",Ae=Re+" Phone",Me="Nokia",De="Ouya",Le="Generic",Ne=Le+" "+ne.toLowerCase(),je=Le+" "+ae.toLowerCase(),qe="Konqueror",Ue="(\\d+(\\.\\d+)?)",He=new RegExp("Version/"+Ue),We=new RegExp(Ce,"i"),Be=new RegExp(Te+" \\w+","i"),ze=new RegExp(Ie+" \\w+","i"),Ve=new RegExp(pe+"|PlayBook|BB10","i"),Ge={"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"},Je=function(e,t){return t=t||"",$(e," OPR/")&&$(e,"Mini")?Se:$(e," OPR/")?Ee:Ve.test(e)?pe:$(e,"IE"+ne)||$(e,"WPDesktop")?be:$(e,fe)?_e:$(e,ke)||$(e,"Edg/")?xe:$(e,"FBIOS")?"Facebook "+ne:$(e,"UCWEB")||$(e,"UCBrowser")?"UC Browser":$(e,"CriOS")?ye:$(e,"CrMo")||$(e,ve)?ve:$(e,oe)&&$(e,he)?Fe:$(e,"FxiOS")?$e:$(e.toLowerCase(),qe.toLowerCase())?qe:((e,t)=>{return t&&$(t,ue)||$(i=e,he)&&!$(i,ve)&&!$(i,oe);var i})(e,t)?$(e,ne)?Oe:he:$(e,Pe)?Pe:$(e,"MSIE")||$(e,"Trident/")?we:$(e,"Gecko")?Pe:""},Ye={[be]:[new RegExp("rv:"+Ue)],[xe]:[new RegExp(ke+"?\\/"+Ue)],[ve]:[new RegExp("("+ve+"|CrMo)\\/"+Ue)],[ye]:[new RegExp("CriOS\\/"+Ue)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ue)],[he]:[He],[Oe]:[He],[Ee]:[new RegExp("(Opera|OPR)\\/"+Ue)],[Pe]:[new RegExp(Pe+"\\/"+Ue)],[$e]:[new RegExp("FxiOS\\/"+Ue)],[qe]:[new RegExp("Konqueror[:/]?"+Ue,"i")],[pe]:[new RegExp(pe+" "+Ue),He],[Fe]:[new RegExp("android\\s"+Ue,"i")],[_e]:[new RegExp(fe+"\\/"+Ue)],[we]:[new RegExp("(rv:|MSIE )"+Ue)],Mozilla:[new RegExp("rv:"+Ue)]},Xe=function(e,t){var i=Je(e,t),r=Ye[i];if(N(r))return null;for(var n=0;n<r.length;n++){var s=r[n],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},Ke=[[new RegExp(Ce+"; "+Ce+" (.*?)[);]","i"),e=>[Ce,e&&e[1]||""]],[new RegExp(Ie,"i"),[Ie,""]],[new RegExp(Te,"i"),[Te,""]],[Ve,[pe,""]],[new RegExp(Re,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ae,""];if(new RegExp(ne).test(t)&&!/IEMobile\b/.test(t))return[Re+" "+ne,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=Ge[r]||"";return/arm/i.test(t)&&(n="RT"),[Re,n]}return[Re,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[se,t.join(".")]}return[se,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=N(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+oe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+oe+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[oe,t.join(".")]}return[oe,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[me,""]],[/Linux|debian/i,["Linux",""]]],Ze=function(e){return ze.test(e)?Ie:Be.test(e)?Te:We.test(e)?Ce:new RegExp(De,"i").test(e)?De:new RegExp("("+Ae+"|WPDesktop)","i").test(e)?Ae:/iPad/.test(e)?ce:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?de:Ve.test(e)?pe:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Me,"i").test(e)?Me:/(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(ne).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)?oe:le:new RegExp("(pda|"+ne+")","i").test(e)?Ne:new RegExp(ae,"i").test(e)&&!new RegExp(ae+" pc","i").test(e)?je:""},Qe=e=>e instanceof Error;function et(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return re&&i.length===ie||(ie=i.length,re=i.reduce((i,r)=>{te||(te={});var n=te[r];if(n)i[n[0]]=n[1];else for(var s=e(r),o=s.length-1;o>=0;o--){var a=s[o],l=null==a?void 0:a.filename,c=t[r];if(l&&c){i[l]=c,te[r]=[l,c];break}}return i},{})),re}}class tt{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),s=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(s,i),$exception_level:"error"}}modifyFrames(e){var t=this;return b(function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&A(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),E({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return b(function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i})()}convertToExceptionList(e,t){var i,r,n,s={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(s.stacktrace={type:"raw",frames:e.stack});var o=[s];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,E({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:et(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i){void 0===i&&(i=0);var r=(i,r)=>{if(r<=4){var n=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,n)}};return E({},t,{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,i),next:e=>r(e,i+1)})}}var it="?";function rt(e,t,i,r,n){var s={platform:e,filename:t,function:"<anonymous>"===i?it:i,in_app:!0};return N(r)||(s.lineno=r),N(n)||(s.colno=n),s}var nt=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:it,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},st=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ot=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,at=/\((\S*)(?::(\d+))(?::(\d+))\)/,lt=(e,t)=>{var i=st.exec(e);if(i){var[,r,n,s]=i;return rt(t,r,it,+n,+s)}var o=ot.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=at.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=nt(o[1]||it,o[2]);return rt(t,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},ct=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ut=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,dt=(e,t)=>{var i=ct.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ut.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var n=i[3],s=i[1]||it;return[s,n]=nt(s,n),rt(t,n,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},ht=/\(error: (.*)\)/;class pt{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=j(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return J(e,"DOMException")}isDOMError(e){return J(e,"DOMError")}}class gt{match(e){return e instanceof Error}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ft{constructor(){}match(e){return J(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var _t=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class vt{match(e){return"string"==typeof e}coerce(e,t){var i,[r,n]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=n?n:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(_t);return r&&(t=r[1],i=r[2]),[t,i]}}var mt=["fatal","error","warning","log","info","debug"];function yt(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(!(n.length>t))return r===i.length||n.length<=t?n:n.slice(0,t)+"..."}return""}class wt{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Y(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+yt(e)}isSeverityLevel(e){return j(e)&&!q(e)&&mt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Qe(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(i){return}}}class bt{match(e){return Y(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+yt(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Et{match(e){return G(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class St{match(e){return J(e,"PromiseRejectionEvent")}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return G(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(G(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(t){}return e}}var kt=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={k:function(t){if(o&&(y.DEBUG||m.POSTHOG_DEBUG||i)&&!N(o.console)&&o.console){for(var r=("__rrweb_original__"in o.console[t]?o.console[t].__rrweb_original__:o.console[t]),n=arguments.length,s=new Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];r(e,...s)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning:e=>{r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>kt(e+" "+t,i)};return r},xt=kt("[PostHog.js]"),Pt=xt.createLogger,$t=Pt("[ExternalScriptsLoader]"),It=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return $t.warn(t+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var r=null==h?void 0:h.querySelectorAll("script");if(r)for(var n,s=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:i()}:(e.addEventListener("load",t=>{e.__posthog_loading_callback_fired=!0,i(void 0,t)}),e.onerror=e=>i(e),{v:void 0})}},o=0;o<r.length;o++)if(n=s())return n.v;var a=()=>{if(!h)return i("document not found");var r=h.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,i(void 0,e)},r.onerror=e=>i(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");if("head"===e.config.external_scripts_inject_target)h.head.appendChild(r);else{var n,s=h.querySelectorAll("body > script");s.length>0?null==(n=s[0].parentNode)||n.insertBefore(r,s[0]):h.body.appendChild(r)}};null!=h&&h.body?a():null==h||h.addEventListener("DOMContentLoaded",a)};m.__PosthogExtensions__=m.__PosthogExtensions__||{},m.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var r="/static/"+t+".js?v="+e.version;if("remote-config"===t&&(r="/array/"+e.config.token+"/config.js"),"toolbar"===t){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}var s=e.requestRouter.endpointFor("assets",r);It(e,s,i)},m.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var r=e.requestRouter.endpointFor("api",t);It(e,r,i)};var Tt={};function Ct(e,t,i){if(A(e))if(c&&e.forEach===c)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,n=e.length;r<n;r++)if(r in e&&t.call(i,e[r],r)===Tt)return}function Ft(e,t,i){if(!H(e)){if(A(e))return Ct(e,t,i);if((e=>e instanceof FormData)(e)){for(var r of e.entries())if(t.call(i,r[1],r[0])===Tt)return}else for(var n in e)if(O.call(e,n)&&t.call(i,e[n],n)===Tt)return}}var Ot=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ct(i,function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])}),e},Rt=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ct(i,function(t){Ct(t,function(t){e.push(t)})}),e};function At(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Mt=function(e){try{return e()}catch(t){return}},Dt=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.apply(this,i)}catch(n){xt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),xt.critical(n)}}},Lt=function(e){var t={};return Ft(e,function(e,i){(j(e)&&e.length>0||W(e))&&(t[i]=e)}),t},Nt=["herokuapp.com","vercel.app","netlify.app"];function jt(e){var t=null==e?void 0:e.hostname;if(!j(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Nt)if(i===r)return!1;return!0}function qt(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Ut(e,t,i,r){var{capture:n=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:n,passive:s})}var Ht="$people_distinct_id",Wt="__alias",Bt="__timers",zt="$autocapture_disabled_server_side",Vt="$heatmaps_enabled_server_side",Gt="$exception_capture_enabled_server_side",Jt="$error_tracking_suppression_rules",Yt="$error_tracking_capture_extension_exceptions",Xt="$web_vitals_enabled_server_side",Kt="$dead_clicks_enabled_server_side",Zt="$product_tours_enabled_server_side",Qt="$web_vitals_allowed_metrics",ei="$session_recording_remote_config",ti="$sesid",ii="$session_is_sampled",ri="$enabled_feature_flags",ni="$early_access_features",si="$feature_flag_details",oi="$stored_person_properties",ai="$stored_group_properties",li="$surveys",ci="$flag_call_reported",ui="$user_state",di="$client_session_props",hi="$capture_rate_limit",pi="$initial_campaign_params",gi="$initial_referrer_info",fi="$initial_person_info",_i="$epp",vi="__POSTHOG_TOOLBAR__",mi="$posthog_cookieless",yi=[Ht,Wt,"__cmpns",Bt,"$session_recording_enabled_server_side",Vt,ti,ri,Jt,ui,ni,si,ai,oi,li,ci,di,hi,pi,gi,_i,fi,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function wi(e){return e instanceof Element&&(e.id===vi||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function bi(e){return!!e&&1===e.nodeType}function Ei(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Si(e){return!!e&&3===e.nodeType}function ki(e){return!!e&&11===e.nodeType}function xi(e){return e?I(e).split(/\s+/):[]}function Pi(e){var t=null==o?void 0:o.location.href;return!!(t&&e&&e.some(e=>t.match(e)))}function $i(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return xi(t)}function Ii(e){return H(e)?null:I(e).split(/(\s+)/).filter(e=>Vi(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ti(e){var t="";return Ni(e)&&!ji(e)&&e.childNodes&&e.childNodes.length&&Ft(e.childNodes,function(e){var i;Si(e)&&e.textContent&&(t+=null!==(i=Ii(e.textContent))&&void 0!==i?i:"")}),I(t)}function Ci(e){return N(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Fi=["a","button","form","input","select","textarea","label"];function Oi(e,t){if(N(t))return!0;var i,r=function(e){if(t.some(t=>e.matches(t)))return{v:!0}};for(var n of e)if(i=r(n))return i.v;return!1}function Ri(e){var t=e.parentNode;return!(!t||!bi(t))&&t}var Ai=["next","previous","prev",">","<"],Mi=[".ph-no-rageclick",".ph-no-capture"],Di=e=>!e||Ei(e,"html")||!bi(e),Li=(e,t)=>{if(!o||Di(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],n=e;n.parentNode&&!Ei(n,"body");)if(ki(n.parentNode))r.push(n.parentNode.host),n=n.parentNode.host;else{var s=Ri(n);if(!s)break;if(t||Fi.indexOf(s.tagName.toLowerCase())>-1)i=!0;else{var a=o.getComputedStyle(s);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(s),n=s}return{parentIsUsefulElement:i,targetElementList:r}};function Ni(e){for(var t=e;t.parentNode&&!Ei(t,"body");t=t.parentNode){var i=$i(t);if($(i,"ph-sensitive")||$(i,"ph-no-capture"))return!1}if($($i(e),"ph-include"))return!0;var r=e.type||"";if(j(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var n=e.name||e.id||"";return!j(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function ji(e){return!!(Ei(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ei(e,"select")||Ei(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var qi="(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})",Ui=new RegExp("^(?:"+qi+")$"),Hi=new RegExp(qi),Wi="\\d{3}-?\\d{2}-?\\d{4}",Bi=new RegExp("^("+Wi+")$"),zi=new RegExp("("+Wi+")");function Vi(e,t){if(void 0===t&&(t=!0),H(e))return!1;if(j(e)){if(e=I(e),(t?Ui:Hi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Bi:zi).test(e))return!1}return!0}function Gi(e){var t=Ti(e);return Vi(t=(t+" "+Ji(e)).trim())?t:""}function Ji(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Ft(e.childNodes,function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Ti(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Ji(e)).trim())}catch(n){xt.error("[AutoCapture]",n)}}),t}function Yi(e){return e.replace(/"|\\"/g,'\\"')}function Xi(e){var t=e.attr__class;return t?A(t)?t:xi(t):void 0}class Ki{constructor(e){this.disabled=!1===e;var t=D(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&i-r.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Zi=e=>{var t=null==h?void 0:h.createElement("a");return N(t)?null:(t.href=e,t)},Qi=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;n<r.length;n++){var s=r[n].split("=");if(s[0]===t){i=s;break}}if(!A(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(a){xt.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},er=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");A(h)&&(t.includes(h[0])?u.push(h[0]+"="+i):u.push(c[d]))}var p=l;return null!=a&&(p+="?"+u.join("&")),null!=s&&(p+="#"+s),p},tr=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ir="$copy_autocapture",rr=Pt("[AutoCapture]");function nr(e,t){return t.length>e?t.slice(0,e)+"...":t}function sr(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!bi(t));return t}class or{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Ki(e.config.rageclick),this.C=null}get R(){var e,t,i=D(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map(e=>new RegExp(e)),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),i}F(){if(this.isBrowserSupported()){if(o&&h){var e=e=>{e=e||(null==o?void 0:o.event);try{this.O(e)}catch(pr){rr.error("Failed to capture event",pr)}};if(Ut(h,"submit",e,{capture:!0}),Ut(h,"change",e,{capture:!0}),Ut(h,"click",e,{capture:!0}),this.R.capture_copied_text){var t=e=>{e=e||(null==o?void 0:o.event),this.O(e,ir)};Ut(h,"copy",t,{capture:!0}),Ut(h,"cut",t,{capture:!0})}}}else rr.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[zt]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return null==(t=this.C)||t.forEach(t=>{var r=null==h?void 0:h.querySelectorAll(t);null==r||r.forEach(r=>{e===r&&i.push(t)})}),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[zt],r=this.T;if(U(r)&&!z(i)&&!this.instance.M())return!1;var n=null!==(t=this.T)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}O(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=Ci(e);Si(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&function(e,t){if(!o||Di(e))return!1;var i,r,n;if(z(t)?(i=!!t&&Mi,r=void 0):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:Mi,r=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:s}=Li(e,!1);return!function(e,t){if(!1===e||N(e))return!1;var i;if(!0===e)i=Ai;else{if(!A(e))return!1;if(e.length>10)return xt.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(e=>{var{safeText:t,ariaLabel:r}=e;return i.some(e=>t.includes(e)||r.includes(e))})}(r,s.map(e=>{var t;return{safeText:Ti(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}}))&&!Oi(s,i)}(r,this.instance.config.rageclick)&&this.O(e,"$rageclick");var n=t===ir;if(r&&function(e,t,i,r,n){var s,a,l,c;if(void 0===i&&(i=void 0),!o||Di(e))return!1;if(null!=(s=i)&&s.url_allowlist&&!Pi(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Pi(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some(e=>t.type===e))return!1}var{parentIsUsefulElement:d,targetElementList:h}=Li(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(N(i))return!0;var r,n=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var s of e)if(r=n(s))return r.v;return!1}(h,i))return!1;if(!Oi(h,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var p=o.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var g=e.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Fi.indexOf(g)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this.R,n,n?["copy","cut"]:void 0)){var{props:s,explicitNoCapture:a}=function(e,t){for(var i,r,{e:n,maskAllElementAttributes:s,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!Ei(d,"body");)ki(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,p,g,f=[],_={},v=!1,m=!1;if(Ft(u,e=>{var t=Ni(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&Vi(v)&&v),$($i(e),"ph-no-capture")&&(m=!0),f.push(function(e,t,i,r){var n=e.tagName.toLowerCase(),s={tag_name:n};Fi.indexOf(n)>-1&&!i&&("a"===n.toLowerCase()||"button"===n.toLowerCase()?s.$el_text=nr(1024,Gi(e)):s.$el_text=nr(1024,Ti(e)));var o=$i(e);o.length>0&&(s.classes=o.filter(function(e){return""!==e})),Ft(e.attributes,function(i){var n;if((!ji(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Vi(i.value)&&(n=i.name,!j(n)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=i.value;"class"===i.name&&(o=xi(o).join(" ")),s["attr__"+i.name]=nr(1024,o)}});for(var a=1,l=1,c=e;c=sr(c);)a++,c.tagName===e.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}(e,s,a,l));var i=function(e){if(!Ni(e))return{};var t={};return Ft(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Vi(r)&&(t[i]=r)}}),t}(e);Ot(_,i)}),m)return{props:{},explicitNoCapture:m};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?f[0].$el_text=Gi(e):f[0].$el_text=Ti(e)),v){var y,w;f[0].attr__href=v;var b=null==(y=Zi(v))?void 0:y.host,S=null==o||null==(w=o.location)?void 0:w.host;b&&S&&b!==S&&(h=v)}return{props:Ot({$event_type:n.type,$ce_version:1},c?{}:{$elements:f},{$elements_chain:(g=f,p=g.map(e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Xi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return At(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,i]=e;return r.attributes[t]=i}),r}),p.map(e=>{var t,i,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var s=E({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),o={};return At(s).sort((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)}).forEach(e=>{var[t,i]=e;return o[Yi(t.toString())]=Yi(i.toString())}),(r+=":")+At(o).map(e=>{var[t,i]=e;return t+'="'+i+'"'}).join("")}).join(";"))},null!=(i=f[0])&&i.$el_text?{$el_text:null==(r=f[0])?void 0:r.$el_text}:{},h&&"click"===n.type?{$external_click_url:h}:{},_)}}(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(s.$element_selectors=l),t===ir){var c,u=Ii(null==o||null==(c=o.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;s.$selected_content=u,s.$copy_type=d}return this.instance.capture(t,s),!0}}}isBrowserSupported(){return M(null==h?void 0:h.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return W(e)&&isFinite(e)&&Math.floor(e)===e});var ar="0123456789abcdef";class lr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new lr(n)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+ar.charAt(this.bytes[t]>>>4)+ar.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new lr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class cr{constructor(){this.A=0,this.j=0,this.D=new hr}generate(){var e=this.generateOrAbort();if(N(e)){this.A=0;var t=this.generateOrAbort();if(N(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return lr.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}}var ur,dr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};o&&!N(o.crypto)&&crypto.getRandomValues&&(dr=e=>crypto.getRandomValues(e));class hr{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(dr(this.N),this.U=0),this.N[this.U++]}}var pr,gr=()=>fr().toString(),fr=()=>(ur||(ur=new cr)).generate(),_r="",vr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,mr={H:()=>!!h,B:function(e){xt.error("cookieStore error: "+e)},q:function(e){if(h){try{for(var t=e+"=",i=h.cookie.split(";").filter(e=>e.length),r=0;r<i.length;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(t))return decodeURIComponent(n.substring(t.length,n.length))}}catch(s){}return null}},W:function(e){var t;try{t=JSON.parse(mr.q(e))||{}}catch(i){}return t},G:function(e,t,i,r,n){if(h)try{var s="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=h),_r)return _r;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),n="dmn_chk_"+gr();!_r&&r--;){var s=i.slice(r).join("."),o=n+"=1;domain=."+s+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(n)&&(t.cookie=o+";max-age=0",_r=s)}return _r}(e);if(!i){var r=(n=e.match(vr))?n[0]:"";r!==i&&xt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}var n;return""}(h.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),s="; expires="+l.toUTCString()}n&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&xt.warn("cookieStore warning: large cookie, len="+c.length),h.cookie=c,c}catch(u){return}},V:function(e,t){if(null!=h&&h.cookie)try{mr.G(e,"",-1,t)}catch(i){return}}},yr=null,wr={H:function(){if(!U(yr))return yr;var e=!0;if(N(o))e=!1;else try{var t="__mplssupport__";wr.G(t,"xyz"),'"xyz"'!==wr.q(t)&&(e=!1),wr.V(t)}catch(pr){e=!1}return e||xt.error("localStorage unsupported; falling back to cookie store"),yr=e,e},B:function(e){xt.error("localStorage error: "+e)},q:function(e){try{return null==o?void 0:o.localStorage.getItem(e)}catch(pr){wr.B(pr)}return null},W:function(e){try{return JSON.parse(wr.q(e))||{}}catch(t){}return null},G:function(e,t){try{null==o||o.localStorage.setItem(e,JSON.stringify(t))}catch(pr){wr.B(pr)}},V:function(e){try{null==o||o.localStorage.removeItem(e)}catch(pr){wr.B(pr)}}},br=["$device_id","distinct_id",ti,ii,_i,fi],Er={},Sr={H:function(){return!0},B:function(e){xt.error("memoryStorage error: "+e)},q:function(e){return Er[e]||null},W:function(e){return Er[e]||null},G:function(e,t){Er[e]=t},V:function(e){delete Er[e]}},kr=null,xr={H:function(){if(!U(kr))return kr;if(kr=!0,N(o))kr=!1;else try{var e="__support__";xr.G(e,"xyz"),'"xyz"'!==xr.q(e)&&(kr=!1),xr.V(e)}catch(pr){kr=!1}return kr},B:function(e){xt.error("sessionStorage error: ",e)},q:function(e){try{return null==o?void 0:o.sessionStorage.getItem(e)}catch(pr){xr.B(pr)}return null},W:function(e){try{return JSON.parse(xr.q(e))||null}catch(t){}return null},G:function(e,t){try{null==o||o.sessionStorage.setItem(e,JSON.stringify(t))}catch(pr){xr.B(pr)}},V:function(e){try{null==o||o.sessionStorage.removeItem(e)}catch(pr){xr.B(pr)}}},Pr=((pr={})[pr.PENDING=-1]="PENDING",pr[pr.DENIED=0]="DENIED",pr[pr.GRANTED=1]="GRANTED",pr);class $r{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Pr.DENIED:this.K}isOptedOut(){return"always"===this.R.cookieless_mode||this.consent===Pr.DENIED||this.consent===Pr.PENDING&&(this.R.opt_out_capturing_by_default||"on_reject"===this.R.cookieless_mode)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Pr.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return K(e)?Pr.GRANTED:$(Z,e)?Pr.DENIED:Pr.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z="localStorage"===e?wr:mr;var t="localStorage"===e?mr:wr;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(K(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!qt([null==d?void 0:d.doNotTrack,null==d?void 0:d.msDoNotTrack,m.doNotTrack],e=>K(e))}}var Ir=Pt("[Dead Clicks]"),Tr=()=>!0,Cr=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Kt)),r=e.instance.config.capture_dead_clicks;return z(r)?r:!!D(r)||i};class Fr{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Kt]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Ir.error("failed to load script",t):e()})}et(){var e;if(h){if(!this.tt&&null!=(e=m.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=D(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=m.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(h),Ir.info("starting...")}}else Ir.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Ir.info("stopping..."))}}var Or=Pt("[ExceptionAutocapture]");class Rr{constructor(e){var t,i,r;this.rt=()=>{var e;if(o&&this.isEnabled&&null!=(e=m.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=m.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=m.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=m.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=t(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=i(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=r(this.captureException.bind(this)))}catch(pr){Or.error("failed to start",pr),this.ut()}}},this._instance=e,this.ht=!(null==(t=this._instance.persistence)||!t.props[Gt]),this.dt=new ee({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,h:Or}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return D(e)?t=E({},t,e):(N(e)?this.ht:e)&&(t=E({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Or.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return Or.error("failed to load script",t);e()})}ut(){var e,t,i;null==(e=this.st)||e.call(this),this.st=void 0,null==(t=this.nt)||t.call(this),this.nt=void 0,null==(i=this.ot)||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Gt]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this.dt.consumeRateLimit(r)?Or.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(e)}}function Ar(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return M(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(s){return()=>{}}}class Mr{constructor(e){var t;this._instance=e,this.ct=(null==o||null==(t=o.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(xt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,xt.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(o&&o.history){var i=this;null!=(e=o.history.pushState)&&e.__posthog_wrapped__||Ar(o.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._t("pushState")}),null!=(t=o.history.replaceState)&&t.__posthog_wrapped__||Ar(o.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._t("replaceState")}),this.bt()}}_t(e){try{var t,i=null==o||null==(t=o.location)?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(pr){xt.error("Error capturing "+e+" pageview",pr)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Ut(o,"popstate",e),this.ft=()=>{o&&o.removeEventListener("popstate",e)}}}}var Dr=Pt("[SegmentIntegration]"),Lr="posthog-js";function Nr(e,t){var{organization:i,projectId:r,prefix:n,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=void 0===t?{}:t;return t=>{var a,l,c,u,d;if("*"!==s&&!s.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(a=t.exception)?void 0:a.values)||[],g=p.map(e=>E({},e,{stacktrace:e.stacktrace?E({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>E({},e,{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null==(l=p[0])?void 0:l.value)||t.message,$exception_type:null==(c=p[0])?void 0:c.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(u=p[0])?void 0:u.value)||t.message,$sentry_exception_type:null==(d=p[0])?void 0:d.type,$sentry_tags:t.tags};return i&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+t.event_id),o&&e.exceptions.sendExceptionEvent(f),t}}class jr{constructor(e,t,i,r,n,s){this.name=Lr,this.setupOnce=function(o){o(Nr(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:null==s||s}))}}}var qr=null!=o&&o.location?tr(o.location.hash,"__posthog")||tr(location.hash,"state"):null,Ur="_postHogToolbarParams",Hr=Pt("[Toolbar]"),Wr=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Wr||{});class Br{constructor(e){this.instance=e}yt(e){m.ph_toolbar_state=e}wt(){var e;return null!==(e=m.ph_toolbar_state)&&void 0!==e?e:Wr.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!o||!h)return!1;e=null!=e?e:o.location,i=null!=i?i:o.history;try{if(!t){try{o.localStorage.setItem("test","test"),o.localStorage.removeItem("test")}catch(pr){return!1}t=null==o?void 0:o.localStorage}var r,n=qr||tr(e.hash,"__posthog")||tr(e.hash,"state"),s=n?Mt(()=>JSON.parse(atob(decodeURIComponent(n))))||Mt(()=>JSON.parse(decodeURIComponent(n))):null;return s&&"ph_authorize"===s.action?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?e.hash=s.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(Ur)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(pr){return!1}}xt(e){var t=m.ph_load_toolbar||m.ph_load_editor;!H(t)&&M(t)?t(e,this.instance):Hr.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==h||!h.getElementById(vi));if(!o||t)return!1;var i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=E({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(o.localStorage.setItem(Ur,JSON.stringify(E({},r,{source:void 0}))),this.wt()===Wr.LOADED)this.xt(r);else if(this.wt()===Wr.UNINITIALIZED){var n;this.yt(Wr.LOADING),null==(n=m.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return Hr.error("[Toolbar] Failed to load",e),void this.yt(Wr.UNINITIALIZED);this.yt(Wr.LOADED),this.xt(r)}),Ut(o,"turbolinks:load",()=>{this.yt(Wr.UNINITIALIZED),this.loadToolbar(r)})}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var zr=Pt("[TracingHeaders]");class Vr{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var e,t;N(this.$t)&&(null==(e=m.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),N(this.St)&&(null==(t=m.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return zr.error("failed to load script",t);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):(null==(e=this.$t)||e.call(this),null==(t=this.St)||t.call(this),this.$t=void 0,this.St=void 0)}}var Gr="https?://(.*)",Jr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Yr=Rt(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Jr),Xr="<masked>",Kr=["li_fat_id"];function Zr(e,t,i){if(!h)return{};var r,n=t?Rt([],Jr,i||[]):[],s=Qr(er(h.URL,n,Xr),e),o=(r={},Ft(Kr,function(e){var t=mr.q(e);r[e]=t||null}),r);return Ot(o,s)}function Qr(e,t){var i=Yr.concat(t||[]),r={};return Ft(i,function(t){var i=Qi(e,t);r[t]=i||null}),r}function en(e){var t,i=(t=e)?0===t.search(Gr+"google.([^/?]*)")?"google":0===t.search(Gr+"bing.com")?"bing":0===t.search(Gr+"yahoo.com")?"yahoo":0===t.search(Gr+"duckduckgo.com")?"duckduckgo":null:null,r="yahoo"!=i?"q":"p",n={};if(!U(i)){n.$search_engine=i;var s=h?Qi(h.referrer,r):"";s.length&&(n.ph_keyword=s)}return n}function tn(){return navigator.language||navigator.userLanguage}function rn(){return(null==h?void 0:h.referrer)||"$direct"}function nn(e,t){var i=e?Rt([],Jr,t||[]):[],r=null==p?void 0:p.href.substring(0,1e3);return{r:rn().substring(0,1e3),u:r?er(r,i,Xr):void 0}}function sn(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=Zi(i))?void 0:t.host};if(r){n.$current_url=r;var s=Zi(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=Qr(r);Ot(n,o)}if(i){var a=en(i);Ot(n,a)}return n}function on(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(pr){return}}function an(){try{return(new Date).getTimezoneOffset()}catch(pr){return}}var ln=Pt("[Web Vitals]"),cn=9e5;class un{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),0!==this.N.metrics.length&&(this._instance.capture("$web_vitals",this.N.metrics.reduce((e,t)=>E({},e,{["$web_vitals_"+t.name+"_event"]:E({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=e=>{var t,i=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(N(i))ln.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.Ct();N(r)||(H(null==e?void 0:e.name)||H(null==e?void 0:e.value)?ln.error("Invalid metric received",e):this.Rt&&e.value>=this.Rt?ln.error("Ignoring metric with value >= "+this.Rt,e):(this.N.url!==r&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),N(this.N.url)&&(this.N.url=r),this.N.firstMetricTimestamp=N(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.N.metrics.push(E({},e,{$current_url:r,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var e,t,i,r,n=m.__PosthogExtensions__;N(n)||N(n.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=n.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.It.bind(this)),this.P=!0):ln.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!(null==(t=this._instance.persistence)||!t.props[Xt]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=D(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return H(i)?(null==(t=this._instance.persistence)?void 0:t.props[Qt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return null!=e&&e}get Rt(){var e=D(this._instance.config.capture_performance)&&W(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:cn;return 0<e&&e<=6e4?cn:e}get isEnabled(){var e=null==p?void 0:p.protocol;if("http:"!==e&&"https:"!==e)return ln.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:z(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return z(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(ln.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=D(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=D(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xt]:t}),this._instance.persistence.register({[Qt]:i})),this.kt=t,this.startIfEnabled()}it(e){var t,i;if(null!=(t=m.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks)e();else{var r=this.useAttribution?"web-vitals-with-attribution":"web-vitals";null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,r,t=>{t?ln.error("failed to load script",t):e()})}}Ct(){var e=o?o.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,r=t?Rt([],Jr,i||[]):[];return er(e,r,Xr)}ln.error("Could not determine current URL")}}var dn=Pt("[Heatmaps]");function hn(e){return D(e)&&"clientX"in e&&"clientY"in e&&W(e.clientX)&&W(e.clientY)}class pn{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!(null==(t=this.instance.persistence)||!t.props[Vt]),this.rageclicks=new Ki(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return D(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return H(this.instance.config.capture_heatmaps)?H(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.P)return;dn.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval(null!==(e=this.Ft)&&void 0!==e?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Vt]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft="visible"===(null==h?void 0:h.visibilityState)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){o&&h&&(this.Nt=this.Lt.bind(this),Ut(o,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||(null==o?void 0:o.event)),Ut(h,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(null==o?void 0:o.event)),Ut(h,"mousemove",this.zt,{capture:!0}),this.Bt=new Fr(this.instance,Tr,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Ut(h,"visibilitychange",this.qt),this.P=!0)}At(){var e;o&&h&&(this.Nt&&o.removeEventListener("beforeunload",this.Nt),this.Ut&&h.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&h.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&h.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),null==(e=this.Bt)||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),s=function(e,t,i){for(var r=e;r&&bi(r)&&!Ei(r,"body");){if(r===i)return!1;if($(t,null==o?void 0:o.getComputedStyle(r).position))return!0;r=Ri(r)}return!1}(Ci(e),["fixed","sticky"],n);return{x:e.clientX+(s?0:r),y:e.clientY+(s?0:i),target_fixed:s,type:t}}Dt(e,t){var i;if(void 0===t&&(t="click"),!wi(e.target)&&hn(e)){var r=this.Gt(e,t);null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this.Vt(E({},r,{type:"rageclick"})),this.Vt(r)}}Ht(e){!wi(e.target)&&hn(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(o){var t=o.location.href,i=this.instance.config.mask_personal_data_properties,r=this.instance.config.custom_personal_data_properties,n=i?Rt([],Jr,r||[]):[],s=er(t,n,Xr);this.N=this.N||{},this.N[s]||(this.N[s]=[]),this.N[s].push(e)}}Lt(){this.N&&!L(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class gn{constructor(e){this.Jt=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(xt.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this.Jt)}destroy(){var e;null==(e=this.Xt)||e.call(this),this.Xt=void 0}doPageView(e,t){var i,r=this.Qt(e,t);return this.Kt={pathname:null!==(i=null==o?void 0:o.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.Qt(e,null==(t=this.Kt)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this.Kt)?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:s,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=n;if(!(N(s)||N(o)||N(a)||N(l)||N(c)||N(u))){s=Math.ceil(s),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=s<=1?1:Q(o/s,0,1,xt),h=s<=1?1:Q(a/s,0,1,xt),p=l<=1?1:Q(c/l,0,1,xt),g=l<=1?1:Q(u/l,0,1,xt);r=Ot(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:g})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var fn=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),_n=Uint8Array,vn=Uint16Array,mn=Uint32Array,yn=new _n([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]),wn=new _n([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]),bn=new _n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),En=function(e,t){for(var i=new vn(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new mn(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return[i,n]},Sn=En(yn,2),kn=Sn[0],xn=Sn[1];kn[28]=258,xn[258]=28;for(var Pn=En(wn,0)[1],$n=new vn(32768),In=0;In<32768;++In){var Tn=(43690&In)>>>1|(21845&In)<<1;Tn=(61680&(Tn=(52428&Tn)>>>2|(13107&Tn)<<2))>>>4|(3855&Tn)<<4,$n[In]=((65280&Tn)>>>8|(255&Tn)<<8)>>>1}var Cn=function(e,t,i){for(var r=e.length,n=0,s=new vn(t);n<r;++n)++s[e[n]-1];var o,a=new vn(t);for(n=0;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;for(o=new vn(r),n=0;n<r;++n)o[n]=$n[a[e[n]-1]++]>>>15-e[n];return o},Fn=new _n(288);for(In=0;In<144;++In)Fn[In]=8;for(In=144;In<256;++In)Fn[In]=9;for(In=256;In<280;++In)Fn[In]=7;for(In=280;In<288;++In)Fn[In]=8;var On=new _n(32);for(In=0;In<32;++In)On[In]=5;var Rn=Cn(Fn,9),An=Cn(On,5),Mn=function(e){return(e/8|0)+(7&e&&1)},Dn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof vn?vn:e instanceof mn?mn:_n)(i-t);return r.set(e.subarray(t,i)),r},Ln=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8},Nn=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},jn=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return[new _n(0),0];if(1==n){var o=new _n(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(r=1;r<n;++r)s[r].s>h&&(h=s[r].s);var p=new vn(h+1),g=qn(i[u-1],p,0);if(g>t){r=0;var f=0,_=g-t,v=1<<_;for(s.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(p[m]>t))break;f+=v-(1<<g-p[m]),p[m]=t}for(f>>>=_;f>0;){var y=s[r].s;p[y]<t?f-=1<<t-p[y]++-1:++r}for(;r>=0&&f;--r){var w=s[r].s;p[w]==t&&(--p[w],++f)}g=t}return[new _n(p),g]},qn=function(e,t,i){return-1==e.s?Math.max(qn(e.l,t,i+1),qn(e.r,t,i+1)):t[e.s]=i},Un=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new vn(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&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(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return[i.subarray(0,r),t]},Hn=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},Wn=function(e,t,i){var r=i.length,n=Mn(t+2);e[n]=255&r,e[n+1]=r>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s<r;++s)e[n+s+4]=i[s];return 8*(n+4+r)},Bn=function(e,t,i,r,n,s,o,a,l,c,u){Ln(t,u++,i),++n[256];for(var d=jn(n,15),h=d[0],p=d[1],g=jn(s,15),f=g[0],_=g[1],v=Un(h),m=v[0],y=v[1],w=Un(f),b=w[0],E=w[1],S=new vn(19),k=0;k<m.length;++k)S[31&m[k]]++;for(k=0;k<b.length;++k)S[31&b[k]]++;for(var x=jn(S,7),P=x[0],$=x[1],I=19;I>4&&!P[bn[I-1]];--I);var T,C,F,O,R=c+5<<3,A=Hn(n,Fn)+Hn(s,On)+o,M=Hn(n,h)+Hn(s,f)+o+14+3*I+Hn(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(R<=A&&R<=M)return Wn(t,u,e.subarray(l,l+c));if(Ln(t,u,1+(M<A)),u+=2,M<A){T=Cn(h,p),C=h,F=Cn(f,_),O=f;var D=Cn(P,$);for(Ln(t,u,y-257),Ln(t,u+5,E-1),Ln(t,u+10,I-4),u+=14,k=0;k<I;++k)Ln(t,u+3*k,P[bn[k]]);u+=3*I;for(var L=[m,b],N=0;N<2;++N){var j=L[N];for(k=0;k<j.length;++k){var q=31&j[k];Ln(t,u,D[q]),u+=P[q],q>15&&(Ln(t,u,j[k]>>>5&127),u+=j[k]>>>12)}}}else T=Rn,C=Fn,F=An,O=On;for(k=0;k<a;++k)if(r[k]>255){q=r[k]>>>18&31,Nn(t,u,T[q+257]),u+=C[q+257],q>7&&(Ln(t,u,r[k]>>>23&31),u+=yn[q]);var U=31&r[k];Nn(t,u,F[U]),u+=O[U],U>3&&(Nn(t,u,r[k]>>>5&8191),u+=wn[U])}else Nn(t,u,T[r[k]]),u+=C[r[k]];return Nn(t,u,T[256]),u+C[256]},zn=new mn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vn=function(){for(var e=new mn(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Gn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};var Jn=!!f||!!g,Yn="text/plain",Xn=function(e,t,i){var r;void 0===i&&(i=!0);var[n,s]=e.split("?"),o=E({},t),a=null!==(r=null==s?void 0:s.split("&").map(e=>{var t,[r,n]=e.split("="),s=i&&null!==(t=o[r])&&void 0!==t?t:n;return delete o[r],r+"="+s}))&&void 0!==r?r:[],l=function(e,t){var i,r;void 0===t&&(t="&");var n=[];return Ft(e,function(e,t){N(e)||N(t)||"undefined"===t||(i=encodeURIComponent(e instanceof File?e.name:e.toString()),r=encodeURIComponent(t),n[n.length]=r+"="+i)}),n.join(t)}(o);return l&&a.push(l),n+"?"+a.join("&")},Kn=(e,t)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,t),Zn=e=>{var t,{data:i,compression:r}=e;if(i){if(r===fn.GZipJS){var n=function(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Vn[255&i^t[r]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),r=e.length;i.p(e);var n,s=function(e,t,i){return function(e,t,i,r){var n=e.length,s=new _n(r+n+5*(1+Math.floor(n/7e3))+8),o=s.subarray(r,s.length-8),a=0;if(!t||n<8)for(var l=0;l<=n;l+=65535){var c=l+65535;c<n?a=Wn(o,a,e.subarray(l,c)):(o[l]=!0,a=Wn(o,a,e.subarray(l,n)))}else{for(var u=zn[t-1],d=u>>>13,h=8191&u,p=(1<<i)-1,g=new vn(32768),f=new vn(p+1),_=Math.ceil(i/3),v=2*_,m=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&p},y=new mn(25e3),w=new vn(288),b=new vn(32),E=0,S=0,k=(l=0,0),x=0,P=0;l<n;++l){var $=m(l),I=32767&l,T=f[$];if(g[I]=T,f[$]=I,x<=l){var C=n-l;if((E>7e3||k>24576)&&C>423){a=Bn(e,o,0,y,w,b,S,k,P,l-P,a),k=E=S=0,P=l;for(var F=0;F<286;++F)w[F]=0;for(F=0;F<30;++F)b[F]=0}var O=2,R=0,A=h,M=I-T&32767;if(C>2&&$==m(l-M))for(var D=Math.min(d,C)-1,L=Math.min(32767,l),N=Math.min(258,C);M<=L&&--A&&I!=T;){if(e[l+O]==e[l+O-M]){for(var j=0;j<N&&e[l+j]==e[l+j-M];++j);if(j>O){if(O=j,R=M,j>D)break;var q=Math.min(M,j-2),U=0;for(F=0;F<q;++F){var H=l-M+F+32768&32767,W=H-g[H]+32768&32767;W>U&&(U=W,T=H)}}}M+=(I=T)-(T=g[I])+32768&32767}if(R){y[k++]=268435456|xn[O]<<18|Pn[R];var B=31&xn[O],z=31&Pn[R];S+=yn[B]+wn[z],++w[257+B],++b[z],x=l+O,++E}else y[k++]=e[l],++w[e[l]]}}a=Bn(e,o,!0,y,w,b,S,k,P,l-P,a)}return Dn(s,0,r+Mn(a)+8)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i)}(e,t,10+((n=t).filename&&n.filename.length+1||0)),o=s.length;return function(e,t){var i=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&&Gn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(s,t),Gn(s,o-8,i.d()),Gn(s,o-4,r),s}(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new _n(e.length+(e.length>>>1)),r=0,n=function(e){i[r++]=e},s=0;s<t;++s){if(r+5>i.length){var o=new _n(r+8+(t-s<<1));o.set(i),i=o}var a=e.charCodeAt(s);a<128?n(a):a<2048?(n(192|a>>>6),n(128|63&a)):a>55295&&a<57344?(n(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++s))>>>18),n(128|a>>>12&63),n(128|a>>>6&63),n(128|63&a)):(n(224|a>>>12),n(128|a>>>6&63),n(128|63&a))}return Dn(i,0,r)}(Kn(i)),{mtime:0}),s=new Blob([n],{type:Yn});return{contentType:Yn,body:s,estimatedSize:s.size}}if(r===fn.Base64){var o=function(e){var t,i,r,n,s,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=function(e){var t,i,r,n,s="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,n=0;n<r;n++){var o=e.charCodeAt(n),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),U(a)||(i>t&&(s+=e.substring(t,i)),s+=a,t=i=n+1)}return i>t&&(s+=e.substring(t,e.length)),s}(e);do{t=(s=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=s>>12&63,r=s>>6&63,n=63&s,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(r)+o.charAt(n)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Kn(i)),a=(t=o,"data="+encodeURIComponent("string"==typeof t?t:Kn(t)));return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=Kn(i);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Qn=[];g&&Qn.push({transport:"fetch",method:e=>{var t,i,{contentType:r,body:n,estimatedSize:s}=null!==(t=Zn(e))&&void 0!==t?t:{},o=new Headers;Ft(e.headers,function(e,t){o.append(t,e)}),r&&o.append("Content-Type",r);var a=e.url,l=null;if(_){var c=new _;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),e.timeout)}}g(a,E({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(s||0)<52428.8,body:n,signal:null==(i=l)?void 0:i.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(n){xt.error(n)}null==e.callback||e.callback(r)})).catch(t=>{xt.error(t),null==e.callback||e.callback({statusCode:0,text:t})}).finally(()=>l?clearTimeout(l.timeout):null)}}),f&&Qn.push({transport:"XHR",method:e=>{var t,i=new f;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:n}=null!==(t=Zn(e))&&void 0!==t?t:{};Ft(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(r){}null==e.callback||e.callback(t)}},i.send(n)}}),null!=d&&d.sendBeacon&&Qn.push({transport:"sendBeacon",method:e=>{var t=Xn(e.url,{beacon:"1"});try{var i,{contentType:r,body:n}=null!==(i=Zn(e))&&void 0!==i?i:{},s="string"==typeof n?new Blob([n],{type:r}):n;d.sendBeacon(t,s)}catch(o){}}});var es=function(e,t){if(!function(){return!0}())return!1;try{return new RegExp(t).test(e)}catch(i){return!1}};function ts(e,t,i){return Kn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var is={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>es(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!es(t,e))),icontains:(e,t)=>t.map(rs).some(t=>e.map(rs).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(rs).every(t=>e.map(rs).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})},rs=e=>e.toLowerCase();function ns(e,t){return!e||Object.entries(e).every(e=>{var[i,r]=e,n=null==t?void 0:t[i];if(N(n)||U(n))return!1;var s=[String(n)],o=is[r.operator];return!!o&&o(r.values,s)})}var ss=Pt("[Error tracking]");class os{constructor(e){var t,i;this.Zt=[],this.ti=new tt([new pt,new St,new ft,new gt,new bt,new wt,new vt,new Et],function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],s=t.split("\n"),o=r;o<s.length;o++){var a=s[o];if(!(a.length>1024)){var l=ht.test(a)?a.replace(ht,"$1"):a;if(!l.match(/\S*Error: /)){for(var c of i){var u=c(l,e);if(u){n.push(u);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return E({},e,{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||it});var i})}(n)}}("web:javascript",lt,dt)),this._instance=e,this.Zt=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Jt))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,r,n=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],s=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this.Zt=n,this._instance.persistence&&this._instance.persistence.register({[Jt]:this.Zt,[Yt]:s})}get ii(){var e,t=!!this._instance.get_property(Yt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void ss.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void ss.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void ss.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(0===e.length)return!1;var t=e.reduce((e,t)=>{var{type:i,value:r}=t;return j(i)&&i.length>0&&e.$exception_types.push(i),j(r)&&r.length>0&&e.$exception_values.push(r),e},{$exception_types:[],$exception_values:[]});return this.Zt.some(e=>{var i=e.values.map(e=>{var i,r=is[e.operator],n=A(e.value)?e.value:[e.value],s=null!==(i=t[e.key])&&void 0!==i?i:[];return n.length>0&&r(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}si(e){return e.flatMap(e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}ni(e){if(e.length>0){var t,i,r,n,s=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=s[s.length-1];return null!==(r=null==o||null==(n=o.filename)?void 0:n.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ei(e){return!H(e)&&A(e)}}var as=Pt("[FeatureFlags]"),ls=Pt("[FeatureFlags]",{debugEnabled:!0}),cs="$active_feature_flags",us="$override_feature_flags",ds="$feature_flag_payloads",hs="$override_feature_flag_payloads",ps="$feature_flag_request_id",gs="$feature_flag_evaluated_at",fs=e=>{var t={};for(var[i,r]of At(e||{}))r&&(t[i]=r);return t},_s=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class vs{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=null!==(e=this._instance.config.evaluation_contexts)&&void 0!==e?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(as.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),null!=t&&t.length?t.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||as.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(si),t=this._instance.get_property(us),i=this._instance.get_property(hs);if(!i&&!t)return e||{};var r=Ot({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var s of n){var o,a,l=r[s],c=null==t?void 0:t[s],u=N(c)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!c,d=N(c)?l.variant:"string"==typeof c?c:void 0,h=null==i?void 0:i[s],p=E({},l,{enabled:u,variant:u?null!=d?d:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(p.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(p.original_variant=null==l?void 0:l.variant),h&&(p.metadata=E({},null==l?void 0:l.metadata,{payload:h,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[s]=p}return this.oi||(as.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this.oi=!0),r}getFlagVariants(){var e=this._instance.get_property(ri),t=this._instance.get_property(us);if(!t)return e||{};for(var i=Ot({},e),r=Object.keys(t),n=0;n<r.length;n++)i[r[n]]=t[r[n]];return this.oi||(as.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.oi=!0),i}getFlagPayloads(){var e=this._instance.get_property(ds),t=this._instance.get_property(hs);if(!t)return e||{};for(var i=Ot({},e||{}),r=Object.keys(t),n=0;n<r.length;n++)i[r[n]]=t[r[n]];return this.oi||(as.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.oi=!0),i}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this._instance.bi.emit("featureFlagsReloading",!0),this.gi=setTimeout(()=>{this.mi()},5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.yi(),!this._instance.M())if(this.li)this.hi=!0;else{var i=this._instance.config.token,r=this._instance.get_property("$device_id"),n={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:E({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(oi)||{}),group_properties:this._instance.get_property(ai)};U(r)||N(r)||(n.$device_id=r),(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.pi()&&(n.evaluation_contexts=this.fi());var s=this._instance.config.__preview_remote_config,o=s?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",l=this._instance.requestRouter.endpointFor("flags",o+a);s&&(n.timezone=on()),this.li=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this._instance.config.disable_compression?void 0:fn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r=!0;if(200===e.statusCode&&(this.hi||(this.$anon_distinct_id=void 0),r=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi(null!==(i=e.json)&&void 0!==i?i:{})),!n.disable_flags||this.hi)if(this.vi=!r,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(_s.FeatureFlags))as.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var s;n.disable_flags||this.receivedFeatureFlags(null!==(s=e.json)&&void 0!==s?s:{},r),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}as.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants(),r=e in i,n=i[e],s=this.getFlagPayloads()[e],o=String(n),a=this._instance.get_property(ps)||void 0,l=this._instance.get_property(gs)||void 0,c=this._instance.get_property(ci)||{};if((t.send_event||!("send_event"in t))&&(!(e in c)||!c[e].includes(o))){var u,d,h,p,g,f,_,v,m;A(c[e])?c[e].push(o):c[e]=[o],null==(u=this._instance.persistence)||u.register({[ci]:c});var y=this.getFeatureFlagDetails(e),w={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:s||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(d=this._instance.config.bootstrap)||null==(d=d.featureFlags)?void 0:d[e])||null,$feature_flag_bootstrapped_payload:(null==(h=this._instance.config.bootstrap)||null==(h=h.featureFlagPayloads)?void 0:h[e])||null,$used_bootstrap_value:!this.vi};N(null==y||null==(p=y.metadata)?void 0:p.version)||(w.$feature_flag_version=y.metadata.version);var b,E=null!==(g=null==y||null==(f=y.reason)?void 0:f.description)&&void 0!==g?g:null==y||null==(_=y.reason)?void 0:_.code;E&&(w.$feature_flag_reason=E),null!=y&&null!=(v=y.metadata)&&v.id&&(w.$feature_flag_id=y.metadata.id),N(null==y?void 0:y.original_variant)&&N(null==y?void 0:y.original_enabled)||(w.$feature_flag_original_response=N(y.original_variant)?y.original_enabled:y.original_variant),null!=y&&null!=(m=y.metadata)&&m.original_payload&&(w.$feature_flag_original_payload=null==y||null==(b=y.metadata)?void 0:b.original_payload),this._instance.capture("$feature_flag_called",w)}if(r){var S=s;if(!N(s))try{S=JSON.parse(s)}catch(k){}return{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:S}}}else as.warn('getFeatureFlagResult for key "'+e+"\" failed. Feature flags didn't load in time.")}getRemoteConfigPayload(e,t){var i=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(r.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:r,compression:this._instance.config.disable_compression?void 0:fn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var r,n=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==n?void 0:n[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return N(i)?void 0:!!i}as.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var i=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,i,r,n){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={});var s=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(e=>t[e].enabled).filter(e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload}).map(e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]}))):as.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),o=s.flags,a=s.featureFlags,l=s.featureFlagPayloads;if(a){var c=e.requestId,u=e.evaluatedAt;if(A(a)){as.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(a)for(var h=0;h<a.length;h++)d[a[h]]=!0;t&&t.register({[cs]:a,[ri]:d})}else{var p=a,g=l,f=o;if(e.errorsWhileComputingFlags)if(o){var _=new Set(Object.keys(o).filter(e=>{var t;return!(null!=(t=o[e])&&t.failed)}));p=E({},i,Object.fromEntries(Object.entries(p).filter(e=>{var[t]=e;return _.has(t)}))),g=E({},r,Object.fromEntries(Object.entries(g||{}).filter(e=>{var[t]=e;return _.has(t)}))),f=E({},n,Object.fromEntries(Object.entries(f||{}).filter(e=>{var[t]=e;return _.has(t)})))}else p=E({},i,p),g=E({},r,g),f=E({},n,f);t&&t.register(E({[cs]:Object.keys(fs(p)),[ri]:p||{},[ds]:g||{},[si]:f||{}},c?{[ps]:c}:{},u?{[gs]:u}:{}))}}}(e,this._instance.persistence,i,r,n),this.xi(t)}}override(e,t){void 0===t&&(t=!1),as.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return as.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(us),this._instance.persistence.unregister(hs),this.xi(),ls.info("All overrides cleared");if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this.oi=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(us),ls.info("Flag overrides cleared");else if(i.flags){if(A(i.flags)){for(var r={},n=0;n<i.flags.length;n++)r[i.flags[n]]=!0;this._instance.persistence.register({[us]:r})}else this._instance.persistence.register({[us]:i.flags});ls.info("Flag overrides set",{flags:i.flags})}return"payloads"in i&&(!1===i.payloads?(this._instance.persistence.unregister(hs),ls.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[hs]:i.payloads}),ls.info("Payload overrides set",{payloads:i.payloads}))),void this.xi()}this.xi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:i}=this.Ei();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var r,n=(this._instance.get_property(ni)||[]).find(t=>t.flagKey===e),s={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:s};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(s,!1);var a=E({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[cs]:Object.keys(fs(a)),[ri]:a}),this.xi()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._instance.get_property(ni),n=i?"&"+i.map(e=>"stage="+e).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+n),method:"GET",callback:t=>{var i,r;if(t.json){var n=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(ni),null==(r=this._instance.persistence)||r.register({[ni]:n}),e(n)}}})}Ei(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}xi(e){var{flags:t,flagVariants:i}=this.Ei();this.featureFlagEventHandlers.forEach(r=>r(t,i,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(oi)||{};this._instance.register({[oi]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(oi)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(ai)||{};0!==Object.keys(i).length&&Object.keys(i).forEach(t=>{i[t]=E({},i[t],e[t]),delete e[t]}),this._instance.register({[ai]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ai)||{};this._instance.register({[ai]:E({},t,{[e]:{}})})}else this._instance.unregister(ai)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.oi=!1}}var ms=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class ys{constructor(e,t){var i,r;this.R=e,this.props={},this.$i=!1,this.Si=(r="",(i=e).token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"),this.Y=this.ki(e),this.load(),e.debug&&xt.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Pi}ki(e){-1===ms.indexOf(e.persistence.toLowerCase())&&(xt.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(e){void 0===e&&(e=[]);var t=[...br,...e];return E({},wr,{W:function(e){try{var t={};try{t=mr.W(e)||{}}catch(r){}var i=Ot(t,JSON.parse(wr.q(e)||"{}"));return wr.G(e,i),i}catch(r){}return null},G:function(e,i,r,n,s,o){try{wr.G(e,i,void 0,void 0,o);var a={};t.forEach(e=>{i[e]&&(a[e]=i[e])}),Object.keys(a).length&&mr.G(e,a,r,n,s,o)}catch(l){wr.B(l)}},V:function(e,t){try{null==o||o.localStorage.removeItem(e),mr.V(e,t)}catch(pr){wr.B(pr)}}})}(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return"localstorage"===i&&wr.H()?wr:"localstorage+cookie"===i&&t.H()?t:"sessionstorage"===i&&xr.H()?xr:"memory"===i?Sr:"cookie"===i?mr:t.H()?t:mr}properties(){var e={};return Ft(this.props,function(t,i){if(i===ri&&D(t))for(var r=Object.keys(t),n=0;n<r.length;n++)e["$feature/"+r[n]]=t[r[n]];else o=i,a=!1,(U(s=yi)?a:u&&s.indexOf===u?-1!=s.indexOf(o):(Ft(s,function(e){if(a||(a=e===o))return Tt}),a))||(e[i]=t);var s,o,a}),e}load(){if(!this.Pi){var e=this.Y.W(this.Si);e&&(this.props=Ot({},e))}}save(){this.Pi||this.Y.G(this.Si,this.props,this.Ti,this.Ii,this.Ci,this.R.debug)}remove(){this.Y.V(this.Si,!1),this.Y.V(this.Si,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(D(e)){N(t)&&(t="None"),this.Ti=N(i)?this.Ri:i;var r=!1;if(Ft(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(D(e)){this.Ti=N(t)?this.Ri:t;var i=!1;if(Ft(e,(t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,i=!0)}),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.$i){var e=Zr(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);L(Lt(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=null==h?void 0:h.referrer)?en(e):{})}update_referrer_info(){var e;this.register_once({$referrer:rn(),$referring_domain:null!=h&&h.referrer&&(null==(e=Zi(h.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[pi]||this.props[gi]||this.register_once({[fi]:nn(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Ft([gi,pi],t=>{var i=this.props[t];i&&Ft(i,function(t,i){e["$initial_"+T(i)]=t})});var t,i,r=this.props[fi];if(r){var n=(t=sn(r),i={},Ft(t,function(e,t){i["$initial_"+T(t)]=e}),i);Ot(e,n)}return e}safe_merge(e){return Ft(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){if(this.Ri=this.Ti=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.ki(e),n=this.props;this.clear(),this.Y=r,this.props=n,this.save()}}set_disabled(e){this.Pi=e,this.Pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_secure(e){e!==this.Ci&&(this.Ci=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Bt]||{};i[e]=t,this.props[Bt]=i,this.save()}remove_event_timer(e){var t=(this.props[Bt]||{})[e];return N(t)||(delete this.props[Bt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var ws=Pt("[Product Tours]"),bs="ph_product_tours";class Es{constructor(e){this.Fi=null,this.Oi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Zt]:!(null==e||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Fi||(e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(Zt)||this.it(()=>this.Mi())}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",t=>{t?ws.error("Could not load product tours script",t):e()})}Mi(){var e;!this.Fi&&null!=(e=m.__PosthogExtensions__)&&e.generateProductTours&&(this.Fi=m.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!A(this.Oi)||t){var i=this._instance.persistence;if(i){var r=i.props[bs];if(A(r)&&!t)return this.Oi=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:t=>{var r=t.statusCode;if(200!==r||!t.json){var n="Product Tours API could not be loaded, status: "+r;return ws.error(n),void e([],{isLoaded:!1,error:n})}var s=A(t.json.product_tours)?t.json.product_tours:[];this.Oi=s,i&&i.register({[bs]:s}),e(s,{isLoaded:!0})}})}else e(this.Oi,{isLoaded:!0})}getActiveProductTours(e){H(this.Fi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this.Fi)||t.showTourById(e)}previewTour(e){this.Fi?this.Fi.previewTour(e):this.it(()=>{var t;this.Mi(),null==(t=this.Fi)||t.previewTour(e)})}dismissProductTour(){var e;null==(e=this.Fi)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this.Fi)||e.nextStep()}previousStep(){var e;null==(e=this.Fi)||e.previousStep()}clearCache(){var e;this.Oi=null,null==(e=this._instance.persistence)||e.unregister(bs)}resetTour(e){var t;null==(t=this.Fi)||t.resetTour(e)}resetAllTours(){var e;null==(e=this.Fi)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this.Fi)||t.cancelPendingTour(e)}}var Ss=function(e){return e.Activation="events",e.Cancellation="cancelEvents",e}({});!function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}({}),function(e){e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}({}),function(e){e.Top="top",e.Left="left",e.Right="right",e.Bottom="bottom"}({});var ks=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({});!function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}({}),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}({}),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}({});var xs=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e}({}),Ps=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",e}({}),$s=function(e){return e.Popover="popover",e.Inline="inline",e}({}),Is=Pt("[Surveys]"),Ts="seenSurvey_",Cs=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},Fs=e=>{return r=""+(t=Ts)+(i=e).id,i.current_iteration&&i.current_iteration>0&&(r=""+t+i.id+"_"+i.current_iteration),r;var t,i,r},Os=[ks.Popover,ks.Widget,ks.API],Rs={ignoreConditions:!1,ignoreDelay:!1,displayType:$s.Popover};class As{constructor(){this.Ai={},this.Ai={}}on(e,t){return this.Ai[e]||(this.Ai[e]=[]),this.Ai[e].push(t),()=>{this.Ai[e]=this.Ai[e].filter(e=>e!==t)}}emit(e,t){for(var i of this.Ai[e]||[])i(t);for(var r of this.Ai["*"]||[])r(e,t)}}function Ms(e,t,i){if(H(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(n){return!1}default:return!1}}class Ds{constructor(e){this.ji=new As,this.Di=(e,t)=>this.Li(e,t)&&this.Ni(e,t)&&this.Ui(e,t)&&this.zi(e,t),this.Li=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this.Hi=new Set,this.Bi=new Set}init(){var e,t;N(null==(e=this._instance)?void 0:e._addCaptureHook)||null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.on(e,t)})}register(e){var t,i;if(!N(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t,i;null==(t=this.Bi)||t.add(e),null==(i=e.steps)||i.forEach(e=>{var t;null==(t=this.Hi)||t.add((null==e?void 0:e.event)||"")})}),null!=(i=this._instance)&&i.autocapture)){var r,n=new Set;e.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&n.add(null==e?void 0:e.selector)})}),null==(r=this._instance)||r.autocapture.setElementSelectors(n)}}on(e,t){var i;null!=t&&0!=e.length&&(this.Hi.has(e)||this.Hi.has(null==t?void 0:t.event))&&this.Bi&&(null==(i=this.Bi)?void 0:i.size)>0&&this.Bi.forEach(e=>{this.qi(t,e)&&this.ji.emit("actionCaptured",e.name)})}Wi(e){this.onAction("actionCaptured",t=>e(t))}qi(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this.Di(e,i))return!0;return!1}onAction(e,t){return this.ji.on(e,t)}Ni(e,t){if(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ms(r,t.url,t.url_matching||"contains"))return!1}return!0}Ui(e,t){return!!this.Gi(e,t)&&!!this.Vi(e,t)&&!!this.Ji(e,t)}Gi(e,t){var i;if(null==t||!t.href)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Ms(e.href,t.href,t.href_matching||"exact"));var n,s=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!s&&Ms((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(null==t||!t.text)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Ms(e.text,t.text,t.text_matching||"exact")||Ms(e.$el_text,t.text,t.text_matching||"exact"));var n,s,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(n=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!H(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),s=t.text,o=t.text_matching||"exact",n.some(e=>Ms(e,s,o)))}Ji(e,t){var i,r;if(null==t||!t.selector)return!0;var n=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=n&&n.includes(t.selector))return!0;var s=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&s)try{return new RegExp(t.selector_regex).test(s)}catch(o){return!1}return!1}Ki(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}zi(e,t){return null==t||!t.properties||0===t.properties.length||ns(t.properties.reduce((e,t)=>{var i=A(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}}class Ls{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&ns(e.propertyFilters,null==t?void 0:t.properties)}te(e,t){var i=new Map;return e.forEach(e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach(t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}})}),i}ie(e,t,i){var r=(i===Ss.Activation?this.Yi:this.Xi).get(e),n=[];return this.ee(e=>{n=e.filter(e=>null==r?void 0:r.includes(e.id))}),n.filter(r=>{var n,s=null==(n=r.conditions)||null==(n=n[i])||null==(n=n.values)?void 0:n.find(t=>t.name===e);return this.Zi(s,t)})}register(e){var t;N(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.re(e),this.se(e))}se(e){var t=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0});0!==t.length&&(null==this.ne&&(this.ne=new Ds(this._instance),this.ne.init(),this.ne.Wi(e=>{this.onAction(e)})),t.forEach(e=>{var t,i,r,n,s;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(n=this.ne)||n.register(e.conditions.actions.values),null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)||s.forEach(t=>{if(t&&t.name){var i=this.Qi.get(t.name);i&&i.push(e.id),this.Qi.set(t.name,i||[e.id])}}))}))}re(e){var t,i=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0});0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.onEvent(e,t)}),this.Yi=this.te(e,Ss.Activation),this.Xi=this.te(e,Ss.Cancellation))}onEvent(e,t){var i,r=this.oe(),n=this.ae(),s=this.le(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[n])||[];if(s===e&&t&&o.length>0){var a,l;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(c){var u=o.indexOf(c);u>=0&&(o.splice(u,1),this.ue(o))}}else{if(this.Xi.has(e)){var d=this.ie(e,t,Ss.Cancellation);d.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:d.map(e=>e.id)}),d.forEach(e=>{var t=o.indexOf(e.id);t>=0&&o.splice(t,1),this.he(e.id)}),this.ue(o))}if(this.Yi.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var h=this.ie(e,t,Ss.Activation);this.ue(o.concat(h.map(e=>e.id)||[]))}}}onAction(e){var t,i=this.ae(),r=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(r.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),r=this.ae(),n=[...new Set(e)].filter(e=>!this.de(e));i.info("updating activated items",{activatedItems:n}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[r]:n})}getActivatedIds(){var e,t=this.ae();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}}class Ns extends Ls{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return xs.SHOWN}ee(e){var t;null==(t=this._instance)||t.getSurveys(e)}he(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}oe(){return Is}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class js{constructor(e){this.ce=void 0,this._surveyManager=null,this.fe=!1,this.pe=[],this.ge=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(H(t))return Is.warn("Flags not loaded yet. Not loading surveys.");var i=A(t);this.ce=i?t.length>0:t,Is.info("flags response received, isSurveysEnabled: "+this.ce),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith(Ts)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)Is.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Is.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Is.info("Not loading surveys in cookieless mode without consent.");else{var e=null==m?void 0:m.__PosthogExtensions__;if(e){if(!N(this.ce)||this._instance.config.advanced_enable_surveys){var t=this.ce||this._instance.config.advanced_enable_surveys;this.fe=!0;try{var i=e.generateSurveys;if(i)return void this._e(i,t);var r=e.loadExternalDependency;if(!r)return void this.me("PostHog loadExternalDependency extension not found.");r(this._instance,"surveys",i=>{i||!e.generateSurveys?this.me("Could not load surveys script",i):this._e(e.generateSurveys,t)})}catch(n){throw this.me("Error initializing surveys",n),n}finally{this.fe=!1}}}else Is.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ns(this._instance),Is.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(e,t){Is.error(e,t),this.be({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.pe.push(e),this._surveyManager&&this.be({isLoaded:!0}),()=>{this.pe=this.pe.filter(t=>t!==e)}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Is.info("Disabled. Not loading surveys."),e([]);var i,r=this._instance.get_property(li);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.ge?this.ge.then(t=>{var{surveys:i,context:r}=t;return e(i,r)}):("undefined"!=typeof Promise&&(this.ge=new Promise(e=>{i=e})),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:t=>{var r;this.ge=null;var n=t.statusCode;if(200!==n||!t.json){var s="Surveys API could not be loaded, status: "+n;Is.error(s);var o={isLoaded:!1,error:s};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],c=l.filter(e=>{return!(!(t=e).start_date||t.end_date)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e));var t});c.length>0&&(null==(a=this._surveyEventReceiver)||a.register(c)),null==(r=this._instance.persistence)||r.register({[li]:l});var u={isLoaded:!0};e(l,u),null==i||i({surveys:l,context:u})}}))}be(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){Is.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!H(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Is.warn("init was not called")}ye(e){var t=null;return this.getSurveys(i=>{var r;t=null!==(r=i.find(t=>t.id===e))&&void 0!==r?r:null}),t}we(e){if(H(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(H(this._surveyManager))return Is.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.we(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return H(this._surveyManager)?(Is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(i=>{this.getSurveys(t=>{var r,n=null!==(r=t.find(t=>t.id===e))&&void 0!==r?r:null;if(n){var s=this.we(n);i({visible:s.eligible,disabledReason:s.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var r;if(H(this._surveyManager))Is.warn("init was not called");else{var n="string"==typeof e?this.ye(e):e;if(null!=n&&n.id)if(Os.includes(n.type)){var s=null==h?void 0:h.querySelector(t);if(s)return null!=(r=n.appearance)&&r.surveyPopupDelaySeconds?(Is.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var e,t;Is.info("Rendering survey "+n.id+" with delay of "+(null==(e=n.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(n,s,i),Is.info("Survey "+n.id+" rendered")},1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,s,i);Is.warn("Survey element not found")}else Is.warn("Surveys of type "+n.type+" cannot be rendered in the app");else Is.warn("Survey not found")}}displaySurvey(e,t){var i;if(H(this._surveyManager))Is.warn("init was not called");else{var r=this.ye(e);if(r){var n=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=E({},r,{appearance:E({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==$s.Popover&&t.initialResponses&&Is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var s=this.canRenderSurvey(r);if(!s.visible)return void Is.warn("Survey is not eligible to be displayed: ",s.disabledReason)}t.displayType!==$s.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else Is.warn("Survey not found")}}cancelPendingSurvey(e){H(this._surveyManager)?Is.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}var qs=Pt("[Conversations]");class Us{constructor(e){this.xe=void 0,this._conversationsManager=null,this.Ee=!1,this.$e=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;H(t)||(z(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this.xe=void 0,this.$e=null}loadIfEnabled(){if(!this._conversationsManager&&!this.Ee&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==m?void 0:m.__PosthogExtensions__;if(e&&!N(this.xe)&&this.xe)if(this.$e&&this.$e.token){this.Ee=!0;try{var t=e.initConversations;if(t)return this.Se(t),void(this.Ee=!1);var i=e.loadExternalDependency;if(!i)return void this.ke("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",t=>{t||!e.initConversations?this.ke("Could not load conversations script",t):this.Se(e.initConversations),this.Ee=!1})}catch(r){this.ke("Error initializing conversations",r),this.Ee=!1}}else qs.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),qs.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else qs.error("Cannot complete initialization: remote config is null")}ke(e,t){qs.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():qs.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.xe&&!U(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var r=this;return b(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,i):(qs.warn("Conversations not available yet."),null)})()}getMessages(e,t){var i=this;return b(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(qs.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return b(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(qs.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return b(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(qs.warn("Conversations not available yet."),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}}class Hs{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!H(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=Pt("[logs]"),t=null==m?void 0:m.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",i=>{var r;i||null==(r=t.logs)||!r.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Te=!0)}):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}}var Ws=Pt("[RateLimiter]");class Bs{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Ws.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(i){return void Ws.warn('could not rate limit - continuing. Error: "'+(null==i?void 0:i.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:s}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(hi))&&void 0!==t?t:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*s,a.last=o,a.tokens>n&&(a.tokens=n);var l=a.tokens<1;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+s+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(hi,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var zs=Pt("[RemoteConfig]");class Vs{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}Ie(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(zs.error("PostHog Extensions not found. Cannot load remote config."),e())}Ce(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return zs.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void zs.warn("Remote config is disabled. Falling back to local config.");this.Ie(e=>{if(!e)return zs.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce(e=>{this.wi(e)});this.wi(e)})}catch(pr){zs.error("Error loading remote config",pr)}}wi(e){e?this._instance.config.__preview_remote_config?(this._instance.wi(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):zs.info("__preview_remote_config is disabled. Logging config instead",e):zs.error("Failed to fetch remote config from PostHog.")}}var Gs=3e3;class Js{constructor(e,t){this.Re=!0,this.Fe=[],this.Oe=Q((null==t?void 0:t.flush_interval_ms)||Gs,250,5e3,xt.createLogger("flush interval"),Gs),this.Me=e}enqueue(e){this.Fe.push(e),this.Ae||this.je()}unload(){this.De();var e=this.Fe.length>0?this.Le():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this.Me(E({},e,{transport:"sendBeacon"}))})}enable(){this.Re=!1,this.je()}je(){var e=this;this.Re||(this.Ae=setTimeout(()=>{if(this.De(),this.Fe.length>0){var t=this.Le(),i=function(){var i=t[r],n=(new Date).getTime();i.data&&A(i.data)&&Ft(i.data,e=>{e.offset=Math.abs(e.timestamp-n),delete e.timestamp}),e.Me(i)};for(var r in t)i()}},this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return Ft(this.Fe,t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;N(e[n])&&(e[n]=E({},r,{data:[]})),null==(i=e[n].data)||i.push(r.data)}),this.Fe=[],e}}var Ys=["retriesPerformedSoFar"];class Xs{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!N(o)&&"onLine"in o.navigator&&(this.ze=o.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},Ut(o,"online",this.He),Ut(o,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=S(e,Ys);B(t)&&(i.url=Xn(i.url,{retry_count:t})),this._instance._send_request(E({},i,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.qe(E({retriesPerformedSoFar:t},i)):null==i.callback||i.callback(e)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i,r,n,s,o,a=(i=t,n=(r=3e3*Math.pow(2,i))/2,s=Math.min(18e5,r),o=(Math.random()-.5)*(s-n),Math.ceil(s+o)),l=Date.now()+a;this.Fe.push({retryAt:l,requestOptions:e});var c="Enqueued failed request for retry in "+a;navigator.onLine||(c+=" (Browser is offline)"),xt.warn(c),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),0===this.Fe.length)return this.Ne=!1,void(this.Ge=void 0);this.Ge=setTimeout(()=>{this.ze&&this.Fe.length>0&&this.Lt(),this.We()},this.Ue)}Lt(){var e=Date.now(),t=[],i=this.Fe.filter(i=>i.retryAt<e||(t.push(i),!1));if(this.Fe=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,N(o)||(this.He&&(o.removeEventListener("online",this.He),this.He=void 0),this.Be&&(o.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(E({},e,{transport:"sendBeacon"}))}catch(pr){xt.error(pr)}this.Fe=[]}}class Ks{constructor(e){this.Ve=()=>{var e,t,i,r;this.Je||(this.Je={});var n=this.scrollElement(),s=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=s+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(s),this.Je.maxScrollY=Math.max(s,null!==(e=this.Je.maxScrollY)&&void 0!==e?e:0),this.Je.maxScrollHeight=Math.max(o,null!==(t=this.Je.maxScrollHeight)&&void 0!==t?t:0),this.Je.lastContentY=a,this.Je.maxContentY=Math.max(a,null!==(i=this.Je.maxContentY)&&void 0!==i?i:0),this.Je.maxContentHeight=Math.max(l,null!==(r=this.Je.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){Ut(o,"scroll",this.Ve,{capture:!0}),Ut(o,"scrollend",this.Ve,{capture:!0}),Ut(o,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==o?void 0:o.document.documentElement;var e=A(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var i=null==o?void 0:o.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return o&&(o.scrollY||o.pageYOffset||o.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return o&&(o.scrollX||o.pageXOffset||o.document.documentElement.scrollLeft)||0}}var Zs=e=>nn(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Qs{constructor(e,t,i,r){this.Ke=e=>{var t=this.Ye();if(!t||t.sessionId!==e){var i={sessionId:e,props:this.Xe(this._instance)};this.Qe.register({[di]:i})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=r||Zs,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[di]}getSetOnceProps(){var e,t=null==(e=this.Ye())?void 0:e.props;return t?"r"in t?sn(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Ft(Lt(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+T(i)]=t}),e}}var eo=Pt("[SessionId]");class to{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var r;if(this.ir=[],this.er=void 0,this.tr=new As,this.rr=(e,t)=>!(!B(e)||!B(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Qe=e.persistence,this.sr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ar=t||gr,this.lr=i||gr;var n=this.R.persistence_name||this.R.token,s=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Q(s,60,36e3,eo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+n+"_window_id",this.dr="ph_"+n+"_primary_window_exists",this.vr()){var o=xr.W(this.hr),a=xr.W(this.dr);o&&!a?this.sr=o:xr.V(this.hr),xr.G(this.dr,!0)}if(null!=(r=this.R.bootstrap)&&r.sessionID)try{var l=(()=>{var e=this.R.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.cr(this.R.bootstrap.sessionID,(new Date).getTime(),l)}catch(c){eo.error("Invalid sessionID in bootstrap",c)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return N(this.ir)&&(this.ir=[]),this.ir.push(e),this.nr&&e(this.nr,this.sr),()=>{this.ir=this.ir.filter(t=>t!==e)}}vr(){return"memory"!==this.R.persistence&&!this.Qe.Pi&&xr.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&xr.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?xr.W(this.hr):null}cr(e,t,i){e===this.nr&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.nr=e,this.Qe.register({[ti]:[t,e,i]}))}mr(){var e=this.Qe.props[ti];return A(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&o&&(o.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&xr.V(this.dr)},Ut(o,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this.R.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,n,s]=this.mr(),o=this._r(),a=B(s)&&Math.abs(i-s)>864e5,l=!1,c=!n,u=!c&&!e&&this.rr(i,r);c||u||a?(n=this.ar(),o=this.lr(),eo.info("new session ID generated",{sessionId:n,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),s=i,l=!0):o||(o=this.lr(),l=!0);var d=B(r)&&e&&!a?r:i,h=B(s)?s:(new Date).getTime();return this.gr(o),this.cr(n,d,h),e||this.ur(),l&&this.ir.forEach(e=>e(n,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0)),{sessionId:n,windowId:o,sessionStartTimestamp:h,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}ur(){clearTimeout(this.br),this.br=setTimeout(()=>{var[e]=this.mr();if(this.rr((new Date).getTime(),e)){var t=this.nr;this.resetSessionId(),this.tr.emit("forcedIdleReset",{idleSessionId:t})}},1.1*this.sessionTimeoutMs)}}var io=["$set_once","$set"],ro=Pt("[SiteApps]");class no{constructor(e){this._instance=e,this.yr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wr(e,t){if(t){var i=this.globalsForEvent(t);this.yr.push(i),this.yr.length>1e3&&(this.yr=this.yr.slice(10))}}get siteAppLoaders(){var e;return null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.wr.bind(this));this.Er=()=>{e(),this.yr=[],this.Er=void 0}}}globalsForEvent(e){var t,i,r,n,s,o,a;if(!e)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[d,h]of Object.entries(u))l[d]={id:c[d],type:d,properties:h};var{$set_once:p,$set:g}=e;return{event:E({},S(e,io),{properties:E({},e.properties,g?{$set:E({},null!==(t=null==(i=e.properties)?void 0:i.$set)&&void 0!==t?t:{},g)}:{},p?{$set_once:E({},null!==(r=null==(n=e.properties)?void 0:n.$set_once)&&void 0!==r?r:{},p)}:{}),elements_chain:null!==(s=null==(o=e.properties)?void 0:o.$elements_chain)&&void 0!==s?s:"",distinct_id:null==(a=e.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this.yr.length&&(ro.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.forEach(e=>null==t.processEvent?void 0:t.processEvent(e)),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(i=this.Er)||i.call(this))},r=!1,n=n=>{t.errored=!n,t.loaded=!0,ro.info("Site app with id "+e.id+" "+(n?"loaded":"errored")),r&&i()};try{var{processEvent:s}=e.init({posthog:this._instance,callback:e=>{n(e)}});s&&(t.processEvent=s),r=!0}catch(o){ro.error("Error while initializing PostHog app with config id "+e.id,o),n(!1)}if(r&&t.loaded)try{i()}catch(a){ro.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}$r(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}Sr(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(r){ro.error("Error while processing event "+e.event+" for site app "+i.id,r)}}}onRemoteConfig(e){var t,i,r,n=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",e=>this.Sr(e))):void ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Er)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var s=function(e){var t;m["__$$ph_site_app_"+e]=n._instance,null==(t=m.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,a,t=>{if(t)return ro.error("Error while initializing PostHog app with config id "+e,t)})};for(var{id:o,url:a}of e.siteApps)s(o)}else ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var so=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&x(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some(e=>x(null==e?void 0:e.brand,t)))return!0}catch(n){}return!!e.webdriver},oo=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ao="i.posthog.com";class lo{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this.kr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=oo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=oo.EU:this.kr[this.apiHost]=oo.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if(this.region===oo.CUSTOM)return this.apiHost+t;var i=ao+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var co={icontains:(e,t)=>!!o&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!o&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!o&&es(t.href,e),not_regex:(e,t)=>!!o&&!es(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class uo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments(e=>{uo.Pr("retrieved web experiments from the server"),t.Tr=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;t.Tr&&(uo.Pr("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t.Tr)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);j(r)&&e.variants[r]&&t.Ir(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var n in e.variants){var s=e.variants[n];uo.Cr(s)&&t.Ir(e.name,n,s.transforms)}})},e)},this._instance=e,this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}onFeatureFlags(e){if(this._is_bot())uo.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(H(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();uo.Pr("applying feature flags",e),e.forEach(e=>{var t;if(this.Tr&&null!=(t=this.Tr)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),n=null==(i=this.Tr)?void 0:i.get(e);r&&null!=n&&n.variants[r]&&this.Ir(n.name,r,n.variants[r].transforms)}})}}previewWebExperiment(){var e=uo.getWindowLocation();if(null!=e&&e.search){var t=Qi(null==e?void 0:e.search,"__experiment_id"),i=Qi(null==e?void 0:e.search,"__experiment_variant");t&&i&&(uo.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments(e=>{this.Rr(parseInt(t),i,e)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}Rr(e,t,i){var r=i.filter(t=>t.id===e);r&&r.length>0&&(uo.Pr("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ir(r[0].name,t,r[0].variants[t].transforms))}static Cr(e){return!H(e.conditions)&&uo.Fr(e)&&uo.Or(e)}static Fr(e){var t;if(H(e.conditions)||H(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,n,s=uo.getWindowLocation();return!!s&&(null==(i=e.conditions)||!i.url||co[null!==(r=null==(n=e.conditions)?void 0:n.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,s))}static getWindowLocation(){return null==o?void 0:o.location}static Or(e){var t;if(H(e.conditions)||H(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Zr();if(i.utm_source){var r,n,s,o,a,l,c,u,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(n=e.conditions)||null==(n=n.utm)?void 0:n.utm_campaign)==i.utm_campaign,h=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,p=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,g=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&p&&g&&h}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];xt.info("[WebExperiments] "+e,i)}Ir(e,t,i){this._is_bot()?uo.Pr("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach(i=>{if(i.selector){var r;uo.Pr("applying transform of variant "+t+" for experiment "+e+" ",i);var n=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==n||n.forEach(e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)})}}):uo.Pr("Control variants leave the page unmodified.")}_is_bot(){return d&&this._instance?so(d,this._instance.config.custom_blocked_useragents):void 0}}var ho=Pt("[PostHog ExternalIntegrations]"),po={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class go{constructor(e){this._instance=e}it(e,t){var i;null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return ho.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(t){var i,n,s;!r||null!=(i=m.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e.it(po[t],()=>{var i;null==(i=m.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)}),!r&&null!=(n=m.__PosthogExtensions__)&&null!=(n=n.integrations)&&n[t]&&(null==(s=m.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[t])||s.stop())};for(var[i,r]of Object.entries(null!==(n=this._instance.config.integrations)&&void 0!==n?n:{})){var n;t(i)}}}var fo="[SessionRecording]",_o=Pt(fo);class vo{get started(){var e;return!(null==(e=this.Mr)||!e.isStarted)}get status(){return this.Mr?this.Mr.status:this.Ar&&!this.jr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ar=!1,this.Dr=void 0,this._instance=e,!this._instance.sessionManager)throw _o.error("started without valid sessionManager"),new Error(fo+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(fo+' cannot be used with cookieless_mode="always"')}get jr(){var e,t=!(null==(e=this._instance.get_property(ei))||!e.enabled),i=!this._instance.config.disable_session_recording,r=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return o&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this.jr||null==(t=this.Mr)||!t.isStarted){var i=!N(Object.assign)&&!N(Array.from);this.jr&&i?(this.Lr(e),_o.info("starting")):this.stopRecording()}}Lr(e){var t,i,r;this.jr&&(null!=m&&null!=(t=m.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=m.__PosthogExtensions__)&&i.initSessionRecording?this.Nr(e):null==(r=m.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Ur,t=>{if(t)return _o.error("could not load recorder",t);this.Nr(e)}))}stopRecording(){var e,t;null==(e=this.Dr)||e.call(this),this.Dr=void 0,null==(t=this.Mr)||t.stop()}zr(){var e;null==(e=this._instance.persistence)||e.unregister(ii)}Hr(e){if(this._instance.persistence){var t,i,r=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,i=null==t?void 0:t.sampleRate,n=H(i)?null:parseFloat(i);H(n)&&this.zr();var s=null==t?void 0:t.minimumDurationMilliseconds;r.register({[ei]:E({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:E({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:N(s)?null:s,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this.Dr)||t.call(this),this.Dr=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:_o.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this.Mr)&&i.log?this.Mr.log(e,t):_o.warn("log called before recorder was ready")}get Ur(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(ei);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if(null==(t=m.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=null==(i=m.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;null==(t=this.Mr)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_linked_flag:!0}),null==(e=this.Mr)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_sampling:!0}),null==(e=this.Mr)||e.overrideSampling()}overrideTrigger(e){var t,i;this.Mr||null==(i=this._instance.persistence)||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(t=this.Mr)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this.Mr)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this.Mr)||!i.tryAddCustomEvent(e,t))}}var mo={},yo=()=>{},wo="posthog",bo=!Jn&&-1===(null==v?void 0:v.indexOf("MSIE"))&&-1===(null==v?void 0:v.indexOf("Mozilla")),Eo=e=>{var t;return E({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:jt(null==h?void 0:h.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:yo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,debug:p&&j(null==p?void 0:p.search)&&-1!==p.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==o||null==(t=o.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;xt.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Gs},error_tracking:{},_onCapture:yo,__preview_eager_load_replay:!1},(e=>({rageclick:!(e&&e>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(e&&e>="2025-05-24")||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},So=e=>{var t={};N(e.process_person)||(t.person_profiles=e.process_person),N(e.xhr_headers)||(t.request_headers=e.xhr_headers),N(e.cookie_name)||(t.persistence_name=e.cookie_name),N(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),N(e.store_google)||(t.save_campaign_params=e.store_google),N(e.verbose)||(t.debug=e.verbose);var i=Ot({},t,e);return A(e.property_blacklist)&&(N(e.property_denylist)?i.property_denylist=e.property_blacklist:A(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:xt.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class ko{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){xt.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class xo{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new ko,this.qr=!1,this.version=y.LIB_VERSION,this.bi=new As,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Eo(),this.SentryIntegration=jr,this.sentryIntegration=e=>{return t=Nr(this,e),{name:Lr,processEvent:e=>t(e)};var t},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new vs(this),this.toolbar=new Br(this),this.scrollManager=new Ks(this),this.pageViewManager=new gn(this),this.surveys=new js(this),this.conversations=new Us(this),this.logs=new Hs(this),this.experiments=new uo(this),this.exceptions=new os(this),this.rateLimiter=new Bs(this),this.requestRouter=new lo(this),this.consent=new $r(this),this.externalIntegrations=new go(this),this.people={set:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",e=>xt.info('send "'+(null==e?void 0:e.event)+'"',e))}init(e,t,i){if(i&&i!==wo){var r,n=null!==(r=mo[i])&&void 0!==r?r:new xo;return n._init(e,t,i),mo[i]=n,mo[wo][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r;if(void 0===t&&(t={}),N(e)||q(e))return xt.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Ot({},Eo(t.defaults),So(t),{name:i,token:e})),this.config.on_xhr_error&&xt.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:fn.GZipJS;var n=this.Qr();this.persistence=new ys(this.config,n),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new ys(E({},this.config,{persistence:"sessionStorage"}),n);var s=E({},this.persistence.props),a=E({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Zr=new Js(e=>this.ts(e),this.config.request_queue_config),this.es=new Xs(this),this.__request_queue=[];var l="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new to(this),this.sessionPropsManager=new Qs(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(xt.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(xt.info("Initializing extensions synchronously"),this.rs(l)),y.DEBUG=y.DEBUG||this.config.debug,y.DEBUG&&xt.info("Starting in debug mode",{this:this,config:t,thisC:E({},this.config),p:s,s:a}),void 0!==(null==(r=t.bootstrap)?void 0:r.distinctID)){var c,u,d=this.config.get_device_id(gr()),h=null!=(c=t.bootstrap)&&c.isIdentifiedID?d:t.bootstrap.distinctID;this.persistence.set_property(ui,null!=(u=t.bootstrap)&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this.ss()){var p,g,f=Object.keys((null==(p=t.bootstrap)?void 0:p.featureFlags)||{}).filter(e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])}).reduce((e,i)=>{var r;return e[i]=(null==(r=t.bootstrap)||null==(r=r.featureFlags)?void 0:r[i])||!1,e},{}),_=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlagPayloads)||{}).filter(e=>f[e]).reduce((e,i)=>{var r,n;return null!=(r=t.bootstrap)&&null!=(r=r.featureFlagPayloads)&&r[i]&&(e[i]=null==(n=t.bootstrap)||null==(n=n.featureFlagPayloads)?void 0:n[i]),e},{});this.featureFlags.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:_})}if(l)this.register_once({distinct_id:mi,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(gr());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(ui,"anonymous")}return Ut(o,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||gr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(ui,"identified")),t()},n=i.user();"then"in n&&M(n.then)?n.then(r):r(n)}(e,()=>{i.register((e=>{Promise&&Promise.resolve||Dr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Dr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Dr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then(()=>{t()})})}(this,()=>this.ns()):this.ns(),M(this.config._onCapture)&&this.config._onCapture!==yo&&(xt.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&xt.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new Mr(this),this.historyAutocapture.startIfEnabled();var i=[];i.push(()=>{new Vr(this).startIfEnabledOrStop()}),i.push(()=>{var e;this.siteApps=new no(this),null==(e=this.siteApps)||e.init()}),e||i.push(()=>{this.sessionRecording=new vo(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.push(()=>{this.autocapture=new or(this),this.autocapture.startIfEnabled()}),i.push(()=>{this.surveys.loadIfEnabled()}),i.push(()=>{this.logs.loadIfEnabled()}),i.push(()=>{this.conversations.loadIfEnabled()}),i.push(()=>{this.productTours=new Es(this),this.productTours.loadIfEnabled()}),i.push(()=>{this.heatmaps=new pn(this),this.heatmaps.startIfEnabled()}),i.push(()=>{this.webVitalsAutocapture=new un(this)}),i.push(()=>{this.exceptionObserver=new Rr(this),this.exceptionObserver.startIfEnabledOrStop()}),i.push(()=>{this.deadClicksAutocapture=new Fr(this,Cr),this.deadClicksAutocapture.startIfEnabled()}),i.push(()=>{if(this.os){var e=this.os;this.os=void 0,this.wi(e)}}),this.ls(i,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.ls(e,t)},0);var i=e.shift();if(i)try{i()}catch(n){xt.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&xt.info("PostHog extensions initialized ("+r+"ms)")}wi(e){var t,i,r,n,s,o,a,l,c;if(!h||!h.body)return xt.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.wi(e)},500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=$(e.supportedCompression,fn.GZipJS)?fn.GZipJS:$(e.supportedCompression,fn.Base64)?fn.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(r=this.sessionRecording)||r.onRemoteConfig(e),null==(n=this.autocapture)||n.onRemoteConfig(e),null==(s=this.heatmaps)||s.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),null==(o=this.productTours)||o.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(l=this.exceptionObserver)||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(c=this.deadClicksAutocapture)||c.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(i){xt.critical("`loaded` function failed",i)}if(this.us(),this.config.internal_or_test_user_hostname&&null!=p&&p.hostname){var e=p.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this.hs()},1),new Vs(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this.Zr)||e.enable())}_dom_loaded(){this.is_capturing()&&Ct(this.__request_queue,e=>this.ts(e)),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),null==(e=this.Zr)||e.unload(),null==(t=this.es)||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(bo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Xn(e.url,{ip:this.config.ip?1:0}),e.headers=E({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,r,n=E({},e);n.timeout=n.timeout||6e4,n.url=Xn(n.url,{_:(new Date).getTime().toString(),ver:y.LIB_VERSION,compression:n.compression});var s=null!==(t=n.transport)&&void 0!==t?t:"fetch",o=Qn.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),a=null!==(i=null==(r=qt(o,e=>e.transport===s))?void 0:r.method)&&void 0!==i?i:o[0].method;if(!a)throw new Error("No available transport method");a(n)})(E({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&(null==(i=(r=this.config).on_request_error)||i.call(r,t)),null==e.callback||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],r=[],n=[];Ct(e,e=>{e&&(t=e[0],A(t)?n.push(e):M(e)?e.call(this):A(e)&&"alias"===t?i.push(e):A(e)&&-1!==t.indexOf("capture")&&M(this[t])?n.push(e):r.push(e))});var s=function(e,t){Ct(e,function(e){if(A(e[0])){var i=t;Ft(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};s(i,this),s(r,this),s(n,this)}ss(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!N(e)&&j(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!n||this.config.__preview_capture_bot_pageviews){var s=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==s||!s.isRateLimited){null!=t&&t.$current_url&&!j(null==t?void 0:t.$current_url)&&(xt.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(null==i?void 0:i.timestamp)||o,l=gr(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},a,l)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&n&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),s&&(c.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),(null==i?void 0:i.$set)&&(c.$set=null==i?void 0:i.$set);var u,d="$groupidentify"!==e,h=this.vs(null==i?void 0:i.$set_once,d);if(h&&(c.$set_once=h),(c=function(e,t){return i=e,r=e=>j(e)&&!U(t)?e.slice(0,t):e,n=new Set,function e(t,i){return t!==Object(t)?r?r(t):t:n.has(t)?void 0:(n.add(t),A(t)?(s=[],Ct(t,t=>{s.push(e(t))})):(s={},Ft(t,(t,i)=>{n.has(t)||(s[i]=e(t))})),s);var s}(i);var i,r,n}(c,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,N(null==i?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o),e===xs.DISMISSED||e===xs.SENT){var p=null==t?void 0:t[Ps.SURVEY_ID],g=null==t?void 0:t[Ps.SURVEY_ITERATION];u={id:p,current_iteration:g},localStorage.getItem(Fs(u))||localStorage.setItem(Fs(u),"true"),c.$set=E({},c.$set,{[Cs({id:p,current_iteration:g},e===xs.SENT?"responded":"dismissed")]:!0})}else e===xs.SHOWN&&(c.$set=E({},c.$set,{[Ps.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var f=E({},c.properties.$set,c.$set);if(L(f)||this.setPersonPropertiesForFlags(f),!H(this.config.before_send)){var _=this.cs(c);if(!_)return;c=_}this.bi.emit("eventCaptured",c);var v={method:"POST",url:null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.ts(v):this.Zr.enqueue(v),c}xt.critical("This capture call is ignored due to client rate limiting.")}}else xt.error("No event name provided to posthog.capture")}else xt.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var s=n?void 0:this.persistence.remove_event_timer(e),a=E({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=E({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!j(a.distinct_id)&&!W(a.distinct_id)||q(a.distinct_id))&&xt.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=function(e,t){if(!v)return{};var i,r,n,s=e?Rt([],Jr,t||[]):[],[a,l]=function(e){for(var t=0;t<Ke.length;t++){var[i,r]=Ke[t],n=i.exec(e),s=n&&(M(r)?r(n,e):r);if(s)return s}return["",""]}(v);return Ot(Lt({$os:a,$os_version:l,$browser:Je(v,navigator.vendor),$device:Ze(v),$device_type:(r=v,n=Ze(r),n===ce||n===le||"Kobo"===n||"Kindle Fire"===n||n===je?ae:n===Ie||n===Ce||n===Te||n===De?"Console":n===de?"Wearable":n?ne:"Desktop"),$timezone:on(),$timezone_offset:an()}),{$current_url:er(null==p?void 0:p.href,s,Xr),$host:null==p?void 0:p.host,$pathname:null==p?void 0:p.pathname,$raw_user_agent:v.length>1e3?v.substring(0,997)+"...":v,$browser_version:Xe(v,navigator.vendor),$browser_language:tn(),$browser_language_prefix:(i=tn(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==o?void 0:o.screen.height,$screen_width:null==o?void 0:o.screen.width,$viewport_height:null==o?void 0:o.innerHeight,$viewport_width:null==o?void 0:o.innerWidth,$lib:"web",$lib_version:y.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());a.$session_id=d,a.$window_id=g}this.sessionPropsManager&&Ot(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&Ot(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(f=this.es)?void 0:f.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===oo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=Ot(a,c),"$pageview"===e&&h&&(a.title=h.title),!N(s)){var _=i.getTime()-s;a.$duration=parseFloat((_/1e3).toFixed(3))}v&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ot({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),A(this.config.property_denylist)?Ft(this.config.property_denylist,function(e){delete a[e]}):xt.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(xt.error("sanitize_properties is deprecated. Use before_send instead"),a=m(a,e));var w=this.fs();return a.$process_person_profile=w,w&&!n&&this.ps("_calculate_event_properties"),a}vs(e,t){var i;if(void 0===t&&(t=!0),!this.persistence||!this.fs())return e;if(this.qr)return e;var r=this.persistence.get_initial_props(),n=null==(i=this.sessionPropsManager)?void 0:i.getSetOnceProps(),s=Ot({},r,n||{},e||{}),o=this.config.sanitize_properties;return o&&(xt.error("sanitize_properties is deprecated. Use before_send instead"),s=o(s,"$set_once")),t&&(this.qr=!0),L(s)?void 0:s}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var r=null!=i&&i.merge?this.featureFlags.getFlagVariants():{},n=null!=i&&i.merge?this.featureFlags.getFlagPayloads():{},s=E({},r,e),o=E({},n,t),a={};for(var[l,c]of Object.entries(s)){var u="string"==typeof c;a[l]={key:l,enabled:!!u||Boolean(c),variant:u?c:void 0,reason:void 0,metadata:N(null==o?void 0:o[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.featureFlags.receivedFeatureFlags({flags:a})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.bi.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=Rs),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return xt.uninitializedWarning("posthog.identify");if(W(e)&&(e=e.toString(),xt.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))xt.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==mi){if(this.ps("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(Wt)&&(this.unregister(Wt),this.register({distinct_id:e}));var s="anonymous"===(this.persistence.get_property(ui)||"anonymous");e!==r&&s?(this.persistence.set_property(ui,"identified"),this.setPersonPropertiesForFlags(E({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Jr=ts(e,t,i),this.featureFlags.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(ci))}}else xt.critical('The string "'+mi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else xt.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var i=ts(this.get_distinct_id(),e,t);this.Jr!==i?(this.setPersonPropertiesForFlags(E({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=i):xt.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:E({},r,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),r[e]===t||i||this.reloadFeatureFlags()}else xt.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,n;if(xt.info("reset"),!this.__loaded)return xt.uninitializedWarning("posthog.reset");var s=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(r=this.persistence)||r.set_property(ui,"anonymous"),null==(n=this.sessionManager)||n.resetSessionId(),this.Jr=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:mi,$device_id:null},"");else{var o=this.config.get_device_id(gr());this.register_once({distinct_id:o,$device_id:e?o:s},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var n,s=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-s,0)}return r}alias(e,t){return e===this.get_property(Ht)?(xt.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(N(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Wt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(xt.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=E({},this.config);if(D(e)){var i,r,n,s,o,a,l;Ot(this.config,So(e));var c=this.Qr();null==(i=this.persistence)||i.update_config(this.config,t,c),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new ys(E({},this.config,{persistence:"sessionStorage"}),c);var u=this.Kr(this.config.debug);z(u)&&(this.config.debug=u),z(this.config.debug)&&(this.config.debug?(y.DEBUG=!0,wr.H()&&wr.G("ph_debug","true"),xt.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(y.DEBUG=!1,wr.H()&&wr.V("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(n=this.sessionRecording)||n.startIfEnabledOrStop(),null==(s=this.autocapture)||s.startIfEnabled(),null==(o=this.heatmaps)||o.startIfEnabled(),null==(a=this.exceptionObserver)||a.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),null==(l=this.externalIntegrations)||l.startIfEnabledOrStop()}}startSessionRecording(e){var t,i,r,n,s,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("url")),a.event_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(E({},r,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:wo;return t!==wo&&(t=wo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ui))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ui))}fs(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&L(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Wt])&&(null==(t=this.persistence)||null==(t=t.props)||!t[_i]))}ds(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return"never"===this.config.person_profiles?(xt.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(_i,!0),!0)}Qr(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_s(){var e,t,i,r,n=this.Qr();return(null==(e=this.persistence)?void 0:e.Pi)!==n&&(null==(i=this.persistence)||i.set_disabled(n)),(null==(t=this.sessionPersistence)?void 0:t.Pi)!==n&&(null==(r=this.sessionPersistence)||r.set_disabled(n)),n}opt_in_capturing(e){var t,i,r,n;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new to(this),this.pageViewManager=new gn(this),this.persistence&&(this.sessionPropsManager=new Qs(this,this.sessionManager,this.persistence)),this.sessionRecording=new vo(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),(N(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(n=null==e?void 0:e.captureEventName)&&void 0!==n?n:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()):xt.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:mi,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(i=this.sessionRecording)||i.stopRecording(),this.sessionRecording=void 0,this.hs())):xt.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===Pr.GRANTED?"granted":e===Pr.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return d?so(d,this.config.custom_blocked_useragents):void 0}hs(){h&&("visible"===h.visibilityState?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:h.title},{send_instantly:!0}),this.Gr&&(h.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Ut(h,"visibilitychange",this.Gr)))}debug(e){!1===e?(null==o||o.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==o||o.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,i,r,n,s,o=this.Yr||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(xt.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",r=xt,n=(t="advanced_disable_flags")in(e=o)&&!H(e[t]),s=i in e&&!H(e[i]),n?e[t]:!!s&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}cs(e){if(H(this.config.before_send))return e;var t=A(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),H(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return V(e.event)?xt.warn(n+". This can cause unexpected behavior."):xt.info(n),null}i.properties&&!L(i.properties)||xt.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager.Kt)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Kr(e){var t=z(e)&&!e,i=wr.H()&&"true"===wr.q("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Dt(e.prototype[t[i]])}(xo,["identify"]);var Po,$o=(Po=mo[wo]=new xo,function(){function e(){e.done||(e.done=!0,bo=!1,Ft(mo,function(e){e._dom_loaded()}))}null!=h&&h.addEventListener?"complete"===h.readyState?e():Ut(h,"DOMContentLoaded",e,{capture:!1}):o&&xt.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Po);let Io=null,To=!1;const Co="dori_shopify_end_user_id",Fo="dori_shopify_end_user_session",Oo=()=>"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`;let Ro=null;const Ao=()=>{if(Ro)return Ro;let e;try{const t=window?.DORI_CUSTOMER_ID;if(t){let i=window.localStorage.getItem(Fo);i&&i.trim()||(i=Oo(),window.localStorage.setItem(Fo,i)),e=`shopify_customer_${String(t)}_${i}`}else{const t=window.localStorage.getItem(Co);t&&t.trim()?e=t:(e=`anon_${Oo()}`,window.localStorage.setItem(Co,e))}}catch{e=`anon_${Oo()}`}return Ro=e,e};let Mo=null;const Do=e=>(()=>{if(null===Mo){const e=Lo()??"";Mo=(e=>{let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0)/4294967296})(`${e}:${Ao()}`)}return Mo})()<e,Lo=()=>{try{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null}catch{return null}};let No=null;const jo=()=>{const e={},t=Lo();return t&&(e.sharing_id=t),"undefined"!=typeof window&&window.location&&window.location.hostname&&(e.shop_domain=window.location.hostname),e},qo=e=>{if(!e)return;const t=Uo();if(t)try{t.register({thread_id:e})}catch(i){}},Uo=()=>(Io||To||(Io=(()=>{if($o.__loaded)return $o;if(To)return null;To=!0;try{return $o.init("phc_H5oKb44Ke85TJHMvMDD6MzxtjjVeGZZinXVTyC8t0bY",{api_host:"https://us.i.posthog.com",person_profiles:"identified_only",autocapture:!1,capture_pageview:!1,capture_pageleave:!1,capture_performance:!1,capture_dead_clicks:!1,rageclick:!1,disable_session_recording:!0,bootstrap:{distinctID:Ao()},before_send:e=>{if(!e)return e;if("$exception"===e.event)return Do(.1)&&(e=>{const t=e?.properties??{};if("manual"===t.dori_capture)return!0;const i=(()=>{if(No)return No;const e=[];try{const t=document.querySelector("script#dori-side-widget"),i=t?.src;if(i){e.push(i);const t=i.slice(0,i.lastIndexOf("/")+1);t&&t!==i&&e.push(t)}}catch{}return No=e,e})();if(0===i.length)return!0;const r=t.$exception_list;if(!Array.isArray(r)||0===r.length)return!0;for(const n of r){const e=n?.stacktrace?.frames;if(Array.isArray(e))for(const t of e){const e=t?.filename;if("string"==typeof e&&i.some(t=>e.startsWith(t)))return!0}}return!1})(e)?e:null;const t=(e=>e.startsWith("pf.")||e.startsWith("pdp_hero"))(e.event)?1:.1;return Do(t)?e:null},loaded:e=>{try{e.register({...jo(),surface:"side",flow_version:"1.13.184"})}catch(t){}try{e.unregister("occasion"),e.unregister("occasion_arm")}catch(t){}}}),Io=$o,$o}catch(e){return console.error("[PostHog] Failed to initialize:",e),null}finally{To=!1}})()),Io),Ho=(e,t)=>{const i=Uo();if(i)try{i.capture(e,t)}catch(r){}},Wo=(e,t)=>{const i=Uo();if(i)try{console.error("Error captured:",e,t),i.capture("$exception",{$exception_message:e.message,$exception_type:e.name,$exception_stack_trace:e.stack,dori_capture:"manual",...t})}catch(r){console.error("[PostHog] Failed to capture exception:",r)}},Bo=(e,t)=>(...i)=>{try{return console.log("withErrorHandling",e),t(...i)}catch(r){throw console.error("Error in withErrorHandling:",r),Wo(r,{context:e}),r}},zo=(e,t)=>(...i)=>{try{return t(...i).catch(t=>{throw"AbortError"!==t.name&&Wo(t,{context:e}),t})}catch(r){throw"AbortError"!==r.name&&Wo(r,{context:e}),r}},Vo="dori_widget_bot_data",Go="dori_widget_bot_data_etag",Jo="dori_widget_bot_data_sharing_id",Yo="dori_widget_session_sharing_id",Xo="dori_widget_chat_state",Ko="dori_widget_messages",Zo="dori_widget_current_step",Qo="dori_widget_session_timestamp",ea="dori_widget_fab_animation_timestamp",ta="dori_thread_id",ia="dori_session_key",ra="dori_loaded_from_storage",na="dori_shopify_end_user_id",sa="dori_shopify_end_user_session";function oa(){if("undefined"==typeof window)return"";const e=window;if(e.chatbotData?.sharingID)return String(e.chatbotData.sharingID);const t=document.querySelector("script#dori-side-widget");return t?.getAttribute("data-sharing-id")||""}function aa(){try{const e="__test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}function la(){aa()&&localStorage.setItem(ra,"true")}function ca(){aa()&&localStorage.removeItem(ra)}function ua(){try{const e=localStorage.getItem(Qo);if(!e)return!1;const t=parseInt(e,10);return Date.now()-t<864e5}catch{return!1}}function da(){if(aa())try{[Xo,Ko,Zo,ta,ia,ra,na,sa].forEach(e=>{localStorage.removeItem(e)})}catch(e){console.error("Error clearing local storage:",e)}}function ha(){const e=oa();return!e||localStorage.getItem(Jo)===e}function pa(e){if(aa())try{if(e){localStorage.setItem(Vo,JSON.stringify(e));const t=oa();t&&localStorage.setItem(Jo,t)}else localStorage.removeItem(Vo),localStorage.removeItem(Jo)}catch(t){console.error("Error saving bot data:",t)}}function ga(){if(!aa()||!ua())return null;if(!ha())return null;try{const e=localStorage.getItem(Vo);return e?JSON.parse(e):null}catch(e){return console.error("Error loading bot data:",e),null}}function fa(){if(aa())try{localStorage.removeItem(Vo),localStorage.removeItem(Go),localStorage.removeItem(Jo)}catch(e){console.error("Error clearing bot data cache:",e)}}function _a(e){if(aa())try{localStorage.setItem(Xo,JSON.stringify(e))}catch(t){console.error("Error saving chat state:",t)}}function va(e){if(aa())try{const t=e.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():e.timestamp}));localStorage.setItem(Ko,JSON.stringify(t))}catch(t){console.error("Error saving messages:",t)}}function ma(){if(!aa()||!ua())return[];try{const e=localStorage.getItem(Ko);return e?JSON.parse(e).map(e=>({...e,content:"string"==typeof e.content?r(e.content):e.content,timestamp:new Date(e.timestamp)})):[]}catch(e){return console.error("Error loading messages:",e),[]}}function ya(e){if(aa())try{localStorage.setItem(Zo,e)}catch(t){console.error("Error saving current step:",t)}}function wa(){if(!aa()||!ua())return null;try{const e=ga(),t=function(){if(!aa()||!ua())return null;try{const e=localStorage.getItem(Xo);return e?JSON.parse(e):null}catch(e){return console.error("Error loading chat state:",e),null}}(),i=ma(),r=function(){if(!aa()||!ua())return"welcome";try{return localStorage.getItem(Zo)||"welcome"}catch(e){return console.error("Error loading current step:",e),"welcome"}}();return e||i.length>0?{botData:e,chatState:t||{repliedProduct:null,focusedProduct:null,threadId:null,isRequestInProgress:!1},messages:i,currentStep:r,sessionTimestamp:Date.now()}:null}catch(e){return console.error("Error loading session data:",e),null}}function ba(){if(!aa()||!ua())return!1;try{const e=ga(),t=ma();return!!(e||t.length>0)}catch{return!1}}function Ea(){if(aa())try{localStorage.setItem(Qo,Date.now().toString())}catch(e){console.error("Error updating session timestamp:",e)}}function Sa(){if(aa())try{localStorage.setItem(ea,Date.now().toString())}catch(e){console.error("Error saving FAB animation timestamp:",e)}}function ka(){const e=function(){if(!aa()||!ua())return null;try{const e=localStorage.getItem(ea);return e?parseInt(e,10):null}catch(e){return console.error("Error loading FAB animation timestamp:",e),null}}();return!e||Date.now()-e>=3e5}function xa(){if(!aa())return"";try{let e=localStorage.getItem(ia);return e||(e="dori_session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),localStorage.setItem(ia,e)),e}catch(e){return console.error("Error generating session key:",e),""}}function Pa(e){if(aa()&&e){try{localStorage.setItem(ta,e)}catch(t){console.error("Error storing dori thread ID:",t)}qo(e)}}function $a(){if(!aa())return null;try{const e=localStorage.getItem(ta);return qo(e),e}catch(e){return console.error("Error retrieving dori thread ID:",e),null}}function Ia(e){const t=window?.chatbotData;if("undefined"!=typeof window&&t?.ajaxurl){const i=xa();fetch(t.ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"dori_store_thread_session",thread_id:e,session_key:i,nonce:t.nonce})}).catch(e=>console.warn("Failed to store thread in WooCommerce session:",e))}}const Ta="https://standardapi.dori.tech",Ca=["pointerdown","keydown"],Fa=["pointermove","touchstart","wheel","scroll"],Oa=["pointerover","focusin","click"];function Ra(e){const t=(e instanceof Error?e.message:String(e??"")).match(/https?:\/\/[^\s"')]+/);if(!t)return null;const i=t[0].replace(/[.,;:]+$/,"");return/\.m?js(\?|$)/.test(i)?i:null}function Aa(e){return e+(e.includes("?")?"&":"?")+"dori-retry=1"}async function Ma(e,t,i,r=500,n=e=>import(e)){try{return await e()}catch(s){const e=Ra(s);if(!e)return i?.(s,s),{default:t};await new Promise(e=>setTimeout(e,r));try{return await n(Aa(e))}catch(o){return i?.(s,o),{default:t}}}}function Da(e,t){return e&&("header_button"===t||"header_block"===t)}function La(e){if("undefined"==typeof window)return;const t=window;t.__doriOpenReady=!0;const i=t.__doriOpenQueue||[];t.__doriOpenQueue=[],i.length&&e(i[i.length-1])}let Na=null;const ja=e=>{Na=e},qa=()=>{if("undefined"==typeof window)return"";const e=window.location.href;if(!Na)return e;try{const t=new URL(e);return t.hash=`dori_entry=${encodeURIComponent(Na)}`,t.toString()}catch{return e}};function Ua(){try{return globalThis.window?.Shopify??null}catch{return null}}function Ha(){try{const e=Ua()?.customerPrivacy;return e&&"function"==typeof e.preferencesProcessingAllowed?e:null}catch{return null}}function Wa(){try{const e=Ha();return e?!!e.preferencesProcessingAllowed():null}catch{return null}}function Ba(){return Wa()}const za="dori:consent-settled";let Va=!1;function Ga(){return!!Va||((Ha()||"function"!=typeof Ua()?.loadFeatures)&&(Va=!0),Va)}let Ja=!1;function Ya(){if(Va=!0,!Ja){Ja=!0;try{const e=globalThis.window;e?.dispatchEvent?.(new CustomEvent(za))}catch{}}}let Xa=null;function Ka(){if(Ga())return Ya(),Promise.resolve(Wa());if(Xa)return Xa;const e=Ua()?.loadFeatures;return Xa=new Promise(t=>{let i=!1;const r=()=>{i||(i=!0,clearTimeout(n),Ya(),t(Wa()))},n=setTimeout(r,4e3);try{e.call(Ua(),[{name:"consent-tracking-api",version:"0.1"}],r)}catch{r()}}).finally(()=>{Xa=null}),Xa}function Za(e){const t=globalThis.document;if(!t?.addEventListener)return()=>{};const i=()=>e(Wa());return t.addEventListener("visitorConsentCollected",i),()=>t.removeEventListener("visitorConsentCollected",i)}const Qa=2592e6,el={product_prompts:[]},tl="dori_shopper_note:v3:",il=["dori_shopper_note:v1:","dori_shopper_note:v2:"],rl="__doriShopperNoteFallback";function nl(){try{const e=globalThis.window;return e?(e[rl]||(e[rl]={}),e[rl]):null}catch{return null}}const sl="dori:shopper-note";function ol(){try{const e=globalThis.window;e?.dispatchEvent?.(new CustomEvent(sl))}catch{}}function al(e){const t=globalThis.window;if(!t?.addEventListener)return()=>{};const i=t=>{t.key&&!t.key.startsWith(tl)||e()};return t.addEventListener(sl,e),t.addEventListener(za,e),t.addEventListener("storage",i),()=>{t.removeEventListener(sl,e),t.removeEventListener(za,e),t.removeEventListener("storage",i)}}function ll(){try{return globalThis.window?.localStorage??null}catch{return null}}function cl(e){return e.testMode||!e.sharingId?null:Ga()&&!1!==Ba()?`${tl}${e.sharingId}`:null}const ul="__doriShopperNoteRevFloor";function dl(){try{const e=globalThis.window;return e?(e[ul]||(e[ul]={}),e[ul]):null}catch{return null}}function hl(e,t){return Math.max(t?.rev??0,dl()?.[e]??0)}function pl(e,t){const i=dl();i&&(i[e]=Math.max(i[e]??0,t+1))}function gl(e){let t=nl()?.[e]?.rev??0;try{const i=ll()?.getItem(e),r=i?JSON.parse(i):null;r&&"number"==typeof r.rev&&(t=Math.max(t,r.rev))}catch{}return t}function fl(e,t){return Array.isArray(e)?e.filter(e=>!!e&&"string"==typeof e.path&&"string"==typeof e.at&&bl(e.path)===e.path&&t-Date.parse(e.at)<=Qa).map(e=>({path:e.path,at:e.at})).slice(-6):[]}function _l(e){const t=e?.product_prompts;return Array.isArray(t)?{product_prompts:t.filter(e=>!!e&&"string"==typeof e.product_id&&("string"==typeof e.text||null===e.text)&&"number"==typeof e.rev).map(e=>({product_id:e.product_id,text:e.text,rev:e.rev})).slice(-8)}:el}function vl(e,t){let i=!1;try{const r=ll();r&&(r.setItem(e,JSON.stringify(t)),i=!0)}catch{i=!1}if(!i){const i=nl();i&&(i[e]=t)}ol()}function ml(e){const t=cl(e);if(!t)return null;const i=function(e,t){let i=null;try{i=ll()?.getItem(e)??null}catch{i=null}const r=function(e,t=Date.now()){if(!e)return null;try{const i=JSON.parse(e);return i&&3===i.v&&"string"==typeof i.updated_at?{v:3,rev:"number"==typeof i.rev?i.rev:0,memory:"string"==typeof i.memory?i.memory:null,last_product_id:"string"==typeof i.last_product_id?i.last_product_id:null,pages:fl(i.pages,t),plan:_l(i.plan),updated_at:i.updated_at}:null}catch{return null}}(i,t);if(r)return r;const n=nl()?.[e];return n?{...n,pages:fl(n.pages,t),plan:_l(n.plan)}:null}(t,e.now??Date.now());return i?function(e,t){const i=Date.parse(e.updated_at);return!Number.isFinite(i)||t-i>Qa}(i,e.now??Date.now())?(function(e){const t=cl(e);if(!t)return;pl(t,gl(t));const i=nl();i&&delete i[t];try{ll()?.removeItem(t)}catch{}ol()}(e),null):i:null}function yl(e){const t=cl(e);return t?hl(t,ml(e)):0}function wl(e,t,i){const r=cl(e);if(!r)return null;const n=ml(e),s=hl(r,n);if(void 0!==i&&s!==i)return n;const o={v:3,rev:s+1,memory:n?.memory??null,last_product_id:n?.last_product_id??null,pages:n?.pages??[],plan:el,...t,updated_at:new Date(e.now??Date.now()).toISOString()};return vl(r,o),o}function bl(e){let t;try{t=new URL(e,"https://store.invalid")}catch{return null}const i=t.pathname.replace(/^\/[a-z]{2}(?:-[a-z0-9]{2,4})?(?=\/(?:products|collections|pages|search)(?:\/|$))/i,"").replace(/\/+$/,"");if("/search"===i.toLowerCase()){const e=(t.searchParams.get("q")||"").replace(/[&#?\s]+/g," ").trim().slice(0,60).trim();return!e||/@|\d{6,}|\d(?:[\s().+\-/]*\d){6,}/.test(e)?null:`/search?q=${e}`}const r=i.match(/^(?:\/collections\/[^/]+)?\/(products)\/([^/]+)$|^\/(collections|pages)\/([^/]+)$/i);if(!r)return null;const n=(r[1]||r[3]).toLowerCase();let s=r[2]||r[4];try{s=decodeURIComponent(s)}catch{}return!s||s.length>100||/[\s/?#]/.test(s)?null:`/${n}/${s}`}function El(e,t){if(!0!==Ba())return;const i=cl(e),r=bl(t);if(!i||!r)return;const n=ml(e),s=n?.pages??[];if(s.length&&s[s.length-1].path===r)return;const o=new Date(e.now??Date.now()).toISOString();vl(i,{v:3,rev:hl(i,n),memory:n?.memory??null,last_product_id:n?.last_product_id??null,pages:[...s.filter(e=>e.path!==r),{path:r,at:o}].slice(-6),plan:n?.plan??el,updated_at:n?.updated_at??o})}function Sl(){const e=nl();if(e)for(const t of Object.keys(e))pl(t,gl(t)),delete e[t];try{const e=ll();e&&xl(e,["dori_shopper_note:"]).forEach(t=>{pl(t,gl(t)),e.removeItem(t)})}catch{}ol()}function kl(){try{const e=ll();e&&xl(e,il).forEach(t=>e.removeItem(t))}catch{}}function xl(e,t){const i=[];for(let r=0;r<e.length;r++){const n=e.key(r);n&&t.some(e=>n.startsWith(e))&&i.push(n)}return i}function Pl(e,t,i){if(t.forget)return void function(e){const t=cl(e);t&&vl(t,{v:3,rev:hl(t,ml(e))+1,memory:null,last_product_id:null,pages:[],plan:el,updated_at:new Date(e.now??Date.now()).toISOString()})}(e);const r=void 0!==t.memory;!r||t.memory?wl(e,{...r?{memory:t.memory??null}:{}},i.basedOnRev):wl(e,{memory:null,last_product_id:null},i.basedOnRev)}function $l(e,t){if(!e)return;const i=t?bl(t):null,r=!0===Ba()?e.pages.filter(e=>e.path!==i).slice(-5):[];return e.memory||r.length?{memory:e.memory,last_product_id:e.last_product_id,...r.length?{pages:r}:{}}:void 0}const Il="/apps/dori/customer-token";let Tl=null,Cl=0,Fl=null;function Ol(e=Date.now()){return function(){if("undefined"==typeof window)return!1;const e=window.DORI_CUSTOMER_ID;return null!=e&&""!==String(e).trim()}()?Tl&&Tl.expiresAt-3e5>e?Promise.resolve(Tl.token):e<Cl?Promise.resolve(null):(Fl||(Fl=async function(){const e=new AbortController,t=setTimeout(()=>e.abort(),2500);try{const t=await fetch(function(){if("undefined"==typeof document)return Il;const e=function(e){const t=e?.dataset.prefix;return t&&Yc.test(t)?t:null}(Kc(document));return e?`${e}/customer-token`:Il}(),{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"},signal:e.signal}),i=t.ok?await t.json():null,r="string"==typeof i?.token?i.token:null,n="number"==typeof i?.expires_in?i.expires_in:0;return r&&n>0?(Tl={token:r,expiresAt:Date.now()+1e3*n},r):(Tl=null,Cl=Date.now()+3e5,null)}catch{return null}finally{clearTimeout(t)}}().finally(()=>{Fl=null})),Fl):Promise.resolve(null)}function Rl(){Ol()}function Al(e){return e.add_quantity&&e.add_quantity>0?Math.floor(e.add_quantity):e.minimum_quantity&&e.minimum_quantity>1?Math.floor(e.minimum_quantity):1}function Ml(e){return e.price_unit&&e.add_quantity?`1 ${e.price_unit}`:void 0}function Dl(){if("undefined"==typeof window)return;const e=window.Shopify?.country;return"string"==typeof e&&/^[A-Za-z]{2}$/.test(e)?e.toUpperCase():void 0}const Ll=(e,t)=>Object.assign(t,{doriCode:e}),Nl=e=>{const t=e?.doriCode;return"string"==typeof t?t:"unknown"},jl="__dori_usage_cap_silent__",ql={demoSharingData:`${Ta}/bot-sharing-data/`,runAssistant:`${Ta}/v2/run-assistant`,streamV2:`${Ta}/v2/stream`,cartContextSync:`${Ta}/shopify/cart-context/sync`,searchProductLog:`${Ta}/search-selected-item-log`,getUploadUrl:`${Ta}/get-upload-url`,trackProductView:`${Ta}/roi/track-view`,trackSession:`${Ta}/roi/track-session`,messageFeedback:`${Ta}/feedback/message`,threadContact:`${Ta}/thread`,handover:`${Ta}/handover/chat`,klaviyoCard:`${Ta}/integrations/klaviyo/request`,omnisendCard:`${Ta}/integrations/omnisend/request`,klaviyoStorefront:`${Ta}/integrations/klaviyo/storefront`,storeQuizzes:`${Ta}/store-quizzes`};async function Ul(e,t,i,r=[],n=!1){const s=oa();if(!e.card_id||!s)return"expired";try{const a=await fetch((o=e.provider,"omnisend"===o?ql.omnisendCard:ql.klaviyoCard),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({card_id:e.card_id,email:t,marketing_consent:i,sharing_id:s,choices:r,signed_up:n})});if(!a.ok)return"error";const l=await a.json();return"string"==typeof l?.status?l.status:"error"}catch{return"error"}var o}async function Hl(e,t){const i=await zl(e,t);return!!i?.ok}async function Wl(e,t,i=!1){const r=await zl(e,{...t,trigger:"handover"},{partial:!0,replace:i});if(!r)return{ok:!1,invalid:!1};if(400===r.status)return{ok:!1,invalid:!0};if(!r.ok)return{ok:!1,invalid:!1};const n=await r.json().catch(()=>({}));return{ok:!0,email:n.contact_email??null,phone:n.contact_phone??null}}async function Bl(e,t){const i=await zl(e,{email:t,trigger:"email_signup"},{partial:!0});return!!i?.ok}async function zl(e,t,{partial:i=!1,replace:r=!1}={}){const n=oa();if(!e||!n)return null;await Ka();const s=(o=ml({sharingId:n,testMode:!1}))&&o.memory?{memory:o.memory,last_product_id:o.last_product_id}:null;var o;try{return await fetch(`${ql.threadContact}/${e}/contact`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sharing_id:n,phone:t.phone??null,email:t.email??null,trigger:t.trigger??null,shopper_note:s,partial:i,replace:r})})}catch(a){return console.error("[Dori Widget] Failed to save contact details:",a),null}}async function Vl(e,t,i,r=!1,n=null,s=[]){const o=new URLSearchParams({sharing_id:t});null!==i&&o.set("after",String(i)),r&&o.set("typing","true"),null!==n&&o.set("seen",String(n)),s.length&&o.set("shown",s.join(","));try{const t=await fetch(`${ql.handover}/${encodeURIComponent(e)}?${o}`);return t.ok?await t.json():null}catch{return null}}const Gl=zo("sendMessageToStreamAPI",async(e,t,i,r,n,s,o,a,l,c,u,d,h,p)=>{const g=t.assistant_id,f="undefined"!=typeof document?document.querySelector("script#dori-side-widget"):null,_=f?.getAttribute("data-currency")||void 0,v=c?null:await Ol(),m={assistant_id:g,thread_id:i||void 0,message:e,src:qa(),platform:"shopify_widget",image_url:a,end_user_id:l,browser_id:l,test_mode:c||void 0,focused_product_id:u||void 0,shortlist:d&&d.length>0?d:void 0,currency:_,country:Dl(),shopper_note:h,customer_token:v||void 0,supports_handover:!0,...Zc(p)};let y;Object.keys(m).forEach(e=>void 0===m[e]&&delete m[e]);const w={Accept:"application/json","Content-Type":"application/json"};"undefined"!=typeof window&&window.idToken&&(w.Authorization=`Bearer ${window.idToken}`);const b=new AbortController,E=()=>b.abort();o?.signal.addEventListener("abort",E);const S=setTimeout(()=>b.abort(),25e3);try{y=await fetch(ql.runAssistant,{method:"POST",headers:w,body:JSON.stringify(m),signal:b.signal})}catch($){throw console.error("[Dori Widget] Run assistant request failed:",{error:$,errorName:$?.name,errorMessage:$?.message,assistant_id:g,thread_id:i}),Ll("run_fetch_failed",$)}finally{clearTimeout(S),o?.signal.removeEventListener("abort",E)}if(o?.signal.aborted)return;if(429===y.status)return console.error("[Dori Widget] API rate limit exceeded:",{status:429,assistant_id:g,thread_id:i}),void n("You have exceeded the request limit. Please wait at least 24 hours and try again.");if(402===y.status)return console.error("[Dori Widget] Monthly conversation limit reached:",{status:402,assistant_id:g,thread_id:i}),void n(jl);if(401===y.status){const e=await async function(e){fa();const t=oa();if(!t)return null;try{const i=await fetch(`${ql.demoSharingData}${t}`);if(!i.ok)return null;const r=await i.json(),n=r?.data,s=n?.assistant_id;return s?(pa(n),e.assistant_id=s,s):null}catch(i){return console.error("[Dori Widget] Failed to recover assistant_id:",i),null}}(t);if(e&&e!==g){console.warn("[Dori Widget] Stale assistant_id — retrying with refreshed id:",{stale:g,refreshed:e}),m.assistant_id=e;const t=new AbortController,i=setTimeout(()=>t.abort(),25e3);try{y=await fetch(ql.runAssistant,{method:"POST",headers:w,body:JSON.stringify(m),signal:t.signal})}catch(I){throw console.error("[Dori Widget] Retry after stale assistant_id failed:",I),Ll("run_fetch_failed_retry",I)}finally{clearTimeout(i)}}}if(!y.ok)throw console.error("[Dori Widget] Run assistant response not OK:",{status:y.status,statusText:y.statusText,assistant_id:m.assistant_id,thread_id:i}),Ll(`run_http_${y.status}`,new Error(`Run assistant request failed with status ${y.status}: ${y.statusText}`));let k;try{k=await y.json()}catch(T){throw console.error("[Dori Widget] Failed to parse run assistant response:",T),Ll("run_parse_failed",new Error("Failed to parse run assistant response"))}const x=k.thread_id;if(!x)throw Ll("run_no_thread_id",new Error("No thread_id received from run assistant"));if("live"===k.handover)return r({thread_id:x,handover:"live"}),void s();if("running"===k.turn||"done"===k.turn)return r({thread_id:x,turn:k.turn}),void s();const P=`${ql.streamV2}/${x}`;return new Promise(e=>{const t=new EventSource(P);let i=!1;const a=()=>{d()};let l;o&&o.signal.addEventListener("abort",a);let c=!1;const u=()=>{clearTimeout(l),l=setTimeout(()=>{if(c)return console.warn("[Dori Widget] Suggestions tail timed out — completing without chips",{thread_id:x}),void d(()=>s());console.error("[Dori Widget] SSE stream silent too long — surfacing error",{thread_id:x,readyState:t.readyState}),d(()=>n("The connection dropped while waiting for a reply. Please send your message again."))},c?15e3:45e3)},d=r=>{i||(i=!0,clearTimeout(l),o&&o.signal.removeEventListener("abort",a),t.close(),r?.(),e())};u(),t.onopen=()=>{u(),console.log("[Dori Widget] SSE stream connected",{thread_id:x})},t.onerror=()=>{console.log("[Dori Widget] SSE stream error, EventSource will auto-reconnect",{thread_id:x,readyState:t.readyState})},t.onmessage=e=>{u(),Bo("SSE message parse",()=>{const t=JSON.parse(e.data);"suggestions_pending"!==t.status||c||(c=!0,u());const i={thread_id:t.thread_id,text:t.text,wait:t.wait,tool_name:t.tool_name,products:t.products,shape:t.shape,status:t.status,suggestions:t.suggestions,action:t.action,shopper_note:t.shopper_note};Object.keys(i).forEach(e=>void 0===i[e]&&delete i[e]),Object.keys(i).length>0&&r(i)})()},t.addEventListener("start",()=>{u(),console.log("[Dori Widget] SSE stream started",{thread_id:x})}),t.addEventListener("end",()=>{console.log("[Dori Widget] SSE stream ended",{thread_id:x}),d(s)})})}),Jl=zo("trackProductClick",async(e,t,i)=>{zc("opened",{assistantId:t.assistant_id,threadId:i,how:"page"});const r={log:{assistant_id:t.assistant_id,thread_id:i,created_at:(new Date).toISOString(),selected_item_id:e.id,tool_call_id:e.tool_call_id}};await fetch(ql.searchProductLog,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r),keepalive:!0})});function Yl(){if("undefined"==typeof document)return null;const e=document.cookie.match(/(?:^|;\s*)dori_client_id=([^;]+)/);return e?decodeURIComponent(e[1]):null}const Xl=zo("trackProductViewsBatch",async(e,t,i,r,n,s,o,a)=>{if(0===e.length)return;const l={customer_email:s||null,customer_id:o||null,external_product_ids:e,thread_id:t,platform:r,session_key:i,sharing_id:n,end_user_id:a||null,client_id:Yl()};await fetch(ql.trackProductView,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(l)})}),Kl=zo("trackSession",async(e,t,i,r,n,s)=>{if(!e||!t)return;const o={sharing_id:t,thread_id:e,platform:i,session_key:r,customer_id:n||null,end_user_id:s||null,client_id:Yl()};await fetch(ql.trackSession,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)})});async function Zl(e,t,i){try{const r=new AbortController,n=setTimeout(()=>r.abort(),2e4),s=i?AbortSignal.any([i,r.signal]):r.signal,o=await fetch(`${ql.storeQuizzes}/${e}?lang=${encodeURIComponent(t)}`,{signal:s});if(clearTimeout(n),!o.ok)return console.warn("[Dori Widget] Store quizzes fetch failed:",o.status),null;const a=await o.json(),l=a?.variants;return l&&Array.isArray(l)&&0!==l.length?l.map(e=>({welcome_hook:e.welcome_hook||"",entry_label:e.entry_label||"",steps:e.steps||[],result_prompt:e.result_prompt||"",result_type:e.quiz_type||e.result_type||"recommendation",analyzing_text:e.analyzing_text||"",email_signup:a?.email_signup?.headline?a.email_signup:null})):null}catch(r){return"AbortError"!==r?.name&&console.warn("[Dori Widget] Store quizzes error:",r),null}}let Ql=0;function ec(e){return"shopify"===String(e?.platform||"").toLowerCase()}function tc(){if("undefined"==typeof window)return"/";const e=window.Shopify?.routes?.root||"/";return e.endsWith("/")?e:`${e}/`}function ic(){const e=window.HeadlessCheckout;if("function"==typeof e?.checkout)try{return void e.checkout(null)}catch{}window.location.href=`${tc()}checkout`}function rc(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function nc(){if("undefined"==typeof window)return`anon_${rc()}`;try{const e=window.localStorage.getItem(na);if(e&&e.trim())return e;const t=`anon_${rc()}`;return window.localStorage.setItem(na,t),t}catch{return`anon_${rc()}`}}async function sc(){try{const e=tc(),t=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)return null;const i=await t.json();return{item_count:Number(i?.item_count||0),total_price:Number(i?.total_price||0),currency:String(i?.currency||""),items:Array.isArray(i?.items)?i.items:[]}}catch{return null}}const oc=e=>e&&"Default Title"!==e?e:null;function ac(e,t){if(!e)return null;const i=null!=t.variantId?String(t.variantId):null;let r;i&&(r=e.items.find(e=>String(e.id)===i)),!r&&t.name&&(r=e.items.find(e=>e.product_title===t.name));const n=e.items.filter(e=>e!==r),s=n.slice(0,2).map(e=>{const t=e.final_price??e.price;return{title:e.product_title??null,variant_title:oc(e.variant_title),quantity:e.quantity,line_price:e.final_line_price??(null!=t?t*e.quantity:null),image:e.image??null}});return{currency:e.currency,item_count:e.item_count,total_price:e.total_price,added:{name:t.name??r?.product_title??null,variant_title:oc(t.variantTitle)??oc(r?.variant_title),image:r?.image??null,quantity:t.quantity??r?.quantity??1,unit_price:r?.final_price??r?.price??null},others:s,hidden_line_count:Math.max(0,n.length-s.length)}}let lc=!1;async function cc(){if("undefined"!=typeof window&&!lc){lc=!0;try{const e=tc(),t=nc(),i=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!i.ok)return;const r=await i.json(),n=r?.attributes||{};if(n._dori_visitor_id===t)return;await fetch(`${e}cart/update.js`,{method:"POST",credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({attributes:{...n,_dori_visitor_id:t}})})}catch{}finally{lc=!1}}}async function uc(){if("undefined"!=typeof window&&!lc){lc=!0;try{const e=tc(),t=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)return;const i=await t.json();if(!i?.attributes||!("_dori_visitor_id"in i.attributes))return;await fetch(`${e}cart/update.js`,{method:"POST",credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({attributes:{_dori_visitor_id:""}})})}catch{}finally{lc=!1}}}async function dc(e){const t=Date.now();if(t-Ql<800)return null;Ql=t;const i=await async function(){try{const e=tc(),t=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)return null;const i=await t.json(),r=String(i?.token||"").trim();return r?{token:r,item_count:Number(i?.item_count||0),currency:String(i?.currency||""),total_price:Number(i?.total_price||0),subtotal_price:Number(i?.items_subtotal_price||0),updated_at:(new Date).toISOString()}:null}catch{return null}}();if(!i)return null;try{const t=await fetch(ql.cartContextSync,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({assistant_id:e.assistantId,platform:e.platform,end_user_id:e.endUserId,thread_id:e.threadId||void 0,cart:i,src:e.src||("undefined"!=typeof window?window.location.href:"")})});if(!t.ok)return null;const r=await t.json();return"string"==typeof r?.thread_id?r.thread_id:null}catch{return null}}function hc(e,t){const i=e.toUpperCase();return!!["POST","PUT","PATCH","DELETE"].includes(i)&&["/cart/add","/cart/change","/cart/update","/cart/clear"].some(e=>t.includes(e))}function pc(e){if("undefined"==typeof window)return()=>{};let t=null;const i=()=>{null!==t&&window.clearTimeout(t),t=window.setTimeout(()=>{e()},700)},r=window.fetch.bind(window);window.fetch=async(...e)=>{const t=await r(...e);try{const t=e[0],r=e[1];hc((r?.method||(t instanceof Request?t.method:"GET")||"GET").toString(),"string"==typeof t?t:t instanceof URL?t.toString():t.url)&&i()}catch{}return t};const n=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(e,t,i,r,s){return this.__doriCartMethod=e,this.__doriCartUrl=String(t||""),n.call(this,e,t,i??!0,r,s)},XMLHttpRequest.prototype.send=function(e){return this.addEventListener("loadend",()=>{try{hc(String(this.__doriCartMethod||"GET"),String(this.__doriCartUrl||""))&&i()}catch{}}),s.call(this,e)},()=>{window.fetch=r,XMLHttpRequest.prototype.open=n,XMLHttpRequest.prototype.send=s,null!==t&&window.clearTimeout(t)}}const gc=["cart-icon-bubble","cart-drawer","cart-notification-product","cart-notification-button","cart-live-region-text"],fc=[".cart-count-bubble","[data-cart-count]",".cart-count",".cart-item-count","#CartCount",".site-header__cart-count",".header__cart-count",".js-cart-count"];function _c(e){if(!e)return null;try{return new URL(e,window.location.origin).pathname.replace(/\/$/,"")}catch{return null}}function vc(e=document){return Array.from(e.querySelectorAll("a[href]")).filter(e=>function(e){const t=_c(e);return!!t&&/^(\/[a-z]{2}(-[a-z]{2})?)?\/cart$/i.test(t)}(e.getAttribute("href")))}function mc(e,t){if(!t)return!1;try{const i=(new DOMParser).parseFromString(t,"text/html"),r=i.getElementById(`shopify-section-${e}`)||i.querySelector(".shopify-section"),n=document.getElementById(`shopify-section-${e}`);if(n&&r)return n.replaceWith(r),!0;const s=document.getElementById(e);if(s&&r)return s.innerHTML=r.innerHTML,!0;const o=document.querySelector(e),a=i.querySelector(e);if(o&&a)return o.replaceWith(a),!0}catch{}return!1}function yc(e,t){let i=2;try{i=new Intl.NumberFormat("en",{style:"currency",currency:t}).resolvedOptions().maximumFractionDigits??2}catch{}return{amount:(Number(e)/100).toFixed(i),currencyCode:t}}function wc(e){const t=String(e?.currency||"USD"),i=String(e?.token??""),r=Array.isArray(e?.items)?e.items:[];return{id:`gid://shopify/Cart/${i}`,totalQuantity:Number(e?.item_count)||0,cost:{totalAmount:yc(e?.total_price??0,t)},lines:r.map(e=>({id:`gid://shopify/CartLine/${e?.key??e?.id}?cart=${i}`,quantity:Number(e?.quantity)||0,cost:{totalAmount:yc(e?.final_line_price??0,t)}})),discountCodes:(Array.isArray(e?.discount_codes)?e.discount_codes:[]).map(e=>({applicable:e?.applicable,code:e?.code}))}}function bc(){return!!Ec()&&(window.dispatchEvent(new CustomEvent("dori:close-widget",{detail:{reason:"cart"}})),!0)}function Ec(){if("undefined"==typeof document)return!1;const e=['[data-testid="cart-drawer-trigger"]','button[aria-haspopup="dialog"][aria-label="Cart" i]','[aria-controls="CartDrawer"]',".js-drawer-open-cart",'[data-drawer-toggle="cart"]'];for(const r of e){const e=Array.from(document.querySelectorAll(r)),t=e.find(e=>null!==e.offsetParent)||e[0];if(t){const e=document.getElementById(t.getAttribute("aria-controls")||"")||document.querySelector("cart-drawer-component, cart-drawer");if("true"===t.getAttribute("aria-expanded")||kc(e))return Sc(e);try{return t.click(),Sc(e)}catch{}}}if(document.querySelector("cart-drawer")){const e=document.querySelector("#cart-icon-bubble");if(e)try{return e.click(),Sc(document.querySelector("cart-drawer"))}catch{}}const t=document.querySelector("cart-drawer-component");if(t){const e=t.querySelector?.("dialog");if(e&&!e.open&&"function"==typeof e.showModal)try{return e.showModal(),Sc(t)}catch{}try{return t.open=!0,Sc(t)}catch{}}const i=document.querySelector("cart-drawer");if(i&&"function"==typeof i.open){i.classList?.remove?.("is-empty");try{return i.open(),Sc(i)}catch{}}return!1}function Sc(e){return async function(e){if(!e)return;const t=tc();let i=[];try{const e=await fetch(`${t}cart.js`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});if(!e.ok)return;const r=await e.json();i=Array.isArray(r?.items)?r.items:[]}catch{return}if(i.length){for(let t=0;t<1500;t+=250){if(kc(e)&&xc(e,i))return;await new Promise(e=>setTimeout(e,250))}kc(e)&&!xc(e,i)&&(window.location.href=`${t}cart`)}}(e).catch(()=>{}),!0}function kc(e){if(!e)return!1;let t=e;e.getBoundingClientRect().width<1&&(t=e.querySelector("dialog, [role='dialog']")||e);const i=t.getBoundingClientRect();if(i.width<1||i.height<1)return!1;if(i.right<=0||i.bottom<=0||i.left>=window.innerWidth||i.top>=window.innerHeight)return!1;if("hidden"===getComputedStyle(t).visibility)return!1;for(let r=t;r&&r!==document.body;r=r.parentElement)if(Number(getComputedStyle(r).opacity)<.05)return!1;return!0}function xc(e,t){const i=e=>String(e??"").toLowerCase().replace(/\s+/g," ").trim(),r=i(e.innerText??e.textContent),n=Array.from(e.querySelectorAll("a[href]")).filter(e=>e.getClientRects().length>0).map(e=>{const t=e.getAttribute("href")||"";try{return decodeURI(t)}catch{return t}});return t.some(e=>{const t=String(e?.handle||"");if(t&&n.some(e=>e.includes(`/products/${t}`)))return!0;const s=i(e?.product_title).slice(0,16);return s.length>=4&&r.includes(s)})}async function Pc(e){if("undefined"==typeof window||"undefined"==typeof document)return null;const t=tc();let i=null;try{const e=await fetch(`${t}cart.js`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});e.ok&&(i=await e.json())}catch{}const r=i&&Number.isFinite(Number(i.item_count))?Number(i.item_count):null;let n=null;if(!n)try{const e=await fetch(`${t}?sections=${gc.join(",")}`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});e.ok&&(n=await e.json())}catch{}let s=!1;if(n)for(const o of gc)mc(o,n[o]??null)&&(s=!0);if(!s)try{const e=vc(),i=new Map,r=new Set;for(const t of e){const e=t.closest('[id^="shopify-section-"]'),n=e?.id?.replace(/^shopify-section-/,"");n&&(i.set(t,n),r.add(n))}const n=Array.from(r).slice(0,5);if(n.length){const r=await fetch(`${t}?sections=${n.map(encodeURIComponent).join(",")}`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});if(r.ok){const t=await r.json(),o={};for(const e of n)"string"==typeof t?.[e]&&(o[e]=(new DOMParser).parseFromString(t[e],"text/html"));for(const r of e){const e=i.get(r),t=e?o[e]:void 0;if(!t)continue;const n=_c(r.getAttribute("href")),a=vc(t).find(e=>_c(e.getAttribute("href"))===n);a&&(r.innerHTML=a.innerHTML,s=!0)}}}}catch{}if(!s&&null!=r)try{document.querySelectorAll(fc.join(",")).forEach(e=>{const t=e;t.textContent=String(r),t.hasAttribute("data-cart-count")&&t.setAttribute("data-cart-count",String(r)),t.removeAttribute("hidden"),r>0&&t.style.removeProperty("display")})}catch{}return r&&document.querySelectorAll("cart-drawer.is-empty").forEach(e=>e.classList.remove("is-empty")),function(e){if("undefined"==typeof document)return;const t=e?{cart:e,source:"dori"}:{source:"dori"},i=["cart:refresh","cart:build","cart:updated","cart:change","ajaxProduct:added","eurus:cart:reload"];for(const r of i)try{document.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:t}))}catch{}try{const t=e&&Number.isFinite(Number(e.item_count))?Number(e.item_count):void 0;document.dispatchEvent(new CustomEvent("cart:update",{bubbles:!0,detail:{data:{itemCount:t,source:"product-form-component"}}}))}catch{}try{!function(e){if(!e||"object"!=typeof e||!Array.isArray(e.items))return;const t=new Event("shopify:cart:lines-update",{bubbles:!0,cancelable:!0});Object.assign(t,{action:"update",lines:[],promise:Promise.resolve({cart:wc(e),detail:{items:e.items,itemCount:Number(e.item_count)||0,source:"dori",didError:!1}})}),document.dispatchEvent(t)}(e)}catch{}}(i),r}const $c="sidekick";function Ic(e,t={}){try{fetch(`${Ta}/events/widget`,{method:"POST",headers:{"Content-Type":"application/json"},keepalive:!0,body:JSON.stringify({event:e,assistant_id:t.assistantId||void 0,thread_id:t.threadId||void 0,payload:{surface:$c,visitor:nc()||void 0,...t.payload}})}).catch(()=>{})}catch{}try{Ho(`pf.${e}`,{thread_id:t.threadId||void 0,...t.payload})}catch{}}const Tc="banner",Cc="dori:banner_visit",Fc="dori:banner_seen",Oc="dori:banner_seen_pending",Rc="\n[BANNER] ";let Ac=null,Mc=!0;function Dc(e){return"banner"===e?.source||"banner_link"===e?.source||!e?.source&&!!e?.initiator}function Lc(e){if("banner_link"!==e?.source||e.intent||e.initiator)return e;const t="undefined"==typeof document?null:document.getElementById("dori-banner-link");return t?{...e,intent:t.dataset.intent,initiator:{message:t.dataset.message,query:t.dataset.query}}:e}function Nc(e){return("string"==typeof e?.intent?e.intent.trim():"")||Tc}function jc(e,t){const i="string"==typeof t?.message?t.message.trim():"",r="string"==typeof t?.query?(e=>e.replace(/\[/g,"(").replace(/\]/g,")").replace(/\s+/g," ").trim())(t.query):"";return i&&r&&e!==Tc?{message:i,apiMessage:`${i}${Rc}The shopper tapped the store's banner, so this line is the banner's, not typed by them. The banner's brief: "${r}". Reply with one short question that narrows this down and names 3 or 4 short answers inside it, in one sentence. The shopper can tap each answer, so don't list them again below it. Once they answer, show a few products with a reason for each.`}:null}function qc(){if(!Mc)return Ac;try{const e=sessionStorage.getItem(Cc),t=e?JSON.parse(e):null;if(t&&"string"==typeof t.intent)return Ac=t}catch{}return Ac}function Uc(e){Ac=e;try{sessionStorage.setItem(Cc,JSON.stringify(e))}catch{Mc=!1}}function Hc(e){ja(`banner:${e}`);const t=qc();return t?.intent===e?{firstTap:!1,sendOpener:!t.sent}:(Uc({intent:e}),{firstTap:!0,sendOpener:!0})}function Wc(){const e=qc();e&&!e.sent&&Uc({...e,sent:!0})}function Bc(){const e=qc();e&&ja(`banner:${e.intent}`)}function zc(e,t){const i=qc();!i||i[e]||"opened"===e&&!i.answered||(Uc({...i,[e]:!0}),Ic("answered"===e?"banner_answered":"banner_product_opened",{assistantId:t.assistantId,threadId:t.threadId,payload:{intent:i.intent,...t.how?{how:t.how}:{}}}))}const Vc=e=>!!e?.includes(Rc);function Gc(e){let t=!1;const i=i=>{if(t)return;t=!0;try{if(sessionStorage.removeItem(Oc),"1"===sessionStorage.getItem(Fc))return;sessionStorage.setItem(Fc,"1")}catch{}const r="string"==typeof i?.intent?i.intent.trim():"";e(r||Tc)},r=function(){try{const e=sessionStorage.getItem(Oc);return e?JSON.parse(e):null}catch{return null}}()??window.__doriBannerSeen;r&&i(r);const n=e=>i(e.detail);return window.addEventListener("dori:banner-seen",n),()=>window.removeEventListener("dori:banner-seen",n)}const Jc="dori-ai-page",Yc=/^\/(a|apps|community|tools)\/[A-Za-z0-9_-]{1,30}$/,Xc=/^[a-z0-9_-]{1,32}$/i;function Kc(e){return e.getElementById(Jc)??null}function Zc(e){if(!e)return{};const t=!!e.rules&&(void 0!==e.rules.size||void 0!==e.rules.max_price);return{surface:"ai_page",turn_id:e.turnId,...t?{page_rules:e.rules}:{}}}function Qc(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const eu=/^\/(a|apps|community|tools)\/[A-Za-z0-9_-]{1,30}\/ai$/,tu=/^\/[A-Za-z0-9/_-]*$/;function iu(e,t,i){const r=!0===e?.ai_page?e.ai_page_path:null;return r&&eu.test(r)?"ask_button"===i&&"ai_page"!==e?.ask_button_opens?null:`${t&&tu.test(t)?t.replace(/\/+$/,""):""}${r}?src=${i}`:null}function ru(e){return!e||Dc(e)?null:e.expand?"link"===e.source?"link":"chat":"header_button"===e.source||"header_block"===e.source?"ask_button":null}function nu(e){const t=new URLSearchParams(e).get("src");return`ai_page:${t&&Xc.test(t)?t.toLowerCase():"direct"}`}const su=(e,t=[])=>{if(!t||0===t.length)return!1;const i=e.replace(/^\/+/,"").toLowerCase();return t.some(e=>{const t=e.replace(/^\/+/,"").toLowerCase();return i.includes(t)})},ou=()=>"undefined"==typeof window?"":window.location.pathname,au=new Set;let lu=!1;function cu(){for(const e of au)try{e()}catch{}}const uu="dori-bot-data-ready",du="dori-bot-data-error",hu=(e,t)=>{window.dispatchEvent(new CustomEvent(e,t?{detail:{error:t}}:void 0))},pu=async e=>{const t=await fetch(e);if(200!==t.status)throw new Error(`Failed to fetch bot data: ${t.status}`);const i=await t.json();if(i.error)throw new Error(i.error);if(!i.data)throw new Error("No data received from bot sharing API");return i},gu=(e,t)=>{pa(e),t&&function(e){if(aa())try{e?localStorage.setItem(Go,e):localStorage.removeItem(Go)}catch(t){console.error("Error saving ETag:",t)}}(t),Ea()};let fu=!1,_u="";const vu=()=>{const e=ga();if(!fu&&!0!==e?.feature_flags?.ask_button&&!document.querySelector("[data-dori-ask-block]"))return;fu||function(){if(au.add(()=>{window.location.pathname!==_u&&vu()}),!lu&&"undefined"!=typeof window){lu=!0;for(const e of["pushState","replaceState"]){const t=history[e];history[e]=function(...e){const i=t.apply(this,e);return cu(),i}}window.addEventListener("popstate",cu)}}(),fu=!0,_u=window.location.pathname;const i=!!e&&su(_u,e.banned_paths||[]);t(async()=>{const{applyAskButton:e}=await import("./assets/apply-CnbnshVa.js");return{applyAskButton:e}},__vite__mapDeps([0,1]),import.meta.url).then(({applyAskButton:t})=>t(e,i)).catch(e=>console.error("[Dori Widget] Ask button failed to load:",e))};window.addEventListener(uu,vu),async function(){try{const t=(()=>{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null})();if(!t)return void hu(du,"No sharing ID found");!function(){if(aa())try{const e=oa();if(!e)return;const t=localStorage.getItem(Yo);if(t===e)return;t&&(fa(),da()),localStorage.setItem(Yo,e)}catch(e){console.error("Error resetting session for new store:",e)}}();const i=ga(),r=function(){if(!aa()||!ua())return null;if(!ha())return null;try{return localStorage.getItem(Go)}catch(e){return console.error("Error loading ETag:",e),null}}(),n=`${Ta}/bot-sharing-data/${t}`;i&&hu(uu);const s=i?[]:[1500,4e3];for(let o=0;;o++)try{const e=r?{"If-None-Match":r}:{},t=await fetch(n,{headers:e});if(304===t.status){if(!i){const e=await pu(n);gu(e.data,t.headers.get("ETag")),hu(uu)}return}if(200===t.status){const e=await t.json();if(e.error)throw new Error(e.error);if(!e.data)throw new Error("No data received");return gu(e.data,t.headers.get("ETag")),void hu(uu)}throw new Error(`Failed to fetch bot data: ${t.status}`)}catch(e){if(i)return;if(o<s.length){await new Promise(e=>setTimeout(e,s[o]));continue}const t=e instanceof Error?e.message:String(e);return void hu(du,t)}}catch(e){const t=e instanceof Error?e.message:String(e);hu(du,t)}}(),function(){if("undefined"==typeof window)return;const e=window;e.__doriOpenQueue=e.__doriOpenQueue||[];const t=t=>{e.__doriOpenReady||e.__doriOpenQueue.push(t??{})};e.doriWidget=e.doriWidget||{},"function"!=typeof e.doriWidget.open&&(e.doriWidget.open=t),e.addEventListener("dori:open-widget",e=>t(e.detail))}(),"undefined"!=typeof window&&"undefined"!=typeof document&&document.addEventListener("click",e=>function(e,t){if(e.defaultPrevented||0!==e.button)return!1;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;const i=e.target,r=i&&"function"==typeof i.closest?i.closest("a[href]"):null;if(!r)return!1;const n=r.getAttribute("target");if(n&&"_self"!==n)return!1;const s=function(e,t){const i={open:!1,expand:!1,banner:!1};try{const r=new URL(e,t);if(r.origin!==new URL(t).origin)return i;const n=r.searchParams.get("dori-chat")?.trim().toLowerCase();if("banner"===n)return{open:!0,expand:!0,banner:!0};if("open"===n||"expand"===n)return{open:!0,expand:"expand"===n,banner:!1};if("#dori-chat"===r.hash.toLowerCase())return{open:!0,expand:!1,banner:!1}}catch{}return i}(r.getAttribute("href")||"",t);return!(!s.open||s.banner&&"undefined"!=typeof document&&Kc(document)||(e.preventDefault(),window.doriWidget?.open?.({source:s.banner?"banner_link":"link",expand:s.expand}),0))}(e,window.location.href),!0);const mu=()=>{t(async()=>{const{initializeDoriWidget:e}=await import("./assets/main-DtXI9PnM.js");return{initializeDoriWidget:e}},__vite__mapDeps([2,3,4,1]),import.meta.url).then(({initializeDoriWidget:e})=>e()).catch(async e=>{const t=Ra(e);if(t){await new Promise(e=>setTimeout(e,1500));try{const e=await import(Aa(t));e.initializeDoriWidget?.()}catch(i){console.error("[Dori Widget] Error initializing widget (after retry):",e,i)}}else console.error("[Dori Widget] Error initializing widget:",e)})},yu=()=>{const e=Kc(document);var i;e?(i=e,t(async()=>{const{mountAiPage:e}=await import("./assets/mount-5SwUgqR8.js");return{mountAiPage:e}},__vite__mapDeps([5,3]),import.meta.url).then(({mountAiPage:e})=>e(i)).catch(async e=>{const t=Ra(e);if(t){await new Promise(e=>setTimeout(e,1500));try{const e=await import(Aa(t));e.mountAiPage?.(i)}catch(r){console.error("[Dori Widget] AI page failed to load (after retry):",e,r)}}else console.error("[Dori Widget] AI page failed to load:",e)})):"undefined"!=typeof window&&(window.__doriOpenQueue?.length??0)>0?mu():function(e,t={}){let i=!1;try{i=window.self!==window.top}catch{i=!0}if(i)return t.onLoadStart?.(),void e();let r=!1;const n=[],s=()=>{if(!r){r=!0;for(const e of n)e();t.onLoadStart?.(),e()}},o=(e,t)=>{"function"==typeof window.requestIdleCallback?window.requestIdleCallback(()=>e(),{timeout:t}):window.setTimeout(e,200)},a=(e,t,i)=>{e.addEventListener(t,i,{once:!0,passive:!0,capture:!0}),n.push(()=>e.removeEventListener(t,i,!0))};for(const d of Ca)a(window,d,s);let l=!1;const c=()=>{l||r||(l=!0,o(s,2e3))};for(const d of Fa)a(window,d,c);for(const d of t.immediateTargets??[])if(d)for(const e of Oa)a(d,e,s);const u=()=>{if(r)return;const e=window.setTimeout(()=>o(s,1e3),5e3);n.push(()=>window.clearTimeout(e))};"complete"===document.readyState?u():window.addEventListener("load",u,{once:!0})}(mu)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",yu,{once:!0}):yu();export{va as $,ql as A,su as B,iu as C,Bc as D,Gc as E,Bo as F,La as G,ru as H,Da as I,Lc as J,Nc as K,Hc as L,jc as M,Dc as N,Qc as O,ja as P,nu as Q,Ec as R,Ta as S,Bl as T,Pc as U,aa as V,Vl as W,Ea as X,pa as Y,_a as Z,t as _,Jl as a,ya as a0,wa as a1,$a as a2,la as a3,ml as a4,Zl as a5,dc as a6,ac as a7,zc as a8,zo as a9,Wl as aA,uc as aa,cc as ab,pc as ac,da as ad,al as ae,Ka as af,El as ag,kl as ah,Rl as ai,Sl as aj,Za as ak,Vc as al,Wc as am,$l as an,yl as ao,Gl as ap,ca as aq,Pa as ar,Ia as as,Kl as at,Pl as au,r as av,jl as aw,Nl as ax,ga as ay,Ul as az,Ml as b,Ho as c,Al as d,xa as e,sc as f,oa as g,ba as h,ec as i,nc as j,Xl as k,ma as l,ic as m,tc as n,bc as o,s as p,Ma as q,Wo as r,Hl as s,Ic as t,n as u,Uo as v,Dl as w,ka as x,Sa as y,ou as z};
|
|
2
|
+
const e={},t=function(t,i,r){let n=Promise.resolve();if(i&&i.length>0){let t=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};const s=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");n=t(i.map(t=>{if(t=function(e,t){return new URL(e,t).href}(t,r),t in e)return;e[t]=!0;const i=t.endsWith(".css"),n=i?'[rel="stylesheet"]':"";if(r)for(let e=s.length-1;e>=0;e--){const r=s[e];if(r.href===t&&(!i||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${t}"]${n}`))return;const o=document.createElement("link");return o.rel=i?"stylesheet":"modulepreload",i||(o.as="script"),o.crossOrigin="",o.href=t,a&&o.setAttribute("nonce",a),document.head.appendChild(o),i?new Promise((e,i)=>{o.addEventListener("load",e),o.addEventListener("error",()=>i(new Error(`Unable to preload CSS for ${t}`)))}):void 0}))}function s(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return n.then(e=>{for(const t of e||[])"rejected"===t.status&&s(t.reason);return t().catch(s)})};let i=null;function r(e){let t=e.replace(/<thought>[\s\S]*?<\/thought>/gi,"");return t=t.replace(/<thought>[\s\S]*$/gi,""),t.trim()}const n=(e,t)=>{if(!e)return;const r=e.closest('[data-scroll-container="chat-messages"]');r&&null===i&&(i=setTimeout(()=>{i=null,t&&!t()||r.scrollTo({top:r.scrollHeight,behavior:"smooth"})},200))},s=(e,t,i=new Date)=>{const r=e?.feature_flags?.panel_greeting;return"string"==typeof r?r.trim():((e,t,i=new Date)=>{const r=e||"Dori";return`${i.getHours()>=18&&t.hiImEvening?t.hiImEvening:t.hiIm} ${r}!`})(e?.agent_name,t,i)};var o="undefined"!=typeof window?window:void 0,a="undefined"!=typeof globalThis?globalThis:o;"undefined"==typeof self&&(a.self=a),"undefined"==typeof File&&(a.File=function(){});var l=Array.prototype,c=l.forEach,u=l.indexOf,d=null==a?void 0:a.navigator,h=null==a?void 0:a.document,p=null==a?void 0:a.location,g=null==a?void 0:a.fetch,f=null!=a&&a.XMLHttpRequest&&"withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:void 0,_=null==a?void 0:a.AbortController,v=null==d?void 0:d.userAgent,m=null!=o?o:{},y={DEBUG:!1,LIB_VERSION:"1.343.2"};function w(e,t,i,r,n,s,o){try{var a=e[s](o),l=a.value}catch(c){return void i(c)}a.done?t(l):Promise.resolve(l).then(r,n)}function b(e){return function(){var t=this,i=arguments;return new Promise(function(r,n){var s=e.apply(t,i);function o(e){w(s,r,n,o,a,"next",e)}function a(e){w(s,r,n,o,a,"throw",e)}o(void 0)})}}function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},E.apply(null,arguments)}function S(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var k=["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"],x=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return k.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})},P=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function $(e,t){return-1!==e.indexOf(t)}var I=function(e){return e.trim()},T=function(e){return e.replace(/^\$/,"")},C=Array.isArray,F=Object.prototype,O=F.hasOwnProperty,R=F.toString,A=C||function(e){return"[object Array]"===R.call(e)},M=e=>"function"==typeof e,D=e=>e===Object(e)&&!A(e),L=e=>{if(D(e)){for(var t in e)if(O.call(e,t))return!1;return!0}return!1},N=e=>void 0===e,j=e=>"[object String]"==R.call(e),q=e=>j(e)&&0===e.trim().length,U=e=>null===e,H=e=>N(e)||U(e),W=e=>"[object Number]"==R.call(e)&&e==e,B=e=>W(e)&&e>0,z=e=>"[object Boolean]"===R.call(e),V=e=>$(P,e);function G(e){return null===e||"object"!=typeof e}function J(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function Y(e){return!N(Event)&&function(e,t){try{return e instanceof t}catch(i){return!1}}(e,Event)}var X=[!0,"true",1,"1","yes"],K=e=>$(X,e),Z=[!1,"false",0,"0","no"];function Q(e,t,i,r,n){return t>i&&(r.warn("min cannot be greater than max."),t=i),W(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),Q(n||i,t,i,r))}class ee{constructor(e){this.t={},this.i=e.i,this.o=Q(e.bucketSize,0,100,e.h),this.m=Q(e.refillRate,0,this.o,e.h),this.$=Q(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,r=Math.floor(i/this.$);if(r>0){var n=r*this.m;e.tokens=Math.min(e.tokens+n,this.o),e.lastAccess=e.lastAccess+r*this.$}}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.t[r];return n?this.S(n,i):(n={tokens:this.o,lastAccess:i},this.t[r]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null==(t=this.i)||t.call(this,e)),0===n.tokens)}stop(){this.t={}}}var te,ie,re,ne="Mobile",se="iOS",oe="Android",ae="Tablet",le=oe+" "+ae,ce="iPad",ue="Apple",de=ue+" Watch",he="Safari",pe="BlackBerry",ge="Samsung",fe=ge+"Browser",_e=ge+" Internet",ve="Chrome",me=ve+" OS",ye=ve+" "+se,we="Internet Explorer",be=we+" "+ne,Ee="Opera",Se=Ee+" Mini",ke="Edge",xe="Microsoft "+ke,Pe="Firefox",$e=Pe+" "+se,Ie="Nintendo",Te="PlayStation",Ce="Xbox",Fe=oe+" "+ne,Oe=ne+" "+he,Re="Windows",Ae=Re+" Phone",Me="Nokia",De="Ouya",Le="Generic",Ne=Le+" "+ne.toLowerCase(),je=Le+" "+ae.toLowerCase(),qe="Konqueror",Ue="(\\d+(\\.\\d+)?)",He=new RegExp("Version/"+Ue),We=new RegExp(Ce,"i"),Be=new RegExp(Te+" \\w+","i"),ze=new RegExp(Ie+" \\w+","i"),Ve=new RegExp(pe+"|PlayBook|BB10","i"),Ge={"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"},Je=function(e,t){return t=t||"",$(e," OPR/")&&$(e,"Mini")?Se:$(e," OPR/")?Ee:Ve.test(e)?pe:$(e,"IE"+ne)||$(e,"WPDesktop")?be:$(e,fe)?_e:$(e,ke)||$(e,"Edg/")?xe:$(e,"FBIOS")?"Facebook "+ne:$(e,"UCWEB")||$(e,"UCBrowser")?"UC Browser":$(e,"CriOS")?ye:$(e,"CrMo")||$(e,ve)?ve:$(e,oe)&&$(e,he)?Fe:$(e,"FxiOS")?$e:$(e.toLowerCase(),qe.toLowerCase())?qe:((e,t)=>{return t&&$(t,ue)||$(i=e,he)&&!$(i,ve)&&!$(i,oe);var i})(e,t)?$(e,ne)?Oe:he:$(e,Pe)?Pe:$(e,"MSIE")||$(e,"Trident/")?we:$(e,"Gecko")?Pe:""},Ye={[be]:[new RegExp("rv:"+Ue)],[xe]:[new RegExp(ke+"?\\/"+Ue)],[ve]:[new RegExp("("+ve+"|CrMo)\\/"+Ue)],[ye]:[new RegExp("CriOS\\/"+Ue)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ue)],[he]:[He],[Oe]:[He],[Ee]:[new RegExp("(Opera|OPR)\\/"+Ue)],[Pe]:[new RegExp(Pe+"\\/"+Ue)],[$e]:[new RegExp("FxiOS\\/"+Ue)],[qe]:[new RegExp("Konqueror[:/]?"+Ue,"i")],[pe]:[new RegExp(pe+" "+Ue),He],[Fe]:[new RegExp("android\\s"+Ue,"i")],[_e]:[new RegExp(fe+"\\/"+Ue)],[we]:[new RegExp("(rv:|MSIE )"+Ue)],Mozilla:[new RegExp("rv:"+Ue)]},Xe=function(e,t){var i=Je(e,t),r=Ye[i];if(N(r))return null;for(var n=0;n<r.length;n++){var s=r[n],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},Ke=[[new RegExp(Ce+"; "+Ce+" (.*?)[);]","i"),e=>[Ce,e&&e[1]||""]],[new RegExp(Ie,"i"),[Ie,""]],[new RegExp(Te,"i"),[Te,""]],[Ve,[pe,""]],[new RegExp(Re,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ae,""];if(new RegExp(ne).test(t)&&!/IEMobile\b/.test(t))return[Re+" "+ne,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=Ge[r]||"";return/arm/i.test(t)&&(n="RT"),[Re,n]}return[Re,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[se,t.join(".")]}return[se,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=N(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+oe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+oe+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[oe,t.join(".")]}return[oe,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[me,""]],[/Linux|debian/i,["Linux",""]]],Ze=function(e){return ze.test(e)?Ie:Be.test(e)?Te:We.test(e)?Ce:new RegExp(De,"i").test(e)?De:new RegExp("("+Ae+"|WPDesktop)","i").test(e)?Ae:/iPad/.test(e)?ce:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?de:Ve.test(e)?pe:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Me,"i").test(e)?Me:/(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(ne).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)?oe:le:new RegExp("(pda|"+ne+")","i").test(e)?Ne:new RegExp(ae,"i").test(e)&&!new RegExp(ae+" pc","i").test(e)?je:""},Qe=e=>e instanceof Error;function et(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return re&&i.length===ie||(ie=i.length,re=i.reduce((i,r)=>{te||(te={});var n=te[r];if(n)i[n[0]]=n[1];else for(var s=e(r),o=s.length-1;o>=0;o--){var a=s[o],l=null==a?void 0:a.filename,c=t[r];if(l&&c){i[l]=c,te[r]=[l,c];break}}return i},{})),re}}class tt{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),s=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(s,i),$exception_level:"error"}}modifyFrames(e){var t=this;return b(function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&A(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),E({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return b(function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i})()}convertToExceptionList(e,t){var i,r,n,s={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(s.stacktrace={type:"raw",frames:e.stack});var o=[s];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,E({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:et(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i){void 0===i&&(i=0);var r=(i,r)=>{if(r<=4){var n=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,n)}};return E({},t,{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,i),next:e=>r(e,i+1)})}}var it="?";function rt(e,t,i,r,n){var s={platform:e,filename:t,function:"<anonymous>"===i?it:i,in_app:!0};return N(r)||(s.lineno=r),N(n)||(s.colno=n),s}var nt=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:it,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},st=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ot=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,at=/\((\S*)(?::(\d+))(?::(\d+))\)/,lt=(e,t)=>{var i=st.exec(e);if(i){var[,r,n,s]=i;return rt(t,r,it,+n,+s)}var o=ot.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=at.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=nt(o[1]||it,o[2]);return rt(t,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},ct=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ut=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,dt=(e,t)=>{var i=ct.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ut.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var n=i[3],s=i[1]||it;return[s,n]=nt(s,n),rt(t,n,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},ht=/\(error: (.*)\)/;class pt{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=j(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return J(e,"DOMException")}isDOMError(e){return J(e,"DOMError")}}class gt{match(e){return e instanceof Error}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ft{constructor(){}match(e){return J(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var _t=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class vt{match(e){return"string"==typeof e}coerce(e,t){var i,[r,n]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=n?n:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(_t);return r&&(t=r[1],i=r[2]),[t,i]}}var mt=["fatal","error","warning","log","info","debug"];function yt(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(!(n.length>t))return r===i.length||n.length<=t?n:n.slice(0,t)+"..."}return""}class wt{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Y(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+yt(e)}isSeverityLevel(e){return j(e)&&!q(e)&&mt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Qe(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(i){return}}}class bt{match(e){return Y(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+yt(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Et{match(e){return G(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class St{match(e){return J(e,"PromiseRejectionEvent")}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return G(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(G(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(t){}return e}}var kt=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={k:function(t){if(o&&(y.DEBUG||m.POSTHOG_DEBUG||i)&&!N(o.console)&&o.console){for(var r=("__rrweb_original__"in o.console[t]?o.console[t].__rrweb_original__:o.console[t]),n=arguments.length,s=new Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];r(e,...s)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning:e=>{r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>kt(e+" "+t,i)};return r},xt=kt("[PostHog.js]"),Pt=xt.createLogger,$t=Pt("[ExternalScriptsLoader]"),It=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return $t.warn(t+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var r=null==h?void 0:h.querySelectorAll("script");if(r)for(var n,s=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:i()}:(e.addEventListener("load",t=>{e.__posthog_loading_callback_fired=!0,i(void 0,t)}),e.onerror=e=>i(e),{v:void 0})}},o=0;o<r.length;o++)if(n=s())return n.v;var a=()=>{if(!h)return i("document not found");var r=h.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,i(void 0,e)},r.onerror=e=>i(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");if("head"===e.config.external_scripts_inject_target)h.head.appendChild(r);else{var n,s=h.querySelectorAll("body > script");s.length>0?null==(n=s[0].parentNode)||n.insertBefore(r,s[0]):h.body.appendChild(r)}};null!=h&&h.body?a():null==h||h.addEventListener("DOMContentLoaded",a)};m.__PosthogExtensions__=m.__PosthogExtensions__||{},m.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var r="/static/"+t+".js?v="+e.version;if("remote-config"===t&&(r="/array/"+e.config.token+"/config.js"),"toolbar"===t){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}var s=e.requestRouter.endpointFor("assets",r);It(e,s,i)},m.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var r=e.requestRouter.endpointFor("api",t);It(e,r,i)};var Tt={};function Ct(e,t,i){if(A(e))if(c&&e.forEach===c)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,n=e.length;r<n;r++)if(r in e&&t.call(i,e[r],r)===Tt)return}function Ft(e,t,i){if(!H(e)){if(A(e))return Ct(e,t,i);if((e=>e instanceof FormData)(e)){for(var r of e.entries())if(t.call(i,r[1],r[0])===Tt)return}else for(var n in e)if(O.call(e,n)&&t.call(i,e[n],n)===Tt)return}}var Ot=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ct(i,function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])}),e},Rt=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ct(i,function(t){Ct(t,function(t){e.push(t)})}),e};function At(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Mt=function(e){try{return e()}catch(t){return}},Dt=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.apply(this,i)}catch(n){xt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),xt.critical(n)}}},Lt=function(e){var t={};return Ft(e,function(e,i){(j(e)&&e.length>0||W(e))&&(t[i]=e)}),t},Nt=["herokuapp.com","vercel.app","netlify.app"];function jt(e){var t=null==e?void 0:e.hostname;if(!j(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Nt)if(i===r)return!1;return!0}function qt(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Ut(e,t,i,r){var{capture:n=!1,passive:s=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:n,passive:s})}var Ht="$people_distinct_id",Wt="__alias",Bt="__timers",zt="$autocapture_disabled_server_side",Vt="$heatmaps_enabled_server_side",Gt="$exception_capture_enabled_server_side",Jt="$error_tracking_suppression_rules",Yt="$error_tracking_capture_extension_exceptions",Xt="$web_vitals_enabled_server_side",Kt="$dead_clicks_enabled_server_side",Zt="$product_tours_enabled_server_side",Qt="$web_vitals_allowed_metrics",ei="$session_recording_remote_config",ti="$sesid",ii="$session_is_sampled",ri="$enabled_feature_flags",ni="$early_access_features",si="$feature_flag_details",oi="$stored_person_properties",ai="$stored_group_properties",li="$surveys",ci="$flag_call_reported",ui="$user_state",di="$client_session_props",hi="$capture_rate_limit",pi="$initial_campaign_params",gi="$initial_referrer_info",fi="$initial_person_info",_i="$epp",vi="__POSTHOG_TOOLBAR__",mi="$posthog_cookieless",yi=[Ht,Wt,"__cmpns",Bt,"$session_recording_enabled_server_side",Vt,ti,ri,Jt,ui,ni,si,ai,oi,li,ci,di,hi,pi,gi,_i,fi,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function wi(e){return e instanceof Element&&(e.id===vi||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function bi(e){return!!e&&1===e.nodeType}function Ei(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Si(e){return!!e&&3===e.nodeType}function ki(e){return!!e&&11===e.nodeType}function xi(e){return e?I(e).split(/\s+/):[]}function Pi(e){var t=null==o?void 0:o.location.href;return!!(t&&e&&e.some(e=>t.match(e)))}function $i(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return xi(t)}function Ii(e){return H(e)?null:I(e).split(/(\s+)/).filter(e=>Vi(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ti(e){var t="";return Ni(e)&&!ji(e)&&e.childNodes&&e.childNodes.length&&Ft(e.childNodes,function(e){var i;Si(e)&&e.textContent&&(t+=null!==(i=Ii(e.textContent))&&void 0!==i?i:"")}),I(t)}function Ci(e){return N(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Fi=["a","button","form","input","select","textarea","label"];function Oi(e,t){if(N(t))return!0;var i,r=function(e){if(t.some(t=>e.matches(t)))return{v:!0}};for(var n of e)if(i=r(n))return i.v;return!1}function Ri(e){var t=e.parentNode;return!(!t||!bi(t))&&t}var Ai=["next","previous","prev",">","<"],Mi=[".ph-no-rageclick",".ph-no-capture"],Di=e=>!e||Ei(e,"html")||!bi(e),Li=(e,t)=>{if(!o||Di(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],n=e;n.parentNode&&!Ei(n,"body");)if(ki(n.parentNode))r.push(n.parentNode.host),n=n.parentNode.host;else{var s=Ri(n);if(!s)break;if(t||Fi.indexOf(s.tagName.toLowerCase())>-1)i=!0;else{var a=o.getComputedStyle(s);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(s),n=s}return{parentIsUsefulElement:i,targetElementList:r}};function Ni(e){for(var t=e;t.parentNode&&!Ei(t,"body");t=t.parentNode){var i=$i(t);if($(i,"ph-sensitive")||$(i,"ph-no-capture"))return!1}if($($i(e),"ph-include"))return!0;var r=e.type||"";if(j(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var n=e.name||e.id||"";return!j(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function ji(e){return!!(Ei(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ei(e,"select")||Ei(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var qi="(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})",Ui=new RegExp("^(?:"+qi+")$"),Hi=new RegExp(qi),Wi="\\d{3}-?\\d{2}-?\\d{4}",Bi=new RegExp("^("+Wi+")$"),zi=new RegExp("("+Wi+")");function Vi(e,t){if(void 0===t&&(t=!0),H(e))return!1;if(j(e)){if(e=I(e),(t?Ui:Hi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Bi:zi).test(e))return!1}return!0}function Gi(e){var t=Ti(e);return Vi(t=(t+" "+Ji(e)).trim())?t:""}function Ji(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Ft(e.childNodes,function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Ti(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Ji(e)).trim())}catch(n){xt.error("[AutoCapture]",n)}}),t}function Yi(e){return e.replace(/"|\\"/g,'\\"')}function Xi(e){var t=e.attr__class;return t?A(t)?t:xi(t):void 0}class Ki{constructor(e){this.disabled=!1===e;var t=D(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&i-r.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Zi=e=>{var t=null==h?void 0:h.createElement("a");return N(t)?null:(t.href=e,t)},Qi=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;n<r.length;n++){var s=r[n].split("=");if(s[0]===t){i=s;break}}if(!A(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(a){xt.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},er=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),n=r[0]||"",s=r[1],o=n.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");A(h)&&(t.includes(h[0])?u.push(h[0]+"="+i):u.push(c[d]))}var p=l;return null!=a&&(p+="?"+u.join("&")),null!=s&&(p+="#"+s),p},tr=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ir="$copy_autocapture",rr=Pt("[AutoCapture]");function nr(e,t){return t.length>e?t.slice(0,e)+"...":t}function sr(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!bi(t));return t}class or{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Ki(e.config.rageclick),this.C=null}get R(){var e,t,i=D(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map(e=>new RegExp(e)),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),i}F(){if(this.isBrowserSupported()){if(o&&h){var e=e=>{e=e||(null==o?void 0:o.event);try{this.O(e)}catch(pr){rr.error("Failed to capture event",pr)}};if(Ut(h,"submit",e,{capture:!0}),Ut(h,"change",e,{capture:!0}),Ut(h,"click",e,{capture:!0}),this.R.capture_copied_text){var t=e=>{e=e||(null==o?void 0:o.event),this.O(e,ir)};Ut(h,"copy",t,{capture:!0}),Ut(h,"cut",t,{capture:!0})}}}else rr.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[zt]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return null==(t=this.C)||t.forEach(t=>{var r=null==h?void 0:h.querySelectorAll(t);null==r||r.forEach(r=>{e===r&&i.push(t)})}),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[zt],r=this.T;if(U(r)&&!z(i)&&!this.instance.M())return!1;var n=null!==(t=this.T)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}O(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=Ci(e);Si(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&function(e,t){if(!o||Di(e))return!1;var i,r,n;if(z(t)?(i=!!t&&Mi,r=void 0):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:Mi,r=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:s}=Li(e,!1);return!function(e,t){if(!1===e||N(e))return!1;var i;if(!0===e)i=Ai;else{if(!A(e))return!1;if(e.length>10)return xt.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(e=>{var{safeText:t,ariaLabel:r}=e;return i.some(e=>t.includes(e)||r.includes(e))})}(r,s.map(e=>{var t;return{safeText:Ti(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}}))&&!Oi(s,i)}(r,this.instance.config.rageclick)&&this.O(e,"$rageclick");var n=t===ir;if(r&&function(e,t,i,r,n){var s,a,l,c;if(void 0===i&&(i=void 0),!o||Di(e))return!1;if(null!=(s=i)&&s.url_allowlist&&!Pi(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Pi(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some(e=>t.type===e))return!1}var{parentIsUsefulElement:d,targetElementList:h}=Li(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(N(i))return!0;var r,n=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var s of e)if(r=n(s))return r.v;return!1}(h,i))return!1;if(!Oi(h,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var p=o.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var g=e.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Fi.indexOf(g)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this.R,n,n?["copy","cut"]:void 0)){var{props:s,explicitNoCapture:a}=function(e,t){for(var i,r,{e:n,maskAllElementAttributes:s,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!Ei(d,"body");)ki(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,p,g,f=[],_={},v=!1,m=!1;if(Ft(u,e=>{var t=Ni(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&Vi(v)&&v),$($i(e),"ph-no-capture")&&(m=!0),f.push(function(e,t,i,r){var n=e.tagName.toLowerCase(),s={tag_name:n};Fi.indexOf(n)>-1&&!i&&("a"===n.toLowerCase()||"button"===n.toLowerCase()?s.$el_text=nr(1024,Gi(e)):s.$el_text=nr(1024,Ti(e)));var o=$i(e);o.length>0&&(s.classes=o.filter(function(e){return""!==e})),Ft(e.attributes,function(i){var n;if((!ji(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Vi(i.value)&&(n=i.name,!j(n)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=i.value;"class"===i.name&&(o=xi(o).join(" ")),s["attr__"+i.name]=nr(1024,o)}});for(var a=1,l=1,c=e;c=sr(c);)a++,c.tagName===e.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}(e,s,a,l));var i=function(e){if(!Ni(e))return{};var t={};return Ft(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Vi(r)&&(t[i]=r)}}),t}(e);Ot(_,i)}),m)return{props:{},explicitNoCapture:m};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?f[0].$el_text=Gi(e):f[0].$el_text=Ti(e)),v){var y,w;f[0].attr__href=v;var b=null==(y=Zi(v))?void 0:y.host,S=null==o||null==(w=o.location)?void 0:w.host;b&&S&&b!==S&&(h=v)}return{props:Ot({$event_type:n.type,$ce_version:1},c?{}:{$elements:f},{$elements_chain:(g=f,p=g.map(e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Xi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return At(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,i]=e;return r.attributes[t]=i}),r}),p.map(e=>{var t,i,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var s=E({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),o={};return At(s).sort((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)}).forEach(e=>{var[t,i]=e;return o[Yi(t.toString())]=Yi(i.toString())}),(r+=":")+At(o).map(e=>{var[t,i]=e;return t+'="'+i+'"'}).join("")}).join(";"))},null!=(i=f[0])&&i.$el_text?{$el_text:null==(r=f[0])?void 0:r.$el_text}:{},h&&"click"===n.type?{$external_click_url:h}:{},_)}}(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(s.$element_selectors=l),t===ir){var c,u=Ii(null==o||null==(c=o.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;s.$selected_content=u,s.$copy_type=d}return this.instance.capture(t,s),!0}}}isBrowserSupported(){return M(null==h?void 0:h.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return W(e)&&isFinite(e)&&Math.floor(e)===e});var ar="0123456789abcdef";class lr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new lr(n)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+ar.charAt(this.bytes[t]>>>4)+ar.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new lr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class cr{constructor(){this.A=0,this.j=0,this.D=new hr}generate(){var e=this.generateOrAbort();if(N(e)){this.A=0;var t=this.generateOrAbort();if(N(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return lr.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}}var ur,dr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};o&&!N(o.crypto)&&crypto.getRandomValues&&(dr=e=>crypto.getRandomValues(e));class hr{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(dr(this.N),this.U=0),this.N[this.U++]}}var pr,gr=()=>fr().toString(),fr=()=>(ur||(ur=new cr)).generate(),_r="",vr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,mr={H:()=>!!h,B:function(e){xt.error("cookieStore error: "+e)},q:function(e){if(h){try{for(var t=e+"=",i=h.cookie.split(";").filter(e=>e.length),r=0;r<i.length;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(t))return decodeURIComponent(n.substring(t.length,n.length))}}catch(s){}return null}},W:function(e){var t;try{t=JSON.parse(mr.q(e))||{}}catch(i){}return t},G:function(e,t,i,r,n){if(h)try{var s="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=h),_r)return _r;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),n="dmn_chk_"+gr();!_r&&r--;){var s=i.slice(r).join("."),o=n+"=1;domain=."+s+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(n)&&(t.cookie=o+";max-age=0",_r=s)}return _r}(e);if(!i){var r=(n=e.match(vr))?n[0]:"";r!==i&&xt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}var n;return""}(h.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),s="; expires="+l.toUTCString()}n&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&xt.warn("cookieStore warning: large cookie, len="+c.length),h.cookie=c,c}catch(u){return}},V:function(e,t){if(null!=h&&h.cookie)try{mr.G(e,"",-1,t)}catch(i){return}}},yr=null,wr={H:function(){if(!U(yr))return yr;var e=!0;if(N(o))e=!1;else try{var t="__mplssupport__";wr.G(t,"xyz"),'"xyz"'!==wr.q(t)&&(e=!1),wr.V(t)}catch(pr){e=!1}return e||xt.error("localStorage unsupported; falling back to cookie store"),yr=e,e},B:function(e){xt.error("localStorage error: "+e)},q:function(e){try{return null==o?void 0:o.localStorage.getItem(e)}catch(pr){wr.B(pr)}return null},W:function(e){try{return JSON.parse(wr.q(e))||{}}catch(t){}return null},G:function(e,t){try{null==o||o.localStorage.setItem(e,JSON.stringify(t))}catch(pr){wr.B(pr)}},V:function(e){try{null==o||o.localStorage.removeItem(e)}catch(pr){wr.B(pr)}}},br=["$device_id","distinct_id",ti,ii,_i,fi],Er={},Sr={H:function(){return!0},B:function(e){xt.error("memoryStorage error: "+e)},q:function(e){return Er[e]||null},W:function(e){return Er[e]||null},G:function(e,t){Er[e]=t},V:function(e){delete Er[e]}},kr=null,xr={H:function(){if(!U(kr))return kr;if(kr=!0,N(o))kr=!1;else try{var e="__support__";xr.G(e,"xyz"),'"xyz"'!==xr.q(e)&&(kr=!1),xr.V(e)}catch(pr){kr=!1}return kr},B:function(e){xt.error("sessionStorage error: ",e)},q:function(e){try{return null==o?void 0:o.sessionStorage.getItem(e)}catch(pr){xr.B(pr)}return null},W:function(e){try{return JSON.parse(xr.q(e))||null}catch(t){}return null},G:function(e,t){try{null==o||o.sessionStorage.setItem(e,JSON.stringify(t))}catch(pr){xr.B(pr)}},V:function(e){try{null==o||o.sessionStorage.removeItem(e)}catch(pr){xr.B(pr)}}},Pr=((pr={})[pr.PENDING=-1]="PENDING",pr[pr.DENIED=0]="DENIED",pr[pr.GRANTED=1]="GRANTED",pr);class $r{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Pr.DENIED:this.K}isOptedOut(){return"always"===this.R.cookieless_mode||this.consent===Pr.DENIED||this.consent===Pr.PENDING&&(this.R.opt_out_capturing_by_default||"on_reject"===this.R.cookieless_mode)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Pr.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return K(e)?Pr.GRANTED:$(Z,e)?Pr.DENIED:Pr.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z="localStorage"===e?wr:mr;var t="localStorage"===e?mr:wr;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(K(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!qt([null==d?void 0:d.doNotTrack,null==d?void 0:d.msDoNotTrack,m.doNotTrack],e=>K(e))}}var Ir=Pt("[Dead Clicks]"),Tr=()=>!0,Cr=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Kt)),r=e.instance.config.capture_dead_clicks;return z(r)?r:!!D(r)||i};class Fr{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Kt]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Ir.error("failed to load script",t):e()})}et(){var e;if(h){if(!this.tt&&null!=(e=m.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=D(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=m.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(h),Ir.info("starting...")}}else Ir.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Ir.info("stopping..."))}}var Or=Pt("[ExceptionAutocapture]");class Rr{constructor(e){var t,i,r;this.rt=()=>{var e;if(o&&this.isEnabled&&null!=(e=m.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=m.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=m.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=m.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=t(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=i(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=r(this.captureException.bind(this)))}catch(pr){Or.error("failed to start",pr),this.ut()}}},this._instance=e,this.ht=!(null==(t=this._instance.persistence)||!t.props[Gt]),this.dt=new ee({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,h:Or}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return D(e)?t=E({},t,e):(N(e)?this.ht:e)&&(t=E({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Or.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return Or.error("failed to load script",t);e()})}ut(){var e,t,i;null==(e=this.st)||e.call(this),this.st=void 0,null==(t=this.nt)||t.call(this),this.nt=void 0,null==(i=this.ot)||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Gt]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this.dt.consumeRateLimit(r)?Or.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(e)}}function Ar(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return M(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(s){return()=>{}}}class Mr{constructor(e){var t;this._instance=e,this.ct=(null==o||null==(t=o.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(xt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,xt.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(o&&o.history){var i=this;null!=(e=o.history.pushState)&&e.__posthog_wrapped__||Ar(o.history,"pushState",e=>function(t,r,n){e.call(this,t,r,n),i._t("pushState")}),null!=(t=o.history.replaceState)&&t.__posthog_wrapped__||Ar(o.history,"replaceState",e=>function(t,r,n){e.call(this,t,r,n),i._t("replaceState")}),this.bt()}}_t(e){try{var t,i=null==o||null==(t=o.location)?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(pr){xt.error("Error capturing "+e+" pageview",pr)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Ut(o,"popstate",e),this.ft=()=>{o&&o.removeEventListener("popstate",e)}}}}var Dr=Pt("[SegmentIntegration]"),Lr="posthog-js";function Nr(e,t){var{organization:i,projectId:r,prefix:n,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=void 0===t?{}:t;return t=>{var a,l,c,u,d;if("*"!==s&&!s.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(a=t.exception)?void 0:a.values)||[],g=p.map(e=>E({},e,{stacktrace:e.stacktrace?E({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>E({},e,{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null==(l=p[0])?void 0:l.value)||t.message,$exception_type:null==(c=p[0])?void 0:c.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(u=p[0])?void 0:u.value)||t.message,$sentry_exception_type:null==(d=p[0])?void 0:d.type,$sentry_tags:t.tags};return i&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+t.event_id),o&&e.exceptions.sendExceptionEvent(f),t}}class jr{constructor(e,t,i,r,n,s){this.name=Lr,this.setupOnce=function(o){o(Nr(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:null==s||s}))}}}var qr=null!=o&&o.location?tr(o.location.hash,"__posthog")||tr(location.hash,"state"):null,Ur="_postHogToolbarParams",Hr=Pt("[Toolbar]"),Wr=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Wr||{});class Br{constructor(e){this.instance=e}yt(e){m.ph_toolbar_state=e}wt(){var e;return null!==(e=m.ph_toolbar_state)&&void 0!==e?e:Wr.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!o||!h)return!1;e=null!=e?e:o.location,i=null!=i?i:o.history;try{if(!t){try{o.localStorage.setItem("test","test"),o.localStorage.removeItem("test")}catch(pr){return!1}t=null==o?void 0:o.localStorage}var r,n=qr||tr(e.hash,"__posthog")||tr(e.hash,"state"),s=n?Mt(()=>JSON.parse(atob(decodeURIComponent(n))))||Mt(()=>JSON.parse(decodeURIComponent(n))):null;return s&&"ph_authorize"===s.action?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?e.hash=s.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(Ur)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(pr){return!1}}xt(e){var t=m.ph_load_toolbar||m.ph_load_editor;!H(t)&&M(t)?t(e,this.instance):Hr.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==h||!h.getElementById(vi));if(!o||t)return!1;var i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=E({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(o.localStorage.setItem(Ur,JSON.stringify(E({},r,{source:void 0}))),this.wt()===Wr.LOADED)this.xt(r);else if(this.wt()===Wr.UNINITIALIZED){var n;this.yt(Wr.LOADING),null==(n=m.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return Hr.error("[Toolbar] Failed to load",e),void this.yt(Wr.UNINITIALIZED);this.yt(Wr.LOADED),this.xt(r)}),Ut(o,"turbolinks:load",()=>{this.yt(Wr.UNINITIALIZED),this.loadToolbar(r)})}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var zr=Pt("[TracingHeaders]");class Vr{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var e,t;N(this.$t)&&(null==(e=m.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),N(this.St)&&(null==(t=m.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return zr.error("failed to load script",t);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):(null==(e=this.$t)||e.call(this),null==(t=this.St)||t.call(this),this.$t=void 0,this.St=void 0)}}var Gr="https?://(.*)",Jr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Yr=Rt(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Jr),Xr="<masked>",Kr=["li_fat_id"];function Zr(e,t,i){if(!h)return{};var r,n=t?Rt([],Jr,i||[]):[],s=Qr(er(h.URL,n,Xr),e),o=(r={},Ft(Kr,function(e){var t=mr.q(e);r[e]=t||null}),r);return Ot(o,s)}function Qr(e,t){var i=Yr.concat(t||[]),r={};return Ft(i,function(t){var i=Qi(e,t);r[t]=i||null}),r}function en(e){var t,i=(t=e)?0===t.search(Gr+"google.([^/?]*)")?"google":0===t.search(Gr+"bing.com")?"bing":0===t.search(Gr+"yahoo.com")?"yahoo":0===t.search(Gr+"duckduckgo.com")?"duckduckgo":null:null,r="yahoo"!=i?"q":"p",n={};if(!U(i)){n.$search_engine=i;var s=h?Qi(h.referrer,r):"";s.length&&(n.ph_keyword=s)}return n}function tn(){return navigator.language||navigator.userLanguage}function rn(){return(null==h?void 0:h.referrer)||"$direct"}function nn(e,t){var i=e?Rt([],Jr,t||[]):[],r=null==p?void 0:p.href.substring(0,1e3);return{r:rn().substring(0,1e3),u:r?er(r,i,Xr):void 0}}function sn(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=Zi(i))?void 0:t.host};if(r){n.$current_url=r;var s=Zi(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=Qr(r);Ot(n,o)}if(i){var a=en(i);Ot(n,a)}return n}function on(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(pr){return}}function an(){try{return(new Date).getTimezoneOffset()}catch(pr){return}}var ln=Pt("[Web Vitals]"),cn=9e5;class un{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),0!==this.N.metrics.length&&(this._instance.capture("$web_vitals",this.N.metrics.reduce((e,t)=>E({},e,{["$web_vitals_"+t.name+"_event"]:E({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=e=>{var t,i=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(N(i))ln.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.Ct();N(r)||(H(null==e?void 0:e.name)||H(null==e?void 0:e.value)?ln.error("Invalid metric received",e):this.Rt&&e.value>=this.Rt?ln.error("Ignoring metric with value >= "+this.Rt,e):(this.N.url!==r&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),N(this.N.url)&&(this.N.url=r),this.N.firstMetricTimestamp=N(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.N.metrics.push(E({},e,{$current_url:r,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var e,t,i,r,n=m.__PosthogExtensions__;N(n)||N(n.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=n.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.It.bind(this)),this.P=!0):ln.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!(null==(t=this._instance.persistence)||!t.props[Xt]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=D(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return H(i)?(null==(t=this._instance.persistence)?void 0:t.props[Qt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return null!=e&&e}get Rt(){var e=D(this._instance.config.capture_performance)&&W(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:cn;return 0<e&&e<=6e4?cn:e}get isEnabled(){var e=null==p?void 0:p.protocol;if("http:"!==e&&"https:"!==e)return ln.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:z(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return z(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(ln.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=D(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=D(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xt]:t}),this._instance.persistence.register({[Qt]:i})),this.kt=t,this.startIfEnabled()}it(e){var t,i;if(null!=(t=m.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks)e();else{var r=this.useAttribution?"web-vitals-with-attribution":"web-vitals";null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,r,t=>{t?ln.error("failed to load script",t):e()})}}Ct(){var e=o?o.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,r=t?Rt([],Jr,i||[]):[];return er(e,r,Xr)}ln.error("Could not determine current URL")}}var dn=Pt("[Heatmaps]");function hn(e){return D(e)&&"clientX"in e&&"clientY"in e&&W(e.clientX)&&W(e.clientY)}class pn{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!(null==(t=this.instance.persistence)||!t.props[Vt]),this.rageclicks=new Ki(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return D(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return H(this.instance.config.capture_heatmaps)?H(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.P)return;dn.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval(null!==(e=this.Ft)&&void 0!==e?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Vt]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft="visible"===(null==h?void 0:h.visibilityState)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){o&&h&&(this.Nt=this.Lt.bind(this),Ut(o,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||(null==o?void 0:o.event)),Ut(h,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(null==o?void 0:o.event)),Ut(h,"mousemove",this.zt,{capture:!0}),this.Bt=new Fr(this.instance,Tr,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Ut(h,"visibilitychange",this.qt),this.P=!0)}At(){var e;o&&h&&(this.Nt&&o.removeEventListener("beforeunload",this.Nt),this.Ut&&h.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&h.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&h.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),null==(e=this.Bt)||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),s=function(e,t,i){for(var r=e;r&&bi(r)&&!Ei(r,"body");){if(r===i)return!1;if($(t,null==o?void 0:o.getComputedStyle(r).position))return!0;r=Ri(r)}return!1}(Ci(e),["fixed","sticky"],n);return{x:e.clientX+(s?0:r),y:e.clientY+(s?0:i),target_fixed:s,type:t}}Dt(e,t){var i;if(void 0===t&&(t="click"),!wi(e.target)&&hn(e)){var r=this.Gt(e,t);null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this.Vt(E({},r,{type:"rageclick"})),this.Vt(r)}}Ht(e){!wi(e.target)&&hn(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(o){var t=o.location.href,i=this.instance.config.mask_personal_data_properties,r=this.instance.config.custom_personal_data_properties,n=i?Rt([],Jr,r||[]):[],s=er(t,n,Xr);this.N=this.N||{},this.N[s]||(this.N[s]=[]),this.N[s].push(e)}}Lt(){this.N&&!L(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class gn{constructor(e){this.Jt=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(xt.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this.Jt)}destroy(){var e;null==(e=this.Xt)||e.call(this),this.Xt=void 0}doPageView(e,t){var i,r=this.Qt(e,t);return this.Kt={pathname:null!==(i=null==o?void 0:o.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.Qt(e,null==(t=this.Kt)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this.Kt)?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:s,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=n;if(!(N(s)||N(o)||N(a)||N(l)||N(c)||N(u))){s=Math.ceil(s),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=s<=1?1:Q(o/s,0,1,xt),h=s<=1?1:Q(a/s,0,1,xt),p=l<=1?1:Q(c/l,0,1,xt),g=l<=1?1:Q(u/l,0,1,xt);r=Ot(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:g})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var fn=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),_n=Uint8Array,vn=Uint16Array,mn=Uint32Array,yn=new _n([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]),wn=new _n([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]),bn=new _n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),En=function(e,t){for(var i=new vn(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var n=new mn(i[30]);for(r=1;r<30;++r)for(var s=i[r];s<i[r+1];++s)n[s]=s-i[r]<<5|r;return[i,n]},Sn=En(yn,2),kn=Sn[0],xn=Sn[1];kn[28]=258,xn[258]=28;for(var Pn=En(wn,0)[1],$n=new vn(32768),In=0;In<32768;++In){var Tn=(43690&In)>>>1|(21845&In)<<1;Tn=(61680&(Tn=(52428&Tn)>>>2|(13107&Tn)<<2))>>>4|(3855&Tn)<<4,$n[In]=((65280&Tn)>>>8|(255&Tn)<<8)>>>1}var Cn=function(e,t,i){for(var r=e.length,n=0,s=new vn(t);n<r;++n)++s[e[n]-1];var o,a=new vn(t);for(n=0;n<t;++n)a[n]=a[n-1]+s[n-1]<<1;for(o=new vn(r),n=0;n<r;++n)o[n]=$n[a[e[n]-1]++]>>>15-e[n];return o},Fn=new _n(288);for(In=0;In<144;++In)Fn[In]=8;for(In=144;In<256;++In)Fn[In]=9;for(In=256;In<280;++In)Fn[In]=7;for(In=280;In<288;++In)Fn[In]=8;var On=new _n(32);for(In=0;In<32;++In)On[In]=5;var Rn=Cn(Fn,9),An=Cn(On,5),Mn=function(e){return(e/8|0)+(7&e&&1)},Dn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof vn?vn:e instanceof mn?mn:_n)(i-t);return r.set(e.subarray(t,i)),r},Ln=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8},Nn=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},jn=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var n=i.length,s=i.slice();if(!n)return[new _n(0),0];if(1==n){var o=new _n(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(r=1;r<n;++r)s[r].s>h&&(h=s[r].s);var p=new vn(h+1),g=qn(i[u-1],p,0);if(g>t){r=0;var f=0,_=g-t,v=1<<_;for(s.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<n;++r){var m=s[r].s;if(!(p[m]>t))break;f+=v-(1<<g-p[m]),p[m]=t}for(f>>>=_;f>0;){var y=s[r].s;p[y]<t?f-=1<<t-p[y]++-1:++r}for(;r>=0&&f;--r){var w=s[r].s;p[w]==t&&(--p[w],++f)}g=t}return[new _n(p),g]},qn=function(e,t,i){return-1==e.s?Math.max(qn(e.l,t,i+1),qn(e.r,t,i+1)):t[e.s]=i},Un=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new vn(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&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(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return[i.subarray(0,r),t]},Hn=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},Wn=function(e,t,i){var r=i.length,n=Mn(t+2);e[n]=255&r,e[n+1]=r>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s<r;++s)e[n+s+4]=i[s];return 8*(n+4+r)},Bn=function(e,t,i,r,n,s,o,a,l,c,u){Ln(t,u++,i),++n[256];for(var d=jn(n,15),h=d[0],p=d[1],g=jn(s,15),f=g[0],_=g[1],v=Un(h),m=v[0],y=v[1],w=Un(f),b=w[0],E=w[1],S=new vn(19),k=0;k<m.length;++k)S[31&m[k]]++;for(k=0;k<b.length;++k)S[31&b[k]]++;for(var x=jn(S,7),P=x[0],$=x[1],I=19;I>4&&!P[bn[I-1]];--I);var T,C,F,O,R=c+5<<3,A=Hn(n,Fn)+Hn(s,On)+o,M=Hn(n,h)+Hn(s,f)+o+14+3*I+Hn(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(R<=A&&R<=M)return Wn(t,u,e.subarray(l,l+c));if(Ln(t,u,1+(M<A)),u+=2,M<A){T=Cn(h,p),C=h,F=Cn(f,_),O=f;var D=Cn(P,$);for(Ln(t,u,y-257),Ln(t,u+5,E-1),Ln(t,u+10,I-4),u+=14,k=0;k<I;++k)Ln(t,u+3*k,P[bn[k]]);u+=3*I;for(var L=[m,b],N=0;N<2;++N){var j=L[N];for(k=0;k<j.length;++k){var q=31&j[k];Ln(t,u,D[q]),u+=P[q],q>15&&(Ln(t,u,j[k]>>>5&127),u+=j[k]>>>12)}}}else T=Rn,C=Fn,F=An,O=On;for(k=0;k<a;++k)if(r[k]>255){q=r[k]>>>18&31,Nn(t,u,T[q+257]),u+=C[q+257],q>7&&(Ln(t,u,r[k]>>>23&31),u+=yn[q]);var U=31&r[k];Nn(t,u,F[U]),u+=O[U],U>3&&(Nn(t,u,r[k]>>>5&8191),u+=wn[U])}else Nn(t,u,T[r[k]]),u+=C[r[k]];return Nn(t,u,T[256]),u+C[256]},zn=new mn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vn=function(){for(var e=new mn(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Gn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};var Jn=!!f||!!g,Yn="text/plain",Xn=function(e,t,i){var r;void 0===i&&(i=!0);var[n,s]=e.split("?"),o=E({},t),a=null!==(r=null==s?void 0:s.split("&").map(e=>{var t,[r,n]=e.split("="),s=i&&null!==(t=o[r])&&void 0!==t?t:n;return delete o[r],r+"="+s}))&&void 0!==r?r:[],l=function(e,t){var i,r;void 0===t&&(t="&");var n=[];return Ft(e,function(e,t){N(e)||N(t)||"undefined"===t||(i=encodeURIComponent(e instanceof File?e.name:e.toString()),r=encodeURIComponent(t),n[n.length]=r+"="+i)}),n.join(t)}(o);return l&&a.push(l),n+"?"+a.join("&")},Kn=(e,t)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,t),Zn=e=>{var t,{data:i,compression:r}=e;if(i){if(r===fn.GZipJS){var n=function(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Vn[255&i^t[r]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),r=e.length;i.p(e);var n,s=function(e,t,i){return function(e,t,i,r){var n=e.length,s=new _n(r+n+5*(1+Math.floor(n/7e3))+8),o=s.subarray(r,s.length-8),a=0;if(!t||n<8)for(var l=0;l<=n;l+=65535){var c=l+65535;c<n?a=Wn(o,a,e.subarray(l,c)):(o[l]=!0,a=Wn(o,a,e.subarray(l,n)))}else{for(var u=zn[t-1],d=u>>>13,h=8191&u,p=(1<<i)-1,g=new vn(32768),f=new vn(p+1),_=Math.ceil(i/3),v=2*_,m=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&p},y=new mn(25e3),w=new vn(288),b=new vn(32),E=0,S=0,k=(l=0,0),x=0,P=0;l<n;++l){var $=m(l),I=32767&l,T=f[$];if(g[I]=T,f[$]=I,x<=l){var C=n-l;if((E>7e3||k>24576)&&C>423){a=Bn(e,o,0,y,w,b,S,k,P,l-P,a),k=E=S=0,P=l;for(var F=0;F<286;++F)w[F]=0;for(F=0;F<30;++F)b[F]=0}var O=2,R=0,A=h,M=I-T&32767;if(C>2&&$==m(l-M))for(var D=Math.min(d,C)-1,L=Math.min(32767,l),N=Math.min(258,C);M<=L&&--A&&I!=T;){if(e[l+O]==e[l+O-M]){for(var j=0;j<N&&e[l+j]==e[l+j-M];++j);if(j>O){if(O=j,R=M,j>D)break;var q=Math.min(M,j-2),U=0;for(F=0;F<q;++F){var H=l-M+F+32768&32767,W=H-g[H]+32768&32767;W>U&&(U=W,T=H)}}}M+=(I=T)-(T=g[I])+32768&32767}if(R){y[k++]=268435456|xn[O]<<18|Pn[R];var B=31&xn[O],z=31&Pn[R];S+=yn[B]+wn[z],++w[257+B],++b[z],x=l+O,++E}else y[k++]=e[l],++w[e[l]]}}a=Bn(e,o,!0,y,w,b,S,k,P,l-P,a)}return Dn(s,0,r+Mn(a)+8)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i)}(e,t,10+((n=t).filename&&n.filename.length+1||0)),o=s.length;return function(e,t){var i=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&&Gn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(s,t),Gn(s,o-8,i.d()),Gn(s,o-4,r),s}(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new _n(e.length+(e.length>>>1)),r=0,n=function(e){i[r++]=e},s=0;s<t;++s){if(r+5>i.length){var o=new _n(r+8+(t-s<<1));o.set(i),i=o}var a=e.charCodeAt(s);a<128?n(a):a<2048?(n(192|a>>>6),n(128|63&a)):a>55295&&a<57344?(n(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++s))>>>18),n(128|a>>>12&63),n(128|a>>>6&63),n(128|63&a)):(n(224|a>>>12),n(128|a>>>6&63),n(128|63&a))}return Dn(i,0,r)}(Kn(i)),{mtime:0}),s=new Blob([n],{type:Yn});return{contentType:Yn,body:s,estimatedSize:s.size}}if(r===fn.Base64){var o=function(e){var t,i,r,n,s,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=function(e){var t,i,r,n,s="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,n=0;n<r;n++){var o=e.charCodeAt(n),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),U(a)||(i>t&&(s+=e.substring(t,i)),s+=a,t=i=n+1)}return i>t&&(s+=e.substring(t,e.length)),s}(e);do{t=(s=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=s>>12&63,r=s>>6&63,n=63&s,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(r)+o.charAt(n)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Kn(i)),a=(t=o,"data="+encodeURIComponent("string"==typeof t?t:Kn(t)));return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=Kn(i);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Qn=[];g&&Qn.push({transport:"fetch",method:e=>{var t,i,{contentType:r,body:n,estimatedSize:s}=null!==(t=Zn(e))&&void 0!==t?t:{},o=new Headers;Ft(e.headers,function(e,t){o.append(t,e)}),r&&o.append("Content-Type",r);var a=e.url,l=null;if(_){var c=new _;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),e.timeout)}}g(a,E({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(s||0)<52428.8,body:n,signal:null==(i=l)?void 0:i.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(n){xt.error(n)}null==e.callback||e.callback(r)})).catch(t=>{xt.error(t),null==e.callback||e.callback({statusCode:0,text:t})}).finally(()=>l?clearTimeout(l.timeout):null)}}),f&&Qn.push({transport:"XHR",method:e=>{var t,i=new f;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:n}=null!==(t=Zn(e))&&void 0!==t?t:{};Ft(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(r){}null==e.callback||e.callback(t)}},i.send(n)}}),null!=d&&d.sendBeacon&&Qn.push({transport:"sendBeacon",method:e=>{var t=Xn(e.url,{beacon:"1"});try{var i,{contentType:r,body:n}=null!==(i=Zn(e))&&void 0!==i?i:{},s="string"==typeof n?new Blob([n],{type:r}):n;d.sendBeacon(t,s)}catch(o){}}});var es=function(e,t){if(!function(){return!0}())return!1;try{return new RegExp(t).test(e)}catch(i){return!1}};function ts(e,t,i){return Kn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var is={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>es(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!es(t,e))),icontains:(e,t)=>t.map(rs).some(t=>e.map(rs).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(rs).every(t=>e.map(rs).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})},rs=e=>e.toLowerCase();function ns(e,t){return!e||Object.entries(e).every(e=>{var[i,r]=e,n=null==t?void 0:t[i];if(N(n)||U(n))return!1;var s=[String(n)],o=is[r.operator];return!!o&&o(r.values,s)})}var ss=Pt("[Error tracking]");class os{constructor(e){var t,i;this.Zt=[],this.ti=new tt([new pt,new St,new ft,new gt,new bt,new wt,new vt,new Et],function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],s=t.split("\n"),o=r;o<s.length;o++){var a=s[o];if(!(a.length>1024)){var l=ht.test(a)?a.replace(ht,"$1"):a;if(!l.match(/\S*Error: /)){for(var c of i){var u=c(l,e);if(u){n.push(u);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return E({},e,{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||it});var i})}(n)}}("web:javascript",lt,dt)),this._instance=e,this.Zt=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Jt))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,r,n=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],s=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this.Zt=n,this._instance.persistence&&this._instance.persistence.register({[Jt]:this.Zt,[Yt]:s})}get ii(){var e,t=!!this._instance.get_property(Yt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void ss.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void ss.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void ss.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(0===e.length)return!1;var t=e.reduce((e,t)=>{var{type:i,value:r}=t;return j(i)&&i.length>0&&e.$exception_types.push(i),j(r)&&r.length>0&&e.$exception_values.push(r),e},{$exception_types:[],$exception_values:[]});return this.Zt.some(e=>{var i=e.values.map(e=>{var i,r=is[e.operator],n=A(e.value)?e.value:[e.value],s=null!==(i=t[e.key])&&void 0!==i?i:[];return n.length>0&&r(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}si(e){return e.flatMap(e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}ni(e){if(e.length>0){var t,i,r,n,s=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=s[s.length-1];return null!==(r=null==o||null==(n=o.filename)?void 0:n.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ei(e){return!H(e)&&A(e)}}var as=Pt("[FeatureFlags]"),ls=Pt("[FeatureFlags]",{debugEnabled:!0}),cs="$active_feature_flags",us="$override_feature_flags",ds="$feature_flag_payloads",hs="$override_feature_flag_payloads",ps="$feature_flag_request_id",gs="$feature_flag_evaluated_at",fs=e=>{var t={};for(var[i,r]of At(e||{}))r&&(t[i]=r);return t},_s=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class vs{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=null!==(e=this._instance.config.evaluation_contexts)&&void 0!==e?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(as.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),null!=t&&t.length?t.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||as.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(si),t=this._instance.get_property(us),i=this._instance.get_property(hs);if(!i&&!t)return e||{};var r=Ot({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var s of n){var o,a,l=r[s],c=null==t?void 0:t[s],u=N(c)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!c,d=N(c)?l.variant:"string"==typeof c?c:void 0,h=null==i?void 0:i[s],p=E({},l,{enabled:u,variant:u?null!=d?d:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(p.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(p.original_variant=null==l?void 0:l.variant),h&&(p.metadata=E({},null==l?void 0:l.metadata,{payload:h,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[s]=p}return this.oi||(as.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this.oi=!0),r}getFlagVariants(){var e=this._instance.get_property(ri),t=this._instance.get_property(us);if(!t)return e||{};for(var i=Ot({},e),r=Object.keys(t),n=0;n<r.length;n++)i[r[n]]=t[r[n]];return this.oi||(as.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.oi=!0),i}getFlagPayloads(){var e=this._instance.get_property(ds),t=this._instance.get_property(hs);if(!t)return e||{};for(var i=Ot({},e||{}),r=Object.keys(t),n=0;n<r.length;n++)i[r[n]]=t[r[n]];return this.oi||(as.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.oi=!0),i}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this._instance.bi.emit("featureFlagsReloading",!0),this.gi=setTimeout(()=>{this.mi()},5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.yi(),!this._instance.M())if(this.li)this.hi=!0;else{var i=this._instance.config.token,r=this._instance.get_property("$device_id"),n={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:E({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(oi)||{}),group_properties:this._instance.get_property(ai)};U(r)||N(r)||(n.$device_id=r),(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.pi()&&(n.evaluation_contexts=this.fi());var s=this._instance.config.__preview_remote_config,o=s?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",l=this._instance.requestRouter.endpointFor("flags",o+a);s&&(n.timezone=on()),this.li=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this._instance.config.disable_compression?void 0:fn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r=!0;if(200===e.statusCode&&(this.hi||(this.$anon_distinct_id=void 0),r=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi(null!==(i=e.json)&&void 0!==i?i:{})),!n.disable_flags||this.hi)if(this.vi=!r,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(_s.FeatureFlags))as.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var s;n.disable_flags||this.receivedFeatureFlags(null!==(s=e.json)&&void 0!==s?s:{},r),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}as.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants(),r=e in i,n=i[e],s=this.getFlagPayloads()[e],o=String(n),a=this._instance.get_property(ps)||void 0,l=this._instance.get_property(gs)||void 0,c=this._instance.get_property(ci)||{};if((t.send_event||!("send_event"in t))&&(!(e in c)||!c[e].includes(o))){var u,d,h,p,g,f,_,v,m;A(c[e])?c[e].push(o):c[e]=[o],null==(u=this._instance.persistence)||u.register({[ci]:c});var y=this.getFeatureFlagDetails(e),w={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:s||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(d=this._instance.config.bootstrap)||null==(d=d.featureFlags)?void 0:d[e])||null,$feature_flag_bootstrapped_payload:(null==(h=this._instance.config.bootstrap)||null==(h=h.featureFlagPayloads)?void 0:h[e])||null,$used_bootstrap_value:!this.vi};N(null==y||null==(p=y.metadata)?void 0:p.version)||(w.$feature_flag_version=y.metadata.version);var b,E=null!==(g=null==y||null==(f=y.reason)?void 0:f.description)&&void 0!==g?g:null==y||null==(_=y.reason)?void 0:_.code;E&&(w.$feature_flag_reason=E),null!=y&&null!=(v=y.metadata)&&v.id&&(w.$feature_flag_id=y.metadata.id),N(null==y?void 0:y.original_variant)&&N(null==y?void 0:y.original_enabled)||(w.$feature_flag_original_response=N(y.original_variant)?y.original_enabled:y.original_variant),null!=y&&null!=(m=y.metadata)&&m.original_payload&&(w.$feature_flag_original_payload=null==y||null==(b=y.metadata)?void 0:b.original_payload),this._instance.capture("$feature_flag_called",w)}if(r){var S=s;if(!N(s))try{S=JSON.parse(s)}catch(k){}return{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:S}}}else as.warn('getFeatureFlagResult for key "'+e+"\" failed. Feature flags didn't load in time.")}getRemoteConfigPayload(e,t){var i=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(r.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:r,compression:this._instance.config.disable_compression?void 0:fn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var r,n=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==n?void 0:n[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return N(i)?void 0:!!i}as.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var i=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,i,r,n){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={});var s=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(e=>t[e].enabled).filter(e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload}).map(e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]}))):as.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),o=s.flags,a=s.featureFlags,l=s.featureFlagPayloads;if(a){var c=e.requestId,u=e.evaluatedAt;if(A(a)){as.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(a)for(var h=0;h<a.length;h++)d[a[h]]=!0;t&&t.register({[cs]:a,[ri]:d})}else{var p=a,g=l,f=o;if(e.errorsWhileComputingFlags)if(o){var _=new Set(Object.keys(o).filter(e=>{var t;return!(null!=(t=o[e])&&t.failed)}));p=E({},i,Object.fromEntries(Object.entries(p).filter(e=>{var[t]=e;return _.has(t)}))),g=E({},r,Object.fromEntries(Object.entries(g||{}).filter(e=>{var[t]=e;return _.has(t)}))),f=E({},n,Object.fromEntries(Object.entries(f||{}).filter(e=>{var[t]=e;return _.has(t)})))}else p=E({},i,p),g=E({},r,g),f=E({},n,f);t&&t.register(E({[cs]:Object.keys(fs(p)),[ri]:p||{},[ds]:g||{},[si]:f||{}},c?{[ps]:c}:{},u?{[gs]:u}:{}))}}}(e,this._instance.persistence,i,r,n),this.xi(t)}}override(e,t){void 0===t&&(t=!1),as.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return as.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(us),this._instance.persistence.unregister(hs),this.xi(),ls.info("All overrides cleared");if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this.oi=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(us),ls.info("Flag overrides cleared");else if(i.flags){if(A(i.flags)){for(var r={},n=0;n<i.flags.length;n++)r[i.flags[n]]=!0;this._instance.persistence.register({[us]:r})}else this._instance.persistence.register({[us]:i.flags});ls.info("Flag overrides set",{flags:i.flags})}return"payloads"in i&&(!1===i.payloads?(this._instance.persistence.unregister(hs),ls.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[hs]:i.payloads}),ls.info("Payload overrides set",{payloads:i.payloads}))),void this.xi()}this.xi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:i}=this.Ei();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var r,n=(this._instance.get_property(ni)||[]).find(t=>t.flagKey===e),s={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:s};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(s,!1);var a=E({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[cs]:Object.keys(fs(a)),[ri]:a}),this.xi()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._instance.get_property(ni),n=i?"&"+i.map(e=>"stage="+e).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+n),method:"GET",callback:t=>{var i,r;if(t.json){var n=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(ni),null==(r=this._instance.persistence)||r.register({[ni]:n}),e(n)}}})}Ei(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}xi(e){var{flags:t,flagVariants:i}=this.Ei();this.featureFlagEventHandlers.forEach(r=>r(t,i,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(oi)||{};this._instance.register({[oi]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(oi)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(ai)||{};0!==Object.keys(i).length&&Object.keys(i).forEach(t=>{i[t]=E({},i[t],e[t]),delete e[t]}),this._instance.register({[ai]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ai)||{};this._instance.register({[ai]:E({},t,{[e]:{}})})}else this._instance.unregister(ai)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.oi=!1}}var ms=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class ys{constructor(e,t){var i,r;this.R=e,this.props={},this.$i=!1,this.Si=(r="",(i=e).token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"),this.Y=this.ki(e),this.load(),e.debug&&xt.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Pi}ki(e){-1===ms.indexOf(e.persistence.toLowerCase())&&(xt.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(e){void 0===e&&(e=[]);var t=[...br,...e];return E({},wr,{W:function(e){try{var t={};try{t=mr.W(e)||{}}catch(r){}var i=Ot(t,JSON.parse(wr.q(e)||"{}"));return wr.G(e,i),i}catch(r){}return null},G:function(e,i,r,n,s,o){try{wr.G(e,i,void 0,void 0,o);var a={};t.forEach(e=>{i[e]&&(a[e]=i[e])}),Object.keys(a).length&&mr.G(e,a,r,n,s,o)}catch(l){wr.B(l)}},V:function(e,t){try{null==o||o.localStorage.removeItem(e),mr.V(e,t)}catch(pr){wr.B(pr)}}})}(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return"localstorage"===i&&wr.H()?wr:"localstorage+cookie"===i&&t.H()?t:"sessionstorage"===i&&xr.H()?xr:"memory"===i?Sr:"cookie"===i?mr:t.H()?t:mr}properties(){var e={};return Ft(this.props,function(t,i){if(i===ri&&D(t))for(var r=Object.keys(t),n=0;n<r.length;n++)e["$feature/"+r[n]]=t[r[n]];else o=i,a=!1,(U(s=yi)?a:u&&s.indexOf===u?-1!=s.indexOf(o):(Ft(s,function(e){if(a||(a=e===o))return Tt}),a))||(e[i]=t);var s,o,a}),e}load(){if(!this.Pi){var e=this.Y.W(this.Si);e&&(this.props=Ot({},e))}}save(){this.Pi||this.Y.G(this.Si,this.props,this.Ti,this.Ii,this.Ci,this.R.debug)}remove(){this.Y.V(this.Si,!1),this.Y.V(this.Si,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(D(e)){N(t)&&(t="None"),this.Ti=N(i)?this.Ri:i;var r=!1;if(Ft(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(D(e)){this.Ti=N(t)?this.Ri:t;var i=!1;if(Ft(e,(t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,i=!0)}),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.$i){var e=Zr(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);L(Lt(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=null==h?void 0:h.referrer)?en(e):{})}update_referrer_info(){var e;this.register_once({$referrer:rn(),$referring_domain:null!=h&&h.referrer&&(null==(e=Zi(h.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[pi]||this.props[gi]||this.register_once({[fi]:nn(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Ft([gi,pi],t=>{var i=this.props[t];i&&Ft(i,function(t,i){e["$initial_"+T(i)]=t})});var t,i,r=this.props[fi];if(r){var n=(t=sn(r),i={},Ft(t,function(e,t){i["$initial_"+T(t)]=e}),i);Ot(e,n)}return e}safe_merge(e){return Ft(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){if(this.Ri=this.Ti=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.ki(e),n=this.props;this.clear(),this.Y=r,this.props=n,this.save()}}set_disabled(e){this.Pi=e,this.Pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_secure(e){e!==this.Ci&&(this.Ci=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Bt]||{};i[e]=t,this.props[Bt]=i,this.save()}remove_event_timer(e){var t=(this.props[Bt]||{})[e];return N(t)||(delete this.props[Bt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var ws=Pt("[Product Tours]"),bs="ph_product_tours";class Es{constructor(e){this.Fi=null,this.Oi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Zt]:!(null==e||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Fi||(e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(Zt)||this.it(()=>this.Mi())}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",t=>{t?ws.error("Could not load product tours script",t):e()})}Mi(){var e;!this.Fi&&null!=(e=m.__PosthogExtensions__)&&e.generateProductTours&&(this.Fi=m.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!A(this.Oi)||t){var i=this._instance.persistence;if(i){var r=i.props[bs];if(A(r)&&!t)return this.Oi=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:t=>{var r=t.statusCode;if(200!==r||!t.json){var n="Product Tours API could not be loaded, status: "+r;return ws.error(n),void e([],{isLoaded:!1,error:n})}var s=A(t.json.product_tours)?t.json.product_tours:[];this.Oi=s,i&&i.register({[bs]:s}),e(s,{isLoaded:!0})}})}else e(this.Oi,{isLoaded:!0})}getActiveProductTours(e){H(this.Fi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this.Fi)||t.showTourById(e)}previewTour(e){this.Fi?this.Fi.previewTour(e):this.it(()=>{var t;this.Mi(),null==(t=this.Fi)||t.previewTour(e)})}dismissProductTour(){var e;null==(e=this.Fi)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this.Fi)||e.nextStep()}previousStep(){var e;null==(e=this.Fi)||e.previousStep()}clearCache(){var e;this.Oi=null,null==(e=this._instance.persistence)||e.unregister(bs)}resetTour(e){var t;null==(t=this.Fi)||t.resetTour(e)}resetAllTours(){var e;null==(e=this.Fi)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this.Fi)||t.cancelPendingTour(e)}}var Ss=function(e){return e.Activation="events",e.Cancellation="cancelEvents",e}({});!function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}({}),function(e){e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}({}),function(e){e.Top="top",e.Left="left",e.Right="right",e.Bottom="bottom"}({});var ks=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({});!function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}({}),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}({}),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}({});var xs=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e}({}),Ps=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",e}({}),$s=function(e){return e.Popover="popover",e.Inline="inline",e}({}),Is=Pt("[Surveys]"),Ts="seenSurvey_",Cs=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},Fs=e=>{return r=""+(t=Ts)+(i=e).id,i.current_iteration&&i.current_iteration>0&&(r=""+t+i.id+"_"+i.current_iteration),r;var t,i,r},Os=[ks.Popover,ks.Widget,ks.API],Rs={ignoreConditions:!1,ignoreDelay:!1,displayType:$s.Popover};class As{constructor(){this.Ai={},this.Ai={}}on(e,t){return this.Ai[e]||(this.Ai[e]=[]),this.Ai[e].push(t),()=>{this.Ai[e]=this.Ai[e].filter(e=>e!==t)}}emit(e,t){for(var i of this.Ai[e]||[])i(t);for(var r of this.Ai["*"]||[])r(e,t)}}function Ms(e,t,i){if(H(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(n){return!1}default:return!1}}class Ds{constructor(e){this.ji=new As,this.Di=(e,t)=>this.Li(e,t)&&this.Ni(e,t)&&this.Ui(e,t)&&this.zi(e,t),this.Li=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this.Hi=new Set,this.Bi=new Set}init(){var e,t;N(null==(e=this._instance)?void 0:e._addCaptureHook)||null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.on(e,t)})}register(e){var t,i;if(!N(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t,i;null==(t=this.Bi)||t.add(e),null==(i=e.steps)||i.forEach(e=>{var t;null==(t=this.Hi)||t.add((null==e?void 0:e.event)||"")})}),null!=(i=this._instance)&&i.autocapture)){var r,n=new Set;e.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&n.add(null==e?void 0:e.selector)})}),null==(r=this._instance)||r.autocapture.setElementSelectors(n)}}on(e,t){var i;null!=t&&0!=e.length&&(this.Hi.has(e)||this.Hi.has(null==t?void 0:t.event))&&this.Bi&&(null==(i=this.Bi)?void 0:i.size)>0&&this.Bi.forEach(e=>{this.qi(t,e)&&this.ji.emit("actionCaptured",e.name)})}Wi(e){this.onAction("actionCaptured",t=>e(t))}qi(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this.Di(e,i))return!0;return!1}onAction(e,t){return this.ji.on(e,t)}Ni(e,t){if(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ms(r,t.url,t.url_matching||"contains"))return!1}return!0}Ui(e,t){return!!this.Gi(e,t)&&!!this.Vi(e,t)&&!!this.Ji(e,t)}Gi(e,t){var i;if(null==t||!t.href)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Ms(e.href,t.href,t.href_matching||"exact"));var n,s=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!s&&Ms((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(null==t||!t.text)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Ms(e.text,t.text,t.text_matching||"exact")||Ms(e.$el_text,t.text,t.text_matching||"exact"));var n,s,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(n=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!H(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),s=t.text,o=t.text_matching||"exact",n.some(e=>Ms(e,s,o)))}Ji(e,t){var i,r;if(null==t||!t.selector)return!0;var n=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=n&&n.includes(t.selector))return!0;var s=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&s)try{return new RegExp(t.selector_regex).test(s)}catch(o){return!1}return!1}Ki(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}zi(e,t){return null==t||!t.properties||0===t.properties.length||ns(t.properties.reduce((e,t)=>{var i=A(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}}class Ls{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&ns(e.propertyFilters,null==t?void 0:t.properties)}te(e,t){var i=new Map;return e.forEach(e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach(t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}})}),i}ie(e,t,i){var r=(i===Ss.Activation?this.Yi:this.Xi).get(e),n=[];return this.ee(e=>{n=e.filter(e=>null==r?void 0:r.includes(e.id))}),n.filter(r=>{var n,s=null==(n=r.conditions)||null==(n=n[i])||null==(n=n.values)?void 0:n.find(t=>t.name===e);return this.Zi(s,t)})}register(e){var t;N(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.re(e),this.se(e))}se(e){var t=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0});0!==t.length&&(null==this.ne&&(this.ne=new Ds(this._instance),this.ne.init(),this.ne.Wi(e=>{this.onAction(e)})),t.forEach(e=>{var t,i,r,n,s;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(n=this.ne)||n.register(e.conditions.actions.values),null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)||s.forEach(t=>{if(t&&t.name){var i=this.Qi.get(t.name);i&&i.push(e.id),this.Qi.set(t.name,i||[e.id])}}))}))}re(e){var t,i=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0});0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.onEvent(e,t)}),this.Yi=this.te(e,Ss.Activation),this.Xi=this.te(e,Ss.Cancellation))}onEvent(e,t){var i,r=this.oe(),n=this.ae(),s=this.le(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[n])||[];if(s===e&&t&&o.length>0){var a,l;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(c){var u=o.indexOf(c);u>=0&&(o.splice(u,1),this.ue(o))}}else{if(this.Xi.has(e)){var d=this.ie(e,t,Ss.Cancellation);d.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:d.map(e=>e.id)}),d.forEach(e=>{var t=o.indexOf(e.id);t>=0&&o.splice(t,1),this.he(e.id)}),this.ue(o))}if(this.Yi.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var h=this.ie(e,t,Ss.Activation);this.ue(o.concat(h.map(e=>e.id)||[]))}}}onAction(e){var t,i=this.ae(),r=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(r.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),r=this.ae(),n=[...new Set(e)].filter(e=>!this.de(e));i.info("updating activated items",{activatedItems:n}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[r]:n})}getActivatedIds(){var e,t=this.ae();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}}class Ns extends Ls{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return xs.SHOWN}ee(e){var t;null==(t=this._instance)||t.getSurveys(e)}he(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}oe(){return Is}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class js{constructor(e){this.ce=void 0,this._surveyManager=null,this.fe=!1,this.pe=[],this.ge=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(H(t))return Is.warn("Flags not loaded yet. Not loading surveys.");var i=A(t);this.ce=i?t.length>0:t,Is.info("flags response received, isSurveysEnabled: "+this.ce),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith(Ts)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)Is.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Is.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Is.info("Not loading surveys in cookieless mode without consent.");else{var e=null==m?void 0:m.__PosthogExtensions__;if(e){if(!N(this.ce)||this._instance.config.advanced_enable_surveys){var t=this.ce||this._instance.config.advanced_enable_surveys;this.fe=!0;try{var i=e.generateSurveys;if(i)return void this._e(i,t);var r=e.loadExternalDependency;if(!r)return void this.me("PostHog loadExternalDependency extension not found.");r(this._instance,"surveys",i=>{i||!e.generateSurveys?this.me("Could not load surveys script",i):this._e(e.generateSurveys,t)})}catch(n){throw this.me("Error initializing surveys",n),n}finally{this.fe=!1}}}else Is.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ns(this._instance),Is.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(e,t){Is.error(e,t),this.be({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.pe.push(e),this._surveyManager&&this.be({isLoaded:!0}),()=>{this.pe=this.pe.filter(t=>t!==e)}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Is.info("Disabled. Not loading surveys."),e([]);var i,r=this._instance.get_property(li);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.ge?this.ge.then(t=>{var{surveys:i,context:r}=t;return e(i,r)}):("undefined"!=typeof Promise&&(this.ge=new Promise(e=>{i=e})),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:t=>{var r;this.ge=null;var n=t.statusCode;if(200!==n||!t.json){var s="Surveys API could not be loaded, status: "+n;Is.error(s);var o={isLoaded:!1,error:s};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],c=l.filter(e=>{return!(!(t=e).start_date||t.end_date)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e));var t});c.length>0&&(null==(a=this._surveyEventReceiver)||a.register(c)),null==(r=this._instance.persistence)||r.register({[li]:l});var u={isLoaded:!0};e(l,u),null==i||i({surveys:l,context:u})}}))}be(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){Is.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!H(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Is.warn("init was not called")}ye(e){var t=null;return this.getSurveys(i=>{var r;t=null!==(r=i.find(t=>t.id===e))&&void 0!==r?r:null}),t}we(e){if(H(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(H(this._surveyManager))return Is.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.we(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return H(this._surveyManager)?(Is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(i=>{this.getSurveys(t=>{var r,n=null!==(r=t.find(t=>t.id===e))&&void 0!==r?r:null;if(n){var s=this.we(n);i({visible:s.eligible,disabledReason:s.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var r;if(H(this._surveyManager))Is.warn("init was not called");else{var n="string"==typeof e?this.ye(e):e;if(null!=n&&n.id)if(Os.includes(n.type)){var s=null==h?void 0:h.querySelector(t);if(s)return null!=(r=n.appearance)&&r.surveyPopupDelaySeconds?(Is.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var e,t;Is.info("Rendering survey "+n.id+" with delay of "+(null==(e=n.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(n,s,i),Is.info("Survey "+n.id+" rendered")},1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,s,i);Is.warn("Survey element not found")}else Is.warn("Surveys of type "+n.type+" cannot be rendered in the app");else Is.warn("Survey not found")}}displaySurvey(e,t){var i;if(H(this._surveyManager))Is.warn("init was not called");else{var r=this.ye(e);if(r){var n=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=E({},r,{appearance:E({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==$s.Popover&&t.initialResponses&&Is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var s=this.canRenderSurvey(r);if(!s.visible)return void Is.warn("Survey is not eligible to be displayed: ",s.disabledReason)}t.displayType!==$s.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else Is.warn("Survey not found")}}cancelPendingSurvey(e){H(this._surveyManager)?Is.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}var qs=Pt("[Conversations]");class Us{constructor(e){this.xe=void 0,this._conversationsManager=null,this.Ee=!1,this.$e=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;H(t)||(z(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this.xe=void 0,this.$e=null}loadIfEnabled(){if(!this._conversationsManager&&!this.Ee&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==m?void 0:m.__PosthogExtensions__;if(e&&!N(this.xe)&&this.xe)if(this.$e&&this.$e.token){this.Ee=!0;try{var t=e.initConversations;if(t)return this.Se(t),void(this.Ee=!1);var i=e.loadExternalDependency;if(!i)return void this.ke("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",t=>{t||!e.initConversations?this.ke("Could not load conversations script",t):this.Se(e.initConversations),this.Ee=!1})}catch(r){this.ke("Error initializing conversations",r),this.Ee=!1}}else qs.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),qs.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else qs.error("Cannot complete initialization: remote config is null")}ke(e,t){qs.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():qs.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.xe&&!U(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var r=this;return b(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,i):(qs.warn("Conversations not available yet."),null)})()}getMessages(e,t){var i=this;return b(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(qs.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return b(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(qs.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return b(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(qs.warn("Conversations not available yet."),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}}class Hs{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!H(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=Pt("[logs]"),t=null==m?void 0:m.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",i=>{var r;i||null==(r=t.logs)||!r.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Te=!0)}):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}}var Ws=Pt("[RateLimiter]");class Bs{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Ws.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(i){return void Ws.warn('could not rate limit - continuing. Error: "'+(null==i?void 0:i.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:s}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(hi))&&void 0!==t?t:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*s,a.last=o,a.tokens>n&&(a.tokens=n);var l=a.tokens<1;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+s+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(hi,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var zs=Pt("[RemoteConfig]");class Vs{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}Ie(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(zs.error("PostHog Extensions not found. Cannot load remote config."),e())}Ce(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return zs.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void zs.warn("Remote config is disabled. Falling back to local config.");this.Ie(e=>{if(!e)return zs.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce(e=>{this.wi(e)});this.wi(e)})}catch(pr){zs.error("Error loading remote config",pr)}}wi(e){e?this._instance.config.__preview_remote_config?(this._instance.wi(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):zs.info("__preview_remote_config is disabled. Logging config instead",e):zs.error("Failed to fetch remote config from PostHog.")}}var Gs=3e3;class Js{constructor(e,t){this.Re=!0,this.Fe=[],this.Oe=Q((null==t?void 0:t.flush_interval_ms)||Gs,250,5e3,xt.createLogger("flush interval"),Gs),this.Me=e}enqueue(e){this.Fe.push(e),this.Ae||this.je()}unload(){this.De();var e=this.Fe.length>0?this.Le():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this.Me(E({},e,{transport:"sendBeacon"}))})}enable(){this.Re=!1,this.je()}je(){var e=this;this.Re||(this.Ae=setTimeout(()=>{if(this.De(),this.Fe.length>0){var t=this.Le(),i=function(){var i=t[r],n=(new Date).getTime();i.data&&A(i.data)&&Ft(i.data,e=>{e.offset=Math.abs(e.timestamp-n),delete e.timestamp}),e.Me(i)};for(var r in t)i()}},this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return Ft(this.Fe,t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;N(e[n])&&(e[n]=E({},r,{data:[]})),null==(i=e[n].data)||i.push(r.data)}),this.Fe=[],e}}var Ys=["retriesPerformedSoFar"];class Xs{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!N(o)&&"onLine"in o.navigator&&(this.ze=o.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},Ut(o,"online",this.He),Ut(o,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=S(e,Ys);B(t)&&(i.url=Xn(i.url,{retry_count:t})),this._instance._send_request(E({},i,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.qe(E({retriesPerformedSoFar:t},i)):null==i.callback||i.callback(e)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i,r,n,s,o,a=(i=t,n=(r=3e3*Math.pow(2,i))/2,s=Math.min(18e5,r),o=(Math.random()-.5)*(s-n),Math.ceil(s+o)),l=Date.now()+a;this.Fe.push({retryAt:l,requestOptions:e});var c="Enqueued failed request for retry in "+a;navigator.onLine||(c+=" (Browser is offline)"),xt.warn(c),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),0===this.Fe.length)return this.Ne=!1,void(this.Ge=void 0);this.Ge=setTimeout(()=>{this.ze&&this.Fe.length>0&&this.Lt(),this.We()},this.Ue)}Lt(){var e=Date.now(),t=[],i=this.Fe.filter(i=>i.retryAt<e||(t.push(i),!1));if(this.Fe=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,N(o)||(this.He&&(o.removeEventListener("online",this.He),this.He=void 0),this.Be&&(o.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(E({},e,{transport:"sendBeacon"}))}catch(pr){xt.error(pr)}this.Fe=[]}}class Ks{constructor(e){this.Ve=()=>{var e,t,i,r;this.Je||(this.Je={});var n=this.scrollElement(),s=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=s+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(s),this.Je.maxScrollY=Math.max(s,null!==(e=this.Je.maxScrollY)&&void 0!==e?e:0),this.Je.maxScrollHeight=Math.max(o,null!==(t=this.Je.maxScrollHeight)&&void 0!==t?t:0),this.Je.lastContentY=a,this.Je.maxContentY=Math.max(a,null!==(i=this.Je.maxContentY)&&void 0!==i?i:0),this.Je.maxContentHeight=Math.max(l,null!==(r=this.Je.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){Ut(o,"scroll",this.Ve,{capture:!0}),Ut(o,"scrollend",this.Ve,{capture:!0}),Ut(o,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==o?void 0:o.document.documentElement;var e=A(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var i=null==o?void 0:o.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return o&&(o.scrollY||o.pageYOffset||o.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return o&&(o.scrollX||o.pageXOffset||o.document.documentElement.scrollLeft)||0}}var Zs=e=>nn(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Qs{constructor(e,t,i,r){this.Ke=e=>{var t=this.Ye();if(!t||t.sessionId!==e){var i={sessionId:e,props:this.Xe(this._instance)};this.Qe.register({[di]:i})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=r||Zs,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[di]}getSetOnceProps(){var e,t=null==(e=this.Ye())?void 0:e.props;return t?"r"in t?sn(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Ft(Lt(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+T(i)]=t}),e}}var eo=Pt("[SessionId]");class to{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var r;if(this.ir=[],this.er=void 0,this.tr=new As,this.rr=(e,t)=>!(!B(e)||!B(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Qe=e.persistence,this.sr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ar=t||gr,this.lr=i||gr;var n=this.R.persistence_name||this.R.token,s=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Q(s,60,36e3,eo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+n+"_window_id",this.dr="ph_"+n+"_primary_window_exists",this.vr()){var o=xr.W(this.hr),a=xr.W(this.dr);o&&!a?this.sr=o:xr.V(this.hr),xr.G(this.dr,!0)}if(null!=(r=this.R.bootstrap)&&r.sessionID)try{var l=(()=>{var e=this.R.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.cr(this.R.bootstrap.sessionID,(new Date).getTime(),l)}catch(c){eo.error("Invalid sessionID in bootstrap",c)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return N(this.ir)&&(this.ir=[]),this.ir.push(e),this.nr&&e(this.nr,this.sr),()=>{this.ir=this.ir.filter(t=>t!==e)}}vr(){return"memory"!==this.R.persistence&&!this.Qe.Pi&&xr.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&xr.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?xr.W(this.hr):null}cr(e,t,i){e===this.nr&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.nr=e,this.Qe.register({[ti]:[t,e,i]}))}mr(){var e=this.Qe.props[ti];return A(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&o&&(o.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&xr.V(this.dr)},Ut(o,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this.R.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,n,s]=this.mr(),o=this._r(),a=B(s)&&Math.abs(i-s)>864e5,l=!1,c=!n,u=!c&&!e&&this.rr(i,r);c||u||a?(n=this.ar(),o=this.lr(),eo.info("new session ID generated",{sessionId:n,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),s=i,l=!0):o||(o=this.lr(),l=!0);var d=B(r)&&e&&!a?r:i,h=B(s)?s:(new Date).getTime();return this.gr(o),this.cr(n,d,h),e||this.ur(),l&&this.ir.forEach(e=>e(n,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0)),{sessionId:n,windowId:o,sessionStartTimestamp:h,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}ur(){clearTimeout(this.br),this.br=setTimeout(()=>{var[e]=this.mr();if(this.rr((new Date).getTime(),e)){var t=this.nr;this.resetSessionId(),this.tr.emit("forcedIdleReset",{idleSessionId:t})}},1.1*this.sessionTimeoutMs)}}var io=["$set_once","$set"],ro=Pt("[SiteApps]");class no{constructor(e){this._instance=e,this.yr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wr(e,t){if(t){var i=this.globalsForEvent(t);this.yr.push(i),this.yr.length>1e3&&(this.yr=this.yr.slice(10))}}get siteAppLoaders(){var e;return null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.wr.bind(this));this.Er=()=>{e(),this.yr=[],this.Er=void 0}}}globalsForEvent(e){var t,i,r,n,s,o,a;if(!e)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[d,h]of Object.entries(u))l[d]={id:c[d],type:d,properties:h};var{$set_once:p,$set:g}=e;return{event:E({},S(e,io),{properties:E({},e.properties,g?{$set:E({},null!==(t=null==(i=e.properties)?void 0:i.$set)&&void 0!==t?t:{},g)}:{},p?{$set_once:E({},null!==(r=null==(n=e.properties)?void 0:n.$set_once)&&void 0!==r?r:{},p)}:{}),elements_chain:null!==(s=null==(o=e.properties)?void 0:o.$elements_chain)&&void 0!==s?s:"",distinct_id:null==(a=e.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this.yr.length&&(ro.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.forEach(e=>null==t.processEvent?void 0:t.processEvent(e)),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(i=this.Er)||i.call(this))},r=!1,n=n=>{t.errored=!n,t.loaded=!0,ro.info("Site app with id "+e.id+" "+(n?"loaded":"errored")),r&&i()};try{var{processEvent:s}=e.init({posthog:this._instance,callback:e=>{n(e)}});s&&(t.processEvent=s),r=!0}catch(o){ro.error("Error while initializing PostHog app with config id "+e.id,o),n(!1)}if(r&&t.loaded)try{i()}catch(a){ro.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}$r(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}Sr(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(r){ro.error("Error while processing event "+e.event+" for site app "+i.id,r)}}}onRemoteConfig(e){var t,i,r,n=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",e=>this.Sr(e))):void ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Er)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var s=function(e){var t;m["__$$ph_site_app_"+e]=n._instance,null==(t=m.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,a,t=>{if(t)return ro.error("Error while initializing PostHog app with config id "+e,t)})};for(var{id:o,url:a}of e.siteApps)s(o)}else ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var so=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&x(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some(e=>x(null==e?void 0:e.brand,t)))return!0}catch(n){}return!!e.webdriver},oo=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ao="i.posthog.com";class lo{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this.kr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=oo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=oo.EU:this.kr[this.apiHost]=oo.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if(this.region===oo.CUSTOM)return this.apiHost+t;var i=ao+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var co={icontains:(e,t)=>!!o&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!o&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!o&&es(t.href,e),not_regex:(e,t)=>!!o&&!es(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class uo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments(e=>{uo.Pr("retrieved web experiments from the server"),t.Tr=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;t.Tr&&(uo.Pr("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t.Tr)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);j(r)&&e.variants[r]&&t.Ir(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var n in e.variants){var s=e.variants[n];uo.Cr(s)&&t.Ir(e.name,n,s.transforms)}})},e)},this._instance=e,this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}onFeatureFlags(e){if(this._is_bot())uo.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(H(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();uo.Pr("applying feature flags",e),e.forEach(e=>{var t;if(this.Tr&&null!=(t=this.Tr)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),n=null==(i=this.Tr)?void 0:i.get(e);r&&null!=n&&n.variants[r]&&this.Ir(n.name,r,n.variants[r].transforms)}})}}previewWebExperiment(){var e=uo.getWindowLocation();if(null!=e&&e.search){var t=Qi(null==e?void 0:e.search,"__experiment_id"),i=Qi(null==e?void 0:e.search,"__experiment_variant");t&&i&&(uo.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments(e=>{this.Rr(parseInt(t),i,e)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}Rr(e,t,i){var r=i.filter(t=>t.id===e);r&&r.length>0&&(uo.Pr("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ir(r[0].name,t,r[0].variants[t].transforms))}static Cr(e){return!H(e.conditions)&&uo.Fr(e)&&uo.Or(e)}static Fr(e){var t;if(H(e.conditions)||H(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,n,s=uo.getWindowLocation();return!!s&&(null==(i=e.conditions)||!i.url||co[null!==(r=null==(n=e.conditions)?void 0:n.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,s))}static getWindowLocation(){return null==o?void 0:o.location}static Or(e){var t;if(H(e.conditions)||H(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Zr();if(i.utm_source){var r,n,s,o,a,l,c,u,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(n=e.conditions)||null==(n=n.utm)?void 0:n.utm_campaign)==i.utm_campaign,h=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,p=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,g=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&p&&g&&h}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];xt.info("[WebExperiments] "+e,i)}Ir(e,t,i){this._is_bot()?uo.Pr("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach(i=>{if(i.selector){var r;uo.Pr("applying transform of variant "+t+" for experiment "+e+" ",i);var n=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==n||n.forEach(e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)})}}):uo.Pr("Control variants leave the page unmodified.")}_is_bot(){return d&&this._instance?so(d,this._instance.config.custom_blocked_useragents):void 0}}var ho=Pt("[PostHog ExternalIntegrations]"),po={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class go{constructor(e){this._instance=e}it(e,t){var i;null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return ho.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(t){var i,n,s;!r||null!=(i=m.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e.it(po[t],()=>{var i;null==(i=m.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)}),!r&&null!=(n=m.__PosthogExtensions__)&&null!=(n=n.integrations)&&n[t]&&(null==(s=m.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[t])||s.stop())};for(var[i,r]of Object.entries(null!==(n=this._instance.config.integrations)&&void 0!==n?n:{})){var n;t(i)}}}var fo="[SessionRecording]",_o=Pt(fo);class vo{get started(){var e;return!(null==(e=this.Mr)||!e.isStarted)}get status(){return this.Mr?this.Mr.status:this.Ar&&!this.jr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ar=!1,this.Dr=void 0,this._instance=e,!this._instance.sessionManager)throw _o.error("started without valid sessionManager"),new Error(fo+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(fo+' cannot be used with cookieless_mode="always"')}get jr(){var e,t=!(null==(e=this._instance.get_property(ei))||!e.enabled),i=!this._instance.config.disable_session_recording,r=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return o&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this.jr||null==(t=this.Mr)||!t.isStarted){var i=!N(Object.assign)&&!N(Array.from);this.jr&&i?(this.Lr(e),_o.info("starting")):this.stopRecording()}}Lr(e){var t,i,r;this.jr&&(null!=m&&null!=(t=m.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=m.__PosthogExtensions__)&&i.initSessionRecording?this.Nr(e):null==(r=m.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Ur,t=>{if(t)return _o.error("could not load recorder",t);this.Nr(e)}))}stopRecording(){var e,t;null==(e=this.Dr)||e.call(this),this.Dr=void 0,null==(t=this.Mr)||t.stop()}zr(){var e;null==(e=this._instance.persistence)||e.unregister(ii)}Hr(e){if(this._instance.persistence){var t,i,r=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,i=null==t?void 0:t.sampleRate,n=H(i)?null:parseFloat(i);H(n)&&this.zr();var s=null==t?void 0:t.minimumDurationMilliseconds;r.register({[ei]:E({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:E({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:N(s)?null:s,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this.Dr)||t.call(this),this.Dr=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:_o.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this.Mr)&&i.log?this.Mr.log(e,t):_o.warn("log called before recorder was ready")}get Ur(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(ei);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if(null==(t=m.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=null==(i=m.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;null==(t=this.Mr)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_linked_flag:!0}),null==(e=this.Mr)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_sampling:!0}),null==(e=this.Mr)||e.overrideSampling()}overrideTrigger(e){var t,i;this.Mr||null==(i=this._instance.persistence)||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(t=this.Mr)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this.Mr)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this.Mr)||!i.tryAddCustomEvent(e,t))}}var mo={},yo=()=>{},wo="posthog",bo=!Jn&&-1===(null==v?void 0:v.indexOf("MSIE"))&&-1===(null==v?void 0:v.indexOf("Mozilla")),Eo=e=>{var t;return E({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:jt(null==h?void 0:h.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:yo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,debug:p&&j(null==p?void 0:p.search)&&-1!==p.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==o||null==(t=o.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;xt.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Gs},error_tracking:{},_onCapture:yo,__preview_eager_load_replay:!1},(e=>({rageclick:!(e&&e>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(e&&e>="2025-05-24")||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},So=e=>{var t={};N(e.process_person)||(t.person_profiles=e.process_person),N(e.xhr_headers)||(t.request_headers=e.xhr_headers),N(e.cookie_name)||(t.persistence_name=e.cookie_name),N(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),N(e.store_google)||(t.save_campaign_params=e.store_google),N(e.verbose)||(t.debug=e.verbose);var i=Ot({},t,e);return A(e.property_blacklist)&&(N(e.property_denylist)?i.property_denylist=e.property_blacklist:A(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:xt.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class ko{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){xt.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class xo{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new ko,this.qr=!1,this.version=y.LIB_VERSION,this.bi=new As,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Eo(),this.SentryIntegration=jr,this.sentryIntegration=e=>{return t=Nr(this,e),{name:Lr,processEvent:e=>t(e)};var t},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new vs(this),this.toolbar=new Br(this),this.scrollManager=new Ks(this),this.pageViewManager=new gn(this),this.surveys=new js(this),this.conversations=new Us(this),this.logs=new Hs(this),this.experiments=new uo(this),this.exceptions=new os(this),this.rateLimiter=new Bs(this),this.requestRouter=new lo(this),this.consent=new $r(this),this.externalIntegrations=new go(this),this.people={set:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",e=>xt.info('send "'+(null==e?void 0:e.event)+'"',e))}init(e,t,i){if(i&&i!==wo){var r,n=null!==(r=mo[i])&&void 0!==r?r:new xo;return n._init(e,t,i),mo[i]=n,mo[wo][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r;if(void 0===t&&(t={}),N(e)||q(e))return xt.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Ot({},Eo(t.defaults),So(t),{name:i,token:e})),this.config.on_xhr_error&&xt.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:fn.GZipJS;var n=this.Qr();this.persistence=new ys(this.config,n),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new ys(E({},this.config,{persistence:"sessionStorage"}),n);var s=E({},this.persistence.props),a=E({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Zr=new Js(e=>this.ts(e),this.config.request_queue_config),this.es=new Xs(this),this.__request_queue=[];var l="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new to(this),this.sessionPropsManager=new Qs(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(xt.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(xt.info("Initializing extensions synchronously"),this.rs(l)),y.DEBUG=y.DEBUG||this.config.debug,y.DEBUG&&xt.info("Starting in debug mode",{this:this,config:t,thisC:E({},this.config),p:s,s:a}),void 0!==(null==(r=t.bootstrap)?void 0:r.distinctID)){var c,u,d=this.config.get_device_id(gr()),h=null!=(c=t.bootstrap)&&c.isIdentifiedID?d:t.bootstrap.distinctID;this.persistence.set_property(ui,null!=(u=t.bootstrap)&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this.ss()){var p,g,f=Object.keys((null==(p=t.bootstrap)?void 0:p.featureFlags)||{}).filter(e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])}).reduce((e,i)=>{var r;return e[i]=(null==(r=t.bootstrap)||null==(r=r.featureFlags)?void 0:r[i])||!1,e},{}),_=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlagPayloads)||{}).filter(e=>f[e]).reduce((e,i)=>{var r,n;return null!=(r=t.bootstrap)&&null!=(r=r.featureFlagPayloads)&&r[i]&&(e[i]=null==(n=t.bootstrap)||null==(n=n.featureFlagPayloads)?void 0:n[i]),e},{});this.featureFlags.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:_})}if(l)this.register_once({distinct_id:mi,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(gr());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(ui,"anonymous")}return Ut(o,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||gr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(ui,"identified")),t()},n=i.user();"then"in n&&M(n.then)?n.then(r):r(n)}(e,()=>{i.register((e=>{Promise&&Promise.resolve||Dr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Dr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Dr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then(()=>{t()})})}(this,()=>this.ns()):this.ns(),M(this.config._onCapture)&&this.config._onCapture!==yo&&(xt.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&xt.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new Mr(this),this.historyAutocapture.startIfEnabled();var i=[];i.push(()=>{new Vr(this).startIfEnabledOrStop()}),i.push(()=>{var e;this.siteApps=new no(this),null==(e=this.siteApps)||e.init()}),e||i.push(()=>{this.sessionRecording=new vo(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.push(()=>{this.autocapture=new or(this),this.autocapture.startIfEnabled()}),i.push(()=>{this.surveys.loadIfEnabled()}),i.push(()=>{this.logs.loadIfEnabled()}),i.push(()=>{this.conversations.loadIfEnabled()}),i.push(()=>{this.productTours=new Es(this),this.productTours.loadIfEnabled()}),i.push(()=>{this.heatmaps=new pn(this),this.heatmaps.startIfEnabled()}),i.push(()=>{this.webVitalsAutocapture=new un(this)}),i.push(()=>{this.exceptionObserver=new Rr(this),this.exceptionObserver.startIfEnabledOrStop()}),i.push(()=>{this.deadClicksAutocapture=new Fr(this,Cr),this.deadClicksAutocapture.startIfEnabled()}),i.push(()=>{if(this.os){var e=this.os;this.os=void 0,this.wi(e)}}),this.ls(i,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.ls(e,t)},0);var i=e.shift();if(i)try{i()}catch(n){xt.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&xt.info("PostHog extensions initialized ("+r+"ms)")}wi(e){var t,i,r,n,s,o,a,l,c;if(!h||!h.body)return xt.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.wi(e)},500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=$(e.supportedCompression,fn.GZipJS)?fn.GZipJS:$(e.supportedCompression,fn.Base64)?fn.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(r=this.sessionRecording)||r.onRemoteConfig(e),null==(n=this.autocapture)||n.onRemoteConfig(e),null==(s=this.heatmaps)||s.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),null==(o=this.productTours)||o.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(l=this.exceptionObserver)||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(c=this.deadClicksAutocapture)||c.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(i){xt.critical("`loaded` function failed",i)}if(this.us(),this.config.internal_or_test_user_hostname&&null!=p&&p.hostname){var e=p.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this.hs()},1),new Vs(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this.Zr)||e.enable())}_dom_loaded(){this.is_capturing()&&Ct(this.__request_queue,e=>this.ts(e)),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),null==(e=this.Zr)||e.unload(),null==(t=this.es)||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(bo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Xn(e.url,{ip:this.config.ip?1:0}),e.headers=E({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,r,n=E({},e);n.timeout=n.timeout||6e4,n.url=Xn(n.url,{_:(new Date).getTime().toString(),ver:y.LIB_VERSION,compression:n.compression});var s=null!==(t=n.transport)&&void 0!==t?t:"fetch",o=Qn.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),a=null!==(i=null==(r=qt(o,e=>e.transport===s))?void 0:r.method)&&void 0!==i?i:o[0].method;if(!a)throw new Error("No available transport method");a(n)})(E({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&(null==(i=(r=this.config).on_request_error)||i.call(r,t)),null==e.callback||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],r=[],n=[];Ct(e,e=>{e&&(t=e[0],A(t)?n.push(e):M(e)?e.call(this):A(e)&&"alias"===t?i.push(e):A(e)&&-1!==t.indexOf("capture")&&M(this[t])?n.push(e):r.push(e))});var s=function(e,t){Ct(e,function(e){if(A(e[0])){var i=t;Ft(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};s(i,this),s(r,this),s(n,this)}ss(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!N(e)&&j(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!n||this.config.__preview_capture_bot_pageviews){var s=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==s||!s.isRateLimited){null!=t&&t.$current_url&&!j(null==t?void 0:t.$current_url)&&(xt.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(null==i?void 0:i.timestamp)||o,l=gr(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},a,l)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&n&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),s&&(c.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),(null==i?void 0:i.$set)&&(c.$set=null==i?void 0:i.$set);var u,d="$groupidentify"!==e,h=this.vs(null==i?void 0:i.$set_once,d);if(h&&(c.$set_once=h),(c=function(e,t){return i=e,r=e=>j(e)&&!U(t)?e.slice(0,t):e,n=new Set,function e(t,i){return t!==Object(t)?r?r(t):t:n.has(t)?void 0:(n.add(t),A(t)?(s=[],Ct(t,t=>{s.push(e(t))})):(s={},Ft(t,(t,i)=>{n.has(t)||(s[i]=e(t))})),s);var s}(i);var i,r,n}(c,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,N(null==i?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o),e===xs.DISMISSED||e===xs.SENT){var p=null==t?void 0:t[Ps.SURVEY_ID],g=null==t?void 0:t[Ps.SURVEY_ITERATION];u={id:p,current_iteration:g},localStorage.getItem(Fs(u))||localStorage.setItem(Fs(u),"true"),c.$set=E({},c.$set,{[Cs({id:p,current_iteration:g},e===xs.SENT?"responded":"dismissed")]:!0})}else e===xs.SHOWN&&(c.$set=E({},c.$set,{[Ps.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var f=E({},c.properties.$set,c.$set);if(L(f)||this.setPersonPropertiesForFlags(f),!H(this.config.before_send)){var _=this.cs(c);if(!_)return;c=_}this.bi.emit("eventCaptured",c);var v={method:"POST",url:null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.ts(v):this.Zr.enqueue(v),c}xt.critical("This capture call is ignored due to client rate limiting.")}}else xt.error("No event name provided to posthog.capture")}else xt.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var s=n?void 0:this.persistence.remove_event_timer(e),a=E({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=E({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!j(a.distinct_id)&&!W(a.distinct_id)||q(a.distinct_id))&&xt.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=function(e,t){if(!v)return{};var i,r,n,s=e?Rt([],Jr,t||[]):[],[a,l]=function(e){for(var t=0;t<Ke.length;t++){var[i,r]=Ke[t],n=i.exec(e),s=n&&(M(r)?r(n,e):r);if(s)return s}return["",""]}(v);return Ot(Lt({$os:a,$os_version:l,$browser:Je(v,navigator.vendor),$device:Ze(v),$device_type:(r=v,n=Ze(r),n===ce||n===le||"Kobo"===n||"Kindle Fire"===n||n===je?ae:n===Ie||n===Ce||n===Te||n===De?"Console":n===de?"Wearable":n?ne:"Desktop"),$timezone:on(),$timezone_offset:an()}),{$current_url:er(null==p?void 0:p.href,s,Xr),$host:null==p?void 0:p.host,$pathname:null==p?void 0:p.pathname,$raw_user_agent:v.length>1e3?v.substring(0,997)+"...":v,$browser_version:Xe(v,navigator.vendor),$browser_language:tn(),$browser_language_prefix:(i=tn(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==o?void 0:o.screen.height,$screen_width:null==o?void 0:o.screen.width,$viewport_height:null==o?void 0:o.innerHeight,$viewport_width:null==o?void 0:o.innerWidth,$lib:"web",$lib_version:y.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());a.$session_id=d,a.$window_id=g}this.sessionPropsManager&&Ot(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&Ot(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(f=this.es)?void 0:f.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===oo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=Ot(a,c),"$pageview"===e&&h&&(a.title=h.title),!N(s)){var _=i.getTime()-s;a.$duration=parseFloat((_/1e3).toFixed(3))}v&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ot({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),A(this.config.property_denylist)?Ft(this.config.property_denylist,function(e){delete a[e]}):xt.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(xt.error("sanitize_properties is deprecated. Use before_send instead"),a=m(a,e));var w=this.fs();return a.$process_person_profile=w,w&&!n&&this.ps("_calculate_event_properties"),a}vs(e,t){var i;if(void 0===t&&(t=!0),!this.persistence||!this.fs())return e;if(this.qr)return e;var r=this.persistence.get_initial_props(),n=null==(i=this.sessionPropsManager)?void 0:i.getSetOnceProps(),s=Ot({},r,n||{},e||{}),o=this.config.sanitize_properties;return o&&(xt.error("sanitize_properties is deprecated. Use before_send instead"),s=o(s,"$set_once")),t&&(this.qr=!0),L(s)?void 0:s}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var r=null!=i&&i.merge?this.featureFlags.getFlagVariants():{},n=null!=i&&i.merge?this.featureFlags.getFlagPayloads():{},s=E({},r,e),o=E({},n,t),a={};for(var[l,c]of Object.entries(s)){var u="string"==typeof c;a[l]={key:l,enabled:!!u||Boolean(c),variant:u?c:void 0,reason:void 0,metadata:N(null==o?void 0:o[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.featureFlags.receivedFeatureFlags({flags:a})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.bi.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=Rs),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return xt.uninitializedWarning("posthog.identify");if(W(e)&&(e=e.toString(),xt.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))xt.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==mi){if(this.ps("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(Wt)&&(this.unregister(Wt),this.register({distinct_id:e}));var s="anonymous"===(this.persistence.get_property(ui)||"anonymous");e!==r&&s?(this.persistence.set_property(ui,"identified"),this.setPersonPropertiesForFlags(E({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Jr=ts(e,t,i),this.featureFlags.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(ci))}}else xt.critical('The string "'+mi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else xt.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var i=ts(this.get_distinct_id(),e,t);this.Jr!==i?(this.setPersonPropertiesForFlags(E({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=i):xt.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:E({},r,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),r[e]===t||i||this.reloadFeatureFlags()}else xt.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,n;if(xt.info("reset"),!this.__loaded)return xt.uninitializedWarning("posthog.reset");var s=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(r=this.persistence)||r.set_property(ui,"anonymous"),null==(n=this.sessionManager)||n.resetSessionId(),this.Jr=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:mi,$device_id:null},"");else{var o=this.config.get_device_id(gr());this.register_once({distinct_id:o,$device_id:e?o:s},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var n,s=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-s,0)}return r}alias(e,t){return e===this.get_property(Ht)?(xt.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(N(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Wt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(xt.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=E({},this.config);if(D(e)){var i,r,n,s,o,a,l;Ot(this.config,So(e));var c=this.Qr();null==(i=this.persistence)||i.update_config(this.config,t,c),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new ys(E({},this.config,{persistence:"sessionStorage"}),c);var u=this.Kr(this.config.debug);z(u)&&(this.config.debug=u),z(this.config.debug)&&(this.config.debug?(y.DEBUG=!0,wr.H()&&wr.G("ph_debug","true"),xt.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(y.DEBUG=!1,wr.H()&&wr.V("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(n=this.sessionRecording)||n.startIfEnabledOrStop(),null==(s=this.autocapture)||s.startIfEnabled(),null==(o=this.heatmaps)||o.startIfEnabled(),null==(a=this.exceptionObserver)||a.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),null==(l=this.externalIntegrations)||l.startIfEnabledOrStop()}}startSessionRecording(e){var t,i,r,n,s,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("url")),a.event_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(E({},r,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:wo;return t!==wo&&(t=wo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ui))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ui))}fs(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&L(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Wt])&&(null==(t=this.persistence)||null==(t=t.props)||!t[_i]))}ds(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return"never"===this.config.person_profiles?(xt.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(_i,!0),!0)}Qr(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_s(){var e,t,i,r,n=this.Qr();return(null==(e=this.persistence)?void 0:e.Pi)!==n&&(null==(i=this.persistence)||i.set_disabled(n)),(null==(t=this.sessionPersistence)?void 0:t.Pi)!==n&&(null==(r=this.sessionPersistence)||r.set_disabled(n)),n}opt_in_capturing(e){var t,i,r,n;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new to(this),this.pageViewManager=new gn(this),this.persistence&&(this.sessionPropsManager=new Qs(this,this.sessionManager,this.persistence)),this.sessionRecording=new vo(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),(N(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(n=null==e?void 0:e.captureEventName)&&void 0!==n?n:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()):xt.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:mi,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(i=this.sessionRecording)||i.stopRecording(),this.sessionRecording=void 0,this.hs())):xt.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===Pr.GRANTED?"granted":e===Pr.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return d?so(d,this.config.custom_blocked_useragents):void 0}hs(){h&&("visible"===h.visibilityState?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:h.title},{send_instantly:!0}),this.Gr&&(h.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Ut(h,"visibilitychange",this.Gr)))}debug(e){!1===e?(null==o||o.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==o||o.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,i,r,n,s,o=this.Yr||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(xt.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",r=xt,n=(t="advanced_disable_flags")in(e=o)&&!H(e[t]),s=i in e&&!H(e[i]),n?e[t]:!!s&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}cs(e){if(H(this.config.before_send))return e;var t=A(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),H(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return V(e.event)?xt.warn(n+". This can cause unexpected behavior."):xt.info(n),null}i.properties&&!L(i.properties)||xt.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager.Kt)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Kr(e){var t=z(e)&&!e,i=wr.H()&&"true"===wr.q("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Dt(e.prototype[t[i]])}(xo,["identify"]);var Po,$o=(Po=mo[wo]=new xo,function(){function e(){e.done||(e.done=!0,bo=!1,Ft(mo,function(e){e._dom_loaded()}))}null!=h&&h.addEventListener?"complete"===h.readyState?e():Ut(h,"DOMContentLoaded",e,{capture:!1}):o&&xt.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Po);let Io=null,To=!1;const Co="dori_shopify_end_user_id",Fo="dori_shopify_end_user_session",Oo=()=>"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`;let Ro=null;const Ao=()=>{if(Ro)return Ro;let e;try{const t=window?.DORI_CUSTOMER_ID;if(t){let i=window.localStorage.getItem(Fo);i&&i.trim()||(i=Oo(),window.localStorage.setItem(Fo,i)),e=`shopify_customer_${String(t)}_${i}`}else{const t=window.localStorage.getItem(Co);t&&t.trim()?e=t:(e=`anon_${Oo()}`,window.localStorage.setItem(Co,e))}}catch{e=`anon_${Oo()}`}return Ro=e,e};let Mo=null;const Do=e=>(()=>{if(null===Mo){const e=Lo()??"";Mo=(e=>{let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0)/4294967296})(`${e}:${Ao()}`)}return Mo})()<e,Lo=()=>{try{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null}catch{return null}};let No=null;const jo=()=>{const e={},t=Lo();return t&&(e.sharing_id=t),"undefined"!=typeof window&&window.location&&window.location.hostname&&(e.shop_domain=window.location.hostname),e},qo=e=>{if(!e)return;const t=Uo();if(t)try{t.register({thread_id:e})}catch(i){}},Uo=()=>(Io||To||(Io=(()=>{if($o.__loaded)return $o;if(To)return null;To=!0;try{return $o.init("phc_H5oKb44Ke85TJHMvMDD6MzxtjjVeGZZinXVTyC8t0bY",{api_host:"https://us.i.posthog.com",person_profiles:"identified_only",autocapture:!1,capture_pageview:!1,capture_pageleave:!1,capture_performance:!1,capture_dead_clicks:!1,rageclick:!1,disable_session_recording:!0,bootstrap:{distinctID:Ao()},before_send:e=>{if(!e)return e;if("$exception"===e.event)return Do(.1)&&(e=>{const t=e?.properties??{};if("manual"===t.dori_capture)return!0;const i=(()=>{if(No)return No;const e=[];try{const t=document.querySelector("script#dori-side-widget"),i=t?.src;if(i){e.push(i);const t=i.slice(0,i.lastIndexOf("/")+1);t&&t!==i&&e.push(t)}}catch{}return No=e,e})();if(0===i.length)return!0;const r=t.$exception_list;if(!Array.isArray(r)||0===r.length)return!0;for(const n of r){const e=n?.stacktrace?.frames;if(Array.isArray(e))for(const t of e){const e=t?.filename;if("string"==typeof e&&i.some(t=>e.startsWith(t)))return!0}}return!1})(e)?e:null;const t=(e=>e.startsWith("pf.")||e.startsWith("pdp_hero"))(e.event)?1:.1;return Do(t)?e:null},loaded:e=>{try{e.register({...jo(),surface:"side",flow_version:"1.13.185"})}catch(t){}try{e.unregister("occasion"),e.unregister("occasion_arm")}catch(t){}}}),Io=$o,$o}catch(e){return console.error("[PostHog] Failed to initialize:",e),null}finally{To=!1}})()),Io),Ho=(e,t)=>{const i=Uo();if(i)try{i.capture(e,t)}catch(r){}},Wo=(e,t)=>{const i=Uo();if(i)try{console.error("Error captured:",e,t),i.capture("$exception",{$exception_message:e.message,$exception_type:e.name,$exception_stack_trace:e.stack,dori_capture:"manual",...t})}catch(r){console.error("[PostHog] Failed to capture exception:",r)}},Bo=(e,t)=>(...i)=>{try{return console.log("withErrorHandling",e),t(...i)}catch(r){throw console.error("Error in withErrorHandling:",r),Wo(r,{context:e}),r}},zo=(e,t)=>(...i)=>{try{return t(...i).catch(t=>{throw"AbortError"!==t.name&&Wo(t,{context:e}),t})}catch(r){throw"AbortError"!==r.name&&Wo(r,{context:e}),r}},Vo="dori_widget_bot_data",Go="dori_widget_bot_data_etag",Jo="dori_widget_bot_data_sharing_id",Yo="dori_widget_session_sharing_id",Xo="dori_widget_chat_state",Ko="dori_widget_messages",Zo="dori_widget_current_step",Qo="dori_widget_session_timestamp",ea="dori_widget_fab_animation_timestamp",ta="dori_thread_id",ia="dori_session_key",ra="dori_loaded_from_storage",na="dori_shopify_end_user_id",sa="dori_shopify_end_user_session";function oa(){if("undefined"==typeof window)return"";const e=window;if(e.chatbotData?.sharingID)return String(e.chatbotData.sharingID);const t=document.querySelector("script#dori-side-widget");return t?.getAttribute("data-sharing-id")||""}function aa(){try{const e="__test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}function la(){aa()&&localStorage.setItem(ra,"true")}function ca(){aa()&&localStorage.removeItem(ra)}function ua(){try{const e=localStorage.getItem(Qo);if(!e)return!1;const t=parseInt(e,10);return Date.now()-t<864e5}catch{return!1}}function da(){if(aa())try{[Xo,Ko,Zo,ta,ia,ra,na,sa].forEach(e=>{localStorage.removeItem(e)})}catch(e){console.error("Error clearing local storage:",e)}}function ha(){const e=oa();return!e||localStorage.getItem(Jo)===e}function pa(e){if(aa())try{if(e){localStorage.setItem(Vo,JSON.stringify(e));const t=oa();t&&localStorage.setItem(Jo,t)}else localStorage.removeItem(Vo),localStorage.removeItem(Jo)}catch(t){console.error("Error saving bot data:",t)}}function ga(){if(!aa()||!ua())return null;if(!ha())return null;try{const e=localStorage.getItem(Vo);return e?JSON.parse(e):null}catch(e){return console.error("Error loading bot data:",e),null}}function fa(){if(aa())try{localStorage.removeItem(Vo),localStorage.removeItem(Go),localStorage.removeItem(Jo)}catch(e){console.error("Error clearing bot data cache:",e)}}function _a(e){if(aa())try{localStorage.setItem(Xo,JSON.stringify(e))}catch(t){console.error("Error saving chat state:",t)}}function va(e){if(aa())try{const t=e.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():e.timestamp}));localStorage.setItem(Ko,JSON.stringify(t))}catch(t){console.error("Error saving messages:",t)}}function ma(){if(!aa()||!ua())return[];try{const e=localStorage.getItem(Ko);return e?JSON.parse(e).map(e=>({...e,content:"string"==typeof e.content?r(e.content):e.content,timestamp:new Date(e.timestamp)})):[]}catch(e){return console.error("Error loading messages:",e),[]}}function ya(e){if(aa())try{localStorage.setItem(Zo,e)}catch(t){console.error("Error saving current step:",t)}}function wa(){if(!aa()||!ua())return null;try{const e=ga(),t=function(){if(!aa()||!ua())return null;try{const e=localStorage.getItem(Xo);return e?JSON.parse(e):null}catch(e){return console.error("Error loading chat state:",e),null}}(),i=ma(),r=function(){if(!aa()||!ua())return"welcome";try{return localStorage.getItem(Zo)||"welcome"}catch(e){return console.error("Error loading current step:",e),"welcome"}}();return e||i.length>0?{botData:e,chatState:t||{repliedProduct:null,focusedProduct:null,threadId:null,isRequestInProgress:!1},messages:i,currentStep:r,sessionTimestamp:Date.now()}:null}catch(e){return console.error("Error loading session data:",e),null}}function ba(){if(!aa()||!ua())return!1;try{const e=ga(),t=ma();return!!(e||t.length>0)}catch{return!1}}function Ea(){if(aa())try{localStorage.setItem(Qo,Date.now().toString())}catch(e){console.error("Error updating session timestamp:",e)}}function Sa(){if(aa())try{localStorage.setItem(ea,Date.now().toString())}catch(e){console.error("Error saving FAB animation timestamp:",e)}}function ka(){const e=function(){if(!aa()||!ua())return null;try{const e=localStorage.getItem(ea);return e?parseInt(e,10):null}catch(e){return console.error("Error loading FAB animation timestamp:",e),null}}();return!e||Date.now()-e>=3e5}function xa(){if(!aa())return"";try{let e=localStorage.getItem(ia);return e||(e="dori_session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),localStorage.setItem(ia,e)),e}catch(e){return console.error("Error generating session key:",e),""}}function Pa(e){if(aa()&&e){try{localStorage.setItem(ta,e)}catch(t){console.error("Error storing dori thread ID:",t)}qo(e)}}function $a(){if(!aa())return null;try{const e=localStorage.getItem(ta);return qo(e),e}catch(e){return console.error("Error retrieving dori thread ID:",e),null}}function Ia(e){const t=window?.chatbotData;if("undefined"!=typeof window&&t?.ajaxurl){const i=xa();fetch(t.ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"dori_store_thread_session",thread_id:e,session_key:i,nonce:t.nonce})}).catch(e=>console.warn("Failed to store thread in WooCommerce session:",e))}}const Ta="https://standardapi.dori.tech",Ca=["pointerdown","keydown"],Fa=["pointermove","touchstart","wheel","scroll"],Oa=["pointerover","focusin","click"];function Ra(e){const t=(e instanceof Error?e.message:String(e??"")).match(/https?:\/\/[^\s"')]+/);if(!t)return null;const i=t[0].replace(/[.,;:]+$/,"");return/\.m?js(\?|$)/.test(i)?i:null}function Aa(e){return e+(e.includes("?")?"&":"?")+"dori-retry=1"}async function Ma(e,t,i,r=500,n=e=>import(e)){try{return await e()}catch(s){const e=Ra(s);if(!e)return i?.(s,s),{default:t};await new Promise(e=>setTimeout(e,r));try{return await n(Aa(e))}catch(o){return i?.(s,o),{default:t}}}}function Da(e,t){return e&&("header_button"===t||"header_block"===t)}function La(e){if("undefined"==typeof window)return;const t=window;t.__doriOpenReady=!0;const i=t.__doriOpenQueue||[];t.__doriOpenQueue=[],i.length&&e(i[i.length-1])}let Na=null;const ja=e=>{Na=e},qa=()=>{if("undefined"==typeof window)return"";const e=window.location.href;if(!Na)return e;try{const t=new URL(e);return t.hash=`dori_entry=${encodeURIComponent(Na)}`,t.toString()}catch{return e}};function Ua(){try{return globalThis.window?.Shopify??null}catch{return null}}function Ha(){try{const e=Ua()?.customerPrivacy;return e&&"function"==typeof e.preferencesProcessingAllowed?e:null}catch{return null}}function Wa(){try{const e=Ha();return e?!!e.preferencesProcessingAllowed():null}catch{return null}}function Ba(){return Wa()}const za="dori:consent-settled";let Va=!1;function Ga(){return!!Va||((Ha()||"function"!=typeof Ua()?.loadFeatures)&&(Va=!0),Va)}let Ja=!1;function Ya(){if(Va=!0,!Ja){Ja=!0;try{const e=globalThis.window;e?.dispatchEvent?.(new CustomEvent(za))}catch{}}}let Xa=null;function Ka(){if(Ga())return Ya(),Promise.resolve(Wa());if(Xa)return Xa;const e=Ua()?.loadFeatures;return Xa=new Promise(t=>{let i=!1;const r=()=>{i||(i=!0,clearTimeout(n),Ya(),t(Wa()))},n=setTimeout(r,4e3);try{e.call(Ua(),[{name:"consent-tracking-api",version:"0.1"}],r)}catch{r()}}).finally(()=>{Xa=null}),Xa}function Za(e){const t=globalThis.document;if(!t?.addEventListener)return()=>{};const i=()=>e(Wa());return t.addEventListener("visitorConsentCollected",i),()=>t.removeEventListener("visitorConsentCollected",i)}const Qa=2592e6,el={product_prompts:[]},tl="dori_shopper_note:v3:",il="dori_shopper_note:",rl=["dori_shopper_note:v1:","dori_shopper_note:v2:"],nl="__doriShopperNoteFallback";function sl(){try{const e=globalThis.window;return e?(e[nl]||(e[nl]={}),e[nl]):null}catch{return null}}const ol="dori:shopper-note";function al(){try{const e=globalThis.window;e?.dispatchEvent?.(new CustomEvent(ol))}catch{}}function ll(e){const t=globalThis.window;if(!t?.addEventListener)return()=>{};const i=t=>{t.key&&!t.key.startsWith(tl)||e()};return t.addEventListener(ol,e),t.addEventListener(za,e),t.addEventListener("storage",i),()=>{t.removeEventListener(ol,e),t.removeEventListener(za,e),t.removeEventListener("storage",i)}}function cl(){try{return globalThis.window?.localStorage??null}catch{return null}}function ul(e){return e.testMode||!e.sharingId?null:Ga()&&!1!==Ba()?`${tl}${e.sharingId}`:null}const dl="__doriShopperNoteRevFloor";function hl(){try{const e=globalThis.window;return e?(e[dl]||(e[dl]={}),e[dl]):null}catch{return null}}function pl(e,t){const i=hl();return Math.max(t?.rev??0,i?.[e]??0,i?.["*"]??0)}function gl(e,t){const i=hl();i&&(i[e]=Math.max(i[e]??0,t+1))}function fl(e){const t=hl();if(!t)return e;const i=Object.values(sl()??{}).map(e=>"number"==typeof e?.rev?e.rev:0);return t["*"]=Math.max(0,e,...Object.values(t),...i)+1,t["*"]}const _l="__doriShopperNotePage";let vl;function ml(){try{const e=globalThis.window;return e?(e[_l]||(e[_l]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`),e[_l]):""}catch{return""}}function yl(){if(void 0!==vl)return vl;try{vl="function"==typeof BroadcastChannel?new BroadcastChannel("dori-shopper-note"):null,vl&&(vl.onmessage=e=>{if(!0!==e.data?.fence||e.data.page===ml())return;fl("number"==typeof e.data.rev?e.data.rev:0);const t=sl();if(t)for(const i of e.data.keys??Object.keys(t))delete t[i];al()})}catch{vl=null}return vl}function wl(e){let t=0;try{const i=cl();for(const r of e??(i?Rl(i,[il]):[]))t=Math.max(t,El(r))}catch{}bl(fl(t),e)}function bl(e,t){try{const i={fence:!0,page:ml(),rev:e,...t?{keys:t}:{}};yl()?.postMessage(i)}catch{}}function El(e){let t=sl()?.[e]?.rev??0;try{const i=cl()?.getItem(e),r=i?JSON.parse(i):null;r&&"number"==typeof r.rev&&(t=Math.max(t,r.rev))}catch{}return t}function Sl(e,t){return Array.isArray(e)?e.filter(e=>!!e&&"string"==typeof e.path&&"string"==typeof e.at&&Tl(e.path)===e.path&&t-Date.parse(e.at)<=Qa).map(e=>({path:e.path,at:e.at})).slice(-6):[]}function kl(e){const t=e?.product_prompts;return Array.isArray(t)?{product_prompts:t.filter(e=>!!e&&"string"==typeof e.product_id&&("string"==typeof e.text||null===e.text)&&"number"==typeof e.rev).map(e=>({product_id:e.product_id,text:e.text,rev:e.rev})).slice(-8)}:el}function xl(e,t){let i=!1;try{const r=cl();r&&(r.setItem(e,JSON.stringify(t)),i=!0)}catch{i=!1}const r=sl();if(i)r&&delete r[e];else{r&&(r[e]=t);try{cl()?.removeItem(e)}catch{}}al()}function Pl(e){const t=ul(e);if(!t)return null;const i=function(e,t){yl();let i=null;try{i=cl()?.getItem(e)??null}catch{i=null}const r=function(e,t=Date.now()){if(!e)return null;try{const i=JSON.parse(e);return i&&3===i.v&&"string"==typeof i.updated_at?{v:3,rev:"number"==typeof i.rev?i.rev:0,memory:"string"==typeof i.memory?i.memory:null,last_product_id:"string"==typeof i.last_product_id?i.last_product_id:null,pages:Sl(i.pages,t),plan:kl(i.plan),updated_at:i.updated_at}:null}catch{return null}}(i,t),n=sl()?.[e],s=n?{...n,pages:Sl(n.pages,t),plan:kl(n.plan)}:null;return r&&s?s.rev>r.rev?s:r:r??s}(t,e.now??Date.now());return i?function(e,t){const i=Date.parse(e.updated_at);return!Number.isFinite(i)||t-i>Qa}(i,e.now??Date.now())?(function(e){const t=ul(e);if(!t)return;gl(t,El(t));const i=sl();i&&delete i[t];try{cl()?.removeItem(t)}catch{}al()}(e),null):i:null}function $l(e){const t=ul(e);return t?pl(t,Pl(e)):0}function Il(e,t,i){const r=ul(e);if(!r)return null;const n=Pl(e),s=pl(r,n);if(void 0!==i&&s!==i)return n;const o={v:3,rev:s+1,memory:n?.memory??null,last_product_id:n?.last_product_id??null,pages:n?.pages??[],plan:el,...t,updated_at:new Date(e.now??Date.now()).toISOString()};return xl(r,o),o}function Tl(e){let t;try{t=new URL(e,"https://store.invalid")}catch{return null}const i=t.pathname.replace(/^\/[a-z]{2}(?:-[a-z0-9]{2,4})?(?=\/(?:products|collections|pages|search)(?:\/|$))/i,"").replace(/\/+$/,"");if("/search"===i.toLowerCase()){const e=(t.searchParams.get("q")||"").replace(/[&#?\s]+/g," ").trim().slice(0,60).trim();return!e||/@|\d{6,}|\d(?:[\s().+\-/]*\d){6,}/.test(e)?null:`/search?q=${e}`}const r=i.match(/^(?:\/collections\/[^/]+)?\/(products)\/([^/]+)$|^\/(collections|pages)\/([^/]+)$/i);if(!r)return null;const n=(r[1]||r[3]).toLowerCase();let s=r[2]||r[4];try{s=decodeURIComponent(s)}catch{}return!s||s.length>100||/[\s/?#]/.test(s)?null:`/${n}/${s}`}function Cl(e,t){if(!0!==Ba())return;const i=ul(e),r=Tl(t);if(!i||!r)return;const n=Pl(e),s=n?.pages??[];if(s.length&&s[s.length-1].path===r)return;const o=new Date(e.now??Date.now()).toISOString();xl(i,{v:3,rev:pl(i,n),memory:n?.memory??null,last_product_id:n?.last_product_id??null,pages:[...s.filter(e=>e.path!==r),{path:r,at:o}].slice(-6),plan:n?.plan??el,updated_at:n?.updated_at??o})}function Fl(){wl();const e=sl();if(e)for(const t of Object.keys(e))gl(t,El(t)),delete e[t];try{const e=cl();e&&Rl(e,[il]).forEach(t=>{gl(t,El(t)),e.removeItem(t)})}catch{}al()}function Ol(){try{const e=cl();e&&Rl(e,rl).forEach(t=>e.removeItem(t))}catch{}}function Rl(e,t){const i=[];for(let r=0;r<e.length;r++){const n=e.key(r);n&&t.some(e=>n.startsWith(e))&&i.push(n)}return i}function Al(e){if(!e)return;const t=`dori_shopper_note:about:${e}`;wl([t]),gl(t,El(t));const i=sl();i&&delete i[t];try{cl()?.removeItem(t)}catch{}al()}function Ml(e,t,i){if(t.forget)return function(e){const t=ul(e);if(!t)return;const i=pl(t,Pl(e))+1;bl(i,[t]),xl(t,{v:3,rev:i,memory:null,last_product_id:null,pages:[],plan:el,updated_at:new Date(e.now??Date.now()).toISOString()})}(e),void Al(e.sharingId);const r=void 0!==t.memory;if(r&&!t.memory)return Il(e,{memory:null,last_product_id:null},i.basedOnRev),void Al(e.sharingId);Il(e,{...r?{memory:t.memory??null}:{}},i.basedOnRev)}function Dl(e,t){if(!e)return;const i=t?Tl(t):null,r=!0===Ba()?e.pages.filter(e=>e.path!==i).slice(-5):[];return e.memory||r.length?{memory:e.memory,last_product_id:e.last_product_id,...r.length?{pages:r}:{}}:void 0}const Ll="/apps/dori/customer-token";let Nl=null,jl=0,ql=null;function Ul(e=Date.now()){return function(){if("undefined"==typeof window)return!1;const e=window.DORI_CUSTOMER_ID;return null!=e&&""!==String(e).trim()}()?Nl&&Nl.expiresAt-3e5>e?Promise.resolve(Nl.token):e<jl?Promise.resolve(null):(ql||(ql=async function(){const e=new AbortController,t=setTimeout(()=>e.abort(),2500);try{const t=await fetch(function(){if("undefined"==typeof document)return Ll;const e=function(e){const t=e?.dataset.prefix;return t&&nu.test(t)?t:null}(ou(document));return e?`${e}/customer-token`:Ll}(),{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"},signal:e.signal}),i=t.ok?await t.json():null,r="string"==typeof i?.token?i.token:null,n="number"==typeof i?.expires_in?i.expires_in:0;return r&&n>0?(Nl={token:r,expiresAt:Date.now()+1e3*n},r):(Nl=null,jl=Date.now()+3e5,null)}catch{return null}finally{clearTimeout(t)}}().finally(()=>{ql=null})),ql):Promise.resolve(null)}function Hl(){Ul()}function Wl(e){return e.add_quantity&&e.add_quantity>0?Math.floor(e.add_quantity):e.minimum_quantity&&e.minimum_quantity>1?Math.floor(e.minimum_quantity):1}function Bl(e){return e.price_unit&&e.add_quantity?`1 ${e.price_unit}`:void 0}function zl(){if("undefined"==typeof window)return;const e=window.Shopify?.country;return"string"==typeof e&&/^[A-Za-z]{2}$/.test(e)?e.toUpperCase():void 0}const Vl=(e,t)=>Object.assign(t,{doriCode:e}),Gl=e=>{const t=e?.doriCode;return"string"==typeof t?t:"unknown"},Jl="__dori_usage_cap_silent__",Yl={demoSharingData:`${Ta}/bot-sharing-data/`,runAssistant:`${Ta}/v2/run-assistant`,streamV2:`${Ta}/v2/stream`,cartContextSync:`${Ta}/shopify/cart-context/sync`,searchProductLog:`${Ta}/search-selected-item-log`,getUploadUrl:`${Ta}/get-upload-url`,trackProductView:`${Ta}/roi/track-view`,trackSession:`${Ta}/roi/track-session`,messageFeedback:`${Ta}/feedback/message`,threadContact:`${Ta}/thread`,handover:`${Ta}/handover/chat`,klaviyoCard:`${Ta}/integrations/klaviyo/request`,omnisendCard:`${Ta}/integrations/omnisend/request`,klaviyoStorefront:`${Ta}/integrations/klaviyo/storefront`,storeQuizzes:`${Ta}/store-quizzes`};async function Xl(e,t,i,r=[],n=!1){const s=oa();if(!e.card_id||!s)return"expired";try{const a=await fetch((o=e.provider,"omnisend"===o?Yl.omnisendCard:Yl.klaviyoCard),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({card_id:e.card_id,email:t,marketing_consent:i,sharing_id:s,choices:r,signed_up:n})});if(!a.ok)return"error";const l=await a.json();return"string"==typeof l?.status?l.status:"error"}catch{return"error"}var o}async function Kl(e,t){const i=await ec(e,t);return!!i?.ok}async function Zl(e,t,i=!1){const r=await ec(e,{...t,trigger:"handover"},{partial:!0,replace:i});if(!r)return{ok:!1,invalid:!1};if(400===r.status)return{ok:!1,invalid:!0};if(!r.ok)return{ok:!1,invalid:!1};const n=await r.json().catch(()=>({}));return{ok:!0,email:n.contact_email??null,phone:n.contact_phone??null}}async function Ql(e,t){const i=await ec(e,{email:t,trigger:"email_signup"},{partial:!0});return!!i?.ok}async function ec(e,t,{partial:i=!1,replace:r=!1}={}){const n=oa();if(!e||!n)return null;await Ka();const s=(o=Pl({sharingId:n,testMode:!1}))&&o.memory?{memory:o.memory,last_product_id:o.last_product_id}:null;var o;try{return await fetch(`${Yl.threadContact}/${e}/contact`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sharing_id:n,phone:t.phone??null,email:t.email??null,trigger:t.trigger??null,shopper_note:s,partial:i,replace:r})})}catch(a){return console.error("[Dori Widget] Failed to save contact details:",a),null}}async function tc(e,t,i,r=!1,n=null,s=[]){const o=new URLSearchParams({sharing_id:t});null!==i&&o.set("after",String(i)),r&&o.set("typing","true"),null!==n&&o.set("seen",String(n)),s.length&&o.set("shown",s.join(","));try{const t=await fetch(`${Yl.handover}/${encodeURIComponent(e)}?${o}`);return t.ok?await t.json():null}catch{return null}}const ic=zo("sendMessageToStreamAPI",async(e,t,i,r,n,s,o,a,l,c,u,d,h,p)=>{const g=t.assistant_id,f="undefined"!=typeof document?document.querySelector("script#dori-side-widget"):null,_=f?.getAttribute("data-currency")||void 0,v=c?null:await Ul(),m={assistant_id:g,thread_id:i||void 0,message:e,src:qa(),platform:"shopify_widget",image_url:a,end_user_id:l,browser_id:l,test_mode:c||void 0,focused_product_id:u||void 0,shortlist:d&&d.length>0?d:void 0,currency:_,country:zl(),shopper_note:h,customer_token:v||void 0,supports_handover:!0,...au(p)};let y;Object.keys(m).forEach(e=>void 0===m[e]&&delete m[e]);const w={Accept:"application/json","Content-Type":"application/json"};"undefined"!=typeof window&&window.idToken&&(w.Authorization=`Bearer ${window.idToken}`);const b=new AbortController,E=()=>b.abort();o?.signal.addEventListener("abort",E);const S=setTimeout(()=>b.abort(),25e3);try{y=await fetch(Yl.runAssistant,{method:"POST",headers:w,body:JSON.stringify(m),signal:b.signal})}catch($){throw console.error("[Dori Widget] Run assistant request failed:",{error:$,errorName:$?.name,errorMessage:$?.message,assistant_id:g,thread_id:i}),Vl("run_fetch_failed",$)}finally{clearTimeout(S),o?.signal.removeEventListener("abort",E)}if(o?.signal.aborted)return;if(429===y.status)return console.error("[Dori Widget] API rate limit exceeded:",{status:429,assistant_id:g,thread_id:i}),void n("You have exceeded the request limit. Please wait at least 24 hours and try again.");if(402===y.status)return console.error("[Dori Widget] Monthly conversation limit reached:",{status:402,assistant_id:g,thread_id:i}),void n(Jl);if(401===y.status){const e=await async function(e){fa();const t=oa();if(!t)return null;try{const i=await fetch(`${Yl.demoSharingData}${t}`);if(!i.ok)return null;const r=await i.json(),n=r?.data,s=n?.assistant_id;return s?(pa(n),e.assistant_id=s,s):null}catch(i){return console.error("[Dori Widget] Failed to recover assistant_id:",i),null}}(t);if(e&&e!==g){console.warn("[Dori Widget] Stale assistant_id — retrying with refreshed id:",{stale:g,refreshed:e}),m.assistant_id=e;const t=new AbortController,i=setTimeout(()=>t.abort(),25e3);try{y=await fetch(Yl.runAssistant,{method:"POST",headers:w,body:JSON.stringify(m),signal:t.signal})}catch(I){throw console.error("[Dori Widget] Retry after stale assistant_id failed:",I),Vl("run_fetch_failed_retry",I)}finally{clearTimeout(i)}}}if(!y.ok)throw console.error("[Dori Widget] Run assistant response not OK:",{status:y.status,statusText:y.statusText,assistant_id:m.assistant_id,thread_id:i}),Vl(`run_http_${y.status}`,new Error(`Run assistant request failed with status ${y.status}: ${y.statusText}`));let k;try{k=await y.json()}catch(T){throw console.error("[Dori Widget] Failed to parse run assistant response:",T),Vl("run_parse_failed",new Error("Failed to parse run assistant response"))}const x=k.thread_id;if(!x)throw Vl("run_no_thread_id",new Error("No thread_id received from run assistant"));if("live"===k.handover)return r({thread_id:x,handover:"live"}),void s();if("running"===k.turn||"done"===k.turn)return r({thread_id:x,turn:k.turn}),void s();const P=`${Yl.streamV2}/${x}`;return new Promise(e=>{const t=new EventSource(P);let i=!1;const a=()=>{d()};let l;o&&o.signal.addEventListener("abort",a);let c=!1;const u=()=>{clearTimeout(l),l=setTimeout(()=>{if(c)return console.warn("[Dori Widget] Suggestions tail timed out — completing without chips",{thread_id:x}),void d(()=>s());console.error("[Dori Widget] SSE stream silent too long — surfacing error",{thread_id:x,readyState:t.readyState}),d(()=>n("The connection dropped while waiting for a reply. Please send your message again."))},c?15e3:45e3)},d=r=>{i||(i=!0,clearTimeout(l),o&&o.signal.removeEventListener("abort",a),t.close(),r?.(),e())};u(),t.onopen=()=>{u(),console.log("[Dori Widget] SSE stream connected",{thread_id:x})},t.onerror=()=>{console.log("[Dori Widget] SSE stream error, EventSource will auto-reconnect",{thread_id:x,readyState:t.readyState})},t.onmessage=e=>{u(),Bo("SSE message parse",()=>{const t=JSON.parse(e.data);"suggestions_pending"!==t.status||c||(c=!0,u());const i={thread_id:t.thread_id,text:t.text,wait:t.wait,tool_name:t.tool_name,products:t.products,shape:t.shape,status:t.status,suggestions:t.suggestions,action:t.action,shopper_note:t.shopper_note};Object.keys(i).forEach(e=>void 0===i[e]&&delete i[e]),Object.keys(i).length>0&&r(i)})()},t.addEventListener("start",()=>{u(),console.log("[Dori Widget] SSE stream started",{thread_id:x})}),t.addEventListener("end",()=>{console.log("[Dori Widget] SSE stream ended",{thread_id:x}),d(s)})})}),rc=zo("trackProductClick",async(e,t,i)=>{eu("opened",{assistantId:t.assistant_id,threadId:i,how:"page"});const r={log:{assistant_id:t.assistant_id,thread_id:i,created_at:(new Date).toISOString(),selected_item_id:e.id,tool_call_id:e.tool_call_id}};await fetch(Yl.searchProductLog,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r),keepalive:!0})});function nc(){if("undefined"==typeof document)return null;const e=document.cookie.match(/(?:^|;\s*)dori_client_id=([^;]+)/);return e?decodeURIComponent(e[1]):null}const sc=zo("trackProductViewsBatch",async(e,t,i,r,n,s,o,a)=>{if(0===e.length)return;const l={customer_email:s||null,customer_id:o||null,external_product_ids:e,thread_id:t,platform:r,session_key:i,sharing_id:n,end_user_id:a||null,client_id:nc()};await fetch(Yl.trackProductView,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(l)})}),oc=zo("trackSession",async(e,t,i,r,n,s)=>{if(!e||!t)return;const o={sharing_id:t,thread_id:e,platform:i,session_key:r,customer_id:n||null,end_user_id:s||null,client_id:nc()};await fetch(Yl.trackSession,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)})});async function ac(e,t,i){try{const r=new AbortController,n=setTimeout(()=>r.abort(),2e4),s=i?AbortSignal.any([i,r.signal]):r.signal,o=await fetch(`${Yl.storeQuizzes}/${e}?lang=${encodeURIComponent(t)}`,{signal:s});if(clearTimeout(n),!o.ok)return console.warn("[Dori Widget] Store quizzes fetch failed:",o.status),null;const a=await o.json(),l=a?.variants;return l&&Array.isArray(l)&&0!==l.length?l.map(e=>({welcome_hook:e.welcome_hook||"",entry_label:e.entry_label||"",steps:e.steps||[],result_prompt:e.result_prompt||"",result_type:e.quiz_type||e.result_type||"recommendation",analyzing_text:e.analyzing_text||"",email_signup:a?.email_signup?.headline?a.email_signup:null})):null}catch(r){return"AbortError"!==r?.name&&console.warn("[Dori Widget] Store quizzes error:",r),null}}let lc=0;function cc(e){return"shopify"===String(e?.platform||"").toLowerCase()}function uc(){if("undefined"==typeof window)return"/";const e=window.Shopify?.routes?.root||"/";return e.endsWith("/")?e:`${e}/`}function dc(){const e=window.HeadlessCheckout;if("function"==typeof e?.checkout)try{return void e.checkout(null)}catch{}window.location.href=`${uc()}checkout`}function hc(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function pc(){if("undefined"==typeof window)return`anon_${hc()}`;try{const e=window.localStorage.getItem(na);if(e&&e.trim())return e;const t=`anon_${hc()}`;return window.localStorage.setItem(na,t),t}catch{return`anon_${hc()}`}}async function gc(){try{const e=uc(),t=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)return null;const i=await t.json();return{item_count:Number(i?.item_count||0),total_price:Number(i?.total_price||0),currency:String(i?.currency||""),items:Array.isArray(i?.items)?i.items:[]}}catch{return null}}const fc=e=>e&&"Default Title"!==e?e:null;function _c(e,t){if(!e)return null;const i=null!=t.variantId?String(t.variantId):null;let r;i&&(r=e.items.find(e=>String(e.id)===i)),!r&&t.name&&(r=e.items.find(e=>e.product_title===t.name));const n=e.items.filter(e=>e!==r),s=n.slice(0,2).map(e=>{const t=e.final_price??e.price;return{title:e.product_title??null,variant_title:fc(e.variant_title),quantity:e.quantity,line_price:e.final_line_price??(null!=t?t*e.quantity:null),image:e.image??null}});return{currency:e.currency,item_count:e.item_count,total_price:e.total_price,added:{name:t.name??r?.product_title??null,variant_title:fc(t.variantTitle)??fc(r?.variant_title),image:r?.image??null,quantity:t.quantity??r?.quantity??1,unit_price:r?.final_price??r?.price??null},others:s,hidden_line_count:Math.max(0,n.length-s.length)}}let vc=!1;async function mc(){if("undefined"!=typeof window&&!vc){vc=!0;try{const e=uc(),t=pc(),i=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!i.ok)return;const r=await i.json(),n=r?.attributes||{};if(n._dori_visitor_id===t)return;await fetch(`${e}cart/update.js`,{method:"POST",credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({attributes:{...n,_dori_visitor_id:t}})})}catch{}finally{vc=!1}}}async function yc(){if("undefined"!=typeof window&&!vc){vc=!0;try{const e=uc(),t=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)return;const i=await t.json();if(!i?.attributes||!("_dori_visitor_id"in i.attributes))return;await fetch(`${e}cart/update.js`,{method:"POST",credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({attributes:{_dori_visitor_id:""}})})}catch{}finally{vc=!1}}}async function wc(e){const t=Date.now();if(t-lc<800)return null;lc=t;const i=await async function(){try{const e=uc(),t=await fetch(`${e}cart.js`,{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(!t.ok)return null;const i=await t.json(),r=String(i?.token||"").trim();return r?{token:r,item_count:Number(i?.item_count||0),currency:String(i?.currency||""),total_price:Number(i?.total_price||0),subtotal_price:Number(i?.items_subtotal_price||0),updated_at:(new Date).toISOString()}:null}catch{return null}}();if(!i)return null;try{const t=await fetch(Yl.cartContextSync,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({assistant_id:e.assistantId,platform:e.platform,end_user_id:e.endUserId,thread_id:e.threadId||void 0,cart:i,src:e.src||("undefined"!=typeof window?window.location.href:"")})});if(!t.ok)return null;const r=await t.json();return"string"==typeof r?.thread_id?r.thread_id:null}catch{return null}}function bc(e,t){const i=e.toUpperCase();return!!["POST","PUT","PATCH","DELETE"].includes(i)&&["/cart/add","/cart/change","/cart/update","/cart/clear"].some(e=>t.includes(e))}function Ec(e){if("undefined"==typeof window)return()=>{};let t=null;const i=()=>{null!==t&&window.clearTimeout(t),t=window.setTimeout(()=>{e()},700)},r=window.fetch.bind(window);window.fetch=async(...e)=>{const t=await r(...e);try{const t=e[0],r=e[1];bc((r?.method||(t instanceof Request?t.method:"GET")||"GET").toString(),"string"==typeof t?t:t instanceof URL?t.toString():t.url)&&i()}catch{}return t};const n=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(e,t,i,r,s){return this.__doriCartMethod=e,this.__doriCartUrl=String(t||""),n.call(this,e,t,i??!0,r,s)},XMLHttpRequest.prototype.send=function(e){return this.addEventListener("loadend",()=>{try{bc(String(this.__doriCartMethod||"GET"),String(this.__doriCartUrl||""))&&i()}catch{}}),s.call(this,e)},()=>{window.fetch=r,XMLHttpRequest.prototype.open=n,XMLHttpRequest.prototype.send=s,null!==t&&window.clearTimeout(t)}}const Sc=["cart-icon-bubble","cart-drawer","cart-notification-product","cart-notification-button","cart-live-region-text"],kc=[".cart-count-bubble","[data-cart-count]",".cart-count",".cart-item-count","#CartCount",".site-header__cart-count",".header__cart-count",".js-cart-count"];function xc(e){if(!e)return null;try{return new URL(e,window.location.origin).pathname.replace(/\/$/,"")}catch{return null}}function Pc(e=document){return Array.from(e.querySelectorAll("a[href]")).filter(e=>function(e){const t=xc(e);return!!t&&/^(\/[a-z]{2}(-[a-z]{2})?)?\/cart$/i.test(t)}(e.getAttribute("href")))}function $c(e,t){if(!t)return!1;try{const i=(new DOMParser).parseFromString(t,"text/html"),r=i.getElementById(`shopify-section-${e}`)||i.querySelector(".shopify-section"),n=document.getElementById(`shopify-section-${e}`);if(n&&r)return n.replaceWith(r),!0;const s=document.getElementById(e);if(s&&r)return s.innerHTML=r.innerHTML,!0;const o=document.querySelector(e),a=i.querySelector(e);if(o&&a)return o.replaceWith(a),!0}catch{}return!1}function Ic(e,t){let i=2;try{i=new Intl.NumberFormat("en",{style:"currency",currency:t}).resolvedOptions().maximumFractionDigits??2}catch{}return{amount:(Number(e)/100).toFixed(i),currencyCode:t}}function Tc(e){const t=String(e?.currency||"USD"),i=String(e?.token??""),r=Array.isArray(e?.items)?e.items:[];return{id:`gid://shopify/Cart/${i}`,totalQuantity:Number(e?.item_count)||0,cost:{totalAmount:Ic(e?.total_price??0,t)},lines:r.map(e=>({id:`gid://shopify/CartLine/${e?.key??e?.id}?cart=${i}`,quantity:Number(e?.quantity)||0,cost:{totalAmount:Ic(e?.final_line_price??0,t)}})),discountCodes:(Array.isArray(e?.discount_codes)?e.discount_codes:[]).map(e=>({applicable:e?.applicable,code:e?.code}))}}function Cc(){return!!Fc()&&(window.dispatchEvent(new CustomEvent("dori:close-widget",{detail:{reason:"cart"}})),!0)}function Fc(){if("undefined"==typeof document)return!1;const e=['[data-testid="cart-drawer-trigger"]','button[aria-haspopup="dialog"][aria-label="Cart" i]','[aria-controls="CartDrawer"]',".js-drawer-open-cart",'[data-drawer-toggle="cart"]'];for(const r of e){const e=Array.from(document.querySelectorAll(r)),t=e.find(e=>null!==e.offsetParent)||e[0];if(t){const e=document.getElementById(t.getAttribute("aria-controls")||"")||document.querySelector("cart-drawer-component, cart-drawer");if("true"===t.getAttribute("aria-expanded")||Rc(e))return Oc(e);try{return t.click(),Oc(e)}catch{}}}if(document.querySelector("cart-drawer")){const e=document.querySelector("#cart-icon-bubble");if(e)try{return e.click(),Oc(document.querySelector("cart-drawer"))}catch{}}const t=document.querySelector("cart-drawer-component");if(t){const e=t.querySelector?.("dialog");if(e&&!e.open&&"function"==typeof e.showModal)try{return e.showModal(),Oc(t)}catch{}try{return t.open=!0,Oc(t)}catch{}}const i=document.querySelector("cart-drawer");if(i&&"function"==typeof i.open){i.classList?.remove?.("is-empty");try{return i.open(),Oc(i)}catch{}}return!1}function Oc(e){return async function(e){if(!e)return;const t=uc();let i=[];try{const e=await fetch(`${t}cart.js`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});if(!e.ok)return;const r=await e.json();i=Array.isArray(r?.items)?r.items:[]}catch{return}if(i.length){for(let t=0;t<1500;t+=250){if(Rc(e)&&Ac(e,i))return;await new Promise(e=>setTimeout(e,250))}Rc(e)&&!Ac(e,i)&&(window.location.href=`${t}cart`)}}(e).catch(()=>{}),!0}function Rc(e){if(!e)return!1;let t=e;e.getBoundingClientRect().width<1&&(t=e.querySelector("dialog, [role='dialog']")||e);const i=t.getBoundingClientRect();if(i.width<1||i.height<1)return!1;if(i.right<=0||i.bottom<=0||i.left>=window.innerWidth||i.top>=window.innerHeight)return!1;if("hidden"===getComputedStyle(t).visibility)return!1;for(let r=t;r&&r!==document.body;r=r.parentElement)if(Number(getComputedStyle(r).opacity)<.05)return!1;return!0}function Ac(e,t){const i=e=>String(e??"").toLowerCase().replace(/\s+/g," ").trim(),r=i(e.innerText??e.textContent),n=Array.from(e.querySelectorAll("a[href]")).filter(e=>e.getClientRects().length>0).map(e=>{const t=e.getAttribute("href")||"";try{return decodeURI(t)}catch{return t}});return t.some(e=>{const t=String(e?.handle||"");if(t&&n.some(e=>e.includes(`/products/${t}`)))return!0;const s=i(e?.product_title).slice(0,16);return s.length>=4&&r.includes(s)})}async function Mc(e){if("undefined"==typeof window||"undefined"==typeof document)return null;const t=uc();let i=null;try{const e=await fetch(`${t}cart.js`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});e.ok&&(i=await e.json())}catch{}const r=i&&Number.isFinite(Number(i.item_count))?Number(i.item_count):null;let n=null;if(!n)try{const e=await fetch(`${t}?sections=${Sc.join(",")}`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});e.ok&&(n=await e.json())}catch{}let s=!1;if(n)for(const o of Sc)$c(o,n[o]??null)&&(s=!0);if(!s)try{const e=Pc(),i=new Map,r=new Set;for(const t of e){const e=t.closest('[id^="shopify-section-"]'),n=e?.id?.replace(/^shopify-section-/,"");n&&(i.set(t,n),r.add(n))}const n=Array.from(r).slice(0,5);if(n.length){const r=await fetch(`${t}?sections=${n.map(encodeURIComponent).join(",")}`,{credentials:"include",cache:"no-store",headers:{Accept:"application/json"}});if(r.ok){const t=await r.json(),o={};for(const e of n)"string"==typeof t?.[e]&&(o[e]=(new DOMParser).parseFromString(t[e],"text/html"));for(const r of e){const e=i.get(r),t=e?o[e]:void 0;if(!t)continue;const n=xc(r.getAttribute("href")),a=Pc(t).find(e=>xc(e.getAttribute("href"))===n);a&&(r.innerHTML=a.innerHTML,s=!0)}}}}catch{}if(!s&&null!=r)try{document.querySelectorAll(kc.join(",")).forEach(e=>{const t=e;t.textContent=String(r),t.hasAttribute("data-cart-count")&&t.setAttribute("data-cart-count",String(r)),t.removeAttribute("hidden"),r>0&&t.style.removeProperty("display")})}catch{}return r&&document.querySelectorAll("cart-drawer.is-empty").forEach(e=>e.classList.remove("is-empty")),function(e){if("undefined"==typeof document)return;const t=e?{cart:e,source:"dori"}:{source:"dori"},i=["cart:refresh","cart:build","cart:updated","cart:change","ajaxProduct:added","eurus:cart:reload"];for(const r of i)try{document.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:t}))}catch{}try{const t=e&&Number.isFinite(Number(e.item_count))?Number(e.item_count):void 0;document.dispatchEvent(new CustomEvent("cart:update",{bubbles:!0,detail:{data:{itemCount:t,source:"product-form-component"}}}))}catch{}try{!function(e){if(!e||"object"!=typeof e||!Array.isArray(e.items))return;const t=new Event("shopify:cart:lines-update",{bubbles:!0,cancelable:!0});Object.assign(t,{action:"update",lines:[],promise:Promise.resolve({cart:Tc(e),detail:{items:e.items,itemCount:Number(e.item_count)||0,source:"dori",didError:!1}})}),document.dispatchEvent(t)}(e)}catch{}}(i),r}const Dc="sidekick";function Lc(e,t={}){try{fetch(`${Ta}/events/widget`,{method:"POST",headers:{"Content-Type":"application/json"},keepalive:!0,body:JSON.stringify({event:e,assistant_id:t.assistantId||void 0,thread_id:t.threadId||void 0,payload:{surface:Dc,visitor:pc()||void 0,...t.payload}})}).catch(()=>{})}catch{}try{Ho(`pf.${e}`,{thread_id:t.threadId||void 0,...t.payload})}catch{}}const Nc="banner",jc="dori:banner_visit",qc="dori:banner_seen",Uc="dori:banner_seen_pending",Hc="\n[BANNER] ";let Wc=null,Bc=!0;function zc(e){return"banner"===e?.source||"banner_link"===e?.source||!e?.source&&!!e?.initiator}function Vc(e){if("banner_link"!==e?.source||e.intent||e.initiator)return e;const t="undefined"==typeof document?null:document.getElementById("dori-banner-link");return t?{...e,intent:t.dataset.intent,initiator:{message:t.dataset.message,query:t.dataset.query}}:e}function Gc(e){return("string"==typeof e?.intent?e.intent.trim():"")||Nc}function Jc(e,t){const i="string"==typeof t?.message?t.message.trim():"",r="string"==typeof t?.query?(e=>e.replace(/\[/g,"(").replace(/\]/g,")").replace(/\s+/g," ").trim())(t.query):"";return i&&r&&e!==Nc?{message:i,apiMessage:`${i}${Hc}The shopper tapped the store's banner, so this line is the banner's, not typed by them. The banner's brief: "${r}". Reply with one short question that narrows this down and names 3 or 4 short answers inside it, in one sentence. The shopper can tap each answer, so don't list them again below it. Once they answer, show a few products with a reason for each.`}:null}function Yc(){if(!Bc)return Wc;try{const e=sessionStorage.getItem(jc),t=e?JSON.parse(e):null;if(t&&"string"==typeof t.intent)return Wc=t}catch{}return Wc}function Xc(e){Wc=e;try{sessionStorage.setItem(jc,JSON.stringify(e))}catch{Bc=!1}}function Kc(e){ja(`banner:${e}`);const t=Yc();return t?.intent===e?{firstTap:!1,sendOpener:!t.sent}:(Xc({intent:e}),{firstTap:!0,sendOpener:!0})}function Zc(){const e=Yc();e&&!e.sent&&Xc({...e,sent:!0})}function Qc(){const e=Yc();e&&ja(`banner:${e.intent}`)}function eu(e,t){const i=Yc();!i||i[e]||"opened"===e&&!i.answered||(Xc({...i,[e]:!0}),Lc("answered"===e?"banner_answered":"banner_product_opened",{assistantId:t.assistantId,threadId:t.threadId,payload:{intent:i.intent,...t.how?{how:t.how}:{}}}))}const tu=e=>!!e?.includes(Hc);function iu(e){let t=!1;const i=i=>{if(t)return;t=!0;try{if(sessionStorage.removeItem(Uc),"1"===sessionStorage.getItem(qc))return;sessionStorage.setItem(qc,"1")}catch{}const r="string"==typeof i?.intent?i.intent.trim():"";e(r||Nc)},r=function(){try{const e=sessionStorage.getItem(Uc);return e?JSON.parse(e):null}catch{return null}}()??window.__doriBannerSeen;r&&i(r);const n=e=>i(e.detail);return window.addEventListener("dori:banner-seen",n),()=>window.removeEventListener("dori:banner-seen",n)}const ru="dori-ai-page",nu=/^\/(a|apps|community|tools)\/[A-Za-z0-9_-]{1,30}$/,su=/^[a-z0-9_-]{1,32}$/i;function ou(e){return e.getElementById(ru)??null}function au(e){if(!e)return{};const t=!!e.rules&&(void 0!==e.rules.size||void 0!==e.rules.max_price);return{surface:"ai_page",turn_id:e.turnId,...t?{page_rules:e.rules}:{}}}function lu(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const cu=/^\/(a|apps|community|tools)\/[A-Za-z0-9_-]{1,30}\/ai$/,uu=/^\/[A-Za-z0-9/_-]*$/;function du(e,t,i){const r=!0===e?.ai_page?e.ai_page_path:null;return r&&cu.test(r)?"ask_button"===i&&"ai_page"!==e?.ask_button_opens?null:`${t&&uu.test(t)?t.replace(/\/+$/,""):""}${r}?src=${i}`:null}function hu(e){return!e||zc(e)?null:e.expand?"link"===e.source?"link":"chat":"header_button"===e.source||"header_block"===e.source?"ask_button":null}function pu(e){const t=new URLSearchParams(e).get("src");return`ai_page:${t&&su.test(t)?t.toLowerCase():"direct"}`}const gu=(e,t=[])=>{if(!t||0===t.length)return!1;const i=e.replace(/^\/+/,"").toLowerCase();return t.some(e=>{const t=e.replace(/^\/+/,"").toLowerCase();return i.includes(t)})},fu=()=>"undefined"==typeof window?"":window.location.pathname,_u=new Set;let vu=!1;function mu(){for(const e of _u)try{e()}catch{}}const yu="dori-bot-data-ready",wu="dori-bot-data-error",bu=(e,t)=>{window.dispatchEvent(new CustomEvent(e,t?{detail:{error:t}}:void 0))},Eu=async e=>{const t=await fetch(e);if(200!==t.status)throw new Error(`Failed to fetch bot data: ${t.status}`);const i=await t.json();if(i.error)throw new Error(i.error);if(!i.data)throw new Error("No data received from bot sharing API");return i},Su=(e,t)=>{pa(e),t&&function(e){if(aa())try{e?localStorage.setItem(Go,e):localStorage.removeItem(Go)}catch(t){console.error("Error saving ETag:",t)}}(t),Ea()};let ku=!1,xu="";const Pu=()=>{const e=ga();if(!ku&&!0!==e?.feature_flags?.ask_button&&!document.querySelector("[data-dori-ask-block]"))return;ku||function(){if(_u.add(()=>{window.location.pathname!==xu&&Pu()}),!vu&&"undefined"!=typeof window){vu=!0;for(const e of["pushState","replaceState"]){const t=history[e];history[e]=function(...e){const i=t.apply(this,e);return mu(),i}}window.addEventListener("popstate",mu)}}(),ku=!0,xu=window.location.pathname;const i=!!e&&gu(xu,e.banned_paths||[]);t(async()=>{const{applyAskButton:e}=await import("./assets/apply-CnbnshVa.js");return{applyAskButton:e}},__vite__mapDeps([0,1]),import.meta.url).then(({applyAskButton:t})=>t(e,i)).catch(e=>console.error("[Dori Widget] Ask button failed to load:",e))};window.addEventListener(yu,Pu),async function(){try{const t=(()=>{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null})();if(!t)return void bu(wu,"No sharing ID found");!function(){if(aa())try{const e=oa();if(!e)return;const t=localStorage.getItem(Yo);if(t===e)return;t&&(fa(),da()),localStorage.setItem(Yo,e)}catch(e){console.error("Error resetting session for new store:",e)}}();const i=ga(),r=function(){if(!aa()||!ua())return null;if(!ha())return null;try{return localStorage.getItem(Go)}catch(e){return console.error("Error loading ETag:",e),null}}(),n=`${Ta}/bot-sharing-data/${t}`;i&&bu(yu);const s=i?[]:[1500,4e3];for(let o=0;;o++)try{const e=r?{"If-None-Match":r}:{},t=await fetch(n,{headers:e});if(304===t.status){if(!i){const e=await Eu(n);Su(e.data,t.headers.get("ETag")),bu(yu)}return}if(200===t.status){const e=await t.json();if(e.error)throw new Error(e.error);if(!e.data)throw new Error("No data received");return Su(e.data,t.headers.get("ETag")),void bu(yu)}throw new Error(`Failed to fetch bot data: ${t.status}`)}catch(e){if(i)return;if(o<s.length){await new Promise(e=>setTimeout(e,s[o]));continue}const t=e instanceof Error?e.message:String(e);return void bu(wu,t)}}catch(e){const t=e instanceof Error?e.message:String(e);bu(wu,t)}}(),function(){if("undefined"==typeof window)return;const e=window;e.__doriOpenQueue=e.__doriOpenQueue||[];const t=t=>{e.__doriOpenReady||e.__doriOpenQueue.push(t??{})};e.doriWidget=e.doriWidget||{},"function"!=typeof e.doriWidget.open&&(e.doriWidget.open=t),e.addEventListener("dori:open-widget",e=>t(e.detail))}(),"undefined"!=typeof window&&"undefined"!=typeof document&&document.addEventListener("click",e=>function(e,t){if(e.defaultPrevented||0!==e.button)return!1;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;const i=e.target,r=i&&"function"==typeof i.closest?i.closest("a[href]"):null;if(!r)return!1;const n=r.getAttribute("target");if(n&&"_self"!==n)return!1;const s=function(e,t){const i={open:!1,expand:!1,banner:!1};try{const r=new URL(e,t);if(r.origin!==new URL(t).origin)return i;const n=r.searchParams.get("dori-chat")?.trim().toLowerCase();if("banner"===n)return{open:!0,expand:!0,banner:!0};if("open"===n||"expand"===n)return{open:!0,expand:"expand"===n,banner:!1};if("#dori-chat"===r.hash.toLowerCase())return{open:!0,expand:!1,banner:!1}}catch{}return i}(r.getAttribute("href")||"",t);return!(!s.open||s.banner&&"undefined"!=typeof document&&ou(document)||(e.preventDefault(),window.doriWidget?.open?.({source:s.banner?"banner_link":"link",expand:s.expand}),0))}(e,window.location.href),!0);const $u=()=>{t(async()=>{const{initializeDoriWidget:e}=await import("./assets/main-DtXI9PnM.js");return{initializeDoriWidget:e}},__vite__mapDeps([2,3,4,1]),import.meta.url).then(({initializeDoriWidget:e})=>e()).catch(async e=>{const t=Ra(e);if(t){await new Promise(e=>setTimeout(e,1500));try{const e=await import(Aa(t));e.initializeDoriWidget?.()}catch(i){console.error("[Dori Widget] Error initializing widget (after retry):",e,i)}}else console.error("[Dori Widget] Error initializing widget:",e)})},Iu=()=>{const e=ou(document);var i;e?(i=e,t(async()=>{const{mountAiPage:e}=await import("./assets/mount-5SwUgqR8.js");return{mountAiPage:e}},__vite__mapDeps([5,3]),import.meta.url).then(({mountAiPage:e})=>e(i)).catch(async e=>{const t=Ra(e);if(t){await new Promise(e=>setTimeout(e,1500));try{const e=await import(Aa(t));e.mountAiPage?.(i)}catch(r){console.error("[Dori Widget] AI page failed to load (after retry):",e,r)}}else console.error("[Dori Widget] AI page failed to load:",e)})):"undefined"!=typeof window&&(window.__doriOpenQueue?.length??0)>0?$u():function(e,t={}){let i=!1;try{i=window.self!==window.top}catch{i=!0}if(i)return t.onLoadStart?.(),void e();let r=!1;const n=[],s=()=>{if(!r){r=!0;for(const e of n)e();t.onLoadStart?.(),e()}},o=(e,t)=>{"function"==typeof window.requestIdleCallback?window.requestIdleCallback(()=>e(),{timeout:t}):window.setTimeout(e,200)},a=(e,t,i)=>{e.addEventListener(t,i,{once:!0,passive:!0,capture:!0}),n.push(()=>e.removeEventListener(t,i,!0))};for(const d of Ca)a(window,d,s);let l=!1;const c=()=>{l||r||(l=!0,o(s,2e3))};for(const d of Fa)a(window,d,c);for(const d of t.immediateTargets??[])if(d)for(const e of Oa)a(d,e,s);const u=()=>{if(r)return;const e=window.setTimeout(()=>o(s,1e3),5e3);n.push(()=>window.clearTimeout(e))};"complete"===document.readyState?u():window.addEventListener("load",u,{once:!0})}($u)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Iu,{once:!0}):Iu();export{va as $,Yl as A,gu as B,du as C,Qc as D,iu as E,Bo as F,La as G,hu as H,Da as I,Vc as J,Gc as K,Kc as L,Jc as M,zc as N,lu as O,ja as P,pu as Q,Fc as R,Ta as S,Ql as T,Mc as U,aa as V,tc as W,Ea as X,pa as Y,_a as Z,t as _,rc as a,ya as a0,wa as a1,$a as a2,la as a3,Pl as a4,ac as a5,wc as a6,_c as a7,eu as a8,zo as a9,Zl as aA,yc as aa,mc as ab,Ec as ac,da as ad,ll as ae,Ka as af,Cl as ag,Ol as ah,Hl as ai,Fl as aj,Za as ak,tu as al,Zc as am,Dl as an,$l as ao,ic as ap,ca as aq,Pa as ar,Ia as as,oc as at,Ml as au,r as av,Jl as aw,Gl as ax,ga as ay,Xl as az,Bl as b,Ho as c,Wl as d,xa as e,gc as f,oa as g,ba as h,cc as i,pc as j,sc as k,ma as l,dc as m,uc as n,Cc as o,s as p,Ma as q,Wo as r,Kl as s,Lc as t,n as u,Uo as v,zl as w,ka as x,Sa as y,fu as z};
|