{
  "version": 3,
  "sources": ["ssg:https://cdn.thenty.io/beta/thenty-sdk.min.js", "ssg:https://framer.com/m/ThentyHelpers-I0Oh.js"],
  "sourcesContent": ["const logStyle=\"color:white;background-color:#FF4A29;font-family:system-ui;font-size:1.2rem;font-weight:bold\";class ThentySDK{constructor(){console.log(\"%cthenty SDK Beta Module\",logStyle),this.apiURL=\"https://api.thenty.io\"}fetchAuthorizationKey(){return(window?.location?new URL(window.location.origin):\"\").host+\".authorization\"}fetchAuthorization(){var e=localStorage.getItem(this.fetchAuthorizationKey());return e?JSON.parse(e):null}setAuthorization(e){var t=this.fetchAuthorizationKey();localStorage.setItem(t,JSON.stringify(e)),window.dispatchEvent(new CustomEvent(\"storage\",{detail:{key:t,newValue:e}}))}fetchMetadataKey(){return(window?.location?new URL(window.location.origin):\"\").host+\".metadata\"}fetchMetadata(){var e=localStorage.getItem(this.fetchMetadataKey());return e?JSON.parse(e):null}logout(e=\"/\"){localStorage.removeItem(this.fetchAuthorizationKey()),window.location.pathname=e}checkForProduct(e=[],t=null){let o=t,r=(o=o||this.fetchAuthorization(),!1);if(o?.hasOwnProperty(\"member\"))for(const a of(o.member.products??[]).map(e=>e.id))if(e.includes(a)){r=!0;break}return r}getRequestHeaders(e=!1){let t=!1;return e&&(t=this.fetchAuthorization()),{\"Content-Type\":\"application/json\",Accept:\"application/json\",\"x-secret-key\":window.variables.secretKey,\"x-site-key\":window.variables.siteKey,\"x-refresh-token\":window.variables.siteKey,...t&&{authorization:t?.authorization?.key,\"x-refresh-token\":t?.authorization.refresh}}}isGoogleRedirect(e=null){e=e??new URLSearchParams(window.location.search);return e?.has(\"code\")&&e?.has(\"state\")&&\"GOOGLE_LOGIN\"===e?.get(\"state\")}fetchGoogleCallback(e=null,t=null){const o=t??new URLSearchParams(window.location.search);fetch(this.apiURL+\"/oauth/members/callback/google\",{method:\"POST\",headers:this.getRequestHeaders(),body:JSON.stringify({code:o.get(\"code\"),...e&&{planIdOverride:e},...window?.Rewardful?.referral&&{rewardfulClientReferenceId:window.Rewardful.referral}})}).then(async e=>{var t=await e.json();if(200<e.status)throw new Error(t.errorMessage);return t}).then(e=>{o.delete(\"code\"),o.delete(\"state\");var t=new URL(window.location.href);t.search=o.toString(),history.replaceState(null,\"\",t.toString()),this.setAuthorization(e),setTimeout(()=>{window.open(e.redirect_url??\"#\",\"_self\")},500)})}refetchSiteMetadataTrigger=()=>{var e=new URL(window.location.origin);window.dispatchEvent(new CustomEvent(\"storage\",{detail:{key:e.host+\".reauth\",newValue:!0}}))};toggleBookmark(e,t){var o=this.fetchAuthorization();return this.fetchGeneric(\"/bookmarks\",\"POST\",{slug:t,collection:e},o?.authorization?.key).then(this.refetchSiteMetadataTrigger)}fetchGeneric(e,t=\"GET\",o=null,r=null){return fetch(\"\"+this.apiURL+e,{method:t,headers:this.getRequestHeaders(r),...o&&{body:JSON.stringify(o)}}).then(async e=>{var t=await e.json();if(200<e.status)throw new Error(t.errorMessage??errorTextLabel);return t})}}const thentyAuth=new ThentySDK;export{thentyAuth};", "import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,useMemo}from\"react\";import{thentyAuth}from\"https://cdn.thenty.io/beta/thenty-sdk.min.js\";export const useThenty=()=>{const metaKey=thentyAuth.fetchMetadataKey();const authKey=thentyAuth.fetchAuthorizationKey();const[authorization,updateAuthorization]=useState(thentyAuth.fetchAuthorization());const[siteMeta,updateSiteMeta]=useState(thentyAuth.fetchMetadata());useEffect(()=>{// Event listener callback\nconst handleStorageChange=event=>{var _event_detail,_event_detail1;var _event_detail_key;const eventKey=(_event_detail_key=(_event_detail=event.detail)===null||_event_detail===void 0?void 0:_event_detail.key)!==null&&_event_detail_key!==void 0?_event_detail_key:event.key;var _event_detail_newValue;const eventNewValue=(_event_detail_newValue=(_event_detail1=event.detail)===null||_event_detail1===void 0?void 0:_event_detail1.newValue)!==null&&_event_detail_newValue!==void 0?_event_detail_newValue:event.newValue;if(eventKey===authKey){updateAuthorization(JSON.parse(eventNewValue));}if(eventKey===metaKey){updateSiteMeta(JSON.parse(eventNewValue));}};window.addEventListener(\"storage\",handleStorageChange);return()=>{window.removeEventListener(\"storage\",handleStorageChange);};},[]);return{authorization,siteMeta};};// TODO - Add to documentation section\nexport const hasTier=(productIds=[])=>{const{authorization}=useThenty();const canAccess=useMemo(()=>{return thentyAuth.checkForProduct(productIds);},[authorization,productIds]);return canAccess;};// TODO - Add to documentation section\nexport const hasProduct=(productIds=[])=>{return hasTier(productIds);};export const fetchUserData=()=>{const{authorization}=useThenty();const userData=useMemo(()=>{if(!authorization)return null;if(authorization===null||authorization===void 0?void 0:authorization.hasOwnProperty(\"member\")){return authorization===null||authorization===void 0?void 0:authorization.member;}else{return null;}},[authorization]);const loggedIn=useMemo(()=>{return!!userData;},[userData]);return{loggedIn,userData};};export const useSSO=planIdOverride=>{const[firstRender,setFirstRender]=useState(true);const ssoQueryParamHandler=()=>{var _window,_window_location,_window1;const searchParams=((_window=window)===null||_window===void 0?void 0:_window.location)?new URLSearchParams((_window1=window)===null||_window1===void 0?void 0:(_window_location=_window1.location)===null||_window_location===void 0?void 0:_window_location.search):{};if(thentyAuth.isGoogleRedirect(searchParams)){thentyAuth.fetchGoogleCallback(planIdOverride,searchParams).catch(err=>console.error(err));}};useEffect(()=>{if(firstRender){ssoQueryParamHandler();setFirstRender(false);}},[firstRender]);};export default function ThentyHelpers(){return /*#__PURE__*/_jsx(_Fragment,{});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ThentyHelpers\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"fetchUserData\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"hasTier\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useThenty\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSSO\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"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,EAAE,CAAC,EAAKI,EAAW,iBAAiBF,CAAY,GAAGE,EAAW,oBAAoBV,EAAeQ,CAAY,EAAE,MAAMG,GAAK,QAAQ,MAAMA,CAAG,CAAC,CAAG,EAAEC,EAAU,IAAI,CAAIX,IAAaG,EAAqB,EAAEF,EAAe,EAAK,EAAG,EAAE,CAACD,CAAW,CAAC,CAAE",
  "names": ["logStyle", "ThentySDK", "window", "t", "o", "r", "a", "e", "thentyAuth", "useThenty", "metaKey", "thentyAuth", "authKey", "authorization", "updateAuthorization", "ye", "siteMeta", "updateSiteMeta", "ue", "handleStorageChange", "event", "_event_detail", "_event_detail1", "_event_detail_key", "eventKey", "_event_detail_newValue", "eventNewValue", "window", "hasTier", "productIds", "se", "fetchUserData", "authorization", "useThenty", "userData", "se", "useSSO", "planIdOverride", "firstRender", "setFirstRender", "ye", "ssoQueryParamHandler", "_window", "_window_location", "_window1", "searchParams", "window", "thentyAuth", "err", "ue"]
}
