import{e as vt}from"../chunks/public.804d7455.js";import{_ as Nt}from"../chunks/preload-helper.a4192956.js";import{s as un,c as hn,u as dn,g as fn,d as pn,o as _n,n as os}from"../chunks/scheduler.a0ac0953.js";import{S as gn,i as mn,g as me,s as Er,h as ye,j as Ye,x as Zt,c as Or,f as Se,k as ke,a as Vr,y as pe,d as yn,t as vn,z as bn}from"../chunks/index.47e350ee.js";import{i as wn}from"../chunks/navigation.c626dd3d.js";import{w as Sn}from"../chunks/singletons.9d2cb84d.js";function kn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var V;(function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"})(V||(V={}));function En(t){return t.nodeType===t.ELEMENT_NODE}function St(t){const e=t==null?void 0:t.host;return(e==null?void 0:e.shadowRoot)===t}function kt(t){return Object.prototype.toString.call(t)==="[object ShadowRoot]"}function On(t){return t.includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t}function xn(t){const{cssText:e}=t;if(e.split('"').length<3)return e;const r=["@import",`url(${JSON.stringify(t.href)})`];return t.layerName===""?r.push("layer"):t.layerName&&r.push(`layer(${t.layerName})`),t.supportsText&&r.push(`supports(${t.supportsText})`),t.media.length&&r.push(t.media.mediaText),r.join(" ")+";"}function er(t){try{const e=t.rules||t.cssRules;return e?On(Array.from(e,as).join("")):null}catch{return null}}function as(t){let e;if(Tn(t))try{e=er(t.styleSheet)||xn(t)}catch{}else if(Cn(t)&&t.selectorText.includes(":"))return In(t.cssText);return e||t.cssText}function In(t){const e=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return t.replace(e,"$1\\$2")}function Tn(t){return"styleSheet"in t}function Cn(t){return"selectorText"in t}class cs{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(e){var r;if(!e)return-1;const i=(r=this.getMeta(e))===null||r===void 0?void 0:r.id;return i??-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const r=this.getId(e);this.idNodeMap.delete(r),e.childNodes&&e.childNodes.forEach(i=>this.removeNodeFromMap(i))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,r){const i=r.id;this.idNodeMap.set(i,e),this.nodeMetaMap.set(e,r)}replace(e,r){const i=this.getNode(e);if(i){const s=this.nodeMetaMap.get(i);s&&this.nodeMetaMap.set(r,s)}this.idNodeMap.set(e,r)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Rn(){return new cs}function Kr({element:t,maskInputOptions:e,tagName:r,type:i,value:s,maskInputFn:n}){let o=s||"";const c=i&&Ge(i);return(e[r.toLowerCase()]||c&&e[c])&&(n?o=n(o,t):o="*".repeat(o.length)),o}function Ge(t){return t.toLowerCase()}const Si="__rrweb_original__";function Mn(t){const e=t.getContext("2d");if(!e)return!0;const r=50;for(let i=0;i<t.width;i+=r)for(let s=0;s<t.height;s+=r){const n=e.getImageData,o=Si in n?n[Si]:n;if(new Uint32Array(o.call(e,i,s,Math.min(r,t.width-i),Math.min(r,t.height-s)).data.buffer).some(a=>a!==0))return!1}return!0}function Yr(t){const e=t.type;return t.hasAttribute("data-rr-is-password")?"password":e?Ge(e):null}function ls(t,e){var r;let i;try{i=new URL(t,e??window.location.href)}catch{return null}const s=/\.([0-9a-z]+)(?:$)/i,n=i.pathname.match(s);return(r=n==null?void 0:n[1])!==null&&r!==void 0?r:null}let An=1;const Dn=new RegExp("[^a-z0-9-_:]"),Rt=-2;function us(){return An++}function Pn(t){if(t instanceof HTMLFormElement)return"form";const e=Ge(t.tagName);return Dn.test(e)?"div":e}function Nn(t){let e="";return t.indexOf("//")>-1?e=t.split("/").slice(0,3).join("/"):e=t.split("/")[0],e=e.split("?")[0],e}let Xe,ki;const Ln=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,$n=/^(?:[a-z+]+:)?\/\//i,jn=/^www\..*/i,Un=/^(data:)([^,]*),(.*)/i;function tr(t,e){return(t||"").replace(Ln,(r,i,s,n,o,c)=>{const a=s||o||c,l=i||n||"";if(!a)return r;if($n.test(a)||jn.test(a))return`url(${l}${a}${l})`;if(Un.test(a))return`url(${l}${a}${l})`;if(a[0]==="/")return`url(${l}${Nn(e)+a}${l})`;const u=e.split("/"),f=a.split("/");u.pop();for(const d of f)d!=="."&&(d===".."?u.pop():u.push(d));return`url(${l}${u.join("/")}${l})`})}const Fn=/^[^ \t\n\r\u000c]+/,qn=/^[, \t\n\r\u000c]+/;function Bn(t,e){if(e.trim()==="")return e;let r=0;function i(n){let o;const c=n.exec(e.substring(r));return c?(o=c[0],r+=o.length,o):""}const s=[];for(;i(qn),!(r>=e.length);){let n=i(Fn);if(n.slice(-1)===",")n=nt(t,n.substring(0,n.length-1)),s.push(n);else{let o="";n=nt(t,n);let c=!1;for(;;){const a=e.charAt(r);if(a===""){s.push((n+o).trim());break}else if(c)a===")"&&(c=!1);else if(a===","){r+=1,s.push((n+o).trim());break}else a==="("&&(c=!0);o+=a,r+=1}}}return s.join(", ")}function nt(t,e){if(!e||e.trim()==="")return e;const r=t.createElement("a");return r.href=e,r.href}function zn(t){return!!(t.tagName==="svg"||t.ownerSVGElement)}function Xr(){const t=document.createElement("a");return t.href="",t.href}function hs(t,e,r,i){return i&&(r==="src"||r==="href"&&!(e==="use"&&i[0]==="#")||r==="xlink:href"&&i[0]!=="#"||r==="background"&&(e==="table"||e==="td"||e==="th")?nt(t,i):r==="srcset"?Bn(t,i):r==="style"?tr(i,Xr()):e==="object"&&r==="data"?nt(t,i):i)}function ds(t,e,r){return(t==="video"||t==="audio")&&e==="autoplay"}function Hn(t,e,r){try{if(typeof e=="string"){if(t.classList.contains(e))return!0}else for(let i=t.classList.length;i--;){const s=t.classList[i];if(e.test(s))return!0}if(r)return t.matches(r)}catch{}return!1}function rr(t,e,r){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return r?rr(t.parentNode,e,r):!1;for(let i=t.classList.length;i--;){const s=t.classList[i];if(e.test(s))return!0}return r?rr(t.parentNode,e,r):!1}function fs(t,e,r,i){try{const s=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(s===null)return!1;if(typeof e=="string"){if(i){if(s.closest(`.${e}`))return!0}else if(s.classList.contains(e))return!0}else if(rr(s,e,i))return!0;if(r){if(i){if(s.closest(r))return!0}else if(s.matches(r))return!0}}catch{}return!1}function Wn(t,e,r){const i=t.contentWindow;if(!i)return;let s=!1,n;try{n=i.document.readyState}catch{return}if(n!=="complete"){const c=setTimeout(()=>{s||(e(),s=!0)},r);t.addEventListener("load",()=>{clearTimeout(c),s=!0,e()});return}const o="about:blank";if(i.location.href!==o||t.src===o||t.src==="")return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}function Gn(t,e,r){let i=!1,s;try{s=t.sheet}catch{return}if(s)return;const n=setTimeout(()=>{i||(e(),i=!0)},r);t.addEventListener("load",()=>{clearTimeout(n),i=!0,e()})}function Jn(t,e){const{doc:r,mirror:i,blockClass:s,blockSelector:n,needsMask:o,inlineStylesheet:c,maskInputOptions:a={},maskTextFn:l,maskInputFn:u,dataURLOptions:f={},inlineImages:d,recordCanvas:p,keepIframeSrcFn:g,newlyAddedElement:_=!1}=e,m=Vn(r,i);switch(t.nodeType){case t.DOCUMENT_NODE:return t.compatMode!=="CSS1Compat"?{type:V.Document,childNodes:[],compatMode:t.compatMode}:{type:V.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:V.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:m};case t.ELEMENT_NODE:return Yn(t,{doc:r,blockClass:s,blockSelector:n,inlineStylesheet:c,maskInputOptions:a,maskInputFn:u,dataURLOptions:f,inlineImages:d,recordCanvas:p,keepIframeSrcFn:g,newlyAddedElement:_,rootId:m});case t.TEXT_NODE:return Kn(t,{needsMask:o,maskTextFn:l,rootId:m});case t.CDATA_SECTION_NODE:return{type:V.CDATA,textContent:"",rootId:m};case t.COMMENT_NODE:return{type:V.Comment,textContent:t.textContent||"",rootId:m};default:return!1}}function Vn(t,e){if(!e.hasNode(t))return;const r=e.getId(t);return r===1?void 0:r}function Kn(t,e){var r;const{needsMask:i,maskTextFn:s,rootId:n}=e,o=t.parentNode&&t.parentNode.tagName;let c=t.textContent;const a=o==="STYLE"?!0:void 0,l=o==="SCRIPT"?!0:void 0;if(a&&c){try{t.nextSibling||t.previousSibling||!((r=t.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(c=er(t.parentNode.sheet))}catch(u){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${u}`,t)}c=tr(c,Xr())}return l&&(c="SCRIPT_PLACEHOLDER"),!a&&!l&&c&&i&&(c=s?s(c,t.parentElement):c.replace(/[\S]/g,"*")),{type:V.Text,textContent:c||"",isStyle:a,rootId:n}}function Yn(t,e){const{doc:r,blockClass:i,blockSelector:s,inlineStylesheet:n,maskInputOptions:o={},maskInputFn:c,dataURLOptions:a={},inlineImages:l,recordCanvas:u,keepIframeSrcFn:f,newlyAddedElement:d=!1,rootId:p}=e,g=Hn(t,i,s),_=Pn(t);let m={};const b=t.attributes.length;for(let v=0;v<b;v++){const S=t.attributes[v];ds(_,S.name,S.value)||(m[S.name]=hs(r,_,Ge(S.name),S.value))}if(_==="link"&&n){const v=Array.from(r.styleSheets).find(k=>k.href===t.href);let S=null;v&&(S=er(v)),S&&(delete m.rel,delete m.href,m._cssText=tr(S,v.href))}if(_==="style"&&t.sheet&&!(t.innerText||t.textContent||"").trim().length){const v=er(t.sheet);v&&(m._cssText=tr(v,Xr()))}if(_==="input"||_==="textarea"||_==="select"){const v=t.value,S=t.checked;m.type!=="radio"&&m.type!=="checkbox"&&m.type!=="submit"&&m.type!=="button"&&v?m.value=Kr({element:t,type:Yr(t),tagName:_,value:v,maskInputOptions:o,maskInputFn:c}):S&&(m.checked=S)}if(_==="option"&&(t.selected&&!o.select?m.selected=!0:delete m.selected),_==="canvas"&&u){if(t.__context==="2d")Mn(t)||(m.rr_dataURL=t.toDataURL(a.type,a.quality));else if(!("__context"in t)){const v=t.toDataURL(a.type,a.quality),S=document.createElement("canvas");S.width=t.width,S.height=t.height;const k=S.toDataURL(a.type,a.quality);v!==k&&(m.rr_dataURL=v)}}if(_==="img"&&l){Xe||(Xe=r.createElement("canvas"),ki=Xe.getContext("2d"));const v=t,S=v.crossOrigin;v.crossOrigin="anonymous";const k=()=>{v.removeEventListener("load",k);try{Xe.width=v.naturalWidth,Xe.height=v.naturalHeight,ki.drawImage(v,0,0),m.rr_dataURL=Xe.toDataURL(a.type,a.quality)}catch(H){console.warn(`Cannot inline img src=${v.currentSrc}! Error: ${H}`)}S?m.crossOrigin=S:v.removeAttribute("crossorigin")};v.complete&&v.naturalWidth!==0?k():v.addEventListener("load",k)}if(_==="audio"||_==="video"){const v=m;v.rr_mediaState=t.paused?"paused":"played",v.rr_mediaCurrentTime=t.currentTime,v.rr_mediaPlaybackRate=t.playbackRate,v.rr_mediaMuted=t.muted,v.rr_mediaLoop=t.loop,v.rr_mediaVolume=t.volume}if(d||(t.scrollLeft&&(m.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(m.rr_scrollTop=t.scrollTop)),g){const{width:v,height:S}=t.getBoundingClientRect();m={class:m.class,rr_width:`${v}px`,rr_height:`${S}px`}}_==="iframe"&&!f(m.src)&&(t.contentDocument||(m.rr_src=m.src),delete m.src);let w;try{customElements.get(_)&&(w=!0)}catch{}return{type:V.Element,tagName:_,attributes:m,childNodes:[],isSVG:zn(t)||void 0,needBlock:g,rootId:p,isCustom:w}}function j(t){return t==null?"":t.toLowerCase()}function Xn(t,e){if(e.comment&&t.type===V.Comment)return!0;if(t.type===V.Element){if(e.script&&(t.tagName==="script"||t.tagName==="link"&&(t.attributes.rel==="preload"||t.attributes.rel==="modulepreload")&&t.attributes.as==="script"||t.tagName==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&ls(t.attributes.href)==="js"))return!0;if(e.headFavicon&&(t.tagName==="link"&&t.attributes.rel==="shortcut icon"||t.tagName==="meta"&&(j(t.attributes.name).match(/^msapplication-tile(image|color)$/)||j(t.attributes.name)==="application-name"||j(t.attributes.rel)==="icon"||j(t.attributes.rel)==="apple-touch-icon"||j(t.attributes.rel)==="shortcut icon")))return!0;if(t.tagName==="meta"){if(e.headMetaDescKeywords&&j(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(j(t.attributes.property).match(/^(og|twitter|fb):/)||j(t.attributes.name).match(/^(og|twitter):/)||j(t.attributes.name)==="pinterest"))return!0;if(e.headMetaRobots&&(j(t.attributes.name)==="robots"||j(t.attributes.name)==="googlebot"||j(t.attributes.name)==="bingbot"))return!0;if(e.headMetaHttpEquiv&&t.attributes["http-equiv"]!==void 0)return!0;if(e.headMetaAuthorship&&(j(t.attributes.name)==="author"||j(t.attributes.name)==="generator"||j(t.attributes.name)==="framework"||j(t.attributes.name)==="publisher"||j(t.attributes.name)==="progid"||j(t.attributes.property).match(/^article:/)||j(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&(j(t.attributes.name)==="google-site-verification"||j(t.attributes.name)==="yandex-verification"||j(t.attributes.name)==="csrf-token"||j(t.attributes.name)==="p:domain_verify"||j(t.attributes.name)==="verify-v1"||j(t.attributes.name)==="verification"||j(t.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function ot(t,e){const{doc:r,mirror:i,blockClass:s,blockSelector:n,maskTextClass:o,maskTextSelector:c,skipChild:a=!1,inlineStylesheet:l=!0,maskInputOptions:u={},maskTextFn:f,maskInputFn:d,slimDOMOptions:p,dataURLOptions:g={},inlineImages:_=!1,recordCanvas:m=!1,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:v=5e3,onStylesheetLoad:S,stylesheetLoadTimeout:k=5e3,keepIframeSrcFn:H=()=>!1,newlyAddedElement:F=!1}=e;let{needsMask:N}=e,{preserveWhiteSpace:L=!0}=e;!N&&t.childNodes&&(N=fs(t,o,c,N===void 0));const X=Jn(t,{doc:r,mirror:i,blockClass:s,blockSelector:n,needsMask:N,inlineStylesheet:l,maskInputOptions:u,maskTextFn:f,maskInputFn:d,dataURLOptions:g,inlineImages:_,recordCanvas:m,keepIframeSrcFn:H,newlyAddedElement:F});if(!X)return console.warn(t,"not serialized"),null;let se;i.hasNode(t)?se=i.getId(t):Xn(X,p)||!L&&X.type===V.Text&&!X.isStyle&&!X.textContent.replace(/^\s+|\s+$/gm,"").length?se=Rt:se=us();const D=Object.assign(X,{id:se});if(i.add(t,D),se===Rt)return null;b&&b(t);let je=!a;if(D.type===V.Element){je=je&&!D.needBlock,delete D.needBlock;const Q=t.shadowRoot;Q&&kt(Q)&&(D.isShadowHost=!0)}if((D.type===V.Document||D.type===V.Element)&&je){p.headWhitespace&&D.type===V.Element&&D.tagName==="head"&&(L=!1);const Q={doc:r,mirror:i,blockClass:s,blockSelector:n,needsMask:N,maskTextClass:o,maskTextSelector:c,skipChild:a,inlineStylesheet:l,maskInputOptions:u,maskTextFn:f,maskInputFn:d,slimDOMOptions:p,dataURLOptions:g,inlineImages:_,recordCanvas:m,preserveWhiteSpace:L,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:v,onStylesheetLoad:S,stylesheetLoadTimeout:k,keepIframeSrcFn:H};if(!(D.type===V.Element&&D.tagName==="textarea"&&D.attributes.value!==void 0))for(const Ie of Array.from(t.childNodes)){const fe=ot(Ie,Q);fe&&D.childNodes.push(fe)}if(En(t)&&t.shadowRoot)for(const Ie of Array.from(t.shadowRoot.childNodes)){const fe=ot(Ie,Q);fe&&(kt(t.shadowRoot)&&(fe.isShadow=!0),D.childNodes.push(fe))}}return t.parentNode&&St(t.parentNode)&&kt(t.parentNode)&&(D.isShadow=!0),D.type===V.Element&&D.tagName==="iframe"&&Wn(t,()=>{const Q=t.contentDocument;if(Q&&w){const Ie=ot(Q,{doc:Q,mirror:i,blockClass:s,blockSelector:n,needsMask:N,maskTextClass:o,maskTextSelector:c,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:f,maskInputFn:d,slimDOMOptions:p,dataURLOptions:g,inlineImages:_,recordCanvas:m,preserveWhiteSpace:L,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:v,onStylesheetLoad:S,stylesheetLoadTimeout:k,keepIframeSrcFn:H});Ie&&w(t,Ie)}},v),D.type===V.Element&&D.tagName==="link"&&typeof D.attributes.rel=="string"&&(D.attributes.rel==="stylesheet"||D.attributes.rel==="preload"&&typeof D.attributes.href=="string"&&ls(D.attributes.href)==="css")&&Gn(t,()=>{if(S){const Q=ot(t,{doc:r,mirror:i,blockClass:s,blockSelector:n,needsMask:N,maskTextClass:o,maskTextSelector:c,skipChild:!1,inlineStylesheet:l,maskInputOptions:u,maskTextFn:f,maskInputFn:d,slimDOMOptions:p,dataURLOptions:g,inlineImages:_,recordCanvas:m,preserveWhiteSpace:L,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:v,onStylesheetLoad:S,stylesheetLoadTimeout:k,keepIframeSrcFn:H});Q&&S(t,Q)}},k),D}function Qn(t,e){const{mirror:r=new cs,blockClass:i="rr-block",blockSelector:s=null,maskTextClass:n="rr-mask",maskTextSelector:o=null,inlineStylesheet:c=!0,inlineImages:a=!1,recordCanvas:l=!1,maskAllInputs:u=!1,maskTextFn:f,maskInputFn:d,slimDOM:p=!1,dataURLOptions:g,preserveWhiteSpace:_,onSerialize:m,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:S,keepIframeSrcFn:k=()=>!1}=e||{};return ot(t,{doc:t,mirror:r,blockClass:i,blockSelector:s,maskTextClass:n,maskTextSelector:o,skipChild:!1,inlineStylesheet:c,maskInputOptions:u===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:u===!1?{password:!0}:u,maskTextFn:f,maskInputFn:d,slimDOMOptions:p===!0||p==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:p==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:p===!1?{}:p,dataURLOptions:g,inlineImages:a,recordCanvas:l,preserveWhiteSpace:_,onSerialize:m,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:S,keepIframeSrcFn:k,newlyAddedElement:!1})}function ee(t,e,r=document){const i={capture:!0,passive:!0};return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}const rt=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;let Ei={map:{},getId(){return console.error(rt),-1},getNode(){return console.error(rt),null},removeNodeFromMap(){console.error(rt)},has(){return console.error(rt),!1},reset(){console.error(rt)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Ei=new Proxy(Ei,{get(t,e,r){return e==="map"&&console.error(rt),Reflect.get(t,e,r)}}));function Mt(t,e,r={}){let i=null,s=0;return function(...n){const o=Date.now();!s&&r.leading===!1&&(s=o);const c=e-(o-s),a=this;c<=0||c>e?(i&&(clearTimeout(i),i=null),s=o,t.apply(a,n)):!i&&r.trailing!==!1&&(i=setTimeout(()=>{s=r.leading===!1?0:Date.now(),i=null,t.apply(a,n)},c))}}function dr(t,e,r,i,s=window){const n=s.Object.getOwnPropertyDescriptor(t,e);return s.Object.defineProperty(t,e,i?r:{set(o){setTimeout(()=>{r.set.call(this,o)},0),n&&n.set&&n.set.call(this,o)}}),()=>dr(t,e,n||{},!0)}function gt(t,e,r){try{if(!(e in t))return()=>{};const i=t[e],s=r(i);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:i}})),t[e]=s,()=>{t[e]=i}}catch{return()=>{}}}let ir=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(ir=()=>new Date().getTime());function ps(t){var e,r,i,s,n,o;const c=t.document;return{left:c.scrollingElement?c.scrollingElement.scrollLeft:t.pageXOffset!==void 0?t.pageXOffset:(c==null?void 0:c.documentElement.scrollLeft)||((r=(e=c==null?void 0:c.body)===null||e===void 0?void 0:e.parentElement)===null||r===void 0?void 0:r.scrollLeft)||((i=c==null?void 0:c.body)===null||i===void 0?void 0:i.scrollLeft)||0,top:c.scrollingElement?c.scrollingElement.scrollTop:t.pageYOffset!==void 0?t.pageYOffset:(c==null?void 0:c.documentElement.scrollTop)||((n=(s=c==null?void 0:c.body)===null||s===void 0?void 0:s.parentElement)===null||n===void 0?void 0:n.scrollTop)||((o=c==null?void 0:c.body)===null||o===void 0?void 0:o.scrollTop)||0}}function _s(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function gs(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function ms(t){return t?t.nodeType===t.ELEMENT_NODE?t:t.parentElement:null}function te(t,e,r,i){if(!t)return!1;const s=ms(t);if(!s)return!1;try{if(typeof e=="string"){if(s.classList.contains(e)||i&&s.closest("."+e)!==null)return!0}else if(rr(s,e,i))return!0}catch{}return!!(r&&(s.matches(r)||i&&s.closest(r)!==null))}function Zn(t,e){return e.getId(t)!==-1}function xr(t,e){return e.getId(t)===Rt}function ys(t,e){if(St(t))return!1;const r=e.getId(t);return e.has(r)?t.parentNode&&t.parentNode.nodeType===t.DOCUMENT_NODE?!1:t.parentNode?ys(t.parentNode,e):!0:!0}function Ur(t){return!!t.changedTouches}function eo(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let r=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function vs(t,e){return!!(t.nodeName==="IFRAME"&&e.getMeta(t))}function bs(t,e){return!!(t.nodeName==="LINK"&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&t.getAttribute("rel")==="stylesheet"&&e.getMeta(t))}function Fr(t){return!!(t!=null&&t.shadowRoot)}class to{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var r;return(r=this.styleIDMap.get(e))!==null&&r!==void 0?r:-1}has(e){return this.styleIDMap.has(e)}add(e,r){if(this.has(e))return this.getId(e);let i;return r===void 0?i=this.id++:i=r,this.styleIDMap.set(e,i),this.idStyleMap.set(i,e),i}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function ws(t){var e,r;let i=null;return((r=(e=t.getRootNode)===null||e===void 0?void 0:e.call(t))===null||r===void 0?void 0:r.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&t.getRootNode().host&&(i=t.getRootNode().host),i}function ro(t){let e=t,r;for(;r=ws(e);)e=r;return e}function io(t){const e=t.ownerDocument;if(!e)return!1;const r=ro(t);return e.contains(r)}function Ss(t){const e=t.ownerDocument;return e?e.contains(t)||io(t):!1}var A=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(A||{}),C=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(C||{}),re=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(re||{}),we=(t=>(t[t.Mouse=0]="Mouse",t[t.Pen=1]="Pen",t[t.Touch=2]="Touch",t))(we||{}),dt=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(dt||{});function Oi(t){return"__ln"in t}class so{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let i=0;i<e;i++)r=(r==null?void 0:r.next)||null;return r}addNode(e){const r={value:e,previous:null,next:null};if(e.__ln=r,e.previousSibling&&Oi(e.previousSibling)){const i=e.previousSibling.__ln.next;r.next=i,r.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=r,i&&(i.previous=r)}else if(e.nextSibling&&Oi(e.nextSibling)&&e.nextSibling.__ln.previous){const i=e.nextSibling.__ln.previous;r.previous=i,r.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=r,i&&(i.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(e){const r=e.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const xi=(t,e)=>`${t}@${e}`;class no{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],r=new Set,i=new so,s=a=>{let l=a,u=Rt;for(;u===Rt;)l=l&&l.nextSibling,u=l&&this.mirror.getId(l);return u},n=a=>{if(!a.parentNode||!Ss(a)||a.parentNode.tagName==="TEXTAREA")return;const l=St(a.parentNode)?this.mirror.getId(ws(a)):this.mirror.getId(a.parentNode),u=s(a);if(l===-1||u===-1)return i.addNode(a);const f=ot(a,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:d=>{vs(d,this.mirror)&&this.iframeManager.addIframe(d),bs(d,this.mirror)&&this.stylesheetManager.trackLinkElement(d),Fr(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(d,p)=>{this.iframeManager.attachIframe(d,p),this.shadowDomManager.observeAttachShadow(d)},onStylesheetLoad:(d,p)=>{this.stylesheetManager.attachLinkElement(d,p)}});f&&(e.push({parentId:l,nextId:u,node:f}),r.add(f.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)Ii(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||n(a);for(const a of this.addedSet)!Ti(this.droppedSet,a)&&!Ii(this.removes,a,this.mirror)||Ti(this.movedSet,a)?n(a):this.droppedSet.add(a);let o=null;for(;i.length;){let a=null;if(o){const l=this.mirror.getId(o.value.parentNode),u=s(o.value);l!==-1&&u!==-1&&(a=o)}if(!a){let l=i.tail;for(;l;){const u=l;if(l=l.previous,u){const f=this.mirror.getId(u.value.parentNode);if(s(u.value)===-1)continue;if(f!==-1){a=u;break}else{const p=u.value;if(p.parentNode&&p.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const g=p.parentNode.host;if(this.mirror.getId(g)!==-1){a=u;break}}}}}}if(!a){for(;i.head;)i.removeNode(i.head.value);break}o=a.previous,i.removeNode(a.value),n(a.value)}const c={texts:this.texts.map(a=>{const l=a.node;return l.parentNode&&l.parentNode.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(l.parentNode),{id:this.mirror.getId(l),value:a.value}}).filter(a=>!r.has(a.id)).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>{const{attributes:l}=a;if(typeof l.style=="string"){const u=JSON.stringify(a.styleDiff),f=JSON.stringify(a._unchangedStyles);u.length<l.style.length&&(u+f).split("var(").length===l.style.split("var(").length&&(l.style=a.styleDiff)}return{id:this.mirror.getId(a.node),attributes:l}}).filter(a=>!r.has(a.id)).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:e};!c.texts.length&&!c.attributes.length&&!c.removes.length&&!c.adds.length||(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(c))},this.genTextAreaValueMutation=e=>{let r=this.attributeMap.get(e);r||(r={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(e,r)),r.attributes.value=Array.from(e.childNodes,i=>i.textContent||"").join("")},this.processMutation=e=>{if(!xr(e.target,this.mirror))switch(e.type){case"characterData":{const r=e.target.textContent;!te(e.target,this.blockClass,this.blockSelector,!1)&&r!==e.oldValue&&this.texts.push({value:fs(e.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,ms(e.target)):r.replace(/[\S]/g,"*"):r,node:e.target});break}case"attributes":{const r=e.target;let i=e.attributeName,s=e.target.getAttribute(i);if(i==="value"){const o=Yr(r);s=Kr({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:o,value:s,maskInputFn:this.maskInputFn})}if(te(e.target,this.blockClass,this.blockSelector,!1)||s===e.oldValue)return;let n=this.attributeMap.get(e.target);if(r.tagName==="IFRAME"&&i==="src"&&!this.keepIframeSrcFn(s))if(!r.contentDocument)i="rr_src";else return;if(n||(n={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(n),this.attributeMap.set(e.target,n)),i==="type"&&r.tagName==="INPUT"&&(e.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!ds(r.tagName,i)&&(n.attributes[i]=hs(this.doc,Ge(r.tagName),Ge(i),s),i==="style")){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const o=this.unattachedDoc.createElement("span");e.oldValue&&o.setAttribute("style",e.oldValue);for(const c of Array.from(r.style)){const a=r.style.getPropertyValue(c),l=r.style.getPropertyPriority(c);a!==o.style.getPropertyValue(c)||l!==o.style.getPropertyPriority(c)?l===""?n.styleDiff[c]=a:n.styleDiff[c]=[a,l]:n._unchangedStyles[c]=[a,l]}for(const c of Array.from(o.style))r.style.getPropertyValue(c)===""&&(n.styleDiff[c]=!1)}break}case"childList":{if(te(e.target,this.blockClass,this.blockSelector,!0))return;if(e.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(e.target);return}e.addedNodes.forEach(r=>this.genAdds(r,e.target)),e.removedNodes.forEach(r=>{const i=this.mirror.getId(r),s=St(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);te(e.target,this.blockClass,this.blockSelector,!1)||xr(r,this.mirror)||!Zn(r,this.mirror)||(this.addedSet.has(r)?(qr(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(e.target)&&i===-1||ys(e.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[xi(i,s)]?qr(this.movedSet,r):this.removes.push({parentId:s,id:i,isShadow:St(e.target)&&kt(e.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(e,r)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!(this.addedSet.has(e)||this.movedSet.has(e))){if(this.mirror.hasNode(e)){if(xr(e,this.mirror))return;this.movedSet.add(e);let i=null;r&&this.mirror.hasNode(r)&&(i=this.mirror.getId(r)),i&&i!==-1&&(this.movedMap[xi(this.mirror.getId(e),i)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);te(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach(i=>this.genAdds(i)),Fr(e)&&e.shadowRoot.childNodes.forEach(i=>{this.processedNodeManager.add(i,this),this.genAdds(i,e)}))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=e[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function qr(t,e){t.delete(e),e.childNodes.forEach(r=>qr(t,r))}function Ii(t,e,r){return t.length===0?!1:ks(t,e,r)}function ks(t,e,r){const{parentNode:i}=e;if(!i)return!1;const s=r.getId(i);return t.some(n=>n.id===s)?!0:ks(t,i,r)}function Ti(t,e){return t.size===0?!1:Es(t,e)}function Es(t,e){const{parentNode:r}=e;return r?t.has(r)?!0:Es(t,r):!1}let Et;function oo(t){Et=t}function ao(){Et=void 0}const M=t=>Et?(...r)=>{try{return t(...r)}catch(i){if(Et&&Et(i)===!0)return;throw i}}:t,We=[];function Lt(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0]}catch{}return t&&t.target}function Os(t,e){var r,i;const s=new no;We.push(s),s.init(t);let n=window.MutationObserver||window.__rrMutationObserver;const o=(i=(r=window==null?void 0:window.Zone)===null||r===void 0?void 0:r.__symbol__)===null||i===void 0?void 0:i.call(r,"MutationObserver");o&&window[o]&&(n=window[o]);const c=new n(M(s.processMutations.bind(s)));return c.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),c}function co({mousemoveCb:t,sampling:e,doc:r,mirror:i}){if(e.mousemove===!1)return()=>{};const s=typeof e.mousemove=="number"?e.mousemove:50,n=typeof e.mousemoveCallback=="number"?e.mousemoveCallback:500;let o=[],c;const a=Mt(M(f=>{const d=Date.now()-c;t(o.map(p=>(p.timeOffset-=d,p)),f),o=[],c=null}),n),l=M(Mt(M(f=>{const d=Lt(f),{clientX:p,clientY:g}=Ur(f)?f.changedTouches[0]:f;c||(c=ir()),o.push({x:p,y:g,id:i.getId(d),timeOffset:ir()-c}),a(typeof DragEvent<"u"&&f instanceof DragEvent?C.Drag:f instanceof MouseEvent?C.MouseMove:C.TouchMove)}),s,{trailing:!1})),u=[ee("mousemove",l,r),ee("touchmove",l,r),ee("drag",l,r)];return M(()=>{u.forEach(f=>f())})}function lo({mouseInteractionCb:t,doc:e,mirror:r,blockClass:i,blockSelector:s,sampling:n}){if(n.mouseInteraction===!1)return()=>{};const o=n.mouseInteraction===!0||n.mouseInteraction===void 0?{}:n.mouseInteraction,c=[];let a=null;const l=u=>f=>{const d=Lt(f);if(te(d,i,s,!0))return;let p=null,g=u;if("pointerType"in f){switch(f.pointerType){case"mouse":p=we.Mouse;break;case"touch":p=we.Touch;break;case"pen":p=we.Pen;break}p===we.Touch?re[u]===re.MouseDown?g="TouchStart":re[u]===re.MouseUp&&(g="TouchEnd"):we.Pen}else Ur(f)&&(p=we.Touch);p!==null?(a=p,(g.startsWith("Touch")&&p===we.Touch||g.startsWith("Mouse")&&p===we.Mouse)&&(p=null)):re[u]===re.Click&&(p=a,a=null);const _=Ur(f)?f.changedTouches[0]:f;if(!_)return;const m=r.getId(d),{clientX:b,clientY:w}=_;M(t)(Object.assign({type:re[g],id:m,x:b,y:w},p!==null&&{pointerType:p}))};return Object.keys(re).filter(u=>Number.isNaN(Number(u))&&!u.endsWith("_Departed")&&o[u]!==!1).forEach(u=>{let f=Ge(u);const d=l(u);if(window.PointerEvent)switch(re[u]){case re.MouseDown:case re.MouseUp:f=f.replace("mouse","pointer");break;case re.TouchStart:case re.TouchEnd:return}c.push(ee(f,d,e))}),M(()=>{c.forEach(u=>u())})}function xs({scrollCb:t,doc:e,mirror:r,blockClass:i,blockSelector:s,sampling:n}){const o=M(Mt(M(c=>{const a=Lt(c);if(!a||te(a,i,s,!0))return;const l=r.getId(a);if(a===e&&e.defaultView){const u=ps(e.defaultView);t({id:l,x:u.left,y:u.top})}else t({id:l,x:a.scrollLeft,y:a.scrollTop})}),n.scroll||100));return ee("scroll",o,e)}function uo({viewportResizeCb:t},{win:e}){let r=-1,i=-1;const s=M(Mt(M(()=>{const n=_s(),o=gs();(r!==n||i!==o)&&(t({width:Number(o),height:Number(n)}),r=n,i=o)}),200));return ee("resize",s,e)}const ho=["INPUT","TEXTAREA","SELECT"],Ci=new WeakMap;function fo({inputCb:t,doc:e,mirror:r,blockClass:i,blockSelector:s,ignoreClass:n,ignoreSelector:o,maskInputOptions:c,maskInputFn:a,sampling:l,userTriggeredOnInput:u}){function f(w){let v=Lt(w);const S=w.isTrusted,k=v&&v.tagName;if(v&&k==="OPTION"&&(v=v.parentElement),!v||!k||ho.indexOf(k)<0||te(v,i,s,!0)||v.classList.contains(n)||o&&v.matches(o))return;let H=v.value,F=!1;const N=Yr(v)||"";N==="radio"||N==="checkbox"?F=v.checked:(c[k.toLowerCase()]||c[N])&&(H=Kr({element:v,maskInputOptions:c,tagName:k,type:N,value:H,maskInputFn:a})),d(v,u?{text:H,isChecked:F,userTriggered:S}:{text:H,isChecked:F});const L=v.name;N==="radio"&&L&&F&&e.querySelectorAll(`input[type="radio"][name="${L}"]`).forEach(X=>{if(X!==v){const se=X.value;d(X,u?{text:se,isChecked:!F,userTriggered:!1}:{text:se,isChecked:!F})}})}function d(w,v){const S=Ci.get(w);if(!S||S.text!==v.text||S.isChecked!==v.isChecked){Ci.set(w,v);const k=r.getId(w);M(t)(Object.assign(Object.assign({},v),{id:k}))}}const g=(l.input==="last"?["change"]:["input","change"]).map(w=>ee(w,M(f),e)),_=e.defaultView;if(!_)return()=>{g.forEach(w=>w())};const m=_.Object.getOwnPropertyDescriptor(_.HTMLInputElement.prototype,"value"),b=[[_.HTMLInputElement.prototype,"value"],[_.HTMLInputElement.prototype,"checked"],[_.HTMLSelectElement.prototype,"value"],[_.HTMLTextAreaElement.prototype,"value"],[_.HTMLSelectElement.prototype,"selectedIndex"],[_.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&g.push(...b.map(w=>dr(w[0],w[1],{set(){M(f)({target:this,isTrusted:!1})}},!1,_))),M(()=>{g.forEach(w=>w())})}function sr(t){const e=[];function r(i,s){if(zt("CSSGroupingRule")&&i.parentRule instanceof CSSGroupingRule||zt("CSSMediaRule")&&i.parentRule instanceof CSSMediaRule||zt("CSSSupportsRule")&&i.parentRule instanceof CSSSupportsRule||zt("CSSConditionRule")&&i.parentRule instanceof CSSConditionRule){const o=Array.from(i.parentRule.cssRules).indexOf(i);s.unshift(o)}else if(i.parentStyleSheet){const o=Array.from(i.parentStyleSheet.cssRules).indexOf(i);s.unshift(o)}return s}return r(t,e)}function Ce(t,e,r){let i,s;return t?(t.ownerNode?i=e.getId(t.ownerNode):s=r.getId(t),{styleId:s,id:i}):{}}function po({styleSheetRuleCb:t,mirror:e,stylesheetManager:r},{win:i}){if(!i.CSSStyleSheet||!i.CSSStyleSheet.prototype)return()=>{};const s=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=new Proxy(s,{apply:M((u,f,d)=>{const[p,g]=d,{id:_,styleId:m}=Ce(f,e,r.styleMirror);return(_&&_!==-1||m&&m!==-1)&&t({id:_,styleId:m,adds:[{rule:p,index:g}]}),u.apply(f,d)})});const n=i.CSSStyleSheet.prototype.deleteRule;i.CSSStyleSheet.prototype.deleteRule=new Proxy(n,{apply:M((u,f,d)=>{const[p]=d,{id:g,styleId:_}=Ce(f,e,r.styleMirror);return(g&&g!==-1||_&&_!==-1)&&t({id:g,styleId:_,removes:[{index:p}]}),u.apply(f,d)})});let o;i.CSSStyleSheet.prototype.replace&&(o=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=new Proxy(o,{apply:M((u,f,d)=>{const[p]=d,{id:g,styleId:_}=Ce(f,e,r.styleMirror);return(g&&g!==-1||_&&_!==-1)&&t({id:g,styleId:_,replace:p}),u.apply(f,d)})}));let c;i.CSSStyleSheet.prototype.replaceSync&&(c=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=new Proxy(c,{apply:M((u,f,d)=>{const[p]=d,{id:g,styleId:_}=Ce(f,e,r.styleMirror);return(g&&g!==-1||_&&_!==-1)&&t({id:g,styleId:_,replaceSync:p}),u.apply(f,d)})}));const a={};Ht("CSSGroupingRule")?a.CSSGroupingRule=i.CSSGroupingRule:(Ht("CSSMediaRule")&&(a.CSSMediaRule=i.CSSMediaRule),Ht("CSSConditionRule")&&(a.CSSConditionRule=i.CSSConditionRule),Ht("CSSSupportsRule")&&(a.CSSSupportsRule=i.CSSSupportsRule));const l={};return Object.entries(a).forEach(([u,f])=>{l[u]={insertRule:f.prototype.insertRule,deleteRule:f.prototype.deleteRule},f.prototype.insertRule=new Proxy(l[u].insertRule,{apply:M((d,p,g)=>{const[_,m]=g,{id:b,styleId:w}=Ce(p.parentStyleSheet,e,r.styleMirror);return(b&&b!==-1||w&&w!==-1)&&t({id:b,styleId:w,adds:[{rule:_,index:[...sr(p),m||0]}]}),d.apply(p,g)})}),f.prototype.deleteRule=new Proxy(l[u].deleteRule,{apply:M((d,p,g)=>{const[_]=g,{id:m,styleId:b}=Ce(p.parentStyleSheet,e,r.styleMirror);return(m&&m!==-1||b&&b!==-1)&&t({id:m,styleId:b,removes:[{index:[...sr(p),_]}]}),d.apply(p,g)})})}),M(()=>{i.CSSStyleSheet.prototype.insertRule=s,i.CSSStyleSheet.prototype.deleteRule=n,o&&(i.CSSStyleSheet.prototype.replace=o),c&&(i.CSSStyleSheet.prototype.replaceSync=c),Object.entries(a).forEach(([u,f])=>{f.prototype.insertRule=l[u].insertRule,f.prototype.deleteRule=l[u].deleteRule})})}function Is({mirror:t,stylesheetManager:e},r){var i,s,n;let o=null;r.nodeName==="#document"?o=t.getId(r):o=t.getId(r.host);const c=r.nodeName==="#document"?(i=r.defaultView)===null||i===void 0?void 0:i.Document:(n=(s=r.ownerDocument)===null||s===void 0?void 0:s.defaultView)===null||n===void 0?void 0:n.ShadowRoot,a=c!=null&&c.prototype?Object.getOwnPropertyDescriptor(c==null?void 0:c.prototype,"adoptedStyleSheets"):void 0;return o===null||o===-1||!c||!a?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var l;return(l=a.get)===null||l===void 0?void 0:l.call(this)},set(l){var u;const f=(u=a.set)===null||u===void 0?void 0:u.call(this,l);if(o!==null&&o!==-1)try{e.adoptStyleSheets(l,o)}catch{}return f}}),M(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})}))}function _o({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:r,stylesheetManager:i},{win:s}){const n=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(n,{apply:M((c,a,l)=>{var u;const[f,d,p]=l;if(r.has(f))return n.apply(a,[f,d,p]);const{id:g,styleId:_}=Ce((u=a.parentRule)===null||u===void 0?void 0:u.parentStyleSheet,e,i.styleMirror);return(g&&g!==-1||_&&_!==-1)&&t({id:g,styleId:_,set:{property:f,value:d,priority:p},index:sr(a.parentRule)}),c.apply(a,l)})});const o=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(o,{apply:M((c,a,l)=>{var u;const[f]=l;if(r.has(f))return o.apply(a,[f]);const{id:d,styleId:p}=Ce((u=a.parentRule)===null||u===void 0?void 0:u.parentStyleSheet,e,i.styleMirror);return(d&&d!==-1||p&&p!==-1)&&t({id:d,styleId:p,remove:{property:f},index:sr(a.parentRule)}),c.apply(a,l)})}),M(()=>{s.CSSStyleDeclaration.prototype.setProperty=n,s.CSSStyleDeclaration.prototype.removeProperty=o})}function go({mediaInteractionCb:t,blockClass:e,blockSelector:r,mirror:i,sampling:s,doc:n}){const o=M(a=>Mt(M(l=>{const u=Lt(l);if(!u||te(u,e,r,!0))return;const{currentTime:f,volume:d,muted:p,playbackRate:g,loop:_}=u;t({type:a,id:i.getId(u),currentTime:f,volume:d,muted:p,playbackRate:g,loop:_})}),s.media||500)),c=[ee("play",o(0),n),ee("pause",o(1),n),ee("seeked",o(2),n),ee("volumechange",o(3),n),ee("ratechange",o(4),n)];return M(()=>{c.forEach(a=>a())})}function mo({fontCb:t,doc:e}){const r=e.defaultView;if(!r)return()=>{};const i=[],s=new WeakMap,n=r.FontFace;r.FontFace=function(a,l,u){const f=new n(a,l,u);return s.set(f,{family:a,buffer:typeof l!="string",descriptors:u,fontSource:typeof l=="string"?l:JSON.stringify(Array.from(new Uint8Array(l)))}),f};const o=gt(e.fonts,"add",function(c){return function(a){return setTimeout(M(()=>{const l=s.get(a);l&&(t(l),s.delete(a))}),0),c.apply(this,[a])}});return i.push(()=>{r.FontFace=n}),i.push(o),M(()=>{i.forEach(c=>c())})}function yo(t){const{doc:e,mirror:r,blockClass:i,blockSelector:s,selectionCb:n}=t;let o=!0;const c=M(()=>{const a=e.getSelection();if(!a||o&&(a!=null&&a.isCollapsed))return;o=a.isCollapsed||!1;const l=[],u=a.rangeCount||0;for(let f=0;f<u;f++){const d=a.getRangeAt(f),{startContainer:p,startOffset:g,endContainer:_,endOffset:m}=d;te(p,i,s,!0)||te(_,i,s,!0)||l.push({start:r.getId(p),startOffset:g,end:r.getId(_),endOffset:m})}n({ranges:l})});return c(),ee("selectionchange",c)}function vo({doc:t,customElementCb:e}){const r=t.defaultView;return!r||!r.customElements?()=>{}:gt(r.customElements,"define",function(s){return function(n,o,c){try{e({define:{name:n}})}catch{console.warn(`Custom element callback failed for ${n}`)}return s.apply(this,[n,o,c])}})}function bo(t,e){const{mutationCb:r,mousemoveCb:i,mouseInteractionCb:s,scrollCb:n,viewportResizeCb:o,inputCb:c,mediaInteractionCb:a,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:f,fontCb:d,selectionCb:p,customElementCb:g}=t;t.mutationCb=(..._)=>{e.mutation&&e.mutation(..._),r(..._)},t.mousemoveCb=(..._)=>{e.mousemove&&e.mousemove(..._),i(..._)},t.mouseInteractionCb=(..._)=>{e.mouseInteraction&&e.mouseInteraction(..._),s(..._)},t.scrollCb=(..._)=>{e.scroll&&e.scroll(..._),n(..._)},t.viewportResizeCb=(..._)=>{e.viewportResize&&e.viewportResize(..._),o(..._)},t.inputCb=(..._)=>{e.input&&e.input(..._),c(..._)},t.mediaInteractionCb=(..._)=>{e.mediaInteaction&&e.mediaInteaction(..._),a(..._)},t.styleSheetRuleCb=(..._)=>{e.styleSheetRule&&e.styleSheetRule(..._),l(..._)},t.styleDeclarationCb=(..._)=>{e.styleDeclaration&&e.styleDeclaration(..._),u(..._)},t.canvasMutationCb=(..._)=>{e.canvasMutation&&e.canvasMutation(..._),f(..._)},t.fontCb=(..._)=>{e.font&&e.font(..._),d(..._)},t.selectionCb=(..._)=>{e.selection&&e.selection(..._),p(..._)},t.customElementCb=(..._)=>{e.customElement&&e.customElement(..._),g(..._)}}function wo(t,e={}){const r=t.doc.defaultView;if(!r)return()=>{};bo(t,e);let i;t.recordDOM&&(i=Os(t,t.doc));const s=co(t),n=lo(t),o=xs(t),c=uo(t,{win:r}),a=fo(t),l=go(t);let u=()=>{},f=()=>{},d=()=>{},p=()=>{};t.recordDOM&&(u=po(t,{win:r}),f=Is(t,t.doc),d=_o(t,{win:r}),t.collectFonts&&(p=mo(t)));const g=yo(t),_=vo(t),m=[];for(const b of t.plugins)m.push(b.observer(b.callback,r,b.options));return M(()=>{We.forEach(b=>b.reset()),i==null||i.disconnect(),s(),n(),o(),c(),a(),l(),u(),f(),d(),p(),g(),_(),m.forEach(b=>b())})}function zt(t){return typeof window[t]<"u"}function Ht(t){return!!(typeof window[t]<"u"&&window[t].prototype&&"insertRule"in window[t].prototype&&"deleteRule"in window[t].prototype)}class Ri{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,r,i,s){const n=i||this.getIdToRemoteIdMap(e),o=s||this.getRemoteIdToIdMap(e);let c=n.get(r);return c||(c=this.generateIdFn(),n.set(r,c),o.set(c,r)),c}getIds(e,r){const i=this.getIdToRemoteIdMap(e),s=this.getRemoteIdToIdMap(e);return r.map(n=>this.getId(e,n,i,s))}getRemoteId(e,r,i){const s=i||this.getRemoteIdToIdMap(e);if(typeof r!="number")return r;const n=s.get(r);return n||-1}getRemoteIds(e,r){const i=this.getRemoteIdToIdMap(e);return r.map(s=>this.getRemoteId(e,s,i))}reset(e){if(!e){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let r=this.iframeIdToRemoteIdMap.get(e);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(e,r)),r}getRemoteIdToIdMap(e){let r=this.iframeRemoteIdToIdMap.get(e);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(e,r)),r}}class So{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Ri(us),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ri(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,r){var i;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(i=this.loadListener)===null||i===void 0||i.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const r=e;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!e.source)return;const s=this.crossOriginIframeMap.get(e.source);if(!s)return;const n=this.transformCrossOriginEvent(s,r.data.event);n&&this.wrappedEmit(n,r.data.isCheckout)}transformCrossOriginEvent(e,r){var i;switch(r.type){case A.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(r.data.node,e);const s=r.data.node.id;return this.crossOriginIframeRootIdMap.set(e,s),this.patchRootIdOnNode(r.data.node,s),{timestamp:r.timestamp,type:A.IncrementalSnapshot,data:{source:C.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case A.Meta:case A.Load:case A.DomContentLoaded:return!1;case A.Plugin:return r;case A.Custom:return this.replaceIds(r.data.payload,e,["id","parentId","previousId","nextId"]),r;case A.IncrementalSnapshot:switch(r.data.source){case C.Mutation:return r.data.adds.forEach(s=>{this.replaceIds(s,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(s.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(s.node,n)}),r.data.removes.forEach(s=>{this.replaceIds(s,e,["parentId","id"])}),r.data.attributes.forEach(s=>{this.replaceIds(s,e,["id"])}),r.data.texts.forEach(s=>{this.replaceIds(s,e,["id"])}),r;case C.Drag:case C.TouchMove:case C.MouseMove:return r.data.positions.forEach(s=>{this.replaceIds(s,e,["id"])}),r;case C.ViewportResize:return!1;case C.MediaInteraction:case C.MouseInteraction:case C.Scroll:case C.CanvasMutation:case C.Input:return this.replaceIds(r.data,e,["id"]),r;case C.StyleSheetRule:case C.StyleDeclaration:return this.replaceIds(r.data,e,["id"]),this.replaceStyleIds(r.data,e,["styleId"]),r;case C.Font:return r;case C.Selection:return r.data.ranges.forEach(s=>{this.replaceIds(s,e,["start","end"])}),r;case C.AdoptedStyleSheet:return this.replaceIds(r.data,e,["id"]),this.replaceStyleIds(r.data,e,["styleIds"]),(i=r.data.styles)===null||i===void 0||i.forEach(s=>{this.replaceStyleIds(s,e,["styleId"])}),r}}return!1}replace(e,r,i,s){for(const n of s)!Array.isArray(r[n])&&typeof r[n]!="number"||(Array.isArray(r[n])?r[n]=e.getIds(i,r[n]):r[n]=e.getId(i,r[n]));return r}replaceIds(e,r,i){return this.replace(this.crossOriginIframeMirror,e,r,i)}replaceStyleIds(e,r,i){return this.replace(this.crossOriginIframeStyleMirror,e,r,i)}replaceIdOnNode(e,r){this.replaceIds(e,r,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(i=>{this.replaceIdOnNode(i,r)})}patchRootIdOnNode(e,r){e.type!==V.Document&&!e.rootId&&(e.rootId=r),"childNodes"in e&&e.childNodes.forEach(i=>{this.patchRootIdOnNode(i,r)})}}class ko{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,r){if(!kt(e)||this.shadowDoms.has(e))return;this.shadowDoms.add(e);const i=Os(Object.assign(Object.assign({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push(()=>i.disconnect()),this.restoreHandlers.push(xs(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(Is({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){!e.contentWindow||!e.contentDocument||this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,r){const i=this;this.restoreHandlers.push(gt(e.prototype,"attachShadow",function(s){return function(n){const o=s.call(this,n);return this.shadowRoot&&Ss(this)&&i.addShadowRoot(this.shadowRoot,r),o}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function Eo(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r}function Oo(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})}var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Wt=0;Wt<at.length;Wt++)xo[at.charCodeAt(Wt)]=Wt;var Io=function(t){var e=new Uint8Array(t),r,i=e.length,s="";for(r=0;r<i;r+=3)s+=at[e[r]>>2],s+=at[(e[r]&3)<<4|e[r+1]>>4],s+=at[(e[r+1]&15)<<2|e[r+2]>>6],s+=at[e[r+2]&63];return i%3===2?s=s.substring(0,s.length-1)+"=":i%3===1&&(s=s.substring(0,s.length-2)+"=="),s};const Mi=new Map;function To(t,e){let r=Mi.get(t);return r||(r=new Map,Mi.set(t,r)),r.has(e)||r.set(e,[]),r.get(e)}const Ts=(t,e,r)=>{if(!t||!(Rs(t,e)||typeof t=="object"))return;const i=t.constructor.name,s=To(r,i);let n=s.indexOf(t);return n===-1&&(n=s.length,s.push(t)),n};function Xt(t,e,r){if(t instanceof Array)return t.map(i=>Xt(i,e,r));if(t===null)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){const i=t.constructor.name,s=Io(t);return{rr_type:i,base64:s}}else{if(t instanceof DataView)return{rr_type:t.constructor.name,args:[Xt(t.buffer,e,r),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){const i=t.constructor.name,{src:s}=t;return{rr_type:i,src:s}}else if(t instanceof HTMLCanvasElement){const i="HTMLImageElement",s=t.toDataURL();return{rr_type:i,src:s}}else{if(t instanceof ImageData)return{rr_type:t.constructor.name,args:[Xt(t.data,e,r),t.width,t.height]};if(Rs(t,e)||typeof t=="object"){const i=t.constructor.name,s=Ts(t,e,r);return{rr_type:i,index:s}}}}return t}const Cs=(t,e,r)=>t.map(i=>Xt(i,e,r)),Rs=(t,e)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof e[s]=="function").find(s=>t instanceof e[s]);function Co(t,e,r,i){const s=[],n=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(const o of n)try{if(typeof e.CanvasRenderingContext2D.prototype[o]!="function")continue;const c=gt(e.CanvasRenderingContext2D.prototype,o,function(a){return function(...l){return te(this.canvas,r,i,!0)||setTimeout(()=>{const u=Cs(l,e,this);t(this.canvas,{type:dt["2D"],property:o,args:u})},0),a.apply(this,l)}});s.push(c)}catch{const a=dr(e.CanvasRenderingContext2D.prototype,o,{set(l){t(this.canvas,{type:dt["2D"],property:o,args:[l],setter:!0})}});s.push(a)}return()=>{s.forEach(o=>o())}}function Ro(t){return t==="experimental-webgl"?"webgl":t}function Ai(t,e,r,i){const s=[];try{const n=gt(t.HTMLCanvasElement.prototype,"getContext",function(o){return function(c,...a){if(!te(this,e,r,!0)){const l=Ro(c);if("__context"in this||(this.__context=l),i&&["webgl","webgl2"].includes(l))if(a[0]&&typeof a[0]=="object"){const u=a[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0)}else a.splice(0,1,{preserveDrawingBuffer:!0})}return o.apply(this,[c,...a])}});s.push(n)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{s.forEach(n=>n())}}function Di(t,e,r,i,s,n,o){const c=[],a=Object.getOwnPropertyNames(t);for(const l of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if(typeof t[l]!="function")continue;const u=gt(t,l,function(f){return function(...d){const p=f.apply(this,d);if(Ts(p,o,this),"tagName"in this.canvas&&!te(this.canvas,i,s,!0)){const g=Cs(d,o,this),_={type:e,property:l,args:g};r(this.canvas,_)}return p}});c.push(u)}catch{const f=dr(t,l,{set(d){r(this.canvas,{type:e,property:l,args:[d],setter:!0})}});c.push(f)}return c}function Mo(t,e,r,i,s){const n=[];return n.push(...Di(e.WebGLRenderingContext.prototype,dt.WebGL,t,r,i,s,e)),typeof e.WebGL2RenderingContext<"u"&&n.push(...Di(e.WebGL2RenderingContext.prototype,dt.WebGL2,t,r,i,s,e)),()=>{n.forEach(o=>o())}}function Ao(t,e){var r=e===void 0?null:e,i=t.toString(),s=i.split(`
`);s.pop(),s.shift();for(var n=s[0].search(/\S/),o=/(['"])__worker_loader_strict__(['"])/g,c=0,a=s.length;c<a;++c)s[c]=s[c].substring(n).replace(o,"$1use strict$2")+`
`;return r&&s.push("//# sourceMappingURL="+r+`
`),s}function Do(t,e){var r=Ao(t,e),i=new Blob(r,{type:"application/javascript"});return URL.createObjectURL(i)}function Po(t,e){var r;return function(s){return r=r||Do(t,e),new Worker(r,s)}}var No=Po(function(){(function(){"__worker_loader_strict__";/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */function t(l,u,f,d){function p(g){return g instanceof f?g:new f(function(_){_(g)})}return new(f||(f=Promise))(function(g,_){function m(v){try{w(d.next(v))}catch(S){_(S)}}function b(v){try{w(d.throw(v))}catch(S){_(S)}}function w(v){v.done?g(v.value):p(v.value).then(m,b)}w((d=d.apply(l,u||[])).next())})}for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=typeof Uint8Array>"u"?[]:new Uint8Array(256),i=0;i<e.length;i++)r[e.charCodeAt(i)]=i;var s=function(l){var u=new Uint8Array(l),f,d=u.length,p="";for(f=0;f<d;f+=3)p+=e[u[f]>>2],p+=e[(u[f]&3)<<4|u[f+1]>>4],p+=e[(u[f+1]&15)<<2|u[f+2]>>6],p+=e[u[f+2]&63];return d%3===2?p=p.substring(0,p.length-1)+"=":d%3===1&&(p=p.substring(0,p.length-2)+"=="),p};const n=new Map,o=new Map;function c(l,u,f){return t(this,void 0,void 0,function*(){const d=`${l}-${u}`;if("OffscreenCanvas"in globalThis){if(o.has(d))return o.get(d);const p=new OffscreenCanvas(l,u);p.getContext("2d");const _=yield(yield p.convertToBlob(f)).arrayBuffer(),m=s(_);return o.set(d,m),m}else return""})}const a=self;a.onmessage=function(l){return t(this,void 0,void 0,function*(){if("OffscreenCanvas"in globalThis){const{id:u,bitmap:f,width:d,height:p,dataURLOptions:g}=l.data,_=c(d,p,g),m=new OffscreenCanvas(d,p);m.getContext("2d").drawImage(f,0,0),f.close();const w=yield m.convertToBlob(g),v=w.type,S=yield w.arrayBuffer(),k=s(S);if(!n.has(u)&&(yield _)===k)return n.set(u,k),a.postMessage({id:u});if(n.get(u)===k)return a.postMessage({id:u});a.postMessage({id:u,type:v,base64:k,width:d,height:p}),n.set(u,k)}else return a.postMessage({id:l.data.id})})}})()},null);class Lo{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(a,l)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(a)||this.pendingCanvasMutations.set(a,[]),this.pendingCanvasMutations.get(a).push(l)};const{sampling:r="all",win:i,blockClass:s,blockSelector:n,recordCanvas:o,dataURLOptions:c}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&r==="all"&&this.initCanvasMutationObserver(i,s,n),o&&typeof r=="number"&&this.initCanvasFPSObserver(r,i,s,n,{dataURLOptions:c})}initCanvasFPSObserver(e,r,i,s,n){const o=Ai(r,i,s,!0),c=new Map,a=new No;a.onmessage=g=>{const{id:_}=g.data;if(c.set(_,!1),!("base64"in g.data))return;const{base64:m,type:b,width:w,height:v}=g.data;this.mutationCb({id:_,type:dt["2D"],commands:[{property:"clearRect",args:[0,0,w,v]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:m}],type:b}]},0,0]}]})};const l=1e3/e;let u=0,f;const d=()=>{const g=[];return r.document.querySelectorAll("canvas").forEach(_=>{te(_,i,s,!0)||g.push(_)}),g},p=g=>{if(u&&g-u<l){f=requestAnimationFrame(p);return}u=g,d().forEach(_=>Oo(this,void 0,void 0,function*(){var m;const b=this.mirror.getId(_);if(c.get(b)||_.width===0||_.height===0)return;if(c.set(b,!0),["webgl","webgl2"].includes(_.__context)){const v=_.getContext(_.__context);((m=v==null?void 0:v.getContextAttributes())===null||m===void 0?void 0:m.preserveDrawingBuffer)===!1&&v.clear(v.COLOR_BUFFER_BIT)}const w=yield createImageBitmap(_);a.postMessage({id:b,bitmap:w,width:_.width,height:_.height,dataURLOptions:n.dataURLOptions},[w])})),f=requestAnimationFrame(p)};f=requestAnimationFrame(p),this.resetObservers=()=>{o(),cancelAnimationFrame(f)}}initCanvasMutationObserver(e,r,i){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=Ai(e,r,i,!1),n=Co(this.processMutation.bind(this),e,r,i),o=Mo(this.processMutation.bind(this),e,r,i,this.mirror);this.resetObservers=()=>{s(),n(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=r=>{this.rafStamps.latestId=r,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,r)=>{const i=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,i)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,r){if(this.frozen||this.locked)return;const i=this.pendingCanvasMutations.get(e);if(!i||r===-1)return;const s=i.map(o=>Eo(o,["type"])),{type:n}=i[0];this.mutationCb({id:r,type:n,commands:s}),this.pendingCanvasMutations.delete(e)}}class $o{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new to,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,r){if(e.length===0)return;const i={id:r,styleIds:[]},s=[];for(const n of e){let o;this.styleMirror.has(n)?o=this.styleMirror.getId(n):(o=this.styleMirror.add(n),s.push({styleId:o,rules:Array.from(n.rules||CSSRule,(c,a)=>({rule:as(c),index:a}))})),i.styleIds.push(o)}s.length>0&&(i.styles=s),this.adoptedStyleSheetCb(i)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}class jo{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(e,r){const i=this.nodeMap.get(e);return i&&Array.from(i).some(s=>s!==r)}add(e,r){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(r))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function J(t){return Object.assign(Object.assign({},t),{timestamp:ir()})}let W,Qt,Ir,nr=!1;const ce=Rn();function $t(t={}){const{emit:e,checkoutEveryNms:r,checkoutEveryNth:i,blockClass:s="rr-block",blockSelector:n=null,ignoreClass:o="rr-ignore",ignoreSelector:c=null,maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:f,maskInputOptions:d,slimDOMOptions:p,maskInputFn:g,maskTextFn:_,hooks:m,packFn:b,sampling:w={},dataURLOptions:v={},mousemoveWait:S,recordDOM:k=!0,recordCanvas:H=!1,recordCrossOriginIframes:F=!1,recordAfter:N=t.recordAfter==="DOMContentLoaded"?t.recordAfter:"load",userTriggeredOnInput:L=!1,collectFonts:X=!1,inlineImages:se=!1,plugins:D,keepIframeSrcFn:je=()=>!1,ignoreCSSAttributes:Q=new Set([]),errorHandler:Ie}=t;oo(Ie);const fe=F?window.parent===window:!0;let Ft=!1;if(!fe)try{window.parent.document&&(Ft=!1)}catch{Ft=!0}if(fe&&!e)throw new Error("emit function is required");S!==void 0&&w.mousemove===void 0&&(w.mousemove=S),ce.reset();const vr=f===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:d!==void 0?d:{password:!0},br=p===!0||p==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:p==="all",headMetaDescKeywords:p==="all"}:p||{};eo();let yi,wr=0;const vi=x=>{for(const ae of D||[])ae.eventProcessor&&(x=ae.eventProcessor(x));return b&&!Ft&&(x=b(x)),x};W=(x,ae)=>{var z;if(!((z=We[0])===null||z===void 0)&&z.isFrozen()&&x.type!==A.FullSnapshot&&!(x.type===A.IncrementalSnapshot&&x.data.source===C.Mutation)&&We.forEach(Z=>Z.unfreeze()),fe)e==null||e(vi(x),ae);else if(Ft){const Z={type:"rrweb",event:vi(x),origin:window.location.origin,isCheckout:ae};window.parent.postMessage(Z,"*")}if(x.type===A.FullSnapshot)yi=x,wr=0;else if(x.type===A.IncrementalSnapshot){if(x.data.source===C.Mutation&&x.data.isAttachIframe)return;wr++;const Z=i&&wr>=i,qe=r&&x.timestamp-yi.timestamp>r;(Z||qe)&&Qt(!0)}};const qt=x=>{W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.Mutation},x)}))},bi=x=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.Scroll},x)})),wi=x=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.CanvasMutation},x)})),ln=x=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.AdoptedStyleSheet},x)})),Ue=new $o({mutationCb:qt,adoptedStyleSheetCb:ln}),Fe=new So({mirror:ce,mutationCb:qt,stylesheetManager:Ue,recordCrossOriginIframes:F,wrappedEmit:W});for(const x of D||[])x.getMirror&&x.getMirror({nodeMirror:ce,crossOriginIframeMirror:Fe.crossOriginIframeMirror,crossOriginIframeStyleMirror:Fe.crossOriginIframeStyleMirror});const Sr=new jo;Ir=new Lo({recordCanvas:H,mutationCb:wi,win:window,blockClass:s,blockSelector:n,mirror:ce,sampling:w.canvas,dataURLOptions:v});const Bt=new ko({mutationCb:qt,scrollCb:bi,bypassOptions:{blockClass:s,blockSelector:n,maskTextClass:a,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:vr,dataURLOptions:v,maskTextFn:_,maskInputFn:g,recordCanvas:H,inlineImages:se,sampling:w,slimDOMOptions:br,iframeManager:Fe,stylesheetManager:Ue,canvasManager:Ir,keepIframeSrcFn:je,processedNodeManager:Sr},mirror:ce});Qt=(x=!1)=>{if(!k)return;W(J({type:A.Meta,data:{href:window.location.href,width:gs(),height:_s()}}),x),Ue.reset(),Bt.init(),We.forEach(z=>z.lock());const ae=Qn(document,{mirror:ce,blockClass:s,blockSelector:n,maskTextClass:a,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:vr,maskTextFn:_,slimDOM:br,dataURLOptions:v,recordCanvas:H,inlineImages:se,onSerialize:z=>{vs(z,ce)&&Fe.addIframe(z),bs(z,ce)&&Ue.trackLinkElement(z),Fr(z)&&Bt.addShadowRoot(z.shadowRoot,document)},onIframeLoad:(z,Z)=>{Fe.attachIframe(z,Z),Bt.observeAttachShadow(z)},onStylesheetLoad:(z,Z)=>{Ue.attachLinkElement(z,Z)},keepIframeSrcFn:je});if(!ae)return console.warn("Failed to snapshot the document");W(J({type:A.FullSnapshot,data:{node:ae,initialOffset:ps(window)}}),x),We.forEach(z=>z.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Ue.adoptStyleSheets(document.adoptedStyleSheets,ce.getId(document))};try{const x=[],ae=Z=>{var qe;return M(wo)({mutationCb:qt,mousemoveCb:(q,kr)=>W(J({type:A.IncrementalSnapshot,data:{source:kr,positions:q}})),mouseInteractionCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.MouseInteraction},q)})),scrollCb:bi,viewportResizeCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.ViewportResize},q)})),inputCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.Input},q)})),mediaInteractionCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.MediaInteraction},q)})),styleSheetRuleCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.StyleSheetRule},q)})),styleDeclarationCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.StyleDeclaration},q)})),canvasMutationCb:wi,fontCb:q=>W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.Font},q)})),selectionCb:q=>{W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.Selection},q)}))},customElementCb:q=>{W(J({type:A.IncrementalSnapshot,data:Object.assign({source:C.CustomElement},q)}))},blockClass:s,ignoreClass:o,ignoreSelector:c,maskTextClass:a,maskTextSelector:l,maskInputOptions:vr,inlineStylesheet:u,sampling:w,recordDOM:k,recordCanvas:H,inlineImages:se,userTriggeredOnInput:L,collectFonts:X,doc:Z,maskInputFn:g,maskTextFn:_,keepIframeSrcFn:je,blockSelector:n,slimDOMOptions:br,dataURLOptions:v,mirror:ce,iframeManager:Fe,stylesheetManager:Ue,shadowDomManager:Bt,processedNodeManager:Sr,canvasManager:Ir,ignoreCSSAttributes:Q,plugins:((qe=D==null?void 0:D.filter(q=>q.observer))===null||qe===void 0?void 0:qe.map(q=>({observer:q.observer,options:q.options,callback:kr=>W(J({type:A.Plugin,data:{plugin:q.name,payload:kr}}))})))||[]},m)};Fe.addLoadListener(Z=>{try{x.push(ae(Z.contentDocument))}catch(qe){console.warn(qe)}});const z=()=>{Qt(),x.push(ae(document)),nr=!0};return document.readyState==="interactive"||document.readyState==="complete"?z():(x.push(ee("DOMContentLoaded",()=>{W(J({type:A.DomContentLoaded,data:{}})),N==="DOMContentLoaded"&&z()})),x.push(ee("load",()=>{W(J({type:A.Load,data:{}})),N==="load"&&z()},window))),()=>{x.forEach(Z=>Z()),Sr.destroy(),nr=!1,ao()}}catch(x){console.warn(x)}}$t.addCustomEvent=(t,e)=>{if(!nr)throw new Error("please add custom event after start recording");W(J({type:A.Custom,data:{tag:t,payload:e}}))};$t.freezePage=()=>{We.forEach(t=>t.freeze())};$t.takeFullSnapshot=t=>{if(!nr)throw new Error("please take full snapshot after start recording");Qt(t)};$t.mirror=ce;var Ms=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Ms||{}),_e=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(_e||{}),Ee={DEBUG:!1,LIB_VERSION:"2.54.0"},O;if(typeof window>"u"){var Pi={hostname:""};O={navigator:{userAgent:""},document:{location:Pi,referrer:""},screen:{width:0,height:0},location:Pi}}else O=window;var Ot=24*60*60*1e3,fr=Array.prototype,Uo=Function.prototype,As=Object.prototype,Ae=fr.slice,jt=As.toString,pr=As.hasOwnProperty,G=O.console,De=O.navigator,$=O.document,Gt=O.opera,or=O.screen,ve=De.userAgent,Tr=Uo.bind,Ni=fr.forEach,Li=fr.indexOf,$i=fr.map,Fo=Array.isArray,Br={},h={trim:function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},P={log:function(){if(Ee.DEBUG&&!h.isUndefined(G)&&G)try{G.log.apply(G,arguments)}catch{h.each(arguments,function(e){G.log(e)})}},warn:function(){if(Ee.DEBUG&&!h.isUndefined(G)&&G){var t=["Mixpanel warning:"].concat(h.toArray(arguments));try{G.warn.apply(G,t)}catch{h.each(t,function(r){G.warn(r)})}}},error:function(){if(Ee.DEBUG&&!h.isUndefined(G)&&G){var t=["Mixpanel error:"].concat(h.toArray(arguments));try{G.error.apply(G,t)}catch{h.each(t,function(r){G.error(r)})}}},critical:function(){if(!h.isUndefined(G)&&G){var t=["Mixpanel error:"].concat(h.toArray(arguments));try{G.error.apply(G,t)}catch{h.each(t,function(r){G.error(r)})}}}},Cr=function(t,e){return function(){return arguments[0]="["+e+"] "+arguments[0],t.apply(P,arguments)}},_r=function(t){return{log:Cr(P.log,t),error:Cr(P.error,t),critical:Cr(P.critical,t)}};h.bind=function(t,e){var r,i;if(Tr&&t.bind===Tr)return Tr.apply(t,Ae.call(arguments,1));if(!h.isFunction(t))throw new TypeError;return r=Ae.call(arguments,2),i=function(){if(!(this instanceof i))return t.apply(e,r.concat(Ae.call(arguments)));var s={};s.prototype=t.prototype;var n=new s;s.prototype=null;var o=t.apply(n,r.concat(Ae.call(arguments)));return Object(o)===o?o:n},i};h.each=function(t,e,r){if(t!=null){if(Ni&&t.forEach===Ni)t.forEach(e,r);else if(t.length===+t.length){for(var i=0,s=t.length;i<s;i++)if(i in t&&e.call(r,t[i],i,t)===Br)return}else for(var n in t)if(pr.call(t,n)&&e.call(r,t[n],n,t)===Br)return}};h.extend=function(t){return h.each(Ae.call(arguments,1),function(e){for(var r in e)e[r]!==void 0&&(t[r]=e[r])}),t};h.isArray=Fo||function(t){return jt.call(t)==="[object Array]"};h.isFunction=function(t){try{return/^\s*\bfunction\b/.test(t)}catch{return!1}};h.isArguments=function(t){return!!(t&&pr.call(t,"callee"))};h.toArray=function(t){return t?t.toArray?t.toArray():h.isArray(t)||h.isArguments(t)?Ae.call(t):h.values(t):[]};h.map=function(t,e,r){if($i&&t.map===$i)return t.map(e,r);var i=[];return h.each(t,function(s){i.push(e.call(r,s))}),i};h.keys=function(t){var e=[];return t===null||h.each(t,function(r,i){e[e.length]=i}),e};h.values=function(t){var e=[];return t===null||h.each(t,function(r){e[e.length]=r}),e};h.include=function(t,e){var r=!1;return t===null?r:Li&&t.indexOf===Li?t.indexOf(e)!=-1:(h.each(t,function(i){if(r||(r=i===e))return Br}),r)};h.includes=function(t,e){return t.indexOf(e)!==-1};h.inherit=function(t,e){return t.prototype=new e,t.prototype.constructor=t,t.superclass=e.prototype,t};h.isObject=function(t){return t===Object(t)&&!h.isArray(t)};h.isEmptyObject=function(t){if(h.isObject(t)){for(var e in t)if(pr.call(t,e))return!1;return!0}return!1};h.isUndefined=function(t){return t===void 0};h.isString=function(t){return jt.call(t)=="[object String]"};h.isDate=function(t){return jt.call(t)=="[object Date]"};h.isNumber=function(t){return jt.call(t)=="[object Number]"};h.isElement=function(t){return!!(t&&t.nodeType===1)};h.encodeDates=function(t){return h.each(t,function(e,r){h.isDate(e)?t[r]=h.formatDate(e):h.isObject(e)&&(t[r]=h.encodeDates(e))}),t};h.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()};h.formatDate=function(t){function e(r){return r<10?"0"+r:r}return t.getUTCFullYear()+"-"+e(t.getUTCMonth()+1)+"-"+e(t.getUTCDate())+"T"+e(t.getUTCHours())+":"+e(t.getUTCMinutes())+":"+e(t.getUTCSeconds())};h.strip_empty_properties=function(t){var e={};return h.each(t,function(r,i){h.isString(r)&&r.length>0&&(e[i]=r)}),e};h.truncate=function(t,e){var r;return typeof t=="string"?r=t.slice(0,e):h.isArray(t)?(r=[],h.each(t,function(i){r.push(h.truncate(i,e))})):h.isObject(t)?(r={},h.each(t,function(i,s){r[s]=h.truncate(i,e)})):r=t,r};h.JSONEncode=function(){return function(t){var e=t,r=function(s){var n=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return n.lastIndex=0,n.test(s)?'"'+s.replace(n,function(c){var a=o[c];return typeof a=="string"?a:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+s+'"'},i=function(s,n){var o="",c="    ",a=0,l="",u="",f=0,d=o,p=[],g=n[s];switch(g&&typeof g=="object"&&typeof g.toJSON=="function"&&(g=g.toJSON(s)),typeof g){case"string":return r(g);case"number":return isFinite(g)?String(g):"null";case"boolean":case"null":return String(g);case"object":if(!g)return"null";if(o+=c,p=[],jt.apply(g)==="[object Array]"){for(f=g.length,a=0;a<f;a+=1)p[a]=i(a,g)||"null";return u=p.length===0?"[]":o?`[
`+o+p.join(`,
`+o)+`
`+d+"]":"["+p.join(",")+"]",o=d,u}for(l in g)pr.call(g,l)&&(u=i(l,g),u&&p.push(r(l)+(o?": ":":")+u));return u=p.length===0?"{}":o?"{"+p.join(",")+d+"}":"{"+p.join(",")+"}",o=d,u}};return i("",{"":e})}}();h.JSONDecode=function(){var t,e,r={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
`,r:"\r",t:"	"},i,s=function(p){var g=new SyntaxError(p);throw g.at=t,g.text=i,g},n=function(p){return p&&p!==e&&s("Expected '"+p+"' instead of '"+e+"'"),e=i.charAt(t),t+=1,e},o=function(){var p,g="";for(e==="-"&&(g="-",n("-"));e>="0"&&e<="9";)g+=e,n();if(e===".")for(g+=".";n()&&e>="0"&&e<="9";)g+=e;if(e==="e"||e==="E")for(g+=e,n(),(e==="-"||e==="+")&&(g+=e,n());e>="0"&&e<="9";)g+=e,n();if(p=+g,!isFinite(p))s("Bad number");else return p},c=function(){var p,g,_="",m;if(e==='"')for(;n();){if(e==='"')return n(),_;if(e==="\\")if(n(),e==="u"){for(m=0,g=0;g<4&&(p=parseInt(n(),16),!!isFinite(p));g+=1)m=m*16+p;_+=String.fromCharCode(m)}else if(typeof r[e]=="string")_+=r[e];else break;else _+=e}s("Bad string")},a=function(){for(;e&&e<=" ";)n()},l=function(){switch(e){case"t":return n("t"),n("r"),n("u"),n("e"),!0;case"f":return n("f"),n("a"),n("l"),n("s"),n("e"),!1;case"n":return n("n"),n("u"),n("l"),n("l"),null}s('Unexpected "'+e+'"')},u,f=function(){var p=[];if(e==="["){if(n("["),a(),e==="]")return n("]"),p;for(;e;){if(p.push(u()),a(),e==="]")return n("]"),p;n(","),a()}}s("Bad array")},d=function(){var p,g={};if(e==="{"){if(n("{"),a(),e==="}")return n("}"),g;for(;e;){if(p=c(),a(),n(":"),Object.hasOwnProperty.call(g,p)&&s('Duplicate key "'+p+'"'),g[p]=u(),a(),e==="}")return n("}"),g;n(","),a()}}s("Bad object")};return u=function(){switch(a(),e){case"{":return d();case"[":return f();case'"':return c();case"-":return o();default:return e>="0"&&e<="9"?o():l()}},function(p){var g;return i=p,t=0,e=" ",g=u(),a(),e&&s("Syntax error"),g}}();h.base64Encode=function(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r,i,s,n,o,c,a,l,u=0,f=0,d="",p=[];if(!t)return t;t=h.utf8Encode(t);do r=t.charCodeAt(u++),i=t.charCodeAt(u++),s=t.charCodeAt(u++),l=r<<16|i<<8|s,n=l>>18&63,o=l>>12&63,c=l>>6&63,a=l&63,p[f++]=e.charAt(n)+e.charAt(o)+e.charAt(c)+e.charAt(a);while(u<t.length);switch(d=p.join(""),t.length%3){case 1:d=d.slice(0,-2)+"==";break;case 2:d=d.slice(0,-1)+"=";break}return d};h.utf8Encode=function(t){t=(t+"").replace(/\r\n/g,`
`).replace(/\r/g,`
`);var e="",r,i,s=0,n;for(r=i=0,s=t.length,n=0;n<s;n++){var o=t.charCodeAt(n),c=null;o<128?i++:o>127&&o<2048?c=String.fromCharCode(o>>6|192,o&63|128):c=String.fromCharCode(o>>12|224,o>>6&63|128,o&63|128),c!==null&&(i>r&&(e+=t.substring(r,i)),e+=c,r=i=n+1)}return i>r&&(e+=t.substring(r,t.length)),e};h.UUID=function(){var t=function(){var i=1*new Date,s;if(O.performance&&O.performance.now)s=O.performance.now();else for(s=0;i==1*new Date;)s++;return i.toString(16)+Math.floor(s).toString(16)},e=function(){return Math.random().toString(16).replace(".","")},r=function(){var i=ve,s,n,o=[],c=0;function a(l,u){var f,d=0;for(f=0;f<u.length;f++)d|=o[f]<<f*8;return l^d}for(s=0;s<i.length;s++)n=i.charCodeAt(s),o.unshift(n&255),o.length>=4&&(c=a(c,o),o=[]);return o.length>0&&(c=a(c,o)),c.toString(16)};return function(){var i=(or.height*or.width).toString(16);return t()+"-"+e()+"-"+r()+"-"+i+"-"+t()}}();var ji=["ahrefsbot","ahrefssiteaudit","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandexbot","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];h.isBlockedUA=function(t){var e;for(t=t.toLowerCase(),e=0;e<ji.length;e++)if(t.indexOf(ji[e])!==-1)return!0;return!1};h.HTTPBuildQuery=function(t,e){var r,i,s=[];return h.isUndefined(e)&&(e="&"),h.each(t,function(n,o){r=encodeURIComponent(n.toString()),i=encodeURIComponent(o),s[s.length]=i+"="+r}),s.join(e)};h.getQueryParam=function(t,e){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var r="[\\?&]"+e+"=([^&#]*)",i=new RegExp(r),s=i.exec(t);if(s===null||s&&typeof s[1]!="string"&&s[1].length)return"";var n=s[1];try{n=decodeURIComponent(n)}catch{P.error("Skipping decoding for malformed query param: "+n)}return n.replace(/\+/g," ")};h.cookie={get:function(t){for(var e=t+"=",r=$.cookie.split(";"),i=0;i<r.length;i++){for(var s=r[i];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}return null},parse:function(t){var e;try{e=h.JSONDecode(h.cookie.get(t))||{}}catch{}return e},set_seconds:function(t,e,r,i,s,n,o){var c="",a="",l="";if(o)c="; domain="+o;else if(i){var u=Ui($.location.hostname);c=u?"; domain=."+u:""}if(r){var f=new Date;f.setTime(f.getTime()+r*1e3),a="; expires="+f.toGMTString()}n&&(s=!0,l="; SameSite=None"),s&&(l+="; secure"),$.cookie=t+"="+encodeURIComponent(e)+a+"; path=/"+c+l},set:function(t,e,r,i,s,n,o){var c="",a="",l="";if(o)c="; domain="+o;else if(i){var u=Ui($.location.hostname);c=u?"; domain=."+u:""}if(r){var f=new Date;f.setTime(f.getTime()+r*24*60*60*1e3),a="; expires="+f.toGMTString()}n&&(s=!0,l="; SameSite=None"),s&&(l+="; secure");var d=t+"="+encodeURIComponent(e)+a+"; path=/"+c+l;return $.cookie=d,d},remove:function(t,e,r){h.cookie.set(t,"",-1,e,!1,!1,r)}};var Rr=null,ar=function(t,e){if(Rr!==null&&!e)return Rr;var r=!0;try{t=t||window.localStorage;var i="__mplss_"+Qr(8),s="xyz";t.setItem(i,s),t.getItem(i)!==s&&(r=!1),t.removeItem(i)}catch{r=!1}return Rr=r,r};h.localStorage={is_supported:function(t){var e=ar(null,t);return e||P.error("localStorage unsupported; falling back to cookie store"),e},error:function(t){P.error("localStorage error: "+t)},get:function(t){try{return window.localStorage.getItem(t)}catch(e){h.localStorage.error(e)}return null},parse:function(t){try{return h.JSONDecode(h.localStorage.get(t))||{}}catch{}return null},set:function(t,e){try{window.localStorage.setItem(t,e)}catch(r){h.localStorage.error(r)}},remove:function(t){try{window.localStorage.removeItem(t)}catch(e){h.localStorage.error(e)}}};h.register_event=function(){var t=function(i,s,n,o,c){if(!i){P.error("No valid element provided to register_event");return}if(i.addEventListener&&!o)i.addEventListener(s,n,!!c);else{var a="on"+s,l=i[a];i[a]=e(i,n,l)}};function e(i,s,n){var o=function(c){if(c=c||r(window.event),!!c){var a=!0,l,u;return h.isFunction(n)&&(l=n(c)),u=s.call(i,c),(l===!1||u===!1)&&(a=!1),a}};return o}function r(i){return i&&(i.preventDefault=r.preventDefault,i.stopPropagation=r.stopPropagation),i}return r.preventDefault=function(){this.returnValue=!1},r.stopPropagation=function(){this.cancelBubble=!0},t}();var qo=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');h.dom_query=function(){function t(s){return s.all?s.all:s.getElementsByTagName("*")}var e=/[\t\r\n]/g;function r(s,n){var o=" "+n+" ";return(" "+s.className+" ").replace(e," ").indexOf(o)>=0}function i(s){if(!$.getElementsByTagName)return[];var n=s.split(" "),o,c,a,l,u,f,d,p,g,_,m=[$];for(f=0;f<n.length;f++){if(o=n[f].replace(/^\s+/,"").replace(/\s+$/,""),o.indexOf("#")>-1){c=o.split("#"),a=c[0];var b=c[1],w=$.getElementById(b);if(!w||a&&w.nodeName.toLowerCase()!=a)return[];m=[w];continue}if(o.indexOf(".")>-1){c=o.split("."),a=c[0];var v=c[1];for(a||(a="*"),l=[],u=0,d=0;d<m.length;d++)for(a=="*"?g=t(m[d]):g=m[d].getElementsByTagName(a),p=0;p<g.length;p++)l[u++]=g[p];for(m=[],_=0,d=0;d<l.length;d++)l[d].className&&h.isString(l[d].className)&&r(l[d],v)&&(m[_++]=l[d]);continue}var S=o.match(qo);if(S){a=S[1];var k=S[2],H=S[3],F=S[4];for(a||(a="*"),l=[],u=0,d=0;d<m.length;d++)for(a=="*"?g=t(m[d]):g=m[d].getElementsByTagName(a),p=0;p<g.length;p++)l[u++]=g[p];m=[],_=0;var N;switch(H){case"=":N=function(L){return L.getAttribute(k)==F};break;case"~":N=function(L){return L.getAttribute(k).match(new RegExp("\\b"+F+"\\b"))};break;case"|":N=function(L){return L.getAttribute(k).match(new RegExp("^"+F+"-?"))};break;case"^":N=function(L){return L.getAttribute(k).indexOf(F)===0};break;case"$":N=function(L){return L.getAttribute(k).lastIndexOf(F)==L.getAttribute(k).length-F.length};break;case"*":N=function(L){return L.getAttribute(k).indexOf(F)>-1};break;default:N=function(L){return L.getAttribute(k)}}for(m=[],_=0,d=0;d<l.length;d++)N(l[d])&&(m[_++]=l[d]);continue}for(a=o,l=[],u=0,d=0;d<m.length;d++)for(g=m[d].getElementsByTagName(a),p=0;p<g.length;p++)l[u++]=g[p];m=l}return m}return function(s){return h.isElement(s)?[s]:h.isObject(s)&&!h.isUndefined(s.length)?s:i.call(this,s)}}();var Bo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],zo=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","ttclid","twclid","wbraid"];h.info={campaignParams:function(t){var e="",r={};return h.each(Bo,function(i){e=h.getQueryParam($.URL,i),e.length?r[i]=e:t!==void 0&&(r[i]=t)}),r},clickParams:function(){var t="",e={};return h.each(zo,function(r){t=h.getQueryParam($.URL,r),t.length&&(e[r]=t)}),e},marketingParams:function(){return h.extend(h.info.campaignParams(),h.info.clickParams())},searchEngine:function(t){return t.search("https?://(.*)google.([^/?]*)")===0?"google":t.search("https?://(.*)bing.com")===0?"bing":t.search("https?://(.*)yahoo.com")===0?"yahoo":t.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null},searchInfo:function(t){var e=h.info.searchEngine(t),r=e!="yahoo"?"q":"p",i={};if(e!==null){i.$search_engine=e;var s=h.getQueryParam(t,r);s.length&&(i.mp_keyword=s)}return i},browser:function(t,e,r){return e=e||"",r||h.includes(t," OPR/")?h.includes(t,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":h.includes(t,"IEMobile")||h.includes(t,"WPDesktop")?"Internet Explorer Mobile":h.includes(t,"SamsungBrowser/")?"Samsung Internet":h.includes(t,"Edge")||h.includes(t,"Edg/")?"Microsoft Edge":h.includes(t,"FBIOS")?"Facebook Mobile":h.includes(t,"Chrome")?"Chrome":h.includes(t,"CriOS")?"Chrome iOS":h.includes(t,"UCWEB")||h.includes(t,"UCBrowser")?"UC Browser":h.includes(t,"FxiOS")?"Firefox iOS":h.includes(e,"Apple")?h.includes(t,"Mobile")?"Mobile Safari":"Safari":h.includes(t,"Android")?"Android Mobile":h.includes(t,"Konqueror")?"Konqueror":h.includes(t,"Firefox")?"Firefox":h.includes(t,"MSIE")||h.includes(t,"Trident/")?"Internet Explorer":h.includes(t,"Gecko")?"Mozilla":""},browserVersion:function(t,e,r){var i=h.info.browser(t,e,r),s={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/},n=s[i];if(n===void 0)return null;var o=t.match(n);return o?parseFloat(o[o.length-2]):null},os:function(){var t=ve;return/Windows/i.test(t)?/Phone/.test(t)||/WPDesktop/.test(t)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(t)?"iOS":/Android/.test(t)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":/Mac/i.test(t)?"Mac OS X":/Linux/.test(t)?"Linux":/CrOS/.test(t)?"Chrome OS":""},device:function(t){return/Windows Phone/i.test(t)||/WPDesktop/.test(t)?"Windows Phone":/iPad/.test(t)?"iPad":/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":/Android/.test(t)?"Android":""},referringDomain:function(t){var e=t.split("/");return e.length>=3?e[2]:""},currentUrl:function(){return O.location.href},properties:function(t){return typeof t!="object"&&(t={}),h.extend(h.strip_empty_properties({$os:h.info.os(),$browser:h.info.browser(ve,De.vendor,Gt),$referrer:$.referrer,$referring_domain:h.info.referringDomain($.referrer),$device:h.info.device(ve)}),{$current_url:h.info.currentUrl(),$browser_version:h.info.browserVersion(ve,De.vendor,Gt),$screen_height:or.height,$screen_width:or.width,mp_lib:"web",$lib_version:Ee.LIB_VERSION,$insert_id:Qr(),time:h.timestamp()/1e3},h.strip_empty_properties(t))},people_properties:function(){return h.extend(h.strip_empty_properties({$os:h.info.os(),$browser:h.info.browser(ve,De.vendor,Gt)}),{$browser_version:h.info.browserVersion(ve,De.vendor,Gt)})},mpPageViewProperties:function(){return h.strip_empty_properties({current_page_title:$.title,current_domain:O.location.hostname,current_url_path:O.location.pathname,current_url_protocol:O.location.protocol,current_url_search:O.location.search})}};var Qr=function(t){var e=Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10);return t?e.substring(0,t):e},Ho=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,Wo=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,Ui=function(t){var e=Wo,r=t.split("."),i=r[r.length-1];(i.length>4||i==="com"||i==="org")&&(e=Ho);var s=t.match(e);return s?s[0]:""},cr=null,lr=null;typeof JSON<"u"&&(cr=JSON.stringify,lr=JSON.parse);cr=cr||h.JSONEncode;lr=lr||h.JSONDecode;h.toArray=h.toArray;h.isObject=h.isObject;h.JSONEncode=h.JSONEncode;h.JSONDecode=h.JSONDecode;h.isBlockedUA=h.isBlockedUA;h.isEmptyObject=h.isEmptyObject;h.info=h.info;h.info.device=h.info.device;h.info.browser=h.info.browser;h.info.browserVersion=h.info.browserVersion;h.info.properties=h.info.properties;var Go="__mp_opt_in_out_";function Jo(t,e){Ns(!0,t,e)}function Vo(t,e){Ns(!1,t,e)}function Ko(t,e){return Ps(t,e)==="1"}function Ds(t,e){if(Xo(e))return P.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"'),!0;var r=Ps(t,e)==="0";return r&&P.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),r}function Ne(t){return ti(t,function(e){return this.get_config(e)})}function Le(t){return ti(t,function(e){return this._get_config(e)})}function mt(t){return ti(t,function(e){return this._get_config(e)})}function Yo(t,e){e=e||{},Zr(e).remove(ei(t,e),!!e.crossSubdomainCookie,e.cookieDomain)}function Zr(t){return t=t||{},t.persistenceType==="localStorage"?h.localStorage:h.cookie}function ei(t,e){return e=e||{},(e.persistencePrefix||Go)+t}function Ps(t,e){return Zr(e).get(ei(t,e))}function Xo(t){if(t&&t.ignoreDnt)return!1;var e=t&&t.window||O,r=e.navigator||{},i=!1;return h.each([r.doNotTrack,r.msDoNotTrack,e.doNotTrack],function(s){h.includes([!0,1,"1","yes"],s)&&(i=!0)}),i}function Ns(t,e,r){if(!h.isString(e)||!e.length){P.error("gdpr."+(t?"optIn":"optOut")+" called with an invalid token");return}r=r||{},Zr(r).set(ei(e,r),t?1:0,h.isNumber(r.cookieExpiration)?r.cookieExpiration:null,!!r.crossSubdomainCookie,!!r.secureCookie,!!r.crossSiteCookie,r.cookieDomain),r.track&&t&&r.track(r.trackEventName||"$opt_in",r.trackProperties,{send_immediately:!0})}function ti(t,e){return function(){var r=!1;try{var i=e.call(this,"token"),s=e.call(this,"ignore_dnt"),n=e.call(this,"opt_out_tracking_persistence_type"),o=e.call(this,"opt_out_tracking_cookie_prefix"),c=e.call(this,"window");i&&(r=Ds(i,{ignoreDnt:s,persistenceType:n,persistencePrefix:o,window:c}))}catch(l){P.error("Unexpected error when checking tracking opt-out status: "+l)}if(!r)return t.apply(this,arguments);var a=arguments[arguments.length-1];typeof a=="function"&&a(0)}}var Qo=_r("lock"),Ls=function(t,e){e=e||{},this.storageKey=t,this.storage=e.storage||window.localStorage,this.pollIntervalMS=e.pollIntervalMS||100,this.timeoutMS=e.timeoutMS||2e3};Ls.prototype.withLock=function(t,e,r){!r&&typeof e!="function"&&(r=e,e=null);var i=r||new Date().getTime()+"|"+Math.random(),s=new Date().getTime(),n=this.storageKey,o=this.pollIntervalMS,c=this.timeoutMS,a=this.storage,l=n+":X",u=n+":Y",f=n+":Z",d=function(w){e&&e(w)},p=function(w){if(new Date().getTime()-s>c){Qo.error("Timeout waiting for mutex on "+n+"; clearing lock. ["+i+"]"),a.removeItem(f),a.removeItem(u),m();return}setTimeout(function(){try{w()}catch(v){d(v)}},o*(Math.random()+.1))},g=function(w,v){w()?v():p(function(){g(w,v)})},_=function(){var w=a.getItem(u);if(w&&w!==i)return!1;if(a.setItem(u,i),a.getItem(u)===i)return!0;if(!ar(a,!0))throw new Error("localStorage support dropped while acquiring lock");return!1},m=function(){a.setItem(l,i),g(_,function(){if(a.getItem(l)===i){b();return}p(function(){if(a.getItem(u)!==i){m();return}g(function(){return!a.getItem(f)},b)})})},b=function(){a.setItem(f,"1");try{t()}finally{a.removeItem(f),a.getItem(u)===i&&a.removeItem(u),a.getItem(l)===i&&a.removeItem(l)}};try{if(ar(a,!0))m();else throw new Error("localStorage support check failed")}catch(w){d(w)}};var Fi=_r("batch"),$e=function(t,e){e=e||{},this.storageKey=t,this.storage=e.storage||window.localStorage,this.reportError=e.errorReporter||h.bind(Fi.error,Fi),this.lock=new Ls(t,{storage:this.storage}),this.usePersistence=e.usePersistence,this.pid=e.pid||null,this.memQueue=[]};$e.prototype.enqueue=function(t,e,r){var i={id:Qr(),flushAfter:new Date().getTime()+e*2,payload:t};this.usePersistence?this.lock.withLock(h.bind(function(){var n;try{var o=this.readFromStorage();o.push(i),n=this.saveToStorage(o),n&&this.memQueue.push(i)}catch{this.reportError("Error enqueueing item",t),n=!1}r&&r(n)},this),h.bind(function(n){this.reportError("Error acquiring storage lock",n),r&&r(!1)},this),this.pid):(this.memQueue.push(i),r&&r(!0))};$e.prototype.fillBatch=function(t){var e=this.memQueue.slice(0,t);if(this.usePersistence&&e.length<t){var r=this.readFromStorage();if(r.length){var i={};h.each(e,function(o){i[o.id]=!0});for(var s=0;s<r.length;s++){var n=r[s];if(new Date().getTime()>n.flushAfter&&!i[n.id]&&(n.orphaned=!0,e.push(n),e.length>=t))break}}}return e};var qi=function(t,e){var r=[];return h.each(t,function(i){i.id&&!e[i.id]&&r.push(i)}),r};$e.prototype.removeItemsByID=function(t,e){var r={};if(h.each(t,function(s){r[s]=!0}),this.memQueue=qi(this.memQueue,r),!this.usePersistence)e&&e(!0);else{var i=h.bind(function(){var s;try{var n=this.readFromStorage();if(n=qi(n,r),s=this.saveToStorage(n),s){n=this.readFromStorage();for(var o=0;o<n.length;o++){var c=n[o];if(c.id&&r[c.id])return this.reportError("Item not removed from storage"),!1}}}catch{this.reportError("Error removing items",t),s=!1}return s},this);this.lock.withLock(function(){var n=i();e&&e(n)},h.bind(function(n){var o=!1;if(this.reportError("Error acquiring storage lock",n),!ar(this.storage,!0)&&(o=i(),!o))try{this.storage.removeItem(this.storageKey)}catch(c){this.reportError("Error clearing queue",c)}e&&e(o)},this),this.pid)}};var Bi=function(t,e){var r=[];return h.each(t,function(i){var s=i.id;if(s in e){var n=e[s];n!==null&&(i.payload=n,r.push(i))}else r.push(i)}),r};$e.prototype.updatePayloads=function(t,e){this.memQueue=Bi(this.memQueue,t),this.usePersistence?this.lock.withLock(h.bind(function(){var i;try{var s=this.readFromStorage();s=Bi(s,t),i=this.saveToStorage(s)}catch{this.reportError("Error updating items",t),i=!1}e&&e(i)},this),h.bind(function(i){this.reportError("Error acquiring storage lock",i),e&&e(!1)},this),this.pid):e&&e(!0)};$e.prototype.readFromStorage=function(){var t;try{t=this.storage.getItem(this.storageKey),t&&(t=lr(t),h.isArray(t)||(this.reportError("Invalid storage entry:",t),t=null))}catch(e){this.reportError("Error retrieving queue",e),t=null}return t||[]};$e.prototype.saveToStorage=function(t){try{return this.storage.setItem(this.storageKey,cr(t)),!0}catch(e){return this.reportError("Error saving queue",e),!1}};$e.prototype.clear=function(){this.memQueue=[],this.usePersistence&&this.storage.removeItem(this.storageKey)};var Zo=10*60*1e3,xt=_r("batch"),he=function(t,e){this.errorReporter=e.errorReporter,this.queue=new $e(t,{errorReporter:h.bind(this.reportError,this),storage:e.storage,usePersistence:e.usePersistence}),this.libConfig=e.libConfig,this.sendRequest=e.sendRequestFunc,this.beforeSendHook=e.beforeSendHook,this.stopAllBatching=e.stopAllBatchingFunc,this.batchSize=this.libConfig.batch_size,this.flushInterval=this.libConfig.batch_flush_interval_ms,this.stopped=!this.libConfig.batch_autostart,this.consecutiveRemovalFailures=0,this.itemIdsSentSuccessfully={},this.flushOnlyOnInterval=e.flushOnlyOnInterval||!1};he.prototype.enqueue=function(t,e){this.queue.enqueue(t,this.flushInterval,e)};he.prototype.start=function(){this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()};he.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)};he.prototype.clear=function(){this.queue.clear()};he.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size};he.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)};he.prototype.scheduleFlush=function(t){this.flushInterval=t,this.stopped||(this.timeoutID=setTimeout(h.bind(this.flush,this),this.flushInterval))};he.prototype.flush=function(t){try{if(this.requestInProgress){xt.log("Flush: Request already in progress");return}t=t||{};var e=this.libConfig.batch_request_timeout_ms,r=new Date().getTime(),i=this.batchSize,s=this.queue.fillBatch(i),n=s.length===i,o=[],c={};if(h.each(s,function(u){var f=u.payload;if(this.beforeSendHook&&!u.orphaned&&(f=this.beforeSendHook(f)),f){f.event&&f.properties&&(f.properties=h.extend({},f.properties,{mp_sent_by_lib_version:Ee.LIB_VERSION}));var d=!0,p=u.id;p?(this.itemIdsSentSuccessfully[p]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:u,batchSize:s.length,timesSent:this.itemIdsSentSuccessfully[p]}),d=!1):this.reportError("[dupe] found item with no ID",{item:u}),d&&o.push(f)}c[u.id]=f},this),o.length<1){this.resetFlush();return}this.requestInProgress=!0;var a=h.bind(function(u){this.requestInProgress=!1;try{var f=!1;if(t.unloading)this.queue.updatePayloads(c);else if(h.isObject(u)&&u.error==="timeout"&&new Date().getTime()-r>=e)this.reportError("Network timeout; retrying"),this.flush();else if(h.isObject(u)&&(u.httpStatusCode>=500||u.httpStatusCode===429||u.error==="timeout")){var d=this.flushInterval*2;u.retryAfter&&(d=parseInt(u.retryAfter,10)*1e3||d),d=Math.min(Zo,d),this.reportError("Error; retry in "+d+" ms"),this.scheduleFlush(d)}else if(h.isObject(u)&&u.httpStatusCode===413)if(s.length>1){var p=Math.max(1,Math.floor(i/2));this.batchSize=Math.min(this.batchSize,p,s.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush()}else this.reportError("Single-event request too large; dropping",s),this.resetBatchSize(),f=!0;else f=!0;f&&(this.queue.removeItemsByID(h.map(s,function(g){return g.id}),h.bind(function(g){g?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!n?this.resetFlush():this.flush()):(this.reportError("Failed to remove items from queue"),++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush())},this)),h.each(s,h.bind(function(g){var _=g.id;_?(this.itemIdsSentSuccessfully[_]=this.itemIdsSentSuccessfully[_]||0,this.itemIdsSentSuccessfully[_]++,this.itemIdsSentSuccessfully[_]>5&&this.reportError("[dupe] item ID sent too many times",{item:g,batchSize:s.length,timesSent:this.itemIdsSentSuccessfully[_]})):this.reportError("[dupe] found item with no ID while removing",{item:g})},this)))}catch(g){this.reportError("Error handling API response",g),this.resetFlush()}},this),l={method:"POST",verbose:!0,ignore_json_errors:!0,timeout_ms:e};t.unloading&&(l.transport="sendBeacon"),xt.log("MIXPANEL REQUEST:",o),this.sendRequest(o,l,a)}catch(u){this.reportError("Error flushing request queue",u),this.resetFlush()}};he.prototype.reportError=function(t,e){if(xt.error.apply(xt.error,arguments),this.errorReporter)try{e instanceof Error||(e=new Error(t)),this.errorReporter(t,e)}catch(r){xt.error(r)}};var lt=_r("recorder"),zi=O.CompressionStream,ea={batch_size:1e3,batch_flush_interval_ms:10*1e3,batch_request_timeout_ms:90*1e3,batch_autostart:!0},ta=new Set([_e.MouseMove,_e.MouseInteraction,_e.Scroll,_e.ViewportResize,_e.Input,_e.TouchMove,_e.MediaInteraction,_e.Drag,_e.Selection]);function ra(t){return t.type===Ms.IncrementalSnapshot&&ta.has(t.source)}var de=function(t){this._mixpanel=t,this._stopRecording=null,this.recEvents=[],this.seqNo=0,this.replayId=null,this.replayStartTime=null,this.sendBatchId=null,this.idleTimeoutId=null,this.maxTimeoutId=null,this.recordMaxMs=Ot,this._initBatcher()};de.prototype._initBatcher=function(){this.batcher=new he("__mprec",{libConfig:ea,sendRequestFunc:h.bind(this.flushEventsWithOptOut,this),errorReporter:h.bind(this.reportError,this),flushOnlyOnInterval:!0,usePersistence:!1})};de.prototype.get_config=function(t){return this._mixpanel.get_config(t)};de.prototype.startRecording=function(){if(this._stopRecording!==null){lt.log("Recording already in progress, skipping startRecording.");return}this.recordMaxMs=this.get_config("record_max_ms"),this.recordMaxMs>Ot&&(this.recordMaxMs=Ot,lt.critical("record_max_ms cannot be greater than "+Ot+"ms. Capping value.")),this.recEvents=[],this.seqNo=0,this.replayStartTime=null,this.replayId=h.UUID(),this.batcher.start();var t=h.bind(function(){clearTimeout(this.idleTimeoutId),this.idleTimeoutId=setTimeout(h.bind(function(){lt.log("Idle timeout reached, restarting recording."),this.resetRecording()},this),this.get_config("record_idle_timeout_ms"))},this);this._stopRecording=$t({emit:h.bind(function(e){this.batcher.enqueue(e),ra(e)&&t()},this),blockClass:this.get_config("record_block_class"),blockSelector:this.get_config("record_block_selector"),collectFonts:this.get_config("record_collect_fonts"),inlineImages:this.get_config("record_inline_images"),maskAllInputs:!0,maskTextClass:this.get_config("record_mask_text_class"),maskTextSelector:this.get_config("record_mask_text_selector")}),t(),this.maxTimeoutId=setTimeout(h.bind(this.resetRecording,this),this.recordMaxMs)};de.prototype.resetRecording=function(){this.stopRecording(),this.startRecording()};de.prototype.stopRecording=function(){this._stopRecording!==null&&(this._stopRecording(),this._stopRecording=null),this.batcher.flush(),this.replayId=null,clearTimeout(this.idleTimeoutId),clearTimeout(this.maxTimeoutId)};de.prototype.flushEventsWithOptOut=function(t,e,r){this._flushEvents(t,e,r,h.bind(this._onOptOut,this))};de.prototype._onOptOut=function(t){t===0&&(this.recEvents=[],this.stopRecording())};de.prototype._sendRequest=function(t,e,r){var i=h.bind(function(s,n){s.status===200&&this.seqNo++,r({status:0,httpStatusCode:s.status,responseBody:n,retryAfter:s.headers.get("Retry-After")})},this);O.fetch(this.get_config("api_host")+"/"+this.get_config("api_routes").record+"?"+new URLSearchParams(t),{method:"POST",headers:{Authorization:"Basic "+btoa(this.get_config("token")+":"),"Content-Type":"application/octet-stream"},body:e}).then(function(s){s.json().then(function(n){i(s,n)}).catch(function(n){r({error:n})})}).catch(function(s){r({error:s})})};de.prototype._flushEvents=Ne(function(t,e,r){const i=t.length;if(i>0){var s=t[0].timestamp;this.seqNo===0&&(this.replayStartTime=s);var n=t[i-1].timestamp-this.replayStartTime,o={distinct_id:String(this._mixpanel.get_distinct_id()),seq:this.seqNo,batch_start_time:s/1e3,replay_id:this.replayId,replay_length_ms:n,replay_start_time:this.replayStartTime/1e3},c=h.JSONEncode(t),a=this._mixpanel.get_property("$device_id");a&&(o.$device_id=a);var l=this._mixpanel.get_property("$user_id");if(l&&(o.$user_id=l),zi){var u=new Blob([c],{type:"application/json"}).stream(),f=u.pipeThrough(new zi("gzip"));new Response(f).blob().then(h.bind(function(d){o.format="gzip",this._sendRequest(o,d,r)},this))}else o.format="body",this._sendRequest(o,c,r)}});de.prototype.reportError=function(t,e){lt.error.apply(lt.error,arguments);try{!e&&!(t instanceof Error)&&(t=new Error(t)),this.get_config("error_reporter")(t,e)}catch(r){lt.error(r)}};O.__mp_recorder=de;var xe=function(){};xe.prototype.create_properties=function(){};xe.prototype.event_handler=function(){};xe.prototype.after_track_handler=function(){};xe.prototype.init=function(t){return this.mp=t,this};xe.prototype.track=function(t,e,r,i){var s=this,n=h.dom_query(t);if(n.length===0){P.error("The DOM query ("+t+") returned 0 elements");return}return h.each(n,function(o){h.register_event(o,this.override_event,function(c){var a={},l=s.create_properties(r,this),u=s.mp.get_config("track_links_timeout");s.event_handler(c,this,a),window.setTimeout(s.track_callback(i,l,a,!0),u),s.mp.track(e,l,s.track_callback(i,l,a))})},this),!0};xe.prototype.track_callback=function(t,e,r,i){i=i||!1;var s=this;return function(){r.callback_fired||(r.callback_fired=!0,!(t&&t(i,e)===!1)&&s.after_track_handler(e,r,i))}};xe.prototype.create_properties=function(t,e){var r;return typeof t=="function"?r=t(e):r=h.extend({},t),r};var ft=function(){this.override_event="click"};h.inherit(ft,xe);ft.prototype.create_properties=function(t,e){var r=ft.superclass.create_properties.apply(this,arguments);return e.href&&(r.url=e.href),r};ft.prototype.event_handler=function(t,e,r){r.new_tab=t.which===2||t.metaKey||t.ctrlKey||e.target==="_blank",r.href=e.href,r.new_tab||t.preventDefault()};ft.prototype.after_track_handler=function(t,e){e.new_tab||setTimeout(function(){window.location=e.href},0)};var gr=function(){this.override_event="submit"};h.inherit(gr,xe);gr.prototype.event_handler=function(t,e,r){r.element=e,t.preventDefault()};gr.prototype.after_track_handler=function(t,e){setTimeout(function(){e.element.submit()},0)};var Pe="$set",pt="$set_once",ue="$unset",Je="$add",be="$append",Ve="$union",Oe="$remove",ia="$delete",$s={set_action:function(t,e){var r={},i={};return h.isObject(t)?h.each(t,function(s,n){this._is_reserved_property(n)||(i[n]=s)},this):i[t]=e,r[Pe]=i,r},unset_action:function(t){var e={},r=[];return h.isArray(t)||(t=[t]),h.each(t,function(i){this._is_reserved_property(i)||r.push(i)},this),e[ue]=r,e},set_once_action:function(t,e){var r={},i={};return h.isObject(t)?h.each(t,function(s,n){this._is_reserved_property(n)||(i[n]=s)},this):i[t]=e,r[pt]=i,r},union_action:function(t,e){var r={},i={};return h.isObject(t)?h.each(t,function(s,n){this._is_reserved_property(n)||(i[n]=h.isArray(s)?s:[s])},this):i[t]=h.isArray(e)?e:[e],r[Ve]=i,r},append_action:function(t,e){var r={},i={};return h.isObject(t)?h.each(t,function(s,n){this._is_reserved_property(n)||(i[n]=s)},this):i[t]=e,r[be]=i,r},remove_action:function(t,e){var r={},i={};return h.isObject(t)?h.each(t,function(s,n){this._is_reserved_property(n)||(i[n]=s)},this):i[t]=e,r[Oe]=i,r},delete_action:function(){var t={};return t[ia]="",t}},B=function(){};h.extend(B.prototype,$s);B.prototype._init=function(t,e,r){this._mixpanel=t,this._group_key=e,this._group_id=r};B.prototype.set=mt(function(t,e,r){var i=this.set_action(t,e);return h.isObject(t)&&(r=e),this._send_request(i,r)});B.prototype.set_once=mt(function(t,e,r){var i=this.set_once_action(t,e);return h.isObject(t)&&(r=e),this._send_request(i,r)});B.prototype.unset=mt(function(t,e){var r=this.unset_action(t);return this._send_request(r,e)});B.prototype.union=mt(function(t,e,r){h.isObject(t)&&(r=e);var i=this.union_action(t,e);return this._send_request(i,r)});B.prototype.delete=mt(function(t){var e=this.delete_action();return this._send_request(e,t)});B.prototype.remove=mt(function(t,e,r){var i=this.remove_action(t,e);return this._send_request(i,r)});B.prototype._send_request=function(t,e){t.$group_key=this._group_key,t.$group_id=this._group_id,t.$token=this._get_config("token");var r=h.encodeDates(t);return this._mixpanel._track_or_batch({type:"groups",data:r,endpoint:this._get_config("api_host")+"/"+this._get_config("api_routes").groups,batcher:this._mixpanel.request_batchers.groups},e)};B.prototype._is_reserved_property=function(t){return t==="$group_key"||t==="$group_id"};B.prototype._get_config=function(t){return this._mixpanel.get_config(t)};B.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id};B.prototype.remove=B.prototype.remove;B.prototype.set=B.prototype.set;B.prototype.set_once=B.prototype.set_once;B.prototype.union=B.prototype.union;B.prototype.unset=B.prototype.unset;B.prototype.toString=B.prototype.toString;var E=function(){};h.extend(E.prototype,$s);E.prototype._init=function(t){this._mixpanel=t};E.prototype.set=Le(function(t,e,r){var i=this.set_action(t,e);return h.isObject(t)&&(r=e),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),i[Pe]=h.extend({},h.info.people_properties(),i[Pe]),this._send_request(i,r)});E.prototype.set_once=Le(function(t,e,r){var i=this.set_once_action(t,e);return h.isObject(t)&&(r=e),this._send_request(i,r)});E.prototype.unset=Le(function(t,e){var r=this.unset_action(t);return this._send_request(r,e)});E.prototype.increment=Le(function(t,e,r){var i={},s={};return h.isObject(t)?(h.each(t,function(n,o){if(!this._is_reserved_property(o))if(isNaN(parseFloat(n))){P.error("Invalid increment value passed to mixpanel.people.increment - must be a number");return}else s[o]=n},this),r=e):(h.isUndefined(e)&&(e=1),s[t]=e),i[Je]=s,this._send_request(i,r)});E.prototype.append=Le(function(t,e,r){h.isObject(t)&&(r=e);var i=this.append_action(t,e);return this._send_request(i,r)});E.prototype.remove=Le(function(t,e,r){h.isObject(t)&&(r=e);var i=this.remove_action(t,e);return this._send_request(i,r)});E.prototype.union=Le(function(t,e,r){h.isObject(t)&&(r=e);var i=this.union_action(t,e);return this._send_request(i,r)});E.prototype.track_charge=Le(function(t,e,r){if(!h.isNumber(t)&&(t=parseFloat(t),isNaN(t))){P.error("Invalid value passed to mixpanel.people.track_charge - must be a number");return}return this.append("$transactions",h.extend({$amount:t},e),r)});E.prototype.clear_charges=function(t){return this.set("$transactions",[],t)};E.prototype.delete_user=function(){if(!this._identify_called()){P.error("mixpanel.people.delete_user() requires you to call identify() first");return}var t={$delete:this._mixpanel.get_distinct_id()};return this._send_request(t)};E.prototype.toString=function(){return this._mixpanel.toString()+".people"};E.prototype._send_request=function(t,e){t.$token=this._get_config("token"),t.$distinct_id=this._mixpanel.get_distinct_id();var r=this._mixpanel.get_property("$device_id"),i=this._mixpanel.get_property("$user_id"),s=this._mixpanel.get_property("$had_persisted_distinct_id");r&&(t.$device_id=r),i&&(t.$user_id=i),s&&(t.$had_persisted_distinct_id=s);var n=h.encodeDates(t);return this._identify_called()?this._mixpanel._track_or_batch({type:"people",data:n,endpoint:this._get_config("api_host")+"/"+this._get_config("api_routes").engage,batcher:this._mixpanel.request_batchers.people},e):(this._enqueue(t),h.isUndefined(e)||(this._get_config("verbose")?e({status:-1,error:null}):e(-1)),h.truncate(n,255))};E.prototype._get_config=function(t){return this._mixpanel.get_config(t)};E.prototype._identify_called=function(){return this._mixpanel._flags.identify_called===!0};E.prototype._enqueue=function(t){Pe in t?this._mixpanel.persistence._add_to_people_queue(Pe,t):pt in t?this._mixpanel.persistence._add_to_people_queue(pt,t):ue in t?this._mixpanel.persistence._add_to_people_queue(ue,t):Je in t?this._mixpanel.persistence._add_to_people_queue(Je,t):be in t?this._mixpanel.persistence._add_to_people_queue(be,t):Oe in t?this._mixpanel.persistence._add_to_people_queue(Oe,t):Ve in t?this._mixpanel.persistence._add_to_people_queue(Ve,t):P.error("Invalid call to _enqueue():",t)};E.prototype._flush_one_queue=function(t,e,r,i){var s=this,n=h.extend({},this._mixpanel.persistence.load_queue(t)),o=n;!h.isUndefined(n)&&h.isObject(n)&&!h.isEmptyObject(n)&&(s._mixpanel.persistence._pop_from_people_queue(t,n),s._mixpanel.persistence.save(),i&&(o=i(n)),e.call(s,o,function(c,a){c===0&&s._mixpanel.persistence._add_to_people_queue(t,n),h.isUndefined(r)||r(c,a)}))};E.prototype._flush=function(t,e,r,i,s,n,o){var c=this;this._flush_one_queue(Pe,this.set,t),this._flush_one_queue(pt,this.set_once,i),this._flush_one_queue(ue,this.unset,n,function(m){return h.keys(m)}),this._flush_one_queue(Je,this.increment,e),this._flush_one_queue(Ve,this.union,s);var a=this._mixpanel.persistence.load_queue(be);if(!h.isUndefined(a)&&h.isArray(a)&&a.length)for(var l,u=function(m,b){m===0&&c._mixpanel.persistence._add_to_people_queue(be,l),h.isUndefined(r)||r(m,b)},f=a.length-1;f>=0;f--)a=this._mixpanel.persistence.load_queue(be),l=a.pop(),c._mixpanel.persistence.save(),h.isEmptyObject(l)||c.append(l,u);var d=this._mixpanel.persistence.load_queue(Oe);if(!h.isUndefined(d)&&h.isArray(d)&&d.length)for(var p,g=function(m,b){m===0&&c._mixpanel.persistence._add_to_people_queue(Oe,p),h.isUndefined(o)||o(m,b)},_=d.length-1;_>=0;_--)d=this._mixpanel.persistence.load_queue(Oe),p=d.pop(),c._mixpanel.persistence.save(),h.isEmptyObject(p)||c.remove(p,g)};E.prototype._is_reserved_property=function(t){return t==="$distinct_id"||t==="$token"||t==="$device_id"||t==="$user_id"||t==="$had_persisted_distinct_id"};E.prototype.set=E.prototype.set;E.prototype.set_once=E.prototype.set_once;E.prototype.unset=E.prototype.unset;E.prototype.increment=E.prototype.increment;E.prototype.append=E.prototype.append;E.prototype.remove=E.prototype.remove;E.prototype.union=E.prototype.union;E.prototype.track_charge=E.prototype.track_charge;E.prototype.clear_charges=E.prototype.clear_charges;E.prototype.delete_user=E.prototype.delete_user;E.prototype.toString=E.prototype.toString;var ri="__mps",ii="__mpso",si="__mpus",ni="__mpa",oi="__mpap",ai="__mpr",ci="__mpu",js="$people_distinct_id",ur="__alias",At="__timers",sa=[ri,ii,si,ni,oi,ai,ci,js,ur,At],I=function(t){this.props={},this.campaign_params_saved=!1,t.persistence_name?this.name="mp_"+t.persistence_name:this.name="mp_"+t.token+"_mixpanel";var e=t.persistence;e!=="cookie"&&e!=="localStorage"&&(P.critical("Unknown persistence type "+e+"; falling back to cookie"),e=t.persistence="cookie"),e==="localStorage"&&h.localStorage.is_supported()?this.storage=h.localStorage:this.storage=h.cookie,this.load(),this.update_config(t),this.upgrade(),this.save()};I.prototype.properties=function(){var t={};return this.load(),h.each(this.props,function(e,r){h.include(sa,r)||(t[r]=e)}),t};I.prototype.load=function(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=h.extend({},t))}};I.prototype.upgrade=function(){var t,e;this.storage===h.localStorage?(t=h.cookie.parse(this.name),h.cookie.remove(this.name),h.cookie.remove(this.name,!0),t&&this.register_once(t)):this.storage===h.cookie&&(e=h.localStorage.parse(this.name),h.localStorage.remove(this.name),e&&this.register_once(e))};I.prototype.save=function(){this.disabled||this.storage.set(this.name,h.JSONEncode(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)};I.prototype.load_prop=function(t){return this.load(),this.props[t]};I.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)};I.prototype.clear=function(){this.remove(),this.props={}};I.prototype.register_once=function(t,e,r){return h.isObject(t)?(typeof e>"u"&&(e="None"),this.expire_days=typeof r>"u"?this.default_expiry:r,this.load(),h.each(t,function(i,s){(!this.props.hasOwnProperty(s)||this.props[s]===e)&&(this.props[s]=i)},this),this.save(),!0):!1};I.prototype.register=function(t,e){return h.isObject(t)?(this.expire_days=typeof e>"u"?this.default_expiry:e,this.load(),h.extend(this.props,t),this.save(),!0):!1};I.prototype.unregister=function(t){this.load(),t in this.props&&(delete this.props[t],this.save())};I.prototype.update_search_keyword=function(t){this.register(h.info.searchInfo(t))};I.prototype.update_referrer_info=function(t){this.register_once({$initial_referrer:t||"$direct",$initial_referring_domain:h.info.referringDomain(t)||"$direct"},"")};I.prototype.get_referrer_info=function(){return h.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})};I.prototype.update_config=function(t){this.default_expiry=this.expire_days=t.cookie_expiration,this.set_disabled(t.disable_persistence),this.set_cookie_domain(t.cookie_domain),this.set_cross_site(t.cross_site_cookie),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie)};I.prototype.set_disabled=function(t){this.disabled=t,this.disabled?this.remove():this.save()};I.prototype.set_cookie_domain=function(t){t!==this.cookie_domain&&(this.remove(),this.cookie_domain=t,this.save())};I.prototype.set_cross_site=function(t){t!==this.cross_site&&(this.cross_site=t,this.remove(),this.save())};I.prototype.set_cross_subdomain=function(t){t!==this.cross_subdomain&&(this.cross_subdomain=t,this.remove(),this.save())};I.prototype.get_cross_subdomain=function(){return this.cross_subdomain};I.prototype.set_secure=function(t){t!==this.secure&&(this.secure=!!t,this.remove(),this.save())};I.prototype._add_to_people_queue=function(t,e){var r=this._get_queue_key(t),i=e[t],s=this._get_or_create_queue(Pe),n=this._get_or_create_queue(pt),o=this._get_or_create_queue(ue),c=this._get_or_create_queue(Je),a=this._get_or_create_queue(Ve),l=this._get_or_create_queue(Oe,[]),u=this._get_or_create_queue(be,[]);r===ri?(h.extend(s,i),this._pop_from_people_queue(Je,i),this._pop_from_people_queue(Ve,i),this._pop_from_people_queue(ue,i)):r===ii?(h.each(i,function(f,d){d in n||(n[d]=f)}),this._pop_from_people_queue(ue,i)):r===si?h.each(i,function(f){h.each([s,n,c,a],function(d){f in d&&delete d[f]}),h.each(u,function(d){f in d&&delete d[f]}),o[f]=!0}):r===ni?(h.each(i,function(f,d){d in s?s[d]+=f:(d in c||(c[d]=0),c[d]+=f)},this),this._pop_from_people_queue(ue,i)):r===ci?(h.each(i,function(f,d){h.isArray(f)&&(d in a||(a[d]=[]),a[d]=a[d].concat(f))}),this._pop_from_people_queue(ue,i)):r===ai?(l.push(i),this._pop_from_people_queue(be,i)):r===oi&&(u.push(i),this._pop_from_people_queue(ue,i)),P.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),P.log(e),this.save()};I.prototype._pop_from_people_queue=function(t,e){var r=this.props[this._get_queue_key(t)];h.isUndefined(r)||h.each(e,function(i,s){t===be||t===Oe?h.each(r,function(n){n[s]===i&&delete n[s]}):delete r[s]},this)};I.prototype.load_queue=function(t){return this.load_prop(this._get_queue_key(t))};I.prototype._get_queue_key=function(t){if(t===Pe)return ri;if(t===pt)return ii;if(t===ue)return si;if(t===Je)return ni;if(t===be)return oi;if(t===Oe)return ai;if(t===Ve)return ci;P.error("Invalid queue:",t)};I.prototype._get_or_create_queue=function(t,e){var r=this._get_queue_key(t);return e=h.isUndefined(e)?{}:e,this.props[r]||(this.props[r]=e)};I.prototype.set_event_timer=function(t,e){var r=this.load_prop(At)||{};r[t]=e,this.props[At]=r,this.save()};I.prototype.remove_event_timer=function(t){var e=this.load_prop(At)||{},r=e[t];return h.isUndefined(r)||(delete this.props[At][t],this.save()),r};var li,Us=function(t,e){throw new Error(t+" not available in this build.")},Y,Fs=0,na=1,oa=function(t){return t},Dt=function(){},oe="mixpanel",qs="base64",aa="json",ui="$device:",ut=O.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,Bs=!ut&&ve.indexOf("MSIE")===-1&&ve.indexOf("Mozilla")===-1,hr=null;De.sendBeacon&&(hr=function(){return De.sendBeacon.apply(De,arguments)});var zs={track:"track/",engage:"engage/",groups:"groups/",record:"record/"},Hi={api_host:"https://api-js.mixpanel.com",api_routes:zs,api_method:"POST",api_transport:"XHR",api_payload_format:qs,app_host:"https://mixpanel.com",cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:Dt,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:Dt,mp_loader:null,track_marketing:!0,track_pageview:!1,skip_first_touch_marketing:!1,store_google:!0,stop_utm_persistence:!1,save_referrer:!0,test:!1,verbose:!1,img:!1,debug:!1,track_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_tracking_by_default:!1,opt_out_persistence_by_default:!1,opt_out_tracking_persistence_type:"localStorage",opt_out_tracking_cookie_prefix:null,property_blacklist:[],xhr_headers:{},ignore_dnt:!1,batch_requests:!0,batch_size:50,batch_flush_interval_ms:5e3,batch_request_timeout_ms:9e4,batch_autostart:!0,hooks:{},record_block_class:new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),record_block_selector:"img, video",record_collect_fonts:!1,record_idle_timeout_ms:30*60*1e3,record_inline_images:!1,record_mask_text_class:new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),record_mask_text_selector:"*",record_max_ms:Ot,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},Hs=!1,y=function(){},zr=function(t,e,r){var i,s=r===oe?Y:Y[r];if(s&&li===Fs)i=s;else{if(s&&!h.isArray(s)){P.error("You have already initialized "+r);return}i=new y}if(i._cached_groups={},i._init(t,e,r),i.people=new E,i.people._init(i),!i.get_config("skip_first_touch_marketing")){var n=h.info.campaignParams(null),o={},c=!1;h.each(n,function(a,l){o["initial_"+l]=a,a&&(c=!0)}),c&&i.people.set_once(o)}return Ee.DEBUG=Ee.DEBUG||i.get_config("debug"),!h.isUndefined(s)&&h.isArray(s)&&(i._execute_array.call(i.people,s.people),i._execute_array(s)),i};y.prototype.init=function(t,e,r){if(h.isUndefined(r)){this.report_error("You must name your new library: init(token, config, name)");return}if(r===oe){this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");return}var i=zr(t,e,r);return Y[r]=i,i._loaded(),i};y.prototype._init=function(t,e,r){e=e||{},this.__loaded=!0,this.config={};var i={};if(!("api_payload_format"in e)){var s=e.api_host||Hi.api_host;s.match(/\.mixpanel\.com/)&&(i.api_payload_format=aa)}if(this.set_config(h.extend({},Hi,i,e,{name:r,token:t,callback_fn:(r===oe?r:oe+"."+r)+"._jsc"})),this._jsc=Dt,this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.request_batchers={},this._batch_requests=this.get_config("batch_requests"),this._batch_requests){if(!h.localStorage.is_supported(!0)||!ut)this._batch_requests=!1,P.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),h.each(this.get_batcher_configs(),function(a){P.log("Clearing batch queue "+a.queue_key),h.localStorage.remove(a.queue_key)});else if(this.init_batchers(),hr&&O.addEventListener){var n=h.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);O.addEventListener("pagehide",function(a){a.persisted&&n()}),O.addEventListener("visibilitychange",function(){$.visibilityState==="hidden"&&n()})}}this.persistence=this.cookie=new I(this.config),this.unpersisted_superprops={},this._gdpr_init();var o=h.UUID();this.get_distinct_id()||this.register_once({distinct_id:ui+o,$device_id:o},"");var c=this.get_config("track_pageview");c&&this._init_url_change_tracking(c),this.get_config("record_sessions_percent")>0&&Math.random()*100<=this.get_config("record_sessions_percent")&&this.start_session_recording()};y.prototype.start_session_recording=Ne(function(){if(!O.MutationObserver){P.critical("Browser does not support MutationObserver; skipping session recording");return}var t=h.bind(function(){this._recorder=this._recorder||new O.__mp_recorder(this),this._recorder.startRecording()},this);h.isUndefined(O.__mp_recorder)?Us(this.get_config("recorder_src"),t):t()});y.prototype.stop_session_recording=function(){this._recorder?this._recorder.stopRecording():P.critical("Session recorder module not loaded")};y.prototype.get_session_recording_properties=function(){var t={};if(this._recorder){var e=this._recorder.replayId;e&&(t.$mp_replay_id=e)}return t};y.prototype._loaded=function(){if(this.get_config("loaded")(this),this._set_default_superprops(),this.people.set_once(this.persistence.get_referrer_info()),this.get_config("store_google")&&this.get_config("stop_utm_persistence")){var t=h.info.campaignParams(null);h.each(t,(function(e,r){this.unregister(r)}).bind(this))}};y.prototype._set_default_superprops=function(){this.persistence.update_search_keyword($.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(h.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info($.referrer)};y.prototype._dom_loaded=function(){h.each(this.__dom_loaded_queue,function(t){this._track_dom.apply(this,t)},this),this.has_opted_out_tracking()||h.each(this.__request_queue,function(t){this._send_request.apply(this,t)},this),delete this.__dom_loaded_queue,delete this.__request_queue};y.prototype._track_dom=function(t,e){if(this.get_config("img"))return this.report_error("You can't use DOM tracking functions with img = true."),!1;if(!Hs)return this.__dom_loaded_queue.push([t,e]),!1;var r=new t().init(this);return r.track.apply(r,e)};y.prototype._init_url_change_tracking=function(t){var e="",r=this.track_pageview();if(r&&(e=h.info.currentUrl()),h.include(["full-url","url-with-path-and-query-string","url-with-path"],t)){O.addEventListener("popstate",function(){O.dispatchEvent(new Event("mp_locationchange"))}),O.addEventListener("hashchange",function(){O.dispatchEvent(new Event("mp_locationchange"))});var i=O.history.pushState;typeof i=="function"&&(O.history.pushState=function(n,o,c){i.call(O.history,n,o,c),O.dispatchEvent(new Event("mp_locationchange"))});var s=O.history.replaceState;typeof s=="function"&&(O.history.replaceState=function(n,o,c){s.call(O.history,n,o,c),O.dispatchEvent(new Event("mp_locationchange"))}),O.addEventListener("mp_locationchange",(function(){var n=h.info.currentUrl(),o=!1;if(t==="full-url"?o=n!==e:t==="url-with-path-and-query-string"?o=n.split("#")[0]!==e.split("#")[0]:t==="url-with-path"&&(o=n.split("#")[0].split("?")[0]!==e.split("#")[0].split("?")[0]),o){var c=this.track_pageview();c&&(e=n)}}).bind(this))}};y.prototype._prepare_callback=function(t,e){if(h.isUndefined(t))return null;if(ut){var r=function(o){t(o,e)};return r}else{var i=this._jsc,s=""+Math.floor(Math.random()*1e8),n=this.get_config("callback_fn")+"["+s+"]";return i[s]=function(o){delete i[s],t(o,e)},n}};y.prototype._send_request=function(t,e,r,i){var s=!0;if(Bs)return this.__request_queue.push(arguments),s;var n={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},o=null;!i&&(h.isFunction(r)||typeof r=="string")&&(i=r,r=null),r=h.extend(n,r||{}),ut||(r.method="GET");var c=r.method==="POST",a=hr&&c&&r.transport.toLowerCase()==="sendbeacon",l=r.verbose;e.verbose&&(l=!0),this.get_config("test")&&(e.test=1),l&&(e.verbose=1),this.get_config("img")&&(e.img=1),ut||(i?e.callback=i:(l||this.get_config("test"))&&(e.callback="(function(){})")),e.ip=this.get_config("ip")?1:0,e._=new Date().getTime().toString(),c&&(o="data="+encodeURIComponent(e.data),delete e.data),t+="?"+h.HTTPBuildQuery(e);var u=this;if("img"in e){var f=$.createElement("img");f.src=t,$.body.appendChild(f)}else if(a){try{s=hr(t,o)}catch(b){u.report_error(b),s=!1}try{i&&i(s?1:0)}catch(b){u.report_error(b)}}else if(ut)try{var d=new XMLHttpRequest;d.open(r.method,t,!0);var p=this.get_config("xhr_headers");if(c&&(p["Content-Type"]="application/x-www-form-urlencoded"),h.each(p,function(b,w){d.setRequestHeader(w,b)}),r.timeout_ms&&typeof d.timeout<"u"){d.timeout=r.timeout_ms;var g=new Date().getTime()}d.withCredentials=!0,d.onreadystatechange=function(){if(d.readyState===4)if(d.status===200){if(i)if(l){var b;try{b=h.JSONDecode(d.responseText)}catch(S){if(u.report_error(S),r.ignore_json_errors)b=d.responseText;else return}i(b)}else i(Number(d.responseText))}else{var w;if(d.timeout&&!d.status&&new Date().getTime()-g>=d.timeout?w="timeout":w="Bad HTTP status: "+d.status+" "+d.statusText,u.report_error(w),i)if(l){var v=d.responseHeaders||{};i({status:0,httpStatusCode:d.status,error:w,retryAfter:v["Retry-After"]})}else i(0)}},d.send(o)}catch(b){u.report_error(b),s=!1}else{var _=$.createElement("script");_.type="text/javascript",_.async=!0,_.defer=!0,_.src=t;var m=$.getElementsByTagName("script")[0];m.parentNode.insertBefore(_,m)}return s};y.prototype._execute_array=function(t){var e,r=[],i=[],s=[];h.each(t,function(o){o&&(e=o[0],h.isArray(e)?s.push(o):typeof o=="function"?o.call(this):h.isArray(o)&&e==="alias"?r.push(o):h.isArray(o)&&e.indexOf("track")!==-1&&typeof this[e]=="function"?s.push(o):i.push(o))},this);var n=function(o,c){h.each(o,function(a){if(h.isArray(a[0])){var l=c;h.each(a,function(u){l=l[u[0]].apply(l,u.slice(1))})}else this[a[0]].apply(this,a.slice(1))},c)};n(r,this),n(i,this),n(s,this)};y.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events};y.prototype.get_batcher_configs=function(){var t="__mpq_"+this.get_config("token"),e=this.get_config("api_routes");return this._batcher_configs=this._batcher_configs||{events:{type:"events",endpoint:"/"+e.track,queue_key:t+"_ev"},people:{type:"people",endpoint:"/"+e.engage,queue_key:t+"_pp"},groups:{type:"groups",endpoint:"/"+e.groups,queue_key:t+"_gr"}},this._batcher_configs};y.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var t=h.bind(function(r){return new he(r.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:h.bind(function(i,s,n){this._send_request(this.get_config("api_host")+r.endpoint,this._encode_data_for_request(i),s,this._prepare_callback(n,i))},this),beforeSendHook:h.bind(function(i){return this._run_hook("before_send_"+r.type,i)},this),stopAllBatchingFunc:h.bind(this.stop_batch_senders,this),usePersistence:!0})},this),e=this.get_batcher_configs();this.request_batchers={events:t(e.events),people:t(e.people),groups:t(e.groups)}}this.get_config("batch_autostart")&&this.start_batch_senders()};y.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,h.each(this.request_batchers,function(t){t.start()}))};y.prototype.stop_batch_senders=function(){this._batch_requests=!1,h.each(this.request_batchers,function(t){t.stop(),t.clear()})};y.prototype.push=function(t){this._execute_array([t])};y.prototype.disable=function(t){typeof t>"u"?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(t)};y.prototype._encode_data_for_request=function(t){var e=h.JSONEncode(t);return this.get_config("api_payload_format")===qs&&(e=h.base64Encode(e)),{data:e}};y.prototype._track_or_batch=function(t,e){var r=h.truncate(t.data,255),i=t.endpoint,s=t.batcher,n=t.should_send_immediately,o=t.send_request_options||{};e=e||Dt;var c=!0,a=h.bind(function(){return o.skip_hooks||(r=this._run_hook("before_send_"+t.type,r)),r?(P.log("MIXPANEL REQUEST:"),P.log(r),this._send_request(i,this._encode_data_for_request(r),o,this._prepare_callback(e,r))):null},this);return this._batch_requests&&!n?s.enqueue(r,function(l){l?e(1,r):a()}):c=a(),c&&r};y.prototype.track=Ne(function(t,e,r,i){!i&&typeof r=="function"&&(i=r,r=null),r=r||{};var s=r.transport;s&&(r.transport=s);var n=r.send_immediately;if(typeof i!="function"&&(i=Dt),h.isUndefined(t)){this.report_error("No event name provided to mixpanel.track");return}if(this._event_is_disabled(t)){i(0);return}e=h.extend({},e),e.token=this.get_config("token");var o=this.persistence.remove_event_timer(t);if(!h.isUndefined(o)){var c=new Date().getTime()-o;e.$duration=parseFloat((c/1e3).toFixed(3))}this._set_default_superprops();var a=this.get_config("track_marketing")?h.info.marketingParams():{};e=h.extend({},h.info.properties({mp_loader:this.get_config("mp_loader")}),a,this.persistence.properties(),this.unpersisted_superprops,this.get_session_recording_properties(),e);var l=this.get_config("property_blacklist");h.isArray(l)?h.each(l,function(d){delete e[d]}):this.report_error("Invalid value for property_blacklist config: "+l);var u={event:t,properties:e},f=this._track_or_batch({type:"events",data:u,endpoint:this.get_config("api_host")+"/"+this.get_config("api_routes").track,batcher:this.request_batchers.events,should_send_immediately:n,send_request_options:r},i);return f});y.prototype.set_group=Ne(function(t,e,r){h.isArray(e)||(e=[e]);var i={};return i[t]=e,this.register(i),this.people.set(t,e,r)});y.prototype.add_group=Ne(function(t,e,r){var i=this.get_property(t),s={};return i===void 0?(s[t]=[e],this.register(s)):i.indexOf(e)===-1&&(i.push(e),s[t]=i,this.register(s)),this.people.union(t,e,r)});y.prototype.remove_group=Ne(function(t,e,r){var i=this.get_property(t);if(i!==void 0){var s=i.indexOf(e);s>-1&&(i.splice(s,1),this.register({group_key:i})),i.length===0&&this.unregister(t)}return this.people.remove(t,e,r)});y.prototype.track_with_groups=Ne(function(t,e,r,i){var s=h.extend({},e||{});return h.each(r,function(n,o){n!=null&&(s[o]=n)}),this.track(t,s,i)});y.prototype._create_map_key=function(t,e){return t+"_"+JSON.stringify(e)};y.prototype._remove_group_from_cache=function(t,e){delete this._cached_groups[this._create_map_key(t,e)]};y.prototype.get_group=function(t,e){var r=this._create_map_key(t,e),i=this._cached_groups[r];return(i===void 0||i._group_key!==t||i._group_id!==e)&&(i=new B,i._init(this,t,e),this._cached_groups[r]=i),i};y.prototype.track_pageview=Ne(function(t,e){typeof t!="object"&&(t={}),e=e||{};var r=e.event_name||"$mp_web_page_view",i=h.extend(h.info.mpPageViewProperties(),h.info.campaignParams(),h.info.clickParams()),s=h.extend({},i,t);return this.track(r,s)});y.prototype.track_links=function(){return this._track_dom.call(this,ft,arguments)};y.prototype.track_forms=function(){return this._track_dom.call(this,gr,arguments)};y.prototype.time_event=function(t){if(h.isUndefined(t)){this.report_error("No event name provided to mixpanel.time_event");return}this._event_is_disabled(t)||this.persistence.set_event_timer(t,new Date().getTime())};var ca={persistent:!0},hi=function(t){var e;return h.isObject(t)?e=t:h.isUndefined(t)?e={}:e={days:t},h.extend({},ca,e)};y.prototype.register=function(t,e){var r=hi(e);r.persistent?this.persistence.register(t,r.days):h.extend(this.unpersisted_superprops,t)};y.prototype.register_once=function(t,e,r){var i=hi(r);i.persistent?this.persistence.register_once(t,e,i.days):(typeof e>"u"&&(e="None"),h.each(t,function(s,n){(!this.unpersisted_superprops.hasOwnProperty(n)||this.unpersisted_superprops[n]===e)&&(this.unpersisted_superprops[n]=s)},this))};y.prototype.unregister=function(t,e){e=hi(e),e.persistent?this.persistence.unregister(t):delete this.unpersisted_superprops[t]};y.prototype._register_single=function(t,e){var r={};r[t]=e,this.register(r)};y.prototype.identify=function(t,e,r,i,s,n,o,c){var a=this.get_distinct_id();if(t&&a!==t){if(typeof t=="string"&&t.indexOf(ui)===0)return this.report_error("distinct_id cannot have $device: prefix"),-1;this.register({$user_id:t})}if(!this.get_property("$device_id")){var l=a;this.register_once({$had_persisted_distinct_id:!0,$device_id:l},"")}t!==a&&t!==this.get_property(ur)&&(this.unregister(ur),this.register({distinct_id:t})),this._flags.identify_called=!0,this.people._flush(e,r,i,s,n,o,c),t!==a&&this.track("$identify",{distinct_id:t,$anon_distinct_id:a},{skip_hooks:!0})};y.prototype.reset=function(){this.persistence.clear(),this._flags.identify_called=!1;var t=h.UUID();this.register_once({distinct_id:ui+t,$device_id:t},"")};y.prototype.get_distinct_id=function(){return this.get_property("distinct_id")};y.prototype.alias=function(t,e){if(t===this.get_property(js))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var r=this;return h.isUndefined(e)&&(e=this.get_distinct_id()),t!==e?(this._register_single(ur,t),this.track("$create_alias",{alias:t,distinct_id:e},{skip_hooks:!0},function(){r.identify(t)})):(this.report_error("alias matches current distinct_id - skipping api call."),this.identify(t),-1)};y.prototype.name_tag=function(t){this._register_single("mp_name_tag",t)};y.prototype.set_config=function(t){if(h.isObject(t)){h.extend(this.config,t);var e=t.batch_size;e&&h.each(this.request_batchers,function(r){r.resetBatchSize()}),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),Ee.DEBUG=Ee.DEBUG||this.get_config("debug")}};y.prototype.get_config=function(t){return this.config[t]};y.prototype._run_hook=function(t){var e=(this.config.hooks[t]||oa).apply(this,Ae.call(arguments,1));return typeof e>"u"&&(this.report_error(t+" hook did not return a value"),e=null),e};y.prototype.get_property=function(t){return this.persistence.load_prop([t])};y.prototype.toString=function(){var t=this.get_config("name");return t!==oe&&(t=oe+"."+t),t};y.prototype._event_is_disabled=function(t){return h.isBlockedUA(ve)||this._flags.disable_all_events||h.include(this.__disabled_events,t)};y.prototype._gdpr_init=function(){var t=this.get_config("opt_out_tracking_persistence_type")==="localStorage";t&&h.localStorage.is_supported()&&(!this.has_opted_in_tracking()&&this.has_opted_in_tracking({persistence_type:"cookie"})&&this.opt_in_tracking({enable_persistence:!1}),!this.has_opted_out_tracking()&&this.has_opted_out_tracking({persistence_type:"cookie"})&&this.opt_out_tracking({clear_persistence:!1}),this.clear_opt_in_out_tracking({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_tracking()?this._gdpr_update_persistence({clear_persistence:!0}):!this.has_opted_in_tracking()&&(this.get_config("opt_out_tracking_by_default")||h.cookie.get("mp_optout"))&&(h.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))};y.prototype._gdpr_update_persistence=function(t){var e;if(t&&t.clear_persistence)e=!0;else if(t&&t.enable_persistence)e=!1;else return;!this.get_config("disable_persistence")&&this.persistence.disabled!==e&&this.persistence.set_disabled(e),e?this.stop_batch_senders():this._batchers_were_started&&this.start_batch_senders()};y.prototype._gdpr_call_func=function(t,e){return e=h.extend({track:h.bind(this.track,this),persistence_type:this.get_config("opt_out_tracking_persistence_type"),cookie_prefix:this.get_config("opt_out_tracking_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_site_cookie:this.get_config("cross_site_cookie"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),cookie_domain:this.get_config("cookie_domain"),secure_cookie:this.get_config("secure_cookie"),ignore_dnt:this.get_config("ignore_dnt")},e),h.localStorage.is_supported()||(e.persistence_type="cookie"),t(this.get_config("token"),{track:e.track,trackEventName:e.track_event_name,trackProperties:e.track_properties,persistenceType:e.persistence_type,persistencePrefix:e.cookie_prefix,cookieDomain:e.cookie_domain,cookieExpiration:e.cookie_expiration,crossSiteCookie:e.cross_site_cookie,crossSubdomainCookie:e.cross_subdomain_cookie,secureCookie:e.secure_cookie,ignoreDnt:e.ignore_dnt})};y.prototype.opt_in_tracking=function(t){t=h.extend({enable_persistence:!0},t),this._gdpr_call_func(Jo,t),this._gdpr_update_persistence(t)};y.prototype.opt_out_tracking=function(t){t=h.extend({clear_persistence:!0,delete_user:!0},t),t.delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(Vo,t),this._gdpr_update_persistence(t)};y.prototype.has_opted_in_tracking=function(t){return this._gdpr_call_func(Ko,t)};y.prototype.has_opted_out_tracking=function(t){return this._gdpr_call_func(Ds,t)};y.prototype.clear_opt_in_out_tracking=function(t){t=h.extend({enable_persistence:!0},t),this._gdpr_call_func(Yo,t),this._gdpr_update_persistence(t)};y.prototype.report_error=function(t,e){P.error.apply(P.error,arguments);try{!e&&!(t instanceof Error)&&(t=new Error(t)),this.get_config("error_reporter")(t,e)}catch(r){P.error(r)}};y.prototype.init=y.prototype.init;y.prototype.reset=y.prototype.reset;y.prototype.disable=y.prototype.disable;y.prototype.time_event=y.prototype.time_event;y.prototype.track=y.prototype.track;y.prototype.track_links=y.prototype.track_links;y.prototype.track_forms=y.prototype.track_forms;y.prototype.track_pageview=y.prototype.track_pageview;y.prototype.register=y.prototype.register;y.prototype.register_once=y.prototype.register_once;y.prototype.unregister=y.prototype.unregister;y.prototype.identify=y.prototype.identify;y.prototype.alias=y.prototype.alias;y.prototype.name_tag=y.prototype.name_tag;y.prototype.set_config=y.prototype.set_config;y.prototype.get_config=y.prototype.get_config;y.prototype.get_property=y.prototype.get_property;y.prototype.get_distinct_id=y.prototype.get_distinct_id;y.prototype.toString=y.prototype.toString;y.prototype.opt_out_tracking=y.prototype.opt_out_tracking;y.prototype.opt_in_tracking=y.prototype.opt_in_tracking;y.prototype.has_opted_out_tracking=y.prototype.has_opted_out_tracking;y.prototype.has_opted_in_tracking=y.prototype.has_opted_in_tracking;y.prototype.clear_opt_in_out_tracking=y.prototype.clear_opt_in_out_tracking;y.prototype.get_group=y.prototype.get_group;y.prototype.set_group=y.prototype.set_group;y.prototype.add_group=y.prototype.add_group;y.prototype.remove_group=y.prototype.remove_group;y.prototype.track_with_groups=y.prototype.track_with_groups;y.prototype.start_batch_senders=y.prototype.start_batch_senders;y.prototype.stop_batch_senders=y.prototype.stop_batch_senders;y.prototype.start_session_recording=y.prototype.start_session_recording;y.prototype.stop_session_recording=y.prototype.stop_session_recording;y.prototype.get_session_recording_properties=y.prototype.get_session_recording_properties;y.prototype.DEFAULT_API_ROUTES=zs;I.prototype.properties=I.prototype.properties;I.prototype.update_search_keyword=I.prototype.update_search_keyword;I.prototype.update_referrer_info=I.prototype.update_referrer_info;I.prototype.get_cross_subdomain=I.prototype.get_cross_subdomain;I.prototype.clear=I.prototype.clear;var ct={},la=function(){h.each(ct,function(t,e){e!==oe&&(Y[e]=t)}),Y._=h},ua=function(){Y.init=function(t,e,r){if(r)return Y[r]||(Y[r]=ct[r]=zr(t,e,r),Y[r]._loaded()),Y[r];var i=Y;ct[oe]?i=ct[oe]:t&&(i=zr(t,e,oe),i._loaded(),ct[oe]=i),Y=i,li===na&&(O[oe]=Y),la()}},ha=function(){function t(){t.done||(t.done=!0,Hs=!0,Bs=!1,h.each(ct,function(i){i._dom_loaded()}))}function e(){try{$.documentElement.doScroll("left")}catch{setTimeout(e,1);return}t()}if($.addEventListener)$.readyState==="complete"?t():$.addEventListener("DOMContentLoaded",t,!1);else if($.attachEvent){$.attachEvent("onreadystatechange",t);var r=!1;try{r=O.frameElement===null}catch{}$.documentElement.doScroll&&r&&e()}h.register_event(O,"load",t,!0)};function da(t){return Us=t,li=Fs,Y=new y,ua(),Y.init(),ha(),Y}function fa(t,e){e()}var pa=da(fa),_a=pa;const Jt=kn(_a);new TextEncoder;const ga=new TextDecoder,ma=t=>{const e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r},ya=t=>{let e=t;e instanceof Uint8Array&&(e=ga.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return ma(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}},va=ya,ba=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Nt(()=>Promise.resolve().then(()=>Ut),void 0,import.meta.url).then(({default:i})=>i(...r)):e=fetch,(...r)=>e(...r)};class di extends Error{constructor(e,r="FunctionsError",i){super(e),this.name=r,this.context=i}}class wa extends di{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class Sa extends di{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class ka extends di{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Ea=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};class Oa{constructor(e,{headers:r={},customFetch:i}={}){this.url=e,this.headers=r,this.fetch=ba(i)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var i;return Ea(this,void 0,void 0,function*(){try{const{headers:s,method:n,body:o}=r;let c={},a;o&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(c["Content-Type"]="application/octet-stream",a=o):typeof o=="string"?(c["Content-Type"]="text/plain",a=o):typeof FormData<"u"&&o instanceof FormData?a=o:(c["Content-Type"]="application/json",a=JSON.stringify(o)));const l=yield this.fetch(`${this.url}/${e}`,{method:n||"POST",headers:Object.assign(Object.assign(Object.assign({},c),this.headers),s),body:a}).catch(p=>{throw new wa(p)}),u=l.headers.get("x-relay-error");if(u&&u==="true")throw new Sa(l);if(!l.ok)throw new ka(l);let f=((i=l.headers.get("Content-Type"))!==null&&i!==void 0?i:"text/plain").split(";")[0].trim(),d;return f==="application/json"?d=yield l.json():f==="application/octet-stream"?d=yield l.blob():f==="multipart/form-data"?d=yield l.formData():d=yield l.text(),{data:d,error:null}}catch(s){return{data:null,error:s}}})}}var xa=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},_t=xa();const Ia=_t.fetch,fi=_t.fetch.bind(_t),Ws=_t.Headers,Ta=_t.Request,Ca=_t.Response,Ut=Object.freeze(Object.defineProperty({__proto__:null,Headers:Ws,Request:Ta,Response:Ca,default:fi,fetch:Ia},Symbol.toStringTag,{value:"Module"}));class Ra{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=fi:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const i=this.fetch;let s=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async n=>{var o,c,a;let l=null,u=null,f=null,d=n.status,p=n.statusText;if(n.ok){if(this.method!=="HEAD"){const b=await n.text();b===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?u=b:u=JSON.parse(b))}const _=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),m=(c=n.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");_&&m&&m.length>1&&(f=parseInt(m[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(u)&&(u.length>1?(l={code:"PGRST116",details:`Results contain ${u.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},u=null,f=null,d=406,p="Not Acceptable"):u.length===1?u=u[0]:u=null)}else{const _=await n.text();try{l=JSON.parse(_),Array.isArray(l)&&n.status===404&&(u=[],l=null,d=200,p="OK")}catch{n.status===404&&_===""?(d=204,p="No Content"):l={message:_}}if(l&&this.isMaybeSingle&&(!((a=l==null?void 0:l.details)===null||a===void 0)&&a.includes("0 rows"))&&(l=null,d=200,p="OK"),l&&this.shouldThrowOnError)throw l}return{error:l,data:u,count:f,status:d,statusText:p}});return this.shouldThrowOnError||(s=s.catch(n=>{var o,c,a;return{error:{message:`${(o=n==null?void 0:n.name)!==null&&o!==void 0?o:"FetchError"}: ${n==null?void 0:n.message}`,details:`${(c=n==null?void 0:n.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(a=n==null?void 0:n.code)!==null&&a!==void 0?a:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,r)}}class Ma extends Ra{select(e){let r=!1;const i=(e??"*").split("").map(s=>/\s/.test(s)&&!r?"":(s==='"'&&(r=!r),s)).join("");return this.url.searchParams.set("select",i),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:r=!0,nullsFirst:i,foreignTable:s,referencedTable:n=s}={}){const o=n?`${n}.order`:"order",c=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${c?`${c},`:""}${e}.${r?"asc":"desc"}${i===void 0?"":i?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:i=r}={}){const s=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,r,{foreignTable:i,referencedTable:s=i}={}){const n=typeof s>"u"?"offset":`${s}.offset`,o=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${e}`),this.url.searchParams.set(o,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:r=!1,settings:i=!1,buffers:s=!1,wal:n=!1,format:o="text"}={}){var c;const a=[e?"analyze":null,r?"verbose":null,i?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(c=this.headers.Accept)!==null&&c!==void 0?c:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${l}"; options=${a};`,o==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class it extends Ma{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){const i=r.map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${i})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:i,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");const o=i===void 0?"":`(${i})`;return this.url.searchParams.append(e,`${n}fts${o}.${r}`),this}match(e){return Object.entries(e).forEach(([r,i])=>{this.url.searchParams.append(r,`eq.${i}`)}),this}not(e,r,i){return this.url.searchParams.append(e,`not.${r}.${i}`),this}or(e,{foreignTable:r,referencedTable:i=r}={}){const s=i?`${i}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,r,i){return this.url.searchParams.append(e,`${r}.${i}`),this}}class Aa{constructor(e,{headers:r={},schema:i,fetch:s}){this.url=e,this.headers=r,this.schema=i,this.fetch=s}select(e,{head:r=!1,count:i}={}){const s=r?"HEAD":"GET";let n=!1;const o=(e??"*").split("").map(c=>/\s/.test(c)&&!n?"":(c==='"'&&(n=!n),c)).join("");return this.url.searchParams.set("select",o),i&&(this.headers.Prefer=`count=${i}`),new it({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:r,defaultToNull:i=!0}={}){const s="POST",n=[];if(this.headers.Prefer&&n.push(this.headers.Prefer),r&&n.push(`count=${r}`),i||n.push("missing=default"),this.headers.Prefer=n.join(","),Array.isArray(e)){const o=e.reduce((c,a)=>c.concat(Object.keys(a)),[]);if(o.length>0){const c=[...new Set(o)].map(a=>`"${a}"`);this.url.searchParams.set("columns",c.join(","))}}return new it({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:r,ignoreDuplicates:i=!1,count:s,defaultToNull:n=!0}={}){const o="POST",c=[`resolution=${i?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&c.push(this.headers.Prefer),s&&c.push(`count=${s}`),n||c.push("missing=default"),this.headers.Prefer=c.join(","),Array.isArray(e)){const a=e.reduce((l,u)=>l.concat(Object.keys(u)),[]);if(a.length>0){const l=[...new Set(a)].map(u=>`"${u}"`);this.url.searchParams.set("columns",l.join(","))}}return new it({method:o,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:r}={}){const i="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),r&&s.push(`count=${r}`),this.headers.Prefer=s.join(","),new it({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const r="DELETE",i=[];return e&&i.push(`count=${e}`),this.headers.Prefer&&i.unshift(this.headers.Prefer),this.headers.Prefer=i.join(","),new it({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const Da="1.9.0",Pa={"X-Client-Info":`postgrest-js/${Da}`};class pi{constructor(e,{headers:r={},schema:i,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},Pa),r),this.schemaName=i,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new Aa(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new pi(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:i=!1,count:s}={}){let n;const o=new URL(`${this.url}/rpc/${e}`);let c;i?(n="HEAD",Object.entries(r).forEach(([l,u])=>{o.searchParams.append(l,`${u}`)})):(n="POST",c=r);const a=Object.assign({},this.headers);return s&&(a.Prefer=`count=${s}`),new it({method:n,url:o,headers:a,schema:this.schemaName,body:c,fetch:this.fetch,allowEmpty:!1})}}const Na="2.9.0",La={"X-Client-Info":`realtime-js/${Na}`},$a="1.0.0",Gs=1e4,ja=1e3;var It;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(It||(It={}));var ie;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(ie||(ie={}));var le;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(le||(le={}));var Hr;(function(t){t.websocket="websocket"})(Hr||(Hr={}));var He;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(He||(He={}));class Js{constructor(e,r){this.callback=e,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}class Ua{constructor(){this.HEADER_LENGTH=1}decode(e,r){return e.constructor===ArrayBuffer?r(this._binaryDecode(e)):r(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const r=new DataView(e),i=new TextDecoder;return this._decodeBroadcast(e,r,i)}_decodeBroadcast(e,r,i){const s=r.getUint8(1),n=r.getUint8(2);let o=this.HEADER_LENGTH+2;const c=i.decode(e.slice(o,o+s));o=o+s;const a=i.decode(e.slice(o,o+n));o=o+n;const l=JSON.parse(i.decode(e.slice(o,e.byteLength)));return{ref:null,topic:c,event:a,payload:l}}}class Mr{constructor(e,r,i={},s=Gs){this.channel=e,this.event=r,this.payload=i,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,r){var i;return this._hasReceived(e)&&r((i=this.receivedResp)===null||i===void 0?void 0:i.response),this.recHooks.push({status:e,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:r}){this.recHooks.filter(i=>i.status===e).forEach(i=>i.callback(r))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Wi;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(Wi||(Wi={}));class Tt{constructor(e,r){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const i=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(i.state,{},s=>{const{onJoin:n,onLeave:o,onSync:c}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Tt.syncState(this.state,s,n,o),this.pendingDiffs.forEach(a=>{this.state=Tt.syncDiff(this.state,a,n,o)}),this.pendingDiffs=[],c()}),this.channel._on(i.diff,{},s=>{const{onJoin:n,onLeave:o,onSync:c}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=Tt.syncDiff(this.state,s,n,o),c())}),this.onJoin((s,n,o)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:n,newPresences:o})}),this.onLeave((s,n,o)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:n,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,r,i,s){const n=this.cloneDeep(e),o=this.transformState(r),c={},a={};return this.map(n,(l,u)=>{o[l]||(a[l]=u)}),this.map(o,(l,u)=>{const f=n[l];if(f){const d=u.map(m=>m.presence_ref),p=f.map(m=>m.presence_ref),g=u.filter(m=>p.indexOf(m.presence_ref)<0),_=f.filter(m=>d.indexOf(m.presence_ref)<0);g.length>0&&(c[l]=g),_.length>0&&(a[l]=_)}else c[l]=u}),this.syncDiff(n,{joins:c,leaves:a},i,s)}static syncDiff(e,r,i,s){const{joins:n,leaves:o}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return i||(i=()=>{}),s||(s=()=>{}),this.map(n,(c,a)=>{var l;const u=(l=e[c])!==null&&l!==void 0?l:[];if(e[c]=this.cloneDeep(a),u.length>0){const f=e[c].map(p=>p.presence_ref),d=u.filter(p=>f.indexOf(p.presence_ref)<0);e[c].unshift(...d)}i(c,u,a)}),this.map(o,(c,a)=>{let l=e[c];if(!l)return;const u=a.map(f=>f.presence_ref);l=l.filter(f=>u.indexOf(f.presence_ref)<0),e[c]=l,s(c,l,a),l.length===0&&delete e[c]}),e}static map(e,r){return Object.getOwnPropertyNames(e).map(i=>r(i,e[i]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((r,i)=>{const s=e[i];return"metas"in s?r[i]=s.metas.map(n=>(n.presence_ref=n.phx_ref,delete n.phx_ref,delete n.phx_ref_prev,n)):r[i]=s,r},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var U;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(U||(U={}));const Gi=(t,e,r={})=>{var i;const s=(i=r.skipTypes)!==null&&i!==void 0?i:[];return Object.keys(e).reduce((n,o)=>(n[o]=Fa(o,t,e,s),n),{})},Fa=(t,e,r,i)=>{const s=e.find(c=>c.name===t),n=s==null?void 0:s.type,o=r[t];return n&&!i.includes(n)?Vs(n,o):Wr(o)},Vs=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Ha(e,r)}switch(t){case U.bool:return qa(e);case U.float4:case U.float8:case U.int2:case U.int4:case U.int8:case U.numeric:case U.oid:return Ba(e);case U.json:case U.jsonb:return za(e);case U.timestamp:return Wa(e);case U.abstime:case U.date:case U.daterange:case U.int4range:case U.int8range:case U.money:case U.reltime:case U.text:case U.time:case U.timestamptz:case U.timetz:case U.tsrange:case U.tstzrange:return Wr(e);default:return Wr(e)}},Wr=t=>t,qa=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Ba=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},za=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},Ha=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,i=t[r];if(t[0]==="{"&&i==="}"){let n;const o=t.slice(1,r);try{n=JSON.parse("["+o+"]")}catch{n=o?o.split(","):[]}return n.map(c=>Vs(e,c))}return t},Wa=t=>typeof t=="string"?t.replace(" ","T"):t;var Ji;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Ji||(Ji={}));var Vi;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes"})(Vi||(Vi={}));var Ki;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Ki||(Ki={}));class _i{constructor(e,r={config:{}},i){this.topic=e,this.params=r,this.socket=i,this.bindings={},this.state=ie.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},r.config),this.timeout=this.socket.timeout,this.joinPush=new Mr(this,le.join,this.params,this.timeout),this.rejoinTimer=new Js(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=ie.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=ie.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=ie.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=ie.errored,this.rejoinTimer.scheduleTimeout())}),this._on(le.reply,{},(s,n)=>{this._trigger(this._replyEventName(n),s)}),this.presence=new Tt(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,r=this.timeout){var i,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:n,presence:o}}=this.params;this._onError(l=>e&&e("CHANNEL_ERROR",l)),this._onClose(()=>e&&e("CLOSED"));const c={},a={broadcast:n,presence:o,postgres_changes:(s=(i=this.bindings.postgres_changes)===null||i===void 0?void 0:i.map(l=>l.filter))!==null&&s!==void 0?s:[]};this.socket.accessToken&&(c.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:a},c)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",({postgres_changes:l})=>{var u;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),l===void 0){e&&e("SUBSCRIBED");return}else{const f=this.bindings.postgres_changes,d=(u=f==null?void 0:f.length)!==null&&u!==void 0?u:0,p=[];for(let g=0;g<d;g++){const _=f[g],{filter:{event:m,schema:b,table:w,filter:v}}=_,S=l&&l[g];if(S&&S.event===m&&S.schema===b&&S.table===w&&S.filter===v)p.push(Object.assign(Object.assign({},_),{id:S.id}));else{this.unsubscribe(),e&&e("CHANNEL_ERROR",new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=p,e&&e("SUBSCRIBED");return}}).receive("error",l=>{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(l).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,i){return this._on(e,r,i)}async send(e,r={}){var i,s;if(!this._canPush()&&e.type==="broadcast"){const{event:n,payload:o}=e,c={method:"POST",headers:{apikey:(i=this.socket.accessToken)!==null&&i!==void 0?i:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:n,payload:o}]})};try{return(await this._fetchWithTimeout(this.broadcastEndpointURL,c,(s=r.timeout)!==null&&s!==void 0?s:this.timeout)).ok?"ok":"error"}catch(a){return a.name==="AbortError"?"timed out":"error"}}else return new Promise(n=>{var o,c,a;const l=this._push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((a=(c=(o=this.params)===null||o===void 0?void 0:o.config)===null||c===void 0?void 0:c.broadcast)===null||a===void 0)&&a.ack)&&n("ok"),l.receive("ok",()=>n("ok")),l.receive("timeout",()=>n("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=ie.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(le.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(i=>{const s=new Mr(this,le.leave,{},e);s.receive("ok",()=>{r(),i("ok")}).receive("timeout",()=>{r(),i("timed out")}).receive("error",()=>{i("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}_broadcastEndpointURL(){let e=this.socket.endPoint;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"}async _fetchWithTimeout(e,r,i){const s=new AbortController,n=setTimeout(()=>s.abort(),i),o=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:s.signal}));return clearTimeout(n),o}_push(e,r,i=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new Mr(this,e,r,i);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,r,i){return r}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,r,i){var s,n;const o=e.toLocaleLowerCase(),{close:c,error:a,leave:l,join:u}=le;if(i&&[c,a,l,u].indexOf(o)>=0&&i!==this._joinRef())return;let d=this._onMessage(o,r,i);if(r&&!d)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(p=>{var g,_,m;return((g=p.filter)===null||g===void 0?void 0:g.event)==="*"||((m=(_=p.filter)===null||_===void 0?void 0:_.event)===null||m===void 0?void 0:m.toLocaleLowerCase())===o}).map(p=>p.callback(d,i)):(n=this.bindings[o])===null||n===void 0||n.filter(p=>{var g,_,m,b,w,v;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in p){const S=p.id,k=(g=p.filter)===null||g===void 0?void 0:g.event;return S&&((_=r.ids)===null||_===void 0?void 0:_.includes(S))&&(k==="*"||(k==null?void 0:k.toLocaleLowerCase())===((m=r.data)===null||m===void 0?void 0:m.type.toLocaleLowerCase()))}else{const S=(w=(b=p==null?void 0:p.filter)===null||b===void 0?void 0:b.event)===null||w===void 0?void 0:w.toLocaleLowerCase();return S==="*"||S===((v=r==null?void 0:r.event)===null||v===void 0?void 0:v.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===o}).map(p=>{if(typeof d=="object"&&"ids"in d){const g=d.data,{schema:_,table:m,commit_timestamp:b,type:w,errors:v}=g;d=Object.assign(Object.assign({},{schema:_,table:m,commit_timestamp:b,eventType:w,new:{},old:{},errors:v}),this._getPayloadRecords(g))}p.callback(d,i)})}_isClosed(){return this.state===ie.closed}_isJoined(){return this.state===ie.joined}_isJoining(){return this.state===ie.joining}_isLeaving(){return this.state===ie.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,r,i){const s=e.toLocaleLowerCase(),n={type:s,filter:r,callback:i};return this.bindings[s]?this.bindings[s].push(n):this.bindings[s]=[n],this}_off(e,r){const i=e.toLocaleLowerCase();return this.bindings[i]=this.bindings[i].filter(s=>{var n;return!(((n=s.type)===null||n===void 0?void 0:n.toLocaleLowerCase())===i&&_i.isEqual(s.filter,r))}),this}static isEqual(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const i in e)if(e[i]!==r[i])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(le.close,{},e)}_onError(e){this._on(le.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=ie.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=Gi(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=Gi(e.columns,e.old_record)),r}}const Ga=()=>{},Ks=typeof WebSocket<"u",Ja=Ks?WebSocket:require("ws");class Va{constructor(e,r){var i;this.accessToken=null,this.channels=[],this.endPoint="",this.headers=La,this.params={},this.timeout=Gs,this.transport=Ja,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=Ga,this.conn=null,this.sendBuffer=[],this.serializer=new Ua,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=n=>{let o;return n?o=n:typeof fetch>"u"?o=(...c)=>Nt(()=>Promise.resolve().then(()=>Ut),void 0,import.meta.url).then(({default:a})=>a(...c)):o=fetch,(...c)=>o(...c)},this.endPoint=`${e}/${Hr.websocket}`,r!=null&&r.params&&(this.params=r.params),r!=null&&r.headers&&(this.headers=Object.assign(Object.assign({},this.headers),r.headers)),r!=null&&r.timeout&&(this.timeout=r.timeout),r!=null&&r.logger&&(this.logger=r.logger),r!=null&&r.transport&&(this.transport=r.transport),r!=null&&r.heartbeatIntervalMs&&(this.heartbeatIntervalMs=r.heartbeatIntervalMs);const s=(i=r==null?void 0:r.params)===null||i===void 0?void 0:i.apikey;s&&(this.accessToken=s),this.reconnectAfterMs=r!=null&&r.reconnectAfterMs?r.reconnectAfterMs:n=>[1e3,2e3,5e3,1e4][n-1]||1e4,this.encode=r!=null&&r.encode?r.encode:(n,o)=>o(JSON.stringify(n)),this.decode=r!=null&&r.decode?r.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new Js(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){this.conn||(Ks?this.conn=new this.transport(this._endPointURL()):this.conn=new this.transport(this._endPointURL(),void 0,{headers:this.headers}),this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e)))}disconnect(e,r){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,r??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.disconnect(),e}log(e,r,i){this.logger(e,r,i)}connectionState(){switch(this.conn&&this.conn.readyState){case It.connecting:return He.Connecting;case It.open:return He.Open;case It.closing:return He.Closing;default:return He.Closed}}isConnected(){return this.connectionState()===He.Open}channel(e,r={config:{}}){const i=new _i(`realtime:${e}`,r,this);return this.channels.push(i),i}push(e){const{topic:r,event:i,payload:s,ref:n}=e,o=()=>{this.encode(e,c=>{var a;(a=this.conn)===null||a===void 0||a.send(c)})};this.log("push",`${r} ${i} (${n})`,s),this.isConnected()?o():this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach(r=>{e&&r.updateJoinPayload({access_token:e}),r.joinedOnce&&r._isJoined()&&r._push(le.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let r=this.channels.find(i=>i.topic===e&&(i._isJoined()||i._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${e}"`),r.unsubscribe())}_remove(e){this.channels=this.channels.filter(r=>r._joinRef()!==e._joinRef())}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:$a}))}_onConnMessage(e){this.decode(e.data,r=>{let{topic:i,event:s,payload:n,ref:o}=r;(o&&o===this.pendingHeartbeatRef||s===(n==null?void 0:n.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${n.status||""} ${i} ${s} ${o&&"("+o+")"||""}`,n),this.channels.filter(c=>c._isMember(i)).forEach(c=>c._trigger(s,n,o)),this.stateChangeCallbacks.message.forEach(c=>c(r))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(r=>r(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(r=>r(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(le.error))}_appendParams(e,r){if(Object.keys(r).length===0)return e;const i=e.match(/\?/)?"&":"?",s=new URLSearchParams(r);return`${e}${i}${s}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(ja,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}class gi extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function K(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Ka extends gi{constructor(e,r){super(e),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Yi extends gi{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}var Ya=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};const Ys=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Nt(()=>Promise.resolve().then(()=>Ut),void 0,import.meta.url).then(({default:i})=>i(...r)):e=fetch,(...r)=>e(...r)},Xa=()=>Ya(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Nt(()=>Promise.resolve().then(()=>Ut),void 0,import.meta.url)).Response:Response});var yt=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};const Ar=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Qa=(t,e)=>yt(void 0,void 0,void 0,function*(){const r=yield Xa();t instanceof r?t.json().then(i=>{e(new Ka(Ar(i),t.status||500))}).catch(i=>{e(new Yi(Ar(i),i))}):e(new Yi(Ar(t),t))}),Za=(t,e,r,i)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(i),Object.assign(Object.assign({},s),r))};function mr(t,e,r,i,s,n){return yt(this,void 0,void 0,function*(){return new Promise((o,c)=>{t(r,Za(e,i,s,n)).then(a=>{if(!a.ok)throw a;return i!=null&&i.noResolveJson?a:a.json()}).then(a=>o(a)).catch(a=>Qa(a,c))})})}function Gr(t,e,r,i){return yt(this,void 0,void 0,function*(){return mr(t,"GET",e,r,i)})}function Re(t,e,r,i,s){return yt(this,void 0,void 0,function*(){return mr(t,"POST",e,i,s,r)})}function ec(t,e,r,i,s){return yt(this,void 0,void 0,function*(){return mr(t,"PUT",e,i,s,r)})}function Xs(t,e,r,i,s){return yt(this,void 0,void 0,function*(){return mr(t,"DELETE",e,i,s,r)})}var ne=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};const tc={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Xi={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class rc{constructor(e,r={},i,s){this.url=e,this.headers=r,this.bucketId=i,this.fetch=Ys(s)}uploadOrUpdate(e,r,i,s){return ne(this,void 0,void 0,function*(){try{let n;const o=Object.assign(Object.assign({},Xi),s),c=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});typeof Blob<"u"&&i instanceof Blob?(n=new FormData,n.append("cacheControl",o.cacheControl),n.append("",i)):typeof FormData<"u"&&i instanceof FormData?(n=i,n.append("cacheControl",o.cacheControl)):(n=i,c["cache-control"]=`max-age=${o.cacheControl}`,c["content-type"]=o.contentType);const a=this._removeEmptyFolders(r),l=this._getFinalPath(a),u=yield this.fetch(`${this.url}/object/${l}`,Object.assign({method:e,body:n,headers:c},o!=null&&o.duplex?{duplex:o.duplex}:{})),f=yield u.json();return u.ok?{data:{path:a,id:f.Id,fullPath:f.Key},error:null}:{data:null,error:f}}catch(n){if(K(n))return{data:null,error:n};throw n}})}upload(e,r,i){return ne(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,i)})}uploadToSignedUrl(e,r,i,s){return ne(this,void 0,void 0,function*(){const n=this._removeEmptyFolders(e),o=this._getFinalPath(n),c=new URL(this.url+`/object/upload/sign/${o}`);c.searchParams.set("token",r);try{let a;const l=Object.assign({upsert:Xi.upsert},s),u=Object.assign(Object.assign({},this.headers),{"x-upsert":String(l.upsert)});typeof Blob<"u"&&i instanceof Blob?(a=new FormData,a.append("cacheControl",l.cacheControl),a.append("",i)):typeof FormData<"u"&&i instanceof FormData?(a=i,a.append("cacheControl",l.cacheControl)):(a=i,u["cache-control"]=`max-age=${l.cacheControl}`,u["content-type"]=l.contentType);const f=yield this.fetch(c.toString(),{method:"PUT",body:a,headers:u}),d=yield f.json();return f.ok?{data:{path:n,fullPath:d.Key},error:null}:{data:null,error:d}}catch(a){if(K(a))return{data:null,error:a};throw a}})}createSignedUploadUrl(e){return ne(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e);const i=yield Re(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:this.headers}),s=new URL(this.url+i.url),n=s.searchParams.get("token");if(!n)throw new gi("No token returned by API");return{data:{signedUrl:s.toString(),path:e,token:n},error:null}}catch(r){if(K(r))return{data:null,error:r};throw r}})}update(e,r,i){return ne(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,i)})}move(e,r){return ne(this,void 0,void 0,function*(){try{return{data:yield Re(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r},{headers:this.headers}),error:null}}catch(i){if(K(i))return{data:null,error:i};throw i}})}copy(e,r){return ne(this,void 0,void 0,function*(){try{return{data:{path:(yield Re(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r},{headers:this.headers})).Key},error:null}}catch(i){if(K(i))return{data:null,error:i};throw i}})}createSignedUrl(e,r,i){return ne(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),n=yield Re(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:r},i!=null&&i.transform?{transform:i.transform}:{}),{headers:this.headers});const o=i!=null&&i.download?`&download=${i.download===!0?"":i.download}`:"";return n={signedUrl:encodeURI(`${this.url}${n.signedURL}${o}`)},{data:n,error:null}}catch(s){if(K(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,i){return ne(this,void 0,void 0,function*(){try{const s=yield Re(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),n=i!=null&&i.download?`&download=${i.download===!0?"":i.download}`:"";return{data:s.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${n}`):null})),error:null}}catch(s){if(K(s))return{data:null,error:s};throw s}})}download(e,r){return ne(this,void 0,void 0,function*(){const s=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",n=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),o=n?`?${n}`:"";try{const c=this._getFinalPath(e);return{data:yield(yield Gr(this.fetch,`${this.url}/${s}/${c}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(c){if(K(c))return{data:null,error:c};throw c}})}getPublicUrl(e,r){const i=this._getFinalPath(e),s=[],n=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";n!==""&&s.push(n);const c=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",a=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});a!==""&&s.push(a);let l=s.join("&");return l!==""&&(l=`?${l}`),{data:{publicUrl:encodeURI(`${this.url}/${c}/public/${i}${l}`)}}}remove(e){return ne(this,void 0,void 0,function*(){try{return{data:yield Xs(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(K(r))return{data:null,error:r};throw r}})}list(e,r,i){return ne(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},tc),r),{prefix:e||""});return{data:yield Re(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},i),error:null}}catch(s){if(K(s))return{data:null,error:s};throw s}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}}const ic="2.5.5",sc={"X-Client-Info":`storage-js/${ic}`};var Qe=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};class nc{constructor(e,r={},i){this.url=e,this.headers=Object.assign(Object.assign({},sc),r),this.fetch=Ys(i)}listBuckets(){return Qe(this,void 0,void 0,function*(){try{return{data:yield Gr(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}})}getBucket(e){return Qe(this,void 0,void 0,function*(){try{return{data:yield Gr(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(K(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Qe(this,void 0,void 0,function*(){try{return{data:yield Re(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(i){if(K(i))return{data:null,error:i};throw i}})}updateBucket(e,r){return Qe(this,void 0,void 0,function*(){try{return{data:yield ec(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(i){if(K(i))return{data:null,error:i};throw i}})}emptyBucket(e){return Qe(this,void 0,void 0,function*(){try{return{data:yield Re(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(K(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Qe(this,void 0,void 0,function*(){try{return{data:yield Xs(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(K(r))return{data:null,error:r};throw r}})}}class oc extends nc{constructor(e,r={},i){super(e,r,i)}from(e){return new rc(this.url,this.headers,e,this.fetch)}}const ac="2.39.0";let wt="";typeof Deno<"u"?wt="deno":typeof document<"u"?wt="web":typeof navigator<"u"&&navigator.product==="ReactNative"?wt="react-native":wt="node";const cc={"X-Client-Info":`supabase-js-${wt}/${ac}`};var lc=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};const uc=t=>{let e;return t?e=t:typeof fetch>"u"?e=fi:e=fetch,(...r)=>e(...r)},hc=()=>typeof Headers>"u"?Ws:Headers,dc=(t,e,r)=>{const i=uc(r),s=hc();return(n,o)=>lc(void 0,void 0,void 0,function*(){var c;const a=(c=yield e())!==null&&c!==void 0?c:t;let l=new s(o==null?void 0:o.headers);return l.has("apikey")||l.set("apikey",t),l.has("Authorization")||l.set("Authorization",`Bearer ${a}`),i(n,Object.assign(Object.assign({},o),{headers:l}))})};function fc(t){return t.replace(/\/$/,"")}function pc(t,e){const{db:r,auth:i,realtime:s,global:n}=t,{db:o,auth:c,realtime:a,global:l}=e;return{db:Object.assign(Object.assign({},o),r),auth:Object.assign(Object.assign({},c),i),realtime:Object.assign(Object.assign({},a),s),global:Object.assign(Object.assign({},l),n)}}function _c(t){return Math.round(Date.now()/1e3)+t}function gc(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const ge=()=>typeof document<"u",Be={tested:!1,writable:!1},Ct=()=>{if(!ge())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Be.tested)return Be.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Be.tested=!0,Be.writable=!0}catch{Be.tested=!0,Be.writable=!1}return Be.writable};function Dr(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,n)=>{e[n]=s})}catch{}return r.searchParams.forEach((i,s)=>{e[s]=i}),e}const Qs=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Nt(()=>Promise.resolve().then(()=>Ut),void 0,import.meta.url).then(({default:i})=>i(...r)):e=fetch,(...r)=>e(...r)},mc=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",ze=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Vt=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Pr=async(t,e)=>{await t.removeItem(e)};function yc(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let r="",i,s,n,o,c,a,l,u=0;for(t=t.replace("-","+").replace("_","/");u<t.length;)o=e.indexOf(t.charAt(u++)),c=e.indexOf(t.charAt(u++)),a=e.indexOf(t.charAt(u++)),l=e.indexOf(t.charAt(u++)),i=o<<2|c>>4,s=(c&15)<<4|a>>2,n=(a&3)<<6|l,r=r+String.fromCharCode(i),a!=64&&s!=0&&(r=r+String.fromCharCode(s)),l!=64&&n!=0&&(r=r+String.fromCharCode(n));return r}class yr{constructor(){this.promise=new yr.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}yr.promiseConstructor=Promise;function Qi(t){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,r=t.split(".");if(r.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(r[1]))throw new Error("JWT is not valid: payload is not in base64url format");const i=r[1];return JSON.parse(yc(i))}async function vc(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function bc(t,e){return new Promise((i,s)=>{(async()=>{for(let n=0;n<1/0;n++)try{const o=await t(n);if(!e(n,null,o)){i(o);return}}catch(o){if(!e(n,o)){s(o);return}}})()})}function wc(t){return("0"+t.toString(16)).substr(-2)}function Ze(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",i=r.length;let s="";for(let n=0;n<56;n++)s+=r.charAt(Math.floor(Math.random()*i));return s}return crypto.getRandomValues(e),Array.from(e,wc).join("")}async function Sc(t){const r=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(i);return Array.from(s).map(n=>String.fromCharCode(n)).join("")}function kc(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function et(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await Sc(t);return kc(r)}class mi extends Error{constructor(e,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r}}function T(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Ec extends mi{constructor(e,r){super(e,r),this.name="AuthApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}function Oc(t){return T(t)&&t.name==="AuthApiError"}class Zs extends mi{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class Ke extends mi{constructor(e,r,i){super(e),this.name=r,this.status=i}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class tt extends Ke{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class Nr extends Ke{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500)}}class Kt extends Ke{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class Yt extends Ke{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Zi extends Ke{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Jr extends Ke{constructor(e,r){super(e,"AuthRetryableFetchError",r)}}function Lr(t){return T(t)&&t.name==="AuthRetryableFetchError"}class xc extends Ke{constructor(e,r,i){super(e,"AuthWeakPasswordError",r),this.reasons=i}}var Ic=globalThis&&globalThis.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};const st=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Tc=[502,503,504];async function es(t){if(!mc(t))throw new Jr(st(t),0);if(Tc.includes(t.status))throw new Jr(st(t),t.status);let e;try{e=await t.json()}catch(r){throw new Zs(st(r),r)}throw typeof e=="object"&&e&&typeof e.weak_password=="object"&&e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.reasons.reduce((r,i)=>r&&typeof i=="string",!0)?new xc(st(e),t.status,e.weak_password.reasons):new Ec(st(e),t.status||500)}const Cc=(t,e,r,i)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(i),Object.assign(Object.assign({},s),r))};async function R(t,e,r,i){var s;const n=Object.assign({},i==null?void 0:i.headers);i!=null&&i.jwt&&(n.Authorization=`Bearer ${i.jwt}`);const o=(s=i==null?void 0:i.query)!==null&&s!==void 0?s:{};i!=null&&i.redirectTo&&(o.redirect_to=i.redirectTo);const c=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",a=await Rc(t,e,r+c,{headers:n,noResolveJson:i==null?void 0:i.noResolveJson},{},i==null?void 0:i.body);return i!=null&&i.xform?i==null?void 0:i.xform(a):{data:Object.assign({},a),error:null}}async function Rc(t,e,r,i,s,n){const o=Cc(e,i,s,n);let c;try{c=await t(r,o)}catch(a){throw console.error(a),new Jr(st(a),0)}if(c.ok||await es(c),i!=null&&i.noResolveJson)return c;try{return await c.json()}catch(a){await es(a)}}function Te(t){var e;let r=null;Pc(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=_c(t.expires_in)));const i=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:i},error:null}}function Me(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function Mc(t){return{data:t,error:null}}function Ac(t){const{action_link:e,email_otp:r,hashed_token:i,redirect_to:s,verification_type:n}=t,o=Ic(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),c={action_link:e,email_otp:r,hashed_token:i,redirect_to:s,verification_type:n},a=Object.assign({},o);return{data:{properties:c,user:a},error:null}}function Dc(t){return t}function Pc(t){return t.access_token&&t.refresh_token&&t.expires_in}var Nc=globalThis&&globalThis.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r};class Lc{constructor({url:e="",headers:r={},fetch:i}){this.url=e,this.headers=r,this.fetch=Qs(i),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,r="global"){try{return await R(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(i){if(T(i))return{data:null,error:i};throw i}}async inviteUserByEmail(e,r={}){try{return await R(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Me})}catch(i){if(T(i))return{data:{user:null},error:i};throw i}}async generateLink(e){try{const{options:r}=e,i=Nc(e,["options"]),s=Object.assign(Object.assign({},i),r);return"newEmail"in i&&(s.new_email=i==null?void 0:i.newEmail,delete s.newEmail),await R(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:Ac,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(T(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await R(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Me})}catch(r){if(T(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,i,s,n,o,c,a;try{const l={nextPage:null,lastPage:0,total:0},u=await R(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(i=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:"",per_page:(n=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:""},xform:Dc});if(u.error)throw u.error;const f=await u.json(),d=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,p=(a=(c=u.headers.get("link"))===null||c===void 0?void 0:c.split(","))!==null&&a!==void 0?a:[];return p.length>0&&(p.forEach(g=>{const _=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),m=JSON.parse(g.split(";")[1].split("=")[1]);l[`${m}Page`]=_}),l.total=parseInt(d)),{data:Object.assign(Object.assign({},f),l),error:null}}catch(l){if(T(l))return{data:{users:[]},error:l};throw l}}async getUserById(e){try{return await R(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Me})}catch(r){if(T(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){try{return await R(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Me})}catch(i){if(T(i))return{data:{user:null},error:i};throw i}}async deleteUser(e,r=!1){try{return await R(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Me})}catch(i){if(T(i))return{data:{user:null},error:i};throw i}}async _listFactors(e){try{const{data:r,error:i}=await R(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:i}}catch(r){if(T(r))return{data:null,error:r};throw r}}async _deleteFactor(e){try{return{data:await R(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(T(r))return{data:null,error:r};throw r}}}const en="2.60.1",$c="http://localhost:9999",jc="supabase.auth.token",Uc={"X-Client-Info":`gotrue-js/${en}`},ts=10,Fc={getItem:t=>Ct()?globalThis.localStorage.getItem(t):null,setItem:(t,e)=>{Ct()&&globalThis.localStorage.setItem(t,e)},removeItem:t=>{Ct()&&globalThis.localStorage.removeItem(t)}};function rs(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function qc(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}globalThis&&Ct()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug");class Bc extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}qc();const zc={url:$c,storageKey:jc,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Uc,flowType:"implicit",debug:!1},bt=30*1e3,is=3;async function Hc(t,e,r){return await r()}class Pt{constructor(e){var r;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Pt.nextInstanceID,Pt.nextInstanceID+=1,this.instanceID>0&&ge()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const i=Object.assign(Object.assign({},zc),e);if(this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.persistSession=i.persistSession,this.storageKey=i.storageKey,this.autoRefreshToken=i.autoRefreshToken,this.admin=new Lc({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=Qs(i.fetch),this.lock=i.lock||Hc,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?i.storage?this.storage=i.storage:Ct()?this.storage=Fc:(this.memoryStorage={},this.storage=rs(this.memoryStorage)):(this.memoryStorage={},this.storage=rs(this.memoryStorage)),ge()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(s){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",s)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async s=>{this._debug("received broadcast notification from other tab or client",s),await this._notifyAllSubscribers(s.data.event,s.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${en}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){try{const e=ge()?await this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:r,error:i}=await this._getSessionFromURL(e);if(i)return this._debug("#_initialize()","error detecting session from URL",i),(i==null?void 0:i.message)==="Identity is already linked"||(i==null?void 0:i.message)==="Identity is already linked to another user"?{error:i}:(await this._removeSession(),{error:i});const{session:s,redirectType:n}=r;return this._debug("#_initialize()","detected session in URL",s,"redirect type",n),await this._saveSession(s),setTimeout(async()=>{n==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",s):await this._notifyAllSubscribers("SIGNED_IN",s)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){return T(e)?{error:e}:{error:new Zs("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signUp(e){var r,i,s;try{await this._removeSession();let n;if("email"in e){const{email:u,password:f,options:d}=e;let p=null,g=null;if(this.flowType==="pkce"){const _=Ze();await ze(this.storage,`${this.storageKey}-code-verifier`,_),p=await et(_),g=_===p?"plain":"s256"}n=await R(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:d==null?void 0:d.emailRedirectTo,body:{email:u,password:f,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:p,code_challenge_method:g},xform:Te})}else if("phone"in e){const{phone:u,password:f,options:d}=e;n=await R(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:f,data:(i=d==null?void 0:d.data)!==null&&i!==void 0?i:{},channel:(s=d==null?void 0:d.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken}},xform:Te})}else throw new Kt("You must provide either an email or phone number and a password");const{data:o,error:c}=n;if(c||!o)return{data:{user:null,session:null},error:c};const a=o.session,l=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",a)),{data:{user:l,session:a},error:null}}catch(n){if(T(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithPassword(e){try{await this._removeSession();let r;if("email"in e){const{email:n,password:o,options:c}=e;r=await R(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:n,password:o,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:Te})}else if("phone"in e){const{phone:n,password:o,options:c}=e;r=await R(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:n,password:o,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:Te})}else throw new Kt("You must provide either an email or phone number and a password");const{data:i,error:s}=r;return s?{data:{user:null,session:null},error:s}:!i||!i.session||!i.user?{data:{user:null,session:null},error:new Nr}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:{user:i.user,session:i.session},error:s})}catch(r){if(T(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,i,s,n;return await this._removeSession(),await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(i=e.options)===null||i===void 0?void 0:i.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(n=e.options)===null||n===void 0?void 0:n.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){const[r,i]=(await Vt(this.storage,`${this.storageKey}-code-verifier`)).split("/"),{data:s,error:n}=await R(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:Te});return await Pr(this.storage,`${this.storageKey}-code-verifier`),n?{data:{user:null,session:null,redirectType:null},error:n}:!s||!s.session||!s.user?{data:{user:null,session:null,redirectType:null},error:new Nr}:(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign(Object.assign({},s),{redirectType:i??null}),error:n})}async signInWithIdToken(e){await this._removeSession();try{const{options:r,provider:i,token:s,access_token:n,nonce:o}=e,c=await R(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:i,id_token:s,access_token:n,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Te}),{data:a,error:l}=c;return l?{data:{user:null,session:null},error:l}:!a||!a.session||!a.user?{data:{user:null,session:null},error:new Nr}:(a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:a,error:l})}catch(r){if(T(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,i,s,n,o;try{if(await this._removeSession(),"email"in e){const{email:c,options:a}=e;let l=null,u=null;if(this.flowType==="pkce"){const d=Ze();await ze(this.storage,`${this.storageKey}-code-verifier`,d),l=await et(d),u=d===l?"plain":"s256"}const{error:f}=await R(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:c,data:(r=a==null?void 0:a.data)!==null&&r!==void 0?r:{},create_user:(i=a==null?void 0:a.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken},code_challenge:l,code_challenge_method:u},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in e){const{phone:c,options:a}=e,{data:l,error:u}=await R(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:c,data:(s=a==null?void 0:a.data)!==null&&s!==void 0?s:{},create_user:(n=a==null?void 0:a.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken},channel:(o=a==null?void 0:a.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:l==null?void 0:l.message_id},error:u}}throw new Kt("You must provide either an email or phone number.")}catch(c){if(T(c))return{data:{user:null,session:null},error:c};throw c}}async verifyOtp(e){var r,i;try{e.type!=="email_change"&&e.type!=="phone_change"&&await this._removeSession();let s,n;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,n=(i=e.options)===null||i===void 0?void 0:i.captchaToken);const{data:o,error:c}=await R(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:n}}),redirectTo:s,xform:Te});if(c)throw c;if(!o)throw new Error("An error occurred on token verification.");const a=o.session,l=o.user;return a!=null&&a.access_token&&(await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)),{data:{user:l,session:a},error:null}}catch(s){if(T(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var r,i,s;try{await this._removeSession();let n=null,o=null;if(this.flowType==="pkce"){const c=Ze();await ze(this.storage,`${this.storageKey}-code-verifier`,c),n=await et(c),o=c===n?"plain":"s256"}return await R(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(i=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&i!==void 0?i:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:n,code_challenge_method:o}),headers:this.headers,xform:Mc})}catch(n){if(T(n))return{data:null,error:n};throw n}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:i}=e;if(i)throw i;if(!r)throw new tt;const{error:s}=await R(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(T(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{e.type!="email_change"&&e.type!="phone_change"&&await this._removeSession();const r=`${this.url}/resend`;if("email"in e){const{email:i,type:s,options:n}=e,{error:o}=await R(this.fetch,"POST",r,{headers:this.headers,body:{email:i,type:s,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},redirectTo:n==null?void 0:n.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in e){const{phone:i,type:s,options:n}=e,{data:o,error:c}=await R(this.fetch,"POST",r,{headers:this.headers,body:{phone:i,type:s,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:c}}throw new Kt("You must provide either an email or phone number and a type")}catch(r){if(T(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,this._acquireLock(-1,async()=>this._useSession(async e=>e))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const i=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await i,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const i=r();for(this.pendingInLock.push((async()=>{try{await i}catch{}})()),await i;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await i}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Vt(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const i=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${i?"":" not"} expired`,"expires_at",e.expires_at),!i)return{data:{session:e},error:null};const{session:s,error:n}=await this._callRefreshToken(e.refresh_token);return n?{data:{session:null},error:n}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await R(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Me}):await this._useSession(async r=>{var i,s;const{data:n,error:o}=r;if(o)throw o;return await R(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(s=(i=n.session)===null||i===void 0?void 0:i.access_token)!==null&&s!==void 0?s:void 0,xform:Me})})}catch(r){if(T(r))return{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async i=>{const{data:s,error:n}=i;if(n)throw n;if(!s.session)throw new tt;const o=s.session;let c=null,a=null;if(this.flowType==="pkce"&&e.email!=null){const f=Ze();await ze(this.storage,`${this.storageKey}-code-verifier`,f),c=await et(f),a=f===c?"plain":"s256"}const{data:l,error:u}=await R(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:c,code_challenge_method:a}),jwt:o.access_token,xform:Me});if(u)throw u;return o.user=l.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(i){if(T(i))return{data:{user:null},error:i};throw i}}_decodeJWT(e){return Qi(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new tt;const r=Date.now()/1e3;let i=r,s=!0,n=null;const o=Qi(e.access_token);if(o.exp&&(i=o.exp,s=i<=r),s){const{session:c,error:a}=await this._callRefreshToken(e.refresh_token);if(a)return{data:{user:null,session:null},error:a};if(!c)return{data:{user:null,session:null},error:null};n=c}else{const{data:c,error:a}=await this._getUser(e.access_token);if(a)throw a;n={access_token:e.access_token,refresh_token:e.refresh_token,user:c.user,token_type:"bearer",expires_in:i-r,expires_at:i},await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)}return{data:{user:n.user,session:n},error:null}}catch(r){if(T(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var i;if(!e){const{data:o,error:c}=r;if(c)throw c;e=(i=o.session)!==null&&i!==void 0?i:void 0}if(!(e!=null&&e.refresh_token))throw new tt;const{session:s,error:n}=await this._callRefreshToken(e.refresh_token);return n?{data:{user:null,session:null},error:n}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(T(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e){try{if(!ge())throw new Yt("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new Yt("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new Zi("Not a valid PKCE flow url.");const r=Dr(window.location.href);if(e){if(!r.code)throw new Zi("No code detected.");const{data:w,error:v}=await this._exchangeCodeForSession(r.code);if(v)throw v;const S=new URL(window.location.href);return S.searchParams.delete("code"),window.history.replaceState(window.history.state,"",S.toString()),{data:{session:w.session,redirectType:null},error:null}}if(r.error||r.error_description||r.error_code)throw new Yt(r.error_description||"Error in URL with unspecified error_description",{error:r.error||"unspecified_error",code:r.error_code||"unspecified_code"});const{provider_token:i,provider_refresh_token:s,access_token:n,refresh_token:o,expires_in:c,expires_at:a,token_type:l}=r;if(!n||!c||!o||!l)throw new Yt("No session defined in URL");const u=Math.round(Date.now()/1e3),f=parseInt(c);let d=u+f;a&&(d=parseInt(a));const p=d-u;p*1e3<=bt&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${f}s`);const g=d-f;u-g>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",g,d,u):u-g<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clok for skew",g,d,u);const{data:_,error:m}=await this._getUser(n);if(m)throw m;const b={provider_token:i,provider_refresh_token:s,access_token:n,expires_in:f,expires_at:d,refresh_token:o,token_type:l,user:_.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:b,redirectType:r.type},error:null}}catch(r){if(T(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantFlow(){const e=Dr(window.location.href);return!!(ge()&&(e.access_token||e.error_description))}async _isPKCEFlow(){const e=Dr(window.location.href),r=await Vt(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var i;const{data:s,error:n}=r;if(n)return{error:n};const o=(i=s.session)===null||i===void 0?void 0:i.access_token;if(o){const{error:c}=await this.admin.signOut(o,e);if(c&&!(Oc(c)&&(c.status===404||c.status===401)))return{error:c}}return e!=="others"&&(await this._removeSession(),await Pr(this.storage,`${this.storageKey}-code-verifier`),await this._notifyAllSubscribers("SIGNED_OUT",null)),{error:null}})}onAuthStateChange(e){const r=gc(),i={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,i),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:i}}}async _emitInitialSession(e){return await this._useSession(async r=>{var i,s;try{const{data:{session:n},error:o}=r;if(o)throw o;await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",n)),this._debug("INITIAL_SESSION","callback id",e,"session",n)}catch(n){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",n),console.error(n)}})}async resetPasswordForEmail(e,r={}){let i=null,s=null;if(this.flowType==="pkce"){const n=Ze();await ze(this.storage,`${this.storageKey}-code-verifier`,`${n}/PASSWORD_RECOVERY`),i=await et(n),s=n===i?"plain":"s256"}try{return await R(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:i,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(n){if(T(n))return{data:null,error:n};throw n}}async getUserIdentities(){var e;try{const{data:r,error:i}=await this.getUser();if(i)throw i;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if(T(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{const{data:i,error:s}=await this._useSession(async n=>{var o,c,a,l,u;const{data:f,error:d}=n;if(d)throw d;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(c=e.options)===null||c===void 0?void 0:c.scopes,queryParams:(a=e.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:!0});return await R(this.fetch,"GET",p,{headers:this.headers,jwt:(u=(l=f.session)===null||l===void 0?void 0:l.access_token)!==null&&u!==void 0?u:void 0})});if(s)throw s;return ge()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(i==null?void 0:i.url),{data:{provider:e.provider,url:i==null?void 0:i.url},error:null}}catch(i){if(T(i))return{data:{provider:e.provider,url:null},error:i};throw i}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var i,s;const{data:n,error:o}=r;if(o)throw o;return await R(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(i=n.session)===null||i===void 0?void 0:i.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(T(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const i=Date.now();return await bc(async s=>(await vc(s*200),this._debug(r,"refreshing attempt",s),await R(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Te})),(s,n,o)=>o&&o.error&&Lr(o.error)&&Date.now()+(s+1)*200-i<bt)}catch(i){if(this._debug(r,"error",i),T(i))return{data:{session:null,user:null},error:i};throw i}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const i=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",i),ge()&&!r.skipBrowserRedirect&&window.location.assign(i),{data:{provider:e,url:i},error:null}}async _recoverAndRefresh(){var e;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const i=await Vt(this.storage,this.storageKey);if(this._debug(r,"session from storage",i),!this._isValidSession(i)){this._debug(r,"session is not valid"),i!==null&&await this._removeSession();return}const s=Math.round(Date.now()/1e3),n=((e=i.expires_at)!==null&&e!==void 0?e:1/0)<s+ts;if(this._debug(r,`session has${n?"":" not"} expired with margin of ${ts}s`),n){if(this.autoRefreshToken&&i.refresh_token){const{error:o}=await this._callRefreshToken(i.refresh_token);o&&(console.error(o),Lr(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",i)}catch(i){this._debug(r,"error",i),console.error(i);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var r,i;if(!e)throw new tt;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new yr;const{data:n,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!n.session)throw new tt;await this._saveSession(n.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",n.session);const c={session:n.session,error:null};return this.refreshingDeferred.resolve(c),c}catch(n){if(this._debug(s,"error",n),T(n)){const o={session:null,error:n};return Lr(n)||(await this._removeSession(),await this._notifyAllSubscribers("SIGNED_OUT",null)),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(i=this.refreshingDeferred)===null||i===void 0||i.reject(n),n}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,r,i=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",r,`broadcast = ${i}`);try{this.broadcastChannel&&i&&this.broadcastChannel.postMessage({event:e,session:r});const n=[],o=Array.from(this.stateChangeEmitters.values()).map(async c=>{try{await c.callback(e,r)}catch(a){n.push(a)}});if(await Promise.all(o),n.length>0){for(let c=0;c<n.length;c+=1)console.error(n[c]);throw n[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),await ze(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await Pr(this.storage,this.storageKey)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ge()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),bt);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:i}}=r;if(!i||!i.refresh_token||!i.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((i.expires_at*1e3-e)/bt);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${bt}ms, refresh threshold is ${is} ticks`),s<=is&&await this._callRefreshToken(i.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Bc)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ge()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,i){const s=[`provider=${encodeURIComponent(r)}`];if(i!=null&&i.redirectTo&&s.push(`redirect_to=${encodeURIComponent(i.redirectTo)}`),i!=null&&i.scopes&&s.push(`scopes=${encodeURIComponent(i.scopes)}`),this.flowType==="pkce"){const n=Ze();await ze(this.storage,`${this.storageKey}-code-verifier`,n);const o=await et(n),c=n===o?"plain":"s256";this._debug("PKCE","code verifier",`${n.substring(0,5)}...`,"code challenge",o,"method",c);const a=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(c)}`});s.push(a.toString())}if(i!=null&&i.queryParams){const n=new URLSearchParams(i.queryParams);s.push(n.toString())}return i!=null&&i.skipBrowserRedirect&&s.push(`skip_http_redirect=${i.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var i;const{data:s,error:n}=r;return n?{data:null,error:n}:await R(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(i=s==null?void 0:s.session)===null||i===void 0?void 0:i.access_token})})}catch(r){if(T(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var i,s;const{data:n,error:o}=r;if(o)return{data:null,error:o};const{data:c,error:a}=await R(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(i=n==null?void 0:n.session)===null||i===void 0?void 0:i.access_token});return a?{data:null,error:a}:(!((s=c==null?void 0:c.totp)===null||s===void 0)&&s.qr_code&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(T(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var i;const{data:s,error:n}=r;if(n)return{data:null,error:n};const{data:o,error:c}=await R(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(i=s==null?void 0:s.session)===null||i===void 0?void 0:i.access_token});return c?{data:null,error:c}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:c})})}catch(r){if(T(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var i;const{data:s,error:n}=r;return n?{data:null,error:n}:await R(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(i=s==null?void 0:s.session)===null||i===void 0?void 0:i.access_token})})}catch(r){if(T(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){const{data:r,error:i}=await this._challenge({factorId:e.factorId});return i?{data:null,error:i}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){const{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};const i=(e==null?void 0:e.factors)||[],s=i.filter(n=>n.factor_type==="totp"&&n.status==="verified");return{data:{all:i,totp:s},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,i;const{data:{session:s},error:n}=e;if(n)return{data:null,error:n};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const o=this._decodeJWT(s.access_token);let c=null;o.aal&&(c=o.aal);let a=c;((i=(r=s.user.factors)===null||r===void 0?void 0:r.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(a="aal2");const u=o.amr||[];return{data:{currentLevel:c,nextLevel:a,currentAuthenticationMethods:u},error:null}}))}}Pt.nextInstanceID=0;class Wc extends Pt{constructor(e){super(e)}}var Gc=globalThis&&globalThis.__awaiter||function(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function c(u){try{l(i.next(u))}catch(f){o(f)}}function a(u){try{l(i.throw(u))}catch(f){o(f)}}function l(u){u.done?n(u.value):s(u.value).then(c,a)}l((i=i.apply(t,e||[])).next())})};const Jc={headers:cc},Vc={schema:"public"},Kc={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Yc={};class Xc{constructor(e,r,i){var s,n,o,c,a,l,u,f;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const d=fc(e);this.realtimeUrl=`${d}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${d}/auth/v1`,this.storageUrl=`${d}/storage/v1`,this.functionsUrl=`${d}/functions/v1`;const p=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,g={db:Vc,realtime:Yc,auth:Object.assign(Object.assign({},Kc),{storageKey:p}),global:Jc},_=pc(i??{},g);this.storageKey=(n=(s=_.auth)===null||s===void 0?void 0:s.storageKey)!==null&&n!==void 0?n:"",this.headers=(c=(o=_.global)===null||o===void 0?void 0:o.headers)!==null&&c!==void 0?c:{},this.auth=this._initSupabaseAuthClient((a=_.auth)!==null&&a!==void 0?a:{},this.headers,(l=_.global)===null||l===void 0?void 0:l.fetch),this.fetch=dc(r,this._getAccessToken.bind(this),(u=_.global)===null||u===void 0?void 0:u.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},_.realtime)),this.rest=new pi(`${d}/rest/v1`,{headers:this.headers,schema:(f=_.db)===null||f===void 0?void 0:f.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new Oa(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new oc(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},i){return this.rest.rpc(e,r,i)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return Gc(this,void 0,void 0,function*(){const{data:i}=yield this.auth.getSession();return(r=(e=i.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:i,storage:s,storageKey:n,flowType:o,debug:c},a,l){const u={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Wc({url:this.authUrl,headers:Object.assign(Object.assign({},u),a),storageKey:n,autoRefreshToken:e,persistSession:r,detectSessionInUrl:i,storage:s,flowType:o,debug:c,fetch:l})}_initRealtimeClient(e){return new Va(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,i)=>{this._handleTokenChanged(r,"CLIENT",i==null?void 0:i.access_token)})}_handleTokenChanged(e,r,i){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==i?(this.realtime.setAuth(i??null),this.changedAccessToken=i):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Qc=(t,e,r)=>new Xc(t,e,r);var Zc=Object.create,tn=Object.defineProperty,el=Object.getOwnPropertyDescriptor,rn=Object.getOwnPropertyNames,tl=Object.getPrototypeOf,rl=Object.prototype.hasOwnProperty,il=(t,e)=>function(){return e||(0,t[rn(t)[0]])((e={exports:{}}).exports,e),e.exports},sl=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rn(e))!rl.call(t,s)&&s!==r&&tn(t,s,{get:()=>e[s],enumerable:!(i=el(e,s))||i.enumerable});return t},sn=(t,e,r)=>(r=t!=null?Zc(tl(t)):{},sl(e||!t||!t.__esModule?tn(r,"default",{value:t,enumerable:!0}):r,t)),nn=il({"../../node_modules/.pnpm/cookie@0.5.0/node_modules/cookie/index.js"(t){t.parse=i,t.serialize=s;var e=Object.prototype.toString,r=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function i(l,u){if(typeof l!="string")throw new TypeError("argument str must be a string");for(var f={},d=u||{},p=d.decode||n,g=0;g<l.length;){var _=l.indexOf("=",g);if(_===-1)break;var m=l.indexOf(";",g);if(m===-1)m=l.length;else if(m<_){g=l.lastIndexOf(";",_-1)+1;continue}var b=l.slice(g,_).trim();if(f[b]===void 0){var w=l.slice(_+1,m).trim();w.charCodeAt(0)===34&&(w=w.slice(1,-1)),f[b]=a(w,p)}g=m+1}return f}function s(l,u,f){var d=f||{},p=d.encode||o;if(typeof p!="function")throw new TypeError("option encode is invalid");if(!r.test(l))throw new TypeError("argument name is invalid");var g=p(u);if(g&&!r.test(g))throw new TypeError("argument val is invalid");var _=l+"="+g;if(d.maxAge!=null){var m=d.maxAge-0;if(isNaN(m)||!isFinite(m))throw new TypeError("option maxAge is invalid");_+="; Max-Age="+Math.floor(m)}if(d.domain){if(!r.test(d.domain))throw new TypeError("option domain is invalid");_+="; Domain="+d.domain}if(d.path){if(!r.test(d.path))throw new TypeError("option path is invalid");_+="; Path="+d.path}if(d.expires){var b=d.expires;if(!c(b)||isNaN(b.valueOf()))throw new TypeError("option expires is invalid");_+="; Expires="+b.toUTCString()}if(d.httpOnly&&(_+="; HttpOnly"),d.secure&&(_+="; Secure"),d.priority){var w=typeof d.priority=="string"?d.priority.toLowerCase():d.priority;switch(w){case"low":_+="; Priority=Low";break;case"medium":_+="; Priority=Medium";break;case"high":_+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(d.sameSite){var v=typeof d.sameSite=="string"?d.sameSite.toLowerCase():d.sameSite;switch(v){case!0:_+="; SameSite=Strict";break;case"lax":_+="; SameSite=Lax";break;case"strict":_+="; SameSite=Strict";break;case"none":_+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return _}function n(l){return l.indexOf("%")!==-1?decodeURIComponent(l):l}function o(l){return encodeURIComponent(l)}function c(l){return e.call(l)==="[object Date]"||l instanceof Date}function a(l,u){try{return u(l)}catch{return l}}}}),$r=sn(nn()),on=sn(nn());function ss(t){if(!t)return null;try{const e=JSON.parse(t);if(!e)return null;if(e.constructor.name==="Object")return e;if(e.constructor.name!=="Array")throw new Error(`Unexpected format: ${e.constructor.name}`);const[r,i,s]=e[0].split("."),n=va(i),o=new TextDecoder,{exp:c,sub:a,...l}=JSON.parse(o.decode(n));return{expires_at:c,expires_in:c-Math.round(Date.now()/1e3),token_type:"bearer",access_token:e[0],refresh_token:e[1],provider_token:e[2],provider_refresh_token:e[3],user:{id:a,factors:e[4],...l}}}catch(e){return console.warn("Failed to parse cookie string:",e),null}}function nl(t){var e;return JSON.stringify([t.access_token,t.refresh_token,t.provider_token,t.provider_refresh_token,((e=t.user)==null?void 0:e.factors)??null])}function ht(){return typeof window<"u"&&typeof window.document<"u"}var ns={path:"/",sameSite:"lax",maxAge:60*60*24*365*1e3};function an(t){return new RegExp(".{1,"+t+"}","g")}var cn=3180,ol=an(cn);function al(t,e,r){const i=r!==void 0?an(r):ol;if(Math.ceil(e.length/(r??cn))===1)return[{name:t,value:e}];const n=[],o=e.match(i);return o==null||o.forEach((c,a)=>{const l=`${t}.${a}`;n.push({name:l,value:c})}),n}function cl(t,e=()=>null){let r=[];for(let i=0;;i++){const s=`${t}.${i}`,n=e(s);if(!n)break;r.push(n)}return r.length?r.join(""):null}var ll=class{constructor(t){this.cookieOptions={...ns,...t,maxAge:ns.maxAge}}getItem(t){const e=this.getCookie(t);if(t.endsWith("-code-verifier")&&e)return e;if(e)return JSON.stringify(ss(e));const r=cl(t,i=>this.getCookie(i));return r!==null?JSON.stringify(ss(r)):null}setItem(t,e){if(t.endsWith("-code-verifier")){this.setCookie(t,e);return}let r=JSON.parse(e);const i=nl(r);al(t,i).forEach(n=>{this.setCookie(n.name,n.value)})}removeItem(t){this._deleteSingleCookie(t),this._deleteChunkedCookies(t)}_deleteSingleCookie(t){this.getCookie(t)&&this.deleteCookie(t)}_deleteChunkedCookies(t,e=0){for(let r=e;;r++){const i=`${t}.${r}`;if(this.getCookie(i)===void 0)break;this.deleteCookie(i)}}},ul=class extends ll{constructor(t){super(t)}getCookie(t){return ht()?(0,$r.parse)(document.cookie)[t]:null}setCookie(t,e){if(!ht())return null;document.cookie=(0,$r.serialize)(t,e,{...this.cookieOptions,httpOnly:!1})}deleteCookie(t){if(!ht())return null;document.cookie=(0,$r.serialize)(t,"",{...this.cookieOptions,maxAge:0,httpOnly:!1})}};function hl(t,e,r){var i;const s=ht();return Qc(t,e,{...r,auth:{flowType:"pkce",autoRefreshToken:s,detectSessionInUrl:s,persistSession:!0,storage:r.auth.storage,...(i=r.auth)!=null&&i.storageKey?{storageKey:r.auth.storageKey}:{}}})}on.parse;on.serialize;/*! Bundled license information:

cookie/index.js:
  (*!
   * cookie
   * Copyright(c) 2012-2014 Roman Shtylman
   * Copyright(c) 2015 Douglas Christopher Wilson
   * MIT Licensed
   *)
*/var dl=class extends ul{constructor(t=null,e){super(e),this.serverSession=t}getItem(t){return ht()?super.getItem(t):JSON.stringify(this.serverSession)}},jr;function fl({supabaseUrl:t,supabaseKey:e,event:r,serverSession:i,options:s,cookieOptions:n}){var o;const c=ht();if(c&&jr)return jr;const a=hl(t,e,{...s,global:{fetch:r.fetch,...s==null?void 0:s.global,headers:{...(o=s==null?void 0:s.global)==null?void 0:o.headers,"X-Client-Info":"@supabase/auth-helpers-sveltekit@0.10.7"}},auth:{storage:new dl(i,n)}});return c&&(jr=a),a}const pl=async({fetch:t,data:e,depends:r})=>{var n;r("supabase:auth");const i=fl({supabaseUrl:vt.PUBLIC_SUPABASE_URL,supabaseKey:vt.PUBLIC_SUPABASE_ANON_KEY,event:{fetch:t},serverSession:e.session}),{data:{session:s}}=await i.auth.getSession();return vt.PUBLIC_ENV==="production"&&(Jt.init(vt.PUBLIC_MIXPANEL_TOKEN,{debug:!0,track_pageview:!0,persistence:"localStorage"}),Jt.identify((n=s==null?void 0:s.user)==null?void 0:n.id),Jt.people.set({$email:s==null?void 0:s.user.email})),{supabase:i,session:s,mixpanel:vt.PUBLIC_ENV==="production"?Jt:null}},xl=Object.freeze(Object.defineProperty({__proto__:null,load:pl},Symbol.toStringTag,{value:"Module"}));const _l=Sn(null);function gl(t){let e,r="로그인",i,s;return{c(){e=me("button"),e.textContent=r,this.h()},l(n){e=ye(n,"BUTTON",{class:!0,"data-svelte-h":!0}),Zt(e)!=="svelte-85f29j"&&(e.textContent=r),this.h()},h(){ke(e,"class","rounded-md h-10 text-center bg-orange-100 px-3.5 py-2.5 text-sm font-semibold text-black leading-tight hover:bg-black hover:text-white border-[1px] border-black shadow-[2px_2px_0px_0px_#000] hover:shadow-none")},m(n,o){Vr(n,e,o),i||(s=bn(e,"click",t[1]),i=!0)},p:os,d(n){n&&Se(e),i=!1,s()}}}function ml(t){let e,r='<button class="rounded-md h-10 text-center bg-orange-100 px-3.5 py-2.5 text-sm font-semibold text-black leading-tight hover:bg-black hover:text-white border-[1px] border-black shadow-[2px_2px_0px_0px_#000] hover:shadow-none">내 정보</button>';return{c(){e=me("a"),e.innerHTML=r,this.h()},l(i){e=ye(i,"A",{href:!0,"aria-current":!0,"data-svelte-h":!0}),Zt(e)!=="svelte-12m72gn"&&(e.innerHTML=r),this.h()},h(){ke(e,"href","/account"),ke(e,"aria-current","page")},m(i,s){Vr(i,e,s)},p:os,d(i){i&&Se(e)}}}function yl(t){let e,r,i,s,n='<a href="/" class="flex items-center space-x-3 rtl:space-x-reverse"><span class="self-center text-2xl font-bold whitespace-nowrap font-mimi">에피코딩</span></a>',o,c,a,l,u,f,d,p='<div class="mx-auto w-full max-w-screen-xl"><div class="grid grid-cols-1 gap-8 px-4 py-6 lg:py-8 md:grid-cols-2"><div><ul class="text-gray-500 text-sm"><li class="mb-1">상호명: 에피테크</li> <li class="mb-1">사업자등록번호: 355-24-01642</li> <li class="mb-1">통신판매업신고번호: 2023-서울광진-2136</li> <li class="mb-1">대표자명: 손태희</li> <li class="mb-1">사업장 주소: 서울특별시 광진구 능동로44길 27-5(중곡동)</li> <li class="mb-1">연락처: <a target="_blank" href="https://discord.gg/QqRrykr5K9">디스코드</a></li></ul></div> <div><ul class="text-gray-500 text-sm"><li class="mb-2"><a href="/">홈</a></li> <li class="mb-2"><a href="/legal">이용약관</a></li> <li class="mb-2"><a target="_blank" href="https://www.youtube.com/@effy_coding">유튜브</a></li> <li class="mb-2"><a target="_blank" href="https://discord.gg/QqRrykr5K9">디스코드</a></li></ul></div></div> <div class="px-4 py-6 md:flex md:items-center md:justify-between"><span class="text-sm text-gray-500 sm:text-center">© 2024 에피코딩 All Rights Reserved.</span></div></div>',g;function _(S,k){return S[0]?ml:gl}let m=_(t),b=m(t);const w=t[4].default,v=hn(w,t,t[3],null);return{c(){e=me("div"),r=me("nav"),i=me("div"),s=me("div"),s.innerHTML=n,o=Er(),c=me("div"),a=me("ul"),l=me("li"),b.c(),u=Er(),v&&v.c(),f=Er(),d=me("footer"),d.innerHTML=p,this.h()},l(S){e=ye(S,"DIV",{class:!0});var k=Ye(e);r=ye(k,"NAV",{});var H=Ye(r);i=ye(H,"DIV",{class:!0});var F=Ye(i);s=ye(F,"DIV",{class:!0,"data-svelte-h":!0}),Zt(s)!=="svelte-1tdnt5t"&&(s.innerHTML=n),o=Or(F),c=ye(F,"DIV",{class:!0,id:!0});var N=Ye(c);a=ye(N,"UL",{class:!0});var L=Ye(a);l=ye(L,"LI",{});var X=Ye(l);b.l(X),X.forEach(Se),L.forEach(Se),N.forEach(Se),F.forEach(Se),H.forEach(Se),u=Or(k),v&&v.l(k),f=Or(k),d=ye(k,"FOOTER",{"data-svelte-h":!0}),Zt(d)!=="svelte-xep03"&&(d.innerHTML=p),k.forEach(Se),this.h()},h(){ke(s,"class","flex flex-1"),ke(a,"class","font-medium flex flex-col md:p-0 rounded-lg rtl:space-x-reverse mt-0"),ke(c,"class","flex w-auto"),ke(c,"id","navbar-default"),ke(i,"class","max-w-screen-xl flex flex-wrap mx-auto p-4"),ke(e,"class","app svelte-cile87")},m(S,k){Vr(S,e,k),pe(e,r),pe(r,i),pe(i,s),pe(i,o),pe(i,c),pe(c,a),pe(a,l),b.m(l,null),pe(e,u),v&&v.m(e,null),pe(e,f),pe(e,d),g=!0},p(S,[k]){m===(m=_(S))&&b?b.p(S,k):(b.d(1),b=m(S),b&&(b.c(),b.m(l,null))),v&&v.p&&(!g||k&8)&&dn(v,w,S,S[3],g?pn(w,S[3],k,null):fn(S[3]),null)},i(S){g||(yn(v,S),g=!0)},o(S){vn(v,S),g=!1},d(S){S&&Se(e),b.d(),v&&v.d(S)}}}function vl(t,e,r){let{$$slots:i={},$$scope:s}=e,{data:n}=e,{supabase:o,session:c}=n;_n(()=>{const{data:l}=o.auth.onAuthStateChange((u,f)=>{(f==null?void 0:f.expires_at)!==(c==null?void 0:c.expires_at)&&wn("supabase:auth")});return()=>l.subscription.unsubscribe()});async function a(){const{error:l}=await o.auth.signInWithOAuth({provider:"google",options:{redirectTo:`${location.origin}/auth/callback`,queryParams:{access_type:"offline",prompt:"consent"}}});l&&console.error(l)}return t.$$set=l=>{"data"in l&&r(2,n=l.data),"$$scope"in l&&r(3,s=l.$$scope)},t.$$.update=()=>{var l,u;t.$$.dirty&4&&r(0,{supabase:o,session:c}=n,c),t.$$.dirty&1&&(l=c==null?void 0:c.user)!=null&&l.id&&_l.set((u=c==null?void 0:c.user)==null?void 0:u.id)},[c,a,n,s,i]}class Il extends gn{constructor(e){super(),mn(this,e,vl,yl,un,{data:2})}}export{Il as component,xl as universal};
