@useknest/widget-web 0.1.0-beta.14 → 0.1.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- (function(Ct,Ur){typeof exports=="object"&&typeof module<"u"?Ur(exports):typeof define=="function"&&define.amd?define(["exports"],Ur):(Ct=typeof globalThis<"u"?globalThis:Ct||self,Ur(Ct.KnestWidget={}))})(this,(function(Ct){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");const Fr=1,Mr=2,Wa=4,cd=8,ud=16,dd=1,hd=2,Ga="[",sr="[!",Ys="]",Vt={},ge=Symbol(),fd="http://www.w3.org/1999/xhtml",Ka=!1;var Xs=Array.isArray,pd=Array.prototype.indexOf,Zs=Array.from,Br=Object.keys,Rn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,gd=Object.getOwnPropertyDescriptors,md=Object.prototype,_d=Array.prototype,Va=Object.getPrototypeOf,Ja=Object.isExtensible;const vd=()=>{};function Ya(t){return typeof t?.then=="function"}function bd(t){for(var e=0;e<t.length;e++)t[e]()}function Xa(){var t,e,n=new Promise((r,s)=>{t=r,e=s});return{promise:n,resolve:t,reject:e}}const $e=2,Qs=4,ei=8,Jt=16,vt=32,Pt=64,ti=128,We=256,qr=512,ke=1024,je=2048,Nt=4096,Qe=8192,Yt=16384,ni=32768,Hr=65536,Za=1<<17,yd=1<<18,Xt=1<<19,wd=1<<20,ri=1<<21,zr=1<<22,Zt=1<<23,Wr=Symbol("$state"),Ed=Symbol("legacy props"),kd=Symbol(""),ir=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},si=3,Qt=8;function Sd(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Td(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function xd(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Ad(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Od(t){throw new Error("https://svelte.dev/e/effect_orphan")}function Rd(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Id(){throw new Error("https://svelte.dev/e/hydration_failed")}function $d(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Cd(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Pd(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Nd(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function ar(t){console.warn("https://svelte.dev/e/hydration_mismatch")}function Ld(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let N=!1;function De(t){N=t}let F;function Ee(t){if(t===null)throw ar(),Vt;return F=t}function en(){return Ee(et(F))}function K(t){if(N){if(et(F)!==null)throw ar(),Vt;F=t}}function jd(t=1){if(N){for(var e=t,n=F;e--;)n=et(n);F=n}}function or(t=!0){for(var e=0,n=F;;){if(n.nodeType===Qt){var r=n.data;if(r===Ys){if(e===0)return n;e-=1}else(r===Ga||r===sr)&&(e+=1)}var s=et(n);t&&n.remove(),n=s}}function Qa(t){if(!t||t.nodeType!==Qt)throw ar(),Vt;return t.data}function eo(t){return t===this.v}function Dd(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function to(t){return!Dd(t,this.v)}let Ud=!1,Ce=null;function Lt(t){Ce=t}function Gr(t,e=!1,n){Ce={p:Ce,c:null,e:null,s:t,x:null,l:null}}function Kr(t){var e=Ce,n=e.e;if(n!==null){e.e=null;for(var r of n)So(r)}return t!==void 0&&(e.x=t),Ce=e.p,t??{}}function no(){return!0}let tn=[];function ro(){var t=tn;tn=[],bd(t)}function bt(t){if(tn.length===0&&!Cn){var e=tn;queueMicrotask(()=>{e===tn&&ro()})}tn.push(t)}function Fd(){for(;tn.length>0;)ro()}const Md=new WeakMap;function so(t){var e=U;if(e===null)return B.f|=Zt,t;if((e.f&ni)===0){if((e.f&ti)===0)throw!e.parent&&t instanceof Error&&io(t),t;e.b.error(t)}else $n(t,e)}function $n(t,e){for(;e!==null;){if((e.f&ti)!==0)try{e.b.error(t);return}catch(n){t=n}e=e.parent}throw t instanceof Error&&io(t),t}function io(t){const e=Md.get(t);e&&(Rn(t,"message",{value:e.message}),Rn(t,"stack",{value:e.stack}))}const Vr=new Set;let ne=null,Jr=null,ii=new Set,ct=[],Yr=null,ai=!1,Cn=!1;class Ue{current=new Map;#t=new Map;#e=new Set;#u=0;#i=null;#l=[];#s=[];#r=[];#n=[];#a=[];#c=[];skipped_effects=new Set;process(e){ct=[],Jr=null;var n=Ue.apply(this);for(const i of e)this.#d(i);if(this.#u===0){this.#h();var r=this.#s,s=this.#r;this.#s=[],this.#r=[],this.#n=[],Jr=this,ne=null,oo(r),oo(s),Jr=null,this.#i?.resolve()}else this.#o(this.#s),this.#o(this.#r),this.#o(this.#n);n();for(const i of this.#l)dr(i);this.#l=[]}#d(e){e.f^=ke;for(var n=e.first;n!==null;){var r=n.f,s=(r&(vt|Pt))!==0,i=s&&(r&ke)!==0,a=i||(r&Qe)!==0||this.skipped_effects.has(n);if(!a&&n.fn!==null){s?n.f^=ke:(r&Qs)!==0?this.#r.push(n):(r&ke)===0&&((r&zr)!==0&&n.b?.is_pending()?this.#l.push(n):ns(n)&&((n.f&Jt)!==0&&this.#n.push(n),dr(n)));var o=n.first;if(o!==null){n=o;continue}}var l=n.parent;for(n=n.next;n===null&&l!==null;)n=l.next,l=l.parent}}#o(e){for(const n of e)((n.f&je)!==0?this.#a:this.#c).push(n),xe(n,ke);e.length=0}capture(e,n){this.#t.has(e)||this.#t.set(e,n),this.current.set(e,e.v)}activate(){ne=this}deactivate(){ne=null}flush(){if(ct.length>0){if(this.activate(),ao(),ne!==null&&ne!==this)return}else this.#u===0&&this.#h();this.deactivate();for(const e of ii)if(ii.delete(e),e(),ne!==null)break}#h(){for(const e of this.#e)e();if(this.#e.clear(),Vr.size>1){this.#t.clear();let e=!0;for(const n of Vr){if(n===this){e=!1;continue}for(const[r,s]of this.current){if(n.current.has(r))if(e)n.current.set(r,s);else continue;lo(r)}if(ct.length>0){ne=n;const r=Ue.apply(n);for(const s of ct)n.#d(s);ct=[],r()}}ne=null}Vr.delete(this)}increment(){this.#u+=1}decrement(){this.#u-=1;for(const e of this.#a)xe(e,je),rn(e);for(const e of this.#c)xe(e,Nt),rn(e);this.flush()}add_callback(e){this.#e.add(e)}settled(){return(this.#i??=Xa()).promise}static ensure(){if(ne===null){const e=ne=new Ue;Vr.add(ne),Cn||Ue.enqueue(()=>{ne===e&&e.flush()})}return ne}static enqueue(e){bt(e)}static apply(e){return vd}}function _e(t){var e=Cn;Cn=!0;try{for(var n;;){if(Fd(),ct.length===0&&(ne?.flush(),ct.length===0))return Yr=null,n;ao()}}finally{Cn=e}}function ao(){var t=Nn;ai=!0;try{var e=0;for(Co(!0);ct.length>0;){var n=Ue.ensure();if(e++>1e3){var r,s;Bd()}n.process(ct),jt.clear()}}finally{ai=!1,Co(t),Yr=null}}function Bd(){try{Rd()}catch(t){$n(t,Yr)}}let nn=null;function oo(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(Yt|Qe))===0&&ns(r)&&(nn=[],dr(r),r.deps===null&&r.first===null&&r.nodes_start===null&&(r.teardown===null&&r.ac===null?Ro(r):r.fn=null),nn?.length>0)){jt.clear();for(const s of nn)dr(s);nn=[]}}nn=null}}function lo(t){if(t.reactions!==null)for(const e of t.reactions){const n=e.f;(n&$e)!==0?lo(e):(n&(zr|Jt))!==0&&(xe(e,je),rn(e))}}function rn(t){for(var e=Yr=t;e.parent!==null;){e=e.parent;var n=e.f;if(ai&&e===U&&(n&Jt)!==0)return;if((n&(Pt|vt))!==0){if((n&ke)===0)return;e.f^=ke}}ct.push(e)}function qd(t){let e=0,n=yt(0),r;return()=>{th()&&(w(n),Qr(()=>(e===0&&(r=ss(()=>t(()=>lr(n)))),e+=1,()=>{bt(()=>{e-=1,e===0&&(r?.(),r=void 0,lr(n))})})))}}var Hd=Hr|Xt|ti;function zd(t,e,n){new Wd(t,e,n)}class Wd{parent;#t=!1;#e;#u=N?F:null;#i;#l;#s;#r=null;#n=null;#a=null;#c=null;#d=0;#o=0;#h=!1;#f=null;#_=()=>{this.#f&&wt(this.#f,this.#d)};#v=qd(()=>(this.#f=yt(this.#d),()=>{this.#f=null}));constructor(e,n,r){this.#e=e,this.#i=n,this.#l=r,this.parent=U.b,this.#t=!!this.#i.pending,this.#s=es(()=>{if(U.b=this,N){const s=this.#u;en(),s.nodeType===Qt&&s.data===sr?this.#y():this.#b()}else{try{this.#r=Me(()=>r(this.#e))}catch(s){this.error(s)}this.#o>0?this.#g():this.#t=!1}},Hd),N&&(this.#e=F)}#b(){try{this.#r=Me(()=>this.#l(this.#e))}catch(e){this.error(e)}this.#t=!1}#y(){const e=this.#i.pending;e&&(this.#n=Me(()=>e(this.#e)),Ue.enqueue(()=>{this.#r=this.#p(()=>(Ue.ensure(),Me(()=>this.#l(this.#e)))),this.#o>0?this.#g():(St(this.#n,()=>{this.#n=null}),this.#t=!1)}))}is_pending(){return this.#t||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#i.pending}#p(e){var n=U,r=B,s=Ce;Ge(this.#s),Se(this.#s),Lt(this.#s.ctx);try{return e()}catch(i){return so(i),null}finally{Ge(n),Se(r),Lt(s)}}#g(){const e=this.#i.pending;this.#r!==null&&(this.#c=document.createDocumentFragment(),Gd(this.#r,this.#c)),this.#n===null&&(this.#n=Me(()=>e(this.#e)))}#m(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#m(e);return}this.#o+=e,this.#o===0&&(this.#t=!1,this.#n&&St(this.#n,()=>{this.#n=null}),this.#c&&(this.#e.before(this.#c),this.#c=null),bt(()=>{Ue.ensure().flush()}))}update_pending_count(e){this.#m(e),this.#d+=e,ii.add(this.#_)}get_effect_pending(){return this.#v(),w(this.#f)}error(e){var n=this.#i.onerror;let r=this.#i.failed;if(this.#h||!n&&!r)throw e;this.#r&&(Be(this.#r),this.#r=null),this.#n&&(Be(this.#n),this.#n=null),this.#a&&(Be(this.#a),this.#a=null),N&&(Ee(this.#u),jd(),Ee(or()));var s=!1,i=!1;const a=()=>{if(s){Ld();return}s=!0,i&&Nd(),Ue.ensure(),this.#d=0,this.#a!==null&&St(this.#a,()=>{this.#a=null}),this.#t=this.has_pending_snippet(),this.#r=this.#p(()=>(this.#h=!1,Me(()=>this.#l(this.#e)))),this.#o>0?this.#g():this.#t=!1};var o=B;try{Se(null),i=!0,n?.(e,a),i=!1}catch(l){$n(l,this.#s&&this.#s.parent)}finally{Se(o)}r&&bt(()=>{this.#a=this.#p(()=>{this.#h=!0;try{return Me(()=>{r(this.#e,()=>e,()=>a)})}catch(l){return $n(l,this.#s.parent),null}finally{this.#h=!1}})})}}function Gd(t,e){for(var n=t.nodes_start,r=t.nodes_end;n!==null;){var s=n===r?null:et(n);e.append(n),n=s}}function Kd(t,e,n){const r=Xr;if(e.length===0){n(t.map(r));return}var s=ne,i=U,a=Vd(),o=N;Promise.all(e.map(l=>Jd(l))).then(l=>{a();try{n([...t.map(r),...l])}catch(c){(i.f&Yt)===0&&$n(c,i)}o&&De(!1),s?.deactivate(),co()}).catch(l=>{$n(l,i)})}function Vd(){var t=U,e=B,n=Ce,r=ne,s=N;if(s)var i=F;return function(){Ge(t),Se(e),Lt(n),r?.activate(),s&&(De(!0),Ee(i))}}function co(){Ge(null),Se(null),Lt(null)}function Xr(t){var e=$e|je,n=B!==null&&(B.f&$e)!==0?B:null;return U===null||n!==null&&(n.f&We)!==0?e|=We:U.f|=Xt,{ctx:Ce,deps:null,effects:null,equals:eo,f:e,fn:t,reactions:null,rv:0,v:ge,wv:0,parent:n??U,ac:null}}function Jd(t,e){let n=U;n===null&&Td();var r=n.b,s=void 0,i=yt(ge),a=!B,o=new Map;return sh(()=>{var l=Xa();s=l.promise;try{Promise.resolve(t()).then(l.resolve,l.reject)}catch(h){l.reject(h)}var c=ne,u=r.is_pending();a&&(r.update_pending_count(1),u||(c.increment(),o.get(c)?.reject(ir),o.set(c,l)));const d=(h,f=void 0)=>{u||c.activate(),f?f!==ir&&(i.f|=Zt,wt(i,f)):((i.f&Zt)!==0&&(i.f^=Zt),wt(i,h)),a&&(r.update_pending_count(-1),u||c.decrement()),co()};l.promise.then(d,h=>d(null,h||"unknown"))}),ko(()=>{for(const l of o.values())l.reject(ir)}),new Promise(l=>{function c(u){function d(){u===s?l(i):c(s)}u.then(d,d)}c(s)})}function Pn(t){const e=Xr(t);return No(e),e}function Yd(t){const e=Xr(t);return e.equals=to,e}function uo(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)Be(e[n])}}function Xd(t){for(var e=t.parent;e!==null;){if((e.f&$e)===0)return e;e=e.parent}return null}function oi(t){var e,n=U;Ge(Xd(t));try{uo(t),e=Fo(t)}finally{Ge(n)}return e}function ho(t){var e=oi(t);if(t.equals(e)||(t.v=e,t.wv=Do()),!sn){var n=(Dt||(t.f&We)!==0)&&t.deps!==null?Nt:ke;xe(t,n)}}const jt=new Map;function yt(t,e){var n={f:0,v:t,reactions:null,equals:eo,rv:0,wv:0};return n}function te(t,e){const n=yt(t);return No(n),n}function fo(t,e=!1,n=!0){const r=yt(t);return e||(r.equals=to),r}function R(t,e,n=!1){B!==null&&(!nt||(B.f&Za)!==0)&&no()&&(B.f&($e|Jt|zr|Za))!==0&&!Tt?.includes(t)&&Pd();let r=n?Et(e):e;return wt(t,r)}function wt(t,e){if(!t.equals(e)){var n=t.v;sn?jt.set(t,e):jt.set(t,n),t.v=e;var r=Ue.ensure();r.capture(t,n),(t.f&$e)!==0&&((t.f&je)!==0&&oi(t),xe(t,(t.f&We)===0?ke:Nt)),t.wv=Do(),po(t,je),U!==null&&(U.f&ke)!==0&&(U.f&(vt|Pt))===0&&(Ke===null?ah([t]):Ke.push(t))}return e}function lr(t){R(t,t.v+1)}function po(t,e){var n=t.reactions;if(n!==null)for(var r=n.length,s=0;s<r;s++){var i=n[s],a=i.f,o=(a&je)===0;o&&xe(i,e),(a&$e)!==0?po(i,Nt):o&&((a&Jt)!==0&&nn!==null&&nn.push(i),rn(i))}}function Et(t){if(typeof t!="object"||t===null||Wr in t)return t;const e=Va(t);if(e!==md&&e!==_d)return t;var n=new Map,r=Xs(t),s=te(0),i=an,a=o=>{if(an===i)return o();var l=B,c=an;Se(null),jo(i);var u=o();return Se(l),jo(c),u};return r&&n.set("length",te(t.length)),new Proxy(t,{defineProperty(o,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&$d();var u=n.get(l);return u===void 0?u=a(()=>{var d=te(c.value);return n.set(l,d),d}):R(u,c.value,!0),!0},deleteProperty(o,l){var c=n.get(l);if(c===void 0){if(l in o){const u=a(()=>te(ge));n.set(l,u),lr(s)}}else R(c,ge),lr(s);return!0},get(o,l,c){if(l===Wr)return t;var u=n.get(l),d=l in o;if(u===void 0&&(!d||In(o,l)?.writable)&&(u=a(()=>{var f=Et(d?o[l]:ge),g=te(f);return g}),n.set(l,u)),u!==void 0){var h=w(u);return h===ge?void 0:h}return Reflect.get(o,l,c)},getOwnPropertyDescriptor(o,l){var c=Reflect.getOwnPropertyDescriptor(o,l);if(c&&"value"in c){var u=n.get(l);u&&(c.value=w(u))}else if(c===void 0){var d=n.get(l),h=d?.v;if(d!==void 0&&h!==ge)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(o,l){if(l===Wr)return!0;var c=n.get(l),u=c!==void 0&&c.v!==ge||Reflect.has(o,l);if(c!==void 0||U!==null&&(!u||In(o,l)?.writable)){c===void 0&&(c=a(()=>{var h=u?Et(o[l]):ge,f=te(h);return f}),n.set(l,c));var d=w(c);if(d===ge)return!1}return u},set(o,l,c,u){var d=n.get(l),h=l in o;if(r&&l==="length")for(var f=c;f<d.v;f+=1){var g=n.get(f+"");g!==void 0?R(g,ge):f in o&&(g=a(()=>te(ge)),n.set(f+"",g))}if(d===void 0)(!h||In(o,l)?.writable)&&(d=a(()=>te(void 0)),R(d,Et(c)),n.set(l,d));else{h=d.v!==ge;var v=a(()=>Et(c));R(d,v)}var _=Reflect.getOwnPropertyDescriptor(o,l);if(_?.set&&_.set.call(u,c),!h){if(r&&typeof l=="string"){var S=n.get("length"),p=Number(l);Number.isInteger(p)&&p>=S.v&&R(S,p+1)}lr(s)}return!0},ownKeys(o){w(s);var l=Reflect.ownKeys(o).filter(d=>{var h=n.get(d);return h===void 0||h.v!==ge});for(var[c,u]of n)u.v!==ge&&!(c in o)&&l.push(c);return l},setPrototypeOf(){Cd()}})}var go,mo,_o,vo;function li(){if(go===void 0){go=window,mo=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;_o=In(e,"firstChild").get,vo=In(e,"nextSibling").get,Ja(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),Ja(n)&&(n.__t=void 0)}}function kt(t=""){return document.createTextNode(t)}function Fe(t){return _o.call(t)}function et(t){return vo.call(t)}function X(t,e){if(!N)return Fe(t);var n=Fe(F);if(n===null)n=F.appendChild(kt());else if(e&&n.nodeType!==si){var r=kt();return n?.before(r),Ee(r),r}return Ee(n),n}function tt(t,e=!1){if(!N){var n=Fe(t);return n instanceof Comment&&n.data===""?et(n):n}if(e&&F?.nodeType!==si){var r=kt();return F?.before(r),Ee(r),r}return F}function ie(t,e=1,n=!1){let r=N?F:t;for(var s;e--;)s=r,r=et(r);if(!N)return r;if(n&&r?.nodeType!==si){var i=kt();return r===null?s?.after(i):r.before(i),Ee(i),i}return Ee(r),r}function bo(t){t.textContent=""}function yo(){return!1}let wo=!1;function Eo(){wo||(wo=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{if(!t.defaultPrevented)for(const e of t.target.elements)e.__on_r?.()})},{capture:!0}))}function Zr(t){var e=B,n=U;Se(null),Ge(null);try{return t()}finally{Se(e),Ge(n)}}function Zd(t,e,n,r=n){t.addEventListener(e,()=>Zr(n));const s=t.__on_r;s?t.__on_r=()=>{s(),r(!0)}:t.__on_r=()=>r(!0),Eo()}function Qd(t){U===null&&B===null&&Od(),B!==null&&(B.f&We)!==0&&U===null&&Ad(),sn&&xd()}function eh(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function ut(t,e,n,r=!0){var s=U;s!==null&&(s.f&Qe)!==0&&(t|=Qe);var i={ctx:Ce,deps:null,nodes_start:null,nodes_end:null,f:t|je,first:null,fn:e,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(n)try{dr(i),i.f|=ni}catch(l){throw Be(i),l}else e!==null&&rn(i);if(r){var a=i;if(n&&a.deps===null&&a.teardown===null&&a.nodes_start===null&&a.first===a.last&&(a.f&Xt)===0&&(a=a.first),a!==null&&(a.parent=s,s!==null&&eh(a,s),B!==null&&(B.f&$e)!==0&&(t&Pt)===0)){var o=B;(o.effects??=[]).push(a)}}return i}function th(){return B!==null&&!nt}function ko(t){const e=ut(ei,null,!1);return xe(e,ke),e.teardown=t,e}function cr(t){Qd();var e=U.f,n=!B&&(e&vt)!==0&&(e&ni)===0;if(n){var r=Ce;(r.e??=[]).push(t)}else return So(t)}function So(t){return ut(Qs|wd,t,!1)}function nh(t){Ue.ensure();const e=ut(Pt|Xt,t,!0);return()=>{Be(e)}}function rh(t){Ue.ensure();const e=ut(Pt|Xt,t,!0);return(n={})=>new Promise(r=>{n.outro?St(e,()=>{Be(e),r(void 0)}):(Be(e),r(void 0))})}function To(t){return ut(Qs,t,!1)}function sh(t){return ut(zr|Xt,t,!0)}function Qr(t,e=0){return ut(ei|e,t,!0)}function Pe(t,e=[],n=[]){Kd(e,n,r=>{ut(ei,()=>t(...r.map(w)),!0)})}function es(t,e=0){var n=ut(Jt|e,t,!0);return n}function Me(t,e=!0){return ut(vt|Xt,t,!0,e)}function xo(t){var e=t.teardown;if(e!==null){const n=sn,r=B;Po(!0),Se(null);try{e.call(null)}finally{Po(n),Se(r)}}}function Ao(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const s=n.ac;s!==null&&Zr(()=>{s.abort(ir)});var r=n.next;(n.f&Pt)!==0?n.parent=null:Be(n,e),n=r}}function ih(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&vt)===0&&Be(e),e=n}}function Be(t,e=!0){var n=!1;(e||(t.f&yd)!==0)&&t.nodes_start!==null&&t.nodes_end!==null&&(Oo(t.nodes_start,t.nodes_end),n=!0),Ao(t,e&&!n),rs(t,0),xe(t,Yt);var r=t.transitions;if(r!==null)for(const i of r)i.stop();xo(t);var s=t.parent;s!==null&&s.first!==null&&Ro(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes_start=t.nodes_end=t.ac=null}function Oo(t,e){for(;t!==null;){var n=t===e?null:et(t);t.remove(),t=n}}function Ro(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function St(t,e){var n=[];ci(t,n,!0),Io(n,()=>{Be(t),e&&e()})}function Io(t,e){var n=t.length;if(n>0){var r=()=>--n||e();for(var s of t)s.out(r)}else e()}function ci(t,e,n){if((t.f&Qe)===0){if(t.f^=Qe,t.transitions!==null)for(const a of t.transitions)(a.is_global||n)&&e.push(a);for(var r=t.first;r!==null;){var s=r.next,i=(r.f&Hr)!==0||(r.f&vt)!==0;ci(r,e,i?n:!1),r=s}}}function ts(t){$o(t,!0)}function $o(t,e){if((t.f&Qe)!==0){t.f^=Qe,(t.f&ke)===0&&(xe(t,je),rn(t));for(var n=t.first;n!==null;){var r=n.next,s=(n.f&Hr)!==0||(n.f&vt)!==0;$o(n,s?e:!1),n=r}if(t.transitions!==null)for(const i of t.transitions)(i.is_global||e)&&i.in()}}let Nn=!1;function Co(t){Nn=t}let sn=!1;function Po(t){sn=t}let B=null,nt=!1;function Se(t){B=t}let U=null;function Ge(t){U=t}let Tt=null;function No(t){B!==null&&(Tt===null?Tt=[t]:Tt.push(t))}let Te=null,qe=0,Ke=null;function ah(t){Ke=t}let Lo=1,ur=0,an=ur;function jo(t){an=t}let Dt=!1;function Do(){return++Lo}function ns(t){var e=t.f;if((e&je)!==0)return!0;if((e&Nt)!==0){var n=t.deps,r=(e&We)!==0;if(n!==null){var s,i,a=(e&qr)!==0,o=r&&U!==null&&!Dt,l=n.length;if((a||o)&&(U===null||(U.f&Yt)===0)){var c=t,u=c.parent;for(s=0;s<l;s++)i=n[s],(a||!i?.reactions?.includes(c))&&(i.reactions??=[]).push(c);a&&(c.f^=qr),o&&u!==null&&(u.f&We)===0&&(c.f^=We)}for(s=0;s<l;s++)if(i=n[s],ns(i)&&ho(i),i.wv>t.wv)return!0}(!r||U!==null&&!Dt)&&xe(t,ke)}return!1}function Uo(t,e,n=!0){var r=t.reactions;if(r!==null&&!Tt?.includes(t))for(var s=0;s<r.length;s++){var i=r[s];(i.f&$e)!==0?Uo(i,e,!1):e===i&&(n?xe(i,je):(i.f&ke)!==0&&xe(i,Nt),rn(i))}}function Fo(t){var e=Te,n=qe,r=Ke,s=B,i=Dt,a=Tt,o=Ce,l=nt,c=an,u=t.f;Te=null,qe=0,Ke=null,Dt=(u&We)!==0&&(nt||!Nn||B===null),B=(u&(vt|Pt))===0?t:null,Tt=null,Lt(t.ctx),nt=!1,an=++ur,t.ac!==null&&(Zr(()=>{t.ac.abort(ir)}),t.ac=null);try{t.f|=ri;var d=t.fn,h=d(),f=t.deps;if(Te!==null){var g;if(rs(t,qe),f!==null&&qe>0)for(f.length=qe+Te.length,g=0;g<Te.length;g++)f[qe+g]=Te[g];else t.deps=f=Te;if(!Dt||(u&$e)!==0&&t.reactions!==null)for(g=qe;g<f.length;g++)(f[g].reactions??=[]).push(t)}else f!==null&&qe<f.length&&(rs(t,qe),f.length=qe);if(no()&&Ke!==null&&!nt&&f!==null&&(t.f&($e|Nt|je))===0)for(g=0;g<Ke.length;g++)Uo(Ke[g],t);return s!==null&&s!==t&&(ur++,Ke!==null&&(r===null?r=Ke:r.push(...Ke))),(t.f&Zt)!==0&&(t.f^=Zt),h}catch(v){return so(v)}finally{t.f^=ri,Te=e,qe=n,Ke=r,B=s,Dt=i,Tt=a,Lt(o),nt=l,an=c}}function oh(t,e){let n=e.reactions;if(n!==null){var r=pd.call(n,t);if(r!==-1){var s=n.length-1;s===0?n=e.reactions=null:(n[r]=n[s],n.pop())}}n===null&&(e.f&$e)!==0&&(Te===null||!Te.includes(e))&&(xe(e,Nt),(e.f&(We|qr))===0&&(e.f^=qr),uo(e),rs(e,0))}function rs(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)oh(t,n[r])}function dr(t){var e=t.f;if((e&Yt)===0){xe(t,ke);var n=U,r=Nn;U=t,Nn=!0;try{(e&Jt)!==0?ih(t):Ao(t),xo(t);var s=Fo(t);t.teardown=typeof s=="function"?s:null,t.wv=Lo;var i;Ka&&Ud&&(t.f&je)!==0&&t.deps}finally{Nn=r,U=n}}}async function lh(){await Promise.resolve(),_e()}function w(t){var e=t.f,n=(e&$e)!==0;if(B!==null&&!nt){var r=U!==null&&(U.f&Yt)!==0;if(!r&&!Tt?.includes(t)){var s=B.deps;if((B.f&ri)!==0)t.rv<ur&&(t.rv=ur,Te===null&&s!==null&&s[qe]===t?qe++:Te===null?Te=[t]:(!Dt||!Te.includes(t))&&Te.push(t));else{(B.deps??=[]).push(t);var i=t.reactions;i===null?t.reactions=[B]:i.includes(B)||i.push(B)}}}else if(n&&t.deps===null&&t.effects===null){var a=t,o=a.parent;o!==null&&(o.f&We)===0&&(a.f^=We)}if(sn){if(jt.has(t))return jt.get(t);if(n){a=t;var l=a.v;return((a.f&ke)===0&&a.reactions!==null||Mo(a))&&(l=oi(a)),jt.set(a,l),l}}else n&&(a=t,ns(a)&&ho(a));if((t.f&Zt)!==0)throw t.v;return t.v}function Mo(t){if(t.v===ge)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(jt.has(e)||(e.f&$e)!==0&&Mo(e))return!0;return!1}function ss(t){var e=nt;try{return nt=!0,t()}finally{nt=e}}const ch=-7169;function xe(t,e){t.f=t.f&ch|e}const Bo=new Set,ui=new Set;function uh(t){if(!N)return;t.removeAttribute("onload"),t.removeAttribute("onerror");const e=t.__e;e!==void 0&&(t.__e=void 0,queueMicrotask(()=>{t.isConnected&&t.dispatchEvent(e)}))}function dh(t,e,n,r={}){function s(i){if(r.capture||hr.call(e,i),!i.cancelBubble)return Zr(()=>n?.call(this,i))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?bt(()=>{e.addEventListener(t,s,r)}):e.addEventListener(t,s,r),s}function qo(t,e,n,r,s){var i={capture:r,passive:s},a=dh(t,e,n,i);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&ko(()=>{e.removeEventListener(t,a,i)})}function hh(t){for(var e=0;e<t.length;e++)Bo.add(t[e]);for(var n of ui)n(t)}let Ho=null;function hr(t){var e=this,n=e.ownerDocument,r=t.type,s=t.composedPath?.()||[],i=s[0]||t.target;Ho=t;var a=0,o=Ho===t&&t.__root;if(o){var l=s.indexOf(o);if(l!==-1&&(e===document||e===window)){t.__root=e;return}var c=s.indexOf(e);if(c===-1)return;l<=c&&(a=l)}if(i=s[a]||t.target,i!==e){Rn(t,"currentTarget",{configurable:!0,get(){return i||n}});var u=B,d=U;Se(null),Ge(null);try{for(var h,f=[];i!==null;){var g=i.assignedSlot||i.parentNode||i.host||null;try{var v=i["__"+r];if(v!=null&&(!i.disabled||t.target===i))if(Xs(v)){var[_,...S]=v;_.apply(i,[t,...S])}else v.call(i,t)}catch(p){h?f.push(p):h=p}if(t.cancelBubble||g===e||g===null)break;i=g}if(h){for(let p of f)queueMicrotask(()=>{throw p});throw h}}finally{t.__root=e,delete t.currentTarget,Se(u),Ge(d)}}}function di(t){var e=document.createElement("template");return e.innerHTML=t.replaceAll("<!>","<!---->"),e.content}function dt(t,e){var n=U;n.nodes_start===null&&(n.nodes_start=t,n.nodes_end=e)}function Z(t,e){var n=(e&dd)!==0,r=(e&hd)!==0,s,i=!t.startsWith("<!>");return()=>{if(N)return dt(F,null),F;s===void 0&&(s=di(i?t:"<!>"+t),n||(s=Fe(s)));var a=r||mo?document.importNode(s,!0):s.cloneNode(!0);if(n){var o=Fe(a),l=a.lastChild;dt(o,l)}else dt(a,a);return a}}function fh(t,e,n="svg"){var r=!t.startsWith("<!>"),s=`<${n}>${r?t:"<!>"+t}</${n}>`,i;return()=>{if(N)return dt(F,null),F;if(!i){var a=di(s),o=Fe(a);i=Fe(o)}var l=i.cloneNode(!0);return dt(l,l),l}}function hi(t,e){return fh(t,e,"svg")}function xt(){if(N)return dt(F,null),F;var t=document.createDocumentFragment(),e=document.createComment(""),n=kt();return t.append(e,n),dt(e,n),t}function j(t,e){if(N){U.nodes_end=F,en();return}t!==null&&t.before(e)}const ph=["touchstart","touchmove"];function gh(t){return ph.includes(t)}function Ut(t,e){var n=e==null?"":typeof e=="object"?e+"":e;n!==(t.__t??=t.nodeValue)&&(t.__t=n,t.nodeValue=n+"")}function zo(t,e){return Wo(t,e)}function mh(t,e){li(),e.intro=e.intro??!1;const n=e.target,r=N,s=F;try{for(var i=Fe(n);i&&(i.nodeType!==Qt||i.data!==Ga);)i=et(i);if(!i)throw Vt;De(!0),Ee(i);const a=Wo(t,{...e,anchor:i});return De(!1),a}catch(a){if(a instanceof Error&&a.message.split(`
2
- `).some(o=>o.startsWith("https://svelte.dev/e/")))throw a;return a!==Vt&&console.warn("Failed to hydrate: ",a),e.recover===!1&&Id(),li(),bo(n),De(!1),zo(t,e)}finally{De(r),Ee(s)}}const Ln=new Map;function Wo(t,{target:e,anchor:n,props:r={},events:s,context:i,intro:a=!0}){li();var o=new Set,l=d=>{for(var h=0;h<d.length;h++){var f=d[h];if(!o.has(f)){o.add(f);var g=gh(f);e.addEventListener(f,hr,{passive:g});var v=Ln.get(f);v===void 0?(document.addEventListener(f,hr,{passive:g}),Ln.set(f,1)):Ln.set(f,v+1)}}};l(Zs(Bo)),ui.add(l);var c=void 0,u=rh(()=>{var d=n??e.appendChild(kt());return zd(d,{pending:()=>{}},h=>{if(i){Gr({});var f=Ce;f.c=i}if(s&&(r.$$events=s),N&&dt(h,null),c=t(h,r)||{},N&&(U.nodes_end=F,F===null||F.nodeType!==Qt||F.data!==Ys))throw ar(),Vt;i&&Kr()}),()=>{for(var h of o){e.removeEventListener(h,hr);var f=Ln.get(h);--f===0?(document.removeEventListener(h,hr),Ln.delete(h)):Ln.set(h,f)}ui.delete(l),d!==n&&d.parentNode?.removeChild(d)}});return fi.set(c,u),c}let fi=new WeakMap;function _h(t,e){const n=fi.get(t);return n?(fi.delete(t),n(e)):Promise.resolve()}function vh(t){Ce===null&&Sd(),cr(()=>{const e=ss(t);if(typeof e=="function")return e})}const pi=0,is=1,gi=2;function Go(t,e,n,r,s){N&&en();var i=t,a=Ce,o=ge,l,c,u,d=yt(void 0),h=yt(void 0),f=!1;function g(_,S){f=!0,S&&(Ge(v),Se(v),Lt(a));try{_===is&&r&&(c?ts(c):c=Me(()=>r(i,d))),_!==pi&&l&&St(l,()=>l=null),_!==is&&c&&St(c,()=>c=null),_!==gi&&u&&St(u,()=>u=null)}finally{S&&(Lt(null),Se(null),Ge(null),Cn||_e())}}var v=es(()=>{if(o===(o=e()))return;let _=N&&Ya(o)===(i.data===sr);if(_&&(i=or(),Ee(i),De(!1),_=!0),Ya(o)){var S=o;f=!1,S.then(p=>{S===o&&(wt(d,p),g(is,!0))},p=>{if(S===o)throw wt(h,p),g(gi,!0),h.v}),N||bt(()=>{f||g(pi,!0)})}else wt(d,o),g(is,!1);return _&&De(!0),()=>o=ge});N&&(i=F)}function oe(t,e,n=!1){N&&en();var r=t,s=null,i=null,a=ge,o=n?Hr:0,l=!1;const c=(f,g=!0)=>{l=!0,h(g,f)};var u=null;function d(){u!==null&&(u.lastChild.remove(),r.before(u),u=null);var f=a?s:i,g=a?i:s;f&&ts(f),g&&St(g,()=>{a?i=null:s=null})}const h=(f,g)=>{if(a===(a=f))return;let v=!1;if(N){const E=Qa(r)===sr;!!a===E&&(r=or(),Ee(r),De(!1),v=!0)}var _=yo(),S=r;if(_&&(u=document.createDocumentFragment(),u.append(S=kt())),a?s??=g&&Me(()=>g(S)):i??=g&&Me(()=>g(S)),_){var p=ne,m=a?s:i,y=a?i:s;m&&p.skipped_effects.delete(m),y&&p.skipped_effects.add(y),p.add_callback(d)}else d();v&&De(!0)};es(()=>{l=!1,e(c),l||h(null,null)},o),N&&(r=F)}function fr(t,e){return e}function bh(t,e,n){for(var r=t.items,s=[],i=e.length,a=0;a<i;a++)ci(e[a].e,s,!0);var o=i>0&&s.length===0&&n!==null;if(o){var l=n.parentNode;bo(l),l.append(n),r.clear(),ht(t,e[0].prev,e[i-1].next)}Io(s,()=>{for(var c=0;c<i;c++){var u=e[c];o||(r.delete(u.k),ht(t,u.prev,u.next)),Be(u.e,!o)}})}function pr(t,e,n,r,s,i=null){var a=t,o={flags:e,items:new Map,first:null},l=(e&Wa)!==0;if(l){var c=t;a=N?Ee(Fe(c)):c.appendChild(kt())}N&&en();var u=null,d=!1,h=new Map,f=Yd(()=>{var S=n();return Xs(S)?S:S==null?[]:Zs(S)}),g,v;function _(){yh(v,g,o,h,a,s,e,r,n),i!==null&&(g.length===0?u?ts(u):u=Me(()=>i(a)):u!==null&&St(u,()=>{u=null}))}es(()=>{v??=U,g=w(f);var S=g.length;if(d&&S===0)return;d=S===0;let p=!1;if(N){var m=Qa(a)===sr;m!==(S===0)&&(a=or(),Ee(a),De(!1),p=!0)}if(N){for(var y=null,E,b=0;b<S;b++){if(F.nodeType===Qt&&F.data===Ys){a=F,p=!0,De(!1);break}var k=g[b],A=r(k,b);E=mi(F,o,y,null,k,A,b,s,e,n),o.items.set(A,E),y=E}S>0&&Ee(or())}if(N)S===0&&i&&(u=Me(()=>i(a)));else if(yo()){var T=new Set,x=ne;for(b=0;b<S;b+=1){k=g[b],A=r(k,b);var C=o.items.get(A)??h.get(A);C?(e&(Fr|Mr))!==0&&Ko(C,k,b,e):(E=mi(null,o,null,null,k,A,b,s,e,n,!0),h.set(A,E)),T.add(A)}for(const[V,ae]of o.items)T.has(V)||x.skipped_effects.add(ae.e);x.add_callback(_)}else _();p&&De(!0),w(f)}),N&&(a=F)}function yh(t,e,n,r,s,i,a,o,l){var c=(a&cd)!==0,u=(a&(Fr|Mr))!==0,d=e.length,h=n.items,f=n.first,g=f,v,_=null,S,p=[],m=[],y,E,b,k;if(c)for(k=0;k<d;k+=1)y=e[k],E=o(y,k),b=h.get(E),b!==void 0&&(b.a?.measure(),(S??=new Set).add(b));for(k=0;k<d;k+=1){if(y=e[k],E=o(y,k),b=h.get(E),b===void 0){var A=r.get(E);if(A!==void 0){r.delete(E),h.set(E,A);var T=_?_.next:g;ht(n,_,A),ht(n,A,T),_i(A,T,s),_=A}else{var x=g?g.e.nodes_start:s;_=mi(x,n,_,_===null?n.first:_.next,y,E,k,i,a,l)}h.set(E,_),p=[],m=[],g=_.next;continue}if(u&&Ko(b,y,k,a),(b.e.f&Qe)!==0&&(ts(b.e),c&&(b.a?.unfix(),(S??=new Set).delete(b))),b!==g){if(v!==void 0&&v.has(b)){if(p.length<m.length){var C=m[0],V;_=C.prev;var ae=p[0],be=p[p.length-1];for(V=0;V<p.length;V+=1)_i(p[V],C,s);for(V=0;V<m.length;V+=1)v.delete(m[V]);ht(n,ae.prev,be.next),ht(n,_,ae),ht(n,be,C),g=C,_=be,k-=1,p=[],m=[]}else v.delete(b),_i(b,g,s),ht(n,b.prev,b.next),ht(n,b,_===null?n.first:_.next),ht(n,_,b),_=b;continue}for(p=[],m=[];g!==null&&g.k!==E;)(g.e.f&Qe)===0&&(v??=new Set).add(g),m.push(g),g=g.next;if(g===null)continue;b=g}p.push(b),_=b,g=b.next}if(g!==null||v!==void 0){for(var re=v===void 0?[]:Zs(v);g!==null;)(g.e.f&Qe)===0&&re.push(g),g=g.next;var ye=re.length;if(ye>0){var Le=(a&Wa)!==0&&d===0?s:null;if(c){for(k=0;k<ye;k+=1)re[k].a?.measure();for(k=0;k<ye;k+=1)re[k].a?.fix()}bh(n,re,Le)}}c&&bt(()=>{if(S!==void 0)for(b of S)b.a?.apply()}),t.first=n.first&&n.first.e,t.last=_&&_.e;for(var W of r.values())Be(W.e);r.clear()}function Ko(t,e,n,r){(r&Fr)!==0&&wt(t.v,e),(r&Mr)!==0?wt(t.i,n):t.i=n}function mi(t,e,n,r,s,i,a,o,l,c,u){var d=(l&Fr)!==0,h=(l&ud)===0,f=d?h?fo(s,!1,!1):yt(s):s,g=(l&Mr)===0?a:yt(a),v={i:g,v:f,k:i,a:null,e:null,prev:n,next:r};try{if(t===null){var _=document.createDocumentFragment();_.append(t=kt())}return v.e=Me(()=>o(t,f,g,c),N),v.e.prev=n&&n.e,v.e.next=r&&r.e,n===null?u||(e.first=v):(n.next=v,n.e.next=v.e),r!==null&&(r.prev=v,r.e.prev=v.e),v}finally{}}function _i(t,e,n){for(var r=t.next?t.next.e.nodes_start:n,s=e?e.e.nodes_start:n,i=t.e.nodes_start;i!==null&&i!==r;){var a=et(i);s.before(i),i=a}}function ht(t,e,n){e===null?t.first=n:(e.next=n,e.e.next=n&&n.e),n!==null&&(n.prev=e,n.e.prev=e&&e.e)}function wh(t,e,n=!1,r=!1,s=!1){var i=t,a="";Pe(()=>{var o=U;if(a===(a=e()??"")){N&&en();return}if(o.nodes_start!==null&&(Oo(o.nodes_start,o.nodes_end),o.nodes_start=o.nodes_end=null),a!==""){if(N){F.data;for(var l=en(),c=l;l!==null&&(l.nodeType!==Qt||l.data!=="");)c=l,l=et(l);if(l===null)throw ar(),Vt;dt(F,c),i=Ee(l);return}var u=a+"";n?u=`<svg>${u}</svg>`:r&&(u=`<math>${u}</math>`);var d=di(u);if((n||r)&&(d=Fe(d)),dt(Fe(d),d.lastChild),n||r)for(;Fe(d);)i.before(Fe(d));else i.before(d)}})}function Vo(t,e){To(()=>{var n=t.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+e.hash)){const s=document.createElement("style");s.id=e.hash,s.textContent=e.code,r.appendChild(s)}})}const Jo=[...`
3
- \r\f \v\uFEFF`];function Eh(t,e,n){var r=""+t;if(n){for(var s in n)if(n[s])r=r?r+" "+s:s;else if(r.length)for(var i=s.length,a=0;(a=r.indexOf(s,a))>=0;){var o=a+i;(a===0||Jo.includes(r[a-1]))&&(o===r.length||Jo.includes(r[o]))?r=(a===0?"":r.substring(0,a))+r.substring(o+1):a=o}}return r===""?null:r}function kh(t,e){return t==null?null:String(t)}function Sh(t,e,n,r,s,i){var a=t.__className;if(N||a!==n||a===void 0){var o=Eh(n,r,i);(!N||o!==t.getAttribute("class"))&&(o==null?t.removeAttribute("class"):t.className=o),t.__className=n}else if(i&&s!==i)for(var l in i){var c=!!i[l];(s==null||c!==!!s[l])&&t.classList.toggle(l,c)}return i}function as(t,e,n,r){var s=t.__style;if(N||s!==e){var i=kh(e);(!N||i!==t.getAttribute("style"))&&(i==null?t.removeAttribute("style"):t.style.cssText=i),t.__style=e}return r}const Th=Symbol("is custom element"),xh=Symbol("is html");function Ah(t){if(N){var e=!1,n=()=>{if(!e){if(e=!0,t.hasAttribute("value")){var r=t.value;Ve(t,"value",null),t.value=r}if(t.hasAttribute("checked")){var s=t.checked;Ve(t,"checked",null),t.checked=s}}};t.__on_r=n,bt(n),Eo()}}function Ve(t,e,n,r){var s=Oh(t);N&&(s[e]=t.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&t.nodeName==="LINK")||s[e]!==(s[e]=n)&&(e==="loading"&&(t[kd]=n),n==null?t.removeAttribute(e):typeof n!="string"&&Rh(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function Oh(t){return t.__attributes??={[Th]:t.nodeName.includes("-"),[xh]:t.namespaceURI===fd}}var Yo=new Map;function Rh(t){var e=t.getAttribute("is")||t.nodeName,n=Yo.get(e);if(n)return n;Yo.set(e,n=[]);for(var r,s=t,i=Element.prototype;i!==s;){r=gd(s);for(var a in r)r[a].set&&n.push(a);s=Va(s)}return n}function Ih(t,e,n=e){var r=new WeakSet;Zd(t,"input",async s=>{var i=s?t.defaultValue:t.value;if(i=vi(t)?bi(i):i,n(i),ne!==null&&r.add(ne),await lh(),i!==(i=e())){var a=t.selectionStart,o=t.selectionEnd;t.value=i??"",o!==null&&(t.selectionStart=a,t.selectionEnd=Math.min(o,t.value.length))}}),(N&&t.defaultValue!==t.value||ss(e)==null&&t.value)&&(n(vi(t)?bi(t.value):t.value),ne!==null&&r.add(ne)),Qr(()=>{var s=e();if(t===document.activeElement){var i=Jr??ne;if(r.has(i))return}vi(t)&&s===bi(t.value)||t.type==="date"&&!s&&!t.value||s!==t.value&&(t.value=s??"")})}function vi(t){var e=t.type;return e==="number"||e==="range"}function bi(t){return t===""?null:+t}function Xo(t,e){return t===e||t?.[Wr]===e}function Zo(t={},e,n,r){return To(()=>{var s,i;return Qr(()=>{s=i,i=[],ss(()=>{t!==n(...i)&&(e(t,...i),s&&Xo(n(...s),t)&&e(null,...s))})}),()=>{bt(()=>{i&&Xo(n(...i),t)&&e(null,...i)})}}),t}function Ae(t,e,n,r){var s=r,i=!0,a=()=>(i&&(i=!1,s=r),s),o;o=t[e],o===void 0&&r!==void 0&&(o=a());var l;l=()=>{var h=t[e];return h===void 0?a():(i=!0,h)};var c=!1,u=Xr(()=>(c=!1,l())),d=U;return(function(h,f){if(arguments.length>0){const g=f?w(u):h;return R(u,g),c=!0,s!==void 0&&(s=g),h}return sn&&c||(d.f&Yt)!==0?u.v:w(u)})}function $h(t){return new Ch(t)}class Ch{#t;#e;constructor(e){var n=new Map,r=(i,a)=>{var o=fo(a,!1,!1);return n.set(i,o),o};const s=new Proxy({...e.props||{},$$events:{}},{get(i,a){return w(n.get(a)??r(a,Reflect.get(i,a)))},has(i,a){return a===Ed?!0:(w(n.get(a)??r(a,Reflect.get(i,a))),Reflect.has(i,a))},set(i,a,o){return R(n.get(a)??r(a,o),o),Reflect.set(i,a,o)}});this.#e=(e.hydrate?mh:zo)(e.component,{target:e.target,anchor:e.anchor,props:s,context:e.context,intro:e.intro??!1,recover:e.recover}),(!e?.props?.$$host||e.sync===!1)&&_e(),this.#t=s.$$events;for(const i of Object.keys(this.#e))i==="$set"||i==="$destroy"||i==="$on"||Rn(this,i,{get(){return this.#e[i]},set(a){this.#e[i]=a},enumerable:!0});this.#e.$set=i=>{Object.assign(s,i)},this.#e.$destroy=()=>{_h(this.#e)}}$set(e){this.#e.$set(e)}$on(e,n){this.#t[e]=this.#t[e]||[];const r=(...s)=>n.call(this,...s);return this.#t[e].push(r),()=>{this.#t[e]=this.#t[e].filter(s=>s!==r)}}$destroy(){this.#e.$destroy()}}let Qo;typeof HTMLElement=="function"&&(Qo=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;$$me;constructor(t,e,n){super(),this.$$ctor=t,this.$$s=e,n&&this.attachShadow({mode:"open"})}addEventListener(t,e,n){if(this.$$l[t]=this.$$l[t]||[],this.$$l[t].push(e),this.$$c){const r=this.$$c.$on(t,e);this.$$l_u.set(e,r)}super.addEventListener(t,e,n)}removeEventListener(t,e,n){if(super.removeEventListener(t,e,n),this.$$c){const r=this.$$l_u.get(e);r&&(r(),this.$$l_u.delete(e))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let t=function(r){return s=>{const i=document.createElement("slot");r!=="default"&&(i.name=r),j(s,i)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const e={},n=Ph(this);for(const r of this.$$s)r in n&&(r==="default"&&!this.$$d.children?(this.$$d.children=t(r),e.default=!0):e[r]=t(r));for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=os(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=$h({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:e,$$host:this}}),this.$$me=nh(()=>{Qr(()=>{this.$$r=!0;for(const r of Br(this.$$c)){if(!this.$$p_d[r]?.reflect)continue;this.$$d[r]=this.$$c[r];const s=os(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1})});for(const r in this.$$l)for(const s of this.$$l[r]){const i=this.$$c.$on(r,s);this.$$l_u.set(s,i)}this.$$l={}}}attributeChangedCallback(t,e,n){this.$$r||(t=this.$$g_p(t),this.$$d[t]=os(t,n,this.$$p_d,"toProp"),this.$$c?.$set({[t]:this.$$d[t]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(t){return Br(this.$$p_d).find(e=>this.$$p_d[e].attribute===t||!this.$$p_d[e].attribute&&e.toLowerCase()===t)||t}});function os(t,e,n,r){const s=n[t]?.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!n[t])return e;if(r==="toAttribute")switch(s){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(s){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Ph(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}function yi(t,e,n,r,s,i){let a=class extends Qo{constructor(){super(t,n,s),this.$$p_d=e}static get observedAttributes(){return Br(e).map(o=>(e[o].attribute||o).toLowerCase())}};return Br(e).forEach(o=>{Rn(a.prototype,o,{get(){return this.$$c&&o in this.$$c?this.$$c[o]:this.$$d[o]},set(l){l=os(o,l,e),this.$$d[o]=l;var c=this.$$c;if(c){var u=In(c,o)?.get;u?c[o]=l:c.$set({[o]:l})}}})}),r.forEach(o=>{Rn(a.prototype,o,{get(){return this.$$c?.[o]}})}),t.element=a,a}const Nh=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Promise.resolve().then(()=>qn).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)};class wi extends Error{constructor(e,n="FunctionsError",r){super(e),this.name=n,this.context=r}}class el extends wi{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class tl extends wi{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class nl extends wi{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Ei;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(Ei||(Ei={}));var Lh=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class jh{constructor(e,{headers:n={},customFetch:r,region:s=Ei.Any}={}){this.url=e,this.headers=n,this.region=s,this.fetch=Nh(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return Lh(this,arguments,void 0,function*(n,r={}){var s;try{const{headers:i,method:a,body:o,signal:l}=r;let c={},{region:u}=r;u||(u=this.region);const d=new URL(`${this.url}/${n}`);u&&u!=="any"&&(c["x-region"]=u,d.searchParams.set("forceFunctionRegion",u));let h;o&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(c["Content-Type"]="application/octet-stream",h=o):typeof o=="string"?(c["Content-Type"]="text/plain",h=o):typeof FormData<"u"&&o instanceof FormData?h=o:(c["Content-Type"]="application/json",h=JSON.stringify(o)));const f=yield this.fetch(d.toString(),{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},c),this.headers),i),body:h,signal:l}).catch(S=>{throw S.name==="AbortError"?S:new el(S)}),g=f.headers.get("x-relay-error");if(g&&g==="true")throw new tl(f);if(!f.ok)throw new nl(f);let v=((s=f.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),_;return v==="application/json"?_=yield f.json():v==="application/octet-stream"?_=yield f.blob():v==="text/event-stream"?_=f:v==="multipart/form-data"?_=yield f.formData():_=yield f.text(),{data:_,error:null,response:f}}catch(i){return i instanceof Error&&i.name==="AbortError"?{data:null,error:new el(i)}:{data:null,error:i,response:i instanceof nl||i instanceof tl?i.context:void 0}}})}}function Dh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Uh(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var ve={},jn={},Dn={},Un={},Fn={},Mn={},Fh=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")},Bn=Fh();const Mh=Bn.fetch,rl=Bn.fetch.bind(Bn),sl=Bn.Headers,Bh=Bn.Request,qh=Bn.Response,qn=Object.freeze(Object.defineProperty({__proto__:null,Headers:sl,Request:Bh,Response:qh,default:rl,fetch:Mh},Symbol.toStringTag,{value:"Module"})),Hh=Uh(qn);var ls={},il;function al(){if(il)return ls;il=1,Object.defineProperty(ls,"__esModule",{value:!0});class t extends Error{constructor(n){super(n.message),this.name="PostgrestError",this.details=n.details,this.hint=n.hint,this.code=n.code}}return ls.default=t,ls}var ol;function ll(){if(ol)return Mn;ol=1;var t=Mn&&Mn.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Mn,"__esModule",{value:!0});const e=t(Hh),n=t(al());class r{constructor(i){var a,o;this.shouldThrowOnError=!1,this.method=i.method,this.url=i.url,this.headers=new Headers(i.headers),this.schema=i.schema,this.body=i.body,this.shouldThrowOnError=(a=i.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=i.signal,this.isMaybeSingle=(o=i.isMaybeSingle)!==null&&o!==void 0?o:!1,i.fetch?this.fetch=i.fetch:typeof fetch>"u"?this.fetch=e.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(i,a){return this.headers=new Headers(this.headers),this.headers.set(i,a),this}then(i,a){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const o=this.fetch;let l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var u,d,h,f;let g=null,v=null,_=null,S=c.status,p=c.statusText;if(c.ok){if(this.method!=="HEAD"){const b=await c.text();b===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((u=this.headers.get("Accept"))===null||u===void 0)&&u.includes("application/vnd.pgrst.plan+text"))?v=b:v=JSON.parse(b))}const y=(d=this.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),E=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");y&&E&&E.length>1&&(_=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(v)&&(v.length>1?(g={code:"PGRST116",details:`Results contain ${v.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},v=null,_=null,S=406,p="Not Acceptable"):v.length===1?v=v[0]:v=null)}else{const y=await c.text();try{g=JSON.parse(y),Array.isArray(g)&&c.status===404&&(v=[],g=null,S=200,p="OK")}catch{c.status===404&&y===""?(S=204,p="No Content"):g={message:y}}if(g&&this.isMaybeSingle&&(!((f=g?.details)===null||f===void 0)&&f.includes("0 rows"))&&(g=null,S=200,p="OK"),g&&this.shouldThrowOnError)throw new n.default(g)}return{error:g,data:v,count:_,status:S,statusText:p}});return this.shouldThrowOnError||(l=l.catch(c=>{var u,d,h;return{error:{message:`${(u=c?.name)!==null&&u!==void 0?u:"FetchError"}: ${c?.message}`,details:`${(d=c?.stack)!==null&&d!==void 0?d:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(i,a)}returns(){return this}overrideTypes(){return this}}return Mn.default=r,Mn}var cl;function ul(){if(cl)return Fn;cl=1;var t=Fn&&Fn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Fn,"__esModule",{value:!0});const e=t(ll());class n extends e.default{select(s){let i=!1;const a=(s??"*").split("").map(o=>/\s/.test(o)&&!i?"":(o==='"'&&(i=!i),o)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:i=!0,nullsFirst:a,foreignTable:o,referencedTable:l=o}={}){const c=l?`${l}.order`:"order",u=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${u?`${u},`:""}${s}.${i?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:i,referencedTable:a=i}={}){const o=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(o,`${s}`),this}range(s,i,{foreignTable:a,referencedTable:o=a}={}){const l=typeof o>"u"?"offset":`${o}.offset`,c=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${s}`),this.url.searchParams.set(c,`${i-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:s=!1,verbose:i=!1,settings:a=!1,buffers:o=!1,wal:l=!1,format:c="text"}={}){var u;const d=[s?"analyze":null,i?"verbose":null,a?"settings":null,o?"buffers":null,l?"wal":null].filter(Boolean).join("|"),h=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${c}; for="${h}"; options=${d};`),c==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}}return Fn.default=n,Fn}var dl;function ki(){if(dl)return Un;dl=1;var t=Un&&Un.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Un,"__esModule",{value:!0});const e=t(ul());class n extends e.default{eq(s,i){return this.url.searchParams.append(s,`eq.${i}`),this}neq(s,i){return this.url.searchParams.append(s,`neq.${i}`),this}gt(s,i){return this.url.searchParams.append(s,`gt.${i}`),this}gte(s,i){return this.url.searchParams.append(s,`gte.${i}`),this}lt(s,i){return this.url.searchParams.append(s,`lt.${i}`),this}lte(s,i){return this.url.searchParams.append(s,`lte.${i}`),this}like(s,i){return this.url.searchParams.append(s,`like.${i}`),this}likeAllOf(s,i){return this.url.searchParams.append(s,`like(all).{${i.join(",")}}`),this}likeAnyOf(s,i){return this.url.searchParams.append(s,`like(any).{${i.join(",")}}`),this}ilike(s,i){return this.url.searchParams.append(s,`ilike.${i}`),this}ilikeAllOf(s,i){return this.url.searchParams.append(s,`ilike(all).{${i.join(",")}}`),this}ilikeAnyOf(s,i){return this.url.searchParams.append(s,`ilike(any).{${i.join(",")}}`),this}is(s,i){return this.url.searchParams.append(s,`is.${i}`),this}in(s,i){const a=Array.from(new Set(i)).map(o=>typeof o=="string"&&new RegExp("[,()]").test(o)?`"${o}"`:`${o}`).join(",");return this.url.searchParams.append(s,`in.(${a})`),this}contains(s,i){return typeof i=="string"?this.url.searchParams.append(s,`cs.${i}`):Array.isArray(i)?this.url.searchParams.append(s,`cs.{${i.join(",")}}`):this.url.searchParams.append(s,`cs.${JSON.stringify(i)}`),this}containedBy(s,i){return typeof i=="string"?this.url.searchParams.append(s,`cd.${i}`):Array.isArray(i)?this.url.searchParams.append(s,`cd.{${i.join(",")}}`):this.url.searchParams.append(s,`cd.${JSON.stringify(i)}`),this}rangeGt(s,i){return this.url.searchParams.append(s,`sr.${i}`),this}rangeGte(s,i){return this.url.searchParams.append(s,`nxl.${i}`),this}rangeLt(s,i){return this.url.searchParams.append(s,`sl.${i}`),this}rangeLte(s,i){return this.url.searchParams.append(s,`nxr.${i}`),this}rangeAdjacent(s,i){return this.url.searchParams.append(s,`adj.${i}`),this}overlaps(s,i){return typeof i=="string"?this.url.searchParams.append(s,`ov.${i}`):this.url.searchParams.append(s,`ov.{${i.join(",")}}`),this}textSearch(s,i,{config:a,type:o}={}){let l="";o==="plain"?l="pl":o==="phrase"?l="ph":o==="websearch"&&(l="w");const c=a===void 0?"":`(${a})`;return this.url.searchParams.append(s,`${l}fts${c}.${i}`),this}match(s){return Object.entries(s).forEach(([i,a])=>{this.url.searchParams.append(i,`eq.${a}`)}),this}not(s,i,a){return this.url.searchParams.append(s,`not.${i}.${a}`),this}or(s,{foreignTable:i,referencedTable:a=i}={}){const o=a?`${a}.or`:"or";return this.url.searchParams.append(o,`(${s})`),this}filter(s,i,a){return this.url.searchParams.append(s,`${i}.${a}`),this}}return Un.default=n,Un}var hl;function fl(){if(hl)return Dn;hl=1;var t=Dn&&Dn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Dn,"__esModule",{value:!0});const e=t(ki());class n{constructor(s,{headers:i={},schema:a,fetch:o}){this.url=s,this.headers=new Headers(i),this.schema=a,this.fetch=o}select(s,i){const{head:a=!1,count:o}=i??{},l=a?"HEAD":"GET";let c=!1;const u=(s??"*").split("").map(d=>/\s/.test(d)&&!c?"":(d==='"'&&(c=!c),d)).join("");return this.url.searchParams.set("select",u),o&&this.headers.append("Prefer",`count=${o}`),new e.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:i,defaultToNull:a=!0}={}){var o;const l="POST";if(i&&this.headers.append("Prefer",`count=${i}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const c=s.reduce((u,d)=>u.concat(Object.keys(d)),[]);if(c.length>0){const u=[...new Set(c)].map(d=>`"${d}"`);this.url.searchParams.set("columns",u.join(","))}}return new e.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}upsert(s,{onConflict:i,ignoreDuplicates:a=!1,count:o,defaultToNull:l=!0}={}){var c;const u="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),i!==void 0&&this.url.searchParams.set("on_conflict",i),o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const d=s.reduce((h,f)=>h.concat(Object.keys(f)),[]);if(d.length>0){const h=[...new Set(d)].map(f=>`"${f}"`);this.url.searchParams.set("columns",h.join(","))}}return new e.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(c=this.fetch)!==null&&c!==void 0?c:fetch})}update(s,{count:i}={}){var a;const o="PATCH";return i&&this.headers.append("Prefer",`count=${i}`),new e.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var i;const a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new e.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}}return Dn.default=n,Dn}var pl;function zh(){if(pl)return jn;pl=1;var t=jn&&jn.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(jn,"__esModule",{value:!0});const e=t(fl()),n=t(ki());class r{constructor(i,{headers:a={},schema:o,fetch:l}={}){this.url=i,this.headers=new Headers(a),this.schemaName=o,this.fetch=l}from(i){const a=new URL(`${this.url}/${i}`);return new e.default(a,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(i){return new r(this.url,{headers:this.headers,schema:i,fetch:this.fetch})}rpc(i,a={},{head:o=!1,get:l=!1,count:c}={}){var u;let d;const h=new URL(`${this.url}/rpc/${i}`);let f;o||l?(d=o?"HEAD":"GET",Object.entries(a).filter(([v,_])=>_!==void 0).map(([v,_])=>[v,Array.isArray(_)?`{${_.join(",")}}`:`${_}`]).forEach(([v,_])=>{h.searchParams.append(v,_)})):(d="POST",f=a);const g=new Headers(this.headers);return c&&g.set("Prefer",`count=${c}`),new n.default({method:d,url:h,headers:g,schema:this.schemaName,body:f,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}}return jn.default=r,jn}var gl;function Wh(){if(gl)return ve;gl=1;var t=ve&&ve.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(ve,"__esModule",{value:!0}),ve.PostgrestError=ve.PostgrestBuilder=ve.PostgrestTransformBuilder=ve.PostgrestFilterBuilder=ve.PostgrestQueryBuilder=ve.PostgrestClient=void 0;const e=t(zh());ve.PostgrestClient=e.default;const n=t(fl());ve.PostgrestQueryBuilder=n.default;const r=t(ki());ve.PostgrestFilterBuilder=r.default;const s=t(ul());ve.PostgrestTransformBuilder=s.default;const i=t(ll());ve.PostgrestBuilder=i.default;const a=t(al());return ve.PostgrestError=a.default,ve.default={PostgrestClient:e.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:r.default,PostgrestTransformBuilder:s.default,PostgrestBuilder:i.default,PostgrestError:a.default},ve}var Gh=Wh();const Kh=Dh(Gh),{PostgrestClient:Vh,PostgrestQueryBuilder:Mw,PostgrestFilterBuilder:Bw,PostgrestTransformBuilder:qw,PostgrestBuilder:Hw,PostgrestError:zw}=Kh;class Jh{static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const n=process.versions;if(n&&n.node){const r=n.node,s=parseInt(r.replace(/^v/,"").split(".")[0]);return s>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${s} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${s} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
1
+ (function(Ct,Fr){typeof exports=="object"&&typeof module<"u"?Fr(exports):typeof define=="function"&&define.amd?define(["exports"],Fr):(Ct=typeof globalThis<"u"?globalThis:Ct||self,Fr(Ct.KnestWidget={}))})(this,(function(Ct){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");const Mr=1,Br=2,Ga=4,ud=8,dd=16,hd=1,fd=2,Ka="[",ir="[!",Xs="]",Jt={},_e=Symbol(),pd="http://www.w3.org/1999/xhtml",Va=!1;var Zs=Array.isArray,gd=Array.prototype.indexOf,Qs=Array.from,qr=Object.keys,In=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,md=Object.getOwnPropertyDescriptors,_d=Object.prototype,vd=Array.prototype,Ja=Object.getPrototypeOf,Ya=Object.isExtensible;const bd=()=>{};function Xa(t){return typeof t?.then=="function"}function yd(t){for(var e=0;e<t.length;e++)t[e]()}function Za(){var t,e,n=new Promise((r,s)=>{t=r,e=s});return{promise:n,resolve:t,reject:e}}const Ce=2,ei=4,ti=8,Yt=16,_t=32,Pt=64,ni=128,Ke=256,Hr=512,Te=1024,De=2048,Nt=4096,Ze=8192,Xt=16384,ri=32768,zr=65536,Qa=1<<17,wd=1<<18,Zt=1<<19,Ed=1<<20,si=1<<21,Wr=1<<22,Qt=1<<23,Gr=Symbol("$state"),kd=Symbol("legacy props"),Sd=Symbol(""),ar=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ii=3,en=8;function Td(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function xd(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Ad(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Rd(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Od(t){throw new Error("https://svelte.dev/e/effect_orphan")}function Id(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function $d(){throw new Error("https://svelte.dev/e/hydration_failed")}function Cd(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Pd(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Nd(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Ld(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function or(t){console.warn("https://svelte.dev/e/hydration_mismatch")}function jd(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let P=!1;function Ue(t){P=t}let F;function we(t){if(t===null)throw or(),Jt;return F=t}function tn(){return we(Qe(F))}function K(t){if(P){if(Qe(F)!==null)throw or(),Jt;F=t}}function Dd(t=1){if(P){for(var e=t,n=F;e--;)n=Qe(n);F=n}}function lr(t=!0){for(var e=0,n=F;;){if(n.nodeType===en){var r=n.data;if(r===Xs){if(e===0)return n;e-=1}else(r===Ka||r===ir)&&(e+=1)}var s=Qe(n);t&&n.remove(),n=s}}function eo(t){if(!t||t.nodeType!==en)throw or(),Jt;return t.data}function to(t){return t===this.v}function Ud(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function no(t){return!Ud(t,this.v)}let Fd=!1,Pe=null;function Lt(t){Pe=t}function Kr(t,e=!1,n){Pe={p:Pe,c:null,e:null,s:t,x:null,l:null}}function Vr(t){var e=Pe,n=e.e;if(n!==null){e.e=null;for(var r of n)To(r)}return t!==void 0&&(e.x=t),Pe=e.p,t??{}}function ro(){return!0}let nn=[];function so(){var t=nn;nn=[],yd(t)}function vt(t){if(nn.length===0&&!Pn){var e=nn;queueMicrotask(()=>{e===nn&&so()})}nn.push(t)}function Md(){for(;nn.length>0;)so()}const Bd=new WeakMap;function io(t){var e=U;if(e===null)return B.f|=Qt,t;if((e.f&ri)===0){if((e.f&ni)===0)throw!e.parent&&t instanceof Error&&ao(t),t;e.b.error(t)}else Cn(t,e)}function Cn(t,e){for(;e!==null;){if((e.f&ni)!==0)try{e.b.error(t);return}catch(n){t=n}e=e.parent}throw t instanceof Error&&ao(t),t}function ao(t){const e=Bd.get(t);e&&(In(t,"message",{value:e.message}),In(t,"stack",{value:e.stack}))}const Jr=new Set;let ne=null,Yr=null,ai=new Set,lt=[],Xr=null,oi=!1,Pn=!1;class Fe{current=new Map;#t=new Map;#e=new Set;#u=0;#i=null;#l=[];#s=[];#r=[];#n=[];#a=[];#c=[];skipped_effects=new Set;process(e){lt=[],Yr=null;var n=Fe.apply(this);for(const i of e)this.#d(i);if(this.#u===0){this.#h();var r=this.#s,s=this.#r;this.#s=[],this.#r=[],this.#n=[],Yr=this,ne=null,lo(r),lo(s),Yr=null,this.#i?.resolve()}else this.#o(this.#s),this.#o(this.#r),this.#o(this.#n);n();for(const i of this.#l)hr(i);this.#l=[]}#d(e){e.f^=Te;for(var n=e.first;n!==null;){var r=n.f,s=(r&(_t|Pt))!==0,i=s&&(r&Te)!==0,a=i||(r&Ze)!==0||this.skipped_effects.has(n);if(!a&&n.fn!==null){s?n.f^=Te:(r&ei)!==0?this.#r.push(n):(r&Te)===0&&((r&Wr)!==0&&n.b?.is_pending()?this.#l.push(n):rs(n)&&((n.f&Yt)!==0&&this.#n.push(n),hr(n)));var o=n.first;if(o!==null){n=o;continue}}var l=n.parent;for(n=n.next;n===null&&l!==null;)n=l.next,l=l.parent}}#o(e){for(const n of e)((n.f&De)!==0?this.#a:this.#c).push(n),Re(n,Te);e.length=0}capture(e,n){this.#t.has(e)||this.#t.set(e,n),this.current.set(e,e.v)}activate(){ne=this}deactivate(){ne=null}flush(){if(lt.length>0){if(this.activate(),oo(),ne!==null&&ne!==this)return}else this.#u===0&&this.#h();this.deactivate();for(const e of ai)if(ai.delete(e),e(),ne!==null)break}#h(){for(const e of this.#e)e();if(this.#e.clear(),Jr.size>1){this.#t.clear();let e=!0;for(const n of Jr){if(n===this){e=!1;continue}for(const[r,s]of this.current){if(n.current.has(r))if(e)n.current.set(r,s);else continue;co(r)}if(lt.length>0){ne=n;const r=Fe.apply(n);for(const s of lt)n.#d(s);lt=[],r()}}ne=null}Jr.delete(this)}increment(){this.#u+=1}decrement(){this.#u-=1;for(const e of this.#a)Re(e,De),sn(e);for(const e of this.#c)Re(e,Nt),sn(e);this.flush()}add_callback(e){this.#e.add(e)}settled(){return(this.#i??=Za()).promise}static ensure(){if(ne===null){const e=ne=new Fe;Jr.add(ne),Pn||Fe.enqueue(()=>{ne===e&&e.flush()})}return ne}static enqueue(e){vt(e)}static apply(e){return bd}}function de(t){var e=Pn;Pn=!0;try{for(var n;;){if(Md(),lt.length===0&&(ne?.flush(),lt.length===0))return Xr=null,n;oo()}}finally{Pn=e}}function oo(){var t=Ln;oi=!0;try{var e=0;for(Po(!0);lt.length>0;){var n=Fe.ensure();if(e++>1e3){var r,s;qd()}n.process(lt),jt.clear()}}finally{oi=!1,Po(t),Xr=null}}function qd(){try{Id()}catch(t){Cn(t,Xr)}}let rn=null;function lo(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(Xt|Ze))===0&&rs(r)&&(rn=[],hr(r),r.deps===null&&r.first===null&&r.nodes_start===null&&(r.teardown===null&&r.ac===null?Io(r):r.fn=null),rn?.length>0)){jt.clear();for(const s of rn)hr(s);rn=[]}}rn=null}}function co(t){if(t.reactions!==null)for(const e of t.reactions){const n=e.f;(n&Ce)!==0?co(e):(n&(Wr|Yt))!==0&&(Re(e,De),sn(e))}}function sn(t){for(var e=Xr=t;e.parent!==null;){e=e.parent;var n=e.f;if(oi&&e===U&&(n&Yt)!==0)return;if((n&(Pt|_t))!==0){if((n&Te)===0)return;e.f^=Te}}lt.push(e)}function Hd(t){let e=0,n=bt(0),r;return()=>{nh()&&(w(n),es(()=>(e===0&&(r=is(()=>t(()=>cr(n)))),e+=1,()=>{vt(()=>{e-=1,e===0&&(r?.(),r=void 0,cr(n))})})))}}var zd=zr|Zt|ni;function Wd(t,e,n){new Gd(t,e,n)}class Gd{parent;#t=!1;#e;#u=P?F:null;#i;#l;#s;#r=null;#n=null;#a=null;#c=null;#d=0;#o=0;#h=!1;#f=null;#_=()=>{this.#f&&yt(this.#f,this.#d)};#v=Hd(()=>(this.#f=bt(this.#d),()=>{this.#f=null}));constructor(e,n,r){this.#e=e,this.#i=n,this.#l=r,this.parent=U.b,this.#t=!!this.#i.pending,this.#s=ts(()=>{if(U.b=this,P){const s=this.#u;tn(),s.nodeType===en&&s.data===ir?this.#y():this.#b()}else{try{this.#r=Be(()=>r(this.#e))}catch(s){this.error(s)}this.#o>0?this.#g():this.#t=!1}},zd),P&&(this.#e=F)}#b(){try{this.#r=Be(()=>this.#l(this.#e))}catch(e){this.error(e)}this.#t=!1}#y(){const e=this.#i.pending;e&&(this.#n=Be(()=>e(this.#e)),Fe.enqueue(()=>{this.#r=this.#p(()=>(Fe.ensure(),Be(()=>this.#l(this.#e)))),this.#o>0?this.#g():(kt(this.#n,()=>{this.#n=null}),this.#t=!1)}))}is_pending(){return this.#t||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#i.pending}#p(e){var n=U,r=B,s=Pe;Ve(this.#s),xe(this.#s),Lt(this.#s.ctx);try{return e()}catch(i){return io(i),null}finally{Ve(n),xe(r),Lt(s)}}#g(){const e=this.#i.pending;this.#r!==null&&(this.#c=document.createDocumentFragment(),Kd(this.#r,this.#c)),this.#n===null&&(this.#n=Be(()=>e(this.#e)))}#m(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#m(e);return}this.#o+=e,this.#o===0&&(this.#t=!1,this.#n&&kt(this.#n,()=>{this.#n=null}),this.#c&&(this.#e.before(this.#c),this.#c=null),vt(()=>{Fe.ensure().flush()}))}update_pending_count(e){this.#m(e),this.#d+=e,ai.add(this.#_)}get_effect_pending(){return this.#v(),w(this.#f)}error(e){var n=this.#i.onerror;let r=this.#i.failed;if(this.#h||!n&&!r)throw e;this.#r&&(qe(this.#r),this.#r=null),this.#n&&(qe(this.#n),this.#n=null),this.#a&&(qe(this.#a),this.#a=null),P&&(we(this.#u),Dd(),we(lr()));var s=!1,i=!1;const a=()=>{if(s){jd();return}s=!0,i&&Ld(),Fe.ensure(),this.#d=0,this.#a!==null&&kt(this.#a,()=>{this.#a=null}),this.#t=this.has_pending_snippet(),this.#r=this.#p(()=>(this.#h=!1,Be(()=>this.#l(this.#e)))),this.#o>0?this.#g():this.#t=!1};var o=B;try{xe(null),i=!0,n?.(e,a),i=!1}catch(l){Cn(l,this.#s&&this.#s.parent)}finally{xe(o)}r&&vt(()=>{this.#a=this.#p(()=>{this.#h=!0;try{return Be(()=>{r(this.#e,()=>e,()=>a)})}catch(l){return Cn(l,this.#s.parent),null}finally{this.#h=!1}})})}}function Kd(t,e){for(var n=t.nodes_start,r=t.nodes_end;n!==null;){var s=n===r?null:Qe(n);e.append(n),n=s}}function Vd(t,e,n){const r=Zr;if(e.length===0){n(t.map(r));return}var s=ne,i=U,a=Jd(),o=P;Promise.all(e.map(l=>Yd(l))).then(l=>{a();try{n([...t.map(r),...l])}catch(c){(i.f&Xt)===0&&Cn(c,i)}o&&Ue(!1),s?.deactivate(),uo()}).catch(l=>{Cn(l,i)})}function Jd(){var t=U,e=B,n=Pe,r=ne,s=P;if(s)var i=F;return function(){Ve(t),xe(e),Lt(n),r?.activate(),s&&(Ue(!0),we(i))}}function uo(){Ve(null),xe(null),Lt(null)}function Zr(t){var e=Ce|De,n=B!==null&&(B.f&Ce)!==0?B:null;return U===null||n!==null&&(n.f&Ke)!==0?e|=Ke:U.f|=Zt,{ctx:Pe,deps:null,effects:null,equals:to,f:e,fn:t,reactions:null,rv:0,v:_e,wv:0,parent:n??U,ac:null}}function Yd(t,e){let n=U;n===null&&xd();var r=n.b,s=void 0,i=bt(_e),a=!B,o=new Map;return ih(()=>{var l=Za();s=l.promise;try{Promise.resolve(t()).then(l.resolve,l.reject)}catch(h){l.reject(h)}var c=ne,u=r.is_pending();a&&(r.update_pending_count(1),u||(c.increment(),o.get(c)?.reject(ar),o.set(c,l)));const d=(h,f=void 0)=>{u||c.activate(),f?f!==ar&&(i.f|=Qt,yt(i,f)):((i.f&Qt)!==0&&(i.f^=Qt),yt(i,h)),a&&(r.update_pending_count(-1),u||c.decrement()),uo()};l.promise.then(d,h=>d(null,h||"unknown"))}),So(()=>{for(const l of o.values())l.reject(ar)}),new Promise(l=>{function c(u){function d(){u===s?l(i):c(s)}u.then(d,d)}c(s)})}function Nn(t){const e=Zr(t);return Lo(e),e}function Xd(t){const e=Zr(t);return e.equals=no,e}function ho(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)qe(e[n])}}function Zd(t){for(var e=t.parent;e!==null;){if((e.f&Ce)===0)return e;e=e.parent}return null}function li(t){var e,n=U;Ve(Zd(t));try{ho(t),e=Mo(t)}finally{Ve(n)}return e}function fo(t){var e=li(t);if(t.equals(e)||(t.v=e,t.wv=Uo()),!an){var n=(Dt||(t.f&Ke)!==0)&&t.deps!==null?Nt:Te;Re(t,n)}}const jt=new Map;function bt(t,e){var n={f:0,v:t,reactions:null,equals:to,rv:0,wv:0};return n}function te(t,e){const n=bt(t);return Lo(n),n}function po(t,e=!1,n=!0){const r=bt(t);return e||(r.equals=no),r}function O(t,e,n=!1){B!==null&&(!tt||(B.f&Qa)!==0)&&ro()&&(B.f&(Ce|Yt|Wr|Qa))!==0&&!St?.includes(t)&&Nd();let r=n?wt(e):e;return yt(t,r)}function yt(t,e){if(!t.equals(e)){var n=t.v;an?jt.set(t,e):jt.set(t,n),t.v=e;var r=Fe.ensure();r.capture(t,n),(t.f&Ce)!==0&&((t.f&De)!==0&&li(t),Re(t,(t.f&Ke)===0?Te:Nt)),t.wv=Uo(),go(t,De),U!==null&&(U.f&Te)!==0&&(U.f&(_t|Pt))===0&&(Je===null?oh([t]):Je.push(t))}return e}function cr(t){O(t,t.v+1)}function go(t,e){var n=t.reactions;if(n!==null)for(var r=n.length,s=0;s<r;s++){var i=n[s],a=i.f,o=(a&De)===0;o&&Re(i,e),(a&Ce)!==0?go(i,Nt):o&&((a&Yt)!==0&&rn!==null&&rn.push(i),sn(i))}}function wt(t){if(typeof t!="object"||t===null||Gr in t)return t;const e=Ja(t);if(e!==_d&&e!==vd)return t;var n=new Map,r=Zs(t),s=te(0),i=on,a=o=>{if(on===i)return o();var l=B,c=on;xe(null),Do(i);var u=o();return xe(l),Do(c),u};return r&&n.set("length",te(t.length)),new Proxy(t,{defineProperty(o,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&Cd();var u=n.get(l);return u===void 0?u=a(()=>{var d=te(c.value);return n.set(l,d),d}):O(u,c.value,!0),!0},deleteProperty(o,l){var c=n.get(l);if(c===void 0){if(l in o){const u=a(()=>te(_e));n.set(l,u),cr(s)}}else O(c,_e),cr(s);return!0},get(o,l,c){if(l===Gr)return t;var u=n.get(l),d=l in o;if(u===void 0&&(!d||$n(o,l)?.writable)&&(u=a(()=>{var f=wt(d?o[l]:_e),m=te(f);return m}),n.set(l,u)),u!==void 0){var h=w(u);return h===_e?void 0:h}return Reflect.get(o,l,c)},getOwnPropertyDescriptor(o,l){var c=Reflect.getOwnPropertyDescriptor(o,l);if(c&&"value"in c){var u=n.get(l);u&&(c.value=w(u))}else if(c===void 0){var d=n.get(l),h=d?.v;if(d!==void 0&&h!==_e)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(o,l){if(l===Gr)return!0;var c=n.get(l),u=c!==void 0&&c.v!==_e||Reflect.has(o,l);if(c!==void 0||U!==null&&(!u||$n(o,l)?.writable)){c===void 0&&(c=a(()=>{var h=u?wt(o[l]):_e,f=te(h);return f}),n.set(l,c));var d=w(c);if(d===_e)return!1}return u},set(o,l,c,u){var d=n.get(l),h=l in o;if(r&&l==="length")for(var f=c;f<d.v;f+=1){var m=n.get(f+"");m!==void 0?O(m,_e):f in o&&(m=a(()=>te(_e)),n.set(f+"",m))}if(d===void 0)(!h||$n(o,l)?.writable)&&(d=a(()=>te(void 0)),O(d,wt(c)),n.set(l,d));else{h=d.v!==_e;var _=a(()=>wt(c));O(d,_)}var v=Reflect.getOwnPropertyDescriptor(o,l);if(v?.set&&v.set.call(u,c),!h){if(r&&typeof l=="string"){var S=n.get("length"),g=Number(l);Number.isInteger(g)&&g>=S.v&&O(S,g+1)}cr(s)}return!0},ownKeys(o){w(s);var l=Reflect.ownKeys(o).filter(d=>{var h=n.get(d);return h===void 0||h.v!==_e});for(var[c,u]of n)u.v!==_e&&!(c in o)&&l.push(c);return l},setPrototypeOf(){Pd()}})}var mo,_o,vo,bo;function ci(){if(mo===void 0){mo=window,_o=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;vo=$n(e,"firstChild").get,bo=$n(e,"nextSibling").get,Ya(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),Ya(n)&&(n.__t=void 0)}}function Et(t=""){return document.createTextNode(t)}function Me(t){return vo.call(t)}function Qe(t){return bo.call(t)}function X(t,e){if(!P)return Me(t);var n=Me(F);if(n===null)n=F.appendChild(Et());else if(e&&n.nodeType!==ii){var r=Et();return n?.before(r),we(r),r}return we(n),n}function et(t,e=!1){if(!P){var n=Me(t);return n instanceof Comment&&n.data===""?Qe(n):n}if(e&&F?.nodeType!==ii){var r=Et();return F?.before(r),we(r),r}return F}function ie(t,e=1,n=!1){let r=P?F:t;for(var s;e--;)s=r,r=Qe(r);if(!P)return r;if(n&&r?.nodeType!==ii){var i=Et();return r===null?s?.after(i):r.before(i),we(i),i}return we(r),r}function yo(t){t.textContent=""}function wo(){return!1}let Eo=!1;function ko(){Eo||(Eo=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{if(!t.defaultPrevented)for(const e of t.target.elements)e.__on_r?.()})},{capture:!0}))}function Qr(t){var e=B,n=U;xe(null),Ve(null);try{return t()}finally{xe(e),Ve(n)}}function Qd(t,e,n,r=n){t.addEventListener(e,()=>Qr(n));const s=t.__on_r;s?t.__on_r=()=>{s(),r(!0)}:t.__on_r=()=>r(!0),ko()}function eh(t){U===null&&B===null&&Od(),B!==null&&(B.f&Ke)!==0&&U===null&&Rd(),an&&Ad()}function th(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function ct(t,e,n,r=!0){var s=U;s!==null&&(s.f&Ze)!==0&&(t|=Ze);var i={ctx:Pe,deps:null,nodes_start:null,nodes_end:null,f:t|De,first:null,fn:e,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(n)try{hr(i),i.f|=ri}catch(l){throw qe(i),l}else e!==null&&sn(i);if(r){var a=i;if(n&&a.deps===null&&a.teardown===null&&a.nodes_start===null&&a.first===a.last&&(a.f&Zt)===0&&(a=a.first),a!==null&&(a.parent=s,s!==null&&th(a,s),B!==null&&(B.f&Ce)!==0&&(t&Pt)===0)){var o=B;(o.effects??=[]).push(a)}}return i}function nh(){return B!==null&&!tt}function So(t){const e=ct(ti,null,!1);return Re(e,Te),e.teardown=t,e}function ur(t){eh();var e=U.f,n=!B&&(e&_t)!==0&&(e&ri)===0;if(n){var r=Pe;(r.e??=[]).push(t)}else return To(t)}function To(t){return ct(ei|Ed,t,!1)}function rh(t){Fe.ensure();const e=ct(Pt|Zt,t,!0);return()=>{qe(e)}}function sh(t){Fe.ensure();const e=ct(Pt|Zt,t,!0);return(n={})=>new Promise(r=>{n.outro?kt(e,()=>{qe(e),r(void 0)}):(qe(e),r(void 0))})}function xo(t){return ct(ei,t,!1)}function ih(t){return ct(Wr|Zt,t,!0)}function es(t,e=0){return ct(ti|e,t,!0)}function Ne(t,e=[],n=[]){Vd(e,n,r=>{ct(ti,()=>t(...r.map(w)),!0)})}function ts(t,e=0){var n=ct(Yt|e,t,!0);return n}function Be(t,e=!0){return ct(_t|Zt,t,!0,e)}function Ao(t){var e=t.teardown;if(e!==null){const n=an,r=B;No(!0),xe(null);try{e.call(null)}finally{No(n),xe(r)}}}function Ro(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const s=n.ac;s!==null&&Qr(()=>{s.abort(ar)});var r=n.next;(n.f&Pt)!==0?n.parent=null:qe(n,e),n=r}}function ah(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&_t)===0&&qe(e),e=n}}function qe(t,e=!0){var n=!1;(e||(t.f&wd)!==0)&&t.nodes_start!==null&&t.nodes_end!==null&&(Oo(t.nodes_start,t.nodes_end),n=!0),Ro(t,e&&!n),ss(t,0),Re(t,Xt);var r=t.transitions;if(r!==null)for(const i of r)i.stop();Ao(t);var s=t.parent;s!==null&&s.first!==null&&Io(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes_start=t.nodes_end=t.ac=null}function Oo(t,e){for(;t!==null;){var n=t===e?null:Qe(t);t.remove(),t=n}}function Io(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function kt(t,e){var n=[];ui(t,n,!0),$o(n,()=>{qe(t),e&&e()})}function $o(t,e){var n=t.length;if(n>0){var r=()=>--n||e();for(var s of t)s.out(r)}else e()}function ui(t,e,n){if((t.f&Ze)===0){if(t.f^=Ze,t.transitions!==null)for(const a of t.transitions)(a.is_global||n)&&e.push(a);for(var r=t.first;r!==null;){var s=r.next,i=(r.f&zr)!==0||(r.f&_t)!==0;ui(r,e,i?n:!1),r=s}}}function ns(t){Co(t,!0)}function Co(t,e){if((t.f&Ze)!==0){t.f^=Ze,(t.f&Te)===0&&(Re(t,De),sn(t));for(var n=t.first;n!==null;){var r=n.next,s=(n.f&zr)!==0||(n.f&_t)!==0;Co(n,s?e:!1),n=r}if(t.transitions!==null)for(const i of t.transitions)(i.is_global||e)&&i.in()}}let Ln=!1;function Po(t){Ln=t}let an=!1;function No(t){an=t}let B=null,tt=!1;function xe(t){B=t}let U=null;function Ve(t){U=t}let St=null;function Lo(t){B!==null&&(St===null?St=[t]:St.push(t))}let Ae=null,He=0,Je=null;function oh(t){Je=t}let jo=1,dr=0,on=dr;function Do(t){on=t}let Dt=!1;function Uo(){return++jo}function rs(t){var e=t.f;if((e&De)!==0)return!0;if((e&Nt)!==0){var n=t.deps,r=(e&Ke)!==0;if(n!==null){var s,i,a=(e&Hr)!==0,o=r&&U!==null&&!Dt,l=n.length;if((a||o)&&(U===null||(U.f&Xt)===0)){var c=t,u=c.parent;for(s=0;s<l;s++)i=n[s],(a||!i?.reactions?.includes(c))&&(i.reactions??=[]).push(c);a&&(c.f^=Hr),o&&u!==null&&(u.f&Ke)===0&&(c.f^=Ke)}for(s=0;s<l;s++)if(i=n[s],rs(i)&&fo(i),i.wv>t.wv)return!0}(!r||U!==null&&!Dt)&&Re(t,Te)}return!1}function Fo(t,e,n=!0){var r=t.reactions;if(r!==null&&!St?.includes(t))for(var s=0;s<r.length;s++){var i=r[s];(i.f&Ce)!==0?Fo(i,e,!1):e===i&&(n?Re(i,De):(i.f&Te)!==0&&Re(i,Nt),sn(i))}}function Mo(t){var e=Ae,n=He,r=Je,s=B,i=Dt,a=St,o=Pe,l=tt,c=on,u=t.f;Ae=null,He=0,Je=null,Dt=(u&Ke)!==0&&(tt||!Ln||B===null),B=(u&(_t|Pt))===0?t:null,St=null,Lt(t.ctx),tt=!1,on=++dr,t.ac!==null&&(Qr(()=>{t.ac.abort(ar)}),t.ac=null);try{t.f|=si;var d=t.fn,h=d(),f=t.deps;if(Ae!==null){var m;if(ss(t,He),f!==null&&He>0)for(f.length=He+Ae.length,m=0;m<Ae.length;m++)f[He+m]=Ae[m];else t.deps=f=Ae;if(!Dt||(u&Ce)!==0&&t.reactions!==null)for(m=He;m<f.length;m++)(f[m].reactions??=[]).push(t)}else f!==null&&He<f.length&&(ss(t,He),f.length=He);if(ro()&&Je!==null&&!tt&&f!==null&&(t.f&(Ce|Nt|De))===0)for(m=0;m<Je.length;m++)Fo(Je[m],t);return s!==null&&s!==t&&(dr++,Je!==null&&(r===null?r=Je:r.push(...Je))),(t.f&Qt)!==0&&(t.f^=Qt),h}catch(_){return io(_)}finally{t.f^=si,Ae=e,He=n,Je=r,B=s,Dt=i,St=a,Lt(o),tt=l,on=c}}function lh(t,e){let n=e.reactions;if(n!==null){var r=gd.call(n,t);if(r!==-1){var s=n.length-1;s===0?n=e.reactions=null:(n[r]=n[s],n.pop())}}n===null&&(e.f&Ce)!==0&&(Ae===null||!Ae.includes(e))&&(Re(e,Nt),(e.f&(Ke|Hr))===0&&(e.f^=Hr),ho(e),ss(e,0))}function ss(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)lh(t,n[r])}function hr(t){var e=t.f;if((e&Xt)===0){Re(t,Te);var n=U,r=Ln;U=t,Ln=!0;try{(e&Yt)!==0?ah(t):Ro(t),Ao(t);var s=Mo(t);t.teardown=typeof s=="function"?s:null,t.wv=jo;var i;Va&&Fd&&(t.f&De)!==0&&t.deps}finally{Ln=r,U=n}}}async function ch(){await Promise.resolve(),de()}function w(t){var e=t.f,n=(e&Ce)!==0;if(B!==null&&!tt){var r=U!==null&&(U.f&Xt)!==0;if(!r&&!St?.includes(t)){var s=B.deps;if((B.f&si)!==0)t.rv<dr&&(t.rv=dr,Ae===null&&s!==null&&s[He]===t?He++:Ae===null?Ae=[t]:(!Dt||!Ae.includes(t))&&Ae.push(t));else{(B.deps??=[]).push(t);var i=t.reactions;i===null?t.reactions=[B]:i.includes(B)||i.push(B)}}}else if(n&&t.deps===null&&t.effects===null){var a=t,o=a.parent;o!==null&&(o.f&Ke)===0&&(a.f^=Ke)}if(an){if(jt.has(t))return jt.get(t);if(n){a=t;var l=a.v;return((a.f&Te)===0&&a.reactions!==null||Bo(a))&&(l=li(a)),jt.set(a,l),l}}else n&&(a=t,rs(a)&&fo(a));if((t.f&Qt)!==0)throw t.v;return t.v}function Bo(t){if(t.v===_e)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(jt.has(e)||(e.f&Ce)!==0&&Bo(e))return!0;return!1}function is(t){var e=tt;try{return tt=!0,t()}finally{tt=e}}const uh=-7169;function Re(t,e){t.f=t.f&uh|e}const qo=new Set,di=new Set;function dh(t){if(!P)return;t.removeAttribute("onload"),t.removeAttribute("onerror");const e=t.__e;e!==void 0&&(t.__e=void 0,queueMicrotask(()=>{t.isConnected&&t.dispatchEvent(e)}))}function hh(t,e,n,r={}){function s(i){if(r.capture||fr.call(e,i),!i.cancelBubble)return Qr(()=>n?.call(this,i))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?vt(()=>{e.addEventListener(t,s,r)}):e.addEventListener(t,s,r),s}function Ho(t,e,n,r,s){var i={capture:r,passive:s},a=hh(t,e,n,i);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&So(()=>{e.removeEventListener(t,a,i)})}function fh(t){for(var e=0;e<t.length;e++)qo.add(t[e]);for(var n of di)n(t)}let zo=null;function fr(t){var e=this,n=e.ownerDocument,r=t.type,s=t.composedPath?.()||[],i=s[0]||t.target;zo=t;var a=0,o=zo===t&&t.__root;if(o){var l=s.indexOf(o);if(l!==-1&&(e===document||e===window)){t.__root=e;return}var c=s.indexOf(e);if(c===-1)return;l<=c&&(a=l)}if(i=s[a]||t.target,i!==e){In(t,"currentTarget",{configurable:!0,get(){return i||n}});var u=B,d=U;xe(null),Ve(null);try{for(var h,f=[];i!==null;){var m=i.assignedSlot||i.parentNode||i.host||null;try{var _=i["__"+r];if(_!=null&&(!i.disabled||t.target===i))if(Zs(_)){var[v,...S]=_;v.apply(i,[t,...S])}else _.call(i,t)}catch(g){h?f.push(g):h=g}if(t.cancelBubble||m===e||m===null)break;i=m}if(h){for(let g of f)queueMicrotask(()=>{throw g});throw h}}finally{t.__root=e,delete t.currentTarget,xe(u),Ve(d)}}}function hi(t){var e=document.createElement("template");return e.innerHTML=t.replaceAll("<!>","<!---->"),e.content}function ut(t,e){var n=U;n.nodes_start===null&&(n.nodes_start=t,n.nodes_end=e)}function Z(t,e){var n=(e&hd)!==0,r=(e&fd)!==0,s,i=!t.startsWith("<!>");return()=>{if(P)return ut(F,null),F;s===void 0&&(s=hi(i?t:"<!>"+t),n||(s=Me(s)));var a=r||_o?document.importNode(s,!0):s.cloneNode(!0);if(n){var o=Me(a),l=a.lastChild;ut(o,l)}else ut(a,a);return a}}function ph(t,e,n="svg"){var r=!t.startsWith("<!>"),s=`<${n}>${r?t:"<!>"+t}</${n}>`,i;return()=>{if(P)return ut(F,null),F;if(!i){var a=hi(s),o=Me(a);i=Me(o)}var l=i.cloneNode(!0);return ut(l,l),l}}function fi(t,e){return ph(t,e,"svg")}function Tt(){if(P)return ut(F,null),F;var t=document.createDocumentFragment(),e=document.createComment(""),n=Et();return t.append(e,n),ut(e,n),t}function j(t,e){if(P){U.nodes_end=F,tn();return}t!==null&&t.before(e)}const gh=["touchstart","touchmove"];function mh(t){return gh.includes(t)}function Ut(t,e){var n=e==null?"":typeof e=="object"?e+"":e;n!==(t.__t??=t.nodeValue)&&(t.__t=n,t.nodeValue=n+"")}function Wo(t,e){return Go(t,e)}function _h(t,e){ci(),e.intro=e.intro??!1;const n=e.target,r=P,s=F;try{for(var i=Me(n);i&&(i.nodeType!==en||i.data!==Ka);)i=Qe(i);if(!i)throw Jt;Ue(!0),we(i);const a=Go(t,{...e,anchor:i});return Ue(!1),a}catch(a){if(a instanceof Error&&a.message.split(`
2
+ `).some(o=>o.startsWith("https://svelte.dev/e/")))throw a;return a!==Jt&&console.warn("Failed to hydrate: ",a),e.recover===!1&&$d(),ci(),yo(n),Ue(!1),Wo(t,e)}finally{Ue(r),we(s)}}const jn=new Map;function Go(t,{target:e,anchor:n,props:r={},events:s,context:i,intro:a=!0}){ci();var o=new Set,l=d=>{for(var h=0;h<d.length;h++){var f=d[h];if(!o.has(f)){o.add(f);var m=mh(f);e.addEventListener(f,fr,{passive:m});var _=jn.get(f);_===void 0?(document.addEventListener(f,fr,{passive:m}),jn.set(f,1)):jn.set(f,_+1)}}};l(Qs(qo)),di.add(l);var c=void 0,u=sh(()=>{var d=n??e.appendChild(Et());return Wd(d,{pending:()=>{}},h=>{if(i){Kr({});var f=Pe;f.c=i}if(s&&(r.$$events=s),P&&ut(h,null),c=t(h,r)||{},P&&(U.nodes_end=F,F===null||F.nodeType!==en||F.data!==Xs))throw or(),Jt;i&&Vr()}),()=>{for(var h of o){e.removeEventListener(h,fr);var f=jn.get(h);--f===0?(document.removeEventListener(h,fr),jn.delete(h)):jn.set(h,f)}di.delete(l),d!==n&&d.parentNode?.removeChild(d)}});return pi.set(c,u),c}let pi=new WeakMap;function vh(t,e){const n=pi.get(t);return n?(pi.delete(t),n(e)):Promise.resolve()}function bh(t){Pe===null&&Td(),ur(()=>{const e=is(t);if(typeof e=="function")return e})}const gi=0,as=1,mi=2;function Ko(t,e,n,r,s){P&&tn();var i=t,a=Pe,o=_e,l,c,u,d=bt(void 0),h=bt(void 0),f=!1;function m(v,S){f=!0,S&&(Ve(_),xe(_),Lt(a));try{v===as&&r&&(c?ns(c):c=Be(()=>r(i,d))),v!==gi&&l&&kt(l,()=>l=null),v!==as&&c&&kt(c,()=>c=null),v!==mi&&u&&kt(u,()=>u=null)}finally{S&&(Lt(null),xe(null),Ve(null),Pn||de())}}var _=ts(()=>{if(o===(o=e()))return;let v=P&&Xa(o)===(i.data===ir);if(v&&(i=lr(),we(i),Ue(!1),v=!0),Xa(o)){var S=o;f=!1,S.then(g=>{S===o&&(yt(d,g),m(as,!0))},g=>{if(S===o)throw yt(h,g),m(mi,!0),h.v}),P||vt(()=>{f||m(gi,!0)})}else yt(d,o),m(as,!1);return v&&Ue(!0),()=>o=_e});P&&(i=F)}function oe(t,e,n=!1){P&&tn();var r=t,s=null,i=null,a=_e,o=n?zr:0,l=!1;const c=(f,m=!0)=>{l=!0,h(m,f)};var u=null;function d(){u!==null&&(u.lastChild.remove(),r.before(u),u=null);var f=a?s:i,m=a?i:s;f&&ns(f),m&&kt(m,()=>{a?i=null:s=null})}const h=(f,m)=>{if(a===(a=f))return;let _=!1;if(P){const E=eo(r)===ir;!!a===E&&(r=lr(),we(r),Ue(!1),_=!0)}var v=wo(),S=r;if(v&&(u=document.createDocumentFragment(),u.append(S=Et())),a?s??=m&&Be(()=>m(S)):i??=m&&Be(()=>m(S)),v){var g=ne,p=a?s:i,y=a?i:s;p&&g.skipped_effects.delete(p),y&&g.skipped_effects.add(y),g.add_callback(d)}else d();_&&Ue(!0)};ts(()=>{l=!1,e(c),l||h(null,null)},o),P&&(r=F)}function pr(t,e){return e}function yh(t,e,n){for(var r=t.items,s=[],i=e.length,a=0;a<i;a++)ui(e[a].e,s,!0);var o=i>0&&s.length===0&&n!==null;if(o){var l=n.parentNode;yo(l),l.append(n),r.clear(),dt(t,e[0].prev,e[i-1].next)}$o(s,()=>{for(var c=0;c<i;c++){var u=e[c];o||(r.delete(u.k),dt(t,u.prev,u.next)),qe(u.e,!o)}})}function gr(t,e,n,r,s,i=null){var a=t,o={flags:e,items:new Map,first:null},l=(e&Ga)!==0;if(l){var c=t;a=P?we(Me(c)):c.appendChild(Et())}P&&tn();var u=null,d=!1,h=new Map,f=Xd(()=>{var S=n();return Zs(S)?S:S==null?[]:Qs(S)}),m,_;function v(){wh(_,m,o,h,a,s,e,r,n),i!==null&&(m.length===0?u?ns(u):u=Be(()=>i(a)):u!==null&&kt(u,()=>{u=null}))}ts(()=>{_??=U,m=w(f);var S=m.length;if(d&&S===0)return;d=S===0;let g=!1;if(P){var p=eo(a)===ir;p!==(S===0)&&(a=lr(),we(a),Ue(!1),g=!0)}if(P){for(var y=null,E,b=0;b<S;b++){if(F.nodeType===en&&F.data===Xs){a=F,g=!0,Ue(!1);break}var k=m[b],A=r(k,b);E=_i(F,o,y,null,k,A,b,s,e,n),o.items.set(A,E),y=E}S>0&&we(lr())}if(P)S===0&&i&&(u=Be(()=>i(a)));else if(wo()){var T=new Set,x=ne;for(b=0;b<S;b+=1){k=m[b],A=r(k,b);var $=o.items.get(A)??h.get(A);$?(e&(Mr|Br))!==0&&Vo($,k,b,e):(E=_i(null,o,null,null,k,A,b,s,e,n,!0),h.set(A,E)),T.add(A)}for(const[V,pe]of o.items)T.has(V)||x.skipped_effects.add(pe.e);x.add_callback(v)}else v();g&&Ue(!0),w(f)}),P&&(a=F)}function wh(t,e,n,r,s,i,a,o,l){var c=(a&ud)!==0,u=(a&(Mr|Br))!==0,d=e.length,h=n.items,f=n.first,m=f,_,v=null,S,g=[],p=[],y,E,b,k;if(c)for(k=0;k<d;k+=1)y=e[k],E=o(y,k),b=h.get(E),b!==void 0&&(b.a?.measure(),(S??=new Set).add(b));for(k=0;k<d;k+=1){if(y=e[k],E=o(y,k),b=h.get(E),b===void 0){var A=r.get(E);if(A!==void 0){r.delete(E),h.set(E,A);var T=v?v.next:m;dt(n,v,A),dt(n,A,T),vi(A,T,s),v=A}else{var x=m?m.e.nodes_start:s;v=_i(x,n,v,v===null?n.first:v.next,y,E,k,i,a,l)}h.set(E,v),g=[],p=[],m=v.next;continue}if(u&&Vo(b,y,k,a),(b.e.f&Ze)!==0&&(ns(b.e),c&&(b.a?.unfix(),(S??=new Set).delete(b))),b!==m){if(_!==void 0&&_.has(b)){if(g.length<p.length){var $=p[0],V;v=$.prev;var pe=g[0],ge=g[g.length-1];for(V=0;V<g.length;V+=1)vi(g[V],$,s);for(V=0;V<p.length;V+=1)_.delete(p[V]);dt(n,pe.prev,ge.next),dt(n,v,pe),dt(n,ge,$),m=$,v=ge,k-=1,g=[],p=[]}else _.delete(b),vi(b,m,s),dt(n,b.prev,b.next),dt(n,b,v===null?n.first:v.next),dt(n,v,b),v=b;continue}for(g=[],p=[];m!==null&&m.k!==E;)(m.e.f&Ze)===0&&(_??=new Set).add(m),p.push(m),m=m.next;if(m===null)continue;b=m}g.push(b),v=b,m=b.next}if(m!==null||_!==void 0){for(var re=_===void 0?[]:Qs(_);m!==null;)(m.e.f&Ze)===0&&re.push(m),m=m.next;var ye=re.length;if(ye>0){var Ge=(a&Ga)!==0&&d===0?s:null;if(c){for(k=0;k<ye;k+=1)re[k].a?.measure();for(k=0;k<ye;k+=1)re[k].a?.fix()}yh(n,re,Ge)}}c&&vt(()=>{if(S!==void 0)for(b of S)b.a?.apply()}),t.first=n.first&&n.first.e,t.last=v&&v.e;for(var W of r.values())qe(W.e);r.clear()}function Vo(t,e,n,r){(r&Mr)!==0&&yt(t.v,e),(r&Br)!==0?yt(t.i,n):t.i=n}function _i(t,e,n,r,s,i,a,o,l,c,u){var d=(l&Mr)!==0,h=(l&dd)===0,f=d?h?po(s,!1,!1):bt(s):s,m=(l&Br)===0?a:bt(a),_={i:m,v:f,k:i,a:null,e:null,prev:n,next:r};try{if(t===null){var v=document.createDocumentFragment();v.append(t=Et())}return _.e=Be(()=>o(t,f,m,c),P),_.e.prev=n&&n.e,_.e.next=r&&r.e,n===null?u||(e.first=_):(n.next=_,n.e.next=_.e),r!==null&&(r.prev=_,r.e.prev=_.e),_}finally{}}function vi(t,e,n){for(var r=t.next?t.next.e.nodes_start:n,s=e?e.e.nodes_start:n,i=t.e.nodes_start;i!==null&&i!==r;){var a=Qe(i);s.before(i),i=a}}function dt(t,e,n){e===null?t.first=n:(e.next=n,e.e.next=n&&n.e),n!==null&&(n.prev=e,n.e.prev=e&&e.e)}function Eh(t,e,n=!1,r=!1,s=!1){var i=t,a="";Ne(()=>{var o=U;if(a===(a=e()??"")){P&&tn();return}if(o.nodes_start!==null&&(Oo(o.nodes_start,o.nodes_end),o.nodes_start=o.nodes_end=null),a!==""){if(P){F.data;for(var l=tn(),c=l;l!==null&&(l.nodeType!==en||l.data!=="");)c=l,l=Qe(l);if(l===null)throw or(),Jt;ut(F,c),i=we(l);return}var u=a+"";n?u=`<svg>${u}</svg>`:r&&(u=`<math>${u}</math>`);var d=hi(u);if((n||r)&&(d=Me(d)),ut(Me(d),d.lastChild),n||r)for(;Me(d);)i.before(Me(d));else i.before(d)}})}function Jo(t,e){xo(()=>{var n=t.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+e.hash)){const s=document.createElement("style");s.id=e.hash,s.textContent=e.code,r.appendChild(s)}})}const Yo=[...`
3
+ \r\f \v\uFEFF`];function kh(t,e,n){var r=""+t;if(n){for(var s in n)if(n[s])r=r?r+" "+s:s;else if(r.length)for(var i=s.length,a=0;(a=r.indexOf(s,a))>=0;){var o=a+i;(a===0||Yo.includes(r[a-1]))&&(o===r.length||Yo.includes(r[o]))?r=(a===0?"":r.substring(0,a))+r.substring(o+1):a=o}}return r===""?null:r}function Sh(t,e){return t==null?null:String(t)}function Th(t,e,n,r,s,i){var a=t.__className;if(P||a!==n||a===void 0){var o=kh(n,r,i);(!P||o!==t.getAttribute("class"))&&(o==null?t.removeAttribute("class"):t.className=o),t.__className=n}else if(i&&s!==i)for(var l in i){var c=!!i[l];(s==null||c!==!!s[l])&&t.classList.toggle(l,c)}return i}function os(t,e,n,r){var s=t.__style;if(P||s!==e){var i=Sh(e);(!P||i!==t.getAttribute("style"))&&(i==null?t.removeAttribute("style"):t.style.cssText=i),t.__style=e}return r}const xh=Symbol("is custom element"),Ah=Symbol("is html");function Rh(t){if(P){var e=!1,n=()=>{if(!e){if(e=!0,t.hasAttribute("value")){var r=t.value;Ye(t,"value",null),t.value=r}if(t.hasAttribute("checked")){var s=t.checked;Ye(t,"checked",null),t.checked=s}}};t.__on_r=n,vt(n),ko()}}function Ye(t,e,n,r){var s=Oh(t);P&&(s[e]=t.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&t.nodeName==="LINK")||s[e]!==(s[e]=n)&&(e==="loading"&&(t[Sd]=n),n==null?t.removeAttribute(e):typeof n!="string"&&Ih(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function Oh(t){return t.__attributes??={[xh]:t.nodeName.includes("-"),[Ah]:t.namespaceURI===pd}}var Xo=new Map;function Ih(t){var e=t.getAttribute("is")||t.nodeName,n=Xo.get(e);if(n)return n;Xo.set(e,n=[]);for(var r,s=t,i=Element.prototype;i!==s;){r=md(s);for(var a in r)r[a].set&&n.push(a);s=Ja(s)}return n}function $h(t,e,n=e){var r=new WeakSet;Qd(t,"input",async s=>{var i=s?t.defaultValue:t.value;if(i=bi(t)?yi(i):i,n(i),ne!==null&&r.add(ne),await ch(),i!==(i=e())){var a=t.selectionStart,o=t.selectionEnd;t.value=i??"",o!==null&&(t.selectionStart=a,t.selectionEnd=Math.min(o,t.value.length))}}),(P&&t.defaultValue!==t.value||is(e)==null&&t.value)&&(n(bi(t)?yi(t.value):t.value),ne!==null&&r.add(ne)),es(()=>{var s=e();if(t===document.activeElement){var i=Yr??ne;if(r.has(i))return}bi(t)&&s===yi(t.value)||t.type==="date"&&!s&&!t.value||s!==t.value&&(t.value=s??"")})}function bi(t){var e=t.type;return e==="number"||e==="range"}function yi(t){return t===""?null:+t}function Zo(t,e){return t===e||t?.[Gr]===e}function Qo(t={},e,n,r){return xo(()=>{var s,i;return es(()=>{s=i,i=[],is(()=>{t!==n(...i)&&(e(t,...i),s&&Zo(n(...s),t)&&e(null,...s))})}),()=>{vt(()=>{i&&Zo(n(...i),t)&&e(null,...i)})}}),t}function Ee(t,e,n,r){var s=r,i=!0,a=()=>(i&&(i=!1,s=r),s),o;o=t[e],o===void 0&&r!==void 0&&(o=a());var l;l=()=>{var h=t[e];return h===void 0?a():(i=!0,h)};var c=!1,u=Zr(()=>(c=!1,l())),d=U;return(function(h,f){if(arguments.length>0){const m=f?w(u):h;return O(u,m),c=!0,s!==void 0&&(s=m),h}return an&&c||(d.f&Xt)!==0?u.v:w(u)})}function Ch(t){return new Ph(t)}class Ph{#t;#e;constructor(e){var n=new Map,r=(i,a)=>{var o=po(a,!1,!1);return n.set(i,o),o};const s=new Proxy({...e.props||{},$$events:{}},{get(i,a){return w(n.get(a)??r(a,Reflect.get(i,a)))},has(i,a){return a===kd?!0:(w(n.get(a)??r(a,Reflect.get(i,a))),Reflect.has(i,a))},set(i,a,o){return O(n.get(a)??r(a,o),o),Reflect.set(i,a,o)}});this.#e=(e.hydrate?_h:Wo)(e.component,{target:e.target,anchor:e.anchor,props:s,context:e.context,intro:e.intro??!1,recover:e.recover}),(!e?.props?.$$host||e.sync===!1)&&de(),this.#t=s.$$events;for(const i of Object.keys(this.#e))i==="$set"||i==="$destroy"||i==="$on"||In(this,i,{get(){return this.#e[i]},set(a){this.#e[i]=a},enumerable:!0});this.#e.$set=i=>{Object.assign(s,i)},this.#e.$destroy=()=>{vh(this.#e)}}$set(e){this.#e.$set(e)}$on(e,n){this.#t[e]=this.#t[e]||[];const r=(...s)=>n.call(this,...s);return this.#t[e].push(r),()=>{this.#t[e]=this.#t[e].filter(s=>s!==r)}}$destroy(){this.#e.$destroy()}}let el;typeof HTMLElement=="function"&&(el=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;$$me;constructor(t,e,n){super(),this.$$ctor=t,this.$$s=e,n&&this.attachShadow({mode:"open"})}addEventListener(t,e,n){if(this.$$l[t]=this.$$l[t]||[],this.$$l[t].push(e),this.$$c){const r=this.$$c.$on(t,e);this.$$l_u.set(e,r)}super.addEventListener(t,e,n)}removeEventListener(t,e,n){if(super.removeEventListener(t,e,n),this.$$c){const r=this.$$l_u.get(e);r&&(r(),this.$$l_u.delete(e))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let t=function(r){return s=>{const i=document.createElement("slot");r!=="default"&&(i.name=r),j(s,i)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const e={},n=Nh(this);for(const r of this.$$s)r in n&&(r==="default"&&!this.$$d.children?(this.$$d.children=t(r),e.default=!0):e[r]=t(r));for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=ls(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=Ch({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:e,$$host:this}}),this.$$me=rh(()=>{es(()=>{this.$$r=!0;for(const r of qr(this.$$c)){if(!this.$$p_d[r]?.reflect)continue;this.$$d[r]=this.$$c[r];const s=ls(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1})});for(const r in this.$$l)for(const s of this.$$l[r]){const i=this.$$c.$on(r,s);this.$$l_u.set(s,i)}this.$$l={}}}attributeChangedCallback(t,e,n){this.$$r||(t=this.$$g_p(t),this.$$d[t]=ls(t,n,this.$$p_d,"toProp"),this.$$c?.$set({[t]:this.$$d[t]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(t){return qr(this.$$p_d).find(e=>this.$$p_d[e].attribute===t||!this.$$p_d[e].attribute&&e.toLowerCase()===t)||t}});function ls(t,e,n,r){const s=n[t]?.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!r||!n[t])return e;if(r==="toAttribute")switch(s){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(s){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Nh(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}function wi(t,e,n,r,s,i){let a=class extends el{constructor(){super(t,n,s),this.$$p_d=e}static get observedAttributes(){return qr(e).map(o=>(e[o].attribute||o).toLowerCase())}};return qr(e).forEach(o=>{In(a.prototype,o,{get(){return this.$$c&&o in this.$$c?this.$$c[o]:this.$$d[o]},set(l){l=ls(o,l,e),this.$$d[o]=l;var c=this.$$c;if(c){var u=$n(c,o)?.get;u?c[o]=l:c.$set({[o]:l})}}})}),r.forEach(o=>{In(a.prototype,o,{get(){return this.$$c?.[o]}})}),t.element=a,a}const Lh=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Promise.resolve().then(()=>Hn).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)};class Ei extends Error{constructor(e,n="FunctionsError",r){super(e),this.name=n,this.context=r}}class tl extends Ei{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class nl extends Ei{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class rl extends Ei{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var ki;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(ki||(ki={}));var jh=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class Dh{constructor(e,{headers:n={},customFetch:r,region:s=ki.Any}={}){this.url=e,this.headers=n,this.region=s,this.fetch=Lh(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return jh(this,arguments,void 0,function*(n,r={}){var s;try{const{headers:i,method:a,body:o,signal:l}=r;let c={},{region:u}=r;u||(u=this.region);const d=new URL(`${this.url}/${n}`);u&&u!=="any"&&(c["x-region"]=u,d.searchParams.set("forceFunctionRegion",u));let h;o&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(c["Content-Type"]="application/octet-stream",h=o):typeof o=="string"?(c["Content-Type"]="text/plain",h=o):typeof FormData<"u"&&o instanceof FormData?h=o:(c["Content-Type"]="application/json",h=JSON.stringify(o)));const f=yield this.fetch(d.toString(),{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},c),this.headers),i),body:h,signal:l}).catch(S=>{throw S.name==="AbortError"?S:new tl(S)}),m=f.headers.get("x-relay-error");if(m&&m==="true")throw new nl(f);if(!f.ok)throw new rl(f);let _=((s=f.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),v;return _==="application/json"?v=yield f.json():_==="application/octet-stream"?v=yield f.blob():_==="text/event-stream"?v=f:_==="multipart/form-data"?v=yield f.formData():v=yield f.text(),{data:v,error:null,response:f}}catch(i){return i instanceof Error&&i.name==="AbortError"?{data:null,error:new tl(i)}:{data:null,error:i,response:i instanceof rl||i instanceof nl?i.context:void 0}}})}}function Uh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Fh(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var be={},Dn={},Un={},Fn={},Mn={},Bn={},Mh=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")},qn=Mh();const Bh=qn.fetch,sl=qn.fetch.bind(qn),il=qn.Headers,qh=qn.Request,Hh=qn.Response,Hn=Object.freeze(Object.defineProperty({__proto__:null,Headers:il,Request:qh,Response:Hh,default:sl,fetch:Bh},Symbol.toStringTag,{value:"Module"})),zh=Fh(Hn);var cs={},al;function ol(){if(al)return cs;al=1,Object.defineProperty(cs,"__esModule",{value:!0});class t extends Error{constructor(n){super(n.message),this.name="PostgrestError",this.details=n.details,this.hint=n.hint,this.code=n.code}}return cs.default=t,cs}var ll;function cl(){if(ll)return Bn;ll=1;var t=Bn&&Bn.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Bn,"__esModule",{value:!0});const e=t(zh),n=t(ol());class r{constructor(i){var a,o;this.shouldThrowOnError=!1,this.method=i.method,this.url=i.url,this.headers=new Headers(i.headers),this.schema=i.schema,this.body=i.body,this.shouldThrowOnError=(a=i.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=i.signal,this.isMaybeSingle=(o=i.isMaybeSingle)!==null&&o!==void 0?o:!1,i.fetch?this.fetch=i.fetch:typeof fetch>"u"?this.fetch=e.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(i,a){return this.headers=new Headers(this.headers),this.headers.set(i,a),this}then(i,a){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const o=this.fetch;let l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var u,d,h,f;let m=null,_=null,v=null,S=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){const b=await c.text();b===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((u=this.headers.get("Accept"))===null||u===void 0)&&u.includes("application/vnd.pgrst.plan+text"))?_=b:_=JSON.parse(b))}const y=(d=this.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),E=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");y&&E&&E.length>1&&(v=parseInt(E[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(_)&&(_.length>1?(m={code:"PGRST116",details:`Results contain ${_.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},_=null,v=null,S=406,g="Not Acceptable"):_.length===1?_=_[0]:_=null)}else{const y=await c.text();try{m=JSON.parse(y),Array.isArray(m)&&c.status===404&&(_=[],m=null,S=200,g="OK")}catch{c.status===404&&y===""?(S=204,g="No Content"):m={message:y}}if(m&&this.isMaybeSingle&&(!((f=m?.details)===null||f===void 0)&&f.includes("0 rows"))&&(m=null,S=200,g="OK"),m&&this.shouldThrowOnError)throw new n.default(m)}return{error:m,data:_,count:v,status:S,statusText:g}});return this.shouldThrowOnError||(l=l.catch(c=>{var u,d,h;return{error:{message:`${(u=c?.name)!==null&&u!==void 0?u:"FetchError"}: ${c?.message}`,details:`${(d=c?.stack)!==null&&d!==void 0?d:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(i,a)}returns(){return this}overrideTypes(){return this}}return Bn.default=r,Bn}var ul;function dl(){if(ul)return Mn;ul=1;var t=Mn&&Mn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Mn,"__esModule",{value:!0});const e=t(cl());class n extends e.default{select(s){let i=!1;const a=(s??"*").split("").map(o=>/\s/.test(o)&&!i?"":(o==='"'&&(i=!i),o)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:i=!0,nullsFirst:a,foreignTable:o,referencedTable:l=o}={}){const c=l?`${l}.order`:"order",u=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${u?`${u},`:""}${s}.${i?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:i,referencedTable:a=i}={}){const o=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(o,`${s}`),this}range(s,i,{foreignTable:a,referencedTable:o=a}={}){const l=typeof o>"u"?"offset":`${o}.offset`,c=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${s}`),this.url.searchParams.set(c,`${i-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:s=!1,verbose:i=!1,settings:a=!1,buffers:o=!1,wal:l=!1,format:c="text"}={}){var u;const d=[s?"analyze":null,i?"verbose":null,a?"settings":null,o?"buffers":null,l?"wal":null].filter(Boolean).join("|"),h=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${c}; for="${h}"; options=${d};`),c==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}}return Mn.default=n,Mn}var hl;function Si(){if(hl)return Fn;hl=1;var t=Fn&&Fn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Fn,"__esModule",{value:!0});const e=t(dl());class n extends e.default{eq(s,i){return this.url.searchParams.append(s,`eq.${i}`),this}neq(s,i){return this.url.searchParams.append(s,`neq.${i}`),this}gt(s,i){return this.url.searchParams.append(s,`gt.${i}`),this}gte(s,i){return this.url.searchParams.append(s,`gte.${i}`),this}lt(s,i){return this.url.searchParams.append(s,`lt.${i}`),this}lte(s,i){return this.url.searchParams.append(s,`lte.${i}`),this}like(s,i){return this.url.searchParams.append(s,`like.${i}`),this}likeAllOf(s,i){return this.url.searchParams.append(s,`like(all).{${i.join(",")}}`),this}likeAnyOf(s,i){return this.url.searchParams.append(s,`like(any).{${i.join(",")}}`),this}ilike(s,i){return this.url.searchParams.append(s,`ilike.${i}`),this}ilikeAllOf(s,i){return this.url.searchParams.append(s,`ilike(all).{${i.join(",")}}`),this}ilikeAnyOf(s,i){return this.url.searchParams.append(s,`ilike(any).{${i.join(",")}}`),this}is(s,i){return this.url.searchParams.append(s,`is.${i}`),this}in(s,i){const a=Array.from(new Set(i)).map(o=>typeof o=="string"&&new RegExp("[,()]").test(o)?`"${o}"`:`${o}`).join(",");return this.url.searchParams.append(s,`in.(${a})`),this}contains(s,i){return typeof i=="string"?this.url.searchParams.append(s,`cs.${i}`):Array.isArray(i)?this.url.searchParams.append(s,`cs.{${i.join(",")}}`):this.url.searchParams.append(s,`cs.${JSON.stringify(i)}`),this}containedBy(s,i){return typeof i=="string"?this.url.searchParams.append(s,`cd.${i}`):Array.isArray(i)?this.url.searchParams.append(s,`cd.{${i.join(",")}}`):this.url.searchParams.append(s,`cd.${JSON.stringify(i)}`),this}rangeGt(s,i){return this.url.searchParams.append(s,`sr.${i}`),this}rangeGte(s,i){return this.url.searchParams.append(s,`nxl.${i}`),this}rangeLt(s,i){return this.url.searchParams.append(s,`sl.${i}`),this}rangeLte(s,i){return this.url.searchParams.append(s,`nxr.${i}`),this}rangeAdjacent(s,i){return this.url.searchParams.append(s,`adj.${i}`),this}overlaps(s,i){return typeof i=="string"?this.url.searchParams.append(s,`ov.${i}`):this.url.searchParams.append(s,`ov.{${i.join(",")}}`),this}textSearch(s,i,{config:a,type:o}={}){let l="";o==="plain"?l="pl":o==="phrase"?l="ph":o==="websearch"&&(l="w");const c=a===void 0?"":`(${a})`;return this.url.searchParams.append(s,`${l}fts${c}.${i}`),this}match(s){return Object.entries(s).forEach(([i,a])=>{this.url.searchParams.append(i,`eq.${a}`)}),this}not(s,i,a){return this.url.searchParams.append(s,`not.${i}.${a}`),this}or(s,{foreignTable:i,referencedTable:a=i}={}){const o=a?`${a}.or`:"or";return this.url.searchParams.append(o,`(${s})`),this}filter(s,i,a){return this.url.searchParams.append(s,`${i}.${a}`),this}}return Fn.default=n,Fn}var fl;function pl(){if(fl)return Un;fl=1;var t=Un&&Un.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Un,"__esModule",{value:!0});const e=t(Si());class n{constructor(s,{headers:i={},schema:a,fetch:o}){this.url=s,this.headers=new Headers(i),this.schema=a,this.fetch=o}select(s,i){const{head:a=!1,count:o}=i??{},l=a?"HEAD":"GET";let c=!1;const u=(s??"*").split("").map(d=>/\s/.test(d)&&!c?"":(d==='"'&&(c=!c),d)).join("");return this.url.searchParams.set("select",u),o&&this.headers.append("Prefer",`count=${o}`),new e.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:i,defaultToNull:a=!0}={}){var o;const l="POST";if(i&&this.headers.append("Prefer",`count=${i}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const c=s.reduce((u,d)=>u.concat(Object.keys(d)),[]);if(c.length>0){const u=[...new Set(c)].map(d=>`"${d}"`);this.url.searchParams.set("columns",u.join(","))}}return new e.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}upsert(s,{onConflict:i,ignoreDuplicates:a=!1,count:o,defaultToNull:l=!0}={}){var c;const u="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),i!==void 0&&this.url.searchParams.set("on_conflict",i),o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const d=s.reduce((h,f)=>h.concat(Object.keys(f)),[]);if(d.length>0){const h=[...new Set(d)].map(f=>`"${f}"`);this.url.searchParams.set("columns",h.join(","))}}return new e.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(c=this.fetch)!==null&&c!==void 0?c:fetch})}update(s,{count:i}={}){var a;const o="PATCH";return i&&this.headers.append("Prefer",`count=${i}`),new e.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:s}={}){var i;const a="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new e.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}}return Un.default=n,Un}var gl;function Wh(){if(gl)return Dn;gl=1;var t=Dn&&Dn.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Dn,"__esModule",{value:!0});const e=t(pl()),n=t(Si());class r{constructor(i,{headers:a={},schema:o,fetch:l}={}){this.url=i,this.headers=new Headers(a),this.schemaName=o,this.fetch=l}from(i){const a=new URL(`${this.url}/${i}`);return new e.default(a,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(i){return new r(this.url,{headers:this.headers,schema:i,fetch:this.fetch})}rpc(i,a={},{head:o=!1,get:l=!1,count:c}={}){var u;let d;const h=new URL(`${this.url}/rpc/${i}`);let f;o||l?(d=o?"HEAD":"GET",Object.entries(a).filter(([_,v])=>v!==void 0).map(([_,v])=>[_,Array.isArray(v)?`{${v.join(",")}}`:`${v}`]).forEach(([_,v])=>{h.searchParams.append(_,v)})):(d="POST",f=a);const m=new Headers(this.headers);return c&&m.set("Prefer",`count=${c}`),new n.default({method:d,url:h,headers:m,schema:this.schemaName,body:f,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}}return Dn.default=r,Dn}var ml;function Gh(){if(ml)return be;ml=1;var t=be&&be.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(be,"__esModule",{value:!0}),be.PostgrestError=be.PostgrestBuilder=be.PostgrestTransformBuilder=be.PostgrestFilterBuilder=be.PostgrestQueryBuilder=be.PostgrestClient=void 0;const e=t(Wh());be.PostgrestClient=e.default;const n=t(pl());be.PostgrestQueryBuilder=n.default;const r=t(Si());be.PostgrestFilterBuilder=r.default;const s=t(dl());be.PostgrestTransformBuilder=s.default;const i=t(cl());be.PostgrestBuilder=i.default;const a=t(ol());return be.PostgrestError=a.default,be.default={PostgrestClient:e.default,PostgrestQueryBuilder:n.default,PostgrestFilterBuilder:r.default,PostgrestTransformBuilder:s.default,PostgrestBuilder:i.default,PostgrestError:a.default},be}var Kh=Gh();const Vh=Uh(Kh),{PostgrestClient:Jh,PostgrestQueryBuilder:Bw,PostgrestFilterBuilder:qw,PostgrestTransformBuilder:Hw,PostgrestBuilder:zw,PostgrestError:Ww}=Vh;class Yh{static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const n=process.versions;if(n&&n.node){const r=n.node,s=parseInt(r.replace(/^v/,"").split(".")[0]);return s>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${s} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${s} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
4
4
  import ws from "ws"
5
5
  new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let n=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(n+=`
6
6
 
7
- Suggested solution: ${e.workaround}`),new Error(n)}static createWebSocket(e,n){const r=this.getWebSocketConstructor();return new r(e,n)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const Yh="realtime-js/2.75.0",Xh="1.0.0",Si=1e4,Zh=1e3,Qh=100;var gr;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(gr||(gr={}));var me;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(me||(me={}));var rt;(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"})(rt||(rt={}));var Ti;(function(t){t.websocket="websocket"})(Ti||(Ti={}));var on;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(on||(on={}));class ef{constructor(){this.HEADER_LENGTH=1}decode(e,n){return e.constructor===ArrayBuffer?n(this._binaryDecode(e)):n(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const n=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,n,r)}_decodeBroadcast(e,n,r){const s=n.getUint8(1),i=n.getUint8(2);let a=this.HEADER_LENGTH+2;const o=r.decode(e.slice(a,a+s));a=a+s;const l=r.decode(e.slice(a,a+i));a=a+i;const c=JSON.parse(r.decode(e.slice(a,e.byteLength)));return{ref:null,topic:o,event:l,payload:c}}}class ml{constructor(e,n){this.callback=e,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var ee;(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"})(ee||(ee={}));const _l=(t,e,n={})=>{var r;const s=(r=n.skipTypes)!==null&&r!==void 0?r:[];return e?Object.keys(e).reduce((i,a)=>(i[a]=tf(a,t,e,s),i),{}):{}},tf=(t,e,n,r)=>{const s=e.find(o=>o.name===t),i=s?.type,a=n[t];return i&&!r.includes(i)?vl(i,a):xi(a)},vl=(t,e)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return af(e,n)}switch(t){case ee.bool:return nf(e);case ee.float4:case ee.float8:case ee.int2:case ee.int4:case ee.int8:case ee.numeric:case ee.oid:return rf(e);case ee.json:case ee.jsonb:return sf(e);case ee.timestamp:return of(e);case ee.abstime:case ee.date:case ee.daterange:case ee.int4range:case ee.int8range:case ee.money:case ee.reltime:case ee.text:case ee.time:case ee.timestamptz:case ee.timetz:case ee.tsrange:case ee.tstzrange:return xi(e);default:return xi(e)}},xi=t=>t,nf=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},rf=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},sf=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},af=(t,e)=>{if(typeof t!="string")return t;const n=t.length-1,r=t[n];if(t[0]==="{"&&r==="}"){let i;const a=t.slice(1,n);try{i=JSON.parse("["+a+"]")}catch{i=a?a.split(","):[]}return i.map(o=>vl(e,o))}return t},of=t=>typeof t=="string"?t.replace(" ","T"):t,bl=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"};class Ai{constructor(e,n,r={},s=Si){this.channel=e,this.event=n,this.payload=r,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,n){var r;return this._hasReceived(e)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:n})}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:n}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(n))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var yl;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(yl||(yl={}));class mr{constructor(e,n){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=n?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.joinRef=this.channel._joinRef(),this.state=mr.syncState(this.state,s,i,a),this.pendingDiffs.forEach(l=>{this.state=mr.syncDiff(this.state,l,i,a)}),this.pendingDiffs=[],o()}),this.channel._on(r.diff,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=mr.syncDiff(this.state,s,i,a),o())}),this.onJoin((s,i,a)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:a})}),this.onLeave((s,i,a)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:a})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,n,r,s){const i=this.cloneDeep(e),a=this.transformState(n),o={},l={};return this.map(i,(c,u)=>{a[c]||(l[c]=u)}),this.map(a,(c,u)=>{const d=i[c];if(d){const h=u.map(_=>_.presence_ref),f=d.map(_=>_.presence_ref),g=u.filter(_=>f.indexOf(_.presence_ref)<0),v=d.filter(_=>h.indexOf(_.presence_ref)<0);g.length>0&&(o[c]=g),v.length>0&&(l[c]=v)}else o[c]=u}),this.syncDiff(i,{joins:o,leaves:l},r,s)}static syncDiff(e,n,r,s){const{joins:i,leaves:a}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(o,l)=>{var c;const u=(c=e[o])!==null&&c!==void 0?c:[];if(e[o]=this.cloneDeep(l),u.length>0){const d=e[o].map(f=>f.presence_ref),h=u.filter(f=>d.indexOf(f.presence_ref)<0);e[o].unshift(...h)}r(o,u,l)}),this.map(a,(o,l)=>{let c=e[o];if(!c)return;const u=l.map(d=>d.presence_ref);c=c.filter(d=>u.indexOf(d.presence_ref)<0),e[o]=c,s(o,c,l),c.length===0&&delete e[o]}),e}static map(e,n){return Object.getOwnPropertyNames(e).map(r=>n(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((n,r)=>{const s=e[r];return"metas"in s?n[r]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):n[r]=s,n},{})}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 wl;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(wl||(wl={}));var _r;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(_r||(_r={}));var At;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(At||(At={}));class Oi{constructor(e,n={config:{}},r){var s,i;if(this.topic=e,this.params=n,this.socket=r,this.bindings={},this.state=me.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new Ai(this,rt.join,this.params,this.timeout),this.rejoinTimer=new ml(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=me.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=me.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=me.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=me.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=me.errored,this.rejoinTimer.scheduleTimeout())}),this._on(rt.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new mr(this),this.broadcastEndpointURL=bl(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((i=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||i===void 0)&&i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,n=this.timeout){var r,s,i;if(this.socket.isConnected()||this.socket.connect(),this.state==me.closed){const{config:{broadcast:a,presence:o,private:l}}=this.params,c=(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(f=>f.filter))!==null&&s!==void 0?s:[],u=!!this.bindings[_r.PRESENCE]&&this.bindings[_r.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,d={},h={broadcast:a,presence:Object.assign(Object.assign({},o),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(f=>e?.(At.CHANNEL_ERROR,f)),this._onClose(()=>e?.(At.CLOSED)),this.updateJoinPayload(Object.assign({config:h},d)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:f})=>{var g;if(this.socket.setAuth(),f===void 0){e?.(At.SUBSCRIBED);return}else{const v=this.bindings.postgres_changes,_=(g=v?.length)!==null&&g!==void 0?g:0,S=[];for(let p=0;p<_;p++){const m=v[p],{filter:{event:y,schema:E,table:b,filter:k}}=m,A=f&&f[p];if(A&&A.event===y&&A.schema===E&&A.table===b&&A.filter===k)S.push(Object.assign(Object.assign({},m),{id:A.id}));else{this.unsubscribe(),this.state=me.errored,e?.(At.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=S,e&&e(At.SUBSCRIBED);return}}).receive("error",f=>{this.state=me.errored,e?.(At.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e?.(At.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,n={}){return await this.send({type:"presence",event:"track",payload:e},n.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,n,r){return this.state===me.joined&&e===_r.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,n,r)}async send(e,n={}){var r,s;if(!this._canPush()&&e.type==="broadcast"){const{event:i,payload:a}=e,l={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((s=c.body)===null||s===void 0?void 0:s.cancel()),c.ok?"ok":"error"}catch(c){return c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var a,o,l;const c=this._push(e.type,e,n.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(o=(a=this.params)===null||a===void 0?void 0:a.config)===null||o===void 0?void 0:o.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=me.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(rt.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(s=>{r=new Ai(this,rt.leave,{},e),r.receive("ok",()=>{n(),s("ok")}).receive("timeout",()=>{n(),s("timed out")}).receive("error",()=>{s("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r?.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=me.closed,this.bindings={}}async _fetchWithTimeout(e,n,r){const s=new AbortController,i=setTimeout(()=>s.abort(),r),a=await this.socket.fetch(e,Object.assign(Object.assign({},n),{signal:s.signal}));return clearTimeout(i),a}_push(e,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new Ai(this,e,n,r);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>Qh){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(e,n,r){return n}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,n,r){var s,i;const a=e.toLocaleLowerCase(),{close:o,error:l,leave:c,join:u}=rt;if(r&&[o,l,c,u].indexOf(a)>=0&&r!==this._joinRef())return;let h=this._onMessage(a,n,r);if(n&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(f=>{var g,v,_;return((g=f.filter)===null||g===void 0?void 0:g.event)==="*"||((_=(v=f.filter)===null||v===void 0?void 0:v.event)===null||_===void 0?void 0:_.toLocaleLowerCase())===a}).map(f=>f.callback(h,r)):(i=this.bindings[a])===null||i===void 0||i.filter(f=>{var g,v,_,S,p,m;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in f){const y=f.id,E=(g=f.filter)===null||g===void 0?void 0:g.event;return y&&((v=n.ids)===null||v===void 0?void 0:v.includes(y))&&(E==="*"||E?.toLocaleLowerCase()===((_=n.data)===null||_===void 0?void 0:_.type.toLocaleLowerCase()))}else{const y=(p=(S=f?.filter)===null||S===void 0?void 0:S.event)===null||p===void 0?void 0:p.toLocaleLowerCase();return y==="*"||y===((m=n?.event)===null||m===void 0?void 0:m.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===a}).map(f=>{if(typeof h=="object"&&"ids"in h){const g=h.data,{schema:v,table:_,commit_timestamp:S,type:p,errors:m}=g;h=Object.assign(Object.assign({},{schema:v,table:_,commit_timestamp:S,eventType:p,new:{},old:{},errors:m}),this._getPayloadRecords(g))}f.callback(h,r)})}_isClosed(){return this.state===me.closed}_isJoined(){return this.state===me.joined}_isJoining(){return this.state===me.joining}_isLeaving(){return this.state===me.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,n,r){const s=e.toLocaleLowerCase(),i={type:s,filter:n,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,n){const r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&Oi.isEqual(s.filter,n))})),this}static isEqual(e,n){if(Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(rt.close,{},e)}_onError(e){this._on(rt.error,{},n=>e(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=me.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const n={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(n.new=_l(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(n.old=_l(e.columns,e.old_record)),n}}const Ri=()=>{},cs={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},lf=[1e3,2e3,5e3,1e4],cf=1e4,uf=`
7
+ Suggested solution: ${e.workaround}`),new Error(n)}static createWebSocket(e,n){const r=this.getWebSocketConstructor();return new r(e,n)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const Xh="realtime-js/2.75.0",Zh="1.0.0",Ti=1e4,Qh=1e3,ef=100;var mr;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(mr||(mr={}));var ve;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(ve||(ve={}));var nt;(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"})(nt||(nt={}));var xi;(function(t){t.websocket="websocket"})(xi||(xi={}));var ln;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(ln||(ln={}));class tf{constructor(){this.HEADER_LENGTH=1}decode(e,n){return e.constructor===ArrayBuffer?n(this._binaryDecode(e)):n(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const n=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,n,r)}_decodeBroadcast(e,n,r){const s=n.getUint8(1),i=n.getUint8(2);let a=this.HEADER_LENGTH+2;const o=r.decode(e.slice(a,a+s));a=a+s;const l=r.decode(e.slice(a,a+i));a=a+i;const c=JSON.parse(r.decode(e.slice(a,e.byteLength)));return{ref:null,topic:o,event:l,payload:c}}}class _l{constructor(e,n){this.callback=e,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var ee;(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"})(ee||(ee={}));const vl=(t,e,n={})=>{var r;const s=(r=n.skipTypes)!==null&&r!==void 0?r:[];return e?Object.keys(e).reduce((i,a)=>(i[a]=nf(a,t,e,s),i),{}):{}},nf=(t,e,n,r)=>{const s=e.find(o=>o.name===t),i=s?.type,a=n[t];return i&&!r.includes(i)?bl(i,a):Ai(a)},bl=(t,e)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return of(e,n)}switch(t){case ee.bool:return rf(e);case ee.float4:case ee.float8:case ee.int2:case ee.int4:case ee.int8:case ee.numeric:case ee.oid:return sf(e);case ee.json:case ee.jsonb:return af(e);case ee.timestamp:return lf(e);case ee.abstime:case ee.date:case ee.daterange:case ee.int4range:case ee.int8range:case ee.money:case ee.reltime:case ee.text:case ee.time:case ee.timestamptz:case ee.timetz:case ee.tsrange:case ee.tstzrange:return Ai(e);default:return Ai(e)}},Ai=t=>t,rf=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},sf=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},af=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},of=(t,e)=>{if(typeof t!="string")return t;const n=t.length-1,r=t[n];if(t[0]==="{"&&r==="}"){let i;const a=t.slice(1,n);try{i=JSON.parse("["+a+"]")}catch{i=a?a.split(","):[]}return i.map(o=>bl(e,o))}return t},lf=t=>typeof t=="string"?t.replace(" ","T"):t,yl=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"};class Ri{constructor(e,n,r={},s=Ti){this.channel=e,this.event=n,this.payload=r,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,n){var r;return this._hasReceived(e)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:n})}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:n}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(n))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var wl;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(wl||(wl={}));class _r{constructor(e,n){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=n?.events||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.joinRef=this.channel._joinRef(),this.state=_r.syncState(this.state,s,i,a),this.pendingDiffs.forEach(l=>{this.state=_r.syncDiff(this.state,l,i,a)}),this.pendingDiffs=[],o()}),this.channel._on(r.diff,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=_r.syncDiff(this.state,s,i,a),o())}),this.onJoin((s,i,a)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:a})}),this.onLeave((s,i,a)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:a})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,n,r,s){const i=this.cloneDeep(e),a=this.transformState(n),o={},l={};return this.map(i,(c,u)=>{a[c]||(l[c]=u)}),this.map(a,(c,u)=>{const d=i[c];if(d){const h=u.map(v=>v.presence_ref),f=d.map(v=>v.presence_ref),m=u.filter(v=>f.indexOf(v.presence_ref)<0),_=d.filter(v=>h.indexOf(v.presence_ref)<0);m.length>0&&(o[c]=m),_.length>0&&(l[c]=_)}else o[c]=u}),this.syncDiff(i,{joins:o,leaves:l},r,s)}static syncDiff(e,n,r,s){const{joins:i,leaves:a}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(o,l)=>{var c;const u=(c=e[o])!==null&&c!==void 0?c:[];if(e[o]=this.cloneDeep(l),u.length>0){const d=e[o].map(f=>f.presence_ref),h=u.filter(f=>d.indexOf(f.presence_ref)<0);e[o].unshift(...h)}r(o,u,l)}),this.map(a,(o,l)=>{let c=e[o];if(!c)return;const u=l.map(d=>d.presence_ref);c=c.filter(d=>u.indexOf(d.presence_ref)<0),e[o]=c,s(o,c,l),c.length===0&&delete e[o]}),e}static map(e,n){return Object.getOwnPropertyNames(e).map(r=>n(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((n,r)=>{const s=e[r];return"metas"in s?n[r]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):n[r]=s,n},{})}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 El;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(El||(El={}));var vr;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(vr||(vr={}));var xt;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(xt||(xt={}));class Oi{constructor(e,n={config:{}},r){var s,i;if(this.topic=e,this.params=n,this.socket=r,this.bindings={},this.state=ve.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new Ri(this,nt.join,this.params,this.timeout),this.rejoinTimer=new _l(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=ve.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=ve.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=ve.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=ve.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=ve.errored,this.rejoinTimer.scheduleTimeout())}),this._on(nt.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new _r(this),this.broadcastEndpointURL=yl(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((i=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||i===void 0)&&i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,n=this.timeout){var r,s,i;if(this.socket.isConnected()||this.socket.connect(),this.state==ve.closed){const{config:{broadcast:a,presence:o,private:l}}=this.params,c=(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(f=>f.filter))!==null&&s!==void 0?s:[],u=!!this.bindings[vr.PRESENCE]&&this.bindings[vr.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,d={},h={broadcast:a,presence:Object.assign(Object.assign({},o),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(f=>e?.(xt.CHANNEL_ERROR,f)),this._onClose(()=>e?.(xt.CLOSED)),this.updateJoinPayload(Object.assign({config:h},d)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:f})=>{var m;if(this.socket.setAuth(),f===void 0){e?.(xt.SUBSCRIBED);return}else{const _=this.bindings.postgres_changes,v=(m=_?.length)!==null&&m!==void 0?m:0,S=[];for(let g=0;g<v;g++){const p=_[g],{filter:{event:y,schema:E,table:b,filter:k}}=p,A=f&&f[g];if(A&&A.event===y&&A.schema===E&&A.table===b&&A.filter===k)S.push(Object.assign(Object.assign({},p),{id:A.id}));else{this.unsubscribe(),this.state=ve.errored,e?.(xt.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=S,e&&e(xt.SUBSCRIBED);return}}).receive("error",f=>{this.state=ve.errored,e?.(xt.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e?.(xt.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,n={}){return await this.send({type:"presence",event:"track",payload:e},n.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,n,r){return this.state===ve.joined&&e===vr.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,n,r)}async send(e,n={}){var r,s;if(!this._canPush()&&e.type==="broadcast"){const{event:i,payload:a}=e,l={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((s=c.body)===null||s===void 0?void 0:s.cancel()),c.ok?"ok":"error"}catch(c){return c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var a,o,l;const c=this._push(e.type,e,n.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(o=(a=this.params)===null||a===void 0?void 0:a.config)===null||o===void 0?void 0:o.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=ve.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(nt.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(s=>{r=new Ri(this,nt.leave,{},e),r.receive("ok",()=>{n(),s("ok")}).receive("timeout",()=>{n(),s("timed out")}).receive("error",()=>{s("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r?.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=ve.closed,this.bindings={}}async _fetchWithTimeout(e,n,r){const s=new AbortController,i=setTimeout(()=>s.abort(),r),a=await this.socket.fetch(e,Object.assign(Object.assign({},n),{signal:s.signal}));return clearTimeout(i),a}_push(e,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new Ri(this,e,n,r);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>ef){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(e,n,r){return n}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,n,r){var s,i;const a=e.toLocaleLowerCase(),{close:o,error:l,leave:c,join:u}=nt;if(r&&[o,l,c,u].indexOf(a)>=0&&r!==this._joinRef())return;let h=this._onMessage(a,n,r);if(n&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(f=>{var m,_,v;return((m=f.filter)===null||m===void 0?void 0:m.event)==="*"||((v=(_=f.filter)===null||_===void 0?void 0:_.event)===null||v===void 0?void 0:v.toLocaleLowerCase())===a}).map(f=>f.callback(h,r)):(i=this.bindings[a])===null||i===void 0||i.filter(f=>{var m,_,v,S,g,p;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in f){const y=f.id,E=(m=f.filter)===null||m===void 0?void 0:m.event;return y&&((_=n.ids)===null||_===void 0?void 0:_.includes(y))&&(E==="*"||E?.toLocaleLowerCase()===((v=n.data)===null||v===void 0?void 0:v.type.toLocaleLowerCase()))}else{const y=(g=(S=f?.filter)===null||S===void 0?void 0:S.event)===null||g===void 0?void 0:g.toLocaleLowerCase();return y==="*"||y===((p=n?.event)===null||p===void 0?void 0:p.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===a}).map(f=>{if(typeof h=="object"&&"ids"in h){const m=h.data,{schema:_,table:v,commit_timestamp:S,type:g,errors:p}=m;h=Object.assign(Object.assign({},{schema:_,table:v,commit_timestamp:S,eventType:g,new:{},old:{},errors:p}),this._getPayloadRecords(m))}f.callback(h,r)})}_isClosed(){return this.state===ve.closed}_isJoined(){return this.state===ve.joined}_isJoining(){return this.state===ve.joining}_isLeaving(){return this.state===ve.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,n,r){const s=e.toLocaleLowerCase(),i={type:s,filter:n,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,n){const r=e.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&Oi.isEqual(s.filter,n))})),this}static isEqual(e,n){if(Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(nt.close,{},e)}_onError(e){this._on(nt.error,{},n=>e(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=ve.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const n={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(n.new=vl(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(n.old=vl(e.columns,e.old_record)),n}}const Ii=()=>{},us={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},cf=[1e3,2e3,5e3,1e4],uf=1e4,df=`
8
8
  addEventListener("message", (e) => {
9
9
  if (e.data.event === "start") {
10
10
  setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
11
11
  }
12
- });`;class df{constructor(e,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Si,this.transport=null,this.heartbeatIntervalMs=cs.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Ri,this.ref=0,this.reconnectTimer=null,this.logger=Ri,this.conn=null,this.sendBuffer=[],this.serializer=new ef,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=s=>{let i;return s?i=s:typeof fetch>"u"?i=(...a)=>Promise.resolve().then(()=>qn).then(({default:o})=>o(...a)).catch(o=>{throw new Error(`Failed to load @supabase/node-fetch: ${o.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):i=fetch,(...a)=>i(...a)},!(!((r=n?.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${e}/${Ti.websocket}`,this.httpEndpoint=bl(e),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=Jh.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const n=e.message;throw n.includes("Node.js")?new Error(`${n}
12
+ });`;class hf{constructor(e,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Ti,this.transport=null,this.heartbeatIntervalMs=us.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Ii,this.ref=0,this.reconnectTimer=null,this.logger=Ii,this.conn=null,this.sendBuffer=[],this.serializer=new tf,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=s=>{let i;return s?i=s:typeof fetch>"u"?i=(...a)=>Promise.resolve().then(()=>Hn).then(({default:o})=>o(...a)).catch(o=>{throw new Error(`Failed to load @supabase/node-fetch: ${o.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):i=fetch,(...a)=>i(...a)},!(!((r=n?.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${e}/${xi.websocket}`,this.httpEndpoint=yl(e),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=Yh.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const n=e.message;throw n.includes("Node.js")?new Error(`${n}
13
13
 
14
14
  To use Realtime in Node.js, you need to provide a WebSocket implementation:
15
15
 
@@ -22,49 +22,49 @@ Option 2: Install and provide the "ws" package:
22
22
  const client = new RealtimeClient(url, {
23
23
  ...options,
24
24
  transport: ws
25
- })`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Xh}))}disconnect(e,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},e?this.conn.close(e,n??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const n=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const e=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,n,r){this.logger(e,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case gr.connecting:return on.Connecting;case gr.open:return on.Open;case gr.closing:return on.Closing;default:return on.Closed}}isConnected(){return this.connectionState()===on.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,n={config:{}}){const r=`realtime:${e}`,s=this.getChannels().find(i=>i.topic===r);if(s)return s;{const i=new Oi(`realtime:${e}`,n,this);return this.channels.push(i),i}}push(e){const{topic:n,event:r,payload:s,ref:i}=e,a=()=>{this.encode(e,o=>{var l;(l=this.conn)===null||l===void 0||l.send(o)})};this.log("push",`${n} ${r} (${i})`,s),this.isConnected()?a():this.sendBuffer.push(a)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(Zh,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},cs.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let n=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${e}"`),n.unsubscribe())}_remove(e){this.channels=this.channels.filter(n=>n.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,n=>{if(n.topic==="phoenix"&&n.event==="phx_reply")try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error")}catch(c){this.log("error","error in heartbeat callback",c)}n.ref&&n.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:r,event:s,payload:i,ref:a}=n,o=a?`(${a})`:"",l=i.status||"";this.log("receive",`${l} ${r} ${s} ${o}`.trim(),i),this.channels.filter(c=>c._isMember(r)).forEach(c=>c._trigger(s,i,a)),this._triggerStateCallbacks("message",n)})}_clearTimer(e){var n;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in 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))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this.workerRef.terminate()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var n;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(rt.error))}_appendParams(e,n){if(Object.keys(n).length===0)return e;const r=e.match(/\?/)?"&":"?",s=new URLSearchParams(n);return`${e}${r}${s}`}_workerObjectUrl(e){let n;if(e)n=e;else{const r=new Blob([uf],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(e,n=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(e=null){let n;e?n=e:this.accessToken?n=await this.accessToken():n=this.accessTokenValue,this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(r=>{const s={access_token:n,version:Yh};n&&r.updateJoinPayload(s),r.joinedOnce&&r._isJoined()&&r._push(rt.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(n=>{this.log("error",`error setting auth in ${e}`,n)})}_triggerStateCallbacks(e,n){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(n)}catch(s){this.log("error",`error in ${e} callback`,s)}})}catch(r){this.log("error",`error triggering ${e} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new ml(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},cs.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var n,r,s,i,a,o,l,c,u;if(this.transport=(n=e?.transport)!==null&&n!==void 0?n:null,this.timeout=(r=e?.timeout)!==null&&r!==void 0?r:Si,this.heartbeatIntervalMs=(s=e?.heartbeatIntervalMs)!==null&&s!==void 0?s:cs.HEARTBEAT_INTERVAL,this.worker=(i=e?.worker)!==null&&i!==void 0?i:!1,this.accessToken=(a=e?.accessToken)!==null&&a!==void 0?a:null,this.heartbeatCallback=(o=e?.heartbeatCallback)!==null&&o!==void 0?o:Ri,e?.params&&(this.params=e.params),e?.logger&&(this.logger=e.logger),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(l=e?.reconnectAfterMs)!==null&&l!==void 0?l:(d=>lf[d-1]||cf),this.encode=(c=e?.encode)!==null&&c!==void 0?c:((d,h)=>h(JSON.stringify(d))),this.decode=(u=e?.decode)!==null&&u!==void 0?u:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl}}}class Ii extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function he(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class hf extends Ii{constructor(e,n,r){super(e),this.name="StorageApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class $i extends Ii{constructor(e,n){super(e),this.name="StorageUnknownError",this.originalError=n}}var ff=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const El=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Promise.resolve().then(()=>qn).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},pf=()=>ff(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Promise.resolve().then(()=>qn)).Response:Response}),Ci=t=>{if(Array.isArray(t))return t.map(n=>Ci(n));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([n,r])=>{const s=n.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[s]=Ci(r)}),e},gf=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};var ln=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const Pi=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),mf=(t,e,n)=>ln(void 0,void 0,void 0,function*(){const r=yield pf();t instanceof r&&!n?.noResolveJson?t.json().then(s=>{const i=t.status||500,a=s?.statusCode||i+"";e(new hf(Pi(s),i,a))}).catch(s=>{e(new $i(Pi(s),s))}):e(new $i(Pi(t),t))}),_f=(t,e,n,r)=>{const s={method:t,headers:e?.headers||{}};return t==="GET"||!r?s:(gf(r)?(s.headers=Object.assign({"Content-Type":"application/json"},e?.headers),s.body=JSON.stringify(r)):s.body=r,e?.duplex&&(s.duplex=e.duplex),Object.assign(Object.assign({},s),n))};function vr(t,e,n,r,s,i){return ln(this,void 0,void 0,function*(){return new Promise((a,o)=>{t(n,_f(e,r,s,i)).then(l=>{if(!l.ok)throw l;return r?.noResolveJson?l:l.json()}).then(l=>a(l)).catch(l=>mf(l,o,r))})})}function us(t,e,n,r){return ln(this,void 0,void 0,function*(){return vr(t,"GET",e,n,r)})}function ft(t,e,n,r,s){return ln(this,void 0,void 0,function*(){return vr(t,"POST",e,r,s,n)})}function Ni(t,e,n,r,s){return ln(this,void 0,void 0,function*(){return vr(t,"PUT",e,r,s,n)})}function vf(t,e,n,r){return ln(this,void 0,void 0,function*(){return vr(t,"HEAD",e,Object.assign(Object.assign({},n),{noResolveJson:!0}),r)})}function kl(t,e,n,r,s){return ln(this,void 0,void 0,function*(){return vr(t,"DELETE",e,r,s,n)})}var bf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class yf{constructor(e,n){this.downloadFn=e,this.shouldThrowOnError=n}then(e,n){return this.execute().then(e,n)}execute(){return bf(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(he(e))return{data:null,error:e};throw e}})}}var wf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class Ef{constructor(e,n){this.downloadFn=e,this.shouldThrowOnError=n}asStream(){return new yf(this.downloadFn,this.shouldThrowOnError)}then(e,n){return this.execute().then(e,n)}execute(){return wf(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(he(e))return{data:null,error:e};throw e}})}}var Ne=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const kf={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Sl={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Sf{constructor(e,n={},r,s){this.shouldThrowOnError=!1,this.url=e,this.headers=n,this.bucketId=r,this.fetch=El(s)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(e,n,r,s){return Ne(this,void 0,void 0,function*(){try{let i;const a=Object.assign(Object.assign({},Sl),s);let o=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(a.upsert)});const l=a.metadata;typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",this.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",this.encodeMetadata(l))):(i=r,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=this.toBase64(this.encodeMetadata(l)))),s?.headers&&(o=Object.assign(Object.assign({},o),s.headers));const c=this._removeEmptyFolders(n),u=this._getFinalPath(c),d=yield(e=="PUT"?Ni:ft)(this.fetch,`${this.url}/object/${u}`,i,Object.assign({headers:o},a?.duplex?{duplex:a.duplex}:{}));return{data:{path:c,id:d.Id,fullPath:d.Key},error:null}}catch(i){if(this.shouldThrowOnError)throw i;if(he(i))return{data:null,error:i};throw i}})}upload(e,n,r){return Ne(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,n,r)})}uploadToSignedUrl(e,n,r,s){return Ne(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);o.searchParams.set("token",n);try{let l;const c=Object.assign({upsert:Sl.upsert},s),u=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",c.cacheControl)):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType);const d=yield Ni(this.fetch,o.toString(),l,{headers:u});return{data:{path:i,fullPath:d.Key},error:null}}catch(l){if(this.shouldThrowOnError)throw l;if(he(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e,n){return Ne(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e);const s=Object.assign({},this.headers);n?.upsert&&(s["x-upsert"]="true");const i=yield ft(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:s}),a=new URL(this.url+i.url),o=a.searchParams.get("token");if(!o)throw new Ii("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:o},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}update(e,n,r){return Ne(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,n,r)})}move(e,n,r){return Ne(this,void 0,void 0,function*(){try{return{data:yield ft(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n,destinationBucket:r?.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}copy(e,n,r){return Ne(this,void 0,void 0,function*(){try{return{data:{path:(yield ft(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n,destinationBucket:r?.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}createSignedUrl(e,n,r){return Ne(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield ft(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:n},r?.transform?{transform:r.transform}:{}),{headers:this.headers});const a=r?.download?`&download=${r.download===!0?"":r.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${a}`)},{data:i,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}createSignedUrls(e,n,r){return Ne(this,void 0,void 0,function*(){try{const s=yield ft(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:n,paths:e},{headers:this.headers}),i=r?.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(a=>Object.assign(Object.assign({},a),{signedUrl:a.signedURL?encodeURI(`${this.url}${a.signedURL}${i}`):null})),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}download(e,n){const s=typeof n?.transform<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString(n?.transform||{}),a=i?`?${i}`:"",o=this._getFinalPath(e),l=()=>us(this.fetch,`${this.url}/${s}/${o}${a}`,{headers:this.headers,noResolveJson:!0});return new Ef(l,this.shouldThrowOnError)}info(e){return Ne(this,void 0,void 0,function*(){const n=this._getFinalPath(e);try{const r=yield us(this.fetch,`${this.url}/object/info/${n}`,{headers:this.headers});return{data:Ci(r),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}exists(e){return Ne(this,void 0,void 0,function*(){const n=this._getFinalPath(e);try{return yield vf(this.fetch,`${this.url}/object/${n}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r)&&r instanceof $i){const s=r.originalError;if([400,404].includes(s?.status))return{data:!1,error:r}}throw r}})}getPublicUrl(e,n){const r=this._getFinalPath(e),s=[],i=n?.download?`download=${n.download===!0?"":n.download}`:"";i!==""&&s.push(i);const o=typeof n?.transform<"u"?"render/image":"object",l=this.transformOptsToQueryString(n?.transform||{});l!==""&&s.push(l);let c=s.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${r}${c}`)}}}remove(e){return Ne(this,void 0,void 0,function*(){try{return{data:yield kl(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}list(e,n,r){return Ne(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},kf),n),{prefix:e||""});return{data:yield ft(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}listV2(e,n){return Ne(this,void 0,void 0,function*(){try{const r=Object.assign({},e);return{data:yield ft(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},n),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const n=[];return e.width&&n.push(`width=${e.width}`),e.height&&n.push(`height=${e.height}`),e.resize&&n.push(`resize=${e.resize}`),e.format&&n.push(`format=${e.format}`),e.quality&&n.push(`quality=${e.quality}`),n.join("&")}}const Tf={"X-Client-Info":"storage-js/2.75.0"};var Hn=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class xf{constructor(e,n={},r,s){this.shouldThrowOnError=!1;const i=new URL(e);s?.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Tf),n),this.fetch=El(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(){return Hn(this,void 0,void 0,function*(){try{return{data:yield us(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(he(e))return{data:null,error:e};throw e}})}getBucket(e){return Hn(this,void 0,void 0,function*(){try{return{data:yield us(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}createBucket(e){return Hn(this,arguments,void 0,function*(n,r={public:!1}){try{return{data:yield ft(this.fetch,`${this.url}/bucket`,{id:n,name:n,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}updateBucket(e,n){return Hn(this,void 0,void 0,function*(){try{return{data:yield Ni(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}emptyBucket(e){return Hn(this,void 0,void 0,function*(){try{return{data:yield ft(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}deleteBucket(e){return Hn(this,void 0,void 0,function*(){try{return{data:yield kl(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}}class Af extends xf{constructor(e,n={},r,s){super(e,n,r,s)}from(e){return new Sf(this.url,this.headers,e,this.fetch)}}const Of="2.75.0";let br="";typeof Deno<"u"?br="deno":typeof document<"u"?br="web":typeof navigator<"u"&&navigator.product==="ReactNative"?br="react-native":br="node";const Rf={headers:{"X-Client-Info":`supabase-js-${br}/${Of}`}},If={schema:"public"},$f={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Cf={};var Pf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const Nf=t=>{let e;return t?e=t:typeof fetch>"u"?e=rl:e=fetch,(...n)=>e(...n)},Lf=()=>typeof Headers>"u"?sl:Headers,jf=(t,e,n)=>{const r=Nf(n),s=Lf();return(i,a)=>Pf(void 0,void 0,void 0,function*(){var o;const l=(o=yield e())!==null&&o!==void 0?o:t;let c=new s(a?.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),r(i,Object.assign(Object.assign({},a),{headers:c}))})};var Df=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};function Uf(t){return t.endsWith("/")?t:t+"/"}function Ff(t,e){var n,r;const{db:s,auth:i,realtime:a,global:o}=t,{db:l,auth:c,realtime:u,global:d}=e,h={db:Object.assign(Object.assign({},l),s),auth:Object.assign(Object.assign({},c),i),realtime:Object.assign(Object.assign({},u),a),storage:{},global:Object.assign(Object.assign(Object.assign({},d),o),{headers:Object.assign(Object.assign({},(n=d?.headers)!==null&&n!==void 0?n:{}),(r=o?.headers)!==null&&r!==void 0?r:{})}),accessToken:()=>Df(this,void 0,void 0,function*(){return""})};return t.accessToken?h.accessToken=t.accessToken:delete h.accessToken,h}function Mf(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Uf(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const Tl="2.75.0",zn=30*1e3,Li=3,ji=Li*zn,Bf="http://localhost:9999",qf="supabase.auth.token",Hf={"X-Client-Info":`gotrue-js/${Tl}`},Di="X-Supabase-Api-Version",xl={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},zf=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Wf=600*1e3;class yr extends Error{constructor(e,n,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function $(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Gf extends yr{constructor(e,n,r){super(e,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function Kf(t){return $(t)&&t.name==="AuthApiError"}class cn extends yr{constructor(e,n){super(e),this.name="AuthUnknownError",this.originalError=n}}class Ft extends yr{constructor(e,n,r,s){super(e,r,s),this.name=n,this.status=r}}class Mt extends Ft{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Vf(t){return $(t)&&t.name==="AuthSessionMissingError"}class Wn extends Ft{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class ds extends Ft{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class hs extends Ft{constructor(e,n=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function Jf(t){return $(t)&&t.name==="AuthImplicitGrantRedirectError"}class Al extends Ft{constructor(e,n=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Ui extends Ft{constructor(e,n){super(e,"AuthRetryableFetchError",n,void 0)}}function Fi(t){return $(t)&&t.name==="AuthRetryableFetchError"}class Ol extends Ft{constructor(e,n,r){super(e,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class Mi extends Ft{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const fs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Rl=`
26
- \r=`.split(""),Yf=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<Rl.length;e+=1)t[Rl[e].charCodeAt(0)]=-2;for(let e=0;e<fs.length;e+=1)t[fs[e].charCodeAt(0)]=e;return t})();function Il(t,e,n){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(fs[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(fs[r]),e.queuedBits-=6}}function $l(t,e,n){const r=Yf[t];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)n(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Cl(t){const e=[],n=a=>{e.push(String.fromCodePoint(a))},r={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=a=>{Qf(a,r,n)};for(let a=0;a<t.length;a+=1)$l(t.charCodeAt(a),s,i);return e.join("")}function Xf(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function Zf(t,e){for(let n=0;n<t.length;n+=1){let r=t.charCodeAt(n);if(r>55295&&r<=56319){const s=(r-55296)*1024&65535;r=(t.charCodeAt(n+1)-56320&65535|s)+65536,n+=1}Xf(r,e)}}function Qf(t,e,n){if(e.utf8seq===0){if(t<=127){n(t);return}for(let r=1;r<6;r+=1)if((t>>7-r&1)===0){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&n(e.codepoint)}}function Gn(t){const e=[],n={queue:0,queuedBits:0},r=s=>{e.push(s)};for(let s=0;s<t.length;s+=1)$l(t.charCodeAt(s),n,r);return new Uint8Array(e)}function ep(t){const e=[];return Zf(t,n=>e.push(n)),new Uint8Array(e)}function un(t){const e=[],n={queue:0,queuedBits:0},r=s=>{e.push(s)};return t.forEach(s=>Il(s,n,r)),Il(null,n,r),e.join("")}function tp(t){return Math.round(Date.now()/1e3)+t}function np(){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 He=()=>typeof window<"u"&&typeof document<"u",dn={tested:!1,writable:!1},Pl=()=>{if(!He())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(dn.tested)return dn.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),dn.tested=!0,dn.writable=!0}catch{dn.tested=!0,dn.writable=!1}return dn.writable};function rp(t){const e={},n=new URL(t);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return n.searchParams.forEach((r,s)=>{e[s]=r}),e}const Nl=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Promise.resolve().then(()=>qn).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},sp=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Kn=async(t,e,n)=>{await t.setItem(e,JSON.stringify(n))},hn=async(t,e)=>{const n=await t.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Bt=async(t,e)=>{await t.removeItem(e)};class ps{constructor(){this.promise=new ps.promiseConstructor((e,n)=>{this.resolve=e,this.reject=n})}}ps.promiseConstructor=Promise;function Bi(t){const e=t.split(".");if(e.length!==3)throw new Mi("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!zf.test(e[r]))throw new Mi("JWT not in base64url format");return{header:JSON.parse(Cl(e[0])),payload:JSON.parse(Cl(e[1])),signature:Gn(e[2]),raw:{header:e[0],payload:e[1]}}}async function ip(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function ap(t,e){return new Promise((r,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const a=await t(i);if(!e(i,null,a)){r(a);return}}catch(a){if(!e(i,a)){s(a);return}}})()})}function op(t){return("0"+t.toString(16)).substr(-2)}function lp(){const e=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let s="";for(let i=0;i<56;i++)s+=n.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(e),Array.from(e,op).join("")}async function cp(t){const n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=new Uint8Array(r);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function up(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 n=await cp(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Vn(t,e,n=!1){const r=lp();let s=r;n&&(s+="/PASSWORD_RECOVERY"),await Kn(t,`${e}-code-verifier`,s);const i=await up(r);return[i,r===i?"plain":"s256"]}const dp=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function hp(t){const e=t.headers.get(Di);if(!e||!e.match(dp))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function fp(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function pp(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const gp=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Jn(t){if(!gp.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function qi(){const t={};return new Proxy(t,{get:(e,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Ll(t){return JSON.parse(JSON.stringify(t))}var mp=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};const fn=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),_p=[502,503,504];async function jl(t){var e;if(!sp(t))throw new Ui(fn(t),0);if(_p.includes(t.status))throw new Ui(fn(t),t.status);let n;try{n=await t.json()}catch(i){throw new cn(fn(i),i)}let r;const s=hp(t);if(s&&s.getTime()>=xl["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new Ol(fn(n),t.status,((e=n.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new Mt}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((i,a)=>i&&typeof a=="string",!0))throw new Ol(fn(n),t.status,n.weak_password.reasons);throw new Gf(fn(n),t.status||500,r)}const vp=(t,e,n,r)=>{const s={method:t,headers:e?.headers||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),n))};async function L(t,e,n,r){var s;const i=Object.assign({},r?.headers);i[Di]||(i[Di]=xl["2024-01-01"].name),r?.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const a=(s=r?.query)!==null&&s!==void 0?s:{};r?.redirectTo&&(a.redirect_to=r.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await bp(t,e,n+o,{headers:i,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(l):{data:Object.assign({},l),error:null}}async function bp(t,e,n,r,s,i){const a=vp(e,r,s,i);let o;try{o=await t(n,Object.assign({},a))}catch(l){throw console.error(l),new Ui(fn(l),0)}if(o.ok||await jl(o),r?.noResolveJson)return o;try{return await o.json()}catch(l){await jl(l)}}function st(t){var e;let n=null;Ep(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=tp(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:n,user:r},error:null}}function Dl(t){const e=st(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function qt(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function yp(t){return{data:t,error:null}}function wp(t){const{action_link:e,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i}=t,a=mp(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i},l=Object.assign({},a);return{data:{properties:o,user:l},error:null}}function Ul(t){return t}function Ep(t){return t.access_token&&t.refresh_token&&t.expires_in}const Hi=["global","local","others"];var kp=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};class Sp{constructor({url:e="",headers:n={},fetch:r}){this.url=e,this.headers=n,this.fetch=Nl(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,n=Hi[0]){if(Hi.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Hi.join(", ")}`);try{return await L(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if($(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,n={}){try{return await L(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:qt})}catch(r){if($(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:n}=e,r=kp(e,["options"]),s=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(s.new_email=r?.newEmail,delete s.newEmail),await L(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:wp,redirectTo:n?.redirectTo})}catch(n){if($(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(e){try{return await L(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:qt})}catch(n){if($(n))return{data:{user:null},error:n};throw n}}async listUsers(e){var n,r,s,i,a,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await L(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Ul});if(u.error)throw u.error;const d=await u.json(),h=(a=u.headers.get("x-total-count"))!==null&&a!==void 0?a:0,f=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(g=>{const v=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(g.split(";")[1].split("=")[1]);c[`${_}Page`]=v}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if($(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){Jn(e);try{return await L(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:qt})}catch(n){if($(n))return{data:{user:null},error:n};throw n}}async updateUserById(e,n){Jn(e);try{return await L(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:n,headers:this.headers,xform:qt})}catch(r){if($(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,n=!1){Jn(e);try{return await L(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:n},xform:qt})}catch(r){if($(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){Jn(e.userId);try{const{data:n,error:r}=await L(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:n,error:r}}catch(n){if($(n))return{data:null,error:n};throw n}}async _deleteFactor(e){Jn(e.userId),Jn(e.id);try{return{data:await L(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(n){if($(n))return{data:null,error:n};throw n}}async _listOAuthClients(e){var n,r,s,i,a,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await L(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Ul});if(u.error)throw u.error;const d=await u.json(),h=(a=u.headers.get("x-total-count"))!==null&&a!==void 0?a:0,f=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(g=>{const v=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),_=JSON.parse(g.split(";")[1].split("=")[1]);c[`${_}Page`]=v}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if($(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await L(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if($(n))return{data:null,error:n};throw n}}async _getOAuthClient(e){try{return await L(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if($(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await L(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if($(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(e){try{return await L(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if($(n))return{data:null,error:n};throw n}}}function Fl(t={}){return{getItem:e=>t[e]||null,setItem:(e,n)=>{t[e]=n},removeItem:e=>{delete t[e]}}}const Yn={debug:!!(globalThis&&Pl()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Ml extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Tp extends Ml{}async function xp(t,e,n){Yn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),Yn.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async s=>{if(s){Yn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await n()}finally{Yn.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Yn.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Tp(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Yn.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await n()}}))}function Ap(){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)}}function Bl(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Op(t){return parseInt(t,16)}function Rp(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function Ip(t){var e;const{chainId:n,domain:r,expirationTime:s,issuedAt:i=new Date,nonce:a,notBefore:o,requestId:l,resources:c,scheme:u,uri:d,version:h}=t;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!d)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(h!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${h}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
27
- `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=Bl(t.address),g=u?`${u}://${r}`:r,v=t.statement?`${t.statement}
28
- `:"",_=`${g} wants you to sign in with your Ethereum account:
25
+ })`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Zh}))}disconnect(e,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},e?this.conn.close(e,n??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const n=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const e=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,n,r){this.logger(e,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case mr.connecting:return ln.Connecting;case mr.open:return ln.Open;case mr.closing:return ln.Closing;default:return ln.Closed}}isConnected(){return this.connectionState()===ln.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,n={config:{}}){const r=`realtime:${e}`,s=this.getChannels().find(i=>i.topic===r);if(s)return s;{const i=new Oi(`realtime:${e}`,n,this);return this.channels.push(i),i}}push(e){const{topic:n,event:r,payload:s,ref:i}=e,a=()=>{this.encode(e,o=>{var l;(l=this.conn)===null||l===void 0||l.send(o)})};this.log("push",`${n} ${r} (${i})`,s),this.isConnected()?a():this.sendBuffer.push(a)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(Qh,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},us.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let n=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${e}"`),n.unsubscribe())}_remove(e){this.channels=this.channels.filter(n=>n.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,n=>{if(n.topic==="phoenix"&&n.event==="phx_reply")try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error")}catch(c){this.log("error","error in heartbeat callback",c)}n.ref&&n.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:r,event:s,payload:i,ref:a}=n,o=a?`(${a})`:"",l=i.status||"";this.log("receive",`${l} ${r} ${s} ${o}`.trim(),i),this.channels.filter(c=>c._isMember(r)).forEach(c=>c._trigger(s,i,a)),this._triggerStateCallbacks("message",n)})}_clearTimer(e){var n;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in 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))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this.workerRef.terminate()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var n;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(nt.error))}_appendParams(e,n){if(Object.keys(n).length===0)return e;const r=e.match(/\?/)?"&":"?",s=new URLSearchParams(n);return`${e}${r}${s}`}_workerObjectUrl(e){let n;if(e)n=e;else{const r=new Blob([df],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(e,n=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(e=null){let n;e?n=e:this.accessToken?n=await this.accessToken():n=this.accessTokenValue,this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(r=>{const s={access_token:n,version:Xh};n&&r.updateJoinPayload(s),r.joinedOnce&&r._isJoined()&&r._push(nt.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(n=>{this.log("error",`error setting auth in ${e}`,n)})}_triggerStateCallbacks(e,n){try{this.stateChangeCallbacks[e].forEach(r=>{try{r(n)}catch(s){this.log("error",`error in ${e} callback`,s)}})}catch(r){this.log("error",`error triggering ${e} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new _l(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},us.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var n,r,s,i,a,o,l,c,u;if(this.transport=(n=e?.transport)!==null&&n!==void 0?n:null,this.timeout=(r=e?.timeout)!==null&&r!==void 0?r:Ti,this.heartbeatIntervalMs=(s=e?.heartbeatIntervalMs)!==null&&s!==void 0?s:us.HEARTBEAT_INTERVAL,this.worker=(i=e?.worker)!==null&&i!==void 0?i:!1,this.accessToken=(a=e?.accessToken)!==null&&a!==void 0?a:null,this.heartbeatCallback=(o=e?.heartbeatCallback)!==null&&o!==void 0?o:Ii,e?.params&&(this.params=e.params),e?.logger&&(this.logger=e.logger),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(l=e?.reconnectAfterMs)!==null&&l!==void 0?l:(d=>cf[d-1]||uf),this.encode=(c=e?.encode)!==null&&c!==void 0?c:((d,h)=>h(JSON.stringify(d))),this.decode=(u=e?.decode)!==null&&u!==void 0?u:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl}}}class $i extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function he(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class ff extends $i{constructor(e,n,r){super(e),this.name="StorageApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Ci extends $i{constructor(e,n){super(e),this.name="StorageUnknownError",this.originalError=n}}var pf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const kl=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Promise.resolve().then(()=>Hn).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},gf=()=>pf(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Promise.resolve().then(()=>Hn)).Response:Response}),Pi=t=>{if(Array.isArray(t))return t.map(n=>Pi(n));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([n,r])=>{const s=n.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[s]=Pi(r)}),e},mf=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};var cn=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const Ni=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),_f=(t,e,n)=>cn(void 0,void 0,void 0,function*(){const r=yield gf();t instanceof r&&!n?.noResolveJson?t.json().then(s=>{const i=t.status||500,a=s?.statusCode||i+"";e(new ff(Ni(s),i,a))}).catch(s=>{e(new Ci(Ni(s),s))}):e(new Ci(Ni(t),t))}),vf=(t,e,n,r)=>{const s={method:t,headers:e?.headers||{}};return t==="GET"||!r?s:(mf(r)?(s.headers=Object.assign({"Content-Type":"application/json"},e?.headers),s.body=JSON.stringify(r)):s.body=r,e?.duplex&&(s.duplex=e.duplex),Object.assign(Object.assign({},s),n))};function br(t,e,n,r,s,i){return cn(this,void 0,void 0,function*(){return new Promise((a,o)=>{t(n,vf(e,r,s,i)).then(l=>{if(!l.ok)throw l;return r?.noResolveJson?l:l.json()}).then(l=>a(l)).catch(l=>_f(l,o,r))})})}function ds(t,e,n,r){return cn(this,void 0,void 0,function*(){return br(t,"GET",e,n,r)})}function ht(t,e,n,r,s){return cn(this,void 0,void 0,function*(){return br(t,"POST",e,r,s,n)})}function Li(t,e,n,r,s){return cn(this,void 0,void 0,function*(){return br(t,"PUT",e,r,s,n)})}function bf(t,e,n,r){return cn(this,void 0,void 0,function*(){return br(t,"HEAD",e,Object.assign(Object.assign({},n),{noResolveJson:!0}),r)})}function Sl(t,e,n,r,s){return cn(this,void 0,void 0,function*(){return br(t,"DELETE",e,r,s,n)})}var yf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class wf{constructor(e,n){this.downloadFn=e,this.shouldThrowOnError=n}then(e,n){return this.execute().then(e,n)}execute(){return yf(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(he(e))return{data:null,error:e};throw e}})}}var Ef=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class kf{constructor(e,n){this.downloadFn=e,this.shouldThrowOnError=n}asStream(){return new wf(this.downloadFn,this.shouldThrowOnError)}then(e,n){return this.execute().then(e,n)}execute(){return Ef(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(he(e))return{data:null,error:e};throw e}})}}var Le=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const Sf={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Tl={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Tf{constructor(e,n={},r,s){this.shouldThrowOnError=!1,this.url=e,this.headers=n,this.bucketId=r,this.fetch=kl(s)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(e,n,r,s){return Le(this,void 0,void 0,function*(){try{let i;const a=Object.assign(Object.assign({},Tl),s);let o=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(a.upsert)});const l=a.metadata;typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",this.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.append("cacheControl",a.cacheControl),l&&i.append("metadata",this.encodeMetadata(l))):(i=r,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=this.toBase64(this.encodeMetadata(l)))),s?.headers&&(o=Object.assign(Object.assign({},o),s.headers));const c=this._removeEmptyFolders(n),u=this._getFinalPath(c),d=yield(e=="PUT"?Li:ht)(this.fetch,`${this.url}/object/${u}`,i,Object.assign({headers:o},a?.duplex?{duplex:a.duplex}:{}));return{data:{path:c,id:d.Id,fullPath:d.Key},error:null}}catch(i){if(this.shouldThrowOnError)throw i;if(he(i))return{data:null,error:i};throw i}})}upload(e,n,r){return Le(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,n,r)})}uploadToSignedUrl(e,n,r,s){return Le(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);o.searchParams.set("token",n);try{let l;const c=Object.assign({upsert:Tl.upsert},s),u=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",c.cacheControl)):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType);const d=yield Li(this.fetch,o.toString(),l,{headers:u});return{data:{path:i,fullPath:d.Key},error:null}}catch(l){if(this.shouldThrowOnError)throw l;if(he(l))return{data:null,error:l};throw l}})}createSignedUploadUrl(e,n){return Le(this,void 0,void 0,function*(){try{let r=this._getFinalPath(e);const s=Object.assign({},this.headers);n?.upsert&&(s["x-upsert"]="true");const i=yield ht(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:s}),a=new URL(this.url+i.url),o=a.searchParams.get("token");if(!o)throw new $i("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:o},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}update(e,n,r){return Le(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,n,r)})}move(e,n,r){return Le(this,void 0,void 0,function*(){try{return{data:yield ht(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n,destinationBucket:r?.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}copy(e,n,r){return Le(this,void 0,void 0,function*(){try{return{data:{path:(yield ht(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:n,destinationBucket:r?.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}createSignedUrl(e,n,r){return Le(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield ht(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:n},r?.transform?{transform:r.transform}:{}),{headers:this.headers});const a=r?.download?`&download=${r.download===!0?"":r.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${a}`)},{data:i,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}createSignedUrls(e,n,r){return Le(this,void 0,void 0,function*(){try{const s=yield ht(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:n,paths:e},{headers:this.headers}),i=r?.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(a=>Object.assign(Object.assign({},a),{signedUrl:a.signedURL?encodeURI(`${this.url}${a.signedURL}${i}`):null})),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}download(e,n){const s=typeof n?.transform<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString(n?.transform||{}),a=i?`?${i}`:"",o=this._getFinalPath(e),l=()=>ds(this.fetch,`${this.url}/${s}/${o}${a}`,{headers:this.headers,noResolveJson:!0});return new kf(l,this.shouldThrowOnError)}info(e){return Le(this,void 0,void 0,function*(){const n=this._getFinalPath(e);try{const r=yield ds(this.fetch,`${this.url}/object/info/${n}`,{headers:this.headers});return{data:Pi(r),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}exists(e){return Le(this,void 0,void 0,function*(){const n=this._getFinalPath(e);try{return yield bf(this.fetch,`${this.url}/object/${n}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r)&&r instanceof Ci){const s=r.originalError;if([400,404].includes(s?.status))return{data:!1,error:r}}throw r}})}getPublicUrl(e,n){const r=this._getFinalPath(e),s=[],i=n?.download?`download=${n.download===!0?"":n.download}`:"";i!==""&&s.push(i);const o=typeof n?.transform<"u"?"render/image":"object",l=this.transformOptsToQueryString(n?.transform||{});l!==""&&s.push(l);let c=s.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${r}${c}`)}}}remove(e){return Le(this,void 0,void 0,function*(){try{return{data:yield Sl(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}list(e,n,r){return Le(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},Sf),n),{prefix:e||""});return{data:yield ht(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}listV2(e,n){return Le(this,void 0,void 0,function*(){try{const r=Object.assign({},e);return{data:yield ht(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},n),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const n=[];return e.width&&n.push(`width=${e.width}`),e.height&&n.push(`height=${e.height}`),e.resize&&n.push(`resize=${e.resize}`),e.format&&n.push(`format=${e.format}`),e.quality&&n.push(`quality=${e.quality}`),n.join("&")}}const xf={"X-Client-Info":"storage-js/2.75.0"};var zn=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class Af{constructor(e,n={},r,s){this.shouldThrowOnError=!1;const i=new URL(e);s?.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},xf),n),this.fetch=kl(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(){return zn(this,void 0,void 0,function*(){try{return{data:yield ds(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(he(e))return{data:null,error:e};throw e}})}getBucket(e){return zn(this,void 0,void 0,function*(){try{return{data:yield ds(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}createBucket(e){return zn(this,arguments,void 0,function*(n,r={public:!1}){try{return{data:yield ht(this.fetch,`${this.url}/bucket`,{id:n,name:n,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(he(s))return{data:null,error:s};throw s}})}updateBucket(e,n){return zn(this,void 0,void 0,function*(){try{return{data:yield Li(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(he(r))return{data:null,error:r};throw r}})}emptyBucket(e){return zn(this,void 0,void 0,function*(){try{return{data:yield ht(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}deleteBucket(e){return zn(this,void 0,void 0,function*(){try{return{data:yield Sl(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(he(n))return{data:null,error:n};throw n}})}}class Rf extends Af{constructor(e,n={},r,s){super(e,n,r,s)}from(e){return new Tf(this.url,this.headers,e,this.fetch)}}const Of="2.75.0";let yr="";typeof Deno<"u"?yr="deno":typeof document<"u"?yr="web":typeof navigator<"u"&&navigator.product==="ReactNative"?yr="react-native":yr="node";const If={headers:{"X-Client-Info":`supabase-js-${yr}/${Of}`}},$f={schema:"public"},Cf={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Pf={};var Nf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};const Lf=t=>{let e;return t?e=t:typeof fetch>"u"?e=sl:e=fetch,(...n)=>e(...n)},jf=()=>typeof Headers>"u"?il:Headers,Df=(t,e,n)=>{const r=Lf(n),s=jf();return(i,a)=>Nf(void 0,void 0,void 0,function*(){var o;const l=(o=yield e())!==null&&o!==void 0?o:t;let c=new s(a?.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),r(i,Object.assign(Object.assign({},a),{headers:c}))})};var Uf=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};function Ff(t){return t.endsWith("/")?t:t+"/"}function Mf(t,e){var n,r;const{db:s,auth:i,realtime:a,global:o}=t,{db:l,auth:c,realtime:u,global:d}=e,h={db:Object.assign(Object.assign({},l),s),auth:Object.assign(Object.assign({},c),i),realtime:Object.assign(Object.assign({},u),a),storage:{},global:Object.assign(Object.assign(Object.assign({},d),o),{headers:Object.assign(Object.assign({},(n=d?.headers)!==null&&n!==void 0?n:{}),(r=o?.headers)!==null&&r!==void 0?r:{})}),accessToken:()=>Uf(this,void 0,void 0,function*(){return""})};return t.accessToken?h.accessToken=t.accessToken:delete h.accessToken,h}function Bf(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Ff(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const xl="2.75.0",Wn=30*1e3,ji=3,Di=ji*Wn,qf="http://localhost:9999",Hf="supabase.auth.token",zf={"X-Client-Info":`gotrue-js/${xl}`},Ui="X-Supabase-Api-Version",Al={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Wf=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Gf=600*1e3;class wr extends Error{constructor(e,n,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function I(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Kf extends wr{constructor(e,n,r){super(e,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function Vf(t){return I(t)&&t.name==="AuthApiError"}class un extends wr{constructor(e,n){super(e),this.name="AuthUnknownError",this.originalError=n}}class Ft extends wr{constructor(e,n,r,s){super(e,r,s),this.name=n,this.status=r}}class Mt extends Ft{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Jf(t){return I(t)&&t.name==="AuthSessionMissingError"}class Gn extends Ft{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class hs extends Ft{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class fs extends Ft{constructor(e,n=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function Yf(t){return I(t)&&t.name==="AuthImplicitGrantRedirectError"}class Rl extends Ft{constructor(e,n=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Fi extends Ft{constructor(e,n){super(e,"AuthRetryableFetchError",n,void 0)}}function Mi(t){return I(t)&&t.name==="AuthRetryableFetchError"}class Ol extends Ft{constructor(e,n,r){super(e,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class Bi extends Ft{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const ps="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Il=`
26
+ \r=`.split(""),Xf=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<Il.length;e+=1)t[Il[e].charCodeAt(0)]=-2;for(let e=0;e<ps.length;e+=1)t[ps[e].charCodeAt(0)]=e;return t})();function $l(t,e,n){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(ps[r]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const r=e.queue>>e.queuedBits-6&63;n(ps[r]),e.queuedBits-=6}}function Cl(t,e,n){const r=Xf[t];if(r>-1)for(e.queue=e.queue<<6|r,e.queuedBits+=6;e.queuedBits>=8;)n(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Pl(t){const e=[],n=a=>{e.push(String.fromCodePoint(a))},r={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=a=>{ep(a,r,n)};for(let a=0;a<t.length;a+=1)Cl(t.charCodeAt(a),s,i);return e.join("")}function Zf(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function Qf(t,e){for(let n=0;n<t.length;n+=1){let r=t.charCodeAt(n);if(r>55295&&r<=56319){const s=(r-55296)*1024&65535;r=(t.charCodeAt(n+1)-56320&65535|s)+65536,n+=1}Zf(r,e)}}function ep(t,e,n){if(e.utf8seq===0){if(t<=127){n(t);return}for(let r=1;r<6;r+=1)if((t>>7-r&1)===0){e.utf8seq=r;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&n(e.codepoint)}}function Kn(t){const e=[],n={queue:0,queuedBits:0},r=s=>{e.push(s)};for(let s=0;s<t.length;s+=1)Cl(t.charCodeAt(s),n,r);return new Uint8Array(e)}function tp(t){const e=[];return Qf(t,n=>e.push(n)),new Uint8Array(e)}function dn(t){const e=[],n={queue:0,queuedBits:0},r=s=>{e.push(s)};return t.forEach(s=>$l(s,n,r)),$l(null,n,r),e.join("")}function np(t){return Math.round(Date.now()/1e3)+t}function rp(){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 ze=()=>typeof window<"u"&&typeof document<"u",hn={tested:!1,writable:!1},Nl=()=>{if(!ze())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(hn.tested)return hn.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),hn.tested=!0,hn.writable=!0}catch{hn.tested=!0,hn.writable=!1}return hn.writable};function sp(t){const e={},n=new URL(t);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return n.searchParams.forEach((r,s)=>{e[s]=r}),e}const Ll=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...n)=>Promise.resolve().then(()=>Hn).then(({default:r})=>r(...n)):e=fetch,(...n)=>e(...n)},ip=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Vn=async(t,e,n)=>{await t.setItem(e,JSON.stringify(n))},fn=async(t,e)=>{const n=await t.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Bt=async(t,e)=>{await t.removeItem(e)};class gs{constructor(){this.promise=new gs.promiseConstructor((e,n)=>{this.resolve=e,this.reject=n})}}gs.promiseConstructor=Promise;function qi(t){const e=t.split(".");if(e.length!==3)throw new Bi("Invalid JWT structure");for(let r=0;r<e.length;r++)if(!Wf.test(e[r]))throw new Bi("JWT not in base64url format");return{header:JSON.parse(Pl(e[0])),payload:JSON.parse(Pl(e[1])),signature:Kn(e[2]),raw:{header:e[0],payload:e[1]}}}async function ap(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function op(t,e){return new Promise((r,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const a=await t(i);if(!e(i,null,a)){r(a);return}}catch(a){if(!e(i,a)){s(a);return}}})()})}function lp(t){return("0"+t.toString(16)).substr(-2)}function cp(){const e=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let s="";for(let i=0;i<56;i++)s+=n.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(e),Array.from(e,lp).join("")}async function up(t){const n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=new Uint8Array(r);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function dp(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 n=await up(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Jn(t,e,n=!1){const r=cp();let s=r;n&&(s+="/PASSWORD_RECOVERY"),await Vn(t,`${e}-code-verifier`,s);const i=await dp(r);return[i,r===i?"plain":"s256"]}const hp=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function fp(t){const e=t.headers.get(Ui);if(!e||!e.match(hp))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function pp(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function gp(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const mp=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Yn(t){if(!mp.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Hi(){const t={};return new Proxy(t,{get:(e,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function jl(t){return JSON.parse(JSON.stringify(t))}var _p=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};const pn=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),vp=[502,503,504];async function Dl(t){var e;if(!ip(t))throw new Fi(pn(t),0);if(vp.includes(t.status))throw new Fi(pn(t),t.status);let n;try{n=await t.json()}catch(i){throw new un(pn(i),i)}let r;const s=fp(t);if(s&&s.getTime()>=Al["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new Ol(pn(n),t.status,((e=n.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(r==="session_not_found")throw new Mt}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((i,a)=>i&&typeof a=="string",!0))throw new Ol(pn(n),t.status,n.weak_password.reasons);throw new Kf(pn(n),t.status||500,r)}const bp=(t,e,n,r)=>{const s={method:t,headers:e?.headers||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),n))};async function N(t,e,n,r){var s;const i=Object.assign({},r?.headers);i[Ui]||(i[Ui]=Al["2024-01-01"].name),r?.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const a=(s=r?.query)!==null&&s!==void 0?s:{};r?.redirectTo&&(a.redirect_to=r.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",l=await yp(t,e,n+o,{headers:i,noResolveJson:r?.noResolveJson},{},r?.body);return r?.xform?r?.xform(l):{data:Object.assign({},l),error:null}}async function yp(t,e,n,r,s,i){const a=bp(e,r,s,i);let o;try{o=await t(n,Object.assign({},a))}catch(l){throw console.error(l),new Fi(pn(l),0)}if(o.ok||await Dl(o),r?.noResolveJson)return o;try{return await o.json()}catch(l){await Dl(l)}}function rt(t){var e;let n=null;kp(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=np(t.expires_in)));const r=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:n,user:r},error:null}}function Ul(t){const e=rt(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(e.data.weak_password=t.weak_password),e}function qt(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function wp(t){return{data:t,error:null}}function Ep(t){const{action_link:e,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i}=t,a=_p(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i},l=Object.assign({},a);return{data:{properties:o,user:l},error:null}}function Fl(t){return t}function kp(t){return t.access_token&&t.refresh_token&&t.expires_in}const zi=["global","local","others"];var Sp=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};class Tp{constructor({url:e="",headers:n={},fetch:r}){this.url=e,this.headers=n,this.fetch=Ll(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,n=zi[0]){if(zi.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${zi.join(", ")}`);try{return await N(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(r){if(I(r))return{data:null,error:r};throw r}}async inviteUserByEmail(e,n={}){try{return await N(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:qt})}catch(r){if(I(r))return{data:{user:null},error:r};throw r}}async generateLink(e){try{const{options:n}=e,r=Sp(e,["options"]),s=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(s.new_email=r?.newEmail,delete s.newEmail),await N(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:Ep,redirectTo:n?.redirectTo})}catch(n){if(I(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(e){try{return await N(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:qt})}catch(n){if(I(n))return{data:{user:null},error:n};throw n}}async listUsers(e){var n,r,s,i,a,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await N(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Fl});if(u.error)throw u.error;const d=await u.json(),h=(a=u.headers.get("x-total-count"))!==null&&a!==void 0?a:0,f=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(m=>{const _=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(m.split(";")[1].split("=")[1]);c[`${v}Page`]=_}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(I(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){Yn(e);try{return await N(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:qt})}catch(n){if(I(n))return{data:{user:null},error:n};throw n}}async updateUserById(e,n){Yn(e);try{return await N(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:n,headers:this.headers,xform:qt})}catch(r){if(I(r))return{data:{user:null},error:r};throw r}}async deleteUser(e,n=!1){Yn(e);try{return await N(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:n},xform:qt})}catch(r){if(I(r))return{data:{user:null},error:r};throw r}}async _listFactors(e){Yn(e.userId);try{const{data:n,error:r}=await N(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:n,error:r}}catch(n){if(I(n))return{data:null,error:n};throw n}}async _deleteFactor(e){Yn(e.userId),Yn(e.id);try{return{data:await N(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(n){if(I(n))return{data:null,error:n};throw n}}async _listOAuthClients(e){var n,r,s,i,a,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await N(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=e?.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=e?.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Fl});if(u.error)throw u.error;const d=await u.json(),h=(a=u.headers.get("x-total-count"))!==null&&a!==void 0?a:0,f=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(m=>{const _=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(m.split(";")[1].split("=")[1]);c[`${v}Page`]=_}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(I(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await N(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(I(n))return{data:null,error:n};throw n}}async _getOAuthClient(e){try{return await N(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(I(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await N(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(I(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(e){try{return await N(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(I(n))return{data:null,error:n};throw n}}}function Ml(t={}){return{getItem:e=>t[e]||null,setItem:(e,n)=>{t[e]=n},removeItem:e=>{delete t[e]}}}const Xn={debug:!!(globalThis&&Nl()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Bl extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class xp extends Bl{}async function Ap(t,e,n){Xn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const r=new globalThis.AbortController;return e>0&&setTimeout(()=>{r.abort(),Xn.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async s=>{if(s){Xn.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await n()}finally{Xn.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Xn.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new xp(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Xn.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await n()}}))}function Rp(){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)}}function ql(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Op(t){return parseInt(t,16)}function Ip(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}function $p(t){var e;const{chainId:n,domain:r,expirationTime:s,issuedAt:i=new Date,nonce:a,notBefore:o,requestId:l,resources:c,scheme:u,uri:d,version:h}=t;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${a}`);if(!d)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(h!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${h}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
27
+ `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=ql(t.address),m=u?`${u}://${r}`:r,_=t.statement?`${t.statement}
28
+ `:"",v=`${m} wants you to sign in with your Ethereum account:
29
29
  ${f}
30
30
 
31
- ${v}`;let S=`URI: ${d}
31
+ ${_}`;let S=`URI: ${d}
32
32
  Version: ${h}
33
33
  Chain ID: ${n}${a?`
34
34
  Nonce: ${a}`:""}
35
35
  Issued At: ${i.toISOString()}`;if(s&&(S+=`
36
36
  Expiration Time: ${s.toISOString()}`),o&&(S+=`
37
37
  Not Before: ${o.toISOString()}`),l&&(S+=`
38
- Request ID: ${l}`),c){let p=`
39
- Resources:`;for(const m of c){if(!m||typeof m!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${m}`);p+=`
40
- - ${m}`}S+=p}return`${_}
41
- ${S}`}class fe extends Error{constructor({message:e,code:n,cause:r,name:s}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(i=s??(r instanceof Error?r.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=n}}class gs extends fe{constructor(e,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:e}),this.name="WebAuthnUnknownError",this.originalError=n}}function $p({error:t,options:e}){var n,r,s;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new fe({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new fe({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new fe({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new fe({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new fe({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new fe({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new fe({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new fe({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const a=window.location.hostname;if(Hl(a)){if(i.rp.id!==a)return new fe({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new fe({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new fe({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new fe({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new fe({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Cp({error:t,options:e}){const{publicKey:n}=e;if(!n)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new fe({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new fe({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(Hl(r)){if(n.rpId!==r)return new fe({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new fe({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new fe({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new fe({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}var ql=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};class Pp{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const Np=new Pp;function Lp(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:n,excludeCredentials:r}=t,s=ql(t,["challenge","user","excludeCredentials"]),i=Gn(e).buffer,a=Object.assign(Object.assign({},n),{id:Gn(n.id).buffer}),o=Object.assign(Object.assign({},s),{challenge:i,user:a});if(r&&r.length>0){o.excludeCredentials=new Array(r.length);for(let l=0;l<r.length;l++){const c=r[l];o.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Gn(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}function jp(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:n}=t,r=ql(t,["challenge","allowCredentials"]),s=Gn(e).buffer,i=Object.assign(Object.assign({},r),{challenge:s});if(n&&n.length>0){i.allowCredentials=new Array(n.length);for(let a=0;a<n.length;a++){const o=n[a];i.allowCredentials[a]=Object.assign(Object.assign({},o),{id:Gn(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return i}function Dp(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t;return{id:t.id,rawId:t.id,response:{attestationObject:un(new Uint8Array(t.response.attestationObject)),clientDataJSON:un(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Up(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t,r=t.getClientExtensionResults(),s=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:un(new Uint8Array(s.authenticatorData)),clientDataJSON:un(new Uint8Array(s.clientDataJSON)),signature:un(new Uint8Array(s.signature)),userHandle:s.userHandle?un(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Hl(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function zl(){var t,e;return!!(He()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Fp(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new gs("Browser returned unexpected credential type",e)}:{data:null,error:new gs("Empty credential response",e)}}catch(e){return{data:null,error:$p({error:e,options:t})}}}async function Mp(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new gs("Browser returned unexpected credential type",e)}:{data:null,error:new gs("Empty credential response",e)}}catch(e){return{data:null,error:Cp({error:e,options:t})}}}const Bp={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"none"},qp={userVerification:"preferred",hints:["security-key"]};function ms(...t){const e=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),n=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),r={};for(const s of t)if(s)for(const i in s){const a=s[i];if(a!==void 0)if(Array.isArray(a))r[i]=a;else if(n(a))r[i]=a;else if(e(a)){const o=r[i];e(o)?r[i]=ms(o,a):r[i]=ms(a)}else r[i]=a}return r}function Hp(t,e){return ms(Bp,t,e||{})}function zp(t,e){return ms(qp,t,e||{})}class Wp{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:n,friendlyName:r,signal:s},i){try{const{data:a,error:o}=await this.client.mfa.challenge({factorId:e,webauthn:n});if(!a)return{data:null,error:o};const l=s??Np.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:c}=a.webauthn.credential_options.publicKey;c.name||(c.name=`${c.id}:${r}`),c.displayName||(c.displayName=c.name)}switch(a.webauthn.type){case"create":{const c=Hp(a.webauthn.credential_options.publicKey,i?.create),{data:u,error:d}=await Fp({publicKey:c,signal:l});return u?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:u}},error:null}:{data:null,error:d}}case"request":{const c=zp(a.webauthn.credential_options.publicKey,i?.request),{data:u,error:d}=await Mp(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:c,signal:l}));return u?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:u}},error:null}:{data:null,error:d}}}}catch(a){return $(a)?{data:null,error:a}:{data:null,error:new cn("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:n,webauthn:r}){return this.client.mfa.verify({factorId:n,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}},i){if(!n)return{data:null,error:new yr("rpId is required for WebAuthn authentication")};try{if(!zl())return{data:null,error:new cn("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this.challenge({factorId:e,webauthn:{rpId:n,rpOrigins:r},signal:s},{request:i});if(!a)return{data:null,error:o};const{webauthn:l}=a;return this._verify({factorId:e,challengeId:a.challengeId,webauthn:{type:l.type,rpId:n,rpOrigins:r,credential_response:l.credential_response}})}catch(a){return $(a)?{data:null,error:a}:{data:null,error:new cn("Unexpected error in authenticate",a)}}}async _register({friendlyName:e,rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s},i){if(!n)return{data:null,error:new yr("rpId is required for WebAuthn registration")};try{if(!zl())return{data:null,error:new cn("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this._enroll({friendlyName:e});if(!a)return await this.client.mfa.listFactors().then(u=>{var d;return(d=u.data)===null||d===void 0?void 0:d.all.find(h=>h.factor_type==="webauthn"&&h.friendly_name===e&&h.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u?.id}):void 0),{data:null,error:o};const{data:l,error:c}=await this._challenge({factorId:a.id,friendlyName:a.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:s},{create:i});return l?this._verify({factorId:a.id,challengeId:l.challengeId,webauthn:{rpId:n,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(a){return $(a)?{data:null,error:a}:{data:null,error:new cn("Unexpected error in register",a)}}}}Ap();const Gp={url:Bf,storageKey:qf,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Hf,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function Wl(t,e,n){return await n()}const Xn={};class wr{get jwks(){var e,n;return(n=(e=Xn[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(e){Xn[this.storageKey]=Object.assign(Object.assign({},Xn[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,n;return(n=(e=Xn[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Xn[this.storageKey]=Object.assign(Object.assign({},Xn[this.storageKey]),{cachedAt:e})}constructor(e){var n,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=wr.nextInstanceID,wr.nextInstanceID+=1,this.instanceID>0&&He()&&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 s=Object.assign(Object.assign({},Gp),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new Sp({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=Nl(s.fetch),this.lock=s.lock||Wl,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:He()&&(!((n=globalThis?.navigator)===null||n===void 0)&&n.locks)?this.lock=xp:this.lock=Wl,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),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),webauthn:new Wp(this)},this.persistSession?(s.storage?this.storage=s.storage:Pl()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Fl(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=Fl(this.memoryStorage)),He()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${Tl}) ${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(){var e;try{const n=rp(window.location.href);let r="none";if(this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce"),He()&&this.detectSessionInUrl&&r!=="none"){const{data:s,error:i}=await this._getSessionFromURL(n,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Jf(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:a,redirectType:o}=s;return this._debug("#_initialize()","detected session in URL",a,"redirect type",o),await this._saveSession(a),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return $(n)?{error:n}:{error:new cn("Unexpected error during initialization",n)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var n,r,s;try{const i=await L(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=e?.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(s=e?.options)===null||s===void 0?void 0:s.captchaToken}},xform:st}),{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const l=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(i){if($(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var n,r,s;try{let i;if("email"in e){const{email:u,password:d,options:h}=e;let f=null,g=null;this.flowType==="pkce"&&([f,g]=await Vn(this.storage,this.storageKey)),i=await L(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h?.emailRedirectTo,body:{email:u,password:d,data:(n=h?.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:f,code_challenge_method:g},xform:st})}else if("phone"in e){const{phone:u,password:d,options:h}=e;i=await L(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:d,data:(r=h?.data)!==null&&r!==void 0?r:{},channel:(s=h?.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:st})}else throw new ds("You must provide either an email or phone number and a password");const{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const l=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(i){if($(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let n;if("email"in e){const{email:i,password:a,options:o}=e;n=await L(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Dl})}else if("phone"in e){const{phone:i,password:a,options:o}=e;n=await L(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Dl})}else throw new ds("You must provide either an email or phone number and a password");const{data:r,error:s}=n;return s?{data:{user:null,session:null},error:s}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Wn}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(n){if($(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOAuth(e){var n,r,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(n=e.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:n}=e;switch(n){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(e){var n,r,s,i,a,o,l,c,u,d,h;let f,g;if("message"in e)f=e.message,g=e.signature;else{const{chain:v,wallet:_,statement:S,options:p}=e;let m;if(He())if(typeof _=="object")m=_;else{const T=window;if("ethereum"in T&&typeof T.ethereum=="object"&&"request"in T.ethereum&&typeof T.ethereum.request=="function")m=T.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof _!="object"||!p?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");m=_}const y=new URL((n=p?.url)!==null&&n!==void 0?n:window.location.href),E=await m.request({method:"eth_requestAccounts"}).then(T=>T).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!E||E.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const b=Bl(E[0]);let k=(r=p?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!k){const T=await m.request({method:"eth_chainId"});k=Op(T)}const A={domain:y.host,address:b,statement:S,uri:y.href,version:"1",chainId:k,nonce:(s=p?.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(a=(i=p?.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&a!==void 0?a:new Date,expirationTime:(o=p?.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(l=p?.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=p?.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=p?.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=Ip(A),g=await m.request({method:"personal_sign",params:[Rp(f),b]})}try{const{data:v,error:_}=await L(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:g},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(h=e.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:st});if(_)throw _;return!v||!v.session||!v.user?{data:{user:null,session:null},error:new Wn}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),{data:Object.assign({},v),error:_})}catch(v){if($(v))return{data:{user:null,session:null},error:v};throw v}}async signInWithSolana(e){var n,r,s,i,a,o,l,c,u,d,h,f;let g,v;if("message"in e)g=e.message,v=e.signature;else{const{chain:_,wallet:S,statement:p,options:m}=e;let y;if(He())if(typeof S=="object")y=S;else{const b=window;if("solana"in b&&typeof b.solana=="object"&&("signIn"in b.solana&&typeof b.solana.signIn=="function"||"signMessage"in b.solana&&typeof b.solana.signMessage=="function"))y=b.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof S!="object"||!m?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");y=S}const E=new URL((n=m?.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in y&&y.signIn){const b=await y.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},m?.signInWithSolana),{version:"1",domain:E.host,uri:E.href}),p?{statement:p}:null));let k;if(Array.isArray(b)&&b[0]&&typeof b[0]=="object")k=b[0];else if(b&&typeof b=="object"&&"signedMessage"in b&&"signature"in b)k=b;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in k&&"signature"in k&&(typeof k.signedMessage=="string"||k.signedMessage instanceof Uint8Array)&&k.signature instanceof Uint8Array)g=typeof k.signedMessage=="string"?k.signedMessage:new TextDecoder().decode(k.signedMessage),v=k.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in y)||typeof y.signMessage!="function"||!("publicKey"in y)||typeof y!="object"||!y.publicKey||!("toBase58"in y.publicKey)||typeof y.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");g=[`${E.host} wants you to sign in with your Solana account:`,y.publicKey.toBase58(),...p?["",p,""]:[""],"Version: 1",`URI: ${E.href}`,`Issued At: ${(s=(r=m?.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=m?.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${m.signInWithSolana.notBefore}`]:[],...!((a=m?.signInWithSolana)===null||a===void 0)&&a.expirationTime?[`Expiration Time: ${m.signInWithSolana.expirationTime}`]:[],...!((o=m?.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${m.signInWithSolana.chainId}`]:[],...!((l=m?.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${m.signInWithSolana.nonce}`]:[],...!((c=m?.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${m.signInWithSolana.requestId}`]:[],...!((d=(u=m?.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||d===void 0)&&d.length?["Resources",...m.signInWithSolana.resources.map(k=>`- ${k}`)]:[]].join(`
42
- `);const b=await y.signMessage(new TextEncoder().encode(g),"utf8");if(!b||!(b instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");v=b}}try{const{data:_,error:S}=await L(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:g,signature:un(v)},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:st});if(S)throw S;return!_||!_.session||!_.user?{data:{user:null,session:null},error:new Wn}:(_.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),{data:Object.assign({},_),error:S})}catch(_){if($(_))return{data:{user:null,session:null},error:_};throw _}}async _exchangeCodeForSession(e){const n=await hn(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(n??"").split("/");try{const{data:i,error:a}=await L(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:st});if(await Bt(this.storage,`${this.storageKey}-code-verifier`),a)throw a;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new Wn}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:a})}catch(i){if($(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:n,provider:r,token:s,access_token:i,nonce:a}=e,o=await L(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:n?.captchaToken}},xform:st}),{data:l,error:c}=o;return c?{data:{user:null,session:null},error:c}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Wn}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:c})}catch(n){if($(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOtp(e){var n,r,s,i,a;try{if("email"in e){const{email:o,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await Vn(this.storage,this.storageKey));const{error:d}=await L(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(n=l?.data)!==null&&n!==void 0?n:{},create_user:(r=l?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l?.emailRedirectTo});return{data:{user:null,session:null},error:d}}if("phone"in e){const{phone:o,options:l}=e,{data:c,error:u}=await L(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(s=l?.data)!==null&&s!==void 0?s:{},create_user:(i=l?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},channel:(a=l?.channel)!==null&&a!==void 0?a:"sms"}});return{data:{user:null,session:null,messageId:c?.message_id},error:u}}throw new ds("You must provide either an email or phone number.")}catch(o){if($(o))return{data:{user:null,session:null},error:o};throw o}}async verifyOtp(e){var n,r;try{let s,i;"options"in e&&(s=(n=e.options)===null||n===void 0?void 0:n.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:a,error:o}=await L(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:st});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const l=a.session,c=a.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(s){if($(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var n,r,s;try{let i=null,a=null;return this.flowType==="pkce"&&([i,a]=await Vn(this.storage,this.storageKey)),await L(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:(r=(n=e.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e?.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:a}),headers:this.headers,xform:yp})}catch(i){if($(i))return{data:null,error:i};throw i}}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:n},error:r}=e;if(r)throw r;if(!n)throw new Mt;const{error:s}=await L(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if($(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const n=`${this.url}/resend`;if("email"in e){const{email:r,type:s,options:i}=e,{error:a}=await L(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:i?.captchaToken}},redirectTo:i?.emailRedirectTo});return{data:{user:null,session:null},error:a}}else if("phone"in e){const{phone:r,type:s,options:i}=e,{data:a,error:o}=await L(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:i?.captchaToken}}});return{data:{user:null,session:null,messageId:a?.message_id},error:o}}throw new ds("You must provide either an email or phone number and a type")}catch(n){if($(n))return{data:{user:null,session:null},error:n};throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async n=>n))}async _acquireLock(e,n){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await n()))();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 r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}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 n=await this.__loadSession();return await e(n)}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 n=await hn(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?e=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<ji:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const a=await hn(this.userStorage,this.storageKey+"-user");a?.user?e.user=a.user:e.user=qi()}if(this.storage.isServer&&e.user){let a=this.suppressGetSessionWarning;e=new Proxy(e,{get:(l,c,u)=>(!a&&c==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),a=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,c,u))})}return{data:{session:e},error:null}}const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await L(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:qt}):await this._useSession(async n=>{var r,s,i;const{data:a,error:o}=n;if(o)throw o;return!(!((r=a.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Mt}:await L(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:qt})})}catch(n){if($(n))return Vf(n)&&(await this._removeSession(),await Bt(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:n};throw n}}async updateUser(e,n={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,n))}async _updateUser(e,n={}){try{return await this._useSession(async r=>{const{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new Mt;const a=s.session;let o=null,l=null;this.flowType==="pkce"&&e.email!=null&&([o,l]=await Vn(this.storage,this.storageKey));const{data:c,error:u}=await L(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:a.access_token,xform:qt});if(u)throw u;return a.user=c.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),{data:{user:a.user},error:null}})}catch(r){if($(r))return{data:{user:null},error:r};throw r}}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 Mt;const n=Date.now()/1e3;let r=n,s=!0,i=null;const{payload:a}=Bi(e.access_token);if(a.exp&&(r=a.exp,s=r<=n),s){const{data:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!o)return{data:{user:null,session:null},error:null};i=o}else{const{data:o,error:l}=await this._getUser(e.access_token);if(l)throw l;i={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(n){if($(n))return{data:{session:null,user:null},error:n};throw n}}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 n=>{var r;if(!e){const{data:a,error:o}=n;if(o)throw o;e=(r=a.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new Mt;const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(n){if($(n))return{data:{user:null,session:null},error:n};throw n}}async _getSessionFromURL(e,n){try{if(!He())throw new hs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new hs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new Al("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new hs("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Al("No code detected.");const{data:p,error:m}=await this._exchangeCodeForSession(e.code);if(m)throw m;const y=new URL(window.location.href);return y.searchParams.delete("code"),window.history.replaceState(window.history.state,"",y.toString()),{data:{session:p.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:s,access_token:i,refresh_token:a,expires_in:o,expires_at:l,token_type:c}=e;if(!i||!o||!a||!c)throw new hs("No session defined in URL");const u=Math.round(Date.now()/1e3),d=parseInt(o);let h=u+d;l&&(h=parseInt(l));const f=h-u;f*1e3<=zn&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${d}s`);const g=h-d;u-g>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",g,h,u):u-g<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",g,h,u);const{data:v,error:_}=await this._getUser(i);if(_)throw _;const S={provider_token:r,provider_refresh_token:s,access_token:i,expires_in:d,expires_at:h,refresh_token:a,token_type:c,user:v.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:S,redirectType:e.type},error:null}}catch(r){if($(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const n=await hn(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&n)}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 n=>{var r;const{data:s,error:i}=n;if(i)return{error:i};const a=(r=s.session)===null||r===void 0?void 0:r.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(Kf(o)&&(o.status===404||o.status===401||o.status===403)))return{error:o}}return e!=="others"&&(await this._removeSession(),await Bt(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const n=np(),r={id:n,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async n=>{var r,s;try{const{data:{session:i},error:a}=n;if(a)throw a;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){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",i),console.error(i)}})}async resetPasswordForEmail(e,n={}){let r=null,s=null;this.flowType==="pkce"&&([r,s]=await Vn(this.storage,this.storageKey,!0));try{return await L(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(i){if($(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=n.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(n){if($(n))return{data:null,error:n};throw n}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var n;try{const{data:r,error:s}=await this._useSession(async i=>{var a,o,l,c,u;const{data:d,error:h}=i;if(h)throw h;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(a=e.options)===null||a===void 0?void 0:a.redirectTo,scopes:(o=e.options)===null||o===void 0?void 0:o.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await L(this.fetch,"GET",f,{headers:this.headers,jwt:(u=(c=d.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(s)throw s;return He()&&!(!((n=e.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r?.url),{data:{provider:e.provider,url:r?.url},error:null}}catch(r){if($(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async linkIdentityIdToken(e){return await this._useSession(async n=>{var r;try{const{error:s,data:{session:i}}=n;if(s)throw s;const{options:a,provider:o,token:l,access_token:c,nonce:u}=e,d=await L(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i?.access_token)!==null&&r!==void 0?r:void 0,body:{provider:o,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:st}),{data:h,error:f}=d;return f?{data:{user:null,session:null},error:f}:!h||!h.session||!h.user?{data:{user:null,session:null},error:new Wn}:(h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),{data:h,error:f})}catch(s){if($(s))return{data:{user:null,session:null},error:s};throw s}})}async unlinkIdentity(e){try{return await this._useSession(async n=>{var r,s;const{data:i,error:a}=n;if(a)throw a;return await L(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(n){if($(n))return{data:null,error:n};throw n}}async _refreshAccessToken(e){const n=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await ap(async s=>(s>0&&await ip(200*Math.pow(2,s-1)),this._debug(n,"refreshing attempt",s),await L(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:st})),(s,i)=>{const a=200*Math.pow(2,s);return i&&Fi(i)&&Date.now()+a-r<zn})}catch(r){if(this._debug(n,"error",r),$(r))return{data:{session:null,user:null},error:r};throw r}finally{this._debug(n,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,n){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",n,"url",r),He()&&!n.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,n;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const s=await hn(this.storage,this.storageKey);if(s&&this.userStorage){let a=await hn(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:s.user},await Kn(this.userStorage,this.storageKey+"-user",a)),s.user=(e=a?.user)!==null&&e!==void 0?e:qi()}else if(s&&!s.user&&!s.user){const a=await hn(this.storage,this.storageKey+"-user");a&&a?.user?(s.user=a.user,await Bt(this.storage,this.storageKey+"-user"),await Kn(this.storage,this.storageKey,s)):s.user=qi()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),s!==null&&await this._removeSession();return}const i=((n=s.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<ji;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${ji}s`),i){if(this.autoRefreshToken&&s.refresh_token){const{error:a}=await this._callRefreshToken(s.refresh_token);a&&(console.error(a),Fi(a)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",a),await this._removeSession()))}}else if(s.user&&s.user.__isUserNotAvailableProxy===!0)try{const{data:a,error:o}=await this._getUser(s.access_token);!o&&a?.user?(s.user=a.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(r,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(s){this._debug(r,"error",s),console.error(s);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var n,r;if(!e)throw new Mt;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new ps;const{data:i,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!i.session)throw new Mt;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const o={data:i.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(i){if(this._debug(s,"error",i),$(i)){const a={data:null,error:i};return Fi(i)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(a),a}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,n,r=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",n,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:n});const i=[],a=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,n)}catch(l){i.push(l)}});if(await Promise.all(a),i.length>0){for(let o=0;o<i.length;o+=1)console.error(i[o]);throw i[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const n=Object.assign({},e),r=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&n.user&&await Kn(this.userStorage,this.storageKey+"-user",{user:n.user});const s=Object.assign({},n);delete s.user;const i=Ll(s);await Kn(this.storage,this.storageKey,i)}else{const s=Ll(n);await Kn(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),await Bt(this.storage,this.storageKey),await Bt(this.storage,this.storageKey+"-code-verifier"),await Bt(this.storage,this.storageKey+"-user"),this.userStorage&&await Bt(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&He()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),zn);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 n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((r.expires_at*1e3-e)/zn);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${zn}ms, refresh threshold is ${Li} ticks`),s<=Li&&await this._callRefreshToken(r.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Ml)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!He()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const n=`#_onVisibilityChanged(${e})`;this._debug(n,"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(n,"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,n,r){const s=[`provider=${encodeURIComponent(n)}`];if(r?.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,a]=await Vn(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(o.toString())}if(r?.queryParams){const i=new URLSearchParams(r.queryParams);s.push(i.toString())}return r?.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;return i?{data:null,error:i}:await L(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if($(n))return{data:null,error:n};throw n}}async _enroll(e){try{return await this._useSession(async n=>{var r,s;const{data:i,error:a}=n;if(a)return{data:null,error:a};const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await L(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(r=i?.session)===null||r===void 0?void 0:r.access_token});return c?{data:null,error:c}:(e.factorType==="totp"&&l.type==="totp"&&(!((s=l?.totp)===null||s===void 0)&&s.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(n){if($(n))return{data:null,error:n};throw n}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i)return{data:null,error:i};const a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Dp(e.webauthn.credential_response):Up(e.webauthn.credential_response)})}:{code:e.code}),{data:o,error:l}=await L(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});return l?{data:null,error:l}:(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:l})})}catch(n){if($(n))return{data:null,error:n};throw n}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i)return{data:null,error:i};const a=await L(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});if(a.error)return a;const{data:o}=a;if(o.type!=="webauthn")return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:Lp(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:jp(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if($(n))return{data:null,error:n};throw n}})}async _challengeAndVerify(e){const{data:n,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:n.id,code:e.code})}async _listFactors(){var e;const{data:{user:n},error:r}=await this.getUser();if(r)return{data:null,error:r};const s={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=n?.factors)!==null&&e!==void 0?e:[])s.all.push(i),i.status==="verified"&&s[i.factor_type].push(i);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var n,r;const{data:{session:s},error:i}=e;if(i)return{data:null,error:i};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:a}=Bi(s.access_token);let o=null;a.aal&&(o=a.aal);let l=o;((r=(n=s.user.factors)===null||n===void 0?void 0:n.filter(d=>d.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const u=a.amr||[];return{data:{currentLevel:o,nextLevel:l,currentAuthenticationMethods:u},error:null}}))}async fetchJwk(e,n={keys:[]}){let r=n.keys.find(o=>o.kid===e);if(r)return r;const s=Date.now();if(r=this.jwks.keys.find(o=>o.kid===e),r&&this.jwks_cached_at+Wf>s)return r;const{data:i,error:a}=await L(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,r=i.keys.find(o=>o.kid===e),!r)?null:r}async getClaims(e,n={}){try{let r=e;if(!r){const{data:f,error:g}=await this.getSession();if(g||!f.session)return{data:null,error:g};r=f.session.access_token}const{header:s,payload:i,signature:a,raw:{header:o,payload:l}}=Bi(r);n?.allowExpired||fp(i.exp);const c=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,n?.keys?{keys:n.keys}:n?.jwks);if(!c){const{error:f}=await this.getUser(r);if(f)throw f;return{data:{claims:i,header:s,signature:a},error:null}}const u=pp(s.alg),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,a,ep(`${o}.${l}`)))throw new Mi("Invalid JWT signature");return{data:{claims:i,header:s,signature:a},error:null}}catch(r){if($(r))return{data:null,error:r};throw r}}}wr.nextInstanceID=0;const Kp=wr;class Vp extends Kp{constructor(e){super(e)}}var Jp=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class Yp{constructor(e,n,r){var s,i,a;this.supabaseUrl=e,this.supabaseKey=n;const o=Mf(e);if(!n)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",o),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",o),this.storageUrl=new URL("storage/v1",o),this.functionsUrl=new URL("functions/v1",o);const l=`sb-${o.hostname.split(".")[0]}-auth-token`,c={db:If,realtime:Cf,auth:Object.assign(Object.assign({},$f),{storageKey:l}),global:Rf},u=Ff(r??{},c);this.storageKey=(s=u.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=u.global.headers)!==null&&i!==void 0?i:{},u.accessToken?(this.accessToken=u.accessToken,this.auth=new Proxy({},{get:(d,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((a=u.auth)!==null&&a!==void 0?a:{},this.headers,u.global.fetch),this.fetch=jf(n,this._getAccessToken.bind(this),u.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},u.realtime)),this.rest=new Vh(new URL("rest/v1",o).href,{headers:this.headers,schema:u.db.schema,fetch:this.fetch}),this.storage=new Af(this.storageUrl.href,this.headers,this.fetch,r?.storage),u.accessToken||this._listenForAuthEvents()}get functions(){return new jh(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,n={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,n,r)}channel(e,n={config:{}}){return this.realtime.channel(e,n)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){return Jp(this,void 0,void 0,function*(){var e,n;if(this.accessToken)return yield this.accessToken();const{data:r}=yield this.auth.getSession();return(n=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&n!==void 0?n:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:s,userStorage:i,storageKey:a,flowType:o,lock:l,debug:c},u,d){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Vp({url:this.authUrl.href,headers:Object.assign(Object.assign({},h),u),storageKey:a,autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:s,userStorage:i,flowType:o,lock:l,debug:c,fetch:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(f=>f.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new df(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((n,r)=>{this._handleTokenChanged(n,"CLIENT",r?.access_token)})}_handleTokenChanged(e,n,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),n=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Xp=(t,e,n)=>new Yp(t,e,n);function Zp(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}Zp()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function zi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pn=zi();function Gl(t){pn=t}var Er={exec:()=>null};function H(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(Oe.caret,"$1"),n=n.replace(s,a),r},getRegex:()=>new RegExp(n,e)};return r}var Qp=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Oe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},eg=/^(?:[ \t]*(?:\n|$))+/,tg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ng=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,kr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,rg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wi=/(?:[*+-]|\d{1,9}[.)])/,Kl=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Vl=H(Kl).replace(/bull/g,Wi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),sg=H(Kl).replace(/bull/g,Wi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Gi=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ig=/^[^\n]+/,Ki=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ag=H(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ki).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),og=H(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wi).getRegex(),_s="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Vi=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,lg=H("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Vi).replace("tag",_s).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jl=H(Gi).replace("hr",kr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_s).getRegex(),cg=H(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Jl).getRegex(),Ji={blockquote:cg,code:tg,def:ag,fences:ng,heading:rg,hr:kr,html:lg,lheading:Vl,list:og,newline:eg,paragraph:Jl,table:Er,text:ig},Yl=H("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",kr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_s).getRegex(),ug={...Ji,lheading:sg,table:Yl,paragraph:H(Gi).replace("hr",kr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yl).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_s).getRegex()},dg={...Ji,html:H(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vi).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Er,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H(Gi).replace("hr",kr).replace("heading",` *#{1,6} *[^
43
- ]`).replace("lheading",Vl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},hg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,fg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Xl=/^( {2,}|\\)\n(?!\s*$)/,pg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vs=/[\p{P}\p{S}]/u,Yi=/[\s\p{P}\p{S}]/u,Zl=/[^\s\p{P}\p{S}]/u,gg=H(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Yi).getRegex(),Ql=/(?!~)[\p{P}\p{S}]/u,mg=/(?!~)[\s\p{P}\p{S}]/u,_g=/(?:[^\s\p{P}\p{S}]|~)/u,vg=H(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Qp?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ec=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,bg=H(ec,"u").replace(/punct/g,vs).getRegex(),yg=H(ec,"u").replace(/punct/g,Ql).getRegex(),tc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wg=H(tc,"gu").replace(/notPunctSpace/g,Zl).replace(/punctSpace/g,Yi).replace(/punct/g,vs).getRegex(),Eg=H(tc,"gu").replace(/notPunctSpace/g,_g).replace(/punctSpace/g,mg).replace(/punct/g,Ql).getRegex(),kg=H("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Zl).replace(/punctSpace/g,Yi).replace(/punct/g,vs).getRegex(),Sg=H(/\\(punct)/,"gu").replace(/punct/g,vs).getRegex(),Tg=H(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xg=H(Vi).replace("(?:-->|$)","-->").getRegex(),Ag=H("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",xg).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),bs=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Og=H(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",bs).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),nc=H(/^!?\[(label)\]\[(ref)\]/).replace("label",bs).replace("ref",Ki).getRegex(),rc=H(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ki).getRegex(),Rg=H("reflink|nolink(?!\\()","g").replace("reflink",nc).replace("nolink",rc).getRegex(),sc=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Xi={_backpedal:Er,anyPunctuation:Sg,autolink:Tg,blockSkip:vg,br:Xl,code:fg,del:Er,emStrongLDelim:bg,emStrongRDelimAst:wg,emStrongRDelimUnd:kg,escape:hg,link:Og,nolink:rc,punctuation:gg,reflink:nc,reflinkSearch:Rg,tag:Ag,text:pg,url:Er},Ig={...Xi,link:H(/^!?\[(label)\]\((.*?)\)/).replace("label",bs).getRegex(),reflink:H(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",bs).getRegex()},Zi={...Xi,emStrongRDelimAst:Eg,emStrongLDelim:yg,url:H(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",sc).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:H(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",sc).getRegex()},$g={...Zi,br:H(Xl).replace("{2,}","*").getRegex(),text:H(Zi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ys={normal:Ji,gfm:ug,pedantic:dg},Sr={normal:Xi,gfm:Zi,breaks:$g,pedantic:Ig},Cg={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ic=t=>Cg[t];function pt(t,e){if(e){if(Oe.escapeTest.test(t))return t.replace(Oe.escapeReplace,ic)}else if(Oe.escapeTestNoEncode.test(t))return t.replace(Oe.escapeReplaceNoEncode,ic);return t}function ac(t){try{t=encodeURI(t).replace(Oe.percentDecode,"%")}catch{return null}return t}function oc(t,e){let n=t.replace(Oe.findPipe,(i,a,o)=>{let l=!1,c=a;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Oe.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(Oe.slashPipe,"|");return r}function Tr(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function Pg(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function lc(t,e,n,r,s){let i=e.href,a=e.title||null,o=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}function Ng(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
38
+ Request ID: ${l}`),c){let g=`
39
+ Resources:`;for(const p of c){if(!p||typeof p!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${p}`);g+=`
40
+ - ${p}`}S+=g}return`${v}
41
+ ${S}`}class fe extends Error{constructor({message:e,code:n,cause:r,name:s}){var i;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=(i=s??(r instanceof Error?r.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=n}}class ms extends fe{constructor(e,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:e}),this.name="WebAuthnUnknownError",this.originalError=n}}function Cp({error:t,options:e}){var n,r,s;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new fe({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new fe({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new fe({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new fe({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new fe({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new fe({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new fe({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new fe({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const a=window.location.hostname;if(zl(a)){if(i.rp.id!==a)return new fe({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new fe({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new fe({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new fe({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new fe({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function Pp({error:t,options:e}){const{publicKey:n}=e;if(!n)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new fe({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new fe({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const r=window.location.hostname;if(zl(r)){if(n.rpId!==r)return new fe({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new fe({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new fe({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new fe({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}var Hl=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n};class Np{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const Lp=new Np;function jp(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:n,excludeCredentials:r}=t,s=Hl(t,["challenge","user","excludeCredentials"]),i=Kn(e).buffer,a=Object.assign(Object.assign({},n),{id:Kn(n.id).buffer}),o=Object.assign(Object.assign({},s),{challenge:i,user:a});if(r&&r.length>0){o.excludeCredentials=new Array(r.length);for(let l=0;l<r.length;l++){const c=r[l];o.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Kn(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}function Dp(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:n}=t,r=Hl(t,["challenge","allowCredentials"]),s=Kn(e).buffer,i=Object.assign(Object.assign({},r),{challenge:s});if(n&&n.length>0){i.allowCredentials=new Array(n.length);for(let a=0;a<n.length;a++){const o=n[a];i.allowCredentials[a]=Object.assign(Object.assign({},o),{id:Kn(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return i}function Up(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t;return{id:t.id,rawId:t.id,response:{attestationObject:dn(new Uint8Array(t.response.attestationObject)),clientDataJSON:dn(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Fp(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t,r=t.getClientExtensionResults(),s=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:dn(new Uint8Array(s.authenticatorData)),clientDataJSON:dn(new Uint8Array(s.clientDataJSON)),signature:dn(new Uint8Array(s.signature)),userHandle:s.userHandle?dn(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(e=n.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function zl(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function Wl(){var t,e;return!!(ze()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Mp(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new ms("Browser returned unexpected credential type",e)}:{data:null,error:new ms("Empty credential response",e)}}catch(e){return{data:null,error:Cp({error:e,options:t})}}}async function Bp(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new ms("Browser returned unexpected credential type",e)}:{data:null,error:new ms("Empty credential response",e)}}catch(e){return{data:null,error:Pp({error:e,options:t})}}}const qp={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"none"},Hp={userVerification:"preferred",hints:["security-key"]};function _s(...t){const e=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),n=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),r={};for(const s of t)if(s)for(const i in s){const a=s[i];if(a!==void 0)if(Array.isArray(a))r[i]=a;else if(n(a))r[i]=a;else if(e(a)){const o=r[i];e(o)?r[i]=_s(o,a):r[i]=_s(a)}else r[i]=a}return r}function zp(t,e){return _s(qp,t,e||{})}function Wp(t,e){return _s(Hp,t,e||{})}class Gp{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:n,friendlyName:r,signal:s},i){try{const{data:a,error:o}=await this.client.mfa.challenge({factorId:e,webauthn:n});if(!a)return{data:null,error:o};const l=s??Lp.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:c}=a.webauthn.credential_options.publicKey;c.name||(c.name=`${c.id}:${r}`),c.displayName||(c.displayName=c.name)}switch(a.webauthn.type){case"create":{const c=zp(a.webauthn.credential_options.publicKey,i?.create),{data:u,error:d}=await Mp({publicKey:c,signal:l});return u?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:u}},error:null}:{data:null,error:d}}case"request":{const c=Wp(a.webauthn.credential_options.publicKey,i?.request),{data:u,error:d}=await Bp(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:c,signal:l}));return u?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:u}},error:null}:{data:null,error:d}}}}catch(a){return I(a)?{data:null,error:a}:{data:null,error:new un("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:n,webauthn:r}){return this.client.mfa.verify({factorId:n,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}},i){if(!n)return{data:null,error:new wr("rpId is required for WebAuthn authentication")};try{if(!Wl())return{data:null,error:new un("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this.challenge({factorId:e,webauthn:{rpId:n,rpOrigins:r},signal:s},{request:i});if(!a)return{data:null,error:o};const{webauthn:l}=a;return this._verify({factorId:e,challengeId:a.challengeId,webauthn:{type:l.type,rpId:n,rpOrigins:r,credential_response:l.credential_response}})}catch(a){return I(a)?{data:null,error:a}:{data:null,error:new un("Unexpected error in authenticate",a)}}}async _register({friendlyName:e,rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s},i){if(!n)return{data:null,error:new wr("rpId is required for WebAuthn registration")};try{if(!Wl())return{data:null,error:new un("Browser does not support WebAuthn",null)};const{data:a,error:o}=await this._enroll({friendlyName:e});if(!a)return await this.client.mfa.listFactors().then(u=>{var d;return(d=u.data)===null||d===void 0?void 0:d.all.find(h=>h.factor_type==="webauthn"&&h.friendly_name===e&&h.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u?.id}):void 0),{data:null,error:o};const{data:l,error:c}=await this._challenge({factorId:a.id,friendlyName:a.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:s},{create:i});return l?this._verify({factorId:a.id,challengeId:l.challengeId,webauthn:{rpId:n,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(a){return I(a)?{data:null,error:a}:{data:null,error:new un("Unexpected error in register",a)}}}}Rp();const Kp={url:qf,storageKey:Hf,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:zf,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function Gl(t,e,n){return await n()}const Zn={};class Er{get jwks(){var e,n;return(n=(e=Zn[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(e){Zn[this.storageKey]=Object.assign(Object.assign({},Zn[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,n;return(n=(e=Zn[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Zn[this.storageKey]=Object.assign(Object.assign({},Zn[this.storageKey]),{cachedAt:e})}constructor(e){var n,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Er.nextInstanceID,Er.nextInstanceID+=1,this.instanceID>0&&ze()&&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 s=Object.assign(Object.assign({},Kp),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new Tp({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=Ll(s.fetch),this.lock=s.lock||Gl,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:ze()&&(!((n=globalThis?.navigator)===null||n===void 0)&&n.locks)?this.lock=Ap:this.lock=Gl,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),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),webauthn:new Gp(this)},this.persistSession?(s.storage?this.storage=s.storage:Nl()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Ml(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=Ml(this.memoryStorage)),ze()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${xl}) ${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(){var e;try{const n=sp(window.location.href);let r="none";if(this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce"),ze()&&this.detectSessionInUrl&&r!=="none"){const{data:s,error:i}=await this._getSessionFromURL(n,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Yf(i)){const l=(e=i.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:a,redirectType:o}=s;return this._debug("#_initialize()","detected session in URL",a,"redirect type",o),await this._saveSession(a),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return I(n)?{error:n}:{error:new un("Unexpected error during initialization",n)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var n,r,s;try{const i=await N(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=e?.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(s=e?.options)===null||s===void 0?void 0:s.captchaToken}},xform:rt}),{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const l=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(i){if(I(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var n,r,s;try{let i;if("email"in e){const{email:u,password:d,options:h}=e;let f=null,m=null;this.flowType==="pkce"&&([f,m]=await Jn(this.storage,this.storageKey)),i=await N(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h?.emailRedirectTo,body:{email:u,password:d,data:(n=h?.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:f,code_challenge_method:m},xform:rt})}else if("phone"in e){const{phone:u,password:d,options:h}=e;i=await N(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:d,data:(r=h?.data)!==null&&r!==void 0?r:{},channel:(s=h?.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:rt})}else throw new hs("You must provide either an email or phone number and a password");const{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const l=a.session,c=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(i){if(I(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let n;if("email"in e){const{email:i,password:a,options:o}=e;n=await N(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Ul})}else if("phone"in e){const{phone:i,password:a,options:o}=e;n=await N(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Ul})}else throw new hs("You must provide either an email or phone number and a password");const{data:r,error:s}=n;return s?{data:{user:null,session:null},error:s}:!r||!r.session||!r.user?{data:{user:null,session:null},error:new Gn}:(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),{data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(n){if(I(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOAuth(e){var n,r,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(n=e.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:n}=e;switch(n){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(e){var n,r,s,i,a,o,l,c,u,d,h;let f,m;if("message"in e)f=e.message,m=e.signature;else{const{chain:_,wallet:v,statement:S,options:g}=e;let p;if(ze())if(typeof v=="object")p=v;else{const T=window;if("ethereum"in T&&typeof T.ethereum=="object"&&"request"in T.ethereum&&typeof T.ethereum.request=="function")p=T.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!g?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");p=v}const y=new URL((n=g?.url)!==null&&n!==void 0?n:window.location.href),E=await p.request({method:"eth_requestAccounts"}).then(T=>T).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!E||E.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const b=ql(E[0]);let k=(r=g?.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!k){const T=await p.request({method:"eth_chainId"});k=Op(T)}const A={domain:y.host,address:b,statement:S,uri:y.href,version:"1",chainId:k,nonce:(s=g?.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(a=(i=g?.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&a!==void 0?a:new Date,expirationTime:(o=g?.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(l=g?.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=g?.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=g?.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=$p(A),m=await p.request({method:"personal_sign",params:[Ip(f),b]})}try{const{data:_,error:v}=await N(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:m},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(h=e.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:rt});if(v)throw v;return!_||!_.session||!_.user?{data:{user:null,session:null},error:new Gn}:(_.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),{data:Object.assign({},_),error:v})}catch(_){if(I(_))return{data:{user:null,session:null},error:_};throw _}}async signInWithSolana(e){var n,r,s,i,a,o,l,c,u,d,h,f;let m,_;if("message"in e)m=e.message,_=e.signature;else{const{chain:v,wallet:S,statement:g,options:p}=e;let y;if(ze())if(typeof S=="object")y=S;else{const b=window;if("solana"in b&&typeof b.solana=="object"&&("signIn"in b.solana&&typeof b.solana.signIn=="function"||"signMessage"in b.solana&&typeof b.solana.signMessage=="function"))y=b.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof S!="object"||!p?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");y=S}const E=new URL((n=p?.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in y&&y.signIn){const b=await y.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},p?.signInWithSolana),{version:"1",domain:E.host,uri:E.href}),g?{statement:g}:null));let k;if(Array.isArray(b)&&b[0]&&typeof b[0]=="object")k=b[0];else if(b&&typeof b=="object"&&"signedMessage"in b&&"signature"in b)k=b;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in k&&"signature"in k&&(typeof k.signedMessage=="string"||k.signedMessage instanceof Uint8Array)&&k.signature instanceof Uint8Array)m=typeof k.signedMessage=="string"?k.signedMessage:new TextDecoder().decode(k.signedMessage),_=k.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in y)||typeof y.signMessage!="function"||!("publicKey"in y)||typeof y!="object"||!y.publicKey||!("toBase58"in y.publicKey)||typeof y.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");m=[`${E.host} wants you to sign in with your Solana account:`,y.publicKey.toBase58(),...g?["",g,""]:[""],"Version: 1",`URI: ${E.href}`,`Issued At: ${(s=(r=p?.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=p?.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${p.signInWithSolana.notBefore}`]:[],...!((a=p?.signInWithSolana)===null||a===void 0)&&a.expirationTime?[`Expiration Time: ${p.signInWithSolana.expirationTime}`]:[],...!((o=p?.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${p.signInWithSolana.chainId}`]:[],...!((l=p?.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${p.signInWithSolana.nonce}`]:[],...!((c=p?.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${p.signInWithSolana.requestId}`]:[],...!((d=(u=p?.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||d===void 0)&&d.length?["Resources",...p.signInWithSolana.resources.map(k=>`- ${k}`)]:[]].join(`
42
+ `);const b=await y.signMessage(new TextEncoder().encode(m),"utf8");if(!b||!(b instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");_=b}}try{const{data:v,error:S}=await N(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:dn(_)},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:rt});if(S)throw S;return!v||!v.session||!v.user?{data:{user:null,session:null},error:new Gn}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),{data:Object.assign({},v),error:S})}catch(v){if(I(v))return{data:{user:null,session:null},error:v};throw v}}async _exchangeCodeForSession(e){const n=await fn(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(n??"").split("/");try{const{data:i,error:a}=await N(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:r},xform:rt});if(await Bt(this.storage,`${this.storageKey}-code-verifier`),a)throw a;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new Gn}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:a})}catch(i){if(I(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:n,provider:r,token:s,access_token:i,nonce:a}=e,o=await N(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:n?.captchaToken}},xform:rt}),{data:l,error:c}=o;return c?{data:{user:null,session:null},error:c}:!l||!l.session||!l.user?{data:{user:null,session:null},error:new Gn}:(l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),{data:l,error:c})}catch(n){if(I(n))return{data:{user:null,session:null},error:n};throw n}}async signInWithOtp(e){var n,r,s,i,a;try{if("email"in e){const{email:o,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await Jn(this.storage,this.storageKey));const{error:d}=await N(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(n=l?.data)!==null&&n!==void 0?n:{},create_user:(r=l?.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l?.emailRedirectTo});return{data:{user:null,session:null},error:d}}if("phone"in e){const{phone:o,options:l}=e,{data:c,error:u}=await N(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(s=l?.data)!==null&&s!==void 0?s:{},create_user:(i=l?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},channel:(a=l?.channel)!==null&&a!==void 0?a:"sms"}});return{data:{user:null,session:null,messageId:c?.message_id},error:u}}throw new hs("You must provide either an email or phone number.")}catch(o){if(I(o))return{data:{user:null,session:null},error:o};throw o}}async verifyOtp(e){var n,r;try{let s,i;"options"in e&&(s=(n=e.options)===null||n===void 0?void 0:n.redirectTo,i=(r=e.options)===null||r===void 0?void 0:r.captchaToken);const{data:a,error:o}=await N(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:rt});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const l=a.session,c=a.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),{data:{user:c,session:l},error:null}}catch(s){if(I(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var n,r,s;try{let i=null,a=null;return this.flowType==="pkce"&&([i,a]=await Jn(this.storage,this.storageKey)),await N(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:(r=(n=e.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e?.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:a}),headers:this.headers,xform:wp})}catch(i){if(I(i))return{data:null,error:i};throw i}}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:n},error:r}=e;if(r)throw r;if(!n)throw new Mt;const{error:s}=await N(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(I(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const n=`${this.url}/resend`;if("email"in e){const{email:r,type:s,options:i}=e,{error:a}=await N(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:i?.captchaToken}},redirectTo:i?.emailRedirectTo});return{data:{user:null,session:null},error:a}}else if("phone"in e){const{phone:r,type:s,options:i}=e,{data:a,error:o}=await N(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:i?.captchaToken}}});return{data:{user:null,session:null,messageId:a?.message_id},error:o}}throw new hs("You must provide either an email or phone number and a type")}catch(n){if(I(n))return{data:{user:null,session:null},error:n};throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async n=>n))}async _acquireLock(e,n){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await n()))();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 r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}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 n=await this.__loadSession();return await e(n)}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 n=await fn(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?e=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const r=e.expires_at?e.expires_at*1e3-Date.now()<Di:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",e.expires_at),!r){if(this.userStorage){const a=await fn(this.userStorage,this.storageKey+"-user");a?.user?e.user=a.user:e.user=Hi()}if(this.storage.isServer&&e.user){let a=this.suppressGetSessionWarning;e=new Proxy(e,{get:(l,c,u)=>(!a&&c==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),a=!0,this.suppressGetSessionWarning=!0),Reflect.get(l,c,u))})}return{data:{session:e},error:null}}const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await N(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:qt}):await this._useSession(async n=>{var r,s,i;const{data:a,error:o}=n;if(o)throw o;return!(!((r=a.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Mt}:await N(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:qt})})}catch(n){if(I(n))return Jf(n)&&(await this._removeSession(),await Bt(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:n};throw n}}async updateUser(e,n={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,n))}async _updateUser(e,n={}){try{return await this._useSession(async r=>{const{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new Mt;const a=s.session;let o=null,l=null;this.flowType==="pkce"&&e.email!=null&&([o,l]=await Jn(this.storage,this.storageKey));const{data:c,error:u}=await N(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:l}),jwt:a.access_token,xform:qt});if(u)throw u;return a.user=c.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),{data:{user:a.user},error:null}})}catch(r){if(I(r))return{data:{user:null},error:r};throw r}}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 Mt;const n=Date.now()/1e3;let r=n,s=!0,i=null;const{payload:a}=qi(e.access_token);if(a.exp&&(r=a.exp,s=r<=n),s){const{data:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return{data:{user:null,session:null},error:l};if(!o)return{data:{user:null,session:null},error:null};i=o}else{const{data:o,error:l}=await this._getUser(e.access_token);if(l)throw l;i={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(n){if(I(n))return{data:{session:null,user:null},error:n};throw n}}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 n=>{var r;if(!e){const{data:a,error:o}=n;if(o)throw o;e=(r=a.session)!==null&&r!==void 0?r:void 0}if(!e?.refresh_token)throw new Mt;const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(n){if(I(n))return{data:{user:null,session:null},error:n};throw n}}async _getSessionFromURL(e,n){try{if(!ze())throw new fs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new fs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new Rl("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new fs("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Rl("No code detected.");const{data:g,error:p}=await this._exchangeCodeForSession(e.code);if(p)throw p;const y=new URL(window.location.href);return y.searchParams.delete("code"),window.history.replaceState(window.history.state,"",y.toString()),{data:{session:g.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:s,access_token:i,refresh_token:a,expires_in:o,expires_at:l,token_type:c}=e;if(!i||!o||!a||!c)throw new fs("No session defined in URL");const u=Math.round(Date.now()/1e3),d=parseInt(o);let h=u+d;l&&(h=parseInt(l));const f=h-u;f*1e3<=Wn&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${d}s`);const m=h-d;u-m>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",m,h,u):u-m<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",m,h,u);const{data:_,error:v}=await this._getUser(i);if(v)throw v;const S={provider_token:r,provider_refresh_token:s,access_token:i,expires_in:d,expires_at:h,refresh_token:a,token_type:c,user:_.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:S,redirectType:e.type},error:null}}catch(r){if(I(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const n=await fn(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&n)}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 n=>{var r;const{data:s,error:i}=n;if(i)return{error:i};const a=(r=s.session)===null||r===void 0?void 0:r.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(Vf(o)&&(o.status===404||o.status===401||o.status===403)))return{error:o}}return e!=="others"&&(await this._removeSession(),await Bt(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const n=rp(),r={id:n,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(e){return await this._useSession(async n=>{var r,s;try{const{data:{session:i},error:a}=n;if(a)throw a;await((r=this.stateChangeEmitters.get(e))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){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",i),console.error(i)}})}async resetPasswordForEmail(e,n={}){let r=null,s=null;this.flowType==="pkce"&&([r,s]=await Jn(this.storage,this.storageKey,!0));try{return await N(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(i){if(I(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return{data:{identities:(e=n.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(n){if(I(n))return{data:null,error:n};throw n}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var n;try{const{data:r,error:s}=await this._useSession(async i=>{var a,o,l,c,u;const{data:d,error:h}=i;if(h)throw h;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(a=e.options)===null||a===void 0?void 0:a.redirectTo,scopes:(o=e.options)===null||o===void 0?void 0:o.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await N(this.fetch,"GET",f,{headers:this.headers,jwt:(u=(c=d.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(s)throw s;return ze()&&!(!((n=e.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r?.url),{data:{provider:e.provider,url:r?.url},error:null}}catch(r){if(I(r))return{data:{provider:e.provider,url:null},error:r};throw r}}async linkIdentityIdToken(e){return await this._useSession(async n=>{var r;try{const{error:s,data:{session:i}}=n;if(s)throw s;const{options:a,provider:o,token:l,access_token:c,nonce:u}=e,d=await N(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i?.access_token)!==null&&r!==void 0?r:void 0,body:{provider:o,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:rt}),{data:h,error:f}=d;return f?{data:{user:null,session:null},error:f}:!h||!h.session||!h.user?{data:{user:null,session:null},error:new Gn}:(h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),{data:h,error:f})}catch(s){if(I(s))return{data:{user:null,session:null},error:s};throw s}})}async unlinkIdentity(e){try{return await this._useSession(async n=>{var r,s;const{data:i,error:a}=n;if(a)throw a;return await N(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(n){if(I(n))return{data:null,error:n};throw n}}async _refreshAccessToken(e){const n=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await op(async s=>(s>0&&await ap(200*Math.pow(2,s-1)),this._debug(n,"refreshing attempt",s),await N(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:rt})),(s,i)=>{const a=200*Math.pow(2,s);return i&&Mi(i)&&Date.now()+a-r<Wn})}catch(r){if(this._debug(n,"error",r),I(r))return{data:{session:null,user:null},error:r};throw r}finally{this._debug(n,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,n){const r=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",n,"url",r),ze()&&!n.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}async _recoverAndRefresh(){var e,n;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const s=await fn(this.storage,this.storageKey);if(s&&this.userStorage){let a=await fn(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:s.user},await Vn(this.userStorage,this.storageKey+"-user",a)),s.user=(e=a?.user)!==null&&e!==void 0?e:Hi()}else if(s&&!s.user&&!s.user){const a=await fn(this.storage,this.storageKey+"-user");a&&a?.user?(s.user=a.user,await Bt(this.storage,this.storageKey+"-user"),await Vn(this.storage,this.storageKey,s)):s.user=Hi()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),s!==null&&await this._removeSession();return}const i=((n=s.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<Di;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${Di}s`),i){if(this.autoRefreshToken&&s.refresh_token){const{error:a}=await this._callRefreshToken(s.refresh_token);a&&(console.error(a),Mi(a)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",a),await this._removeSession()))}}else if(s.user&&s.user.__isUserNotAvailableProxy===!0)try{const{data:a,error:o}=await this._getUser(s.access_token);!o&&a?.user?(s.user=a.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(r,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(s){this._debug(r,"error",s),console.error(s);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var n,r;if(!e)throw new Mt;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new gs;const{data:i,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!i.session)throw new Mt;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const o={data:i.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(i){if(this._debug(s,"error",i),I(i)){const a={data:null,error:i};return Mi(i)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(a),a}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,n,r=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",n,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:n});const i=[],a=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,n)}catch(l){i.push(l)}});if(await Promise.all(a),i.length>0){for(let o=0;o<i.length;o+=1)console.error(i[o]);throw i[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const n=Object.assign({},e),r=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&n.user&&await Vn(this.userStorage,this.storageKey+"-user",{user:n.user});const s=Object.assign({},n);delete s.user;const i=jl(s);await Vn(this.storage,this.storageKey,i)}else{const s=jl(n);await Vn(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),await Bt(this.storage,this.storageKey),await Bt(this.storage,this.storageKey+"-code-verifier"),await Bt(this.storage,this.storageKey+"-user"),this.userStorage&&await Bt(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ze()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Wn);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 n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((r.expires_at*1e3-e)/Wn);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Wn}ms, refresh threshold is ${ji} ticks`),s<=ji&&await this._callRefreshToken(r.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof Bl)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ze()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const n=`#_onVisibilityChanged(${e})`;this._debug(n,"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(n,"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,n,r){const s=[`provider=${encodeURIComponent(n)}`];if(r?.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r?.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,a]=await Jn(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(o.toString())}if(r?.queryParams){const i=new URLSearchParams(r.queryParams);s.push(i.toString())}return r?.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;return i?{data:null,error:i}:await N(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(I(n))return{data:null,error:n};throw n}}async _enroll(e){try{return await this._useSession(async n=>{var r,s;const{data:i,error:a}=n;if(a)return{data:null,error:a};const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await N(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(r=i?.session)===null||r===void 0?void 0:r.access_token});return c?{data:null,error:c}:(e.factorType==="totp"&&l.type==="totp"&&(!((s=l?.totp)===null||s===void 0)&&s.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),{data:l,error:null})})}catch(n){if(I(n))return{data:null,error:n};throw n}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i)return{data:null,error:i};const a=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?Up(e.webauthn.credential_response):Fp(e.webauthn.credential_response)})}:{code:e.code}),{data:o,error:l}=await N(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:a,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});return l?{data:null,error:l}:(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:l})})}catch(n){if(I(n))return{data:null,error:n};throw n}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i)return{data:null,error:i};const a=await N(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(r=s?.session)===null||r===void 0?void 0:r.access_token});if(a.error)return a;const{data:o}=a;if(o.type!=="webauthn")return{data:o,error:null};switch(o.webauthn.type){case"create":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:jp(o.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},o),{webauthn:Object.assign(Object.assign({},o.webauthn),{credential_options:Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:Dp(o.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(I(n))return{data:null,error:n};throw n}})}async _challengeAndVerify(e){const{data:n,error:r}=await this._challenge({factorId:e.factorId});return r?{data:null,error:r}:await this._verify({factorId:e.factorId,challengeId:n.id,code:e.code})}async _listFactors(){var e;const{data:{user:n},error:r}=await this.getUser();if(r)return{data:null,error:r};const s={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=n?.factors)!==null&&e!==void 0?e:[])s.all.push(i),i.status==="verified"&&s[i.factor_type].push(i);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var n,r;const{data:{session:s},error:i}=e;if(i)return{data:null,error:i};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:a}=qi(s.access_token);let o=null;a.aal&&(o=a.aal);let l=o;((r=(n=s.user.factors)===null||n===void 0?void 0:n.filter(d=>d.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(l="aal2");const u=a.amr||[];return{data:{currentLevel:o,nextLevel:l,currentAuthenticationMethods:u},error:null}}))}async fetchJwk(e,n={keys:[]}){let r=n.keys.find(o=>o.kid===e);if(r)return r;const s=Date.now();if(r=this.jwks.keys.find(o=>o.kid===e),r&&this.jwks_cached_at+Gf>s)return r;const{data:i,error:a}=await N(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,r=i.keys.find(o=>o.kid===e),!r)?null:r}async getClaims(e,n={}){try{let r=e;if(!r){const{data:f,error:m}=await this.getSession();if(m||!f.session)return{data:null,error:m};r=f.session.access_token}const{header:s,payload:i,signature:a,raw:{header:o,payload:l}}=qi(r);n?.allowExpired||pp(i.exp);const c=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,n?.keys?{keys:n.keys}:n?.jwks);if(!c){const{error:f}=await this.getUser(r);if(f)throw f;return{data:{claims:i,header:s,signature:a},error:null}}const u=gp(s.alg),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,a,tp(`${o}.${l}`)))throw new Bi("Invalid JWT signature");return{data:{claims:i,header:s,signature:a},error:null}}catch(r){if(I(r))return{data:null,error:r};throw r}}}Er.nextInstanceID=0;const Vp=Er;class Jp extends Vp{constructor(e){super(e)}}var Yp=function(t,e,n,r){function s(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){u.done?i(u.value):s(u.value).then(o,l)}c((r=r.apply(t,e||[])).next())})};class Xp{constructor(e,n,r){var s,i,a;this.supabaseUrl=e,this.supabaseKey=n;const o=Bf(e);if(!n)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",o),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",o),this.storageUrl=new URL("storage/v1",o),this.functionsUrl=new URL("functions/v1",o);const l=`sb-${o.hostname.split(".")[0]}-auth-token`,c={db:$f,realtime:Pf,auth:Object.assign(Object.assign({},Cf),{storageKey:l}),global:If},u=Mf(r??{},c);this.storageKey=(s=u.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=u.global.headers)!==null&&i!==void 0?i:{},u.accessToken?(this.accessToken=u.accessToken,this.auth=new Proxy({},{get:(d,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((a=u.auth)!==null&&a!==void 0?a:{},this.headers,u.global.fetch),this.fetch=Df(n,this._getAccessToken.bind(this),u.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},u.realtime)),this.rest=new Jh(new URL("rest/v1",o).href,{headers:this.headers,schema:u.db.schema,fetch:this.fetch}),this.storage=new Rf(this.storageUrl.href,this.headers,this.fetch,r?.storage),u.accessToken||this._listenForAuthEvents()}get functions(){return new Dh(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,n={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,n,r)}channel(e,n={config:{}}){return this.realtime.channel(e,n)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){return Yp(this,void 0,void 0,function*(){var e,n;if(this.accessToken)return yield this.accessToken();const{data:r}=yield this.auth.getSession();return(n=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&n!==void 0?n:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:s,userStorage:i,storageKey:a,flowType:o,lock:l,debug:c},u,d){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Jp({url:this.authUrl.href,headers:Object.assign(Object.assign({},h),u),storageKey:a,autoRefreshToken:e,persistSession:n,detectSessionInUrl:r,storage:s,userStorage:i,flowType:o,lock:l,debug:c,fetch:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(f=>f.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new hf(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((n,r)=>{this._handleTokenChanged(n,"CLIENT",r?.access_token)})}_handleTokenChanged(e,n,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),n=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Zp=(t,e,n)=>new Xp(t,e,n);function Qp(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}Qp()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function Wi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var gn=Wi();function Kl(t){gn=t}var kr={exec:()=>null};function H(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(Oe.caret,"$1"),n=n.replace(s,a),r},getRegex:()=>new RegExp(n,e)};return r}var eg=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Oe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},tg=/^(?:[ \t]*(?:\n|$))+/,ng=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,rg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gi=/(?:[*+-]|\d{1,9}[.)])/,Vl=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jl=H(Vl).replace(/bull/g,Gi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ig=H(Vl).replace(/bull/g,Gi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ki=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ag=/^[^\n]+/,Vi=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,og=H(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vi).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),lg=H(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Gi).getRegex(),vs="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ji=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cg=H("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ji).replace("tag",vs).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Yl=H(Ki).replace("hr",Sr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vs).getRegex(),ug=H(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Yl).getRegex(),Yi={blockquote:ug,code:ng,def:og,fences:rg,heading:sg,hr:Sr,html:cg,lheading:Jl,list:lg,newline:tg,paragraph:Yl,table:kr,text:ag},Xl=H("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Sr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vs).getRegex(),dg={...Yi,lheading:ig,table:Xl,paragraph:H(Ki).replace("hr",Sr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Xl).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vs).getRegex()},hg={...Yi,html:H(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ji).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:kr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H(Ki).replace("hr",Sr).replace("heading",` *#{1,6} *[^
43
+ ]`).replace("lheading",Jl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},fg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Zl=/^( {2,}|\\)\n(?!\s*$)/,gg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bs=/[\p{P}\p{S}]/u,Xi=/[\s\p{P}\p{S}]/u,Ql=/[^\s\p{P}\p{S}]/u,mg=H(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xi).getRegex(),ec=/(?!~)[\p{P}\p{S}]/u,_g=/(?!~)[\s\p{P}\p{S}]/u,vg=/(?:[^\s\p{P}\p{S}]|~)/u,bg=H(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",eg?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),tc=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,yg=H(tc,"u").replace(/punct/g,bs).getRegex(),wg=H(tc,"u").replace(/punct/g,ec).getRegex(),nc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Eg=H(nc,"gu").replace(/notPunctSpace/g,Ql).replace(/punctSpace/g,Xi).replace(/punct/g,bs).getRegex(),kg=H(nc,"gu").replace(/notPunctSpace/g,vg).replace(/punctSpace/g,_g).replace(/punct/g,ec).getRegex(),Sg=H("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ql).replace(/punctSpace/g,Xi).replace(/punct/g,bs).getRegex(),Tg=H(/\\(punct)/,"gu").replace(/punct/g,bs).getRegex(),xg=H(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ag=H(Ji).replace("(?:-->|$)","-->").getRegex(),Rg=H("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ag).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ys=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Og=H(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ys).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),rc=H(/^!?\[(label)\]\[(ref)\]/).replace("label",ys).replace("ref",Vi).getRegex(),sc=H(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vi).getRegex(),Ig=H("reflink|nolink(?!\\()","g").replace("reflink",rc).replace("nolink",sc).getRegex(),ic=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Zi={_backpedal:kr,anyPunctuation:Tg,autolink:xg,blockSkip:bg,br:Zl,code:pg,del:kr,emStrongLDelim:yg,emStrongRDelimAst:Eg,emStrongRDelimUnd:Sg,escape:fg,link:Og,nolink:sc,punctuation:mg,reflink:rc,reflinkSearch:Ig,tag:Rg,text:gg,url:kr},$g={...Zi,link:H(/^!?\[(label)\]\((.*?)\)/).replace("label",ys).getRegex(),reflink:H(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ys).getRegex()},Qi={...Zi,emStrongRDelimAst:kg,emStrongLDelim:wg,url:H(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ic).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:H(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ic).getRegex()},Cg={...Qi,br:H(Zl).replace("{2,}","*").getRegex(),text:H(Qi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ws={normal:Yi,gfm:dg,pedantic:hg},Tr={normal:Zi,gfm:Qi,breaks:Cg,pedantic:$g},Pg={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ac=t=>Pg[t];function ft(t,e){if(e){if(Oe.escapeTest.test(t))return t.replace(Oe.escapeReplace,ac)}else if(Oe.escapeTestNoEncode.test(t))return t.replace(Oe.escapeReplaceNoEncode,ac);return t}function oc(t){try{t=encodeURI(t).replace(Oe.percentDecode,"%")}catch{return null}return t}function lc(t,e){let n=t.replace(Oe.findPipe,(i,a,o)=>{let l=!1,c=a;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Oe.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(Oe.slashPipe,"|");return r}function xr(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function Ng(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function cc(t,e,n,r,s){let i=e.href,a=e.title||null,o=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}function Lg(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
44
44
  `).map(i=>{let a=i.match(n.other.beginningSpace);if(a===null)return i;let[o]=a;return o.length>=s.length?i.slice(s.length):i}).join(`
45
- `)}var ws=class{options;rules;lexer;constructor(t){this.options=t||pn}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Tr(n,`
46
- `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=Ng(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Tr(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Tr(e[0],`
47
- `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Tr(e[0],`
45
+ `)}var Es=class{options;rules;lexer;constructor(t){this.options=t||gn}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:xr(n,`
46
+ `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=Lg(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=xr(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:xr(e[0],`
47
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=xr(e[0],`
48
48
  `).split(`
49
49
  `),r="",s="",i=[];for(;n.length>0;){let a=!1,o=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))o.push(n[l]),a=!0;else if(!a)o.push(n[l]);else break;n=n.slice(l);let c=o.join(`
50
50
  `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
51
51
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
52
52
  ${c}`:c,s=s?`${s}
53
- ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=d,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let f=h,g=f.raw+`
53
+ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=d,n.length===0)break;let h=i.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let f=h,m=f.raw+`
54
54
  `+n.join(`
55
- `),v=this.blockquote(g);i[i.length-1]=v,r=r.substring(0,r.length-f.raw.length)+v.raw,s=s.substring(0,s.length-f.text.length)+v.text;break}else if(h?.type==="list"){let f=h,g=f.raw+`
55
+ `),_=this.blockquote(m);i[i.length-1]=_,r=r.substring(0,r.length-f.raw.length)+_.raw,s=s.substring(0,s.length-f.text.length)+_.text;break}else if(h?.type==="list"){let f=h,m=f.raw+`
56
56
  `+n.join(`
57
- `),v=this.list(g);i[i.length-1]=v,r=r.substring(0,r.length-h.raw.length)+v.raw,s=s.substring(0,s.length-f.raw.length)+v.raw,n=g.substring(i.at(-1).raw.length).split(`
57
+ `),_=this.list(m);i[i.length-1]=_,r=r.substring(0,r.length-h.raw.length)+_.raw,s=s.substring(0,s.length-f.raw.length)+_.raw,n=m.substring(i.at(-1).raw.length).split(`
58
58
  `);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,c="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=e[2].split(`
59
59
  `,1)[0].replace(this.rules.other.listReplaceTabs,S=>" ".repeat(3*S.length)),h=t.split(`
60
- `,1)[0],f=!d.trim(),g=0;if(this.options.pedantic?(g=2,u=d.trimStart()):f?g=e[1].length+1:(g=e[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=d.slice(g),g+=e[1].length),f&&this.rules.other.blankLine.test(h)&&(c+=h+`
61
- `,t=t.substring(h.length+1),l=!0),!l){let S=this.rules.other.nextBulletRegex(g),p=this.rules.other.hrRegex(g),m=this.rules.other.fencesBeginRegex(g),y=this.rules.other.headingBeginRegex(g),E=this.rules.other.htmlBeginRegex(g);for(;t;){let b=t.split(`
62
- `,1)[0],k;if(h=b,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),k=h):k=h.replace(this.rules.other.tabCharGlobal," "),m.test(h)||y.test(h)||E.test(h)||S.test(h)||p.test(h))break;if(k.search(this.rules.other.nonSpaceChar)>=g||!h.trim())u+=`
63
- `+k.slice(g);else{if(f||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||m.test(d)||y.test(d)||p.test(d))break;u+=`
60
+ `,1)[0],f=!d.trim(),m=0;if(this.options.pedantic?(m=2,u=d.trimStart()):f?m=e[1].length+1:(m=e[2].search(this.rules.other.nonSpaceChar),m=m>4?1:m,u=d.slice(m),m+=e[1].length),f&&this.rules.other.blankLine.test(h)&&(c+=h+`
61
+ `,t=t.substring(h.length+1),l=!0),!l){let S=this.rules.other.nextBulletRegex(m),g=this.rules.other.hrRegex(m),p=this.rules.other.fencesBeginRegex(m),y=this.rules.other.headingBeginRegex(m),E=this.rules.other.htmlBeginRegex(m);for(;t;){let b=t.split(`
62
+ `,1)[0],k;if(h=b,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),k=h):k=h.replace(this.rules.other.tabCharGlobal," "),p.test(h)||y.test(h)||E.test(h)||S.test(h)||g.test(h))break;if(k.search(this.rules.other.nonSpaceChar)>=m||!h.trim())u+=`
63
+ `+k.slice(m);else{if(f||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||p.test(d)||y.test(d)||g.test(d))break;u+=`
64
64
  `+h}!f&&!h.trim()&&(f=!0),c+=b+`
65
- `,t=t.substring(b.length+1),d=k.slice(g)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0));let v=null,_;this.options.gfm&&(v=this.rules.other.listIsTask.exec(u),v&&(_=v[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:c,task:!!v,checked:_,loose:!1,text:u,tokens:[]}),s.raw+=c}let o=s.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let l=0;l<s.items.length;l++)if(this.lexer.state.top=!1,s.items[l].tokens=this.lexer.blockTokens(s.items[l].text,[]),!s.loose){let c=s.items[l].tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));s.loose=u}if(s.loose)for(let l=0;l<s.items.length;l++)s.items[l].loose=!0;return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=oc(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
66
- `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(oc(a,i.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
67
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Tr(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Pg(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),lc(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return lc(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,a,o=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let u=[...r[0]][0].length,d=t.slice(0,s+r.index+u+a);if(Math.min(s,a)%2){let f=d.slice(1,-1);return{type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},it=class Ha{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pn,this.options.tokenizer=this.options.tokenizer||new ws,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Oe,block:ys.normal,inline:Sr.normal};this.options.pedantic?(n.block=ys.pedantic,n.inline=Sr.pedantic):this.options.gfm&&(n.block=ys.gfm,this.options.breaks?n.inline=Sr.breaks:n.inline=Sr.gfm),this.tokenizer.rules=n}static get rules(){return{block:ys,inline:Sr}}static lex(e,n){return new Ha(n).lex(e)}static lexInline(e,n){return new Ha(n).inlineTokens(e)}lex(e){e=e.replace(Oe.carriageReturn,`
65
+ `,t=t.substring(b.length+1),d=k.slice(m)}}s.loose||(a?s.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0));let _=null,v;this.options.gfm&&(_=this.rules.other.listIsTask.exec(u),_&&(v=_[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:c,task:!!_,checked:v,loose:!1,text:u,tokens:[]}),s.raw+=c}let o=s.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let l=0;l<s.items.length;l++)if(this.lexer.state.top=!1,s.items[l].tokens=this.lexer.blockTokens(s.items[l].text,[]),!s.loose){let c=s.items[l].tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));s.loose=u}if(s.loose)for(let l=0;l<s.items.length;l++)s.items[l].loose=!0;return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=lc(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
66
+ `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<n.length;a++)i.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:i.align[a]});for(let a of s)i.rows.push(lc(a,i.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
67
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=xr(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Ng(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),cc(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return cc(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,i,a,o=s,l=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+s);(r=c.exec(e))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let u=[...r[0]][0].length,d=t.slice(0,s+r.index+u+a);if(Math.min(s,a)%2){let f=d.slice(1,-1);return{type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},st=class za{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||gn,this.options.tokenizer=this.options.tokenizer||new Es,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Oe,block:ws.normal,inline:Tr.normal};this.options.pedantic?(n.block=ws.pedantic,n.inline=Tr.pedantic):this.options.gfm&&(n.block=ws.gfm,this.options.breaks?n.inline=Tr.breaks:n.inline=Tr.gfm),this.tokenizer.rules=n}static get rules(){return{block:ws,inline:Tr}}static lex(e,n){return new za(n).lex(e)}static lexInline(e,n){return new za(n).inlineTokens(e)}lex(e){e=e.replace(Oe.carriageReturn,`
68
68
  `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.options.pedantic&&(e=e.replace(Oe.tabCharGlobal," ").replace(Oe.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(a=>(s=a.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let a=n.at(-1);s.raw.length===1&&a!==void 0?a.raw+=`
69
69
  `:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
70
70
  `)?"":`
@@ -78,16 +78,16 @@ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
78
78
  `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
79
79
  `)?"":`
80
80
  `)+s.raw,a.text+=`
81
- `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r=e,s=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let a=!1,o="";for(;e;){a||(o=""),a=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let u=n.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,r,o)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,d=e.slice(1),h;this.options.extensions.startInline.forEach(f=>{h=f.call({lexer:this},d),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(o=l.raw.slice(-1)),a=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},Es=class{options;parser;constructor(t){this.options=t||pn}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(Oe.notSpaceStart)?.[0],s=t.replace(Oe.endingNewline,"")+`
82
- `;return r?'<pre><code class="language-'+pt(r)+'">'+(n?s:pt(s,!0))+`</code></pre>
83
- `:"<pre><code>"+(n?s:pt(s,!0))+`</code></pre>
81
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r=e,s=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let a=!1,o="";for(;e;){a||(o=""),a=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let u=n.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,r,o)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,d=e.slice(1),h;this.options.extensions.startInline.forEach(f=>{h=f.call({lexer:this},d),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(o=l.raw.slice(-1)),a=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):n.push(l);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return n}},ks=class{options;parser;constructor(t){this.options=t||gn}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(Oe.notSpaceStart)?.[0],s=t.replace(Oe.endingNewline,"")+`
82
+ `;return r?'<pre><code class="language-'+ft(r)+'">'+(n?s:ft(s,!0))+`</code></pre>
83
+ `:"<pre><code>"+(n?s:ft(s,!0))+`</code></pre>
84
84
  `}blockquote({tokens:t}){return`<blockquote>
85
85
  ${this.parser.parse(t)}</blockquote>
86
86
  `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
87
87
  `}hr(t){return`<hr>
88
88
  `}list(t){let e=t.ordered,n=t.start,r="";for(let a=0;a<t.items.length;a++){let o=t.items[a];r+=this.listitem(o)}let s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
89
89
  `+r+"</"+s+`>
90
- `}listitem(t){let e="";if(t.task){let n=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=n+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=n+" "+pt(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):e+=n+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
90
+ `}listitem(t){let e="";if(t.task){let n=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=n+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=n+" "+ft(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):e+=n+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
91
91
  `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
92
92
  `}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let a=0;a<i.length;a++)n+=this.tablecell(i[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
93
93
  <thead>
@@ -96,32 +96,32 @@ ${this.parser.parse(t)}</blockquote>
96
96
  `}tablerow({text:t}){return`<tr>
97
97
  ${t}</tr>
98
98
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
99
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${pt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=ac(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+pt(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ac(t);if(s===null)return pt(n);t=s;let i=`<img src="${t}" alt="${n}"`;return e&&(i+=` title="${pt(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:pt(t.text)}},Qi=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},at=class za{options;renderer;textRenderer;constructor(e){this.options=e||pn,this.options.renderer=this.options.renderer||new Es,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Qi}static parse(e,n){return new za(n).parse(e)}static parseInline(e,n){return new za(n).parseInline(e)}parse(e,n=!0){let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){r+=l||"";continue}}let a=i;switch(a.type){case"space":{r+=this.renderer.space(a);continue}case"hr":{r+=this.renderer.hr(a);continue}case"heading":{r+=this.renderer.heading(a);continue}case"code":{r+=this.renderer.code(a);continue}case"table":{r+=this.renderer.table(a);continue}case"blockquote":{r+=this.renderer.blockquote(a);continue}case"list":{r+=this.renderer.list(a);continue}case"html":{r+=this.renderer.html(a);continue}case"def":{r+=this.renderer.def(a);continue}case"paragraph":{r+=this.renderer.paragraph(a);continue}case"text":{let o=a,l=this.renderer.text(o);for(;s+1<e.length&&e[s+1].type==="text";)o=e[++s],l+=`
100
- `+this.renderer.text(o);n?r+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):r+=l;continue}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,n=this.renderer){let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=o||"";continue}}let a=i;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}},xr=class{options;block;constructor(t){this.options=t||pn}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?it.lex:it.lexInline}provideParser(){return this.block?at.parse:at.parseInline}},Lg=class{defaults=zi();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=at;Renderer=Es;TextRenderer=Qi;Lexer=it;Tokenizer=ws;Hooks=xr;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let s=r;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let a=s[i].flat(1/0);n=n.concat(this.walkTokens(a,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...a){let o=s.renderer.apply(this,a);return o===!1&&(o=i.apply(this,a)),o}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new Es(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,o=n.renderer[a],l=s[a];s[a]=(...c)=>{let u=o.apply(s,c);return u===!1&&(u=l.apply(s,c)),u||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ws(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,o=n.tokenizer[a],l=s[a];s[a]=(...c)=>{let u=o.apply(s,c);return u===!1&&(u=l.apply(s,c)),u}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new xr;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,o=n.hooks[a],l=s[a];xr.passThroughHooks.has(i)?s[a]=c=>{if(this.defaults.async&&xr.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await o.call(s,c);return l.call(s,d)})();let u=o.call(s,c);return l.call(s,u)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(s,c);return d===!1&&(d=await l.apply(s,c)),d})();let u=o.apply(s,c);return u===!1&&(u=l.apply(s,c)),u}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(a){let o=[];return o.push(i.call(this,a)),s&&(o=o.concat(s.call(this,a))),o}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return it.lex(t,e??this.defaults)}parser(t,e){return at.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(e):e,o=await(s.hooks?await s.hooks.provideLexer():t?it.lex:it.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(o):o;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?at.parse:at.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let a=(s.hooks?s.hooks.provideLexer():t?it.lex:it.lexInline)(e,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let o=(s.hooks?s.hooks.provideParser():t?at.parse:at.parseInline)(a,s);return s.hooks&&(o=s.hooks.postprocess(o)),o}catch(a){return i(a)}}}onError(t,e){return n=>{if(n.message+=`
101
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+pt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},gn=new Lg;function z(t,e){return gn.parse(t,e)}z.options=z.setOptions=function(t){return gn.setOptions(t),z.defaults=gn.defaults,Gl(z.defaults),z},z.getDefaults=zi,z.defaults=pn,z.use=function(...t){return gn.use(...t),z.defaults=gn.defaults,Gl(z.defaults),z},z.walkTokens=function(t,e){return gn.walkTokens(t,e)},z.parseInline=gn.parseInline,z.Parser=at,z.parser=at.parse,z.Renderer=Es,z.TextRenderer=Qi,z.Lexer=it,z.lexer=it.lex,z.Tokenizer=ws,z.Hooks=xr,z.parse=z,z.options,z.setOptions,z.use,z.walkTokens,z.parseInline,at.parse,it.lex;const D=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Q=globalThis,mn="9.47.1";function ks(){return Ss(Q),Q}function Ss(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||mn,e[mn]=e[mn]||{}}function Ar(t,e,n=Q){const r=n.__SENTRY__=n.__SENTRY__||{},s=r[mn]=r[mn]||{};return s[t]||(s[t]=e())}const jg=["debug","info","warn","error","log","assert","trace"],Dg="Sentry Logger ",Ts={};function Zn(t){if(!("console"in Q))return t();const e=Q.console,n={},r=Object.keys(Ts);r.forEach(s=>{const i=Ts[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function Ug(){ta().enabled=!0}function Fg(){ta().enabled=!1}function cc(){return ta().enabled}function Mg(...t){ea("log",...t)}function Bg(...t){ea("warn",...t)}function qg(...t){ea("error",...t)}function ea(t,...e){D&&cc()&&Zn(()=>{Q.console[t](`${Dg}[${t}]:`,...e)})}function ta(){return D?Ar("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const P={enable:Ug,disable:Fg,isEnabled:cc,log:Mg,warn:Bg,error:qg},uc=50,_n="?",dc=/\(error: (.*)\)/,hc=/captureMessage|captureException/;function fc(...t){const e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,s=0)=>{const i=[],a=n.split(`
102
- `);for(let o=r;o<a.length;o++){const l=a[o];if(l.length>1024)continue;const c=dc.test(l)?l.replace(dc,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){i.push(d);break}}if(i.length>=uc+s)break}}return zg(i.slice(s))}}function Hg(t){return Array.isArray(t)?fc(...t):t}function zg(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(xs(e).function||"")&&e.pop(),e.reverse(),hc.test(xs(e).function||"")&&(e.pop(),hc.test(xs(e).function||"")&&e.pop()),e.slice(0,uc).map(n=>({...n,filename:n.filename||xs(e).filename,function:n.function||_n}))}function xs(t){return t[t.length-1]||{}}const na="<anonymous>";function Ht(t){try{return!t||typeof t!="function"?na:t.name||na}catch{return na}}function pc(t){const e=t.exception;if(e){const n=[];try{return e.values.forEach(r=>{r.stacktrace.frames&&n.push(...r.stacktrace.frames)}),n}catch{return}}}const As={},gc={};function vn(t,e){As[t]=As[t]||[],As[t].push(e)}function bn(t,e){if(!gc[t]){gc[t]=!0;try{e()}catch(n){D&&P.error(`Error while instrumenting ${t}`,n)}}}function ot(t,e){const n=t&&As[t];if(n)for(const r of n)try{r(e)}catch(s){D&&P.error(`Error while triggering instrumentation handler.
99
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${ft(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=oc(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+ft(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=oc(t);if(s===null)return ft(n);t=s;let i=`<img src="${t}" alt="${n}"`;return e&&(i+=` title="${ft(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:ft(t.text)}},ea=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},it=class Wa{options;renderer;textRenderer;constructor(e){this.options=e||gn,this.options.renderer=this.options.renderer||new ks,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ea}static parse(e,n){return new Wa(n).parse(e)}static parseInline(e,n){return new Wa(n).parseInline(e)}parse(e,n=!0){let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){r+=l||"";continue}}let a=i;switch(a.type){case"space":{r+=this.renderer.space(a);continue}case"hr":{r+=this.renderer.hr(a);continue}case"heading":{r+=this.renderer.heading(a);continue}case"code":{r+=this.renderer.code(a);continue}case"table":{r+=this.renderer.table(a);continue}case"blockquote":{r+=this.renderer.blockquote(a);continue}case"list":{r+=this.renderer.list(a);continue}case"html":{r+=this.renderer.html(a);continue}case"def":{r+=this.renderer.def(a);continue}case"paragraph":{r+=this.renderer.paragraph(a);continue}case"text":{let o=a,l=this.renderer.text(o);for(;s+1<e.length&&e[s+1].type==="text";)o=e[++s],l+=`
100
+ `+this.renderer.text(o);n?r+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):r+=l;continue}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,n=this.renderer){let r="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=o||"";continue}}let a=i;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}},Ar=class{options;block;constructor(t){this.options=t||gn}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?st.lex:st.lexInline}provideParser(){return this.block?it.parse:it.parseInline}},jg=class{defaults=Wi();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=it;Renderer=ks;TextRenderer=ea;Lexer=st;Tokenizer=Es;Hooks=Ar;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let s=r;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let a=s[i].flat(1/0);n=n.concat(this.walkTokens(a,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...a){let o=s.renderer.apply(this,a);return o===!1&&(o=i.apply(this,a)),o}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new ks(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,o=n.renderer[a],l=s[a];s[a]=(...c)=>{let u=o.apply(s,c);return u===!1&&(u=l.apply(s,c)),u||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Es(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,o=n.tokenizer[a],l=s[a];s[a]=(...c)=>{let u=o.apply(s,c);return u===!1&&(u=l.apply(s,c)),u}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Ar;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,o=n.hooks[a],l=s[a];Ar.passThroughHooks.has(i)?s[a]=c=>{if(this.defaults.async&&Ar.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await o.call(s,c);return l.call(s,d)})();let u=o.call(s,c);return l.call(s,u)}:s[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(s,c);return d===!1&&(d=await l.apply(s,c)),d})();let u=o.apply(s,c);return u===!1&&(u=l.apply(s,c)),u}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(a){let o=[];return o.push(i.call(this,a)),s&&(o=o.concat(s.call(this,a))),o}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return st.lex(t,e??this.defaults)}parser(t,e){return it.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let a=s.hooks?await s.hooks.preprocess(e):e,o=await(s.hooks?await s.hooks.provideLexer():t?st.lex:st.lexInline)(a,s),l=s.hooks?await s.hooks.processAllTokens(o):o;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():t?it.parse:it.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let a=(s.hooks?s.hooks.provideLexer():t?st.lex:st.lexInline)(e,s);s.hooks&&(a=s.hooks.processAllTokens(a)),s.walkTokens&&this.walkTokens(a,s.walkTokens);let o=(s.hooks?s.hooks.provideParser():t?it.parse:it.parseInline)(a,s);return s.hooks&&(o=s.hooks.postprocess(o)),o}catch(a){return i(a)}}}onError(t,e){return n=>{if(n.message+=`
101
+ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+ft(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},mn=new jg;function z(t,e){return mn.parse(t,e)}z.options=z.setOptions=function(t){return mn.setOptions(t),z.defaults=mn.defaults,Kl(z.defaults),z},z.getDefaults=Wi,z.defaults=gn,z.use=function(...t){return mn.use(...t),z.defaults=mn.defaults,Kl(z.defaults),z},z.walkTokens=function(t,e){return mn.walkTokens(t,e)},z.parseInline=mn.parseInline,z.Parser=it,z.parser=it.parse,z.Renderer=ks,z.TextRenderer=ea,z.Lexer=st,z.lexer=st.lex,z.Tokenizer=Es,z.Hooks=Ar,z.parse=z,z.options,z.setOptions,z.use,z.walkTokens,z.parseInline,it.parse,st.lex;const D=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Q=globalThis,_n="9.47.1";function Ss(){return Ts(Q),Q}function Ts(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||_n,e[_n]=e[_n]||{}}function Rr(t,e,n=Q){const r=n.__SENTRY__=n.__SENTRY__||{},s=r[_n]=r[_n]||{};return s[t]||(s[t]=e())}const Dg=["debug","info","warn","error","log","assert","trace"],Ug="Sentry Logger ",xs={};function Qn(t){if(!("console"in Q))return t();const e=Q.console,n={},r=Object.keys(xs);r.forEach(s=>{const i=xs[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function Fg(){na().enabled=!0}function Mg(){na().enabled=!1}function uc(){return na().enabled}function Bg(...t){ta("log",...t)}function qg(...t){ta("warn",...t)}function Hg(...t){ta("error",...t)}function ta(t,...e){D&&uc()&&Qn(()=>{Q.console[t](`${Ug}[${t}]:`,...e)})}function na(){return D?Rr("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const C={enable:Fg,disable:Mg,isEnabled:uc,log:Bg,warn:qg,error:Hg},dc=50,vn="?",hc=/\(error: (.*)\)/,fc=/captureMessage|captureException/;function pc(...t){const e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,s=0)=>{const i=[],a=n.split(`
102
+ `);for(let o=r;o<a.length;o++){const l=a[o];if(l.length>1024)continue;const c=hc.test(l)?l.replace(hc,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){i.push(d);break}}if(i.length>=dc+s)break}}return Wg(i.slice(s))}}function zg(t){return Array.isArray(t)?pc(...t):t}function Wg(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(As(e).function||"")&&e.pop(),e.reverse(),fc.test(As(e).function||"")&&(e.pop(),fc.test(As(e).function||"")&&e.pop()),e.slice(0,dc).map(n=>({...n,filename:n.filename||As(e).filename,function:n.function||vn}))}function As(t){return t[t.length-1]||{}}const ra="<anonymous>";function Ht(t){try{return!t||typeof t!="function"?ra:t.name||ra}catch{return ra}}function gc(t){const e=t.exception;if(e){const n=[];try{return e.values.forEach(r=>{r.stacktrace.frames&&n.push(...r.stacktrace.frames)}),n}catch{return}}}const Rs={},mc={};function bn(t,e){Rs[t]=Rs[t]||[],Rs[t].push(e)}function yn(t,e){if(!mc[t]){mc[t]=!0;try{e()}catch(n){D&&C.error(`Error while instrumenting ${t}`,n)}}}function at(t,e){const n=t&&Rs[t];if(n)for(const r of n)try{r(e)}catch(s){D&&C.error(`Error while triggering instrumentation handler.
103
103
  Type: ${t}
104
104
  Name: ${Ht(r)}
105
- Error:`,s)}}let ra=null;function Wg(t){const e="error";vn(e,t),bn(e,Gg)}function Gg(){ra=Q.onerror,Q.onerror=function(t,e,n,r,s){return ot("error",{column:r,error:s,line:n,msg:t,url:e}),ra?ra.apply(this,arguments):!1},Q.onerror.__SENTRY_INSTRUMENTED__=!0}let sa=null;function Kg(t){const e="unhandledrejection";vn(e,t),bn(e,Vg)}function Vg(){sa=Q.onunhandledrejection,Q.onunhandledrejection=function(t){return ot("unhandledrejection",t),sa?sa.apply(this,arguments):!0},Q.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const mc=Object.prototype.toString;function ia(t){switch(mc.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return zt(t,Error)}}function Qn(t,e){return mc.call(t)===`[object ${e}]`}function _c(t){return Qn(t,"ErrorEvent")}function vc(t){return Qn(t,"DOMError")}function Jg(t){return Qn(t,"DOMException")}function Ot(t){return Qn(t,"String")}function aa(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function oa(t){return t===null||aa(t)||typeof t!="object"&&typeof t!="function"}function Or(t){return Qn(t,"Object")}function Os(t){return typeof Event<"u"&&zt(t,Event)}function Yg(t){return typeof Element<"u"&&zt(t,Element)}function Xg(t){return Qn(t,"RegExp")}function Rs(t){return!!(t?.then&&typeof t.then=="function")}function Zg(t){return Or(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function zt(t,e){try{return t instanceof e}catch{return!1}}function bc(t){return!!(typeof t=="object"&&t!==null&&(t.__isVue||t._isVue))}function Qg(t){return typeof Request<"u"&&zt(t,Request)}const la=Q,em=80;function yc(t,e={}){if(!t)return"<unknown>";try{let n=t;const r=5,s=[];let i=0,a=0;const o=" > ",l=o.length;let c;const u=Array.isArray(e)?e:e.keyAttrs,d=!Array.isArray(e)&&e.maxStringLength||em;for(;n&&i++<r&&(c=tm(n,u),!(c==="html"||i>1&&a+s.length*l+c.length>=d));)s.push(c),a+=c.length,n=n.parentNode;return s.reverse().join(o)}catch{return"<unknown>"}}function tm(t,e){const n=t,r=[];if(!n?.tagName)return"";if(la.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());const s=e?.length?e.filter(a=>n.getAttribute(a)).map(a=>[a,n.getAttribute(a)]):null;if(s?.length)s.forEach(a=>{r.push(`[${a[0]}="${a[1]}"]`)});else{n.id&&r.push(`#${n.id}`);const a=n.className;if(a&&Ot(a)){const o=a.split(/\s+/);for(const l of o)r.push(`.${l}`)}}const i=["aria-label","type","name","title","alt"];for(const a of i){const o=n.getAttribute(a);o&&r.push(`[${a}="${o}"]`)}return r.join("")}function ca(){try{return la.document.location.href}catch{return""}}function nm(t){if(!la.HTMLElement)return null;let e=t;const n=5;for(let r=0;r<n;r++){if(!e)return null;if(e instanceof HTMLElement){if(e.dataset.sentryComponent)return e.dataset.sentryComponent;if(e.dataset.sentryElement)return e.dataset.sentryElement}e=e.parentNode}return null}function Is(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function wc(t,e){if(!Array.isArray(t))return"";const n=[];for(let r=0;r<t.length;r++){const s=t[r];try{bc(s)?n.push("[VueViewModel]"):n.push(String(s))}catch{n.push("[value cannot be serialized]")}}return n.join(e)}function rm(t,e,n=!1){return Ot(t)?Xg(e)?e.test(t):Ot(e)?n?t===e:t.includes(e):!1:!1}function $s(t,e=[],n=!1){return e.some(r=>rm(t,r,n))}function ze(t,e,n){if(!(e in t))return;const r=t[e];if(typeof r!="function")return;const s=n(r);typeof s=="function"&&Ec(s,r);try{t[e]=s}catch{D&&P.log(`Failed to replace method "${e}" in object`,t)}}function yn(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{D&&P.log(`Failed to add non-enumerable property "${e}" to object`,t)}}function Ec(t,e){try{const n=e.prototype||{};t.prototype=e.prototype=n,yn(t,"__sentry_original__",e)}catch{}}function ua(t){return t.__sentry_original__}function kc(t){if(ia(t))return{message:t.message,name:t.name,stack:t.stack,...Tc(t)};if(Os(t)){const e={type:t.type,target:Sc(t.target),currentTarget:Sc(t.currentTarget),...Tc(t)};return typeof CustomEvent<"u"&&zt(t,CustomEvent)&&(e.detail=t.detail),e}else return t}function Sc(t){try{return Yg(t)?yc(t):Object.prototype.toString.call(t)}catch{return"<unknown>"}}function Tc(t){if(typeof t=="object"&&t!==null){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}else return{}}function sm(t,e=40){const n=Object.keys(kc(t));n.sort();const r=n[0];if(!r)return"[object has no keys]";if(r.length>=e)return Is(r,e);for(let s=n.length;s>0;s--){const i=n.slice(0,s).join(", ");if(!(i.length>e))return s===n.length?i:Is(i,e)}return""}function im(){const t=Q;return t.crypto||t.msCrypto}function Je(t=im()){let e=()=>Math.random()*16;try{if(t?.randomUUID)return t.randomUUID().replace(/-/g,"");t?.getRandomValues&&(e=()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]})}catch{}return("10000000100040008000"+1e11).replace(/[018]/g,n=>(n^(e()&15)>>n/4).toString(16))}function xc(t){return t.exception?.values?.[0]}function wn(t){const{message:e,event_id:n}=t;if(e)return e;const r=xc(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function da(t,e,n){const r=t.exception=t.exception||{},s=r.values=r.values||[],i=s[0]=s[0]||{};i.value||(i.value=e||""),i.type||(i.type="Error")}function er(t,e){const n=xc(t);if(!n)return;const r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism={...r,...s,...e},e&&"data"in e){const i={...s?.data,...e.data};n.mechanism.data=i}}function Ac(t){if(am(t))return!0;try{yn(t,"__sentry_captured__",!0)}catch{}return!1}function am(t){try{return t.__sentry_captured__}catch{}}const Oc=1e3;function Rr(){return Date.now()/Oc}function om(){const{performance:t}=Q;if(!t?.now||!t.timeOrigin)return Rr;const e=t.timeOrigin;return()=>(e+t.now())/Oc}let Rc;function Rt(){return(Rc??(Rc=om()))()}function lm(t){const e=Rt(),n={sid:Je(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>um(n)};return t&&tr(n,t),n}function tr(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Rt(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:Je()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function cm(t,e){let n={};t.status==="ok"&&(n={status:"exited"}),tr(t,n)}function um(t){return{sid:`${t.sid}`,init:t.init,started:new Date(t.started*1e3).toISOString(),timestamp:new Date(t.timestamp*1e3).toISOString(),status:t.status,errors:t.errors,did:typeof t.did=="number"||typeof t.did=="string"?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}}}function Ir(t,e,n=2){if(!e||typeof e!="object"||n<=0)return e;if(t&&Object.keys(e).length===0)return t;const r={...t};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=Ir(r[s],e[s],n-1));return r}function Ic(){return Je()}function $c(){return Je().substring(16)}const ha="_sentrySpan";function Cc(t,e){e?yn(t,ha,e):delete t[ha]}function Pc(t){return t[ha]}const dm=100;class gt{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:Ic(),sampleRand:Math.random()}}clone(){const e=new gt;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,Cc(e,Pc(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&tr(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,n){return this._tags={...this._tags,[e]:n},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,n){return this._extra={...this._extra,[e]:n},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,n){return n===null?delete this._contexts[e]:this._contexts[e]=n,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const n=typeof e=="function"?e(this):e,r=n instanceof gt?n.getScopeData():Or(n)?e:void 0,{tags:s,extra:i,user:a,contexts:o,level:l,fingerprint:c=[],propagationContext:u}=r||{};return this._tags={...this._tags,...s},this._extra={...this._extra,...i},this._contexts={...this._contexts,...o},a&&Object.keys(a).length&&(this._user=a),l&&(this._level=l),c.length&&(this._fingerprint=c),u&&(this._propagationContext=u),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,Cc(this,void 0),this._attachments=[],this.setPropagationContext({traceId:Ic(),sampleRand:Math.random()}),this._notifyScopeListeners(),this}addBreadcrumb(e,n){const r=typeof n=="number"?n:dm;if(r<=0)return this;const s={timestamp:Rr(),...e,message:e.message?Is(e.message,2048):e.message};return this._breadcrumbs.push(s),this._breadcrumbs.length>r&&(this._breadcrumbs=this._breadcrumbs.slice(-r),this._client?.recordDroppedEvent("buffer_overflow","log_item")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:Pc(this)}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Ir(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){const r=n?.event_id||Je();if(!this._client)return D&&P.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:s,...n,event_id:r},this),r}captureMessage(e,n,r){const s=r?.event_id||Je();if(!this._client)return D&&P.warn("No client configured on scope - will not capture message!"),s;const i=new Error(e);return this._client.captureMessage(e,n,{originalException:e,syntheticException:i,...r,event_id:s},this),s}captureEvent(e,n){const r=n?.event_id||Je();return this._client?(this._client.captureEvent(e,{...n,event_id:r},this),r):(D&&P.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}function hm(){return Ar("defaultCurrentScope",()=>new gt)}function fm(){return Ar("defaultIsolationScope",()=>new gt)}class pm{constructor(e,n){let r;e?r=e:r=new gt;let s;n?s=n:s=new gt,this._stack=[{scope:r}],this._isolationScope=s}withScope(e){const n=this._pushScope();let r;try{r=e(n)}catch(s){throw this._popScope(),s}return Rs(r)?r.then(s=>(this._popScope(),s),s=>{throw this._popScope(),s}):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}}function nr(){const t=ks(),e=Ss(t);return e.stack=e.stack||new pm(hm(),fm())}function gm(t){return nr().withScope(t)}function mm(t,e){const n=nr();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function Nc(t){return nr().withScope(()=>t(nr().getIsolationScope()))}function _m(){return{withIsolationScope:Nc,withScope:gm,withSetScope:mm,withSetIsolationScope:(t,e)=>Nc(e),getCurrentScope:()=>nr().getScope(),getIsolationScope:()=>nr().getIsolationScope()}}function fa(t){const e=Ss(t);return e.acs?e.acs:_m()}function Wt(){const t=ks();return fa(t).getCurrentScope()}function $r(){const t=ks();return fa(t).getIsolationScope()}function vm(){return Ar("globalScope",()=>new gt)}function bm(...t){const e=ks(),n=fa(e);if(t.length===2){const[r,s]=t;return r?n.withSetScope(r,s):n.withScope(s)}return n.withScope(t[0])}function Re(){return Wt().getClient()}function ym(t){const e=t.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:s}=e,i={trace_id:n,span_id:s||$c()};return r&&(i.parent_span_id=r),i}const wm="sentry.source",Em="sentry.sample_rate",km="sentry.previous_trace_sample_rate",Sm="sentry.op",Tm="sentry.origin",Lc="sentry.profile_id",jc="sentry.exclusive_time",xm=0,Am=1,Om="_sentryScope",Rm="_sentryIsolationScope";function Dc(t){return{scope:t[Om],isolationScope:t[Rm]}}const Im="sentry-",$m=/^sentry-/;function Cm(t){const e=Pm(t);if(!e)return;const n=Object.entries(e).reduce((r,[s,i])=>{if(s.match($m)){const a=s.slice(Im.length);r[a]=i}return r},{});if(Object.keys(n).length>0)return n}function Pm(t){if(!(!t||!Ot(t)&&!Array.isArray(t)))return Array.isArray(t)?t.reduce((e,n)=>{const r=Uc(n);return Object.entries(r).forEach(([s,i])=>{e[s]=i}),e},{}):Uc(t)}function Uc(t){return t.split(",").map(e=>e.split("=").map(n=>{try{return decodeURIComponent(n.trim())}catch{return}})).reduce((e,[n,r])=>(n&&r&&(e[n]=r),e),{})}function Nm(t){if(typeof t=="boolean")return Number(t);const e=typeof t=="string"?parseFloat(t):t;if(!(typeof e!="number"||isNaN(e)||e<0||e>1))return e}const Fc=1;let Mc=!1;function Lm(t){const{spanId:e,traceId:n,isRemote:r}=t.spanContext(),s=r?e:pa(t).parent_span_id,i=Dc(t).scope,a=r?i?.getPropagationContext().propagationSpanId||$c():e;return{parent_span_id:s,span_id:a,trace_id:n}}function jm(t){if(t&&t.length>0)return t.map(({context:{spanId:e,traceId:n,traceFlags:r,...s},attributes:i})=>({span_id:e,trace_id:n,sampled:r===Fc,attributes:i,...s}))}function Bc(t){return typeof t=="number"?qc(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?qc(t.getTime()):Rt()}function qc(t){return t>9999999999?t/1e3:t}function pa(t){if(Um(t))return t.getSpanJSON();const{spanId:e,traceId:n}=t.spanContext();if(Dm(t)){const{attributes:r,startTime:s,name:i,endTime:a,status:o,links:l}=t,c="parentSpanId"in t?t.parentSpanId:"parentSpanContext"in t?t.parentSpanContext?.spanId:void 0;return{span_id:e,trace_id:n,data:r,description:i,parent_span_id:c,start_timestamp:Bc(s),timestamp:Bc(a)||void 0,status:Mm(o),op:r[Sm],origin:r[Tm],links:jm(l)}}return{span_id:e,trace_id:n,start_timestamp:0,data:{}}}function Dm(t){const e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function Um(t){return typeof t.getSpanJSON=="function"}function Fm(t){const{traceFlags:e}=t.spanContext();return e===Fc}function Mm(t){if(!(!t||t.code===xm))return t.code===Am?"ok":t.message||"unknown_error"}const Bm="_sentryRootSpan";function Hc(t){return t[Bm]||t}function zc(){Mc||(Zn(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly.")}),Mc=!0)}function qm(t){if(typeof __SENTRY_TRACING__=="boolean"&&!__SENTRY_TRACING__)return!1;const e=t||Re()?.getOptions();return!!e&&(e.tracesSampleRate!=null||!!e.tracesSampler)}const ga="production",Hm=/^o(\d+)\./,zm=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function Wm(t){return t==="http"||t==="https"}function Cs(t,e=!1){const{host:n,path:r,pass:s,port:i,projectId:a,protocol:o,publicKey:l}=t;return`${o}://${l}${e&&s?`:${s}`:""}@${n}${i?`:${i}`:""}/${r&&`${r}/`}${a}`}function Gm(t){const e=zm.exec(t);if(!e){Zn(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}const[n,r,s="",i="",a="",o=""]=e.slice(1);let l="",c=o;const u=c.split("/");if(u.length>1&&(l=u.slice(0,-1).join("/"),c=u.pop()),c){const d=c.match(/^\d+/);d&&(c=d[0])}return Wc({host:i,pass:s,path:l,projectId:c,port:a,protocol:n,publicKey:r})}function Wc(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function Km(t){if(!D)return!0;const{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(a=>t[a]?!1:(P.error(`Invalid Sentry Dsn: ${a} missing`),!0))?!1:n.match(/^\d+$/)?Wm(r)?e&&isNaN(parseInt(e,10))?(P.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(P.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(P.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function Vm(t){return t.match(Hm)?.[1]}function Jm(t){const e=typeof t=="string"?Gm(t):Wc(t);if(!(!e||!Km(e)))return e}const Ym="_frozenDsc";function Gc(t,e){const n=e.getOptions(),{publicKey:r,host:s}=e.getDsn()||{};let i;n.orgId?i=String(n.orgId):s&&(i=Vm(s));const a={environment:n.environment||ga,release:n.release,public_key:r,trace_id:t,org_id:i};return e.emit("createDsc",a),a}function Xm(t,e){const n=e.getPropagationContext();return n.dsc||Gc(n.traceId,t)}function Zm(t){const e=Re();if(!e)return{};const n=Hc(t),r=pa(n),s=r.data,i=n.spanContext().traceState,a=i?.get("sentry.sample_rate")??s[Em]??s[km];function o(g){return(typeof a=="number"||typeof a=="string")&&(g.sample_rate=`${a}`),g}const l=n[Ym];if(l)return o(l);const c=i?.get("sentry.dsc"),u=c&&Cm(c);if(u)return o(u);const d=Gc(t.spanContext().traceId,e),h=s[wm],f=r.description;return h!=="url"&&f&&(d.transaction=f),qm()&&(d.sampled=String(Fm(n)),d.sample_rand=i?.get("sentry.sample_rand")??Dc(n).scope?.getPropagationContext().sampleRand.toString()),o(d),e.emit("createDsc",d,n),d}function It(t,e=100,n=1/0){try{return ma("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function Kc(t,e=3,n=100*1024){const r=It(t,e);return n_(r)>n?Kc(t,e-1,n):r}function ma(t,e,n=1/0,r=1/0,s=r_()){const[i,a]=s;if(e==null||["boolean","string"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e))return e;const o=Qm(t,e);if(!o.startsWith("[object "))return o;if(e.__sentry_skip_normalization__)return e;const l=typeof e.__sentry_override_normalization_depth__=="number"?e.__sentry_override_normalization_depth__:n;if(l===0)return o.replace("object ","");if(i(e))return"[Circular ~]";const c=e;if(c&&typeof c.toJSON=="function")try{const f=c.toJSON();return ma("",f,l-1,r,s)}catch{}const u=Array.isArray(e)?[]:{};let d=0;const h=kc(e);for(const f in h){if(!Object.prototype.hasOwnProperty.call(h,f))continue;if(d>=r){u[f]="[MaxProperties ~]";break}const g=h[f];u[f]=ma(f,g,l-1,r,s),d++}return a(e),u}function Qm(t,e){try{if(t==="domain"&&e&&typeof e=="object"&&e._events)return"[Domain]";if(t==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&e===global)return"[Global]";if(typeof window<"u"&&e===window)return"[Window]";if(typeof document<"u"&&e===document)return"[Document]";if(bc(e))return"[VueViewModel]";if(Zg(e))return"[SyntheticEvent]";if(typeof e=="number"&&!Number.isFinite(e))return`[${e}]`;if(typeof e=="function")return`[Function: ${Ht(e)}]`;if(typeof e=="symbol")return`[${String(e)}]`;if(typeof e=="bigint")return`[BigInt: ${String(e)}]`;const n=e_(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(n){return`**non-serializable** (${n})`}}function e_(t){const e=Object.getPrototypeOf(t);return e?.constructor?e.constructor.name:"null prototype"}function t_(t){return~-encodeURI(t).split(/%..|./).length}function n_(t){return t_(JSON.stringify(t))}function r_(){const t=new WeakSet;function e(r){return t.has(r)?!0:(t.add(r),!1)}function n(r){t.delete(r)}return[e,n]}function Cr(t,e=[]){return[t,e]}function s_(t,e){const[n,r]=t;return[n,[...r,e]]}function Vc(t,e){const n=t[1];for(const r of n){const s=r[0].type;if(e(r,s))return!0}return!1}function _a(t){const e=Ss(Q);return e.encodePolyfill?e.encodePolyfill(t):new TextEncoder().encode(t)}function i_(t){const[e,n]=t;let r=JSON.stringify(e);function s(i){typeof r=="string"?r=typeof i=="string"?r+i:[_a(r),i]:r.push(typeof i=="string"?_a(i):i)}for(const i of n){const[a,o]=i;if(s(`
105
+ Error:`,s)}}let sa=null;function Gg(t){const e="error";bn(e,t),yn(e,Kg)}function Kg(){sa=Q.onerror,Q.onerror=function(t,e,n,r,s){return at("error",{column:r,error:s,line:n,msg:t,url:e}),sa?sa.apply(this,arguments):!1},Q.onerror.__SENTRY_INSTRUMENTED__=!0}let ia=null;function Vg(t){const e="unhandledrejection";bn(e,t),yn(e,Jg)}function Jg(){ia=Q.onunhandledrejection,Q.onunhandledrejection=function(t){return at("unhandledrejection",t),ia?ia.apply(this,arguments):!0},Q.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const _c=Object.prototype.toString;function aa(t){switch(_c.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return zt(t,Error)}}function er(t,e){return _c.call(t)===`[object ${e}]`}function vc(t){return er(t,"ErrorEvent")}function bc(t){return er(t,"DOMError")}function Yg(t){return er(t,"DOMException")}function At(t){return er(t,"String")}function oa(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function la(t){return t===null||oa(t)||typeof t!="object"&&typeof t!="function"}function Or(t){return er(t,"Object")}function Os(t){return typeof Event<"u"&&zt(t,Event)}function Xg(t){return typeof Element<"u"&&zt(t,Element)}function Zg(t){return er(t,"RegExp")}function Is(t){return!!(t?.then&&typeof t.then=="function")}function Qg(t){return Or(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function zt(t,e){try{return t instanceof e}catch{return!1}}function yc(t){return!!(typeof t=="object"&&t!==null&&(t.__isVue||t._isVue))}function em(t){return typeof Request<"u"&&zt(t,Request)}const ca=Q,tm=80;function wc(t,e={}){if(!t)return"<unknown>";try{let n=t;const r=5,s=[];let i=0,a=0;const o=" > ",l=o.length;let c;const u=Array.isArray(e)?e:e.keyAttrs,d=!Array.isArray(e)&&e.maxStringLength||tm;for(;n&&i++<r&&(c=nm(n,u),!(c==="html"||i>1&&a+s.length*l+c.length>=d));)s.push(c),a+=c.length,n=n.parentNode;return s.reverse().join(o)}catch{return"<unknown>"}}function nm(t,e){const n=t,r=[];if(!n?.tagName)return"";if(ca.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());const s=e?.length?e.filter(a=>n.getAttribute(a)).map(a=>[a,n.getAttribute(a)]):null;if(s?.length)s.forEach(a=>{r.push(`[${a[0]}="${a[1]}"]`)});else{n.id&&r.push(`#${n.id}`);const a=n.className;if(a&&At(a)){const o=a.split(/\s+/);for(const l of o)r.push(`.${l}`)}}const i=["aria-label","type","name","title","alt"];for(const a of i){const o=n.getAttribute(a);o&&r.push(`[${a}="${o}"]`)}return r.join("")}function ua(){try{return ca.document.location.href}catch{return""}}function rm(t){if(!ca.HTMLElement)return null;let e=t;const n=5;for(let r=0;r<n;r++){if(!e)return null;if(e instanceof HTMLElement){if(e.dataset.sentryComponent)return e.dataset.sentryComponent;if(e.dataset.sentryElement)return e.dataset.sentryElement}e=e.parentNode}return null}function $s(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function Ec(t,e){if(!Array.isArray(t))return"";const n=[];for(let r=0;r<t.length;r++){const s=t[r];try{yc(s)?n.push("[VueViewModel]"):n.push(String(s))}catch{n.push("[value cannot be serialized]")}}return n.join(e)}function sm(t,e,n=!1){return At(t)?Zg(e)?e.test(t):At(e)?n?t===e:t.includes(e):!1:!1}function Cs(t,e=[],n=!1){return e.some(r=>sm(t,r,n))}function We(t,e,n){if(!(e in t))return;const r=t[e];if(typeof r!="function")return;const s=n(r);typeof s=="function"&&kc(s,r);try{t[e]=s}catch{D&&C.log(`Failed to replace method "${e}" in object`,t)}}function wn(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{D&&C.log(`Failed to add non-enumerable property "${e}" to object`,t)}}function kc(t,e){try{const n=e.prototype||{};t.prototype=e.prototype=n,wn(t,"__sentry_original__",e)}catch{}}function da(t){return t.__sentry_original__}function Sc(t){if(aa(t))return{message:t.message,name:t.name,stack:t.stack,...xc(t)};if(Os(t)){const e={type:t.type,target:Tc(t.target),currentTarget:Tc(t.currentTarget),...xc(t)};return typeof CustomEvent<"u"&&zt(t,CustomEvent)&&(e.detail=t.detail),e}else return t}function Tc(t){try{return Xg(t)?wc(t):Object.prototype.toString.call(t)}catch{return"<unknown>"}}function xc(t){if(typeof t=="object"&&t!==null){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}else return{}}function im(t,e=40){const n=Object.keys(Sc(t));n.sort();const r=n[0];if(!r)return"[object has no keys]";if(r.length>=e)return $s(r,e);for(let s=n.length;s>0;s--){const i=n.slice(0,s).join(", ");if(!(i.length>e))return s===n.length?i:$s(i,e)}return""}function am(){const t=Q;return t.crypto||t.msCrypto}function Xe(t=am()){let e=()=>Math.random()*16;try{if(t?.randomUUID)return t.randomUUID().replace(/-/g,"");t?.getRandomValues&&(e=()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]})}catch{}return("10000000100040008000"+1e11).replace(/[018]/g,n=>(n^(e()&15)>>n/4).toString(16))}function Ac(t){return t.exception?.values?.[0]}function En(t){const{message:e,event_id:n}=t;if(e)return e;const r=Ac(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function ha(t,e,n){const r=t.exception=t.exception||{},s=r.values=r.values||[],i=s[0]=s[0]||{};i.value||(i.value=e||""),i.type||(i.type="Error")}function tr(t,e){const n=Ac(t);if(!n)return;const r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism={...r,...s,...e},e&&"data"in e){const i={...s?.data,...e.data};n.mechanism.data=i}}function Rc(t){if(om(t))return!0;try{wn(t,"__sentry_captured__",!0)}catch{}return!1}function om(t){try{return t.__sentry_captured__}catch{}}const Oc=1e3;function Ir(){return Date.now()/Oc}function lm(){const{performance:t}=Q;if(!t?.now||!t.timeOrigin)return Ir;const e=t.timeOrigin;return()=>(e+t.now())/Oc}let Ic;function Rt(){return(Ic??(Ic=lm()))()}function cm(t){const e=Rt(),n={sid:Xe(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>dm(n)};return t&&nr(n,t),n}function nr(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Rt(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:Xe()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function um(t,e){let n={};t.status==="ok"&&(n={status:"exited"}),nr(t,n)}function dm(t){return{sid:`${t.sid}`,init:t.init,started:new Date(t.started*1e3).toISOString(),timestamp:new Date(t.timestamp*1e3).toISOString(),status:t.status,errors:t.errors,did:typeof t.did=="number"||typeof t.did=="string"?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}}}function $r(t,e,n=2){if(!e||typeof e!="object"||n<=0)return e;if(t&&Object.keys(e).length===0)return t;const r={...t};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=$r(r[s],e[s],n-1));return r}function $c(){return Xe()}function Cc(){return Xe().substring(16)}const fa="_sentrySpan";function Pc(t,e){e?wn(t,fa,e):delete t[fa]}function Nc(t){return t[fa]}const hm=100;class pt{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:$c(),sampleRand:Math.random()}}clone(){const e=new pt;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,Pc(e,Nc(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&nr(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,n){return this._tags={...this._tags,[e]:n},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,n){return this._extra={...this._extra,[e]:n},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,n){return n===null?delete this._contexts[e]:this._contexts[e]=n,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const n=typeof e=="function"?e(this):e,r=n instanceof pt?n.getScopeData():Or(n)?e:void 0,{tags:s,extra:i,user:a,contexts:o,level:l,fingerprint:c=[],propagationContext:u}=r||{};return this._tags={...this._tags,...s},this._extra={...this._extra,...i},this._contexts={...this._contexts,...o},a&&Object.keys(a).length&&(this._user=a),l&&(this._level=l),c.length&&(this._fingerprint=c),u&&(this._propagationContext=u),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,Pc(this,void 0),this._attachments=[],this.setPropagationContext({traceId:$c(),sampleRand:Math.random()}),this._notifyScopeListeners(),this}addBreadcrumb(e,n){const r=typeof n=="number"?n:hm;if(r<=0)return this;const s={timestamp:Ir(),...e,message:e.message?$s(e.message,2048):e.message};return this._breadcrumbs.push(s),this._breadcrumbs.length>r&&(this._breadcrumbs=this._breadcrumbs.slice(-r),this._client?.recordDroppedEvent("buffer_overflow","log_item")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:Nc(this)}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=$r(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){const r=n?.event_id||Xe();if(!this._client)return D&&C.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:s,...n,event_id:r},this),r}captureMessage(e,n,r){const s=r?.event_id||Xe();if(!this._client)return D&&C.warn("No client configured on scope - will not capture message!"),s;const i=new Error(e);return this._client.captureMessage(e,n,{originalException:e,syntheticException:i,...r,event_id:s},this),s}captureEvent(e,n){const r=n?.event_id||Xe();return this._client?(this._client.captureEvent(e,{...n,event_id:r},this),r):(D&&C.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}function fm(){return Rr("defaultCurrentScope",()=>new pt)}function pm(){return Rr("defaultIsolationScope",()=>new pt)}class gm{constructor(e,n){let r;e?r=e:r=new pt;let s;n?s=n:s=new pt,this._stack=[{scope:r}],this._isolationScope=s}withScope(e){const n=this._pushScope();let r;try{r=e(n)}catch(s){throw this._popScope(),s}return Is(r)?r.then(s=>(this._popScope(),s),s=>{throw this._popScope(),s}):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}}function rr(){const t=Ss(),e=Ts(t);return e.stack=e.stack||new gm(fm(),pm())}function mm(t){return rr().withScope(t)}function _m(t,e){const n=rr();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function Lc(t){return rr().withScope(()=>t(rr().getIsolationScope()))}function vm(){return{withIsolationScope:Lc,withScope:mm,withSetScope:_m,withSetIsolationScope:(t,e)=>Lc(e),getCurrentScope:()=>rr().getScope(),getIsolationScope:()=>rr().getIsolationScope()}}function pa(t){const e=Ts(t);return e.acs?e.acs:vm()}function Wt(){const t=Ss();return pa(t).getCurrentScope()}function Cr(){const t=Ss();return pa(t).getIsolationScope()}function bm(){return Rr("globalScope",()=>new pt)}function ym(...t){const e=Ss(),n=pa(e);if(t.length===2){const[r,s]=t;return r?n.withSetScope(r,s):n.withScope(s)}return n.withScope(t[0])}function Ie(){return Wt().getClient()}function wm(t){const e=t.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:s}=e,i={trace_id:n,span_id:s||Cc()};return r&&(i.parent_span_id=r),i}const Em="sentry.source",km="sentry.sample_rate",Sm="sentry.previous_trace_sample_rate",Tm="sentry.op",xm="sentry.origin",jc="sentry.profile_id",Dc="sentry.exclusive_time",Am=0,Rm=1,Om="_sentryScope",Im="_sentryIsolationScope";function Uc(t){return{scope:t[Om],isolationScope:t[Im]}}const $m="sentry-",Cm=/^sentry-/;function Pm(t){const e=Nm(t);if(!e)return;const n=Object.entries(e).reduce((r,[s,i])=>{if(s.match(Cm)){const a=s.slice($m.length);r[a]=i}return r},{});if(Object.keys(n).length>0)return n}function Nm(t){if(!(!t||!At(t)&&!Array.isArray(t)))return Array.isArray(t)?t.reduce((e,n)=>{const r=Fc(n);return Object.entries(r).forEach(([s,i])=>{e[s]=i}),e},{}):Fc(t)}function Fc(t){return t.split(",").map(e=>e.split("=").map(n=>{try{return decodeURIComponent(n.trim())}catch{return}})).reduce((e,[n,r])=>(n&&r&&(e[n]=r),e),{})}function Lm(t){if(typeof t=="boolean")return Number(t);const e=typeof t=="string"?parseFloat(t):t;if(!(typeof e!="number"||isNaN(e)||e<0||e>1))return e}const Mc=1;let Bc=!1;function jm(t){const{spanId:e,traceId:n,isRemote:r}=t.spanContext(),s=r?e:ga(t).parent_span_id,i=Uc(t).scope,a=r?i?.getPropagationContext().propagationSpanId||Cc():e;return{parent_span_id:s,span_id:a,trace_id:n}}function Dm(t){if(t&&t.length>0)return t.map(({context:{spanId:e,traceId:n,traceFlags:r,...s},attributes:i})=>({span_id:e,trace_id:n,sampled:r===Mc,attributes:i,...s}))}function qc(t){return typeof t=="number"?Hc(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Hc(t.getTime()):Rt()}function Hc(t){return t>9999999999?t/1e3:t}function ga(t){if(Fm(t))return t.getSpanJSON();const{spanId:e,traceId:n}=t.spanContext();if(Um(t)){const{attributes:r,startTime:s,name:i,endTime:a,status:o,links:l}=t,c="parentSpanId"in t?t.parentSpanId:"parentSpanContext"in t?t.parentSpanContext?.spanId:void 0;return{span_id:e,trace_id:n,data:r,description:i,parent_span_id:c,start_timestamp:qc(s),timestamp:qc(a)||void 0,status:Bm(o),op:r[Tm],origin:r[xm],links:Dm(l)}}return{span_id:e,trace_id:n,start_timestamp:0,data:{}}}function Um(t){const e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function Fm(t){return typeof t.getSpanJSON=="function"}function Mm(t){const{traceFlags:e}=t.spanContext();return e===Mc}function Bm(t){if(!(!t||t.code===Am))return t.code===Rm?"ok":t.message||"unknown_error"}const qm="_sentryRootSpan";function zc(t){return t[qm]||t}function Wc(){Bc||(Qn(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly.")}),Bc=!0)}function Hm(t){if(typeof __SENTRY_TRACING__=="boolean"&&!__SENTRY_TRACING__)return!1;const e=t||Ie()?.getOptions();return!!e&&(e.tracesSampleRate!=null||!!e.tracesSampler)}const ma="production",zm=/^o(\d+)\./,Wm=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function Gm(t){return t==="http"||t==="https"}function Ps(t,e=!1){const{host:n,path:r,pass:s,port:i,projectId:a,protocol:o,publicKey:l}=t;return`${o}://${l}${e&&s?`:${s}`:""}@${n}${i?`:${i}`:""}/${r&&`${r}/`}${a}`}function Km(t){const e=Wm.exec(t);if(!e){Qn(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}const[n,r,s="",i="",a="",o=""]=e.slice(1);let l="",c=o;const u=c.split("/");if(u.length>1&&(l=u.slice(0,-1).join("/"),c=u.pop()),c){const d=c.match(/^\d+/);d&&(c=d[0])}return Gc({host:i,pass:s,path:l,projectId:c,port:a,protocol:n,publicKey:r})}function Gc(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function Vm(t){if(!D)return!0;const{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(a=>t[a]?!1:(C.error(`Invalid Sentry Dsn: ${a} missing`),!0))?!1:n.match(/^\d+$/)?Gm(r)?e&&isNaN(parseInt(e,10))?(C.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(C.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(C.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function Jm(t){return t.match(zm)?.[1]}function Ym(t){const e=typeof t=="string"?Km(t):Gc(t);if(!(!e||!Vm(e)))return e}const Xm="_frozenDsc";function Kc(t,e){const n=e.getOptions(),{publicKey:r,host:s}=e.getDsn()||{};let i;n.orgId?i=String(n.orgId):s&&(i=Jm(s));const a={environment:n.environment||ma,release:n.release,public_key:r,trace_id:t,org_id:i};return e.emit("createDsc",a),a}function Zm(t,e){const n=e.getPropagationContext();return n.dsc||Kc(n.traceId,t)}function Qm(t){const e=Ie();if(!e)return{};const n=zc(t),r=ga(n),s=r.data,i=n.spanContext().traceState,a=i?.get("sentry.sample_rate")??s[km]??s[Sm];function o(m){return(typeof a=="number"||typeof a=="string")&&(m.sample_rate=`${a}`),m}const l=n[Xm];if(l)return o(l);const c=i?.get("sentry.dsc"),u=c&&Pm(c);if(u)return o(u);const d=Kc(t.spanContext().traceId,e),h=s[Em],f=r.description;return h!=="url"&&f&&(d.transaction=f),Hm()&&(d.sampled=String(Mm(n)),d.sample_rand=i?.get("sentry.sample_rand")??Uc(n).scope?.getPropagationContext().sampleRand.toString()),o(d),e.emit("createDsc",d,n),d}function Ot(t,e=100,n=1/0){try{return _a("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function Vc(t,e=3,n=100*1024){const r=Ot(t,e);return r_(r)>n?Vc(t,e-1,n):r}function _a(t,e,n=1/0,r=1/0,s=s_()){const[i,a]=s;if(e==null||["boolean","string"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e))return e;const o=e_(t,e);if(!o.startsWith("[object "))return o;if(e.__sentry_skip_normalization__)return e;const l=typeof e.__sentry_override_normalization_depth__=="number"?e.__sentry_override_normalization_depth__:n;if(l===0)return o.replace("object ","");if(i(e))return"[Circular ~]";const c=e;if(c&&typeof c.toJSON=="function")try{const f=c.toJSON();return _a("",f,l-1,r,s)}catch{}const u=Array.isArray(e)?[]:{};let d=0;const h=Sc(e);for(const f in h){if(!Object.prototype.hasOwnProperty.call(h,f))continue;if(d>=r){u[f]="[MaxProperties ~]";break}const m=h[f];u[f]=_a(f,m,l-1,r,s),d++}return a(e),u}function e_(t,e){try{if(t==="domain"&&e&&typeof e=="object"&&e._events)return"[Domain]";if(t==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&e===global)return"[Global]";if(typeof window<"u"&&e===window)return"[Window]";if(typeof document<"u"&&e===document)return"[Document]";if(yc(e))return"[VueViewModel]";if(Qg(e))return"[SyntheticEvent]";if(typeof e=="number"&&!Number.isFinite(e))return`[${e}]`;if(typeof e=="function")return`[Function: ${Ht(e)}]`;if(typeof e=="symbol")return`[${String(e)}]`;if(typeof e=="bigint")return`[BigInt: ${String(e)}]`;const n=t_(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(n){return`**non-serializable** (${n})`}}function t_(t){const e=Object.getPrototypeOf(t);return e?.constructor?e.constructor.name:"null prototype"}function n_(t){return~-encodeURI(t).split(/%..|./).length}function r_(t){return n_(JSON.stringify(t))}function s_(){const t=new WeakSet;function e(r){return t.has(r)?!0:(t.add(r),!1)}function n(r){t.delete(r)}return[e,n]}function Pr(t,e=[]){return[t,e]}function i_(t,e){const[n,r]=t;return[n,[...r,e]]}function Jc(t,e){const n=t[1];for(const r of n){const s=r[0].type;if(e(r,s))return!0}return!1}function va(t){const e=Ts(Q);return e.encodePolyfill?e.encodePolyfill(t):new TextEncoder().encode(t)}function a_(t){const[e,n]=t;let r=JSON.stringify(e);function s(i){typeof r=="string"?r=typeof i=="string"?r+i:[va(r),i]:r.push(typeof i=="string"?va(i):i)}for(const i of n){const[a,o]=i;if(s(`
106
106
  ${JSON.stringify(a)}
107
- `),typeof o=="string"||o instanceof Uint8Array)s(o);else{let l;try{l=JSON.stringify(o)}catch{l=JSON.stringify(It(o))}s(l)}}return typeof r=="string"?r:a_(r)}function a_(t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function o_(t){const e=typeof t.data=="string"?_a(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const l_={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",raw_security:"security",log:"log_item"};function Jc(t){return l_[t]}function Yc(t){if(!t?.sdk)return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function c_(t,e,n,r){const s=t.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:t.event_id,sent_at:new Date().toISOString(),...e&&{sdk:e},...!!n&&r&&{dsn:Cs(r)},...s&&{trace:s}}}function u_(t,e){return e&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||e.name,t.sdk.version=t.sdk.version||e.version,t.sdk.integrations=[...t.sdk.integrations||[],...e.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...e.packages||[]]),t}function d_(t,e,n,r){const s=Yc(n),i={sent_at:new Date().toISOString(),...s&&{sdk:s},...!!r&&e&&{dsn:Cs(e)}},a="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return Cr(i,[a])}function h_(t,e,n,r){const s=Yc(n),i=t.type&&t.type!=="replay_event"?t.type:"event";u_(t,n?.sdk);const a=c_(t,s,r,e);return delete t.sdkProcessingMetadata,Cr(a,[[{type:i},t]])}const va=0,Xc=1,Zc=2;function En(t){return new Gt(e=>{e(t)})}function Ps(t){return new Gt((e,n)=>{n(t)})}class Gt{constructor(e){this._state=va,this._handlers=[],this._runExecutor(e)}then(e,n){return new Gt((r,s)=>{this._handlers.push([!1,i=>{if(!e)r(i);else try{r(e(i))}catch(a){s(a)}},i=>{if(!n)s(i);else try{r(n(i))}catch(a){s(a)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new Gt((n,r)=>{let s,i;return this.then(a=>{i=!1,s=a,e&&e()},a=>{i=!0,s=a,e&&e()}).then(()=>{if(i){r(s);return}n(s)})})}_executeHandlers(){if(this._state===va)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===Xc&&n[1](this._value),this._state===Zc&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,a)=>{if(this._state===va){if(Rs(a)){a.then(r,s);return}this._state=i,this._value=a,this._executeHandlers()}},r=i=>{n(Xc,i)},s=i=>{n(Zc,i)};try{e(r,s)}catch(i){s(i)}}}function ba(t,e,n,r=0){return new Gt((s,i)=>{const a=t[r];if(e===null||typeof a!="function")s(e);else{const o=a({...e},n);D&&a.id&&o===null&&P.log(`Event processor "${a.id}" dropped event`),Rs(o)?o.then(l=>ba(t,l,n,r+1).then(s)).then(null,i):ba(t,o,n,r+1).then(s).then(null,i)}})}function f_(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;p_(t,e),r&&__(t,r),v_(t,n),g_(t,s),m_(t,i)}function Qc(t,e){const{extra:n,tags:r,user:s,contexts:i,level:a,sdkProcessingMetadata:o,breadcrumbs:l,fingerprint:c,eventProcessors:u,attachments:d,propagationContext:h,transactionName:f,span:g}=e;Ns(t,"extra",n),Ns(t,"tags",r),Ns(t,"user",s),Ns(t,"contexts",i),t.sdkProcessingMetadata=Ir(t.sdkProcessingMetadata,o,2),a&&(t.level=a),f&&(t.transactionName=f),g&&(t.span=g),l.length&&(t.breadcrumbs=[...t.breadcrumbs,...l]),c.length&&(t.fingerprint=[...t.fingerprint,...c]),u.length&&(t.eventProcessors=[...t.eventProcessors,...u]),d.length&&(t.attachments=[...t.attachments,...d]),t.propagationContext={...t.propagationContext,...h}}function Ns(t,e,n){t[e]=Ir(t[e],n,1)}function p_(t,e){const{extra:n,tags:r,user:s,contexts:i,level:a,transactionName:o}=e;Object.keys(n).length&&(t.extra={...n,...t.extra}),Object.keys(r).length&&(t.tags={...r,...t.tags}),Object.keys(s).length&&(t.user={...s,...t.user}),Object.keys(i).length&&(t.contexts={...i,...t.contexts}),a&&(t.level=a),o&&t.type!=="transaction"&&(t.transaction=o)}function g_(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function m_(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}function __(t,e){t.contexts={trace:Lm(e),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:Zm(e),...t.sdkProcessingMetadata};const n=Hc(e),r=pa(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function v_(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint.length||delete t.fingerprint}let Ls,eu,js;function b_(t){const e=Q._sentryDebugIds;if(!e)return{};const n=Object.keys(e);return js&&n.length===eu||(eu=n.length,js=n.reduce((r,s)=>{Ls||(Ls={});const i=Ls[s];if(i)r[i[0]]=i[1];else{const a=t(s);for(let o=a.length-1;o>=0;o--){const c=a[o]?.filename,u=e[s];if(c&&u){r[c]=u,Ls[s]=[c,u];break}}}return r},{})),js}function y_(t,e,n,r,s,i){const{normalizeDepth:a=3,normalizeMaxBreadth:o=1e3}=t,l={...e,event_id:e.event_id||n.event_id||Je(),timestamp:e.timestamp||Rr()},c=n.integrations||t.integrations.map(_=>_.name);w_(l,t),S_(l,c),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&E_(l,t.stackParser);const u=x_(r,n.captureContext);n.mechanism&&er(l,n.mechanism);const d=s?s.getEventProcessors():[],h=vm().getScopeData();if(i){const _=i.getScopeData();Qc(h,_)}if(u){const _=u.getScopeData();Qc(h,_)}const f=[...n.attachments||[],...h.attachments];f.length&&(n.attachments=f),f_(l,h);const g=[...d,...h.eventProcessors];return ba(g,l,n).then(_=>(_&&k_(_),typeof a=="number"&&a>0?T_(_,a,o):_))}function w_(t,e){const{environment:n,release:r,dist:s,maxValueLength:i=250}=e;t.environment=t.environment||n||ga,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const a=t.request;a?.url&&(a.url=Is(a.url,i))}function E_(t,e){const n=b_(e);t.exception?.values?.forEach(r=>{r.stacktrace?.frames?.forEach(s=>{s.filename&&(s.debug_id=n[s.filename])})})}function k_(t){const e={};if(t.exception?.values?.forEach(r=>{r.stacktrace?.frames?.forEach(s=>{s.debug_id&&(s.abs_path?e[s.abs_path]=s.debug_id:s.filename&&(e[s.filename]=s.debug_id),delete s.debug_id)})}),Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.entries(e).forEach(([r,s])=>{n.push({type:"sourcemap",code_file:r,debug_id:s})})}function S_(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function T_(t,e,n){if(!t)return null;const r={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(s=>({...s,...s.data&&{data:It(s.data,e,n)}}))},...t.user&&{user:It(t.user,e,n)},...t.contexts&&{contexts:It(t.contexts,e,n)},...t.extra&&{extra:It(t.extra,e,n)}};return t.contexts?.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=It(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(s=>({...s,...s.data&&{data:It(s.data,e,n)}}))),t.contexts?.flags&&r.contexts&&(r.contexts.flags=It(t.contexts.flags,3,n)),r}function x_(t,e){if(!e)return t;const n=t?t.clone():new gt;return n.update(e),n}function A_(t){if(t)return O_(t)?{captureContext:t}:I_(t)?{captureContext:t}:t}function O_(t){return t instanceof gt||typeof t=="function"}const R_=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function I_(t){return Object.keys(t).some(e=>R_.includes(e))}function tu(t,e){return Wt().captureException(t,A_(e))}function nu(t,e){return Wt().captureEvent(t,e)}function ru(t){const e=$r(),n=Wt(),{userAgent:r}=Q.navigator||{},s=lm({user:n.getUser()||e.getUser(),...r&&{userAgent:r},...t}),i=e.getSession();return i?.status==="ok"&&tr(i,{status:"exited"}),su(),e.setSession(s),s}function su(){const t=$r(),n=Wt().getSession()||t.getSession();n&&cm(n),iu(),t.setSession()}function iu(){const t=$r(),e=Re(),n=t.getSession();n&&e&&e.captureSession(n)}function au(t=!1){if(t){su();return}iu()}const $_="7";function C_(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function P_(t){return`${C_(t)}${t.projectId}/envelope/`}function N_(t,e){const n={sentry_version:$_};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function L_(t,e,n){return e||`${P_(t)}?${N_(t,n)}`}const ou=[];function j_(t){const e={};return t.forEach(n=>{const{name:r}=n,s=e[r];s&&!s.isDefaultInstance&&n.isDefaultInstance||(e[r]=n)}),Object.values(e)}function D_(t){const e=t.defaultIntegrations||[],n=t.integrations;e.forEach(s=>{s.isDefaultInstance=!0});let r;if(Array.isArray(n))r=[...e,...n];else if(typeof n=="function"){const s=n(e);r=Array.isArray(s)?s:[s]}else r=e;return j_(r)}function U_(t,e){const n={};return e.forEach(r=>{r&&cu(t,r,n)}),n}function lu(t,e){for(const n of e)n?.afterAllSetup&&n.afterAllSetup(t)}function cu(t,e,n){if(n[e.name]){D&&P.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,ou.indexOf(e.name)===-1&&typeof e.setupOnce=="function"&&(e.setupOnce(),ou.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){const r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,i)=>r(s,i,t))}if(typeof e.processEvent=="function"){const r=e.processEvent.bind(e),s=Object.assign((i,a)=>r(i,a,t),{id:e.name});t.addEventProcessor(s)}D&&P.log(`Integration installed: ${e.name}`)}function Vw(t){return t}function F_(t,e,n){const r=[{type:"client_report"},{timestamp:Rr(),discarded_events:t}];return Cr(e?{dsn:e}:{},[r])}function uu(t){const e=[];t.message&&e.push(t.message);try{const n=t.exception.values[t.exception.values.length-1];n?.value&&(e.push(n.value),n.type&&e.push(`${n.type}: ${n.value}`))}catch{}return e}function M_(t){const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:a,op:o}=t.contexts?.trace??{};return{data:a??{},description:t.transaction,op:o,parent_span_id:n,span_id:r??"",start_timestamp:t.start_timestamp??0,status:s,timestamp:t.timestamp,trace_id:e??"",origin:i,profile_id:a?.[Lc],exclusive_time:a?.[jc],measurements:t.measurements,is_segment:!0}}function B_(t){return{type:"transaction",timestamp:t.timestamp,start_timestamp:t.start_timestamp,transaction:t.description,contexts:{trace:{trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,op:t.op,status:t.status,origin:t.origin,data:{...t.data,...t.profile_id&&{[Lc]:t.profile_id},...t.exclusive_time&&{[jc]:t.exclusive_time}}}},measurements:t.measurements}}const du="Not capturing exception because it's already been captured.",hu="Discarded session because of missing or non-string release",fu=Symbol.for("SentryInternalError"),pu=Symbol.for("SentryDoNotSendEventError");function Ds(t){return{message:t,[fu]:!0}}function ya(t){return{message:t,[pu]:!0}}function gu(t){return!!t&&typeof t=="object"&&fu in t}function mu(t){return!!t&&typeof t=="object"&&pu in t}class q_{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=Jm(e.dsn):D&&P.warn("No DSN provided, client will not send events."),this._dsn){const n=L_(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:n})}}captureException(e,n,r){const s=Je();if(Ac(e))return D&&P.log(du),s;const i={event_id:s,...n};return this._process(this.eventFromException(e,i).then(a=>this._captureEvent(a,i,r))),i.event_id}captureMessage(e,n,r,s){const i={event_id:Je(),...r},a=aa(e)?e:String(e),o=oa(e)?this.eventFromMessage(a,n,i):this.eventFromException(e,i);return this._process(o.then(l=>this._captureEvent(l,i,s))),i.event_id}captureEvent(e,n,r){const s=Je();if(n?.originalException&&Ac(n.originalException))return D&&P.log(du),s;const i={event_id:s,...n},a=e.sdkProcessingMetadata||{},o=a.capturedSpanScope,l=a.capturedSpanIsolationScope;return this._process(this._captureEvent(e,i,o||r,l)),i.event_id}captureSession(e){this.sendSession(e),tr(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const n=this._transport;return n?(this.emit("flush"),this._isClientDoneProcessing(e).then(r=>n.flush(e).then(s=>r&&s))):En(!0)}close(e){return this.flush(e).then(n=>(this.getOptions().enabled=!1,this.emit("close"),n))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}addIntegration(e){const n=this._integrations[e.name];cu(this,e,this._integrations),n||lu(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);let r=h_(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])r=s_(r,o_(i));const s=this.sendEnvelope(r);s&&s.then(i=>this.emit("afterSendEvent",e,i),null)}sendSession(e){const{release:n,environment:r=ga}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){D&&P.warn(hu);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){D&&P.warn(hu);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=d_(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(s)}recordDroppedEvent(e,n,r=1){if(this._options.sendClientReports){const s=`${e}:${n}`;D&&P.log(`Recording outcome: "${s}"${r>1?` (${r} times)`:""}`),this._outcomes[s]=(this._outcomes[s]||0)+r}}on(e,n){const r=this._hooks[e]=this._hooks[e]||[];return r.push(n),()=>{const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(e,...n){const r=this._hooks[e];r&&r.forEach(s=>s(...n))}sendEnvelope(e){return this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport?this._transport.send(e).then(null,n=>(D&&P.error("Error while sending envelope:",n),n)):(D&&P.error("Transport disabled"),En({}))}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=U_(this,e),lu(this,e)}_updateSessionFromEvent(e,n){let r=n.level==="fatal",s=!1;const i=n.exception?.values;if(i){s=!0;for(const l of i)if(l.mechanism?.handled===!1){r=!0;break}}const a=e.status==="ok";(a&&e.errors===0||a&&r)&&(tr(e,{...r&&{status:"crashed"},errors:e.errors||Number(s||r)}),this.captureSession(e))}_isClientDoneProcessing(e){return new Gt(n=>{let r=0;const s=1,i=setInterval(()=>{this._numProcessing==0?(clearInterval(i),n(!0)):(r+=s,e&&r>=e&&(clearInterval(i),n(!1)))},s)})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s){const i=this.getOptions(),a=Object.keys(this._integrations);return!n.integrations&&a?.length&&(n.integrations=a),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),y_(i,e,n,r,this,s).then(o=>{if(o===null)return o;this.emit("postprocessEvent",o,n),o.contexts={trace:ym(r),...o.contexts};const l=Xm(this,r);return o.sdkProcessingMetadata={dynamicSamplingContext:l,...o.sdkProcessingMetadata},o})}_captureEvent(e,n={},r=Wt(),s=$r()){return D&&wa(e)&&P.log(`Captured error event \`${uu(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{D&&(mu(i)?P.log(i.message):gu(i)?P.warn(i.message):P.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:a}=i,o=_u(e),l=wa(e),c=e.type||"error",u=`before send for type \`${c}\``,d=typeof a>"u"?void 0:Nm(a);if(l&&typeof d=="number"&&Math.random()>d)return this.recordDroppedEvent("sample_rate","error"),Ps(ya(`Discarding event because it's not included in the random sample (sampling rate = ${a})`));const h=c==="replay_event"?"replay":c;return this._prepareEvent(e,n,r,s).then(f=>{if(f===null)throw this.recordDroppedEvent("event_processor",h),ya("An event processor returned `null`, will not send event.");if(n.data&&n.data.__sentry__===!0)return f;const v=z_(this,i,f,n);return H_(v,u)}).then(f=>{if(f===null){if(this.recordDroppedEvent("before_send",h),o){const S=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",S)}throw ya(`${u} returned \`null\`, will not send event.`)}const g=r.getSession()||s.getSession();if(l&&g&&this._updateSessionFromEvent(g,f),o){const _=f.sdkProcessingMetadata?.spanCountBeforeProcessing||0,S=f.spans?f.spans.length:0,p=_-S;p>0&&this.recordDroppedEvent("before_send","span",p)}const v=f.transaction_info;if(o&&v&&f.transaction!==e.transaction){const _="custom";f.transaction_info={...v,source:_}}return this.sendEvent(f,n),f}).then(null,f=>{throw mu(f)||gu(f)?f:(this.captureException(f,{data:{__sentry__:!0},originalException:f}),Ds(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
108
- Reason: ${f}`))})}_process(e){this._numProcessing++,e.then(n=>(this._numProcessing--,n),n=>(this._numProcessing--,n))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([n,r])=>{const[s,i]=n.split(":");return{reason:s,category:i,quantity:r}})}_flushOutcomes(){D&&P.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){D&&P.log("No outcomes to send");return}if(!this._dsn){D&&P.log("No dsn provided, will not send outcomes");return}D&&P.log("Sending outcomes:",e);const n=F_(e,this._options.tunnel&&Cs(this._dsn));this.sendEnvelope(n)}}function H_(t,e){const n=`${e} must return \`null\` or a valid event.`;if(Rs(t))return t.then(r=>{if(!Or(r)&&r!==null)throw Ds(n);return r},r=>{throw Ds(`${e} rejected with ${r}`)});if(!Or(t)&&t!==null)throw Ds(n);return t}function z_(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,beforeSendSpan:a}=e;let o=n;if(wa(o)&&s)return s(o,r);if(_u(o)){if(a){const l=a(M_(o));if(l?o=Ir(n,B_(l)):zc(),o.spans){const c=[];for(const u of o.spans){const d=a(u);d?c.push(d):(zc(),c.push(u))}o.spans=c}}if(i){if(o.spans){const l=o.spans.length;o.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:l}}return i(o,r)}}return o}function wa(t){return t.type===void 0}function _u(t){return t.type==="transaction"}function W_(t){return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},{items:t}]}function G_(t,e,n,r){const s={};return e?.sdk&&(s.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(s.dsn=Cs(r)),Cr(s,[W_(t)])}function Ea(t,e){const n=K_(t)??[];if(n.length===0)return;const r=t.getOptions(),s=G_(n,r._metadata,r.tunnel,t.getDsn());vu().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function K_(t){return vu().get(t)}function vu(){return Ar("clientToLogBufferMap",()=>new WeakMap)}function V_(t,e){e.debug===!0&&(D?P.enable():Zn(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),Wt().update(e.initialScope);const r=new t(e);return J_(r),r.init(),r}function J_(t){Wt().setClient(t)}const bu=Symbol.for("SentryBufferFullError");function Y_(t){const e=[];function n(){return t===void 0||e.length<t}function r(a){return e.splice(e.indexOf(a),1)[0]||Promise.resolve(void 0)}function s(a){if(!n())return Ps(bu);const o=a();return e.indexOf(o)===-1&&e.push(o),o.then(()=>r(o)).then(null,()=>r(o).then(null,()=>{})),o}function i(a){return new Gt((o,l)=>{let c=e.length;if(!c)return o(!0);const u=setTimeout(()=>{a&&a>0&&o(!1)},a);e.forEach(d=>{En(d).then(()=>{--c||(clearTimeout(u),o(!0))},l)})})}return{$:e,add:s,drain:i}}const X_=60*1e3;function Z_(t,e=Date.now()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?X_:r-e}function Q_(t,e){return t[e]||t.all||0}function ev(t,e,n=Date.now()){return Q_(t,e)>n}function tv(t,{statusCode:e,headers:n},r=Date.now()){const s={...t},i=n?.["x-sentry-rate-limits"],a=n?.["retry-after"];if(i)for(const o of i.trim().split(",")){const[l,c,,,u]=o.split(":",5),d=parseInt(l,10),h=(isNaN(d)?60:d)*1e3;if(!c)s.all=r+h;else for(const f of c.split(";"))f==="metric_bucket"?(!u||u.split(";").includes("custom"))&&(s[f]=r+h):s[f]=r+h}else a?s.all=r+Z_(a,r):e===429&&(s.all=r+60*1e3);return s}const nv=64;function rv(t,e,n=Y_(t.bufferSize||nv)){let r={};const s=a=>n.drain(a);function i(a){const o=[];if(Vc(a,(d,h)=>{const f=Jc(h);ev(r,f)?t.recordDroppedEvent("ratelimit_backoff",f):o.push(d)}),o.length===0)return En({});const l=Cr(a[0],o),c=d=>{Vc(l,(h,f)=>{t.recordDroppedEvent(d,Jc(f))})},u=()=>e({body:i_(l)}).then(d=>(d.statusCode!==void 0&&(d.statusCode<200||d.statusCode>=300)&&D&&P.warn(`Sentry responded with status code ${d.statusCode} to sent event.`),r=tv(r,d),d),d=>{throw c("network_error"),D&&P.error("Encountered error running transport request:",d),d});return n.add(u).then(d=>d,d=>{if(d===bu)return D&&P.error("Skipped sending event because buffer is full."),c("queue_overflow"),En({});throw d})}return{send:i,flush:s}}function sv(t){t.user?.ip_address===void 0&&(t.user={...t.user,ip_address:"{{auto}}"})}function iv(t){"aggregates"in t?t.attrs?.ip_address===void 0&&(t.attrs={...t.attrs,ip_address:"{{auto}}"}):t.ipAddress===void 0&&(t.ipAddress="{{auto}}")}function av(t,e,n=[e],r="npm"){const s=t._metadata||{};s.sdk||(s.sdk={name:`sentry.javascript.${e}`,packages:n.map(i=>({name:`${r}:@sentry/${i}`,version:mn})),version:mn}),t._metadata=s}const ov=100;function kn(t,e){const n=Re(),r=$r();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=ov}=n.getOptions();if(i<=0)return;const o={timestamp:Rr(),...t},l=s?Zn(()=>s(o,e)):o;l!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",l,e),r.addBreadcrumb(l,i))}let yu;const lv="FunctionToString",wu=new WeakMap,cv=(()=>({name:lv,setupOnce(){yu=Function.prototype.toString;try{Function.prototype.toString=function(...t){const e=ua(this),n=wu.has(Re())&&e!==void 0?e:this;return yu.apply(n,t)}}catch{}},setup(t){wu.set(t,!0)}})),uv=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,`can't redefine non-configurable property "solana"`,"vv().getRestrictions is not a function. (In 'vv().getRestrictions(1,a)', 'vv().getRestrictions' is undefined)","Can't find variable: _AutofillCallbackHandler",/^Non-Error promise rejection captured with value: Object Not Found Matching Id:\d+, MethodName:simulateEvent, ParamCount:\d+$/,/^Java exception was raised during method invocation$/],dv="EventFilters",hv=(t={})=>{let e;return{name:dv,setup(n){const r=n.getOptions();e=Eu(t,r)},processEvent(n,r,s){if(!e){const i=s.getOptions();e=Eu(t,i)}return pv(n,e)?null:n}}},fv=((t={})=>({...hv(t),name:"InboundFilters"}));function Eu(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:uv],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[]]}}function pv(t,e){if(t.type){if(t.type==="transaction"&&mv(t,e.ignoreTransactions))return D&&P.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
109
- Event: ${wn(t)}`),!0}else{if(gv(t,e.ignoreErrors))return D&&P.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
110
- Event: ${wn(t)}`),!0;if(yv(t))return D&&P.warn(`Event dropped due to not having an error message, error type or stacktrace.
111
- Event: ${wn(t)}`),!0;if(_v(t,e.denyUrls))return D&&P.warn(`Event dropped due to being matched by \`denyUrls\` option.
112
- Event: ${wn(t)}.
113
- Url: ${Us(t)}`),!0;if(!vv(t,e.allowUrls))return D&&P.warn(`Event dropped due to not being matched by \`allowUrls\` option.
114
- Event: ${wn(t)}.
115
- Url: ${Us(t)}`),!0}return!1}function gv(t,e){return e?.length?uu(t).some(n=>$s(n,e)):!1}function mv(t,e){if(!e?.length)return!1;const n=t.transaction;return n?$s(n,e):!1}function _v(t,e){if(!e?.length)return!1;const n=Us(t);return n?$s(n,e):!1}function vv(t,e){if(!e?.length)return!0;const n=Us(t);return n?$s(n,e):!0}function bv(t=[]){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n&&n.filename!=="<anonymous>"&&n.filename!=="[native code]")return n.filename||null}return null}function Us(t){try{const n=[...t.exception?.values??[]].reverse().find(r=>r.mechanism?.parent_id===void 0&&r.stacktrace?.frames?.length)?.stacktrace?.frames;return n?bv(n):null}catch{return D&&P.error(`Cannot extract url for event ${wn(t)}`),null}}function yv(t){return t.exception?.values?.length?!t.message&&!t.exception.values.some(e=>e.stacktrace||e.type&&e.type!=="Error"||e.value):!1}function wv(t,e,n,r,s,i){if(!s.exception?.values||!i||!zt(i.originalException,Error))return;const a=s.exception.values.length>0?s.exception.values[s.exception.values.length-1]:void 0;a&&(s.exception.values=ka(t,e,r,i.originalException,n,s.exception.values,a,0))}function ka(t,e,n,r,s,i,a,o){if(i.length>=n+1)return i;let l=[...i];if(zt(r[s],Error)){ku(a,o);const c=t(e,r[s]),u=l.length;Su(c,s,u,o),l=ka(t,e,n,r[s],s,[c,...l],c,u)}return Array.isArray(r.errors)&&r.errors.forEach((c,u)=>{if(zt(c,Error)){ku(a,o);const d=t(e,c),h=l.length;Su(d,`errors[${u}]`,h,o),l=ka(t,e,n,c,s,[d,...l],d,h)}}),l}function ku(t,e){t.mechanism=t.mechanism||{type:"generic",handled:!0},t.mechanism={...t.mechanism,...t.type==="AggregateError"&&{is_exception_group:!0},exception_id:e}}function Su(t,e,n,r){t.mechanism=t.mechanism||{type:"generic",handled:!0},t.mechanism={...t.mechanism,type:"chained",source:e,exception_id:n,parent_id:r}}function Ev(t){const e="console";vn(e,t),bn(e,kv)}function kv(){"console"in Q&&jg.forEach(function(t){t in Q.console&&ze(Q.console,t,function(e){return Ts[t]=e,function(...n){ot("console",{args:n,level:t}),Ts[t]?.apply(Q.console,n)}})})}function Sv(t){return t==="warn"?"warning":["fatal","error","warning","log","info","debug"].includes(t)?t:"log"}const Tv="Dedupe",xv=(()=>{let t;return{name:Tv,processEvent(e){if(e.type)return e;try{if(Av(e,t))return D&&P.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return t=e}}});function Av(t,e){return e?!!(Ov(t,e)||Rv(t,e)):!1}function Ov(t,e){const n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!xu(t,e)||!Tu(t,e))}function Rv(t,e){const n=Au(e),r=Au(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!xu(t,e)||!Tu(t,e))}function Tu(t,e){let n=pc(t),r=pc(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let s=0;s<r.length;s++){const i=r[s],a=n[s];if(i.filename!==a.filename||i.lineno!==a.lineno||i.colno!==a.colno||i.function!==a.function)return!1}return!0}function xu(t,e){let n=t.fingerprint,r=e.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;n=n,r=r;try{return n.join("")===r.join("")}catch{return!1}}function Au(t){return t.exception?.values?.[0]}function Sa(t){if(!t)return{};const e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)return{};const n=e[6]||"",r=e[8]||"";return{host:e[4],path:e[5],protocol:e[2],search:n,hash:r,relative:e[5]+n+r}}function Ou(t){if(t!==void 0)return t>=400&&t<500?"warning":t>=500?"error":void 0}const Pr=Q;function Iv(){return"history"in Pr&&!!Pr.history}function $v(){if(!("fetch"in Pr))return!1;try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch{return!1}}function Ta(t){return t&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(t.toString())}function Cv(){if(typeof EdgeRuntime=="string")return!0;if(!$v())return!1;if(Ta(Pr.fetch))return!0;let t=!1;const e=Pr.document;if(e&&typeof e.createElement=="function")try{const n=e.createElement("iframe");n.hidden=!0,e.head.appendChild(n),n.contentWindow?.fetch&&(t=Ta(n.contentWindow.fetch)),e.head.removeChild(n)}catch(n){D&&P.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",n)}return t}function Pv(t,e){const n="fetch";vn(n,t),bn(n,()=>Nv(void 0,e))}function Nv(t,e=!1){e&&!Cv()||ze(Q,"fetch",function(n){return function(...r){const s=new Error,{method:i,url:a}=Lv(r),o={args:r,fetchData:{method:i,url:a},startTimestamp:Rt()*1e3,virtualError:s,headers:jv(r)};return ot("fetch",{...o}),n.apply(Q,r).then(async l=>(ot("fetch",{...o,endTimestamp:Rt()*1e3,response:l}),l),l=>{if(ot("fetch",{...o,endTimestamp:Rt()*1e3,error:l}),ia(l)&&l.stack===void 0&&(l.stack=s.stack,yn(l,"framesToPop",1)),l instanceof TypeError&&(l.message==="Failed to fetch"||l.message==="Load failed"||l.message==="NetworkError when attempting to fetch resource."))try{const c=new URL(o.fetchData.url);l.message=`${l.message} (${c.host})`}catch{}throw l})}})}function xa(t,e){return!!t&&typeof t=="object"&&!!t[e]}function Ru(t){return typeof t=="string"?t:t?xa(t,"url")?t.url:t.toString?t.toString():"":""}function Lv(t){if(t.length===0)return{method:"GET",url:""};if(t.length===2){const[n,r]=t;return{url:Ru(n),method:xa(r,"method")?String(r.method).toUpperCase():"GET"}}const e=t[0];return{url:Ru(e),method:xa(e,"method")?String(e.method).toUpperCase():"GET"}}function jv(t){const[e,n]=t;try{if(typeof n=="object"&&n!==null&&"headers"in n&&n.headers)return new Headers(n.headers);if(Qg(e))return new Headers(e.headers)}catch{}}function Dv(){return"npm"}const le=Q;let Aa=0;function Iu(){return Aa>0}function Uv(){Aa++,setTimeout(()=>{Aa--})}function rr(t,e={}){function n(s){return typeof s=="function"}if(!n(t))return t;try{const s=t.__sentry_wrapped__;if(s)return typeof s=="function"?s:t;if(ua(t))return t}catch{return t}const r=function(...s){try{const i=s.map(a=>rr(a,e));return t.apply(this,i)}catch(i){throw Uv(),bm(a=>{a.addEventProcessor(o=>(e.mechanism&&(da(o,void 0),er(o,e.mechanism)),o.extra={...o.extra,arguments:s},o)),tu(i)}),i}};try{for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}catch{}Ec(r,t),yn(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}function Fv(){const t=ca(),{referrer:e}=le.document||{},{userAgent:n}=le.navigator||{},r={...e&&{Referer:e},...n&&{"User-Agent":n}};return{url:t,headers:r}}function Oa(t,e){const n=Ia(t,e),r={type:zv(e),value:Wv(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function Mv(t,e,n,r){const i=Re()?.getOptions().normalizeDepth,a=Yv(e),o={__serialized__:Kc(e,i)};if(a)return{exception:{values:[Oa(t,a)]},extra:o};const l={exception:{values:[{type:Os(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:Vv(e,{isUnhandledRejection:r})}]},extra:o};if(n){const c=Ia(t,n);c.length&&(l.exception.values[0].stacktrace={frames:c})}return l}function Ra(t,e){return{exception:{values:[Oa(t,e)]}}}function Ia(t,e){const n=e.stacktrace||e.stack||"",r=qv(e),s=Hv(e);try{return t(n,r,s)}catch{}return[]}const Bv=/Minified React error #\d+;/i;function qv(t){return t&&Bv.test(t.message)?1:0}function Hv(t){return typeof t.framesToPop=="number"?t.framesToPop:0}function $u(t){return typeof WebAssembly<"u"&&typeof WebAssembly.Exception<"u"?t instanceof WebAssembly.Exception:!1}function zv(t){const e=t?.name;return!e&&$u(t)?t.message&&Array.isArray(t.message)&&t.message.length==2?t.message[0]:"WebAssembly.Exception":e}function Wv(t){const e=t?.message;return $u(t)?Array.isArray(t.message)&&t.message.length==2?t.message[1]:"wasm exception":e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function Gv(t,e,n,r){const s=n?.syntheticException||void 0,i=$a(t,e,s,r);return er(i),i.level="error",n?.event_id&&(i.event_id=n.event_id),En(i)}function Kv(t,e,n="info",r,s){const i=r?.syntheticException||void 0,a=Ca(t,e,i,s);return a.level=n,r?.event_id&&(a.event_id=r.event_id),En(a)}function $a(t,e,n,r,s){let i;if(_c(e)&&e.error)return Ra(t,e.error);if(vc(e)||Jg(e)){const a=e;if("stack"in e)i=Ra(t,e);else{const o=a.name||(vc(a)?"DOMError":"DOMException"),l=a.message?`${o}: ${a.message}`:o;i=Ca(t,l,n,r),da(i,l)}return"code"in a&&(i.tags={...i.tags,"DOMException.code":`${a.code}`}),i}return ia(e)?Ra(t,e):Or(e)||Os(e)?(i=Mv(t,e,n,s),er(i,{synthetic:!0}),i):(i=Ca(t,e,n,r),da(i,`${e}`),er(i,{synthetic:!0}),i)}function Ca(t,e,n,r){const s={};if(r&&n){const i=Ia(t,n);i.length&&(s.exception={values:[{value:e,stacktrace:{frames:i}}]}),er(s,{synthetic:!0})}if(aa(e)){const{__sentry_template_string__:i,__sentry_template_values__:a}=e;return s.logentry={message:i,params:a},s}return s.message=e,s}function Vv(t,{isUnhandledRejection:e}){const n=sm(t),r=e?"promise rejection":"exception";return _c(t)?`Event \`ErrorEvent\` captured as ${r} with message \`${t.message}\``:Os(t)?`Event \`${Jv(t)}\` (type=${t.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}function Jv(t){try{const e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{}}function Yv(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if(n instanceof Error)return n}}const Xv=5e3;class Zv extends q_{constructor(e){const n=Qv(e),r=le.SENTRY_SDK_SOURCE||Dv();av(n,"browser",["browser"],r),super(n);const{sendDefaultPii:s,sendClientReports:i,enableLogs:a,_experiments:o}=this._options,l=a??o?.enableLogs;le.document&&(i||l)&&le.document.addEventListener("visibilitychange",()=>{le.document.visibilityState==="hidden"&&(i&&this._flushOutcomes(),l&&Ea(this))}),l&&(this.on("flush",()=>{Ea(this)}),this.on("afterCaptureLog",()=>{this._logFlushIdleTimeout&&clearTimeout(this._logFlushIdleTimeout),this._logFlushIdleTimeout=setTimeout(()=>{Ea(this)},Xv)})),s&&(this.on("postprocessEvent",sv),this.on("beforeSendSession",iv))}eventFromException(e,n){return Gv(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Kv(this._options.stackParser,e,n,r,this._options.attachStacktrace)}_prepareEvent(e,n,r,s){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r,s)}}function Qv(t){return{release:typeof __SENTRY_RELEASE__=="string"?__SENTRY_RELEASE__:le.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...t}}const eb=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Ie=Q,tb=1e3;let Cu,Pa,Na;function nb(t){vn("dom",t),bn("dom",rb)}function rb(){if(!Ie.document)return;const t=ot.bind(null,"dom"),e=Pu(t,!0);Ie.document.addEventListener("click",e,!1),Ie.document.addEventListener("keypress",e,!1),["EventTarget","Node"].forEach(n=>{const s=Ie[n]?.prototype;s?.hasOwnProperty?.("addEventListener")&&(ze(s,"addEventListener",function(i){return function(a,o,l){if(a==="click"||a=="keypress")try{const c=this.__sentry_instrumentation_handlers__=this.__sentry_instrumentation_handlers__||{},u=c[a]=c[a]||{refCount:0};if(!u.handler){const d=Pu(t);u.handler=d,i.call(this,a,d,l)}u.refCount++}catch{}return i.call(this,a,o,l)}}),ze(s,"removeEventListener",function(i){return function(a,o,l){if(a==="click"||a=="keypress")try{const c=this.__sentry_instrumentation_handlers__||{},u=c[a];u&&(u.refCount--,u.refCount<=0&&(i.call(this,a,u.handler,l),u.handler=void 0,delete c[a]),Object.keys(c).length===0&&delete this.__sentry_instrumentation_handlers__)}catch{}return i.call(this,a,o,l)}}))})}function sb(t){if(t.type!==Pa)return!1;try{if(!t.target||t.target._sentryId!==Na)return!1}catch{}return!0}function ib(t,e){return t!=="keypress"?!1:e?.tagName?!(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable):!0}function Pu(t,e=!1){return n=>{if(!n||n._sentryCaptured)return;const r=ab(n);if(ib(n.type,r))return;yn(n,"_sentryCaptured",!0),r&&!r._sentryId&&yn(r,"_sentryId",Je());const s=n.type==="keypress"?"input":n.type;sb(n)||(t({event:n,name:s,global:e}),Pa=n.type,Na=r?r._sentryId:void 0),clearTimeout(Cu),Cu=Ie.setTimeout(()=>{Na=void 0,Pa=void 0},tb)}}function ab(t){try{return t.target}catch{return null}}let Fs;function Nu(t){const e="history";vn(e,t),bn(e,ob)}function ob(){if(Ie.addEventListener("popstate",()=>{const e=Ie.location.href,n=Fs;if(Fs=e,n===e)return;ot("history",{from:n,to:e})}),!Iv())return;function t(e){return function(...n){const r=n.length>2?n[2]:void 0;if(r){const s=Fs,i=lb(String(r));if(Fs=i,s===i)return e.apply(this,n);ot("history",{from:s,to:i})}return e.apply(this,n)}}ze(Ie.history,"pushState",t),ze(Ie.history,"replaceState",t)}function lb(t){try{return new URL(t,Ie.location.origin).toString()}catch{return t}}const Ms={};function cb(t){const e=Ms[t];if(e)return e;let n=Ie[t];if(Ta(n))return Ms[t]=n.bind(Ie);const r=Ie.document;if(r&&typeof r.createElement=="function")try{const s=r.createElement("iframe");s.hidden=!0,r.head.appendChild(s);const i=s.contentWindow;i?.[t]&&(n=i[t]),r.head.removeChild(s)}catch(s){eb&&P.warn(`Could not create sandbox iframe for ${t} check, bailing to window.${t}: `,s)}return n&&(Ms[t]=n.bind(Ie))}function Lu(t){Ms[t]=void 0}const Nr="__sentry_xhr_v3__";function ub(t){vn("xhr",t),bn("xhr",db)}function db(){if(!Ie.XMLHttpRequest)return;const t=XMLHttpRequest.prototype;t.open=new Proxy(t.open,{apply(e,n,r){const s=new Error,i=Rt()*1e3,a=Ot(r[0])?r[0].toUpperCase():void 0,o=hb(r[1]);if(!a||!o)return e.apply(n,r);n[Nr]={method:a,url:o,request_headers:{}},a==="POST"&&o.match(/sentry_key/)&&(n.__sentry_own_request__=!0);const l=()=>{const c=n[Nr];if(c&&n.readyState===4){try{c.status_code=n.status}catch{}const u={endTimestamp:Rt()*1e3,startTimestamp:i,xhr:n,virtualError:s};ot("xhr",u)}};return"onreadystatechange"in n&&typeof n.onreadystatechange=="function"?n.onreadystatechange=new Proxy(n.onreadystatechange,{apply(c,u,d){return l(),c.apply(u,d)}}):n.addEventListener("readystatechange",l),n.setRequestHeader=new Proxy(n.setRequestHeader,{apply(c,u,d){const[h,f]=d,g=u[Nr];return g&&Ot(h)&&Ot(f)&&(g.request_headers[h.toLowerCase()]=f),c.apply(u,d)}}),e.apply(n,r)}}),t.send=new Proxy(t.send,{apply(e,n,r){const s=n[Nr];if(!s)return e.apply(n,r);r[0]!==void 0&&(s.body=r[0]);const i={startTimestamp:Rt()*1e3,xhr:n};return ot("xhr",i),e.apply(n,r)}})}function hb(t){if(Ot(t))return t;try{return t.toString()}catch{}}function fb(t,e=cb("fetch")){let n=0,r=0;function s(i){const a=i.body.length;n+=a,r++;const o={body:i.body,method:"POST",referrerPolicy:"strict-origin",headers:t.headers,keepalive:n<=6e4&&r<15,...t.fetchOptions};if(!e)return Lu("fetch"),Ps("No fetch implementation available");try{return e(t.url,o).then(l=>(n-=a,r--,{statusCode:l.status,headers:{"x-sentry-rate-limits":l.headers.get("X-Sentry-Rate-Limits"),"retry-after":l.headers.get("Retry-After")}}))}catch(l){return Lu("fetch"),n-=a,r--,Ps(l)}}return rv(t,s)}const pb=30,gb=50;function La(t,e,n,r){const s={filename:t,function:e==="<anonymous>"?_n:e,in_app:!0};return n!==void 0&&(s.lineno=n),r!==void 0&&(s.colno=r),s}const mb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,_b=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,vb=/\((\S*)(?::(\d+))(?::(\d+))\)/,bb=[pb,t=>{const e=mb.exec(t);if(e){const[,r,s,i]=e;return La(r,_n,+s,+i)}const n=_b.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=vb.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[s,i]=ju(n[1]||_n,n[2]);return La(i,s,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}}],yb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,wb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Eb=fc(...[bb,[gb,t=>{const e=yb.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const i=wb.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],s=e[1]||_n;return[s,r]=ju(s,r),La(r,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]),ju=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:_n,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},Bs=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,qs=1024,kb="Breadcrumbs",Du=((t={})=>{const e={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...t};return{name:kb,setup(n){e.console&&Ev(xb(n)),e.dom&&nb(Tb(n,e.dom)),e.xhr&&ub(Ab(n)),e.fetch&&Pv(Ob(n)),e.history&&Nu(Rb(n)),e.sentry&&n.on("beforeSendEvent",Sb(n))}}});function Sb(t){return function(n){Re()===t&&kn({category:`sentry.${n.type==="transaction"?"transaction":"event"}`,event_id:n.event_id,level:n.level,message:wn(n)},{event:n})}}function Tb(t,e){return function(r){if(Re()!==t)return;let s,i,a=typeof e=="object"?e.serializeAttribute:void 0,o=typeof e=="object"&&typeof e.maxStringLength=="number"?e.maxStringLength:void 0;o&&o>qs&&(Bs&&P.warn(`\`dom.maxStringLength\` cannot exceed ${qs}, but a value of ${o} was configured. Sentry will use ${qs} instead.`),o=qs),typeof a=="string"&&(a=[a]);try{const c=r.event,u=Ib(c)?c.target:c;s=yc(u,{keyAttrs:a,maxStringLength:o}),i=nm(u)}catch{s="<unknown>"}if(s.length===0)return;const l={category:`ui.${r.name}`,message:s};i&&(l.data={"ui.component_name":i}),kn(l,{event:r.event,name:r.name,global:r.global})}}function xb(t){return function(n){if(Re()!==t)return;const r={category:"console",data:{arguments:n.args,logger:"console"},level:Sv(n.level),message:wc(n.args," ")};if(n.level==="assert")if(n.args[0]===!1)r.message=`Assertion failed: ${wc(n.args.slice(1)," ")||"console.assert"}`,r.data.arguments=n.args.slice(1);else return;kn(r,{input:n.args,level:n.level})}}function Ab(t){return function(n){if(Re()!==t)return;const{startTimestamp:r,endTimestamp:s}=n,i=n.xhr[Nr];if(!r||!s||!i)return;const{method:a,url:o,status_code:l,body:c}=i,u={method:a,url:o,status_code:l},d={xhr:n.xhr,input:c,startTimestamp:r,endTimestamp:s},h={category:"xhr",data:u,type:"http",level:Ou(l)};t.emit("beforeOutgoingRequestBreadcrumb",h,d),kn(h,d)}}function Ob(t){return function(n){if(Re()!==t)return;const{startTimestamp:r,endTimestamp:s}=n;if(s&&!(n.fetchData.url.match(/sentry_key/)&&n.fetchData.method==="POST"))if(n.fetchData.method,n.fetchData.url,n.error){const i=n.fetchData,a={data:n.error,input:n.args,startTimestamp:r,endTimestamp:s},o={category:"fetch",data:i,level:"error",type:"http"};t.emit("beforeOutgoingRequestBreadcrumb",o,a),kn(o,a)}else{const i=n.response,a={...n.fetchData,status_code:i?.status};n.fetchData.request_body_size,n.fetchData.response_body_size,i?.status;const o={input:n.args,response:i,startTimestamp:r,endTimestamp:s},l={category:"fetch",data:a,type:"http",level:Ou(a.status_code)};t.emit("beforeOutgoingRequestBreadcrumb",l,o),kn(l,o)}}}function Rb(t){return function(n){if(Re()!==t)return;let r=n.from,s=n.to;const i=Sa(le.location.href);let a=r?Sa(r):void 0;const o=Sa(s);a?.path||(a=i),i.protocol===o.protocol&&i.host===o.host&&(s=o.relative),i.protocol===a.protocol&&i.host===a.host&&(r=a.relative),kn({category:"navigation",data:{from:r,to:s}})}}function Ib(t){return!!t&&!!t.target}const $b=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","BroadcastChannel","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","SharedWorker","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],Cb="BrowserApiErrors",Pb=((t={})=>{const e={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...t};return{name:Cb,setupOnce(){e.setTimeout&&ze(le,"setTimeout",Uu),e.setInterval&&ze(le,"setInterval",Uu),e.requestAnimationFrame&&ze(le,"requestAnimationFrame",Nb),e.XMLHttpRequest&&"XMLHttpRequest"in le&&ze(XMLHttpRequest.prototype,"send",Lb);const n=e.eventTarget;n&&(Array.isArray(n)?n:$b).forEach(s=>jb(s,e))}}});function Uu(t){return function(...e){const n=e[0];return e[0]=rr(n,{mechanism:{data:{function:Ht(t)},handled:!1,type:"instrument"}}),t.apply(this,e)}}function Nb(t){return function(e){return t.apply(this,[rr(e,{mechanism:{data:{function:"requestAnimationFrame",handler:Ht(t)},handled:!1,type:"instrument"}})])}}function Lb(t){return function(...e){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(s=>{s in n&&typeof n[s]=="function"&&ze(n,s,function(i){const a={mechanism:{data:{function:s,handler:Ht(i)},handled:!1,type:"instrument"}},o=ua(i);return o&&(a.mechanism.data.handler=Ht(o)),rr(i,a)})}),t.apply(this,e)}}function jb(t,e){const r=le[t]?.prototype;r?.hasOwnProperty?.("addEventListener")&&(ze(r,"addEventListener",function(s){return function(i,a,o){try{Db(a)&&(a.handleEvent=rr(a.handleEvent,{mechanism:{data:{function:"handleEvent",handler:Ht(a),target:t},handled:!1,type:"instrument"}}))}catch{}return e.unregisterOriginalCallbacks&&Ub(this,i,a),s.apply(this,[i,rr(a,{mechanism:{data:{function:"addEventListener",handler:Ht(a),target:t},handled:!1,type:"instrument"}}),o])}}),ze(r,"removeEventListener",function(s){return function(i,a,o){try{const l=a.__sentry_wrapped__;l&&s.call(this,i,l,o)}catch{}return s.call(this,i,a,o)}}))}function Db(t){return typeof t.handleEvent=="function"}function Ub(t,e,n){t&&typeof t=="object"&&"removeEventListener"in t&&typeof t.removeEventListener=="function"&&t.removeEventListener(e,n)}const Fb=()=>({name:"BrowserSession",setupOnce(){if(typeof le.document>"u"){Bs&&P.warn("Using the `browserSessionIntegration` in non-browser environments is not supported.");return}ru({ignoreDuration:!0}),au(),Nu(({from:t,to:e})=>{t!==void 0&&t!==e&&(ru({ignoreDuration:!0}),au())})}}),Mb="GlobalHandlers",Bb=((t={})=>{const e={onerror:!0,onunhandledrejection:!0,...t};return{name:Mb,setupOnce(){Error.stackTraceLimit=50},setup(n){e.onerror&&(qb(n),Fu("onerror")),e.onunhandledrejection&&(Hb(n),Fu("onunhandledrejection"))}}});function qb(t){Wg(e=>{const{stackParser:n,attachStacktrace:r}=Mu();if(Re()!==t||Iu())return;const{msg:s,url:i,line:a,column:o,error:l}=e,c=Gb($a(n,l||s,void 0,r,!1),i,a,o);c.level="error",nu(c,{originalException:l,mechanism:{handled:!1,type:"onerror"}})})}function Hb(t){Kg(e=>{const{stackParser:n,attachStacktrace:r}=Mu();if(Re()!==t||Iu())return;const s=zb(e),i=oa(s)?Wb(s):$a(n,s,void 0,r,!0);i.level="error",nu(i,{originalException:s,mechanism:{handled:!1,type:"onunhandledrejection"}})})}function zb(t){if(oa(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}function Wb(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function Gb(t,e,n,r){const s=t.exception=t.exception||{},i=s.values=s.values||[],a=i[0]=i[0]||{},o=a.stacktrace=a.stacktrace||{},l=o.frames=o.frames||[],c=r,u=n,d=Ot(e)&&e.length>0?e:ca();return l.length===0&&l.push({colno:c,filename:d,function:_n,in_app:!0,lineno:u}),t}function Fu(t){Bs&&P.log(`Global Handler attached: ${t}`)}function Mu(){return Re()?.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}const Kb=()=>({name:"HttpContext",preprocessEvent(t){if(!le.navigator&&!le.location&&!le.document)return;const e=Fv(),n={...e.headers,...t.request?.headers};t.request={...e,...t.request,headers:n}}}),Vb="cause",Jb=5,Yb="LinkedErrors",Xb=((t={})=>{const e=t.limit||Jb,n=t.key||Vb;return{name:Yb,preprocessEvent(r,s,i){const a=i.getOptions();wv(Oa,a.stackParser,n,e,r,s)}}});function Zb(){return Qb()?(Bs&&Zn(()=>{console.error("[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/")}),!0):!1}function Qb(){if(typeof le.window>"u")return!1;const t=le;if(t.nw||!(t.chrome||t.browser)?.runtime?.id)return!1;const n=ca(),r=["chrome-extension","moz-extension","ms-browser-extension","safari-web-extension"];return!(le===le.top&&r.some(i=>n.startsWith(`${i}://`)))}function ey(t){return[fv(),cv(),Pb(),Du(),Bb(),Xb(),xv(),Kb(),Fb()]}function ty(t={}){const e=!t.skipBrowserExtensionCheck&&Zb(),n={...t,enabled:e?!1:t.enabled,stackParser:Hg(t.stackParser||Eb),integrations:D_({integrations:t.integrations,defaultIntegrations:t.defaultIntegrations==null?ey():t.defaultIntegrations}),transport:t.transport||fb};return V_(Zv,n)}const Hs="https://useknest.com",zs="/api/v1",ny="https://lghrsugmhzpccpriqhrx.supabase.co",ry="sb_publishable_-KUwilDA78QM849gk662FA_kEzMezNS";function sy(t=Hs){return`${t}${zs}/chat-messages`}function iy(t=Hs){return`${t}${zs}/widget-config`}const ay="Sorry, I didn't get a response.",Bu="Unknown error occurred",qu="This domain is not authorized. Please add it to your allowed origins in the Knest dashboard.",oy="This chatbot has reached its usage limit. Please contact the site owner to upgrade their plan.",ly="https://useknest.com/default-avatar.svg",ja="#3b82f6",Hu="Hi! I'm your AI assistant. I'm trained to answer questions about your documentation. How can I help you today?",cy=["How do I get started?","What features are available?","How do I integrate this?"],zu=["image/jpeg","image/png","image/gif","image/webp"],uy=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain"],Wu=[...zu,...uy],dy=Wu.join(","),hy=10*1024*1024,fy=5;function py(t=Hs){return`${t}${zs}/chat-attachments/upload-url`}function gy(t=Hs){return`${t}${zs}/chat-attachments/signed-url`}function my(t){return zu.includes(t)}const _y="knest-widget-config-",vy=1440*60*1e3;function Da(t){return _y+t}function by(t,e){try{const n=localStorage.getItem(Da(t));if(!n)return null;const{config:r,cachedAt:s}=JSON.parse(n);return Date.now()-s>vy?(localStorage.removeItem(Da(t)),null):(e&&r.updatedAt,r)}catch{return null}}function yy(t,e){try{const n={config:e,cachedAt:Date.now()};localStorage.setItem(Da(t),JSON.stringify(n))}catch{}}async function Gu(t,e){try{const n=await fetch(iy(e),{method:"GET",headers:{"X-Api-Key":t}});if(n.ok){const s=await n.json();return yy(t,s),{config:s,error:null}}if(n.status===401||n.status===403){const s=await n.json().catch(()=>({}));return console.warn("Widget config auth error:",n.status,s),{config:null,error:"auth"}}const r=await n.text();return console.warn("Failed to fetch widget config:",n.status,r),{config:null,error:"network"}}catch(n){return console.error("Error fetching widget config:",n),{config:null,error:"network"}}}async function wy(t,e,n){const r=by(t);return r?(n&&Gu(t,e).then(s=>{s.config&&s.config.updatedAt!==r.updatedAt&&n(s.config)}),{config:r,error:null}):Gu(t,e)}let Sn=null,Ws=!1,Gs=null;async function Ey(t,e){return Gs||(Ws&&Sn?!0:(Gs=(async()=>{try{Sn=Xp(t,e,{auth:{persistSession:!0,storageKey:"knest-widget-auth"}});const{data:{session:n}}=await Sn.auth.getSession();if(n)return Ws=!0,!0;const{error:r}=await Sn.auth.signInAnonymously();return r?(console.error("Widget auth error:",r.message),!1):(Ws=!0,!0)}catch(n){return console.error("Widget auth initialization failed:",n),!1}finally{Gs=null}})(),Gs))}async function Ua(){if(!Sn)return null;const{data:{session:t}}=await Sn.auth.getSession();return t?.access_token||null}function ky(){return Ws}function Sy(){return Sn}async function Ty(t){const{publishableApiKey:e,content:n,threadId:r,callbacks:s,baseUrl:i,metadata:a}=t;try{if(!ky())throw new Error("Widget not authenticated. Call initWidgetAuth() first.");const o=await Ua();if(!o)throw new Error("No access token available. Please refresh and try again.");const l={content:n};r&&(l.threadId=r),a&&(l.metadata=a);const c=await fetch(sy(i),{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":e,Authorization:`Bearer ${o}`},credentials:"include",body:JSON.stringify(l)});if(!c.ok){if(c.status===401||c.status===403)throw new Error(qu);if(c.status===429){const v=await c.json();throw v.code==="USAGE_LIMIT_EXCEEDED"?new Error(oy):new Error(v.error||"Rate limited")}const g=await c.json();throw new Error(g.error||"Failed to send message")}const u=c.body?.getReader();if(!u)throw new Error("Response body is not readable");const d=new TextDecoder;let h="",f=!1;for(;;){const{done:g,value:v}=await u.read();if(g)break;h+=d.decode(v,{stream:!0});const _=h.split(`
116
- `);h=_.pop()||"";for(const S of _)if(S.startsWith("data: "))try{const p=JSON.parse(S.slice(6));if(p.type==="init")p.threadId&&s.onInit&&s.onInit(p.threadId);else if(p.type==="content")p.content&&(f=!0,s.onContent(p.content));else if(p.type==="complete")s.onComplete&&s.onComplete(p.sources||[]);else if(p.type==="done")p.humanTakeover&&(f=!0),s.onDone&&s.onDone({humanTakeover:p.humanTakeover});else if(p.type==="error")throw new Error(p.error||Bu)}catch(p){console.error("Error parsing SSE data:",p,S)}}f||s.onError(ay)}catch(o){const l=o instanceof Error?o.message:Bu;s.onError(l)}}var Ku=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Vu={exports:{}},Ju;function Ay(){return Ju||(Ju=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
107
+ `),typeof o=="string"||o instanceof Uint8Array)s(o);else{let l;try{l=JSON.stringify(o)}catch{l=JSON.stringify(Ot(o))}s(l)}}return typeof r=="string"?r:o_(r)}function o_(t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function l_(t){const e=typeof t.data=="string"?va(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const c_={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",raw_security:"security",log:"log_item"};function Yc(t){return c_[t]}function Xc(t){if(!t?.sdk)return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function u_(t,e,n,r){const s=t.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:t.event_id,sent_at:new Date().toISOString(),...e&&{sdk:e},...!!n&&r&&{dsn:Ps(r)},...s&&{trace:s}}}function d_(t,e){return e&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||e.name,t.sdk.version=t.sdk.version||e.version,t.sdk.integrations=[...t.sdk.integrations||[],...e.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...e.packages||[]]),t}function h_(t,e,n,r){const s=Xc(n),i={sent_at:new Date().toISOString(),...s&&{sdk:s},...!!r&&e&&{dsn:Ps(e)}},a="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return Pr(i,[a])}function f_(t,e,n,r){const s=Xc(n),i=t.type&&t.type!=="replay_event"?t.type:"event";d_(t,n?.sdk);const a=u_(t,s,r,e);return delete t.sdkProcessingMetadata,Pr(a,[[{type:i},t]])}const ba=0,Zc=1,Qc=2;function kn(t){return new Gt(e=>{e(t)})}function Ns(t){return new Gt((e,n)=>{n(t)})}class Gt{constructor(e){this._state=ba,this._handlers=[],this._runExecutor(e)}then(e,n){return new Gt((r,s)=>{this._handlers.push([!1,i=>{if(!e)r(i);else try{r(e(i))}catch(a){s(a)}},i=>{if(!n)s(i);else try{r(n(i))}catch(a){s(a)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new Gt((n,r)=>{let s,i;return this.then(a=>{i=!1,s=a,e&&e()},a=>{i=!0,s=a,e&&e()}).then(()=>{if(i){r(s);return}n(s)})})}_executeHandlers(){if(this._state===ba)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===Zc&&n[1](this._value),this._state===Qc&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,a)=>{if(this._state===ba){if(Is(a)){a.then(r,s);return}this._state=i,this._value=a,this._executeHandlers()}},r=i=>{n(Zc,i)},s=i=>{n(Qc,i)};try{e(r,s)}catch(i){s(i)}}}function ya(t,e,n,r=0){return new Gt((s,i)=>{const a=t[r];if(e===null||typeof a!="function")s(e);else{const o=a({...e},n);D&&a.id&&o===null&&C.log(`Event processor "${a.id}" dropped event`),Is(o)?o.then(l=>ya(t,l,n,r+1).then(s)).then(null,i):ya(t,o,n,r+1).then(s).then(null,i)}})}function p_(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;g_(t,e),r&&v_(t,r),b_(t,n),m_(t,s),__(t,i)}function eu(t,e){const{extra:n,tags:r,user:s,contexts:i,level:a,sdkProcessingMetadata:o,breadcrumbs:l,fingerprint:c,eventProcessors:u,attachments:d,propagationContext:h,transactionName:f,span:m}=e;Ls(t,"extra",n),Ls(t,"tags",r),Ls(t,"user",s),Ls(t,"contexts",i),t.sdkProcessingMetadata=$r(t.sdkProcessingMetadata,o,2),a&&(t.level=a),f&&(t.transactionName=f),m&&(t.span=m),l.length&&(t.breadcrumbs=[...t.breadcrumbs,...l]),c.length&&(t.fingerprint=[...t.fingerprint,...c]),u.length&&(t.eventProcessors=[...t.eventProcessors,...u]),d.length&&(t.attachments=[...t.attachments,...d]),t.propagationContext={...t.propagationContext,...h}}function Ls(t,e,n){t[e]=$r(t[e],n,1)}function g_(t,e){const{extra:n,tags:r,user:s,contexts:i,level:a,transactionName:o}=e;Object.keys(n).length&&(t.extra={...n,...t.extra}),Object.keys(r).length&&(t.tags={...r,...t.tags}),Object.keys(s).length&&(t.user={...s,...t.user}),Object.keys(i).length&&(t.contexts={...i,...t.contexts}),a&&(t.level=a),o&&t.type!=="transaction"&&(t.transaction=o)}function m_(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function __(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}function v_(t,e){t.contexts={trace:jm(e),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:Qm(e),...t.sdkProcessingMetadata};const n=zc(e),r=ga(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function b_(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint.length||delete t.fingerprint}let js,tu,Ds;function y_(t){const e=Q._sentryDebugIds;if(!e)return{};const n=Object.keys(e);return Ds&&n.length===tu||(tu=n.length,Ds=n.reduce((r,s)=>{js||(js={});const i=js[s];if(i)r[i[0]]=i[1];else{const a=t(s);for(let o=a.length-1;o>=0;o--){const c=a[o]?.filename,u=e[s];if(c&&u){r[c]=u,js[s]=[c,u];break}}}return r},{})),Ds}function w_(t,e,n,r,s,i){const{normalizeDepth:a=3,normalizeMaxBreadth:o=1e3}=t,l={...e,event_id:e.event_id||n.event_id||Xe(),timestamp:e.timestamp||Ir()},c=n.integrations||t.integrations.map(v=>v.name);E_(l,t),T_(l,c),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&k_(l,t.stackParser);const u=A_(r,n.captureContext);n.mechanism&&tr(l,n.mechanism);const d=s?s.getEventProcessors():[],h=bm().getScopeData();if(i){const v=i.getScopeData();eu(h,v)}if(u){const v=u.getScopeData();eu(h,v)}const f=[...n.attachments||[],...h.attachments];f.length&&(n.attachments=f),p_(l,h);const m=[...d,...h.eventProcessors];return ya(m,l,n).then(v=>(v&&S_(v),typeof a=="number"&&a>0?x_(v,a,o):v))}function E_(t,e){const{environment:n,release:r,dist:s,maxValueLength:i=250}=e;t.environment=t.environment||n||ma,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const a=t.request;a?.url&&(a.url=$s(a.url,i))}function k_(t,e){const n=y_(e);t.exception?.values?.forEach(r=>{r.stacktrace?.frames?.forEach(s=>{s.filename&&(s.debug_id=n[s.filename])})})}function S_(t){const e={};if(t.exception?.values?.forEach(r=>{r.stacktrace?.frames?.forEach(s=>{s.debug_id&&(s.abs_path?e[s.abs_path]=s.debug_id:s.filename&&(e[s.filename]=s.debug_id),delete s.debug_id)})}),Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.entries(e).forEach(([r,s])=>{n.push({type:"sourcemap",code_file:r,debug_id:s})})}function T_(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function x_(t,e,n){if(!t)return null;const r={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(s=>({...s,...s.data&&{data:Ot(s.data,e,n)}}))},...t.user&&{user:Ot(t.user,e,n)},...t.contexts&&{contexts:Ot(t.contexts,e,n)},...t.extra&&{extra:Ot(t.extra,e,n)}};return t.contexts?.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=Ot(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(s=>({...s,...s.data&&{data:Ot(s.data,e,n)}}))),t.contexts?.flags&&r.contexts&&(r.contexts.flags=Ot(t.contexts.flags,3,n)),r}function A_(t,e){if(!e)return t;const n=t?t.clone():new pt;return n.update(e),n}function R_(t){if(t)return O_(t)?{captureContext:t}:$_(t)?{captureContext:t}:t}function O_(t){return t instanceof pt||typeof t=="function"}const I_=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function $_(t){return Object.keys(t).some(e=>I_.includes(e))}function nu(t,e){return Wt().captureException(t,R_(e))}function ru(t,e){return Wt().captureEvent(t,e)}function su(t){const e=Cr(),n=Wt(),{userAgent:r}=Q.navigator||{},s=cm({user:n.getUser()||e.getUser(),...r&&{userAgent:r},...t}),i=e.getSession();return i?.status==="ok"&&nr(i,{status:"exited"}),iu(),e.setSession(s),s}function iu(){const t=Cr(),n=Wt().getSession()||t.getSession();n&&um(n),au(),t.setSession()}function au(){const t=Cr(),e=Ie(),n=t.getSession();n&&e&&e.captureSession(n)}function ou(t=!1){if(t){iu();return}au()}const C_="7";function P_(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function N_(t){return`${P_(t)}${t.projectId}/envelope/`}function L_(t,e){const n={sentry_version:C_};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function j_(t,e,n){return e||`${N_(t)}?${L_(t,n)}`}const lu=[];function D_(t){const e={};return t.forEach(n=>{const{name:r}=n,s=e[r];s&&!s.isDefaultInstance&&n.isDefaultInstance||(e[r]=n)}),Object.values(e)}function U_(t){const e=t.defaultIntegrations||[],n=t.integrations;e.forEach(s=>{s.isDefaultInstance=!0});let r;if(Array.isArray(n))r=[...e,...n];else if(typeof n=="function"){const s=n(e);r=Array.isArray(s)?s:[s]}else r=e;return D_(r)}function F_(t,e){const n={};return e.forEach(r=>{r&&uu(t,r,n)}),n}function cu(t,e){for(const n of e)n?.afterAllSetup&&n.afterAllSetup(t)}function uu(t,e,n){if(n[e.name]){D&&C.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,lu.indexOf(e.name)===-1&&typeof e.setupOnce=="function"&&(e.setupOnce(),lu.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){const r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,i)=>r(s,i,t))}if(typeof e.processEvent=="function"){const r=e.processEvent.bind(e),s=Object.assign((i,a)=>r(i,a,t),{id:e.name});t.addEventProcessor(s)}D&&C.log(`Integration installed: ${e.name}`)}function Jw(t){return t}function M_(t,e,n){const r=[{type:"client_report"},{timestamp:Ir(),discarded_events:t}];return Pr(e?{dsn:e}:{},[r])}function du(t){const e=[];t.message&&e.push(t.message);try{const n=t.exception.values[t.exception.values.length-1];n?.value&&(e.push(n.value),n.type&&e.push(`${n.type}: ${n.value}`))}catch{}return e}function B_(t){const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:a,op:o}=t.contexts?.trace??{};return{data:a??{},description:t.transaction,op:o,parent_span_id:n,span_id:r??"",start_timestamp:t.start_timestamp??0,status:s,timestamp:t.timestamp,trace_id:e??"",origin:i,profile_id:a?.[jc],exclusive_time:a?.[Dc],measurements:t.measurements,is_segment:!0}}function q_(t){return{type:"transaction",timestamp:t.timestamp,start_timestamp:t.start_timestamp,transaction:t.description,contexts:{trace:{trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,op:t.op,status:t.status,origin:t.origin,data:{...t.data,...t.profile_id&&{[jc]:t.profile_id},...t.exclusive_time&&{[Dc]:t.exclusive_time}}}},measurements:t.measurements}}const hu="Not capturing exception because it's already been captured.",fu="Discarded session because of missing or non-string release",pu=Symbol.for("SentryInternalError"),gu=Symbol.for("SentryDoNotSendEventError");function Us(t){return{message:t,[pu]:!0}}function wa(t){return{message:t,[gu]:!0}}function mu(t){return!!t&&typeof t=="object"&&pu in t}function _u(t){return!!t&&typeof t=="object"&&gu in t}class H_{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=Ym(e.dsn):D&&C.warn("No DSN provided, client will not send events."),this._dsn){const n=j_(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:n})}}captureException(e,n,r){const s=Xe();if(Rc(e))return D&&C.log(hu),s;const i={event_id:s,...n};return this._process(this.eventFromException(e,i).then(a=>this._captureEvent(a,i,r))),i.event_id}captureMessage(e,n,r,s){const i={event_id:Xe(),...r},a=oa(e)?e:String(e),o=la(e)?this.eventFromMessage(a,n,i):this.eventFromException(e,i);return this._process(o.then(l=>this._captureEvent(l,i,s))),i.event_id}captureEvent(e,n,r){const s=Xe();if(n?.originalException&&Rc(n.originalException))return D&&C.log(hu),s;const i={event_id:s,...n},a=e.sdkProcessingMetadata||{},o=a.capturedSpanScope,l=a.capturedSpanIsolationScope;return this._process(this._captureEvent(e,i,o||r,l)),i.event_id}captureSession(e){this.sendSession(e),nr(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const n=this._transport;return n?(this.emit("flush"),this._isClientDoneProcessing(e).then(r=>n.flush(e).then(s=>r&&s))):kn(!0)}close(e){return this.flush(e).then(n=>(this.getOptions().enabled=!1,this.emit("close"),n))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}addIntegration(e){const n=this._integrations[e.name];uu(this,e,this._integrations),n||cu(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);let r=f_(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])r=i_(r,l_(i));const s=this.sendEnvelope(r);s&&s.then(i=>this.emit("afterSendEvent",e,i),null)}sendSession(e){const{release:n,environment:r=ma}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){D&&C.warn(fu);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){D&&C.warn(fu);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=h_(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(s)}recordDroppedEvent(e,n,r=1){if(this._options.sendClientReports){const s=`${e}:${n}`;D&&C.log(`Recording outcome: "${s}"${r>1?` (${r} times)`:""}`),this._outcomes[s]=(this._outcomes[s]||0)+r}}on(e,n){const r=this._hooks[e]=this._hooks[e]||[];return r.push(n),()=>{const s=r.indexOf(n);s>-1&&r.splice(s,1)}}emit(e,...n){const r=this._hooks[e];r&&r.forEach(s=>s(...n))}sendEnvelope(e){return this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport?this._transport.send(e).then(null,n=>(D&&C.error("Error while sending envelope:",n),n)):(D&&C.error("Transport disabled"),kn({}))}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=F_(this,e),cu(this,e)}_updateSessionFromEvent(e,n){let r=n.level==="fatal",s=!1;const i=n.exception?.values;if(i){s=!0;for(const l of i)if(l.mechanism?.handled===!1){r=!0;break}}const a=e.status==="ok";(a&&e.errors===0||a&&r)&&(nr(e,{...r&&{status:"crashed"},errors:e.errors||Number(s||r)}),this.captureSession(e))}_isClientDoneProcessing(e){return new Gt(n=>{let r=0;const s=1,i=setInterval(()=>{this._numProcessing==0?(clearInterval(i),n(!0)):(r+=s,e&&r>=e&&(clearInterval(i),n(!1)))},s)})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s){const i=this.getOptions(),a=Object.keys(this._integrations);return!n.integrations&&a?.length&&(n.integrations=a),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),w_(i,e,n,r,this,s).then(o=>{if(o===null)return o;this.emit("postprocessEvent",o,n),o.contexts={trace:wm(r),...o.contexts};const l=Zm(this,r);return o.sdkProcessingMetadata={dynamicSamplingContext:l,...o.sdkProcessingMetadata},o})}_captureEvent(e,n={},r=Wt(),s=Cr()){return D&&Ea(e)&&C.log(`Captured error event \`${du(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{D&&(_u(i)?C.log(i.message):mu(i)?C.warn(i.message):C.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:a}=i,o=vu(e),l=Ea(e),c=e.type||"error",u=`before send for type \`${c}\``,d=typeof a>"u"?void 0:Lm(a);if(l&&typeof d=="number"&&Math.random()>d)return this.recordDroppedEvent("sample_rate","error"),Ns(wa(`Discarding event because it's not included in the random sample (sampling rate = ${a})`));const h=c==="replay_event"?"replay":c;return this._prepareEvent(e,n,r,s).then(f=>{if(f===null)throw this.recordDroppedEvent("event_processor",h),wa("An event processor returned `null`, will not send event.");if(n.data&&n.data.__sentry__===!0)return f;const _=W_(this,i,f,n);return z_(_,u)}).then(f=>{if(f===null){if(this.recordDroppedEvent("before_send",h),o){const S=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",S)}throw wa(`${u} returned \`null\`, will not send event.`)}const m=r.getSession()||s.getSession();if(l&&m&&this._updateSessionFromEvent(m,f),o){const v=f.sdkProcessingMetadata?.spanCountBeforeProcessing||0,S=f.spans?f.spans.length:0,g=v-S;g>0&&this.recordDroppedEvent("before_send","span",g)}const _=f.transaction_info;if(o&&_&&f.transaction!==e.transaction){const v="custom";f.transaction_info={..._,source:v}}return this.sendEvent(f,n),f}).then(null,f=>{throw _u(f)||mu(f)?f:(this.captureException(f,{data:{__sentry__:!0},originalException:f}),Us(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
108
+ Reason: ${f}`))})}_process(e){this._numProcessing++,e.then(n=>(this._numProcessing--,n),n=>(this._numProcessing--,n))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([n,r])=>{const[s,i]=n.split(":");return{reason:s,category:i,quantity:r}})}_flushOutcomes(){D&&C.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){D&&C.log("No outcomes to send");return}if(!this._dsn){D&&C.log("No dsn provided, will not send outcomes");return}D&&C.log("Sending outcomes:",e);const n=M_(e,this._options.tunnel&&Ps(this._dsn));this.sendEnvelope(n)}}function z_(t,e){const n=`${e} must return \`null\` or a valid event.`;if(Is(t))return t.then(r=>{if(!Or(r)&&r!==null)throw Us(n);return r},r=>{throw Us(`${e} rejected with ${r}`)});if(!Or(t)&&t!==null)throw Us(n);return t}function W_(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,beforeSendSpan:a}=e;let o=n;if(Ea(o)&&s)return s(o,r);if(vu(o)){if(a){const l=a(B_(o));if(l?o=$r(n,q_(l)):Wc(),o.spans){const c=[];for(const u of o.spans){const d=a(u);d?c.push(d):(Wc(),c.push(u))}o.spans=c}}if(i){if(o.spans){const l=o.spans.length;o.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:l}}return i(o,r)}}return o}function Ea(t){return t.type===void 0}function vu(t){return t.type==="transaction"}function G_(t){return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},{items:t}]}function K_(t,e,n,r){const s={};return e?.sdk&&(s.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(s.dsn=Ps(r)),Pr(s,[G_(t)])}function ka(t,e){const n=V_(t)??[];if(n.length===0)return;const r=t.getOptions(),s=K_(n,r._metadata,r.tunnel,t.getDsn());bu().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function V_(t){return bu().get(t)}function bu(){return Rr("clientToLogBufferMap",()=>new WeakMap)}function J_(t,e){e.debug===!0&&(D?C.enable():Qn(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),Wt().update(e.initialScope);const r=new t(e);return Y_(r),r.init(),r}function Y_(t){Wt().setClient(t)}const yu=Symbol.for("SentryBufferFullError");function X_(t){const e=[];function n(){return t===void 0||e.length<t}function r(a){return e.splice(e.indexOf(a),1)[0]||Promise.resolve(void 0)}function s(a){if(!n())return Ns(yu);const o=a();return e.indexOf(o)===-1&&e.push(o),o.then(()=>r(o)).then(null,()=>r(o).then(null,()=>{})),o}function i(a){return new Gt((o,l)=>{let c=e.length;if(!c)return o(!0);const u=setTimeout(()=>{a&&a>0&&o(!1)},a);e.forEach(d=>{kn(d).then(()=>{--c||(clearTimeout(u),o(!0))},l)})})}return{$:e,add:s,drain:i}}const Z_=60*1e3;function Q_(t,e=Date.now()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?Z_:r-e}function ev(t,e){return t[e]||t.all||0}function tv(t,e,n=Date.now()){return ev(t,e)>n}function nv(t,{statusCode:e,headers:n},r=Date.now()){const s={...t},i=n?.["x-sentry-rate-limits"],a=n?.["retry-after"];if(i)for(const o of i.trim().split(",")){const[l,c,,,u]=o.split(":",5),d=parseInt(l,10),h=(isNaN(d)?60:d)*1e3;if(!c)s.all=r+h;else for(const f of c.split(";"))f==="metric_bucket"?(!u||u.split(";").includes("custom"))&&(s[f]=r+h):s[f]=r+h}else a?s.all=r+Q_(a,r):e===429&&(s.all=r+60*1e3);return s}const rv=64;function sv(t,e,n=X_(t.bufferSize||rv)){let r={};const s=a=>n.drain(a);function i(a){const o=[];if(Jc(a,(d,h)=>{const f=Yc(h);tv(r,f)?t.recordDroppedEvent("ratelimit_backoff",f):o.push(d)}),o.length===0)return kn({});const l=Pr(a[0],o),c=d=>{Jc(l,(h,f)=>{t.recordDroppedEvent(d,Yc(f))})},u=()=>e({body:a_(l)}).then(d=>(d.statusCode!==void 0&&(d.statusCode<200||d.statusCode>=300)&&D&&C.warn(`Sentry responded with status code ${d.statusCode} to sent event.`),r=nv(r,d),d),d=>{throw c("network_error"),D&&C.error("Encountered error running transport request:",d),d});return n.add(u).then(d=>d,d=>{if(d===yu)return D&&C.error("Skipped sending event because buffer is full."),c("queue_overflow"),kn({});throw d})}return{send:i,flush:s}}function iv(t){t.user?.ip_address===void 0&&(t.user={...t.user,ip_address:"{{auto}}"})}function av(t){"aggregates"in t?t.attrs?.ip_address===void 0&&(t.attrs={...t.attrs,ip_address:"{{auto}}"}):t.ipAddress===void 0&&(t.ipAddress="{{auto}}")}function ov(t,e,n=[e],r="npm"){const s=t._metadata||{};s.sdk||(s.sdk={name:`sentry.javascript.${e}`,packages:n.map(i=>({name:`${r}:@sentry/${i}`,version:_n})),version:_n}),t._metadata=s}const lv=100;function Sn(t,e){const n=Ie(),r=Cr();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=lv}=n.getOptions();if(i<=0)return;const o={timestamp:Ir(),...t},l=s?Qn(()=>s(o,e)):o;l!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",l,e),r.addBreadcrumb(l,i))}let wu;const cv="FunctionToString",Eu=new WeakMap,uv=(()=>({name:cv,setupOnce(){wu=Function.prototype.toString;try{Function.prototype.toString=function(...t){const e=da(this),n=Eu.has(Ie())&&e!==void 0?e:this;return wu.apply(n,t)}}catch{}},setup(t){Eu.set(t,!0)}})),dv=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,`can't redefine non-configurable property "solana"`,"vv().getRestrictions is not a function. (In 'vv().getRestrictions(1,a)', 'vv().getRestrictions' is undefined)","Can't find variable: _AutofillCallbackHandler",/^Non-Error promise rejection captured with value: Object Not Found Matching Id:\d+, MethodName:simulateEvent, ParamCount:\d+$/,/^Java exception was raised during method invocation$/],hv="EventFilters",fv=(t={})=>{let e;return{name:hv,setup(n){const r=n.getOptions();e=ku(t,r)},processEvent(n,r,s){if(!e){const i=s.getOptions();e=ku(t,i)}return gv(n,e)?null:n}}},pv=((t={})=>({...fv(t),name:"InboundFilters"}));function ku(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:dv],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[]]}}function gv(t,e){if(t.type){if(t.type==="transaction"&&_v(t,e.ignoreTransactions))return D&&C.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
109
+ Event: ${En(t)}`),!0}else{if(mv(t,e.ignoreErrors))return D&&C.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
110
+ Event: ${En(t)}`),!0;if(wv(t))return D&&C.warn(`Event dropped due to not having an error message, error type or stacktrace.
111
+ Event: ${En(t)}`),!0;if(vv(t,e.denyUrls))return D&&C.warn(`Event dropped due to being matched by \`denyUrls\` option.
112
+ Event: ${En(t)}.
113
+ Url: ${Fs(t)}`),!0;if(!bv(t,e.allowUrls))return D&&C.warn(`Event dropped due to not being matched by \`allowUrls\` option.
114
+ Event: ${En(t)}.
115
+ Url: ${Fs(t)}`),!0}return!1}function mv(t,e){return e?.length?du(t).some(n=>Cs(n,e)):!1}function _v(t,e){if(!e?.length)return!1;const n=t.transaction;return n?Cs(n,e):!1}function vv(t,e){if(!e?.length)return!1;const n=Fs(t);return n?Cs(n,e):!1}function bv(t,e){if(!e?.length)return!0;const n=Fs(t);return n?Cs(n,e):!0}function yv(t=[]){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n&&n.filename!=="<anonymous>"&&n.filename!=="[native code]")return n.filename||null}return null}function Fs(t){try{const n=[...t.exception?.values??[]].reverse().find(r=>r.mechanism?.parent_id===void 0&&r.stacktrace?.frames?.length)?.stacktrace?.frames;return n?yv(n):null}catch{return D&&C.error(`Cannot extract url for event ${En(t)}`),null}}function wv(t){return t.exception?.values?.length?!t.message&&!t.exception.values.some(e=>e.stacktrace||e.type&&e.type!=="Error"||e.value):!1}function Ev(t,e,n,r,s,i){if(!s.exception?.values||!i||!zt(i.originalException,Error))return;const a=s.exception.values.length>0?s.exception.values[s.exception.values.length-1]:void 0;a&&(s.exception.values=Sa(t,e,r,i.originalException,n,s.exception.values,a,0))}function Sa(t,e,n,r,s,i,a,o){if(i.length>=n+1)return i;let l=[...i];if(zt(r[s],Error)){Su(a,o);const c=t(e,r[s]),u=l.length;Tu(c,s,u,o),l=Sa(t,e,n,r[s],s,[c,...l],c,u)}return Array.isArray(r.errors)&&r.errors.forEach((c,u)=>{if(zt(c,Error)){Su(a,o);const d=t(e,c),h=l.length;Tu(d,`errors[${u}]`,h,o),l=Sa(t,e,n,c,s,[d,...l],d,h)}}),l}function Su(t,e){t.mechanism=t.mechanism||{type:"generic",handled:!0},t.mechanism={...t.mechanism,...t.type==="AggregateError"&&{is_exception_group:!0},exception_id:e}}function Tu(t,e,n,r){t.mechanism=t.mechanism||{type:"generic",handled:!0},t.mechanism={...t.mechanism,type:"chained",source:e,exception_id:n,parent_id:r}}function kv(t){const e="console";bn(e,t),yn(e,Sv)}function Sv(){"console"in Q&&Dg.forEach(function(t){t in Q.console&&We(Q.console,t,function(e){return xs[t]=e,function(...n){at("console",{args:n,level:t}),xs[t]?.apply(Q.console,n)}})})}function Tv(t){return t==="warn"?"warning":["fatal","error","warning","log","info","debug"].includes(t)?t:"log"}const xv="Dedupe",Av=(()=>{let t;return{name:xv,processEvent(e){if(e.type)return e;try{if(Rv(e,t))return D&&C.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return t=e}}});function Rv(t,e){return e?!!(Ov(t,e)||Iv(t,e)):!1}function Ov(t,e){const n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!Au(t,e)||!xu(t,e))}function Iv(t,e){const n=Ru(e),r=Ru(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!Au(t,e)||!xu(t,e))}function xu(t,e){let n=gc(t),r=gc(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let s=0;s<r.length;s++){const i=r[s],a=n[s];if(i.filename!==a.filename||i.lineno!==a.lineno||i.colno!==a.colno||i.function!==a.function)return!1}return!0}function Au(t,e){let n=t.fingerprint,r=e.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;n=n,r=r;try{return n.join("")===r.join("")}catch{return!1}}function Ru(t){return t.exception?.values?.[0]}function Ta(t){if(!t)return{};const e=t.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)return{};const n=e[6]||"",r=e[8]||"";return{host:e[4],path:e[5],protocol:e[2],search:n,hash:r,relative:e[5]+n+r}}function Ou(t){if(t!==void 0)return t>=400&&t<500?"warning":t>=500?"error":void 0}const Nr=Q;function $v(){return"history"in Nr&&!!Nr.history}function Cv(){if(!("fetch"in Nr))return!1;try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch{return!1}}function xa(t){return t&&/^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(t.toString())}function Pv(){if(typeof EdgeRuntime=="string")return!0;if(!Cv())return!1;if(xa(Nr.fetch))return!0;let t=!1;const e=Nr.document;if(e&&typeof e.createElement=="function")try{const n=e.createElement("iframe");n.hidden=!0,e.head.appendChild(n),n.contentWindow?.fetch&&(t=xa(n.contentWindow.fetch)),e.head.removeChild(n)}catch(n){D&&C.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",n)}return t}function Nv(t,e){const n="fetch";bn(n,t),yn(n,()=>Lv(void 0,e))}function Lv(t,e=!1){e&&!Pv()||We(Q,"fetch",function(n){return function(...r){const s=new Error,{method:i,url:a}=jv(r),o={args:r,fetchData:{method:i,url:a},startTimestamp:Rt()*1e3,virtualError:s,headers:Dv(r)};return at("fetch",{...o}),n.apply(Q,r).then(async l=>(at("fetch",{...o,endTimestamp:Rt()*1e3,response:l}),l),l=>{if(at("fetch",{...o,endTimestamp:Rt()*1e3,error:l}),aa(l)&&l.stack===void 0&&(l.stack=s.stack,wn(l,"framesToPop",1)),l instanceof TypeError&&(l.message==="Failed to fetch"||l.message==="Load failed"||l.message==="NetworkError when attempting to fetch resource."))try{const c=new URL(o.fetchData.url);l.message=`${l.message} (${c.host})`}catch{}throw l})}})}function Aa(t,e){return!!t&&typeof t=="object"&&!!t[e]}function Iu(t){return typeof t=="string"?t:t?Aa(t,"url")?t.url:t.toString?t.toString():"":""}function jv(t){if(t.length===0)return{method:"GET",url:""};if(t.length===2){const[n,r]=t;return{url:Iu(n),method:Aa(r,"method")?String(r.method).toUpperCase():"GET"}}const e=t[0];return{url:Iu(e),method:Aa(e,"method")?String(e.method).toUpperCase():"GET"}}function Dv(t){const[e,n]=t;try{if(typeof n=="object"&&n!==null&&"headers"in n&&n.headers)return new Headers(n.headers);if(em(e))return new Headers(e.headers)}catch{}}function Uv(){return"npm"}const le=Q;let Ra=0;function $u(){return Ra>0}function Fv(){Ra++,setTimeout(()=>{Ra--})}function sr(t,e={}){function n(s){return typeof s=="function"}if(!n(t))return t;try{const s=t.__sentry_wrapped__;if(s)return typeof s=="function"?s:t;if(da(t))return t}catch{return t}const r=function(...s){try{const i=s.map(a=>sr(a,e));return t.apply(this,i)}catch(i){throw Fv(),ym(a=>{a.addEventProcessor(o=>(e.mechanism&&(ha(o,void 0),tr(o,e.mechanism)),o.extra={...o.extra,arguments:s},o)),nu(i)}),i}};try{for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}catch{}kc(r,t),wn(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}function Mv(){const t=ua(),{referrer:e}=le.document||{},{userAgent:n}=le.navigator||{},r={...e&&{Referer:e},...n&&{"User-Agent":n}};return{url:t,headers:r}}function Oa(t,e){const n=$a(t,e),r={type:Wv(e),value:Gv(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function Bv(t,e,n,r){const i=Ie()?.getOptions().normalizeDepth,a=Xv(e),o={__serialized__:Vc(e,i)};if(a)return{exception:{values:[Oa(t,a)]},extra:o};const l={exception:{values:[{type:Os(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:Jv(e,{isUnhandledRejection:r})}]},extra:o};if(n){const c=$a(t,n);c.length&&(l.exception.values[0].stacktrace={frames:c})}return l}function Ia(t,e){return{exception:{values:[Oa(t,e)]}}}function $a(t,e){const n=e.stacktrace||e.stack||"",r=Hv(e),s=zv(e);try{return t(n,r,s)}catch{}return[]}const qv=/Minified React error #\d+;/i;function Hv(t){return t&&qv.test(t.message)?1:0}function zv(t){return typeof t.framesToPop=="number"?t.framesToPop:0}function Cu(t){return typeof WebAssembly<"u"&&typeof WebAssembly.Exception<"u"?t instanceof WebAssembly.Exception:!1}function Wv(t){const e=t?.name;return!e&&Cu(t)?t.message&&Array.isArray(t.message)&&t.message.length==2?t.message[0]:"WebAssembly.Exception":e}function Gv(t){const e=t?.message;return Cu(t)?Array.isArray(t.message)&&t.message.length==2?t.message[1]:"wasm exception":e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function Kv(t,e,n,r){const s=n?.syntheticException||void 0,i=Ca(t,e,s,r);return tr(i),i.level="error",n?.event_id&&(i.event_id=n.event_id),kn(i)}function Vv(t,e,n="info",r,s){const i=r?.syntheticException||void 0,a=Pa(t,e,i,s);return a.level=n,r?.event_id&&(a.event_id=r.event_id),kn(a)}function Ca(t,e,n,r,s){let i;if(vc(e)&&e.error)return Ia(t,e.error);if(bc(e)||Yg(e)){const a=e;if("stack"in e)i=Ia(t,e);else{const o=a.name||(bc(a)?"DOMError":"DOMException"),l=a.message?`${o}: ${a.message}`:o;i=Pa(t,l,n,r),ha(i,l)}return"code"in a&&(i.tags={...i.tags,"DOMException.code":`${a.code}`}),i}return aa(e)?Ia(t,e):Or(e)||Os(e)?(i=Bv(t,e,n,s),tr(i,{synthetic:!0}),i):(i=Pa(t,e,n,r),ha(i,`${e}`),tr(i,{synthetic:!0}),i)}function Pa(t,e,n,r){const s={};if(r&&n){const i=$a(t,n);i.length&&(s.exception={values:[{value:e,stacktrace:{frames:i}}]}),tr(s,{synthetic:!0})}if(oa(e)){const{__sentry_template_string__:i,__sentry_template_values__:a}=e;return s.logentry={message:i,params:a},s}return s.message=e,s}function Jv(t,{isUnhandledRejection:e}){const n=im(t),r=e?"promise rejection":"exception";return vc(t)?`Event \`ErrorEvent\` captured as ${r} with message \`${t.message}\``:Os(t)?`Event \`${Yv(t)}\` (type=${t.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}function Yv(t){try{const e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{}}function Xv(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if(n instanceof Error)return n}}const Zv=5e3;class Qv extends H_{constructor(e){const n=eb(e),r=le.SENTRY_SDK_SOURCE||Uv();ov(n,"browser",["browser"],r),super(n);const{sendDefaultPii:s,sendClientReports:i,enableLogs:a,_experiments:o}=this._options,l=a??o?.enableLogs;le.document&&(i||l)&&le.document.addEventListener("visibilitychange",()=>{le.document.visibilityState==="hidden"&&(i&&this._flushOutcomes(),l&&ka(this))}),l&&(this.on("flush",()=>{ka(this)}),this.on("afterCaptureLog",()=>{this._logFlushIdleTimeout&&clearTimeout(this._logFlushIdleTimeout),this._logFlushIdleTimeout=setTimeout(()=>{ka(this)},Zv)})),s&&(this.on("postprocessEvent",iv),this.on("beforeSendSession",av))}eventFromException(e,n){return Kv(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Vv(this._options.stackParser,e,n,r,this._options.attachStacktrace)}_prepareEvent(e,n,r,s){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r,s)}}function eb(t){return{release:typeof __SENTRY_RELEASE__=="string"?__SENTRY_RELEASE__:le.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...t}}const tb=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,$e=Q,nb=1e3;let Pu,Na,La;function rb(t){bn("dom",t),yn("dom",sb)}function sb(){if(!$e.document)return;const t=at.bind(null,"dom"),e=Nu(t,!0);$e.document.addEventListener("click",e,!1),$e.document.addEventListener("keypress",e,!1),["EventTarget","Node"].forEach(n=>{const s=$e[n]?.prototype;s?.hasOwnProperty?.("addEventListener")&&(We(s,"addEventListener",function(i){return function(a,o,l){if(a==="click"||a=="keypress")try{const c=this.__sentry_instrumentation_handlers__=this.__sentry_instrumentation_handlers__||{},u=c[a]=c[a]||{refCount:0};if(!u.handler){const d=Nu(t);u.handler=d,i.call(this,a,d,l)}u.refCount++}catch{}return i.call(this,a,o,l)}}),We(s,"removeEventListener",function(i){return function(a,o,l){if(a==="click"||a=="keypress")try{const c=this.__sentry_instrumentation_handlers__||{},u=c[a];u&&(u.refCount--,u.refCount<=0&&(i.call(this,a,u.handler,l),u.handler=void 0,delete c[a]),Object.keys(c).length===0&&delete this.__sentry_instrumentation_handlers__)}catch{}return i.call(this,a,o,l)}}))})}function ib(t){if(t.type!==Na)return!1;try{if(!t.target||t.target._sentryId!==La)return!1}catch{}return!0}function ab(t,e){return t!=="keypress"?!1:e?.tagName?!(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable):!0}function Nu(t,e=!1){return n=>{if(!n||n._sentryCaptured)return;const r=ob(n);if(ab(n.type,r))return;wn(n,"_sentryCaptured",!0),r&&!r._sentryId&&wn(r,"_sentryId",Xe());const s=n.type==="keypress"?"input":n.type;ib(n)||(t({event:n,name:s,global:e}),Na=n.type,La=r?r._sentryId:void 0),clearTimeout(Pu),Pu=$e.setTimeout(()=>{La=void 0,Na=void 0},nb)}}function ob(t){try{return t.target}catch{return null}}let Ms;function Lu(t){const e="history";bn(e,t),yn(e,lb)}function lb(){if($e.addEventListener("popstate",()=>{const e=$e.location.href,n=Ms;if(Ms=e,n===e)return;at("history",{from:n,to:e})}),!$v())return;function t(e){return function(...n){const r=n.length>2?n[2]:void 0;if(r){const s=Ms,i=cb(String(r));if(Ms=i,s===i)return e.apply(this,n);at("history",{from:s,to:i})}return e.apply(this,n)}}We($e.history,"pushState",t),We($e.history,"replaceState",t)}function cb(t){try{return new URL(t,$e.location.origin).toString()}catch{return t}}const Bs={};function ub(t){const e=Bs[t];if(e)return e;let n=$e[t];if(xa(n))return Bs[t]=n.bind($e);const r=$e.document;if(r&&typeof r.createElement=="function")try{const s=r.createElement("iframe");s.hidden=!0,r.head.appendChild(s);const i=s.contentWindow;i?.[t]&&(n=i[t]),r.head.removeChild(s)}catch(s){tb&&C.warn(`Could not create sandbox iframe for ${t} check, bailing to window.${t}: `,s)}return n&&(Bs[t]=n.bind($e))}function ju(t){Bs[t]=void 0}const Lr="__sentry_xhr_v3__";function db(t){bn("xhr",t),yn("xhr",hb)}function hb(){if(!$e.XMLHttpRequest)return;const t=XMLHttpRequest.prototype;t.open=new Proxy(t.open,{apply(e,n,r){const s=new Error,i=Rt()*1e3,a=At(r[0])?r[0].toUpperCase():void 0,o=fb(r[1]);if(!a||!o)return e.apply(n,r);n[Lr]={method:a,url:o,request_headers:{}},a==="POST"&&o.match(/sentry_key/)&&(n.__sentry_own_request__=!0);const l=()=>{const c=n[Lr];if(c&&n.readyState===4){try{c.status_code=n.status}catch{}const u={endTimestamp:Rt()*1e3,startTimestamp:i,xhr:n,virtualError:s};at("xhr",u)}};return"onreadystatechange"in n&&typeof n.onreadystatechange=="function"?n.onreadystatechange=new Proxy(n.onreadystatechange,{apply(c,u,d){return l(),c.apply(u,d)}}):n.addEventListener("readystatechange",l),n.setRequestHeader=new Proxy(n.setRequestHeader,{apply(c,u,d){const[h,f]=d,m=u[Lr];return m&&At(h)&&At(f)&&(m.request_headers[h.toLowerCase()]=f),c.apply(u,d)}}),e.apply(n,r)}}),t.send=new Proxy(t.send,{apply(e,n,r){const s=n[Lr];if(!s)return e.apply(n,r);r[0]!==void 0&&(s.body=r[0]);const i={startTimestamp:Rt()*1e3,xhr:n};return at("xhr",i),e.apply(n,r)}})}function fb(t){if(At(t))return t;try{return t.toString()}catch{}}function pb(t,e=ub("fetch")){let n=0,r=0;function s(i){const a=i.body.length;n+=a,r++;const o={body:i.body,method:"POST",referrerPolicy:"strict-origin",headers:t.headers,keepalive:n<=6e4&&r<15,...t.fetchOptions};if(!e)return ju("fetch"),Ns("No fetch implementation available");try{return e(t.url,o).then(l=>(n-=a,r--,{statusCode:l.status,headers:{"x-sentry-rate-limits":l.headers.get("X-Sentry-Rate-Limits"),"retry-after":l.headers.get("Retry-After")}}))}catch(l){return ju("fetch"),n-=a,r--,Ns(l)}}return sv(t,s)}const gb=30,mb=50;function ja(t,e,n,r){const s={filename:t,function:e==="<anonymous>"?vn:e,in_app:!0};return n!==void 0&&(s.lineno=n),r!==void 0&&(s.colno=r),s}const _b=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,vb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,bb=/\((\S*)(?::(\d+))(?::(\d+))\)/,yb=[gb,t=>{const e=_b.exec(t);if(e){const[,r,s,i]=e;return ja(r,vn,+s,+i)}const n=vb.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=bb.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[s,i]=Du(n[1]||vn,n[2]);return ja(i,s,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}}],wb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Eb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,kb=pc(...[yb,[mb,t=>{const e=wb.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const i=Eb.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],s=e[1]||vn;return[s,r]=Du(s,r),ja(r,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]),Du=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:vn,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},qs=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Hs=1024,Sb="Breadcrumbs",Uu=((t={})=>{const e={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...t};return{name:Sb,setup(n){e.console&&kv(Ab(n)),e.dom&&rb(xb(n,e.dom)),e.xhr&&db(Rb(n)),e.fetch&&Nv(Ob(n)),e.history&&Lu(Ib(n)),e.sentry&&n.on("beforeSendEvent",Tb(n))}}});function Tb(t){return function(n){Ie()===t&&Sn({category:`sentry.${n.type==="transaction"?"transaction":"event"}`,event_id:n.event_id,level:n.level,message:En(n)},{event:n})}}function xb(t,e){return function(r){if(Ie()!==t)return;let s,i,a=typeof e=="object"?e.serializeAttribute:void 0,o=typeof e=="object"&&typeof e.maxStringLength=="number"?e.maxStringLength:void 0;o&&o>Hs&&(qs&&C.warn(`\`dom.maxStringLength\` cannot exceed ${Hs}, but a value of ${o} was configured. Sentry will use ${Hs} instead.`),o=Hs),typeof a=="string"&&(a=[a]);try{const c=r.event,u=$b(c)?c.target:c;s=wc(u,{keyAttrs:a,maxStringLength:o}),i=rm(u)}catch{s="<unknown>"}if(s.length===0)return;const l={category:`ui.${r.name}`,message:s};i&&(l.data={"ui.component_name":i}),Sn(l,{event:r.event,name:r.name,global:r.global})}}function Ab(t){return function(n){if(Ie()!==t)return;const r={category:"console",data:{arguments:n.args,logger:"console"},level:Tv(n.level),message:Ec(n.args," ")};if(n.level==="assert")if(n.args[0]===!1)r.message=`Assertion failed: ${Ec(n.args.slice(1)," ")||"console.assert"}`,r.data.arguments=n.args.slice(1);else return;Sn(r,{input:n.args,level:n.level})}}function Rb(t){return function(n){if(Ie()!==t)return;const{startTimestamp:r,endTimestamp:s}=n,i=n.xhr[Lr];if(!r||!s||!i)return;const{method:a,url:o,status_code:l,body:c}=i,u={method:a,url:o,status_code:l},d={xhr:n.xhr,input:c,startTimestamp:r,endTimestamp:s},h={category:"xhr",data:u,type:"http",level:Ou(l)};t.emit("beforeOutgoingRequestBreadcrumb",h,d),Sn(h,d)}}function Ob(t){return function(n){if(Ie()!==t)return;const{startTimestamp:r,endTimestamp:s}=n;if(s&&!(n.fetchData.url.match(/sentry_key/)&&n.fetchData.method==="POST"))if(n.fetchData.method,n.fetchData.url,n.error){const i=n.fetchData,a={data:n.error,input:n.args,startTimestamp:r,endTimestamp:s},o={category:"fetch",data:i,level:"error",type:"http"};t.emit("beforeOutgoingRequestBreadcrumb",o,a),Sn(o,a)}else{const i=n.response,a={...n.fetchData,status_code:i?.status};n.fetchData.request_body_size,n.fetchData.response_body_size,i?.status;const o={input:n.args,response:i,startTimestamp:r,endTimestamp:s},l={category:"fetch",data:a,type:"http",level:Ou(a.status_code)};t.emit("beforeOutgoingRequestBreadcrumb",l,o),Sn(l,o)}}}function Ib(t){return function(n){if(Ie()!==t)return;let r=n.from,s=n.to;const i=Ta(le.location.href);let a=r?Ta(r):void 0;const o=Ta(s);a?.path||(a=i),i.protocol===o.protocol&&i.host===o.host&&(s=o.relative),i.protocol===a.protocol&&i.host===a.host&&(r=a.relative),Sn({category:"navigation",data:{from:r,to:s}})}}function $b(t){return!!t&&!!t.target}const Cb=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","BroadcastChannel","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","SharedWorker","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],Pb="BrowserApiErrors",Nb=((t={})=>{const e={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,unregisterOriginalCallbacks:!1,...t};return{name:Pb,setupOnce(){e.setTimeout&&We(le,"setTimeout",Fu),e.setInterval&&We(le,"setInterval",Fu),e.requestAnimationFrame&&We(le,"requestAnimationFrame",Lb),e.XMLHttpRequest&&"XMLHttpRequest"in le&&We(XMLHttpRequest.prototype,"send",jb);const n=e.eventTarget;n&&(Array.isArray(n)?n:Cb).forEach(s=>Db(s,e))}}});function Fu(t){return function(...e){const n=e[0];return e[0]=sr(n,{mechanism:{data:{function:Ht(t)},handled:!1,type:"instrument"}}),t.apply(this,e)}}function Lb(t){return function(e){return t.apply(this,[sr(e,{mechanism:{data:{function:"requestAnimationFrame",handler:Ht(t)},handled:!1,type:"instrument"}})])}}function jb(t){return function(...e){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(s=>{s in n&&typeof n[s]=="function"&&We(n,s,function(i){const a={mechanism:{data:{function:s,handler:Ht(i)},handled:!1,type:"instrument"}},o=da(i);return o&&(a.mechanism.data.handler=Ht(o)),sr(i,a)})}),t.apply(this,e)}}function Db(t,e){const r=le[t]?.prototype;r?.hasOwnProperty?.("addEventListener")&&(We(r,"addEventListener",function(s){return function(i,a,o){try{Ub(a)&&(a.handleEvent=sr(a.handleEvent,{mechanism:{data:{function:"handleEvent",handler:Ht(a),target:t},handled:!1,type:"instrument"}}))}catch{}return e.unregisterOriginalCallbacks&&Fb(this,i,a),s.apply(this,[i,sr(a,{mechanism:{data:{function:"addEventListener",handler:Ht(a),target:t},handled:!1,type:"instrument"}}),o])}}),We(r,"removeEventListener",function(s){return function(i,a,o){try{const l=a.__sentry_wrapped__;l&&s.call(this,i,l,o)}catch{}return s.call(this,i,a,o)}}))}function Ub(t){return typeof t.handleEvent=="function"}function Fb(t,e,n){t&&typeof t=="object"&&"removeEventListener"in t&&typeof t.removeEventListener=="function"&&t.removeEventListener(e,n)}const Mb=()=>({name:"BrowserSession",setupOnce(){if(typeof le.document>"u"){qs&&C.warn("Using the `browserSessionIntegration` in non-browser environments is not supported.");return}su({ignoreDuration:!0}),ou(),Lu(({from:t,to:e})=>{t!==void 0&&t!==e&&(su({ignoreDuration:!0}),ou())})}}),Bb="GlobalHandlers",qb=((t={})=>{const e={onerror:!0,onunhandledrejection:!0,...t};return{name:Bb,setupOnce(){Error.stackTraceLimit=50},setup(n){e.onerror&&(Hb(n),Mu("onerror")),e.onunhandledrejection&&(zb(n),Mu("onunhandledrejection"))}}});function Hb(t){Gg(e=>{const{stackParser:n,attachStacktrace:r}=Bu();if(Ie()!==t||$u())return;const{msg:s,url:i,line:a,column:o,error:l}=e,c=Kb(Ca(n,l||s,void 0,r,!1),i,a,o);c.level="error",ru(c,{originalException:l,mechanism:{handled:!1,type:"onerror"}})})}function zb(t){Vg(e=>{const{stackParser:n,attachStacktrace:r}=Bu();if(Ie()!==t||$u())return;const s=Wb(e),i=la(s)?Gb(s):Ca(n,s,void 0,r,!0);i.level="error",ru(i,{originalException:s,mechanism:{handled:!1,type:"onunhandledrejection"}})})}function Wb(t){if(la(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}function Gb(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function Kb(t,e,n,r){const s=t.exception=t.exception||{},i=s.values=s.values||[],a=i[0]=i[0]||{},o=a.stacktrace=a.stacktrace||{},l=o.frames=o.frames||[],c=r,u=n,d=At(e)&&e.length>0?e:ua();return l.length===0&&l.push({colno:c,filename:d,function:vn,in_app:!0,lineno:u}),t}function Mu(t){qs&&C.log(`Global Handler attached: ${t}`)}function Bu(){return Ie()?.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}const Vb=()=>({name:"HttpContext",preprocessEvent(t){if(!le.navigator&&!le.location&&!le.document)return;const e=Mv(),n={...e.headers,...t.request?.headers};t.request={...e,...t.request,headers:n}}}),Jb="cause",Yb=5,Xb="LinkedErrors",Zb=((t={})=>{const e=t.limit||Yb,n=t.key||Jb;return{name:Xb,preprocessEvent(r,s,i){const a=i.getOptions();Ev(Oa,a.stackParser,n,e,r,s)}}});function Qb(){return ey()?(qs&&Qn(()=>{console.error("[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/")}),!0):!1}function ey(){if(typeof le.window>"u")return!1;const t=le;if(t.nw||!(t.chrome||t.browser)?.runtime?.id)return!1;const n=ua(),r=["chrome-extension","moz-extension","ms-browser-extension","safari-web-extension"];return!(le===le.top&&r.some(i=>n.startsWith(`${i}://`)))}function ty(t){return[pv(),uv(),Nb(),Uu(),qb(),Zb(),Av(),Vb(),Mb()]}function ny(t={}){const e=!t.skipBrowserExtensionCheck&&Qb(),n={...t,enabled:e?!1:t.enabled,stackParser:zg(t.stackParser||kb),integrations:U_({integrations:t.integrations,defaultIntegrations:t.defaultIntegrations==null?ty():t.defaultIntegrations}),transport:t.transport||pb};return J_(Qv,n)}const zs="https://useknest.com",Ws="/api/v1",ry="https://lghrsugmhzpccpriqhrx.supabase.co",sy="sb_publishable_-KUwilDA78QM849gk662FA_kEzMezNS";function iy(t=zs){return`${t}${Ws}/chat-messages`}function ay(t=zs){return`${t}${Ws}/widget-config`}const oy="Sorry, I didn't get a response.",qu="Unknown error occurred",Hu="This domain is not authorized. Please add it to your allowed origins in the Knest dashboard.",ly="This chatbot has reached its usage limit. Please contact the site owner to upgrade their plan.",cy="https://useknest.com/default-avatar.svg",Da="#3b82f6",zu="Hi! I'm your AI assistant. I'm trained to answer questions about your documentation. How can I help you today?",uy=["How do I get started?","What features are available?","How do I integrate this?"],Wu=["image/jpeg","image/png","image/gif","image/webp"],dy=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain"],Gu=[...Wu,...dy],hy=Gu.join(","),fy=10*1024*1024,py=5;function gy(t=zs){return`${t}${Ws}/chat-attachments/upload-url`}function my(t=zs){return`${t}${Ws}/chat-attachments/signed-url`}function _y(t){return Wu.includes(t)}const vy="knest-widget-config-",by=1440*60*1e3;function Ua(t){return vy+t}function yy(t,e){try{const n=localStorage.getItem(Ua(t));if(!n)return null;const{config:r,cachedAt:s}=JSON.parse(n);return Date.now()-s>by?(localStorage.removeItem(Ua(t)),null):(e&&r.updatedAt,r)}catch{return null}}function wy(t,e){try{const n={config:e,cachedAt:Date.now()};localStorage.setItem(Ua(t),JSON.stringify(n))}catch{}}async function Ku(t,e){try{const n=await fetch(ay(e),{method:"GET",headers:{"X-Api-Key":t}});if(n.ok){const s=await n.json();return wy(t,s),{config:s,error:null}}if(n.status===401||n.status===403){const s=await n.json().catch(()=>({}));return console.warn("Widget config auth error:",n.status,s),{config:null,error:"auth"}}const r=await n.text();return console.warn("Failed to fetch widget config:",n.status,r),{config:null,error:"network"}}catch(n){return console.error("Error fetching widget config:",n),{config:null,error:"network"}}}async function Ey(t,e,n){const r=yy(t);return r?(n&&Ku(t,e).then(s=>{s.config&&s.config.updatedAt!==r.updatedAt&&n(s.config)}),{config:r,error:null}):Ku(t,e)}let Tn=null,Gs=!1,Ks=null;async function ky(t,e){return Ks||(Gs&&Tn?!0:(Ks=(async()=>{try{Tn=Zp(t,e,{auth:{persistSession:!0,storageKey:"knest-widget-auth"}});const{data:{session:n}}=await Tn.auth.getSession();if(n)return Gs=!0,!0;const{error:r}=await Tn.auth.signInAnonymously();return r?(console.error("Widget auth error:",r.message),!1):(Gs=!0,!0)}catch(n){return console.error("Widget auth initialization failed:",n),!1}finally{Ks=null}})(),Ks))}async function Fa(){if(!Tn)return null;const{data:{session:t}}=await Tn.auth.getSession();return t?.access_token||null}function Sy(){return Gs}function Ty(){return Tn}async function xy(t){const{publishableApiKey:e,content:n,threadId:r,callbacks:s,baseUrl:i,metadata:a,user:o}=t;try{if(!Sy())throw new Error("Widget not authenticated. Call initWidgetAuth() first.");const l=await Fa();if(!l)throw new Error("No access token available. Please refresh and try again.");const c={content:n};r&&(c.threadId=r),a&&(c.metadata=a),o&&(!o.id&&!o.email?console.warn("[Knest] user prop ignored: at least id or email is required."):(c.user=o,o.email&&(c.email=o.email),o.fullName&&(c.fullName=o.fullName)));const u=await fetch(iy(i),{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":e,Authorization:`Bearer ${l}`},credentials:"include",body:JSON.stringify(c)});if(!u.ok){if(u.status===401||u.status===403)throw new Error(Hu);if(u.status===429){const v=await u.json();throw v.code==="USAGE_LIMIT_EXCEEDED"?new Error(ly):new Error(v.error||"Rate limited")}const _=await u.json();throw new Error(_.error||"Failed to send message")}const d=u.body?.getReader();if(!d)throw new Error("Response body is not readable");const h=new TextDecoder;let f="",m=!1;for(;;){const{done:_,value:v}=await d.read();if(_)break;f+=h.decode(v,{stream:!0});const S=f.split(`
116
+ `);f=S.pop()||"";for(const g of S)if(g.startsWith("data: "))try{const p=JSON.parse(g.slice(6));if(p.type==="init")p.threadId&&s.onInit&&s.onInit(p.threadId);else if(p.type==="content")p.content&&(m=!0,s.onContent(p.content));else if(p.type==="complete")s.onComplete&&s.onComplete(p.sources||[]);else if(p.type==="done")p.humanTakeover&&(m=!0),s.onDone&&s.onDone({humanTakeover:p.humanTakeover});else if(p.type==="error")throw new Error(p.error||qu)}catch(p){console.error("Error parsing SSE data:",p,g)}}m||s.onError(oy)}catch(l){const c=l instanceof Error?l.message:qu;s.onError(c)}}var Vu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ay(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ju={exports:{}},Yu;function Ry(){return Yu||(Yu=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
117
117
  * Prism: Lightweight, robust, elegant syntax highlighting
118
118
  *
119
119
  * @license MIT <https://opensource.org/licenses/MIT>
120
120
  * @author Lea Verou <https://lea.verou.me>
121
121
  * @namespace
122
122
  * @public
123
- */var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,i=0,a={},o={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function p(m){return m instanceof l?new l(m.type,p(m.content),m.alias):Array.isArray(m)?m.map(p):m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(p){return Object.prototype.toString.call(p).slice(8,-1)},objId:function(p){return p.__id||Object.defineProperty(p,"__id",{value:++i}),p.__id},clone:function p(m,y){y=y||{};var E,b;switch(o.util.type(m)){case"Object":if(b=o.util.objId(m),y[b])return y[b];E={},y[b]=E;for(var k in m)m.hasOwnProperty(k)&&(E[k]=p(m[k],y));return E;case"Array":return b=o.util.objId(m),y[b]?y[b]:(E=[],y[b]=E,m.forEach(function(A,T){E[T]=p(A,y)}),E);default:return m}},getLanguage:function(p){for(;p;){var m=s.exec(p.className);if(m)return m[1].toLowerCase();p=p.parentElement}return"none"},setLanguage:function(p,m){p.className=p.className.replace(RegExp(s,"gi"),""),p.classList.add("language-"+m)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(E){var p=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(E.stack)||[])[1];if(p){var m=document.getElementsByTagName("script");for(var y in m)if(m[y].src==p)return m[y]}return null}},isActive:function(p,m,y){for(var E="no-"+m;p;){var b=p.classList;if(b.contains(m))return!0;if(b.contains(E))return!1;p=p.parentElement}return!!y}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(p,m){var y=o.util.clone(o.languages[p]);for(var E in m)y[E]=m[E];return y},insertBefore:function(p,m,y,E){E=E||o.languages;var b=E[p],k={};for(var A in b)if(b.hasOwnProperty(A)){if(A==m)for(var T in y)y.hasOwnProperty(T)&&(k[T]=y[T]);y.hasOwnProperty(A)||(k[A]=b[A])}var x=E[p];return E[p]=k,o.languages.DFS(o.languages,function(C,V){V===x&&C!=p&&(this[C]=k)}),k},DFS:function p(m,y,E,b){b=b||{};var k=o.util.objId;for(var A in m)if(m.hasOwnProperty(A)){y.call(m,A,m[A],E||A);var T=m[A],x=o.util.type(T);x==="Object"&&!b[k(T)]?(b[k(T)]=!0,p(T,y,null,b)):x==="Array"&&!b[k(T)]&&(b[k(T)]=!0,p(T,y,A,b))}}},plugins:{},highlightAll:function(p,m){o.highlightAllUnder(document,p,m)},highlightAllUnder:function(p,m,y){var E={callback:y,container:p,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};o.hooks.run("before-highlightall",E),E.elements=Array.prototype.slice.apply(E.container.querySelectorAll(E.selector)),o.hooks.run("before-all-elements-highlight",E);for(var b=0,k;k=E.elements[b++];)o.highlightElement(k,m===!0,E.callback)},highlightElement:function(p,m,y){var E=o.util.getLanguage(p),b=o.languages[E];o.util.setLanguage(p,E);var k=p.parentElement;k&&k.nodeName.toLowerCase()==="pre"&&o.util.setLanguage(k,E);var A=p.textContent,T={element:p,language:E,grammar:b,code:A};function x(V){T.highlightedCode=V,o.hooks.run("before-insert",T),T.element.innerHTML=T.highlightedCode,o.hooks.run("after-highlight",T),o.hooks.run("complete",T),y&&y.call(T.element)}if(o.hooks.run("before-sanity-check",T),k=T.element.parentElement,k&&k.nodeName.toLowerCase()==="pre"&&!k.hasAttribute("tabindex")&&k.setAttribute("tabindex","0"),!T.code){o.hooks.run("complete",T),y&&y.call(T.element);return}if(o.hooks.run("before-highlight",T),!T.grammar){x(o.util.encode(T.code));return}if(m&&r.Worker){var C=new Worker(o.filename);C.onmessage=function(V){x(V.data)},C.postMessage(JSON.stringify({language:T.language,code:T.code,immediateClose:!0}))}else x(o.highlight(T.code,T.grammar,T.language))},highlight:function(p,m,y){var E={code:p,grammar:m,language:y};if(o.hooks.run("before-tokenize",E),!E.grammar)throw new Error('The language "'+E.language+'" has no grammar.');return E.tokens=o.tokenize(E.code,E.grammar),o.hooks.run("after-tokenize",E),l.stringify(o.util.encode(E.tokens),E.language)},tokenize:function(p,m){var y=m.rest;if(y){for(var E in y)m[E]=y[E];delete m.rest}var b=new d;return h(b,b.head,p),u(p,b,m,b.head,0),g(b)},hooks:{all:{},add:function(p,m){var y=o.hooks.all;y[p]=y[p]||[],y[p].push(m)},run:function(p,m){var y=o.hooks.all[p];if(!(!y||!y.length))for(var E=0,b;b=y[E++];)b(m)}},Token:l};r.Prism=o;function l(p,m,y,E){this.type=p,this.content=m,this.alias=y,this.length=(E||"").length|0}l.stringify=function p(m,y){if(typeof m=="string")return m;if(Array.isArray(m)){var E="";return m.forEach(function(x){E+=p(x,y)}),E}var b={type:m.type,content:p(m.content,y),tag:"span",classes:["token",m.type],attributes:{},language:y},k=m.alias;k&&(Array.isArray(k)?Array.prototype.push.apply(b.classes,k):b.classes.push(k)),o.hooks.run("wrap",b);var A="";for(var T in b.attributes)A+=" "+T+'="'+(b.attributes[T]||"").replace(/"/g,"&quot;")+'"';return"<"+b.tag+' class="'+b.classes.join(" ")+'"'+A+">"+b.content+"</"+b.tag+">"};function c(p,m,y,E){p.lastIndex=m;var b=p.exec(y);if(b&&E&&b[1]){var k=b[1].length;b.index+=k,b[0]=b[0].slice(k)}return b}function u(p,m,y,E,b,k){for(var A in y)if(!(!y.hasOwnProperty(A)||!y[A])){var T=y[A];T=Array.isArray(T)?T:[T];for(var x=0;x<T.length;++x){if(k&&k.cause==A+","+x)return;var C=T[x],V=C.inside,ae=!!C.lookbehind,be=!!C.greedy,re=C.alias;if(be&&!C.pattern.global){var ye=C.pattern.toString().match(/[imsuy]*$/)[0];C.pattern=RegExp(C.pattern.source,ye+"g")}for(var Le=C.pattern||C,W=E.next,se=b;W!==m.tail&&!(k&&se>=k.reach);se+=W.value.length,W=W.next){var ce=W.value;if(m.length>p.length)return;if(!(ce instanceof l)){var O=1,I;if(be){if(I=c(Le,se,p,ae),!I||I.index>=p.length)break;var J=I.index,q=I.index+I[0].length,G=se;for(G+=W.value.length;J>=G;)W=W.next,G+=W.value.length;if(G-=W.value.length,se=G,W.value instanceof l)continue;for(var ue=W;ue!==m.tail&&(G<q||typeof ue.value=="string");ue=ue.next)O++,G+=ue.value.length;O--,ce=p.slice(se,G),I.index-=se}else if(I=c(Le,0,ce,ae),!I)continue;var J=I.index,M=I[0],Ye=ce.slice(0,J),Kt=ce.slice(J+M.length),we=se+ce.length;k&&we>k.reach&&(k.reach=we);var pe=W.prev;Ye&&(pe=h(m,pe,Ye),se+=Ye.length),f(m,pe,O);var Xe=new l(A,V?o.tokenize(M,V):M,re,M);if(W=h(m,pe,Xe),Kt&&h(m,W,Kt),O>1){var Ze={cause:A+","+x,reach:we};u(p,m,y,W.prev,se,Ze),k&&Ze.reach>k.reach&&(k.reach=Ze.reach)}}}}}}function d(){var p={value:null,prev:null,next:null},m={value:null,prev:p,next:null};p.next=m,this.head=p,this.tail=m,this.length=0}function h(p,m,y){var E=m.next,b={value:y,prev:m,next:E};return m.next=b,E.prev=b,p.length++,b}function f(p,m,y){for(var E=m.next,b=0;b<y&&E!==p.tail;b++)E=E.next;m.next=E,E.prev=m,p.length-=b}function g(p){for(var m=[],y=p.head.next;y!==p.tail;)m.push(y.value),y=y.next;return m}if(!r.document)return r.addEventListener&&(o.disableWorkerMessageHandler||r.addEventListener("message",function(p){var m=JSON.parse(p.data),y=m.language,E=m.code,b=m.immediateClose;r.postMessage(o.highlight(E,o.languages[y],y)),b&&r.close()},!1)),o;var v=o.util.currentScript();v&&(o.filename=v.src,v.hasAttribute("data-manual")&&(o.manual=!0));function _(){o.manual||o.highlightAll()}if(!o.manual){var S=document.readyState;S==="loading"||S==="interactive"&&v&&v.defer?document.addEventListener("DOMContentLoaded",_):window.requestAnimationFrame?window.requestAnimationFrame(_):window.setTimeout(_,16)}return o})(e);t.exports&&(t.exports=n),typeof Ku<"u"&&(Ku.Prism=n),n.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",function(r){r.type==="entity"&&(r.attributes.title=r.content.replace(/&amp;/,"&"))}),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(r,s){var i={};i["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:n.languages[s]},i.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:i}};a["language-"+s]={pattern:/[\s\S]+/,inside:n.languages[s]};var o={};o[r]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return r}),"i"),lookbehind:!0,greedy:!0,inside:a},n.languages.insertBefore("markup","cdata",o)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(r,s){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+r+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[s,"language-"+s],inside:n.languages[s]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,(function(r){var s=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;r.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+s.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+s.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+s.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+s.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:s,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},r.languages.css.atrule.inside.rest=r.languages.css;var i=r.languages.markup;i&&(i.tag.addInlined("style","css"),i.tag.addAttribute("style","css"))})(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,(function(){if(typeof n>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var r="Loading…",s=function(v,_){return"✖ Error "+v+" while fetching file: "+_},i="✖ Error: File does not exist or is empty",a={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},o="data-src-status",l="loading",c="loaded",u="failed",d="pre[data-src]:not(["+o+'="'+c+'"]):not(['+o+'="'+l+'"])';function h(v,_,S){var p=new XMLHttpRequest;p.open("GET",v,!0),p.onreadystatechange=function(){p.readyState==4&&(p.status<400&&p.responseText?_(p.responseText):p.status>=400?S(s(p.status,p.statusText)):S(i))},p.send(null)}function f(v){var _=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(v||"");if(_){var S=Number(_[1]),p=_[2],m=_[3];return p?m?[S,Number(m)]:[S,void 0]:[S,S]}}n.hooks.add("before-highlightall",function(v){v.selector+=", "+d}),n.hooks.add("before-sanity-check",function(v){var _=v.element;if(_.matches(d)){v.code="",_.setAttribute(o,l);var S=_.appendChild(document.createElement("CODE"));S.textContent=r;var p=_.getAttribute("data-src"),m=v.language;if(m==="none"){var y=(/\.(\w+)$/.exec(p)||[,"none"])[1];m=a[y]||y}n.util.setLanguage(S,m),n.util.setLanguage(_,m);var E=n.plugins.autoloader;E&&E.loadLanguages(m),h(p,function(b){_.setAttribute(o,c);var k=f(_.getAttribute("data-range"));if(k){var A=b.split(/\r\n?|\n/g),T=k[0],x=k[1]==null?A.length:k[1];T<0&&(T+=A.length),T=Math.max(0,Math.min(T-1,A.length)),x<0&&(x+=A.length),x=Math.max(0,Math.min(x,A.length)),b=A.slice(T,x).join(`
124
- `),_.hasAttribute("data-start")||_.setAttribute("data-start",String(T+1))}S.textContent=b,n.highlightElement(S)},function(b){_.setAttribute(o,u),S.textContent=b})}}),n.plugins.fileHighlight={highlight:function(v){for(var _=(v||document).querySelectorAll(d),S=0,p;p=_[S++];)n.highlightElement(p)}};var g=!1;n.fileHighlight=function(){g||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),g=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}})()})(Vu)),Vu.exports}var Oy=Ay();const Yu=xy(Oy);var Ry={},Xu;function Iy(){return Xu||(Xu=1,Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),Ry}Iy();var $y={},Zu;function Cy(){return Zu||(Zu=1,(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var e=t.languages.extend("typescript",{});delete e["class-name"],t.languages.typescript["class-name"].inside=e,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e}}}}),t.languages.ts=t.languages.typescript})(Prism)),$y}Cy(),(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],i=r.variable[1].inside,a=0;a<s.length;a++)i[s[a]]=t.languages.bash[s[a]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism),Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+e.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+e.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+e.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+e.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:e,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var n=t.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(Prism),Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&amp;/,"&"))}),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,e){var n={};n["language-"+e]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[e]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};r["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var s={};s[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:r},Prism.languages.insertBefore("markup","cdata",s)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(t,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml,Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};const Py={js:"javascript",ts:"typescript",shell:"bash",sh:"bash",html:"markup",xml:"markup"};z.setOptions({breaks:!0,gfm:!0});const Qu=new z.Renderer;Qu.code=({text:t,lang:e})=>{const n=e?Py[e]||e:"plaintext",r=Yu.languages[n];if(r){const s=Yu.highlight(t,r,n);return`<pre><code class="language-${n}">${s}</code></pre>`}return`<pre><code>${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</code></pre>`},z.use({renderer:Qu});function Ny(t){return z.parse(t)}function Ly(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function jy(t){return Wu.includes(t.type)?t.size>hy?"File exceeds the 10MB size limit.":null:`File type "${t.type}" is not supported.`}async function Dy({publishableApiKey:t,threadId:e,fileName:n,fileType:r,fileSize:s,baseUrl:i}){const a=await Ua(),o=await fetch(py(i),{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":t,...a?{Authorization:`Bearer ${a}`}:{}},body:JSON.stringify({threadId:e,fileName:n,fileType:r,fileSize:s})});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.error||`Upload URL request failed: ${o.status}`)}return o.json()}async function Uy(t,e){const n=await fetch(t,{method:"PUT",headers:{"Content-Type":e.type},body:e});if(!n.ok)throw new Error(`Storage upload failed: ${n.status}`)}async function Fy({publishableApiKey:t,threadId:e,file:n,baseUrl:r}){const{uploadUrl:s,storagePath:i}=await Dy({publishableApiKey:t,threadId:e,fileName:n.name,fileType:n.type,fileSize:n.size,baseUrl:r});return await Uy(s,n),{fileName:n.name,fileType:n.type,fileSize:n.size,storagePath:i}}async function My({publishableApiKey:t,storagePath:e,baseUrl:n}){const r=await Ua();try{const s=await fetch(gy(n),{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":t,...r?{Authorization:`Bearer ${r}`}:{}},body:JSON.stringify({storagePath:e})});return s.ok&&(await s.json()).url||null}catch{return null}}const By="https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us.sentry.io/4510472944156672",qy=["@useknest","useknest","widget-core","widget-web","widget-react","widget.umd.js","widget.js","knest"];function Hy(t){if(t.tags?.source==="knest-widget")return!0;const e=t.exception?.values?.[0]?.stacktrace?.frames;return!e||e.length===0?!1:e.some(n=>{const r=n.filename||"";return qy.some(s=>r.includes(s))})}let ed=!1;function td(){ed||(ty({dsn:By,tracesSampleRate:0,integrations:[Du({console:!1,dom:!0,fetch:!0,history:!1,xhr:!1})],initialScope:{tags:{source:"knest-widget"}},beforeSend(t){return Hy(t)?t:null}}),ed=!0)}function nd(t,e){const n=typeof t=="string"?new Error(t):t;tu(n,{tags:{source:"knest-widget"},extra:e})}function zy(t,e){const n=Sy();if(!n)return()=>{};const r=n.channel(`thread:${t}`).on("broadcast",{event:"new-message"},s=>{e(s.payload)}).subscribe();return()=>{r.unsubscribe()}}const Wy="knest-widget-chat-",Gy=14400*1e3,Ky=300,Lr=new Map;function Ks(t){return Wy+t}function Vy(t){try{const e=localStorage.getItem(Ks(t));if(!e)return null;const n=JSON.parse(e);return Date.now()-n.savedAt>Gy?(localStorage.removeItem(Ks(t)),null):n}catch{return null}}function Jy(t,e){try{localStorage.setItem(Ks(t),JSON.stringify(e))}catch{}}function Yy(t,e){const n=Lr.get(t);n!==void 0&&clearTimeout(n);const r=setTimeout(()=>{Jy(t,e),Lr.delete(t)},Ky);Lr.set(t,r)}function Xy(t){const e=Lr.get(t);e!==void 0&&(clearTimeout(e),Lr.delete(t));try{localStorage.removeItem(Ks(t))}catch{}}var Zy=Z('<div class="user-avatar svelte-19vup0k">AI</div>'),Qy=Z('<img alt="Avatar" class="avatar-img svelte-19vup0k"/>'),ew=Z('<div class="user-avatar svelte-19vup0k">U</div>'),tw=Z('<div class="message-avatar svelte-19vup0k"><!></div>'),nw=Z('<div class="loading svelte-19vup0k"><div class="dot svelte-19vup0k"></div> <div class="dot svelte-19vup0k"></div> <div class="dot svelte-19vup0k"></div></div>'),rw=Z('<a target="_blank" rel="noopener noreferrer" class="attachment-image-link svelte-19vup0k"><img class="attachment-image svelte-19vup0k"/></a>'),sw=Z('<a target="_blank" rel="noopener noreferrer"><svg class="attachment-file-icon svelte-19vup0k" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" class="svelte-19vup0k"></path></svg> <span class="attachment-file-name svelte-19vup0k"> </span> <span class="attachment-file-size svelte-19vup0k"> </span></a>'),iw=Z('<div class="attachments svelte-19vup0k"></div>'),aw=Z('<div class="source-breadcrumb svelte-19vup0k"> </div>'),ow=Z('<a target="_blank" rel="noopener noreferrer" class="source-item svelte-19vup0k"><svg class="source-icon svelte-19vup0k" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.746 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" class="svelte-19vup0k"></path></svg> <div class="source-text svelte-19vup0k"><!> <div class="source-title svelte-19vup0k"> </div></div></a>'),lw=Z('<div class="sources svelte-19vup0k"><div class="sources-label svelte-19vup0k">Sources</div> <!></div>'),cw=Z('<div class="message-wrapper svelte-19vup0k"><div class="message svelte-19vup0k"><!> <div class="message-content svelte-19vup0k"><!> <!> <!></div></div></div>');const uw={hash:"svelte-19vup0k",code:`.message-wrapper.svelte-19vup0k {display:flex;flex-direction:column;}.message.svelte-19vup0k {display:flex;gap:1rem;padding:1.25rem 1.5rem;align-items:center;}.message-avatar.svelte-19vup0k {display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0;}.avatar-img.svelte-19vup0k {width:100%;height:100%;border-radius:0.25rem;object-fit:contain;}.user-avatar.svelte-19vup0k {width:2rem;height:2rem;border-radius:0.25rem;display:flex;align-items:center;justify-content:center;color:white;font-size:0.875rem;font-weight:500;}.message-content.svelte-19vup0k {flex:1;min-width:0;}.message-content.svelte-19vup0k p {margin:0 0 0.5rem 0;font-size:0.875rem;line-height:1.625;color:inherit;word-wrap:break-word;}.message-content.svelte-19vup0k p:last-child {margin-bottom:0;}.message-content.svelte-19vup0k code {background-color:#f3f4f6;padding:0.125rem 0.375rem;border-radius:0.25rem;font-family:ui-monospace, monospace;font-size:0.8125rem;color:#ef4444;}.message-content.svelte-19vup0k pre {background-color:#1f2937;color:#f9fafb;padding:12px;border-radius:6px;overflow-x:auto;margin:8px 0;font-size:0.8125rem;line-height:1.5;}.message-content.svelte-19vup0k pre code {background-color:transparent;padding:0;color:inherit;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;}
123
+ */var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,i=0,a={},o={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function g(p){return p instanceof l?new l(p.type,g(p.content),p.alias):Array.isArray(p)?p.map(g):p.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(g){return Object.prototype.toString.call(g).slice(8,-1)},objId:function(g){return g.__id||Object.defineProperty(g,"__id",{value:++i}),g.__id},clone:function g(p,y){y=y||{};var E,b;switch(o.util.type(p)){case"Object":if(b=o.util.objId(p),y[b])return y[b];E={},y[b]=E;for(var k in p)p.hasOwnProperty(k)&&(E[k]=g(p[k],y));return E;case"Array":return b=o.util.objId(p),y[b]?y[b]:(E=[],y[b]=E,p.forEach(function(A,T){E[T]=g(A,y)}),E);default:return p}},getLanguage:function(g){for(;g;){var p=s.exec(g.className);if(p)return p[1].toLowerCase();g=g.parentElement}return"none"},setLanguage:function(g,p){g.className=g.className.replace(RegExp(s,"gi"),""),g.classList.add("language-"+p)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(E){var g=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(E.stack)||[])[1];if(g){var p=document.getElementsByTagName("script");for(var y in p)if(p[y].src==g)return p[y]}return null}},isActive:function(g,p,y){for(var E="no-"+p;g;){var b=g.classList;if(b.contains(p))return!0;if(b.contains(E))return!1;g=g.parentElement}return!!y}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(g,p){var y=o.util.clone(o.languages[g]);for(var E in p)y[E]=p[E];return y},insertBefore:function(g,p,y,E){E=E||o.languages;var b=E[g],k={};for(var A in b)if(b.hasOwnProperty(A)){if(A==p)for(var T in y)y.hasOwnProperty(T)&&(k[T]=y[T]);y.hasOwnProperty(A)||(k[A]=b[A])}var x=E[g];return E[g]=k,o.languages.DFS(o.languages,function($,V){V===x&&$!=g&&(this[$]=k)}),k},DFS:function g(p,y,E,b){b=b||{};var k=o.util.objId;for(var A in p)if(p.hasOwnProperty(A)){y.call(p,A,p[A],E||A);var T=p[A],x=o.util.type(T);x==="Object"&&!b[k(T)]?(b[k(T)]=!0,g(T,y,null,b)):x==="Array"&&!b[k(T)]&&(b[k(T)]=!0,g(T,y,A,b))}}},plugins:{},highlightAll:function(g,p){o.highlightAllUnder(document,g,p)},highlightAllUnder:function(g,p,y){var E={callback:y,container:g,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};o.hooks.run("before-highlightall",E),E.elements=Array.prototype.slice.apply(E.container.querySelectorAll(E.selector)),o.hooks.run("before-all-elements-highlight",E);for(var b=0,k;k=E.elements[b++];)o.highlightElement(k,p===!0,E.callback)},highlightElement:function(g,p,y){var E=o.util.getLanguage(g),b=o.languages[E];o.util.setLanguage(g,E);var k=g.parentElement;k&&k.nodeName.toLowerCase()==="pre"&&o.util.setLanguage(k,E);var A=g.textContent,T={element:g,language:E,grammar:b,code:A};function x(V){T.highlightedCode=V,o.hooks.run("before-insert",T),T.element.innerHTML=T.highlightedCode,o.hooks.run("after-highlight",T),o.hooks.run("complete",T),y&&y.call(T.element)}if(o.hooks.run("before-sanity-check",T),k=T.element.parentElement,k&&k.nodeName.toLowerCase()==="pre"&&!k.hasAttribute("tabindex")&&k.setAttribute("tabindex","0"),!T.code){o.hooks.run("complete",T),y&&y.call(T.element);return}if(o.hooks.run("before-highlight",T),!T.grammar){x(o.util.encode(T.code));return}if(p&&r.Worker){var $=new Worker(o.filename);$.onmessage=function(V){x(V.data)},$.postMessage(JSON.stringify({language:T.language,code:T.code,immediateClose:!0}))}else x(o.highlight(T.code,T.grammar,T.language))},highlight:function(g,p,y){var E={code:g,grammar:p,language:y};if(o.hooks.run("before-tokenize",E),!E.grammar)throw new Error('The language "'+E.language+'" has no grammar.');return E.tokens=o.tokenize(E.code,E.grammar),o.hooks.run("after-tokenize",E),l.stringify(o.util.encode(E.tokens),E.language)},tokenize:function(g,p){var y=p.rest;if(y){for(var E in y)p[E]=y[E];delete p.rest}var b=new d;return h(b,b.head,g),u(g,b,p,b.head,0),m(b)},hooks:{all:{},add:function(g,p){var y=o.hooks.all;y[g]=y[g]||[],y[g].push(p)},run:function(g,p){var y=o.hooks.all[g];if(!(!y||!y.length))for(var E=0,b;b=y[E++];)b(p)}},Token:l};r.Prism=o;function l(g,p,y,E){this.type=g,this.content=p,this.alias=y,this.length=(E||"").length|0}l.stringify=function g(p,y){if(typeof p=="string")return p;if(Array.isArray(p)){var E="";return p.forEach(function(x){E+=g(x,y)}),E}var b={type:p.type,content:g(p.content,y),tag:"span",classes:["token",p.type],attributes:{},language:y},k=p.alias;k&&(Array.isArray(k)?Array.prototype.push.apply(b.classes,k):b.classes.push(k)),o.hooks.run("wrap",b);var A="";for(var T in b.attributes)A+=" "+T+'="'+(b.attributes[T]||"").replace(/"/g,"&quot;")+'"';return"<"+b.tag+' class="'+b.classes.join(" ")+'"'+A+">"+b.content+"</"+b.tag+">"};function c(g,p,y,E){g.lastIndex=p;var b=g.exec(y);if(b&&E&&b[1]){var k=b[1].length;b.index+=k,b[0]=b[0].slice(k)}return b}function u(g,p,y,E,b,k){for(var A in y)if(!(!y.hasOwnProperty(A)||!y[A])){var T=y[A];T=Array.isArray(T)?T:[T];for(var x=0;x<T.length;++x){if(k&&k.cause==A+","+x)return;var $=T[x],V=$.inside,pe=!!$.lookbehind,ge=!!$.greedy,re=$.alias;if(ge&&!$.pattern.global){var ye=$.pattern.toString().match(/[imsuy]*$/)[0];$.pattern=RegExp($.pattern.source,ye+"g")}for(var Ge=$.pattern||$,W=E.next,se=b;W!==p.tail&&!(k&&se>=k.reach);se+=W.value.length,W=W.next){var ce=W.value;if(p.length>g.length)return;if(!(ce instanceof l)){var ae=1,R;if(ge){if(R=c(Ge,se,g,pe),!R||R.index>=g.length)break;var me=R.index,L=R.index+R[0].length,M=se;for(M+=W.value.length;me>=M;)W=W.next,M+=W.value.length;if(M-=W.value.length,se=M,W.value instanceof l)continue;for(var J=W;J!==p.tail&&(M<L||typeof J.value=="string");J=J.next)ae++,M+=J.value.length;ae--,ce=g.slice(se,M),R.index-=se}else if(R=c(Ge,0,ce,pe),!R)continue;var me=R.index,G=R[0],q=ce.slice(0,me),Kt=ce.slice(me+G.length),It=se+ce.length;k&&It>k.reach&&(k.reach=It);var ke=W.prev;q&&(ke=h(p,ke,q),se+=q.length),f(p,ke,ae);var Se=new l(A,V?o.tokenize(G,V):G,re,G);if(W=h(p,ke,Se),Kt&&h(p,W,Kt),ae>1){var je={cause:A+","+x,reach:It};u(g,p,y,W.prev,se,je),k&&je.reach>k.reach&&(k.reach=je.reach)}}}}}}function d(){var g={value:null,prev:null,next:null},p={value:null,prev:g,next:null};g.next=p,this.head=g,this.tail=p,this.length=0}function h(g,p,y){var E=p.next,b={value:y,prev:p,next:E};return p.next=b,E.prev=b,g.length++,b}function f(g,p,y){for(var E=p.next,b=0;b<y&&E!==g.tail;b++)E=E.next;p.next=E,E.prev=p,g.length-=b}function m(g){for(var p=[],y=g.head.next;y!==g.tail;)p.push(y.value),y=y.next;return p}if(!r.document)return r.addEventListener&&(o.disableWorkerMessageHandler||r.addEventListener("message",function(g){var p=JSON.parse(g.data),y=p.language,E=p.code,b=p.immediateClose;r.postMessage(o.highlight(E,o.languages[y],y)),b&&r.close()},!1)),o;var _=o.util.currentScript();_&&(o.filename=_.src,_.hasAttribute("data-manual")&&(o.manual=!0));function v(){o.manual||o.highlightAll()}if(!o.manual){var S=document.readyState;S==="loading"||S==="interactive"&&_&&_.defer?document.addEventListener("DOMContentLoaded",v):window.requestAnimationFrame?window.requestAnimationFrame(v):window.setTimeout(v,16)}return o})(e);t.exports&&(t.exports=n),typeof Vu<"u"&&(Vu.Prism=n),n.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",function(r){r.type==="entity"&&(r.attributes.title=r.content.replace(/&amp;/,"&"))}),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(r,s){var i={};i["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:n.languages[s]},i.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:i}};a["language-"+s]={pattern:/[\s\S]+/,inside:n.languages[s]};var o={};o[r]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return r}),"i"),lookbehind:!0,greedy:!0,inside:a},n.languages.insertBefore("markup","cdata",o)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(r,s){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+r+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[s,"language-"+s],inside:n.languages[s]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,(function(r){var s=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;r.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+s.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+s.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+s.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+s.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:s,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},r.languages.css.atrule.inside.rest=r.languages.css;var i=r.languages.markup;i&&(i.tag.addInlined("style","css"),i.tag.addAttribute("style","css"))})(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,(function(){if(typeof n>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var r="Loading…",s=function(_,v){return"✖ Error "+_+" while fetching file: "+v},i="✖ Error: File does not exist or is empty",a={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},o="data-src-status",l="loading",c="loaded",u="failed",d="pre[data-src]:not(["+o+'="'+c+'"]):not(['+o+'="'+l+'"])';function h(_,v,S){var g=new XMLHttpRequest;g.open("GET",_,!0),g.onreadystatechange=function(){g.readyState==4&&(g.status<400&&g.responseText?v(g.responseText):g.status>=400?S(s(g.status,g.statusText)):S(i))},g.send(null)}function f(_){var v=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(_||"");if(v){var S=Number(v[1]),g=v[2],p=v[3];return g?p?[S,Number(p)]:[S,void 0]:[S,S]}}n.hooks.add("before-highlightall",function(_){_.selector+=", "+d}),n.hooks.add("before-sanity-check",function(_){var v=_.element;if(v.matches(d)){_.code="",v.setAttribute(o,l);var S=v.appendChild(document.createElement("CODE"));S.textContent=r;var g=v.getAttribute("data-src"),p=_.language;if(p==="none"){var y=(/\.(\w+)$/.exec(g)||[,"none"])[1];p=a[y]||y}n.util.setLanguage(S,p),n.util.setLanguage(v,p);var E=n.plugins.autoloader;E&&E.loadLanguages(p),h(g,function(b){v.setAttribute(o,c);var k=f(v.getAttribute("data-range"));if(k){var A=b.split(/\r\n?|\n/g),T=k[0],x=k[1]==null?A.length:k[1];T<0&&(T+=A.length),T=Math.max(0,Math.min(T-1,A.length)),x<0&&(x+=A.length),x=Math.max(0,Math.min(x,A.length)),b=A.slice(T,x).join(`
124
+ `),v.hasAttribute("data-start")||v.setAttribute("data-start",String(T+1))}S.textContent=b,n.highlightElement(S)},function(b){v.setAttribute(o,u),S.textContent=b})}}),n.plugins.fileHighlight={highlight:function(_){for(var v=(_||document).querySelectorAll(d),S=0,g;g=v[S++];)n.highlightElement(g)}};var m=!1;n.fileHighlight=function(){m||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),m=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}})()})(Ju)),Ju.exports}var Oy=Ry();const Xu=Ay(Oy);var Iy={},Zu;function $y(){return Zu||(Zu=1,Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),Iy}$y();var Cy={},Qu;function Py(){return Qu||(Qu=1,(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var e=t.languages.extend("typescript",{});delete e["class-name"],t.languages.typescript["class-name"].inside=e,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e}}}}),t.languages.ts=t.languages.typescript})(Prism)),Cy}Py(),(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],i=r.variable[1].inside,a=0;a<s.length;a++)i[s[a]]=t.languages.bash[s[a]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism),Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+e.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+e.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+e.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+e.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:e,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var n=t.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(Prism),Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&amp;/,"&"))}),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,e){var n={};n["language-"+e]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[e]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};r["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var s={};s[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:r},Prism.languages.insertBefore("markup","cdata",s)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(t,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml,Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};const Ny={js:"javascript",ts:"typescript",shell:"bash",sh:"bash",html:"markup",xml:"markup"};z.setOptions({breaks:!0,gfm:!0});const ed=new z.Renderer;ed.code=({text:t,lang:e})=>{const n=e?Ny[e]||e:"plaintext",r=Xu.languages[n];if(r){const s=Xu.highlight(t,r,n);return`<pre><code class="language-${n}">${s}</code></pre>`}return`<pre><code>${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</code></pre>`},z.use({renderer:ed});function Ly(t){return z.parse(t)}function jy(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Dy(t){return Gu.includes(t.type)?t.size>fy?"File exceeds the 10MB size limit.":null:`File type "${t.type}" is not supported.`}async function Uy({publishableApiKey:t,threadId:e,fileName:n,fileType:r,fileSize:s,baseUrl:i}){const a=await Fa(),o=await fetch(gy(i),{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":t,...a?{Authorization:`Bearer ${a}`}:{}},body:JSON.stringify({threadId:e,fileName:n,fileType:r,fileSize:s})});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.error||`Upload URL request failed: ${o.status}`)}return o.json()}async function Fy(t,e){const n=await fetch(t,{method:"PUT",headers:{"Content-Type":e.type},body:e});if(!n.ok)throw new Error(`Storage upload failed: ${n.status}`)}async function My({publishableApiKey:t,threadId:e,file:n,baseUrl:r}){const{uploadUrl:s,storagePath:i}=await Uy({publishableApiKey:t,threadId:e,fileName:n.name,fileType:n.type,fileSize:n.size,baseUrl:r});return await Fy(s,n),{fileName:n.name,fileType:n.type,fileSize:n.size,storagePath:i}}async function By({publishableApiKey:t,storagePath:e,baseUrl:n}){const r=await Fa();try{const s=await fetch(my(n),{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":t,...r?{Authorization:`Bearer ${r}`}:{}},body:JSON.stringify({storagePath:e})});return s.ok&&(await s.json()).url||null}catch{return null}}const qy="https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us.sentry.io/4510472944156672",Hy=["@useknest","useknest","widget-core","widget-web","widget-react","widget.umd.js","widget.js","knest"];function zy(t){if(t.tags?.source==="knest-widget")return!0;const e=t.exception?.values?.[0]?.stacktrace?.frames;return!e||e.length===0?!1:e.some(n=>{const r=n.filename||"";return Hy.some(s=>r.includes(s))})}let td=!1;function nd(){td||(ny({dsn:qy,tracesSampleRate:0,integrations:[Uu({console:!1,dom:!0,fetch:!0,history:!1,xhr:!1})],initialScope:{tags:{source:"knest-widget"}},beforeSend(t){return zy(t)?t:null}}),td=!0)}function rd(t,e){const n=typeof t=="string"?new Error(t):t;nu(n,{tags:{source:"knest-widget"},extra:e})}function Wy(t,e){const n=Ty();if(!n)return()=>{};const r=n.channel(`thread:${t}`).on("broadcast",{event:"new-message"},s=>{e(s.payload)}).subscribe();return()=>{r.unsubscribe()}}const Gy="knest-widget-chat-",Ky=14400*1e3,Vy=300,jr=new Map;function Vs(t){return Gy+t}function Jy(t){try{const e=localStorage.getItem(Vs(t));if(!e)return null;const n=JSON.parse(e);return Date.now()-n.savedAt>Ky?(localStorage.removeItem(Vs(t)),null):n}catch{return null}}function Yy(t,e){try{localStorage.setItem(Vs(t),JSON.stringify(e))}catch{}}function Xy(t,e){const n=jr.get(t);n!==void 0&&clearTimeout(n);const r=setTimeout(()=>{Yy(t,e),jr.delete(t)},Vy);jr.set(t,r)}function Zy(t){const e=jr.get(t);e!==void 0&&(clearTimeout(e),jr.delete(t));try{localStorage.removeItem(Vs(t))}catch{}}var Qy=Z('<div class="user-avatar svelte-19vup0k">AI</div>'),ew=Z('<img alt="Avatar" class="avatar-img svelte-19vup0k"/>'),tw=Z('<div class="user-avatar svelte-19vup0k">U</div>'),nw=Z('<div class="message-avatar svelte-19vup0k"><!></div>'),rw=Z('<div class="loading svelte-19vup0k"><div class="dot svelte-19vup0k"></div> <div class="dot svelte-19vup0k"></div> <div class="dot svelte-19vup0k"></div></div>'),sw=Z('<a target="_blank" rel="noopener noreferrer" class="attachment-image-link svelte-19vup0k"><img class="attachment-image svelte-19vup0k"/></a>'),iw=Z('<a target="_blank" rel="noopener noreferrer"><svg class="attachment-file-icon svelte-19vup0k" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" class="svelte-19vup0k"></path></svg> <span class="attachment-file-name svelte-19vup0k"> </span> <span class="attachment-file-size svelte-19vup0k"> </span></a>'),aw=Z('<div class="attachments svelte-19vup0k"></div>'),ow=Z('<div class="source-breadcrumb svelte-19vup0k"> </div>'),lw=Z('<a target="_blank" rel="noopener noreferrer" class="source-item svelte-19vup0k"><svg class="source-icon svelte-19vup0k" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.746 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" class="svelte-19vup0k"></path></svg> <div class="source-text svelte-19vup0k"><!> <div class="source-title svelte-19vup0k"> </div></div></a>'),cw=Z('<div class="sources svelte-19vup0k"><div class="sources-label svelte-19vup0k">Sources</div> <!></div>'),uw=Z('<div class="message-wrapper svelte-19vup0k"><div class="message svelte-19vup0k"><!> <div class="message-content svelte-19vup0k"><!> <!> <!></div></div></div>');const dw={hash:"svelte-19vup0k",code:`.message-wrapper.svelte-19vup0k {display:flex;flex-direction:column;}.message.svelte-19vup0k {display:flex;gap:1rem;padding:1.25rem 1.5rem;align-items:center;}.message-avatar.svelte-19vup0k {display:flex;align-items:center;justify-content:center;width:2rem;height:2rem;flex-shrink:0;}.avatar-img.svelte-19vup0k {width:100%;height:100%;border-radius:0.25rem;object-fit:contain;}.user-avatar.svelte-19vup0k {width:2rem;height:2rem;border-radius:0.25rem;display:flex;align-items:center;justify-content:center;color:white;font-size:0.875rem;font-weight:500;}.message-content.svelte-19vup0k {flex:1;min-width:0;}.message-content.svelte-19vup0k p {margin:0 0 0.5rem 0;font-size:0.875rem;line-height:1.625;color:inherit;word-wrap:break-word;}.message-content.svelte-19vup0k p:last-child {margin-bottom:0;}.message-content.svelte-19vup0k code {background-color:#f3f4f6;padding:0.125rem 0.375rem;border-radius:0.25rem;font-family:ui-monospace, monospace;font-size:0.8125rem;color:#ef4444;}.message-content.svelte-19vup0k pre {background-color:#1f2937;color:#f9fafb;padding:12px;border-radius:6px;overflow-x:auto;margin:8px 0;font-size:0.8125rem;line-height:1.5;}.message-content.svelte-19vup0k pre code {background-color:transparent;padding:0;color:inherit;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;}
125
125
 
126
126
  /* Prism.js syntax highlighting - GitHub Dark theme */.message-content.svelte-19vup0k .token.keyword,
127
127
  .message-content.svelte-19vup0k .token.builtin,
@@ -143,7 +143,7 @@ Url: ${Us(t)}`),!0}return!1}function gv(t,e){return e?.length?uu(t).some(n=>$s(n
143
143
  40% {
144
144
  transform: scale(1);
145
145
  }
146
- }.attachments.svelte-19vup0k {display:flex;flex-direction:column;gap:0.5rem;margin-top:0.5rem;}.attachment-image-link.svelte-19vup0k {display:inline-block;}.attachment-image.svelte-19vup0k {max-width:240px;border-radius:0.5rem;display:block;}.attachment-file.svelte-19vup0k {display:inline-flex;align-items:center;gap:0.375rem;padding:0.375rem 0.625rem;border:1px solid #e5e7eb;border-radius:9999px;background:#f9fafb;text-decoration:none;font-size:0.8125rem;color:#374151;transition:background 0.15s;}.attachment-file.svelte-19vup0k:hover:not(.disabled) {background:#f3f4f6;}.attachment-file.disabled.svelte-19vup0k {opacity:0.5;pointer-events:none;}.attachment-file-icon.svelte-19vup0k {width:0.875rem;height:0.875rem;color:#6b7280;flex-shrink:0;}.attachment-file-name.svelte-19vup0k {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px;}.attachment-file-size.svelte-19vup0k {color:#9ca3af;flex-shrink:0;}.sources.svelte-19vup0k {margin-top:0.75rem;}.sources-label.svelte-19vup0k {font-size:0.75rem;font-weight:500;color:#6b7280;margin-bottom:0.5rem;}.source-item.svelte-19vup0k {display:flex;gap:0.5rem;padding:0.5rem 0.75rem;margin-bottom:0.25rem;border:1px solid #e5e7eb;border-radius:0.375rem;background:#f9fafb;text-decoration:none;transition:all 0.15s;}.source-item.svelte-19vup0k:hover {border-color:#d1d5db;background:#f3f4f6;}.source-icon.svelte-19vup0k {width:1rem;height:1rem;color:#6b7280;flex-shrink:0;}.source-text.svelte-19vup0k {flex:1;min-width:0;}.source-breadcrumb.svelte-19vup0k {font-size:0.75rem;color:#6b7280;margin-bottom:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.source-title.svelte-19vup0k {font-size:0.875rem;font-weight:500;color:#374151;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}`};function Fa(t,e){Gr(e,!0),Vo(t,uw);let n=Ae(e,"message"),r=Ae(e,"isLoading",7,!1),s=Ae(e,"avatarUrl",7,"/default-avatar.svg"),i=Ae(e,"brandColor",7,ja),a=Ae(e,"showAvatar",7,!0),o=Ae(e,"publishableApiKey"),l=Ae(e,"baseUrl"),c=te(!1),u=te(Et({}));function d(){R(c,!0)}async function h(x){if(x.url)return x.url;if(!x.storagePath||!o())return;if(w(u)[x.storagePath])return w(u)[x.storagePath];const C=await My({publishableApiKey:o(),storagePath:x.storagePath,baseUrl:l()});return C&&R(u,{...w(u),[x.storagePath]:C},!0),C??void 0}var f={get message(){return n()},set message(x){n(x),_e()},get isLoading(){return r()},set isLoading(x=!1){r(x),_e()},get avatarUrl(){return s()},set avatarUrl(x="/default-avatar.svg"){s(x),_e()},get brandColor(){return i()},set brandColor(x=ja){i(x),_e()},get showAvatar(){return a()},set showAvatar(x=!0){a(x),_e()},get publishableApiKey(){return o()},set publishableApiKey(x){o(x),_e()},get baseUrl(){return l()},set baseUrl(x){l(x),_e()}},g=cw(),v=X(g),_=X(v);{var S=x=>{var C=tw(),V=X(C);{var ae=re=>{var ye=xt(),Le=tt(ye);{var W=ce=>{var O=Zy();Pe(()=>as(O,`background-color: ${i()??""}`)),j(ce,O)},se=ce=>{var O=Qy();Pe(()=>Ve(O,"src",s())),qo("error",O,d),uh(O),j(ce,O)};oe(Le,ce=>{w(c)?ce(W):ce(se,!1)})}j(re,ye)},be=re=>{var ye=ew();Pe(()=>as(ye,`background-color: ${i()??""}`)),j(re,ye)};oe(V,re=>{n().role==="assistant"?re(ae):re(be,!1)})}K(C),j(x,C)};oe(_,x=>{a()&&x(S)})}var p=ie(_,2),m=X(p);{var y=x=>{var C=nw();j(x,C)},E=x=>{var C=xt(),V=tt(C);wh(V,()=>Ny(n().content)),j(x,C)};oe(m,x=>{!n().content&&r()&&n().role==="assistant"?x(y):x(E,!1)})}var b=ie(m,2);{var k=x=>{var C=iw();pr(C,21,()=>n().attachments,fr,(V,ae)=>{var be=xt(),re=tt(be);{var ye=W=>{var se=xt(),ce=tt(se);Go(ce,()=>h(w(ae)),null,(O,I)=>{var q=xt(),G=tt(q);{var ue=J=>{var M=rw(),Ye=X(M);K(M),Pe(()=>{Ve(M,"href",w(I)),Ve(Ye,"src",w(I)),Ve(Ye,"alt",w(ae).fileName)}),j(J,M)};oe(G,J=>{w(I)&&J(ue)})}j(O,q)}),j(W,se)},Le=W=>{var se=xt(),ce=tt(se);Go(ce,()=>h(w(ae)),null,(O,I)=>{var q=sw();let G;var ue=ie(X(q),2),J=X(ue,!0);K(ue);var M=ie(ue,2),Ye=X(M,!0);K(M),K(q),Pe((Kt,we)=>{Ve(q,"href",w(I)||"#"),G=Sh(q,1,"attachment-file svelte-19vup0k",null,G,Kt),Ut(J,w(ae).fileName),Ut(Ye,we)},[()=>({disabled:!w(I)}),()=>Ly(w(ae).fileSize)]),j(O,q)}),j(W,se)};oe(re,W=>{my(w(ae).fileType)?W(ye):W(Le,!1)})}j(V,be)}),K(C),j(x,C)};oe(b,x=>{n().attachments&&n().attachments.length>0&&x(k)})}var A=ie(b,2);{var T=x=>{var C=lw(),V=ie(X(C),2);pr(V,17,()=>n().sources.slice(0,1),fr,(ae,be)=>{var re=ow(),ye=ie(X(re),2),Le=X(ye);{var W=O=>{var I=aw(),q=X(I,!0);K(I),Pe(()=>Ut(q,w(be).breadcrumb)),j(O,I)};oe(Le,O=>{w(be).breadcrumb&&O(W)})}var se=ie(Le,2),ce=X(se,!0);K(se),K(ye),K(re),Pe(()=>{Ve(re,"href",w(be).url),Ut(ce,w(be).title)}),j(ae,re)}),K(C),j(x,C)};oe(A,x=>{n().sources&&n().sources.length>0&&x(T)})}return K(p),K(v),K(g),j(t,g),Kr(f)}yi(Fa,{message:{},isLoading:{},avatarUrl:{},brandColor:{},showAvatar:{},publishableApiKey:{},baseUrl:{}},[],[],!0);function dw(t,e,n,r,s,i,a,o){Xy(e()),R(n,void 0),R(r,[{role:"assistant",content:w(s)?.welcomeMessage||Hu}],!0),R(i,""),R(a,[],!0),R(o,null)}var hw=Z('<div class="loading-container svelte-7fg7a1"><div class="loading-content svelte-7fg7a1"><div class="spinner-ring svelte-7fg7a1"></div> <p class="loading-text svelte-7fg7a1">Loading chat...</p></div></div>'),fw=Z('<div class="error-container svelte-7fg7a1"><div class="error-content svelte-7fg7a1"><p class="error-text svelte-7fg7a1"> </p></div></div>'),pw=Z('<div class="separator svelte-7fg7a1"></div>'),gw=Z("<!> <!>",1),mw=(t,e,n)=>e(w(n)),_w=Z('<button class="example-btn svelte-7fg7a1"> </button>'),vw=Z('<div class="examples svelte-7fg7a1"><h3 class="svelte-7fg7a1">Example Questions</h3> <!></div>'),bw=Z('<span class="file-chip svelte-7fg7a1"> <button type="button" class="chip-remove svelte-7fg7a1">×</button></span>'),yw=Z('<div class="file-preview svelte-7fg7a1"></div>'),ww=Z('<p class="attach-error svelte-7fg7a1"> </p>'),Ew=(t,e)=>w(e)?.click(),kw=Z('<div class="reset-row svelte-7fg7a1"><button class="reset-btn svelte-7fg7a1">Clear chat</button></div>'),Sw=Z('<div class="footer svelte-7fg7a1"><a href="https://useknest.com" target="_blank" rel="noopener noreferrer" class="powered-by svelte-7fg7a1"><span>Powered by</span> <svg width="14" height="14" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="16" cy="16" r="3" fill="currentColor"></circle><path d="M16 6 A10 10 0 0 1 26 16" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><path d="M26 16 A10 10 0 0 1 16 26" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><path d="M16 26 A10 10 0 0 1 6 16" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><path d="M6 16 A10 10 0 0 1 16 6" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><circle cx="16" cy="5" r="2" fill="currentColor"></circle><circle cx="27" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="27" r="2" fill="currentColor"></circle><circle cx="5" cy="16" r="2" fill="currentColor"></circle><circle cx="23" cy="9" r="1.5" fill="currentColor"></circle><circle cx="23" cy="23" r="1.5" fill="currentColor"></circle><circle cx="9" cy="23" r="1.5" fill="currentColor"></circle><circle cx="9" cy="9" r="1.5" fill="currentColor"></circle></svg> <span>Knest</span></a></div>'),Tw=Z('<div class="messages-container svelte-7fg7a1"><!> <!> <div></div></div> <div class="input-section svelte-7fg7a1"><input type="file" multiple style="display:none"/> <!> <!> <div class="input-wrapper svelte-7fg7a1"><input type="text" placeholder="Ask me anything..." class="input-field svelte-7fg7a1"/> <button class="attach-btn svelte-7fg7a1" type="button" aria-label="Attach file"><svg class="attach-icon svelte-7fg7a1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"></path></svg></button> <button class="send-btn svelte-7fg7a1" aria-label="Send message"><svg class="send-icon svelte-7fg7a1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"></path></svg></button></div> <!> <!></div>',1),xw=Z('<div class="chat-card svelte-7fg7a1"><!></div>'),Aw=Z('<div class="bubble-panel svelte-7fg7a1"><!></div>'),Ow=(t,e)=>R(e,!w(e)),Rw=hi('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" class="bubble-spinner svelte-7fg7a1"><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-opacity="0.25" stroke-width="3" fill="none"></circle><path d="M12 3a9 9 0 0 1 9 9" stroke="currentColor" stroke-width="3" stroke-linecap="round" fill="none"></path></svg>'),Iw=hi('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg>'),$w=hi('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg>'),Cw=Z('<div class="bubble-container svelte-7fg7a1"><!> <button class="bubble-button svelte-7fg7a1"><!></button></div>');const Pw={hash:"svelte-7fg7a1",code:`:host {display:block;font-family:system-ui,
146
+ }.attachments.svelte-19vup0k {display:flex;flex-direction:column;gap:0.5rem;margin-top:0.5rem;}.attachment-image-link.svelte-19vup0k {display:inline-block;}.attachment-image.svelte-19vup0k {max-width:240px;border-radius:0.5rem;display:block;}.attachment-file.svelte-19vup0k {display:inline-flex;align-items:center;gap:0.375rem;padding:0.375rem 0.625rem;border:1px solid #e5e7eb;border-radius:9999px;background:#f9fafb;text-decoration:none;font-size:0.8125rem;color:#374151;transition:background 0.15s;}.attachment-file.svelte-19vup0k:hover:not(.disabled) {background:#f3f4f6;}.attachment-file.disabled.svelte-19vup0k {opacity:0.5;pointer-events:none;}.attachment-file-icon.svelte-19vup0k {width:0.875rem;height:0.875rem;color:#6b7280;flex-shrink:0;}.attachment-file-name.svelte-19vup0k {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px;}.attachment-file-size.svelte-19vup0k {color:#9ca3af;flex-shrink:0;}.sources.svelte-19vup0k {margin-top:0.75rem;}.sources-label.svelte-19vup0k {font-size:0.75rem;font-weight:500;color:#6b7280;margin-bottom:0.5rem;}.source-item.svelte-19vup0k {display:flex;gap:0.5rem;padding:0.5rem 0.75rem;margin-bottom:0.25rem;border:1px solid #e5e7eb;border-radius:0.375rem;background:#f9fafb;text-decoration:none;transition:all 0.15s;}.source-item.svelte-19vup0k:hover {border-color:#d1d5db;background:#f3f4f6;}.source-icon.svelte-19vup0k {width:1rem;height:1rem;color:#6b7280;flex-shrink:0;}.source-text.svelte-19vup0k {flex:1;min-width:0;}.source-breadcrumb.svelte-19vup0k {font-size:0.75rem;color:#6b7280;margin-bottom:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.source-title.svelte-19vup0k {font-size:0.875rem;font-weight:500;color:#374151;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}`};function Ma(t,e){Kr(e,!0),Jo(t,dw);let n=Ee(e,"message"),r=Ee(e,"isLoading",7,!1),s=Ee(e,"avatarUrl",7,"/default-avatar.svg"),i=Ee(e,"brandColor",7,Da),a=Ee(e,"showAvatar",7,!0),o=Ee(e,"publishableApiKey"),l=Ee(e,"baseUrl"),c=te(!1),u=te(wt({}));function d(){O(c,!0)}async function h(x){if(x.url)return x.url;if(!x.storagePath||!o())return;if(w(u)[x.storagePath])return w(u)[x.storagePath];const $=await By({publishableApiKey:o(),storagePath:x.storagePath,baseUrl:l()});return $&&O(u,{...w(u),[x.storagePath]:$},!0),$??void 0}var f={get message(){return n()},set message(x){n(x),de()},get isLoading(){return r()},set isLoading(x=!1){r(x),de()},get avatarUrl(){return s()},set avatarUrl(x="/default-avatar.svg"){s(x),de()},get brandColor(){return i()},set brandColor(x=Da){i(x),de()},get showAvatar(){return a()},set showAvatar(x=!0){a(x),de()},get publishableApiKey(){return o()},set publishableApiKey(x){o(x),de()},get baseUrl(){return l()},set baseUrl(x){l(x),de()}},m=uw(),_=X(m),v=X(_);{var S=x=>{var $=nw(),V=X($);{var pe=re=>{var ye=Tt(),Ge=et(ye);{var W=ce=>{var ae=Qy();Ne(()=>os(ae,`background-color: ${i()??""}`)),j(ce,ae)},se=ce=>{var ae=ew();Ne(()=>Ye(ae,"src",s())),Ho("error",ae,d),dh(ae),j(ce,ae)};oe(Ge,ce=>{w(c)?ce(W):ce(se,!1)})}j(re,ye)},ge=re=>{var ye=tw();Ne(()=>os(ye,`background-color: ${i()??""}`)),j(re,ye)};oe(V,re=>{n().role==="assistant"?re(pe):re(ge,!1)})}K($),j(x,$)};oe(v,x=>{a()&&x(S)})}var g=ie(v,2),p=X(g);{var y=x=>{var $=rw();j(x,$)},E=x=>{var $=Tt(),V=et($);Eh(V,()=>Ly(n().content)),j(x,$)};oe(p,x=>{!n().content&&r()&&n().role==="assistant"?x(y):x(E,!1)})}var b=ie(p,2);{var k=x=>{var $=aw();gr($,21,()=>n().attachments,pr,(V,pe)=>{var ge=Tt(),re=et(ge);{var ye=W=>{var se=Tt(),ce=et(se);Ko(ce,()=>h(w(pe)),null,(ae,R)=>{var L=Tt(),M=et(L);{var J=me=>{var G=sw(),q=X(G);K(G),Ne(()=>{Ye(G,"href",w(R)),Ye(q,"src",w(R)),Ye(q,"alt",w(pe).fileName)}),j(me,G)};oe(M,me=>{w(R)&&me(J)})}j(ae,L)}),j(W,se)},Ge=W=>{var se=Tt(),ce=et(se);Ko(ce,()=>h(w(pe)),null,(ae,R)=>{var L=iw();let M;var J=ie(X(L),2),me=X(J,!0);K(J);var G=ie(J,2),q=X(G,!0);K(G),K(L),Ne((Kt,It)=>{Ye(L,"href",w(R)||"#"),M=Th(L,1,"attachment-file svelte-19vup0k",null,M,Kt),Ut(me,w(pe).fileName),Ut(q,It)},[()=>({disabled:!w(R)}),()=>jy(w(pe).fileSize)]),j(ae,L)}),j(W,se)};oe(re,W=>{_y(w(pe).fileType)?W(ye):W(Ge,!1)})}j(V,ge)}),K($),j(x,$)};oe(b,x=>{n().attachments&&n().attachments.length>0&&x(k)})}var A=ie(b,2);{var T=x=>{var $=cw(),V=ie(X($),2);gr(V,17,()=>n().sources.slice(0,1),pr,(pe,ge)=>{var re=lw(),ye=ie(X(re),2),Ge=X(ye);{var W=ae=>{var R=ow(),L=X(R,!0);K(R),Ne(()=>Ut(L,w(ge).breadcrumb)),j(ae,R)};oe(Ge,ae=>{w(ge).breadcrumb&&ae(W)})}var se=ie(Ge,2),ce=X(se,!0);K(se),K(ye),K(re),Ne(()=>{Ye(re,"href",w(ge).url),Ut(ce,w(ge).title)}),j(pe,re)}),K($),j(x,$)};oe(A,x=>{n().sources&&n().sources.length>0&&x(T)})}return K(g),K(_),K(m),j(t,m),Vr(f)}wi(Ma,{message:{},isLoading:{},avatarUrl:{},brandColor:{},showAvatar:{},publishableApiKey:{},baseUrl:{}},[],[],!0);function hw(t,e,n,r,s,i,a,o){Zy(e()),O(n,void 0),O(r,[{role:"assistant",content:w(s)?.welcomeMessage||zu}],!0),O(i,""),O(a,[],!0),O(o,null)}var fw=Z('<div class="loading-container svelte-7fg7a1"><div class="loading-content svelte-7fg7a1"><div class="spinner-ring svelte-7fg7a1"></div> <p class="loading-text svelte-7fg7a1">Loading chat...</p></div></div>'),pw=Z('<div class="error-container svelte-7fg7a1"><div class="error-content svelte-7fg7a1"><p class="error-text svelte-7fg7a1"> </p></div></div>'),gw=Z('<div class="separator svelte-7fg7a1"></div>'),mw=Z("<!> <!>",1),_w=(t,e,n)=>e(w(n)),vw=Z('<button class="example-btn svelte-7fg7a1"> </button>'),bw=Z('<div class="examples svelte-7fg7a1"><h3 class="svelte-7fg7a1">Example Questions</h3> <!></div>'),yw=Z('<span class="file-chip svelte-7fg7a1"> <button type="button" class="chip-remove svelte-7fg7a1">×</button></span>'),ww=Z('<div class="file-preview svelte-7fg7a1"></div>'),Ew=Z('<p class="attach-error svelte-7fg7a1"> </p>'),kw=(t,e)=>w(e)?.click(),Sw=Z('<div class="reset-row svelte-7fg7a1"><button class="reset-btn svelte-7fg7a1">Clear chat</button></div>'),Tw=Z('<div class="footer svelte-7fg7a1"><a href="https://useknest.com" target="_blank" rel="noopener noreferrer" class="powered-by svelte-7fg7a1"><span>Powered by</span> <svg width="14" height="14" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="16" cy="16" r="3" fill="currentColor"></circle><path d="M16 6 A10 10 0 0 1 26 16" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><path d="M26 16 A10 10 0 0 1 16 26" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><path d="M16 26 A10 10 0 0 1 6 16" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><path d="M6 16 A10 10 0 0 1 16 6" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none"></path><circle cx="16" cy="5" r="2" fill="currentColor"></circle><circle cx="27" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="27" r="2" fill="currentColor"></circle><circle cx="5" cy="16" r="2" fill="currentColor"></circle><circle cx="23" cy="9" r="1.5" fill="currentColor"></circle><circle cx="23" cy="23" r="1.5" fill="currentColor"></circle><circle cx="9" cy="23" r="1.5" fill="currentColor"></circle><circle cx="9" cy="9" r="1.5" fill="currentColor"></circle></svg> <span>Knest</span></a></div>'),xw=Z('<div class="messages-container svelte-7fg7a1"><!> <!> <div></div></div> <div class="input-section svelte-7fg7a1"><input type="file" multiple style="display:none"/> <!> <!> <div class="input-wrapper svelte-7fg7a1"><input type="text" placeholder="Ask me anything..." class="input-field svelte-7fg7a1"/> <button class="attach-btn svelte-7fg7a1" type="button" aria-label="Attach file"><svg class="attach-icon svelte-7fg7a1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"></path></svg></button> <button class="send-btn svelte-7fg7a1" aria-label="Send message"><svg class="send-icon svelte-7fg7a1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"></path></svg></button></div> <!> <!></div>',1),Aw=Z('<div class="chat-card svelte-7fg7a1"><!></div>'),Rw=Z('<div class="bubble-panel svelte-7fg7a1"><!></div>'),Ow=(t,e)=>O(e,!w(e)),Iw=fi('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" class="bubble-spinner svelte-7fg7a1"><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-opacity="0.25" stroke-width="3" fill="none"></circle><path d="M12 3a9 9 0 0 1 9 9" stroke="currentColor" stroke-width="3" stroke-linecap="round" fill="none"></path></svg>'),$w=fi('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg>'),Cw=fi('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg>'),Pw=Z('<div class="bubble-container svelte-7fg7a1"><!> <button class="bubble-button svelte-7fg7a1"><!></button></div>');const Nw={hash:"svelte-7fg7a1",code:`:host {display:block;font-family:system-ui,
147
147
  -apple-system,
148
148
  sans-serif;}.chat-card.svelte-7fg7a1 {display:flex;flex-direction:column;height:600px;background:white;color:#374151;border-radius:1rem;box-shadow:0 10px 15px -3px rgba(0, 0, 0, 0.1);overflow:hidden;}.loading-container.svelte-7fg7a1 {display:flex;align-items:center;justify-content:center;height:100%;background:linear-gradient(135deg, #fdfbf7 0%, #ffffff 100%);}.loading-content.svelte-7fg7a1 {display:flex;flex-direction:column;align-items:center;gap:1.5rem;}.spinner-ring.svelte-7fg7a1 {width:3rem;height:3rem;border:3px solid #f3f4f6;border-top-color:#3b82f6;border-radius:50%;
149
149
  animation: svelte-7fg7a1-spin 0.8s linear infinite;}
@@ -159,4 +159,4 @@ Url: ${Us(t)}`),!0}return!1}function gv(t,e){return e?.length?uu(t).some(n=>$s(n
159
159
  animation: svelte-7fg7a1-spin 1s linear infinite;}.bubble-panel.svelte-7fg7a1 {width:380px;height:520px;max-width:calc(100vw - 48px);max-height:calc(100vh - 100px);border-radius:1rem;border:1px solid rgba(0, 0, 0, 0.1);box-shadow:0 10px 15px -3px rgba(0, 0, 0, 0.1);overflow:hidden;}.bubble-panel.svelte-7fg7a1 .chat-card:where(.svelte-7fg7a1) {height:100%;}
160
160
 
161
161
  @media (max-width: 440px) {.bubble-container.svelte-7fg7a1 {bottom:16px;right:16px;}.bubble-panel.svelte-7fg7a1 {width:calc(100vw - 32px);height:calc(100vh - 100px);}
162
- }`};function rd(t,e){Gr(e,!0),Vo(t,Pw);const n=O=>{var I=xw(),q=X(I);{var G=J=>{var M=hw();j(J,M)},ue=J=>{var M=xt(),Ye=tt(M);{var Kt=pe=>{var Xe=fw(),Ze=X(Xe),Tn=X(Ze),lt=X(Tn,!0);K(Tn),K(Ze),K(Xe),Pe(()=>Ut(lt,qu)),j(pe,Xe)},we=pe=>{var Xe=Tw(),Ze=tt(Xe),Tn=X(Ze);pr(Tn,17,()=>w(g),fr,(Y,de,$t)=>{var xn=gw(),An=tt(xn);{let _t=Pn(()=>!w(de).content&&w(_)&&w(de).role==="assistant"),qa=Pn(()=>a()?.baseUrl);Fa(An,{get message(){return w(de)},get isLoading(){return w(_t)},get avatarUrl(){return w(d)},get brandColor(){return w(f)},get publishableApiKey(){return r()},get baseUrl(){return w(qa)}})}var On=ie(An,2);{var mt=_t=>{var qa=pw();j(_t,qa)};oe(On,_t=>{$t<w(g).length-1&&_t(mt)})}j(Y,xn)});var lt=ie(Tn,2);{var jr=Y=>{var de=vw(),$t=ie(X(de),2);pr($t,17,()=>w(h),fr,(xn,An,On)=>{var mt=_w();mt.__click=[mw,re,An];var _t=X(mt,!0);K(mt),Pe(()=>{as(mt,On===0?`border-color: ${w(f)}; border-width: 2px;`:""),Ut(_t,w(An))}),j(xn,mt)}),K(de),j(Y,de)};oe(lt,Y=>{w(g).length===1&&!w(l)&&Y(jr)})}var Nw=ie(lt,2);Zo(Nw,Y=>R(S,Y),()=>w(S)),K(Ze);var sd=ie(Ze,2),Vs=X(sd);Vs.__change=C,Zo(Vs,Y=>R(T,Y),()=>w(T));var id=ie(Vs,2);{var Lw=Y=>{var de=yw();pr(de,21,()=>w(b),fr,($t,xn,An)=>{var On=bw(),mt=X(On),_t=ie(mt);_t.__click=()=>V(An),K(On),Pe(()=>{Ut(mt,`${w(xn).name??""} `),Ve(_t,"aria-label",`Remove ${w(xn).name??""}`)}),j($t,On)}),K(de),j(Y,de)};oe(id,Y=>{w(b).length>0&&Y(Lw)})}var ad=ie(id,2);{var jw=Y=>{var de=ww(),$t=X(de,!0);K(de),Pe(()=>Ut($t,w(A))),j(Y,de)};oe(ad,Y=>{w(A)&&Y(jw)})}var Ba=ie(ad,2),Dr=X(Ba);Ah(Dr);var Js=ie(Dr,2);Js.__click=[Ew,T];var od=ie(Js,2);od.__click=ae,K(Ba);var ld=ie(Ba,2);{var Dw=Y=>{var de=kw(),$t=X(de);$t.__click=[dw,r,p,g,o,v,b,A],K(de),j(Y,de)};oe(ld,Y=>{w(g).length>1&&!w(_)&&Y(Dw)})}var Uw=ie(ld,2);{var Fw=Y=>{var de=Sw();j(Y,de)};oe(Uw,Y=>{Y(Fw)})}K(sd),Pe(Y=>{Ve(Vs,"accept",dy),Dr.disabled=w(_)||w(k)||!w(u),Js.disabled=!w(p)||w(_)||w(k),Ve(Js,"title",w(p)?"Attach file":"Send a message first to enable attachments"),od.disabled=Y},[()=>w(_)||w(k)||!w(v).trim()||!w(u)]),qo("keypress",Dr,be),Ih(Dr,()=>w(v),Y=>R(v,Y)),j(pe,Xe)};oe(Ye,pe=>{w(c)==="auth"?pe(Kt):pe(we,!1)},!0)}j(J,M)};oe(q,J=>{w(l)?J(G):J(ue,!1)})}K(I),j(O,I)};let r=Ae(e,"publishableApiKey"),s=Ae(e,"mode",7,"inline"),i=Ae(e,"defaultOpen",7,!1),a=Ae(e,"_internal"),o=te(null),l=te(!0),c=te(null),u=te(!1),d=Pn(()=>w(o)?.avatarUrl||ly),h=Pn(()=>w(o)?.exampleQuestions||cy),f=Pn(()=>w(o)?.brandColor||ja),g=te(Et([])),v=te(""),_=te(!1),S=te(void 0),p=te(void 0),m=te(Et(i())),y=te(!1),E=null,b=te(Et([])),k=te(!1),A=te(null),T=te(void 0);vh(()=>{typeof requestIdleCallback<"u"?requestIdleCallback(()=>td()):setTimeout(()=>td(),0)}),cr(()=>{if(!r()||w(y))return;R(y,!0);const O=a()?.supabaseUrl||ny,I=a()?.supabaseAnonKey||ry;E=Ey(O,I),x()});async function x(){const O=await wy(r(),a()?.baseUrl,q=>{R(o,q,!0)});if(O.error){R(c,O.error,!0),R(l,!1);return}R(o,O.config,!0),R(l,!1);const I=Vy(r());if(I&&I.messages.length>0?(R(g,I.messages,!0),R(p,I.threadId,!0),R(v,I.input,!0)):R(g,[{role:"assistant",content:O.config?.welcomeMessage||Hu}],!0),E){const q=await E;q||console.warn("Widget auth initialization failed"),R(u,q,!0)}}cr(()=>{w(g).length>0&&w(S)&&w(S).scrollIntoView({behavior:"smooth"})}),cr(()=>!w(p)||!w(u)?void 0:zy(w(p),I=>{if(I.role!=="human"||w(g).some(G=>G.id===I.id))return;const q=I.metadata?.attachments??[];R(g,[...w(g),{id:I.id,role:"assistant",content:I.content,...q.length>0?{attachments:q}:{}}],!0)}));function C(O){const I=O.target,q=Array.from(I.files||[]);I.value="",R(A,null);for(const ue of q){const J=jy(ue);if(J){R(A,J,!0);return}}const G=fy-w(b).length;R(b,[...w(b),...q.slice(0,G)],!0)}function V(O){R(b,w(b).filter((I,q)=>q!==O),!0)}async function ae(){if(!w(v).trim()||w(_)||!w(u))return;const O=w(v).trim();R(v,""),R(_,!0),R(A,null);let I=[];if(w(b).length>0&&w(p)){R(k,!0);try{I=await Promise.all(w(b).map(M=>Fy({publishableApiKey:r(),threadId:w(p),file:M,baseUrl:a()?.baseUrl})))}catch(M){nd(M instanceof Error?M.message:"Upload failed",{threadId:w(p),baseUrl:a()?.baseUrl}),R(A,M instanceof Error?M.message:"Upload failed.",!0),R(_,!1),R(k,!1);return}R(k,!1),R(b,[],!0)}const q=I.length>0?{attachments:I}:void 0;R(g,[...w(g),{role:"user",content:O,...I.length>0?{attachments:I}:{}}],!0);const G=w(g).length;R(g,[...w(g),{role:"assistant",content:""}],!0);let ue="",J=[];await Ty({publishableApiKey:r(),content:O,threadId:w(p),baseUrl:a()?.baseUrl,metadata:q,callbacks:{onInit:M=>{w(p)||R(p,M,!0)},onContent:M=>{ue+=M,R(g,[...w(g).slice(0,G),{role:"assistant",content:ue},...w(g).slice(G+1)],!0)},onComplete:M=>{J=M,R(g,[...w(g).slice(0,G),{role:"assistant",content:ue,sources:J},...w(g).slice(G+1)],!0)},onDone:({humanTakeover:M})=>{M&&R(g,[...w(g).slice(0,G),...w(g).slice(G+1)],!0)},onError:M=>{nd(M,{userMessage:O,threadId:w(p),baseUrl:a()?.baseUrl}),R(g,[...w(g).slice(0,G),{role:"assistant",content:`Error: ${M}`},...w(g).slice(G+1)],!0)}}}),R(_,!1)}function be(O){O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),ae())}async function re(O){R(v,O,!0),await ae()}cr(()=>{const O=w(g),I=w(p),q=w(v);O.length<=1&&!q||Yy(r(),{threadId:I,messages:O,input:q,savedAt:Date.now()})});var ye={get publishableApiKey(){return r()},set publishableApiKey(O){r(O),_e()},get mode(){return s()},set mode(O="inline"){s(O),_e()},get defaultOpen(){return i()},set defaultOpen(O=!1){i(O),_e()},get _internal(){return a()},set _internal(O){a(O),_e()}},Le=xt(),W=tt(Le);{var se=O=>{n(O)},ce=O=>{const I=Pn(()=>w(l)?"#9ca3af":w(f));var q=Cw(),G=X(q);{var ue=we=>{var pe=Aw(),Xe=X(pe);n(Xe),K(pe),j(we,pe)};oe(G,we=>{w(m)&&we(ue)})}var J=ie(G,2);J.__click=[Ow,m];var M=X(J);{var Ye=we=>{var pe=Rw();j(we,pe)},Kt=we=>{var pe=xt(),Xe=tt(pe);{var Ze=lt=>{var jr=Iw();j(lt,jr)},Tn=lt=>{var jr=$w();j(lt,jr)};oe(Xe,lt=>{w(m)?lt(Ze):lt(Tn,!1)},!0)}j(we,pe)};oe(M,we=>{w(l)?we(Ye):we(Kt,!1)})}K(J),K(q),Pe(()=>{Ve(J,"aria-label",w(l)?"Loading chat":w(m)?"Close chat":"Open chat"),as(J,`background-color: ${w(I)??""}`)}),j(O,q)};oe(W,O=>{s()==="inline"?O(se):O(ce,!1)})}return j(t,Le),Kr(ye)}hh(["click","change"]),yi(rd,{publishableApiKey:{},mode:{},defaultOpen:{},_internal:{}},[],[],!0);function Ma(t,e){Gr(e,!0);let n=Ae(e,"publishableApiKey"),r=Ae(e,"mode",7,"inline"),s=Ae(e,"defaultOpen",7,!1),i=Ae(e,"_internal");var a={get publishableApiKey(){return n()},set publishableApiKey(o){n(o),_e()},get mode(){return r()},set mode(o="inline"){r(o),_e()},get defaultOpen(){return s()},set defaultOpen(o=!1){s(o),_e()},get _internal(){return i()},set _internal(o){i(o),_e()}};return rd(t,{get publishableApiKey(){return n()},get mode(){return r()},get defaultOpen(){return s()},get _internal(){return i()}}),Kr(a)}customElements.define("knest-chat",yi(Ma,{publishableApiKey:{attribute:"publishable-api-key",type:"String"},mode:{attribute:"mode",type:"String"},defaultOpen:{attribute:"default-open",type:"Boolean"},_internal:{type:"Object"}},[],[],!0)),Ct.ChatMessage=Fa,Ct.ChatWidget=Ma,Ct.default=Ma,Object.defineProperties(Ct,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
162
+ }`};function sd(t,e){Kr(e,!0),Jo(t,Nw);const n=R=>{var L=Aw(),M=X(L);{var J=G=>{var q=fw();j(G,q)},me=G=>{var q=Tt(),Kt=et(q);{var It=Se=>{var je=pw(),Vt=X(je),xn=X(Vt),ot=X(xn,!0);K(xn),K(Vt),K(je),Ne(()=>Ut(ot,Hu)),j(Se,je)},ke=Se=>{var je=xw(),Vt=et(je),xn=X(Vt);gr(xn,17,()=>w(_),pr,(Y,ue,$t)=>{var An=mw(),Rn=et(An);{let mt=Nn(()=>!w(ue).content&&w(S)&&w(ue).role==="assistant"),Ha=Nn(()=>o()?.baseUrl);Ma(Rn,{get message(){return w(ue)},get isLoading(){return w(mt)},get avatarUrl(){return w(h)},get brandColor(){return w(m)},get publishableApiKey(){return r()},get baseUrl(){return w(Ha)}})}var On=ie(Rn,2);{var gt=mt=>{var Ha=gw();j(mt,Ha)};oe(On,mt=>{$t<w(_).length-1&&mt(gt)})}j(Y,An)});var ot=ie(xn,2);{var Dr=Y=>{var ue=bw(),$t=ie(X(ue),2);gr($t,17,()=>w(f),pr,(An,Rn,On)=>{var gt=vw();gt.__click=[_w,ye,Rn];var mt=X(gt,!0);K(gt),Ne(()=>{os(gt,On===0?`border-color: ${w(m)}; border-width: 2px;`:""),Ut(mt,w(Rn))}),j(An,gt)}),K(ue),j(Y,ue)};oe(ot,Y=>{w(_).length===1&&!w(c)&&Y(Dr)})}var Lw=ie(ot,2);Qo(Lw,Y=>O(g,Y),()=>w(g)),K(Vt);var id=ie(Vt,2),Js=X(id);Js.__change=V,Qo(Js,Y=>O(x,Y),()=>w(x));var ad=ie(Js,2);{var jw=Y=>{var ue=ww();gr(ue,21,()=>w(k),pr,($t,An,Rn)=>{var On=yw(),gt=X(On),mt=ie(gt);mt.__click=()=>pe(Rn),K(On),Ne(()=>{Ut(gt,`${w(An).name??""} `),Ye(mt,"aria-label",`Remove ${w(An).name??""}`)}),j($t,On)}),K(ue),j(Y,ue)};oe(ad,Y=>{w(k).length>0&&Y(jw)})}var od=ie(ad,2);{var Dw=Y=>{var ue=Ew(),$t=X(ue,!0);K(ue),Ne(()=>Ut($t,w(T))),j(Y,ue)};oe(od,Y=>{w(T)&&Y(Dw)})}var qa=ie(od,2),Ur=X(qa);Rh(Ur);var Ys=ie(Ur,2);Ys.__click=[kw,x];var ld=ie(Ys,2);ld.__click=ge,K(qa);var cd=ie(qa,2);{var Uw=Y=>{var ue=Sw(),$t=X(ue);$t.__click=[hw,r,p,_,l,v,k,T],K(ue),j(Y,ue)};oe(cd,Y=>{w(_).length>1&&!w(S)&&Y(Uw)})}var Fw=ie(cd,2);{var Mw=Y=>{var ue=Tw();j(Y,ue)};oe(Fw,Y=>{Y(Mw)})}K(id),Ne(Y=>{Ye(Js,"accept",hy),Ur.disabled=w(S)||w(A)||!w(d),Ys.disabled=!w(p)||w(S)||w(A),Ye(Ys,"title",w(p)?"Attach file":"Send a message first to enable attachments"),ld.disabled=Y},[()=>w(S)||w(A)||!w(v).trim()||!w(d)]),Ho("keypress",Ur,re),$h(Ur,()=>w(v),Y=>O(v,Y)),j(Se,je)};oe(Kt,Se=>{w(u)==="auth"?Se(It):Se(ke,!1)},!0)}j(G,q)};oe(M,G=>{w(c)?G(J):G(me,!1)})}K(L),j(R,L)};let r=Ee(e,"publishableApiKey"),s=Ee(e,"mode",7,"inline"),i=Ee(e,"defaultOpen",7,!1),a=Ee(e,"user"),o=Ee(e,"_internal"),l=te(null),c=te(!0),u=te(null),d=te(!1),h=Nn(()=>w(l)?.avatarUrl||cy),f=Nn(()=>w(l)?.exampleQuestions||uy),m=Nn(()=>w(l)?.brandColor||Da),_=te(wt([])),v=te(""),S=te(!1),g=te(void 0),p=te(void 0),y=te(wt(i())),E=te(!1),b=null,k=te(wt([])),A=te(!1),T=te(null),x=te(void 0);bh(()=>{typeof requestIdleCallback<"u"?requestIdleCallback(()=>nd()):setTimeout(()=>nd(),0)}),ur(()=>{if(!r()||w(E))return;O(E,!0);const R=o()?.supabaseUrl||ry,L=o()?.supabaseAnonKey||sy;b=ky(R,L),$()});async function $(){const R=await Ey(r(),o()?.baseUrl,M=>{O(l,M,!0)});if(R.error){O(u,R.error,!0),O(c,!1);return}O(l,R.config,!0),O(c,!1);const L=Jy(r());if(L&&L.messages.length>0?(O(_,L.messages,!0),O(p,L.threadId,!0),O(v,L.input,!0)):O(_,[{role:"assistant",content:R.config?.welcomeMessage||zu}],!0),b){const M=await b;M||console.warn("Widget auth initialization failed"),O(d,M,!0)}}ur(()=>{w(_).length>0&&w(g)&&w(g).scrollIntoView({behavior:"smooth"})}),ur(()=>!w(p)||!w(d)?void 0:Wy(w(p),L=>{if(L.role!=="human"||w(_).some(J=>J.id===L.id))return;const M=L.metadata?.attachments??[];O(_,[...w(_),{id:L.id,role:"assistant",content:L.content,...M.length>0?{attachments:M}:{}}],!0)}));function V(R){const L=R.target,M=Array.from(L.files||[]);L.value="",O(T,null);for(const me of M){const G=Dy(me);if(G){O(T,G,!0);return}}const J=py-w(k).length;O(k,[...w(k),...M.slice(0,J)],!0)}function pe(R){O(k,w(k).filter((L,M)=>M!==R),!0)}async function ge(){if(!w(v).trim()||w(S)||!w(d))return;const R=w(v).trim();O(v,""),O(S,!0),O(T,null);let L=[];if(w(k).length>0&&w(p)){O(A,!0);try{L=await Promise.all(w(k).map(q=>My({publishableApiKey:r(),threadId:w(p),file:q,baseUrl:o()?.baseUrl})))}catch(q){rd(q instanceof Error?q.message:"Upload failed",{threadId:w(p),baseUrl:o()?.baseUrl}),O(T,q instanceof Error?q.message:"Upload failed.",!0),O(S,!1),O(A,!1);return}O(A,!1),O(k,[],!0)}const M=L.length>0?{attachments:L}:void 0;O(_,[...w(_),{role:"user",content:R,...L.length>0?{attachments:L}:{}}],!0);const J=w(_).length;O(_,[...w(_),{role:"assistant",content:""}],!0);let me="",G=[];await xy({publishableApiKey:r(),content:R,threadId:w(p),baseUrl:o()?.baseUrl,metadata:M,user:a(),callbacks:{onInit:q=>{w(p)||O(p,q,!0)},onContent:q=>{me+=q,O(_,[...w(_).slice(0,J),{role:"assistant",content:me},...w(_).slice(J+1)],!0)},onComplete:q=>{G=q,O(_,[...w(_).slice(0,J),{role:"assistant",content:me,sources:G},...w(_).slice(J+1)],!0)},onDone:({humanTakeover:q})=>{q&&O(_,[...w(_).slice(0,J),...w(_).slice(J+1)],!0)},onError:q=>{rd(q,{userMessage:R,threadId:w(p),baseUrl:o()?.baseUrl}),O(_,[...w(_).slice(0,J),{role:"assistant",content:`Error: ${q}`},...w(_).slice(J+1)],!0)}}}),O(S,!1)}function re(R){R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),ge())}async function ye(R){O(v,R,!0),await ge()}ur(()=>{const R=w(_),L=w(p),M=w(v);R.length<=1&&!M||Xy(r(),{threadId:L,messages:R,input:M,savedAt:Date.now()})});var Ge={get publishableApiKey(){return r()},set publishableApiKey(R){r(R),de()},get mode(){return s()},set mode(R="inline"){s(R),de()},get defaultOpen(){return i()},set defaultOpen(R=!1){i(R),de()},get user(){return a()},set user(R){a(R),de()},get _internal(){return o()},set _internal(R){o(R),de()}},W=Tt(),se=et(W);{var ce=R=>{n(R)},ae=R=>{const L=Nn(()=>w(c)?"#9ca3af":w(m));var M=Pw(),J=X(M);{var me=ke=>{var Se=Rw(),je=X(Se);n(je),K(Se),j(ke,Se)};oe(J,ke=>{w(y)&&ke(me)})}var G=ie(J,2);G.__click=[Ow,y];var q=X(G);{var Kt=ke=>{var Se=Iw();j(ke,Se)},It=ke=>{var Se=Tt(),je=et(Se);{var Vt=ot=>{var Dr=$w();j(ot,Dr)},xn=ot=>{var Dr=Cw();j(ot,Dr)};oe(je,ot=>{w(y)?ot(Vt):ot(xn,!1)},!0)}j(ke,Se)};oe(q,ke=>{w(c)?ke(Kt):ke(It,!1)})}K(G),K(M),Ne(()=>{Ye(G,"aria-label",w(c)?"Loading chat":w(y)?"Close chat":"Open chat"),os(G,`background-color: ${w(L)??""}`)}),j(R,M)};oe(se,R=>{s()==="inline"?R(ce):R(ae,!1)})}return j(t,W),Vr(Ge)}fh(["click","change"]),wi(sd,{publishableApiKey:{},mode:{},defaultOpen:{},user:{},_internal:{}},[],[],!0);function Ba(t,e){Kr(e,!0);let n=Ee(e,"publishableApiKey"),r=Ee(e,"mode",7,"inline"),s=Ee(e,"defaultOpen",7,!1),i=Ee(e,"user"),a=Ee(e,"_internal");var o={get publishableApiKey(){return n()},set publishableApiKey(l){n(l),de()},get mode(){return r()},set mode(l="inline"){r(l),de()},get defaultOpen(){return s()},set defaultOpen(l=!1){s(l),de()},get user(){return i()},set user(l){i(l),de()},get _internal(){return a()},set _internal(l){a(l),de()}};return sd(t,{get publishableApiKey(){return n()},get mode(){return r()},get defaultOpen(){return s()},get user(){return i()},get _internal(){return a()}}),Vr(o)}customElements.define("knest-chat",wi(Ba,{publishableApiKey:{attribute:"publishable-api-key",type:"String"},mode:{attribute:"mode",type:"String"},defaultOpen:{attribute:"default-open",type:"Boolean"},user:{type:"Object"},_internal:{type:"Object"}},[],[],!0)),Ct.ChatMessage=Ma,Ct.ChatWidget=Ba,Ct.default=Ba,Object.defineProperties(Ct,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));