@framerauth/sdk 2.1.4 → 2.1.5

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 +1 @@
1
- "use strict";(()=>{var We=Object.defineProperty,$e=Object.defineProperties,Ie=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable,Z=(t,e,r)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,U=(t,e)=>{for(var r in e||(e={}))Me.call(e,r)&&Z(t,r,e[r]);if(X)for(var r of X(e))He.call(e,r)&&Z(t,r,e[r]);return t},O=(t,e)=>$e(t,Ie(e)),qe=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},Je=async(t,e)=>{var r,n,o,a,s,b;let m=e||{},i={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:m,hooks:i};for(let d of e?.plugins||[]){if(d.init){let P=await((r=d.init)==null?void 0:r.call(d,t.toString(),e));m=P.options||m,t=P.url}i.onRequest.push((n=d.hooks)==null?void 0:n.onRequest),i.onResponse.push((o=d.hooks)==null?void 0:o.onResponse),i.onSuccess.push((a=d.hooks)==null?void 0:a.onSuccess),i.onError.push((s=d.hooks)==null?void 0:s.onError),i.onRetry.push((b=d.hooks)==null?void 0:b.onRetry)}return{url:t,options:m,hooks:i}},ee=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},Ve=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function Ke(t){if(typeof t=="number")return new ee({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new ee(t);case"exponential":return new Ve(t);default:throw new Error("Invalid retry strategy")}}var Ge=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},Qe=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ye(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Qe.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function Xe(t){try{return JSON.parse(t),!0}catch{return!1}}function ne(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function te(t){try{return JSON.parse(t)}catch{return t}}function re(t){return typeof t=="function"}function Ze(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&re(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&re(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function et(t){let e=new Headers(t?.headers),r=await Ge(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=tt(t?.body);n&&e.set("content-type",n)}return e}function tt(t){return ne(t)?"application/json":null}function rt(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(ne(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function nt(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return ae.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function ot(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var at=class oe extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,oe.prototype)}};async function st(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new at(r.issues);return r.value}var ae=["get","post","put","patch","delete"];function it(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let P=t.toString().split("@")[1].split("/")[0];ae.includes(P)&&(t=t.replace(`@${P}/`,"/"))}a.endsWith("/")||(a+="/");let[s,b]=t.replace(a,"").split("?"),m=new URLSearchParams(b);for(let[P,h]of Object.entries(o||{}))h!=null&&m.set(P,String(h));if(n)if(Array.isArray(n)){let P=s.split("/").filter(h=>h.startsWith(":"));for(let[h,H]of P.entries()){let B=n[h];s=s.replace(H,B)}}else for(let[P,h]of Object.entries(n))s=s.replace(`:${P}`,String(h));s=s.split("/").map(encodeURIComponent).join("/"),s.startsWith("/")&&(s=s.slice(1));let i=m.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${s}${i}`,a):`${a}${s}${i}`}var c=async(t,e)=>{var r,n,o,a,s,b,m,i;let{hooks:d,url:P,options:h}=await Je(t,e),H=Ze(h),B=new AbortController,xe=(r=h.signal)!=null?r:B.signal,_e=it(P,h),Be=rt(h),De=await et(h),je=nt(P,h),f=O(U({},h),{url:_e,headers:De,body:Be,method:je,signal:xe});for(let v of d.onRequest)if(v){let y=await v(f);y instanceof Object&&(f=y)}("pipeTo"in f&&typeof f.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in f||(f.duplex="half"));let{clearTimeout:Ce}=ot(h,B),l=await H(f.url,f);Ce();let Q={response:l,request:f};for(let v of d.onResponse)if(v){let y=await v(O(U({},Q),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?l.clone():l}));y instanceof Response?l=y:y instanceof Object&&(l=y.response)}if(l.ok){if(!(f.method!=="HEAD"))return{data:"",error:null};let y=Ye(l),E={data:"",response:l,request:f};if(y==="json"||y==="text"){let T=await l.text(),ze=await((a=f.jsonParser)!=null?a:te)(T);E.data=ze}else E.data=await l[y]();f?.output&&f.output&&!f.disableValidation&&(E.data=await st(f.output,E.data));for(let T of d.onSuccess)T&&await T(O(U({},E),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?l.clone():l}));return e?.throw?E.data:{data:E.data,error:null}}let Ne=(b=e?.jsonParser)!=null?b:te,D=await l.text(),Y=Xe(D),q=Y?await Ne(D):null,Fe={response:l,responseText:D,request:f,error:O(U({},q),{status:l.status,statusText:l.statusText})};for(let v of d.onError)v&&await v(O(U({},Fe),{response:(m=e?.hookOptions)!=null&&m.cloneResponse?l.clone():l}));if(e?.retry){let v=Ke(e.retry),y=(i=e.retryAttempt)!=null?i:0;if(await v.shouldAttemptRetry(y,l)){for(let T of d.onRetry)T&&await T(Q);let E=v.getDelay(y);return await new Promise(T=>setTimeout(T,E)),await c(t,O(U({},e),{retryAttempt:y+1}))}}if(e?.throw)throw new qe(l.status,l.statusText,Y?q:D);return{data:null,error:O(U({},q),{status:l.status,statusText:l.statusText})}};var lt="https://core.framerauth.com/v2",j=class{baseURL=null;data;state;api;auth;constructor(e){this.baseURL=null,this.data=e.data,this.state=e.state,this.api={fetchBookmarks:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await c(`${this.baseURL}/profile/bookmarks`,{credentials:"include"});if(!r.data)return r;let n=new Set(r.data),o={};for(let a of n)o[a]=!0;return{data:o,error:null}},fetchProject:async()=>await c(`${lt}/public/project/config`)},this.auth={getSession:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await c(`${this.baseURL}/get-session`,{method:"GET",credentials:"include",query:{disableCookieCache:!0}});return r.data?(this.data.user.set(r.data.user),this.data.session.set(r.data.session),this.data.tags.set(r.data.user.tags??[])):(this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({})),r},signUp:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await c(`${this.baseURL}/sign-up/email`,{method:"POST",credentials:"include",body:r});return n.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(o=>{this.data.bookmarks.set(o.data??{})})),n},signIn:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await c(`${this.baseURL}/sign-in/email`,{method:"POST",credentials:"include",body:r});return n.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(o=>{this.data.bookmarks.set(o.data??{})})),n},signInSocial:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await c(`${this.baseURL}/sign-in/social`,{method:"POST",credentials:"include",body:r});return n.data?.url&&(window.location.href=n.data.url),n},signOut:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await c(`${this.baseURL}/sign-out`,{method:"POST",credentials:"include",body:{}});return this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),r?.redirectTo&&(window.location.href=r.redirectTo),n},sendOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/email-otp/send-verification-otp`;return await c(n,{body:r,credentials:"include",method:"POST"})},signInOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/sign-in/email-otp`,o=await c(n,{body:r,credentials:"include",method:"POST"});return o.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(a=>{this.data.bookmarks.set(a.data??{})})),o},updateProfile:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile`;return await c(n,{body:r,credentials:"include",method:"PATCH"})},updateProfilePicture:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/avatar`;return await c(n,{method:"POST",body:r,credentials:"include"})},createBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks`;return await c(n,{body:r,credentials:"include",method:"POST"})},deleteBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks/${r.bookmark_type}/${r.id}`;return await c(n,{credentials:"include",method:"DELETE"})},sendForgotPasswordEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/request-password-reset`;return await c(n,{body:r,credentials:"include",method:"POST"})},resetPassword:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/reset-password`;return await c(n,{body:r,credentials:"include",method:"POST"})},storeCheckout:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/store/checkout/session`;return await c(n,{body:r,credentials:"include",method:"POST"})},sendVerificationEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/send-verification-email`;return await c(n,{body:r,credentials:"include",method:"POST"})}}}updateBaseURL(e){this.baseURL=e}};var S=[],A=0,C=4,ct=0,p=t=>{let e=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=e.push(n),()=>{for(let a=A+C;a<S.length;)S[a]===n?S.splice(a,C):a+=C;let o=e.indexOf(n);~o&&(e.splice(o,1),--r.lc||r.off())}},notify(n,o){ct++;let a=!S.length;for(let s of e)S.push(s,r.value,n,o);if(a){for(A=0;A<S.length;A+=C)S[A](S[A+1],S[A+2],S[A+3]);S.length=0}},off(){},set(n){let o=r.value;o!==n&&(r.value=n,r.notify(o))},subscribe(n){let o=r.listen(n);return n(r.value),o},value:t};return r};var ut=5,N=6,F=10,dt=(t,e,r,n)=>(t.events=t.events||{},t.events[r+F]||(t.events[r+F]=n(o=>{t.events[r].reduceRight((a,s)=>(s(a),a),{shared:{},...o})})),t.events[r]=t.events[r]||[],t.events[r].push(e),()=>{let o=t.events[r],a=o.indexOf(e);o.splice(a,1),o.length||(delete t.events[r],t.events[r+F](),delete t.events[r+F])});var se=1e3,J=(t,e)=>dt(t,n=>{let o=e(n);o&&t.events[N].push(o)},ut,n=>{let o=t.listen;t.listen=(...s)=>(!t.lc&&!t.active&&(t.active=!0,n()),o(...s));let a=t.off;return t.events[N]=[],t.off=()=>{a(),setTimeout(()=>{if(t.active&&!t.lc){t.active=!1;for(let s of t.events[N])s();t.events[N]=[]}},se)},()=>{t.listen=o,t.off=a}});var z=(t={})=>{let e=p(t);return e.setKey=function(r,n){let o=e.value;typeof n>"u"&&r in e.value?(e.value={...e.value},delete e.value[r],e.notify(o,r)):e.value[r]!==n&&(e.value={...e.value,[r]:n},e.notify(o,r))},e};var ie=t=>t,x={},V={addEventListener(){},removeEventListener(){}};function ft(){try{return typeof localStorage<"u"}catch{return!1}}ft()&&(x=localStorage);var ht={addEventListener(t,e,r){window.addEventListener("storage",e),window.addEventListener("pageshow",r)},removeEventListener(t,e,r){window.removeEventListener("storage",e),window.removeEventListener("pageshow",r)}};typeof window<"u"&&(V=ht);function w(t,e=void 0,r={}){let n=r.encode||ie,o=r.decode||ie,a=p(e),s=a.set;a.set=i=>{let d=n(i);typeof d>"u"?delete x[t]:x[t]=d,s(i)};function b(i){i.key===t?i.newValue===null?s(e):s(o(i.newValue)):x[t]||s(e)}function m(){a.set(x[t]?o(x[t]):e)}return J(a,()=>{if(m(),r.listen!==!1)return V.addEventListener(t,b,m),()=>{V.removeEventListener(t,b,m)}}),a}var pt="framerauth_v2_",le=new TextEncoder,mt=new TextDecoder;function ce(){let t=typeof window<"u"?window.location.hostname:"1f8cXd6c7b4a3vL4z5746oUgQ28190adbef";return le.encode(pt+t)}function gt(t){let e=ce(),r=le.encode(t),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r[o]^e[o%e.length];return n}function yt(t){let e=gt(t),r=Array.from(e,n=>String.fromCharCode(n)).join("");return btoa(r)}function bt(t){let e=ce(),r=atob(t),n=Uint8Array.from(r,a=>a.charCodeAt(0)),o=new Uint8Array(n.length);for(let a=0;a<n.length;a++)o[a]=n[a]^e[a%e.length];return mt.decode(o)}function R({obfuscate:t}){return e=>{let r=JSON.stringify(e);return t&&(r=yt(r)),r}}function k({deobfuscate:t,fallback:e,validator:r}){return n=>{try{if(!n)return e;t&&(n=bt(n));let o=JSON.parse(n);if(r){let a=r(o);return a===null?e:a}return o}catch{return e}}}var ue=w("fa-project",null,{encode:R({obfuscate:!0}),decode:k({deobfuscate:!0,fallback:null})}),de=p(!1);var fe=w("fa-tags",[],{encode:R({obfuscate:!0}),decode:k({deobfuscate:!0,fallback:[]})}),he=p(!1);function pe(t){return Array.isArray(t)?t.length===0?!0:t.every(e=>e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.name=="string"):!1}function Pt(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id!="string"||typeof e.email!="string"||typeof e.name!="string"||typeof e.email_verified!="boolean"||!(e.created_at instanceof Date||typeof e.created_at=="string")||!(e.updated_at instanceof Date||typeof e.updated_at=="string")?!1:pe(e.tags)}function vt(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id=="string"&&typeof e.user_id=="string"&&typeof e.token=="string"&&(e.expires_at instanceof Date||typeof e.expires_at=="string")&&(e.created_at instanceof Date||typeof e.created_at=="string")&&(e.updated_at instanceof Date||typeof e.updated_at=="string")}function me(t){if(!t||typeof t!="object")return null;let e=t;return pe(e.tags)||(e.tags=[]),Pt(e)?e:null}function ge(t){return vt(t)?t:null}function St(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.entries(t).every(([e,r])=>typeof e=="string"&&typeof r=="boolean")}function ye(t){return!t||typeof t!="object"||Array.isArray(t)?{}:St(t)?t:{}}var be=w("fa-user",null,{encode:R({obfuscate:!0}),decode:k({deobfuscate:!0,fallback:null,validator:me})}),Pe=p(!1);var ve=w("fa-session",null,{encode:R({obfuscate:!0}),decode:k({deobfuscate:!0,fallback:null,validator:ge})}),Se=p(!1);var we=p(!0);function _(){document.body.style.visibility="hidden"}function L(){document.body.style.visibility="visible"}function W(){let t=document.querySelector('meta[name="framerauth:error-path"]');if(t){let e=t.getAttribute("content");if(e)return e.trim()}return"/sign-in"}function g(t){let r=(t??"").trim();if(r.includes("://"))try{r=new URL(r).pathname}catch{}return r=r.split("#")[0]??"",r=r.split("?")[0]??"",r.length===0&&(r="/"),r.startsWith("/")||(r=`/${r}`),r!=="/"&&r.endsWith("/")&&(r=r.slice(0,-1)),r}function $(t,e){return g(t)===g(e)}function K(t=window.location.pathname){let e=W();return $(t,e)}function Re(){let t=document.querySelector('meta[name="framerauth:boost"]');if(!t)return[];let e=t.getAttribute("content");return e?e.split(",").map(r=>r.trim()).filter(Boolean):[]}function ke(t){let e=t.map(r=>r.trim()).filter(Boolean).map(r=>{if(r==="*"||r==="/*")return{kind:"all"};let n=r.startsWith("/")?r:`/${r}`;return n.endsWith("/**")?{kind:"deep",base:g(n.slice(0,-3))}:n.endsWith("/*")?{kind:"oneSegment",base:g(n.slice(0,-2))}:n.endsWith("*")?{kind:"prefixPathSegment",base:g(n.slice(0,-1))}:{kind:"exact",base:g(n)}});return r=>{let n=g(r);return e.some(o=>{if(o.kind==="all")return!0;if(o.kind==="exact")return n===o.base;if(o.kind==="deep")return n.startsWith(`${o.base}/`);if(o.kind==="oneSegment"){if(!n.startsWith(`${o.base}/`))return!1;let a=n.slice(o.base.length+1);return a.length>0&&!a.includes("/")}return n===o.base||n.startsWith(`${o.base}/`)})}}var I=class{hasAccess;isPublicPath;errorPath;onError;observer=null;currentCanonical;originalPushState;originalReplaceState;isMonkeyPatched=!1;constructor(e){this.hasAccess=e.hasAccess,this.isPublicPath=e.isPublicPath,this.errorPath=e.errorPath,this.onError=e.onError,this.currentCanonical=this.getCurrentCanonical(),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history)}getCurrentCanonical(){return document.querySelector('link[rel="canonical"]')?.href??null}normalizeToPath(e){if(e instanceof URL)return g(e.pathname);if(e.startsWith("./"))return g(e.slice(1));if(e.startsWith("/"))return g(e);try{let r=new URL(e);return g(r.pathname)}catch{return g(e.startsWith("/")?e:"/"+e)}}normalizePathInput(e){let r=e.startsWith("/")?e:`/${e}`;return g(r)}isErrorPath(e){let r=this.normalizePathInput(e);return $(r,this.errorPath)}checkAccess(e){let r=this.normalizePathInput(e);if(this.isErrorPath(r)||this.isPublicPath(r))return!0;try{return this.hasAccess(r)}catch{return!1}}isOnErrorPage(){let e=this.normalizePathInput(window.location.pathname);return $(e,this.errorPath)}redirectToError(){if(this.isOnErrorPage()){L();return}window.location.replace(this.errorPath)}handleAccessDenied(e){e&&this.onError&&this.onError(e),this.redirectToError()}monkeyPatchHistory(){if(this.isMonkeyPatched)return;let e=this;history.pushState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||_()}return e.originalPushState.call(this,r,n,o)},history.replaceState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||_()}return e.originalReplaceState.call(this,r,n,o)},this.isMonkeyPatched=!0}restoreHistory(){this.isMonkeyPatched&&(history.pushState=this.originalPushState,history.replaceState=this.originalReplaceState,this.isMonkeyPatched=!1)}start(){this.stop(),this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(document.head,{childList:!0,attributes:!0,attributeFilter:["rel","href"],subtree:!0}),this.monkeyPatchHistory()}stop(){this.observer&&(this.observer.disconnect(),this.observer=null),this.restoreHistory(),L()}handleMutations(e){let r=!1;for(let n of e){if(n.type==="childList"){let o=[...Array.from(n.addedNodes),...Array.from(n.removedNodes)];for(let a of o)if(a.nodeType===Node.ELEMENT_NODE){let s=a;if(this.isCanonicalLink(s)){r=!0;break}}}else if(n.type==="attributes"){let o=n.target;(this.isCanonicalLink(o)||n.oldValue==="canonical")&&(r=!0)}if(r)break}r&&this.checkCanonicalChange()}isCanonicalLink(e){return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"}checkCanonicalChange(){let e=this.getCurrentCanonical();if(e!==this.currentCanonical)if(this.currentCanonical=e,e){let r=this.normalizeToPath(e);if(!this.checkAccess(r)){this.handleAccessDenied();return}L()}else L()}};var Ee=w("fa-bookmarks",z(),{encode:R({obfuscate:!0}),decode:k({deobfuscate:!0,fallback:{},validator:ye})}),Te=p(!1);var Ae=(t,e)=>{let r=g(e),n=t.data.user.get(),o=t.data.session.get(),a=t.data.project.get();if(!a)return!1;if(!Object.prototype.hasOwnProperty.call(a.pages,r))return!0;if(!n||!o)return!1;let b=a.pages[r];return b.length===0?!0:b.some(m=>n.tags.find(i=>i.id===m))};console.log("FramerAuth SDK (JavaScript): 2.1.4");var wt="/v2",Rt=0,u=new j({data:{user:be,project:ue,tags:fe,bookmarks:Ee,session:ve},state:{initializing:we,userLoading:Pe,projectLoading:de,tagsLoading:he,bookmarksLoading:Te,sessionLoading:Se}});window.FramerAuth=u;var kt=Re(),Le=ke(kt);function Et(){return K()?!0:u.data.project.get()!==null&&Le(window.location.pathname)}function M(t){let e=Ue(t);if(!e)throw new Error("Unable to initialize FramerAuth: project tenantHost is missing");u.updateBaseURL(`https://${e}${wt}`)}function Ue(t){if(t.customDomain)return t.customDomain;let e=Tt(t);return e?`${t.slug}.${e}`:null}function Tt(t){return Rt||t.tenantHost||null}function G(){u.api.fetchBookmarks().then(({data:t})=>{u.data.bookmarks.set(t??{})})}function Oe(){let t=W(),e=new I({hasAccess:n=>Ae(u,n),isPublicPath:n=>Le(n),errorPath:t,onError:n=>{console.error("[Router] Error in router:",n)}});return e.checkAccess(window.location.pathname)?(e.start(),!0):(e.handleAccessDenied(),!1)}function At(){let t=u.data.project.get();return t&&Ue(t)?(M(t),u.api.fetchProject().then(e=>{e.data&&(u.data.project.set(e.data),M(e.data))}),u.auth.getSession().then(e=>{e.data!==null&&G()})):u.api.fetchProject().then(e=>{if(e.data)return u.data.project.set(e.data),M(e.data),u.auth.getSession()}).then(e=>{e?.data!==null&&G()}),Oe()}async function Lt(){_();let t=u.data.project.get(),e=await u.api.fetchProject();if(e.data)t=e.data,u.data.project.set(t);else if(!t)throw new Error(e.error.message||"Unable to load FramerAuth project!");M(t),(await u.auth.getSession()).data!==null&&G();let n=Oe();return n&&L(),n}async function Ut(){u.state.initializing.set(!0);try{(Et()?At():await Lt())&&window.dispatchEvent(new CustomEvent("framerauth:initialized"))}catch(t){console.error("Failed to initialize FramerAuth:",t),K()?L():window.location.replace(W()),window.dispatchEvent(new CustomEvent("framerauth:initialization-failed",{detail:{error:t}}))}finally{u.state.initializing.set(!1)}}Ut();})();
1
+ "use strict";(()=>{var We=Object.defineProperty,Ie=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Z=(t,e,r)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,L=(t,e)=>{for(var r in e||(e={}))He.call(e,r)&&Z(t,r,e[r]);if(X)for(var r of X(e))qe.call(e,r)&&Z(t,r,e[r]);return t},U=(t,e)=>Ie(t,Me(e)),Je=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},Ve=async(t,e)=>{var r,n,o,a,s,b;let m=e||{},i={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:m,hooks:i};for(let d of e?.plugins||[]){if(d.init){let P=await((r=d.init)==null?void 0:r.call(d,t.toString(),e));m=P.options||m,t=P.url}i.onRequest.push((n=d.hooks)==null?void 0:n.onRequest),i.onResponse.push((o=d.hooks)==null?void 0:o.onResponse),i.onSuccess.push((a=d.hooks)==null?void 0:a.onSuccess),i.onError.push((s=d.hooks)==null?void 0:s.onError),i.onRetry.push((b=d.hooks)==null?void 0:b.onRetry)}return{url:t,options:m,hooks:i}},ee=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},Ke=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function Ge(t){if(typeof t=="number")return new ee({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new ee(t);case"exponential":return new Ke(t);default:throw new Error("Invalid retry strategy")}}var Qe=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},Ye=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Xe(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Ye.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function Ze(t){try{return JSON.parse(t),!0}catch{return!1}}function ne(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function te(t){try{return JSON.parse(t)}catch{return t}}function re(t){return typeof t=="function"}function et(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&re(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&re(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function tt(t){let e=new Headers(t?.headers),r=await Qe(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=rt(t?.body);n&&e.set("content-type",n)}return e}function rt(t){return ne(t)?"application/json":null}function nt(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(ne(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function ot(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return ae.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function at(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var st=class oe extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,oe.prototype)}};async function it(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new st(r.issues);return r.value}var ae=["get","post","put","patch","delete"];function lt(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let P=t.toString().split("@")[1].split("/")[0];ae.includes(P)&&(t=t.replace(`@${P}/`,"/"))}a.endsWith("/")||(a+="/");let[s,b]=t.replace(a,"").split("?"),m=new URLSearchParams(b);for(let[P,h]of Object.entries(o||{}))h!=null&&m.set(P,String(h));if(n)if(Array.isArray(n)){let P=s.split("/").filter(h=>h.startsWith(":"));for(let[h,H]of P.entries()){let B=n[h];s=s.replace(H,B)}}else for(let[P,h]of Object.entries(n))s=s.replace(`:${P}`,String(h));s=s.split("/").map(encodeURIComponent).join("/"),s.startsWith("/")&&(s=s.slice(1));let i=m.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${s}${i}`,a):`${a}${s}${i}`}var u=async(t,e)=>{var r,n,o,a,s,b,m,i;let{hooks:d,url:P,options:h}=await Ve(t,e),H=et(h),B=new AbortController,_e=(r=h.signal)!=null?r:B.signal,Be=lt(P,h),De=nt(h),Fe=await tt(h),je=ot(P,h),f=U(L({},h),{url:Be,headers:Fe,body:De,method:je,signal:_e});for(let v of d.onRequest)if(v){let y=await v(f);y instanceof Object&&(f=y)}("pipeTo"in f&&typeof f.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in f||(f.duplex="half"));let{clearTimeout:Ne}=at(h,B),l=await H(f.url,f);Ne();let Q={response:l,request:f};for(let v of d.onResponse)if(v){let y=await v(U(L({},Q),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?l.clone():l}));y instanceof Response?l=y:y instanceof Object&&(l=y.response)}if(l.ok){if(!(f.method!=="HEAD"))return{data:"",error:null};let y=Xe(l),T={data:"",response:l,request:f};if(y==="json"||y==="text"){let E=await l.text(),ze=await((a=f.jsonParser)!=null?a:te)(E);T.data=ze}else T.data=await l[y]();f?.output&&f.output&&!f.disableValidation&&(T.data=await it(f.output,T.data));for(let E of d.onSuccess)E&&await E(U(L({},T),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?l.clone():l}));return e?.throw?T.data:{data:T.data,error:null}}let Ce=(b=e?.jsonParser)!=null?b:te,D=await l.text(),Y=Ze(D),q=Y?await Ce(D):null,$e={response:l,responseText:D,request:f,error:U(L({},q),{status:l.status,statusText:l.statusText})};for(let v of d.onError)v&&await v(U(L({},$e),{response:(m=e?.hookOptions)!=null&&m.cloneResponse?l.clone():l}));if(e?.retry){let v=Ge(e.retry),y=(i=e.retryAttempt)!=null?i:0;if(await v.shouldAttemptRetry(y,l)){for(let E of d.onRetry)E&&await E(Q);let T=v.getDelay(y);return await new Promise(E=>setTimeout(E,T)),await u(t,U(L({},e),{retryAttempt:y+1}))}}if(e?.throw)throw new Je(l.status,l.statusText,Y?q:D);return{data:null,error:U(L({},q),{status:l.status,statusText:l.statusText})}};var ct="https://core.framerauth.com/v2",F=class{baseURL=null;useBearerAuth=!1;data;state;api;auth;constructor(e){this.baseURL=null,this.data=e.data,this.state=e.state,this.api={fetchBookmarks:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await u(`${this.baseURL}/profile/bookmarks`,{...this.authOptions()});if(!r.data)return r;let n=new Set(r.data),o={};for(let a of n)o[a]=!0;return{data:o,error:null}},fetchProject:async()=>await u(`${ct}/public/project/config`)},this.auth={getSession:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await u(`${this.baseURL}/get-session`,{method:"GET",...this.authOptions(),query:{disableCookieCache:!0}});return r.data?(this.data.user.set(r.data.user),this.data.session.set(r.data.session),this.data.tags.set(r.data.user.tags??[])):(this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),this.data.bearerToken.set(null)),r},signUp:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await u(`${this.baseURL}/sign-up/email`,{method:"POST",...this.authOptions(),body:r,onSuccess:o=>{let a=o.response.headers.get("set-auth-token");a&&this.data.bearerToken.set(a)}});return n.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(o=>{this.data.bookmarks.set(o.data??{})})),n},signIn:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await u(`${this.baseURL}/sign-in/email`,{method:"POST",...this.authOptions(),body:r,onSuccess:o=>{let a=o.response.headers.get("set-auth-token");a&&this.data.bearerToken.set(a)}});return n.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(o=>{this.data.bookmarks.set(o.data??{})})),n},signInSocial:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await u(`${this.baseURL}/sign-in/social`,{method:"POST",...this.authOptions(),body:r});return n.data?.url&&(window.location.href=n.data.url),n},signOut:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await u(`${this.baseURL}/sign-out`,{method:"POST",...this.authOptions(),body:{}});return this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),this.data.bearerToken.set(null),r?.redirectTo&&(window.location.href=r.redirectTo),n},sendOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/email-otp/send-verification-otp`;return await u(n,{body:r,...this.authOptions(),method:"POST"})},signInOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/sign-in/email-otp`,o=await u(n,{body:r,...this.authOptions(),method:"POST",onSuccess:a=>{let s=a.response.headers.get("set-auth-token");s&&this.data.bearerToken.set(s)}});return o.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(a=>{this.data.bookmarks.set(a.data??{})})),o},updateProfile:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile`;return await u(n,{body:r,...this.authOptions(),method:"PATCH"})},updateProfilePicture:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/avatar`;return await u(n,{method:"POST",body:r,...this.authOptions()})},createBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks`;return await u(n,{body:r,...this.authOptions(),method:"POST"})},deleteBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks/${r.bookmark_type}/${r.id}`;return await u(n,{...this.authOptions(),method:"DELETE"})},sendForgotPasswordEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/request-password-reset`;return await u(n,{body:r,...this.authOptions(),method:"POST"})},resetPassword:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/reset-password`;return await u(n,{body:r,...this.authOptions(),method:"POST"})},storeCheckout:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/store/checkout/session`;return await u(n,{body:r,...this.authOptions(),method:"POST"})},storePortal:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/plugins/${r.pluginId}/portal`,o=this.authOptions();return await u(n,{...o,method:"GET",headers:{...o.headers,Accept:"application/json"}})},sendVerificationEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/send-verification-email`;return await u(n,{body:r,...this.authOptions(),method:"POST"})},exchangeOneTimeToken:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await u(`${this.baseURL}/one-time-token/verify`,{method:"POST",body:{token:r}});return n.data?.session?.token&&this.data.bearerToken.set(n.data.session.token),n}}}updateBaseURL(e){this.baseURL=e}updateAuthMode(e){this.useBearerAuth=e}async handleOTTFromURL(){if(!this.useBearerAuth)return;let e=new URLSearchParams(window.location.search),r=e.get("ott");if(!r)return;e.delete("ott");let n=e.size?`${window.location.pathname}?${e.toString()}${window.location.hash}`:`${window.location.pathname}${window.location.hash}`;history.replaceState(null,"",n),await this.auth.exchangeOneTimeToken(r)}authOptions(){if(this.useBearerAuth){let e=this.data.bearerToken.get();return e?{headers:{Authorization:`Bearer ${e}`}}:{}}return{credentials:"include"}}};var R=[],A=0,j=4,ut=0,p=t=>{let e=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=e.push(n),()=>{for(let a=A+j;a<R.length;)R[a]===n?R.splice(a,j):a+=j;let o=e.indexOf(n);~o&&(e.splice(o,1),--r.lc||r.off())}},notify(n,o){ut++;let a=!R.length;for(let s of e)R.push(s,r.value,n,o);if(a){for(A=0;A<R.length;A+=j)R[A](R[A+1],R[A+2],R[A+3]);R.length=0}},off(){},set(n){let o=r.value;o!==n&&(r.value=n,r.notify(o))},subscribe(n){let o=r.listen(n);return n(r.value),o},value:t};return r};var dt=5,N=6,C=10,ft=(t,e,r,n)=>(t.events=t.events||{},t.events[r+C]||(t.events[r+C]=n(o=>{t.events[r].reduceRight((a,s)=>(s(a),a),{shared:{},...o})})),t.events[r]=t.events[r]||[],t.events[r].push(e),()=>{let o=t.events[r],a=o.indexOf(e);o.splice(a,1),o.length||(delete t.events[r],t.events[r+C](),delete t.events[r+C])});var se=1e3,J=(t,e)=>ft(t,n=>{let o=e(n);o&&t.events[N].push(o)},dt,n=>{let o=t.listen;t.listen=(...s)=>(!t.lc&&!t.active&&(t.active=!0,n()),o(...s));let a=t.off;return t.events[N]=[],t.off=()=>{a(),setTimeout(()=>{if(t.active&&!t.lc){t.active=!1;for(let s of t.events[N])s();t.events[N]=[]}},se)},()=>{t.listen=o,t.off=a}});var $=(t={})=>{let e=p(t);return e.setKey=function(r,n){let o=e.value;typeof n>"u"&&r in e.value?(e.value={...e.value},delete e.value[r],e.notify(o,r)):e.value[r]!==n&&(e.value={...e.value,[r]:n},e.notify(o,r))},e};var ie=t=>t,x={},V={addEventListener(){},removeEventListener(){}};function ht(){try{return typeof localStorage<"u"}catch{return!1}}ht()&&(x=localStorage);var pt={addEventListener(t,e,r){window.addEventListener("storage",e),window.addEventListener("pageshow",r)},removeEventListener(t,e,r){window.removeEventListener("storage",e),window.removeEventListener("pageshow",r)}};typeof window<"u"&&(V=pt);function k(t,e=void 0,r={}){let n=r.encode||ie,o=r.decode||ie,a=p(e),s=a.set;a.set=i=>{let d=n(i);typeof d>"u"?delete x[t]:x[t]=d,s(i)};function b(i){i.key===t?i.newValue===null?s(e):s(o(i.newValue)):x[t]||s(e)}function m(){a.set(x[t]?o(x[t]):e)}return J(a,()=>{if(m(),r.listen!==!1)return V.addEventListener(t,b,m),()=>{V.removeEventListener(t,b,m)}}),a}var mt="framerauth_v2_",le=new TextEncoder,gt=new TextDecoder;function ce(){let t=typeof window<"u"?window.location.hostname:"1f8cXd6c7b4a3vL4z5746oUgQ28190adbef";return le.encode(mt+t)}function yt(t){let e=ce(),r=le.encode(t),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r[o]^e[o%e.length];return n}function bt(t){let e=yt(t),r=Array.from(e,n=>String.fromCharCode(n)).join("");return btoa(r)}function Pt(t){let e=ce(),r=atob(t),n=Uint8Array.from(r,a=>a.charCodeAt(0)),o=new Uint8Array(n.length);for(let a=0;a<n.length;a++)o[a]=n[a]^e[a%e.length];return gt.decode(o)}function S({obfuscate:t}){return e=>{let r=JSON.stringify(e);return t&&(r=bt(r)),r}}function w({deobfuscate:t,fallback:e,validator:r}){return n=>{try{if(!n)return e;t&&(n=Pt(n));let o=JSON.parse(n);if(r){let a=r(o);return a===null?e:a}return o}catch{return e}}}var ue=k("fa-project",null,{encode:S({obfuscate:!0}),decode:w({deobfuscate:!0,fallback:null})}),de=p(!1);var fe=k("fa-tags",[],{encode:S({obfuscate:!0}),decode:w({deobfuscate:!0,fallback:[]})}),he=p(!1);function pe(t){return Array.isArray(t)?t.length===0?!0:t.every(e=>e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.name=="string"):!1}function vt(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id!="string"||typeof e.email!="string"||typeof e.name!="string"||typeof e.email_verified!="boolean"||!(e.created_at instanceof Date||typeof e.created_at=="string")||!(e.updated_at instanceof Date||typeof e.updated_at=="string")?!1:pe(e.tags)}function kt(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id=="string"&&typeof e.user_id=="string"&&typeof e.token=="string"&&(e.expires_at instanceof Date||typeof e.expires_at=="string")&&(e.created_at instanceof Date||typeof e.created_at=="string")&&(e.updated_at instanceof Date||typeof e.updated_at=="string")}function me(t){if(!t||typeof t!="object")return null;let e=t;return pe(e.tags)||(e.tags=[]),vt(e)?e:null}function ge(t){return kt(t)?t:null}function St(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.entries(t).every(([e,r])=>typeof e=="string"&&typeof r=="boolean")}function ye(t){return!t||typeof t!="object"||Array.isArray(t)?{}:St(t)?t:{}}var be=k("fa-user",null,{encode:S({obfuscate:!0}),decode:w({deobfuscate:!0,fallback:null,validator:me})}),Pe=p(!1);var ve=k("fa-session",null,{encode:S({obfuscate:!0}),decode:w({deobfuscate:!0,fallback:null,validator:ge})}),ke=p(!1);var Se=p(!0);function _(){document.body.style.visibility="hidden"}function O(){document.body.style.visibility="visible"}function z(){let t=document.querySelector('meta[name="framerauth:error-path"]');if(t){let e=t.getAttribute("content");if(e)return e.trim()}return"/sign-in"}function g(t){let r=(t??"").trim();if(r.includes("://"))try{r=new URL(r).pathname}catch{}return r=r.split("#")[0]??"",r=r.split("?")[0]??"",r.length===0&&(r="/"),r.startsWith("/")||(r=`/${r}`),r!=="/"&&r.endsWith("/")&&(r=r.slice(0,-1)),r}function W(t,e){return g(t)===g(e)}function K(t=window.location.pathname){let e=z();return W(t,e)}function we(){let t=document.querySelector('meta[name="framerauth:boost"]');if(!t)return[];let e=t.getAttribute("content");return e?e.split(",").map(r=>r.trim()).filter(Boolean):[]}function Re(t){let e=t.map(r=>r.trim()).filter(Boolean).map(r=>{if(r==="*"||r==="/*")return{kind:"all"};let n=r.startsWith("/")?r:`/${r}`;return n.endsWith("/**")?{kind:"deep",base:g(n.slice(0,-3))}:n.endsWith("/*")?{kind:"oneSegment",base:g(n.slice(0,-2))}:n.endsWith("*")?{kind:"prefixPathSegment",base:g(n.slice(0,-1))}:{kind:"exact",base:g(n)}});return r=>{let n=g(r);return e.some(o=>{if(o.kind==="all")return!0;if(o.kind==="exact")return n===o.base;if(o.kind==="deep")return n.startsWith(`${o.base}/`);if(o.kind==="oneSegment"){if(!n.startsWith(`${o.base}/`))return!1;let a=n.slice(o.base.length+1);return a.length>0&&!a.includes("/")}return n===o.base||n.startsWith(`${o.base}/`)})}}var I=class{hasAccess;isPublicPath;errorPath;onError;observer=null;currentCanonical;originalPushState;originalReplaceState;isMonkeyPatched=!1;constructor(e){this.hasAccess=e.hasAccess,this.isPublicPath=e.isPublicPath,this.errorPath=e.errorPath,this.onError=e.onError,this.currentCanonical=this.getCurrentCanonical(),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history)}getCurrentCanonical(){return document.querySelector('link[rel="canonical"]')?.href??null}normalizeToPath(e){if(e instanceof URL)return g(e.pathname);if(e.startsWith("./"))return g(e.slice(1));if(e.startsWith("/"))return g(e);try{let r=new URL(e);return g(r.pathname)}catch{return g(e.startsWith("/")?e:"/"+e)}}normalizePathInput(e){let r=e.startsWith("/")?e:`/${e}`;return g(r)}isErrorPath(e){let r=this.normalizePathInput(e);return W(r,this.errorPath)}checkAccess(e){let r=this.normalizePathInput(e);if(this.isErrorPath(r)||this.isPublicPath(r))return!0;try{return this.hasAccess(r)}catch{return!1}}isOnErrorPage(){let e=this.normalizePathInput(window.location.pathname);return W(e,this.errorPath)}redirectToError(){if(this.isOnErrorPage()){O();return}window.location.replace(this.errorPath)}handleAccessDenied(e){e&&this.onError&&this.onError(e),this.redirectToError()}monkeyPatchHistory(){if(this.isMonkeyPatched)return;let e=this;history.pushState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||_()}return e.originalPushState.call(this,r,n,o)},history.replaceState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||_()}return e.originalReplaceState.call(this,r,n,o)},this.isMonkeyPatched=!0}restoreHistory(){this.isMonkeyPatched&&(history.pushState=this.originalPushState,history.replaceState=this.originalReplaceState,this.isMonkeyPatched=!1)}start(){this.stop(),this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(document.head,{childList:!0,attributes:!0,attributeFilter:["rel","href"],subtree:!0}),this.monkeyPatchHistory()}stop(){this.observer&&(this.observer.disconnect(),this.observer=null),this.restoreHistory(),O()}handleMutations(e){let r=!1;for(let n of e){if(n.type==="childList"){let o=[...Array.from(n.addedNodes),...Array.from(n.removedNodes)];for(let a of o)if(a.nodeType===Node.ELEMENT_NODE){let s=a;if(this.isCanonicalLink(s)){r=!0;break}}}else if(n.type==="attributes"){let o=n.target;(this.isCanonicalLink(o)||n.oldValue==="canonical")&&(r=!0)}if(r)break}r&&this.checkCanonicalChange()}isCanonicalLink(e){return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"}checkCanonicalChange(){let e=this.getCurrentCanonical();if(e!==this.currentCanonical)if(this.currentCanonical=e,e){let r=this.normalizeToPath(e);if(!this.checkAccess(r)){this.handleAccessDenied();return}O()}else O()}};var Te=k("fa-bookmarks",$(),{encode:S({obfuscate:!0}),decode:w({deobfuscate:!0,fallback:{},validator:ye})}),Ee=p(!1);var Ae=k("fa-bearer-token",null,{encode:S({obfuscate:!0}),decode:w({deobfuscate:!0,fallback:null})});var Oe=(t,e)=>{let r=g(e),n=t.data.user.get(),o=t.data.session.get(),a=t.data.project.get();if(!a)return!1;if(!Object.prototype.hasOwnProperty.call(a.pages,r))return!0;if(!n||!o)return!1;let b=a.pages[r];return b.length===0?!0:b.some(m=>n.tags.find(i=>i.id===m))};console.log("FramerAuth SDK (JavaScript): 2.1.5");var wt="/v2",Rt=0,c=new F({data:{user:be,project:ue,tags:fe,bookmarks:Te,session:ve,bearerToken:Ae},state:{initializing:Se,userLoading:Pe,projectLoading:de,tagsLoading:he,bookmarksLoading:Ee,sessionLoading:ke}});window.FramerAuth=c;var Tt=we(),Le=Re(Tt);function Et(){return K()?!0:c.data.project.get()!==null&&Le(window.location.pathname)}function M(t){let e=Ue(t);if(!e)throw new Error("Unable to initialize FramerAuth: project tenantHost is missing");c.updateBaseURL(`https://${e}${wt}`),c.updateAuthMode(At(t))}function At(t){return t.sessionTransport==="bearer"}function Ue(t){if(t.customDomain)return t.customDomain;let e=Ot(t);return e?`${t.slug}.${e}`:null}function Ot(t){return Rt||t.tenantHost||null}function G(){c.api.fetchBookmarks().then(({data:t})=>{c.data.bookmarks.set(t??{})})}function xe(){let t=z(),e=new I({hasAccess:n=>Oe(c,n),isPublicPath:n=>Le(n),errorPath:t,onError:n=>{console.error("[Router] Error in router:",n)}});return e.checkAccess(window.location.pathname)?(e.start(),!0):(e.handleAccessDenied(),!1)}function Lt(){let t=c.data.project.get();return t&&Ue(t)?(M(t),c.api.fetchProject().then(e=>{e.data&&(c.data.project.set(e.data),M(e.data))}),c.handleOTTFromURL().then(()=>c.auth.getSession()).then(e=>{e.data!==null&&G()})):c.api.fetchProject().then(e=>{if(e.data)return c.data.project.set(e.data),M(e.data),c.handleOTTFromURL().then(()=>c.auth.getSession())}).then(e=>{e?.data!==null&&G()}),xe()}async function Ut(){_();let t=c.data.project.get(),e=await c.api.fetchProject();if(e.data)t=e.data,c.data.project.set(t);else if(!t)throw new Error(e.error.message||"Unable to load FramerAuth project!");M(t),await c.handleOTTFromURL(),(await c.auth.getSession()).data!==null&&G();let n=xe();return n&&O(),n}async function xt(){c.state.initializing.set(!0);try{(Et()?Lt():await Ut())&&window.dispatchEvent(new CustomEvent("framerauth:initialized"))}catch(t){console.error("Failed to initialize FramerAuth:",t),K()?O():window.location.replace(z()),window.dispatchEvent(new CustomEvent("framerauth:initialization-failed",{detail:{error:t}}))}finally{c.state.initializing.set(!1)}}xt();})();
@@ -1 +1 @@
1
- var le=()=>typeof window<"u",fe=()=>window.location.host.endsWith("framercanvas.com"),w="FramerAuth snippet missing from start of <body>",v=()=>!le()||fe()||!window?.FramerAuth?null:window.FramerAuth;async function Ve(){let t=v();if(!t)return{data:null,error:{message:w}};try{return await t.auth.getSession()}catch(e){return{data:null,error:{message:e instanceof Error?e.message:"Unknown error"}}}}async function De(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signUp(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ze(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signIn(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Je(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ke(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ge(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signOut(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Qe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfile(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ye(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfilePicture(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Xe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendForgotPasswordEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ze(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.resetPassword(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function et(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInSocial(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function tt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storeCheckout(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function rt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendVerificationEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}var de=Object.defineProperty,me=Object.defineProperties,he=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable,K=(t,e,r)=>e in t?de(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,A=(t,e)=>{for(var r in e||(e={}))pe.call(e,r)&&K(t,r,e[r]);if(J)for(var r of J(e))ye.call(e,r)&&K(t,r,e[r]);return t},R=(t,e)=>me(t,he(e)),ge=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},we=async(t,e)=>{var r,n,o,a,s,u;let c=e||{},i={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:c,hooks:i};for(let m of e?.plugins||[]){if(m.init){let l=await((r=m.init)==null?void 0:r.call(m,t.toString(),e));c=l.options||c,t=l.url}i.onRequest.push((n=m.hooks)==null?void 0:n.onRequest),i.onResponse.push((o=m.hooks)==null?void 0:o.onResponse),i.onSuccess.push((a=m.hooks)==null?void 0:a.onSuccess),i.onError.push((s=m.hooks)==null?void 0:s.onError),i.onRetry.push((u=m.hooks)==null?void 0:u.onRetry)}return{url:t,options:c,hooks:i}},G=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},ve=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function ke(t){if(typeof t=="number")return new G({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new G(t);case"exponential":return new ve(t);default:throw new Error("Invalid retry strategy")}}var be=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},Pe=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Se(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Pe.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function Te(t){try{return JSON.parse(t),!0}catch{return!1}}function X(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function Q(t){try{return JSON.parse(t)}catch{return t}}function Y(t){return typeof t=="function"}function xe(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&Y(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Y(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Ae(t){let e=new Headers(t?.headers),r=await be(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=Re(t?.body);n&&e.set("content-type",n)}return e}function Re(t){return X(t)?"application/json":null}function Ee(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(X(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function Oe(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return ee.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function _e(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var Ue=class Z extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,Z.prototype)}};async function Fe(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new Ue(r.issues);return r.value}var ee=["get","post","put","patch","delete"];function je(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let l=t.toString().split("@")[1].split("/")[0];ee.includes(l)&&(t=t.replace(`@${l}/`,"/"))}a.endsWith("/")||(a+="/");let[s,u]=t.replace(a,"").split("?"),c=new URLSearchParams(u);for(let[l,d]of Object.entries(o||{}))d!=null&&c.set(l,String(d));if(n)if(Array.isArray(n)){let l=s.split("/").filter(d=>d.startsWith(":"));for(let[d,x]of l.entries()){let g=n[d];s=s.replace(x,g)}}else for(let[l,d]of Object.entries(n))s=s.replace(`:${l}`,String(d));s=s.split("/").map(encodeURIComponent).join("/"),s.startsWith("/")&&(s=s.slice(1));let i=c.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${s}${i}`,a):`${a}${s}${i}`}var M=async(t,e)=>{var r,n,o,a,s,u,c,i;let{hooks:m,url:l,options:d}=await we(t,e),x=xe(d),g=new AbortController,F=(r=d.signal)!=null?r:g.signal,B=je(l,d),ne=Ee(d),ae=await Ae(d),oe=Oe(l,d),h=R(A({},d),{url:B,headers:ae,body:ne,method:oe,signal:F});for(let b of m.onRequest)if(b){let p=await b(h);p instanceof Object&&(h=p)}("pipeTo"in h&&typeof h.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in h||(h.duplex="half"));let{clearTimeout:se}=_e(d,g),f=await x(h.url,h);se();let D={response:f,request:h};for(let b of m.onResponse)if(b){let p=await b(R(A({},D),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?f.clone():f}));p instanceof Response?f=p:p instanceof Object&&(f=p.response)}if(f.ok){if(!(h.method!=="HEAD"))return{data:"",error:null};let p=Se(f),P={data:"",response:f,request:h};if(p==="json"||p==="text"){let S=await f.text(),ce=await((a=h.jsonParser)!=null?a:Q)(S);P.data=ce}else P.data=await f[p]();h?.output&&h.output&&!h.disableValidation&&(P.data=await Fe(h.output,P.data));for(let S of m.onSuccess)S&&await S(R(A({},P),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?f.clone():f}));return e?.throw?P.data:{data:P.data,error:null}}let ie=(u=e?.jsonParser)!=null?u:Q,j=await f.text(),z=Te(j),$=z?await ie(j):null,ue={response:f,responseText:j,request:h,error:R(A({},$),{status:f.status,statusText:f.statusText})};for(let b of m.onError)b&&await b(R(A({},ue),{response:(c=e?.hookOptions)!=null&&c.cloneResponse?f.clone():f}));if(e?.retry){let b=ke(e.retry),p=(i=e.retryAttempt)!=null?i:0;if(await b.shouldAttemptRetry(p,f)){for(let S of m.onRetry)S&&await S(D);let P=b.getDelay(p);return await new Promise(S=>setTimeout(S,P)),await M(t,R(A({},e),{retryAttempt:p+1}))}}if(e?.throw)throw new ge(f.status,f.statusText,z?$:j);return{data:null,error:R(A({},$),{status:f.status,statusText:f.statusText})}};function q(t,e,r){let n=new Set(e).add(void 0);return t.listen((o,a,s)=>{n.has(s)&&r(o,a,s)})}import{useCallback as Le,useRef as Ce,useSyncExternalStore as Ie}from"react";var W=(t,e)=>r=>{t.current!==r&&(t.current=r,e())};function T(t,{keys:e,deps:r=[t,e]}={}){let n=Ce();n.current=t.get();let o=Le(s=>(W(n,s)(t.value),e?.length>0?q(t,e,W(n,s)):t.listen(W(n,s))),r),a=()=>n.current;return Ie(o,a,a)}import{useState as te}from"react";var Be="https://core.framerauth.com/v2",O=()=>typeof window<"u",_=()=>window.location.host.endsWith("framercanvas.com"),$e=()=>{let t=Object.keys(window.parent);for(let e=t.length-1;e>=0;e--)try{let r=new URLSearchParams(window.parent[t[e]].location.search).get("siteId");if(r)return r}catch{}},Me=async()=>{let t=$e()||"";return await M(`${Be}/public/project/config`,{headers:{"x-framer-project-id":t}})};function wt(){if(!O()||_()||!window?.FramerAuth)return{initializing:!0,setInitializing:()=>{}};let t=window.FramerAuth;return{initializing:T(t.state.initializing)}}function E(){if(!O()||_()||!window?.FramerAuth)return{session:null,loading:!1,setSession:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=T(t.data.session),r=T(t.state.sessionLoading);return{session:e,loading:r,setSession:a=>t.data.session.set(a),setLoading:a=>t.state.sessionLoading.set(a)}}function L(){if(!O()||_()||!window?.FramerAuth)return{user:null,loading:!1,setUser:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=T(t.data.user),r=T(t.state.userLoading),n=a=>t.data.user.set(a),o=a=>t.state.userLoading.set(a);return e&&!Object.prototype.hasOwnProperty.call(e,"tags")&&(e.tags=[]),{user:e,loading:r,setUser:n,setLoading:o}}function vt(){let[t,e]=te(null),[r,n]=te(!1);if(!O())return{project:null,loading:!1,setProject:()=>{},setLoading:()=>{},fetchProject:async()=>({data:null,error:{message:"Browser not available"}})};if(_()&&!window?.FramerAuth){let l=g=>e(g),d=g=>n(g);return{project:t,loading:r,setProject:l,setLoading:d,fetchProject:async()=>{d(!0);let g=await Me();return g.data&&l(g.data),d(!1),g}}}let a=window.FramerAuth,s=T(a.data.project),u=T(a.state.projectLoading),c=l=>a.data.project.set(l),i=l=>a.state.projectLoading.set(l);return{project:s,loading:u,setProject:c,setLoading:i,fetchProject:async()=>{i(!0);let l=await a.api.fetchProject();return l.data&&c(l.data),i(!1),l}}}function C(t){if(!O()||_()||!window?.FramerAuth)return{bookmarks:null,loading:!1,createBookmark:a=>{},deleteBookmark:a=>{},setLoading:()=>{}};let e=window.FramerAuth;return{bookmarks:T(e.data.bookmarks,{keys:t}),createBookmark:a=>{let u={...e.data.bookmarks.get(),[a]:!0};e.data.bookmarks.set(u)},deleteBookmark:a=>{let u={...e.data.bookmarks.get()};delete u[a],e.data.bookmarks.set(u)}}}import{useEffect as N,useMemo as k,useRef as V}from"react";import{useRouter as qe,RenderTarget as re,inferInitialRouteFromPath as We}from"framer";function H(t,e="any"){return t==="all"||t==="any"?t:e}function U(t){return t!==null}function I(t,e,r="all"){if(!U(t))return!1;if(e.length===0)return t.tags.length>0;let n=t.tags.map(o=>o.name);return r==="any"?e.some(o=>n.includes(o)):e.every(o=>n.includes(o))}import{jsx as y}from"react/jsx-runtime";typeof window<"u"&&window.FramerAuth&&console.log("FramerAuth SDK (React): 2.1.4");function Et(t){return e=>{let{session:r}=E();return r?y(t,{...e}):null}}function Ot(t){return e=>{let{session:r}=E();return r?null:y(t,{...e})}}function _t(t){return e=>{let{session:r}=E(),n=r?null:e?.variant;return y(t,{...e,variant:n})}}function Ut(t){return e=>{let{user:r}=L(),n=V(null),o=e?.tags,a=k(()=>!o||typeof o!="string"?null:o.split(",").map(i=>i.trim()).filter(Boolean),[o]),s=H(e?.require),u=k(()=>U(r)?a?I(r,a,s):r.tags.length>0:!1,[r,a,s]);return N(()=>{if(n.current){let i=a?n.current.parentElement:n.current;if(!i)return;u?i.style.display="":i.style.display="none"}},[n.current,u]),k(()=>u!==!0?y("div",{ref:n}):y(t,{ref:n,...e}),[e,u,void 0])}}function Ft(t){return e=>{let{user:r}=L(),n=V(null),o=e?.tags,a=k(()=>!o||typeof o!="string"?null:o.split(",").map(i=>i.trim()).filter(Boolean),[o]),s=H(e?.require),u=k(()=>U(r)?a?I(r,a,s):r.tags.length>0:!1,[r,a,s]);return N(()=>{if(n.current){let i=a?n.current.parentElement:n.current;if(!i)return;u?i.style.display="none":i.style.display=""}},[n.current,u]),k(()=>u===!0?y("div",{ref:n}):y(t,{ref:n,...e}),[e,u,void 0])}}function jt(t){return e=>{let{user:r}=L(),n=e?.variant,o=e?.tags;if(!o||typeof o!="string"||o.trim().length===0){let c=null;return(!U(r)||r.tags.length===0)&&(c=n),y(t,{...e,variant:c})}let a=o.split(",").map(c=>c.trim()).filter(Boolean),u=I(r,a,"any")?null:n;return y(t,{...e,variant:u})}}function Lt(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),a=k(()=>n?Object.keys(n).some(u=>u.startsWith(`${e}:`)):!1,[n])?null:"Empty State";return y(t,{...r,variant:a})}}function Ct(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),o=V(null),a=k(()=>`${e}:${r?.slug}`,[r]),s=k(()=>He()?!0:n?a in n:!1,[n?.[a],a]);return N(()=>{if(o.current){let c=o.current.parentElement;if(!c)return;s?c.style.display="":c.style.display="none"}},[o.current,s]),k(()=>s?y(t,{ref:o,...r}):y("div",{ref:o}),[r,s,void 0])}}function It(t,e="saved-for-later"){return r=>{let n=qe(),{session:o}=E(),{bookmarks:a,createBookmark:s,deleteBookmark:u}=C([`${e}:${r?.slug}`]),c=k(()=>`${e}:${r?.slug}`,[r]),i=k(()=>a?c in a:!1,[a?.[c],c]),m=async d=>{try{if(i)u(c),window?.FramerAuth.auth.deleteBookmark({id:r?.slug,bookmark_type:e});else if(s(c),window?.FramerAuth.auth.createBookmark({id:r?.slug,bookmark_type:e}),r?.link){let[x,g]=r.link.split("#"),{routeId:F,pathVariables:B}=We(n.routes,x);F&&n.navigate(F,g,B)}}catch(x){console.error(x)}},l=k(()=>i?r?.variant:void 0,[i,r?.variant]);return o?y(t,{...r,variant:l,onClick:m}):null}}function Bt(t){return e=>y(t,{...e,onClick:async n=>{window?.FramerAuth.auth.signInSocial({provider:"github",callbackURL:window.location.origin+"/account"})}})}function $t(t,e){return r=>{let{session:n}=E();return n?y(t,{...r,onClick:async a=>{window?.FramerAuth.auth.signOut({redirectTo:e.redirectTo})}}):null}}function He(){return re.current()===re.canvas}export{Bt as buttonSignInSocial,$t as buttonSignOut,Ve as getSession,He as isCanvas,Ze as resetPassword,Xe as sendForgotPasswordEmail,Ke as sendOTP,rt as sendVerificationEmail,Et as showIfSignedIn,Ot as showIfSignedOut,Ut as showIfWithTag,Ft as showIfWithoutTag,ze as signIn,Je as signInOTP,et as signInSocial,Ge as signOut,De as signUp,tt as storeCheckout,_t as toggleVariant,jt as toggleVariantIfWithTag,Qe as updateProfile,Ye as updateProfilePicture,C as useBookmarks,wt as useIsInitializing,vt as useProject,E as useSession,L as useUser,Lt as withBookmarks,Ct as withIsBookmarked,It as withToggleBookmark};
1
+ var he=()=>typeof window<"u",ge=()=>window.location.host.endsWith("framercanvas.com"),w="FramerAuth snippet missing from start of <body>",v=()=>!he()||ge()||!window?.FramerAuth?null:window.FramerAuth;async function Ge(){let t=v();if(!t)return{data:null,error:{message:w}};try{return await t.auth.getSession()}catch(e){return{data:null,error:{message:e instanceof Error?e.message:"Unknown error"}}}}async function Qe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signUp(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ye(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signIn(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Xe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ze(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function et(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signOut(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function tt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfile(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function rt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfilePicture(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function nt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendForgotPasswordEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function at(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.resetPassword(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ot(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInSocial(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function st(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storeCheckout(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function it(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storePortal(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ut(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendVerificationEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}var ye=Object.defineProperty,we=Object.defineProperties,ve=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Q=(t,e,r)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,A=(t,e)=>{for(var r in e||(e={}))ke.call(e,r)&&Q(t,r,e[r]);if(G)for(var r of G(e))Pe.call(e,r)&&Q(t,r,e[r]);return t},O=(t,e)=>we(t,ve(e)),be=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},Te=async(t,e)=>{var r,n,o,a,s,c;let i=e||{},u={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:i,hooks:u};for(let f of e?.plugins||[]){if(f.init){let l=await((r=f.init)==null?void 0:r.call(f,t.toString(),e));i=l.options||i,t=l.url}u.onRequest.push((n=f.hooks)==null?void 0:n.onRequest),u.onResponse.push((o=f.hooks)==null?void 0:o.onResponse),u.onSuccess.push((a=f.hooks)==null?void 0:a.onSuccess),u.onError.push((s=f.hooks)==null?void 0:s.onError),u.onRetry.push((c=f.hooks)==null?void 0:c.onRetry)}return{url:t,options:i,hooks:u}},Y=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},Se=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function xe(t){if(typeof t=="number")return new Y({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new Y(t);case"exponential":return new Se(t);default:throw new Error("Invalid retry strategy")}}var Ae=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},Oe=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ee(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Oe.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function Re(t){try{return JSON.parse(t),!0}catch{return!1}}function ee(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function X(t){try{return JSON.parse(t)}catch{return t}}function Z(t){return typeof t=="function"}function _e(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&Z(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Z(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Ue(t){let e=new Headers(t?.headers),r=await Ae(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=Fe(t?.body);n&&e.set("content-type",n)}return e}function Fe(t){return ee(t)?"application/json":null}function je(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(ee(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function Le(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return re.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Ce(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var Ie=class te extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,te.prototype)}};async function Be(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new Ie(r.issues);return r.value}var re=["get","post","put","patch","delete"];function $e(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let l=t.toString().split("@")[1].split("/")[0];re.includes(l)&&(t=t.replace(`@${l}/`,"/"))}a.endsWith("/")||(a+="/");let[s,c]=t.replace(a,"").split("?"),i=new URLSearchParams(c);for(let[l,m]of Object.entries(o||{}))m!=null&&i.set(l,String(m));if(n)if(Array.isArray(n)){let l=s.split("/").filter(m=>m.startsWith(":"));for(let[m,x]of l.entries()){let y=n[m];s=s.replace(x,y)}}else for(let[l,m]of Object.entries(n))s=s.replace(`:${l}`,String(m));s=s.split("/").map(encodeURIComponent).join("/"),s.startsWith("/")&&(s=s.slice(1));let u=i.toString();return u=u.length>0?`?${u}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${s}${u}`,a):`${a}${s}${u}`}var M=async(t,e)=>{var r,n,o,a,s,c,i,u;let{hooks:f,url:l,options:m}=await Te(t,e),x=_e(m),y=new AbortController,F=(r=m.signal)!=null?r:y.signal,B=$e(l,m),ue=je(m),le=await Ue(m),ce=Le(l,m),p=O(A({},m),{url:B,headers:le,body:ue,method:ce,signal:F});for(let P of f.onRequest)if(P){let h=await P(p);h instanceof Object&&(p=h)}("pipeTo"in p&&typeof p.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in p||(p.duplex="half"));let{clearTimeout:fe}=Ce(m,y),d=await x(p.url,p);fe();let J={response:d,request:p};for(let P of f.onResponse)if(P){let h=await P(O(A({},J),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?d.clone():d}));h instanceof Response?d=h:h instanceof Object&&(d=h.response)}if(d.ok){if(!(p.method!=="HEAD"))return{data:"",error:null};let h=Ee(d),b={data:"",response:d,request:p};if(h==="json"||h==="text"){let T=await d.text(),pe=await((a=p.jsonParser)!=null?a:X)(T);b.data=pe}else b.data=await d[h]();p?.output&&p.output&&!p.disableValidation&&(b.data=await Be(p.output,b.data));for(let T of f.onSuccess)T&&await T(O(A({},b),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?d.clone():d}));return e?.throw?b.data:{data:b.data,error:null}}let de=(c=e?.jsonParser)!=null?c:X,j=await d.text(),K=Re(j),$=K?await de(j):null,me={response:d,responseText:j,request:p,error:O(A({},$),{status:d.status,statusText:d.statusText})};for(let P of f.onError)P&&await P(O(A({},me),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?d.clone():d}));if(e?.retry){let P=xe(e.retry),h=(u=e.retryAttempt)!=null?u:0;if(await P.shouldAttemptRetry(h,d)){for(let T of f.onRetry)T&&await T(J);let b=P.getDelay(h);return await new Promise(T=>setTimeout(T,b)),await M(t,O(A({},e),{retryAttempt:h+1}))}}if(e?.throw)throw new be(d.status,d.statusText,K?$:j);return{data:null,error:O(A({},$),{status:d.status,statusText:d.statusText})}};function q(t,e,r){let n=new Set(e).add(void 0);return t.listen((o,a,s)=>{n.has(s)&&r(o,a,s)})}import{useCallback as Me,useRef as qe,useSyncExternalStore as He}from"react";var H=(t,e)=>r=>{t.current!==r&&(t.current=r,e())};function S(t,{keys:e,deps:r=[t,e]}={}){let n=qe();n.current=t.get();let o=Me(s=>(H(n,s)(t.value),e?.length>0?q(t,e,H(n,s)):t.listen(H(n,s))),r),a=()=>n.current;return He(o,a,a)}import{useState as ne}from"react";var Ne="https://core.framerauth.com/v2",R=()=>typeof window<"u",_=()=>window.location.host.endsWith("framercanvas.com"),We=()=>{let t=Object.keys(window.parent);for(let e=t.length-1;e>=0;e--)try{let r=new URLSearchParams(window.parent[t[e]].location.search).get("siteId");if(r)return r}catch{}},Ve=async()=>{let t=We()||"";return await M(`${Ne}/public/project/config`,{headers:{"x-framer-project-id":t}})};function St(){if(!R()||_()||!window?.FramerAuth)return{initializing:!0,setInitializing:()=>{}};let t=window.FramerAuth;return{initializing:S(t.state.initializing)}}function E(){if(!R()||_()||!window?.FramerAuth)return{session:null,loading:!1,setSession:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=S(t.data.session),r=S(t.state.sessionLoading);return{session:e,loading:r,setSession:a=>t.data.session.set(a),setLoading:a=>t.state.sessionLoading.set(a)}}function L(){if(!R()||_()||!window?.FramerAuth)return{user:null,loading:!1,setUser:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=S(t.data.user),r=S(t.state.userLoading),n=a=>t.data.user.set(a),o=a=>t.state.userLoading.set(a);return e&&!Object.prototype.hasOwnProperty.call(e,"tags")&&(e.tags=[]),{user:e,loading:r,setUser:n,setLoading:o}}function xt(){let[t,e]=ne(null),[r,n]=ne(!1);if(!R())return{project:null,loading:!1,setProject:()=>{},setLoading:()=>{},fetchProject:async()=>({data:null,error:{message:"Browser not available"}})};if(_()&&!window?.FramerAuth){let l=y=>e(y),m=y=>n(y);return{project:t,loading:r,setProject:l,setLoading:m,fetchProject:async()=>{m(!0);let y=await Ve();return y.data&&l(y.data),m(!1),y}}}let a=window.FramerAuth,s=S(a.data.project),c=S(a.state.projectLoading),i=l=>a.data.project.set(l),u=l=>a.state.projectLoading.set(l);return{project:s,loading:c,setProject:i,setLoading:u,fetchProject:async()=>{u(!0);let l=await a.api.fetchProject();return l.data&&i(l.data),u(!1),l}}}function C(t){if(!R()||_()||!window?.FramerAuth)return{bookmarks:null,loading:!1,createBookmark:a=>{},deleteBookmark:a=>{},setLoading:()=>{}};let e=window.FramerAuth;return{bookmarks:S(e.data.bookmarks,{keys:t}),createBookmark:a=>{let c={...e.data.bookmarks.get(),[a]:!0};e.data.bookmarks.set(c)},deleteBookmark:a=>{let c={...e.data.bookmarks.get()};delete c[a],e.data.bookmarks.set(c)}}}import{useEffect as V,useMemo as k,useRef as D}from"react";import{useRouter as De,RenderTarget as oe,inferInitialRouteFromPath as ze}from"framer";function ae(t){return t.toLowerCase()}function N(t,e="any"){return t==="all"||t==="any"?t:e}function U(t){return t!==null}function I(t,e,r="all"){if(!U(t))return!1;if(e.length===0)return t.tags.length>0;let n=t.tags.map(a=>ae(a.name)),o=e.map(ae);return r==="any"?o.some(a=>n.includes(a)):o.every(a=>n.includes(a))}import{jsx as g}from"react/jsx-runtime";typeof window<"u"&&window.FramerAuth&&console.log("FramerAuth SDK (React): 2.1.5");function se(t){let e=t;return typeof e?.displayName=="string"&&e.displayName.length>0&&typeof e?.defaultProps=="object"&&e.defaultProps!==null}function ie(t,e){return e?t.parentElement:t}function W(t){let e;if(typeof t=="string")e=t.split(",");else if(Array.isArray(t))e=t.filter(n=>typeof n=="string");else return null;let r=e.map(n=>n.trim()).filter(Boolean);return r.length>0?r:null}function z(t,e){return e!==void 0?typeof e=="string"||Array.isArray(e)||e===null?{tags:W(e),operator:"any"}:{tags:W(e.tags),operator:N(e.require)}:{tags:W(t?.tags),operator:N(t?.require)}}function Lt(t){return e=>{let{session:r}=E();return r?g(t,{...e}):null}}function Ct(t){return e=>{let{session:r}=E();return r?null:g(t,{...e})}}function It(t){return e=>{let{session:r}=E(),n=r?null:e?.variant;return g(t,{...e,variant:n})}}function Bt(t,e){let r=se(t);return n=>{let{user:o}=L(),a=D(null),{tags:s,operator:c}=k(()=>z(n,e),[n?.tags,n?.require,e]),i=k(()=>U(o)?s?I(o,s,c):o.tags.length>0:!1,[o,s,c]);return V(()=>{if(a.current){let f=ie(a.current,r);if(!f)return;i?f.style.display="":f.style.display="none"}},[a.current,i]),k(()=>i!==!0?g("div",{ref:a}):g(t,{ref:a,...n}),[n,i,void 0])}}function $t(t,e){let r=se(t);return n=>{let{user:o}=L(),a=D(null),{tags:s,operator:c}=k(()=>z(n,e),[n?.tags,n?.require,e]),i=k(()=>U(o)?s?I(o,s,c):o.tags.length>0:!1,[o,s,c]);return V(()=>{if(a.current){let f=ie(a.current,r);if(!f)return;i?f.style.display="none":f.style.display=""}},[a.current,i]),k(()=>i===!0?g("div",{ref:a}):g(t,{ref:a,...n}),[n,i,void 0])}}function Mt(t,e){return r=>{let{user:n}=L(),o=r?.variant,{tags:a,operator:s}=z(r,e);if(!a){let u=null;return(!U(n)||n.tags.length===0)&&(u=o),g(t,{...r,variant:u})}let i=I(n,a,s)?null:o;return g(t,{...r,variant:i})}}function qt(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),a=k(()=>n?Object.keys(n).some(c=>c.startsWith(`${e}:`)):!1,[n])?null:"Empty State";return g(t,{...r,variant:a})}}function Ht(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),o=D(null),a=k(()=>`${e}:${r?.slug}`,[r]),s=k(()=>Je()?!0:n?a in n:!1,[n?.[a],a]);return V(()=>{if(o.current){let i=o.current.parentElement;if(!i)return;s?i.style.display="":i.style.display="none"}},[o.current,s]),k(()=>s?g(t,{ref:o,...r}):g("div",{ref:o}),[r,s,void 0])}}function Nt(t,e="saved-for-later"){return r=>{let n=De(),{session:o}=E(),{bookmarks:a,createBookmark:s,deleteBookmark:c}=C([`${e}:${r?.slug}`]),i=k(()=>`${e}:${r?.slug}`,[r]),u=k(()=>a?i in a:!1,[a?.[i],i]),f=async m=>{try{if(u)c(i),window?.FramerAuth.auth.deleteBookmark({id:r?.slug,bookmark_type:e});else if(s(i),window?.FramerAuth.auth.createBookmark({id:r?.slug,bookmark_type:e}),r?.link){let[x,y]=r.link.split("#"),{routeId:F,pathVariables:B}=ze(n.routes,x);F&&n.navigate(F,y,B)}}catch(x){console.error(x)}},l=k(()=>u?r?.variant:void 0,[u,r?.variant]);return o?g(t,{...r,variant:l,onClick:f}):null}}function Wt(t){return e=>g(t,{...e,onClick:async n=>{window?.FramerAuth.auth.signInSocial({provider:"github",callbackURL:window.location.origin+"/account"})}})}function Vt(t,e){return r=>{let{session:n}=E();return n?g(t,{...r,onClick:async a=>{window?.FramerAuth.auth.signOut({redirectTo:e.redirectTo})}}):null}}function Je(){return oe.current()===oe.canvas}export{Wt as buttonSignInSocial,Vt as buttonSignOut,Ge as getSession,Je as isCanvas,at as resetPassword,nt as sendForgotPasswordEmail,Ze as sendOTP,ut as sendVerificationEmail,Lt as showIfSignedIn,Ct as showIfSignedOut,Bt as showIfWithTag,$t as showIfWithoutTag,Ye as signIn,Xe as signInOTP,ot as signInSocial,et as signOut,Qe as signUp,st as storeCheckout,it as storePortal,It as toggleVariant,Mt as toggleVariantIfWithTag,tt as updateProfile,rt as updateProfilePicture,C as useBookmarks,St as useIsInitializing,xt as useProject,E as useSession,L as useUser,qt as withBookmarks,Ht as withIsBookmarked,Nt as withToggleBookmark};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@framerauth/sdk",
3
3
  "license": "MIT",
4
- "version": "2.1.4",
4
+ "version": "2.1.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",